Search in sources :

Example 1 with CredentialView

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

the class CredentialsHandlerTest method getCredentialVersion_whenTheVersionExists_returnsDataResponse.

@Test
public void getCredentialVersion_whenTheVersionExists_returnsDataResponse() {
    when(permissionedCredentialService.findVersionByUuid(eq(UUID_STRING), any(List.class))).thenReturn(version1);
    CredentialView credentialVersion = subject.getCredentialVersionByUUID(UUID_STRING, newArrayList());
    assertThat(credentialVersion.getName(), equalTo(CREDENTIAL_NAME));
    assertThat(credentialVersion.getVersionCreatedAt(), equalTo(VERSION1_CREATED_AT));
}
Also used : CredentialView(org.cloudfoundry.credhub.view.CredentialView) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) Test(org.junit.Test)

Example 2 with CredentialView

use of org.cloudfoundry.credhub.view.CredentialView 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 3 with CredentialView

use of org.cloudfoundry.credhub.view.CredentialView 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)3 Test (org.junit.Test)3 DataResponse (org.cloudfoundry.credhub.view.DataResponse)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)1 SshCredentialVersion (org.cloudfoundry.credhub.domain.SshCredentialVersion)1