private SignOut ( [ callback ) : |
||
callback | [ | |
return |
public void Allow_SignOut() { // Prepare HttpResponseMessage httpResponseMessage = null; string issuer = "https://unittest.accesscontrol.windows.net/v2/wsfederation"; string wtrealm = "urn:dataonboardingapi:unittest"; string callbackUrl = "http://unittest:123/landingpage"; string apiUrl = "http://unittest-api-dataonboarding.cloudapp.net"; using (ShimsContext.Create()) { ShimDiagnosticsProvider.AllInstances.WriteInformationTraceTraceEventIdString = (diagnosticsProvider, traceEventId, message) => { }; ShimFederatedAuthentication.WSFederationAuthenticationModuleGet = () => { var wsFederationAuthenticationModule = new ShimWSFederationAuthenticationModule(); wsFederationAuthenticationModule.SignOutBoolean = (param) => { }; return wsFederationAuthenticationModule; }; ShimFederatedAuthentication.FederationConfigurationGet = () => { var federationConfiguration = new ShimFederationConfiguration(); federationConfiguration.WsFederationConfigurationGet = () => { var acsConfig = new ShimWsFederationConfiguration(); acsConfig.RealmGet = () => { return wtrealm; }; acsConfig.IssuerGet = ()=> { return issuer; ; }; return acsConfig; }; return federationConfiguration; }; var authenticationController = new AuthenticationController(); authenticationController.Request = new HttpRequestMessage(HttpMethod.Get, apiUrl); // Perform httpResponseMessage = authenticationController.SignOut(callbackUrl); } // Assert Assert.AreEqual(HttpStatusCode.Moved, httpResponseMessage.StatusCode, "Stataus is not as expected(Moved)"); string wReply = string.Format("{0}/SignOutCallback?callback={1}", apiUrl, callbackUrl); string expectedCallbackUrl = string.Format("{0}?wa=wsignout1.0&wreply={1}&wtrealm={2}", issuer, HttpUtility.UrlEncode(wReply), wtrealm); Assert.AreEqual(HttpUtility.UrlDecode(expectedCallbackUrl), HttpUtility.UrlDecode(httpResponseMessage.Headers.Location.ToString())); }
public void Return_BadRequest_SignOut_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.SignOut(callbackUrl); // Assert Assert.AreEqual(HttpStatusCode.BadRequest, httpResponseMessage.StatusCode, "Stataus is not as expected(Bad Request)"); }