[KEYCLOAK-6015] replyTo can be empty string in DB
This commit is contained in:
parent
b672229efc
commit
1a541889f4
2 changed files with 9 additions and 6 deletions
|
@ -120,10 +120,10 @@ public class DefaultEmailSenderProvider implements EmailSenderProvider {
|
||||||
msg.setFrom(toInternetAddress(from, fromDisplayName));
|
msg.setFrom(toInternetAddress(from, fromDisplayName));
|
||||||
|
|
||||||
msg.setReplyTo(new Address[]{toInternetAddress(from, fromDisplayName)});
|
msg.setReplyTo(new Address[]{toInternetAddress(from, fromDisplayName)});
|
||||||
if (replyTo != null) {
|
if (replyTo != null && !replyTo.isEmpty()) {
|
||||||
msg.setReplyTo(new Address[]{toInternetAddress(replyTo, replyToDisplayName)});
|
msg.setReplyTo(new Address[]{toInternetAddress(replyTo, replyToDisplayName)});
|
||||||
}
|
}
|
||||||
if (envelopeFrom != null) {
|
if (envelopeFrom != null && !envelopeFrom.isEmpty()) {
|
||||||
msg.setEnvelopeFrom(envelopeFrom);
|
msg.setEnvelopeFrom(envelopeFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,12 @@ public class SMTPConnectionTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
private String settings(String host, String port, String from, String auth, String ssl, String starttls,
|
private String settings(String host, String port, String from, String auth, String ssl, String starttls,
|
||||||
String username, String password) throws Exception {
|
String username, String password) throws Exception {
|
||||||
Map<String, String> config = smtpMap(host, port, from, auth, ssl, starttls, username, password);
|
Map<String, String> config = smtpMap(host, port, from, auth, ssl, starttls, username, password, "", "");
|
||||||
return writeValueAsPrettyString(config);
|
return writeValueAsPrettyString(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> smtpMap(String host, String port, String from, String auth, String ssl, String starttls, String username, String password) {
|
private Map<String, String> smtpMap(String host, String port, String from, String auth, String ssl, String starttls,
|
||||||
|
String username, String password, String replyTo, String envelopeFrom) {
|
||||||
Map<String, String> config = new HashMap<>();
|
Map<String, String> config = new HashMap<>();
|
||||||
config.put("host", host);
|
config.put("host", host);
|
||||||
config.put("port", port);
|
config.put("port", port);
|
||||||
|
@ -75,11 +76,13 @@ public class SMTPConnectionTest extends AbstractKeycloakTest {
|
||||||
config.put("starttls", starttls);
|
config.put("starttls", starttls);
|
||||||
config.put("user", username);
|
config.put("user", username);
|
||||||
config.put("password", password);
|
config.put("password", password);
|
||||||
|
config.put("replyTo", replyTo);
|
||||||
|
config.put("envelopeFrom", envelopeFrom);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithEmptySettings() throws Exception {
|
public void testWithNullSettings() throws Exception {
|
||||||
Response response = realm.testSMTPConnection(settings(null, null, null, null, null, null,
|
Response response = realm.testSMTPConnection(settings(null, null, null, null, null, null,
|
||||||
null, null));
|
null, null));
|
||||||
assertStatus(response, 500);
|
assertStatus(response, 500);
|
||||||
|
@ -114,7 +117,7 @@ public class SMTPConnectionTest extends AbstractKeycloakTest {
|
||||||
Map<String, String> oldSmtp = realmRep.getSmtpServer();
|
Map<String, String> oldSmtp = realmRep.getSmtpServer();
|
||||||
try {
|
try {
|
||||||
realmRep.setSmtpServer(smtpMap("127.0.0.1", "3025", "auto@keycloak.org", "true", null, null,
|
realmRep.setSmtpServer(smtpMap("127.0.0.1", "3025", "auto@keycloak.org", "true", null, null,
|
||||||
"admin@localhost", "admin"));
|
"admin@localhost", "admin", null, null));
|
||||||
realm.update(realmRep);
|
realm.update(realmRep);
|
||||||
|
|
||||||
greenMailRule.credentials("admin@localhost", "admin");
|
greenMailRule.credentials("admin@localhost", "admin");
|
||||||
|
|
Loading…
Reference in a new issue