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;
.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"));
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()
.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) {
.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())
.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();
+ }
}