Search in sources :

Example 31 with PermissionTemplateDto

use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.

the class TemplateUsersActionTest method fail_if_not_logged_in.

@Test
public void fail_if_not_logged_in() throws Exception {
    PermissionTemplateDto template = addTemplateToDefaultOrganization();
    userSession.anonymous();
    expectedException.expect(UnauthorizedException.class);
    newRequest(null, template.getUuid()).execute();
}
Also used : PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) BasePermissionWsTest(org.sonar.server.permission.ws.BasePermissionWsTest) Test(org.junit.Test)

Example 32 with PermissionTemplateDto

use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.

the class TemplateUsersActionTest method fail_if_insufficient_privileges.

@Test
public void fail_if_insufficient_privileges() throws Exception {
    PermissionTemplateDto template = addTemplateToDefaultOrganization();
    userSession.logIn().addPermission(SCAN, db.getDefaultOrganization());
    expectedException.expect(ForbiddenException.class);
    newRequest(null, template.getUuid()).execute();
}
Also used : PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) BasePermissionWsTest(org.sonar.server.permission.ws.BasePermissionWsTest) Test(org.junit.Test)

Example 33 with PermissionTemplateDto

use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.

the class SetDefaultTemplateActionTest method fail_if_qualifier_is_not_root.

@Test
public void fail_if_qualifier_is_not_root() throws Exception {
    OrganizationDto organization = db.organizations().insert();
    PermissionTemplateDto template = insertTemplate(organization);
    loginAsAdmin(organization);
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Value of parameter 'qualifier' (FIL) must be one of: [TRK, VW]");
    newRequest(template.getUuid(), Qualifiers.FILE);
}
Also used : PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) BasePermissionWsTest(org.sonar.server.permission.ws.BasePermissionWsTest) Test(org.junit.Test)

Example 34 with PermissionTemplateDto

use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.

the class SetDefaultTemplateActionTest method fail_if_organization_has_no_default_templates.

@Test
public void fail_if_organization_has_no_default_templates() throws Exception {
    OrganizationDto organization = db.organizations().insert();
    PermissionTemplateDto template = insertTemplate(organization);
    loginAsAdmin(organization);
    expectedException.expect(NotFoundException.class);
    expectedException.expectMessage("No Default templates for organization with uuid '" + organization.getUuid() + "'");
    newRequest(template.getUuid(), null);
}
Also used : PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) BasePermissionWsTest(org.sonar.server.permission.ws.BasePermissionWsTest) Test(org.junit.Test)

Example 35 with PermissionTemplateDto

use of org.sonar.db.permission.template.PermissionTemplateDto in project sonarqube by SonarSource.

the class SetDefaultTemplateActionTest method update_project_default_template_without_qualifier_param.

@Test
public void update_project_default_template_without_qualifier_param() throws Exception {
    OrganizationDto organization = db.organizations().insert();
    db.organizations().setDefaultTemplates(organization, "any-project-template-uuid", "any-view-template-uuid");
    PermissionTemplateDto template = insertTemplate(organization);
    loginAsAdmin(organization);
    // default value is project qualifier's value
    newRequest(template.getUuid(), null);
    assertDefaultTemplates(organization, template.getUuid(), "any-view-template-uuid");
}
Also used : PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) BasePermissionWsTest(org.sonar.server.permission.ws.BasePermissionWsTest) Test(org.junit.Test)

Aggregations

PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)97 Test (org.junit.Test)63 BasePermissionWsTest (org.sonar.server.permission.ws.BasePermissionWsTest)42 OrganizationDto (org.sonar.db.organization.OrganizationDto)33 GroupDto (org.sonar.db.user.GroupDto)17 DbSession (org.sonar.db.DbSession)16 UserDto (org.sonar.db.user.UserDto)15 PermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateGroupDto)14 InputStream (java.io.InputStream)13 PermissionTemplateTesting.newPermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateDto)12 DefaultTemplates (org.sonar.db.organization.DefaultTemplates)10 PermissionTemplateUserDto (org.sonar.db.permission.template.PermissionTemplateUserDto)9 WsPermissions (org.sonarqube.ws.WsPermissions)9 PermissionTemplateTesting.newPermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateGroupDto)8 GroupTesting.newGroupDto (org.sonar.db.user.GroupTesting.newGroupDto)8 PermissionTemplateTesting.newPermissionTemplateUserDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateUserDto)7 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)7 WsGroupsResponse (org.sonarqube.ws.WsPermissions.WsGroupsResponse)7 ComponentDto (org.sonar.db.component.ComponentDto)6 Date (java.util.Date)5