Ejemplo n.º 1
0
        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>();
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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();
        }