use of uk.gov.ida.hub.policy.domain.IdpSelected in project verify-hub by alphagov.
the class AuthnRequestFromTransactionHandlerTest method stateControllerInvokedFromSessionRepositoryForselectedIdp.
@Test
public void stateControllerInvokedFromSessionRepositoryForselectedIdp() {
SessionId sessionId = new SessionId("aSessionId");
IdpSelected idpSelected = new IdpSelected(IDP_ENTITY_ID, PRINCIPAL_IP_ADDRESS, REGISTERING, REQUESTED_LOA);
IdpSelectingStateControllerSpy idpSelectingStateController = new IdpSelectingStateControllerSpy();
when(sessionRepository.getStateController(sessionId, IdpSelectingState.class)).thenReturn((idpSelectingStateController));
authnRequestFromTransactionHandler.selectIdpForGivenSessionId(sessionId, idpSelected);
assertThat(idpSelectingStateController.idpEntityId()).isEqualTo(IDP_ENTITY_ID);
assertThat(idpSelectingStateController.principalIpAddress()).isEqualTo(PRINCIPAL_IP_ADDRESS);
assertThat(idpSelectingStateController.registering()).isEqualTo(REGISTERING);
assertThat(idpSelectingStateController.getRequestedLoa()).isEqualTo(REQUESTED_LOA);
}
use of uk.gov.ida.hub.policy.domain.IdpSelected in project verify-hub by alphagov.
the class AuthnRequestFromTransactionResourceIntegrationTest method badEntityResponseThrown_WhenMandatoryFieldsAreMissing.
@Test
public void badEntityResponseThrown_WhenMandatoryFieldsAreMissing() throws Exception {
sessionId = aSessionIsCreated();
Response response = postIdpSelected(new IdpSelected(null, null, null, null));
assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_UNPROCESSABLE_ENTITY);
ValidationErrorMessage msg = response.readEntity(ValidationErrorMessage.class);
assertThat(msg.getErrors()).contains("selectedIdpEntityId may not be empty");
assertThat(msg.getErrors()).contains("principalIpAddress may not be empty");
assertThat(msg.getErrors()).contains("registration may not be null");
assertThat(msg.getErrors()).contains("requestedLoa may not be null");
}
use of uk.gov.ida.hub.policy.domain.IdpSelected in project verify-hub by alphagov.
the class AuthnRequestFromTransactionResourceIntegrationTest method idpSelected_shouldThrowIfIdpIsNotAvailable.
@Test
public void idpSelected_shouldThrowIfIdpIsNotAvailable() throws JsonProcessingException {
sessionId = aSessionIsCreated();
IdpSelected idpSelected = new IdpSelected("does-not-exist", principalIpAddress, REGISTERING, LEVEL_2);
Response response = postIdpSelected(idpSelected);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto error = response.readEntity(ErrorStatusDto.class);
assertThat(error.getExceptionType()).isEqualTo(ExceptionType.STATE_PROCESSING_VALIDATION);
}
use of uk.gov.ida.hub.policy.domain.IdpSelected in project verify-hub by alphagov.
the class AuthnRequestFromTransactionResourceIntegrationTest method selectIdp_shouldReturnSuccessResponseAndAudit.
@Test
public void selectIdp_shouldReturnSuccessResponseAndAudit() throws JsonProcessingException {
sessionId = aSessionIsCreated();
Response response = postIdpSelected(new IdpSelected(idpEntityId, principalIpAddress, REGISTERING, LEVEL_2));
assertThat(response.getStatus()).isEqualTo(Response.Status.CREATED.getStatusCode());
// one session started event, one idp selected event
assertThat(eventSinkStub.getRecordedRequest()).hasSize(2);
String recordedEvent = eventSinkStub.getLastRequest().getEntity();
assertThat(recordedEvent).contains(sessionId.getSessionId());
assertThat(recordedEvent).contains(principalIpAddress);
assertThat(recordedEvent).contains(EventSinkHubEventConstants.SessionEvents.IDP_SELECTED);
assertThat(recordedEvent).contains(samlResponse.getId());
}
use of uk.gov.ida.hub.policy.domain.IdpSelected in project verify-hub by alphagov.
the class SessionResourceIntegrationTest method anIdpIsSelectedForSignIn.
private void anIdpIsSelectedForSignIn(SessionId sessionId, String idpEntityId) {
final URI policyUri = policy.uri(UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_SELECT_IDP_RESOURCE).build(sessionId).getPath());
client.target(policyUri).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(new IdpSelected(idpEntityId, "this-is-an-ip-address", SIGNING_IN, REQUESTED_LOA)));
}
Aggregations