Skip to content

Commit

Permalink
Fix the obo authenticator test
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Aug 3, 2023
1 parent 1da0310 commit 0bd2545
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private AuthCredentials extractCredentials0(final RestRequest request) {
}

final String tokenType = claims.get(TOKEN_TYPE_CLAIM).toString();
if (tokenType != TOKEN_TYPE) {
if (!tokenType.equals(TOKEN_TYPE)) {
log.error("This toke is not verifying as an on-behalf-of token");
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.crypto.SecretKey;
Expand Down Expand Up @@ -169,7 +168,7 @@ public void testBearer() throws Exception {
Assert.assertEquals("Leonard McCoy", credentials.getUsername());
Assert.assertEquals(0, credentials.getSecurityRoles().size());
Assert.assertEquals(0, credentials.getBackendRoles().size());
Assert.assertEquals(2, credentials.getAttributes().size());
Assert.assertEquals(3, credentials.getAttributes().size());
}

@Test
Expand Down Expand Up @@ -227,10 +226,10 @@ public void testRoles() throws Exception {
public void testNoTokenType() throws Exception {

final AuthCredentials credentials = extractCredentialsFromJwtHeader(
signingKeyB64Encoded,
claimsEncryptionKey,
Jwts.builder().setSubject("Leonard McCoy").claim("dr", "role1,role2").setAudience("svc1"),
true
signingKeyB64Encoded,
claimsEncryptionKey,
Jwts.builder().setSubject("Leonard McCoy").claim("dr", "role1,role2").setAudience("svc1"),
true
);

Assert.assertNull(credentials);
Expand Down

0 comments on commit 0bd2545

Please sign in to comment.