Allow the nomulus renew_domain command to specify the client ID (#567)

* Allow the `nomulus renew_domain` command to specify the client ID

This means that a superuser can renew a domain and have the associated history
entry, one time billing event, and renewal grace period be recorded against a
specified registrar rather than the owning registrar of the domain.  This is
useful to e.g. renew a domain for free by "charging" the renewal to the
registry's fake registrar.  Since the grace period is written to the specified
cliend id as well, if the actual registrar deletes the domain, they don't get
back the money that they didn't pay in the first place.
This commit is contained in:
Ben McIlwain
2020-04-24 18:06:27 -04:00
committed by GitHub
parent 210de9340e
commit cd13f6c5d3
3 changed files with 95 additions and 27 deletions
@@ -15,6 +15,7 @@
package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.util.CollectionUtils.findDuplicates;
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
@@ -37,6 +38,13 @@ import org.joda.time.format.DateTimeFormatter;
@Parameters(separators = " =", commandDescription = "Renew domain(s) via EPP.")
final class RenewDomainCommand extends MutatingEppToolCommand {
@Parameter(
names = {"-c", "--client"},
description =
"The registrar to execute as and bill the renewal to; otherwise each domain's sponsoring"
+ " registrar. Renewals by non-sponsoring registrars require --superuser as well.")
String clientId;
@Parameter(
names = {"-p", "--period"},
description = "Number of years to renew the registration for (defaults to 1).")
@@ -63,7 +71,7 @@ final class RenewDomainCommand extends MutatingEppToolCommand {
setSoyTemplate(RenewDomainSoyInfo.getInstance(), RenewDomainSoyInfo.RENEWDOMAIN);
DomainBase domain = domainOptional.get();
addSoyRecord(
domain.getCurrentSponsorClientId(),
isNullOrEmpty(clientId) ? domain.getCurrentSponsorClientId() : clientId,
new SoyMapData(
"domainName", domain.getFullyQualifiedDomainName(),
"expirationDate", domain.getRegistrationExpirationTime().toString(DATE_FORMATTER),