コード例 #1
0
        /// <summary>
        /// Send ValidateNegotiateInfoRequest to Server, fill in the fields according to params.
        /// Verify the response.
        /// </summary>
        public void ValidateNegotiateInfoRequest(DialectType dialectType,
                                                 CapabilitiesType capabilitiesType,
                                                 SecurityModeType securityModeType,
                                                 ClientGuidType clientGuidType)
        {
            Capabilities_Values capbilities = Connection_ClientCapabilities;

            if (capabilitiesType == CapabilitiesType.CapabilitiesDifferentFromNegotiate)
            {
                capbilities ^= Capabilities_Values.GLOBAL_CAP_DFS;
            }

            SecurityMode_Values securityMode = Connection_ClientSecurityMode;

            if (securityModeType == SecurityModeType.SecurityModeDifferentFromNegotiate)
            {
                securityMode ^= SecurityMode_Values.NEGOTIATE_SIGNING_ENABLED;
            }

            Guid guid = clientGuidType == ClientGuidType.ClientGuidSameWithNegotiate ? Connection_ClientGuid : Guid.NewGuid();

            DialectRevision[] dialects = null;
            if (DialectType.None != dialectType)
            {
                ModelDialectRevision dialect = Connection_Dialect;
                if (DialectType.DialectDifferentFromNegotiate == dialectType)
                {
                    dialect = ModelDialectRevision.Smb30 == Connection_Dialect ? ModelDialectRevision.Smb21 : ModelDialectRevision.Smb30;
                }
                dialects = Smb2Utility.GetDialects(ModelUtility.GetDialectRevision(dialect));
            }
            else
            {
                dialects = new DialectRevision[] { 0 }
            };

            VALIDATE_NEGOTIATE_INFO_Request validateNegotiateInfoRequest;

            validateNegotiateInfoRequest.Dialects     = dialects;
            validateNegotiateInfoRequest.DialectCount = (ushort)dialects.Length;
            validateNegotiateInfoRequest.Capabilities = capbilities;
            validateNegotiateInfoRequest.SecurityMode = securityMode;
            validateNegotiateInfoRequest.Guid         = guid;

            Site.Log.Add(
                LogEntryKind.Debug,
                "Dialects in ValidateNegotiateInfoRequest: {0}", Smb2Utility.GetArrayString(validateNegotiateInfoRequest.Dialects));
            Site.Log.Add(
                LogEntryKind.Debug,
                "DialectCount in ValidateNegotiateInfoRequest: {0}", validateNegotiateInfoRequest.DialectCount);
            Site.Log.Add(
                LogEntryKind.Debug,
                "Capabilities in ValidateNegotiateInfoRequest: {0}", validateNegotiateInfoRequest.Capabilities);
            Site.Log.Add(
                LogEntryKind.Debug,
                "SecurityMode in ValidateNegotiateInfoRequest: {0}", validateNegotiateInfoRequest.SecurityMode);
            Site.Log.Add(
                LogEntryKind.Debug,
                "Guid in ValidateNegotiateInfoRequest: {0}", validateNegotiateInfoRequest.Guid);

            byte[] inputBuffer = TypeMarshal.ToBytes <VALIDATE_NEGOTIATE_INFO_Request>(validateNegotiateInfoRequest);
            byte[] outputBuffer;
            try
            {
                uint status = testClient.ValidateNegotiateInfo(treeId, inputBuffer, out outputBuffer, checker: CheckIoCtlResponse);
                if (Smb2Status.STATUS_SUCCESS == status)
                {
                    VALIDATE_NEGOTIATE_INFO_Response validateNegotiateInfoResponse = TypeMarshal.ToStruct <VALIDATE_NEGOTIATE_INFO_Response>(outputBuffer);
                    Site.Assert.AreEqual(negotiateResponse.DialectRevision,
                                         validateNegotiateInfoResponse.Dialect,
                                         "Dialect in Negotiate response({0}) and ValidateNegotiateInfo response({1}) should be the same",
                                         negotiateResponse.DialectRevision.ToString(),
                                         validateNegotiateInfoResponse.Dialect.ToString());

                    Site.Assert.AreEqual((uint)negotiateResponse.Capabilities,
                                         (uint)validateNegotiateInfoResponse.Capabilities,
                                         "Capabilities in Negotiate response({0}) and ValidateNegotiateResponse({1}) should be the same",
                                         negotiateResponse.Capabilities.ToString(),
                                         validateNegotiateInfoResponse.Capabilities.ToString());

                    Site.Assert.AreEqual((ushort)negotiateResponse.SecurityMode,
                                         (ushort)validateNegotiateInfoResponse.SecurityMode,
                                         "SecurityMode in Negotiate response({0}) and ValidateNegotiateInfo response({1}) should be the same",
                                         negotiateResponse.SecurityMode.ToString(),
                                         validateNegotiateInfoResponse.SecurityMode.ToString());

                    Site.Assert.AreEqual(negotiateResponse.ServerGuid,
                                         validateNegotiateInfoResponse.Guid,
                                         "ClientGuid in Negotiate response({0}) and ValidateNegotiateInfo response({1}) should be the same",
                                         negotiateResponse.ServerGuid.ToString(),
                                         validateNegotiateInfoResponse.Guid.ToString());
                }

                testClient.TreeDisconnect(treeId);
                testClient.LogOff();
                testClient.Disconnect();
                this.ValidateNegotiateInfoResponse((ModelSmb2Status)status, validateNegotiateInfoConfig);
                return;
            }
            catch
            {
            }

            Site.Assert.IsTrue(testClient.Smb2Client.IsServerDisconnected, "ValidateNegotiationInfo failure should be caused by transport connection termination");
            TerminateConnection();
        }
        public static void ValidateNegotiateInfoRequest(DialectType dialectType,
            CapabilitiesType capabilitiesType,
            SecurityModeType securityModeType,
            ClientGuidType clientGuidType)
        {
            Condition.IsTrue(State == ModelState.Connected);

            // Those four parameters don’t need to be full-mesh.
            Combination.Isolated(DialectType.None == dialectType);
            Combination.Isolated(DialectType.DialectDifferentFromNegotiate == dialectType);
            Combination.Isolated(capabilitiesType == CapabilitiesType.CapabilitiesDifferentFromNegotiate);
            Combination.Isolated(securityModeType == SecurityModeType.SecurityModeDifferentFromNegotiate);
            Combination.Isolated(clientGuidType == ClientGuidType.ClientGuidDifferentFromNegotiate);

            if (DialectType.DialectSameWithNegotiate != dialectType)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.15.12: The server MUST determine the greatest common dialect between the dialects it implements and the Dialects array of the VALIDATE_NEGOTIATE_INFO request." +
                    " If no dialect is matched, or if the value is not equal to Connection.Dialect, the server MUST terminate the transport connection and free the Connection object");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "No dialect is matched between the dialects it implements and the Dialects array of the VALIDATE_NEGOTIATE_INFO request, or if the value is not equal to Connection.Dialect");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                IsSameWithNegotiate = false;
            }

            if (capabilitiesType == CapabilitiesType.CapabilitiesDifferentFromNegotiate)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.15.12: If Connection.ClientCapabilities is not equal to the Capabilities received in the VALIDATE_NEGOTIATE_INFO request structure, the server MUST terminate the transport connection and free the Connection object");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "Connection.ClientCapabilities is not equal to the Capabilities received in the VALIDATE_NEGOTIATE_INFO request");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                IsSameWithNegotiate = false;
            }

            if (securityModeType == SecurityModeType.SecurityModeDifferentFromNegotiate)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.15.12: If the SecurityMode received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to Connection.ClientSecurityMode, the server MUST terminate the transport connection and free the Connection object");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "SecurityMode received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to Connection.ClientSecurityMode");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                IsSameWithNegotiate = false;
            }

            if (clientGuidType == ClientGuidType.ClientGuidDifferentFromNegotiate)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.15.12: If the Guid received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to the Connection.ClientGuid, the server MUST terminate the transport connection and free the Connection object");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "Guid received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to the Connection.ClientGuid");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                IsSameWithNegotiate = false;
            }
        }
コード例 #3
0
        public static void ValidateNegotiateInfoRequest(DialectType dialectType,
                                                        CapabilitiesType capabilitiesType,
                                                        SecurityModeType securityModeType,
                                                        ClientGuidType clientGuidType)
        {
            Condition.IsTrue(State == ModelState.Connected);

            // Those four parameters don’t need to be full-mesh.
            Combination.Isolated(DialectType.None == dialectType);
            Combination.Isolated(DialectType.DialectDifferentFromNegotiate == dialectType);
            Combination.Isolated(capabilitiesType == CapabilitiesType.CapabilitiesDifferentFromNegotiate);
            Combination.Isolated(securityModeType == SecurityModeType.SecurityModeDifferentFromNegotiate);
            Combination.Isolated(clientGuidType == ClientGuidType.ClientGuidDifferentFromNegotiate);

            if (DialectType.DialectSameWithNegotiate != dialectType)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.15.12: The server MUST determine the greatest common dialect between the dialects it implements and the Dialects array of the VALIDATE_NEGOTIATE_INFO request." +
                    " If no dialect is matched, or if the value is not equal to Connection.Dialect, the server MUST terminate the transport connection and free the Connection object");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "No dialect is matched between the dialects it implements and the Dialects array of the VALIDATE_NEGOTIATE_INFO request, or if the value is not equal to Connection.Dialect");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                IsSameWithNegotiate = false;
            }

            if (capabilitiesType == CapabilitiesType.CapabilitiesDifferentFromNegotiate)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.15.12: If Connection.ClientCapabilities is not equal to the Capabilities received in the VALIDATE_NEGOTIATE_INFO request structure, the server MUST terminate the transport connection and free the Connection object");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "Connection.ClientCapabilities is not equal to the Capabilities received in the VALIDATE_NEGOTIATE_INFO request");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                IsSameWithNegotiate = false;
            }

            if (securityModeType == SecurityModeType.SecurityModeDifferentFromNegotiate)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.15.12: If the SecurityMode received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to Connection.ClientSecurityMode, the server MUST terminate the transport connection and free the Connection object");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "SecurityMode received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to Connection.ClientSecurityMode");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                IsSameWithNegotiate = false;
            }

            if (clientGuidType == ClientGuidType.ClientGuidDifferentFromNegotiate)
            {
                ModelHelper.Log(
                    LogType.Requirement,
                    "3.3.5.15.12: If the Guid received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to the Connection.ClientGuid, the server MUST terminate the transport connection and free the Connection object");
                ModelHelper.Log(
                    LogType.TestInfo,
                    "Guid received in the VALIDATE_NEGOTIATE_INFO request structure is not equal to the Connection.ClientGuid");
                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
                IsSameWithNegotiate = false;
            }
        }
        /// <summary>
        /// Send ValidateNegotiateInfoRequest to Server, fill in the fields according to params.
        /// Verify the response.
        /// </summary>
        public void ValidateNegotiateInfoRequest(DialectType dialectType,
            CapabilitiesType capabilitiesType,
            SecurityModeType securityModeType,
            ClientGuidType clientGuidType)
        {
            Capabilities_Values capbilities = Connection_ClientCapabilities;
            if (capabilitiesType == CapabilitiesType.CapabilitiesDifferentFromNegotiate)
                capbilities ^= Capabilities_Values.GLOBAL_CAP_DFS;

            SecurityMode_Values securityMode = Connection_ClientSecurityMode;
            if (securityModeType == SecurityModeType.SecurityModeDifferentFromNegotiate)
                securityMode ^= SecurityMode_Values.NEGOTIATE_SIGNING_ENABLED;

            Guid guid = clientGuidType == ClientGuidType.ClientGuidSameWithNegotiate ? Connection_ClientGuid : Guid.NewGuid();

            DialectRevision[] dialects = null;
            if (DialectType.None != dialectType)
            {
                ModelDialectRevision dialect = Connection_Dialect;
                if (DialectType.DialectDifferentFromNegotiate == dialectType)
                    dialect = ModelDialectRevision.Smb30 == Connection_Dialect ? ModelDialectRevision.Smb21 : ModelDialectRevision.Smb30;
                dialects = Smb2Utility.GetDialects(ModelUtility.GetDialectRevision(dialect));
            }
            else
                dialects = new DialectRevision[] { 0 };

            VALIDATE_NEGOTIATE_INFO_Request validateNegotiateInfoRequest;
            validateNegotiateInfoRequest.Dialects = dialects;
            validateNegotiateInfoRequest.DialectCount = (ushort)dialects.Length;
            validateNegotiateInfoRequest.Capabilities = capbilities;
            validateNegotiateInfoRequest.SecurityMode = securityMode;
            validateNegotiateInfoRequest.Guid = guid;

            Site.Log.Add(
                LogEntryKind.Debug,
                "Dialects in ValidateNegotiateInfoRequest: {0}", Smb2Utility.GetArrayString(validateNegotiateInfoRequest.Dialects));
            Site.Log.Add(
                LogEntryKind.Debug,
                "DialectCount in ValidateNegotiateInfoRequest: {0}", validateNegotiateInfoRequest.DialectCount);
            Site.Log.Add(
                LogEntryKind.Debug,
                "Capabilities in ValidateNegotiateInfoRequest: {0}", validateNegotiateInfoRequest.Capabilities);
            Site.Log.Add(
                LogEntryKind.Debug,
                "SecurityMode in ValidateNegotiateInfoRequest: {0}", validateNegotiateInfoRequest.SecurityMode);
            Site.Log.Add(
                LogEntryKind.Debug,
                "Guid in ValidateNegotiateInfoRequest: {0}", validateNegotiateInfoRequest.Guid);

            byte[] inputBuffer = TypeMarshal.ToBytes<VALIDATE_NEGOTIATE_INFO_Request>(validateNegotiateInfoRequest);
            byte[] outputBuffer;
            try
            {
                uint status = testClient.ValidateNegotiateInfo(treeId, inputBuffer, out outputBuffer, checker: CheckIoCtlResponse);
                if (Smb2Status.STATUS_SUCCESS == status)
                {
                    VALIDATE_NEGOTIATE_INFO_Response validateNegotiateInfoResponse = TypeMarshal.ToStruct<VALIDATE_NEGOTIATE_INFO_Response>(outputBuffer);
                    Site.Assert.AreEqual(negotiateResponse.DialectRevision,
                                         validateNegotiateInfoResponse.Dialect,
                                         "Dialect in Negotiate response({0}) and ValidateNegotiateInfo response({1}) should be the same",
                                         negotiateResponse.DialectRevision.ToString(),
                                         validateNegotiateInfoResponse.Dialect.ToString());

                    Site.Assert.AreEqual((uint)negotiateResponse.Capabilities,
                                         (uint)validateNegotiateInfoResponse.Capabilities,
                                         "Capabilities in Negotiate response({0}) and ValidateNegotiateResponse({1}) should be the same",
                                         negotiateResponse.Capabilities.ToString(),
                                         validateNegotiateInfoResponse.Capabilities.ToString());

                    Site.Assert.AreEqual((ushort)negotiateResponse.SecurityMode,
                                         (ushort)validateNegotiateInfoResponse.SecurityMode,
                                         "SecurityMode in Negotiate response({0}) and ValidateNegotiateInfo response({1}) should be the same",
                                         negotiateResponse.SecurityMode.ToString(),
                                         validateNegotiateInfoResponse.SecurityMode.ToString());

                    Site.Assert.AreEqual(negotiateResponse.ServerGuid,
                                         validateNegotiateInfoResponse.Guid,
                                         "ClientGuid in Negotiate response({0}) and ValidateNegotiateInfo response({1}) should be the same",
                                         negotiateResponse.ServerGuid.ToString(),
                                         validateNegotiateInfoResponse.Guid.ToString());
                }

                testClient.TreeDisconnect(treeId);
                testClient.LogOff();
                testClient.Disconnect();
                this.ValidateNegotiateInfoResponse((ModelSmb2Status)status, validateNegotiateInfoConfig);
                return;
            }
            catch
            {
            }

            Site.Assert.IsTrue(testClient.Smb2Client.IsServerDisconnected, "ValidateNegotiationInfo failure should be caused by transport connection termination");
            TerminateConnection();
        }