use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class PermissionAndCredentialTest method auditsTheRequestWithNoNewPermissions.
private void auditsTheRequestWithNoNewPermissions() throws Exception {
List<EventAuditRecordParameters> auditRecordParameters = newArrayList(new EventAuditRecordParameters(CREDENTIAL_ACCESS, "/test-password"));
auditingHelper.verifyAuditing(UAA_OAUTH2_CLIENT_CREDENTIALS_ACTOR_ID, "/api/v1/data", 200, auditRecordParameters);
}
use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class PermissionsEndpointTest method POST_whenTheLeadingSlashIsMissing_prependsTheSlashCorrectly.
@Test
public void POST_whenTheLeadingSlashIsMissing_prependsTheSlashCorrectly() throws Exception {
RequestHelper.grantPermissions(mockMvc, credentialName, AuthConstants.UAA_OAUTH2_PASSWORD_GRANT_TOKEN, "dan", "read");
auditingHelper.verifyAuditing(AuthConstants.UAA_OAUTH2_PASSWORD_GRANT_ACTOR_ID, "/api/v1/permissions", 201, newArrayList(new EventAuditRecordParameters(ACL_UPDATE, credentialName, PermissionOperation.READ, "dan")));
PermissionsView acl = RequestHelper.getPermissions(mockMvc, credentialName, AuthConstants.UAA_OAUTH2_PASSWORD_GRANT_TOKEN);
assertThat(acl.getCredentialName(), equalTo(credentialName));
assertThat(acl.getPermissions(), hasSize(2));
assertThat(acl.getPermissions(), containsInAnyOrder(samePropertyValuesAs(new PermissionEntry(AuthConstants.UAA_OAUTH2_PASSWORD_GRANT_ACTOR_ID, asList(PermissionOperation.READ, PermissionOperation.WRITE, PermissionOperation.DELETE, PermissionOperation.READ_ACL, PermissionOperation.WRITE_ACL))), samePropertyValuesAs(new PermissionEntry("dan", singletonList(PermissionOperation.READ)))));
}
use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class PermissionsEndpointTest method DELETE_whenTheActorDoesNotHavePermissionToDeletePermissions_returnsNotFound.
@Test
public void DELETE_whenTheActorDoesNotHavePermissionToDeletePermissions_returnsNotFound() throws Exception {
RequestHelper.grantPermissions(mockMvc, credentialName, AuthConstants.UAA_OAUTH2_PASSWORD_GRANT_TOKEN, "dan", "read");
RequestHelper.expectStatusWhenDeletingPermissions(mockMvc, 404, credentialName, "dan", AuthConstants.UAA_OAUTH2_CLIENT_CREDENTIALS_TOKEN);
auditingHelper.verifyAuditing(AuthConstants.UAA_OAUTH2_CLIENT_CREDENTIALS_ACTOR_ID, "/api/v1/permissions", 404, newArrayList(new EventAuditRecordParameters(ACL_DELETE, credentialName, PermissionOperation.READ, "dan")));
PermissionsView permissions = RequestHelper.getPermissions(mockMvc, credentialName, AuthConstants.UAA_OAUTH2_PASSWORD_GRANT_TOKEN);
assertThat(permissions.getPermissions(), hasSize(2));
}
use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class CertificateServiceTest method findByUuid_ReturnsCertificateWithMatchingUuidAndPersistsAuditEntry.
@Test
public void findByUuid_ReturnsCertificateWithMatchingUuidAndPersistsAuditEntry() {
when(permissionCheckingService.hasPermission(actor, credentialName, PermissionOperation.READ)).thenReturn(true);
CertificateCredentialVersion certificate = subject.findByCredentialUuid(credentialUuid, auditRecordParameters);
assertThat(certificate, not(nullValue()));
assertThat(auditRecordParameters.size(), equalTo(1));
EventAuditRecordParameters auditRecord = this.auditRecordParameters.get(0);
assertThat(auditRecord.getAuditingOperationCode(), equalTo(AuditingOperationCode.CREDENTIAL_ACCESS));
assertThat(auditRecord.getCredentialName(), equalTo(credentialName));
}
use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class PermissionedCertificateService method getAll.
public List<Credential> getAll(List<EventAuditRecordParameters> auditRecordParameters) {
auditRecordParameters.add(new EventAuditRecordParameters(AuditingOperationCode.CREDENTIAL_FIND, null));
final List<Credential> allCertificates = certificateDataService.findAll();
return allCertificates.stream().filter(credential -> permissionCheckingService.hasPermission(userContextHolder.getUserContext().getActor(), credential.getName(), PermissionOperation.READ)).collect(Collectors.toList());
}
Aggregations