public static void OpenRequest( ClientGuidType clientGuidType, PathNameType pathNameType, CreateType createType, ShareType shareType, AppInstanceIdType appInstanceIdType) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNotNull(Open); // Isolate below params to limite the expanded test cases. Combination.Isolated(clientGuidType == ClientGuidType.SameClientGuid); Combination.Isolated(pathNameType == PathNameType.DifferentPathName); Combination.Isolated(shareType == ShareType.DifferentShareDifferentLocal); Combination.Isolated(shareType == ShareType.DifferentShareSameLocal); Combination.Isolated(appInstanceIdType == AppInstanceIdType.InvalidAppInstanceId); Combination.Isolated(appInstanceIdType == AppInstanceIdType.NoAppInstanceId); // "AppInstanceId is zero" is only applicable for the first Create Request. // For the second Create Request, only valid/notvalid/none make sense. Condition.IsFalse(appInstanceIdType == AppInstanceIdType.AppInstanceIdIsZero); // CreateDurableThenDisconnect is only applicable for the first Create Request. Condition.IsFalse(createType == CreateType.CreateDurableThenDisconnect); // If the client doesn't disconnect from the server after sending the first Create Request, // then the second Create Request does not need to contain reconnect context. // And vice versa. Condition.IfThen(Open.CreateTypeWhenPrepare != CreateType.CreateDurableThenDisconnect, createType != CreateType.ReconnectDurable); Condition.IfThen(Open.CreateTypeWhenPrepare == CreateType.CreateDurableThenDisconnect, createType == CreateType.ReconnectDurable); if (createType == CreateType.ReconnectDurable) { ModelHelper.Log(LogType.Requirement, "3.3.5.9.13: If the create request also includes the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context, " + "the server MUST process the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context as specified in section 3.3.5.9.12, " + "and this section MUST be skipped."); ModelHelper.Log(LogType.TestInfo, "SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context is included."); return; } if (!ModelUtility.IsSmb3xFamily(MaxSmbVersionSupported)) { ModelHelper.Log(LogType.Requirement, "2.2.13.2.13: The SMB2_CREATE_APP_INSTANCE_ID context is valid only for the SMB 3.x dialect family."); ModelHelper.Log(LogType.TestInfo, "The dialect version of the server is {0}.", MaxSmbVersionSupported); return; } if (appInstanceIdType == AppInstanceIdType.ValidAppInstanceId && Open.AppInstanceId != AppInstanceIdType.NoAppInstanceId && pathNameType == PathNameType.SamePathName && shareType == ShareType.SameShare && clientGuidType == ClientGuidType.DifferentClientGuid) { ModelHelper.Log(LogType.Requirement, "3.3.5.9.13: The server MUST attempt to locate an Open in GlobalOpenTable where:"); ModelHelper.Log(LogType.Requirement, "\tAppInstanceId in the request is equal to Open.AppInstanceId."); ModelHelper.Log(LogType.Requirement, "\tTarget path name is equal to Open.PathName."); ModelHelper.Log(LogType.Requirement, "\tOpen.TreeConnect.Share is equal to TreeConnect.Share."); ModelHelper.Log(LogType.Requirement, "\tOpen.Session.Connection.ClientGuid is not equal to the current Connection.ClientGuid."); ModelHelper.Log(LogType.TestInfo, "All the above conditions are met."); ModelHelper.Log(LogType.Requirement, "If an Open is found, the server MUST calculate the maximal access that the user, " + "identified by Session.SecurityContext, has on the file being opened<277>. " + "If the maximal access includes GENERIC_READ access, the server MUST close the open as specified in 3.3.4.17."); // The user used in this model is administrator, so maximal access always includes GENERIC_READ access. ModelHelper.Log(LogType.TestInfo, "The maximal access includes GENERIC_READ access. So open is closed."); // close open Open = null; } else { ModelHelper.Log(LogType.TestInfo, "appInstanceIdType is {0}.", appInstanceIdType.ToString()); ModelHelper.Log(LogType.TestInfo, "pathNameType is {0}.", pathNameType.ToString()); ModelHelper.Log(LogType.TestInfo, "shareType is {0}.", shareType.ToString()); ModelHelper.Log(LogType.TestInfo, "clientGuidType is {0}.", clientGuidType.ToString()); ModelHelper.Log(LogType.TestInfo, "All the above conditions do not match the requirement, so open will not be closed."); ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields); } }
public void OpenRequest( ClientGuidType clientGuidType, PathNameType pathNameType, CreateType createType, ShareType shareType, AppInstanceIdType appInstanceIdType) { Smb2FunctionalClient testClient = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site); uint treeId; string share; switch (shareType) { case ShareType.SameShare: share = testConfig.BasicFileShare; break; case ShareType.DifferentShareSameLocal: share = testConfig.SameWithSMBBasic; break; case ShareType.DifferentShareDifferentLocal: share = testConfig.DifferentFromSMBBasic; break; default: throw new ArgumentException("shareType"); } ConnectToShare( clientDialect, testClient, clientGuidType == ClientGuidType.SameClientGuid ? this.connection_ClientGuid : Guid.NewGuid(), share, out treeId); FILEID fileId; Smb2CreateContextResponse[] createContextResponse; uint status; string fileNameInOpen; if (pathNameType == PathNameType.SamePathName) { fileNameInOpen = fileName; } else { fileNameInOpen = fileName + different; AddTestFileName(Smb2Utility.GetUncPath(testConfig.SutComputerName, share), fileNameInOpen); } status = testClient.Create( treeId, fileNameInOpen, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileId, out createContextResponse, createContexts: CreateContexts(appInstanceIdType, createType, false), shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { }); testClient.Disconnect(); testClient = null; // Check if the Open is closed. // If status is success, and fileId is the same with the previous one, then the Open is not closed. // Otherwise, use some other way to check if the Open is closed. bool ifClosed; if (status == Smb2Status.STATUS_SUCCESS && fileId.Persistent == this.open_FileId.Persistent) { ifClosed = false; } else { ifClosed = CheckIfOpenClosed(clientDialect, createType); } this.OpenResponse(ifClosed ? OpenStatus.OpenClosed : OpenStatus.OpenNotClosed); }
public void OpenRequest( ClientGuidType clientGuidType, PathNameType pathNameType, CreateType createType, ShareType shareType, AppInstanceIdType appInstanceIdType) { Smb2FunctionalClient testClient = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site); uint treeId; string share; switch (shareType) { case ShareType.SameShare: share = testConfig.BasicFileShare; break; case ShareType.DifferentShareSameLocal: share = testConfig.SameWithSMBBasic; break; case ShareType.DifferentShareDifferentLocal: share = testConfig.DifferentFromSMBBasic; cleanFileInDifferentShare = true; break; default: throw new ArgumentException("shareType"); } ConnectToShare( clientDialect, testClient, clientGuidType == ClientGuidType.SameClientGuid ? this.connection_ClientGuid : Guid.NewGuid(), share, out treeId); FILEID fileId; Smb2CreateContextResponse[] createContextResponse; uint status; string fileNameInOpen; if (pathNameType == PathNameType.SamePathName) { fileNameInOpen = fileName; } else { fileNameInOpen = fileName + different; cleanFileWithDifferentName = true; } status = testClient.Create( treeId, fileNameInOpen, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileId, out createContextResponse, createContexts: CreateContexts(appInstanceIdType, createType, false), shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { }); // The file is not created, no need to delete. if (status != Smb2Status.STATUS_SUCCESS) { cleanFileInDifferentShare = false; cleanFileWithDifferentName = false; } testClient.Disconnect(); testClient = null; // Check if the Open is closed. // If status is success, and fileId is the same with the previous one, then the Open is not closed. // Otherwise, use some other way to check if the Open is closed. bool ifClosed; if (status == Smb2Status.STATUS_SUCCESS && fileId.Persistent == this.open_FileId.Persistent) ifClosed = false; else ifClosed = CheckIfOpenClosed(clientDialect, createType); this.OpenResponse(ifClosed ? OpenStatus.OpenClosed : OpenStatus.OpenNotClosed); }