Search in sources :

Example 6 with TransactionConfig

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);
}
Also used : MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) MatchingServiceConfigBuilder.aMatchingServiceConfig(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) Test(org.junit.jupiter.api.Test)

Example 7 with 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());
    }
}
Also used : TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.jupiter.api.Test)

Example 8 with TransactionConfig

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());
}
Also used : TrustStoreConfiguration(uk.gov.ida.truststore.TrustStoreConfiguration) FileBackedTranslationsDataSource(uk.gov.ida.hub.config.data.FileBackedTranslationsDataSource) KeyStoreLoader(uk.gov.ida.truststore.KeyStoreLoader) OCSPPKIXParametersProvider(uk.gov.ida.common.shared.security.verification.OCSPPKIXParametersProvider) TranslationData(uk.gov.ida.hub.config.domain.TranslationData) IdentityProviderConfig(uk.gov.ida.hub.config.domain.IdentityProviderConfig) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) FileBackedIdentityProviderConfigDataSource(uk.gov.ida.hub.config.data.FileBackedIdentityProviderConfigDataSource) OCSPPKIXParametersProvider(uk.gov.ida.common.shared.security.verification.OCSPPKIXParametersProvider) PKIXParametersProvider(uk.gov.ida.common.shared.security.verification.PKIXParametersProvider) X509CertificateFactory(uk.gov.ida.common.shared.security.X509CertificateFactory) TypeLiteral(com.google.inject.TypeLiteral) MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) FileBackedTransactionConfigDataSource(uk.gov.ida.hub.config.data.FileBackedTransactionConfigDataSource) FileBackedMatchingServiceConfigDataSource(uk.gov.ida.hub.config.data.FileBackedMatchingServiceConfigDataSource) ConfigDataBootstrap(uk.gov.ida.hub.config.data.ConfigDataBootstrap) FileBackedMatchingServiceConfigDataSource(uk.gov.ida.hub.config.data.FileBackedMatchingServiceConfigDataSource) ConfigDataSource(uk.gov.ida.hub.config.data.ConfigDataSource) FileBackedTransactionConfigDataSource(uk.gov.ida.hub.config.data.FileBackedTransactionConfigDataSource) FileBackedIdentityProviderConfigDataSource(uk.gov.ida.hub.config.data.FileBackedIdentityProviderConfigDataSource) ConfigHealthCheck(uk.gov.ida.hub.config.healthcheck.ConfigHealthCheck) CertificateChainConfigValidator(uk.gov.ida.hub.config.domain.CertificateChainConfigValidator) LevelsOfAssuranceConfigValidator(uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)

Example 9 with TransactionConfig

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);
}
Also used : IdentityProviderConfig(uk.gov.ida.hub.config.domain.IdentityProviderConfig) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) Test(org.junit.jupiter.api.Test)

Example 10 with TransactionConfig

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));
}
Also used : TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) Certificate(uk.gov.ida.hub.config.domain.Certificate) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionConfig (uk.gov.ida.hub.config.domain.TransactionConfig)21 Test (org.junit.jupiter.api.Test)15 IdentityProviderConfig (uk.gov.ida.hub.config.domain.IdentityProviderConfig)8 MatchingServiceConfig (uk.gov.ida.hub.config.domain.MatchingServiceConfig)7 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)7 Certificate (uk.gov.ida.hub.config.domain.Certificate)6 TranslationData (uk.gov.ida.hub.config.domain.TranslationData)6 MatchingServiceConfigBuilder.aMatchingServiceConfig (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig)5 TranslationDataBuilder.aTranslationData (uk.gov.ida.hub.config.domain.builders.TranslationDataBuilder.aTranslationData)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 CertificateChainConfigValidator (uk.gov.ida.hub.config.domain.CertificateChainConfigValidator)2 NoCertificateFoundException (uk.gov.ida.hub.config.exceptions.NoCertificateFoundException)2 Timed (com.codahale.metrics.annotation.Timed)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 URI (java.net.URI)1