protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { var token = _tokenProvider.GenerateApiToken("hmcts-video-api-client", 2); request.Headers.Add("Authorization", $"Bearer {token}"); return(base.SendAsync(request, cancellationToken)); }
public void Should_be_invalid_token_when_token_generated_with_different_secret() { var secretKey = "F8pf/zwOgm/kASEFs+BKRDdyq+RhHCQ9i9tPjeaPjUebm6HvzXKIsr/nX28wpwAZoWRG0FQK9LVf6nrkW/vg4w=="; var customTokenSettings = new KinlyConfiguration { ApiSecret = secretKey, Audience = Audience, Issuer = Issuer }; _customJwtTokenProvider = new CustomJwtTokenProvider(customTokenSettings); var token = _customJwtTokenProvider.GenerateApiToken("Test User", 1); var claimsPrincipal = _customJwtTokenHandler.IsValidToken(token); claimsPrincipal.Should().BeFalse(); }
public void Should_generate_jwt_token_when_generate_token_is_called() { var generateToken = _customJwtTokenProvider.GenerateApiToken("Test User", 30); generateToken.Should().NotBeNullOrEmpty(); }