From: Teryk Bellahsene Date: Thu, 16 Jun 2016 13:25:52 +0000 (+0200) Subject: SONAR-7747 IT to add and remove a project template creator X-Git-Tag: 6.0-RC1~288 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4ab4957309615cd9fbc11f172261b09d5a85ac32;p=sonarqube.git SONAR-7747 IT to add and remove a project template creator --- diff --git a/it/it-tests/src/test/java/it/authorisation/PermissionSearchTest.java b/it/it-tests/src/test/java/it/authorisation/PermissionSearchTest.java index 06728cb237b..0d7508a3ee1 100644 --- a/it/it-tests/src/test/java/it/authorisation/PermissionSearchTest.java +++ b/it/it-tests/src/test/java/it/authorisation/PermissionSearchTest.java @@ -35,12 +35,14 @@ import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.permission.AddGroupToTemplateWsRequest; import org.sonarqube.ws.client.permission.AddGroupWsRequest; +import org.sonarqube.ws.client.permission.AddProjectCreatorToTemplateWsRequest; import org.sonarqube.ws.client.permission.AddUserToTemplateWsRequest; import org.sonarqube.ws.client.permission.AddUserWsRequest; import org.sonarqube.ws.client.permission.CreateTemplateWsRequest; import org.sonarqube.ws.client.permission.GroupsWsRequest; import org.sonarqube.ws.client.permission.PermissionsService; import org.sonarqube.ws.client.permission.RemoveGroupFromTemplateWsRequest; +import org.sonarqube.ws.client.permission.RemoveProjectCreatorFromTemplateWsRequest; import org.sonarqube.ws.client.permission.RemoveUserFromTemplateWsRequest; import org.sonarqube.ws.client.permission.SearchTemplatesWsRequest; import org.sonarqube.ws.client.permission.UsersWsRequest; @@ -134,6 +136,12 @@ public class PermissionSearchTest { .setTemplateName("my-new-template") .setGroupName(GROUP_NAME)); + permissionsWsClient.addProjectCreatorToTemplate( + AddProjectCreatorToTemplateWsRequest.builder() + .setPermission("admin") + .setTemplateName("my-new-template") + .build()); + SearchTemplatesWsResponse searchTemplatesWsResponse = permissionsWsClient.searchTemplates( new SearchTemplatesWsRequest() .setQuery("my-new-template")); @@ -141,6 +149,7 @@ public class PermissionSearchTest { assertThat(searchTemplatesWsResponse.getPermissionTemplates(0).getPermissions(0).getKey()).isEqualTo("admin"); assertThat(searchTemplatesWsResponse.getPermissionTemplates(0).getPermissions(0).getUsersCount()).isEqualTo(1); assertThat(searchTemplatesWsResponse.getPermissionTemplates(0).getPermissions(0).getGroupsCount()).isEqualTo(1); + assertThat(searchTemplatesWsResponse.getPermissionTemplates(0).getPermissions(0).getWithProjectCreator()).isTrue(); permissionsWsClient.removeGroupFromTemplate( new RemoveGroupFromTemplateWsRequest() @@ -154,13 +163,20 @@ public class PermissionSearchTest { .setTemplateName("my-new-template") .setLogin(LOGIN)); + permissionsWsClient.removeProjectCreatorFromTemplate( + RemoveProjectCreatorFromTemplateWsRequest.builder() + .setPermission("admin") + .setTemplateName("my-new-template") + .build() + ); + SearchTemplatesWsResponse clearedSearchTemplatesWsResponse = permissionsWsClient.searchTemplates( new SearchTemplatesWsRequest() .setQuery("my-new-template")); assertThat(clearedSearchTemplatesWsResponse.getPermissionTemplates(0).getPermissionsList()) - .extracting(Permission::getUsersCount, Permission::getGroupsCount) + .extracting(Permission::getUsersCount, Permission::getGroupsCount, Permission::getWithProjectCreator) .hasSize(5) - .containsOnly(tuple(0, 0)); + .containsOnly(tuple(0, 0, false)); } private static void createUser(String login, String name) { diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java index 694f100d1f1..b39aca3bfc8 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsService.java @@ -152,6 +152,14 @@ public class PermissionsService extends BaseService { .setParam(PARAM_TEMPLATE_NAME, request.getTemplateName())); } + public void removeProjectCreatorFromTemplate(RemoveProjectCreatorFromTemplateWsRequest request) { + call( + new PostRequest(path("remove_project_creator_from_template")) + .setParam(PARAM_PERMISSION, request.getPermission()) + .setParam(PARAM_TEMPLATE_ID, request.getTemplateId()) + .setParam(PARAM_TEMPLATE_NAME, request.getTemplateName())); + } + public void removeUser(RemoveUserWsRequest request) { call(new PostRequest(path("remove_user")) .setParam(PARAM_PERMISSION, request.getPermission()) diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java index e18ff730830..f82ae59934b 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/permission/PermissionsServiceTest.java @@ -472,4 +472,22 @@ public class PermissionsServiceTest { .hasParam(PARAM_TEMPLATE_NAME, TEMPLATE_NAME_VALUE) .andNoOtherParam(); } + + @Test + public void remove_project_creator_from_template() { + underTest.removeProjectCreatorFromTemplate(RemoveProjectCreatorFromTemplateWsRequest.builder() + .setPermission(PERMISSION_VALUE) + .setTemplateId(TEMPLATE_ID_VALUE) + .setTemplateName(TEMPLATE_NAME_VALUE) + .build()); + + assertThat(serviceTester.getPostParser()).isNull(); + PostRequest getRequest = serviceTester.getPostRequest(); + serviceTester.assertThat(getRequest) + .hasPath("remove_project_creator_from_template") + .hasParam(PARAM_PERMISSION, PERMISSION_VALUE) + .hasParam(PARAM_TEMPLATE_ID, TEMPLATE_ID_VALUE) + .hasParam(PARAM_TEMPLATE_NAME, TEMPLATE_NAME_VALUE) + .andNoOtherParam(); + } }