use of uk.gov.ida.hub.config.domain.TransactionConfigEntityData in project verify-hub by alphagov.
the class CertificateServiceTest method findsEncryptionCertificate_WhenEnabledTransCertificateExists.
@Test
public void findsEncryptionCertificate_WhenEnabledTransCertificateExists() throws Exception {
TransactionConfigEntityData transactionConfigEntityData = aTransactionConfigData().withEntityId(ENTITY_ID).withEnabled(true).build();
when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(transactionConfigEntityData));
when(certificateValidityChecker.isValid(any(CertificateDetails.class))).thenReturn(true);
CertificateDetails certificateDetails = certificateService.encryptionCertificateFor(ENTITY_ID);
assertThat(certificateDetails).isEqualTo(aCertifcateDetail(ENTITY_ID, transactionConfigEntityData.getEncryptionCertificate(), FederationEntityType.RP));
}
use of uk.gov.ida.hub.config.domain.TransactionConfigEntityData 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.TransactionConfigEntityData 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.TransactionConfigEntityData in project verify-hub by alphagov.
the class MatchingServiceResource method getMatchingServices.
@GET
@Timed
public Collection<MatchingServiceConfigEntityDataDto> getMatchingServices() {
Collection<MatchingServiceConfigEntityDataDto> matchingServices = new ArrayList<>();
for (TransactionConfigEntityData transactionConfigEntityData : transactionConfigEntityDataRepository.getAllData()) {
MatchingServiceConfigEntityData matchingServiceConfigEntityData = matchingServiceConfigEntityDataRepository.getData(transactionConfigEntityData.getMatchingServiceEntityId()).get();
matchingServices.add(new MatchingServiceConfigEntityDataDto(matchingServiceConfigEntityData.getEntityId(), matchingServiceConfigEntityData.getUri(), transactionConfigEntityData.getEntityId(), matchingServiceConfigEntityData.getHealthCheckEnabled(), matchingServiceConfigEntityData.getOnboarding(), matchingServiceConfigEntityData.getUserAccountCreationUri()));
}
return matchingServices;
}
use of uk.gov.ida.hub.config.domain.TransactionConfigEntityData in project verify-hub by alphagov.
the class CertificateServiceTest method throwsDisabledException_WhenEncryptionCertificateExistsButIsNotEnabled.
@Test(expected = CertificateDisabledException.class)
public void throwsDisabledException_WhenEncryptionCertificateExistsButIsNotEnabled() throws Exception {
TransactionConfigEntityData transactionConfigEntityData = aTransactionConfigData().withEntityId(ENTITY_ID).withEnabled(false).build();
when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(transactionConfigEntityData));
when(certificateValidityChecker.isValid(Mockito.any(CertificateDetails.class))).thenReturn(true);
certificateService.encryptionCertificateFor(ENTITY_ID);
}
Aggregations