public void MSOXCMAPIHTTP_S01_TC02_ReconnectToMailboxServer()
{
this.CheckMapiHttpIsSupported();
MailboxResponseBodyBase responseBody;
#region Send a valid Connect request type to establish a Session Context with the server.
WebHeaderCollection connectHeaders = new WebHeaderCollection();
ConnectSuccessResponseBody connectResponse = this.ConnectToServer(out connectHeaders);
#endregion
#region Wait for the Session Context expired.
int expireTime = int.Parse(connectHeaders["X-ExpirationInfo"]);
System.Threading.Thread.Sleep(expireTime);
List<string> metatagsFromMailbox = new List<string>();
WebHeaderCollection pingHeaders = new WebHeaderCollection();
uint responseCode = this.Adapter.PING(ServerEndpoint.MailboxServerEndpoint, out metatagsFromMailbox, out pingHeaders);
if (responseCode != 10)
{
expireTime = int.Parse(pingHeaders["X-ExpirationInfo"]);
System.Threading.Thread.Sleep(expireTime);
}
#endregion
#region Send an Execute request that includes a Logon ROP to server after the Session Context expired.
uint responseCodeAfterSessionContextExpired = this.ExecuteLogonROP(AdapterHelper.SessionContextCookies);
// Add the debug information
this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R1283");
// Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1283
this.Site.CaptureRequirementIfAreEqual<uint>(
10,
responseCodeAfterSessionContextExpired,
1283,
@"[In Reconnecting and Establishing a New Session Context Server] If the Session Context has expired, is no longer valid, or is not valid for the server in which the mailbox currently resides, then the server fails the request with an X-ResponseCode value of 10, as specified in section 2.2.3.3.3.");
#endregion
#region Send a Connect request type which includes a valid cookie to reconnect with server.
connectHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Connect, AdapterHelper.ClientInstance, AdapterHelper.Counter);
CookieCollection cookies = AdapterHelper.SessionContextCookies;
HttpStatusCode httpStatusCode;
this.Adapter.Connect(this.AdminUserName, this.AdminUserPassword, this.AdminUserDN, ref cookies, out responseBody, ref connectHeaders, out httpStatusCode);
uint responseCodeHasSequenceCookie = AdapterHelper.GetFinalResponseCode(connectHeaders["X-ResponseCode"]);
// Add the debug information
this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R1280");
// Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1280
// If the Set-Cookie header is not null, then server passes the cookies to the client.
this.Site.CaptureRequirementIfIsNotNull(
connectHeaders["Set-Cookie"],
1280,
@"[In Reconnecting and Establishing a New Session Context Server] The response from the server uses the Set-Cookie header, as specified in section 2.2.3.2.3, to pass any required cookies to the client.");
#endregion
#region Send an Execute request that includes a Logon ROP to server.
uint responseCodeAfterReconnect = this.ExecuteLogonROP(AdapterHelper.SessionContextCookies);
// Add the debug information
this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R1278");
// Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1278
this.Site.CaptureRequirementIfAreEqual<uint>(
0,
responseCodeAfterReconnect,
1278,
@"[In Reconnecting and Establishing a New Session Context Server] The server returns a new session context cookie that is associated with a new Session Context.");
#endregion
#region Send a Connect request type which includes a valid Session Context cookie and doesn't include sequence cookie to reconnect with server.
connectHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Connect, AdapterHelper.ClientInstance, AdapterHelper.Counter);
CookieCollection cookieNotSequence = new CookieCollection();
cookieNotSequence.Add(AdapterHelper.SessionContextCookies[0]);
this.Adapter.Connect(this.AdminUserName, this.AdminUserPassword, this.AdminUserDN, ref cookieNotSequence, out responseBody, ref connectHeaders, out httpStatusCode);
uint responseCodeNotSequenceCookie = AdapterHelper.GetFinalResponseCode(connectHeaders["X-ResponseCode"]);
// Add the debug information
this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R1329: The X-Response header is {0} when client sends the sequence cookie and the X-Response header is {1} when client does not send the sequence cookie", responseCodeHasSequenceCookie, responseCodeNotSequenceCookie);
// Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1329
bool isVerifiedR1329 = responseCodeNotSequenceCookie == 0 && responseCodeHasSequenceCookie == 0;
this.Site.CaptureRequirementIfIsTrue(
isVerifiedR1329,
1329,
@"[In Reconnecting and Establishing a New Session Context Server] Server will reconnect successfully no matter client sends the sequence validation cookie or not.");
#endregion
#region Send a Disconnect request type request to destroy the Session Context.
this.Adapter.Disconnect(out responseBody);
#endregion
}