Beispiel #1
0
        public void TreeMgmt_SMB311_COMPRESS_DATA()
        {
            #region Check Applicability
            TestConfig.CheckDialect(DialectRevision.Smb311);
            TestConfig.CheckPlatform(Platform.WindowsServer2022);
            if (string.IsNullOrEmpty(testConfig.CompressedFileShare))
            {
                Assert.Inconclusive("This test requires a share with compression enabled");
            }
            #endregion

            var compressedSharePath = Smb2Utility.GetUncPath(testConfig.SutComputerName, testConfig.CompressedFileShare);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Start a client by sending the following requests: NEGOTIATE; SESSION_SETUP");

            client.Negotiate(TestConfig.RequestDialects, TestConfig.IsSMB1NegotiateEnabled);
            client.SessionSetup(TestConfig.DefaultSecurityPackage, TestConfig.SutComputerName, TestConfig.AccountCredential, false);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends TREE_CONNECT request and expects STATUS_SUCCESS with flag SMB2_SHAREFLAG_COMPRESS_DATA.");
            uint treeId;

            client.TreeConnect(compressedSharePath, out treeId,
                               (header, response) =>
            {
                BaseTestSite.Assert.AreEqual(
                    Smb2Status.STATUS_SUCCESS,
                    header.Status,
                    "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status));

                BaseTestSite.Assert.IsTrue(
                    response.ShareFlags.HasFlag(ShareFlags_Values.SHAREFLAG_COMPRESS_DATA),
                    "The share should support compress data, actually server returns {0}.", response.ShareFlags.ToString());
            });
            client.TreeDisconnect(treeId);
        }
Beispiel #2
0
        public void TreeMgmt_SMB311_TREE_CONNECT_EXTENSION_PRESENT()
        {
            #region Check Applicability
            TestConfig.CheckPlatform(Platform.WindowsServer2019);
            TestConfig.CheckDialect(DialectRevision.Smb311);
            #endregion

            Smb2FunctionalClient client = new Smb2FunctionalClient(TestConfig.Timeout, TestConfig, BaseTestSite);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Start a client by sending the following requests: CONNECT; NEGOTIATE; SESSION_SETUP");
            client.ConnectToServer(TestConfig.UnderlyingTransport, TestConfig.SutComputerName, TestConfig.SutIPAddress);
            client.Negotiate(TestConfig.RequestDialects, TestConfig.IsSMB1NegotiateEnabled);
            //Use domain credential to do session setup (e.g. contoso.com\administrator)
            client.SessionSetup(
                TestConfig.DefaultSecurityPackage,
                TestConfig.SutComputerName,
                TestConfig.AccountCredential,
                TestConfig.UseServerGssToken);

            string infraSharePath = string.Format(@"\\{0}\{1}", TestConfig.ClusteredInfrastructureFileServerName, TestConfig.InfrastructureRootShare);
            uint   treeId;

            string          domainName = TestConfig.DriverComputerName;
            string          userName   = TestConfig.UserName;
            string          password   = TestConfig.UserPassword;
            const int       LOGON32_PROVIDER_DEFAULT  = 0;
            const int       LOGON32_LOGON_INTERACTIVE = 2; //This parameter causes LogonUser to create a primary token.
            SafeTokenHandle safeTokenHandle;               // Call LogonUser to obtain a handle to an access token.
            bool            returnValue = LogonUser(userName, domainName, password,
                                                    LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,
                                                    out safeTokenHandle);
            if (false == returnValue)
            {
                int ret = Marshal.GetLastWin32Error();
                throw new System.ComponentModel.Win32Exception(ret);
            }
            using (safeTokenHandle)
            {
                using (WindowsIdentity identity = new WindowsIdentity(safeTokenHandle.DangerousGetHandle()))
                {
                    BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends TREE_CONNECT request with extension context and expects success");
                    //Use another local account(e.g. local\administrator) as an idenity passed in tree connect extension
                    client.TreeConnect(
                        infraSharePath,
                        out treeId,
                        (header, response) =>
                    {
                        BaseTestSite.Assert.AreEqual(
                            Smb2Status.STATUS_SUCCESS,
                            header.Status,
                            "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status));
                        BaseTestSite.Assert.IsTrue(
                            response.ShareFlags.HasFlag(ShareFlags_Values.SHAREFLAG_IDENTITY_REMOTING),
                            "The share should support identity remoting, actually server returns {0}.", response.ShareFlags.ToString());
                    },
                        TreeConnect_Flags.SMB2_SHAREFLAG_EXTENSION_PRESENT,
                        identity);

                    FILEID fileId;
                    Smb2CreateContextResponse[] serverCreateContexts;
                    BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client impersonates another log in user to send CREATE request and expects success.");
                    client.Create(
                        treeId,
                        GetTestFileName(infraSharePath),
                        CreateOptions_Values.FILE_DIRECTORY_FILE,
                        out fileId,
                        out serverCreateContexts,
                        checker: (header, response) =>
                    {
                        BaseTestSite.Assert.AreEqual(
                            Smb2Status.STATUS_SUCCESS,
                            header.Status,
                            "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status));
                    }
                        );

                    BaseTestSite.Log.Add(LogEntryKind.TestStep, "Tear down the client by sending the following requests: CLOSE; TREE_DISCONNECT; LOG_OFF");
                    client.Close(treeId, fileId);
                }
            }

            client.TreeDisconnect(treeId);
            client.LogOff();
        }
Beispiel #3
0
        public void TreeMgmt_SMB311_TREE_CONNECT_EXTENSION_PRESENT()
        {
            #region Check Applicability
            TestConfig.CheckPlatform(Platform.WindowsServer2019);
            TestConfig.CheckDialect(DialectRevision.Smb311);
            #endregion

            Smb2FunctionalClient client = new Smb2FunctionalClient(TestConfig.Timeout, TestConfig, BaseTestSite);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Start a client by sending the following requests: CONNECT; NEGOTIATE; SESSION_SETUP");
            client.ConnectToServer(TestConfig.UnderlyingTransport, TestConfig.SutComputerName, TestConfig.SutIPAddress);
            client.Negotiate(TestConfig.RequestDialects, TestConfig.IsSMB1NegotiateEnabled);
            //Use domain credential to do session setup (e.g. contoso.com\administrator)
            client.SessionSetup(
                TestConfig.DefaultSecurityPackage,
                TestConfig.SutComputerName,
                TestConfig.AccountCredential,
                TestConfig.UseServerGssToken);

            string infraSharePath = string.Format(@"\\{0}\{1}", TestConfig.ClusteredInfrastructureFileServerName, TestConfig.InfrastructureRootShare);
            uint   treeId;

            string           anotherUserName = TestConfig.NonAdminUserName;
            _WindowsIdentity identity        = sutCommonControlAdapterAccessor.GetWindowsIdentity(anotherUserName);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends TREE_CONNECT request with extension context and expects success");
            //Use another domain account(e.g. contoso\nonadmin) as an idenity passed in tree connect extension
            client.TreeConnect(
                infraSharePath,
                out treeId,
                (header, response) =>
            {
                BaseTestSite.Assert.AreEqual(
                    Smb2Status.STATUS_SUCCESS,
                    header.Status,
                    "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status));
                BaseTestSite.Assert.IsTrue(
                    response.ShareFlags.HasFlag(ShareFlags_Values.SHAREFLAG_IDENTITY_REMOTING),
                    "The share should support identity remoting, actually server returns {0}.", response.ShareFlags.ToString());
            },
                TreeConnect_Flags.SMB2_SHAREFLAG_EXTENSION_PRESENT,
                identity);

            FILEID fileId;
            Smb2CreateContextResponse[] serverCreateContexts;
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client impersonates another log in user to send CREATE request and expects success.");
            client.Create(
                treeId,
                GetTestFileName(infraSharePath),
                CreateOptions_Values.FILE_DIRECTORY_FILE,
                out fileId,
                out serverCreateContexts,
                checker: (header, response) =>
            {
                BaseTestSite.Assert.AreEqual(
                    Smb2Status.STATUS_SUCCESS,
                    header.Status,
                    "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status));
            }
                );

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Tear down the client by sending the following requests: CLOSE; TREE_DISCONNECT; LOG_OFF");
            client.Close(treeId, fileId);

            client.TreeDisconnect(treeId);
            client.LogOff();
        }
 public void BVT_Encryption_SMB311_AES_256_GCM()
 {
     TestConfig.CheckPlatform(Platform.WindowsServer2022);
     NegotiateWithEncryptionCapabilitiesContext(EncryptionAlgorithm.ENCRYPTION_AES256_GCM);
     PostNegotiateOperations(EnableEncryptionType.EnableEncryptionPerSession, connectEncryptedShare: true);
 }