Search in sources :

Example 1 with UserAccountCreationAttribute

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

the class Cycle0And1MatchRequestSentStateControllerTest method cycle0And1SuccessfulMatchResponseFromMatchingService_shouldLogRelevantEvents.

@Test
public void cycle0And1SuccessfulMatchResponseFromMatchingService_shouldLogRelevantEvents() {
    List<UserAccountCreationAttribute> userAccountCreationAttributes = singletonList(UserAccountCreationAttribute.DATE_OF_BIRTH);
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
    when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(userAccountCreationAttributes);
    MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(MATCHING_SERVICE_ENTITY_ID, REQUEST_ID, "assertionBlob", Optional.of(LevelOfAssurance.LEVEL_1));
    controller.handleMatchResponseFromMatchingService(matchFromMatchingService);
    verify(hubEventLogger, times(1)).logCycle01SuccessfulMatchEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, REQUEST_ID, state.getSessionExpiryTimestamp());
    verify(hubEventLogger, times(0)).logCycle01NoMatchEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, REQUEST_ID, state.getSessionExpiryTimestamp());
}
Also used : UserAccountCreationAttribute(uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute) NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchFromMatchingServiceBuilder.aMatchFromMatchingService(uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService) MatchFromMatchingService(uk.gov.ida.hub.policy.domain.MatchFromMatchingService) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Test(org.junit.Test)

Example 2 with UserAccountCreationAttribute

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

the class Cycle3MatchRequestSentStateControllerTest method getNextStateForNoMatch_shouldReturnNoMatchWhenNoAttributesArePresent.

@Test
public void getNextStateForNoMatch_shouldReturnNoMatchWhenNoAttributesArePresent() {
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().build();
    ImmutableList<UserAccountCreationAttribute> userAccountCreationAttributes = ImmutableList.of();
    when(transactionsConfigProxy.getUserAccountCreationAttributes("request issuer id")).thenReturn(userAccountCreationAttributes);
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, null, null, null, null, transactionsConfigProxy, null, null, null);
    State nextState = controller.getNextStateForNoMatch();
    assertThat(nextState).isInstanceOf(NoMatchState.class);
}
Also used : UserAccountCreationAttribute(uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute) NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) State(uk.gov.ida.hub.policy.domain.State) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Test(org.junit.Test)

Example 3 with UserAccountCreationAttribute

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

the class MatchingServiceResourcesIntegrationTest method aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Disabled.

private void aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Disabled(SessionId sessionId) throws JsonProcessingException {
    SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
    InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService, translatedAuthnRequest.getId(), msaEntityId, Optional.<String>absent(), Optional.<LevelOfAssurance>absent());
    samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
    configStub.setUpStubForCycle01NoMatchCycle3Disabled(rpEntityId);
    List<UserAccountCreationAttribute> userAccountCreationAttributes = ImmutableList.of(UserAccountCreationAttribute.CURRENT_ADDRESS);
    configStub.setUpStubForUserAccountCreation(rpEntityId, userAccountCreationAttributes);
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
    postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
}
Also used : SamlResponseDto(uk.gov.ida.hub.policy.contracts.SamlResponseDto) UserAccountCreationAttribute(uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute) URI(java.net.URI) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)

Example 4 with UserAccountCreationAttribute

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

the class Cycle0And1MatchRequestSentStateController method getNextStateForNoMatch.

@Override
protected State getNextStateForNoMatch() {
    Optional<String> selfAssertedAttributeName = transactionsConfigProxy.getMatchingProcess(state.getRequestIssuerEntityId()).getAttributeName();
    if (selfAssertedAttributeName.isPresent()) {
        hubEventLogger.logWaitingForCycle3AttributesEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getRequestId(), state.getSessionExpiryTimestamp());
        return getAwaitingCycle3DataState();
    }
    List<UserAccountCreationAttribute> userAccountCreationAttributes = transactionsConfigProxy.getUserAccountCreationAttributes(state.getRequestIssuerEntityId());
    if (!userAccountCreationAttributes.isEmpty()) {
        AttributeQueryRequestDto attributeQueryRequestDto = createAttributeQuery(userAccountCreationAttributes);
        return handleUserAccountCreationRequestAndGenerateState(attributeQueryRequestDto);
    }
    hubEventLogger.logCycle01NoMatchEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getRequestId(), state.getSessionExpiryTimestamp());
    return getNoMatchState();
}
Also used : UserAccountCreationAttribute(uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute) AttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)

Example 5 with UserAccountCreationAttribute

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

the class Cycle3MatchRequestSentStateController method getNextStateForNoMatch.

@Override
protected State getNextStateForNoMatch() {
    List<UserAccountCreationAttribute> userAccountCreationAttributes = transactionsConfigProxy.getUserAccountCreationAttributes(state.getRequestIssuerEntityId());
    if (!userAccountCreationAttributes.isEmpty()) {
        AttributeQueryRequestDto attributeQueryRequestDto = createAttributeQuery(userAccountCreationAttributes);
        return handleUserAccountCreationRequestAndGenerateState(attributeQueryRequestDto);
    }
    hubEventLogger.logCycle3NoMatchEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getRequestId());
    return getNoMatchState();
}
Also used : UserAccountCreationAttribute(uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute) AttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)

Aggregations

UserAccountCreationAttribute (uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute)8 URI (java.net.URI)4 Test (org.junit.Test)4 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)4 State (uk.gov.ida.hub.policy.domain.State)3 NoMatchState (uk.gov.ida.hub.policy.domain.state.NoMatchState)3 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)3 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)2 InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)2 SamlResponseDto (uk.gov.ida.hub.policy.contracts.SamlResponseDto)2 MatchingProcess (uk.gov.ida.hub.policy.domain.MatchingProcess)2 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)2 Matchers.anyString (org.mockito.Matchers.anyString)1 MatchFromMatchingServiceBuilder.aMatchFromMatchingService (uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService)1 Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState)1 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)1 MatchFromMatchingService (uk.gov.ida.hub.policy.domain.MatchFromMatchingService)1 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)1 AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1