Search in sources :

Example 1 with IdaAuthnRequestFromHubDto

use of uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto in project verify-hub by alphagov.

the class IdaAuthnRequestTranslatorTest method shouldUseMinimumComparisonTypeAndDuplicateSingleLevelOfAssurance.

@Test
public void shouldUseMinimumComparisonTypeAndDuplicateSingleLevelOfAssurance() {
    IdaAuthnRequestFromHubDto idaAuthnRequestFromHubDto = aRequestDto(asList(AuthnContext.LEVEL_2), false);
    IdaAuthnRequestFromHub idaAuthnRequestFromHub = idaAuthnRequestTranslator.getIdaAuthnRequestFromHub(idaAuthnRequestFromHubDto, URI.create("http://example.com"), HUB_ENTITY_ID);
    assertThat(idaAuthnRequestFromHub.getComparisonType()).isEqualTo(AuthnContextComparisonTypeEnumeration.MINIMUM);
    assertThat(idaAuthnRequestFromHub.getLevelsOfAssurance()).containsSequence(AuthnContext.LEVEL_2, AuthnContext.LEVEL_2);
}
Also used : IdaAuthnRequestFromHub(uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub) IdaAuthnRequestFromHubDto(uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto) Test(org.junit.Test)

Example 2 with IdaAuthnRequestFromHubDto

use of uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto in project verify-hub by alphagov.

the class IdpAuthnRequestGeneratorServiceTest method get_sendAuthnRequest_shouldReturnDtoWithSamlRequestAndPostLocation.

@Test
public void get_sendAuthnRequest_shouldReturnDtoWithSamlRequestAndPostLocation() {
    String idpEntityId = UUID.randomUUID().toString();
    IdaAuthnRequestFromHubDto dto = new IdaAuthnRequestFromHubDto("1", null, Optional.of(false), null, idpEntityId, false);
    String samlRequest = "samlRequest";
    URI ssoUri = UriBuilder.fromPath(UUID.randomUUID().toString()).build();
    when(idaAuthnRequestFromHubStringTransformer.apply(Matchers.<IdaAuthnRequestFromHub>any())).thenReturn(samlRequest);
    when(idpSingleSignOnServiceHelper.getSingleSignOn(idpEntityId)).thenReturn(ssoUri);
    when(idaAuthnRequestTranslator.getIdaAuthnRequestFromHub(dto, ssoUri, HUB_ENTITY_ID)).thenReturn(null);
    final SamlRequestDto output = idpAuthnRequestGeneratorService.generateSaml(dto);
    assertThat(output.getSamlRequest()).isEqualTo(samlRequest);
    assertThat(output.getSsoUri()).isEqualTo(ssoUri);
}
Also used : IdaAuthnRequestFromHubDto(uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto) SamlRequestDto(uk.gov.ida.hub.samlengine.domain.SamlRequestDto) URI(java.net.URI) Test(org.junit.Test)

Example 3 with IdaAuthnRequestFromHubDto

use of uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto in project verify-hub by alphagov.

the class CountryAuthnRequestGeneratorServiceTest method generateSamlRequest.

@Test
public void generateSamlRequest() {
    // Given
    String theCountryEntityId = "theCountryEntityId";
    IdaAuthnRequestFromHubDto dto = new IdaAuthnRequestFromHubDto("1", null, Optional.of(false), null, theCountryEntityId, false);
    URI ssoUri = UriBuilder.fromPath("/the-sso-uri").build();
    String samlRequest = "samlRequest";
    when(eidasAuthnRequestFromHubStringTransformer.apply(any())).thenReturn(samlRequest);
    when(countrySingleSignOnServiceHelper.getSingleSignOn(theCountryEntityId)).thenReturn(ssoUri);
    when(eidasAuthnRequestTranslator.getEidasAuthnRequestFromHub(dto, ssoUri, HUB_ENTITY_ID)).thenReturn(null);
    // When
    final SamlRequestDto output = service.generateSaml(dto);
    // Then
    assertThat(output.getSamlRequest()).isEqualTo(samlRequest);
    assertThat(output.getSsoUri()).isEqualTo(ssoUri);
    verify(countrySingleSignOnServiceHelper).getSingleSignOn(theCountryEntityId);
    verify(eidasAuthnRequestFromHubStringTransformer).apply(any(EidasAuthnRequestFromHub.class));
    verifyNoMoreInteractions(countrySingleSignOnServiceHelper, eidasAuthnRequestFromHubStringTransformer);
}
Also used : EidasAuthnRequestFromHub(uk.gov.ida.saml.hub.domain.EidasAuthnRequestFromHub) IdaAuthnRequestFromHubDto(uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto) SamlRequestDto(uk.gov.ida.hub.samlengine.domain.SamlRequestDto) URI(java.net.URI) Test(org.junit.Test)

Example 4 with IdaAuthnRequestFromHubDto

use of uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto in project verify-hub by alphagov.

the class CountryAuthnRequestGeneratorServiceTest method generateSamlRequestWithOverriddenSsoUri.

@Test
public void generateSamlRequestWithOverriddenSsoUri() {
    // Given
    String theCountryEntityId = "theCountryEntityId";
    URI overriddenSsoURI = URI.create("http://overridden.foo.bar");
    IdaAuthnRequestFromHubDto dto = new IdaAuthnRequestFromHubDto("1", null, Optional.of(false), null, theCountryEntityId, false, overriddenSsoURI);
    URI ssoUri = UriBuilder.fromPath("/the-sso-uri").build();
    String samlRequest = "samlRequest";
    when(eidasAuthnRequestFromHubStringTransformer.apply(any())).thenReturn(samlRequest);
    when(eidasAuthnRequestTranslator.getEidasAuthnRequestFromHub(dto, ssoUri, HUB_ENTITY_ID)).thenReturn(null);
    // When
    final SamlRequestDto output = service.generateSaml(dto);
    // Then
    assertThat(output.getSamlRequest()).isEqualTo(samlRequest);
    assertThat(output.getSsoUri()).isEqualTo(overriddenSsoURI);
    verifyNoMoreInteractions(countrySingleSignOnServiceHelper);
}
Also used : IdaAuthnRequestFromHubDto(uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto) SamlRequestDto(uk.gov.ida.hub.samlengine.domain.SamlRequestDto) URI(java.net.URI) Test(org.junit.Test)

Example 5 with IdaAuthnRequestFromHubDto

use of uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto in project verify-hub by alphagov.

the class IdaAuthnRequestTranslatorTest method shouldUseMinimumComparisonTypeAndLevelsOfAssuranceAsIs.

@Test
public void shouldUseMinimumComparisonTypeAndLevelsOfAssuranceAsIs() {
    IdaAuthnRequestFromHubDto idaAuthnRequestFromHubDto = aRequestDto(asList(AuthnContext.LEVEL_1, AuthnContext.LEVEL_2), false);
    IdaAuthnRequestFromHub idaAuthnRequestFromHub = idaAuthnRequestTranslator.getIdaAuthnRequestFromHub(idaAuthnRequestFromHubDto, URI.create("http://example.com"), HUB_ENTITY_ID);
    assertThat(idaAuthnRequestFromHub.getComparisonType()).isEqualTo(AuthnContextComparisonTypeEnumeration.MINIMUM);
    assertThat(idaAuthnRequestFromHub.getLevelsOfAssurance()).containsSequence(AuthnContext.LEVEL_1, AuthnContext.LEVEL_2);
}
Also used : IdaAuthnRequestFromHub(uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub) IdaAuthnRequestFromHubDto(uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 IdaAuthnRequestFromHubDto (uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto)8 URI (java.net.URI)4 SamlRequestDto (uk.gov.ida.hub.samlengine.domain.SamlRequestDto)4 IdaAuthnRequestFromHub (uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub)4 Response (javax.ws.rs.core.Response)1 DateTime (org.joda.time.DateTime)1 EidasAuthnRequestFromHub (uk.gov.ida.saml.hub.domain.EidasAuthnRequestFromHub)1