Search in sources :

Example 1 with UsersWsRequest

use of org.sonarqube.ws.client.permission.UsersWsRequest in project sonarqube by SonarSource.

the class PermissionSearchTest method permission_web_services.

@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);
}
Also used : UsersWsRequest(org.sonarqube.ws.client.permission.UsersWsRequest) GroupsWsRequest(org.sonarqube.ws.client.permission.GroupsWsRequest) AddUserWsRequest(org.sonarqube.ws.client.permission.AddUserWsRequest) WsPermissions(org.sonarqube.ws.WsPermissions) AddGroupWsRequest(org.sonarqube.ws.client.permission.AddGroupWsRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 WsPermissions (org.sonarqube.ws.WsPermissions)1 AddGroupWsRequest (org.sonarqube.ws.client.permission.AddGroupWsRequest)1 AddUserWsRequest (org.sonarqube.ws.client.permission.AddUserWsRequest)1 GroupsWsRequest (org.sonarqube.ws.client.permission.GroupsWsRequest)1 UsersWsRequest (org.sonarqube.ws.client.permission.UsersWsRequest)1