Search in sources :

Example 1 with EidasCountryDto

use of uk.gov.ida.hub.policy.domain.EidasCountryDto in project verify-hub by alphagov.

the class CountriesService method setSelectedCountry.

public void setSelectedCountry(SessionId sessionId, String countryCode) {
    ensureTransactionSupportsEidas(sessionId);
    List<EidasCountryDto> supportedCountries = getCountries(sessionId);
    Optional<EidasCountryDto> selectedCountry = supportedCountries.stream().filter(country -> country.getSimpleId().equals(countryCode)).findFirst();
    if (!selectedCountry.isPresent()) {
        throw new EidasCountryNotSupportedException(sessionId, countryCode);
    }
    Class<? extends State> expectedStateClass = SessionStartedState.class;
    if (sessionRepository.isSessionInState(sessionId, CountrySelectedState.class)) {
        expectedStateClass = CountrySelectedState.class;
    }
    CountrySelectingStateController countrySelectingStateController = (CountrySelectingStateController) sessionRepository.getStateController(sessionId, expectedStateClass);
    countrySelectingStateController.selectCountry(selectedCountry.get().getEntityId());
}
Also used : SessionId(uk.gov.ida.hub.policy.domain.SessionId) TransactionsConfigProxy(uk.gov.ida.hub.policy.proxy.TransactionsConfigProxy) SessionStartedState(uk.gov.ida.hub.policy.domain.state.SessionStartedState) CountrySelectedState(uk.gov.ida.hub.policy.domain.state.CountrySelectedState) EidasCountryDto(uk.gov.ida.hub.policy.domain.EidasCountryDto) CountrySelectingStateController(uk.gov.ida.hub.policy.domain.controller.CountrySelectingStateController) Collectors(java.util.stream.Collectors) SessionRepository(uk.gov.ida.hub.policy.domain.SessionRepository) Inject(javax.inject.Inject) EidasCountryNotSupportedException(uk.gov.ida.hub.policy.exception.EidasCountryNotSupportedException) List(java.util.List) State(uk.gov.ida.hub.policy.domain.State) Optional(java.util.Optional) CountrySelectingStateController(uk.gov.ida.hub.policy.domain.controller.CountrySelectingStateController) EidasCountryNotSupportedException(uk.gov.ida.hub.policy.exception.EidasCountryNotSupportedException) EidasCountryDto(uk.gov.ida.hub.policy.domain.EidasCountryDto) SessionStartedState(uk.gov.ida.hub.policy.domain.state.SessionStartedState)

Example 2 with EidasCountryDto

use of uk.gov.ida.hub.policy.domain.EidasCountryDto in project verify-hub by alphagov.

the class EidasSuccessfulMatchStateControllerTest method getPreparedResponse_shouldReturnResponse.

@Test
public void getPreparedResponse_shouldReturnResponse() {
    List<EidasCountryDto> enabledIdentityProviders = Arrays.asList(new EidasCountryDto("country-entity-id", "simple-id", true));
    ResponseFromHub expectedResponseFromHub = ResponseFromHubBuilder.aResponseFromHubDto().build();
    when(countriesService.getCountries(state.getSessionId())).thenReturn(enabledIdentityProviders);
    when(responseFromHubFactory.createSuccessResponseFromHub(state.getRequestId(), state.getMatchingServiceAssertion(), state.getRelayState(), state.getRequestIssuerEntityId(), state.getAssertionConsumerServiceUri())).thenReturn(expectedResponseFromHub);
    ResponseFromHub result = controller.getPreparedResponse();
    Assert.assertEquals(result, expectedResponseFromHub);
}
Also used : EidasCountryDto(uk.gov.ida.hub.policy.domain.EidasCountryDto) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 3 with EidasCountryDto

use of uk.gov.ida.hub.policy.domain.EidasCountryDto in project verify-hub by alphagov.

the class EidasSessionResourceContractTest method shouldGetValidatedEidasAuthnResponseFromSamlEngineVerification.

@PactVerification(value = SAML_ENGINE_SERVICE, fragment = "shouldGetValidatedEidasAuthnResponseFromSamlEngine")
@Test
public void shouldGetValidatedEidasAuthnResponseFromSamlEngineVerification() throws Exception {
    configStub.setupStubForEidasRPCountries(TEST_RP, EIDAS_COUNTRIES.stream().map(EidasCountryDto::getEntityId).collect(Collectors.toList()));
    SessionId sessionId = createSessionInCountrySelectingState();
    selectACountry(sessionId);
    Response response = postAuthnResponseToPolicy(sessionId);
    assertThatResponseIsSuccess(response);
    assertThatAQRReceivedBySamlSoapProxyHasSameDataAsSamlEngineSent();
}
Also used : Response(javax.ws.rs.core.Response) EidasCountryDto(uk.gov.ida.hub.policy.domain.EidasCountryDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test)

Example 4 with EidasCountryDto

use of uk.gov.ida.hub.policy.domain.EidasCountryDto in project verify-hub by alphagov.

the class CountrySelectedStateControllerTest method shouldThrowIfCountryNotInListSupplied.

@Test
public void shouldThrowIfCountryNotInListSupplied() {
    exception.expect(StateProcessingValidationException.class);
    exception.expectMessage(String.format("Country with entity id %s is not enabled for eidas", COUNTRY_ENTITY_ID));
    List<EidasCountryDto> enabledCountries = ImmutableList.of(new EidasCountryDto("ID1", "ID1", true), new EidasCountryDto("ID2", "ID2", true));
    controller.validateCountryIsIn(enabledCountries);
}
Also used : EidasCountryDto(uk.gov.ida.hub.policy.domain.EidasCountryDto) Test(org.junit.Test)

Example 5 with EidasCountryDto

use of uk.gov.ida.hub.policy.domain.EidasCountryDto in project verify-hub by alphagov.

the class CountrySelectedStateControllerTest method shouldNotThrowIfCountryInListSupplied.

@Test
public void shouldNotThrowIfCountryInListSupplied() {
    List<EidasCountryDto> enabledCountries = ImmutableList.of(new EidasCountryDto(COUNTRY_ENTITY_ID, COUNTRY_ENTITY_ID, true), new EidasCountryDto("ID2", "ID2", true));
    controller.validateCountryIsIn(enabledCountries);
}
Also used : EidasCountryDto(uk.gov.ida.hub.policy.domain.EidasCountryDto) Test(org.junit.Test)

Aggregations

EidasCountryDto (uk.gov.ida.hub.policy.domain.EidasCountryDto)7 Test (org.junit.Test)4 List (java.util.List)3 SessionId (uk.gov.ida.hub.policy.domain.SessionId)3 URI (java.net.URI)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Response (javax.ws.rs.core.Response)2 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)2 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)2 State (uk.gov.ida.hub.policy.domain.State)2 CountrySelectedState (uk.gov.ida.hub.policy.domain.state.CountrySelectedState)2 TransactionsConfigProxy (uk.gov.ida.hub.policy.proxy.TransactionsConfigProxy)2 PactVerification (au.com.dius.pact.consumer.PactVerification)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Optional (com.google.common.base.Optional)1 HttpStubRule (httpstub.HttpStubRule)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 UUID (java.util.UUID)1