Search in sources :

Example 11 with MatchingServiceConfig

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

the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenDuplicateEntityIdsExist.

@Test
public void start_shouldThrowExceptionWhenDuplicateEntityIdsExist() {
    final String entityId = "entity-id";
    final String simpleId = "simple-id";
    final String matchingServiceEntityId = "matching-service-entity-id";
    final IdentityProviderConfig identityProviderConfigData = anIdentityProviderConfigData().withEntityId(entityId).build();
    final TransactionConfig transactionConfigData = aTransactionConfigData().withEntityId(entityId).withMatchingServiceEntityId(matchingServiceEntityId).build();
    final TranslationData translationData = aTranslationData().withSimpleId(simpleId).build();
    final MatchingServiceConfig matchingServiceConfigData = aMatchingServiceConfig().withEntityId(matchingServiceEntityId).build();
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, translationData);
    try {
        configDataBootstrap.start();
        fail("fail");
    } catch (ConfigValidationException e) {
        assertThat(e.getMessage()).isEqualTo(ConfigValidationException.createDuplicateEntityIdException(entityId).getMessage());
    }
}
Also used : MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) MatchingServiceConfigBuilder.aMatchingServiceConfig(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig) TranslationDataBuilder.aTranslationData(uk.gov.ida.hub.config.domain.builders.TranslationDataBuilder.aTranslationData) TranslationData(uk.gov.ida.hub.config.domain.TranslationData) IdentityProviderConfig(uk.gov.ida.hub.config.domain.IdentityProviderConfig) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.jupiter.api.Test)

Example 12 with MatchingServiceConfig

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

the class ConfigValidCommand method run.

@Override
public void run(Bootstrap<ConfigConfiguration> bootstrap, Namespace namespace, ConfigConfiguration configuration) {
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(new TypeLiteral<ConfigurationFactoryFactory<IdentityProviderConfig>>() {
            }).toInstance(new DefaultConfigurationFactoryFactory<>());
            bind(new TypeLiteral<ConfigurationFactoryFactory<MatchingServiceConfig>>() {
            }).toInstance(new DefaultConfigurationFactoryFactory<>());
            bind(new TypeLiteral<ConfigurationFactoryFactory<TransactionConfig>>() {
            }).toInstance(new DefaultConfigurationFactoryFactory<>());
            bind(new TypeLiteral<ConfigurationFactoryFactory<TranslationData>>() {
            }).toInstance(new DefaultConfigurationFactoryFactory<>());
            bind(new TypeLiteral<ConfigDataSource<TransactionConfig>>() {
            }).to(FileBackedTransactionConfigDataSource.class).asEagerSingleton();
            bind(new TypeLiteral<ConfigDataSource<TranslationData>>() {
            }).to(FileBackedTranslationsDataSource.class).asEagerSingleton();
            bind(new TypeLiteral<ConfigDataSource<MatchingServiceConfig>>() {
            }).to(FileBackedMatchingServiceConfigDataSource.class).asEagerSingleton();
            bind(new TypeLiteral<ConfigDataSource<IdentityProviderConfig>>() {
            }).to(FileBackedIdentityProviderConfigDataSource.class).asEagerSingleton();
            bind(new TypeLiteral<LocalConfigRepository<TransactionConfig>>() {
            }).asEagerSingleton();
            bind(new TypeLiteral<LocalConfigRepository<TranslationData>>() {
            }).asEagerSingleton();
            bind(new TypeLiteral<LocalConfigRepository<MatchingServiceConfig>>() {
            }).asEagerSingleton();
            bind(new TypeLiteral<LocalConfigRepository<IdentityProviderConfig>>() {
            }).asEagerSingleton();
            bind(ConfigConfiguration.class).toInstance(configuration);
            bind(LevelsOfAssuranceConfigValidator.class).toInstance(new LevelsOfAssuranceConfigValidator());
            bind(TrustStoreConfiguration.class).to(ConfigConfiguration.class);
            bind(TrustStoreForCertificateProvider.class);
            bind(CertificateChainConfigValidator.class);
        }
    });
    ConfigDataBootstrap checkConfigValid = injector.getInstance(ConfigDataBootstrap.class);
    try {
        checkConfigValid.start();
    } catch (ConfigValidationException e) {
        LOG.info(e.getMessage());
        throw e;
    }
}
Also used : TrustStoreForCertificateProvider(uk.gov.ida.hub.config.truststore.TrustStoreForCertificateProvider) DefaultConfigurationFactoryFactory(io.dropwizard.configuration.DefaultConfigurationFactoryFactory) ConfigurationFactoryFactory(io.dropwizard.configuration.ConfigurationFactoryFactory) TypeLiteral(com.google.inject.TypeLiteral) MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) Injector(com.google.inject.Injector) LevelsOfAssuranceConfigValidator(uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator) CertificateChainConfigValidator(uk.gov.ida.hub.config.domain.CertificateChainConfigValidator) LocalConfigRepository(uk.gov.ida.hub.config.data.LocalConfigRepository) TranslationData(uk.gov.ida.hub.config.domain.TranslationData) IdentityProviderConfig(uk.gov.ida.hub.config.domain.IdentityProviderConfig) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) AbstractModule(com.google.inject.AbstractModule) DefaultConfigurationFactoryFactory(io.dropwizard.configuration.DefaultConfigurationFactoryFactory) ConfigDataBootstrap(uk.gov.ida.hub.config.data.ConfigDataBootstrap)

Aggregations

MatchingServiceConfig (uk.gov.ida.hub.config.domain.MatchingServiceConfig)12 MatchingServiceConfigBuilder.aMatchingServiceConfig (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig)10 Test (org.junit.jupiter.api.Test)9 TransactionConfig (uk.gov.ida.hub.config.domain.TransactionConfig)7 Certificate (uk.gov.ida.hub.config.domain.Certificate)6 IdentityProviderConfig (uk.gov.ida.hub.config.domain.IdentityProviderConfig)5 TranslationData (uk.gov.ida.hub.config.domain.TranslationData)5 TranslationDataBuilder.aTranslationData (uk.gov.ida.hub.config.domain.builders.TranslationDataBuilder.aTranslationData)3 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)3 TypeLiteral (com.google.inject.TypeLiteral)2 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)2 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)2 CertificateChainConfigValidator (uk.gov.ida.hub.config.domain.CertificateChainConfigValidator)2 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 ConfigurationFactoryFactory (io.dropwizard.configuration.ConfigurationFactoryFactory)1 DefaultConfigurationFactoryFactory (io.dropwizard.configuration.DefaultConfigurationFactoryFactory)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Disabled (org.junit.jupiter.api.Disabled)1