s3/dsdb: convert print func to be py2/py3 compatible
authorNoel Power <noel.power@suse.com>
Fri, 9 Mar 2018 13:57:01 +0000 (13:57 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 23 Mar 2018 06:28:24 +0000 (07:28 +0100)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
25 files changed:
source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py
source4/dsdb/tests/python/acl.py
source4/dsdb/tests/python/ad_dc_medley_performance.py
source4/dsdb/tests/python/ad_dc_performance.py
source4/dsdb/tests/python/ad_dc_search_performance.py
source4/dsdb/tests/python/deletetest.py
source4/dsdb/tests/python/dirsync.py
source4/dsdb/tests/python/ldap.py
source4/dsdb/tests/python/ldap_schema.py
source4/dsdb/tests/python/linked_attributes.py
source4/dsdb/tests/python/notification.py
source4/dsdb/tests/python/password_lockout.py
source4/dsdb/tests/python/password_lockout_base.py
source4/dsdb/tests/python/passwords.py
source4/dsdb/tests/python/rodc.py
source4/dsdb/tests/python/rodc_rwdc.py
source4/dsdb/tests/python/sam.py
source4/dsdb/tests/python/sec_descriptor.py
source4/dsdb/tests/python/sites.py
source4/dsdb/tests/python/sort.py
source4/dsdb/tests/python/token_group.py
source4/dsdb/tests/python/tombstone_reanimation.py
source4/dsdb/tests/python/urgent_replication.py
source4/dsdb/tests/python/user_account_control.py
source4/dsdb/tests/python/vlv.py

index b1c4c2e2a33e60a33ea7d59a1ae4e3306a9f419e..dd2f839c63a09d7e2fbdd54a5f90cfd48213ca75 100755 (executable)
@@ -17,6 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import print_function
 """Tests the possibleInferiors generation in the schema_fsmo ldb module"""
 
 import optparse
@@ -222,20 +223,20 @@ def possible_inferiors_constructed(db, classinfo, c):
 
 def test_class(db, classinfo, oc):
     """test to see if one objectclass returns the correct possibleInferiors"""
-    print "test: objectClass.%s" % oc
+    print("test: objectClass.%s" % oc)
     poss1 = possible_inferiors_search(db, oc)
     poss2 = possible_inferiors_constructed(db, classinfo, oc)
     if poss1 != poss2:
-        print "failure: objectClass.%s [" % oc
-        print "Returned incorrect list for objectclass %s" % oc
-        print "search:      %s" % poss1
-        print "constructed: %s" % poss2
+        print("failure: objectClass.%s [" % oc)
+        print("Returned incorrect list for objectclass %s" % oc)
+        print("search:      %s" % poss1)
+        print("constructed: %s" % poss2)
         for i in range(0,min(len(poss1),len(poss2))):
-            print "%30s %30s" % (poss1[i], poss2[i])
-        print "]"
+            print("%30s %30s" % (poss1[i], poss2[i]))
+        print("]")
         sys.exit(1)
     else:
-        print "success: objectClass.%s" % oc
+        print("success: objectClass.%s" % oc)
 
 def get_object_classes(db):
     """return a list of all object classes"""
@@ -252,4 +253,4 @@ if objectclass is None:
 else:
     test_class(db,classinfo,objectclass)
 
-print "Lists match OK"
+print("Lists match OK")
index fe118988353b8fae08b504487cc1efc3a4503ba4..357e19b2ea9909dc853f95c35bf689e618bc5884 100755 (executable)
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 # This is unit with tests for LDAP access checks
 
+from __future__ import print_function
 import optparse
 import sys
 import base64
@@ -82,7 +83,7 @@ class AclTests(samba.tests.TestCase):
         self.creds_tmp.set_domain(creds.get_domain())
         self.creds_tmp.set_realm(creds.get_realm())
         self.creds_tmp.set_workstation(creds.get_workstation())
-        print "baseDN: %s" % self.base_dn
+        print("baseDN: %s" % self.base_dn)
 
     def get_user_dn(self, name):
         return "CN=%s,CN=Users,%s" % (name, self.base_dn)
@@ -307,7 +308,7 @@ class AclModifyTests(AclTests):
         """5 Modify one attribute if you have DS_WRITE_PROPERTY for it"""
         mod = "(OA;;WP;bf967953-0de6-11d0-a285-00aa003049e2;;%s)" % str(self.user_sid)
         # First test object -- User
-        print "Testing modify on User object"
+        print("Testing modify on User object")
         self.ldb_admin.newuser("test_modify_user1", self.user_pass)
         self.sd_utils.dacl_add_ace(self.get_user_dn("test_modify_user1"), mod)
         ldif = """
@@ -320,7 +321,7 @@ displayName: test_changed"""
                 expression="(distinguishedName=%s)" % self.get_user_dn("test_modify_user1"))
         self.assertEqual(res[0]["displayName"][0], "test_changed")
         # Second test object -- Group
-        print "Testing modify on Group object"
+        print("Testing modify on Group object")
         self.ldb_admin.newgroup("test_modify_group1",
                                 grouptype=samba.dsdb.GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP)
         self.sd_utils.dacl_add_ace("CN=test_modify_group1,CN=Users," + self.base_dn, mod)
@@ -333,7 +334,7 @@ displayName: test_changed"""
         res = self.ldb_admin.search(self.base_dn, expression="(distinguishedName=%s)" % str("CN=test_modify_group1,CN=Users," + self.base_dn))
         self.assertEqual(res[0]["displayName"][0], "test_changed")
         # Third test object -- Organizational Unit
-        print "Testing modify on OU object"
+        print("Testing modify on OU object")
         #delete_force(self.ldb_admin, "OU=test_modify_ou1," + self.base_dn)
         self.ldb_admin.create_ou("OU=test_modify_ou1," + self.base_dn)
         self.sd_utils.dacl_add_ace("OU=test_modify_ou1," + self.base_dn, mod)
@@ -350,7 +351,7 @@ displayName: test_changed"""
         """6 Modify two attributes as you have DS_WRITE_PROPERTY granted only for one of them"""
         mod = "(OA;;WP;bf967953-0de6-11d0-a285-00aa003049e2;;%s)" % str(self.user_sid)
         # First test object -- User
-        print "Testing modify on User object"
+        print("Testing modify on User object")
         #delete_force(self.ldb_admin, self.get_user_dn("test_modify_user1"))
         self.ldb_admin.newuser("test_modify_user1", self.user_pass)
         self.sd_utils.dacl_add_ace(self.get_user_dn("test_modify_user1"), mod)
@@ -380,7 +381,7 @@ url: www.samba.org"""
             # This 'modify' operation should always throw ERR_INSUFFICIENT_ACCESS_RIGHTS
             self.fail()
         # Second test object -- Group
-        print "Testing modify on Group object"
+        print("Testing modify on Group object")
         self.ldb_admin.newgroup("test_modify_group1",
                                 grouptype=samba.dsdb.GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP)
         self.sd_utils.dacl_add_ace("CN=test_modify_group1,CN=Users," + self.base_dn, mod)
@@ -425,7 +426,7 @@ displayName: test_changed"""
             # This 'modify' operation should always throw ERR_INSUFFICIENT_ACCESS_RIGHTS
             self.fail()
         # Second test object -- Organizational Unit
-        print "Testing modify on OU object"
+        print("Testing modify on OU object")
         self.ldb_admin.create_ou("OU=test_modify_ou1," + self.base_dn)
         self.sd_utils.dacl_add_ace("OU=test_modify_ou1," + self.base_dn, mod)
         ldif = """
@@ -456,7 +457,7 @@ url: www.samba.org"""
     def test_modify_u3(self):
         """7 Modify one attribute as you have no what so ever rights granted"""
         # First test object -- User
-        print "Testing modify on User object"
+        print("Testing modify on User object")
         self.ldb_admin.newuser("test_modify_user1", self.user_pass)
         # Modify on attribute you do not have rights for granted
         ldif = """
@@ -474,7 +475,7 @@ url: www.samba.org"""
             self.fail()
 
         # Second test object -- Group
-        print "Testing modify on Group object"
+        print("Testing modify on Group object")
         self.ldb_admin.newgroup("test_modify_group1",
                                 grouptype=samba.dsdb.GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP)
         # Modify on attribute you do not have rights for granted
@@ -493,7 +494,7 @@ url: www.samba.org"""
             self.fail()
 
         # Second test object -- Organizational Unit
-        print "Testing modify on OU object"
+        print("Testing modify on OU object")
         #delete_force(self.ldb_admin, "OU=test_modify_ou1," + self.base_dn)
         self.ldb_admin.create_ou("OU=test_modify_ou1," + self.base_dn)
         # Modify on attribute you do not have rights for granted
@@ -871,7 +872,7 @@ class AclSearchTests(AclTests):
         self.ldb_admin.create_ou("OU=ou5,OU=ou3,OU=ou2,OU=ou1," + self.base_dn, sd=tmp_desc)
         self.ldb_admin.create_ou("OU=ou6,OU=ou4,OU=ou2,OU=ou1," + self.base_dn, sd=tmp_desc)
 
-        print "Testing correct behavior on nonaccessible search base"
+        print("Testing correct behavior on nonaccessible search base")
         try:
              self.ldb_user3.search("OU=ou3,OU=ou2,OU=ou1," + self.base_dn, expression="(objectClass=*)",
                                    scope=SCOPE_BASE)
@@ -1870,7 +1871,7 @@ class AclSPNTests(AclTests):
         del self.ldb_user1
 
     def replace_spn(self, _ldb, dn, spn):
-        print "Setting spn %s on %s" % (spn, dn)
+        print("Setting spn %s on %s" % (spn, dn))
         res = self.ldb_admin.search(dn, expression="(objectClass=*)",
                                     scope=SCOPE_BASE, attrs=["servicePrincipalName"])
         if "servicePrincipalName" in res[0].keys():
index 3e8f87ce186f55385d75860cc8fa44a990e4c23e..f49563c7f6cbeb6f232e7f72af241141f148e8c8 100644 (file)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
+from __future__ import print_function
+
 import optparse
 import sys
 sys.path.insert(0, 'bin/python')
@@ -191,8 +193,9 @@ class UserTests(samba.tests.TestCase):
                                 expression=expression,
                                 scope=SCOPE_SUBTREE,
                                 attrs=['cn'])
-            print >> sys.stderr, '%d %s took %s' % (i, expression,
-                                                    time.time() - t)
+            print('%d %s took %s' % (i, expression,
+                                     time.time() - t),
+                  file=sys.stderr)
 
     def _test_indexed_search(self):
         expressions = ['(objectclass=group)',
@@ -205,8 +208,9 @@ class UserTests(samba.tests.TestCase):
                                 expression=expression,
                                 scope=SCOPE_SUBTREE,
                                 attrs=['cn'])
-            print >> sys.stderr, '%d runs %s took %s' % (i, expression,
-                                                         time.time() - t)
+            print('%d runs %s took %s' % (i, expression,
+                                          time.time() - t),
+                  file=sys.stderr)
 
     def _test_base_search(self):
         for dn in [self.base_dn, self.ou, self.ou_users,
@@ -238,8 +242,9 @@ class UserTests(samba.tests.TestCase):
                                 expression=expression,
                                 scope=SCOPE_SUBTREE,
                                 attrs=['cn'])
-            print >> sys.stderr, '%d runs %s took %s' % (i, expression,
-                                                         time.time() - t)
+            print('%d runs %s took %s' % (i, expression,
+                                          time.time() - t),
+                  file=sys.stderr)
 
     def _test_complex_search(self, n=100):
         classes = ['samaccountname', 'objectCategory', 'dn', 'member']
@@ -365,8 +370,8 @@ class UserTests(samba.tests.TestCase):
             try:
                 self.ldb.modify(m)
             except LdbError as e:
-                print e
-                print m
+                print(e)
+                print(m)
 
     def _test_remove_some_links(self, n=(LINK_BATCH_SIZE // 2)):
         victims = random.sample(list(self.state.active_links), n)
index 09af52f2fd7a0e1aac2311e4446b3016defbd14e..c7269220406d931cdae0a36cdf91ba8f99e01f21 100644 (file)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
+from __future__ import print_function
+
 import optparse
 import sys
 sys.path.insert(0, 'bin/python')
@@ -160,8 +162,8 @@ class UserTests(samba.tests.TestCase):
                                 expression=expression,
                                 scope=SCOPE_SUBTREE,
                                 attrs=['cn'])
-            print >> sys.stderr, '%d %s took %s' % (i, expression,
-                                                    time.time() - t)
+            print('%d %s took %s' % (i, expression,
+                                                    time.time() - t), file=sys.stderr)
 
     def _test_indexed_search(self):
         expressions = ['(objectclass=group)',
@@ -174,8 +176,8 @@ class UserTests(samba.tests.TestCase):
                                 expression=expression,
                                 scope=SCOPE_SUBTREE,
                                 attrs=['cn'])
-            print >> sys.stderr, '%d runs %s took %s' % (i, expression,
-                                                         time.time() - t)
+            print('%d runs %s took %s' % (i, expression,
+                                                         time.time() - t), file=sys.stderr)
 
     def _test_add_many_users(self, n=BATCH_SIZE):
         s = self.state.next_user_id
index 151fb69b666c612fcce6d34ba565ff719dca9309..2b8c52edf76eba00abcb4cc307e0e5a2a20a5f4e 100644 (file)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
+from __future__ import print_function
+
 import optparse
 import sys
 sys.path.insert(0, 'bin/python')
@@ -153,8 +155,9 @@ class UserTests(samba.tests.TestCase):
                                 expression=expression,
                                 scope=SCOPE_SUBTREE,
                                 attrs=['cn'])
-            print >> sys.stderr, '%d %s took %s' % (i, expression,
-                                                    time.time() - t)
+            print('%d %s took %s' % (i, expression,
+                                     time.time() - t),
+                  file=sys.stderr)
 
     def _test_indexed_search(self):
         expressions = ['(objectclass=group)',
@@ -167,8 +170,9 @@ class UserTests(samba.tests.TestCase):
                                 expression=expression,
                                 scope=SCOPE_SUBTREE,
                                 attrs=['cn'])
-            print >> sys.stderr, '%d runs %s took %s' % (i, expression,
-                                                         time.time() - t)
+            print('%d runs %s took %s' % (i, expression,
+                                          time.time() - t),
+                  file=sys.stderr)
 
     def _test_complex_search(self):
         classes = ['samaccountname', 'objectCategory', 'dn', 'member']
@@ -196,7 +200,7 @@ class UserTests(samba.tests.TestCase):
                                   '(', n2, c2, o2, v2,
                                   '))' if n2 else ')',
                                   ')'])
-            print expression
+            print(expression)
             self.ldb.search(self.ou,
                             expression=expression,
                             scope=SCOPE_SUBTREE,
@@ -219,8 +223,9 @@ class UserTests(samba.tests.TestCase):
                                 expression=expression,
                                 scope=SCOPE_SUBTREE,
                                 attrs=['cn'])
-            print >> sys.stderr, '%d runs %s took %s' % (i, expression,
-                                                         time.time() - t)
+            print('%d runs %s took %s' % (i, expression,
+                                          time.time() - t),
+                  file=sys.stderr)
 
     def _test_add_many_users(self, n=BATCH_SIZE):
         s = self.state.next_user_id
index 88695024d5d8e3c6552643e2310e3386b4587eb8..7e8634efe484dc23a5d86e24f7eb34a2a2ca6da4 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function
 import optparse
 import sys
 import os
@@ -52,7 +53,7 @@ class BaseDeleteTests(samba.tests.TestCase):
         self.configuration_dn = self.ldb.get_config_basedn().get_linearized()
 
     def search_guid(self, guid):
-        print "SEARCH by GUID %s" % self.GUID_string(guid)
+        print("SEARCH by GUID %s" % self.GUID_string(guid))
 
         res = self.ldb.search(base="<GUID=%s>" % self.GUID_string(guid),
                          scope=SCOPE_BASE, controls=["show_deleted:1"])
@@ -60,7 +61,7 @@ class BaseDeleteTests(samba.tests.TestCase):
         return res[0]
 
     def search_dn(self,dn):
-        print "SEARCH by DN %s" % dn
+        print("SEARCH by DN %s" % dn)
 
         res = self.ldb.search(expression="(objectClass=*)",
                          base=dn,
@@ -76,14 +77,14 @@ class BasicDeleteTests(BaseDeleteTests):
         super(BasicDeleteTests, self).setUp()
 
     def del_attr_values(self, delObj):
-        print "Checking attributes for %s" % delObj["dn"]
+        print("Checking attributes for %s" % delObj["dn"])
 
         self.assertEquals(delObj["isDeleted"][0],"TRUE")
         self.assertTrue(not("objectCategory" in delObj))
         self.assertTrue(not("sAMAccountType" in delObj))
 
     def preserved_attributes_list(self, liveObj, delObj):
-        print "Checking for preserved attributes list"
+        print("Checking for preserved attributes list")
 
         preserved_list = ["nTSecurityDescriptor", "attributeID", "attributeSyntax", "dNReferenceUpdate", "dNSHostName",
         "flatName", "governsID", "groupType", "instanceType", "lDAPDisplayName", "legacyExchangeDN",
@@ -98,7 +99,7 @@ class BasicDeleteTests(BaseDeleteTests):
                 self.assertTrue(a in delObj)
 
     def check_rdn(self, liveObj, delObj, rdnName):
-        print "Checking for correct rDN"
+        print("Checking for correct rDN")
         rdn=liveObj[rdnName][0]
         rdn2=delObj[rdnName][0]
         name2=delObj["name"][0]
@@ -109,7 +110,7 @@ class BasicDeleteTests(BaseDeleteTests):
         self.assertEquals(name2, dn_rdn)
 
     def delete_deleted(self, ldb, dn):
-        print "Testing the deletion of the already deleted dn %s" % dn
+        print("Testing the deletion of the already deleted dn %s" % dn)
 
         try:
             ldb.delete(dn)
@@ -121,7 +122,7 @@ class BasicDeleteTests(BaseDeleteTests):
     def test_delete_protection(self):
         """Delete protection tests"""
 
-        print self.base_dn
+        print(self.base_dn)
 
         delete_force(self.ldb, "cn=entry1,cn=ldaptestcontainer," + self.base_dn)
         delete_force(self.ldb, "cn=entry2,cn=ldaptestcontainer," + self.base_dn)
@@ -268,7 +269,7 @@ class BasicDeleteTests(BaseDeleteTests):
     def test_all(self):
         """Basic delete tests"""
 
-        print self.base_dn
+        print(self.base_dn)
 
         # user current time in ms to make unique objects
         import time
index 2da776a5766c0ee0f7e463fb5150f8355ea67722..4b607ca52a5c493f153a18bd2c5fb5c2a1a38f7c 100755 (executable)
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
+from __future__ import print_function
 import optparse
 import sys
 sys.path.insert(0, "bin/python")
@@ -83,7 +84,7 @@ class DirsyncBaseTests(samba.tests.TestCase):
         self.configuration_dn = self.ldb_admin.get_config_basedn().get_linearized()
         self.sd_utils = sd_utils.SDUtils(self.ldb_admin)
         #used for anonymous login
-        print "baseDN: %s" % self.base_dn
+        print("baseDN: %s" % self.base_dn)
 
     def get_user_dn(self, name):
         return "CN=%s,CN=Users,%s" % (name, self.base_dn)
@@ -178,7 +179,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
                 expression="samaccountname=*",
                 controls=["dirsync:1:0:1"])
         except LdbError as l:
-            print l
+            print(l)
             self.assertTrue(str(l).find("LDAP_INSUFFICIENT_ACCESS_RIGHTS") != -1)
 
         try:
@@ -186,7 +187,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
                 expression="samaccountname=*",
                 controls=["dirsync:1:0:1"])
         except LdbError as l:
-            print l
+            print(l)
             self.assertTrue(str(l).find("LDAP_INSUFFICIENT_ACCESS_RIGHTS") != -1)
 
         try:
@@ -194,7 +195,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
                 expression="samaccountname=*",
                 controls=["dirsync:1:1:1"])
         except LdbError as l:
-            print l
+            print(l)
             self.assertTrue(str(l).find("LDAP_UNWILLING_TO_PERFORM") != -1)
 
         try:
@@ -202,7 +203,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
                 expression="samaccountname=*",
                 controls=["dirsync:1:0:1"])
         except LdbError as l:
-            print l
+            print(l)
             self.assertTrue(str(l).find("LDAP_INSUFFICIENT_ACCESS_RIGHTS") != -1)
 
         try:
@@ -210,7 +211,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
                 expression="samaccountname=*",
                 controls=["dirsync:1:0:1"])
         except LdbError as l:
-            print l
+            print(l)
             self.assertTrue(str(l).find("LDAP_INSUFFICIENT_ACCESS_RIGHTS") != -1)
 
         try:
@@ -218,7 +219,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
                 expression="samaccountname=*",
                 controls=["dirsync:1:1:1"])
         except LdbError as l:
-            print l
+            print(l)
             self.assertTrue(str(l).find("LDAP_UNWILLING_TO_PERFORM") != -1)
 
     def test_dirsync_attributes(self):
@@ -516,7 +517,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
 
         # Check that reasking the same question but with an updated cookie
         # didn't return any results.
-        print control1
+        print(control1)
         res = self.ldb_admin.search(self.base_dn,
                                     expression="(name=testgroup)",
                                     controls=[control1])
index db0b68c8405f800d21b588bbc4c82da7c9b0a59a..12e36ba8de367775a18df267dad7808aacf88967 100755 (executable)
@@ -17,6 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 import optparse
 import sys
 import time
@@ -2584,11 +2585,11 @@ member: cn=ldaptestuser2,cn=users,""" + self.base_dn + """
         res = ldb.search(self.base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs, controls=["extended_dn:1:1"])
         self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))")
 
-        print res[0]["member"]
+        print(res[0]["member"])
         memberUP = []
         for m in res[0]["member"]:
             memberUP.append(m.upper())
-        print ("<GUID=" + ldb.schema_format_value("objectGUID", ldaptestuser2_guid) + ">;<SID=" + ldb.schema_format_value("objectSid", ldaptestuser2_sid) + ">;CN=ldaptestuser2,CN=Users," + self.base_dn).upper()
+        print(("<GUID=" + ldb.schema_format_value("objectGUID", ldaptestuser2_guid) + ">;<SID=" + ldb.schema_format_value("objectSid", ldaptestuser2_sid) + ">;CN=ldaptestuser2,CN=Users," + self.base_dn).upper())
 
         self.assertTrue(("<GUID=" + ldb.schema_format_value("objectGUID", ldaptestuser2_guid) + ">;<SID=" + ldb.schema_format_value("objectSid", ldaptestuser2_sid) + ">;CN=ldaptestuser2,CN=Users," + self.base_dn).upper() in memberUP)
 
index fff47374722b6441e1378de9b0a6a2cb8d060585..a510f40358d35ce02a4ff4720eabbdd8ff0f313f 100755 (executable)
@@ -20,6 +20,7 @@
 
 
 
+from __future__ import print_function
 import optparse
 import sys
 import time
@@ -1615,7 +1616,7 @@ systemOnly: FALSE
                     #self.assertTrue("msDS-IntId" in ldb_msg, "msDS-IntId expected on: %s" % ldb_msg.dn)
                     if "msDS-IntId" not in ldb_msg:
                         count = count + 1
-                        print "%3d warning: msDS-IntId expected on: %-30s %s" % (count, ldb_msg["attributeID"], ldb_msg["cn"])
+                        print("%3d warning: msDS-IntId expected on: %-30s %s" % (count, ldb_msg["attributeID"], ldb_msg["cn"]))
             else:
                 self.assertTrue("msDS-IntId" not in ldb_msg)
 
index 96ea75dc95392fb4f3212ee0ec1e218373d2b42c..d40192badc7a427d37277376f7fc9fad2a726628 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # Originally based on ./sam.py
+from __future__ import print_function
 import optparse
 import sys
 import os
@@ -65,7 +66,7 @@ class LATests(samba.tests.TestCase):
             try:
                 self.samdb.delete(self.ou, ['tree_delete:1'])
             except ldb.LdbError as e:
-                print "tried deleting %s, got error %s" % (self.ou, e)
+                print("tried deleting %s, got error %s" % (self.ou, e))
         self.samdb.add({'objectclass': 'organizationalUnit',
                         'dn': self.ou})
 
@@ -145,9 +146,9 @@ class LATests(samba.tests.TestCase):
         results = sorted(results)
 
         if expected != results:
-            print msg
-            print "expected %s" % expected
-            print "received %s" % results
+            print(msg)
+            print("expected %s" % expected)
+            print("received %s" % results)
 
         self.assertEqual(results, expected)
 
@@ -208,7 +209,7 @@ class LATests(samba.tests.TestCase):
 
     def test_la_backlinks_reveal(self):
         if opts.no_reveal_internals:
-            print 'skipping because --no-reveal-internals'
+            print('skipping because --no-reveal-internals')
             return
         self._test_la_backlinks(True)
 
@@ -236,7 +237,7 @@ class LATests(samba.tests.TestCase):
 
     def test_la_backlinks_delete_group_reveal(self):
         if opts.no_reveal_internals:
-            print 'skipping because --no-reveal-internals'
+            print('skipping because --no-reveal-internals')
             return
         self._test_la_backlinks_delete_group(True)
 
@@ -350,7 +351,7 @@ class LATests(samba.tests.TestCase):
 
     def test_la_links_delete_link_reveal(self):
         if opts.no_reveal_internals:
-            print 'skipping because --no-reveal-internals'
+            print('skipping because --no-reveal-internals')
             return
         self._test_la_links_delete_link_reveal()
 
index 974aba5a0caceb1b86c0e50b91ce3957004744f3..a4456cb12c678101b0dc8967bdcd5b3d963bc5ad 100755 (executable)
@@ -16,6 +16,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 import optparse
 import sys
 import os
@@ -341,7 +342,7 @@ delete: otherLoginWorkstations
             except LdbError as e9:
                 (num, _) = e9.args
                 if num != ERR_UNWILLING_TO_PERFORM:
-                    print "va[%s]" % va
+                    print("va[%s]" % va)
                 self.assertEquals(num, ERR_UNWILLING_TO_PERFORM)
 
         try:
@@ -359,7 +360,7 @@ delete: otherLoginWorkstations
         except LdbError as e11:
             (num, _) = e11.args
             if num != ERR_UNWILLING_TO_PERFORM:
-                print "va[%s]" % va
+                print("va[%s]" % va)
             self.assertEquals(num, ERR_UNWILLING_TO_PERFORM)
 
 if not "://" in url:
index ee3932ccf00b8fc03ad3d5cc7d960ccd315ed105..1425b87ba8f905f3c2fa4a34b9c3f7d6b29ae52d 100755 (executable)
@@ -7,6 +7,7 @@
 # Copyright Stefan Metzmacher 2014
 #
 
+from __future__ import print_function
 import optparse
 import sys
 import base64
@@ -130,11 +131,11 @@ userAccountControl: %d
         if use_kerberos == MUST_USE_KERBEROS:
             logoncount_relation = 'greater'
             lastlogon_relation = 'greater'
-            print "Performs a password cleartext change operation on 'userPassword' using Kerberos"
+            print("Performs a password cleartext change operation on 'userPassword' using Kerberos")
         else:
             logoncount_relation = 'equal'
             lastlogon_relation = 'equal'
-            print "Performs a password cleartext change operation on 'userPassword' using NTLMSSP"
+            print("Performs a password cleartext change operation on 'userPassword' using NTLMSSP")
 
         if initial_lastlogon_relation is not None:
             lastlogon_relation = initial_lastlogon_relation
@@ -232,7 +233,7 @@ userPassword: thatsAcomplPASS2
                                   msDSUserAccountControlComputed=0)
         badPasswordTime = int(res[0]["badPasswordTime"][0])
 
-        print "two failed password change"
+        print("two failed password change")
 
         # Wrong old password
         try:
@@ -580,7 +581,7 @@ userPassword: thatsAcomplPASS2XYZ
 
     def _test_unicodePwd_lockout_with_clear_change(self, creds, other_ldb,
                                                    initial_logoncount_relation=None):
-        print "Performs a password cleartext change operation on 'unicodePwd'"
+        print("Performs a password cleartext change operation on 'unicodePwd'")
         username = creds.get_username()
         userpass = creds.get_password()
         userdn = "cn=%s,cn=users,%s" % (username, self.base_dn)
@@ -702,7 +703,7 @@ unicodePwd:: """ + base64.b64encode(new_utf16) + """
                                     dsdb.UF_NORMAL_ACCOUNT,
                                   msDSUserAccountControlComputed=0)
 
-        print "two failed password change"
+        print("two failed password change")
 
         # Wrong old password
         try:
index 92448649695469201438558c0e6cd54f465c53f6..164b86f38a64bb9e65a8c46150e63f850f170291 100644 (file)
@@ -1,3 +1,4 @@
+from __future__ import print_function
 import samba
 
 from samba.auth import system_session
@@ -54,7 +55,7 @@ class BasePasswordTestCase(samba.tests.TestCase):
                         (name, res[0][name], res[0].dn))
 
 
-        print  "%s = '%s'" % (name, res[0][name][0])
+        print("%s = '%s'" % (name, res[0][name][0]))
 
         if mode == "present":
             return
@@ -107,9 +108,9 @@ class BasePasswordTestCase(samba.tests.TestCase):
                        effective_bad_password_count=None,
                        msg=None,
                        badPwdCountOnly=False):
-        print '-=' * 36
+        print('-=' * 36)
         if msg is not None:
-            print  "\033[01;32m %s \033[00m\n" % msg
+            print("\033[01;32m %s \033[00m\n" % msg)
         attrs = [
            "objectSid",
            "badPwdCount",
@@ -385,11 +386,11 @@ lockoutThreshold: """ + str(lockoutThreshold) + """
         if use_kerberos == MUST_USE_KERBEROS:
             logoncount_relation = 'greater'
             lastlogon_relation = 'greater'
-            print "Performs a lockout attempt against LDAP using Kerberos"
+            print("Performs a lockout attempt against LDAP using Kerberos")
         else:
             logoncount_relation = 'equal'
             lastlogon_relation = 'equal'
-            print "Performs a lockout attempt against LDAP using NTLM"
+            print("Performs a lockout attempt against LDAP using NTLM")
 
         # Change password on a connection as another user
         res = self._check_account(userdn,
@@ -406,8 +407,8 @@ lockoutThreshold: """ + str(lockoutThreshold) + """
         lastLogon = int(res[0]["lastLogon"][0])
         firstLogon = lastLogon
         lastLogonTimestamp = int(res[0]["lastLogonTimestamp"][0])
-        print firstLogon
-        print lastLogonTimestamp
+        print(firstLogon)
+        print(lastLogonTimestamp)
 
 
         self.assertGreater(lastLogon, badPasswordTime)
@@ -496,7 +497,7 @@ lockoutThreshold: """ + str(lockoutThreshold) + """
                                   msDSUserAccountControlComputed=0)
         badPasswordTime = int(res[0]["badPasswordTime"][0])
 
-        print "two failed password change"
+        print("two failed password change")
 
         # The wrong password
         creds_lockout.set_password("thatsAcomplPASS1x")
@@ -584,7 +585,7 @@ lockoutThreshold: """ + str(lockoutThreshold) + """
 
         # wait for the lockout to end
         time.sleep(self.account_lockout_duration + 1)
-        print self.account_lockout_duration + 1
+        print(self.account_lockout_duration + 1)
 
         res = self._check_account(userdn,
                                   badPwdCount=3, effective_bad_password_count=0,
@@ -726,11 +727,11 @@ lockoutThreshold: """ + str(lockoutThreshold) + """
 
         use_kerberos = creds.get_kerberos_state()
         if use_kerberos == MUST_USE_KERBEROS:
-            print "Testing multiple logon with Kerberos"
+            print("Testing multiple logon with Kerberos")
             logoncount_relation = 'greater'
             lastlogon_relation = 'greater'
         else:
-            print "Testing multiple logon with NTLM"
+            print("Testing multiple logon with NTLM")
             logoncount_relation = 'equal'
             lastlogon_relation = 'equal'
 
@@ -750,7 +751,7 @@ lockoutThreshold: """ + str(lockoutThreshold) + """
         lastLogon = int(res[0]["lastLogon"][0])
         lastLogonTimestamp = int(res[0]["lastLogonTimestamp"][0])
         firstLogon = lastLogon
-        print "last logon is %d" % lastLogon
+        print("last logon is %d" % lastLogon)
         self.assertGreater(lastLogon, badPasswordTime)
         self.assertGreaterEqual(lastLogon, lastLogonTimestamp)
 
index 40b63b58e94d04e0d2ad6615bdbea3216a3c7e1a..c8c2b762a644bd99a8a636a5619bddbbb4b97e0a 100755 (executable)
@@ -8,6 +8,7 @@
 # secured enough (SASL with a minimum of 128 Bit encryption) - consider
 # MS-ADTS 3.1.1.3.1.5
 
+from __future__ import print_function
 import optparse
 import sys
 import base64
@@ -716,7 +717,7 @@ userPassword: thatsAcomplPASS4
              "userPassword": ["thatsAcomplPASS1", "thatsAcomplPASS1"] })
 
     def test_empty_passwords(self):
-        print "Performs some empty passwords testing"
+        print("Performs some empty passwords testing")
 
         try:
             self.ldb.add({
@@ -885,7 +886,7 @@ userPassword: thatsAcomplPASS4
                             num == ERR_NO_SUCH_ATTRIBUTE) # for Windows
 
     def test_plain_userPassword(self):
-        print "Performs testing about the standard 'userPassword' behaviour"
+        print("Performs testing about the standard 'userPassword' behaviour")
 
         # Delete the "dSHeuristics"
         self.ldb.set_dsheuristics(None)
@@ -961,7 +962,7 @@ userPassword: thatsAcomplPASS4
         self.ldb.set_dsheuristics("000000001")
 
     def test_modify_dsheuristics_userPassword(self):
-        print "Performs testing about reading userPassword between dsHeuristic modifies"
+        print("Performs testing about reading userPassword between dsHeuristic modifies")
 
         # Make sure userPassword cannot be read
         self.ldb.set_dsheuristics("000000000")
index e1a4cd942bcb058ae2072ea8cbc54571614eaacb..317990b16bd370aa8b690afcad0309989d25ddd8 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function
 import optparse
 import sys
 import os
@@ -70,7 +71,7 @@ class RodcTests(samba.tests.TestCase):
             except ldb.LdbError as e:
                 (ecode, emsg) = e.args
                 if ecode != ldb.ERR_REFERRAL:
-                    print emsg
+                    print(emsg)
                     self.fail("Adding %s: ldb error: %s %s, wanted referral" %
                               (o['dn'], ecode, emsg))
                 else:
@@ -197,7 +198,7 @@ class RodcTests(samba.tests.TestCase):
         except ldb.LdbError as e4:
             (ecode, emsg) = e4.args
             if ecode != ldb.ERR_REFERRAL:
-                print ecode, emsg
+                print(ecode, emsg)
                 self.fail("Failed to REFER when trying to delete %s" % dn)
             else:
                 m = re.search(r'(ldap://[^>]+)>', emsg)
@@ -216,7 +217,7 @@ class RodcTests(samba.tests.TestCase):
         except ldb.LdbError as e5:
             (ecode, emsg) = e5.args
             if ecode != ldb.ERR_NO_SUCH_OBJECT:
-                print ecode, emsg
+                print(ecode, emsg)
                 self.fail("Failed to NO_SUCH_OBJECT when trying to delete "
                           "%s (which does not exist)" % dn)
 
index 4d9f893d98d1ce8d6be210c8c3819af6e89508a5..1e84369f34f015cdfccf021f741bef6556ad8a90 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
+from __future__ import print_function
 """Test communication of credentials etc, between an RODC and a RWDC.
 
 How does it work when the password is changed on the RWDC?
@@ -50,13 +51,13 @@ def make_creds(username, password, kerberos_state=None):
         kerberos_state = CREDS.get_kerberos_state()
     c.set_kerberos_state(kerberos_state)
 
-    print '-' * 73
+    print('-' * 73)
     if kerberos_state == MUST_USE_KERBEROS:
-        print "we seem to be using kerberos for %s %s" % (username, password)
+        print("we seem to be using kerberos for %s %s" % (username, password))
     elif kerberos_state == DONT_USE_KERBEROS:
-        print "NOT using kerberos for %s %s" % (username, password)
+        print("NOT using kerberos for %s %s" % (username, password))
     else:
-        print "kerberos state is %s" % kerberos_state
+        print("kerberos state is %s" % kerberos_state)
 
     c.set_gensec_features(c.get_gensec_features() |
                           gensec.FEATURE_SEAL)
@@ -98,7 +99,7 @@ def preload_rodc_user(user_dn):
            credstring,
            '--server', RWDC,]
 
-    print ' '.join(cmd)
+    print(' '.join(cmd))
     subprocess.check_call(cmd)
     set_auto_replication(RWDC, False)
 
@@ -164,12 +165,12 @@ class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase):
                              stdout=subprocess.PIPE)
         stdout, stderr = p.communicate()
         if p.returncode:
-            print "failed with code %s" % p.returncode
-            print ' '.join(cmd)
-            print "stdout"
-            print stdout
-            print "stderr"
-            print stderr
+            print("failed with code %s" % p.returncode)
+            print(' '.join(cmd))
+            print("stdout")
+            print(stdout)
+            print("stderr")
+            print(stderr)
             raise RodcRwdcTestException()
 
     def _change_password(self, user_dn, old_password, new_password):
@@ -486,7 +487,7 @@ class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase):
                                   msDSUserAccountControlComputed=0)
         badPasswordTime = int(res[0]["badPasswordTime"][0])
 
-        print "two failed password change"
+        print("two failed password change")
 
         # The wrong password
         creds_lockout.set_password("thatsAcomplPASS1x")
@@ -574,7 +575,7 @@ class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase):
 
         # wait for the lockout to end
         time.sleep(self.account_lockout_duration + 1)
-        print self.account_lockout_duration + 1
+        print(self.account_lockout_duration + 1)
 
         res = self._check_account(userdn,
                                   badPwdCount=3, effective_bad_password_count=0,
@@ -720,12 +721,12 @@ class RodcRwdcTests(password_lockout_base.BasePasswordTestCase):
                              stdout=subprocess.PIPE)
         stdout, stderr = p.communicate()
         if p.returncode:
-            print "failed with code %s" % p.returncode
-            print ' '.join(cmd)
-            print "stdout"
-            print stdout
-            print "stderr"
-            print stderr
+            print("failed with code %s" % p.returncode)
+            print(' '.join(cmd))
+            print("stdout")
+            print(stdout)
+            print("stderr")
+            print(stderr)
             raise RodcRwdcTestException()
 
     def _check_account_initial(self, dn):
index 38b90bda32eb6c8b2d022f2c023ea17a92c8b5d1..b032d228b76e3ac024f698107d8498afb29b54f7 100755 (executable)
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 # This is a port of the original in testprogs/ejs/ldap.js
 
+from __future__ import print_function
 import optparse
 import sys
 import os
@@ -80,7 +81,7 @@ class SamTests(samba.tests.TestCase):
         self.ldb = ldb
         self.base_dn = ldb.domain_dn()
 
-        print "baseDN: %s\n" % self.base_dn
+        print("baseDN: %s\n" % self.base_dn)
 
         delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
         delete_force(self.ldb, "cn=ldaptestuser2,cn=users," + self.base_dn)
@@ -91,7 +92,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_users_groups(self):
         """This tests the SAM users and groups behaviour"""
-        print "Testing users and groups behaviour\n"
+        print("Testing users and groups behaviour\n")
 
         ldb.add({
             "dn": "cn=ldaptestgroup,cn=users," + self.base_dn,
@@ -616,7 +617,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_sam_attributes(self):
         """Test the behaviour of special attributes of SAM objects"""
-        print "Testing the behaviour of special attributes of SAM objects\n"
+        print("Testing the behaviour of special attributes of SAM objects\n")
 
         ldb.add({
             "dn": "cn=ldaptestuser,cn=users," + self.base_dn,
@@ -749,7 +750,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_primary_group_token_constructed(self):
         """Test the primary group token behaviour (hidden-generated-readonly attribute on groups) and some other constructed attributes"""
-        print "Testing primary group token behaviour and other constructed attributes\n"
+        print("Testing primary group token behaviour and other constructed attributes\n")
 
         try:
             ldb.add({
@@ -825,7 +826,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_tokenGroups(self):
         """Test the tokenGroups behaviour (hidden-generated-readonly attribute on SAM objects)"""
-        print "Testing tokenGroups behaviour\n"
+        print("Testing tokenGroups behaviour\n")
 
         # The domain object shouldn't contain any "tokenGroups" entry
         res = ldb.search(self.base_dn, scope=SCOPE_BASE, attrs=["tokenGroups"])
@@ -869,7 +870,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_groupType(self):
         """Test the groupType behaviour"""
-        print "Testing groupType behaviour\n"
+        print("Testing groupType behaviour\n")
 
         # You can never create or change to a
         # "GTYPE_SECURITY_BUILTIN_LOCAL_GROUP"
@@ -1469,7 +1470,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_pwdLastSet(self):
         """Test the pwdLastSet behaviour"""
-        print "Testing pwdLastSet behaviour\n"
+        print("Testing pwdLastSet behaviour\n")
 
         ldb.add({
             "dn": "cn=ldaptestuser,cn=users," + self.base_dn,
@@ -1682,7 +1683,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_ldap_bind_must_change_pwd(self):
         """Test the error messages for failing LDAP binds"""
-        print "Test the error messages for failing LDAP binds\n"
+        print("Test the error messages for failing LDAP binds\n")
 
         delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
 
@@ -1863,7 +1864,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_userAccountControl(self):
         """Test the userAccountControl behaviour"""
-        print "Testing userAccountControl behaviour\n"
+        print("Testing userAccountControl behaviour\n")
 
         # With a user object
 
@@ -2543,7 +2544,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_smartcard_required1(self):
         """Test the UF_SMARTCARD_REQUIRED behaviour"""
-        print "Testing UF_SMARTCARD_REQUIRED behaviour\n"
+        print("Testing UF_SMARTCARD_REQUIRED behaviour\n")
 
         delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
 
@@ -2647,7 +2648,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_smartcard_required2(self):
         """Test the UF_SMARTCARD_REQUIRED behaviour"""
-        print "Testing UF_SMARTCARD_REQUIRED behaviour\n"
+        print("Testing UF_SMARTCARD_REQUIRED behaviour\n")
 
         delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
 
@@ -2795,7 +2796,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_smartcard_required3(self):
         """Test the UF_SMARTCARD_REQUIRED behaviour"""
-        print "Testing UF_SMARTCARD_REQUIRED behaviour\n"
+        print("Testing UF_SMARTCARD_REQUIRED behaviour\n")
 
         delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
 
@@ -2896,7 +2897,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_isCriticalSystemObject(self):
         """Test the isCriticalSystemObject behaviour"""
-        print "Testing isCriticalSystemObject behaviour\n"
+        print("Testing isCriticalSystemObject behaviour\n")
 
         # Add tests
 
@@ -3028,7 +3029,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_service_principal_name_updates(self):
         """Test the servicePrincipalNames update behaviour"""
-        print "Testing servicePrincipalNames update behaviour\n"
+        print("Testing servicePrincipalNames update behaviour\n")
 
         ldb.add({
             "dn": "cn=ldaptestcomputer,cn=computers," + self.base_dn,
@@ -3416,7 +3417,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_sam_description_attribute(self):
         """Test SAM description attribute"""
-        print "Test SAM description attribute"
+        print("Test SAM description attribute")
 
         self.ldb.add({
             "dn": "cn=ldaptestgroup,cn=users," + self.base_dn,
@@ -3589,7 +3590,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_fSMORoleOwner_attribute(self):
         """Test fSMORoleOwner attribute"""
-        print "Test fSMORoleOwner attribute"
+        print("Test fSMORoleOwner attribute")
 
         ds_service_name = self.ldb.get_dsServiceName()
 
@@ -3702,7 +3703,7 @@ class SamTests(samba.tests.TestCase):
 
     def test_new_user_default_attributes(self):
         """Test default attributes for new user objects"""
-        print "Test default attributes for new User objects\n"
+        print("Test default attributes for new User objects\n")
 
         user_name = "ldaptestuser"
         user_dn = "CN=%s,CN=Users,%s" % (user_name, self.base_dn)
index 1417dc4f3f174b7d80ff2d3e77d00764383b40cb..0e3a4c4c5bffd485c25f51da98a13e03295b3381 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function
 import optparse
 import sys
 import os
@@ -152,7 +153,7 @@ showInAdvancedViewOnly: TRUE
         self.domain_sid = security.dom_sid(self.ldb_admin.get_domain_sid())
         self.sd_utils = sd_utils.SDUtils(self.ldb_admin)
         self.addCleanup(self.delete_admin_connection)
-        print "baseDN: %s" % self.base_dn
+        print("baseDN: %s" % self.base_dn)
 
     def delete_admin_connection(self):
         del self.sd_utils
@@ -364,7 +365,7 @@ class OwnerGroupDescriptorTests(DescriptorTests):
         self.assertTrue(ace in desc_sddl)
         # Make sure we have identical result for both "add" and "modify"
         res = re.search("(O:.*G:.*?)D:", desc_sddl).group(1)
-        print self._testMethodName
+        print(self._testMethodName)
         test_number = self._testMethodName[5:]
         self.assertEqual(self.results[self.DS_BEHAVIOR][test_number], res)
 
@@ -1971,7 +1972,7 @@ class RightsAttributesTests(DescriptorTests):
         object_dn = "OU=test_domain_ou1," + self.base_dn
         delete_force(self.ldb_admin, object_dn)
         self.ldb_admin.create_ou(object_dn)
-        print self.get_users_domain_dn("testuser_attr")
+        print(self.get_users_domain_dn("testuser_attr"))
         user_sid = self.sd_utils.get_object_sid(self.get_users_domain_dn("testuser_attr"))
         #give testuser1 read access so attributes can be retrieved
         mod = "(A;CI;RP;;;%s)" % str(user_sid)
@@ -2121,12 +2122,12 @@ class SdAutoInheritTests(DescriptorTests):
         self.assertFalse(sub_sddl2 == sub_sddl0)
 
         if ace not in ou_sddl2:
-            print "ou0: %s" % ou_sddl0
-            print "ou2: %s" % ou_sddl2
+            print("ou0: %s" % ou_sddl0)
+            print("ou2: %s" % ou_sddl2)
 
         if sub_ace not in sub_sddl2:
-            print "sub0: %s" % sub_sddl0
-            print "sub2: %s" % sub_sddl2
+            print("sub0: %s" % sub_sddl0)
+            print("sub2: %s" % sub_sddl2)
 
         self.assertTrue(ace in ou_sddl2)
         self.assertTrue(sub_ace in sub_sddl2)
index 3bb53d9bc4cb731d33bf869d2a01caed241625b7..f5ca6a3bc9f64a6499187103dea7c8bed3e571a7 100755 (executable)
@@ -16,7 +16,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
+from __future__ import print_function
 
 import optparse
 import sys
@@ -473,18 +473,18 @@ class SimpleSubnetTests(SitesBaseTests):
             try:
                 subnets.create_subnet(self.ldb, basedn, cidr, self.sitename)
             except subnets.SubnetInvalid:
-                print >> sys.stderr, "%s fails properly" % (cidr,)
+                print("%s fails properly" % (cidr,), file=sys.stderr)
                 continue
 
             # we are here because it succeeded when it shouldn't have.
-            print >> sys.stderr, "CIDR %s fails to fail" % (cidr,)
+            print("CIDR %s fails to fail" % (cidr,), file=sys.stderr)
             failures.append(cidr)
             subnets.delete_subnet(self.ldb, basedn, cidr)
 
         if failures:
-            print "These bad subnet names were accepted:"
+            print("These bad subnet names were accepted:")
             for cidr in failures:
-                print "    %s" % cidr
+                print("    %s" % cidr)
             self.fail()
 
     def test_create_good_ranges(self):
@@ -613,7 +613,7 @@ class SimpleSubnetTests(SitesBaseTests):
             try:
                 subnets.create_subnet(self.ldb, basedn, cidr, self.sitename)
             except subnets.SubnetInvalid as e:
-                print e
+                print(e)
                 failures.append(cidr)
                 continue
 
@@ -622,15 +622,15 @@ class SimpleSubnetTests(SitesBaseTests):
                                               cidr))
 
             if len(ret) != 1:
-                print "%s was not created" % cidr
+                print("%s was not created" % cidr)
                 failures.append(cidr)
                 continue
             subnets.delete_subnet(self.ldb, basedn, cidr)
 
         if failures:
-            print "These good subnet names were not accepted:"
+            print("These good subnet names were not accepted:")
             for cidr in failures:
-                print "    %s" % cidr
+                print("    %s" % cidr)
             self.fail()
 
 
index 089e4b520cc7ce385aedc223b8a954e36139c301..d41bb953f1d4b79f9ea46150485dee7713886eb7 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # Originally based on ./sam.py
+from __future__ import print_function
 from unicodedata import normalize
 import locale
 locale.setlocale(locale.LC_ALL, ('en_US', 'UTF-8'))
@@ -134,7 +135,7 @@ class BaseSortTests(samba.tests.TestCase):
             try:
                 self.ldb.delete(self.ou, ['tree_delete:1'])
             except ldb.LdbError as e:
-                print "tried deleting %s, got error %s" % (self.ou, e)
+                print("tried deleting %s, got error %s" % (self.ou, e))
 
         self.ldb.add({
             "dn": self.ou,
@@ -222,12 +223,12 @@ class BaseSortTests(samba.tests.TestCase):
                 expected_order = self.expected_results[attr][rev]
                 received_order = [norm(x[attr][0]) for x in res]
                 if expected_order != received_order:
-                    print attr, ['forward', 'reverse'][rev]
-                    print "expected", expected_order
-                    print "recieved", received_order
-                    print "unnormalised:", [x[attr][0] for x in res]
-                    print "unnormalised: «%s»" % '»  «'.join(x[attr][0]
-                                                             for x in res)
+                    print(attr, ['forward', 'reverse'][rev])
+                    print("expected", expected_order)
+                    print("recieved", received_order)
+                    print("unnormalised:", [x[attr][0] for x in res])
+                    print("unnormalised: «%s»" % '»  «'.join(x[attr][0]
+                                                             for x in res))
                 self.assertEquals(expected_order, received_order)
 
     def _test_server_sort_binary(self):
@@ -242,9 +243,9 @@ class BaseSortTests(samba.tests.TestCase):
                 expected_order = self.expected_results_binary[attr][rev]
                 received_order = [x[attr][0] for x in res]
                 if expected_order != received_order:
-                    print attr
-                    print expected_order
-                    print received_order
+                    print(attr)
+                    print(expected_order)
+                    print(received_order)
                 self.assertEquals(expected_order, received_order)
 
     def _test_server_sort_us_english(self):
@@ -268,13 +269,13 @@ class BaseSortTests(samba.tests.TestCase):
                     expected_order = self.expected_results[attr][rev]
                     received_order = [norm(x[attr][0]) for x in res]
                     if expected_order != received_order:
-                        print attr, lang
-                        print ['forward', 'reverse'][rev]
-                        print "expected: ", expected_order
-                        print "recieved: ", received_order
-                        print "unnormalised:", [x[attr][0] for x in res]
-                        print "unnormalised: «%s»" % '»  «'.join(x[attr][0]
-                                                                 for x in res)
+                        print(attr, lang)
+                        print(['forward', 'reverse'][rev])
+                        print("expected: ", expected_order)
+                        print("recieved: ", received_order)
+                        print("unnormalised:", [x[attr][0] for x in res])
+                        print("unnormalised: «%s»" % '»  «'.join(x[attr][0]
+                                                                 for x in res))
 
                     self.assertEquals(expected_order, received_order)
 
@@ -318,22 +319,22 @@ class BaseSortTests(samba.tests.TestCase):
                 received_order = [norm(x[result_attr][0]) for x in res]
 
                 if expected_order != received_order:
-                    print sort_attr, result_attr, ['forward', 'reverse'][rev]
-                    print "expected", expected_order
-                    print "recieved", received_order
-                    print "unnormalised:", [x[result_attr][0] for x in res]
-                    print "unnormalised: «%s»" % '»  «'.join(x[result_attr][0]
-                                                             for x in res)
-                    print "pairs:", pairs
+                    print(sort_attr, result_attr, ['forward', 'reverse'][rev])
+                    print("expected", expected_order)
+                    print("recieved", received_order)
+                    print("unnormalised:", [x[result_attr][0] for x in res])
+                    print("unnormalised: «%s»" % '»  «'.join(x[result_attr][0]
+                                                             for x in res))
+                    print("pairs:", pairs)
                     # There are bugs in Windows that we don't want (or
                     # know how) to replicate regarding timestamp sorting.
                     # Let's remind ourselves.
                     if result_attr == "msTSExpireDate4":
-                        print '-' * 72
+                        print('-' * 72)
                         print ("This test fails against Windows with the "
                                "default number of elements (33).")
-                        print "Try with --elements=27 (or similar)."
-                        print '-' * 72
+                        print("Try with --elements=27 (or similar).")
+                        print('-' * 72)
 
                 self.assertEquals(expected_order, received_order)
                 for x in res:
index 6a9c8677541446d95a5710cbbef014352ef781a3..8c3441e8af9bcc2dff793f3d907279a3bf6f9f75 100755 (executable)
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 # test tokengroups attribute against internal token calculation
 
+from __future__ import print_function
 import optparse
 import sys
 import os
@@ -151,10 +152,10 @@ class StaticTokenTest(samba.tests.TestCase):
         # Run the actual call loop.
         while client_finished == False and server_finished == False:
             if not client_finished:
-                print "running client gensec_update"
+                print("running client gensec_update")
                 (client_finished, client_to_server) = gensec_client.update(server_to_client)
             if not server_finished:
-                print "running server gensec_update"
+                print("running server gensec_update")
                 (server_finished, server_to_client) = gensec_server.update(client_to_server)
 
         session = gensec_server.session_info()
@@ -383,10 +384,10 @@ class DynamicTokenTest(samba.tests.TestCase):
         # Run the actual call loop.
         while client_finished == False and server_finished == False:
             if not client_finished:
-                print "running client gensec_update"
+                print("running client gensec_update")
                 (client_finished, client_to_server) = gensec_client.update(server_to_client)
             if not server_finished:
-                print "running server gensec_update"
+                print("running server gensec_update")
                 (server_finished, server_to_client) = gensec_server.update(client_to_server)
 
         session = gensec_server.session_info()
index 87f600268af8ba341e499f0c8429a0b5774a3a26..829998d90de1399337a4c506e251920fd9380fcd 100755 (executable)
@@ -18,6 +18,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 import sys
 import unittest
 
@@ -210,7 +211,7 @@ class BaseRestoreObjectTestCase(RestoredObjectAttributesBaseTestCase):
             self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS)
 
     def test_undelete(self):
-        print "Testing standard undelete operation"
+        print("Testing standard undelete operation")
         usr1 = "cn=testuser,cn=users," + self.base_dn
         samba.tests.delete_force(self.samdb, usr1)
         self.samdb.add({
@@ -228,7 +229,7 @@ class BaseRestoreObjectTestCase(RestoredObjectAttributesBaseTestCase):
         samba.tests.delete_force(self.samdb, usr1)
 
     def test_rename(self):
-        print "Testing attempt to rename deleted object"
+        print("Testing attempt to rename deleted object")
         usr1 = "cn=testuser,cn=users," + self.base_dn
         self.samdb.add({
             "dn": usr1,
@@ -255,7 +256,7 @@ class BaseRestoreObjectTestCase(RestoredObjectAttributesBaseTestCase):
             self.assertEquals(num, ERR_UNWILLING_TO_PERFORM)
 
     def test_undelete_with_mod(self):
-        print "Testing standard undelete operation with modification of additional attributes"
+        print("Testing standard undelete operation with modification of additional attributes")
         usr1 = "cn=testuser,cn=users," + self.base_dn
         self.samdb.add({
             "dn": usr1,
@@ -272,7 +273,7 @@ class BaseRestoreObjectTestCase(RestoredObjectAttributesBaseTestCase):
         samba.tests.delete_force(self.samdb, usr1)
 
     def test_undelete_newuser(self):
-        print "Testing undelete user with a different dn"
+        print("Testing undelete user with a different dn")
         usr1 = "cn=testuser,cn=users," + self.base_dn
         usr2 = "cn=testuser2,cn=users," + self.base_dn
         samba.tests.delete_force(self.samdb, usr1)
@@ -291,7 +292,7 @@ class BaseRestoreObjectTestCase(RestoredObjectAttributesBaseTestCase):
         samba.tests.delete_force(self.samdb, usr2)
 
     def test_undelete_existing(self):
-        print "Testing undelete user after a user with the same dn has been created"
+        print("Testing undelete user after a user with the same dn has been created")
         usr1 = "cn=testuser,cn=users," + self.base_dn
         self.samdb.add({
             "dn": usr1,
@@ -315,7 +316,7 @@ class BaseRestoreObjectTestCase(RestoredObjectAttributesBaseTestCase):
             self.assertEquals(num, ERR_ENTRY_ALREADY_EXISTS)
 
     def test_undelete_cross_nc(self):
-        print "Cross NC undelete"
+        print("Cross NC undelete")
         c1 = "cn=ldaptestcontainer," + self.base_dn
         c2 = "cn=ldaptestcontainer2," + self.configuration_dn
         c3 = "cn=ldaptestcontainer," + self.configuration_dn
@@ -525,7 +526,7 @@ class RestoreUserObjectTestCase(RestoredObjectAttributesBaseTestCase):
             (DRSUAPI_ATTID_isRecycled, 2)]
 
     def test_restore_user(self):
-        print "Test restored user attributes"
+        print("Test restored user attributes")
         username = "restore_user"
         usr_dn = "CN=%s,CN=Users,%s" % (username, self.base_dn)
         samba.tests.delete_force(self.samdb, usr_dn)
@@ -732,7 +733,7 @@ class RestoreUserPwdObjectTestCase(RestoredObjectAttributesBaseTestCase):
             (DRSUAPI_ATTID_isRecycled, 2)]
 
     def test_restorepw_user(self):
-        print "Test restored user attributes"
+        print("Test restored user attributes")
         username = "restorepw_user"
         usr_dn = "CN=%s,CN=Users,%s" % (username, self.base_dn)
         samba.tests.delete_force(self.samdb, usr_dn)
@@ -827,7 +828,7 @@ class RestoreGroupObjectTestCase(RestoredObjectAttributesBaseTestCase):
                 'cn': groupname }
 
     def test_plain_group(self):
-        print "Test restored Group attributes"
+        print("Test restored Group attributes")
         # create test group
         obj = self._create_test_group("r_group")
         guid = obj["objectGUID"][0]
@@ -846,7 +847,7 @@ class RestoreGroupObjectTestCase(RestoredObjectAttributesBaseTestCase):
         self.assertAttributesExists(self._expected_group_attributes("r_group", str(obj.dn), "Group"), obj_restore)
 
     def test_group_with_members(self):
-        print "Test restored Group with members attributes"
+        print("Test restored Group with members attributes")
         # create test group
         usr1 = self._create_test_user("r_user_1")
         usr2 = self._create_test_user("r_user_2")
@@ -900,7 +901,7 @@ class RestoreContainerObjectTestCase(RestoredObjectAttributesBaseTestCase):
         return self.search_dn(ou_dn)
 
     def test_ou_with_name_description(self):
-        print "Test OU reanimation"
+        print("Test OU reanimation")
         # create OU to test with
         obj = self._create_test_ou(rdn="r_ou",
                                    name="r_ou name",
@@ -924,7 +925,7 @@ class RestoreContainerObjectTestCase(RestoredObjectAttributesBaseTestCase):
         self.assertAttributesExists(expected_attrs, obj_restore)
 
     def test_container(self):
-        print "Test Container reanimation"
+        print("Test Container reanimation")
         # create test Container
         obj = self._create_object({
             "dn": "CN=r_container,CN=Users,%s" % self.base_dn,
index aca6309b0e90e12be19c097ad92abadee3e5720f..a89588b6a411cabcad2363fdbd7d59c7c269e550 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function
 import optparse
 import sys
 sys.path.insert(0, "bin/python")
@@ -47,7 +48,7 @@ class UrgentReplicationTests(samba.tests.TestCase):
         self.ldb = samba.tests.connect_samdb(host, global_schema=False)
         self.base_dn = self.ldb.domain_dn()
 
-        print "baseDN: %s\n" % self.base_dn
+        print("baseDN: %s\n" % self.base_dn)
 
     def test_nonurgent_object(self):
         """Test if the urgent replication is not activated when handling a non urgent object."""
@@ -208,7 +209,7 @@ defaultHidingValue: TRUE""")
             self.assertEquals(res["uSNHighest"], res["uSNUrgent"])
 
         except LdbError:
-            print "Not testing urgent replication when creating classSchema object ...\n"
+            print("Not testing urgent replication when creating classSchema object ...\n")
 
         # urgent replication should be enabled when modifying 
         m = Message()
index e82c9557d87d25503051a9cad9d0c7f6f61e9360..de0c1c444e7603d528cbd704011c925c7070ef3b 100755 (executable)
@@ -8,6 +8,7 @@
 # Licenced under the GPLv3
 #
 
+from __future__ import print_function
 import optparse
 import sys
 import unittest
@@ -102,7 +103,7 @@ class UserAccountControlTests(samba.tests.TestCase):
         msg = ldb.Message.from_dict(self.samdb, msg_dict )
         msg["sAMAccountName"] = samaccountname
 
-        print "Adding computer account %s" % computername
+        print("Adding computer account %s" % computername)
         samdb.add(msg)
 
     def get_creds(self, target_username, target_password):
index d62d01db829dadf4a7dd0ef28ea01bdafc471d9a..68ef11bf25fe0f0fc5dfbd7357989b947c6a1cb5 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # Originally based on ./sam.py
+from __future__ import print_function
 import optparse
 import sys
 import os
@@ -155,7 +156,7 @@ class VLVTests(samba.tests.TestCase):
             try:
                 self.ldb.delete(self.ou, ['tree_delete:1'])
             except ldb.LdbError as e:
-                print "tried deleting %s, got error %s" % (self.ou, e)
+                print("tried deleting %s, got error %s" % (self.ou, e))
         self.ldb.add({
             "dn": self.ou,
             "objectclass": "organizationalUnit"})
@@ -317,9 +318,9 @@ class VLVTests(samba.tests.TestCase):
             gte_map[k] = len(expected_order)
 
         if False:
-            print "gte_map:"
+            print("gte_map:")
             for k in gte_order:
-                print "   %10s => %10s" % (k, gte_map[k])
+                print("   %10s => %10s" % (k, gte_map[k]))
 
         return gte_order, expected_order, gte_map
 
@@ -340,14 +341,14 @@ class VLVTests(samba.tests.TestCase):
             return
 
         if expected_order is not None:
-            print "expected order: %s" % expected_order[:20]
+            print("expected order: %s" % expected_order[:20])
             if len(expected_order) > 20:
-                print "... and %d more not shown" % (len(expected_order) - 20)
+                print("... and %d more not shown" % (len(expected_order) - 20))
 
-        print "offset %d before %d after %d" % (offset, before, after)
-        print "start %d end %d" % (start, end)
-        print "expected: %s" % expected_results
-        print "got     : %s" % results
+        print("offset %d before %d after %d" % (offset, before, after))
+        print("start %d end %d" % (start, end))
+        print("expected: %s" % expected_results)
+        print("got     : %s" % results)
         self.assertEquals(expected_results, results)
 
     def test_server_vlv_with_cookie(self):
@@ -1005,10 +1006,10 @@ class VLVTests(samba.tests.TestCase):
                         iteration += 1
                         if expected_results != results:
                             middle = expected_order[len(expected_order) // 2]
-                            print expected_results, results
-                            print middle
-                            print expected_order
-                            print
+                            print(expected_results, results)
+                            print(middle)
+                            print(expected_order)
+                            print()
                             print ("\nattr %s offset %d before %d "
                                    "after %d gte %s" %
                                    (attr, offset, before, after, gte))