ComponentDto otherProject = db.components().insertPublicProject().getMainBranchComponent();
UserDto otherUser = db.users().insertUser();
db.users().insertMember(group1, user);
- db.users().insertProjectPermissionOnGroup(group1, randomPermission, project);
+ db.users().insertEntityPermissionOnGroup(group1, randomPermission, project);
assertThat(underTest.keepAuthorizedEntityUuids(dbSession, singleton(project.getUuid()), user.getUuid(), randomPermission))
.containsOnly(project.getUuid());
db.users().insertProjectPermissionOnUser(user, UserRole.USER, project2);
db.users().insertProjectPermissionOnUser(user, UserRole.USER, project3);
db.users().insertMember(group, user);
- db.users().insertProjectPermissionOnGroup(group, UserRole.USER, project1);
+ db.users().insertEntityPermissionOnGroup(group, UserRole.USER, project1);
assertThat(underTest.keepAuthorizedEntityUuids(dbSession, newHashSet(project2.getUuid(), project3.getUuid()), user.getUuid(), UserRole.USER))
.containsOnly(project2.getUuid(), project3.getUuid());
GroupDto group = db.users().insertGroup();
db.users().insertMembers(group, user1);
db.users().insertProjectPermissionOnUser(user1, UserRole.USER, project1);
- db.users().insertProjectPermissionOnGroup(group, UserRole.USER, project2);
- db.users().insertProjectPermissionOnGroup(group, UserRole.USER, project3);
+ db.users().insertEntityPermissionOnGroup(group, UserRole.USER, project2);
+ db.users().insertEntityPermissionOnGroup(group, UserRole.USER, project3);
assertThat(underTest.keepAuthorizedEntityUuids(dbSession, newHashSet(project2.getUuid(), project3.getUuid()), user1.getUuid(), UserRole.USER))
.containsOnly(project2.getUuid(), project3.getUuid());
ProjectDto otherProject = db.components().insertPublicProject().getProjectDto();
UserDto otherUser = db.users().insertUser();
db.users().insertMember(group1, user);
- db.users().insertProjectPermissionOnGroup(group1, randomPermission, project);
+ db.users().insertEntityPermissionOnGroup(group1, randomPermission, project);
assertThat(underTest.keepAuthorizedUsersForRoleAndEntity(dbSession, singleton(user.getUuid()), randomPermission, project.getUuid()))
.containsOnly(user.getUuid());
ProjectDto otherProject = db.components().insertPublicProject().getProjectDto();
UserDto otherUser = db.users().insertUser();
db.users().insertMember(group1, user);
- db.users().insertProjectPermissionOnGroup(group1, randomPermission, project);
+ db.users().insertEntityPermissionOnGroup(group1, randomPermission, project);
assertThat(underTest.keepAuthorizedUsersForRoleAndEntity(dbSession, singleton(user.getUuid()), randomPermission, project.getUuid()))
.containsOnly(user.getUuid());
db.users().insertProjectPermissionOnUser(user1, UserRole.USER, project1);
db.users().insertProjectPermissionOnUser(user2, UserRole.USER, project1);
db.users().insertProjectPermissionOnUser(user3, UserRole.USER, project1);
- db.users().insertProjectPermissionOnGroup(group2, UserRole.USER, project3);
+ db.users().insertEntityPermissionOnGroup(group2, UserRole.USER, project3);
assertThat(underTest.keepAuthorizedUsersForRoleAndEntity(dbSession,
// Only 100 and 101 has 'user' role on project
@Test
public void selectEntityPermissions_returns_permissions_of_logged_in_user_on_specified_project_through_group_membership() {
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
- db.users().insertProjectPermissionOnGroup(group1, UserRole.CODEVIEWER, project);
- db.users().insertProjectPermissionOnGroup(group2, UserRole.ISSUE_ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group1, UserRole.CODEVIEWER, project);
+ db.users().insertEntityPermissionOnGroup(group2, UserRole.ISSUE_ADMIN, project);
db.users().insertMember(group1, user);
assertThat(underTest.selectEntityPermissions(dbSession, project.getUuid(), user.getUuid())).containsOnly(UserRole.CODEVIEWER);
public void selectEntityPermissions_returns_permissions_of_logged_in_user_on_specified_private_project_through_all_possible_configurations() {
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
db.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, project);
- db.users().insertProjectPermissionOnGroup(group1, UserRole.USER, project);
+ db.users().insertEntityPermissionOnGroup(group1, UserRole.USER, project);
db.users().insertMember(group1, user);
assertThat(underTest.selectEntityPermissions(dbSession, project.getUuid(), user.getUuid())).containsOnly(UserRole.CODEVIEWER, UserRole.USER);
ProjectDto project = db.components().insertPublicProject().getProjectDto();
db.users().insertProjectPermissionOnUser(user, "p1", project);
db.users().insertProjectPermissionOnAnyone("p2", project);
- db.users().insertProjectPermissionOnGroup(group1, "p3", project);
+ db.users().insertEntityPermissionOnGroup(group1, "p3", project);
db.users().insertMember(group1, user);
assertThat(underTest.selectEntityPermissions(dbSession, project.getUuid(), user.getUuid())).containsOnly("p1", "p2", "p3");
UserDto user = db.users().insertUser();
GroupDto group = db.users().insertGroup();
db.users().insertMember(group, user);
- db.users().insertProjectPermissionOnGroup(group, UserRole.ADMIN, privateProject);
+ db.users().insertEntityPermissionOnGroup(group, UserRole.ADMIN, privateProject);
assertThat(underTest.keepAuthorizedEntityUuids(dbSession, newHashSet(privateProject.getUuid(), publicProject.getUuid()), user.getUuid(), UserRole.ADMIN))
.containsOnly(privateProject.getUuid());
UserDto admin2 = db.users().insertUser();
GroupDto adminGroup = db.users().insertGroup("ADMIN");
db.users().insertMember(adminGroup, admin2);
- db.users().insertProjectPermissionOnGroup(adminGroup, UserRole.ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(adminGroup, UserRole.ADMIN, project);
assertThat(underTest.keepAuthorizedLoginsOnEntity(dbSession, newHashSet(user1.getLogin()), project.getKey(), UserRole.USER))
.containsOnly(user1.getLogin());
GroupDto userGroup = db.users().insertGroup("USERS");
GroupDto adminGroup = db.users().insertGroup("ADMIN");
- db.users().insertProjectPermissionOnGroup(userGroup, UserRole.USER, project);
- db.users().insertProjectPermissionOnGroup(adminGroup, UserRole.ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(userGroup, UserRole.USER, project);
+ db.users().insertEntityPermissionOnGroup(adminGroup, UserRole.ADMIN, project);
// admin with "direct" ADMIN role
UserDto admin1 = db.users().insertUser();
GroupDto userGroup = db.users().insertGroup("USERS");
GroupDto adminGroup = db.users().insertGroup("ADMIN");
- db.users().insertProjectPermissionOnGroup(userGroup, UserRole.USER, project);
- db.users().insertProjectPermissionOnGroup(adminGroup, UserRole.ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(userGroup, UserRole.USER, project);
+ db.users().insertEntityPermissionOnGroup(adminGroup, UserRole.ADMIN, project);
// admin with "direct" ADMIN role
UserDto admin1 = db.users().insertUser();
ProjectDto project2 = db.components().insertPrivateProject().getProjectDto();
ProjectDto project3 = db.components().insertPrivateProject().getProjectDto();
- db.users().insertProjectPermissionOnGroup(group1, UserRole.ISSUE_ADMIN, project1);
- db.users().insertProjectPermissionOnGroup(group1, UserRole.ADMIN, project2);
- db.users().insertProjectPermissionOnGroup(group2, UserRole.ADMIN, project2);
- db.users().insertProjectPermissionOnGroup(group3, UserRole.ADMIN, project2);
- db.users().insertProjectPermissionOnGroup(group1, UserRole.USER, project2);
- db.users().insertProjectPermissionOnGroup(group1, UserRole.USER, project3);
+ db.users().insertEntityPermissionOnGroup(group1, UserRole.ISSUE_ADMIN, project1);
+ db.users().insertEntityPermissionOnGroup(group1, UserRole.ADMIN, project2);
+ db.users().insertEntityPermissionOnGroup(group2, UserRole.ADMIN, project2);
+ db.users().insertEntityPermissionOnGroup(group3, UserRole.ADMIN, project2);
+ db.users().insertEntityPermissionOnGroup(group1, UserRole.USER, project2);
+ db.users().insertEntityPermissionOnGroup(group1, UserRole.USER, project3);
final List<CountPerEntityPermission> result = new ArrayList<>();
underTest.groupsCountByComponentUuidAndPermission(dbSession, asList(project2.getUuid(), project3.getUuid(), "789"),
ProjectDto project2 = db.components().insertPublicProject().getProjectDto();
ProjectDto project3 = db.components().insertPublicProject().getProjectDto();
- db.users().insertProjectPermissionOnGroup(group1, "p1", project1);
- db.users().insertProjectPermissionOnGroup(group1, "p2", project2);
- db.users().insertProjectPermissionOnGroup(group2, "p2", project2);
- db.users().insertProjectPermissionOnGroup(group3, "p2", project2);
+ db.users().insertEntityPermissionOnGroup(group1, "p1", project1);
+ db.users().insertEntityPermissionOnGroup(group1, "p2", project2);
+ db.users().insertEntityPermissionOnGroup(group2, "p2", project2);
+ db.users().insertEntityPermissionOnGroup(group3, "p2", project2);
// anyone group
db.users().insertProjectPermissionOnAnyone("p2", project2);
- db.users().insertProjectPermissionOnGroup(group1, "p3", project2);
- db.users().insertProjectPermissionOnGroup(group1, "p3", project3);
+ db.users().insertEntityPermissionOnGroup(group1, "p3", project2);
+ db.users().insertEntityPermissionOnGroup(group1, "p3", project3);
final List<CountPerEntityPermission> result = new ArrayList<>();
underTest.groupsCountByComponentUuidAndPermission(dbSession, asList(project2.getUuid(), project3.getUuid(), "789"),
IntStream.rangeClosed(1, DEFAULT_PAGE_SIZE + 1).forEach(i -> {
GroupDto group = db.users().insertGroup("Group-" + i);
// Add permission on project to be sure projects are excluded
- db.users().insertProjectPermissionOnGroup(group, GlobalPermission.SCAN.getKey(), project);
+ db.users().insertEntityPermissionOnGroup(group, GlobalPermission.SCAN.getKey(), project);
});
String lastGroupName = "Group-" + (DEFAULT_PAGE_SIZE + 1);
db.users().insertPermissionOnGroup(db.users().selectGroup(lastGroupName).orElseGet(() -> fail("group not found")), GlobalPermission.SCAN);
});
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
String lastGroupName = "Group-" + (DEFAULT_PAGE_SIZE + 1);
- db.users().insertProjectPermissionOnGroup(db.users().selectGroup(lastGroupName).orElseGet(() -> fail("group not found")), GlobalPermission.SCAN.getKey(), project);
+ db.users().insertEntityPermissionOnGroup(db.users().selectGroup(lastGroupName).orElseGet(() -> fail("group not found")), GlobalPermission.SCAN.getKey(), project);
assertThat(underTest.selectGroupNamesByQuery(dbSession, newQuery()
.setEntity(project)
db.users().insertPermissionOnAnyone(GlobalPermission.PROVISION_PROJECTS);
db.users().insertPermissionOnGroup(group1, GlobalPermission.SCAN);
db.users().insertPermissionOnGroup(group3, GlobalPermission.ADMINISTER);
- db.users().insertProjectPermissionOnGroup(group2, UserRole.ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group2, UserRole.ADMIN, project);
assertThat(underTest.selectGroupNamesByQuery(dbSession,
newQuery().setPermission(GlobalPermission.SCAN.getKey()).build())).containsExactly(ANYONE, group1.getName());
ProjectDto project = db.components().insertPublicProject().getProjectDto();
ProjectDto anotherProject = db.components().insertPublicProject().getProjectDto();
- db.users().insertProjectPermissionOnGroup(group1, "p1", project);
- db.users().insertProjectPermissionOnGroup(group1, "p2", project);
+ db.users().insertEntityPermissionOnGroup(group1, "p1", project);
+ db.users().insertEntityPermissionOnGroup(group1, "p2", project);
db.users().insertProjectPermissionOnAnyone("p3", project);
- db.users().insertProjectPermissionOnGroup(group1, "p4", anotherProject);
+ db.users().insertEntityPermissionOnGroup(group1, "p4", anotherProject);
db.users().insertProjectPermissionOnAnyone("p4", anotherProject);
- db.users().insertProjectPermissionOnGroup(group3, "p1", anotherProject);
+ db.users().insertEntityPermissionOnGroup(group3, "p1", anotherProject);
db.users().insertPermissionOnGroup(group2, "p5");
PermissionQuery.Builder builderOnComponent = newQuery()
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
ProjectDto anotherProject = db.components().insertPrivateProject().getProjectDto();
- db.users().insertProjectPermissionOnGroup(group1, GlobalPermission.SCAN.getKey(), project);
- db.users().insertProjectPermissionOnGroup(group1, GlobalPermission.PROVISION_PROJECTS.getKey(), project);
+ db.users().insertEntityPermissionOnGroup(group1, GlobalPermission.SCAN.getKey(), project);
+ db.users().insertEntityPermissionOnGroup(group1, GlobalPermission.PROVISION_PROJECTS.getKey(), project);
- db.users().insertProjectPermissionOnGroup(group1, UserRole.ADMIN, anotherProject);
- db.users().insertProjectPermissionOnGroup(group3, UserRole.SCAN, anotherProject);
+ db.users().insertEntityPermissionOnGroup(group1, UserRole.ADMIN, anotherProject);
+ db.users().insertEntityPermissionOnGroup(group3, UserRole.SCAN, anotherProject);
db.users().insertPermissionOnGroup(group2, GlobalPermission.SCAN);
PermissionQuery.Builder builderOnComponent = newQuery()
ProjectDto project = randomPublicOrPrivateProject().getProjectDto();
GroupDto group1 = db.users().insertGroup();
GroupDto group2 = db.users().insertGroup();
- db.users().insertProjectPermissionOnGroup(group1, "p1", project);
- db.users().insertProjectPermissionOnGroup(group2, "p2", project);
+ db.users().insertEntityPermissionOnGroup(group1, "p1", project);
+ db.users().insertEntityPermissionOnGroup(group2, "p2", project);
assertThat(underTest.selectGroupUuidsWithPermissionOnEntityBut(dbSession, project.getUuid(), "p2"))
.containsOnly(group1.getUuid());
GroupDto group1 = db.users().insertGroup();
GroupDto group2 = db.users().insertGroup();
db.users().insertGroup();
- db.users().insertProjectPermissionOnGroup(group1, "p1", project.getProjectDto());
- db.users().insertProjectPermissionOnGroup(group2, "p2", project.getProjectDto());
+ db.users().insertEntityPermissionOnGroup(group1, "p1", project.getProjectDto());
+ db.users().insertEntityPermissionOnGroup(group2, "p2", project.getProjectDto());
assertThat(underTest.selectGroupUuidsWithPermissionOnEntityBut(dbSession, project.projectUuid(), "p2"))
.containsOnly(group1.getUuid());
ProjectDto project1 = db.components().insertPrivateProject().getProjectDto();
ProjectDto project2 = db.components().insertPrivateProject().getProjectDto();
db.users().insertPermissionOnGroup(group1, "perm1");
- db.users().insertProjectPermissionOnGroup(group1, "perm2", project1);
- db.users().insertProjectPermissionOnGroup(group2, "perm3", project2);
+ db.users().insertEntityPermissionOnGroup(group1, "perm2", project1);
+ db.users().insertEntityPermissionOnGroup(group2, "perm3", project2);
underTest.deleteByEntityUuid(dbSession, project1);
dbSession.commit();
ProjectDto project1 = db.components().insertPublicProject().getProjectDto();
ProjectDto project2 = db.components().insertPublicProject().getProjectDto();
db.users().insertPermissionOnGroup(group1, "perm1");
- db.users().insertProjectPermissionOnGroup(group1, "perm2", project1);
- db.users().insertProjectPermissionOnGroup(group2, "perm3", project2);
+ db.users().insertEntityPermissionOnGroup(group1, "perm2", project1);
+ db.users().insertEntityPermissionOnGroup(group2, "perm3", project2);
db.users().insertProjectPermissionOnAnyone("perm4", project1);
db.users().insertProjectPermissionOnAnyone("perm5", project2);
ProjectDto project1 = db.components().insertPublicProject().getProjectDto();
db.users().insertPermissionOnAnyone("perm1");
db.users().insertPermissionOnGroup(group1, "perm2");
- db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
+ db.users().insertEntityPermissionOnGroup(group1, "perm3", project1);
db.users().insertProjectPermissionOnAnyone("perm4", project1);
underTest.delete(dbSession, "perm2", group1.getUuid(), group1.getName(), null);
ProjectDto project1 = db.components().insertPrivateProject().getProjectDto();
db.users().insertPermissionOnAnyone("perm1");
db.users().insertPermissionOnGroup(group1, "perm2");
- db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
+ db.users().insertEntityPermissionOnGroup(group1, "perm3", project1);
underTest.delete(dbSession, "perm2", group1.getUuid(), group1.getName(), null);
dbSession.commit();
ProjectDto project1 = db.components().insertPublicProject().getProjectDto();
db.users().insertPermissionOnAnyone("perm1");
db.users().insertPermissionOnGroup(group1, "perm2");
- db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
+ db.users().insertEntityPermissionOnGroup(group1, "perm3", project1);
db.users().insertProjectPermissionOnAnyone("perm4", project1);
underTest.delete(dbSession, "perm1", null, null, null);
ProjectDto project1 = db.components().insertPrivateProject().getProjectDto();
db.users().insertPermissionOnAnyone("perm1");
db.users().insertPermissionOnGroup(group1, "perm2");
- db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
+ db.users().insertEntityPermissionOnGroup(group1, "perm3", project1);
underTest.delete(dbSession, "perm3", group1.getUuid(), group1.getName(), project1);
dbSession.commit();
ProjectDto project1 = db.components().insertPublicProject().getProjectDto();
db.users().insertPermissionOnAnyone("perm1");
db.users().insertPermissionOnGroup(group1, "perm2");
- db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
+ db.users().insertEntityPermissionOnGroup(group1, "perm3", project1);
db.users().insertProjectPermissionOnAnyone("perm4", project1);
underTest.delete(dbSession, "perm3", group1.getUuid(), group1.getName(), project1);
ProjectDto project1 = db.components().insertPublicProject().getProjectDto();
db.users().insertPermissionOnAnyone("perm1");
db.users().insertPermissionOnGroup(group1, "perm2");
- db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
+ db.users().insertEntityPermissionOnGroup(group1, "perm3", project1);
db.users().insertProjectPermissionOnAnyone("perm4", project1);
underTest.delete(dbSession, "perm4", null, null, project1);
ProjectDto project = db.components().insertPublicProject().getProjectDto();
GroupDto group = db.users().insertGroup();
db.users().insertProjectPermissionOnAnyone("p1", project);
- db.users().insertProjectPermissionOnGroup(group, "p2", project);
+ db.users().insertEntityPermissionOnGroup(group, "p2", project);
db.users().insertPermissionOnAnyone("p3");
db.users().insertPermissionOnGroup(group, "p4");
assertThat(underTest.selectEntityPermissionsOfGroup(dbSession, null, project.getUuid()))
GroupDto group1 = db.users().insertGroup();
GroupDto group2 = db.users().insertGroup();
db.users().insertProjectPermissionOnAnyone("p1", project);
- db.users().insertProjectPermissionOnGroup(group1, "p2", project);
- db.users().insertProjectPermissionOnGroup(group2, "p3", project);
- db.users().insertProjectPermissionOnGroup(group2, "p4", project);
+ db.users().insertEntityPermissionOnGroup(group1, "p2", project);
+ db.users().insertEntityPermissionOnGroup(group2, "p3", project);
+ db.users().insertEntityPermissionOnGroup(group2, "p4", project);
db.users().insertPermissionOnAnyone("p5");
db.users().insertPermissionOnGroup(group1, "p6");
db.users().insertPermissionOnGroup(group2, "p7");
public void deleteByRootEntityAndGroupUuid_has_no_effect_if_component_has_no_group_permission_for_group_AnyOne() {
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
GroupDto group1 = db.users().insertGroup();
- db.users().insertProjectPermissionOnGroup(group1, "p1", project);
+ db.users().insertEntityPermissionOnGroup(group1, "p1", project);
assertThat(underTest.selectEntityPermissionsOfGroup(dbSession, null, project.getUuid()))
.isEmpty();
assertThat(underTest.selectEntityPermissionsOfGroup(dbSession, group1.getUuid(), project.getUuid()))
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
GroupDto group1 = db.users().insertGroup();
GroupDto group2 = db.users().insertGroup();
- db.users().insertProjectPermissionOnGroup(group1, "p1", project);
+ db.users().insertEntityPermissionOnGroup(group1, "p1", project);
db.users().insertPermissionOnAnyone("p2");
db.users().insertPermissionOnGroup(group1, "p3");
Stream.of("p1", "p2").forEach(permission -> {
db.users().insertPermissionOnAnyone(permission);
db.users().insertPermissionOnGroup(group, permission);
- db.users().insertProjectPermissionOnGroup(group, permission, project);
+ db.users().insertEntityPermissionOnGroup(group, permission, project);
db.users().insertProjectPermissionOnAnyone(permission, project);
});
assertThat(getGlobalPermissionsForAnyone()).containsOnly("p1", "p2");
GroupDto group = db.users().insertGroup();
db.users().insertPermissionOnAnyone("p1");
db.users().insertPermissionOnGroup(group, "p1");
- db.users().insertProjectPermissionOnGroup(group, "p1", project);
+ db.users().insertEntityPermissionOnGroup(group, "p1", project);
db.users().insertProjectPermissionOnAnyone("p1", project);
ProjectDto anotherProject = ComponentTesting.newProjectDto();
private final String userLogin;
public UserPermissionNewValue(UserPermissionDto permissionDto, @Nullable String componentKey, @Nullable String componentName,
- @Nullable UserId userId, String qualifier, @Nullable PermissionTemplateDto templateDto) {
+ @Nullable UserId userId, @Nullable String qualifier, @Nullable PermissionTemplateDto templateDto) {
super(permissionDto.getUuid(), permissionDto.getComponentUuid(), componentKey, componentName, permissionDto.getPermission(), qualifier, templateDto);
this.userUuid = userId != null ? userId.getUuid() : null;
this.userLogin = userId != null ? userId.getLogin() : null;
.setComponentUuid(project.uuid())
.setComponentName(project.name());
- //TODO, will be removed later
+ // TODO, will be removed later
ProjectDto projectDto = new ProjectDto();
projectDto.setQualifier(project.qualifier());
projectDto.setKey(project.getKey());
.setComponentUuid(project.uuid())
.setComponentName(project.name());
- //TODO, will be removed later
+ // TODO, will be removed later
ProjectDto projectDto = new ProjectDto();
projectDto.setQualifier(project.qualifier());
projectDto.setKey(project.getKey());
return dto;
}
- public GroupPermissionDto insertProjectPermissionOnGroup(GroupDto group, String permission, EntityDto entity) {
- checkArgument(entity.isPrivate() || !PUBLIC_PERMISSIONS.contains(permission),
- "%s can't be granted on a public project", permission);
+ public GroupPermissionDto insertEntityPermissionOnGroup(GroupDto group, String permission, EntityDto entityDto) {
+ checkArgument(entityDto.isPrivate() || !PUBLIC_PERMISSIONS.contains(permission),
+ "%s can't be granted on a public entity (project or portfolio)", permission);
+ Optional<BranchDto> branchDto = db.getDbClient().branchDao().selectByUuid(db.getSession(), entityDto.getUuid());
+ // I don't know if this check is worth it
+ branchDto.ifPresent(dto -> checkArgument(dto.isMain(), PERMISSIONS_CANT_BE_GRANTED_ON_BRANCHES));
GroupPermissionDto dto = new GroupPermissionDto()
.setUuid(Uuids.createFast())
.setGroupUuid(group.getUuid())
.setGroupName(group.getName())
.setRole(permission)
- .setComponentUuid(entity.getUuid())
- .setComponentName(entity.getName());
- db.getDbClient().groupPermissionDao().insert(db.getSession(), dto, entity, null);
+ .setComponentUuid(entityDto.getUuid())
+ .setComponentName(entityDto.getUuid());
+ db.getDbClient().groupPermissionDao().insert(db.getSession(), dto, entityDto, null);
db.commit();
return dto;
}
@Test
public void hasComponentPermissionByDtoOrUuid_returns_true_for_anonymous_user_for_permissions_USER_and_CODEVIEWER_on_public_projects_with_group_permissions() {
ProjectData publicProject = db.components().insertPublicProject();
- db.users().insertProjectPermissionOnGroup(db.users().insertGroup(), "p1", publicProject.getProjectDto());
+ db.users().insertEntityPermissionOnGroup(db.users().insertGroup(), "p1", publicProject.getProjectDto());
ServerUserSession underTest = newAnonymousSession();
public void hasComponentPermissionByDtoOrUuid_returns_false_for_authenticated_user_for_permissions_USER_and_CODEVIEWER_on_private_projects_with_group_permissions() {
UserDto user = db.users().insertUser();
ProjectData privateProject = db.components().insertPrivateProject();
- db.users().insertProjectPermissionOnGroup(db.users().insertGroup(), "p1", privateProject.getProjectDto());
+ db.users().insertEntityPermissionOnGroup(db.users().insertGroup(), "p1", privateProject.getProjectDto());
ServerUserSession underTest = newUserSession(user);
public void hasComponentPermissionByDtoOrUuid_returns_false_for_anonymous_user_for_inserted_permissions_on_group_on_public_projects() {
ProjectData publicProject = db.components().insertPublicProject();
GroupDto group = db.users().insertGroup();
- db.users().insertProjectPermissionOnGroup(group, "p1", publicProject.getProjectDto());
+ db.users().insertEntityPermissionOnGroup(group, "p1", publicProject.getProjectDto());
ServerUserSession underTest = newAnonymousSession();
public void hasComponentPermissionByDtoOrUuid_returns_false_for_anonymous_user_for_inserted_permissions_on_group_on_private_projects() {
ProjectData privateProject = db.components().insertPrivateProject();
GroupDto group = db.users().insertGroup();
- db.users().insertProjectPermissionOnGroup(group, "p1", privateProject.getProjectDto());
+ db.users().insertEntityPermissionOnGroup(group, "p1", privateProject.getProjectDto());
ServerUserSession underTest = newAnonymousSession();
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ProjectData;
import org.sonar.db.permission.GroupPermissionDto;
+import org.sonar.db.portfolio.PortfolioDto;
+import org.sonar.db.project.ProjectDto;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDbTester;
import org.sonar.db.user.UserDto;
+import org.sonar.server.project.Project;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
public class PermissionIndexerDaoIT {
@Rule
- public DbTester dbTester = DbTester.create(System2.INSTANCE);
+ public DbTester dbTester = DbTester.create(System2.INSTANCE,true);
private final DbClient dbClient = dbTester.getDbClient();
private final DbSession dbSession = dbTester.getSession();
private final ComponentDbTester componentDbTester = new ComponentDbTester(dbTester);
private final UserDbTester userDbTester = new UserDbTester(dbTester);
- private ComponentDto publicProject;
- private ComponentDto privateProject1;
- private ComponentDto privateProject2;
- private ComponentDto view1;
- private ComponentDto view2;
- private ComponentDto application;
+ private ProjectDto publicProject;
+ private ProjectDto privateProject1;
+ private ProjectDto privateProject2;
+ private PortfolioDto view1;
+ private PortfolioDto view2;
+ private ProjectDto application;
private UserDto user1;
private UserDto user2;
private GroupDto group;
@Before
public void setUp() {
- publicProject = componentDbTester.insertPublicProject().getMainBranchComponent();
- privateProject1 = componentDbTester.insertPrivateProject().getMainBranchComponent();
- privateProject2 = componentDbTester.insertPrivateProject().getMainBranchComponent();
- view1 = componentDbTester.insertPublicPortfolio();
- view2 = componentDbTester.insertPublicPortfolio();
- application = componentDbTester.insertPublicApplication().getMainBranchComponent();
+ publicProject = componentDbTester.insertPublicProject().getProjectDto();
+ privateProject1 = componentDbTester.insertPrivateProject().getProjectDto();
+ privateProject2 = componentDbTester.insertPrivateProject().getProjectDto();
+ view1 = componentDbTester.insertPublicPortfolioDto();
+ view2 = componentDbTester.insertPublicPortfolioDto();
+ application = componentDbTester.insertPublicApplication().getProjectDto();
user1 = userDbTester.insertUser();
user2 = userDbTester.insertUser();
group = userDbTester.insertGroup();
Collection<IndexPermissions> dtos = underTest.selectAll(dbClient, dbSession);
Assertions.assertThat(dtos).hasSize(6);
- IndexPermissions publicProjectAuthorization = getByProjectUuid(publicProject.uuid(), dtos);
+ IndexPermissions publicProjectAuthorization = getByProjectUuid(publicProject.getUuid(), dtos);
isPublic(publicProjectAuthorization, PROJECT);
- IndexPermissions view1Authorization = getByProjectUuid(view1.uuid(), dtos);
+ IndexPermissions view1Authorization = getByProjectUuid(view1.getUuid(), dtos);
isPublic(view1Authorization, VIEW);
- IndexPermissions applicationAuthorization = getByProjectUuid(application.uuid(), dtos);
+ IndexPermissions applicationAuthorization = getByProjectUuid(application.getUuid(), dtos);
isPublic(applicationAuthorization, APP);
- IndexPermissions privateProject1Authorization = getByProjectUuid(privateProject1.uuid(), dtos);
+ IndexPermissions privateProject1Authorization = getByProjectUuid(privateProject1.getUuid(), dtos);
assertThat(privateProject1Authorization.getGroupUuids()).containsOnly(group.getUuid());
assertThat(privateProject1Authorization.isAllowAnyone()).isFalse();
assertThat(privateProject1Authorization.getUserUuids()).containsOnly(user1.getUuid(), user2.getUuid());
assertThat(privateProject1Authorization.getQualifier()).isEqualTo(PROJECT);
- IndexPermissions privateProject2Authorization = getByProjectUuid(privateProject2.uuid(), dtos);
+ IndexPermissions privateProject2Authorization = getByProjectUuid(privateProject2.getUuid(), dtos);
assertThat(privateProject2Authorization.getGroupUuids()).isEmpty();
assertThat(privateProject2Authorization.isAllowAnyone()).isFalse();
assertThat(privateProject2Authorization.getUserUuids()).containsOnly(user1.getUuid());
assertThat(privateProject2Authorization.getQualifier()).isEqualTo(PROJECT);
- IndexPermissions view2Authorization = getByProjectUuid(view2.uuid(), dtos);
+ IndexPermissions view2Authorization = getByProjectUuid(view2.getUuid(), dtos);
isPublic(view2Authorization, VIEW);
}
insertTestDataForProjectsAndViews();
Map<String, IndexPermissions> dtos = underTest
- .selectByUuids(dbClient, dbSession, asList(publicProject.uuid(), privateProject1.uuid(), privateProject2.uuid(), view1.uuid(), view2.uuid(), application.uuid()))
+ .selectByUuids(dbClient, dbSession,
+ asList(publicProject.getUuid(), privateProject1.getUuid(), privateProject2.getUuid(), view1.getUuid(), view2.getUuid(), application.getUuid()))
.stream()
.collect(MoreCollectors.uniqueIndex(IndexPermissions::getProjectUuid, Function.identity()));
Assertions.assertThat(dtos).hasSize(6);
- IndexPermissions publicProjectAuthorization = dtos.get(publicProject.uuid());
+ IndexPermissions publicProjectAuthorization = dtos.get(publicProject.getUuid());
isPublic(publicProjectAuthorization, PROJECT);
- IndexPermissions view1Authorization = dtos.get(view1.uuid());
+ IndexPermissions view1Authorization = dtos.get(view1.getUuid());
isPublic(view1Authorization, VIEW);
- IndexPermissions applicationAuthorization = dtos.get(application.uuid());
+ IndexPermissions applicationAuthorization = dtos.get(application.getUuid());
isPublic(applicationAuthorization, APP);
- IndexPermissions privateProject1Authorization = dtos.get(privateProject1.uuid());
+ IndexPermissions privateProject1Authorization = dtos.get(privateProject1.getUuid());
assertThat(privateProject1Authorization.getGroupUuids()).containsOnly(group.getUuid());
assertThat(privateProject1Authorization.isAllowAnyone()).isFalse();
assertThat(privateProject1Authorization.getUserUuids()).containsOnly(user1.getUuid(), user2.getUuid());
assertThat(privateProject1Authorization.getQualifier()).isEqualTo(PROJECT);
- IndexPermissions privateProject2Authorization = dtos.get(privateProject2.uuid());
+ IndexPermissions privateProject2Authorization = dtos.get(privateProject2.getUuid());
assertThat(privateProject2Authorization.getGroupUuids()).isEmpty();
assertThat(privateProject2Authorization.isAllowAnyone()).isFalse();
assertThat(privateProject2Authorization.getUserUuids()).containsOnly(user1.getUuid());
assertThat(privateProject2Authorization.getQualifier()).isEqualTo(PROJECT);
- IndexPermissions view2Authorization = dtos.get(view2.uuid());
+ IndexPermissions view2Authorization = dtos.get(view2.getUuid());
isPublic(view2Authorization, VIEW);
}
@Test
public void return_private_project_without_any_permission_when_no_permission_in_DB() {
- List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(privateProject1.uuid()));
+ List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(privateProject1.getUuid()));
// no permissions
Assertions.assertThat(dtos).hasSize(1);
assertThat(dto.getGroupUuids()).isEmpty();
assertThat(dto.getUserUuids()).isEmpty();
assertThat(dto.isAllowAnyone()).isFalse();
- assertThat(dto.getProjectUuid()).isEqualTo(privateProject1.uuid());
- assertThat(dto.getQualifier()).isEqualTo(privateProject1.qualifier());
+ assertThat(dto.getProjectUuid()).isEqualTo(privateProject1.getUuid());
+ assertThat(dto.getQualifier()).isEqualTo(privateProject1.getQualifier());
}
@Test
public void return_public_project_with_only_AllowAnyone_true_when_no_permission_in_DB() {
- List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(publicProject.uuid()));
+ List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(publicProject.getUuid()));
Assertions.assertThat(dtos).hasSize(1);
IndexPermissions dto = dtos.get(0);
assertThat(dto.getGroupUuids()).isEmpty();
assertThat(dto.getUserUuids()).isEmpty();
assertThat(dto.isAllowAnyone()).isTrue();
- assertThat(dto.getProjectUuid()).isEqualTo(publicProject.uuid());
- assertThat(dto.getQualifier()).isEqualTo(publicProject.qualifier());
+ assertThat(dto.getProjectUuid()).isEqualTo(publicProject.getUuid());
+ assertThat(dto.getQualifier()).isEqualTo(publicProject.getQualifier());
}
@Test
public void return_private_project_with_AllowAnyone_false_and_user_id_when_user_is_granted_USER_permission_directly() {
dbTester.users().insertProjectPermissionOnUser(user1, USER, privateProject1);
- List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(privateProject1.uuid()));
+ List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(privateProject1.getUuid()));
Assertions.assertThat(dtos).hasSize(1);
IndexPermissions dto = dtos.get(0);
assertThat(dto.getGroupUuids()).isEmpty();
assertThat(dto.getUserUuids()).containsOnly(user1.getUuid());
assertThat(dto.isAllowAnyone()).isFalse();
- assertThat(dto.getProjectUuid()).isEqualTo(privateProject1.uuid());
- assertThat(dto.getQualifier()).isEqualTo(privateProject1.qualifier());
+ assertThat(dto.getProjectUuid()).isEqualTo(privateProject1.getUuid());
+ assertThat(dto.getQualifier()).isEqualTo(privateProject1.getQualifier());
}
@Test
public void return_private_project_with_AllowAnyone_false_and_group_id_but_not_user_id_when_user_is_granted_USER_permission_through_group() {
dbTester.users().insertMember(group, user1);
- dbTester.users().insertProjectPermissionOnGroup(group, USER, privateProject1);
- List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(privateProject1.uuid()));
+ dbTester.users().insertEntityPermissionOnGroup(group, USER, privateProject1);
+ List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(privateProject1.getUuid()));
Assertions.assertThat(dtos).hasSize(1);
IndexPermissions dto = dtos.get(0);
assertThat(dto.getGroupUuids()).containsOnly(group.getUuid());
assertThat(dto.getUserUuids()).isEmpty();
assertThat(dto.isAllowAnyone()).isFalse();
- assertThat(dto.getProjectUuid()).isEqualTo(privateProject1.uuid());
- assertThat(dto.getQualifier()).isEqualTo(privateProject1.qualifier());
+ assertThat(dto.getProjectUuid()).isEqualTo(privateProject1.getUuid());
+ assertThat(dto.getQualifier()).isEqualTo(privateProject1.getQualifier());
}
private void isPublic(IndexPermissions view1Authorization, String qualifier) {
userDbTester.insertProjectPermissionOnUser(user2, ADMIN, privateProject2);
// group1 has USER access on privateProject1 only
- userDbTester.insertProjectPermissionOnGroup(group, USER, privateProject1);
- userDbTester.insertProjectPermissionOnGroup(group, ADMIN, privateProject1);
- userDbTester.insertProjectPermissionOnGroup(group, ADMIN, view1);
- userDbTester.insertProjectPermissionOnGroup(group, ADMIN, application);
+ userDbTester.insertEntityPermissionOnGroup(group, USER, privateProject1);
+ userDbTester.insertEntityPermissionOnGroup(group, ADMIN, privateProject1);
+ userDbTester.insertEntityPermissionOnGroup(group, ADMIN, view1);
+ userDbTester.insertEntityPermissionOnGroup(group, ADMIN, application);
}
}
USER, GROUP, ANYONE, NONE
}
- private static final String SQL_TEMPLATE = "SELECT " +
- " project_authorization.kind as kind, " +
- " project_authorization.project as project, " +
- " project_authorization.user_uuid as user_uuid, " +
- " project_authorization.group_uuid as group_uuid, " +
- " project_authorization.qualifier as qualifier " +
- "FROM ( " +
-
- // users
-
- " SELECT '" + RowKind.USER + "' as kind," +
- " c.uuid AS project, " +
- " c.qualifier AS qualifier, " +
- " user_roles.user_uuid AS user_uuid, " +
- " NULL AS group_uuid " +
- " FROM components c " +
- " INNER JOIN user_roles ON user_roles.component_uuid = c.uuid AND user_roles.role = 'user' " +
- " WHERE " +
- " (c.qualifier = 'TRK' " +
- " or c.qualifier = 'VW' " +
- " or c.qualifier = 'APP') " +
- " AND c.copy_component_uuid is NULL " +
- " {projectsCondition} " +
- " UNION " +
-
- // groups
-
- " SELECT '" + RowKind.GROUP + "' as kind," +
- " c.uuid AS project, " +
- " c.qualifier AS qualifier, " +
- " NULL AS user_uuid, " +
- " groups.uuid AS group_uuid " +
- " FROM components c " +
- " INNER JOIN group_roles ON group_roles.component_uuid = c.uuid AND group_roles.role = 'user' " +
- " INNER JOIN groups ON groups.uuid = group_roles.group_uuid " +
- " WHERE " +
- " (c.qualifier = 'TRK' " +
- " or c.qualifier = 'VW' " +
- " or c.qualifier = 'APP') " +
- " AND c.copy_component_uuid is NULL " +
- " {projectsCondition} " +
- " AND group_uuid IS NOT NULL " +
- " UNION " +
-
- // public projects are accessible to any one
-
- " SELECT '" + RowKind.ANYONE + "' as kind," +
- " c.uuid AS project, " +
- " c.qualifier AS qualifier, " +
- " NULL AS user_uuid, " +
- " NULL AS group_uuid " +
- " FROM components c " +
- " WHERE " +
- " (c.qualifier = 'TRK' " +
- " or c.qualifier = 'VW' " +
- " or c.qualifier = 'APP') " +
- " AND c.copy_component_uuid is NULL " +
- " AND c.private = ? " +
- " {projectsCondition} " +
- " UNION " +
-
- // private project is returned when no authorization
- " SELECT '" + RowKind.NONE + "' as kind," +
- " c.uuid AS project, " +
- " c.qualifier AS qualifier, " +
- " NULL AS user_uuid, " +
- " NULL AS group_uuid " +
- " FROM components c " +
- " WHERE " +
- " (c.qualifier = 'TRK' " +
- " or c.qualifier = 'VW' " +
- " or c.qualifier = 'APP') " +
- " AND c.copy_component_uuid is NULL " +
- " AND c.private = ? " +
- " {projectsCondition} " +
-
- " ) project_authorization";
+ private static final String SQL_TEMPLATE = """
+ with entity as ((select prj.uuid as uuid,
+ prj.private as isPrivate,
+ prj.qualifier as qualifier
+ from projects prj)
+ union
+ (select p.uuid as uuid,
+ p.private as isPrivate,
+ 'VW' as qualifier
+ from portfolios p
+ where p.parent_uuid is null))
+ SELECT entity_authorization.kind as kind,
+ entity_authorization.entity as entity,
+ entity_authorization.user_uuid as user_uuid,
+ entity_authorization.group_uuid as group_uuid,
+ entity_authorization.qualifier as qualifier
+ FROM (SELECT '%s' as kind,
+ e.uuid AS entity,
+ e.qualifier AS qualifier,
+ user_roles.user_uuid AS user_uuid,
+ NULL AS group_uuid
+ FROM entity e
+ INNER JOIN user_roles ON user_roles.component_uuid = e.uuid AND user_roles.role = 'user'
+ WHERE (1 = 1)
+ {entitiesCondition}
+ UNION
+ SELECT '%s' as kind, e.uuid AS entity, e.qualifier AS qualifier, NULL AS user_uuid, groups.uuid AS group_uuid
+ FROM entity e
+ INNER JOIN group_roles
+ ON group_roles.component_uuid = e.uuid AND group_roles.role = 'user'
+ INNER JOIN groups ON groups.uuid = group_roles.group_uuid
+ WHERE group_uuid IS NOT NULL
+ {entitiesCondition}
+ UNION
+ SELECT '%s' as kind, e.uuid AS entity, e.qualifier AS qualifier, NULL AS user_uuid, NULL AS group_uuid
+ FROM entity e
+ WHERE e.isPrivate = ?
+ {entitiesCondition}
+ UNION
+ SELECT '%s' as kind, e.uuid AS entity, e.qualifier AS qualifier, NULL AS user_uuid, NULL AS group_uuid
+ FROM entity e
+ WHERE e.isPrivate = ?
+ {entitiesCondition}
+ ) entity_authorization""".formatted(RowKind.USER, RowKind.GROUP, RowKind.ANYONE, RowKind.NONE);
List<IndexPermissions> selectAll(DbClient dbClient, DbSession session) {
- return doSelectByProjects(dbClient, session, Collections.emptyList());
+ return doSelectByEntities(dbClient, session, Collections.emptyList());
}
- public List<IndexPermissions> selectByUuids(DbClient dbClient, DbSession session, Collection<String> projectOrViewUuids) {
- // we use a smaller partitionSize because the SQL_TEMPLATE contain 4x the list of project uuid.
+ public List<IndexPermissions> selectByUuids(DbClient dbClient, DbSession session, Collection<String> entitiesUuid) {
+ // we use a smaller partitionSize because the SQL_TEMPLATE contain 4x the list of entity uuid.
// the MsSQL jdbc driver accept a maximum of 2100 prepareStatement parameter. To stay under the limit,
- // we go with batch of 1000/2=500 project uuids, to stay under the limit (4x500 < 2100)
- return executeLargeInputs(projectOrViewUuids, subProjectOrViewUuids -> doSelectByProjects(dbClient, session, subProjectOrViewUuids), i -> i / 2);
+ // we go with batch of 1000/2=500 entities uuids, to stay under the limit (4x500 < 2100)
+ return executeLargeInputs(entitiesUuid, entity -> doSelectByEntities(dbClient, session, entity), i -> i / 2);
}
- private static List<IndexPermissions> doSelectByProjects(DbClient dbClient, DbSession session, List<String> projectUuids) {
+ private static List<IndexPermissions> doSelectByEntities(DbClient dbClient, DbSession session, List<String> entitiesUuids) {
try {
- Map<String, IndexPermissions> dtosByProjectUuid = new HashMap<>();
- try (PreparedStatement stmt = createStatement(dbClient, session, projectUuids);
+ Map<String, IndexPermissions> dtosByEntityUuid = new HashMap<>();
+ try (PreparedStatement stmt = createStatement(dbClient, session, entitiesUuids);
ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
- processRow(rs, dtosByProjectUuid);
+ processRow(rs, dtosByEntityUuid);
}
- return ImmutableList.copyOf(dtosByProjectUuid.values());
+ return ImmutableList.copyOf(dtosByEntityUuid.values());
}
} catch (SQLException e) {
throw new IllegalStateException("Fail to select authorizations", e);
}
}
- private static PreparedStatement createStatement(DbClient dbClient, DbSession session, List<String> projectUuids) throws SQLException {
+ private static PreparedStatement createStatement(DbClient dbClient, DbSession session, List<String> entityUuids) throws SQLException {
String sql;
- if (projectUuids.isEmpty()) {
- sql = StringUtils.replace(SQL_TEMPLATE, "{projectsCondition}", "");
+ if (entityUuids.isEmpty()) {
+ sql = StringUtils.replace(SQL_TEMPLATE, "{entitiesCondition}", "");
} else {
- sql = StringUtils.replace(SQL_TEMPLATE, "{projectsCondition}", " AND c.uuid in (" + repeat("?", ", ", projectUuids.size()) + ")");
+ sql = StringUtils.replace(SQL_TEMPLATE, "{entitiesCondition}", " AND e.uuid in (" + repeat("?", ", ", entityUuids.size()) + ")");
}
PreparedStatement stmt = dbClient.getMyBatis().newScrollingSelectStatement(session, sql);
int index = 1;
// query for RowKind.USER
- index = populateProjectUuidPlaceholders(stmt, projectUuids, index);
+ index = populateEntityUuidPlaceholders(stmt, entityUuids, index);
// query for RowKind.GROUP
- index = populateProjectUuidPlaceholders(stmt, projectUuids, index);
+ index = populateEntityUuidPlaceholders(stmt, entityUuids, index);
// query for RowKind.ANYONE
- index = setPrivateProjectPlaceHolder(stmt, index, false);
- index = populateProjectUuidPlaceholders(stmt, projectUuids, index);
+ index = setPrivateEntityPlaceHolder(stmt, index, false);
+ index = populateEntityUuidPlaceholders(stmt, entityUuids, index);
// query for RowKind.NONE
- index = setPrivateProjectPlaceHolder(stmt, index, true);
- populateProjectUuidPlaceholders(stmt, projectUuids, index);
+ index = setPrivateEntityPlaceHolder(stmt, index, true);
+ populateEntityUuidPlaceholders(stmt, entityUuids, index);
return stmt;
}
- private static int populateProjectUuidPlaceholders(PreparedStatement stmt, List<String> projectUuids, int index) throws SQLException {
+ private static int populateEntityUuidPlaceholders(PreparedStatement stmt, List<String> entityUuids, int index) throws SQLException {
int newIndex = index;
- for (String projectUuid : projectUuids) {
- stmt.setString(newIndex, projectUuid);
+ for (String entityUuid : entityUuids) {
+ stmt.setString(newIndex, entityUuid);
newIndex++;
}
return newIndex;
}
- private static int setPrivateProjectPlaceHolder(PreparedStatement stmt, int index, boolean isPrivate) throws SQLException {
+ private static int setPrivateEntityPlaceHolder(PreparedStatement stmt, int index, boolean isPrivate) throws SQLException {
int newIndex = index;
stmt.setBoolean(newIndex, isPrivate);
newIndex++;
return newIndex;
}
- private static void processRow(ResultSet rs, Map<String, IndexPermissions> dtosByProjectUuid) throws SQLException {
+ private static void processRow(ResultSet rs, Map<String, IndexPermissions> dtosByEntityUuid) throws SQLException {
RowKind rowKind = RowKind.valueOf(rs.getString(1));
- String projectUuid = rs.getString(2);
+ String entityUuid = rs.getString(2);
- IndexPermissions dto = dtosByProjectUuid.get(projectUuid);
+ IndexPermissions dto = dtosByEntityUuid.get(entityUuid);
if (dto == null) {
String qualifier = rs.getString(5);
- dto = new IndexPermissions(projectUuid, qualifier);
- dtosByProjectUuid.put(projectUuid, dto);
+ dto = new IndexPermissions(entityUuid, qualifier);
+ dtosByEntityUuid.put(entityUuid, dto);
}
switch (rowKind) {
case NONE:
import org.sonar.api.utils.System2;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
-import org.sonar.db.component.ComponentDto;
+import org.sonar.db.entity.EntityDto;
import org.sonar.db.es.EsQueueDto;
+import org.sonar.db.portfolio.PortfolioDto;
+import org.sonar.db.project.ProjectDto;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.es.EsTester;
private static final IndexMainType INDEX_TYPE_FOO_AUTH = IndexType.main(FooIndexDefinition.DESCRIPTOR, TYPE_AUTHORIZATION);
@Rule
- public DbTester db = DbTester.create(System2.INSTANCE);
+ public DbTester db = DbTester.create(System2.INSTANCE, true);
@Rule
public EsTester es = EsTester.createCustom(new FooIndexDefinition());
@Rule
@Test
public void indexOnStartup_grants_access_to_any_user_and_to_group_Anyone_on_public_projects() {
- ComponentDto project = createAndIndexPublicProject();
+ ProjectDto project = createAndIndexPublicProject();
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
@Test
public void indexAll_grants_access_to_any_user_and_to_group_Anyone_on_public_projects() {
- ComponentDto project = createAndIndexPublicProject();
+ ProjectDto project = createAndIndexPublicProject();
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
@Test
public void deletion_resilience_will_deindex_projects() {
- ComponentDto project1 = createUnindexedPublicProject();
- ComponentDto project2 = createUnindexedPublicProject();
+ ProjectDto project1 = createUnindexedPublicProject();
+ ProjectDto project2 = createUnindexedPublicProject();
// UserDto user1 = db.users().insertUser();
indexOnStartup();
assertThat(es.countDocuments(INDEX_TYPE_FOO_AUTH)).isEqualTo(2);
// Simulate a indexation issue
- db.getDbClient().purgeDao().deleteProject(db.getSession(), project1.uuid(), PROJECT, project1.name(), project1.getKey());
- underTest.prepareForRecovery(db.getSession(), asList(project1.uuid()), ProjectIndexer.Cause.PROJECT_DELETION);
+ db.getDbClient().purgeDao().deleteProject(db.getSession(), project1.getUuid(), PROJECT, project1.getName(), project1.getKey());
+ underTest.prepareForRecovery(db.getSession(), asList(project1.getUuid()), ProjectIndexer.Cause.PROJECT_DELETION);
assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isOne();
Collection<EsQueueDto> esQueueDtos = db.getDbClient().esQueueDao().selectForRecovery(db.getSession(), Long.MAX_VALUE, 2);
@Test
public void indexOnStartup_grants_access_to_user() {
- ComponentDto project = createAndIndexPrivateProject();
+ ProjectDto project = createAndIndexPrivateProject();
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
db.users().insertProjectPermissionOnUser(user1, USER, project);
@Test
public void indexOnStartup_grants_access_to_group_on_private_project() {
- ComponentDto project = createAndIndexPrivateProject();
+ ProjectDto project = createAndIndexPrivateProject();
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
UserDto user3 = db.users().insertUser();
GroupDto group1 = db.users().insertGroup();
GroupDto group2 = db.users().insertGroup();
- db.users().insertProjectPermissionOnGroup(group1, USER, project);
- db.users().insertProjectPermissionOnGroup(group2, ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group1, USER, project);
+ db.users().insertEntityPermissionOnGroup(group2, ADMIN, project);
indexOnStartup();
@Test
public void indexOnStartup_grants_access_to_user_and_group() {
- ComponentDto project = createAndIndexPrivateProject();
+ ProjectDto project = createAndIndexPrivateProject();
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
GroupDto group = db.users().insertGroup();
db.users().insertMember(group, user2);
db.users().insertProjectPermissionOnUser(user1, USER, project);
- db.users().insertProjectPermissionOnGroup(group, USER, project);
+ db.users().insertEntityPermissionOnGroup(group, USER, project);
indexOnStartup();
@Test
public void indexOnStartup_does_not_grant_access_to_anybody_on_private_project() {
- ComponentDto project = createAndIndexPrivateProject();
+ ProjectDto project = createAndIndexPrivateProject();
UserDto user = db.users().insertUser();
GroupDto group = db.users().insertGroup();
@Test
public void indexOnStartup_grants_access_to_anybody_on_public_project() {
- ComponentDto project = createAndIndexPublicProject();
+ ProjectDto project = createAndIndexPublicProject();
UserDto user = db.users().insertUser();
GroupDto group = db.users().insertGroup();
@Test
public void indexOnStartup_grants_access_to_anybody_on_view() {
- ComponentDto view = createAndIndexView();
+ PortfolioDto view = createAndIndexPortfolio();
UserDto user = db.users().insertUser();
GroupDto group = db.users().insertGroup();
public void indexOnStartup_grants_access_on_many_projects() {
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
- ComponentDto project = null;
+ ProjectDto project = null;
for (int i = 0; i < 10; i++) {
project = createAndIndexPrivateProject();
db.users().insertProjectPermissionOnUser(user1, USER, project);
@Test
public void public_projects_are_visible_to_anybody() {
- ComponentDto projectOnOrg1 = createAndIndexPublicProject();
+ ProjectDto projectOnOrg1 = createAndIndexPublicProject();
UserDto user = db.users().insertUser();
indexOnStartup();
@Test
public void indexOnAnalysis_does_nothing_because_CE_does_not_touch_permissions() {
- ComponentDto project = createAndIndexPublicProject();
+ ProjectDto project = createAndIndexPublicProject();
- underTest.indexOnAnalysis(project.uuid());
+ underTest.indexOnAnalysis(project.getUuid());
assertThatAuthIndexHasSize(0);
verifyAnyoneNotAuthorized(project);
@Test
public void permissions_are_not_updated_on_project_tags_update() {
- ComponentDto project = createAndIndexPublicProject();
+ ProjectDto project = createAndIndexPublicProject();
indexPermissions(project, ProjectIndexer.Cause.PROJECT_TAGS_UPDATE);
@Test
public void permissions_are_not_updated_on_project_key_update() {
- ComponentDto project = createAndIndexPublicProject();
+ ProjectDto project = createAndIndexPublicProject();
indexPermissions(project, ProjectIndexer.Cause.PROJECT_TAGS_UPDATE);
@Test
public void index_permissions_on_project_creation() {
- ComponentDto project = createAndIndexPrivateProject();
+ ProjectDto project = createAndIndexPrivateProject();
UserDto user = db.users().insertUser();
db.users().insertProjectPermissionOnUser(user, USER, project);
@Test
public void index_permissions_on_permission_change() {
- ComponentDto project = createAndIndexPrivateProject();
+ ProjectDto project = createAndIndexPrivateProject();
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
db.users().insertProjectPermissionOnUser(user1, USER, project);
@Test
public void delete_permissions_on_project_deletion() {
- ComponentDto project = createAndIndexPrivateProject();
+ ProjectDto project = createAndIndexPrivateProject();
UserDto user = db.users().insertUser();
db.users().insertProjectPermissionOnUser(user, USER, project);
indexPermissions(project, ProjectIndexer.Cause.PROJECT_CREATION);
verifyAuthorized(project, user);
- db.getDbClient().purgeDao().deleteProject(db.getSession(), project.uuid(), PROJECT, project.name(), project.getKey());
+ db.getDbClient().purgeDao().deleteProject(db.getSession(), project.getUuid(), PROJECT, project.getUuid(), project.getKey());
indexPermissions(project, ProjectIndexer.Cause.PROJECT_DELETION);
verifyNotAuthorized(project, user);
@Test
public void errors_during_indexing_are_recovered() {
- ComponentDto project = createAndIndexPublicProject();
+ ProjectDto project = createAndIndexPublicProject();
es.lockWrites(INDEX_TYPE_FOO_AUTH);
IndexingResult result = indexPermissions(project, PERMISSION_CHANGE);
underTest.indexOnStartup(underTest.getIndexTypes());
}
- private void verifyAuthorized(ComponentDto project, UserDto user) {
+ private void verifyAuthorized(EntityDto entity, UserDto user) {
logIn(user);
- verifyAuthorized(project, true);
+ verifyAuthorized(entity, true);
}
- private void verifyAuthorized(ComponentDto project, UserDto user, GroupDto group) {
+ private void verifyAuthorized(EntityDto entity, UserDto user, GroupDto group) {
logIn(user).setGroups(group);
- verifyAuthorized(project, true);
+ verifyAuthorized(entity, true);
}
- private void verifyNotAuthorized(ComponentDto project, UserDto user) {
+ private void verifyNotAuthorized(EntityDto entity, UserDto user) {
logIn(user);
- verifyAuthorized(project, false);
+ verifyAuthorized(entity, false);
}
- private void verifyNotAuthorized(ComponentDto project, UserDto user, GroupDto group) {
+ private void verifyNotAuthorized(EntityDto entity, UserDto user, GroupDto group) {
logIn(user).setGroups(group);
- verifyAuthorized(project, false);
+ verifyAuthorized(entity, false);
}
- private void verifyAnyoneAuthorized(ComponentDto project) {
+ private void verifyAnyoneAuthorized(EntityDto entity) {
userSession.anonymous();
- verifyAuthorized(project, true);
+ verifyAuthorized(entity, true);
}
- private void verifyAnyoneNotAuthorized(ComponentDto project) {
+ private void verifyAnyoneNotAuthorized(EntityDto entity) {
userSession.anonymous();
- verifyAuthorized(project, false);
+ verifyAuthorized(entity, false);
}
- private void verifyAuthorized(ComponentDto project, boolean expectedAccess) {
- assertThat(fooIndex.hasAccessToProject(project.uuid())).isEqualTo(expectedAccess);
+ private void verifyAuthorized(EntityDto entity, boolean expectedAccess) {
+ assertThat(fooIndex.hasAccessToProject(entity.getUuid())).isEqualTo(expectedAccess);
}
private UserSessionRule logIn(UserDto u) {
return userSession;
}
- private IndexingResult indexPermissions(ComponentDto project, ProjectIndexer.Cause cause) {
+ private IndexingResult indexPermissions(EntityDto entity, ProjectIndexer.Cause cause) {
DbSession dbSession = db.getSession();
- Collection<EsQueueDto> items = underTest.prepareForRecovery(dbSession, singletonList(project.uuid()), cause);
+ Collection<EsQueueDto> items = underTest.prepareForRecovery(dbSession, singletonList(entity.getUuid()), cause);
dbSession.commit();
return underTest.index(dbSession, items);
}
- private ComponentDto createUnindexedPublicProject() {
- return db.components().insertPublicProject().getMainBranchComponent();
+ private ProjectDto createUnindexedPublicProject() {
+ return db.components().insertPublicProject().getProjectDto();
}
- private ComponentDto createAndIndexPrivateProject() {
- ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent();
- fooIndexer.indexOnAnalysis(project.uuid());
+ private ProjectDto createAndIndexPrivateProject() {
+ ProjectDto project = db.components().insertPrivateProject().getProjectDto();
+ fooIndexer.indexOnAnalysis(project.getUuid());
return project;
}
- private ComponentDto createAndIndexPublicProject() {
- ComponentDto project = db.components().insertPublicProject().getMainBranchComponent();
- fooIndexer.indexOnAnalysis(project.uuid());
+ private ProjectDto createAndIndexPublicProject() {
+ ProjectDto project = db.components().insertPublicProject().getProjectDto();
+ fooIndexer.indexOnAnalysis(project.getUuid());
return project;
}
- private ComponentDto createAndIndexView() {
- ComponentDto view = db.components().insertPublicPortfolio();
- fooIndexer.indexOnAnalysis(view.uuid());
+ private PortfolioDto createAndIndexPortfolio() {
+ PortfolioDto view = db.components().insertPublicPortfolioDto();
+ fooIndexer.indexOnAnalysis(view.getUuid());
return view;
}
import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.core.util.Uuids;
import org.sonar.db.DbTester;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.ProjectData;
import org.sonar.db.component.ResourceTypesRule;
import org.sonar.db.permission.GlobalPermission;
import org.sonar.db.permission.GroupPermissionDto;
private void applyRemovesPermissionFromGroupOnPrivateProject(String permission) {
GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group);
- db.users().insertProjectPermissionOnGroup(group, permission, privateProject);
+ db.users().insertEntityPermissionOnGroup(group, permission, privateProject);
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, privateProject, groupUuid, permissionService));
public void remove_project_permission_from_group() {
GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group);
db.users().insertPermissionOnGroup(group, ADMINISTER_QUALITY_GATES);
- db.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, privateProject);
- db.users().insertProjectPermissionOnGroup(group, UserRole.CODEVIEWER, privateProject);
+ db.users().insertEntityPermissionOnGroup(group, UserRole.ISSUE_ADMIN, privateProject);
+ db.users().insertEntityPermissionOnGroup(group, UserRole.CODEVIEWER, privateProject);
apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, privateProject, groupUuid, permissionService));
public void search_groups_with_project_permissions() {
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
GroupDto group = db.users().insertGroup("project-group-name");
- db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group, ISSUE_ADMIN, project);
ProjectDto anotherProject = db.components().insertPrivateProject().getProjectDto();
GroupDto anotherGroup = db.users().insertGroup("another-project-group-name");
- db.users().insertProjectPermissionOnGroup(anotherGroup, ISSUE_ADMIN, anotherProject);
+ db.users().insertEntityPermissionOnGroup(anotherGroup, ISSUE_ADMIN, anotherProject);
GroupDto groupWithoutPermission = db.users().insertGroup("group-without-permission");
public void return_also_groups_without_permission_when_search_query() {
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
GroupDto group = db.users().insertGroup("group-with-permission");
- db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group, ISSUE_ADMIN, project);
GroupDto groupWithoutPermission = db.users().insertGroup("group-without-permission");
GroupDto anotherGroup = db.users().insertGroup("another-group");
public void return_only_groups_with_permission_when_no_search_query() {
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
GroupDto group = db.users().insertGroup("project-group-name");
- db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group, ISSUE_ADMIN, project);
GroupDto groupWithoutPermission = db.users().insertGroup("group-without-permission");
public void return_anyone_group_when_search_query_and_no_param_permission() {
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
GroupDto group = db.users().insertGroup("group-with-permission");
- db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group, ISSUE_ADMIN, project);
loginAsAdmin();
String result = newRequest()
public void search_groups_on_views() {
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("view-uuid");
GroupDto group = db.users().insertGroup("project-group-name");
- db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, portfolio);
+ db.users().insertEntityPermissionOnGroup(group, ISSUE_ADMIN, portfolio);
loginAsAdmin();
String result = newRequest()
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("view-uuid");
GroupDto managedGroup = db.users().insertGroup("managed-group");
GroupDto localGroup = db.users().insertGroup("local-group");
- db.users().insertProjectPermissionOnGroup(managedGroup, ISSUE_ADMIN, portfolio);
- db.users().insertProjectPermissionOnGroup(localGroup, ISSUE_ADMIN, portfolio);
+ db.users().insertEntityPermissionOnGroup(managedGroup, ISSUE_ADMIN, portfolio);
+ db.users().insertEntityPermissionOnGroup(localGroup, ISSUE_ADMIN, portfolio);
mockGroupsAsManaged(managedGroup.getUuid());
loginAsAdmin();
public void wsAction_shouldRemoveProjectPermission() {
ProjectDto project = db.components().insertPublicProject().getProjectDto();
db.users().insertPermissionOnGroup(aGroup, GlobalPermission.ADMINISTER);
- db.users().insertProjectPermissionOnGroup(aGroup, UserRole.ADMIN, project);
- db.users().insertProjectPermissionOnGroup(aGroup, UserRole.ISSUE_ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(aGroup, UserRole.ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(aGroup, UserRole.ISSUE_ADMIN, project);
loginAsAdmin();
newRequest()
public void wsAction_whenUsingViewUuid_shouldRemovePermission() {
EntityDto portfolio = db.components().insertPrivatePortfolioDto();
db.users().insertPermissionOnGroup(aGroup, GlobalPermission.ADMINISTER);
- db.users().insertProjectPermissionOnGroup(aGroup, UserRole.ADMIN, portfolio);
- db.users().insertProjectPermissionOnGroup(aGroup, UserRole.ISSUE_ADMIN, portfolio);
+ db.users().insertEntityPermissionOnGroup(aGroup, UserRole.ADMIN, portfolio);
+ db.users().insertEntityPermissionOnGroup(aGroup, UserRole.ISSUE_ADMIN, portfolio);
loginAsAdmin();
newRequest()
public void wsAction_whenUsingProjectKey_shouldRemovePermission() {
ProjectDto project = db.components().insertPublicProject().getProjectDto();
db.users().insertPermissionOnGroup(aGroup, GlobalPermission.ADMINISTER);
- db.users().insertProjectPermissionOnGroup(aGroup, UserRole.ADMIN, project);
- db.users().insertProjectPermissionOnGroup(aGroup, UserRole.ISSUE_ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(aGroup, UserRole.ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(aGroup, UserRole.ISSUE_ADMIN, project);
loginAsAdmin();
newRequest()
@Test
public void wsAction_whenRemovingProjectPermissionAsProjectAdminButNotSystemAdmin_shouldRemovePermission() {
ProjectDto project = db.components().insertPrivateProject().getProjectDto();
- db.users().insertProjectPermissionOnGroup(aGroup, UserRole.CODEVIEWER, project);
- db.users().insertProjectPermissionOnGroup(aGroup, UserRole.ISSUE_ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(aGroup, UserRole.CODEVIEWER, project);
+ db.users().insertEntityPermissionOnGroup(aGroup, UserRole.ISSUE_ADMIN, project);
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
newRequest()
import org.sonar.api.web.UserRole;
import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.db.DbTester;
-import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ResourceTypesRule;
import org.sonar.db.entity.EntityDto;
import org.sonar.db.permission.PermissionQuery;
project = db.components().insertPrivateProject().getProjectDto();
db.users().insertProjectPermissionOnUser(user1, UserRole.ADMIN, project);
db.users().insertProjectPermissionOnUser(user2, UserRole.ADMIN, project);
- db.users().insertProjectPermissionOnGroup(group1, UserRole.ADMIN, project);
- db.users().insertProjectPermissionOnGroup(group2, UserRole.ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group1, UserRole.ADMIN, project);
+ db.users().insertEntityPermissionOnGroup(group2, UserRole.ADMIN, project);
}
@Test
GroupDto group1 = dbTester.users().insertGroup();
GroupDto group2 = dbTester.users().insertGroup();
GroupDto group3 = dbTester.users().insertGroup();
- dbTester.users().insertProjectPermissionOnGroup(group1, "p1", project);
- dbTester.users().insertProjectPermissionOnGroup(group1, "p2", project);
- dbTester.users().insertProjectPermissionOnGroup(group2, "p2", project);
+ dbTester.users().insertEntityPermissionOnGroup(group1, "p1", project);
+ dbTester.users().insertEntityPermissionOnGroup(group1, "p2", project);
+ dbTester.users().insertEntityPermissionOnGroup(group2, "p2", project);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
request.setParam(PARAM_PROJECT, project.getKey())
public void update_a_portfolio_to_private() {
PortfolioDto portfolio = dbTester.components().insertPublicPortfolioDto();
GroupDto group = dbTester.users().insertGroup();
- dbTester.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, portfolio);
+ dbTester.users().insertEntityPermissionOnGroup(group, UserRole.ISSUE_ADMIN, portfolio);
UserDto user = dbTester.users().insertUser();
dbTester.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, portfolio);
userSessionRule.addPortfolioPermission(UserRole.ADMIN, portfolio);
PortfolioDto portfolio = dbTester.components().insertPrivatePortfolioDto();
userSessionRule.addPortfolioPermission(UserRole.ADMIN, portfolio);
GroupDto group = dbTester.users().insertGroup();
- dbTester.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, portfolio);
- dbTester.users().insertProjectPermissionOnGroup(group, UserRole.USER, portfolio);
- dbTester.users().insertProjectPermissionOnGroup(group, UserRole.CODEVIEWER, portfolio);
+ dbTester.users().insertEntityPermissionOnGroup(group, UserRole.ISSUE_ADMIN, portfolio);
+ dbTester.users().insertEntityPermissionOnGroup(group, UserRole.USER, portfolio);
+ dbTester.users().insertEntityPermissionOnGroup(group, UserRole.CODEVIEWER, portfolio);
UserDto user = dbTester.users().insertUser();
dbTester.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, portfolio);
dbTester.users().insertProjectPermissionOnUser(user, UserRole.USER, portfolio);
public void update_an_application_to_private() {
ProjectDto application = dbTester.components().insertPublicApplication().getProjectDto();
GroupDto group = dbTester.users().insertGroup();
- dbTester.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, application);
+ dbTester.users().insertEntityPermissionOnGroup(group, UserRole.ISSUE_ADMIN, application);
UserDto user = dbTester.users().insertUser();
dbTester.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, application);
userSessionRule.addProjectPermission(UserRole.ADMIN, application);
ProjectDto application = dbTester.components().insertPrivateApplication().getProjectDto();
userSessionRule.addProjectPermission(UserRole.ADMIN, application);
GroupDto group = dbTester.users().insertGroup();
- dbTester.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, application);
- dbTester.users().insertProjectPermissionOnGroup(group, UserRole.USER, application);
- dbTester.users().insertProjectPermissionOnGroup(group, UserRole.CODEVIEWER, application);
+ dbTester.users().insertEntityPermissionOnGroup(group, UserRole.ISSUE_ADMIN, application);
+ dbTester.users().insertEntityPermissionOnGroup(group, UserRole.USER, application);
+ dbTester.users().insertEntityPermissionOnGroup(group, UserRole.CODEVIEWER, application);
UserDto user = dbTester.users().insertUser();
dbTester.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, application);
dbTester.users().insertProjectPermissionOnUser(user, UserRole.USER, application);