Search in sources :

Example 1 with DataResponse

use of org.cloudfoundry.credhub.view.DataResponse in project credhub by cloudfoundry-incubator.

the class CredentialsHandlerTest method getAllCredentialVersions_whenTheCredentialExists_returnsADataResponse.

@Test
public void getAllCredentialVersions_whenTheCredentialExists_returnsADataResponse() {
    List<CredentialVersion> credentials = newArrayList(version1, version2);
    when(permissionedCredentialService.findAllByName(eq(CREDENTIAL_NAME), eq(auditRecordParametersList))).thenReturn(credentials);
    when(permissionCheckingService.hasPermission(USER, CREDENTIAL_NAME, PermissionOperation.READ)).thenReturn(true);
    DataResponse credentialVersions = subject.getAllCredentialVersions(CREDENTIAL_NAME, auditRecordParametersList);
    List<CredentialView> credentialViews = credentialVersions.getData();
    assertThat(credentialViews, hasSize(2));
    assertThat(credentialViews.get(0).getName(), equalTo(CREDENTIAL_NAME));
    assertThat(credentialViews.get(0).getVersionCreatedAt(), equalTo(VERSION1_CREATED_AT));
    assertThat(credentialViews.get(1).getName(), equalTo(CREDENTIAL_NAME));
    assertThat(credentialViews.get(1).getVersionCreatedAt(), equalTo(VERSION2_CREATED_AT));
}
Also used : DataResponse(org.cloudfoundry.credhub.view.DataResponse) CredentialView(org.cloudfoundry.credhub.view.CredentialView) SshCredentialVersion(org.cloudfoundry.credhub.domain.SshCredentialVersion) CredentialVersion(org.cloudfoundry.credhub.domain.CredentialVersion) Test(org.junit.Test)

Example 2 with DataResponse

use of org.cloudfoundry.credhub.view.DataResponse in project credhub by cloudfoundry-incubator.

the class CredentialsHandlerTest method getMostRecentCredentialVersion_whenTheCredentialExists_returnsDataResponse.

@Test
public void getMostRecentCredentialVersion_whenTheCredentialExists_returnsDataResponse() {
    when(permissionedCredentialService.findActiveByName(eq(CREDENTIAL_NAME), eq(auditRecordParametersList))).thenReturn(Arrays.asList(version1));
    when(permissionCheckingService.hasPermission(USER, CREDENTIAL_NAME, PermissionOperation.READ)).thenReturn(true);
    DataResponse dataResponse = subject.getCurrentCredentialVersions(CREDENTIAL_NAME, auditRecordParametersList);
    CredentialView credentialView = dataResponse.getData().get(0);
    assertThat(credentialView.getName(), equalTo(CREDENTIAL_NAME));
    assertThat(credentialView.getVersionCreatedAt(), equalTo(VERSION1_CREATED_AT));
}
Also used : DataResponse(org.cloudfoundry.credhub.view.DataResponse) CredentialView(org.cloudfoundry.credhub.view.CredentialView) Test(org.junit.Test)

Aggregations

CredentialView (org.cloudfoundry.credhub.view.CredentialView)2 DataResponse (org.cloudfoundry.credhub.view.DataResponse)2 Test (org.junit.Test)2 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)1 SshCredentialVersion (org.cloudfoundry.credhub.domain.SshCredentialVersion)1