Skip to content

Commit

Permalink
Change invalid token test to expired
Browse files Browse the repository at this point in the history
It does not currently seem possible to properly configure
WireMock stubs for the completely bogus auth token to
avoid "unstubbed" request error log messages in runtime.

So, for now let's use an expired token to validate the
handling of "unauthenticated" requests.
  • Loading branch information
dimas-b committed Sep 9, 2021
1 parent 9e5fd2b commit eb7cba5
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ private String getJwtToken() {
return Jwt.preferredUserName("test_user").issuer("https://server.example.com").sign();
}

private String getExpiredJwtToken() {
return Jwt.preferredUserName("expired")
.issuer("https://server.example.com")
.expiresAt(0)
.sign();
}

@Test
void testValidJwt() {
withClientCustomizer(
Expand All @@ -48,9 +55,9 @@ void testValidJwt() {
}

@Test
void testInvalidToken() {
void testExpiredToken() {
withClientCustomizer(
b -> b.withAuthentication(BearerAuthenticationProvider.create("invalid_token")));
b -> b.withAuthentication(BearerAuthenticationProvider.create(getExpiredJwtToken())));
assertThatThrownBy(() -> client().getTreeApi().getAllReferences())
.isInstanceOfSatisfying(
NessieNotAuthorizedException.class,
Expand Down

0 comments on commit eb7cba5

Please sign in to comment.