Ejemplo n.º 1
0
        public async Task EndSessionRequestDoesNotIncludeTelemetryParametersWhenDisabled()
        {
            var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration();
            var setting       = new TestSettings(opt =>
            {
                opt.ClientId         = "Test Id";
                opt.Configuration    = configuration;
                opt.SignInScheme     = CookieAuthenticationDefaults.AuthenticationScheme;
                opt.DisableTelemetry = true;
            });

            var server = setting.CreateTestServer();

            var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout);

            var res = transaction.Response;

            Assert.Equal(HttpStatusCode.Redirect, res.StatusCode);
            Assert.DoesNotContain(OpenIdConnectParameterNames.SkuTelemetry, res.Headers.Location.Query);
            Assert.DoesNotContain(OpenIdConnectParameterNames.VersionTelemetry, res.Headers.Location.Query);
            setting.ValidateSignoutRedirect(transaction.Response.Headers.Location);
        }
Ejemplo n.º 2
0
        public async Task SignOutWithDefaultRedirectUri()
        {
            var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration();
            var server        = TestServerBuilder.CreateServer(o =>
            {
                o.Authority     = TestServerBuilder.DefaultAuthority;
                o.ClientId      = "Test Id";
                o.Configuration = configuration;
            });

            var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout);

            Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
            Assert.True(transaction.Response.Headers.Location.AbsoluteUri.StartsWith(configuration.EndSessionEndpoint));

            var query = transaction.Response.Headers.Location.Query.Substring(1).Split('&')
                        .Select(each => each.Split('='))
                        .ToDictionary(pair => pair[0], pair => pair[1]);

            string redirectUri;

            Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri));
            Assert.Equal(UrlEncoder.Default.Encode("https://example.com/signout-callback-oidc"), redirectUri, true);
        }
Ejemplo n.º 3
0
 public TestServer CreateTestServer(AuthenticationProperties properties = null) => TestServerBuilder.CreateServer(_configureOptions, handler: null, properties: properties);
Ejemplo n.º 4
0
 public TestServer CreateTestServer(AuthenticationProperties properties = null, Func <HttpContext, Task> handler = null) => TestServerBuilder.CreateServer(_configureOptions, handler: handler, properties: properties);