use of uk.gov.ida.hub.config.domain.IdentityProviderConfig 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());
}
}
use of uk.gov.ida.hub.config.domain.IdentityProviderConfig 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();
}
use of uk.gov.ida.hub.config.domain.IdentityProviderConfig 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());
}
}
use of uk.gov.ida.hub.config.domain.IdentityProviderConfig 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");
}
}
use of uk.gov.ida.hub.config.domain.IdentityProviderConfig in project verify-hub by alphagov.
the class ConfigValidCommand method run.
@Override
public void run(Bootstrap<ConfigConfiguration> bootstrap, Namespace namespace, ConfigConfiguration configuration) {
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(new TypeLiteral<ConfigurationFactoryFactory<IdentityProviderConfig>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<>());
bind(new TypeLiteral<ConfigurationFactoryFactory<MatchingServiceConfig>>() {
}).toInstance(new DefaultConfigurationFactoryFactory<>());
bind(new TypeLiteral<ConfigurationFactoryFactory<TransactionConfig>>() {
}).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(ConfigConfiguration.class).toInstance(configuration);
bind(LevelsOfAssuranceConfigValidator.class).toInstance(new LevelsOfAssuranceConfigValidator());
bind(TrustStoreConfiguration.class).to(ConfigConfiguration.class);
bind(TrustStoreForCertificateProvider.class);
bind(CertificateChainConfigValidator.class);
}
});
ConfigDataBootstrap checkConfigValid = injector.getInstance(ConfigDataBootstrap.class);
try {
checkConfigValid.start();
} catch (ConfigValidationException e) {
LOG.info(e.getMessage());
throw e;
}
}
Aggregations