use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class DeleteActionTest method delete_group_of_an_organization_even_if_name_is_default_group_of_default_organization.
@Test
public void delete_group_of_an_organization_even_if_name_is_default_group_of_default_organization() throws Exception {
OrganizationDto org = db.organizations().insert();
addAdmin(org);
GroupDto group = db.users().insertGroup(org, defaultGroup.getName());
loginAsAdmin(org);
newRequest().setParam("id", group.getId().toString()).execute();
assertThat(db.users().selectGroupById(defaultGroup.getId())).isNotNull();
assertThat(db.users().selectGroupById(group.getId())).isNull();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class UpdateActionTest method fails_if_admin_of_another_organization_only.
@Test
public void fails_if_admin_of_another_organization_only() throws Exception {
OrganizationDto org1 = db.organizations().insert();
OrganizationDto org2 = db.organizations().insert();
GroupDto group = db.users().insertGroup(org1, "group1");
loginAsAdmin(org2);
expectedException.expect(ForbiddenException.class);
newRequest().setParam("id", group.getId().toString()).setParam("name", "some-product-bu").setParam("description", "Business Unit for Some Awesome Product").execute();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class OrganizationDaoTest method selectByPermission_returns_organization_only_if_user_has_specific_permission_by_group_permission.
@Test
public void selectByPermission_returns_organization_only_if_user_has_specific_permission_by_group_permission() {
OrganizationDto organization = dbTester.organizations().insert();
OrganizationDto otherOrganization = dbTester.organizations().insert();
GroupDto group1 = dbTester.users().insertGroup(organization);
GroupDto group2 = dbTester.users().insertGroup(organization);
GroupDto otherGroup1 = dbTester.users().insertGroup(otherOrganization);
GroupDto otherGroup2 = dbTester.users().insertGroup(otherOrganization);
dbTester.users().insertPermissionOnGroup(group1, PERMISSION_1);
dbTester.users().insertPermissionOnGroup(otherGroup2, PERMISSION_2);
dbTester.users().insertPermissionOnGroup(group2, PERMISSION_2);
dbTester.users().insertPermissionOnGroup(otherGroup1, PERMISSION_1);
UserDto user = dbTester.users().insertUser();
dbTester.users().insertMember(group1, user);
dbTester.users().insertMember(otherGroup2, user);
UserDto otherUser = dbTester.users().insertUser();
dbTester.users().insertMember(group2, otherUser);
dbTester.users().insertMember(otherGroup1, otherUser);
assertThat(underTest.selectByPermission(dbSession, user.getId(), PERMISSION_1)).extracting(OrganizationDto::getUuid).containsOnlyOnce(organization.getUuid());
assertThat(underTest.selectByPermission(dbSession, user.getId(), PERMISSION_2)).extracting(OrganizationDto::getUuid).containsOnlyOnce(otherOrganization.getUuid());
assertThat(underTest.selectByPermission(dbSession, otherUser.getId(), PERMISSION_1)).extracting(OrganizationDto::getUuid).containsOnlyOnce(otherOrganization.getUuid());
assertThat(underTest.selectByPermission(dbSession, otherUser.getId(), PERMISSION_2)).extracting(OrganizationDto::getUuid).containsOnlyOnce(organization.getUuid());
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class OrganizationDaoTest method selectByPermission_returns_organization_when_user_has_ADMIN_group_permission_on_some_organization.
@Test
public void selectByPermission_returns_organization_when_user_has_ADMIN_group_permission_on_some_organization() {
UserDto user = dbTester.users().insertUser();
OrganizationDto organization1 = dbTester.organizations().insert();
GroupDto defaultGroup = dbTester.users().insertGroup(organization1);
dbTester.users().insertPermissionOnGroup(defaultGroup, PERMISSION_1);
dbTester.users().insertMember(defaultGroup, user);
OrganizationDto organization2 = dbTester.organizations().insert();
GroupDto group1 = dbTester.users().insertGroup(organization2);
dbTester.users().insertPermissionOnGroup(group1, PERMISSION_1);
dbTester.users().insertMember(group1, user);
UserDto otherUser = dbTester.users().insertUser();
OrganizationDto organization3 = dbTester.organizations().insert();
GroupDto group2 = dbTester.users().insertGroup(organization3);
dbTester.users().insertPermissionOnGroup(group2, PERMISSION_1);
dbTester.users().insertMember(group2, otherUser);
assertThat(underTest.selectByPermission(dbSession, user.getId(), PERMISSION_1)).extracting(OrganizationDto::getUuid).containsOnly(organization1.getUuid(), organization2.getUuid());
assertThat(underTest.selectByPermission(dbSession, otherUser.getId(), PERMISSION_1)).extracting(OrganizationDto::getUuid).containsOnly(organization3.getUuid());
assertThat(underTest.selectByPermission(dbSession, 1234, PERMISSION_1)).isEmpty();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class GroupPermissionDaoTest method insertGroupWithPermissions.
private int insertGroupWithPermissions(OrganizationDto organization1) {
GroupDto group = db.users().insertGroup(organization1);
db.users().insertPermissionOnGroup(group, "foo");
db.users().insertPermissionOnGroup(group, "bar");
db.users().insertPermissionOnGroup(group, "doh");
return group.getId();
}
Aggregations