示例#1
0
    public async Task redirect_uri_should_work_when_dynamic_provider_not_in_cache()
    {
        var response = await _host.BrowserClient.GetAsync(_host.Url("/challenge?scheme=idp1"));

        var authzUrl = response.Headers.Location.ToString();

        await _idp1.BrowserClient.GetAsync(_idp1.Url("/signin"));

        response = await _idp1.BrowserClient.GetAsync(authzUrl);

        var redirectUri = response.Headers.Location.ToString();

        redirectUri.Should().StartWith("https://server/federation/idp1/signin");

        var cache = _host.Resolve <ICache <IdentityProvider> >() as DefaultCache <IdentityProvider>;
        await cache.RemoveAsync("test");

        response = await _host.BrowserClient.GetAsync(redirectUri);

        response = await _host.BrowserClient.GetAsync(_host.Url(response.Headers.Location.ToString()));

        response.StatusCode.Should().Be(HttpStatusCode.OK);
        var body = await response.Content.ReadAsStringAsync();

        body.Should().Be("1"); // sub
    }