use of uk.gov.di.authentication.frontendapi.entity.SignupRequest in project di-authentication-api by alphagov.
the class SignupIntegrationTest method shouldReturn200WhenValidSignUpRequest.
@ParameterizedTest
@MethodSource("consentValues")
void shouldReturn200WhenValidSignUpRequest(boolean consentRequired) throws IOException, Json.JsonException {
String sessionId = redis.createSession();
Map<String, String> headers = new HashMap<>();
headers.put("Session-Id", sessionId);
headers.put("Client-Session-Id", CLIENT_SESSION_ID);
headers.put("X-API-Key", FRONTEND_API_KEY);
Scope scope = new Scope();
scope.add(OIDCScopeValue.OPENID);
AuthenticationRequest authRequest = new AuthenticationRequest.Builder(ResponseType.CODE, scope, new ClientID(CLIENT_ID), URI.create(REDIRECT_URI)).nonce(new Nonce()).build();
redis.createClientSession(CLIENT_SESSION_ID, authRequest.toParameters());
clientStore.registerClient(CLIENT_ID, "The test client", singletonList(REDIRECT_URI), singletonList("test-client@test.com"), singletonList(scope.toString()), Base64.getMimeEncoder().encodeToString(GENERATE_RSA_KEY_PAIR().getPublic().getEncoded()), singletonList("http://localhost/post-redirect-logout"), "http://example.com", String.valueOf(ServiceType.MANDATORY), "https://test.com", "public", consentRequired);
var response = makeRequest(Optional.of(new SignupRequest("joe.bloggs+5@digital.cabinet-office.gov.uk", "password-1")), headers, Map.of());
assertThat(response, hasStatus(200));
SignUpResponse signUpResponse = objectMapper.readValue(response.getBody(), SignUpResponse.class);
assertThat(signUpResponse.isConsentRequired(), equalTo(consentRequired));
assertTrue(userStore.userExists("joe.bloggs+5@digital.cabinet-office.gov.uk"));
assertEventTypesReceived(auditTopic, List.of(CREATE_ACCOUNT));
}
Aggregations