Search in sources :

Example 6 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class MockGroupBuilder method build.

@SuppressWarnings("unchecked")
public Group build() {
    Group group = mock(Group.class);
    when(group.getId()).thenReturn(id);
    when(group.getName()).thenReturn(name);
    when(group.getType()).thenReturn(type);
    return group;
}
Also used : Group(org.camunda.bpm.engine.identity.Group)

Example 7 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class AuthenticationFilterPathMatchingTest method setup.

@Before
public void setup() throws ServletException {
    currentEngine = getProcessEngine(engineName);
    authorizationServiceMock = mock(AuthorizationServiceImpl.class);
    identityServiceMock = mock(IdentityServiceImpl.class);
    repositoryServiceMock = mock(RepositoryService.class);
    when(currentEngine.getAuthorizationService()).thenReturn(authorizationServiceMock);
    when(currentEngine.getIdentityService()).thenReturn(identityServiceMock);
    // for authentication
    userMock = MockProvider.createMockUser();
    List<Group> groupMocks = MockProvider.createMockGroups();
    groupIds = setupGroupQueryMock(groupMocks);
    List<Tenant> tenantMocks = Collections.singletonList(MockProvider.createMockTenant());
    tenantIds = setupTenantQueryMock(tenantMocks);
    GroupQuery mockGroupQuery = mock(GroupQuery.class);
    when(identityServiceMock.createGroupQuery()).thenReturn(mockGroupQuery);
    when(mockGroupQuery.groupMember(anyString())).thenReturn(mockGroupQuery);
    when(mockGroupQuery.list()).thenReturn(groupMocks);
    setupFilter();
}
Also used : Group(org.camunda.bpm.engine.identity.Group) Tenant(org.camunda.bpm.engine.identity.Tenant) IdentityServiceImpl(org.camunda.bpm.engine.impl.IdentityServiceImpl) GroupQuery(org.camunda.bpm.engine.identity.GroupQuery) AuthorizationServiceImpl(org.camunda.bpm.engine.impl.AuthorizationServiceImpl) RepositoryService(org.camunda.bpm.engine.RepositoryService) Before(org.junit.Before)

Example 8 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class AuthenticationFilterPathMatchingTest method setupGroupQueryMock.

protected List<String> setupGroupQueryMock(List<Group> groups) {
    GroupQuery mockGroupQuery = mock(GroupQuery.class);
    when(identityServiceMock.createGroupQuery()).thenReturn(mockGroupQuery);
    when(mockGroupQuery.groupMember(anyString())).thenReturn(mockGroupQuery);
    when(mockGroupQuery.list()).thenReturn(groups);
    List<String> groupIds = new ArrayList<String>();
    for (Group groupMock : groups) {
        groupIds.add(groupMock.getId());
    }
    return groupIds;
}
Also used : Group(org.camunda.bpm.engine.identity.Group) GroupQuery(org.camunda.bpm.engine.identity.GroupQuery) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString)

Example 9 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class LdapGroupQueryTest method testFilterByGroupId.

public void testFilterByGroupId() {
    Group group = identityService.createGroupQuery().groupId("management").singleResult();
    assertNotNull(group);
    // validate result
    assertEquals("management", group.getId());
    assertEquals("management", group.getName());
    group = identityService.createGroupQuery().groupId("whatever").singleResult();
    assertNull(group);
}
Also used : Group(org.camunda.bpm.engine.identity.Group)

Example 10 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class LdapGroupQueryTest method testFilterByGroupName.

public void testFilterByGroupName() {
    Group group = identityService.createGroupQuery().groupName("management").singleResult();
    assertNotNull(group);
    // validate result
    assertEquals("management", group.getId());
    assertEquals("management", group.getName());
    group = identityService.createGroupQuery().groupName("whatever").singleResult();
    assertNull(group);
}
Also used : Group(org.camunda.bpm.engine.identity.Group)

Aggregations

Group (org.camunda.bpm.engine.identity.Group)92 Test (org.junit.Test)34 User (org.camunda.bpm.engine.identity.User)29 GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)22 Authorization (org.camunda.bpm.engine.authorization.Authorization)13 ArrayList (java.util.ArrayList)12 Matchers.anyString (org.mockito.Matchers.anyString)12 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)10 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)9 Tenant (org.camunda.bpm.engine.identity.Tenant)9 IdentityService (org.camunda.bpm.engine.IdentityService)7 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)7 UserQuery (org.camunda.bpm.engine.identity.UserQuery)4 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)4 Before (org.junit.Before)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2