use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testCreateMembershipAlreadyExisting.
@Test
public void testCreateMembershipAlreadyExisting() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
// Create the membership
identityService.createMembership(johndoe.getId(), sales.getId());
thrown.expect(ProcessEngineException.class);
identityService.createMembership(johndoe.getId(), sales.getId());
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testDeleteMembershipWhenUserIsNoMember.
@Test
public void testDeleteMembershipWhenUserIsNoMember() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
// Delete the membership when the user is no member
identityService.deleteMembership(johndoe.getId(), sales.getId());
identityService.deleteGroup("sales");
identityService.deleteUser("johndoe");
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testUpdateGroup.
@Test
public void testUpdateGroup() {
Group group = identityService.newGroup("sales");
group.setName("Sales");
identityService.saveGroup(group);
group = identityService.createGroupQuery().groupId("sales").singleResult();
group.setName("Updated");
identityService.saveGroup(group);
group = identityService.createGroupQuery().groupId("sales").singleResult();
assertEquals("Updated", group.getName());
identityService.deleteGroup(group.getId());
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testFindGroupsByUserAndType.
@Test
public void testFindGroupsByUserAndType() {
Group sales = identityService.newGroup("sales");
sales.setType("hierarchy");
identityService.saveGroup(sales);
Group development = identityService.newGroup("development");
development.setType("hierarchy");
identityService.saveGroup(development);
Group admin = identityService.newGroup("admin");
admin.setType("security-role");
identityService.saveGroup(admin);
Group user = identityService.newGroup("user");
user.setType("security-role");
identityService.saveGroup(user);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
User joesmoe = identityService.newUser("joesmoe");
identityService.saveUser(joesmoe);
User jackblack = identityService.newUser("jackblack");
identityService.saveUser(jackblack);
identityService.createMembership("johndoe", "sales");
identityService.createMembership("johndoe", "user");
identityService.createMembership("johndoe", "admin");
identityService.createMembership("joesmoe", "user");
List<Group> groups = identityService.createGroupQuery().groupMember("johndoe").groupType("security-role").list();
Set<String> groupIds = getGroupIds(groups);
Set<String> expectedGroupIds = new HashSet<String>();
expectedGroupIds.add("user");
expectedGroupIds.add("admin");
assertEquals(expectedGroupIds, groupIds);
groups = identityService.createGroupQuery().groupMember("joesmoe").groupType("security-role").list();
groupIds = getGroupIds(groups);
expectedGroupIds = new HashSet<String>();
expectedGroupIds.add("user");
assertEquals(expectedGroupIds, groupIds);
groups = identityService.createGroupQuery().groupMember("jackblack").groupType("security-role").list();
assertTrue(groups.isEmpty());
identityService.deleteGroup("sales");
identityService.deleteGroup("development");
identityService.deleteGroup("admin");
identityService.deleteGroup("user");
identityService.deleteUser("johndoe");
identityService.deleteUser("joesmoe");
identityService.deleteUser("jackblack");
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class WriteMultipleEntitiesInOneTransactionTest method testWriteMultipleEntitiesInOneTransaction.
public void testWriteMultipleEntitiesInOneTransaction() {
// the identity service provider registered with the engine creates a user, a group, and a membership
// in the following call:
Assert.assertTrue(identityService.checkPassword("multipleEntities", "inOneStep"));
User user = identityService.createUserQuery().userId("multipleEntities").singleResult();
Assert.assertNotNull(user);
Assert.assertEquals("multipleEntities", user.getId());
Assert.assertEquals("{SHA}pfdzmt+49nwknTy7xhZd7ZW5suI=", user.getPassword());
// It is expected, that the User is in exactly one Group
List<Group> groups = this.identityService.createGroupQuery().groupMember("multipleEntities").list();
Assert.assertEquals(1, groups.size());
Group group = groups.get(0);
Assert.assertEquals("multipleEntities_group", group.getId());
// clean the Db
identityService.deleteMembership("multipleEntities", "multipleEntities_group");
identityService.deleteGroup("multipleEntities_group");
identityService.deleteUser("multipleEntities");
}
Aggregations