use of uk.gov.ida.hub.config.domain.CertificateDetails in project verify-hub by alphagov.
the class CertificateServiceTest method findsOnlyValidSignatureVerificationCertificates_WhenTransactionSignatureCertificatesExists.
@Test
public void findsOnlyValidSignatureVerificationCertificates_WhenTransactionSignatureCertificatesExists() throws Exception {
SignatureVerificationCertificate validCert = aSignatureVerificationCertificate().withX509(CERT_ONE_X509).build();
SignatureVerificationCertificate invalidCert = aSignatureVerificationCertificate().withX509(CERT_TWO_X509).build();
TransactionConfigEntityData transactionConfigEntityData = aTransactionConfigData().withEntityId(ENTITY_ID).addSignatureVerificationCertificate(validCert).addSignatureVerificationCertificate(invalidCert).build();
CertificateDetails validCertificate = aCertifcateDetail(ENTITY_ID, validCert, FederationEntityType.RP);
CertificateDetails invalidCertificate = aCertifcateDetail(ENTITY_ID, invalidCert, FederationEntityType.RP);
when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(transactionConfigEntityData));
when(certificateValidityChecker.isValid(invalidCertificate)).thenReturn(false);
when(certificateValidityChecker.isValid(validCertificate)).thenReturn(true);
List<CertificateDetails> certificateDetailsFound = certificateService.signatureVerificatonCertificatesFor(ENTITY_ID);
assertThat(certificateDetailsFound.size()).isEqualTo(1);
assertThat(certificateDetailsFound.get(0)).isEqualTo(validCertificate);
}
use of uk.gov.ida.hub.config.domain.CertificateDetails in project verify-hub by alphagov.
the class CertificateServiceTest method findsOnlyValidSignatureVerificationCertificates_WhenMatchingSignatureCertificatesExists.
@Test
public void findsOnlyValidSignatureVerificationCertificates_WhenMatchingSignatureCertificatesExists() throws Exception {
SignatureVerificationCertificate validSigCert = aSignatureVerificationCertificate().withX509(CERT_ONE_X509).build();
SignatureVerificationCertificate invalidSigCert = aSignatureVerificationCertificate().withX509(CERT_TWO_X509).build();
MatchingServiceConfigEntityData matchingServiceConfigEntityData = aMatchingServiceConfigEntityData().withEntityId(ENTITY_ID).addSignatureVerificationCertificate(validSigCert).addSignatureVerificationCertificate(invalidSigCert).build();
CertificateDetails validCertificate = new CertificateDetails(ENTITY_ID, validSigCert, FederationEntityType.MS);
CertificateDetails invalidCertificate = new CertificateDetails(ENTITY_ID, invalidSigCert, FederationEntityType.MS);
when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(matchingServiceConfigEntityData));
when(certificateValidityChecker.isValid(invalidCertificate)).thenReturn(false);
when(certificateValidityChecker.isValid(validCertificate)).thenReturn(true);
List<CertificateDetails> certificateDetailsFound = certificateService.signatureVerificatonCertificatesFor(ENTITY_ID);
assertThat(certificateDetailsFound.size()).isEqualTo(1);
assertThat(certificateDetailsFound.get(0)).isEqualTo(validCertificate);
}
use of uk.gov.ida.hub.config.domain.CertificateDetails 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.CertificateDetails in project verify-hub by alphagov.
the class CertificateServiceTest method throwsNoCertificateFoundException_WhenMatchingSignatureCertificatesExistButAreInvalid.
@Test(expected = NoCertificateFoundException.class)
public void throwsNoCertificateFoundException_WhenMatchingSignatureCertificatesExistButAreInvalid() throws Exception {
SignatureVerificationCertificate invalidSigCert = aSignatureVerificationCertificate().withX509(CERT_TWO_X509).build();
MatchingServiceConfigEntityData matchingServiceConfigEntityData = aMatchingServiceConfigEntityData().withEntityId(ENTITY_ID).addSignatureVerificationCertificate(invalidSigCert).build();
CertificateDetails invalidCertificate = new CertificateDetails(ENTITY_ID, invalidSigCert, FederationEntityType.MS);
when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(matchingServiceConfigEntityData));
when(certificateValidityChecker.isValid(invalidCertificate)).thenReturn(false);
certificateService.signatureVerificatonCertificatesFor(ENTITY_ID);
}
use of uk.gov.ida.hub.config.domain.CertificateDetails 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));
}
Aggregations