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);
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method do_not_fail_when_group_name_exists_in_multiple_organizations.
@Test
public void do_not_fail_when_group_name_exists_in_multiple_organizations() {
PermissionTemplateDto template = addTemplateToDefaultOrganization();
String groupName = "group-name";
GroupDto group1 = db.users().insertGroup(db.getDefaultOrganization(), groupName);
addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getId(), group1.getId()));
addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getId(), group1.getId()));
OrganizationDto otherOrganization = db.organizations().insert();
db.users().insertGroup(otherOrganization, groupName);
loginAsAdmin(db.getDefaultOrganization());
newRequest().setMediaType(PROTOBUF).setParam(PARAM_TEMPLATE_ID, template.getUuid()).setParam(TEXT_QUERY, "-nam").execute().getInputStream();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class PermissionTemplateDaoTest method add_group_permission_to_template.
@Test
public void add_group_permission_to_template() {
PermissionTemplateDto permissionTemplate = templateDb.insertTemplate();
GroupDto group = db.users().insertGroup();
underTest.insertGroupPermission(dbSession, permissionTemplate.getUuid(), group.getUuid(), "user", permissionTemplate.getName(), group.getName());
dbSession.commit();
assertThat(db.getDbClient().permissionTemplateDao().selectGroupPermissionsByTemplateUuid(db.getSession(), permissionTemplate.getUuid())).extracting(PermissionTemplateGroupDto::getTemplateUuid, PermissionTemplateGroupDto::getGroupUuid, PermissionTemplateGroupDto::getPermission, PermissionTemplateGroupDto::getCreatedAt, PermissionTemplateGroupDto::getUpdatedAt).containsOnly(tuple(permissionTemplate.getUuid(), group.getUuid(), "user", NOW, NOW));
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class PermissionTemplateDaoTest method group_count_by_template_and_permission.
@Test
public void group_count_by_template_and_permission() {
PermissionTemplateDto template1 = templateDb.insertTemplate();
PermissionTemplateDto template2 = templateDb.insertTemplate();
PermissionTemplateDto template3 = templateDb.insertTemplate();
PermissionTemplateDto template4 = templateDb.insertTemplate();
GroupDto group1 = db.users().insertGroup(newGroupDto());
GroupDto group2 = db.users().insertGroup(newGroupDto());
GroupDto group3 = db.users().insertGroup(newGroupDto());
templateDb.addGroupToTemplate(template1.getUuid(), group1.getUuid(), CODEVIEWER, template1.getName(), group1.getName());
templateDb.addGroupToTemplate(template1.getUuid(), group2.getUuid(), CODEVIEWER, template1.getName(), group2.getName());
templateDb.addGroupToTemplate(template1.getUuid(), group3.getUuid(), CODEVIEWER, template1.getName(), group3.getName());
templateDb.addGroupToTemplate(template1.getUuid(), null, CODEVIEWER, template1.getName(), null);
templateDb.addGroupToTemplate(template1.getUuid(), group1.getUuid(), ADMIN, template1.getName(), group1.getName());
templateDb.addGroupToTemplate(template2.getUuid(), group1.getUuid(), ADMIN, template2.getName(), group1.getName());
templateDb.addGroupToTemplate(template4.getUuid(), group1.getUuid(), ISSUE_ADMIN, template4.getName(), group1.getName());
final List<CountByTemplateAndPermissionDto> result = new ArrayList<>();
underTest.groupsCountByTemplateUuidAndPermission(dbSession, asList(template1.getUuid(), template2.getUuid(), template3.getUuid()), context -> result.add(context.getResultObject()));
assertThat(result).extracting(CountByTemplateAndPermissionDto::getPermission, CountByTemplateAndPermissionDto::getTemplateUuid, CountByTemplateAndPermissionDto::getCount).containsOnly(tuple(ADMIN, template1.getUuid(), 1), tuple(CODEVIEWER, template1.getUuid(), 4), tuple(ADMIN, template2.getUuid(), 1));
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class PermissionTemplateDaoTest method remove_by_group.
@Test
public void remove_by_group() {
PermissionTemplateDto permissionTemplate = templateDb.insertTemplate();
GroupDto group1 = db.users().insertGroup();
GroupDto group2 = db.users().insertGroup();
templateDb.addGroupToTemplate(permissionTemplate, group1, "user");
templateDb.addGroupToTemplate(permissionTemplate, group1, "admin");
templateDb.addGroupToTemplate(permissionTemplate, group2, "user");
underTest.deleteByGroup(db.getSession(), group1.getUuid(), group1.getName());
db.getSession().commit();
assertThat(db.getDbClient().permissionTemplateDao().selectGroupPermissionsByTemplateUuid(db.getSession(), permissionTemplate.getUuid())).extracting(PermissionTemplateGroupDto::getGroupUuid, PermissionTemplateGroupDto::getPermission).containsOnly(tuple(group2.getUuid(), "user"));
}
Aggregations