Exemplo n.º 1
0
        public async Task Authority_Get_Introspection_Endpoint()
        {
            _options.Authority = "http://authority.com/";
            _options.ClientId  = "scope";

            var handler = new DiscoveryEndpointHandler();

            _options.DiscoveryHttpHandler = handler;

            var client = PipelineFactory.CreateClient(_options);

            client.SetBearerToken("token");
            var response = await client.GetAsync("http://server/api");

            _options.IntrospectionEndpoint.Should().Be("http://introspection_endpoint");
        }
Exemplo n.º 2
0
        public async Task Authority_Trailing_Slash()
        {
            _options.Authority = "http://authority.com/";
            _options.ClientId  = "scope";

            var handler = new DiscoveryEndpointHandler();

            _options.DiscoveryHttpHandler = handler;

            var client = PipelineFactory.CreateClient(_options);

            client.SetBearerToken("token");
            var response = await client.GetAsync("http://server/api");

            handler.Endpoint.Should().Be("http://authority.com/.well-known/openid-configuration");
        }
Exemplo n.º 3
0
        public async Task ActiveToken_With_Discovery_Unavailable_On_First_Request()
        {
            var handler = new DiscoveryEndpointHandler();

            var client = PipelineFactory.CreateClient((o) =>
            {
                _options(o);
                o.DiscoveryHttpHandler     = handler;
                o.IntrospectionHttpHandler = new IntrospectionEndpointHandler(IntrospectionEndpointHandler.Behavior.Active);
            });

            client.SetBearerToken("sometoken");

            handler.IsFailureTest = true;
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await client.GetAsync("http://test"));

            handler.IsFailureTest = false;
            var result = await client.GetAsync("http://test");

            result.StatusCode.Should().Be(HttpStatusCode.OK);
        }
        public async Task Authority_Get_Introspection_Endpoint()
        {
            var handler = new DiscoveryEndpointHandler();
            OAuth2IntrospectionOptions ops = null;

            var client = PipelineFactory.CreateClient(options =>
            {
                options.Authority = "https://authority.com/";
                options.ClientId  = "scope";

                options.DiscoveryHttpHandler          = handler;
                options.DiscoveryPolicy.RequireKeySet = false;

                options.IntrospectionHttpHandler = new IntrospectionEndpointHandler(IntrospectionEndpointHandler.Behavior.Active);

                ops = options;
            });

            client.SetBearerToken("token");
            await client.GetAsync("http://server/api");

            ops.IntrospectionEndpoint.Should().Be("https://authority.com/introspection_endpoint");
        }