use of org.sonarqube.ws.client.permission.AddUserWsRequest in project sonarqube by SonarSource.
the class OrganizationTest method addPermissionsToUser.
private void addPermissionsToUser(String orgKeyAndName, String login, String permission, String... otherPermissions) {
PermissionsService permissionsService = ItUtils.newAdminWsClient(orchestrator).permissions();
permissionsService.addUser(new AddUserWsRequest().setLogin(login).setOrganization(orgKeyAndName).setPermission(permission));
for (String otherPermission : otherPermissions) {
permissionsService.addUser(new AddUserWsRequest().setLogin(login).setOrganization(orgKeyAndName).setPermission(otherPermission));
}
}
use of org.sonarqube.ws.client.permission.AddUserWsRequest in project sonarqube by SonarSource.
the class RestartTest method createSystemAdministrator.
private void createSystemAdministrator(String login, String password) {
WsClient wsClient = newAdminWsClient(orchestrator);
createNonSystemAdministrator(wsClient, login, password);
wsClient.permissions().addUser(new AddUserWsRequest().setLogin(login).setPermission("admin"));
}
use of org.sonarqube.ws.client.permission.AddUserWsRequest 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);
}
use of org.sonarqube.ws.client.permission.AddUserWsRequest in project sonarqube by SonarSource.
the class QualityProfileAdminPermissionTest method permission_should_grant_access_to_profile.
@Test
public void permission_should_grant_access_to_profile() {
userRule.createUser("not_profileadm", "userpwd");
userRule.createUser("profileadm", "papwd");
permissionsWsClient.addUser(new AddUserWsRequest().setLogin("profileadm").setPermission("profileadmin"));
runSelenese(orchestrator, // Verify normal user is not allowed to do any modification
"/authorisation/QualityProfileAdminPermissionTest/normal-user.html", // Verify profile admin is allowed to do modifications
"/authorisation/QualityProfileAdminPermissionTest/profile-admin.html");
}
use of org.sonarqube.ws.client.permission.AddUserWsRequest in project sonarqube by SonarSource.
the class SettingsTest method initSettingsService.
@BeforeClass
public static void initSettingsService() throws Exception {
userRule.createUser("setting-user", "setting-user");
userRule.createUser("scanner-user", "scanner-user");
adminWsClient = newAdminWsClient(orchestrator);
// Remove 'Execute Analysis' permission from anyone
adminWsClient.permissions().removeGroup(new RemoveGroupWsRequest().setGroupName("anyone").setPermission("scan"));
// Anonymous user, without 'Execute Analysis' permission
anonymousSettingsService = newWsClient(orchestrator).settingsService();
// Authenticated user, without 'Execute Analysis' permission
userSettingsService = newUserWsClient(orchestrator, "setting-user", "setting-user").settingsService();
// User with 'Execute Analysis' permission
adminWsClient.permissions().addUser(new AddUserWsRequest().setLogin("scanner-user").setPermission("scan"));
scanSettingsService = newUserWsClient(orchestrator, "scanner-user", "scanner-user").settingsService();
// User with 'Administer System' permission but without 'Execute Analysis' permission
adminSettingsService = adminWsClient.settingsService();
}
Aggregations