Exemplo n.º 1
0
  @Test
  public void searchGlobalPermissions_does_GET_on_Ws_search_global_permissions() {
    underTest.searchGlobalPermissions();

    assertThat(serviceTester.getGetParser())
        .isSameAs(WsPermissions.WsSearchGlobalPermissionsResponse.parser());
    GetRequest getRequest = serviceTester.getGetRequest();
    serviceTester.assertThat(getRequest).hasPath("search_global_permissions").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);
  }