use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testUnsuccessfulLoginAfterFailureWithoutDelay.
@Test
public void testUnsuccessfulLoginAfterFailureWithoutDelay() {
User user = identityService.newUser("johndoe");
user.setPassword("xxx");
identityService.saveUser(user);
Date now = null;
now = ClockUtil.getCurrentTime();
assertFalse(identityService.checkPassword("johndoe", "invalid pwd"));
// try again before exprTime
ClockUtil.setCurrentTime(DateUtils.addSeconds(now, 1));
try {
assertFalse(identityService.checkPassword("johndoe", "invalid pwd"));
fail("expected exception");
} catch (AuthenticationException e) {
assertEquals("The user with id 'johndoe' is locked.", e.getMessage());
}
identityService.deleteUser("johndoe");
}
use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testSaveUserWithGenericResourceId.
@Test
public void testSaveUserWithGenericResourceId() {
User user = identityService.newUser("*");
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("has an invalid id: id cannot be *. * is a reserved identifier.");
identityService.saveUser(user);
}
use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testCreateMembershipUnexistingGroup.
@Test
public void testCreateMembershipUnexistingGroup() {
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
thrown.expect(ProcessEngineException.class);
identityService.createMembership(johndoe.getId(), "unexistinggroup");
}
use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testUserPicture.
@Test
public void testUserPicture() {
// First, create a new user
User user = identityService.newUser("johndoe");
identityService.saveUser(user);
String userId = user.getId();
Picture picture = new Picture("niceface".getBytes(), "image/string");
identityService.setUserPicture(userId, picture);
picture = identityService.getUserPicture(userId);
// Fetch and update the user
user = identityService.createUserQuery().userId("johndoe").singleResult();
assertTrue("byte arrays differ", Arrays.equals("niceface".getBytes(), picture.getBytes()));
assertEquals("image/string", picture.getMimeType());
identityService.deleteUserPicture("johndoe");
// this is ignored
identityService.deleteUserPicture("someone-else-we-dont-know");
// picture does not exist
picture = identityService.getUserPicture("johndoe");
assertNull(picture);
// add new picture
picture = new Picture("niceface".getBytes(), "image/string");
identityService.setUserPicture(userId, picture);
// makes the picture go away
identityService.deleteUser(user.getId());
}
use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testDeleteMembership.
@Test
public void testDeleteMembership() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
// Add membership
identityService.createMembership(johndoe.getId(), sales.getId());
List<Group> groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
assertTrue(groups.size() == 1);
assertEquals("sales", groups.get(0).getId());
// Delete the membership and check members of sales group
identityService.deleteMembership(johndoe.getId(), sales.getId());
groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
assertTrue(groups.size() == 0);
identityService.deleteGroup("sales");
identityService.deleteUser("johndoe");
}
Aggregations