]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytest: remove py2 str/bytes workaround in py_credentials
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 11 Jun 2024 23:13:24 +0000 (11:13 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 12 Jun 2024 08:14:34 +0000 (08:14 +0000)
It is likely not necessary to cast to list() in most cases.

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

index 767fba28e95b1dd23521e2bddbea441555509554..7d473b19a39c9a936659edcd0872c0bf57e74aec 100644 (file)
@@ -511,10 +511,10 @@ class PyCredentialsTests(TestCase):
         newpass = samba.generate_random_password(PWD_LEN, PWD_LEN)
         encoded = newpass.encode('utf-16-le')
         pwd_len = len(encoded)
-        filler  = [x if isinstance(x, int) else ord(x) for x in os.urandom(DATA_LEN - pwd_len)]
+        filler  = list(os.urandom(DATA_LEN - pwd_len))
         pwd = netlogon.netr_CryptPassword()
         pwd.length = pwd_len
-        pwd.data = filler + [x if isinstance(x, int) else ord(x) for x in encoded]
+        pwd.data = filler + list(encoded)
         self.machine_creds.encrypt_netr_crypt_password(pwd)
         c.netr_ServerPasswordSet2(self.server,
                                   f'{self.machine_name}$',
@@ -591,7 +591,7 @@ class PyCredentialsTests(TestCase):
     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 = list(auth["credential"])
         current.timestamp = auth["timestamp"]
 
         subsequent = netr_Authenticator()
@@ -641,10 +641,10 @@ def samlogon_logon_info(domain_name, computer_name, creds,
 
     logon = netlogon.netr_NetworkInfo()
 
-    logon.challenge     = [x if isinstance(x, int) else ord(x) for x in challenge]
+    logon.challenge     = list(challenge)
     logon.nt            = netlogon.netr_ChallengeResponse()
     logon.nt.length     = len(response["nt_response"])
-    logon.nt.data       = [x if isinstance(x, int) else ord(x) for x in response["nt_response"]]
+    logon.nt.data       = list(response["nt_response"])
     logon.identity_info = netlogon.netr_IdentityInfo()
 
     (username, domain)  = creds.get_ntlm_username_domain()