traffic: simplify tests for badpassword_frequency
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 19 Oct 2018 04:19:09 +0000 (17:19 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 8 Jan 2019 22:55:34 +0000 (23:55 +0100)
x <= 0 will fail one or both of the other test clauses.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/emulate/traffic.py

index dadc6c1..e117958 100644 (file)
@@ -480,8 +480,8 @@ class ReplayContext(object):
            than that requested, but not significantly.
         """
         if not failed_last_time:
-            if (self.badpassword_frequency and self.badpassword_frequency > 0
-                and random.random() < self.badpassword_frequency):
+            if (self.badpassword_frequency and
+                random.random() < self.badpassword_frequency):
                 try:
                     f(bad)
                 except:
@@ -762,7 +762,8 @@ class ReplayContext(object):
     def get_authenticator(self):
         auth = self.machine_creds.new_client_authenticator()
         current  = netr_Authenticator()
-        current.cred.data = [x if isinstance(x, int) else ord(x) for x in auth["credential"]]
+        current.cred.data = [x if isinstance(x, int) else ord(x)
+                             for x in auth["credential"]]
         current.timestamp = auth["timestamp"]
 
         subsequent = netr_Authenticator()