aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-auth
diff options
context:
space:
mode:
authorAurelien Poscia <aurelien.poscia@sonarsource.com>2023-10-16 10:14:56 +0200
committersonartech <sonartech@sonarsource.com>2023-10-20 20:02:40 +0000
commitf5f71fdbe1482d7b132a9923419672459d762aad (patch)
tree70fa662e0dc4811e90ea64f3cf2a2eace0fb1d3f /server/sonar-webserver-auth
parent30f01907496dbda0b3d177748501dc2f0833813f (diff)
downloadsonarqube-f5f71fdbe1482d7b132a9923419672459d762aad.tar.gz
sonarqube-f5f71fdbe1482d7b132a9923419672459d762aad.zip
SONAR-20700 Move GithubPermissionConverter to community edition
Diffstat (limited to 'server/sonar-webserver-auth')
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionService.java30
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java74
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/permission/PermissionServiceImplTest.java45
3 files changed, 0 insertions, 149 deletions
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionService.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionService.java
deleted file mode 100644
index 2f2dc87a3c7..00000000000
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.permission;
-
-import java.util.List;
-import org.sonar.db.permission.GlobalPermission;
-
-public interface PermissionService {
-
- List<GlobalPermission> getGlobalPermissions();
- List<String> getAllProjectPermissions();
-
-}
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java
deleted file mode 100644
index 30514238375..00000000000
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.permission;
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import javax.annotation.concurrent.Immutable;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.ResourceTypes;
-import org.sonar.api.web.UserRole;
-import org.sonar.db.permission.GlobalPermission;
-
-@Immutable
-public class PermissionServiceImpl implements PermissionService {
- public static final Set<String> ALL_PROJECT_PERMISSIONS = Collections.unmodifiableSet(new LinkedHashSet<>(List.of(
- UserRole.ADMIN,
- UserRole.CODEVIEWER,
- UserRole.ISSUE_ADMIN,
- UserRole.SECURITYHOTSPOT_ADMIN,
- UserRole.SCAN,
- UserRole.USER
- )));
-
- private static final List<GlobalPermission> ALL_GLOBAL_PERMISSIONS = List.of(GlobalPermission.values());
-
- private final List<GlobalPermission> globalPermissions;
- private final List<String> projectPermissions;
-
- public PermissionServiceImpl(ResourceTypes resourceTypes) {
- globalPermissions = List.copyOf(ALL_GLOBAL_PERMISSIONS.stream()
- .filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR) || resourceTypes.isQualifierPresent(Qualifiers.APP))
- .filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR) || resourceTypes.isQualifierPresent(Qualifiers.VIEW))
- .toList());
- projectPermissions = List.copyOf(ALL_PROJECT_PERMISSIONS.stream()
- .filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR.getKey()) || resourceTypes.isQualifierPresent(Qualifiers.APP))
- .filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR.getKey()) || resourceTypes.isQualifierPresent(Qualifiers.VIEW))
- .toList());
- }
-
- /**
- * Return an immutable Set of all permissions
- */
- @Override
- public List<GlobalPermission> getGlobalPermissions() {
- return globalPermissions;
- }
-
- /**
- * Return an immutable Set of all project permissions
- */
- @Override
- public List<String> getAllProjectPermissions() {
- return projectPermissions;
- }
-}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/permission/PermissionServiceImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/permission/PermissionServiceImplTest.java
deleted file mode 100644
index eec2167f3c4..00000000000
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/permission/PermissionServiceImplTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.permission;
-
-import org.junit.Test;
-import org.sonar.db.component.ResourceTypesRule;
-import org.sonar.db.permission.GlobalPermission;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class PermissionServiceImplTest {
-
- private ResourceTypesRule resourceTypesRule = new ResourceTypesRule().setRootQualifiers("APP", "VW");
- private PermissionServiceImpl underTest = new PermissionServiceImpl(resourceTypesRule);
-
- @Test
- public void globalPermissions_must_be_ordered() {
- assertThat(underTest.getGlobalPermissions())
- .extracting(GlobalPermission::getKey)
- .containsExactly("admin", "gateadmin", "profileadmin", "provisioning", "scan", "applicationcreator", "portfoliocreator");
- }
-
- @Test
- public void projectPermissions_must_be_ordered() {
- assertThat(underTest.getAllProjectPermissions())
- .containsExactly("admin", "codeviewer", "issueadmin", "securityhotspotadmin", "scan", "user");
- }
-}