ldap: test for empty attributes list
authorAaron Haslett <aaronhaslett@catalyst.net.nz>
Wed, 20 Mar 2019 06:17:07 +0000 (19:17 +1300)
committerGarming Sam <garming@samba.org>
Mon, 6 May 2019 04:23:51 +0000 (04:23 +0000)
Test for LDAP request with an empty attribute list.  LDB responds with
no attributes, but LDAP responds with all attributes.  Fix is attached
to the bug below but we can't push it upstream until we've found all
instances of incorrect empty attribute list usage in Samba.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13852

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/knownfail.d/ldap
source4/dsdb/tests/python/ldap.py

index 5bb01bc38bfbffe567f73df4293a633bfe023a40..0331d3687d41a6e27f52505aca16d3edf1da7305 100644 (file)
@@ -1,2 +1,3 @@
 # the attributes too long test returns the wrong error
-^samba4.ldap.python.+test_attribute_ranges_too_long
\ No newline at end of file
+^samba4.ldap.python.+test_attribute_ranges_too_long
+samba4.ldap.python\(ad_dc_default\).*__main__.BasicTests.test_ldapSearchNoAttributes
index b46d3a1a4b7f77f4820627972cf58b556ae578c0..9b43daa5891516811f0d1a85b6e08daba0d1f3d8 100755 (executable)
@@ -3175,6 +3175,23 @@ nTSecurityDescriptor:: """ + desc_base64
             self.assertTrue(len(res[0]["msTSExpireDate"]) == 1)
             self.assertEquals(str(res[0]["msTSExpireDate"][0]), v_get)
 
+    def test_ldapSearchNoAttributes(self):
+        """Testing ldap search with no attributes"""
+
+        user_name = "testemptyattributesuser"
+        user_dn = "CN=%s,%s" % (user_name, self.base_dn)
+        delete_force(self.ldb, user_dn)
+
+        self.ldb.add({"dn": user_dn,
+                      "objectClass": "user",
+                      "sAMAccountName": user_name})
+
+        res = self.ldb.search(user_dn, scope=SCOPE_BASE, attrs=[])
+        delete_force(self.ldb, user_dn)
+
+        self.assertEqual(len(res), 1)
+        self.assertEqual(len(res[0]), 0)
+
 
 class BaseDnTests(samba.tests.TestCase):