use of uk.gov.di.ipv.cri.passport.library.domain.AuthParams in project di-ipv-cri-uk-passport-back by alphagov.
the class JwtAuthorizationRequestHandlerTest method shouldReturnClaimsAsJsonFromJWT.
@Test
void shouldReturnClaimsAsJsonFromJWT() throws Exception {
when(jarValidator.validateRequestJwt(any(), anyString())).thenReturn(signedJWT.getJWTClaimsSet());
var event = new APIGatewayProxyRequestEvent();
Map<String, String> map = new HashMap<>();
map.put("client_id", "TEST");
event.setHeaders(map);
event.setBody(signedJWT.serialize());
var response = underTest.handleRequest(event, context);
Map<String, Object> claims = OBJECT_MAPPER.readValue(response.getBody(), new TypeReference<>() {
});
AuthParams authParams = OBJECT_MAPPER.convertValue(claims.get("authParams"), new TypeReference<>() {
});
assertEquals("test-user-id", claims.get("user_id"));
assertEquals("code", authParams.getResponseType());
assertEquals("test-client", authParams.getClientId());
assertEquals("test-state", authParams.getState());
assertEquals("http://example.com", authParams.getRedirectUri());
Map<String, Object> sharedClaims = OBJECT_MAPPER.convertValue(claims.get("shared_claims"), new TypeReference<>() {
});
assertEquals(Arrays.asList("01/01/1980", "02/01/1980"), sharedClaims.get("dateOfBirths"));
assertEquals(Collections.singletonList("123 random street, M13 7GE"), sharedClaims.get("addresses"));
assertEquals(Arrays.asList("Daniel", "Dan", "Danny"), sharedClaims.get("givenNames"));
}
Aggregations