Fix PEP8 warning E225 missing whitespace around operator
authorTim Beale <timbeale@catalyst.net.nz>
Fri, 27 Jul 2018 01:26:23 +0000 (13:26 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 17 Aug 2018 00:58:27 +0000 (02:58 +0200)
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/netcmd/pso.py
python/samba/tests/pso.py
python/samba/tests/samba_tool/passwordsettings.py
source4/dsdb/tests/python/password_settings.py
source4/torture/drs/python/getncchanges.py
source4/torture/drs/python/link_conflicts.py

index e43886eb23bbe9918a4ab7891a1c555244fc30e5..f0f733885d93b0caee82e9c406bff67fe1c25184 100644 (file)
@@ -412,7 +412,8 @@ class cmd_domain_pwdsettings_pso_create(Command):
             if num == ldb.ERR_INSUFFICIENT_ACCESS_RIGHTS:
                 raise CommandError("Administrator permissions are needed to create a PSO.")
             else:
-                raise CommandError("Failed to create PSO '%s': %s" %(pso_dn, msg))
+                raise CommandError("Failed to create PSO '%s': %s" % (pso_dn,
+                                                                      msg))
 
 class cmd_domain_pwdsettings_pso_set(Command):
     """Modifies a Password Settings Object (PSO)."""
@@ -489,7 +490,7 @@ class cmd_domain_pwdsettings_pso_set(Command):
             show_pso_by_dn(self.outf, samdb, pso_dn, show_applies_to=False)
         except ldb.LdbError as e:
             (num, msg) = e.args
-            raise CommandError("Failed to update PSO '%s': %s" %(pso_dn, msg))
+            raise CommandError("Failed to update PSO '%s': %s" % (pso_dn, msg))
 
 
 class cmd_domain_pwdsettings_pso_delete(Command):
@@ -572,7 +573,7 @@ class cmd_domain_pwdsettings_pso_list(Command):
 
         for pso in pso_list:
             precedence = pso['msDS-PasswordSettingsPrecedence']
-            self.outf.write("%-10s | %s\n" %(precedence, pso['name']))
+            self.outf.write("%-10s | %s\n" % (precedence, pso['name']))
 
 class cmd_domain_pwdsettings_pso_show(Command):
     """Display a Password Settings Object's details."""
@@ -693,10 +694,10 @@ class cmd_domain_pwdsettings_pso_apply(Command):
                 raise CommandError("PSO '%s' already applies to '%s'"
                                    % (psoname, user_or_group))
             else:
-                raise CommandError("Failed to update PSO '%s': %s" %(psoname,
-                                                                     msg))
+                raise CommandError("Failed to update PSO '%s': %s" % (psoname,
+                                                                      msg))
 
-        self.message("PSO '%s' applied to '%s'" %(psoname, user_or_group))
+        self.message("PSO '%s' applied to '%s'" % (psoname, user_or_group))
 
 
 class cmd_domain_pwdsettings_pso_unapply(Command):
@@ -752,9 +753,10 @@ class cmd_domain_pwdsettings_pso_unapply(Command):
                 raise CommandError("PSO '%s' doesn't apply to '%s'"
                                    % (psoname, user_or_group))
             else:
-                raise CommandError("Failed to update PSO '%s': %s" %(psoname,
-                                                                     msg))
-        self.message("PSO '%s' no longer applies to '%s'" %(psoname, user_or_group))
+                raise CommandError("Failed to update PSO '%s': %s" % (psoname,
+                                                                      msg))
+        self.message("PSO '%s' no longer applies to '%s'" % (psoname,
+                                                             user_or_group))
 
 class cmd_domain_passwordsettings_pso(SuperCommand):
     """Manage fine-grained Password Settings Objects (PSOs)."""
index 76c8d46e90b4c6bf2f2ba8a0dfd74446ade95824..d6ebf50e46dd386f17f4e7d847c1e87e09a599a9 100644 (file)
@@ -33,8 +33,8 @@ class TestUser:
         initial_password = "Initial12#"
         self.name = username
         self.ldb = samdb
-        self.dn = "CN=%s,%s,%s" %(username, (userou or "CN=Users"),
-                                  self.ldb.domain_dn())
+        self.dn = "CN=%s,%s,%s" % (username, (userou or "CN=Users"),
+                                   self.ldb.domain_dn())
 
         # store all passwords that have ever been used for this user, as well
         # as a pwd_history that more closely resembles the history on the DC
@@ -154,9 +154,9 @@ class PasswordSettings:
         Returns a object representing the default password settings that will
         take effect (i.e. when no other Fine-Grained Password Policy applies)
         """
-        pw_attrs=["minPwdAge", "lockoutDuration", "lockOutObservationWindow",
-                  "lockoutThreshold", "maxPwdAge", "minPwdAge", "minPwdLength",
-                  "pwdHistoryLength", "pwdProperties"]
+        pw_attrs = ["minPwdAge", "lockoutDuration", "lockOutObservationWindow",
+                    "lockoutThreshold", "maxPwdAge", "minPwdAge",
+                    "minPwdLength", "pwdHistoryLength", "pwdProperties"]
         res = samdb.search(samdb.domain_dn(), scope=ldb.SCOPE_BASE,
                            attrs=pw_attrs)
 
@@ -195,7 +195,7 @@ class PasswordSettings:
             container = "CN=Password Settings Container,CN=System,%s" % base_dn
 
         self.name = name
-        self.dn = "CN=%s,%s" %(name, container)
+        self.dn = "CN=%s,%s" % (name, container)
         self.ldb = samdb
         self.precedence = precedence
         self.complexity = complexity
index 353756c4931da1928da5f06696b31c15b5fac397..c6577bb6a3df7eaaaf809079c7e6cba34742a698 100644 (file)
@@ -44,7 +44,7 @@ class PwdSettingsCmdTestCase(SambaToolCmdTest):
         """Checks the PSO info in the DB matches what's expected"""
 
         # lookup the PSO in the DB
-        dn = "CN=%s,%s" %(pso_name, self.pso_container)
+        dn = "CN=%s,%s" % (pso_name, self.pso_container)
         pso_attrs = ['name', 'msDS-PasswordSettingsPrecedence',
                      'msDS-PasswordReversibleEncryptionEnabled',
                      'msDS-PasswordHistoryLength', 'msDS-MinimumPasswordLength',
@@ -113,7 +113,7 @@ class PwdSettingsCmdTestCase(SambaToolCmdTest):
                                                  "-H", self.server,
                                                  self.user_auth)
         # make sure we clean-up after the test completes
-        self.obj_cleanup.append("CN=%s,%s" %(pso_name, self.pso_container))
+        self.obj_cleanup.append("CN=%s,%s" % (pso_name, self.pso_container))
 
         self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
@@ -156,7 +156,7 @@ class PwdSettingsCmdTestCase(SambaToolCmdTest):
                                                  "--max-pwd-age=50",
                                                  "-H", self.server,
                                                  self.user_auth)
-        self.obj_cleanup.append("CN=%s,%s" %(pso_name, self.pso_container))
+        self.obj_cleanup.append("CN=%s,%s" % (pso_name, self.pso_container))
         self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertIn("successfully created", out)
@@ -185,7 +185,7 @@ class PwdSettingsCmdTestCase(SambaToolCmdTest):
                                                  "-H", self.server,
                                                  self.user_auth)
         # make sure we clean-up after the test completes
-        pso_settings.dn = "CN=%s,%s" %(pso_name, self.pso_container)
+        pso_settings.dn = "CN=%s,%s" % (pso_name, self.pso_container)
         self.obj_cleanup.append(pso_settings.dn)
 
         # sanity-check the cmd was successful
@@ -234,7 +234,7 @@ class PwdSettingsCmdTestCase(SambaToolCmdTest):
         self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertIn("Deleted PSO", out)
-        dn = "CN=%s,%s" %(pso_name, self.pso_container)
+        dn = "CN=%s,%s" % (pso_name, self.pso_container)
         self.obj_cleanup.remove(dn)
 
         # check the object no longer exists in the DB
@@ -287,7 +287,7 @@ class PwdSettingsCmdTestCase(SambaToolCmdTest):
 
         # add the user to a new group
         group_name = "test-PSO-group"
-        dn = "CN=%s,%s" %(group_name, self.ldb.domain_dn())
+        dn = "CN=%s,%s" % (group_name, self.ldb.domain_dn())
         self.ldb.add({"dn": dn, "objectclass": "group",
                       "sAMAccountName": group_name})
         self.obj_cleanup.append(dn)
@@ -349,7 +349,7 @@ class PwdSettingsCmdTestCase(SambaToolCmdTest):
         self._create_pso(pso_name)
         user = TestUser("test-unpriv-user", self.ldb)
         self.obj_cleanup.append(user.dn)
-        unpriv_auth = "-U%s%%%s" %(user.name, user.get_password())
+        unpriv_auth = "-U%s%%%s" % (user.name, user.get_password())
 
         # check we need admin privileges to be able to do anything to PSOs
         (result, out, err) = self.runsublevelcmd("domain", ("passwordsettings",
index f950a1d50e7a44ac7a6f11bb923074e93f503730..a683292fff314bce0215dcc14fdef6405ea4e684 100644 (file)
@@ -77,7 +77,7 @@ class PasswordSettingsTestCase(PasswordTestCase):
 
     def add_group(self, group_name):
         """Creates a new group"""
-        dn = "CN=%s,%s" %(group_name, self.ou)
+        dn = "CN=%s,%s" % (group_name, self.ou)
         self.ldb.add({"dn": dn, "objectclass": "group"})
         return dn
 
@@ -116,7 +116,7 @@ class PasswordSettingsTestCase(PasswordTestCase):
         except ldb.LdbError as e:
             (num, msg) = e.args
             # fail the test (rather than throw an error)
-            self.fail("Password '%s' unexpectedly rejected: %s" %(password, msg))
+            self.fail("Password '%s' unexpectedly rejected: %s" % (password, msg))
 
     def assert_PSO_applied(self, user, pso):
         """
@@ -126,8 +126,8 @@ class PasswordSettingsTestCase(PasswordTestCase):
         """
         resultant_pso = user.get_resultant_PSO()
         self.assertTrue(resultant_pso == pso.dn,
-                        "Expected PSO %s, not %s" %(pso.name,
-                                                    str(resultant_pso)))
+                        "Expected PSO %s, not %s" % (pso.name,
+                                                     str(resultant_pso)))
 
         # we're mirroring the pwd_history for the user, so make sure this is
         # up-to-date, before we start making password changes
@@ -485,7 +485,7 @@ class PasswordSettingsTestCase(PasswordTestCase):
 
         # we can't wait around long enough for the max-age to expire, so instead
         # just check the msDS-UserPasswordExpiryTimeComputed for the user
-        attrs=['msDS-UserPasswordExpiryTimeComputed']
+        attrs = ['msDS-UserPasswordExpiryTimeComputed']
         res = self.ldb.search(user.dn, attrs=attrs)
         domain_expiry = int(res[0]['msDS-UserPasswordExpiryTimeComputed'][0])
 
index 9136d076e7bbd2e625e5c9f4a1736a656de70def..123a19cc3de894218e2f0e0f998c73d61aee332e 100644 (file)
@@ -159,8 +159,8 @@ class DrsReplicaSyncIntegrityTestCase(drs_base.DrsBaseTestCase):
         # object multiple times, so this might be noteworthy but doesn't
         # warrant failing the test
         if (len(received_list) != len(expected_list)):
-            print("Note: received %d objects but expected %d" %(len(received_list),
-                                                                len(expected_list)))
+            print("Note: received %d objects but expected %d" % (len(received_list),
+                                                                 len(expected_list)))
 
         # Check that we received every object that we were expecting
         for dn in expected_list:
@@ -438,7 +438,7 @@ class DrsReplicaSyncIntegrityTestCase(drs_base.DrsBaseTestCase):
 
         self.assertTrue(len(received_links) == num_expected,
                         "Received %d links but expected %d"
-                        %(len(received_links), num_expected))
+                        % (len(received_links), num_expected))
 
         for dn in objects_with_links:
             self.assert_object_has_link(dn, link_attr, received_links)
@@ -458,7 +458,7 @@ class DrsReplicaSyncIntegrityTestCase(drs_base.DrsBaseTestCase):
         # We didn't find the expected link attribute in the DB for the object.
         # Something has gone wrong somewhere...
         self.assertTrue(link_attr in res[0], "%s in DB doesn't have attribute %s"
-                        %(dn, link_attr))
+                        % (dn, link_attr))
 
         # find the received link in the list and assert that the target and
         # source GUIDs match what's in the DB
@@ -477,7 +477,7 @@ class DrsReplicaSyncIntegrityTestCase(drs_base.DrsBaseTestCase):
                     found = True
 
                     if self._debug:
-                        print("Link %s --> %s" %(dn[:25], link.targetDN[:25]))
+                        print("Link %s --> %s" % (dn[:25], link.targetDN[:25]))
                     break
 
             self.assertTrue(found, "Did not receive expected link for DN %s" % dn)
@@ -986,7 +986,7 @@ class DrsReplicaSyncIntegrityTestCase(drs_base.DrsBaseTestCase):
         # create the link target (a server object) in the config NC
         rand = random.randint(1, 10000000)
         la_target = "CN=getncchanges-%d,CN=Servers,CN=Default-First-Site-Name," \
-                    "CN=Sites,%s" %(rand, self.config_dn)
+                    "CN=Sites,%s" % (rand, self.config_dn)
         self.add_object(la_target, objectclass="server")
 
         # add a cross-partition link between the two
index 0759b1ef1a71b0e8b440d33f34031a3acbf32933..347298b5885f8320c8842cc0067c7c2cb69ca8e4 100644 (file)
@@ -113,7 +113,7 @@ class DrsReplicaLinkConflictTestCase(drs_base.DrsBaseTestCase):
         # that the 2nd run doesn't hit objects that already exist. Add some
         # randomness to the object DN to make it unique
         rand = random.randint(1, 10000000)
-        return "%s-%d,%s" %(obj_name, rand, self.ou)
+        return "%s-%d,%s" % (obj_name, rand, self.ou)
 
     def assert_attrs_match(self, res1, res2, attr, expected_count):
         """
@@ -122,17 +122,17 @@ class DrsReplicaLinkConflictTestCase(drs_base.DrsBaseTestCase):
         """
         actual_len = len(res1[0][attr])
         self.assertTrue(actual_len == expected_count,
-                        "Expected %u %s attributes, but got %u" %(expected_count,
-                                                                  attr, actual_len))
+                        "Expected %u %s attributes, but got %u" % (expected_count,
+                                                                   attr, actual_len))
         actual_len = len(res2[0][attr])
         self.assertTrue(actual_len == expected_count,
-                        "Expected %u %s attributes, but got %u" %(expected_count,
-                                                                  attr, actual_len))
+                        "Expected %u %s attributes, but got %u" % (expected_count,
+                                                                   attr, actual_len))
 
         # check DCs both agree on the same linked attributes
         for val in res1[0][attr]:
             self.assertTrue(val in res2[0][attr],
-                            "%s '%s' not found on DC2" %(attr, val))
+                            "%s '%s' not found on DC2" % (attr, val))
 
     def zero_highwatermark(self):
         """Returns a zeroed highwatermark so that all DRS data gets returned"""