use of org.camunda.bpm.engine.impl.persistence.entity.GroupEntity in project camunda-bpm-platform by camunda.
the class IdentityServiceAuthorizationsTest method testGroupCreateAuthorizations.
public void testGroupCreateAuthorizations() {
// add base permission which allows nobody to create groups:
Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
basePerms.setResource(GROUP);
basePerms.setResourceId(ANY);
// add all then remove 'create'
basePerms.addPermission(ALL);
basePerms.removePermission(CREATE);
authorizationService.saveAuthorization(basePerms);
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId(jonny2);
try {
identityService.newGroup("group1");
fail("exception expected");
} catch (AuthorizationException e) {
assertEquals(1, e.getMissingAuthorizations().size());
MissingAuthorization info = e.getMissingAuthorizations().get(0);
assertEquals(jonny2, e.getUserId());
assertExceptionInfo(CREATE.getName(), GROUP.resourceName(), null, info);
}
// circumvent auth check to get new transient userobject
Group group = new GroupEntity("group1");
try {
identityService.saveGroup(group);
fail("exception expected");
} catch (AuthorizationException e) {
assertEquals(1, e.getMissingAuthorizations().size());
MissingAuthorization info = e.getMissingAuthorizations().get(0);
assertEquals(jonny2, e.getUserId());
assertExceptionInfo(CREATE.getName(), GROUP.resourceName(), null, info);
}
}
Aggregations