mirror of
https://github.com/google/nomulus.git
synced 2025-05-29 17:00:11 +02:00
Add --autorenews parameter to nomulus update_domain
tool (#772)
This commit is contained in:
parent
9167a42c42
commit
b8e9d56aec
19 changed files with 498 additions and 230 deletions
|
@ -68,6 +68,7 @@ import google.registry.model.domain.DomainCommand.Update.Change;
|
|||
import google.registry.model.domain.fee.FeeUpdateCommandExtension;
|
||||
import google.registry.model.domain.metadata.MetadataExtension;
|
||||
import google.registry.model.domain.secdns.SecDnsUpdateExtension;
|
||||
import google.registry.model.domain.superuser.DomainUpdateSuperuserExtension;
|
||||
import google.registry.model.eppcommon.AuthInfo;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
|
@ -152,7 +153,8 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
|||
extensionManager.register(
|
||||
FeeUpdateCommandExtension.class,
|
||||
MetadataExtension.class,
|
||||
SecDnsUpdateExtension.class);
|
||||
SecDnsUpdateExtension.class,
|
||||
DomainUpdateSuperuserExtension.class);
|
||||
flowCustomLogic.beforeValidation();
|
||||
extensionManager.validate();
|
||||
validateClientIsLoggedIn(clientId);
|
||||
|
@ -251,6 +253,15 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
|||
.removeContacts(remove.getContacts())
|
||||
.setRegistrant(firstNonNull(change.getRegistrant(), domain.getRegistrant()))
|
||||
.setAuthInfo(firstNonNull(change.getAuthInfo(), domain.getAuthInfo()));
|
||||
Optional<DomainUpdateSuperuserExtension> superuserExt =
|
||||
eppInput.getSingleExtension(DomainUpdateSuperuserExtension.class);
|
||||
if (superuserExt.isPresent()) {
|
||||
if (superuserExt.get().getAutorenews().isPresent()) {
|
||||
boolean autorenews = superuserExt.get().getAutorenews().get();
|
||||
domainBuilder.setAutorenewEndTime(
|
||||
Optional.ofNullable(autorenews ? null : domain.getRegistrationExpirationTime()));
|
||||
}
|
||||
}
|
||||
return domainBuilder.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
/** A superuser extension that may be present on domain delete commands. */
|
||||
@XmlRootElement(name = "domainDelete")
|
||||
public class DomainDeleteSuperuserExtension extends SuperuserExtension {
|
||||
|
||||
@XmlElement(name = "redemptionGracePeriodDays")
|
||||
int redemptionGracePeriodDays;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
/** A superuser extension that may be present on domain transfer request commands. */
|
||||
@XmlRootElement(name = "domainTransferRequest")
|
||||
public class DomainTransferRequestSuperuserExtension extends SuperuserExtension {
|
||||
|
||||
// We need to specify the period here because the transfer object's period cannot be set to zero.
|
||||
@XmlElement(name = "renewalPeriod")
|
||||
Period renewalPeriod;
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2020 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.model.domain.superuser;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/** A superuser extension that may be present on domain update commands. */
|
||||
@XmlRootElement(name = "domainUpdate")
|
||||
public class DomainUpdateSuperuserExtension extends SuperuserExtension {
|
||||
|
||||
@XmlElement(name = "autorenews")
|
||||
@Nullable
|
||||
String autorenews;
|
||||
|
||||
public Optional<Boolean> getAutorenews() {
|
||||
return Optional.ofNullable(isNullOrEmpty(autorenews) ? null : Boolean.valueOf(autorenews));
|
||||
}
|
||||
}
|
|
@ -50,6 +50,7 @@ import google.registry.model.domain.secdns.SecDnsCreateExtension;
|
|||
import google.registry.model.domain.secdns.SecDnsUpdateExtension;
|
||||
import google.registry.model.domain.superuser.DomainDeleteSuperuserExtension;
|
||||
import google.registry.model.domain.superuser.DomainTransferRequestSuperuserExtension;
|
||||
import google.registry.model.domain.superuser.DomainUpdateSuperuserExtension;
|
||||
import google.registry.model.domain.token.AllocationTokenExtension;
|
||||
import google.registry.model.eppinput.ResourceCommand.ResourceCheck;
|
||||
import google.registry.model.eppinput.ResourceCommand.SingleResourceCommand;
|
||||
|
@ -309,53 +310,62 @@ public class EppInput extends ImmutableObject {
|
|||
@XmlType(propOrder = {"command", "extension", "clTRID"})
|
||||
public static class CommandWrapper extends ImmutableObject {
|
||||
@XmlElements({
|
||||
@XmlElement(name = "check", type = Check.class),
|
||||
@XmlElement(name = "create", type = Create.class),
|
||||
@XmlElement(name = "delete", type = Delete.class),
|
||||
@XmlElement(name = "info", type = Info.class),
|
||||
@XmlElement(name = "login", type = Login.class),
|
||||
@XmlElement(name = "logout", type = Logout.class),
|
||||
@XmlElement(name = "poll", type = Poll.class),
|
||||
@XmlElement(name = "renew", type = Renew.class),
|
||||
@XmlElement(name = "transfer", type = Transfer.class),
|
||||
@XmlElement(name = "update", type = Update.class) })
|
||||
@XmlElement(name = "check", type = Check.class),
|
||||
@XmlElement(name = "create", type = Create.class),
|
||||
@XmlElement(name = "delete", type = Delete.class),
|
||||
@XmlElement(name = "info", type = Info.class),
|
||||
@XmlElement(name = "login", type = Login.class),
|
||||
@XmlElement(name = "logout", type = Logout.class),
|
||||
@XmlElement(name = "poll", type = Poll.class),
|
||||
@XmlElement(name = "renew", type = Renew.class),
|
||||
@XmlElement(name = "transfer", type = Transfer.class),
|
||||
@XmlElement(name = "update", type = Update.class)
|
||||
})
|
||||
InnerCommand command;
|
||||
|
||||
/** Zero or more command extensions. */
|
||||
@XmlElementRefs({
|
||||
// allocation token extension
|
||||
@XmlElementRef(type = AllocationTokenExtension.class),
|
||||
// fee extension version 0.6
|
||||
@XmlElementRef(type = FeeCheckCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeInfoCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeCreateCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeRenewCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeTransferCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeUpdateCommandExtensionV06.class),
|
||||
// fee extension version 0.11
|
||||
@XmlElementRef(type = FeeCheckCommandExtensionV11.class),
|
||||
@XmlElementRef(type = FeeCreateCommandExtensionV11.class),
|
||||
@XmlElementRef(type = FeeRenewCommandExtensionV11.class),
|
||||
@XmlElementRef(type = FeeTransferCommandExtensionV11.class),
|
||||
@XmlElementRef(type = FeeUpdateCommandExtensionV11.class),
|
||||
// fee extension version 0.12
|
||||
@XmlElementRef(type = FeeCheckCommandExtensionV12.class),
|
||||
@XmlElementRef(type = FeeCreateCommandExtensionV12.class),
|
||||
@XmlElementRef(type = FeeRenewCommandExtensionV12.class),
|
||||
@XmlElementRef(type = FeeTransferCommandExtensionV12.class),
|
||||
@XmlElementRef(type = FeeUpdateCommandExtensionV12.class),
|
||||
// other extensions
|
||||
@XmlElementRef(type = LaunchCheckExtension.class),
|
||||
@XmlElementRef(type = LaunchCreateExtension.class),
|
||||
@XmlElementRef(type = LaunchDeleteExtension.class),
|
||||
@XmlElementRef(type = LaunchInfoExtension.class),
|
||||
@XmlElementRef(type = LaunchUpdateExtension.class),
|
||||
@XmlElementRef(type = MetadataExtension.class),
|
||||
@XmlElementRef(type = RgpUpdateExtension.class),
|
||||
@XmlElementRef(type = SecDnsCreateExtension.class),
|
||||
@XmlElementRef(type = SecDnsUpdateExtension.class),
|
||||
@XmlElementRef(type = DomainTransferRequestSuperuserExtension.class),
|
||||
@XmlElementRef(type = DomainDeleteSuperuserExtension.class) })
|
||||
// Fee extension version 0.6
|
||||
@XmlElementRef(type = FeeCheckCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeInfoCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeCreateCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeRenewCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeTransferCommandExtensionV06.class),
|
||||
@XmlElementRef(type = FeeUpdateCommandExtensionV06.class),
|
||||
|
||||
// Fee extension version 0.11
|
||||
@XmlElementRef(type = FeeCheckCommandExtensionV11.class),
|
||||
@XmlElementRef(type = FeeCreateCommandExtensionV11.class),
|
||||
@XmlElementRef(type = FeeRenewCommandExtensionV11.class),
|
||||
@XmlElementRef(type = FeeTransferCommandExtensionV11.class),
|
||||
@XmlElementRef(type = FeeUpdateCommandExtensionV11.class),
|
||||
|
||||
// Fee extension version 0.12
|
||||
@XmlElementRef(type = FeeCheckCommandExtensionV12.class),
|
||||
@XmlElementRef(type = FeeCreateCommandExtensionV12.class),
|
||||
@XmlElementRef(type = FeeRenewCommandExtensionV12.class),
|
||||
@XmlElementRef(type = FeeTransferCommandExtensionV12.class),
|
||||
@XmlElementRef(type = FeeUpdateCommandExtensionV12.class),
|
||||
|
||||
// Launch phase extensions
|
||||
@XmlElementRef(type = LaunchCheckExtension.class),
|
||||
@XmlElementRef(type = LaunchCreateExtension.class),
|
||||
@XmlElementRef(type = LaunchDeleteExtension.class),
|
||||
@XmlElementRef(type = LaunchInfoExtension.class),
|
||||
@XmlElementRef(type = LaunchUpdateExtension.class),
|
||||
|
||||
// Superuser extensions
|
||||
@XmlElementRef(type = DomainDeleteSuperuserExtension.class),
|
||||
@XmlElementRef(type = DomainTransferRequestSuperuserExtension.class),
|
||||
@XmlElementRef(type = DomainUpdateSuperuserExtension.class),
|
||||
|
||||
// Other extensions
|
||||
@XmlElementRef(type = AllocationTokenExtension.class),
|
||||
@XmlElementRef(type = MetadataExtension.class),
|
||||
@XmlElementRef(type = RgpUpdateExtension.class),
|
||||
@XmlElementRef(type = SecDnsCreateExtension.class),
|
||||
@XmlElementRef(type = SecDnsUpdateExtension.class)
|
||||
})
|
||||
@XmlElementWrapper
|
||||
List<CommandExtension> extension;
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@ package google.registry.tools;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.domain.rgp.GracePeriodStatus.AUTO_RENEW;
|
||||
import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static java.util.function.Predicate.isEqual;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
|
@ -31,15 +32,19 @@ import com.google.common.flogger.FluentLogger;
|
|||
import com.google.template.soy.data.SoyMapData;
|
||||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.GracePeriodBase;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.tools.params.NameserversParameter;
|
||||
import google.registry.tools.soy.DomainUpdateSoyInfo;
|
||||
import google.registry.util.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** A command to update a new domain via EPP. */
|
||||
|
@ -48,6 +53,8 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
|
|||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject Clock clock;
|
||||
|
||||
@Parameter(names = "--statuses", description = "Comma-separated list of statuses to set.")
|
||||
private List<String> statuses = new ArrayList<>();
|
||||
|
||||
|
@ -123,6 +130,15 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
|
|||
)
|
||||
boolean clearDsRecords = false;
|
||||
|
||||
@Nullable
|
||||
@Parameter(
|
||||
names = "--autorenews",
|
||||
arity = 1,
|
||||
description =
|
||||
"Whether the domain autorenews. If false, the domain will automatically be"
|
||||
+ " deleted at the end of its current registration period.")
|
||||
Boolean autorenews;
|
||||
|
||||
@Override
|
||||
protected void initMutatingEppToolCommand() {
|
||||
if (!nameservers.isEmpty()) {
|
||||
|
@ -159,7 +175,18 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
|
|||
clearDsRecords = true;
|
||||
}
|
||||
|
||||
ImmutableSet.Builder<String> autorenewGracePeriodWarningDomains = new ImmutableSet.Builder<>();
|
||||
DateTime now = clock.nowUtc();
|
||||
for (String domain : domains) {
|
||||
Optional<DomainBase> domainOptional = loadByForeignKey(DomainBase.class, domain, now);
|
||||
checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domain);
|
||||
DomainBase domainBase = domainOptional.get();
|
||||
checkArgument(
|
||||
!domainBase.getStatusValues().contains(SERVER_UPDATE_PROHIBITED),
|
||||
"The domain '%s' has status SERVER_UPDATE_PROHIBITED. Verify that you are allowed "
|
||||
+ "to make updates, and if so, use the domain_unlock command to enable updates.",
|
||||
domain);
|
||||
|
||||
// Use TreeSets so that the results are always in the same order (this makes testing easier).
|
||||
Set<String> addAdminsThisDomain = new TreeSet<>(addAdmins);
|
||||
Set<String> removeAdminsThisDomain = new TreeSet<>(removeAdmins);
|
||||
|
@ -171,16 +198,6 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
|
|||
Set<String> removeStatusesThisDomain = new TreeSet<>(removeStatuses);
|
||||
|
||||
if (!nameservers.isEmpty() || !admins.isEmpty() || !techs.isEmpty() || !statuses.isEmpty()) {
|
||||
DateTime now = DateTime.now(UTC);
|
||||
Optional<DomainBase> domainOptional =
|
||||
loadByForeignKey(DomainBase.class, domain, now);
|
||||
checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domain);
|
||||
DomainBase domainBase = domainOptional.get();
|
||||
checkArgument(
|
||||
!domainBase.getStatusValues().contains(SERVER_UPDATE_PROHIBITED),
|
||||
"The domain '%s' has status SERVER_UPDATE_PROHIBITED. Verify that you are allowed "
|
||||
+ "to make updates, and if so, use the domain_unlock command to enable updates.",
|
||||
domain);
|
||||
if (!nameservers.isEmpty()) {
|
||||
ImmutableSortedSet<String> existingNameservers = domainBase.loadNameserverHostNames();
|
||||
populateAddRemoveLists(
|
||||
|
@ -232,33 +249,41 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
|
|||
}
|
||||
|
||||
boolean add =
|
||||
!addNameserversThisDomain.isEmpty()
|
||||
(!addNameserversThisDomain.isEmpty()
|
||||
|| !addAdminsThisDomain.isEmpty()
|
||||
|| !addTechsThisDomain.isEmpty()
|
||||
|| !addStatusesThisDomain.isEmpty();
|
||||
|| !addStatusesThisDomain.isEmpty());
|
||||
|
||||
boolean remove =
|
||||
!removeNameserversThisDomain.isEmpty()
|
||||
(!removeNameserversThisDomain.isEmpty()
|
||||
|| !removeAdminsThisDomain.isEmpty()
|
||||
|| !removeTechsThisDomain.isEmpty()
|
||||
|| !removeStatusesThisDomain.isEmpty();
|
||||
|| !removeStatusesThisDomain.isEmpty());
|
||||
|
||||
boolean change = registrant != null || password != null;
|
||||
|
||||
boolean secdns =
|
||||
!addDsRecords.isEmpty()
|
||||
boolean change = (registrant != null || password != null);
|
||||
boolean secDns =
|
||||
(!addDsRecords.isEmpty()
|
||||
|| !removeDsRecords.isEmpty()
|
||||
|| !dsRecords.isEmpty()
|
||||
|| clearDsRecords;
|
||||
|| clearDsRecords);
|
||||
|
||||
if (!add && !remove && !change && !secdns) {
|
||||
if (!add && !remove && !change && !secDns && autorenews == null) {
|
||||
logger.atInfo().log("No changes need to be made to domain %s", domain);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If autorenew is being turned off and this domain is already in the autorenew grace period,
|
||||
// then we want to warn the user that they might want to delete it instead.
|
||||
if (Boolean.FALSE.equals(autorenews)) {
|
||||
if (domainBase.getGracePeriods().stream()
|
||||
.map(GracePeriodBase::getType)
|
||||
.anyMatch(isEqual(AUTO_RENEW))) {
|
||||
autorenewGracePeriodWarningDomains.add(domain);
|
||||
}
|
||||
}
|
||||
|
||||
setSoyTemplate(DomainUpdateSoyInfo.getInstance(), DomainUpdateSoyInfo.DOMAINUPDATE);
|
||||
addSoyRecord(
|
||||
clientId,
|
||||
SoyMapData soyMapData =
|
||||
new SoyMapData(
|
||||
"domain", domain,
|
||||
"add", add,
|
||||
|
@ -274,14 +299,27 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
|
|||
"change", change,
|
||||
"registrant", registrant,
|
||||
"password", password,
|
||||
"secdns", secdns,
|
||||
"secdns", secDns,
|
||||
"addDsRecords", DsRecord.convertToSoy(addDsRecords),
|
||||
"removeDsRecords", DsRecord.convertToSoy(removeDsRecords),
|
||||
"removeAllDsRecords", clearDsRecords));
|
||||
"removeAllDsRecords", clearDsRecords);
|
||||
if (autorenews != null) {
|
||||
soyMapData.put("autorenews", autorenews.toString());
|
||||
}
|
||||
addSoyRecord(clientId, soyMapData);
|
||||
}
|
||||
|
||||
ImmutableSet<String> domainsToWarn = autorenewGracePeriodWarningDomains.build();
|
||||
if (!domainsToWarn.isEmpty()) {
|
||||
logger.atWarning().log(
|
||||
"The following domains are in autorenew grace periods. Consider aborting this command"
|
||||
+ " and running `nomulus delete_domain` instead to terminate autorenewal immediately"
|
||||
+ " rather than in one year, if desired:\n%s",
|
||||
String.join(", ", domainsToWarn));
|
||||
}
|
||||
}
|
||||
|
||||
protected void populateAddRemoveLists(
|
||||
private void populateAddRemoveLists(
|
||||
Set<String> targetSet, Set<String> oldSet, Set<String> addSet, Set<String> removeSet) {
|
||||
addSet.addAll(Sets.difference(targetSet, oldSet));
|
||||
removeSet.addAll(Sets.difference(oldSet, targetSet));
|
||||
|
|
|
@ -42,10 +42,6 @@ public abstract class XjcObject {
|
|||
XjcXmlTransformer.marshalStrict(this, out, encoding);
|
||||
}
|
||||
|
||||
public void marshalLenient(OutputStream out, Charset encoding) throws XmlException {
|
||||
XjcXmlTransformer.marshalLenient(this, out, encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns object into a formatted XML string <i>by any means necessary</i>.
|
||||
*
|
||||
|
|
|
@ -47,4 +47,12 @@
|
|||
</all>
|
||||
</complexType>
|
||||
|
||||
<element name="domainUpdate" type="superuser:domainUpdateType" />
|
||||
|
||||
<complexType name="domainUpdateType">
|
||||
<all>
|
||||
<element name="autorenews" minOccurs="0" type="boolean" />
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
</schema>
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
{@param addDsRecords: list<[keyTag:int, alg:int, digestType:int, digest:string]>}
|
||||
{@param removeDsRecords: list<[keyTag:int, alg:int, digestType:int, digest:string]>}
|
||||
{@param removeAllDsRecords: bool}
|
||||
{@param? autorenews: string}
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
|
@ -96,39 +97,46 @@
|
|||
{/if}
|
||||
</domain:update>
|
||||
</update>
|
||||
{if $secdns}
|
||||
{if $secdns or $autorenews}
|
||||
<extension>
|
||||
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
|
||||
{if $removeAllDsRecords}
|
||||
<secDNS:rem>
|
||||
<secDNS:all>true</secDNS:all>
|
||||
</secDNS:rem>
|
||||
{/if}
|
||||
{if length($removeDsRecords) > 0}
|
||||
<secDNS:rem>
|
||||
{for $dsRecord in $removeDsRecords}
|
||||
<secDNS:dsData>
|
||||
<secDNS:keyTag>{$dsRecord.keyTag}</secDNS:keyTag>
|
||||
<secDNS:alg>{$dsRecord.alg}</secDNS:alg>
|
||||
<secDNS:digestType>{$dsRecord.digestType}</secDNS:digestType>
|
||||
<secDNS:digest>{$dsRecord.digest}</secDNS:digest>
|
||||
</secDNS:dsData>
|
||||
{/for}
|
||||
</secDNS:rem>
|
||||
{/if}
|
||||
{if length($addDsRecords) > 0}
|
||||
<secDNS:add>
|
||||
{for $dsRecord in $addDsRecords}
|
||||
<secDNS:dsData>
|
||||
<secDNS:keyTag>{$dsRecord.keyTag}</secDNS:keyTag>
|
||||
<secDNS:alg>{$dsRecord.alg}</secDNS:alg>
|
||||
<secDNS:digestType>{$dsRecord.digestType}</secDNS:digestType>
|
||||
<secDNS:digest>{$dsRecord.digest}</secDNS:digest>
|
||||
</secDNS:dsData>
|
||||
{/for}
|
||||
</secDNS:add>
|
||||
{/if}
|
||||
</secDNS:update>
|
||||
{if $secdns}
|
||||
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
|
||||
{if $removeAllDsRecords}
|
||||
<secDNS:rem>
|
||||
<secDNS:all>true</secDNS:all>
|
||||
</secDNS:rem>
|
||||
{/if}
|
||||
{if length($removeDsRecords) > 0}
|
||||
<secDNS:rem>
|
||||
{for $dsRecord in $removeDsRecords}
|
||||
<secDNS:dsData>
|
||||
<secDNS:keyTag>{$dsRecord.keyTag}</secDNS:keyTag>
|
||||
<secDNS:alg>{$dsRecord.alg}</secDNS:alg>
|
||||
<secDNS:digestType>{$dsRecord.digestType}</secDNS:digestType>
|
||||
<secDNS:digest>{$dsRecord.digest}</secDNS:digest>
|
||||
</secDNS:dsData>
|
||||
{/for}
|
||||
</secDNS:rem>
|
||||
{/if}
|
||||
{if length($addDsRecords) > 0}
|
||||
<secDNS:add>
|
||||
{for $dsRecord in $addDsRecords}
|
||||
<secDNS:dsData>
|
||||
<secDNS:keyTag>{$dsRecord.keyTag}</secDNS:keyTag>
|
||||
<secDNS:alg>{$dsRecord.alg}</secDNS:alg>
|
||||
<secDNS:digestType>{$dsRecord.digestType}</secDNS:digestType>
|
||||
<secDNS:digest>{$dsRecord.digest}</secDNS:digest>
|
||||
</secDNS:dsData>
|
||||
{/for}
|
||||
</secDNS:add>
|
||||
{/if}
|
||||
</secDNS:update>
|
||||
{/if}
|
||||
{if $autorenews}
|
||||
<superuser:domainUpdate xmlns:superuser="urn:google:params:xml:ns:superuser-1.0">
|
||||
<superuser:autorenews>{$autorenews}</superuser:autorenews>
|
||||
</superuser:domainUpdate>
|
||||
{/if}
|
||||
</extension>
|
||||
{/if}
|
||||
<clTRID>RegistryTool</clTRID>
|
||||
|
|
|
@ -572,6 +572,7 @@ class DomainTransferRequestFlowTest
|
|||
Duration expectedAutomaticTransferLength,
|
||||
BillingEvent.Cancellation.Builder... extraExpectedBillingEvents)
|
||||
throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput(commandFilename, substitutions);
|
||||
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
|
||||
// Replace the ROID in the xml file with the one generated in our test.
|
||||
|
@ -903,7 +904,6 @@ class DomainTransferRequestFlowTest
|
|||
@Test
|
||||
void testSuccess_superuserExtension_zeroPeriod_nonZeroAutomaticTransferLength() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
clock.advanceOneMilli();
|
||||
doSuccessfulSuperuserExtensionTest(
|
||||
"domain_transfer_request_superuser_extension.xml",
|
||||
|
@ -918,7 +918,6 @@ class DomainTransferRequestFlowTest
|
|||
@Test
|
||||
void testSuccess_superuserExtension_zeroPeriod_zeroAutomaticTransferLength() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
clock.advanceOneMilli();
|
||||
doSuccessfulSuperuserExtensionTest(
|
||||
"domain_transfer_request_superuser_extension.xml",
|
||||
|
@ -934,7 +933,6 @@ class DomainTransferRequestFlowTest
|
|||
void testSuccess_superuserExtension_nonZeroPeriod_nonZeroAutomaticTransferLength()
|
||||
throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
clock.advanceOneMilli();
|
||||
doSuccessfulSuperuserExtensionTest(
|
||||
"domain_transfer_request_superuser_extension.xml",
|
||||
|
@ -948,7 +946,6 @@ class DomainTransferRequestFlowTest
|
|||
|
||||
@Test
|
||||
void testSuccess_superuserExtension_zeroPeriod_autorenewGraceActive() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setupDomain("example", "tld");
|
||||
VKey<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
// Set domain to have auto-renewed just before the transfer request, so that it will have an
|
||||
|
|
|
@ -89,12 +89,14 @@ import google.registry.model.host.HostResource;
|
|||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainUpdateFlow}. */
|
||||
public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, DomainBase> {
|
||||
class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, DomainBase> {
|
||||
|
||||
private static final DelegationSignerData SOME_DSDATA =
|
||||
DelegationSignerData.create(1, 2, 3, base16().decode("0123"));
|
||||
|
@ -105,13 +107,12 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
"DIGEST_TYPE", "1",
|
||||
"DIGEST", "38EC35D5B3A34B44C39B");
|
||||
|
||||
ContactResource sh8013Contact;
|
||||
ContactResource mak21Contact;
|
||||
ContactResource unusedContact;
|
||||
HistoryEntry historyEntryDomainCreate;
|
||||
private ContactResource sh8013Contact;
|
||||
private ContactResource mak21Contact;
|
||||
private ContactResource unusedContact;
|
||||
|
||||
@BeforeEach
|
||||
public void initDomainTest() {
|
||||
void initDomainTest() {
|
||||
createTld("tld");
|
||||
// Note that "domain_update.xml" tests adding and removing the same contact type.
|
||||
setEppInput("domain_update.xml");
|
||||
|
@ -141,12 +142,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.setRegistrant(mak21Contact.createVKey())
|
||||
.setNameservers(ImmutableSet.of(host.createVKey()))
|
||||
.build());
|
||||
historyEntryDomainCreate =
|
||||
persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setParent(domain)
|
||||
.build());
|
||||
persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setParent(domain)
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
return domain;
|
||||
}
|
||||
|
@ -164,12 +164,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
DesignatedContact.create(Type.ADMIN, unusedContact.createVKey())))
|
||||
.setNameservers(ImmutableSet.of(host.createVKey()))
|
||||
.build());
|
||||
historyEntryDomainCreate =
|
||||
persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setParent(domain)
|
||||
.build());
|
||||
persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setParent(domain)
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
return domain;
|
||||
}
|
||||
|
@ -193,27 +192,29 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.and()
|
||||
.hasLastEppUpdateTime(clock.nowUtc())
|
||||
.and()
|
||||
.hasLastEppUpdateClientId("TheRegistrar");
|
||||
.hasLastEppUpdateClientId("TheRegistrar")
|
||||
.and()
|
||||
.hasNoAutorenewEndTime();
|
||||
assertNoBillingEvents();
|
||||
assertDnsTasksEnqueued("example.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDryRun() throws Exception {
|
||||
void testDryRun() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess() throws Exception {
|
||||
void testSuccess() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_clTridNotSpecified() throws Exception {
|
||||
void testSuccess_clTridNotSpecified() throws Exception {
|
||||
setEppInput("domain_update_no_cltrid.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -221,7 +222,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_cachingDisabled() throws Exception {
|
||||
void testSuccess_cachingDisabled() throws Exception {
|
||||
boolean origIsCachingEnabled = RegistryConfig.isEppResourceCachingEnabled();
|
||||
try {
|
||||
RegistryConfig.overrideIsEppResourceCachingEnabledForTesting(false);
|
||||
|
@ -234,7 +235,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_inQuietPeriod() throws Exception {
|
||||
void testSuccess_inQuietPeriod() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
|
@ -246,7 +247,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_emptyRegistrant() throws Exception {
|
||||
void testFailure_emptyRegistrant() throws Exception {
|
||||
setEppInput("domain_update_empty_registrant.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -272,7 +273,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_maxNumberOfNameservers() throws Exception {
|
||||
void testSuccess_maxNumberOfNameservers() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
// Modify domain to have 13 nameservers. We will then remove one and add one in the test.
|
||||
|
@ -281,7 +282,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_addAndRemoveLargeNumberOfNameserversAndContacts() throws Exception {
|
||||
void testSuccess_addAndRemoveLargeNumberOfNameserversAndContacts() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
setEppInput("domain_update_max_everything.xml");
|
||||
|
@ -325,7 +326,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_metadata() throws Exception {
|
||||
void testSuccess_metadata() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_update_metadata.xml");
|
||||
persistReferencedEntities();
|
||||
|
@ -344,7 +345,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_metadataNotFromTool() throws Exception {
|
||||
void testSuccess_metadataNotFromTool() throws Exception {
|
||||
setEppInput("domain_update_metadata.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -353,7 +354,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_removeContact() throws Exception {
|
||||
void testSuccess_removeContact() throws Exception {
|
||||
setEppInput("domain_update_remove_contact.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -361,7 +362,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_addAndRemoveSubordinateHostNameservers() throws Exception {
|
||||
void testSuccess_addAndRemoveSubordinateHostNameservers() throws Exception {
|
||||
// Test that operations involving subordinate hosts as nameservers do not change the subordinate
|
||||
// host relationship itself.
|
||||
setEppInput("domain_update_subordinate_hosts.xml");
|
||||
|
@ -394,7 +395,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_registrantMovedToTechContact() throws Exception {
|
||||
void testSuccess_registrantMovedToTechContact() throws Exception {
|
||||
setEppInput("domain_update_registrant_to_tech.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 =
|
||||
|
@ -409,7 +410,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleReferencesToSameContactRemoved() throws Exception {
|
||||
void testSuccess_multipleReferencesToSameContactRemoved() throws Exception {
|
||||
setEppInput("domain_update_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 =
|
||||
|
@ -430,7 +431,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_removeClientUpdateProhibited() throws Exception {
|
||||
void testSuccess_removeClientUpdateProhibited() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
persistDomain()
|
||||
|
@ -474,7 +475,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAdd() throws Exception {
|
||||
void testSuccess_secDnsAdd() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
null,
|
||||
|
@ -485,7 +486,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddPreservesExisting() throws Exception {
|
||||
void testSuccess_secDnsAddPreservesExisting() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
|
@ -497,7 +498,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddSameDoesNothing() throws Exception {
|
||||
void testSuccess_secDnsAddSameDoesNothing() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
|
@ -506,7 +507,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddOnlyKeyTagRemainsSame() throws Exception {
|
||||
void testSuccess_secDnsAddOnlyKeyTagRemainsSame() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
|
@ -517,7 +518,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
|
||||
// Changing any of the four fields in DelegationSignerData should result in a new object
|
||||
@Test
|
||||
public void testSuccess_secDnsAddOnlyChangeKeyTag() throws Exception {
|
||||
void testSuccess_secDnsAddOnlyChangeKeyTag() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
|
@ -527,7 +528,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddOnlyChangeAlgorithm() throws Exception {
|
||||
void testSuccess_secDnsAddOnlyChangeAlgorithm() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
|
@ -536,7 +537,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddOnlyChangeDigestType() throws Exception {
|
||||
void testSuccess_secDnsAddOnlyChangeDigestType() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
|
@ -545,7 +546,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddOnlyChangeDigest() throws Exception {
|
||||
void testSuccess_secDnsAddOnlyChangeDigest() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
|
@ -554,7 +555,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddToMaxRecords() throws Exception {
|
||||
void testSuccess_secDnsAddToMaxRecords() throws Exception {
|
||||
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
builder.add(DelegationSignerData.create(i, 2, 3, new byte[] {0, 1, 2}));
|
||||
|
@ -573,7 +574,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsRemove() throws Exception {
|
||||
void testSuccess_secDnsRemove() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_rem.xml",
|
||||
ImmutableSet.of(
|
||||
|
@ -583,7 +584,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsRemoveAll() throws Exception {
|
||||
void testSuccess_secDnsRemoveAll() throws Exception {
|
||||
// As an aside, this test also validates that it's ok to set the 'urgent' attribute to false.
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_rem_all.xml",
|
||||
|
@ -594,7 +595,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddRemove() throws Exception {
|
||||
void testSuccess_secDnsAddRemove() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add_rem.xml",
|
||||
ImmutableSet.of(
|
||||
|
@ -606,7 +607,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddRemoveToMaxRecords() throws Exception {
|
||||
void testSuccess_secDnsAddRemoveToMaxRecords() throws Exception {
|
||||
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
builder.add(DelegationSignerData.create(i, 2, 3, new byte[] {0, 1, 2}));
|
||||
|
@ -630,7 +631,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsAddRemoveSame() throws Exception {
|
||||
void testSuccess_secDnsAddRemoveSame() throws Exception {
|
||||
// Adding and removing the same dsData is a no-op because removes are processed first.
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add_rem_same.xml",
|
||||
|
@ -643,13 +644,13 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_secDnsRemoveAlreadyNotThere() throws Exception {
|
||||
void testSuccess_secDnsRemoveAlreadyNotThere() throws Exception {
|
||||
// Removing a dsData that isn't there is a no-op.
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_rem.xml", ImmutableSet.of(SOME_DSDATA), ImmutableSet.of(SOME_DSDATA));
|
||||
}
|
||||
|
||||
public void doServerStatusBillingTest(String xmlFilename, boolean isBillable) throws Exception {
|
||||
void doServerStatusBillingTest(String xmlFilename, boolean isBillable) throws Exception {
|
||||
setEppInput(xmlFilename);
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(
|
||||
|
@ -674,7 +675,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_addServerStatusBillingEvent() throws Exception {
|
||||
void testSuccess_addServerStatusBillingEvent() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -682,7 +683,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_noBillingOnPreExistingServerStatus() throws Exception {
|
||||
void testSuccess_noBillingOnPreExistingServerStatus() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
DomainBase addStatusDomain = persistActiveDomain(getUniqueIdFromCommand());
|
||||
persistResource(
|
||||
|
@ -691,7 +692,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_removeServerStatusBillingEvent() throws Exception {
|
||||
void testSuccess_removeServerStatusBillingEvent() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
DomainBase removeStatusDomain = persistDomain();
|
||||
|
@ -701,7 +702,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_changeServerStatusBillingEvent() throws Exception {
|
||||
void testSuccess_changeServerStatusBillingEvent() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
DomainBase changeStatusDomain = persistDomain();
|
||||
|
@ -711,26 +712,26 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_noBillingEventOnNonServerStatusChange() throws Exception {
|
||||
void testSuccess_noBillingEventOnNonServerStatusChange() throws Exception {
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
doServerStatusBillingTest("domain_update_add_non_server_status.xml", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_noBillingEventOnServerHoldStatusChange() throws Exception {
|
||||
void testSuccess_noBillingEventOnServerHoldStatusChange() throws Exception {
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
doServerStatusBillingTest("domain_update_add_server_hold_status.xml", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_noBillingEventOnServerStatusChangeNotFromRegistrar() throws Exception {
|
||||
void testSuccess_noBillingEventOnServerStatusChangeNotFromRegistrar() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
doServerStatusBillingTest("domain_update_add_server_status_non_registrar.xml", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_superuserClientUpdateProhibited() throws Exception {
|
||||
void testSuccess_superuserClientUpdateProhibited() throws Exception {
|
||||
setEppInput("domain_update_add_server_hold_status.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
|
@ -758,29 +759,29 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_secDnsAllCannotBeFalse() throws Exception {
|
||||
void testFailure_secDnsAllCannotBeFalse() throws Exception {
|
||||
doSecDnsFailingTest(SecDnsAllUsageException.class, "domain_update_dsdata_rem_all_false.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_secDnsEmptyNotAllowed() throws Exception {
|
||||
void testFailure_secDnsEmptyNotAllowed() throws Exception {
|
||||
doSecDnsFailingTest(EmptySecDnsUpdateException.class, "domain_update_dsdata_empty.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_secDnsUrgentNotSupported() throws Exception {
|
||||
void testFailure_secDnsUrgentNotSupported() throws Exception {
|
||||
doSecDnsFailingTest(
|
||||
UrgentAttributeNotSupportedException.class, "domain_update_dsdata_urgent.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_secDnsChangeNotSupported() throws Exception {
|
||||
void testFailure_secDnsChangeNotSupported() throws Exception {
|
||||
doSecDnsFailingTest(
|
||||
MaxSigLifeChangeNotSupportedException.class, "domain_update_maxsiglife.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_secDnsTooManyDsRecords() throws Exception {
|
||||
void testFailure_secDnsTooManyDsRecords() throws Exception {
|
||||
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
builder.add(DelegationSignerData.create(i, 2, 3, new byte[] {0, 1, 2}));
|
||||
|
@ -794,7 +795,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tooManyNameservers() throws Exception {
|
||||
void testFailure_tooManyNameservers() throws Exception {
|
||||
setEppInput("domain_update_add_nameserver.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -805,7 +806,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_wrongExtension() throws Exception {
|
||||
void testFailure_wrongExtension() throws Exception {
|
||||
setEppInput("domain_update_wrong_extension.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -814,7 +815,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_neverExisted() throws Exception {
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
persistReferencedEntities();
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
|
@ -822,7 +823,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_existedButWasDeleted() throws Exception {
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
ResourceDoesNotExistException thrown =
|
||||
|
@ -831,7 +832,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingHost() throws Exception {
|
||||
void testFailure_missingHost() throws Exception {
|
||||
persistActiveHost("ns1.example.foo");
|
||||
persistActiveContact("sh8013");
|
||||
persistActiveContact("mak21");
|
||||
|
@ -842,7 +843,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingContact() throws Exception {
|
||||
void testFailure_missingContact() throws Exception {
|
||||
persistActiveHost("ns1.example.foo");
|
||||
persistActiveHost("ns2.example.foo");
|
||||
persistActiveContact("mak21");
|
||||
|
@ -853,7 +854,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addingDuplicateContact() throws Exception {
|
||||
void testFailure_addingDuplicateContact() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistActiveContact("foo");
|
||||
persistDomain();
|
||||
|
@ -878,7 +879,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_statusValueNotClientSettable() throws Exception {
|
||||
void testFailure_statusValueNotClientSettable() throws Exception {
|
||||
setEppInput("domain_update_prohibited_status.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -887,7 +888,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_superuserStatusValueNotClientSettable() throws Exception {
|
||||
void testSuccess_superuserStatusValueNotClientSettable() throws Exception {
|
||||
setEppInput("domain_update_prohibited_status.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -896,7 +897,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_serverUpdateProhibited_prohibitsNonSuperuserUpdates() throws Exception {
|
||||
void testFailure_serverUpdateProhibited_prohibitsNonSuperuserUpdates() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
newDomainBase(getUniqueIdFromCommand())
|
||||
|
@ -908,7 +909,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_serverUpdateProhibited_allowsSuperuserUpdates() throws Exception {
|
||||
void testSuccess_serverUpdateProhibited_allowsSuperuserUpdates() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(persistDomain().asBuilder().addStatusValue(SERVER_UPDATE_PROHIBITED).build());
|
||||
clock.advanceOneMilli();
|
||||
|
@ -917,7 +918,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_serverUpdateProhibited_notSettableWithoutSuperuser() throws Exception {
|
||||
void testFailure_serverUpdateProhibited_notSettableWithoutSuperuser() throws Exception {
|
||||
setEppInput("domain_update_add_registry_lock.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -926,7 +927,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_serverUpdateProhibited_isSettableWithSuperuser() throws Exception {
|
||||
void testSuccess_serverUpdateProhibited_isSettableWithSuperuser() throws Exception {
|
||||
setEppInput("domain_update_add_registry_lock.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -935,7 +936,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_clientUpdateProhibited() throws Exception {
|
||||
void testFailure_clientUpdateProhibited() throws Exception {
|
||||
createTld("com");
|
||||
setEppInput("domain_update_authinfo.xml");
|
||||
persistReferencedEntities();
|
||||
|
@ -950,7 +951,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_serverUpdateProhibited() throws Exception {
|
||||
void testFailure_serverUpdateProhibited() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
newDomainBase(getUniqueIdFromCommand())
|
||||
|
@ -963,7 +964,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_pendingDelete() throws Exception {
|
||||
void testFailure_pendingDelete() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
newDomainBase(getUniqueIdFromCommand())
|
||||
|
@ -977,7 +978,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_duplicateContactInCommand() throws Exception {
|
||||
void testFailure_duplicateContactInCommand() throws Exception {
|
||||
setEppInput("domain_update_duplicate_contact.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -986,7 +987,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_multipleDuplicateContactInCommand() throws Exception {
|
||||
void testFailure_multipleDuplicateContactInCommand() throws Exception {
|
||||
setEppInput("domain_update_multiple_duplicate_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1001,7 +1002,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingContactType() throws Exception {
|
||||
void testFailure_missingContactType() throws Exception {
|
||||
// We need to test for missing type, but not for invalid - the schema enforces that for us.
|
||||
setEppInput("domain_update_missing_contact_type.xml");
|
||||
persistReferencedEntities();
|
||||
|
@ -1011,7 +1012,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unauthorizedClient() throws Exception {
|
||||
void testFailure_unauthorizedClient() throws Exception {
|
||||
sessionMetadata.setClientId("NewRegistrar");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1020,7 +1021,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
sessionMetadata.setClientId("NewRegistrar");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1030,7 +1031,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_notAuthorizedForTld() throws Exception {
|
||||
void testFailure_notAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
persistReferencedEntities();
|
||||
|
@ -1040,7 +1041,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
persistReferencedEntities();
|
||||
|
@ -1051,7 +1052,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_sameNameserverAddedAndRemoved() throws Exception {
|
||||
void testFailure_sameNameserverAddedAndRemoved() throws Exception {
|
||||
setEppInput("domain_update_add_remove_same_host.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
|
@ -1068,7 +1069,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_sameContactAddedAndRemoved() throws Exception {
|
||||
void testFailure_sameContactAddedAndRemoved() throws Exception {
|
||||
setEppInput("domain_update_add_remove_same_contact.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
|
@ -1086,7 +1087,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_removeAdmin() throws Exception {
|
||||
void testFailure_removeAdmin() throws Exception {
|
||||
setEppInput("domain_update_remove_admin.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
|
@ -1102,7 +1103,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_removeTech() throws Exception {
|
||||
void testFailure_removeTech() throws Exception {
|
||||
setEppInput("domain_update_remove_tech.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
|
@ -1118,7 +1119,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addPendingDeleteContact() throws Exception {
|
||||
void testFailure_addPendingDeleteContact() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
persistActiveHost("ns1.example.foo");
|
||||
|
@ -1137,7 +1138,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addPendingDeleteHost() throws Exception {
|
||||
void testFailure_addPendingDeleteHost() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
persistActiveHost("ns1.example.foo");
|
||||
|
@ -1156,7 +1157,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_newRegistrantNotAllowListed() throws Exception {
|
||||
void testFailure_newRegistrantNotAllowListed() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
persistResource(
|
||||
|
@ -1170,8 +1171,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addedNameserverDisallowedInTld()
|
||||
throws Exception {
|
||||
void testFailure_addedNameserverDisallowedInTld() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
persistResource(
|
||||
|
@ -1186,7 +1186,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_newNameserverAllowListed() throws Exception {
|
||||
void testSuccess_newNameserverAllowListed() throws Exception {
|
||||
setEppInput("domain_update_add_nameserver.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1212,7 +1212,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_changeRegistrantAllowListed() throws Exception {
|
||||
void testSuccess_changeRegistrantAllowListed() throws Exception {
|
||||
setEppInput("domain_update_registrant.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1229,7 +1229,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_changeContactsAndRegistrant() throws Exception {
|
||||
void testSuccess_changeContactsAndRegistrant() throws Exception {
|
||||
setEppInput("domain_update_contacts_and_registrant.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomainWithRegistrant();
|
||||
|
@ -1256,7 +1256,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_nameserverAndRegistrantAllowListed() throws Exception {
|
||||
void testSuccess_nameserverAndRegistrantAllowListed() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
persistResource(
|
||||
|
@ -1269,7 +1269,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_tldWithNameserverAllowList_removeNameserver() throws Exception {
|
||||
void testSuccess_tldWithNameserverAllowList_removeNameserver() throws Exception {
|
||||
setEppInput("domain_update_remove_nameserver.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1301,7 +1301,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tldWithNameserverAllowList_removeLastNameserver() throws Exception {
|
||||
void testFailure_tldWithNameserverAllowList_removeLastNameserver() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
setEppInput("domain_update_remove_nameserver.xml");
|
||||
|
@ -1317,7 +1317,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_domainCreateNotRestricted_doNotApplyServerProhibitedStatusCodes()
|
||||
void testSuccess_domainCreateNotRestricted_doNotApplyServerProhibitedStatusCodes()
|
||||
throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1328,7 +1328,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_freePremium_wrongFee() throws Exception {
|
||||
void testFailure_freePremium_wrongFee() throws Exception {
|
||||
setEppInput("domain_update_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1339,7 +1339,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
// This test should throw an exception, because the fee extension is required when the fee is not
|
||||
// zero.
|
||||
@Test
|
||||
public void testFailure_missingFeeOnNonFreeUpdate() throws Exception {
|
||||
void testFailure_missingFeeOnNonFreeUpdate() throws Exception {
|
||||
setEppInput("domain_update_wildcard.xml", ImmutableMap.of("DOMAIN", "non-free-update.tld"));
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -1349,11 +1349,41 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-dom-update");
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuperuserExtension_turnsOffAutorenew() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_update_superuser_extension.xml", ImmutableMap.of("AUTORENEWS", "false"));
|
||||
DateTime expirationTime = clock.nowUtc().plusYears(3);
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
persistDomain().asBuilder().setRegistrationExpirationTime(expirationTime).build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAsSuperuser();
|
||||
assertAboutDomains().that(reloadResourceByForeignKey()).hasAutorenewEndTime(expirationTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuperuserExtension_turnsOnAutorenew() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_update_superuser_extension.xml", ImmutableMap.of("AUTORENEWS", "true"));
|
||||
DateTime expirationTime = clock.nowUtc().plusYears(3);
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
persistDomain()
|
||||
.asBuilder()
|
||||
.setAutorenewEndTime(Optional.of(expirationTime))
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAsSuperuser();
|
||||
assertAboutDomains().that(reloadResourceByForeignKey()).hasNoAutorenewEndTime();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.testing;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.truth.Fact.fact;
|
||||
import static com.google.common.truth.Fact.simpleFact;
|
||||
import static com.google.common.truth.OptionalSubject.optionals;
|
||||
import static google.registry.model.EppResourceUtils.isActive;
|
||||
import static google.registry.testing.DatastoreHelper.getHistoryEntriesOfType;
|
||||
import static google.registry.testing.HistoryEntrySubject.historyEntries;
|
||||
|
@ -32,6 +33,7 @@ import google.registry.model.reporting.HistoryEntry;
|
|||
import google.registry.testing.TruthChainer.And;
|
||||
import google.registry.testing.TruthChainer.Which;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
@ -190,6 +192,16 @@ abstract class AbstractEppResourceSubject<
|
|||
return andChainer();
|
||||
}
|
||||
|
||||
protected <E> And<S> hasValue(E expected, Optional<E> actual, String name) {
|
||||
check(name).about(optionals()).that(actual).hasValue(expected);
|
||||
return andChainer();
|
||||
}
|
||||
|
||||
protected <E> And<S> hasNoValue(Optional<E> actual, String name) {
|
||||
check(name).about(optionals()).that(actual).isEmpty();
|
||||
return andChainer();
|
||||
}
|
||||
|
||||
protected <E> And<S> doesNotHaveValue(E badValue, E actual, String name) {
|
||||
check(name).that(actual).isNotEqualTo(badValue);
|
||||
return andChainer();
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.testing;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.truth.Fact.simpleFact;
|
||||
import static com.google.common.truth.Truth.assertAbout;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.truth.FailureMetadata;
|
||||
|
@ -102,6 +103,15 @@ public final class DomainBaseSubject
|
|||
return hasValue(smdId, actual.getSmdId(), "getSmdId()");
|
||||
}
|
||||
|
||||
public And<DomainBaseSubject> hasAutorenewEndTime(DateTime autorenewEndTime) {
|
||||
checkArgumentNotNull(autorenewEndTime, "Use hasNoAutorenewEndTime() instead");
|
||||
return hasValue(autorenewEndTime, actual.getAutorenewEndTime(), "getAutorenewEndTime()");
|
||||
}
|
||||
|
||||
public And<DomainBaseSubject> hasNoAutorenewEndTime() {
|
||||
return hasNoValue(actual.getAutorenewEndTime(), "getAutorenewEndTime()");
|
||||
}
|
||||
|
||||
public static SimpleSubjectBuilder<DomainBaseSubject, DomainBase> assertAboutDomains() {
|
||||
return assertAbout(DomainBaseSubject::new);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.collect.Iterables.toArray;
|
|||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -41,6 +42,7 @@ import java.io.PrintStream;
|
|||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
@ -66,7 +68,7 @@ public abstract class CommandTestCase<C extends Command> {
|
|||
|
||||
protected C command;
|
||||
|
||||
public final FakeClock fakeClock = new FakeClock();
|
||||
protected final FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
|
|
|
@ -17,12 +17,9 @@ package google.registry.tools;
|
|||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
@ -30,14 +27,12 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
|||
/** Unit tests for {@link CountDomainsCommand}. */
|
||||
public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand> {
|
||||
|
||||
protected FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@BeforeEach
|
||||
final void beforeEach() {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
command.clock = clock;
|
||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
||||
command.clock = fakeClock;
|
||||
createTlds("foo", "bar", "baz", "qux");
|
||||
}
|
||||
|
||||
|
@ -55,13 +50,12 @@ public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand
|
|||
|
||||
@Test
|
||||
void testSuccess_multipleTlds() throws Exception {
|
||||
command.clock = clock;
|
||||
for (int i = 0; i < 29; i++) {
|
||||
persistActiveDomain(String.format("test-%d.foo", i));
|
||||
}
|
||||
for (int j = 0; j < 17; j++) {
|
||||
persistActiveDomain(String.format("test-%d.baz", j));
|
||||
persistDeletedDomain(String.format("del-%d.foo", j), clock.nowUtc().minusYears(1));
|
||||
persistDeletedDomain(String.format("del-%d.foo", j), fakeClock.nowUtc().minusYears(1));
|
||||
}
|
||||
persistActiveDomain("not-counted.qux");
|
||||
runCommand("--tlds=foo,bar,baz");
|
||||
|
|
|
@ -15,27 +15,52 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.domain.rgp.GracePeriodStatus.AUTO_RENEW;
|
||||
import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED;
|
||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.newContactResource;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainBase;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Flag;
|
||||
import google.registry.model.billing.BillingEvent.Reason;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link UpdateDomainCommand}. */
|
||||
class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand> {
|
||||
|
||||
private DomainBase domain;
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
||||
command.clock = fakeClock;
|
||||
domain = persistActiveDomain("example.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_complete() throws Exception {
|
||||
runCommandForced(
|
||||
|
@ -78,6 +103,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
|
|||
|
||||
@Test
|
||||
void testSuccess_multipleDomains() throws Exception {
|
||||
createTld("abc");
|
||||
persistActiveDomain("example.abc");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_nameservers=ns1.zdns.google,ns2.zdns.google",
|
||||
|
@ -110,7 +137,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
|
|||
}
|
||||
|
||||
private void runTest_multipleDomains_setNameservers(String nsParam) throws Exception {
|
||||
createTlds("abc", "tld");
|
||||
createTld("abc");
|
||||
HostResource host1 = persistActiveHost("foo.bar.tld");
|
||||
HostResource host2 = persistActiveHost("baz.bar.tld");
|
||||
persistResource(
|
||||
|
@ -254,6 +281,59 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
|
|||
eppVerifier.verifySent("domain_update_clear_ds_records.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_enableAutorenew() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--autorenews=true", "example.tld");
|
||||
eppVerifier.verifySent(
|
||||
"domain_update_set_autorenew.xml", ImmutableMap.of("AUTORENEWS", "true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_disableAutorenew() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--autorenews=false", "example.tld");
|
||||
eppVerifier.verifySent(
|
||||
"domain_update_set_autorenew.xml", ImmutableMap.of("AUTORENEWS", "false"));
|
||||
assertThat(getStderrAsString()).doesNotContain("autorenew grace period");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_disableAutorenew_inAutorenewGracePeriod() throws Exception {
|
||||
HistoryEntry createHistoryEntry =
|
||||
persistResource(
|
||||
new HistoryEntry.Builder().setType(DOMAIN_CREATE).setParent(domain).build());
|
||||
BillingEvent.Recurring autorenewBillingEvent =
|
||||
persistResource(
|
||||
new BillingEvent.Recurring.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId("example.tld")
|
||||
.setClientId("NewRegistrar")
|
||||
.setEventTime(fakeClock.nowUtc().minusDays(5))
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setParent(createHistoryEntry)
|
||||
.build());
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.setRegistrationExpirationTime(fakeClock.nowUtc().plusDays(360))
|
||||
.setAutorenewBillingEvent(autorenewBillingEvent.createVKey())
|
||||
.setGracePeriods(
|
||||
ImmutableSet.of(
|
||||
GracePeriod.createForRecurring(
|
||||
AUTO_RENEW,
|
||||
domain.getRepoId(),
|
||||
fakeClock.nowUtc().plusDays(40),
|
||||
"NewRegistrar",
|
||||
autorenewBillingEvent.createVKey())))
|
||||
.build());
|
||||
runCommandForced("--client=NewRegistrar", "--autorenews=false", "example.tld");
|
||||
eppVerifier.verifySent(
|
||||
"domain_update_set_autorenew.xml", ImmutableMap.of("AUTORENEWS", "false"));
|
||||
String stdErr = getStderrAsString();
|
||||
assertThat(stdErr).contains("The following domains are in autorenew grace periods.");
|
||||
assertThat(stdErr).contains("example.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_cantUpdateRegistryLockedDomainEvenAsSuperuser() {
|
||||
HostResource host = persistActiveHost("ns1.zdns.google");
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools.javascrap;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
|
||||
|
@ -144,15 +145,15 @@ class BackfillRegistryLocksCommandTest extends CommandTestCase<BackfillRegistryL
|
|||
"--domain_roids", String.format("%s,%s", ursDomain.getRepoId(), nonUrsDomain.getRepoId()));
|
||||
|
||||
RegistryLock ursLock = getMostRecentVerifiedRegistryLockByRepoId(ursDomain.getRepoId()).get();
|
||||
assertThat(ursLock.getLockCompletionTimestamp().get()).isEqualTo(ursTime);
|
||||
assertThat(ursLock.getLockCompletionTimestamp()).hasValue(ursTime);
|
||||
RegistryLock nonUrsLock =
|
||||
getMostRecentVerifiedRegistryLockByRepoId(nonUrsDomain.getRepoId()).get();
|
||||
assertThat(nonUrsLock.getLockCompletionTimestamp().get()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(nonUrsLock.getLockCompletionTimestamp()).hasValue(fakeClock.nowUtc());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_mustProvideDomainRoids() {
|
||||
assertThat(assertThrows(IllegalArgumentException.class, () -> runCommandForced()))
|
||||
assertThat(assertThrows(IllegalArgumentException.class, this::runCommandForced))
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Must provide non-empty domain_roids argument");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example.tld</domain:name>
|
||||
<domain:chg/>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<superuser:domainUpdate xmlns:superuser="urn:google:params:xml:ns:superuser-1.0">
|
||||
<superuser:autorenews>%AUTORENEWS%</superuser:autorenews>
|
||||
</superuser:domainUpdate>
|
||||
</extension>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example.tld</domain:name>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<superuser:domainUpdate xmlns:superuser="urn:google:params:xml:ns:superuser-1.0">
|
||||
<superuser:autorenews>%AUTORENEWS%</superuser:autorenews>
|
||||
</superuser:domainUpdate>
|
||||
</extension>
|
||||
<clTRID>RegistryTool</clTRID>
|
||||
</command>
|
||||
</epp>
|
Loading…
Add table
Add a link
Reference in a new issue