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())));
}
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());
}
}
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);
}
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());
}
}
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));
}
Aggregations