use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionServiceTest method shouldUpdateSessionStateAndCallSamlEngineWhenResponseFromHubIsRequested.
@Test
public void shouldUpdateSessionStateAndCallSamlEngineWhenResponseFromHubIsRequested() {
// Given
SessionId sessionId = createNewSessionId();
when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
ResponseFromHub responseFromHub = aResponseFromHubDto().build();
when(authnRequestHandler.getResponseFromHub(sessionId)).thenReturn(responseFromHub);
AuthnResponseFromHubContainerDto expected = anAuthnResponseFromHubContainerDto().build();
when(samlEngineProxy.generateRpAuthnResponse(responseFromHub)).thenReturn(expected);
// When
AuthnResponseFromHubContainerDto actual = service.getRpAuthnResponse(sessionId);
// Then
assertThat(actual).isEqualTo(expected);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionServiceTest method shouldThrowSessionNotFoundWhenSessionDoesNotExistAndAResponseFromHubIsRequested.
@Test(expected = SessionNotFoundException.class)
public void shouldThrowSessionNotFoundWhenSessionDoesNotExistAndAResponseFromHubIsRequested() {
SessionId sessionId = createNewSessionId();
when(sessionRepository.sessionExists(sessionId)).thenReturn(false);
service.getRpAuthnResponse(sessionId);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionServiceTest method shouldCreateSessionWithTransactionSupportsEidas.
@Test
public void shouldCreateSessionWithTransactionSupportsEidas() throws Exception {
// Given
URI assertionConsumerServiceUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().build();
final SessionId sessionId = SessionIdBuilder.aSessionId().with("coffee-pasta").build();
givenSamlEngineTranslatesRequest(samlResponse);
givenConfigReturnsAssertionConsumerServiceURLFor(samlResponse, assertionConsumerServiceUri);
givenConfigReturnsTransactionSupportsEidas(samlResponse, true);
givenSessionIsCreated(samlResponse, assertionConsumerServiceUri, sessionId, true);
// When
SessionId result = service.create(requestDto);
// Then
assertThat(result, is(sessionId));
verify(authnRequestHandler).handleRequestFromTransaction(samlResponse, requestDto.getRelayState(), requestDto.getPrincipalIPAddressAsSeenByHub(), assertionConsumerServiceUri, true);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionServiceTest method getSession_ThrowsExceptionWhenSessionDoesNotExists.
@Test(expected = SessionNotFoundException.class)
public void getSession_ThrowsExceptionWhenSessionDoesNotExists() {
SessionId sessionId = createNewSessionId();
when(sessionRepository.sessionExists(sessionId)).thenReturn(false);
assertThat(service.getSessionIfItExists(sessionId)).isEqualTo(sessionId);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionServiceTest method shouldCreateSessionIfProvidedAssertionConsumerServiceUrlMatches.
@Test
public void shouldCreateSessionIfProvidedAssertionConsumerServiceUrlMatches() throws Exception {
URI assertionConsumerServiceUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().withAssertionConsumerServiceUrl(assertionConsumerServiceUri).build();
final SessionId sessionId = SessionIdBuilder.aSessionId().with("coffee-pasta").build();
givenSamlEngineTranslatesRequest(samlResponse);
givenConfigReturnsAssertionConsumerServiceURLFor(samlResponse, assertionConsumerServiceUri);
givenSessionIsCreated(samlResponse, assertionConsumerServiceUri, sessionId, false);
SessionId result = service.create(requestDto);
assertThat(result, is(sessionId));
}
Aggregations