use of org.cloudfoundry.credhub.domain.CertificateCredentialVersion in project credhub by cloudfoundry-incubator.
the class CertificateAuthorityServiceTest method findActiveVersion_whenCertificateIsNotACa_throwsException.
@Test
public void findActiveVersion_whenCertificateIsNotACa_throwsException() {
CertificateCredentialVersion notACertificateAuthority = mock(CertificateCredentialVersion.class);
when(notACertificateAuthority.getParsedCertificate()).thenReturn(mock(CertificateReader.class));
when(notACertificateAuthority.getCertificate()).thenReturn(CertificateStringConstants.SIMPLE_SELF_SIGNED_TEST_CERT);
when(certificateVersionDataService.findActive(CREDENTIAL_NAME)).thenReturn(notACertificateAuthority);
try {
certificateAuthorityService.findActiveVersion(CREDENTIAL_NAME);
} catch (ParameterizedValidationException pe) {
assertThat(pe.getMessage(), equalTo("error.cert_not_ca"));
}
}
use of org.cloudfoundry.credhub.domain.CertificateCredentialVersion in project credhub by cloudfoundry-incubator.
the class CertificatesHandlerTest method handleGetAllVersionsRequest_returnsListOfCertificateViews.
@Test
public void handleGetAllVersionsRequest_returnsListOfCertificateViews() {
UUID uuid = UUID.randomUUID();
String certificateName = "some certificate";
CredentialVersion credentialVersion = new CertificateCredentialVersion(certificateName);
when(permissionedCertificateService.getVersions(uuid, false, Collections.emptyList())).thenReturn(Collections.singletonList(credentialVersion));
List<CertificateView> certificateViews = subject.handleGetAllVersionsRequest(uuid.toString(), Collections.emptyList(), false);
assertThat(certificateViews.size(), equalTo(1));
assertThat(certificateViews.get(0).getName(), equalTo(certificateName));
}
use of org.cloudfoundry.credhub.domain.CertificateCredentialVersion in project credhub by cloudfoundry-incubator.
the class CertificatesHandlerTest method handleRegenerate_passesOnTransitionalFlagWhenRegeneratingCertificate.
@Test
public void handleRegenerate_passesOnTransitionalFlagWhenRegeneratingCertificate() {
BaseCredentialGenerateRequest generateRequest = mock(BaseCredentialGenerateRequest.class);
CertificateCredentialVersion certificate = mock(CertificateCredentialVersion.class);
CertificateCredentialValue newValue = mock(CertificateCredentialValue.class);
when(certificate.getName()).thenReturn("test");
when(certificateService.findByCredentialUuid(eq(UUID_STRING), any())).thenReturn(certificate);
when(generationRequestGenerator.createGenerateRequest(eq(certificate), eq("test"), any())).thenReturn(generateRequest);
when(universalCredentialGenerator.generate(eq(generateRequest))).thenReturn(newValue);
when(permissionedCertificateService.save(eq(certificate), any(), any(), any())).thenReturn(mock(CertificateCredentialVersion.class));
CertificateRegenerateRequest regenerateRequest = new CertificateRegenerateRequest(true);
subject.handleRegenerate(UUID_STRING, Collections.emptyList(), regenerateRequest);
verify(newValue).setTransitional(true);
}
Aggregations