Blame SOURCES/0024-Issue-4480-Unexpected-info-returned-to-ldap-request-.patch

be9751
From 61d82ef842e0e4e013937bf05d7f640be2d2fc09 Mon Sep 17 00:00:00 2001
be9751
From: tbordaz <tbordaz@redhat.com>
be9751
Date: Wed, 16 Dec 2020 16:30:28 +0100
be9751
Subject: [PATCH 5/6] Issue 4480 - Unexpected info returned to ldap request
be9751
 (#4491)
be9751
be9751
Bug description:
be9751
	If the bind entry does not exist, the bind result info
be9751
        reports that 'No such entry'. It should not give any
be9751
        information if the target entry exists or not
be9751
be9751
Fix description:
be9751
	Does not return any additional information during a bind
be9751
be9751
relates: https://github.com/389ds/389-ds-base/issues/4480
be9751
be9751
Reviewed by: William Brown, Viktor Ashirov, Mark Reynolds (thank you all)
be9751
be9751
Platforms tested:  F31
be9751
---
be9751
 dirsrvtests/tests/suites/basic/basic_test.py | 112 +++++++++++++++++++
be9751
 1 file changed, 112 insertions(+)
be9751
be9751
diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py
be9751
index 1ae82dcdd..02b73ee85 100644
be9751
--- a/dirsrvtests/tests/suites/basic/basic_test.py
be9751
+++ b/dirsrvtests/tests/suites/basic/basic_test.py
be9751
@@ -1400,6 +1400,118 @@ def test_dscreate_multiple_dashes_name(dscreate_long_instance):
be9751
     assert not dscreate_long_instance.exists()
be9751
 
be9751
 
be9751
+@pytest.fixture(scope="module", params=('c=uk', 'cn=test_user', 'dc=example,dc=com', 'o=south', 'ou=sales', 'wrong=some_value'))
be9751
+def dscreate_test_rdn_value(request):
be9751
+    template_file = "/tmp/dssetup.inf"
be9751
+    template_text = f"""[general]
be9751
+config_version = 2
be9751
+# This invalid hostname ...
be9751
+full_machine_name = localhost.localdomain
be9751
+# Means we absolutely require this.
be9751
+strict_host_checking = False
be9751
+# In tests, we can be run in containers, NEVER trust
be9751
+# that systemd is there, or functional in any capacity
be9751
+systemd = False
be9751
+
be9751
+[slapd]
be9751
+instance_name = test_different_rdn
be9751
+root_dn = cn=directory manager
be9751
+root_password = someLongPassword_123
be9751
+# We do not have access to high ports in containers,
be9751
+# so default to something higher.
be9751
+port = 38999
be9751
+secure_port = 63699
be9751
+
be9751
+[backend-userroot]
be9751
+create_suffix_entry = True
be9751
+suffix = {request.param}
be9751
+"""
be9751
+
be9751
+    with open(template_file, "w") as template_fd:
be9751
+        template_fd.write(template_text)
be9751
+
be9751
+    # Unset PYTHONPATH to avoid mixing old CLI tools and new lib389
be9751
+    tmp_env = os.environ
be9751
+    if "PYTHONPATH" in tmp_env:
be9751
+        del tmp_env["PYTHONPATH"]
be9751
+
be9751
+    def fin():
be9751
+        os.remove(template_file)
be9751
+        if request.param != "wrong=some_value":
be9751
+            try:
be9751
+                subprocess.check_call(['dsctl', 'test_different_rdn', 'remove', '--do-it'])
be9751
+            except subprocess.CalledProcessError as e:
be9751
+                log.fatal(f"Failed to remove test instance  Error ({e.returncode}) {e.output}")
be9751
+        else:
be9751
+            log.info("Wrong RDN is passed, instance not created")
be9751
+    request.addfinalizer(fin)
be9751
+    return template_file, tmp_env, request.param,
be9751
+
be9751
+
be9751
+@pytest.mark.skipif(not get_user_is_root() or ds_is_older('1.4.0.0'),
be9751
+                    reason="This test is only required with new admin cli, and requires root.")
be9751
+@pytest.mark.bz1807419
be9751
+@pytest.mark.ds50928
be9751
+def test_dscreate_with_different_rdn(dscreate_test_rdn_value):
be9751
+    """Test that dscreate works with different RDN attributes as suffix
be9751
+
be9751
+    :id: 77ed6300-6a2f-4e79-a862-1f1105f1e3ef
be9751
+    :parametrized: yes
be9751
+    :setup: None
be9751
+    :steps:
be9751
+        1. Create template file for dscreate with different RDN attributes as suffix
be9751
+        2. Create instance using template file
be9751
+        3. Create instance with 'wrong=some_value' as suffix's RDN attribute
be9751
+    :expectedresults:
be9751
+        1. Should succeeds
be9751
+        2. Should succeeds
be9751
+        3. Should fail
be9751
+    """
be9751
+    try:
be9751
+        subprocess.check_call([
be9751
+            'dscreate',
be9751
+            'from-file',
be9751
+            dscreate_test_rdn_value[0]
be9751
+        ], env=dscreate_test_rdn_value[1])
be9751
+    except subprocess.CalledProcessError as e:
be9751
+        log.fatal(f"dscreate failed!  Error ({e.returncode}) {e.output}")
be9751
+        if  dscreate_test_rdn_value[2] != "wrong=some_value":
be9751
+            assert False
be9751
+        else:
be9751
+            assert True
be9751
+
be9751
+def test_bind_invalid_entry(topology_st):
be9751
+    """Test the failing bind does not return information about the entry
be9751
+
be9751
+    :id: 5cd9b083-eea6-426b-84ca-83c26fc49a6f
be9751
+
be9751
+    :setup: Standalone instance
be9751
+
be9751
+    :steps:
be9751
+    1: bind as non existing entry
be9751
+    2: check that bind info does not report 'No such entry'
be9751
+
be9751
+    :expectedresults:
be9751
+    1: pass
be9751
+    2: pass
be9751
+    """
be9751
+
be9751
+    topology_st.standalone.restart()
be9751
+    INVALID_ENTRY="cn=foooo,%s" % DEFAULT_SUFFIX
be9751
+    try:
be9751
+        topology_st.standalone.simple_bind_s(INVALID_ENTRY, PASSWORD)
be9751
+    except ldap.LDAPError as e:
be9751
+        log.info('test_bind_invalid_entry: Failed to bind as %s (expected)' % INVALID_ENTRY)
be9751
+        log.info('exception description: ' + e.args[0]['desc'])
be9751
+        if 'info' in e.args[0]:
be9751
+            log.info('exception info: ' + e.args[0]['info'])
be9751
+        assert e.args[0]['desc'] == 'Invalid credentials'
be9751
+        assert 'info' not in e.args[0]
be9751
+        pass
be9751
+
be9751
+    log.info('test_bind_invalid_entry: PASSED')
be9751
+
be9751
+
be9751
 if __name__ == '__main__':
be9751
     # Run isolated
be9751
     # -s for DEBUG mode
be9751
-- 
be9751
2.26.2
be9751