use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class TenantRestServiceInteractionTest method createExistingTenant.
@Test
public void createExistingTenant() {
Tenant newTenant = MockProvider.createMockTenant();
when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenReturn(newTenant);
String message = "exception expected";
doThrow(new ProcessEngineException(message)).when(identityServiceMock).saveTenant(newTenant);
given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(ProcessEngineException.class.getSimpleName())).body("message", equalTo(message)).when().post(TENANT_CREATE_URL);
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class TenantRestServiceInteractionTest method failToCreateTenantForReadOnlyService.
@Test
public void failToCreateTenantForReadOnlyService() {
Tenant newTenant = MockProvider.createMockTenant();
when(identityServiceMock.isReadOnly()).thenReturn(true);
given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Identity service implementation is read-only.")).when().post(TENANT_CREATE_URL);
verify(identityServiceMock, never()).newTenant(MockProvider.EXAMPLE_TENANT_ID);
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class TenantRestServiceImpl method createTenant.
public void createTenant(TenantDto dto) {
if (getIdentityService().isReadOnly()) {
throw new InvalidRequestException(Status.FORBIDDEN, "Identity service implementation is read-only.");
}
Tenant newTenant = getIdentityService().newTenant(dto.getId());
dto.update(newTenant);
getIdentityService().saveTenant(newTenant);
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class TenantRestServiceImpl method queryTenants.
public List<TenantDto> queryTenants(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
TenantQueryDto queryDto = new TenantQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
TenantQuery query = queryDto.toQuery(getProcessEngine());
List<Tenant> tenants;
if (firstResult != null || maxResults != null) {
tenants = executePaginatedQuery(query, firstResult, maxResults);
} else {
tenants = query.list();
}
return TenantDto.fromTenantList(tenants);
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class ProcessEngineAuthenticationFilter method getTenantsOfUser.
protected List<String> getTenantsOfUser(ProcessEngine engine, String userId) {
List<Tenant> tenants = engine.getIdentityService().createTenantQuery().userMember(userId).includingGroupsOfUser(true).list();
List<String> tenantIds = new ArrayList<String>();
for (Tenant tenant : tenants) {
tenantIds.add(tenant.getId());
}
return tenantIds;
}
Aggregations