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

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