-
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
Co-authored-by: Aliaksandr Stsiapanay <[email protected]>
- Loading branch information
1 parent
8e4fcd9
commit 500b1ab
Showing
3 changed files
with
95 additions
and
30 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
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 |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verifyNoInteractions; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
|
@@ -61,6 +62,8 @@ public void beforeEach() { | |
settings.put("jwksUrl", "http://host/jwks"); | ||
settings.put("rolePath", "roles"); | ||
settings.put("issuerPattern", "issuer"); | ||
settings.put("loggingKey", "email"); | ||
settings.put("loggingSalt", "salt"); | ||
} | ||
|
||
@Test | ||
|
@@ -291,6 +294,32 @@ public void testExtractClaims_11() throws JwkException { | |
}); | ||
} | ||
|
||
@Test | ||
public void testExtractClaims_12() { | ||
settings.put("disableJwtVerification", Boolean.TRUE); | ||
IdentityProvider identityProvider = new IdentityProvider(settings, vertx, url -> jwkProvider); | ||
Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) keyPair.getPublic(), (RSAPrivateKey) keyPair.getPrivate()); | ||
|
||
String token = JWT.create().withHeader(Map.of("kid", "kid1")) | ||
.withClaim("roles", List.of("role")) | ||
.withClaim("email", "[email protected]") | ||
.withClaim("sub", "sub").sign(algorithm); | ||
|
||
Future<ExtractedClaims> result = identityProvider.extractClaims(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()); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testMatch_Failure() { | ||
IdentityProvider identityProvider = new IdentityProvider(settings, vertx, url -> jwkProvider); | ||
|