Search in sources :

Example 1 with ConfigValidationException

use of uk.gov.ida.hub.config.exceptions.ConfigValidationException 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 2 with ConfigValidationException

use of uk.gov.ida.hub.config.exceptions.ConfigValidationException in project verify-hub by alphagov.

the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenMatchingTransactionEntityIdCheckFails.

@Test
public void start_shouldThrowExceptionWhenMatchingTransactionEntityIdCheckFails() throws Exception {
    final String transEntityId = "trans-entity-id";
    final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId("entity-id").build();
    final TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withEntityId(transEntityId).withMatchingServiceEntityId(NON_EXISTENT_MATCHING_SERVICE_ENTITY_ID).build();
    final MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId(MATCHING_SERVICE_ENTITY_ID).build();
    final CountriesConfigEntityData countriesConfigEntityData = new CountriesConfigEntityData() {
    };
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, countriesConfigEntityData);
    try {
        configDataBootstrap.start();
        fail("fail");
    } catch (ConfigValidationException e) {
        assertThat(e.getMessage()).isEqualTo(ConfigValidationException.createAbsentMatchingServiceConfigException(NON_EXISTENT_MATCHING_SERVICE_ENTITY_ID, transEntityId).getMessage());
    }
}
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) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.Test)

Example 3 with ConfigValidationException

use of uk.gov.ida.hub.config.exceptions.ConfigValidationException in project verify-hub by alphagov.

the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenDuplicateEntityIdsExist.

@Test
public void start_shouldThrowExceptionWhenDuplicateEntityIdsExist() throws Exception {
    final String entityId = "entity-id";
    final String matchingServiceEntityId = "matching-service-entity-id";
    final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId(entityId).build();
    final TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withEntityId(entityId).withMatchingServiceEntityId(matchingServiceEntityId).build();
    final MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId(matchingServiceEntityId).build();
    final CountriesConfigEntityData countriesConfigEntityData = new CountriesConfigEntityData() {
    };
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, countriesConfigEntityData);
    try {
        configDataBootstrap.start();
        fail("fail");
    } catch (ConfigValidationException e) {
        assertThat(e.getMessage()).isEqualTo(ConfigValidationException.createDuplicateEntityIdException(entityId).getMessage());
    }
}
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) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.Test)

Example 4 with ConfigValidationException

use of uk.gov.ida.hub.config.exceptions.ConfigValidationException in project verify-hub by alphagov.

the class IdentityProviderConfigOnboardingTransactionValidatorTest method validate_shouldThrowExceptionWhenOnboardingTransactionDoesNotExist.

@Test
public void validate_shouldThrowExceptionWhenOnboardingTransactionDoesNotExist() throws Exception {
    String transactionEntityID = "transactionEntityID";
    String idpEntityId = "idpEntityId";
    IdentityProviderConfigEntityData identityProviderConfigEntityData = anIdentityProviderConfigData().withEntityId(idpEntityId).withOnboarding(ImmutableList.of(transactionEntityID)).build();
    when(transactionConfigEntityDataConfigEntityDataRepository.getData(transactionEntityID)).thenReturn(Optional.empty());
    try {
        identityProviderConfigOnboardingTransactionValidator.validate(identityProviderConfigEntityData);
        fail("fail");
    } catch (ConfigValidationException e) {
        final ConfigValidationException expectedException = createAbsentOnboardingTransactionConfigException(transactionEntityID, idpEntityId);
        assertThat(expectedException.getMessage()).isEqualTo(e.getMessage());
    }
}
Also used : IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.Test)

Example 5 with ConfigValidationException

use of uk.gov.ida.hub.config.exceptions.ConfigValidationException in project verify-hub by alphagov.

the class TransactionConfigMatchingServiceValidatorTest method validator_shouldThrowExceptionWhenCorrespondingMatchingServiceConfigurationIsAbsent.

@Test
public void validator_shouldThrowExceptionWhenCorrespondingMatchingServiceConfigurationIsAbsent() throws Exception {
    final String matchingServiceEntityId = "matching-service-entity-id";
    TransactionConfigEntityData transactionConfig = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceEntityId).build();
    when(matchingServiceConfigEntityDataRepository.getData(matchingServiceEntityId)).thenReturn(Optional.empty());
    try {
        validator.validate(transactionConfig, matchingServiceConfigEntityDataRepository);
        fail("fail");
    } catch (ConfigValidationException configValidationException) {
        final ConfigValidationException expectedException = createAbsentMatchingServiceConfigException(matchingServiceEntityId, transactionConfig.getEntityId());
        assertThat(configValidationException.getMessage()).isEqualTo(expectedException.getMessage());
    }
}
Also used : TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.Test)

Aggregations

ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)6 Test (org.junit.Test)5 IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)5 TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)5 CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)4 MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)3 MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData)2 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 TypeLiteral (com.google.inject.TypeLiteral)1 ConfigurationFactoryFactory (io.dropwizard.configuration.ConfigurationFactoryFactory)1 DefaultConfigurationFactoryFactory (io.dropwizard.configuration.DefaultConfigurationFactoryFactory)1 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)1 ConfigEntityDataRepository (uk.gov.ida.hub.config.data.ConfigEntityDataRepository)1 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)1 CertificateChainConfigValidator (uk.gov.ida.hub.config.domain.CertificateChainConfigValidator)1 ThrowingCertificateChainConfigValidator (uk.gov.ida.hub.config.domain.ThrowingCertificateChainConfigValidator)1 TrustStoreForCertificateProvider (uk.gov.ida.hub.config.truststore.TrustStoreForCertificateProvider)1