|
65 | 65 | import static org.mockito.Mockito.verify;
|
66 | 66 | import static org.mockito.Mockito.when;
|
67 | 67 | import static org.sonarsource.scanner.lib.ScannerEngineBootstrapper.SQ_VERSION_NEW_BOOTSTRAPPING;
|
| 68 | +import static org.sonarsource.scanner.lib.ScannerEngineBootstrapper.SQ_VERSION_TOKEN_AUTHENTICATION; |
68 | 69 |
|
69 | 70 | class ScannerEngineBootstrapperTest {
|
70 | 71 |
|
@@ -122,6 +123,29 @@ void should_use_new_bootstrapping_with_sonarqube_10_6() throws Exception {
|
122 | 123 | assertThat(bootstrapResult.getEngineFacade().isSonarCloud()).isFalse();
|
123 | 124 | verifySonarQubeServerTypeLogged(SQ_VERSION_NEW_BOOTSTRAPPING);
|
124 | 125 | assertThat(bootstrapResult.getEngineFacade().getServerVersion()).isEqualTo(SQ_VERSION_NEW_BOOTSTRAPPING);
|
| 126 | + assertThat(logTester.logs(Level.WARN)).isEmpty(); |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + @Test |
| 131 | + void should_issue_deprecation_warning_for_sonar_login_property_sonarqube_10_0() throws Exception { |
| 132 | + IsolatedLauncherFactory launcherFactory = mock(IsolatedLauncherFactory.class); |
| 133 | + when(launcherFactory.createLauncher(eq(scannerHttpClient), any(FileCache.class))) |
| 134 | + .thenReturn(mock(IsolatedLauncherFactory.IsolatedLauncherAndClassloader.class)); |
| 135 | + |
| 136 | + ScannerEngineBootstrapper bootstrapper = new ScannerEngineBootstrapper("Gradle", "3.1", system, scannerHttpClient, |
| 137 | + launcherFactory, scannerEngineLauncherFactory); |
| 138 | + when(scannerHttpClient.callRestApi("/analysis/version")).thenThrow(new HttpException(URI.create("http://myserver").toURL(), 404, "Not Found", null)); |
| 139 | + when(scannerHttpClient.callWebApi("/api/server/version")).thenReturn(SQ_VERSION_TOKEN_AUTHENTICATION); |
| 140 | + |
| 141 | + try (var bootstrapResult = bootstrapper.setBootstrapProperty(ScannerProperties.HOST_URL, "http://localhost").setBootstrapProperty(ScannerProperties.SONAR_LOGIN, |
| 142 | + "mockTokenValue").bootstrap()) { |
| 143 | + verify(launcherFactory).createLauncher(eq(scannerHttpClient), any(FileCache.class)); |
| 144 | + assertThat(bootstrapResult.getEngineFacade().isSonarCloud()).isFalse(); |
| 145 | + assertThat(logTester.logs(Level.WARN)).contains("Use of sonar.login property has been deprecated in favor of sonar.token. Please use the sonar.token property when passing " + |
| 146 | + "a token."); |
| 147 | + verifySonarQubeServerTypeLogged(SQ_VERSION_TOKEN_AUTHENTICATION); |
| 148 | + assertThat(bootstrapResult.getEngineFacade().getServerVersion()).isEqualTo(SQ_VERSION_TOKEN_AUTHENTICATION); |
125 | 149 | }
|
126 | 150 | }
|
127 | 151 |
|
|
0 commit comments