use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project di-authentication-api by alphagov.
the class UpdateProfileHandlerTest method generateValidClientSessionAndAuthRequest.
private AuthenticationRequest generateValidClientSessionAndAuthRequest(ClientID clientID) {
ResponseType responseType = new ResponseType(ResponseType.Value.CODE);
State state = new State();
AuthenticationRequest authRequest = new AuthenticationRequest.Builder(responseType, SCOPES, clientID, REDIRECT_URI).state(state).nonce(new Nonce()).build();
ClientSession clientSession = new ClientSession(authRequest.toParameters(), LocalDateTime.now(), mock(VectorOfTrust.class));
when(clientSessionService.getClientSessionFromRequestHeaders(anyMap())).thenReturn(Optional.of(clientSession));
return authRequest;
}
use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project di-authentication-api by alphagov.
the class UpdateProfileHandlerTest method shouldReturn204WhenUpdatingProfileWithConsent.
@Test
void shouldReturn204WhenUpdatingProfileWithConsent() throws ClientNotFoundException, URISyntaxException {
usingValidSession();
APIGatewayProxyRequestEvent event = new APIGatewayProxyRequestEvent();
ClientID clientID = new ClientID();
AuthorizationCode authorizationCode = new AuthorizationCode();
AuthenticationRequest authRequest = generateValidClientSessionAndAuthRequest(clientID);
AuthenticationSuccessResponse authSuccessResponse = new AuthenticationSuccessResponse(authRequest.getRedirectionURI(), authorizationCode, null, null, authRequest.getState(), null, null);
when(authenticationService.getUserProfileFromEmail(TEST_EMAIL_ADDRESS)).thenReturn(Optional.of(generateUserProfileWithoutConsent()));
event.setHeaders(Map.of(COOKIE, buildCookieString("gs", SESSION_ID + "." + CLIENT_SESSION_ID, 3600, "Secure; HttpOnly;", "domain")));
event.setBody(format("{ \"email\": \"%s\", \"updateProfileType\": \"%s\", \"profileInformation\": \"%s\" }", TEST_EMAIL_ADDRESS, CAPTURE_CONSENT, CONSENT_VALUE));
APIGatewayProxyResponseEvent result = makeHandlerRequest(event);
verify(authenticationService).updateConsent(eq(TEST_EMAIL_ADDRESS), any(ClientConsent.class));
assertThat(result, hasStatus(204));
verify(auditService).submitAuditEvent(UPDATE_PROFILE_CONSENT_UPDATED, "request-id", session.getSessionId(), clientID.getValue(), INTERNAL_SUBJECT, TEST_EMAIL_ADDRESS, "", PHONE_NUMBER, PersistentIdHelper.PERSISTENT_ID_UNKNOWN_VALUE);
}
use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project di-authentication-api by alphagov.
the class VerifyCodeHandlerTest method withAuthenticationRequest.
private AuthenticationRequest withAuthenticationRequest(String clientId) {
Scope scope = new Scope();
scope.add(OIDCScopeValue.OPENID);
return new AuthenticationRequest.Builder(new ResponseType(ResponseType.Value.CODE), scope, new ClientID(clientId), REDIRECT_URI).state(new State()).nonce(new Nonce()).build();
}
use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project di-authentication-api by alphagov.
the class ProcessingIdentityHandlerTest method getClientSession.
private ClientSession getClientSession() {
ResponseType responseType = new ResponseType(ResponseType.Value.CODE);
Scope scope = new Scope();
scope.add(OIDCScopeValue.OPENID);
AuthenticationRequest authRequest = new AuthenticationRequest.Builder(responseType, scope, new ClientID(CLIENT_ID), URI.create("http://localhost/redirect")).build();
return new ClientSession(authRequest.toParameters(), null, mock(VectorOfTrust.class));
}
use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project di-authentication-api by alphagov.
the class AuthCodeIntegrationTest method generateAuthRequest.
private AuthenticationRequest generateAuthRequest() {
ResponseType responseType = new ResponseType(ResponseType.Value.CODE);
State state = new State();
Scope scope = new Scope();
Nonce nonce = new Nonce();
scope.add(OIDCScopeValue.OPENID);
return new AuthenticationRequest.Builder(responseType, scope, CLIENT_ID, REDIRECT_URI).state(state).nonce(nonce).build();
}
Aggregations