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());
}
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);
}
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();
}
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);
}
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);
}
Aggregations