-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…497)
- Loading branch information
1 parent
3cc5e0a
commit 72871a1
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,6 +360,51 @@ public void testExtractClaims_13() { | |
}); | ||
} | ||
|
||
@Test | ||
public void testExtractClaims_14() { | ||
settings.put("disableJwtVerification", Boolean.TRUE); | ||
IdentityProvider identityProvider = new IdentityProvider(settings, vertx, client, url -> jwkProvider, factory); | ||
Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) keyPair.getPublic(), (RSAPrivateKey) keyPair.getPrivate()); | ||
|
||
String token = JWT.create().withHeader(Map.of("kid", "kid1")) | ||
// test with a single role as a string field | ||
.withClaim("roles", "role") | ||
.withClaim("email", "[email protected]") | ||
.withClaim("id", 15) | ||
.withClaim("title", "title") | ||
.withClaim("access", List.of("read", "write")) | ||
.withClaim("expire", new Date(1713355825858L)) | ||
.withClaim("numberList", List.of("15", "17", "34")) | ||
.withClaim("map", Map.of("a", List.of("b"))) | ||
.withClaim("sub", "sub").sign(algorithm); | ||
|
||
Future<ExtractedClaims> result = identityProvider.extractClaimsFromJwt(JWT.decode(token)); | ||
|
||
verifyNoInteractions(jwkProvider); | ||
|
||
assertNotNull(result); | ||
result.onComplete(res -> { | ||
assertTrue(res.succeeded()); | ||
ExtractedClaims claims = res.result(); | ||
assertNotNull(claims); | ||
assertEquals(List.of("role"), claims.userRoles()); | ||
assertEquals("sub", claims.sub()); | ||
assertNotNull(claims.userHash()); | ||
Map<String, List<String>> userClaims = claims.userClaims(); | ||
// assert user claim | ||
assertEquals(9, userClaims.size()); | ||
assertEquals(List.of("sub"), userClaims.get("sub")); | ||
assertEquals(List.of("read", "write"), userClaims.get("access")); | ||
assertEquals(List.of("role"), userClaims.get("roles")); | ||
assertEquals(List.of(), userClaims.get("expire")); | ||
assertEquals(List.of("15", "17", "34"), userClaims.get("numberList")); | ||
assertEquals(List.of(), userClaims.get("id")); | ||
assertEquals(List.of("title"), userClaims.get("title")); | ||
assertEquals(List.of(), userClaims.get("map")); | ||
assertEquals(List.of("[email protected]"), userClaims.get("email")); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testExtractClaims_FromUserInfo_01() { | ||
settings.remove("jwksUrl"); | ||
|