Search in sources :

Example 1 with AddGroupWsRequest

use of org.sonarqube.ws.client.permission.AddGroupWsRequest 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)

Example 2 with AddGroupWsRequest

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

the class ProvisioningPermissionTest method restoreData.

@AfterClass
public static void restoreData() throws Exception {
    userRule.resetUsers();
    permissionsWsClient.addGroup(new AddGroupWsRequest().setGroupName("anyone").setPermission("provisioning"));
}
Also used : AddGroupWsRequest(org.sonarqube.ws.client.permission.AddGroupWsRequest) AfterClass(org.junit.AfterClass)

Example 3 with AddGroupWsRequest

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

the class SettingsTest method tearDown.

@AfterClass
public static void tearDown() throws Exception {
    userRule.deactivateUsers("setting-user", "scanner-user");
    // Restore 'Execute Analysis' permission to anyone
    adminWsClient.permissions().addGroup(new AddGroupWsRequest().setGroupName("anyone").setPermission("scan"));
}
Also used : AddGroupWsRequest(org.sonarqube.ws.client.permission.AddGroupWsRequest) AfterClass(org.junit.AfterClass)

Aggregations

AddGroupWsRequest (org.sonarqube.ws.client.permission.AddGroupWsRequest)3 AfterClass (org.junit.AfterClass)2 Test (org.junit.Test)1 WsPermissions (org.sonarqube.ws.WsPermissions)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