]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22559 Refactor submission of project permissions sync tasks
authorAurelien Poscia <aurelien.poscia@sonarsource.com>
Wed, 14 Aug 2024 12:24:00 +0000 (14:24 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 19 Aug 2024 20:02:45 +0000 (20:02 +0000)
server/sonar-auth-common/src/main/java/org/sonar/auth/DevOpsPlatformSettings.java
server/sonar-auth-github/src/it/java/org/sonar/auth/github/GitHubSettingsIT.java
server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubSettings.java
server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabSettings.java
server/sonar-auth-gitlab/src/test/java/org/sonar/auth/gitlab/GitLabSettingsTest.java

index 3c5b74fcb609ba24c4e7bd4c6f4e69742cb24a0c..42b4ae0cf3cd478c3acf0e2f03195cda2b7c867c 100644 (file)
@@ -29,4 +29,6 @@ public interface DevOpsPlatformSettings {
 
   boolean isUserConsentRequiredAfterUpgrade();
 
+  String getProjectsPermissionsProvisioningTaskName();
+
 }
index eab5384f3aa9cafa4ac5c53a04541c58b4dc2504..25b54b74705f75af94aa96cb6feefb5bee671fd0 100644 (file)
@@ -39,6 +39,7 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.sonar.auth.github.GitHubSettings.GITHUB_PROVISION_PROJECT_VISIBILITY;
 import static org.sonar.auth.github.GitHubSettings.GITHUB_USER_CONSENT_FOR_PERMISSIONS_REQUIRED_AFTER_UPGRADE;
+import static org.sonar.db.ce.CeTaskTypes.GITHUB_PROJECT_PERMISSIONS_PROVISIONING;
 
 public class GitHubSettingsIT {
   @Rule
@@ -313,4 +314,10 @@ public class GitHubSettingsIT {
     settings.setProperty("sonar.auth.github.appId", "id");
     settings.setProperty("sonar.auth.github.privateKey.secured", "secret");
   }
+
+  @Test
+  public void getProjectsPermissionsProvisioningTaskName_returnsCorrectTaskName() {
+    assertThat(underTest.getProjectsPermissionsProvisioningTaskName()).isEqualTo(GITHUB_PROJECT_PERMISSIONS_PROVISIONING);
+  }
+
 }
index e98af18b583c9ac79dd6f91364f941f569c4ab34..a5b3e0b4d817a7e74653fda077b9f753fcf2c777 100644 (file)
@@ -42,6 +42,7 @@ import static org.sonar.api.PropertyType.BOOLEAN;
 import static org.sonar.api.PropertyType.PASSWORD;
 import static org.sonar.api.PropertyType.STRING;
 import static org.sonar.api.utils.Preconditions.checkState;
+import static org.sonar.db.ce.CeTaskTypes.GITHUB_PROJECT_PERMISSIONS_PROVISIONING;
 
 @ServerSide
 @ComputeEngineSide
@@ -173,6 +174,11 @@ public class GitHubSettings implements DevOpsPlatformSettings {
     return configuration.get(GITHUB_USER_CONSENT_FOR_PERMISSIONS_REQUIRED_AFTER_UPGRADE).isPresent();
   }
 
+  @Override
+  public String getProjectsPermissionsProvisioningTaskName() {
+    return GITHUB_PROJECT_PERMISSIONS_PROVISIONING;
+  }
+
   @Override
   public boolean isProjectVisibilitySynchronizationActivated() {
     return configuration.getBoolean(GITHUB_PROVISION_PROJECT_VISIBILITY).orElse(true);
index 5a14cb14fde2023a40ff7e935ffa15d7e647df0d..d94d4a238bcbcb8d5ed6342f38fffdc1ce57bc60 100644 (file)
@@ -33,6 +33,7 @@ import org.sonar.db.alm.setting.ALM;
 import static java.lang.String.valueOf;
 import static org.sonar.api.PropertyType.BOOLEAN;
 import static org.sonar.api.PropertyType.PASSWORD;
+import static org.sonar.db.ce.CeTaskTypes.GITLAB_PROJECT_PERMISSIONS_PROVISIONING;
 
 @ComputeEngineSide
 public class GitLabSettings implements DevOpsPlatformSettings {
@@ -117,6 +118,11 @@ public class GitLabSettings implements DevOpsPlatformSettings {
     return configuration.getBoolean(GITLAB_USER_CONSENT_FOR_PERMISSION_PROVISIONING_REQUIRED).isPresent();
   }
 
+  @Override
+  public String getProjectsPermissionsProvisioningTaskName() {
+    return GITLAB_PROJECT_PERMISSIONS_PROVISIONING;
+  }
+
   static List<PropertyDefinition> definitions() {
     return Arrays.asList(
       PropertyDefinition.builder(GITLAB_AUTH_ENABLED)
index 2c21df6171aaff189f39e859b6a0d275cf1178ee..aea7215f05fac2a3aa3de1b12ef90e11f5b5fb70 100644 (file)
@@ -36,6 +36,7 @@ import static org.sonar.auth.gitlab.GitLabSettings.GITLAB_AUTH_SECRET;
 import static org.sonar.auth.gitlab.GitLabSettings.GITLAB_AUTH_SYNC_USER_GROUPS;
 import static org.sonar.auth.gitlab.GitLabSettings.GITLAB_AUTH_URL;
 import static org.sonar.auth.gitlab.GitLabSettings.GITLAB_USER_CONSENT_FOR_PERMISSION_PROVISIONING_REQUIRED;
+import static org.sonar.db.ce.CeTaskTypes.GITLAB_PROJECT_PERMISSIONS_PROVISIONING;
 
 public class GitLabSettingsTest {
 
@@ -134,6 +135,11 @@ public class GitLabSettingsTest {
     assertThat(config.isUserConsentRequiredAfterUpgrade()).isTrue();
   }
 
+  @Test
+  public void getProjectsPermissionsProvisioningTaskName_returnsCorrectTaskName() {
+    assertThat(config.getProjectsPermissionsProvisioningTaskName()).isEqualTo(GITLAB_PROJECT_PERMISSIONS_PROVISIONING);
+  }
+
   private void enableGitlabAuthentication() {
     settings.setProperty(GITLAB_AUTH_ENABLED, true);
     settings.setProperty(GITLAB_AUTH_APPLICATION_ID, "on");