diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-09-19 19:46:19 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-09-19 19:46:19 +0200 |
commit | 27d59f400e79c0a834b2e665719d0411af35cb5d (patch) | |
tree | 8a2f20f0372652e8a5ab93195e7dd88c15cd592d /sonar-ws-client | |
parent | 63b40dda0609ffb8fd7a13fcce6b6859e0a75195 (diff) | |
download | sonarqube-27d59f400e79c0a834b2e665719d0411af35cb5d.tar.gz sonarqube-27d59f400e79c0a834b2e665719d0411af35cb5d.zip |
SONAR-4694 Allow project permissions management from the permission web service
Diffstat (limited to 'sonar-ws-client')
2 files changed, 69 insertions, 4 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java index 1cdd4dc4240..422235e8545 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java @@ -45,6 +45,11 @@ public class PermissionParameters { return this; } + public PermissionParameters component(String component) { + params.put("component", component); + return this; + } + public PermissionParameters permission(String permission) { params.put("permission", permission); return this; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/permissions/DefaultPermissionClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/permissions/DefaultPermissionClientTest.java index cfff8516dde..83d429e8b73 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/permissions/DefaultPermissionClientTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/permissions/DefaultPermissionClientTest.java @@ -45,7 +45,7 @@ public class DefaultPermissionClientTest { } @Test - public void should_add_user_permission() { + public void should_add_global_user_permission() { httpServer.stubStatusCode(200); PermissionParameters params = PermissionParameters.create().user("daveloper").permission("admin"); @@ -59,7 +59,22 @@ public class DefaultPermissionClientTest { } @Test - public void should_add_group_permission() { + public void should_add_component_user_permission() { + httpServer.stubStatusCode(200); + + PermissionParameters params = PermissionParameters.create().user("daveloper").component("org.sample.Sample").permission("admin"); + client.addPermission(params); + + assertThat(httpServer.requestedPath()).isEqualTo("/api/permissions/add"); + assertThat(httpServer.requestParams()).includes( + entry("user", "daveloper"), + entry("component", "org.sample.Sample"), + entry("permission", "admin") + ); + } + + @Test + public void should_add_global_group_permission() { httpServer.stubStatusCode(200); PermissionParameters params = PermissionParameters.create().group("my_group").permission("admin"); @@ -73,7 +88,22 @@ public class DefaultPermissionClientTest { } @Test - public void should_remove_user_permission() { + public void should_add_component_group_permission() { + httpServer.stubStatusCode(200); + + PermissionParameters params = PermissionParameters.create().group("my_group").component("org.sample.Sample").permission("admin"); + client.addPermission(params); + + assertThat(httpServer.requestedPath()).isEqualTo("/api/permissions/add"); + assertThat(httpServer.requestParams()).includes( + entry("group", "my_group"), + entry("component", "org.sample.Sample"), + entry("permission", "admin") + ); + } + + @Test + public void should_remove_global_user_permission() { httpServer.stubStatusCode(200); PermissionParameters params = PermissionParameters.create().user("daveloper").permission("admin"); @@ -87,7 +117,22 @@ public class DefaultPermissionClientTest { } @Test - public void should_remove_group_permission() { + public void should_remove_component_user_permission() { + httpServer.stubStatusCode(200); + + PermissionParameters params = PermissionParameters.create().user("daveloper").component("org.sample.Sample").permission("admin"); + client.removePermission(params); + + assertThat(httpServer.requestedPath()).isEqualTo("/api/permissions/remove"); + assertThat(httpServer.requestParams()).includes( + entry("user", "daveloper"), + entry("component", "org.sample.Sample"), + entry("permission", "admin") + ); + } + + @Test + public void should_remove_global_group_permission() { httpServer.stubStatusCode(200); PermissionParameters params = PermissionParameters.create().group("my_group").permission("admin"); @@ -99,4 +144,19 @@ public class DefaultPermissionClientTest { entry("permission", "admin") ); } + + @Test + public void should_remove_component_group_permission() { + httpServer.stubStatusCode(200); + + PermissionParameters params = PermissionParameters.create().group("my_group").component("org.sample.Sample").permission("admin"); + client.removePermission(params); + + assertThat(httpServer.requestedPath()).isEqualTo("/api/permissions/remove"); + assertThat(httpServer.requestParams()).includes( + entry("group", "my_group"), + entry("component", "org.sample.Sample"), + entry("permission", "admin") + ); + } } |