예제 #1
0
        public void BVT_TreeMgmt_SMB311_Disconnect_NoSignedNoEncryptedTreeConnect()
        {
            #region Check Applicability
            TestConfig.CheckDialect(DialectRevision.Smb311);

            if (TestConfig.IsServerSigningRequired)
            {
                BaseTestSite.Assert.Inconclusive("Test case is only applicable when security signature is not required by the server " +
                                                 "because if signing or encryption is required in server, the server will fail the TreeConnect with STATUS_ACCESS_DENIED, which is not the purpose of this case.");
            }
            if (TestConfig.IsGlobalEncryptDataEnabled && TestConfig.IsGlobalRejectUnencryptedAccessEnabled)
            {
                BaseTestSite.Assert.Inconclusive("Test case is only applicable when encryption is not required by the server " +
                                                 "because if signing or encryption is required in server, the server will fail the TreeConnect with STATUS_ACCESS_DENIED, which is not the purpose of this case.");
            }
            #endregion

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends NEGOTIATE request without NEGOTIATE_SIGNING_REQUIRED and GLOBAL_CAP_ENCRYPTION set.");

            client.Negotiate(
                TestConfig.RequestDialects,
                TestConfig.IsSMB1NegotiateEnabled,
                SecurityMode_Values.NONE,
                Capabilities_Values.NONE);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends SESSION_SETUP request without NEGOTIATE_SIGNING_REQUIRED flag set.");
            client.SessionSetup(
                TestConfig.DefaultSecurityPackage,
                TestConfig.SutComputerName,
                TestConfig.AccountCredential,
                TestConfig.UseServerGssToken,
                SESSION_SETUP_Request_SecurityMode_Values.NONE);

            string uncSharepath = Smb2Utility.GetUncPath(TestConfig.SutComputerName, TestConfig.BasicFileShare);
            uint   treeId;
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends TREE_CONNECT request which is not signed or not encrypted and expects server disconnects the connection.");

            try
            {
                client.EnableSessionSigningAndEncryption(enableSigning: false, enableEncryption: false);
                // Trigger Server Disconnect event
                client.TreeConnect(
                    Packet_Header_Flags_Values.NONE,
                    uncSharepath,
                    out treeId,
                    checker: (Packet_Header header, TREE_CONNECT_Response response) =>
                {
                    BaseTestSite.Assert.AreNotEqual(
                        Smb2Status.STATUS_SUCCESS,
                        header.Status,
                        "TREE_CONNECT should NOT succeed.");
                });

                // Check if server is still responding
                client.Echo(treeId);
            }
            catch
            {
            }

            // Check if server is disconnected
            BaseTestSite.Assert.IsTrue(client.Smb2Client.IsServerDisconnected,
                                       "[MS-SMB2] 3.3.5.7 If Connection.Dialect is \"3.1.1\" and Session.IsAnonymous and Session.IsGuest are set to FALSE" +
                                       " and the request is not signed or not encrypted, then the server MUST disconnect the connection. " +
                                       "Server did {0}disconnect the connection.", client.Smb2Client.IsServerDisconnected ? "" : "not ");
        }