python/tests: test SMB1 and SMB2/3 in auth_log.py
authorStefan Metzmacher <metze@samba.org>
Tue, 20 Jun 2017 06:26:45 +0000 (08:26 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 22 Jun 2017 11:07:39 +0000 (13:07 +0200)
We should do this explicitly in order to make
the tests independent of 'client max protocol'.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
python/samba/tests/auth_log.py

index ff84befda4567a7ad2eb694e403ff14747599192..65800c991816b7f9765009ffd8ff4bc688c9fc5d 100644 (file)
@@ -700,7 +700,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
                           len(messages),
                           "Did not receive the expected number of messages")
 
-    def test_smb_anonymous(self):
+    def test_smb1_anonymous(self):
         def isLastExpectedMessage(msg):
             return (msg["type"] == "Authorization" and
                     msg["Authorization"]["serviceDescription"] == "SMB" and
@@ -712,7 +712,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
 
         path = "//%s/IPC$" % server
         auth = "-N"
-        call(["bin/smbclient", path, auth, "-c quit"])
+        call(["bin/smbclient", path, auth, "-mNT1", "-c quit"])
 
         messages = self.waitForMessages(isLastExpectedMessage)
         self.assertEquals(3,
@@ -745,6 +745,51 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
         self.assertEquals("ANONYMOUS LOGON",
                           msg["Authentication"]["becameAccount"])
 
+    def test_smb2_anonymous(self):
+        def isLastExpectedMessage(msg):
+            return (msg["type"] == "Authorization" and
+                    msg["Authorization"]["serviceDescription"] == "SMB2" and
+                    msg["Authorization"]["authType"] == "NTLMSSP" and
+                    msg["Authorization"]["account"] == "ANONYMOUS LOGON" and
+                    msg["Authorization"]["transportProtection"] == "SMB")
+
+        server   = os.environ["SERVER"]
+
+        path = "//%s/IPC$" % server
+        auth = "-N"
+        call(["bin/smbclient", path, auth, "-mSMB3", "-c quit"])
+
+        messages = self.waitForMessages(isLastExpectedMessage)
+        self.assertEquals(3,
+                          len(messages),
+                          "Did not receive the expected number of messages")
+
+        # Check the first message it should be an Authentication
+        msg = messages[0]
+        self.assertEquals("Authentication", msg["type"])
+        self.assertEquals("NT_STATUS_NO_SUCH_USER",
+                          msg["Authentication"]["status"])
+        self.assertEquals("SMB2",
+                          msg["Authentication"]["serviceDescription"])
+        self.assertEquals("NTLMSSP",
+                          msg["Authentication"]["authDescription"])
+        self.assertEquals("No-Password",
+                          msg["Authentication"]["passwordType"])
+
+        # Check the second message it should be an Authentication
+        msg = messages[1]
+        self.assertEquals("Authentication", msg["type"])
+        self.assertEquals("NT_STATUS_OK",
+                          msg["Authentication"]["status"])
+        self.assertEquals("SMB2",
+                          msg["Authentication"]["serviceDescription"])
+        self.assertEquals("NTLMSSP",
+                          msg["Authentication"]["authDescription"])
+        self.assertEquals("No-Password",
+                          msg["Authentication"]["passwordType"])
+        self.assertEquals("ANONYMOUS LOGON",
+                          msg["Authentication"]["becameAccount"])
+
     def test_smb_no_krb_spnego(self):
         def isLastExpectedMessage(msg):
             return (msg["type"] == "Authorization" and