public void testGroupUpdateAuthorizations() {
// crate group while still in god-mode:
Group group1 = identityService.newGroup("group1");
identityService.saveGroup(group1);
// create global auth
Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
basePerms.setResource(GROUP);
basePerms.setResourceId(ANY);
basePerms.addPermission(ALL);
basePerms.removePermission(UPDATE); // revoke update
authorizationService.saveAuthorization(basePerms);
// turn on authorization
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId(jonny2);
// fetch user:
group1 = identityService.createGroupQuery().singleResult();
group1.setName("Group 1");
try {
identityService.saveGroup(group1);
fail("exception expected");
} catch (AuthorizationException e) {
assertEquals(UPDATE.getName(), e.getViolatedPermissionName());
assertEquals(jonny2, e.getUserId());
assertEquals(GROUP.resourceName(), e.getResourceType());
assertEquals("group1", e.getResourceId());
}
// but I can create a new group:
Group group2 = identityService.newGroup("group2");
identityService.saveGroup(group2);
}