diff options
author | Aurelien Poscia <aurelien.poscia@sonarsource.com> | 2023-12-22 08:39:03 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-01-18 20:03:23 +0000 |
commit | 75f56ca6f7464ac834cae1f23bbdde838327e996 (patch) | |
tree | d972be1f2a01ef4b16b3b8804d5f8ca3547beb9c /server/sonar-webserver-common | |
parent | f9deebc4558057ca6f1a521152e56527a9a0112c (diff) | |
download | sonarqube-75f56ca6f7464ac834cae1f23bbdde838327e996.tar.gz sonarqube-75f56ca6f7464ac834cae1f23bbdde838327e996.zip |
SONAR-21121 Add GitLab provisioning ITs for groups and groups membership
Diffstat (limited to 'server/sonar-webserver-common')
2 files changed, 11 insertions, 2 deletions
diff --git a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/gitlab/config/GitlabConfigurationServiceIT.java b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/gitlab/config/GitlabConfigurationServiceIT.java index 6086c2cdcdd..e50fffe47e6 100644 --- a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/gitlab/config/GitlabConfigurationServiceIT.java +++ b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/gitlab/config/GitlabConfigurationServiceIT.java @@ -39,6 +39,7 @@ import org.sonar.db.user.ExternalGroupDto; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.management.ManagedInstanceService; +import org.sonar.server.setting.ThreadLocalSettings; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -82,6 +83,9 @@ public class GitlabConfigurationServiceIT { @Mock private GitlabGlobalSettingsValidator gitlabGlobalSettingsValidator; + @Mock + private ThreadLocalSettings threadLocalSettings; + private GitlabConfigurationService gitlabConfigurationService; @Before @@ -90,7 +94,8 @@ public class GitlabConfigurationServiceIT { gitlabConfigurationService = new GitlabConfigurationService( dbTester.getDbClient(), managedInstanceService, - gitlabGlobalSettingsValidator); + gitlabGlobalSettingsValidator, + threadLocalSettings); } @Test diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/gitlab/config/GitlabConfigurationService.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/gitlab/config/GitlabConfigurationService.java index 0f2fbaf88fd..5df75318455 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/gitlab/config/GitlabConfigurationService.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/gitlab/config/GitlabConfigurationService.java @@ -36,6 +36,7 @@ import org.sonar.server.common.UpdatedValue; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.management.ManagedInstanceService; +import org.sonar.server.setting.ThreadLocalSettings; import static java.lang.String.format; import static org.apache.commons.lang.StringUtils.isNotBlank; @@ -73,12 +74,14 @@ public class GitlabConfigurationService { private final DbClient dbClient; private final ManagedInstanceService managedInstanceService; private final GitlabGlobalSettingsValidator gitlabGlobalSettingsValidator; + private final ThreadLocalSettings threadLocalSettings; public GitlabConfigurationService(DbClient dbClient, - ManagedInstanceService managedInstanceService, GitlabGlobalSettingsValidator gitlabGlobalSettingsValidator) { + ManagedInstanceService managedInstanceService, GitlabGlobalSettingsValidator gitlabGlobalSettingsValidator, ThreadLocalSettings threadLocalSettings) { this.dbClient = dbClient; this.managedInstanceService = managedInstanceService; this.gitlabGlobalSettingsValidator = gitlabGlobalSettingsValidator; + this.threadLocalSettings = threadLocalSettings; } public GitlabConfiguration updateConfiguration(UpdateGitlabConfigurationRequest updateRequest) { @@ -112,6 +115,7 @@ public class GitlabConfigurationService { value .map(definedValue -> new PropertyDto().setKey(propertyName).setValue(definedValue)) .applyIfDefined(property -> dbClient.propertiesDao().saveProperty(dbSession, property)); + threadLocalSettings.setProperty(propertyName, value.orElse(null)); } private void deleteExternalGroupsWhenDisablingAutoProvisioning( |