Skip to content

Commit d3582c8

Browse files
committed
Setting exclusivity test
1 parent 6d5431e commit d3582c8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailServiceTests.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ public void testSend() throws Exception {
6969
assertThat(sent.account(), is("account1"));
7070
}
7171

72+
public void testDomainAndRecipientAllowCantBeSetAtSameTime() {
73+
Settings settings = Settings.builder()
74+
.putList("xpack.notification.email.account.domain_allowlist", "bar.com")
75+
.putList("xpack.notification.email.recipient_allowlist", "*[email protected]")
76+
.build();
77+
78+
IllegalArgumentException e = expectThrows(
79+
IllegalArgumentException.class,
80+
() -> new EmailService(
81+
settings,
82+
null,
83+
mock(SSLService.class),
84+
new ClusterSettings(Settings.EMPTY, new HashSet<>(EmailService.getSettings()))
85+
)
86+
);
87+
88+
assertThat(
89+
e.getMessage(),
90+
containsString(
91+
"Cannot set both [xpack.notification.email.recipient_allowlist] and "
92+
+ "[xpack.notification.email.account.domain_allowlist] to a non [\"*\"] value at the same time."
93+
)
94+
);
95+
}
96+
7297
public void testAccountSmtpPropertyConfiguration() {
7398
Settings settings = Settings.builder()
7499
.put("xpack.notification.email.account.account1.smtp.host", "localhost")

0 commit comments

Comments
 (0)