use of uk.gov.ida.hub.config.dto.InvalidCertificateDto in project verify-hub by alphagov.
the class ConfigValidationExceptionTest method createInvalidCertificatesException.
@Test
public void createInvalidCertificatesException() {
InvalidCertificateDto invalidCertificateDto = new InvalidCertificateDto("entity-id", CertPathValidatorException.BasicReason.EXPIRED, CertificateUse.ENCRYPTION, FederationEntityType.IDP, "description");
ConfigValidationException exception = ConfigValidationException.createInvalidCertificatesException(singletonList(invalidCertificateDto));
assertThat(exception.getMessage()).isEqualTo("Invalid certificate found.\n" + "Entity Id: entity-id\n" + "Certificate Type: ENCRYPTION\n" + "Federation Type: IDP\n" + "Reason: EXPIRED\n" + "Description: description");
}
use of uk.gov.ida.hub.config.dto.InvalidCertificateDto 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.dto.InvalidCertificateDto in project verify-hub by alphagov.
the class CertificateValidityCheckerTest method getsInvalidCertificates.
@Test
public void getsInvalidCertificates() {
String description = "X509 Certificate is missing or badly formed.";
CertPathValidatorException certPathValidatorException = new CertPathValidatorException(description);
when(certificateChainValidator.validate(localCertificate.getX509Certificate().get(), trustStore)).thenReturn(CertificateValidity.invalid(certPathValidatorException));
Set<InvalidCertificateDto> invalidCertificates = certificateValidityChecker.getInvalidCertificates(List.of(localCertificate));
InvalidCertificateDto expected = new InvalidCertificateDto(localCertificate.getIssuerEntityId(), certPathValidatorException.getReason(), CertificateUse.SIGNING, localCertificate.getFederationEntityType(), description);
assertThat(invalidCertificates).usingFieldByFieldElementComparator().containsOnly(expected);
}
Aggregations