Exemplo n.º 1
0
  @Test
  public void users_does_GET_on_Ws_users() {
    underTest.users(
        new UsersWsRequest()
            .setPermission(PERMISSION_VALUE)
            .setProjectId(PROJECT_ID_VALUE)
            .setProjectKey(PROJECT_KEY_VALUE)
            .setSelected(SELECTED_VALUE)
            .setPage(PAGE_VALUE)
            .setPageSize(PAGE_SIZE_VALUE)
            .setQuery(QUERY_VALUE));

    assertThat(serviceTester.getGetParser()).isSameAs(WsPermissions.UsersWsResponse.parser());
    GetRequest getRequest = serviceTester.getGetRequest();
    serviceTester
        .assertThat(getRequest)
        .hasPath("users")
        .hasParam(PARAM_PERMISSION, PERMISSION_VALUE)
        .hasParam(PARAM_PROJECT_ID, PROJECT_ID_VALUE)
        .hasParam(PARAM_PROJECT_KEY, PROJECT_KEY_VALUE)
        .hasParam(PARAM_SELECTED, SELECTED_VALUE)
        .hasParam(PARAM_P, PAGE_VALUE)
        .hasParam(PARAM_PS, PAGE_SIZE_VALUE)
        .hasParam(PARAM_Q, QUERY_VALUE)
        .andNoOtherParam();
  }
  @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);
  }