public static void CreateRequest(ConnectTargetType connectTargetType, LeaseContextType leaseContextType, LeaseKeyType leaseKey, uint leaseState, LeaseFlagsValues leaseFlags, ParentLeaseKeyType parentLeaseKey) { Condition.IsTrue(state == ModelState.Connected); Condition.IsNull(request); // Limit these three less important paramters to reduce test case numbers. Combination.NWise(1, connectTargetType, leaseKey, leaseState); // Current leasing only supports to test leasing on the file. So limit the exploration. Condition.In(parentLeaseKey, ParentLeaseKeyType.EmptyParentLeaseKey, ParentLeaseKeyType.ValidParentLeaseKey); Combination.Pairwise(leaseFlags, parentLeaseKey); // If Conenction.Dialect is Smb2.002 or Smb2.1, then do not test Lease V2. Condition.IfThen( negotiateDialect == DialectRevision.Smb21 || negotiateDialect == DialectRevision.Smb2002, leaseContextType == LeaseContextType.LeaseV1); if (leaseContextType == LeaseContextType.LeaseV1) { request = new ModelCreateLeaseRequest( (connectTargetType == ConnectTargetType.ConnectToDirectory) ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE, RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE, new ModelCreateRequestLease { LeaseKey = leaseKey, LeaseState = leaseState, LeaseFlags = leaseFlags }, leaseContextType); } else { request = new ModelCreateLeaseRequest( (connectTargetType == ConnectTargetType.ConnectToDirectory) ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE, RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE, new ModelCreateRequestLeaseV2 { LeaseKey = leaseKey, LeaseState = leaseState, LeaseFlags = leaseFlags, ParentLeaseKey = parentLeaseKey }, leaseContextType); } }
public static void SessionSetupRequest( SigningFlagType signingFlagType, SigningEnabledType signingEnabledType, SigningRequiredType signingRequiredType, UserType userType) { Condition.IsTrue(State == ModelState.Connected); // Add isolate for SigningFlagType to reduce redundant cases: If the signingFlagType is set to SignedFlagSet, server will always return // error code STATUS_USER_SESSION_DELETED while verifying signature, we don't need to cover all the invalid combination with other params. Combination.Isolated(signingFlagType == SigningFlagType.SignedFlagSet); ModelHelper.Log(LogType.Requirement, "3.3.5.5.1: The other values MUST be initialized as follows:"); ModelHelper.Log(LogType.Requirement, "\tSession.SigningRequired is set to FALSE."); Session_SigningRequired = false; Request = new SigningModelRequest(signingFlagType); }
public static void ReadConfigReturn(CreditMgmtConfig c) { Condition.IsTrue(state == ModelState.Uninitialized); Condition.IsNotNull(c); Condition.IsTrue( c.MaxSmbVersionSupported == ModelDialectRevision.Smb2002 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb21 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb30 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb302); negotiateDialect = DialectRevision.Smb2Unknown; config = c; request = null; state = ModelState.Initialized; acceptingCondition = false; }
public static void ReadConfigReturn(SigningConfig c) { Condition.IsTrue(State == ModelState.Uninitialized); Condition.IsNotNull(c); NegotiateDialect = DialectRevision.Smb2Unknown; Condition.IsTrue(c.MaxSmbVersionSupported == ModelDialectRevision.Smb2002 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb21 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb30 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb302); Config = c; Request = null; State = ModelState.Initialized; }
public static void ReadConfigReturn(EncryptionConfig c) { Condition.IsTrue(state == ModelState.Uninitialized); Condition.IsNotNull(c); negotiateDialect = DialectRevision.Smb2Unknown; // Force SE to expand Config.MaxSmbVersionServerSupported Condition.IsTrue(c.MaxSmbVersionSupported == ModelDialectRevision.Smb2002 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb21 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb30 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb302 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb311); config = c; request = null; state = ModelState.Initialized; }
public static void OplockBreakAcknowledgementRequest(OplockVolatilePortion volatilePortion, OplockPersistentPortion persistentPortion, OplockLevel_Values oplockLevel) { Combination.Isolated(volatilePortion == OplockVolatilePortion.VolatilePortionNotFound); Combination.Isolated(persistentPortion == OplockPersistentPortion.PersistentNotMatchesDurableFileId); // Isolate the values that are not allowed Combination.Isolated(oplockLevel == OplockLevel_Values.OPLOCK_LEVEL_BATCH); Combination.Isolated(oplockLevel == OplockLevel_Values.OPLOCK_LEVEL_EXCLUSIVE); Combination.Isolated(oplockLevel == OplockLevel_Values.OPLOCK_LEVEL_LEASE); Condition.IsTrue(State == ModelState.Connected); Condition.IsNull(Request); bool volatilePortionFound = volatilePortion == OplockVolatilePortion.VolatilePortionFound; bool persistentMatchesDurableFileId = persistentPortion == OplockPersistentPortion.PersistentMatchesDurableFileId; Request = new ModelOplockBreakAcknowledgementRequest(volatilePortionFound, persistentMatchesDurableFileId, oplockLevel); }
public static void NegotiateRequest( ModelDialectRevision maxSmbVersionClientSupported, SigningFlagType signingFlagType, SigningEnabledType signingEnabledType, SigningRequiredType signingRequiredType) { Condition.IsTrue(State == ModelState.Initialized); Condition.IsNull(Request); // Add isolate for SigningFlagType to reduce redundant cases: If the signingFlagType is set to SignedFlagSet, server will always return error // code STATUS_INVALID_PARAMETER, we don't need to cover all the invalid combination with other params. Combination.Isolated(signingFlagType == SigningFlagType.SignedFlagSet); NegotiateDialect = ModelHelper.DetermineNegotiateDialect(maxSmbVersionClientSupported, Config.MaxSmbVersionSupported); Request = new SigningModelRequest(signingFlagType, signingEnabledType, signingRequiredType); State = ModelState.Connected; }
public static void FileOperationToBreakLeaseRequestCall(FileOperation operation, OperatorType operatorType, ModelDialectRevision dialect) { Condition.IsTrue(state == ModelState.Connected); Condition.IsNull(request); Condition.IsNotNull(smb2Lease); Condition.IsFalse(smb2Lease.Breaking); Condition.IsFalse(smb2Lease.LeaseState == (uint)LeaseStateValues.SMB2_LEASE_NONE); Condition.IsTrue(dialect <= config.MaxSmbVersionSupported); if (operatorType == OperatorType.SameClientId || operatorType == OperatorType.SameClientGuidDifferentLeaseKey) { switch (negotiateDialect) { case DialectRevision.Smb2002: Condition.IsTrue(dialect == ModelDialectRevision.Smb2002); break; case DialectRevision.Smb21: Condition.IsTrue(dialect == ModelDialectRevision.Smb21); break; case DialectRevision.Smb30: Condition.IsTrue(dialect == ModelDialectRevision.Smb30); break; case DialectRevision.Smb302: Condition.IsTrue(dialect == ModelDialectRevision.Smb302); break; default: Condition.Fail(); break; } } else { // Limit the dialect which is used by second client for se exploration. Condition.IsTrue(dialect == ModelDialectRevision.Smb2002); } request = new ModelFileOperationRequest(operation, operatorType, dialect); }
public static void CreateRequest( CreateFileNameType fileNameType, CreateOptionsFileOpenReparsePointType fileOpenReparsePointType, CreateOptionsFileDeleteOnCloseType fileDeleteOnCloseType, CreateContextType contextType, ImpersonationLevelType impersonationType, CreateFileType fileType) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNull(Request); Combination.Isolated(fileNameType == CreateFileNameType.StartWithPathSeparator); Combination.Isolated(fileNameType == CreateFileNameType.OtherInvalidFileName); // Reduce expanded cases Combination.Pairwise(fileNameType, fileOpenReparsePointType, fileDeleteOnCloseType, contextType, impersonationType, fileType); Combination.Isolated(contextType == CreateContextType.InvalidCreateContext); Combination.Isolated(contextType == CreateContextType.InvalidCreateContextSize); Combination.Isolated(impersonationType == ImpersonationLevelType.InvalidImpersonationLevel); Request = new ModelCreateRequest(fileNameType, fileOpenReparsePointType, fileDeleteOnCloseType, contextType, impersonationType); }
public static void ReEstablishResilientOpenRequest(ModelUser user) { Condition.IsTrue(Request == null); /// restrict parameter combination Condition.IfThen(Open == null, user == ModelUser.DefaultUser); Request = new ModelReEstablishResilientOpenRequest(user); }
public static void TreeConnectRequest(ConnectToShareType connectToShareType, ModelRequestType modelRequestType) { Condition.IsTrue(state == ModelState.Connected); Condition.IsNull(request); request = new ModelTreeConnectRequest(connectToShareType, modelRequestType); }
public static void TreeConnectRequest(SigningFlagType signingFlagType) { Condition.IsTrue(State == ModelState.Connected); Request = new SigningModelRequest(signingFlagType); }
public static void SetupConnection() { Condition.IsTrue(State == ModelState.Initialized); Request = null; ModelHelper.Log( LogType.Requirement, "3.3.5.1: Connection.CommandSequenceWindow is set to a sequence window, as specified in section 3.3.1.1, with a starting receive sequence of 0 and a window size of 1"); MessageId = 0; ModelHelper.Log( LogType.TestInfo, "Connection.CommandSequenceWindow to receive sequence of 0."); ModelHelper.Log( LogType.Requirement, "Connection.NegotiateDialect is set to 0xFFFF"); NegotiateDialect = DialectRevision.Smb2Unknown; ModelHelper.Log( LogType.TestInfo, "Connection.NegotiateDialect is set to {0}", NegotiateDialect); State = ModelState.Connected; }
public static void NegotiateRequest(Sequence<DialectRevision> dialects) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNull(Request); Request = new NegotiateRequest(dialects); if (NegotiateDialect == DialectRevision.Smb2002 || NegotiateDialect == DialectRevision.Smb21 || NegotiateDialect == DialectRevision.Smb30 || NegotiateDialect == DialectRevision.Smb302) { ModelHelper.Log( LogType.Requirement, "3.3.5.4: If Connection.NegotiateDialect is 0x0202, 0x0210, 0x0300, or 0x0302 the server MUST disconnect the connection, as specified in section 3.3.7.1, and not reply."); ModelHelper.Log( LogType.TestInfo, "Connection.NegotiateDialect is {0}", NegotiateDialect); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); State = ModelState.Disconnected; return; } // After every successful call, messageId MUST be incremented by 1. // But in this model it is set to 1 to avoid to generate duplicate cases which only have different messageId. MessageId = 1; }
public static void ComNegotiateRequest(Sequence<string> dialects) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNull(Request); Request = new ModelComNegotiateRequest(dialects); if (MessageId > 0) { // Negotiate request is always expected to be the first message in a connection State = ModelState.Disconnected; return; } ModelHelper.Log( LogType.Requirement, "3.3.5.3: This request is defined in [MS-SMB] section 2.2.4.5.1, with the SMB header defined in section 2.2.3.1." + " If the request matches the format described there, and Connection.NegotiateDialect is 0xFFFF, processing MUST continue as specified in 3.3.5.3.1."); if (NegotiateDialect != DialectRevision.Smb2Unknown) //|| (!dialects.Contains(SMBDialects.SMB_2_002) && !dialects.Contains(SMBDialects.SMB_2_X))) // TODO: more comments? { ModelHelper.Log( LogType.Requirement, "3.3.5.3: Otherwise, the server MUST disconnect the connection, as specified in section 3.3.7.1, without sending a response."); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); State = ModelState.Disconnected; return; } if (!(Config.MaxSmbVersionSupported == DialectRevision.Smb21 || ModelUtility.IsSmb3xFamily(Config.MaxSmbVersionSupported))) { ModelHelper.Log( LogType.Requirement, "3.3.5.3.1: If the server does not implement the SMB 2.1 or 3.x dialect family, processing MUST continue as specified in 3.3.5.3.2."); ComNegotiateHandleSmb2002InRequest(dialects); } else { ModelHelper.Log( LogType.Requirement, "3.3.5.3.1: Otherwise, the server MUST scan the dialects provided for the dialect string \"SMB 2.???\"."); if (!dialects.Contains(SMBDialects.SMB_2_X)) { ModelHelper.Log( LogType.Requirement, "3.3.5.3.1: If the string is not present, continue to section 3.3.5.3.2."); ComNegotiateHandleSmb2002InRequest(dialects); } else { ModelHelper.Log( LogType.Requirement, "3.3.5.3.1: If the string is present, the server MUST respond with an SMB2 NEGOTIATE Response as specified in 2.2.4"); ModelHelper.Log( LogType.TestInfo, "\"SMB 2.???\" is present in the dialects provided"); } } // After every successful call, messageId MUST be incremented by 1. // But in this model it is set to 1 to avoid to generate duplicate cases which only have different messageId. MessageId = 1; }
public static void RequestOplockAndOperateFileCall(RequestedOplockLevel_Values requestedOplockLevel, OplockFileOperation fileOperation) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNull(Request); // <46> Section 2.2.14: Windows-based clients never use exclusive oplocks. Because there are no situations where it would // require an exclusive oplock where it would not also require an SMB2_OPLOCK_LEVEL_BATCH, it always requests an SMB2_OPLOCK_LEVEL_BATCH. Condition.IsTrue(requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE && requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE && requestedOplockLevel != RequestedOplockLevel_Values.OPLOCK_LEVEL_EXCLUSIVE); Request = new ModelRequestOplockAndTriggerBreakRequest(requestedOplockLevel); }
public static void SetupConnection(ModelDialectRevision maxSmbVersionClientSupported, ClientSupportDirectoryLeasingType clientSupportDirectoryLeasingType) { Condition.IsTrue(state == ModelState.Initialized); // Current leasing only supports to test leasing on the file. So limit the exploration. Condition.IsTrue(clientSupportDirectoryLeasingType == ClientSupportDirectoryLeasingType.ClientNotSupportDirectoryLeasing); request = null; negotiateDialect = DialectRevision.Smb2Unknown; smb2Lease = null; negotiateDialect = ModelHelper.DetermineNegotiateDialect(maxSmbVersionClientSupported, config.MaxSmbVersionSupported); state = ModelState.Connected; }
public static void TreeConnectRequest(ModelSharePath sharePath) { Condition.IsTrue(State == ModelState.Connected); Condition.IsFalse(Session_TreeConnectExist); Condition.IsNull(Request); // If Security Context is Non Admin, InvalidPath is not used. Condition.IfThen( Session_SecurityContext == ModelSessionSecurityContext.NonAdmin, sharePath != ModelSharePath.InvalidSharePath); Request = new ModelTreeMgmtTreeConnectRequest(sharePath); }
public static void ReadConfigReturn(EncryptionConfig c) { Condition.IsTrue(state == ModelState.Uninitialized); Condition.IsNotNull(c); negotiateDialect = DialectRevision.Smb2Unknown; // Force SE to expand Config.MaxSmbVersionServerSupported Condition.IsTrue(c.MaxSmbVersionSupported == ModelDialectRevision.Smb2002 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb21 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb30 || c.MaxSmbVersionSupported == ModelDialectRevision.Smb302); config = c; request = null; state = ModelState.Initialized; }
public static void LeaseBreakAcknowledgmentRequest(ModelLeaseKeyType modelLeaseKeyType, uint leaseState) { Condition.IsTrue(state == ModelState.Connected); Condition.IsNull(request); Condition.In<uint>(leaseState, 0, 1, 3, 5, 7); request = new ModelLeaseBreakAckRequest(modelLeaseKeyType, leaseState); }
public static void FileOperationVerifyEncryptionRequest(ModelRequestType modelRequestType) { Condition.IsTrue(state == ModelState.Connected); Condition.IsNull(request); request = new ModelFileOperationVerifyEncryptionRequest(modelRequestType); }
public static void CreditOperationRequest( ModelMidType midType, ModelCreditCharge creditCharge, ModelCreditRequestNum creditRequestNum, ModelPayloadSize payloadSize, ModelPayloadType payloadType) { Condition.IsTrue(state == ModelState.Connected); Condition.IsNull(request); Combination.Isolated(midType == ModelMidType.UsedMid); Combination.Isolated(midType == ModelMidType.UnavailableMid); Combination.Isolated(creditCharge == ModelCreditCharge.CreditChargeExceedBoundary); Combination.Isolated(payloadSize == ModelPayloadSize.PayloadSizeLargerThanBoundary); //Pairwise the rest parameters Combination.NWise(2, creditCharge, creditRequestNum, payloadSize, payloadType); request = new ModelCreditOperationRequest( midType, creditCharge, creditRequestNum, payloadSize, payloadType); // NOTE: creditCharge will be ignored if multicredit is not supported if (midType == ModelMidType.UsedMid || midType == ModelMidType.UnavailableMid || (isMultiCreditSupported && creditCharge == ModelCreditCharge.CreditChargeExceedBoundary)) { ModelHelper.Log( LogType.Requirement, "3.3.5.2.3: If the server determines that the MessageId or the range of MessageIds for the incoming request is not valid," + " the server SHOULD<202> terminate the connection. Otherwise, the server MUST remove the MessageId or the range of MessageIds from the Connection.CommandSequenceWindow."); //Not add Platform!=NonWindows because NonWindows could also drop connection if (midType == ModelMidType.UsedMid || midType == ModelMidType.UnavailableMid) { ModelHelper.Log(LogType.TestTag, TestTag.InvalidIdentifier); } if (isMultiCreditSupported && creditCharge == ModelCreditCharge.CreditChargeExceedBoundary) { ModelHelper.Log(LogType.TestTag, TestTag.OutOfBoundary); } expectDisconnection = true; ModelHelper.Log( LogType.TestInfo, "Test case is expecting server disconnect the connection"); ModelHelper.Log( LogType.TestInfo, "Connection.SupportsMultiCredit is set to {0}, messageId type is {1}, creditCharge type is {2}", isMultiCreditSupported, midType, creditCharge); return; } if (!isMultiCreditSupported && payloadSize == ModelPayloadSize.PayloadSizeLargerThanBoundary) { ModelHelper.Log( LogType.Requirement, "3.3.5.2: If Connection.SupportsMultiCredit is FALSE and the size of the request is greater than 68*1024 bytes," + " the server SHOULD<200> terminate the connection"); //Ignore following product behavior as known issue for now ModelHelper.Log( LogType.Requirement, "<200> Section 3.3.5.2: Windows 7 without [MSKB-2536275], and Windows Server 2008 R2 without [MSKB-2536275] terminate the connection when the size of the request is greater than 64*1024 bytes." + " Windows Vista SP1 and Windows Server 2008 on Direct TCP transport disconnect the connection if the size of the message exceeds 128*1024 bytes, and Windows Vista SP1 and Windows Server 2008 on NetBIOS over TCP transport will disconnect the connection if the size of the message exceeds 64*1024 bytes"); ModelHelper.Log(LogType.TestTag, TestTag.OutOfBoundary); expectDisconnection = true; ModelHelper.Log( LogType.TestInfo, "Test case is expecting server to drop the connection"); ModelHelper.Log( LogType.TestInfo, "Connection.SupportsMultiCredit is set to {0}, messageId type is {1}, creditCharge type is {2}", isMultiCreditSupported, midType, creditCharge); } }
public static void IoCtlResiliencyRequest( IoCtlInputCount inputCount, ResilientTimeout timeout) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNotNull(Open); Condition.IsNull(Request); Request = new ModelResiliencyRequest(inputCount, timeout); }
public static void SetupConnection(ModelDialectRevision maxSmbVersionClientSupported, ModelShareFlag shareFlag, ModelShareType shareType) { Condition.IsTrue(State == ModelState.Initialized); Open = null; Request = null; Connection_Dialect = DialectRevision.Smb2Unknown; Connection_Dialect = ModelHelper.DetermineNegotiateDialect(maxSmbVersionClientSupported, Config.MaxSmbVersionSupported); Share_ForceLevel2Oplock = shareFlag == ModelShareFlag.SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK; Share_Type_Include_STYPE_CLUSTER_SOFS = shareType == ModelShareType.STYPE_CLUSTER_SOFS; State = ModelState.Connected; }
public static void ComNegotiateRequest(Sequence <string> dialects) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNull(Request); Request = new ModelComNegotiateRequest(dialects); if (MessageId > 0) { // Negotiate request is always expected to be the first message in a connection State = ModelState.Disconnected; return; } ModelHelper.Log( LogType.Requirement, "3.3.5.3: This request is defined in [MS-SMB] section 2.2.4.5.1, with the SMB header defined in section 2.2.3.1." + " If the request matches the format described there, and Connection.NegotiateDialect is 0xFFFF, processing MUST continue as specified in 3.3.5.3.1."); if (NegotiateDialect != DialectRevision.Smb2Unknown) //|| (!dialects.Contains(SMBDialects.SMB_2_002) && !dialects.Contains(SMBDialects.SMB_2_X))) // TODO: more comments? { ModelHelper.Log( LogType.Requirement, "3.3.5.3: Otherwise, the server MUST disconnect the connection, as specified in section 3.3.7.1, without sending a response."); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); State = ModelState.Disconnected; return; } if (!(Config.MaxSmbVersionSupported == DialectRevision.Smb21 || ModelUtility.IsSmb3xFamily(Config.MaxSmbVersionSupported))) { ModelHelper.Log( LogType.Requirement, "3.3.5.3.1: If the server does not implement the SMB 2.1 or 3.x dialect family, processing MUST continue as specified in 3.3.5.3.2."); ComNegotiateHandleSmb2002InRequest(dialects); } else { ModelHelper.Log( LogType.Requirement, "3.3.5.3.1: Otherwise, the server MUST scan the dialects provided for the dialect string \"SMB 2.???\"."); if (!dialects.Contains(SMBDialects.SMB_2_X)) { ModelHelper.Log( LogType.Requirement, "3.3.5.3.1: If the string is not present, continue to section 3.3.5.3.2."); ComNegotiateHandleSmb2002InRequest(dialects); } else { ModelHelper.Log( LogType.Requirement, "3.3.5.3.1: If the string is present, the server MUST respond with an SMB2 NEGOTIATE Response as specified in 2.2.4"); ModelHelper.Log( LogType.TestInfo, "\"SMB 2.???\" is present in the dialects provided"); } } // After every successful call, messageId MUST be incremented by 1. // But in this model it is set to 1 to avoid to generate duplicate cases which only have different messageId. MessageId = 1; }
public static void TreeDisconnectRequest(ModelTreeId treeId) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNull(Request); // If Security Context is Non Admin or no TreeConnect exists, only ValidTreeId. Condition.IfThen( !Session_TreeConnectExist || Session_SecurityContext == ModelSessionSecurityContext.NonAdmin, treeId == ModelTreeId.ValidExistTreeId || treeId == ModelTreeId.InvalidTreeId); Request = new ModelTreeMgmtTreeDisconnectRequest(treeId); }