Enforce abuse WHOIS contact for REAL registrars when adding TLDs

We do not enforce this for non-REAL registrars or in any environment other than UNITTEST or PRODUCTION. This is similar but separate to [] since we can add allowed TLDs in either location.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=239510275
This commit is contained in:
gbrodman 2019-03-20 17:30:46 -07:00 committed by jianglai
parent 2a18e705a2
commit 4544aa1efe
6 changed files with 210 additions and 12 deletions

View file

@ -14,10 +14,13 @@
package google.registry.tools;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
import com.beust.jcommander.Parameters;
import google.registry.config.RegistryEnvironment;
import google.registry.model.registrar.Registrar;
import javax.annotation.Nullable;
/** Command to update a Registrar. */
@Parameters(separators = " =", commandDescription = "Update registrar account(s)")
@ -28,4 +31,22 @@ final class UpdateRegistrarCommand extends CreateOrUpdateRegistrarCommand {
return checkArgumentPresent(
Registrar.loadByClientId(clientId), "Registrar %s not found", clientId);
}
@Override
void checkModifyAllowedTlds(@Nullable Registrar oldRegistrar) {
// Only allow modifying allowed TLDs if we're in a non-PRODUCTION environment, if the registrar
// is not REAL, or the registrar has a WHOIS abuse contact set.
checkArgumentNotNull(oldRegistrar, "Old registrar was not present during modification");
boolean isRealRegistrar =
Registrar.Type.REAL.equals(registrarType)
|| (Registrar.Type.REAL.equals(oldRegistrar.getType()) && registrarType == null);
if (RegistryEnvironment.PRODUCTION.equals(RegistryEnvironment.get()) && isRealRegistrar) {
checkArgumentPresent(
oldRegistrar.getWhoisAbuseContact(),
"Cannot modify allowed TLDs if there is no WHOIS abuse contact set. Please use the"
+ " \"nomulus registrar_contact\" command on this registrar to set a WHOIS abuse"
+ " contact.");
}
}
}