Search in sources :

Example 6 with BaseCredentialGenerateRequest

use of org.cloudfoundry.credhub.request.BaseCredentialGenerateRequest in project credhub by cloudfoundry-incubator.

the class RegenerateHandler method handleRegenerate.

public CredentialView handleRegenerate(String credentialName, List<EventAuditRecordParameters> auditRecordParameters) {
    CredentialVersion existingCredentialVersion = credentialService.findMostRecent(credentialName);
    BaseCredentialGenerateRequest generateRequest = generationRequestGenerator.createGenerateRequest(existingCredentialVersion, credentialName, auditRecordParameters);
    CredentialValue credentialValue = credentialGenerator.generate(generateRequest);
    final CredentialVersion credentialVersion = credentialService.save(existingCredentialVersion, credentialValue, generateRequest, auditRecordParameters);
    return CredentialView.fromEntity(credentialVersion);
}
Also used : BaseCredentialGenerateRequest(org.cloudfoundry.credhub.request.BaseCredentialGenerateRequest) CredentialValue(org.cloudfoundry.credhub.credential.CredentialValue) CredentialVersion(org.cloudfoundry.credhub.domain.CredentialVersion)

Example 7 with BaseCredentialGenerateRequest

use of org.cloudfoundry.credhub.request.BaseCredentialGenerateRequest 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);
}
Also used : CertificateRegenerateRequest(org.cloudfoundry.credhub.request.CertificateRegenerateRequest) BaseCredentialGenerateRequest(org.cloudfoundry.credhub.request.BaseCredentialGenerateRequest) CertificateCredentialValue(org.cloudfoundry.credhub.credential.CertificateCredentialValue) CertificateCredentialVersion(org.cloudfoundry.credhub.domain.CertificateCredentialVersion) Test(org.junit.Test)

Aggregations

BaseCredentialGenerateRequest (org.cloudfoundry.credhub.request.BaseCredentialGenerateRequest)7 CertificateCredentialValue (org.cloudfoundry.credhub.credential.CertificateCredentialValue)5 CertificateCredentialVersion (org.cloudfoundry.credhub.domain.CertificateCredentialVersion)5 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)4 Test (org.junit.Test)4 CredentialValue (org.cloudfoundry.credhub.credential.CredentialValue)1 ParameterizedValidationException (org.cloudfoundry.credhub.exceptions.ParameterizedValidationException)1 CertificateRegenerateRequest (org.cloudfoundry.credhub.request.CertificateRegenerateRequest)1 CertificateView (org.cloudfoundry.credhub.view.CertificateView)1