Search in sources :

Example 1 with CountrySelectedStateController

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

the class CountriesServiceTest method shouldReturnErrorWhenAnInvalidCountryIsSelected.

@Test(expected = EidasCountryNotSupportedException.class)
public void shouldReturnErrorWhenAnInvalidCountryIsSelected() {
    CountrySelectedStateController mockCountrySelectedStateController = mock(CountrySelectedStateController.class);
    when(sessionRepository.getStateController(sessionId, SessionStartedState.class)).thenReturn(mockCountrySelectedStateController);
    setSystemWideCountries(COUNTRY_1);
    service.setSelectedCountry(sessionId, "not-a-valid-country-code");
}
Also used : CountrySelectedStateController(uk.gov.ida.hub.policy.domain.controller.CountrySelectedStateController) Test(org.junit.Test)

Example 2 with CountrySelectedStateController

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

the class CountriesServiceTest method shouldSetSelectedCountry.

@Test
public void shouldSetSelectedCountry() {
    CountrySelectedStateController mockCountrySelectedStateController = mock(CountrySelectedStateController.class);
    when(sessionRepository.getStateController(sessionId, SessionStartedState.class)).thenReturn(mockCountrySelectedStateController);
    setSystemWideCountries(COUNTRY_1);
    service.setSelectedCountry(sessionId, COUNTRY_1.getSimpleId());
    verify(mockCountrySelectedStateController).selectCountry(COUNTRY_1.getEntityId());
}
Also used : CountrySelectedStateController(uk.gov.ida.hub.policy.domain.controller.CountrySelectedStateController) Test(org.junit.Test)

Example 3 with CountrySelectedStateController

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

the class AuthnResponseFromCountryService method receiveAuthnResponseFromCountry.

public ResponseAction receiveAuthnResponseFromCountry(SessionId sessionId, SamlAuthnResponseContainerDto responseFromCountry) {
    CountrySelectedStateController stateController = (CountrySelectedStateController) sessionRepository.getStateController(sessionId, CountrySelectedState.class);
    String matchingServiceEntityId = stateController.getMatchingServiceEntityId();
    stateController.validateCountryIsIn(countriesService.getCountries(sessionId));
    SamlAuthnResponseTranslatorDto responseToTranslate = samlAuthnResponseTranslatorDtoFactory.fromSamlAuthnResponseContainerDto(responseFromCountry, matchingServiceEntityId);
    InboundResponseFromCountry translatedResponse = samlEngineProxy.translateAuthnResponseFromCountry(responseToTranslate);
    if (translatedResponse.getStatus() != IdpIdaStatus.Status.Success)
        return other(sessionId, false);
    validateSuccessfulResponse(stateController, translatedResponse);
    EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = getEidasAttributeQueryRequestDto(stateController, translatedResponse);
    stateController.transitionToEidasCycle0And1MatchRequestSentState(eidasAttributeQueryRequestDto, responseFromCountry.getPrincipalIPAddressAsSeenByHub(), translatedResponse.getIssuer());
    AttributeQueryContainerDto aqr = samlEngineProxy.generateEidasAttributeQuery(eidasAttributeQueryRequestDto);
    samlSoapProxyProxy.sendHubMatchingServiceRequest(sessionId, getAttributeQueryRequest(aqr));
    return ResponseAction.success(sessionId, false, LevelOfAssurance.LEVEL_2);
}
Also used : AttributeQueryContainerDto(uk.gov.ida.hub.policy.contracts.AttributeQueryContainerDto) InboundResponseFromCountry(uk.gov.ida.hub.policy.domain.InboundResponseFromCountry) SamlAuthnResponseTranslatorDto(uk.gov.ida.hub.policy.contracts.SamlAuthnResponseTranslatorDto) CountrySelectedState(uk.gov.ida.hub.policy.domain.state.CountrySelectedState) CountrySelectedStateController(uk.gov.ida.hub.policy.domain.controller.CountrySelectedStateController) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto)

Aggregations

CountrySelectedStateController (uk.gov.ida.hub.policy.domain.controller.CountrySelectedStateController)3 Test (org.junit.Test)2 AttributeQueryContainerDto (uk.gov.ida.hub.policy.contracts.AttributeQueryContainerDto)1 EidasAttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto)1 SamlAuthnResponseTranslatorDto (uk.gov.ida.hub.policy.contracts.SamlAuthnResponseTranslatorDto)1 InboundResponseFromCountry (uk.gov.ida.hub.policy.domain.InboundResponseFromCountry)1 CountrySelectedState (uk.gov.ida.hub.policy.domain.state.CountrySelectedState)1