use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method fail_to_delete_by_uuid_if_template_is_default_template_for_project.
private void fail_to_delete_by_uuid_if_template_is_default_template_for_project(WsActionTester underTest) throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto projectTemplate = insertTemplateAndAssociatedPermissions(organization);
db.organizations().setDefaultTemplates(projectTemplate, db.permissionTemplates().insertTemplate(organization));
loginAsAdmin(organization);
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("It is not possible to delete the default permission template for projects");
newRequestByUuid(underTest, projectTemplate.getUuid());
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method fail_to_delete_by_name_if_not_admin_with_views.
@Test
public void fail_to_delete_by_name_if_not_admin_with_views() throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto template = db.permissionTemplates().insertTemplate(PermissionTemplateTesting.newPermissionTemplateDto().setOrganizationUuid(organization.getUuid()).setName("the name"));
userSession.logIn();
expectedException.expect(ForbiddenException.class);
newRequestByName(underTestWithViews, organization, template);
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method delete_template_by_name_returns_empty_when_wrong_organization_is_provided.
@Test
public void delete_template_by_name_returns_empty_when_wrong_organization_is_provided() throws Exception {
OrganizationDto organization = db.organizations().insert();
db.organizations().setDefaultTemplates(db.permissionTemplates().insertTemplate(organization), db.permissionTemplates().insertTemplate(organization));
PermissionTemplateDto template = insertTemplateAndAssociatedPermissions(organization);
OrganizationDto otherOrganization = db.organizations().insert();
loginAsAdmin(organization);
runOnAllUnderTests((underTest) -> {
try {
newRequestByName(underTest, otherOrganization, template);
fail("NotFoundException should have been raised");
} catch (NotFoundException e) {
assertThat(e).hasMessage("Permission template with name '" + template.getName() + "' is not found (case insensitive) in organization with key '" + otherOrganization.getKey() + "'");
}
});
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method fail_to_delete_by_uuid_if_not_admin_with_views.
@Test
public void fail_to_delete_by_uuid_if_not_admin_with_views() throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto template = insertTemplateAndAssociatedPermissions(organization);
userSession.logIn();
expectedException.expect(ForbiddenException.class);
newRequestByUuid(underTestWithViews, template.getUuid());
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method fail_to_delete_by_uuid_if_not_admin_without_views.
@Test
public void fail_to_delete_by_uuid_if_not_admin_without_views() throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto template = insertTemplateAndAssociatedPermissions(organization);
userSession.logIn();
expectedException.expect(ForbiddenException.class);
newRequestByUuid(underTestWithoutViews, template.getUuid());
}
Aggregations