Skip to content

Commit 1f57328

Browse files
[FEATURE] usage of JWKS with JWT (w/o OpenID connect)
Signed-off-by: Sebastian Michalski <shekerama@gmail.com>
1 parent e3bee23 commit 1f57328

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticatorTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,26 @@ public void jwksUriTest() {
8484
Assert.assertEquals(requiredIssuer, jwtAuth.getRequiredIssuer());
8585
}
8686

87+
@Test
88+
public void jwksMissingRequiredAudienceAndIssuerTest() {
89+
Settings settings = Settings.builder()
90+
.put("jwks_uri", mockIdpServer.getJwksUri())
91+
.build();
92+
93+
HTTPJwtKeyByOpenIdConnectAuthenticator jwtAuth = new HTTPJwtKeyByOpenIdConnectAuthenticator(settings, null);
94+
95+
AuthCredentials creds = jwtAuth.extractCredentials(new FakeRestRequest(
96+
ImmutableMap.of("Authorization", TestJwts.MC_COY_SIGNED_OCT_1), new HashMap<>()), null);
97+
98+
Assert.assertNotNull(creds);
99+
Assert.assertEquals(TestJwts.MCCOY_SUBJECT, creds.getUsername());
100+
Assert.assertEquals(TestJwts.TEST_AUDIENCE, creds.getAttributes().get("attr.jwt.aud"));
101+
Assert.assertEquals(0, creds.getBackendRoles().size());
102+
Assert.assertEquals(3, creds.getAttributes().size());
103+
Assert.assertNull(jwtAuth.getRequiredAudience());
104+
Assert.assertNull(jwtAuth.getRequiredIssuer());
105+
}
106+
87107
@Test
88108
public void jwksUriMissingTest() {
89109
var exception = Assert.assertThrows(Exception.class, () -> {

0 commit comments

Comments
 (0)