use of org.cloudfoundry.credhub.exceptions.PermissionException in project credhub by cloudfoundry-incubator.
the class PermissionedCredentialServiceTest method save_whenThereIsAnExistingCredentialWithACEs_shouldThrowAnExceptionIfItLacksPermission.
@Test
public void save_whenThereIsAnExistingCredentialWithACEs_shouldThrowAnExceptionIfItLacksPermission() {
when(request.getType()).thenReturn("password");
when(request.getOverwriteMode()).thenReturn(CredentialWriteMode.NO_OVERWRITE.mode);
when(credentialVersionDataService.findMostRecent(CREDENTIAL_NAME)).thenReturn(existingCredentialVersion);
when(permissionCheckingService.hasPermission(userContext.getActor(), CREDENTIAL_NAME, WRITE_ACL)).thenReturn(false);
accessControlEntries.add(new PermissionEntry("some_actor", Arrays.asList(PermissionOperation.READ_ACL)));
try {
subject.save(existingCredentialVersion, credentialValue, request, auditRecordParameters);
} catch (PermissionException pe) {
assertThat(pe.getMessage(), equalTo("error.credential.invalid_access"));
}
}
Aggregations