use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method delete_template_by_name_case_insensitive.
@Test
public void delete_template_by_name_case_insensitive() throws Exception {
runOnAllUnderTests((underTest) -> {
OrganizationDto organization = db.organizations().insert();
db.organizations().setDefaultTemplates(db.permissionTemplates().insertTemplate(organization), db.permissionTemplates().insertTemplate(organization));
PermissionTemplateDto template = insertTemplateAndAssociatedPermissions(organization);
loginAsAdmin(organization);
newRequestByName(underTest, organization, template);
assertTemplateDoesNotExist(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_no_organization_is_provided_and_templates_does_not_belong_to_default_organization.
@Test
public void delete_template_by_name_returns_empty_when_no_organization_is_provided_and_templates_does_not_belong_to_default_organization() throws Exception {
OrganizationDto organization = db.organizations().insert();
db.organizations().setDefaultTemplates(db.permissionTemplates().insertTemplate(organization), db.permissionTemplates().insertTemplate(organization));
PermissionTemplateDto template = insertTemplateAndAssociatedPermissions(organization);
loginAsAdmin(organization);
runOnAllUnderTests((underTest) -> {
try {
newRequestByName(underTest, null, 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 '" + db.getDefaultOrganization().getKey() + "'");
}
});
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method fail_to_delete_by_name_if_template_is_default_template_for_project.
private void fail_to_delete_by_name_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");
newRequestByName(underTest, organization.getKey(), projectTemplate.getName());
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method default_template_for_views_can_be_deleted_by_uuid_if_views_is_not_installed_and_default_template_for_views_is_reset.
@Test
public void default_template_for_views_can_be_deleted_by_uuid_if_views_is_not_installed_and_default_template_for_views_is_reset() throws Exception {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto projectTemplate = db.permissionTemplates().insertTemplate(organization);
PermissionTemplateDto viewTemplate = insertTemplateAndAssociatedPermissions(organization);
db.organizations().setDefaultTemplates(projectTemplate, viewTemplate);
loginAsAdmin(organization);
newRequestByUuid(this.underTestWithoutViews, viewTemplate.getUuid());
assertTemplateDoesNotExist(viewTemplate);
assertThat(db.getDbClient().organizationDao().getDefaultTemplates(db.getSession(), organization.getUuid()).get().getViewUuid()).isNull();
}
use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.
the class DeleteTemplateActionTest method delete_template_in_db.
@Test
public void delete_template_in_db() throws Exception {
runOnAllUnderTests((underTest) -> {
OrganizationDto organization = db.organizations().insert();
PermissionTemplateDto template = insertTemplateAndAssociatedPermissions(organization);
db.organizations().setDefaultTemplates(db.permissionTemplates().insertTemplate(organization), db.permissionTemplates().insertTemplate(organization));
loginAsAdmin(organization);
TestResponse result = newRequestByUuid(underTest, template.getUuid());
assertThat(result.getInput()).isEmpty();
assertTemplateDoesNotExist(template);
});
}
Aggregations