use of org.cloudfoundry.credhub.request.PasswordGenerateRequest in project credhub by cloudfoundry-incubator.
the class PasswordCredentialRegeneratable method createGenerateRequest.
@Override
public BaseCredentialGenerateRequest createGenerateRequest(CredentialVersion credentialVersion, List<EventAuditRecordParameters> auditRecordParameters) {
PasswordCredentialVersion passwordCredential = (PasswordCredentialVersion) credentialVersion;
PasswordGenerateRequest generateRequest = new PasswordGenerateRequest();
generateRequest.setName(passwordCredential.getName());
generateRequest.setType(passwordCredential.getCredentialType());
generateRequest.setOverwrite(true);
StringGenerationParameters generationParameters;
generationParameters = passwordCredential.getGenerationParameters();
if (generationParameters == null) {
auditRecordParameters.add(new EventAuditRecordParameters(CREDENTIAL_UPDATE, credentialVersion.getName()));
throw new ParameterizedValidationException("error.cannot_regenerate_non_generated_password");
}
generateRequest.setGenerationParameters(generationParameters);
return generateRequest;
}
use of org.cloudfoundry.credhub.request.PasswordGenerateRequest in project credhub by cloudfoundry-incubator.
the class GenerateHandlerTest method handleGenerateRequest_whenPasswordGenerateRequest_passesCorrectParametersIncludingGeneration.
@Test
public void handleGenerateRequest_whenPasswordGenerateRequest_passesCorrectParametersIncludingGeneration() {
StringCredentialValue password = new StringCredentialValue("federation");
PasswordGenerateRequest generateRequest = new PasswordGenerateRequest();
final ArrayList<EventAuditRecordParameters> eventAuditRecordParameters = new ArrayList<>();
generateRequest.setType("password");
generateRequest.setGenerationParameters(generationParameters);
generateRequest.setName("/captain");
generateRequest.setAdditionalPermissions(accessControlEntries);
generateRequest.setOverwrite(false);
subject.handle(generateRequest, eventAuditRecordParameters);
verify(credentialService).save(null, null, generateRequest, eventAuditRecordParameters);
verify(permissionService).savePermissions(credentialVersion, accessControlEntries, eventAuditRecordParameters, true, "/captain");
}
Aggregations