From: Noel Power Date: Wed, 10 Oct 2018 20:48:38 +0000 (+0100) Subject: s4/dsdb/tests/python: PY3 port samba4.ldap.secdesc X-Git-Tag: tdb-1.3.17~769 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6ea052c8cbb5981aa02158745c361d0d33880dc;p=thirdparty%2Fsamba.git s4/dsdb/tests/python: PY3 port samba4.ldap.secdesc User str/bytes as needed for various asserts Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/tests/python/sec_descriptor.py b/source4/dsdb/tests/python/sec_descriptor.py index 80356007fc9..7a033bacc19 100755 --- a/source4/dsdb/tests/python/sec_descriptor.py +++ b/source4/dsdb/tests/python/sec_descriptor.py @@ -342,7 +342,7 @@ class OwnerGroupDescriptorTests(DescriptorTests): if groups != []: # User is member of at least one additional group res = self.ldb_admin.search(user_dn, attrs=["memberOf"]) - res = [x.upper() for x in sorted(list(res[0]["memberOf"]))] + res = [str(x).upper() for x in sorted(list(res[0]["memberOf"]))] expected = [] for x in groups: expected.append(self.get_users_domain_dn(x)) @@ -1986,7 +1986,7 @@ class RightsAttributesTests(DescriptorTests): attrs=["sDRightsEffective"]) # user whould have no rights at all self.assertEquals(len(res), 1) - self.assertEquals(res[0]["sDRightsEffective"][0], "0") + self.assertEquals(str(res[0]["sDRightsEffective"][0]), "0") # give the user Write DACL and see what happens mod = "(A;CI;WD;;;%s)" % str(user_sid) self.sd_utils.dacl_add_ace(object_dn, mod) @@ -1994,7 +1994,7 @@ class RightsAttributesTests(DescriptorTests): attrs=["sDRightsEffective"]) # user whould have DACL_SECURITY_INFORMATION self.assertEquals(len(res), 1) - self.assertEquals(res[0]["sDRightsEffective"][0], ("%d") % SECINFO_DACL) + self.assertEquals(str(res[0]["sDRightsEffective"][0]), ("%d") % SECINFO_DACL) # give the user Write Owners and see what happens mod = "(A;CI;WO;;;%s)" % str(user_sid) self.sd_utils.dacl_add_ace(object_dn, mod) @@ -2002,14 +2002,14 @@ class RightsAttributesTests(DescriptorTests): attrs=["sDRightsEffective"]) # user whould have DACL_SECURITY_INFORMATION, OWNER_SECURITY_INFORMATION, GROUP_SECURITY_INFORMATION self.assertEquals(len(res), 1) - self.assertEquals(res[0]["sDRightsEffective"][0], ("%d") % (SECINFO_DACL | SECINFO_GROUP | SECINFO_OWNER)) + self.assertEquals(str(res[0]["sDRightsEffective"][0]), ("%d") % (SECINFO_DACL | SECINFO_GROUP | SECINFO_OWNER)) # no way to grant security privilege bu adding ACE's so we use a memeber of Domain Admins _ldb = self.get_ldb_connection("testuser_attr2", "samba123@") res = _ldb.search(base=object_dn, expression="", scope=SCOPE_BASE, attrs=["sDRightsEffective"]) # user whould have DACL_SECURITY_INFORMATION, OWNER_SECURITY_INFORMATION, GROUP_SECURITY_INFORMATION self.assertEquals(len(res), 1) - self.assertEquals(res[0]["sDRightsEffective"][0], + self.assertEquals(str(res[0]["sDRightsEffective"][0]), ("%d") % (SECINFO_DACL | SECINFO_GROUP | SECINFO_OWNER | SECINFO_SACL)) def test_allowedChildClassesEffective(self): @@ -2034,7 +2034,7 @@ class RightsAttributesTests(DescriptorTests): # allowedChildClassesEffective should only have one value, user self.assertEquals(len(res), 1) self.assertEquals(len(res[0]["allowedChildClassesEffective"]), 1) - self.assertEquals(res[0]["allowedChildClassesEffective"][0], "user") + self.assertEquals(str(res[0]["allowedChildClassesEffective"][0]), "user") def test_allowedAttributesEffective(self): object_dn = "OU=test_domain_ou1," + self.base_dn @@ -2061,8 +2061,8 @@ class RightsAttributesTests(DescriptorTests): # value should only contain user and managedBy self.assertEquals(len(res), 1) self.assertEquals(len(res[0]["allowedAttributesEffective"]), 2) - self.assertTrue("displayName" in res[0]["allowedAttributesEffective"]) - self.assertTrue("managedBy" in res[0]["allowedAttributesEffective"]) + self.assertTrue(b"displayName" in res[0]["allowedAttributesEffective"]) + self.assertTrue(b"managedBy" in res[0]["allowedAttributesEffective"]) class SdAutoInheritTests(DescriptorTests):