use of uk.gov.ida.hub.config.domain.TransactionConfig in project verify-hub by alphagov.
the class TransactionConfigMatchingServiceValidatorTest method matchingServiceEntityId_shouldHaveCorrespondingConfigurationWhenUsingMatching.
@Test
public void matchingServiceEntityId_shouldHaveCorrespondingConfigurationWhenUsingMatching() {
final String matchingServiceEntityId = "matching-service-entity-id";
TransactionConfig transactionConfig = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceEntityId).build();
MatchingServiceConfig matchingServiceConfigData = aMatchingServiceConfig().withEntityId(matchingServiceEntityId).build();
when(matchingServiceConfigRepository.getData(matchingServiceEntityId)).thenReturn(Optional.ofNullable(matchingServiceConfigData));
validator.validate(transactionConfig);
}
use of uk.gov.ida.hub.config.domain.TransactionConfig in project verify-hub by alphagov.
the class TransactionConfigMatchingServiceValidatorTest method validator_shouldThrowExceptionWhenCorrespondingMatchingServiceConfigurationIsAbsent.
@Test
public void validator_shouldThrowExceptionWhenCorrespondingMatchingServiceConfigurationIsAbsent() {
final String matchingServiceEntityId = "matching-service-entity-id";
TransactionConfig transactionConfig = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceEntityId).build();
when(matchingServiceConfigRepository.getData(matchingServiceEntityId)).thenReturn(Optional.empty());
try {
validator.validate(transactionConfig);
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.TransactionConfig 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).asEagerSingleton();
bind(TrustStoreConfiguration.class).to(ConfigConfiguration.class);
bind(new TypeLiteral<ConfigurationFactoryFactory<IdentityProviderConfig>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<>());
bind(new TypeLiteral<ConfigurationFactoryFactory<TransactionConfig>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<>());
bind(new TypeLiteral<ConfigurationFactoryFactory<MatchingServiceConfig>>() {
}).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(new TypeLiteral<ManagedEntityConfigRepository<TransactionConfig>>() {
}).asEagerSingleton();
bind(new TypeLiteral<ManagedEntityConfigRepository<MatchingServiceConfig>>() {
}).asEagerSingleton();
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(OCSPCertificateChainValidator.class);
bind(IdpPredicateFactory.class);
bind(KeyStoreLoader.class).toInstance(new KeyStoreLoader());
bind(OCSPPKIXParametersProvider.class).toInstance(new OCSPPKIXParametersProvider());
bind(PKIXParametersProvider.class).toInstance(new PKIXParametersProvider());
}
use of uk.gov.ida.hub.config.domain.TransactionConfig in project verify-hub by alphagov.
the class IdentityProviderConfigOnboardingTransactionValidatorTest method validate_shouldNotThrowExceptionWhenOnboardingTransactionEntityIdExists.
@Test
public void validate_shouldNotThrowExceptionWhenOnboardingTransactionEntityIdExists() {
String transactionEntityID = "transactionEntityID";
IdentityProviderConfig identityProviderConfig = anIdentityProviderConfigData().withOnboarding(List.of(transactionEntityID)).build();
TransactionConfig transactionConfigEntity = aTransactionConfigData().build();
when(transactionConfigRepository.getData(transactionEntityID)).thenReturn(Optional.ofNullable(transactionConfigEntity));
identityProviderConfigOnboardingTransactionValidator.validate(identityProviderConfig);
}
use of uk.gov.ida.hub.config.domain.TransactionConfig in project verify-hub by alphagov.
the class CertificateServiceTest method encryptionCertificateForEntityIdReturnsCertificateWhenEnabledTransactionCertificateExists.
@Test
public void encryptionCertificateForEntityIdReturnsCertificateWhenEnabledTransactionCertificateExists() {
TransactionConfig transactionConfig = aTransactionConfigData().withEntityId(RP_ONE_ENTITY_ID).withEncryptionCertificate(CERT_ONE_X509).withEnabled(true).build();
when(connectedServiceConfigRepository.has(RP_ONE_ENTITY_ID)).thenReturn(true);
when(connectedServiceConfigRepository.get(RP_ONE_ENTITY_ID)).thenReturn(Optional.of(transactionConfig));
when(certificateValidityChecker.isValid(any(Certificate.class))).thenReturn(true);
Certificate certificate = certificateService.encryptionCertificateFor(RP_ONE_ENTITY_ID);
assertThat(certificate).isEqualTo(new Certificate(RP_ONE_ENTITY_ID, FederationEntityType.RP, CERT_ONE_X509, CertificateUse.ENCRYPTION, CertificateOrigin.FEDERATION, true));
}
Aggregations