use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class UserPermissionDaoTest method selectProjectPermissionsOfUser.
@Test
public void selectProjectPermissionsOfUser() {
OrganizationDto org = dbTester.organizations().insert();
ComponentDto project3 = dbTester.components().insertProject(org);
addGlobalPermission(organizationDto, "perm1", user1);
addProjectPermission(organizationDto, "perm2", user1, project1);
addProjectPermission(organizationDto, "perm3", user1, project1);
addProjectPermission(organizationDto, "perm4", user1, project2);
addProjectPermission(organizationDto, "perm5", user2, project1);
assertThat(underTest.selectProjectPermissionsOfUser(dbSession, user1.getId(), project1.getId())).containsOnly("perm2", "perm3");
assertThat(underTest.selectProjectPermissionsOfUser(dbSession, user1.getId(), project2.getId())).containsOnly("perm4");
assertThat(underTest.selectProjectPermissionsOfUser(dbSession, user1.getId(), project3.getId())).isEmpty();
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class UserPermissionDaoTest method deleteByOrganization_does_not_fail_if_organization_has_no_user_permission.
@Test
public void deleteByOrganization_does_not_fail_if_organization_has_no_user_permission() {
OrganizationDto organization = dbTester.organizations().insert();
underTest.deleteByOrganization(dbSession, organization.getUuid());
dbSession.commit();
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class GroupWithPermissionTemplateDaoTest method select_group_names_by_query_and_template_is_paginated.
@Test
public void select_group_names_by_query_and_template_is_paginated() {
OrganizationDto organization = db.organizations().insert();
IntStream.rangeClosed(0, 9).forEach(i -> db.users().insertGroup(organization, i + "-name"));
PermissionTemplateDto template = permissionTemplateDbTester.insertTemplate(organization);
assertThat(selectGroupNamesByQueryAndTemplate(builder().setPageIndex(1).setPageSize(1), organization, template)).containsExactly("0-name");
assertThat(selectGroupNamesByQueryAndTemplate(builder().setPageIndex(2).setPageSize(3), organization, template)).containsExactly("3-name", "4-name", "5-name");
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class GroupWithPermissionTemplateDaoTest method select_group_names_by_query_and_template.
@Test
public void select_group_names_by_query_and_template() {
OrganizationDto organization = db.organizations().insert();
GroupDto group1 = db.users().insertGroup(organization, "Group-1");
GroupDto group2 = db.users().insertGroup(organization, "Group-2");
GroupDto group3 = db.users().insertGroup(organization, "Group-3");
PermissionTemplateDto template = permissionTemplateDbTester.insertTemplate(organization);
permissionTemplateDbTester.addGroupToTemplate(template.getId(), group1.getId(), USER);
permissionTemplateDbTester.addGroupToTemplate(template.getId(), group1.getId(), ADMIN);
permissionTemplateDbTester.addGroupToTemplate(template.getId(), group2.getId(), PROVISIONING);
PermissionTemplateDto anotherTemplate = permissionTemplateDbTester.insertTemplate(organization);
permissionTemplateDbTester.addGroupToTemplate(anotherTemplate.getId(), null, USER);
permissionTemplateDbTester.addGroupToTemplate(anotherTemplate.getId(), group1.getId(), PROVISIONING);
assertThat(selectGroupNamesByQueryAndTemplate(builder(), organization, template)).containsOnly("Group-1", "Group-2", "Group-3", "Anyone");
assertThat(selectGroupNamesByQueryAndTemplate(builder().withAtLeastOnePermission(), organization, template)).containsOnly("Group-1", "Group-2");
assertThat(selectGroupNamesByQueryAndTemplate(builder().setPermission(USER), organization, template)).containsOnly("Group-1");
assertThat(selectGroupNamesByQueryAndTemplate(builder().setPermission(USER), organization, anotherTemplate)).containsOnly("Anyone");
assertThat(selectGroupNamesByQueryAndTemplate(builder().setSearchQuery("groU"), organization, template)).containsOnly("Group-1", "Group-2", "Group-3");
assertThat(selectGroupNamesByQueryAndTemplate(builder().setSearchQuery("nYo"), organization, template)).containsOnly("Anyone");
assertThat(selectGroupNamesByQueryAndTemplate(builder().setSearchQuery("p-2"), organization, template)).containsOnly("Group-2");
assertThat(selectGroupNamesByQueryAndTemplate(builder().withAtLeastOnePermission().build(), organization, 123L)).isEmpty();
assertThat(selectGroupNamesByQueryAndTemplate(builder().setSearchQuery("unknown"), organization, template)).isEmpty();
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class IssueDaoTest method prepareTables.
private void prepareTables() {
dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RULE);
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto projectDto = dbTester.components().insertProject(organizationDto, (t) -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
dbTester.components().insertComponent(ComponentTesting.newFileDto(projectDto).setUuid(FILE_UUID).setKey(FILE_KEY));
underTest.insert(dbTester.getSession(), newIssueDto(ISSUE_KEY1).setMessage("the message").setRuleId(RULE.getId()).setComponentUuid(FILE_UUID).setProjectUuid(PROJECT_UUID));
underTest.insert(dbTester.getSession(), newIssueDto(ISSUE_KEY2).setRuleId(RULE.getId()).setComponentUuid(FILE_UUID).setProjectUuid(PROJECT_UUID));
dbTester.getSession().commit();
}
Aggregations