public void TestFixtureSetUp()
            {
                m_authService          = new AuthServiceMock(AuthServiceMock.KeyType.ECDSA_P256);
                m_accessTokenValidator = AccessTokenValidatorFactory.CreateRemoteValidator(
                    new HttpClient(),
                    m_authService.Host
                    );

                m_authService.SetupJwks().Wait();
            }
示例#2
0
            public void TestFixtureSetUp()
            {
                m_authService          = new AuthServiceMock(AuthServiceMock.KeyType.ECDSA_P256);
                m_accessTokenValidator = AccessTokenValidatorFactory.CreateRemoteValidator(
                    new HttpClient(m_authService.MockHandler),
                    new Uri(m_authService.Host, ".well-known/jwks")
                    );

                m_authService.SetupJwks().Wait();
            }
示例#3
0
            public void ValidateAsync_GoodSignature_Succeeds_WebCrypto(string jwk, string token)
            {
                var mockHandler = new MockHttpMessageHandler();

                mockHandler
                .When("http://localhost/.well-known/jwks")
                .Respond("application/json", @"{""keys"":[" + jwk + "]}");

                // We expect these to be expired because they are static
                // The rest of the validation should have otherwise proceeded swimmingly
                Assert.Throws <ExpiredTokenException>(() =>
                                                      AccessTokenValidatorFactory
                                                      .CreateRemoteValidator(new HttpClient(mockHandler), new Uri("http://localhost/.well-known/jwks"))
                                                      .ValidateAsync(token)
                                                      .ConfigureAwait(false).GetAwaiter().GetResult()
                                                      );
            }
示例#4
0
            public void ValidateAsync_GoodSignature_Succeeds_WebCrypto(string jwk, string token)
            {
                var mockServer = HttpMockFactory.Create(out string host);

                mockServer
                .Stub(r => r.Get("/.well-known/jwks"))
                .Return(@"{""keys"":[" + jwk + "]}")
                .OK();

                // We expect these to be expired because they are static
                // The rest of the validation should have otherwise proceeded swimmingly
                Assert.Throws <ExpiredTokenException>(() =>
                                                      AccessTokenValidatorFactory
                                                      .CreateRemoteValidator(new HttpClient(), new Uri(host + "/.well-known/jwks"))
                                                      .ValidateAsync(token)
                                                      .SafeAsync().GetAwaiter().GetResult()
                                                      );
            }