Search in sources :

Example 1 with EidasAttributeQueryRequestDto

use of uk.gov.ida.hub.samlengine.domain.EidasAttributeQueryRequestDto in project verify-hub by alphagov.

the class HubEidasAttributeQueryRequestBuilderTest method shouldCreateHubAttributeQueryRequest.

@Test
public void shouldCreateHubAttributeQueryRequest() {
    final EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = anEidasAttributeQueryRequestDto().build();
    final Optional<HubAssertion> cycle3AttributeAssertion = Optional.empty();
    HubEidasAttributeQueryRequest expectedResult = new HubEidasAttributeQueryRequest(eidasAttributeQueryRequestDto.getRequestId(), HUB_EIDAS_ENTITY_ID, NOW, new uk.gov.ida.saml.core.domain.PersistentId(eidasAttributeQueryRequestDto.getPersistentId().getNameId()), eidasAttributeQueryRequestDto.getAssertionConsumerServiceUri(), eidasAttributeQueryRequestDto.getAuthnRequestIssuerEntityId(), eidasAttributeQueryRequestDto.getEncryptedIdentityAssertion(), AuthnContext.LEVEL_2, cycle3AttributeAssertion, USER_ACCOUNT_CREATION_ATTRIBUTES);
    HubEidasAttributeQueryRequest hubEidasAttributeQueryRequest = builder.createHubAttributeQueryRequest(eidasAttributeQueryRequestDto);
    assertThat(hubEidasAttributeQueryRequest.getId()).isEqualTo(expectedResult.getId());
    assertThat(hubEidasAttributeQueryRequest.getPersistentId().getNameId()).isEqualTo(expectedResult.getPersistentId().getNameId());
    assertThat(hubEidasAttributeQueryRequest.getEncryptedIdentityAssertion()).isEqualTo(expectedResult.getEncryptedIdentityAssertion());
    assertThat(hubEidasAttributeQueryRequest.getAssertionConsumerServiceUrl()).isEqualTo(expectedResult.getAssertionConsumerServiceUrl());
    assertThat(hubEidasAttributeQueryRequest.getAuthnRequestIssuerEntityId()).isEqualTo(expectedResult.getAuthnRequestIssuerEntityId());
    assertThat(hubEidasAttributeQueryRequest.getAuthnContext()).isEqualTo(expectedResult.getAuthnContext());
    assertThat(hubEidasAttributeQueryRequest.getIssuer()).isEqualTo(expectedResult.getIssuer());
    assertThat(hubEidasAttributeQueryRequest.getIssueInstant()).isEqualTo(expectedResult.getIssueInstant());
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion()).isEqualTo(cycle3AttributeAssertion);
    assertThat(hubEidasAttributeQueryRequest.getUserAccountCreationAttributes()).isEqualTo(USER_ACCOUNT_CREATION_ATTRIBUTES);
}
Also used : HubEidasAttributeQueryRequest(uk.gov.ida.saml.hub.domain.HubEidasAttributeQueryRequest) HubAssertion(uk.gov.ida.saml.core.domain.HubAssertion) EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto(uk.gov.ida.hub.samlengine.builders.EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto) EidasAttributeQueryRequestDto(uk.gov.ida.hub.samlengine.domain.EidasAttributeQueryRequestDto) Test(org.junit.Test)

Example 2 with EidasAttributeQueryRequestDto

use of uk.gov.ida.hub.samlengine.domain.EidasAttributeQueryRequestDto in project verify-hub by alphagov.

the class HubEidasAttributeQueryRequestBuilderTest method shouldCreateHubAttributeQueryRequestWithCycle3Assertion.

@Test
public void shouldCreateHubAttributeQueryRequestWithCycle3Assertion() {
    final Map<String, String> dataset = new HashMap<>();
    dataset.put("DrivingLicenceNumber", "MORGA657054SM9IJ");
    final Cycle3Dataset cycle3Dataset = new Cycle3Dataset(dataset);
    final EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = anEidasAttributeQueryRequestDto().withCycle3Dataset(cycle3Dataset).build();
    final uk.gov.ida.saml.core.domain.PersistentId persistentId = new uk.gov.ida.saml.core.domain.PersistentId(eidasAttributeQueryRequestDto.getPersistentId().getNameId());
    final uk.gov.ida.saml.core.domain.Cycle3Dataset oldCycle3Dataset = uk.gov.ida.saml.core.domain.Cycle3Dataset.createFromData(eidasAttributeQueryRequestDto.getCycle3Dataset().get().getAttributes());
    final AssertionRestrictions assertionRestrictions = new AssertionRestrictions(eidasAttributeQueryRequestDto.getAssertionExpiry(), eidasAttributeQueryRequestDto.getRequestId(), eidasAttributeQueryRequestDto.getAuthnRequestIssuerEntityId());
    final HubAssertion hubAssertion = new HubAssertion(UUID.randomUUID().toString(), HUB_EIDAS_ENTITY_ID, NOW, persistentId, assertionRestrictions, Optional.of(oldCycle3Dataset));
    final Optional<HubAssertion> cycle3Assertion = Optional.of(hubAssertion);
    final HubEidasAttributeQueryRequest expectedResult = new HubEidasAttributeQueryRequest(eidasAttributeQueryRequestDto.getRequestId(), HUB_EIDAS_ENTITY_ID, NOW, persistentId, eidasAttributeQueryRequestDto.getAssertionConsumerServiceUri(), eidasAttributeQueryRequestDto.getAuthnRequestIssuerEntityId(), eidasAttributeQueryRequestDto.getEncryptedIdentityAssertion(), AuthnContext.LEVEL_2, cycle3Assertion, USER_ACCOUNT_CREATION_ATTRIBUTES);
    HubEidasAttributeQueryRequest hubEidasAttributeQueryRequest = builder.createHubAttributeQueryRequest(eidasAttributeQueryRequestDto);
    assertThat(hubEidasAttributeQueryRequest.getId()).isEqualTo(expectedResult.getId());
    assertThat(hubEidasAttributeQueryRequest.getPersistentId().getNameId()).isEqualTo(expectedResult.getPersistentId().getNameId());
    assertThat(hubEidasAttributeQueryRequest.getEncryptedIdentityAssertion()).isEqualTo(expectedResult.getEncryptedIdentityAssertion());
    assertThat(hubEidasAttributeQueryRequest.getAssertionConsumerServiceUrl()).isEqualTo(expectedResult.getAssertionConsumerServiceUrl());
    assertThat(hubEidasAttributeQueryRequest.getAuthnRequestIssuerEntityId()).isEqualTo(expectedResult.getAuthnRequestIssuerEntityId());
    assertThat(hubEidasAttributeQueryRequest.getAuthnContext()).isEqualTo(expectedResult.getAuthnContext());
    assertThat(hubEidasAttributeQueryRequest.getIssuer()).isEqualTo(expectedResult.getIssuer());
    assertThat(hubEidasAttributeQueryRequest.getIssueInstant()).isEqualTo(expectedResult.getIssueInstant());
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().isPresent()).isTrue();
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().get().getIssuerId()).isEqualTo(hubAssertion.getIssuerId());
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().get().getAssertionRestrictions().getInResponseTo()).isEqualTo(hubAssertion.getAssertionRestrictions().getInResponseTo());
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().get().getAssertionRestrictions().getNotOnOrAfter()).isEqualTo(hubAssertion.getAssertionRestrictions().getNotOnOrAfter());
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().get().getAssertionRestrictions().getRecipient()).isEqualTo(hubAssertion.getAssertionRestrictions().getRecipient());
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().get().getPersistentId().getNameId()).isEqualTo(hubAssertion.getPersistentId().getNameId());
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().get().getIssueInstant()).isEqualTo(hubAssertion.getIssueInstant());
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().get().getCycle3Data().isPresent()).isTrue();
    assertThat(hubEidasAttributeQueryRequest.getCycle3AttributeAssertion().get().getCycle3Data().get().getAttributes()).isEqualTo(hubAssertion.getCycle3Data().get().getAttributes());
    assertThat(hubEidasAttributeQueryRequest.getUserAccountCreationAttributes()).isEqualTo(USER_ACCOUNT_CREATION_ATTRIBUTES);
}
Also used : Cycle3Dataset(uk.gov.ida.hub.samlengine.domain.Cycle3Dataset) HashMap(java.util.HashMap) AssertionRestrictions(uk.gov.ida.saml.core.domain.AssertionRestrictions) HubAssertion(uk.gov.ida.saml.core.domain.HubAssertion) HubEidasAttributeQueryRequest(uk.gov.ida.saml.hub.domain.HubEidasAttributeQueryRequest) EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto(uk.gov.ida.hub.samlengine.builders.EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto) EidasAttributeQueryRequestDto(uk.gov.ida.hub.samlengine.domain.EidasAttributeQueryRequestDto) Test(org.junit.Test)

Example 3 with EidasAttributeQueryRequestDto

use of uk.gov.ida.hub.samlengine.domain.EidasAttributeQueryRequestDto in project verify-hub by alphagov.

the class CountryMatchingServiceRequestGeneratorResourceTest method shouldCreateAttributeQueryRequest.

@Test
public void shouldCreateAttributeQueryRequest() throws Exception {
    EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = new EidasAttributeQueryRequestBuilder().build();
    Response response = generateEidasAttributeQueryRequest(eidasAttributeQueryRequestDto);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    AttributeQueryContainerDto attributeQueryContainerDto = response.readEntity(AttributeQueryContainerDto.class);
    assertThat(attributeQueryContainerDto.getId()).isEqualTo(eidasAttributeQueryRequestDto.getRequestId());
    assertThat(attributeQueryContainerDto.getIssuer()).isEqualTo(HUB_ENTITY_ID);
    assertThat(attributeQueryContainerDto.getMatchingServiceUri()).isEqualTo(eidasAttributeQueryRequestDto.getAttributeQueryUri());
    assertThat(attributeQueryContainerDto.getAttributeQueryClientTimeOut()).isEqualTo(eidasAttributeQueryRequestDto.getMatchingServiceRequestTimeOut());
    assertThat(attributeQueryContainerDto.isOnboarding()).isEqualTo(eidasAttributeQueryRequestDto.isOnboarding());
    assertThat(attributeQueryContainerDto.getSamlRequest()).contains("saml2p:AttributeQuery");
}
Also used : Response(javax.ws.rs.core.Response) AttributeQueryContainerDto(uk.gov.ida.hub.samlengine.contracts.AttributeQueryContainerDto) EidasAttributeQueryRequestBuilder(uk.gov.ida.integrationtest.hub.samlengine.builders.EidasAttributeQueryRequestBuilder) EidasAttributeQueryRequestDto(uk.gov.ida.hub.samlengine.domain.EidasAttributeQueryRequestDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 EidasAttributeQueryRequestDto (uk.gov.ida.hub.samlengine.domain.EidasAttributeQueryRequestDto)3 EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto (uk.gov.ida.hub.samlengine.builders.EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto)2 HubAssertion (uk.gov.ida.saml.core.domain.HubAssertion)2 HubEidasAttributeQueryRequest (uk.gov.ida.saml.hub.domain.HubEidasAttributeQueryRequest)2 HashMap (java.util.HashMap)1 Response (javax.ws.rs.core.Response)1 AttributeQueryContainerDto (uk.gov.ida.hub.samlengine.contracts.AttributeQueryContainerDto)1 Cycle3Dataset (uk.gov.ida.hub.samlengine.domain.Cycle3Dataset)1 EidasAttributeQueryRequestBuilder (uk.gov.ida.integrationtest.hub.samlengine.builders.EidasAttributeQueryRequestBuilder)1 AssertionRestrictions (uk.gov.ida.saml.core.domain.AssertionRestrictions)1