aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-auth-gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-auth-gitlab')
-rw-r--r--server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabSettings.java6
-rw-r--r--server/sonar-auth-gitlab/src/test/java/org/sonar/auth/gitlab/GitLabSettingsTest.java12
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");