Search in sources :

Example 81 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class AddGroupActionTest method reference_group_by_its_name_in_organization.

@Test
public void reference_group_by_its_name_in_organization() throws Exception {
    OrganizationDto org = db.organizations().insert();
    GroupDto group = db.users().insertGroup(org, "the-group");
    loginAsAdmin(org);
    newRequest().setParam(PARAM_ORGANIZATION, org.getKey()).setParam(PARAM_GROUP_NAME, group.getName()).setParam(PARAM_PERMISSION, PROVISIONING).execute();
    assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(PROVISIONING);
}
Also used : GroupDto(org.sonar.db.user.GroupDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 82 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class GroupsActionTest method return_only_groups_with_permission_when_no_search_query.

@Test
public void return_only_groups_with_permission_when_no_search_query() throws Exception {
    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
    GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "project-group-name");
    db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
    GroupDto groupWithoutPermission = db.users().insertGroup(db.getDefaultOrganization(), "group-without-permission");
    loginAsAdmin(db.getDefaultOrganization());
    String result = newRequest().setParam(PARAM_PERMISSION, ISSUE_ADMIN).setParam(PARAM_PROJECT_ID, project.uuid()).execute().getInput();
    assertThat(result).contains(group.getName()).doesNotContain(groupWithoutPermission.getName());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GroupDto(org.sonar.db.user.GroupDto) Test(org.junit.Test)

Example 83 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class GroupsActionTest method return_anyone_group_when_search_query_and_no_param_permission.

@Test
public void return_anyone_group_when_search_query_and_no_param_permission() throws Exception {
    OrganizationDto organizationDto = db.organizations().insert();
    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "project-uuid"));
    GroupDto group = db.users().insertGroup(organizationDto, "group-with-permission");
    db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
    loginAsAdmin(db.getDefaultOrganization());
    String result = newRequest().setParam(PARAM_PROJECT_ID, project.uuid()).setParam(TEXT_QUERY, "nyo").execute().getInput();
    assertThat(result).contains("Anyone");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GroupDto(org.sonar.db.user.GroupDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 84 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class GroupsActionTest method search_groups_on_views.

@Test
public void search_groups_on_views() throws Exception {
    ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "view-uuid").setKey("view-key"));
    GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "project-group-name");
    db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, view);
    loginAsAdmin(db.getDefaultOrganization());
    String result = newRequest().setParam(PARAM_PERMISSION, ISSUE_ADMIN).setParam(PARAM_PROJECT_ID, "view-uuid").execute().getInput();
    assertThat(result).contains("project-group-name").doesNotContain("group-1").doesNotContain("group-2").doesNotContain("group-3");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GroupDto(org.sonar.db.user.GroupDto) Test(org.junit.Test)

Example 85 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class GroupsActionTest method search_groups_with_project_permissions.

@Test
public void search_groups_with_project_permissions() throws Exception {
    OrganizationDto organizationDto = db.getDefaultOrganization();
    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "project-uuid"));
    GroupDto group = db.users().insertGroup(organizationDto, "project-group-name");
    db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
    ComponentDto anotherProject = db.components().insertComponent(newProjectDto(organizationDto));
    GroupDto anotherGroup = db.users().insertGroup(organizationDto, "another-project-group-name");
    db.users().insertProjectPermissionOnGroup(anotherGroup, ISSUE_ADMIN, anotherProject);
    GroupDto groupWithoutPermission = db.users().insertGroup(organizationDto, "group-without-permission");
    userSession.logIn().addProjectUuidPermissions(ADMIN, "project-uuid");
    String result = newRequest().setParam(PARAM_PERMISSION, ISSUE_ADMIN).setParam(PARAM_PROJECT_ID, "project-uuid").execute().getInput();
    assertThat(result).contains(group.getName()).doesNotContain(anotherGroup.getName()).doesNotContain(groupWithoutPermission.getName());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) GroupDto(org.sonar.db.user.GroupDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Aggregations

GroupDto (org.sonar.db.user.GroupDto)177 Test (org.junit.Test)158 OrganizationDto (org.sonar.db.organization.OrganizationDto)74 UserDto (org.sonar.db.user.UserDto)67 ComponentDto (org.sonar.db.component.ComponentDto)38 GroupTesting.newGroupDto (org.sonar.db.user.GroupTesting.newGroupDto)31 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)18 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)17 PermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateGroupDto)14 UserGroupDto (org.sonar.db.user.UserGroupDto)12 DbSession (org.sonar.db.DbSession)11 BasePermissionWsTest (org.sonar.server.permission.ws.BasePermissionWsTest)9 PermissionTemplateTesting.newPermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateGroupDto)8 WsGroupsResponse (org.sonarqube.ws.WsPermissions.WsGroupsResponse)7 InputStream (java.io.InputStream)6 ArrayList (java.util.ArrayList)3 System2 (org.sonar.api.utils.System2)3 DbClient (org.sonar.db.DbClient)3 PermissionTemplateTesting.newPermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateDto)3 Strings (com.google.common.base.Strings)2