use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SetDefaultTemplateActionTest method fail_if_anonymous.
@Test
public void fail_if_anonymous() throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto template = insertTemplate(organization);
userSession.anonymous();
expectedException.expect(UnauthorizedException.class);
newRequest(template.getUuid(), PROJECT);
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SetDefaultTemplateActionTest method fail_if_not_admin.
@Test
public void fail_if_not_admin() throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto template = insertTemplate(organization);
userSession.logIn();
expectedException.expect(ForbiddenException.class);
newRequest(template.getUuid(), null);
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SetDefaultTemplateActionTest method update_project_default_template_by_template_name.
@Test
public void update_project_default_template_by_template_name() throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto viewDefaultTemplate = db.permissionTemplates().insertTemplate(organization);
db.organizations().setDefaultTemplates(db.permissionTemplates().insertTemplate(organization), viewDefaultTemplate);
PermissionTemplateDto template = insertTemplate(organization);
loginAsAdmin(organization);
newRequest().setParam(PARAM_ORGANIZATION, organization.getKey()).setParam(PARAM_TEMPLATE_NAME, template.getName().toUpperCase()).execute();
db.getSession().commit();
assertDefaultTemplates(organization, template.getUuid(), viewDefaultTemplate.getUuid());
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class SetDefaultTemplateActionTest method update_project_default_template.
@Test
public void update_project_default_template() throws Exception {
PermissionTemplateDto viewDefaultTemplate = db.permissionTemplates().insertTemplate(db.getDefaultOrganization());
db.organizations().setDefaultTemplates(db.permissionTemplates().insertTemplate(db.getDefaultOrganization()), viewDefaultTemplate);
PermissionTemplateDto template = insertTemplate(db.getDefaultOrganization());
loginAsAdmin(db.getDefaultOrganization());
newRequest(template.getUuid(), Qualifiers.PROJECT);
assertDefaultTemplates(db.getDefaultOrganization(), template.getUuid(), viewDefaultTemplate.getUuid());
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method search_with_text_query_return_anyone_group_even_when_no_permission_set.
@Test
public void search_with_text_query_return_anyone_group_even_when_no_permission_set() throws Exception {
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "group");
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), group.getId()));
commit();
loginAsAdmin(db.getDefaultOrganization());
InputStream output = newRequest().setMediaType(PROTOBUF).setParam(PARAM_TEMPLATE_ID, template.getUuid()).setParam(TEXT_QUERY, "nyo").execute().getInputStream();
WsGroupsResponse response = WsGroupsResponse.parseFrom(output);
assertThat(response.getGroupsList()).extracting("name").containsExactly("Anyone");
assertThat(response.getGroups(0).getPermissionsList()).isEmpty();
}
Aggregations