mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Add --reason flag to UpdateSmdCommand
Just an old patch that I had lying around and never mailed out. Seemed like it could be worth having checked in. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=124853504
This commit is contained in:
parent
cc01035fe8
commit
9a2b88ee28
2 changed files with 13 additions and 4 deletions
|
@ -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.
|
||||
|
|
|
@ -77,7 +77,7 @@ public class UpdateSmdCommandTest extends CommandTestCase<UpdateSmdCommand> {
|
|||
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<UpdateSmdCommand> {
|
|||
.hasLastEppUpdateClientId("TheRegistrar").and()
|
||||
.hasOnlyOneHistoryEntryWhich()
|
||||
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and()
|
||||
.hasClientId("TheRegistrar");
|
||||
.hasClientId("TheRegistrar").and()
|
||||
.hasMetadataReason("UpdateSmdCommand: testing").and()
|
||||
.hasNoXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue