use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testSuccessfulLoginAfterFailureWithoutDelay.
@Test
public void testSuccessfulLoginAfterFailureWithoutDelay() {
User user = identityService.newUser("johndoe");
user.setPassword("xxx");
identityService.saveUser(user);
Date now = ClockUtil.getCurrentTime();
assertFalse(identityService.checkPassword("johndoe", "invalid pwd"));
try {
assertFalse(identityService.checkPassword("johndoe", "xxx"));
fail("expected exception");
} catch (AuthenticationException e) {
assertEquals("The user with id 'johndoe' is locked.", e.getMessage());
}
ClockUtil.setCurrentTime(DateUtils.addSeconds(now, 30));
assertTrue(identityService.checkPassword("johndoe", "xxx"));
identityService.deleteUser("johndoe");
}
use of org.camunda.bpm.engine.identity.User 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.User in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testUserAccountDetails.
@Test
public void testUserAccountDetails() {
User user = identityService.newUser("testuser");
identityService.saveUser(user);
Map<String, String> accountDetails = new HashMap<String, String>();
accountDetails.put("server", "localhost");
accountDetails.put("port", "35");
identityService.setUserAccount("testuser", "123", "google", "mygoogleusername", "mygooglepwd", accountDetails);
Account googleAccount = identityService.getUserAccount("testuser", "123", "google");
assertEquals(accountDetails, googleAccount.getDetails());
identityService.deleteUser(user.getId());
}
use of org.camunda.bpm.engine.identity.User 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.User 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");
}
Aggregations