Skip to content

Commit 7f620c6

Browse files
committed
Setting exclusivity test
1 parent 6d5431e commit 7f620c6

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222
import java.util.Properties;
2323
import java.util.Set;
24-
2524
import javax.mail.MessagingException;
2625

2726
import 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")

0 commit comments

Comments
 (0)