public static void TerminateConnection(ModelConnectionId connectionId) { VerifyConnection(connectionId); if (ConnectionList[connectionId].Session != null) { ModelHelper.Log(LogType.Requirement, "3.3.7.1: the Session MUST be removed from GlobalSessionTable and freed. "); GlobalSessionTable.Remove(ConnectionList[connectionId].Session.SessionId); } // Disconnect and remove the connection ConnectionList[connectionId].ConnectionState = ModelState.Disconnected; ModelHelper.Log(LogType.Requirement, "3.3.7.1: The connection MUST be removed from ConnectionList and MUST be freed."); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); ConnectionList.Remove(connectionId); }
public static void LogOffResponse(ModelSmb2Status status, ModelConnectionId connectionId, SessionMgmtConfig c) { Condition.IsTrue(config.Platform == c.Platform); if (config.Platform == Platform.NonWindows && ConnectionList.ContainsKey(connectionId) && ConnectionList[connectionId].Session == null && ConnectionList[connectionId].ConstrainedConnection) { // The TD statements are logged in LogOffRequest ModelHelper.Log(LogType.TestInfo, "SUT platform is NonWindows, so server could return an error code instead of disconnect the connection."); Condition.IsTrue(status != ModelSmb2Status.STATUS_SUCCESS); return; } if (VerifyFootnote(connectionId, c, status)) { return; } VerifyConnection(connectionId); Condition.IsNotNull(ConnectionList[connectionId].Request); ModelLogOffRequest logOffRequest = RetrieveOutstandingRequest <ModelLogOffRequest>(connectionId); if (ConnectionList[connectionId].Session != null && ConnectionList[connectionId].Session.SessionId != logOffRequest.sessionId) { ModelHelper.Log(LogType.Requirement, "3.3.5.2.9: If Connection.SessionTable is not empty and SessionId is not found in Connection.SessionTable, " + "the server MUST fail the request with STATUS_USER_SESSION_DELETED."); ModelHelper.Log(LogType.TestInfo, "Connection.SessionTable is not empty and SessionId of Logoff Request is not found in Connection.SessionTable"); ModelHelper.Log(LogType.TestTag, TestTag.InvalidIdentifier); Condition.IsTrue(status == ModelSmb2Status.STATUS_USER_SESSION_DELETED); return; } if (!ConnectionList[connectionId].ConstrainedConnection && ConnectionList[connectionId].Session == null) { ModelHelper.Log(LogType.Requirement, "3.3.5.2.9: If Connection.ConstrainedConnection is FALSE and Connection.SessionTable is empty, then the server MUST fail any request with STATUS_USER_SESSION_DELETED."); ModelHelper.Log(LogType.TestInfo, "Connection.ConstrainedConnection is FALSE and Connection.SessionTable is empty."); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); Condition.IsTrue(status == ModelSmb2Status.STATUS_USER_SESSION_DELETED); return; } if (GlobalSessionTable.ContainsKey(logOffRequest.sessionId)) { if (GlobalSessionTable[logOffRequest.sessionId].State == ModelSessionState.InProgress) { ModelHelper.Log(LogType.Requirement, "3.3.5.2.9: If Session.State is InProgress, the server MUST continue to process the SMB2 LOGOFF, SMB2 CLOSE, and SMB2 LOCK commands. "); ModelHelper.Log(LogType.TestInfo, "Session.State is InProgress"); ModelHelper.Log(LogType.TestTag, TestTag.Compatibility); // Do nothing for LOGOFF and continue } ModelHelper.Log(LogType.Requirement, "3.3.5.6: The server MUST remove this session from the GlobalSessionTable and also from the Connection.SessionTable"); GlobalSessionTable.Remove(logOffRequest.sessionId); ConnectionList[logOffRequest.connectionId].Session = null; } ModelHelper.Log(LogType.TestInfo, "Verifying the Session succeeds."); Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS); }