use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SetDefaultTemplateActionTest method update_view_default_template.
@Test
public void update_view_default_template() throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto projectDefaultTemplate = db.permissionTemplates().insertTemplate(organization);
db.organizations().setDefaultTemplates(projectDefaultTemplate, null);
PermissionTemplateDto template = insertTemplate(organization);
loginAsAdmin(organization);
newRequest(template.getUuid(), VIEW);
assertDefaultTemplates(organization, projectDefaultTemplate.getUuid(), template.getUuid());
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method search_with_text_query.
@Test
public void search_with_text_query() throws Exception {
OrganizationDto defaultOrg = db.getDefaultOrganization();
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group1 = db.users().insertGroup(defaultOrg, "group-1-name");
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), group1.getId()));
GroupDto group2 = db.users().insertGroup(defaultOrg, "group-2-name");
GroupDto group3 = db.users().insertGroup(defaultOrg, "group-3");
commit();
loginAsAdmin(db.getDefaultOrganization());
InputStream output = newRequest().setMediaType(PROTOBUF).setParam(PARAM_TEMPLATE_NAME, template.getName()).setParam(TEXT_QUERY, "-nam").execute().getInputStream();
WsGroupsResponse response = WsGroupsResponse.parseFrom(output);
assertThat(response.getGroupsList()).extracting("name").containsExactly("group-1-name", "group-2-name");
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method fail_if_insufficient_privileges.
@Test
public void fail_if_insufficient_privileges() throws Exception {
PermissionTemplateDto template1 = addTemplateToDefaultOrganization();
userSession.logIn();
expectedException.expect(ForbiddenException.class);
newRequest().setParam(PARAM_PERMISSION, USER).setParam(PARAM_TEMPLATE_ID, template1.getUuid()).execute();
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method fail_if_not_logged_in.
@Test
public void fail_if_not_logged_in() throws Exception {
PermissionTemplateDto template1 = addTemplateToDefaultOrganization();
userSession.anonymous();
expectedException.expect(UnauthorizedException.class);
newRequest().setParam(PARAM_PERMISSION, USER).setParam(PARAM_TEMPLATE_ID, template1.getUuid()).execute();
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class UpdateTemplateActionTest method fail_if_name_already_exists_in_another_template.
@Test
public void fail_if_name_already_exists_in_another_template() throws Exception {
loginAsAdmin(db.getDefaultOrganization());
PermissionTemplateDto anotherTemplate = addTemplateToDefaultOrganization();
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("A template with the name '" + anotherTemplate.getName() + "' already exists (case insensitive).");
call(this.template.getUuid(), anotherTemplate.getName(), null, null);
}
Aggregations