diff options
author | Nolwenn Cadic <98824442+Nolwenn-cadic-sonarsource@users.noreply.github.com> | 2024-07-25 09:00:10 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-07-25 20:02:51 +0000 |
commit | 9f614fdbf0fe66eec11ece07a98e7ad056476be1 (patch) | |
tree | 546f11effd8783e030719f82842b05050010653b /server/sonar-auth-gitlab | |
parent | f2f826c4e98af4ca1996c07873e60095d23f79bd (diff) | |
download | sonarqube-9f614fdbf0fe66eec11ece07a98e7ad056476be1.tar.gz sonarqube-9f614fdbf0fe66eec11ece07a98e7ad056476be1.zip |
SONAR-22596 Fail Gitlab sync task if user consent is needed
Diffstat (limited to 'server/sonar-auth-gitlab')
-rw-r--r-- | server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabSettings.java | 6 | ||||
-rw-r--r-- | server/sonar-auth-gitlab/src/test/java/org/sonar/auth/gitlab/GitLabSettingsTest.java | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabSettings.java b/server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabSettings.java index feef4ed823b..5a14cb14fde 100644 --- a/server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabSettings.java +++ b/server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabSettings.java @@ -46,6 +46,7 @@ public class GitLabSettings implements DevOpsPlatformSettings { public static final String GITLAB_AUTH_SYNC_USER_GROUPS = "sonar.auth.gitlab.groupsSync"; public static final String GITLAB_AUTH_PROVISIONING_TOKEN = "provisioning.gitlab.token.secured"; public static final String GITLAB_AUTH_PROVISIONING_ENABLED = "provisioning.gitlab.enabled"; + public static final String GITLAB_USER_CONSENT_FOR_PERMISSION_PROVISIONING_REQUIRED = "sonar.auth.gitlab.userConsentForPermissionProvisioningRequired"; private static final String CATEGORY = "authentication"; private static final String SUBCATEGORY = "gitlab"; @@ -111,6 +112,11 @@ public class GitLabSettings implements DevOpsPlatformSettings { return true; } + @Override + public boolean isUserConsentRequiredAfterUpgrade() { + return configuration.getBoolean(GITLAB_USER_CONSENT_FOR_PERMISSION_PROVISIONING_REQUIRED).isPresent(); + } + static List<PropertyDefinition> definitions() { return Arrays.asList( PropertyDefinition.builder(GITLAB_AUTH_ENABLED) diff --git a/server/sonar-auth-gitlab/src/test/java/org/sonar/auth/gitlab/GitLabSettingsTest.java b/server/sonar-auth-gitlab/src/test/java/org/sonar/auth/gitlab/GitLabSettingsTest.java index 9a732f4d04c..2c21df6171a 100644 --- a/server/sonar-auth-gitlab/src/test/java/org/sonar/auth/gitlab/GitLabSettingsTest.java +++ b/server/sonar-auth-gitlab/src/test/java/org/sonar/auth/gitlab/GitLabSettingsTest.java @@ -35,6 +35,7 @@ import static org.sonar.auth.gitlab.GitLabSettings.GITLAB_AUTH_PROVISIONING_TOKE 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; public class GitLabSettingsTest { @@ -122,6 +123,17 @@ public class GitLabSettingsTest { assertThat(config.isProjectVisibilitySynchronizationActivated()).isTrue(); } + @Test + public void isUserConsentRequiredForPermissionProvisioning_returnsFalseByDefault() { + assertThat(config.isUserConsentRequiredAfterUpgrade()).isFalse(); + } + + @Test + public void isUserConsentRequiredForPermissionProvisioning_returnsTrueWhenPropertyPresent() { + settings.setProperty(GITLAB_USER_CONSENT_FOR_PERMISSION_PROVISIONING_REQUIRED, ""); + assertThat(config.isUserConsentRequiredAfterUpgrade()).isTrue(); + } + private void enableGitlabAuthentication() { settings.setProperty(GITLAB_AUTH_ENABLED, true); settings.setProperty(GITLAB_AUTH_APPLICATION_ID, "on"); |