diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-09-25 15:43:10 +0200 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-10-02 17:18:15 +0200 |
commit | bb0bd260f3742c010b9e7034ea5d6947e694a130 (patch) | |
tree | 172e2e72927424fcb131c0cfcce75fcd4c33b348 /sonar-ws | |
parent | e212b5945cbd0fdfda9caeac6cf969732f11f74e (diff) | |
download | sonarqube-bb0bd260f3742c010b9e7034ea5d6947e694a130.tar.gz sonarqube-bb0bd260f3742c010b9e7034ea5d6947e694a130.zip |
SONAR-1330 Remove group 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 6a087a42088..ed65f9d6dab 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 @@ -44,6 +44,7 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_CREATE; 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_GROUP; 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; @@ -219,4 +220,12 @@ public class QualityProfilesService extends BaseService { .setParam(PARAM_LANGUAGE, request.getLanguage()) .setParam(PARAM_GROUP, request.getGroup())); } + + public void removeGroup(RemoveGroupRequest request) { + call(new PostRequest(path(ACTION_REMOVE_GROUP)) + .setParam(PARAM_ORGANIZATION, request.getOrganization()) + .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) + .setParam(PARAM_LANGUAGE, request.getLanguage()) + .setParam(PARAM_GROUP, request.getGroup())); + } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveGroupRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveGroupRequest.java new file mode 100644 index 00000000000..6bd43b8257b --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveGroupRequest.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 RemoveGroupRequest { + + private final String organization; + private final String language; + private final String qualityProfile; + private final String group; + + private RemoveGroupRequest(Builder builder) { + this.language = builder.language; + this.organization = builder.organization; + this.qualityProfile = builder.qualityProfile; + this.group = builder.group; + } + + public String getLanguage() { + return language; + } + + public String getOrganization() { + return organization; + } + + public String getQualityProfile() { + return qualityProfile; + } + + public String getGroup() { + return group; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String organization; + private String qualityProfile; + private String language; + private String group; + + 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 setGroup(String group) { + this.group = group; + return this; + } + + public RemoveGroupRequest build() { + return new RemoveGroupRequest(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 9e4a414cb26..a3dd96ee3c0 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 @@ -287,4 +287,23 @@ public class QualityProfilesServiceTest { .hasParam(PARAM_GROUP, "users") .andNoOtherParam(); } + + @Test + public void remove_group() { + underTest.removeGroup(RemoveGroupRequest.builder() + .setOrganization("O1") + .setQualityProfile("P1") + .setLanguage("Xoo") + .setGroup("users") + .build()); + PostRequest request = serviceTester.getPostRequest(); + + serviceTester.assertThat(request) + .hasPath("remove_group") + .hasParam(PARAM_ORGANIZATION, "O1") + .hasParam(PARAM_QUALITY_PROFILE, "P1") + .hasParam(PARAM_LANGUAGE, "Xoo") + .hasParam(PARAM_GROUP, "users") + .andNoOtherParam(); + } } |