Package org.camunda.bpm.engine.authorization

Examples of org.camunda.bpm.engine.authorization.AuthorizationQuery


  public void testAuthorizationResourceOptionsUnauthorized() {
    String fullAuthorizationUrl = "http://localhost:" + PORT + TEST_RESOURCE_ROOT_PATH + AuthorizationRestService.PATH + "/" + MockProvider.EXAMPLE_AUTHORIZATION_ID;
   
    Authorization authorization = MockProvider.createMockGlobalAuthorization();
   
    AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
    when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
    when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
    when(authorizationQuery.singleResult()).thenReturn(authorization);

    Authentication authentication = new Authentication(MockProvider.EXAMPLE_USER_ID, null);   
    when(identityServiceMock.getCurrentAuthentication()).thenReturn(authentication);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, DELETE, AUTHORIZATION, MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(false);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, UPDATE, AUTHORIZATION, MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(false);
View Full Code Here


  public void testAuthorizationResourceOptionsUpdateUnauthorized() {
    String fullAuthorizationUrl = "http://localhost:" + PORT + TEST_RESOURCE_ROOT_PATH + AuthorizationRestService.PATH + "/" + MockProvider.EXAMPLE_AUTHORIZATION_ID;
   
    Authorization authorization = MockProvider.createMockGlobalAuthorization();
   
    AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
    when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
    when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
    when(authorizationQuery.singleResult()).thenReturn(authorization);

    Authentication authentication = new Authentication(MockProvider.EXAMPLE_USER_ID, null);   
    when(identityServiceMock.getCurrentAuthentication()).thenReturn(authentication);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, DELETE, AUTHORIZATION, MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(true);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, UPDATE, AUTHORIZATION, MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(false);
View Full Code Here

  }

  public List<AuthorizationDto> queryAuthorizations(AuthorizationQueryDto queryDto, Integer firstResult, Integer maxResults) {

    queryDto.setObjectMapper(getObjectMapper());
    AuthorizationQuery query = queryDto.toQuery(getProcessEngine());

    List<Authorization> resultList;
    if(firstResult != null || maxResults != null) {
      resultList = executePaginatedQuery(query, firstResult, maxResults);
    } else {
      resultList = query.list();
    }

    return AuthorizationDto.fromAuthorizationList(resultList);
  }
View Full Code Here

    AuthorizationQueryDto queryDto = new AuthorizationQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    return getAuthorizationCount(queryDto);
  }

  protected CountResultDto getAuthorizationCount(AuthorizationQueryDto queryDto) {
    AuthorizationQuery query = queryDto.toQuery(getProcessEngine());
    long count = query.count();
    return new CountResultDto(count);
  }
View Full Code Here

    when(processEngine.getAuthorizationService()).thenReturn(authorizationServiceMock);
    when(processEngine.getIdentityService()).thenReturn(identityServiceMock);
  }

  private AuthorizationQuery setUpMockQuery(List<Authorization> list) {
    AuthorizationQuery query = mock(AuthorizationQuery.class);
    when(query.list()).thenReturn(list);
    when(query.count()).thenReturn((long) list.size());

    when(processEngine.getAuthorizationService().createAuthorizationQuery()).thenReturn(query);

    return query;
  }
View Full Code Here

  }

  @Test
  public void testNoParametersQuery() {

    AuthorizationQuery mockQuery = setUpMockQuery(MockProvider.createMockAuthorizations());

    expect().statusCode(Status.OK.getStatusCode()).when().get(SERVICE_PATH);

    verify(mockQuery).list();
    verifyNoMoreInteractions(mockQuery);
View Full Code Here

  @Test
  public void testSimpleAuthorizationQuery() {

    List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations();
    AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations);

    Response response = given().queryParam("type", Authorization.AUTH_TYPE_GLOBAL)
      .then().expect().statusCode(Status.OK.getStatusCode())
      .when().get(SERVICE_PATH);
View Full Code Here

  @Test
  public void testCompleteGetParameters() {

    List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations();
    AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations);

    Map<String, String> queryParameters = getCompleteStringQueryParameters();

    RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
    for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
View Full Code Here

  }

  @Test
  public void testQueryCount() {

    AuthorizationQuery mockQuery = setUpMockQuery(MockProvider.createMockAuthorizations());

    expect().statusCode(Status.OK.getStatusCode())
      .body("count", equalTo(3))
      .when().get(SERVICE_COUNT_PATH);
View Full Code Here

  }

  @Test
  public void testSuccessfulPagination() {

    AuthorizationQuery mockQuery = setUpMockQuery(MockProvider.createMockAuthorizations());

    int firstResult = 0;
    int maxResults = 10;
    given().queryParam("firstResult", firstResult).queryParam("maxResults", maxResults)
      .then().expect().statusCode(Status.OK.getStatusCode())
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.authorization.AuthorizationQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.