use of uk.gov.ida.hub.config.domain.CountriesConfigEntityData in project verify-hub by alphagov.
the class ConfigDataBootstrapTest method start_shouldOnlyValidateCertificateChainIfIdentityProviderIsEnabled.
@Test
public void start_shouldOnlyValidateCertificateChainIfIdentityProviderIsEnabled() throws Exception {
IdentityProviderConfigEntityData disabledIdp = anIdentityProviderConfigData().withEntityId("idp1EntityId").withEnabled(false).build();
MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId("matchingServiceId").build();
TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withMatchingServiceEntityId("matchingServiceId").withEntityId("rpEntityId").build();
CountriesConfigEntityData countriesConfigData = new CountriesConfigEntityData() {
};
ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(disabledIdp, matchingServiceConfigData, transactionConfigData, countriesConfigData);
configDataBootstrap.start();
verify(certificateChainConfigValidator).validate(ImmutableSet.of(transactionConfigData), ImmutableSet.of(matchingServiceConfigData));
}
use of uk.gov.ida.hub.config.domain.CountriesConfigEntityData in project verify-hub by alphagov.
the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenOnboardingTransactionEntityIdCheckFails.
@Test
public void start_shouldThrowExceptionWhenOnboardingTransactionEntityIdCheckFails() throws Exception {
final String idpEntityId = "idp-entity-id";
final String matchingServiceEntityId = "matching-service-entity-id";
final String nonExistentTransactionEntityId = "non-existent-transaction";
final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId(idpEntityId).withOnboarding(ImmutableList.of(nonExistentTransactionEntityId)).build();
final TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withEntityId("transaction-entity-id").withMatchingServiceEntityId(matchingServiceEntityId).build();
final CountriesConfigEntityData countriesConfigEntityData = new CountriesConfigEntityData() {
};
ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, aMatchingServiceConfigEntityData().withEntityId(matchingServiceEntityId).build(), transactionConfigData, countriesConfigEntityData);
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.CountriesConfigEntityData in project verify-hub by alphagov.
the class ConfigDataBootstrapTest method continuesToStart_WhenCertificateCheckHasInvalidCertificates.
@Ignore
public void continuesToStart_WhenCertificateCheckHasInvalidCertificates() {
final String idpEntityId = "idp-entity-id";
final String matchingServiceId = "matching-service-id";
final String rpEntityId = "rp-entity";
String badCertificateValue = "badCertificate";
final SignatureVerificationCertificate badCertificate = new SignatureVerificationCertificateBuilder().withX509(badCertificateValue).build();
final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId(idpEntityId).addSignatureVerificationCertificate(badCertificate).build();
MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().addSignatureVerificationCertificate(badCertificate).withEntityId(matchingServiceId).build();
TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceId).withEntityId(rpEntityId).build();
InvalidCertificateDto invalidIdpCertificateDto = new InvalidCertificateDto(idpEntityId, CertPathValidatorException.BasicReason.INVALID_SIGNATURE, CertificateType.SIGNING, FederationEntityType.IDP, "certificate was bad!");
InvalidCertificateDto invalidMatchingServiceCertificateDto = new InvalidCertificateDto(matchingServiceId, CertPathValidatorException.BasicReason.NOT_YET_VALID, CertificateType.SIGNING, FederationEntityType.MS, "certificate was not yet valid!");
doThrow(createInvalidCertificatesException(ImmutableList.of(invalidMatchingServiceCertificateDto, invalidIdpCertificateDto))).when(certificateChainConfigValidator).validate(ImmutableSet.of(transactionConfigData), ImmutableSet.of(matchingServiceConfigData));
CountriesConfigEntityData countriesConfigEntityData = createCountriesConfigEntityData();
ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, countriesConfigEntityData);
configDataBootstrap.start();
}
use of uk.gov.ida.hub.config.domain.CountriesConfigEntityData in project verify-hub by alphagov.
the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenMatchingTransactionEntityIdCheckFails.
@Test
public void start_shouldThrowExceptionWhenMatchingTransactionEntityIdCheckFails() throws Exception {
final String transEntityId = "trans-entity-id";
final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId("entity-id").build();
final TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withEntityId(transEntityId).withMatchingServiceEntityId(NON_EXISTENT_MATCHING_SERVICE_ENTITY_ID).build();
final MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId(MATCHING_SERVICE_ENTITY_ID).build();
final CountriesConfigEntityData countriesConfigEntityData = new CountriesConfigEntityData() {
};
ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, countriesConfigEntityData);
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.CountriesConfigEntityData in project verify-hub by alphagov.
the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenDuplicateEntityIdsExist.
@Test
public void start_shouldThrowExceptionWhenDuplicateEntityIdsExist() throws Exception {
final String entityId = "entity-id";
final String matchingServiceEntityId = "matching-service-entity-id";
final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId(entityId).build();
final TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withEntityId(entityId).withMatchingServiceEntityId(matchingServiceEntityId).build();
final MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId(matchingServiceEntityId).build();
final CountriesConfigEntityData countriesConfigEntityData = new CountriesConfigEntityData() {
};
ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, countriesConfigEntityData);
try {
configDataBootstrap.start();
fail("fail");
} catch (ConfigValidationException e) {
assertThat(e.getMessage()).isEqualTo(ConfigValidationException.createDuplicateEntityIdException(entityId).getMessage());
}
}
Aggregations