File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 2121import java .util .List ;
2222import java .util .Properties ;
2323import java .util .Set ;
24-
2524import javax .mail .MessagingException ;
2625
2726import static org .hamcrest .Matchers .containsInAnyOrder ;
@@ -69,6 +68,31 @@ public void testSend() throws Exception {
6968 assertThat (sent .account (), is ("account1" ));
7069 }
7170
71+ public void testDomainAndRecipientAllowCantBeSetAtSameTime () {
72+ Settings settings = Settings .builder ()
73+ .putList ("xpack.notification.email.account.domain_allowlist" , "bar.com" )
74+ .
putList (
"xpack.notification.email.recipient_allowlist" ,
"*[email protected] " )
75+ .build ();
76+
77+ IllegalArgumentException e = expectThrows (
78+ IllegalArgumentException .class ,
79+ () -> new EmailService (
80+ settings ,
81+ null ,
82+ mock (SSLService .class ),
83+ new ClusterSettings (Settings .EMPTY , new HashSet <>(EmailService .getSettings ()))
84+ )
85+ );
86+
87+ assertThat (
88+ e .getMessage (),
89+ containsString (
90+ "Cannot set both [xpack.notification.email.recipient_allowlist] and "
91+ + "[xpack.notification.email.account.domain_allowlist] to a non [\" *\" ] value at the same time."
92+ )
93+ );
94+ }
95+
7296 public void testAccountSmtpPropertyConfiguration () {
7397 Settings settings = Settings .builder ()
7498 .put ("xpack.notification.email.account.account1.smtp.host" , "localhost" )
You can’t perform that action at this time.
0 commit comments