Search in sources :

Example 1 with PasswordSetRequest

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");
}
Also used : StringCredentialValue(org.cloudfoundry.credhub.credential.StringCredentialValue) ArrayList(java.util.ArrayList) PasswordSetRequest(org.cloudfoundry.credhub.request.PasswordSetRequest) EventAuditRecordParameters(org.cloudfoundry.credhub.audit.EventAuditRecordParameters) Test(org.junit.Test)

Example 2 with PasswordSetRequest

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");
}
Also used : StringCredentialValue(org.cloudfoundry.credhub.credential.StringCredentialValue) ArrayList(java.util.ArrayList) PasswordSetRequest(org.cloudfoundry.credhub.request.PasswordSetRequest) EventAuditRecordParameters(org.cloudfoundry.credhub.audit.EventAuditRecordParameters) PasswordCredentialVersion(org.cloudfoundry.credhub.domain.PasswordCredentialVersion) CredentialVersion(org.cloudfoundry.credhub.domain.CredentialVersion) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 EventAuditRecordParameters (org.cloudfoundry.credhub.audit.EventAuditRecordParameters)2 StringCredentialValue (org.cloudfoundry.credhub.credential.StringCredentialValue)2 PasswordSetRequest (org.cloudfoundry.credhub.request.PasswordSetRequest)2 Test (org.junit.Test)2 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)1 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)1