use of org.cloudfoundry.credhub.request.PasswordSetRequest in project credhub by cloudfoundry-incubator.
the class SetHandlerTest method handleSetRequest_whenPasswordSetRequest_passesCorrectParametersIncludingGeneration.
@Test
public void handleSetRequest_whenPasswordSetRequest_passesCorrectParametersIncludingGeneration() {
StringCredentialValue password = new StringCredentialValue("federation");
PasswordSetRequest setRequest = new PasswordSetRequest();
final ArrayList<EventAuditRecordParameters> eventAuditRecordParameters = new ArrayList<>();
setRequest.setType("password");
setRequest.setGenerationParameters(generationParameters);
setRequest.setPassword(password);
setRequest.setName("/captain");
setRequest.setAdditionalPermissions(accessControlEntries);
setRequest.setOverwrite(false);
subject.handle(setRequest, eventAuditRecordParameters);
verify(credentialService).save(null, password, setRequest, eventAuditRecordParameters);
verify(permissionService).savePermissions(credentialVersion, accessControlEntries, eventAuditRecordParameters, true, "/captain");
}
use of org.cloudfoundry.credhub.request.PasswordSetRequest in project credhub by cloudfoundry-incubator.
the class SetHandlerTest method handleSetRequest_whenOverwriteIsTrue_shouldSaveAccessControlEntries.
@Test
public void handleSetRequest_whenOverwriteIsTrue_shouldSaveAccessControlEntries() {
StringCredentialValue password = new StringCredentialValue("federation");
PasswordSetRequest setRequest = new PasswordSetRequest();
CredentialVersion existingCredMock = mock(CredentialVersion.class);
when(credentialService.findMostRecent("/captain")).thenReturn(existingCredMock);
final ArrayList<EventAuditRecordParameters> eventAuditRecordParameters = new ArrayList<>();
setRequest.setType("password");
setRequest.setGenerationParameters(generationParameters);
setRequest.setPassword(password);
setRequest.setName("/captain");
setRequest.setAdditionalPermissions(accessControlEntries);
setRequest.setOverwrite(true);
subject.handle(setRequest, eventAuditRecordParameters);
verify(credentialService).save(existingCredMock, password, setRequest, eventAuditRecordParameters);
verify(permissionService).savePermissions(credentialVersion, accessControlEntries, eventAuditRecordParameters, false, "/captain");
}
Aggregations