diff options
author | Antoine Vigneau <antoine.vigneau@sonarsource.com> | 2024-08-11 23:14:17 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-08-16 20:02:59 +0000 |
commit | 632e1b44c4f2dae8e278e202932226d126afe6b1 (patch) | |
tree | db53eea5b361b6ffd09071796c1a452d2587e3c0 /server/sonar-server-common | |
parent | f7030b054783e5c4eefee9bbd7467988b46f9ba4 (diff) | |
download | sonarqube-632e1b44c4f2dae8e278e202932226d126afe6b1.tar.gz sonarqube-632e1b44c4f2dae8e278e202932226d126afe6b1.zip |
SONAR-22516 Fix BBT using email configuration
Diffstat (limited to 'server/sonar-server-common')
2 files changed, 4 insertions, 3 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java b/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java index 9948abe4f1d..f4005480631 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java @@ -321,7 +321,7 @@ public class EmailNotificationChannel extends NotificationChannel { } private void configureSecureConnection(Email email) { - if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "ssl")) { + if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "SSLTLS")) { email.setSSLOnConnect(true); email.setSSLCheckServerIdentity(true); email.setSslSmtpPort(String.valueOf(configuration.getSmtpPort())); @@ -329,12 +329,12 @@ public class EmailNotificationChannel extends NotificationChannel { // this port is not used except in EmailException message, that's why it's set with the same value than SSL port. // It prevents from getting bad message. email.setSmtpPort(configuration.getSmtpPort()); - } else if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "starttls")) { + } else if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "STARTTLS")) { email.setStartTLSEnabled(true); email.setStartTLSRequired(true); email.setSSLCheckServerIdentity(true); email.setSmtpPort(configuration.getSmtpPort()); - } else if (StringUtils.isBlank(configuration.getSecureConnection())) { + } else if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "NONE")) { email.setSmtpPort(configuration.getSmtpPort()); } else { throw new SonarException("Unknown type of SMTP secure connection: " + configuration.getSecureConnection()); diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/notification/email/EmailNotificationChannelTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/notification/email/EmailNotificationChannelTest.java index bd524e9e6a2..efff8f1b796 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/notification/email/EmailNotificationChannelTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/notification/email/EmailNotificationChannelTest.java @@ -378,6 +378,7 @@ public class EmailNotificationChannelTest { private void configure() { when(configuration.getSmtpHost()).thenReturn("localhost"); when(configuration.getSmtpPort()).thenReturn(smtpServer.getServer().getPort()); + when(configuration.getSecureConnection()).thenReturn("NONE"); when(configuration.getFrom()).thenReturn("server@nowhere"); when(configuration.getFromName()).thenReturn("SonarQube from NoWhere"); when(configuration.getPrefix()).thenReturn(SUBJECT_PREFIX); |