private UserInfoResponse getUserInfo(final String accessToken) { logger.debug("Session validation successful. Getting user information"); final UserInfoClient userInfoClient = new UserInfoClient(this.openIdConfiguration.getUserInfoEndpoint()); final UserInfoResponse userInfoResponse = userInfoClient.execUserInfo(accessToken); logger.trace("userInfoResponse.getStatus(): '{}'", userInfoResponse.getStatus()); logger.trace("userInfoResponse.getErrorType(): '{}'", userInfoResponse.getErrorType()); logger.debug("userInfoResponse.getClaims(): '{}'", userInfoResponse.getClaims()); return userInfoResponse; }
@Test public void requestUserInfoInvalidRequest() throws Exception { showTitle("requestUserInfoInvalidRequest"); UserInfoClient userInfoClient = new UserInfoClient(userInfoEndpoint); UserInfoResponse response = userInfoClient.execUserInfo(null); showClient(userInfoClient); assertEquals(response.getStatus(), 400, "Unexpected response code: " + response.getStatus()); assertNotNull(response.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(response.getErrorDescription(), "Unexpected result: errorDescription not found"); }
@Test public void requestUserInfoInvalidToken() throws Exception { showTitle("requestUserInfoInvalidToken"); UserInfoClient userInfoClient = new UserInfoClient(userInfoEndpoint); UserInfoResponse response = userInfoClient.execUserInfo("INVALID_ACCESS_TOKEN"); showClient(userInfoClient); assertEquals(response.getStatus(), 400, "Unexpected response code: " + response.getStatus()); assertNotNull(response.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(response.getErrorDescription(), "Unexpected result: errorDescription not found"); }
assertNotNull(userInfoResponse.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse.getErrorDescription(), "Unexpected result: errorDescription not found");
showClient(userInfoClient); assertEquals(userInfoResponse.getStatus(), 403, "Unexpected response code: " + userInfoResponse.getStatus()); assertNotNull(userInfoResponse.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse.getErrorDescription(), "Unexpected result: errorDescription not found");
assertNotNull(userInfoResponse.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse.getErrorDescription(), "Unexpected result: errorDescription not found");
assertNotNull(userInfoResponse.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse.getErrorDescription(), "Unexpected result: errorDescription not found");
assertEquals(userInfoResponse.getErrorType(), UserInfoErrorResponseType.INSUFFICIENT_SCOPE);
assertNotNull(response7.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(response7.getErrorDescription(), "Unexpected result: errorDescription not found");
assertNotNull(userInfoResponse2.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse2.getErrorDescription(), "Unexpected result: errorDescription not found");
assertNotNull(userInfoResponse2.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse2.getErrorDescription(), "Unexpected result: errorDescription not found");
assertNotNull(userInfoResponse2.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse2.getErrorDescription(), "Unexpected result: errorDescription not found");
assertNotNull(userInfoResponse1.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse1.getErrorDescription(), "Unexpected result: errorDescription not found"); assertNotNull(userInfoResponse2.getErrorType(), "Unexpected result: errorType not found"); assertNotNull(userInfoResponse2.getErrorDescription(), "Unexpected result: errorDescription not found");