public async Task ShouldReturnCorrectTaskForSignOutRequest() { _userSession = Substitute.For <IUserSession>(); _userSession.GetUserAsync().Returns(Task.FromResult( new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(JwtClaimTypes.Subject, "test"), new Claim(JwtClaimTypes.AuthenticationMethod, "test"), new Claim(JwtClaimTypes.Name, "test person") })))); _validator = new WsFederationRequestValidator(Substitute.For <ILogger <WsFederationRequestValidator> >(), new InMemoryClientStore(new[] { new Client { ClientId = "http://sample-with-policyengine/", ProtocolType = IdentityServerConstants.ProtocolTypes.WsFederation, RedirectUris = new [] { "http://localhost" }, AllowedScopes = { "openid", "profile" } } })); var endpoint = new WsFederationEndpoint(_logger, _validator, GetDefaultResponseGenerator(), _userSession); var httpContext = new DefaultHttpContext(); httpContext.Request.Method = "GET"; httpContext.Request.QueryString = QueryString.FromUriComponent("?wa=wsignout1.0&wtrealm=http%3a%2f%2fsample-with-policyengine%2f"); var result = await endpoint.ProcessAsync(httpContext); Assert.IsInstanceOfType(result, typeof(WsFederationSignOutResult)); }
public async Task PostShouldReturnInvalidMethod() { _userSession = Substitute.For <IUserSession>(); var endpoint = new WsFederationEndpoint(_logger, _validator, GetDefaultResponseGenerator(), _userSession); var httpContext = new DefaultHttpContext(); httpContext.Request.Method = "POST"; var result = (StatusCodeResult)await endpoint.ProcessAsync(httpContext); Assert.AreEqual((int)HttpStatusCode.MethodNotAllowed, result.StatusCode); }