Ejemplo n.º 1
0
  @Test
  public void groups_does_POST_on_WS_groups() {
    GroupsWsRequest request = new GroupsWsRequest();
    underTest.groups(
        request
            .setPermission(PERMISSION_VALUE)
            .setProjectId(PROJECT_ID_VALUE)
            .setProjectKey(PROJECT_KEY_VALUE)
            .setPage(PAGE_VALUE)
            .setPageSize(PAGE_SIZE_VALUE)
            .setSelected(SELECTED_VALUE)
            .setQuery(QUERY_VALUE));

    assertThat(serviceTester.getGetParser()).isSameAs(WsPermissions.WsGroupsResponse.parser());
    GetRequest getRequest = serviceTester.getGetRequest();
    serviceTester
        .assertThat(getRequest)
        .hasPath("groups")
        .hasParam(PARAM_PERMISSION, PERMISSION_VALUE)
        .hasParam(PARAM_PROJECT_ID, PROJECT_ID_VALUE)
        .hasParam(PARAM_PROJECT_KEY, PROJECT_KEY_VALUE)
        .hasParam(PARAM_P, PAGE_VALUE)
        .hasParam(PARAM_PS, PAGE_SIZE_VALUE)
        .hasParam(PARAM_SELECTED, SELECTED_VALUE)
        .hasParam(PARAM_Q, QUERY_VALUE)
        .andNoOtherParam();
  }
Ejemplo n.º 2
0
  @Test
  public void permission_web_services() {
    permissionsWsClient.addUser(new AddUserWsRequest().setPermission("admin").setLogin(LOGIN));
    permissionsWsClient.addGroup(
        new AddGroupWsRequest().setPermission("admin").setGroupName(GROUP_NAME));

    WsPermissions.WsSearchGlobalPermissionsResponse searchGlobalPermissionsWsResponse =
        permissionsWsClient.searchGlobalPermissions();
    assertThat(searchGlobalPermissionsWsResponse.getPermissionsList().get(0).getKey())
        .isEqualTo("admin");
    assertThat(searchGlobalPermissionsWsResponse.getPermissionsList().get(0).getUsersCount())
        .isEqualTo(1);
    // by default, a group has the global admin permission
    assertThat(searchGlobalPermissionsWsResponse.getPermissionsList().get(0).getGroupsCount())
        .isEqualTo(2);

    WsPermissions.UsersWsResponse users =
        permissionsWsClient.users(new UsersWsRequest().setPermission("admin"));
    assertThat(users.getUsersList()).extracting("login").contains(LOGIN);

    WsPermissions.WsGroupsResponse groupsResponse =
        permissionsWsClient.groups(new GroupsWsRequest().setPermission("admin"));
    assertThat(groupsResponse.getGroupsList()).extracting("name").contains(GROUP_NAME);
  }