diff --git a/java/google/registry/reporting/spec11/Spec11EmailUtils.java b/java/google/registry/reporting/spec11/Spec11EmailUtils.java index 89cf7f996..4cfddcc92 100644 --- a/java/google/registry/reporting/spec11/Spec11EmailUtils.java +++ b/java/google/registry/reporting/spec11/Spec11EmailUtils.java @@ -141,6 +141,7 @@ public class Spec11EmailUtils { Map data = ImmutableMap.of( + "date", date.toString(), "registry", registryName, "replyToEmail", spec11ReplyToAddress, "threats", threatMatchMap, diff --git a/javatests/google/registry/reporting/spec11/Spec11EmailUtilsTest.java b/javatests/google/registry/reporting/spec11/Spec11EmailUtilsTest.java index 2f841e361..caa86b75b 100644 --- a/javatests/google/registry/reporting/spec11/Spec11EmailUtilsTest.java +++ b/javatests/google/registry/reporting/spec11/Spec11EmailUtilsTest.java @@ -87,7 +87,7 @@ public class Spec11EmailUtilsTest { } @Test - public void testSuccess_emailSpec11Reports() throws Exception { + public void testSuccess_emailMonthlySpec11Reports() throws Exception { emailUtils.emailSpec11Reports( Spec11EmailSoyInfo.MONTHLY_SPEC_11_EMAIL, "Super Cool Registry Monthly Threat Detector [2018-07-15]", @@ -140,6 +140,61 @@ public class Spec11EmailUtilsTest { "text/plain"); } + @Test + public void testSuccess_emailDailySpec11Reports() throws Exception { + emailUtils.emailSpec11Reports( + Spec11EmailSoyInfo.DAILY_SPEC_11_EMAIL, + "Super Cool Registry Daily Threat Detector [2018-07-15]", + sampleThreatMatches()); + // We inspect individual parameters because Message doesn't implement equals(). + verify(emailService, times(3)).sendMessage(gotMessage.capture()); + List capturedMessages = gotMessage.getAllValues(); + String emailFormat = + "Dear registrar partner,

" + + "Super Cool Registry conducts a daily analysis of all domains registered in its TLDs " + + "to identify potential security concerns. On 2018-07-15, the following domains that " + + "your registrar manages were flagged for potential security concerns:

" + + "%s
Domain NameThreat Type

Please communicate " + + "these findings to the registrant and work with the registrant to mitigate any " + + "security issues and have the domains delisted.

Some helpful resources for " + + "getting off a blocked list include:

You will continue to " + + "receive daily notices when new domains managed by your registrar are flagged for " + + "abuse, as well as a monthly summary of all of your domains under management that " + + "remain flagged for abuse. Once the registrant has resolved the security issues and " + + "followed the steps to have his or her domain reviewed and delisted it will " + + "automatically be removed from our reporting.

If you would like to change " + + "the email to which these notices are sent please update your abuse contact using " + + "your registrar portal account.

If you have any questions regarding this " + + "notice, please contact my-reply-to@test.com.

"; + + validateMessage( + capturedMessages.get(0), + "my-sender@test.com", + "a@fake.com", + "my-reply-to@test.com", + "Super Cool Registry Daily Threat Detector [2018-07-15]", + String.format(emailFormat, "a.comMALWARE"), + "text/html"); + validateMessage( + capturedMessages.get(1), + "my-sender@test.com", + "b@fake.com", + "my-reply-to@test.com", + "Super Cool Registry Daily Threat Detector [2018-07-15]", + String.format( + emailFormat, + "b.comMALWAREc.comMALWARE"), + "text/html"); + validateMessage( + capturedMessages.get(2), + "my-sender@test.com", + "my-receiver@test.com", + null, + "Spec11 Pipeline Success 2018-07-15", + "Spec11 reporting completed successfully.", + "text/plain"); + } + @Test public void testFailure_tooManyRetries_emailsAlert() throws MessagingException, IOException { Message throwingMessage = mock(Message.class);