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));
}
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));
}
Aggregations