Search in sources :

Example 96 with PermissionTemplateDto

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

the class RegisterPermissionTemplatesTest method ignore_administrators_permissions_if_group_does_not_exist.

@Test
public void ignore_administrators_permissions_if_group_does_not_exist() {
    underTest.start();
    PermissionTemplateDto defaultTemplate = selectTemplate();
    assertThat(defaultTemplate.getName()).isEqualTo("Default template");
    List<PermissionTemplateGroupDto> groupPermissions = selectGroupPermissions(defaultTemplate);
    assertThat(groupPermissions).hasSize(2);
    expectGroupPermission(groupPermissions, UserRole.CODEVIEWER, DefaultGroups.ANYONE);
    expectGroupPermission(groupPermissions, UserRole.USER, DefaultGroups.ANYONE);
    verifyDefaultTemplates();
    assertThat(logTester.logs(LoggerLevel.ERROR)).contains("Cannot setup default permission for group: sonar-administrators");
}
Also used : PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) PermissionTemplateTesting.newPermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateDto) PermissionTemplateGroupDto(org.sonar.db.permission.template.PermissionTemplateGroupDto) Test(org.junit.Test)

Example 97 with PermissionTemplateDto

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

the class DeleteActionTest method delete_group_from_permission_templates.

@Test
public void delete_group_from_permission_templates() throws Exception {
    addAdminToDefaultOrganization();
    GroupDto group = db.users().insertGroup();
    PermissionTemplateDto template = db.getDbClient().permissionTemplateDao().insert(db.getSession(), PermissionTemplateTesting.newPermissionTemplateDto());
    db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), template.getId(), group.getId(), "perm");
    db.commit();
    loginAsAdminOnDefaultOrganization();
    assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(1);
    newRequest().setParam("id", group.getId().toString()).execute().assertNoContent();
    assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(0);
}
Also used : PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) GroupDto(org.sonar.db.user.GroupDto) 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