/// <summary> /// Reset all member variables before running next test case /// </summary> public override void Reset() { if (firstClient != null) { firstClient.Disconnect(); firstClient = null; } if (secondClient != null) { secondClient.Disconnect(); secondClient = null; } fileName = null; leaseBreakState = LeaseBreakState.NoLeaseBreak; treeId1 = 0; treeId2 = 0; fileId1 = FILEID.Zero; fileId2 = FILEID.Zero; base.Reset(); }
public static void ConflictResponse(ModelSmb2Status status, LeaseBreakState leaseBreakState) { switch (State) { case FileState.Initial: ModelHelper.Log(LogType.TestInfo, "The state of the file is not changed. So any request from the second client should succeed."); Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS); break; case FileState.Locked: switch (SecondRequest) { case RequestType.ExclusiveLock: ModelHelper.Log( LogType.Requirement, "3.3.5.14.2: If the range being locked is already locked by another open in a way " + "that does not allow this open to take a lock on the range, and if SMB2_LOCKFLAG_FAIL_IMMEDIATELY is set, " + "the server MUST fail the request with STATUS_LOCK_NOT_GRANTED."); ModelHelper.Log(LogType.TestInfo, "The file is already locked and SMB2_LOCKFLAG_FAIL_IMMEDIATELY is set."); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); Condition.IsTrue(status == ModelSmb2Status.STATUS_LOCK_NOT_GRANTED); break; case RequestType.Lease: ModelHelper.Log(LogType.TestInfo, "Lease succeed even the file is locked."); Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS); break; case RequestType.Delete: ModelHelper.Log(LogType.TestInfo, "Delete succeed even the file is locked."); Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS); break; case RequestType.Write: ModelHelper.Log(LogType.TestInfo, "Write fails because the file is locked."); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); Condition.IsTrue(status == ModelSmb2Status.STATUS_FILE_LOCK_CONFLICT); break; case RequestType.Read: ModelHelper.Log(LogType.TestInfo, "Read fails because the file is locked."); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); Condition.IsTrue(status == ModelSmb2Status.STATUS_FILE_LOCK_CONFLICT); break; default: break; } break; case FileState.LeaseGranted: ModelHelper.Log( LogType.TestInfo, "A lease to this file is granted to the first open, but it will not fail the operation from the second client"); Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS); break; case FileState.ToBeDeleted: ModelHelper.Log(LogType.TestInfo, "The file is not deleted, and it will be deleted only if the second open is closed."); ModelHelper.Log(LogType.TestInfo, "So the other operation ahead of Close request from the second client will succeed."); Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS); break; case FileState.Deleted: ModelHelper.Log(LogType.TestInfo, "The file is deleted, so any operation to the non-existed file fails."); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); Condition.IsTrue(status == ModelSmb2Status.STATUS_OBJECT_NAME_NOT_FOUND); break; default: break; } if (State == FileState.LeaseGranted && (SecondRequest == RequestType.Write || SecondRequest == RequestType.ExclusiveLock)) { ModelHelper.Log(LogType.TestInfo, "A lease to this file is granted to the first open. "); ModelHelper.Log(LogType.TestInfo, "The {0} request from second client should break the lease state.", SecondRequest); Condition.IsTrue(leaseBreakState == LeaseBreakState.LeaseBreakExisted); } else { if (State == FileState.LeaseGranted) { ModelHelper.Log( LogType.TestInfo, "A lease is granted to the first open, but the {0} request from the second client cannot break the state.", SecondRequest); } else { ModelHelper.Log(LogType.TestInfo, "No lease is granted to the first open, so no lease break."); } Condition.IsTrue(leaseBreakState == LeaseBreakState.NoLeaseBreak); } }
private void OnLeaseBreakNotificationReceived(Packet_Header header, LEASE_BREAK_Notification_Packet notification) { // Set Lease breake state leaseBreakState = LeaseBreakState.LeaseBreakExisted; }