diff --git a/java/google/registry/tools/UpdateSmdCommand.java b/java/google/registry/tools/UpdateSmdCommand.java index ea5455b49..195030d1b 100644 --- a/java/google/registry/tools/UpdateSmdCommand.java +++ b/java/google/registry/tools/UpdateSmdCommand.java @@ -57,6 +57,11 @@ final class UpdateSmdCommand implements RemoteApiCommand { required = true) private Path smdFile; + @Parameter( + names = "--reason", + description = "Special reason for the SMD update to record in the history entry.") + private String reason; + @Override public void run() throws Exception { final EncodedSignedMark encodedSignedMark = @@ -66,14 +71,15 @@ final class UpdateSmdCommand implements RemoteApiCommand { @Override public void vrun() { try { - updateSmd(id, encodedSignedMark); + updateSmd(id, encodedSignedMark, reason); } catch (EppException e) { throw new RuntimeException(e); } }}); } - private void updateSmd(String applicationId, EncodedSignedMark encodedSignedMark) + private static void updateSmd( + String applicationId, EncodedSignedMark encodedSignedMark, String reason) throws EppException { ofy().assertInTransaction(); DateTime now = ofy().getTransactionTime(); @@ -105,6 +111,7 @@ final class UpdateSmdCommand implements RemoteApiCommand { .setModificationTime(now) .setClientId(domainApplication.getCurrentSponsorClientId()) .setBySuperuser(true) + .setReason("UpdateSmdCommand" + (reason != null ? ": " + reason : "")) .build(); // Save entities to datastore. diff --git a/javatests/google/registry/tools/UpdateSmdCommandTest.java b/javatests/google/registry/tools/UpdateSmdCommandTest.java index 762dbfb82..caf5f67ba 100644 --- a/javatests/google/registry/tools/UpdateSmdCommandTest.java +++ b/javatests/google/registry/tools/UpdateSmdCommandTest.java @@ -77,7 +77,7 @@ public class UpdateSmdCommandTest extends CommandTestCase { public void testSuccess() throws Exception { DateTime before = new DateTime(UTC); String smdFile = writeToTmpFile(ACTIVE_SMD); - runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile); + runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile, "--reason=testing"); EncodedSignedMark encodedSignedMark = TmchData.readEncodedSignedMark(ACTIVE_SMD); assertAboutApplications().that(reloadDomainApplication()) @@ -86,7 +86,9 @@ public class UpdateSmdCommandTest extends CommandTestCase { .hasLastEppUpdateClientId("TheRegistrar").and() .hasOnlyOneHistoryEntryWhich() .hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and() - .hasClientId("TheRegistrar"); + .hasClientId("TheRegistrar").and() + .hasMetadataReason("UpdateSmdCommand: testing").and() + .hasNoXml(); } @Test