private static final Logger LOG = Loggers.get(DeprecatedPropertiesWarningGenerator.class);
@VisibleForTesting
- static final String CREDENTIALS_WARN_MESSAGE = String.format("The properties '%s' and '%s' are deprecated. They will not be supported " +
- "in the future. Please instead use the '%s' parameter.", CoreProperties.LOGIN, CoreProperties.PASSWORD, ScannerWsClientProvider.TOKEN_PROPERTY);
+ static final String PASSWORD_WARN_MESSAGE = String.format("The properties '%s' and '%s' are deprecated and will be removed in the " +
+ "future. Please pass a token with the '%s' property instead.", CoreProperties.LOGIN, CoreProperties.PASSWORD,
+ ScannerWsClientProvider.TOKEN_PROPERTY);
+ @VisibleForTesting
+ static final String LOGIN_WARN_MESSAGE = String.format("The property '%s' is deprecated and will be removed in the future. " +
+ "Please use the '%s' property instead when passing a token.", CoreProperties.LOGIN, ScannerWsClientProvider.TOKEN_PROPERTY);
private final Configuration configuration;
private final AnalysisWarnings analysisWarnings;
public void execute() {
Optional<String> login = configuration.get(CoreProperties.LOGIN);
Optional<String> password = configuration.get(CoreProperties.PASSWORD);
- if (login.isPresent() || password.isPresent()) {
- LOG.warn(CREDENTIALS_WARN_MESSAGE);
- analysisWarnings.addUnique(CREDENTIALS_WARN_MESSAGE);
+ if (password.isPresent()) {
+ LOG.warn(PASSWORD_WARN_MESSAGE);
+ analysisWarnings.addUnique(PASSWORD_WARN_MESSAGE);
+ } else if (login.isPresent()) {
+ LOG.warn(LOGIN_WARN_MESSAGE);
+ analysisWarnings.addUnique(LOGIN_WARN_MESSAGE);
}
}
-
}
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
-import static org.sonar.scanner.scan.DeprecatedPropertiesWarningGenerator.CREDENTIALS_WARN_MESSAGE;
+import static org.sonar.scanner.scan.DeprecatedPropertiesWarningGenerator.LOGIN_WARN_MESSAGE;
+import static org.sonar.scanner.scan.DeprecatedPropertiesWarningGenerator.PASSWORD_WARN_MESSAGE;
public class DeprecatedPropertiesWarningGeneratorTest {
underTest.execute();
- verify(analysisWarnings, times(1)).addUnique(CREDENTIALS_WARN_MESSAGE);
- Assertions.assertThat(logger.logs(LoggerLevel.WARN)).contains(CREDENTIALS_WARN_MESSAGE);
+ verify(analysisWarnings, times(1)).addUnique(LOGIN_WARN_MESSAGE);
+ Assertions.assertThat(logger.logs(LoggerLevel.WARN)).contains(LOGIN_WARN_MESSAGE);
}
@Test
public void execute_whenUsingPassword_shouldAddWarning() {
+ settings.setProperty(CoreProperties.LOGIN, "test");
settings.setProperty(CoreProperties.PASSWORD, "winner winner chicken dinner");
underTest.execute();
- verify(analysisWarnings, times(1)).addUnique(CREDENTIALS_WARN_MESSAGE);
- Assertions.assertThat(logger.logs(LoggerLevel.WARN)).contains(CREDENTIALS_WARN_MESSAGE);
+ verify(analysisWarnings, times(1)).addUnique(PASSWORD_WARN_MESSAGE);
+ Assertions.assertThat(logger.logs(LoggerLevel.WARN)).contains(PASSWORD_WARN_MESSAGE);
}
@Test