use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SearchTemplatesActionTest method insertTemplate.
private PermissionTemplateDto insertTemplate(PermissionTemplateDto template) {
PermissionTemplateDto insert = dbClient.permissionTemplateDao().insert(db.getSession(), template);
db.getSession().commit();
return insert;
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class BasePermissionWsTest method addTemplate.
protected PermissionTemplateDto addTemplate(OrganizationDto organizationDto) {
PermissionTemplateDto dto = newPermissionTemplateDto().setOrganizationUuid(organizationDto.getUuid());
db.getDbClient().permissionTemplateDao().insert(db.getSession(), dto);
db.commit();
return dto;
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SearchTemplatesActionTest method search_in_organization.
@Test
public void search_in_organization() throws Exception {
OrganizationDto org = db.organizations().insert();
PermissionTemplateDto projectDefaultTemplate = db.permissionTemplates().insertTemplate(org);
db.organizations().setDefaultTemplates(projectDefaultTemplate, null);
PermissionTemplateDto templateInOrg = insertProjectTemplate(org);
insertProjectTemplate(db.getDefaultOrganization());
db.commit();
userSession.addPermission(ADMINISTER, org);
WsPermissions.SearchTemplatesWsResponse result = WsPermissions.SearchTemplatesWsResponse.parseFrom(newRequest(underTestWithoutViews).setParam("organization", org.getKey()).setMediaType(MediaTypes.PROTOBUF).execute().getInputStream());
assertThat(result.getPermissionTemplatesCount()).isEqualTo(2);
assertThat(result.getPermissionTemplatesList()).extracting(WsPermissions.PermissionTemplate::getId).containsOnly(projectDefaultTemplate.getUuid(), templateInOrg.getUuid());
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SearchTemplatesActionTest method search_project_permissions.
@Test
public void search_project_permissions() {
OrganizationDto organization = db.getDefaultOrganization();
PermissionTemplateDto projectTemplate = insertProjectTemplate(organization);
PermissionTemplateDto viewsTemplate = insertViewsTemplate(organization);
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
UserDto user3 = db.users().insertUser();
GroupDto group1 = db.users().insertGroup(organization);
GroupDto group2 = db.users().insertGroup(organization);
GroupDto group3 = db.users().insertGroup(organization);
addUserToTemplate(projectTemplate.getId(), user1.getId(), UserRole.ISSUE_ADMIN);
addUserToTemplate(projectTemplate.getId(), user2.getId(), UserRole.ISSUE_ADMIN);
addUserToTemplate(projectTemplate.getId(), user3.getId(), UserRole.ISSUE_ADMIN);
addUserToTemplate(projectTemplate.getId(), user1.getId(), UserRole.CODEVIEWER);
addGroupToTemplate(projectTemplate.getId(), group1.getId(), UserRole.ADMIN);
addPermissionTemplateWithProjectCreator(projectTemplate.getId(), UserRole.ADMIN);
addUserToTemplate(viewsTemplate.getId(), user1.getId(), UserRole.USER);
addUserToTemplate(viewsTemplate.getId(), user2.getId(), UserRole.USER);
addGroupToTemplate(viewsTemplate.getId(), group1.getId(), UserRole.ISSUE_ADMIN);
addGroupToTemplate(viewsTemplate.getId(), group2.getId(), UserRole.ISSUE_ADMIN);
addGroupToTemplate(viewsTemplate.getId(), group3.getId(), UserRole.ISSUE_ADMIN);
db.organizations().setDefaultTemplates(projectTemplate, viewsTemplate);
String result = newRequest().execute().getInput();
assertJson(result).withStrictArrayOrder().isSimilarTo(getClass().getResource("search_templates-example.json"));
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SetDefaultTemplateActionTest method insertTemplate.
private PermissionTemplateDto insertTemplate(OrganizationDto organization) {
PermissionTemplateDto res = dbClient.permissionTemplateDao().insert(db.getSession(), PermissionTemplateTesting.newPermissionTemplateDto().setOrganizationUuid(organization.getUuid()).setUuid("permission-template-uuid"));
db.commit();
return res;
}
Aggregations