Search in sources :

Example 16 with TransactionConfig

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

the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenMatchingTransactionEntityIdCheckFails.

@Test
public void start_shouldThrowExceptionWhenMatchingTransactionEntityIdCheckFails() {
    final String transEntityId = "trans-entity-id";
    final String simpleId = "simple-id";
    final IdentityProviderConfig identityProviderConfigData = anIdentityProviderConfigData().withEntityId("entity-id").build();
    final TransactionConfig transactionConfigData = aTransactionConfigData().withEntityId(transEntityId).withMatchingServiceEntityId(NON_EXISTENT_MATCHING_SERVICE_ENTITY_ID).build();
    final TranslationData translationData = aTranslationData().withSimpleId(simpleId).build();
    final MatchingServiceConfig matchingServiceConfigData = aMatchingServiceConfig().withEntityId(MATCHING_SERVICE_ENTITY_ID).build();
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, translationData);
    try {
        configDataBootstrap.start();
        fail("fail");
    } catch (ConfigValidationException e) {
        assertThat(e.getMessage()).isEqualTo(ConfigValidationException.createAbsentMatchingServiceConfigException(NON_EXISTENT_MATCHING_SERVICE_ENTITY_ID, transEntityId).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 17 with TransactionConfig

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

the class ConfigDataBootstrapTest method continuesToStart_WhenCertificateCheckHasInvalidCertificates.

@Disabled
public void continuesToStart_WhenCertificateCheckHasInvalidCertificates() {
    final String idpEntityId = "idp-entity-id";
    final String simpleId = "simple-id";
    final String matchingServiceId = "matching-service-id";
    final String rpEntityId = "rp-entity";
    String badCertificateValue = "badCertificate";
    final IdentityProviderConfig identityProviderConfigData = anIdentityProviderConfigData().withEntityId(idpEntityId).build();
    MatchingServiceConfig matchingServiceConfigData = aMatchingServiceConfig().addSignatureVerificationCertificate(badCertificateValue).withEntityId(matchingServiceId).build();
    TransactionConfig transactionConfigData = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceId).withEntityId(rpEntityId).build();
    final TranslationData translationData = aTranslationData().withSimpleId(simpleId).build();
    InvalidCertificateDto invalidIdpCertificateDto = new InvalidCertificateDto(idpEntityId, CertPathValidatorException.BasicReason.INVALID_SIGNATURE, CertificateUse.SIGNING, FederationEntityType.IDP, "certificate was bad!");
    InvalidCertificateDto invalidMatchingServiceCertificateDto = new InvalidCertificateDto(matchingServiceId, CertPathValidatorException.BasicReason.NOT_YET_VALID, CertificateUse.SIGNING, FederationEntityType.MS, "certificate was not yet valid!");
    doThrow(createInvalidCertificatesException(List.of(invalidMatchingServiceCertificateDto, invalidIdpCertificateDto))).when(certificateChainConfigValidator).validate(Set.of(transactionConfigData, matchingServiceConfigData));
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, translationData);
    configDataBootstrap.start();
}
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) InvalidCertificateDto(uk.gov.ida.hub.config.dto.InvalidCertificateDto) Disabled(org.junit.jupiter.api.Disabled)

Example 18 with TransactionConfig

use of uk.gov.ida.hub.config.domain.TransactionConfig 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 19 with TransactionConfig

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

the class ManagedEntityConfigRepositoryTest method getThrowsAnExceptionWhenOverrideConfigIsWithoutEncryptionCertificate.

public void getThrowsAnExceptionWhenOverrideConfigIsWithoutEncryptionCertificate() {
    var configRepo = new ManagedEntityConfigRepository<>(localConfigRepository, s3ConfigSource);
    TransactionConfig remoteEnabledTransactionWithoutEncryption = aTransactionConfigData().withEntityId(REMOTE_ENABLED_ENTITY_ID_2).withSelfService(true).build();
    when(localConfigRepository.getData(REMOTE_ENABLED_ENTITY_ID_2)).thenReturn(Optional.of(remoteEnabledTransactionWithoutEncryption));
    Optional<TransactionConfig> result = configRepo.get(REMOTE_ENABLED_ENTITY_ID_2);
    assertThat(result.get().getEntityId()).isEqualTo(REMOTE_ENABLED_ENTITY_ID_2);
    assertThatThrownBy(() -> result.get().getEncryptionCertificate()).isExactlyInstanceOf(NoCertificateFoundException.class).hasMessageContaining(String.format("Remote config encryption certificate missing for %s", REMOTE_ENABLED_ENTITY_ID_2));
}
Also used : NoCertificateFoundException(uk.gov.ida.hub.config.exceptions.NoCertificateFoundException) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig)

Example 20 with TransactionConfig

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

the class LevelsOfAssuranceConfigValidatorTest method shouldNotThrowWhenAnIdpsIsOnboardingAndDoesNotSupportATransaction.

@Test
public void shouldNotThrowWhenAnIdpsIsOnboardingAndDoesNotSupportATransaction() {
    Set<TransactionConfig> transactionsConfig = Set.of(loa1And2Transaction);
    final IdentityProviderConfig onboardingIdp = IdentityProviderConfigDataBuilder.anIdentityProviderConfigData().withOnboarding(List.of("some-other-transaction-id")).withSupportedLevelsOfAssurance(List.of(LevelOfAssurance.LEVEL_3)).build();
    Set<IdentityProviderConfig> identityProviderConfig = Set.of(onboardingIdp, loa1And2Idp);
    try {
        levelsOfAssuranceConfigValidator.validateAllTransactionsAreSupportedByIDPs(identityProviderConfig, transactionsConfig);
    } catch (Exception e) {
        fail("Expected exception not thrown");
    }
}
Also used : 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)

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