public void TestFixtureSetUp() { m_authService = new AuthServiceMock(AuthServiceMock.KeyType.ECDSA_P256); m_accessTokenValidator = AccessTokenValidatorFactory.CreateRemoteValidator( new HttpClient(), m_authService.Host ); m_authService.SetupJwks().Wait(); }
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(); }
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() ); }
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() ); }