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);
}
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);
}
Aggregations