diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-09-22 13:55:06 +0200 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-10-02 17:18:15 +0200 |
commit | 4c0d81eb984640587557787892ee3f1cbdcc193b (patch) | |
tree | 5d649445c7415fd6f1839ce77841facb4082d97b /sonar-ws | |
parent | 92f07538cf9928e2107d201f8518061a69ac1341 (diff) | |
download | sonarqube-4c0d81eb984640587557787892ee3f1cbdcc193b.tar.gz sonarqube-4c0d81eb984640587557787892ee3f1cbdcc193b.zip |
SONAR-1330 Remove user permission to edit single quality profile
Diffstat (limited to 'sonar-ws')
3 files changed, 121 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java index 38f5c2ca100..340fd30d4a5 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java @@ -39,6 +39,7 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DELETE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_REMOVE_PROJECT; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_REMOVE_USER; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_RESTORE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SET_DEFAULT; @@ -181,4 +182,12 @@ public class QualityProfilesService extends BaseService { .setParam(PARAM_LANGUAGE, request.getLanguage()) .setParam(PARAM_LOGIN, request.getUserLogin())); } + + public void removeUser(RemoveUserRequest request) { + call(new PostRequest(path(ACTION_REMOVE_USER)) + .setParam(PARAM_ORGANIZATION, request.getOrganization()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) + .setParam(PARAM_LANGUAGE, request.getLanguage()) + .setParam(PARAM_LOGIN, request.getUserLogin())); + } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveUserRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveUserRequest.java new file mode 100644 index 00000000000..609ac00d562 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveUserRequest.java @@ -0,0 +1,93 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.ws.client.qualityprofile; + +import javax.annotation.concurrent.Immutable; + +@Immutable +public class RemoveUserRequest { + + private final String organization; + private final String language; + private final String qualityProfile; + private final String userLogin; + + private RemoveUserRequest(Builder builder) { + this.language = builder.language; + this.organization = builder.organization; + this.qualityProfile = builder.qualityProfile; + this.userLogin = builder.userLogin; + } + + public String getLanguage() { + return language; + } + + public String getOrganization() { + return organization; + } + + public String getQualityProfile() { + return qualityProfile; + } + + public String getUserLogin() { + return userLogin; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String organization; + private String qualityProfile; + private String language; + private String userLogin; + + private Builder() { + // enforce factory method use + } + + public Builder setLanguage(String language) { + this.language = language; + return this; + } + + public Builder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public Builder setQualityProfile(String qualityProfile) { + this.qualityProfile = qualityProfile; + return this; + } + + public Builder setUserLogin(String userLogin) { + this.userLogin = userLogin; + return this; + } + + public RemoveUserRequest build() { + return new RemoveUserRequest(this); + } + } +} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java index 591d1690abc..63c4fcc8e8d 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java @@ -216,4 +216,23 @@ public class QualityProfilesServiceTest { .hasParam(PARAM_LOGIN, "john") .andNoOtherParam(); } + + @Test + public void remove_user() { + underTest.removeUser(RemoveUserRequest.builder() + .setOrganization("O1") + .setQualityProfile("P1") + .setLanguage("Xoo") + .setUserLogin("john") + .build()); + PostRequest request = serviceTester.getPostRequest(); + + serviceTester.assertThat(request) + .hasPath("remove_user") + .hasParam(PARAM_ORGANIZATION, "O1") + .hasParam(PARAM_QUALITY_PROFILE, "P1") + .hasParam(PARAM_LANGUAGE, "Xoo") + .hasParam(PARAM_LOGIN, "john") + .andNoOtherParam(); + } } |