python/samba/tests: Py3 port for samba.tests.auth_log_netlogon_bad_creds.samba
[amitay/samba.git] / python / samba / tests / auth_log_netlogon_bad_creds.py
index fedd8a1d412a96423959e369e29a23cb120d21ae..d850bd1c1b4f881212597a3d2c8ade0e7ff63ab5 100644 (file)
@@ -36,6 +36,8 @@ from samba.auth import system_session
 from samba.tests import delete_force
 from samba.dsdb import UF_WORKSTATION_TRUST_ACCOUNT, UF_PASSWD_NOTREQD
 from samba.dcerpc.misc import SEC_CHAN_WKSTA
+from samba.dcerpc.netlogon import NETLOGON_NEG_STRONG_KEYS
+from samba.compat import get_string
 
 
 class AuthLogTestsNetLogonBadCreds(samba.tests.auth_log_base.AuthLogTestBase):
@@ -59,9 +61,7 @@ class AuthLogTestsNetLogonBadCreds(samba.tests.auth_log_base.AuthLogTestBase):
         self.dn            = ("cn=%s,cn=users,%s" %
                               (self.netbios_name, self.base_dn))
 
-        utf16pw = unicode(
-            '"' + self.machinepass.encode('utf-8') + '"', 'utf-8'
-        ).encode('utf-16-le')
+        utf16pw = get_string('"' + self.machinepass + '"').encode('utf-16-le')
         self.ldb.add({
             "dn": self.dn,
             "objectclass": "computer",
@@ -115,6 +115,7 @@ class AuthLogTestsNetLogonBadCreds(samba.tests.auth_log_base.AuthLogTestBase):
                           msg["Authorization"]["serviceDescription"])
         self.assertEquals("ncalrpc", msg["Authorization"]["authType"])
         self.assertEquals("NONE", msg["Authorization"]["transportProtection"])
+        self.assertTrue(self.is_guid(msg["Authorization"]["sessionId"]))
 
     def test_netlogon_bad_machine_name(self):
         self._test_netlogon("bad_name",
@@ -172,7 +173,7 @@ class AuthLogTestsNetLogonBadCreds(samba.tests.auth_log_base.AuthLogTestBase):
                                        SEC_CHAN_WKSTA,
                                        self.netbios_name,
                                        creds,
-                                       0x00004000)
+                                       NETLOGON_NEG_STRONG_KEYS)
         except NTSTATUSError:
             pass
         self.waitForMessages(isLastExpectedMessage)