Esempio n. 1
0
        private static void RegisterHighlight(DialectType dialect, Byte[] ashx)
        {
            IHighlightingDefinition definition;

            using (Stream stream = new MemoryStream(ashx))
                using (XmlReader reader = XmlReader.Create(stream))
                    definition = HighlightingLoader.Load(reader, HighlightingManager.Instance);

            HighlightingManager.Instance.RegisterHighlighting(dialect.ToString(), new String[] { }, definition);
        }
        /// <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();
        }
Esempio n. 3
0
 public ServerViewModel(Server model) : base(null, model)
 {
     Dialect = model.Dialect;
 }
        public ShiftTableQueryFactory(DialectType dialectType = DialectType.MySQL)
            : base(dialectType)
        {
            this.ConfigureTable <ShiftProfileRecord>("ShiftProfile", cfg =>
            {
                cfg.Identifier = "p";
                cfg.AddColumn(c => c.IdShiftProfile, null, true, true);
                cfg.AddColumn(c => c.Name);
                cfg.AddColumn(c => c.CycleDays);
                cfg.AddColumn(c => c.Start);
                cfg.AddColumn(c => c.End);
                cfg.AddColumn(c => c.Enable);
                cfg.AddColumn(c => c.CreatedAt, p => { p.IgnoreInsert = true; p.IgnoreUpdate = true; });
            });

            this.ConfigureTable <CrewRecord>("Crew", cfg =>
            {
                cfg.Identifier = "c";
                cfg.AddColumn(c => c.IdCrew, null, true, true);
                cfg.AddColumn(c => c.IdShiftProfile);
                cfg.AddColumn(c => c.Name);
                cfg.AddColumn(c => c.Enable);
                cfg.AddColumn(c => c.CreatedAt, p => { p.IgnoreInsert = true; p.IgnoreUpdate = true; });
            });

            this.ConfigureTable <ShiftRecord>("Shift", cfg =>
            {
                cfg.Identifier = "s";
                cfg.AddColumn(c => c.IdShift, null, true, true);
                cfg.AddColumn(c => c.IdShiftProfile);
                cfg.AddColumn(c => c.Name);
                cfg.AddColumn(c => c.Start);
                cfg.AddColumn(c => c.End);
                cfg.AddColumn(c => c.Enable);
                cfg.AddColumn(c => c.CreatedAt, p => { p.IgnoreInsert = true; p.IgnoreUpdate = true; });
            });

            this.ConfigureTable <HolidayRecord>("Holiday", cfg =>
            {
                cfg.Identifier = "h";
                cfg.AddColumn(c => c.IdHoliday, null, true, true);
                cfg.AddColumn(c => c.IdShiftProfile);
                cfg.AddColumn(c => c.Name);
                cfg.AddColumn(c => c.Start);
                cfg.AddColumn(c => c.End);
                cfg.AddColumn(c => c.Enable);
                cfg.AddColumn(c => c.CreatedAt, p => { p.IgnoreInsert = true; p.IgnoreUpdate = true; });
            });

            this.ConfigureTable <ShiftHistoryRecord>("ShiftHistory", cfg =>
            {
                cfg.Identifier = "sh";
                cfg.AddColumn(c => c.IdShiftHistory, null, true, true);
                cfg.AddColumn(c => c.IdShiftProfile, p => { p.IgnoreUpdate = true; });
                cfg.AddColumn(c => c.IdShift, p => { p.IgnoreUpdate = true; });
                cfg.AddColumn(c => c.IdCrew, p => { p.IgnoreUpdate = true; });
                cfg.AddColumn(c => c.Start);
                cfg.AddColumn(c => c.End);
                cfg.AddColumn(c => c.CreatedAt, p => { p.IgnoreInsert = true; p.IgnoreUpdate = true; });
            });
        }
Esempio n. 5
0
 /// <summary>
 /// Creates an instance of the <see cref="Dialect"/>.
 /// </summary>
 protected Dialect(DialectType type)
 {
     Type = type;
 }
        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;
            }
        }
        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;
            }
        }
Esempio n. 8
0
 public Server(string name, DialectType dialect)
     : base(name)
 {
     Dialect = dialect;
 }
        /// <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();
        }