diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2024-11-27 10:48:57 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-11-27 20:02:57 +0000 |
commit | 67779bbfb3c304bdfd658accc0b4e05c5511ce7b (patch) | |
tree | f70305dd22b9279de13173dd185e1e3062997641 /sonar-scanner-engine/src/test | |
parent | 06c1c1193c492979b84a985403ca67c3d70c4ce6 (diff) | |
download | sonarqube-67779bbfb3c304bdfd658accc0b4e05c5511ce7b.tar.gz sonarqube-67779bbfb3c304bdfd658accc0b4e05c5511ce7b.zip |
SONAR-23774 Add a scanner property to disable loading of OS-level SSL certificates
Diffstat (limited to 'sonar-scanner-engine/src/test')
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java index b041be11fbb..63a52e51cd7 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java @@ -42,7 +42,9 @@ import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.junitpioneer.jupiter.RestoreSystemProperties; +import org.slf4j.event.Level; import org.sonar.api.notifications.AnalysisWarnings; +import org.sonar.api.testfixtures.log.LogTesterJUnit5; import org.sonar.api.utils.System2; import org.sonar.batch.bootstrapper.EnvironmentInformation; import org.sonar.scanner.bootstrap.GlobalAnalysisMode; @@ -72,6 +74,10 @@ class ScannerWsClientProviderTest { private static final GlobalAnalysisMode GLOBAL_ANALYSIS_MODE = new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap())); private static final AnalysisWarnings ANALYSIS_WARNINGS = warning -> { }; + + @RegisterExtension + private LogTesterJUnit5 logTester = new LogTesterJUnit5(); + private SonarUserHome sonarUserHome = mock(SonarUserHome.class); private final Map<String, String> scannerProps = new HashMap<>(); @@ -114,6 +120,25 @@ class ScannerWsClientProviderTest { assertThat(httpConnector.okHttpClient().proxy()).isNull(); } + @Test + void should_load_os_certificates_by_default() { + logTester.setLevel(Level.DEBUG); + + underTest.provide(new ScannerProperties(scannerProps), env, GLOBAL_ANALYSIS_MODE, system2, ANALYSIS_WARNINGS, sonarUserHome); + + assertThat(logTester.logs(Level.DEBUG)).contains("Loading OS trusted SSL certificates..."); + } + + @Test + void should_skip_load_of_os_certificates_if_props_set() { + logTester.setLevel(Level.DEBUG); + scannerProps.put("sonar.scanner.skipSystemTruststore", "true"); + + underTest.provide(new ScannerProperties(scannerProps), env, GLOBAL_ANALYSIS_MODE, system2, ANALYSIS_WARNINGS, sonarUserHome); + + assertThat(logTester.logs(Level.DEBUG)).doesNotContain("Loading OS trusted SSL certificates..."); + } + @ParameterizedTest @CsvSource({ "keystore_changeit.p12, wrong, false", |