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