private SignOutCallback ( [ callback ) : |
||
callback | [ | |
Результат |
public void Return_BadRequest_SignOutCallBack_When_CallBack_IS_Null() { // Prepare HttpResponseMessage httpResponseMessage = null; string callbackUrl = null; var authenticationController = new AuthenticationController(); authenticationController.Request = new HttpRequestMessage(HttpMethod.Get, string.Empty); // Perform httpResponseMessage = authenticationController.SignOutCallback(callbackUrl); // Assert Assert.AreEqual(HttpStatusCode.BadRequest, httpResponseMessage.StatusCode, "Stataus is not as expected(Bad Request)"); }
public void Allow_SignOutCallBack() { // Prepare HttpResponseMessage httpResponseMessage = null; string callbackUrl = "http://unittest:123/landingpage"; var authenticationController = new AuthenticationController(); authenticationController.Request = new HttpRequestMessage(HttpMethod.Get, string.Empty); // Perform httpResponseMessage = authenticationController.SignOutCallback(callbackUrl); // Assert Assert.AreEqual(HttpStatusCode.Moved, httpResponseMessage.StatusCode, "Stataus is not as expected(Moved)"); Assert.AreEqual(callbackUrl, HttpUtility.UrlDecode(httpResponseMessage.Headers.Location.ToString())); // Check FedAuth cookie bool cookieExists = false; string[] cookies = (string[]) httpResponseMessage.Headers.GetValues("set-cookie"); foreach (string cookie in cookies) { if (cookie.Contains("FedAuth")) { cookieExists = true; string[] attributes = cookie.Split(';'); DateTime expiryDate = Convert.ToDateTime(attributes[1].Substring(attributes[1].LastIndexOf('=') + 1)); Assert.IsTrue(DateTime.Now > expiryDate, "FedAuth cookie is not set to expire"); } } Assert.IsTrue(cookieExists, "FedAuth cookie doese not exist"); }