use of uk.gov.ida.hub.config.domain.TransactionConfigEntityData in project verify-hub by alphagov.
the class IdentityProviderConfigOnboardingTransactionValidatorTest method validate_shouldNotThrowExceptionWhenOnboardingTransactionEntityIdExists.
@Test
public void validate_shouldNotThrowExceptionWhenOnboardingTransactionEntityIdExists() throws Exception {
String transactionEntityID = "transactionEntityID";
IdentityProviderConfigEntityData identityProviderConfigEntityData = anIdentityProviderConfigData().withOnboarding(ImmutableList.of(transactionEntityID)).build();
TransactionConfigEntityData transactionConfigEntity = aTransactionConfigData().build();
when(transactionConfigEntityDataConfigEntityDataRepository.getData(transactionEntityID)).thenReturn(Optional.ofNullable(transactionConfigEntity));
identityProviderConfigOnboardingTransactionValidator.validate(identityProviderConfigEntityData);
}
use of uk.gov.ida.hub.config.domain.TransactionConfigEntityData in project verify-hub by alphagov.
the class TransactionConfigMatchingServiceValidatorTest method matchingServiceEntityId_shouldHaveCorrespondingConfiguration.
@Test
public void matchingServiceEntityId_shouldHaveCorrespondingConfiguration() throws Exception {
final String matchingServiceEntityId = "matching-service-entity-id";
TransactionConfigEntityData transactionConfig = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceEntityId).build();
MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId(matchingServiceEntityId).build();
when(matchingServiceConfigEntityDataRepository.getData(matchingServiceEntityId)).thenReturn(Optional.ofNullable(matchingServiceConfigData));
validator.validate(transactionConfig, matchingServiceConfigEntityDataRepository);
}
use of uk.gov.ida.hub.config.domain.TransactionConfigEntityData 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());
}
}
use of uk.gov.ida.hub.config.domain.TransactionConfigEntityData in project verify-hub by alphagov.
the class ConfigModule method configure.
@Override
protected void configure() {
bind(ConfigHealthCheck.class).asEagerSingleton();
bind(ConfigDataBootstrap.class).asEagerSingleton();
bind(CertificateChainConfigValidator.class).annotatedWith(CertificateConfigValidator.class).to(LoggingCertificateChainConfigValidator.class);
bind(TrustStoreConfiguration.class).to(ConfigConfiguration.class);
bind(new TypeLiteral<ConfigurationFactoryFactory<IdentityProviderConfigEntityData>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<IdentityProviderConfigEntityData>());
bind(new TypeLiteral<ConfigurationFactoryFactory<TransactionConfigEntityData>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<TransactionConfigEntityData>());
bind(new TypeLiteral<ConfigurationFactoryFactory<MatchingServiceConfigEntityData>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<MatchingServiceConfigEntityData>());
bind(new TypeLiteral<ConfigurationFactoryFactory<CountriesConfigEntityData>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<CountriesConfigEntityData>());
bind(new TypeLiteral<ConfigDataSource<TransactionConfigEntityData>>() {
}).to(FileBackedTransactionConfigDataSource.class).asEagerSingleton();
bind(new TypeLiteral<ConfigDataSource<MatchingServiceConfigEntityData>>() {
}).to(FileBackedMatchingServiceConfigDataSource.class).asEagerSingleton();
bind(new TypeLiteral<ConfigDataSource<IdentityProviderConfigEntityData>>() {
}).to(FileBackedIdentityProviderConfigDataSource.class).asEagerSingleton();
bind(new TypeLiteral<ConfigDataSource<CountriesConfigEntityData>>() {
}).to(FileBackedCountriesConfigDataSource.class).asEagerSingleton();
bind(new TypeLiteral<ConfigEntityDataRepository<TransactionConfigEntityData>>() {
}).asEagerSingleton();
bind(new TypeLiteral<ConfigEntityDataRepository<CountriesConfigEntityData>>() {
}).asEagerSingleton();
bind(new TypeLiteral<ConfigEntityDataRepository<MatchingServiceConfigEntityData>>() {
}).asEagerSingleton();
bind(new TypeLiteral<ConfigEntityDataRepository<IdentityProviderConfigEntityData>>() {
}).asEagerSingleton();
bind(ObjectMapper.class).toInstance(new ObjectMapper().registerModule(new GuavaModule()));
bind(LevelsOfAssuranceConfigValidator.class).toInstance(new LevelsOfAssuranceConfigValidator());
bind(CertificateChainValidator.class);
bind(TrustStoreForCertificateProvider.class);
bind(X509CertificateFactory.class).toInstance(new X509CertificateFactory());
bind(KeyStoreCache.class);
bind(ExceptionFactory.class);
bind(OCSPCertificateChainValidityChecker.class);
bind(EntityConfigDataToCertificateDtoTransformer.class);
bind(OCSPCertificateChainValidator.class);
bind(IdpPredicateFactory.class);
bind(KeyStoreLoader.class).toInstance(new KeyStoreLoader());
bind(OCSPPKIXParametersProvider.class).toInstance(new OCSPPKIXParametersProvider());
bind(PKIXParametersProvider.class).toInstance(new PKIXParametersProvider());
bind(CertificateService.class);
}
use of uk.gov.ida.hub.config.domain.TransactionConfigEntityData in project verify-hub by alphagov.
the class ConfigValidCommand method run.
@Override
public void run(Bootstrap<ConfigConfiguration> bootstrap, Namespace namespace, ConfigConfiguration configuration) throws Exception {
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(new TypeLiteral<ConfigurationFactoryFactory<IdentityProviderConfigEntityData>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<>());
bind(new TypeLiteral<ConfigurationFactoryFactory<MatchingServiceConfigEntityData>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<>());
bind(new TypeLiteral<ConfigurationFactoryFactory<TransactionConfigEntityData>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<>());
bind(new TypeLiteral<ConfigurationFactoryFactory<CountriesConfigEntityData>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<>());
bind(new TypeLiteral<ConfigDataSource<TransactionConfigEntityData>>() {
}).to(FileBackedTransactionConfigDataSource.class).asEagerSingleton();
bind(new TypeLiteral<ConfigDataSource<MatchingServiceConfigEntityData>>() {
}).to(FileBackedMatchingServiceConfigDataSource.class).asEagerSingleton();
bind(new TypeLiteral<ConfigDataSource<IdentityProviderConfigEntityData>>() {
}).to(FileBackedIdentityProviderConfigDataSource.class).asEagerSingleton();
bind(new TypeLiteral<ConfigDataSource<CountriesConfigEntityData>>() {
}).to(FileBackedCountriesConfigDataSource.class).asEagerSingleton();
bind(new TypeLiteral<ConfigEntityDataRepository<TransactionConfigEntityData>>() {
}).asEagerSingleton();
bind(new TypeLiteral<ConfigEntityDataRepository<CountriesConfigEntityData>>() {
}).asEagerSingleton();
bind(new TypeLiteral<ConfigEntityDataRepository<MatchingServiceConfigEntityData>>() {
}).asEagerSingleton();
bind(new TypeLiteral<ConfigEntityDataRepository<IdentityProviderConfigEntityData>>() {
}).asEagerSingleton();
bind(ConfigConfiguration.class).toInstance(configuration);
bind(LevelsOfAssuranceConfigValidator.class).toInstance(new LevelsOfAssuranceConfigValidator());
bind(TrustStoreConfiguration.class).to(ConfigConfiguration.class);
bind(TrustStoreForCertificateProvider.class);
bind(CertificateChainConfigValidator.class).annotatedWith(CertificateConfigValidator.class).to(ThrowingCertificateChainConfigValidator.class);
}
});
ConfigDataBootstrap checkConfigValid = injector.getInstance(ConfigDataBootstrap.class);
try {
checkConfigValid.start();
} catch (ConfigValidationException e) {
LOG.info(e.getMessage());
throw e;
}
}
Aggregations