tests: Relax auth_log SMB assertions to cover v1 *or* v2
authorTim Beale <timbeale@catalyst.net.nz>
Tue, 15 Jan 2019 22:18:27 +0000 (11:18 +1300)
committerJeremy Allison <jra@samba.org>
Thu, 17 Jan 2019 00:40:31 +0000 (01:40 +0100)
The s4 Python bindings currently only support SMBv1 connections.
If we change the bindings to support *either* v1 or v2, they'll
end up negotiating v2. In which case the server is "SMB2", not "SMB",
and these assertions fail.

Long-term we want to get rid of SMBv1, so it makes sense to write the
tests so that they pass against either v1 or v2.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
python/samba/tests/auth_log.py

index c0d0aab94aa6d8120abeca31c6bbeac6f876a4e5..29976aecbee8623cb4e665b6c31f7db86653daa2 100644 (file)
@@ -701,7 +701,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
     def test_smb(self):
         def isLastExpectedMessage(msg):
             return (msg["type"] == "Authorization" and
-                    msg["Authorization"]["serviceDescription"] == "SMB" and
+                    "SMB" in msg["Authorization"]["serviceDescription"] and
                     msg["Authorization"]["authType"] == "krb5" and
                     msg["Authorization"]["transportProtection"] == "SMB")
 
@@ -910,7 +910,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
     def test_smb_no_krb_spnego(self):
         def isLastExpectedMessage(msg):
             return (msg["type"] == "Authorization" and
-                    msg["Authorization"]["serviceDescription"] == "SMB" and
+                    "SMB" in msg["Authorization"]["serviceDescription"] and
                     msg["Authorization"]["authType"] == "NTLMSSP" and
                     msg["Authorization"]["transportProtection"] == "SMB")
 
@@ -929,8 +929,8 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
         msg = messages[0]
         self.assertEquals("Authentication", msg["type"])
         self.assertEquals("NT_STATUS_OK", msg["Authentication"]["status"])
-        self.assertEquals("SMB",
-                          msg["Authentication"]["serviceDescription"])
+        self.assertIn(msg["Authentication"]["serviceDescription"],
+                      ["SMB", "SMB2"])
         self.assertEquals("NTLMSSP",
                           msg["Authentication"]["authDescription"])
         self.assertEquals("NTLMv2",
@@ -943,7 +943,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
     def test_smb_no_krb_spnego_bad_password(self):
         def isLastExpectedMessage(msg):
             return (msg["type"] == "Authentication" and
-                    msg["Authentication"]["serviceDescription"] == "SMB" and
+                    "SMB" in msg["Authentication"]["serviceDescription"] and
                     msg["Authentication"]["authDescription"] == "NTLMSSP" and
                     msg["Authentication"]["passwordType"] == "NTLMv2" and
                     (msg["Authentication"]["status"] ==
@@ -975,7 +975,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
     def test_smb_no_krb_spnego_bad_user(self):
         def isLastExpectedMessage(msg):
             return (msg["type"] == "Authentication" and
-                    msg["Authentication"]["serviceDescription"] == "SMB" and
+                    "SMB" in msg["Authentication"]["serviceDescription"] and
                     msg["Authentication"]["authDescription"] == "NTLMSSP" and
                     msg["Authentication"]["passwordType"] == "NTLMv2" and
                     (msg["Authentication"]["status"] ==