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