@Test public void getJwkListWhenEmpty() { JWKContext jwkContext = new JWKContext(Collections.emptyList()); assertThat(jwkContext.getJwkList()).isEmpty(); }
private JWTClaimsSet createClaimsSet(JWT parsedToken, List<JWK> jwkList) { try { return this.jwtProcessor.process(parsedToken, new JWKContext(jwkList)); } catch (BadJOSEException | JOSEException e) { throw new JwtException("Failed to validate the token", e); } }
@Override public List<JWK> get(JWKSelector jwkSelector, JWKContext context) { return context.getJwkList(); } }
@Test public void constructorWhenNullThenIllegalArgumentException() { List<JWK> jwkList = null; assertThatCode(() -> new JWKContext(jwkList)) .isInstanceOf(IllegalArgumentException.class); }
@Override public List<JWK> get(JWKSelector jwkSelector, JWKContext context) { return context.getJwkList(); } }
@Test public void getJwkListWhenNotEmpty() { JWK key = mock(JWK.class); JWKContext jwkContext = new JWKContext(Arrays.asList(key)); assertThat(jwkContext.getJwkList()).containsOnly(key); } }
@Test public void getWhenKeysNotEmptyThenContainsKeys() { JWK key = mock(JWK.class); JWKContext jwkContext = new JWKContext(Arrays.asList(key)); assertThat(this.source.get(null, jwkContext)).containsOnly(key); }
private JWTClaimsSet createClaimsSet(JWT parsedToken, List<JWK> jwkList) { try { return this.jwtProcessor.process(parsedToken, new JWKContext(jwkList)); } catch (BadJOSEException | JOSEException e) { throw new JwtException("Failed to validate the token", e); } }