Search in sources :

Example 91 with User

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");
}
Also used : User(org.camunda.bpm.engine.identity.User) AuthenticationException(org.camunda.bpm.engine.AuthenticationException) Date(java.util.Date) Test(org.junit.Test)

Example 92 with User

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);
}
Also used : User(org.camunda.bpm.engine.identity.User) Test(org.junit.Test)

Example 93 with 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");
}
Also used : User(org.camunda.bpm.engine.identity.User) Test(org.junit.Test)

Example 94 with User

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());
}
Also used : User(org.camunda.bpm.engine.identity.User) Picture(org.camunda.bpm.engine.identity.Picture) Test(org.junit.Test)

Example 95 with User

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");
}
Also used : Group(org.camunda.bpm.engine.identity.Group) User(org.camunda.bpm.engine.identity.User) Test(org.junit.Test)

Aggregations

User (org.camunda.bpm.engine.identity.User)139 Test (org.junit.Test)67 Group (org.camunda.bpm.engine.identity.Group)29 UserQuery (org.camunda.bpm.engine.identity.UserQuery)24 Authorization (org.camunda.bpm.engine.authorization.Authorization)20 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)12 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)12 Matchers.anyString (org.mockito.Matchers.anyString)11 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)10 ArrayList (java.util.ArrayList)9 IdentityService (org.camunda.bpm.engine.IdentityService)8 Tenant (org.camunda.bpm.engine.identity.Tenant)8 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 Task (org.camunda.bpm.engine.task.Task)6 Date (java.util.Date)5 HashMap (java.util.HashMap)5 GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)5 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)5 UserCredentialsDto (org.camunda.bpm.engine.rest.dto.identity.UserCredentialsDto)5 UserDto (org.camunda.bpm.engine.rest.dto.identity.UserDto)5