Search in sources :

Example 1 with TransactionConfig

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

the class TransactionsResource method getAssertionConsumerServiceUri.

@GET
@Path(Urls.ConfigUrls.ASSERTION_CONSUMER_SERVICE_URI_PATH)
@Timed
public ResourceLocationDto getAssertionConsumerServiceUri(@PathParam(Urls.SharedUrls.ENTITY_ID_PARAM) String entityId, @QueryParam(Urls.ConfigUrls.ASSERTION_CONSUMER_SERVICE_INDEX_PARAM) Optional<Integer> assertionConsumerServiceIndex) {
    final TransactionConfig configData = getTransactionConfigData(entityId);
    final Optional<URI> assertionConsumerServiceUri = configData.getAssertionConsumerServiceUri(assertionConsumerServiceIndex);
    // we know that the index must be here because we will have pre-validated that there will be a default for the transaction
    return new ResourceLocationDto(assertionConsumerServiceUri.orElseThrow(() -> exceptionFactory.createInvalidAssertionConsumerServiceIndexException(entityId, assertionConsumerServiceIndex.get())));
}
Also used : TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) URI(java.net.URI) ResourceLocationDto(uk.gov.ida.hub.config.dto.ResourceLocationDto) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 2 with TransactionConfig

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

the class TransactionConfigMatchingServiceValidatorTest method validator_shouldThrowExceptionWhenMatchingEntityIdIsAbsentIfUsingMatching.

@Test
public void validator_shouldThrowExceptionWhenMatchingEntityIdIsAbsentIfUsingMatching() {
    TransactionConfig transactionConfig = aTransactionConfigData().withMatchingServiceEntityId(null).build();
    try {
        validator.validate(transactionConfig);
        fail("fail");
    } catch (ConfigValidationException configValidationException) {
        final ConfigValidationException expectedException = createMissingMatchingEntityIdException(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 3 with TransactionConfig

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

the class TransactionConfigMatchingServiceValidatorTest method matchingServiceEntityId_doesNotNeedCorrespondingConfigurationWhenNotUsingMatching.

@Test
public void matchingServiceEntityId_doesNotNeedCorrespondingConfigurationWhenNotUsingMatching() {
    final String matchingServiceEntityId = "matching-service-entity-id";
    TransactionConfig transactionConfig = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceEntityId).withUsingMatching(false).build();
    validator.validate(transactionConfig);
}
Also used : TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) Test(org.junit.jupiter.api.Test)

Example 4 with TransactionConfig

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

the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenOnboardingTransactionEntityIdCheckFails.

@Test
public void start_shouldThrowExceptionWhenOnboardingTransactionEntityIdCheckFails() {
    final String idpEntityId = "idp-entity-id";
    final String simpleId = "simple-id";
    final String matchingServiceEntityId = "matching-service-entity-id";
    final String nonExistentTransactionEntityId = "non-existent-transaction";
    final IdentityProviderConfig identityProviderConfigData = anIdentityProviderConfigData().withEntityId(idpEntityId).withOnboarding(List.of(nonExistentTransactionEntityId)).build();
    final TransactionConfig transactionConfigData = aTransactionConfigData().withEntityId("transaction-entity-id").withMatchingServiceEntityId(matchingServiceEntityId).build();
    final TranslationData translationData = aTranslationData().withSimpleId(simpleId).build();
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, aMatchingServiceConfig().withEntityId(matchingServiceEntityId).build(), transactionConfigData, translationData);
    try {
        configDataBootstrap.start();
        fail("Onboarding transaction entity id check did not fail.");
    } catch (ConfigValidationException e) {
        assertThat(e.getMessage()).isEqualTo(createAbsentOnboardingTransactionConfigException(nonExistentTransactionEntityId, idpEntityId).getMessage());
    }
}
Also used : 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 5 with TransactionConfig

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

the class ManagedEntityConfigRepositoryTest method getThrowsAnExceptionWhenOverrideConfigIsWithoutSigningCertificates.

public void getThrowsAnExceptionWhenOverrideConfigIsWithoutSigningCertificates() {
    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().getSignatureVerificationCertificates()).isExactlyInstanceOf(NoCertificateFoundException.class).hasMessageContaining(String.format("Remote config signing certificates 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)

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