public void SendRequestAsync_InvalidRequest_ReturnsResponse() { var clientAssertion = JwtUtilities.Create( issuer: Constants.AbcParty.ClientId, audience: Constants.AbcParty.ClientId, Constants.AbcParty.PrivateKey, Constants.AbcParty.PublicKeyBase64Der); var requestArgs = CreateRequestArgs(clientAssertion); Func <Task> act = () => _sut.SendRequestAsync(requestArgs); act.Should().Throw <HttpRequestException>(); }
protected static async Task <string> GetAccessTokenAsync() { var clientAssertion = JwtUtilities.Create( issuer: Constants.AbcParty.ClientId, audience: Constants.SchemeOwner.ClientId, Constants.AbcParty.PrivateKey, Constants.AbcParty.PublicKeyBase64Der); var requestArgs = CreateRequestArgs(clientAssertion); var accessTokenAccessor = ServiceScope.ServiceProvider.GetRequiredService <IAccessTokenAccessor>(); return(await accessTokenAccessor.GetAsync(requestArgs)); }
public async Task SendRequestAsync_UriRequestEndsWithSlash_ReturnsAccessToken() { var clientAssertion = JwtUtilities.Create( issuer: Constants.AbcParty.ClientId, audience: Constants.SchemeOwner.ClientId, Constants.AbcParty.PrivateKey, Constants.AbcParty.PublicKeyBase64Der); var requestArgs = CreateRequestArgs(clientAssertion, $"{Constants.SchemeOwner.AccessTokenRequestUri}/"); var result = await _sut.SendRequestAsync(requestArgs); result.Should().NotBeNull(); result.ExpiresIn.Should().Be(3600); result.TokenType.Should().Be("Bearer"); result.AccessToken.Should().NotBeNullOrWhiteSpace(); }