Search in sources :

Example 41 with User

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

Example 42 with User

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

Example 43 with User

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

Example 44 with User

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

Example 45 with User

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