use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.
the class AddGroupAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
GroupIdOrAnyone group = support.findGroup(dbSession, request);
Optional<ProjectId> projectId = support.findProjectId(dbSession, request);
checkProjectAdmin(userSession, group.getOrganizationUuid(), projectId);
PermissionChange change = new GroupPermissionChange(PermissionChange.Operation.ADD, request.mandatoryParam(PARAM_PERMISSION), projectId.orElse(null), group);
permissionUpdater.apply(dbSession, asList(change));
}
response.noContent();
}
use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.
the class RemoveGroupFromTemplateAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
String permission = request.mandatoryParam(PARAM_PERMISSION);
PermissionTemplateDto template = wsSupport.findTemplate(dbSession, WsTemplateRef.fromRequest(request));
checkGlobalAdmin(userSession, template.getOrganizationUuid());
GroupIdOrAnyone groupId = wsSupport.findGroup(dbSession, request);
checkArgument(groupId.getOrganizationUuid().equals(template.getOrganizationUuid()), "Group and template are on different organizations");
dbClient.permissionTemplateDao().deleteGroupPermission(dbSession, template.getId(), groupId.getId(), permission);
dbSession.commit();
}
response.noContent();
}
use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.
the class GroupPermissionChangerTest method do_not_fail_if_removing_a_permission_that_does_not_exist.
@Test
public void do_not_fail_if_removing_a_permission_that_does_not_exist() {
GroupIdOrAnyone groupId = new GroupIdOrAnyone(group);
apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
assertThat(db.users().selectGroupPermissions(group, null)).isEmpty();
assertThat(db.users().selectGroupPermissions(group, project)).isEmpty();
}
use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.
the class GroupPermissionChangerTest method add_permission_to_anyone.
@Test
public void add_permission_to_anyone() {
OrganizationDto defaultOrganization = db.getDefaultOrganization();
GroupIdOrAnyone groupId = new GroupIdOrAnyone(defaultOrganization.getUuid(), null);
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupId));
assertThat(db.users().selectGroupPermissions(group, null)).isEmpty();
assertThat(db.users().selectAnyonePermissions(defaultOrganization, null)).containsOnly(GlobalPermissions.QUALITY_GATE_ADMIN);
}
use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.
the class GroupPermissionChangerTest method add_permission_to_group.
@Test
public void add_permission_to_group() {
GroupIdOrAnyone groupId = new GroupIdOrAnyone(group);
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupId));
assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(GlobalPermissions.QUALITY_GATE_ADMIN);
}
Aggregations