Search in sources :

Example 1 with IdentityProviderConfigEntityData

use of uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData in project verify-hub by alphagov.

the class ConfigDataBootstrapTest method start_shouldOnlyValidateCertificateChainIfIdentityProviderIsEnabled.

@Test
public void start_shouldOnlyValidateCertificateChainIfIdentityProviderIsEnabled() throws Exception {
    IdentityProviderConfigEntityData disabledIdp = anIdentityProviderConfigData().withEntityId("idp1EntityId").withEnabled(false).build();
    MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId("matchingServiceId").build();
    TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withMatchingServiceEntityId("matchingServiceId").withEntityId("rpEntityId").build();
    CountriesConfigEntityData countriesConfigData = new CountriesConfigEntityData() {
    };
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(disabledIdp, matchingServiceConfigData, transactionConfigData, countriesConfigData);
    configDataBootstrap.start();
    verify(certificateChainConfigValidator).validate(ImmutableSet.of(transactionConfigData), ImmutableSet.of(matchingServiceConfigData));
}
Also used : MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) CountriesConfigEntityData(uk.gov.ida.hub.config.domain.CountriesConfigEntityData) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Test(org.junit.Test)

Example 2 with IdentityProviderConfigEntityData

use of uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData in project verify-hub by alphagov.

the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenOnboardingTransactionEntityIdCheckFails.

@Test
public void start_shouldThrowExceptionWhenOnboardingTransactionEntityIdCheckFails() throws Exception {
    final String idpEntityId = "idp-entity-id";
    final String matchingServiceEntityId = "matching-service-entity-id";
    final String nonExistentTransactionEntityId = "non-existent-transaction";
    final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId(idpEntityId).withOnboarding(ImmutableList.of(nonExistentTransactionEntityId)).build();
    final TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withEntityId("transaction-entity-id").withMatchingServiceEntityId(matchingServiceEntityId).build();
    final CountriesConfigEntityData countriesConfigEntityData = new CountriesConfigEntityData() {
    };
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, aMatchingServiceConfigEntityData().withEntityId(matchingServiceEntityId).build(), transactionConfigData, countriesConfigEntityData);
    try {
        configDataBootstrap.start();
        fail("Onboarding transaction entity id check did not fail.");
    } catch (ConfigValidationException e) {
        assertThat(e.getMessage()).isEqualTo(createAbsentOnboardingTransactionConfigException(nonExistentTransactionEntityId, idpEntityId).getMessage());
    }
}
Also used : CountriesConfigEntityData(uk.gov.ida.hub.config.domain.CountriesConfigEntityData) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.Test)

Example 3 with IdentityProviderConfigEntityData

use of uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData in project verify-hub by alphagov.

the class EnabledIdpPredicateTest method shouldBeTrueForEnabled.

@Test
public void shouldBeTrueForEnabled() throws Exception {
    Predicate<IdentityProviderConfigEntityData> enabledPredicate = new EnabledIdpPredicate();
    IdentityProviderConfigEntityData enabledIdp = anIdentityProviderConfigData().withEnabled(true).build();
    assertThat(enabledPredicate.apply(enabledIdp)).isTrue();
}
Also used : IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) Test(org.junit.Test)

Example 4 with IdentityProviderConfigEntityData

use of uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData in project verify-hub by alphagov.

the class IdpEntityIdExtractorTest method apply_shouldReturnEntityId.

@Test
public void apply_shouldReturnEntityId() throws Exception {
    IdentityProviderConfigEntityData identityProviderConfigEntityData = mock(IdentityProviderConfigEntityData.class);
    String idpEntityId = "idp entity id";
    when(identityProviderConfigEntityData.getEntityId()).thenReturn(idpEntityId);
    IdpEntityIdExtractor idpEntityIdExtractor = new IdpEntityIdExtractor();
    String extractedEntityId = idpEntityIdExtractor.apply(identityProviderConfigEntityData);
    assertThat(extractedEntityId).isEqualTo(idpEntityId);
}
Also used : IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) Test(org.junit.Test)

Example 5 with IdentityProviderConfigEntityData

use of uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData in project verify-hub by alphagov.

the class OnboardingForTransactionEntityPredicateTest method shouldBeTrueForOnboardingForSameTransactionEntity.

@Test
public void shouldBeTrueForOnboardingForSameTransactionEntity() {
    String transactionEntity = "transactionEntity";
    Predicate<IdentityProviderConfigEntityData> onboardingPredicate = new OnboardingForTransactionEntityPredicate(transactionEntity);
    IdentityProviderConfigEntityData onboardingSameTransactionEntityIdp = anIdentityProviderConfigData().withOnboarding(ImmutableList.of(transactionEntity)).build();
    assertThat(onboardingPredicate.apply(onboardingSameTransactionEntityIdp)).isTrue();
}
Also used : IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) Test(org.junit.Test)

Aggregations

IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)17 Test (org.junit.Test)14 TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)9 CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)7 MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)6 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)6 MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData)4 TypeLiteral (com.google.inject.TypeLiteral)2 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)2 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 ConfigurationFactoryFactory (io.dropwizard.configuration.ConfigurationFactoryFactory)1 DefaultConfigurationFactoryFactory (io.dropwizard.configuration.DefaultConfigurationFactoryFactory)1 Ignore (org.junit.Ignore)1 X509CertificateFactory (uk.gov.ida.common.shared.security.X509CertificateFactory)1 OCSPPKIXParametersProvider (uk.gov.ida.common.shared.security.verification.OCSPPKIXParametersProvider)1 PKIXParametersProvider (uk.gov.ida.common.shared.security.verification.PKIXParametersProvider)1