Search in sources :

Example 6 with MatchingServiceConfigEntityData

use of uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData in project verify-hub by alphagov.

the class CertificateServiceTest method throwsNotFoundException_WhenMatchingCertificateExistsButIsInvalid.

@Test(expected = NoCertificateFoundException.class)
public void throwsNotFoundException_WhenMatchingCertificateExistsButIsInvalid() throws Exception {
    MatchingServiceConfigEntityData matchingServiceConfigEntityData = aMatchingServiceConfigEntityData().withEntityId(ENTITY_ID).build();
    when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
    when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(matchingServiceConfigEntityData));
    when(certificateValidityChecker.isValid(any(CertificateDetails.class))).thenReturn(false);
    certificateService.encryptionCertificateFor(ENTITY_ID);
}
Also used : MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) CertificateDetails(uk.gov.ida.hub.config.domain.CertificateDetails) Test(org.junit.Test)

Example 7 with MatchingServiceConfigEntityData

use of uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData in project verify-hub by alphagov.

the class CertificateServiceTest method findsEncryptionCertificate_WhenMatchingCertificateExists.

@Test
public void findsEncryptionCertificate_WhenMatchingCertificateExists() throws Exception {
    MatchingServiceConfigEntityData matchingServiceConfigEntityData = aMatchingServiceConfigEntityData().withEntityId(ENTITY_ID).build();
    when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
    when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(matchingServiceConfigEntityData));
    when(certificateValidityChecker.isValid(any(CertificateDetails.class))).thenReturn(true);
    CertificateDetails certificateDetails = certificateService.encryptionCertificateFor(ENTITY_ID);
    assertThat(certificateDetails).isEqualTo(aCertifcateDetail(ENTITY_ID, matchingServiceConfigEntityData.getEncryptionCertificate(), FederationEntityType.MS));
}
Also used : MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) CertificateDetails(uk.gov.ida.hub.config.domain.CertificateDetails) Test(org.junit.Test)

Example 8 with MatchingServiceConfigEntityData

use of uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData in project verify-hub by alphagov.

the class CertificateServiceTest method findsSignatureVerificationCertificates_WhenMatchingSignatureCertificatesExists.

@Test
public void findsSignatureVerificationCertificates_WhenMatchingSignatureCertificatesExists() throws Exception {
    SignatureVerificationCertificate sigCert1 = aSignatureVerificationCertificate().withX509(CERT_ONE_X509).build();
    SignatureVerificationCertificate sigCert2 = aSignatureVerificationCertificate().withX509(CERT_TWO_X509).build();
    MatchingServiceConfigEntityData matchingServiceConfigEntityData = aMatchingServiceConfigEntityData().withEntityId(ENTITY_ID).addSignatureVerificationCertificate(sigCert1).addSignatureVerificationCertificate(sigCert2).build();
    when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
    when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(matchingServiceConfigEntityData));
    when(certificateValidityChecker.isValid(any(CertificateDetails.class))).thenReturn(true);
    List<CertificateDetails> certificateDetailsFound = certificateService.signatureVerificatonCertificatesFor(ENTITY_ID);
    assertThat(certificateDetailsFound.size()).isEqualTo(2);
    assertThat(certificateDetailsFound).contains(aCertifcateDetail(ENTITY_ID, sigCert1, FederationEntityType.MS), aCertifcateDetail(ENTITY_ID, sigCert2, FederationEntityType.MS));
}
Also used : MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) CertificateDetails(uk.gov.ida.hub.config.domain.CertificateDetails) SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate(uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate) SignatureVerificationCertificate(uk.gov.ida.hub.config.domain.SignatureVerificationCertificate) Test(org.junit.Test)

Example 9 with MatchingServiceConfigEntityData

use of uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData 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();
}
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) InvalidCertificateDto(uk.gov.ida.hub.config.dto.InvalidCertificateDto) SignatureVerificationCertificate(uk.gov.ida.hub.config.domain.SignatureVerificationCertificate) SignatureVerificationCertificateBuilder(uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Ignore(org.junit.Ignore)

Example 10 with MatchingServiceConfigEntityData

use of uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData 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());
    }
}
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) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.Test)

Aggregations

MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)14 MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData)10 Test (org.junit.Test)9 TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)9 CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)6 IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)6 CertificateDetails (uk.gov.ida.hub.config.domain.CertificateDetails)5 SignatureVerificationCertificate (uk.gov.ida.hub.config.domain.SignatureVerificationCertificate)4 SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate (uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate)3 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)3 TypeLiteral (com.google.inject.TypeLiteral)2 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)2 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)2 Timed (com.codahale.metrics.annotation.Timed)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 ConfigurationFactoryFactory (io.dropwizard.configuration.ConfigurationFactoryFactory)1 DefaultConfigurationFactoryFactory (io.dropwizard.configuration.DefaultConfigurationFactoryFactory)1