public void BVT_SMB2Basic_CancelRegisteredChangeNotify() { uint status; string testDirectory = CreateTestDirectory(TestConfig.SutComputerName, TestConfig.BasicFileShare); BaseTestSite.Log.Add( LogEntryKind.Debug, "Test directory \"{0}\" was created on share \"{1}\"", testDirectory, TestConfig.BasicFileShare); client1 = new Smb2FunctionalClient(TestConfig.Timeout, TestConfig, BaseTestSite); client1.Smb2Client.ChangeNotifyResponseReceived += new Action <FILE_NOTIFY_INFORMATION[], Packet_Header, CHANGE_NOTIFY_Response>(OnChangeNotifyResponseReceived); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Start a client to create a file by sending the following requests: NEGOTIATE; SESSION_SETUP; TREE_CONNECT; CREATE"); client1.ConnectToServer(TestConfig.UnderlyingTransport, TestConfig.SutComputerName, TestConfig.SutIPAddress); status = client1.Negotiate(TestConfig.RequestDialects, TestConfig.IsSMB1NegotiateEnabled); status = client1.SessionSetup( TestConfig.DefaultSecurityPackage, TestConfig.SutComputerName, TestConfig.AccountCredential, TestConfig.UseServerGssToken); uint treeId1; status = client1.TreeConnect(uncSharePath, out treeId1); Smb2CreateContextResponse[] serverCreateContexts; FILEID fileId1; status = client1.Create( treeId1, testDirectory, CreateOptions_Values.FILE_DIRECTORY_FILE, out fileId1, out serverCreateContexts); BaseTestSite.Log.Add( LogEntryKind.Comment, "Client starts to register CHANGE_NOTIFY on directory \"{0}\"", testDirectory); client1.ChangeNotify(treeId1, fileId1, CompletionFilter_Values.FILE_NOTIFY_CHANGE_LAST_ACCESS); BaseTestSite.Log.Add( LogEntryKind.Comment, "Client starts to cancel the registered CHANGE_NOTIFY on directory \"{0}\"", testDirectory); client1.Cancel(); BaseTestSite.Assert.IsTrue( changeNotificationReceived.WaitOne(TestConfig.WaitTimeoutInMilliseconds), "Change notification should be received within {0} milliseconds", TestConfig.WaitTimeoutInMilliseconds); BaseTestSite.Assert.AreNotEqual( Smb2Status.STATUS_SUCCESS, receivedChangeNotifyHeader.Status, "CHANGE_NOTIFY is not expected to success after cancel, actually server returns {0}.", Smb2Status.GetStatusCode(receivedChangeNotifyHeader.Status)); BaseTestSite.CaptureRequirementIfAreEqual( Smb2Status.STATUS_CANCELLED, receivedChangeNotifyHeader.Status, RequirementCategory.STATUS_CANCELLED.Id, RequirementCategory.STATUS_CANCELLED.Description); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Tear down the client by sending the following requests: CLOSE; TREE_DISCONNECT; LOG_OFF"); client1.Close(treeId1, fileId1); client1.TreeDisconnect(treeId1); client1.LogOff(); }
public void BVT_SMB2Basic_CancelRegisteredChangeNotify() { uint status; string testDirectory = CreateTestDirectory(TestConfig.SutComputerName, TestConfig.BasicFileShare); BaseTestSite.Log.Add( LogEntryKind.Debug, "Test directory \"{0}\" was created on share \"{1}\"", testDirectory, TestConfig.BasicFileShare); client1 = new Smb2FunctionalClient(TestConfig.Timeout, TestConfig, BaseTestSite); client1.Smb2Client.ChangeNotifyResponseReceived += new Action<FILE_NOTIFY_INFORMATION[],Packet_Header,CHANGE_NOTIFY_Response>(OnChangeNotifyResponseReceived); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Start a client to create a file by sending the following requests: NEGOTIATE; SESSION_SETUP; TREE_CONNECT; CREATE"); client1.ConnectToServer(TestConfig.UnderlyingTransport, TestConfig.SutComputerName, TestConfig.SutIPAddress); status = client1.Negotiate(TestConfig.RequestDialects, TestConfig.IsSMB1NegotiateEnabled); status = client1.SessionSetup( TestConfig.DefaultSecurityPackage, TestConfig.SutComputerName, TestConfig.AccountCredential, TestConfig.UseServerGssToken); uint treeId1; status = client1.TreeConnect(uncSharePath, out treeId1); Smb2CreateContextResponse[] serverCreateContexts; FILEID fileId1; status = client1.Create( treeId1, testDirectory, CreateOptions_Values.FILE_DIRECTORY_FILE, out fileId1, out serverCreateContexts); BaseTestSite.Log.Add( LogEntryKind.Comment, "Client starts to register CHANGE_NOTIFY on directory \"{0}\"", testDirectory); client1.ChangeNotify(treeId1, fileId1, CompletionFilter_Values.FILE_NOTIFY_CHANGE_LAST_ACCESS); BaseTestSite.Log.Add( LogEntryKind.Comment, "Client starts to cancel the registered CHANGE_NOTIFY on directory \"{0}\"", testDirectory); client1.Cancel(); BaseTestSite.Assert.IsTrue( changeNotificationReceived.WaitOne(TestConfig.WaitTimeoutInMilliseconds), "Change notification should be received within {0} milliseconds", TestConfig.WaitTimeoutInMilliseconds); BaseTestSite.Assert.AreNotEqual( Smb2Status.STATUS_SUCCESS, receivedChangeNotifyHeader.Status, "CHANGE_NOTIFY is not expected to success after cancel, actually server returns {0}.", Smb2Status.GetStatusCode(receivedChangeNotifyHeader.Status)); BaseTestSite.CaptureRequirementIfAreEqual( Smb2Status.STATUS_CANCELLED, receivedChangeNotifyHeader.Status, RequirementCategory.STATUS_CANCELLED.Id, RequirementCategory.STATUS_CANCELLED.Description); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Tear down the client by sending the following requests: CLOSE; TREE_DISCONNECT; LOG_OFF"); client1.Close(treeId1, fileId1); client1.TreeDisconnect(treeId1); client1.LogOff(); }