Search in sources :

Example 31 with Tenant

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

the class AuthenticationFilterPathMatchingTest method setupTenantQueryMock.

protected List<String> setupTenantQueryMock(List<Tenant> tenants) {
    TenantQuery mockTenantQuery = mock(TenantQuery.class);
    when(identityServiceMock.createTenantQuery()).thenReturn(mockTenantQuery);
    when(mockTenantQuery.userMember(anyString())).thenReturn(mockTenantQuery);
    when(mockTenantQuery.includingGroupsOfUser(anyBoolean())).thenReturn(mockTenantQuery);
    when(mockTenantQuery.list()).thenReturn(tenants);
    List<String> tenantIds = new ArrayList<String>();
    for (Tenant tenant : tenants) {
        tenantIds.add(tenant.getId());
    }
    return tenantIds;
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) TenantQuery(org.camunda.bpm.engine.identity.TenantQuery) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString)

Example 32 with Tenant

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

the class TenantResourceImpl method getTenant.

public TenantDto getTenant(UriInfo context) {
    Tenant tenant = findTenantObject();
    if (tenant == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "Tenant with id " + resourceId + " does not exist");
    }
    TenantDto dto = TenantDto.fromTenant(tenant);
    return dto;
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) TenantDto(org.camunda.bpm.engine.rest.dto.identity.TenantDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 33 with Tenant

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

the class TenantQueryTest method queryById.

@Test
public void queryById() {
    TenantQuery query = identityService.createTenantQuery().tenantId(TENANT_ONE);
    assertThat(query.count(), is(1L));
    assertThat(query.list().size(), is(1));
    Tenant tenant = query.singleResult();
    assertThat(tenant, is(notNullValue()));
    assertThat(tenant.getName(), is("Tenant_1"));
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) TenantQuery(org.camunda.bpm.engine.identity.TenantQuery) Test(org.junit.Test)

Example 34 with Tenant

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

the class IdentityServiceTenantTest method updateTenant.

@Test
public void updateTenant() {
    // create
    Tenant tenant = identityService.newTenant(TENANT_ONE);
    tenant.setName("Tenant");
    identityService.saveTenant(tenant);
    // update
    tenant = identityService.createTenantQuery().singleResult();
    assertThat(tenant, is(notNullValue()));
    tenant.setName("newName");
    identityService.saveTenant(tenant);
    tenant = identityService.createTenantQuery().singleResult();
    assertEquals("newName", tenant.getName());
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) Test(org.junit.Test)

Example 35 with Tenant

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

the class IdentityServiceTenantTest method deleteTenantGroupMembership.

@Test
public void deleteTenantGroupMembership() {
    Tenant tenant = identityService.newTenant(TENANT_ONE);
    identityService.saveTenant(tenant);
    Group group = identityService.newGroup(GROUP_ONE);
    identityService.saveGroup(group);
    identityService.createTenantGroupMembership(TENANT_ONE, GROUP_ONE);
    TenantQuery query = identityService.createTenantQuery().groupMember(GROUP_ONE);
    assertThat(query.count(), is(1L));
    identityService.deleteTenantGroupMembership("nonExisting", GROUP_ONE);
    assertThat(query.count(), is(1L));
    identityService.deleteTenantGroupMembership(TENANT_ONE, "nonExisting");
    assertThat(query.count(), is(1L));
    identityService.deleteTenantGroupMembership(TENANT_ONE, GROUP_ONE);
    assertThat(query.count(), is(0L));
}
Also used : Group(org.camunda.bpm.engine.identity.Group) Tenant(org.camunda.bpm.engine.identity.Tenant) TenantQuery(org.camunda.bpm.engine.identity.TenantQuery) Test(org.junit.Test)

Aggregations

Tenant (org.camunda.bpm.engine.identity.Tenant)47 Test (org.junit.Test)24 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)10 TenantQuery (org.camunda.bpm.engine.identity.TenantQuery)10 Authorization (org.camunda.bpm.engine.authorization.Authorization)9 Group (org.camunda.bpm.engine.identity.Group)9 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)8 User (org.camunda.bpm.engine.identity.User)8 Matchers.anyString (org.mockito.Matchers.anyString)7 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)6 ArrayList (java.util.ArrayList)5 TenantEntity (org.camunda.bpm.engine.impl.persistence.entity.TenantEntity)3 IdentityService (org.camunda.bpm.engine.IdentityService)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)2 AuthorizationServiceImpl (org.camunda.bpm.engine.impl.AuthorizationServiceImpl)2 IdentityServiceImpl (org.camunda.bpm.engine.impl.IdentityServiceImpl)2 Before (org.junit.Before)2 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1