Search in sources :

Example 6 with TransactionConfigEntityData

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));
}
Also used : CertificateDetails(uk.gov.ida.hub.config.domain.CertificateDetails) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Test(org.junit.Test)

Example 7 with TransactionConfigEntityData

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));
}
Also used : MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) CountriesConfigEntityData(uk.gov.ida.hub.config.domain.CountriesConfigEntityData) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Test(org.junit.Test)

Example 8 with TransactionConfigEntityData

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());
    }
}
Also used : CountriesConfigEntityData(uk.gov.ida.hub.config.domain.CountriesConfigEntityData) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.Test)

Example 9 with TransactionConfigEntityData

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;
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.config.dto.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) ArrayList(java.util.ArrayList) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 10 with TransactionConfigEntityData

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);
}
Also used : CertificateDetails(uk.gov.ida.hub.config.domain.CertificateDetails) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Test(org.junit.Test)

Aggregations

TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)20 Test (org.junit.Test)13 IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)9 MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)9 CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)7 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)6 CertificateDetails (uk.gov.ida.hub.config.domain.CertificateDetails)5 MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData)5 Timed (com.codahale.metrics.annotation.Timed)3 GET (javax.ws.rs.GET)3 SignatureVerificationCertificate (uk.gov.ida.hub.config.domain.SignatureVerificationCertificate)3 TypeLiteral (com.google.inject.TypeLiteral)2 Path (javax.ws.rs.Path)2 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)2 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)2 SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate (uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 ImmutableList (com.google.common.collect.ImmutableList)1 AbstractModule (com.google.inject.AbstractModule)1