use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class IdentityServiceTenantTest method createTenantMembershipUnexistingUser.
@Test
public void createTenantMembershipUnexistingUser() {
Tenant tenant = identityService.newTenant(TENANT_ONE);
identityService.saveTenant(tenant);
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("No user found with id 'nonExisting'.");
identityService.createTenantUserMembership(tenant.getId(), "nonExisting");
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class IdentityServiceTenantTest method deleteTenantMembershipsWhileDeleteGroup.
@Test
public void deleteTenantMembershipsWhileDeleteGroup() {
Tenant tenant = identityService.newTenant(TENANT_ONE);
identityService.saveTenant(tenant);
Group group = identityService.newGroup(GROUP_ONE);
identityService.saveGroup(group);
identityService.createTenantGroupMembership(TENANT_ONE, GROUP_ONE);
TenantQuery query = identityService.createTenantQuery().groupMember(GROUP_ONE);
assertThat(query.count(), is(1L));
identityService.deleteGroup(GROUP_ONE);
assertThat(query.count(), is(0L));
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class IdentityServiceTenantTest method createTenantUserMembershipAlreadyExisting.
@Test
public void createTenantUserMembershipAlreadyExisting() {
Tenant tenant = identityService.newTenant(TENANT_ONE);
identityService.saveTenant(tenant);
User user = identityService.newUser(USER_ONE);
identityService.saveUser(user);
identityService.createTenantUserMembership(TENANT_ONE, USER_ONE);
thrown.expect(ProcessEngineException.class);
identityService.createTenantUserMembership(TENANT_ONE, USER_ONE);
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class IdentityServiceTenantTest method deleteTenant.
@Test
public void deleteTenant() {
// create
Tenant tenant = identityService.newTenant(TENANT_ONE);
identityService.saveTenant(tenant);
TenantQuery query = identityService.createTenantQuery();
assertThat(query.count(), is(1L));
identityService.deleteTenant("nonExisting");
assertThat(query.count(), is(1L));
identityService.deleteTenant(TENANT_ONE);
assertThat(query.count(), is(0L));
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class IdentityServiceAuthorizationsTest method testTenantUserMembershipCreateAuthorizations.
public void testTenantUserMembershipCreateAuthorizations() {
User jonny1 = identityService.newUser("jonny1");
identityService.saveUser(jonny1);
Tenant tenant1 = identityService.newTenant("tenant1");
identityService.saveTenant(tenant1);
// add base permission which allows nobody to create memberships
Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
basePerms.setResource(TENANT_MEMBERSHIP);
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.createTenantUserMembership("tenant1", "jonny1");
fail("exception expected");
} catch (AuthorizationException e) {
assertEquals(1, e.getMissingAuthorizations().size());
MissingAuthorization info = e.getMissingAuthorizations().get(0);
assertEquals(jonny2, e.getUserId());
assertExceptionInfo(CREATE.getName(), TENANT_MEMBERSHIP.resourceName(), "tenant1", info);
}
}
Aggregations