public async Task Token_request_error_should_trigger_unauthenticated_request_to_api() { var api = new DownstreamApiHandler(); var client = HostFactory.CreateClient( b => b.AddOidcRefreshToken(_options), TokenEndpointHandler.OidcProtocolError("invalid_grant"), api: api); await client.GetAsync("https://default"); Check.That(api.LastRequestToken).IsNull(); }
public async Task Token_delegation_error_should_trigger_unauthenticated_request_to_downstream() { var downstreamApi = new DownstreamApiHandler(); var client = WebHostFactory.CreateClient( b => b.AddOidcTokenDelegation(_options), TokenEndpointHandler.OidcProtocolError("invalid_grant"), downstreamApi: downstreamApi); client.SetBearerToken("1234"); await client.GetAsync("https://default"); Check.That(downstreamApi.LastRequestToken).IsNull(); }
public async Task Token_request_error_should_trigger_TokenRequestFailed_event() { var eventsMock = new TokenEventsMock(); var client = HostFactory.CreateClient( b => b.AddOidcRefreshToken(o => { _options(o); o.Events = eventsMock.CreateEvents(); }), TokenEndpointHandler.OidcProtocolError("invalid_grant")); await client.GetAsync("https://default"); Check.That(eventsMock.LatestTokenRequestFailed).IsNotNull(); Check.That(eventsMock.LatestTokenRequestFailed.ErrorType).IsEqualTo(ResponseErrorType.Protocol); Check.That(eventsMock.LatestTokenRequestFailed.Error).IsEqualTo("invalid_grant"); }