Search in sources :

Example 1 with EidasAttributeQueryRequestDto

use of uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto in project verify-hub by alphagov.

the class EidasAttributeQueryRequestDtoBuilderTest method build.

@Test
public void build() throws Exception {
    Map<String, String> map = new HashMap<>();
    map.put("attribute", "attributeValue");
    EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto().build();
    assertThat(eidasAttributeQueryRequestDto.getRequestId()).isEqualTo("requestId");
    assertThat(eidasAttributeQueryRequestDto.getPersistentId()).isEqualTo(new PersistentId("nameId"));
    assertThat(eidasAttributeQueryRequestDto.getEncryptedIdentityAssertion()).isEqualTo("encryptedIdentityAssertion");
    assertThat(eidasAttributeQueryRequestDto.getAssertionConsumerServiceUri()).isEqualTo(URI.create("assertionConsumerServiceUri"));
    assertThat(eidasAttributeQueryRequestDto.getAuthnRequestIssuerEntityId()).isEqualTo("authnRequestIssuesEntityId");
    assertThat(eidasAttributeQueryRequestDto.getLevelOfAssurance()).isEqualTo(LevelOfAssurance.LEVEL_2);
    assertThat(eidasAttributeQueryRequestDto.getAttributeQueryUri()).isEqualTo(URI.create("matchingServiceAdapterUri"));
    assertThat(eidasAttributeQueryRequestDto.getMatchingServiceEntityId()).isEqualTo("matchingServiceAdapterEntityId");
    assertThat(eidasAttributeQueryRequestDto.getMatchingServiceRequestTimeOut()).isEqualTo(DateTime.now().plusHours(1));
    assertThat(eidasAttributeQueryRequestDto.isOnboarding()).isTrue();
    assertThat(eidasAttributeQueryRequestDto.getCycle3Dataset()).isEqualTo(Optional.of(new Cycle3Dataset(map)));
    assertThat(eidasAttributeQueryRequestDto.getUserAccountCreationAttributes()).isEqualTo(Optional.absent());
    assertThat(eidasAttributeQueryRequestDto.getAssertionExpiry()).isEqualTo(DateTime.now().plusHours(2));
}
Also used : Cycle3Dataset(uk.gov.ida.hub.policy.domain.Cycle3Dataset) HashMap(java.util.HashMap) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) Test(org.junit.Test)

Example 2 with EidasAttributeQueryRequestDto

use of uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto in project verify-hub by alphagov.

the class CountrySelectedStateControllerTest method shouldTransitionToEidasCycle0And1MatchRequestSentState.

@Test
public void shouldTransitionToEidasCycle0And1MatchRequestSentState() {
    final String ipAddress = "ip-address";
    when(transactionsConfigProxy.getMatchingServiceEntityId(state.getRequestIssuerEntityId())).thenReturn(MSA_ID);
    EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = anEidasAttributeQueryRequestDto().build();
    EidasCycle0And1MatchRequestSentState eidasCycle0And1MatchRequestSentState = new EidasCycle0And1MatchRequestSentState(state.getRequestId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getAssertionConsumerServiceUri(), new SessionId(state.getSessionId().getSessionId()), state.getTransactionSupportsEidas(), COUNTRY_ENTITY_ID, state.getRelayState().orNull(), eidasAttributeQueryRequestDto.getLevelOfAssurance(), MSA_ID, eidasAttributeQueryRequestDto.getEncryptedIdentityAssertion(), eidasAttributeQueryRequestDto.getPersistentId());
    controller.transitionToEidasCycle0And1MatchRequestSentState(eidasAttributeQueryRequestDto, ipAddress, COUNTRY_ENTITY_ID);
    verify(hubEventLogger).logIdpAuthnSucceededEvent(state.getSessionId(), state.getSessionExpiryTimestamp(), state.getCountryEntityId(), state.getRequestIssuerEntityId(), eidasAttributeQueryRequestDto.getPersistentId(), state.getRequestId(), state.getLevelsOfAssurance().get(0), state.getLevelsOfAssurance().get(state.getLevelsOfAssurance().size() - 1), eidasAttributeQueryRequestDto.getLevelOfAssurance(), com.google.common.base.Optional.absent(), ipAddress);
    verify(stateTransitionAction).transitionTo(eidasCycle0And1MatchRequestSentState);
}
Also used : EidasCycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.builder.EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto) Test(org.junit.Test)

Example 3 with EidasAttributeQueryRequestDto

use of uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto in project verify-hub by alphagov.

the class AttributeQueryServiceTest method shouldGenerateEidasAttributeQueryAndSendRequestToMatchingService.

@Test
public void shouldGenerateEidasAttributeQueryAndSendRequestToMatchingService() {
    final EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = anEidasAttributeQueryRequestDto().build();
    final AttributeQueryContainerDto attributeQueryContainerDto = anAttributeQueryContainerDto().build();
    final AttributeQueryRequest attributeQueryRequest = new AttributeQueryRequest(attributeQueryContainerDto.getId(), attributeQueryContainerDto.getIssuer(), attributeQueryContainerDto.getSamlRequest(), attributeQueryContainerDto.getMatchingServiceUri(), attributeQueryContainerDto.getAttributeQueryClientTimeOut(), eidasAttributeQueryRequestDto.isOnboarding());
    when(samlEngineProxy.generateEidasAttributeQuery(eidasAttributeQueryRequestDto)).thenReturn(attributeQueryContainerDto);
    service.sendAttributeQueryRequest(sessionId, eidasAttributeQueryRequestDto);
    verify(samlEngineProxy).generateEidasAttributeQuery(eidasAttributeQueryRequestDto);
    verify(samlSoapProxyProxy).sendHubMatchingServiceRequest(sessionId, attributeQueryRequest);
}
Also used : AttributeQueryContainerDto(uk.gov.ida.hub.policy.contracts.AttributeQueryContainerDto) AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto(uk.gov.ida.hub.policy.builder.AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto) AttributeQueryRequest(uk.gov.ida.hub.policy.proxy.AttributeQueryRequest) EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.builder.EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto) Test(org.junit.Test)

Example 4 with EidasAttributeQueryRequestDto

use of uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto in project verify-hub by alphagov.

the class Cycle3ServiceTest method shouldSendEidasRequestToMatchingServiceViaAttributeQueryServiceAndUpdateSessionStateWhenSuccessfulResponseIsReceived.

@Test
public void shouldSendEidasRequestToMatchingServiceViaAttributeQueryServiceAndUpdateSessionStateWhenSuccessfulResponseIsReceived() {
    final EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto().build();
    final Cycle3AttributeRequestData attributeRequestData = new Cycle3AttributeRequestData("attribute-name", "issuer-id");
    final SessionId eidasSessionId = SessionIdBuilder.aSessionId().build();
    when(eidasAwaitingCycle3DataStateController.getCycle3AttributeRequestData()).thenReturn(attributeRequestData);
    when(sessionRepository.getStateController(eidasSessionId, AbstractAwaitingCycle3DataState.class)).thenReturn(eidasAwaitingCycle3DataStateController);
    when(eidasAwaitingCycle3DataStateController.createAttributeQuery(Matchers.any(Cycle3Dataset.class))).thenReturn(eidasAttributeQueryRequestDto);
    service.sendCycle3MatchingRequest(eidasSessionId, cycle3UserInput);
    verify(eidasAwaitingCycle3DataStateController).createAttributeQuery(Matchers.any(Cycle3Dataset.class));
    verify(attributeQueryService).sendAttributeQueryRequest(eidasSessionId, eidasAttributeQueryRequestDto);
    verify(eidasAwaitingCycle3DataStateController).handleCycle3DataSubmitted("principal-ip-address-as-seen-by-hub");
}
Also used : Cycle3Dataset(uk.gov.ida.hub.policy.domain.Cycle3Dataset) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto) Test(org.junit.Test)

Example 5 with EidasAttributeQueryRequestDto

use of uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto 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

EidasAttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto)8 Test (org.junit.Test)5 MatchingServiceConfigEntityDataDto (uk.gov.ida.hub.policy.contracts.MatchingServiceConfigEntityDataDto)3 Cycle3Dataset (uk.gov.ida.hub.policy.domain.Cycle3Dataset)3 EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto (uk.gov.ida.hub.policy.builder.EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto)2 AttributeQueryContainerDto (uk.gov.ida.hub.policy.contracts.AttributeQueryContainerDto)2 PersistentId (uk.gov.ida.hub.policy.domain.PersistentId)2 SessionId (uk.gov.ida.hub.policy.domain.SessionId)2 URI (java.net.URI)1 HashMap (java.util.HashMap)1 AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto (uk.gov.ida.hub.policy.builder.AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto)1 MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto (uk.gov.ida.hub.policy.builder.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto)1 SamlAuthnResponseTranslatorDto (uk.gov.ida.hub.policy.contracts.SamlAuthnResponseTranslatorDto)1 Cycle3AttributeRequestData (uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)1 InboundResponseFromCountry (uk.gov.ida.hub.policy.domain.InboundResponseFromCountry)1 CountrySelectedStateController (uk.gov.ida.hub.policy.domain.controller.CountrySelectedStateController)1 CountrySelectedState (uk.gov.ida.hub.policy.domain.state.CountrySelectedState)1 EidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState)1 AttributeQueryRequest (uk.gov.ida.hub.policy.proxy.AttributeQueryRequest)1