Skip to content

Commit

Permalink
Fix wrong Authorization header in token tests (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
adutra authored Dec 2, 2024
1 parent a88f24b commit afd14d9
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2330,9 +2330,7 @@ public void testTokenExpiry() {
.untilAsserted(
() -> {
try (Response response =
newRequest(
"http://localhost:%d/api/management/v1/principals", "Bearer " + newToken)
.get()) {
newRequest("http://localhost:%d/api/management/v1/principals", newToken).get()) {
assertThat(response)
.returns(Response.Status.UNAUTHORIZED.getStatusCode(), Response::getStatus);
}
Expand All @@ -2345,8 +2343,7 @@ public void testTokenInactive() {
String newToken =
defaultJwt().withClaim(CLAIM_KEY_ACTIVE, false).sign(Algorithm.HMAC256("polaris"));
try (Response response =
newRequest("http://localhost:%d/api/management/v1/principals", "Bearer " + newToken)
.get()) {
newRequest("http://localhost:%d/api/management/v1/principals", newToken).get()) {
assertThat(response)
.returns(Response.Status.UNAUTHORIZED.getStatusCode(), Response::getStatus);
}
Expand All @@ -2357,8 +2354,7 @@ public void testTokenInvalidSignature() {
// SignatureVerificationException - if the signature is invalid.
String newToken = defaultJwt().sign(Algorithm.HMAC256("invalid_secret"));
try (Response response =
newRequest("http://localhost:%d/api/management/v1/principals", "Bearer " + newToken)
.get()) {
newRequest("http://localhost:%d/api/management/v1/principals", newToken).get()) {
assertThat(response)
.returns(Response.Status.UNAUTHORIZED.getStatusCode(), Response::getStatus);
}
Expand All @@ -2369,8 +2365,7 @@ public void testTokenInvalidPrincipalId() {
String newToken =
defaultJwt().withClaim(CLAIM_KEY_PRINCIPAL_ID, 0).sign(Algorithm.HMAC256("polaris"));
try (Response response =
newRequest("http://localhost:%d/api/management/v1/principals", "Bearer " + newToken)
.get()) {
newRequest("http://localhost:%d/api/management/v1/principals", newToken).get()) {
assertThat(response)
.returns(Response.Status.UNAUTHORIZED.getStatusCode(), Response::getStatus);
}
Expand Down

0 comments on commit afd14d9

Please sign in to comment.