mirror of
https://github.com/google/nomulus
synced 2026-01-22 05:33:12 +00:00
Compare commits
25 Commits
nomulus-20
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a138806199 | ||
|
|
a5c1412aac | ||
|
|
41393e5f8d | ||
|
|
a7387e975b | ||
|
|
5c6667507b | ||
|
|
c187c92ae4 | ||
|
|
22ca4e3f2b | ||
|
|
f27136458a | ||
|
|
d8e647316e | ||
|
|
d6e0a7b979 | ||
|
|
5725eb95e0 | ||
|
|
aa12998276 | ||
|
|
d415416bc5 | ||
|
|
3a1068f313 | ||
|
|
69e5d40f04 | ||
|
|
64f6cd9af4 | ||
|
|
40184689ca | ||
|
|
826ad85d20 | ||
|
|
2b47bc9b0a | ||
|
|
9555dca8c6 | ||
|
|
49484c06d3 | ||
|
|
81d222e7d6 | ||
|
|
7e9d4c27d1 | ||
|
|
f9c22ff1c5 | ||
|
|
2562d582f3 |
@@ -98,8 +98,8 @@ PRESUBMITS = {
|
||||
"File did not include the license header.",
|
||||
|
||||
# Files must end in a newline
|
||||
PresubmitCheck(r".*\n$", ("java", "js", "soy", "sql", "py", "sh", "gradle", "ts"),
|
||||
{"node_modules/"}, REQUIRED):
|
||||
PresubmitCheck(r".*\n$", ("java", "js", "soy", "sql", "py", "sh", "gradle", "ts", "xml"),
|
||||
{"node_modules/", ".idea"}, REQUIRED):
|
||||
"Source files must end in a newline.",
|
||||
|
||||
# System.(out|err).println should only appear in tools/ or load-testing/
|
||||
|
||||
@@ -50,8 +50,6 @@ import google.registry.config.CredentialModule;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.Contact;
|
||||
import google.registry.model.contact.ContactHistory;
|
||||
import google.registry.model.domain.Domain;
|
||||
import google.registry.model.domain.DomainHistory;
|
||||
import google.registry.model.host.Host;
|
||||
@@ -73,7 +71,6 @@ import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import org.apache.beam.sdk.Pipeline;
|
||||
import org.apache.beam.sdk.PipelineResult;
|
||||
import org.apache.beam.sdk.coders.KvCoder;
|
||||
@@ -138,25 +135,21 @@ import org.joda.time.DateTime;
|
||||
* pairs of (contact/host repo ID: pending deposit) for all RDE pending deposits for further
|
||||
* processing.
|
||||
*
|
||||
* <h3>{@link Contact}</h3>
|
||||
*
|
||||
* We first join most recent contact histories, represented by (contact repo ID: contact history
|
||||
* revision ID) pairs, with referenced contacts, represented by (contact repo ID: pending deposit)
|
||||
* pairs, on the contact repo ID, to remove unreferenced contact histories. Contact resources are
|
||||
* then loaded from the remaining referenced contact histories, and marshalled into (pending
|
||||
* deposit: deposit fragment) pairs.
|
||||
*
|
||||
* <h3>{@link Host}</h3>
|
||||
*
|
||||
* Similar to {@link Contact}, we join the most recent host history with referenced hosts to find
|
||||
* most recent referenced hosts. For external hosts we do the same treatment as we did on contacts
|
||||
* and obtain the (pending deposit: deposit fragment) pairs. For subordinate hosts, we need to find
|
||||
* the superordinate domain in order to properly handle pending transfer in the deposit as well. So
|
||||
* we first find the superordinate domain repo ID from the host and join the (superordinate domain
|
||||
* repo ID: (subordinate host repo ID: (pending deposit: revision ID))) pair with the (domain repo
|
||||
* ID: revision ID) pair obtained from the domain history query in order to map the host at
|
||||
* watermark to the domain at watermark. We then proceed to create the (pending deposit: deposit
|
||||
* fragment) pair for subordinate hosts using the added domain information.
|
||||
* <p>We first join most recent host histories, represented by (host repo ID: host history revision
|
||||
* ID) pairs, with referenced hosts, represented by (host repo ID: pending deposit) pairs, on the
|
||||
* host repo ID, to remove unreferenced host histories. Host resources are then loaded from the
|
||||
* remaining referenced host histories, and marshalled into (pending deposit: deposit fragment)
|
||||
* pairs.
|
||||
*
|
||||
* <p>For subordinate hosts, we need to find the superordinate domain in order to properly handle
|
||||
* pending transfer in the deposit as well. So we first find the superordinate domain repo ID from
|
||||
* the host and join the (superordinate domain repo ID: (subordinate host repo ID: (pending deposit:
|
||||
* revision ID))) pair with the (domain repo ID: revision ID) pair obtained from the domain history
|
||||
* query in order to map the host at watermark to the domain at watermark. We then proceed to create
|
||||
* the (pending deposit: deposit fragment) pair for subordinate hosts using the added domain
|
||||
* information.
|
||||
*
|
||||
* <h2>Processing {@link DepositFragment}</h2>
|
||||
*
|
||||
@@ -184,10 +177,10 @@ public class RdePipeline implements Serializable {
|
||||
private final CloudTasksUtils cloudTasksUtils;
|
||||
private final RdeMarshaller marshaller;
|
||||
|
||||
// Registrars to be excluded from data escrow. Not including the sandbox-only OTE type so that
|
||||
// if sneaks into production we would get an extra signal.
|
||||
// Registrars to be excluded from data escrow (i.e. all registrar types that have a null IANA
|
||||
// identifier and thus would not be valid according to the RDE schema).
|
||||
private static final ImmutableSet<Type> IGNORED_REGISTRAR_TYPES =
|
||||
Sets.immutableEnumSet(Registrar.Type.MONITORING, Registrar.Type.TEST);
|
||||
Sets.immutableEnumSet(Registrar.Type.MONITORING, Registrar.Type.OTE, Registrar.Type.TEST);
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@@ -230,9 +223,6 @@ public class RdePipeline implements Serializable {
|
||||
PCollection<KV<String, Long>> domainHistories =
|
||||
getMostRecentHistoryEntries(pipeline, DomainHistory.class);
|
||||
|
||||
PCollection<KV<String, Long>> contactHistories =
|
||||
getMostRecentHistoryEntries(pipeline, ContactHistory.class);
|
||||
|
||||
PCollection<KV<String, Long>> hostHistories =
|
||||
getMostRecentHistoryEntries(pipeline, HostHistory.class);
|
||||
|
||||
@@ -241,10 +231,6 @@ public class RdePipeline implements Serializable {
|
||||
PCollection<KV<PendingDeposit, DepositFragment>> domainFragments =
|
||||
processedDomainHistories.get(DOMAIN_FRAGMENTS);
|
||||
|
||||
PCollection<KV<PendingDeposit, DepositFragment>> contactFragments =
|
||||
processContactHistories(
|
||||
processedDomainHistories.get(REFERENCED_CONTACTS), contactHistories);
|
||||
|
||||
PCollectionTuple processedHosts =
|
||||
processHostHistories(processedDomainHistories.get(REFERENCED_HOSTS), hostHistories);
|
||||
|
||||
@@ -256,7 +242,6 @@ public class RdePipeline implements Serializable {
|
||||
|
||||
return PCollectionList.of(registrarFragments)
|
||||
.and(domainFragments)
|
||||
.and(contactFragments)
|
||||
.and(externalHostFragments)
|
||||
.and(subordinateHostFragments)
|
||||
.apply(
|
||||
@@ -437,7 +422,6 @@ public class RdePipeline implements Serializable {
|
||||
private PCollectionTuple processDomainHistories(PCollection<KV<String, Long>> domainHistories) {
|
||||
Counter activeDomainCounter = Metrics.counter("RDE", "ActiveDomainBase");
|
||||
Counter domainFragmentCounter = Metrics.counter("RDE", "DomainFragment");
|
||||
Counter referencedContactCounter = Metrics.counter("RDE", "ReferencedContact");
|
||||
Counter referencedHostCounter = Metrics.counter("RDE", "ReferencedHost");
|
||||
return domainHistories.apply(
|
||||
"Map DomainHistory to DepositFragment " + "and emit referenced Contact and Host",
|
||||
@@ -463,19 +447,8 @@ public class RdePipeline implements Serializable {
|
||||
KV.of(
|
||||
pendingDeposit,
|
||||
marshaller.marshalDomain(domain, pendingDeposit.mode())));
|
||||
// Contacts and hosts are only deposited in RDE, not BRDA.
|
||||
// Hosts are only deposited in RDE, not BRDA.
|
||||
if (pendingDeposit.mode() == RdeMode.FULL) {
|
||||
HashSet<Serializable> contacts = new HashSet<>();
|
||||
domain.getAdminContact().ifPresent(c -> contacts.add(c.getKey()));
|
||||
domain.getTechContact().ifPresent(c -> contacts.add(c.getKey()));
|
||||
domain.getRegistrant().ifPresent(c -> contacts.add(c.getKey()));
|
||||
domain.getBillingContact().ifPresent(c -> contacts.add(c.getKey()));
|
||||
referencedContactCounter.inc(contacts.size());
|
||||
contacts.forEach(
|
||||
contactRepoId ->
|
||||
receiver
|
||||
.get(REFERENCED_CONTACTS)
|
||||
.output(KV.of((String) contactRepoId, pendingDeposit)));
|
||||
if (domain.getNsHosts() != null) {
|
||||
referencedHostCounter.inc(domain.getNsHosts().size());
|
||||
domain
|
||||
@@ -497,38 +470,6 @@ public class RdePipeline implements Serializable {
|
||||
DOMAIN_FRAGMENTS, TupleTagList.of(REFERENCED_CONTACTS).and(REFERENCED_HOSTS)));
|
||||
}
|
||||
|
||||
private PCollection<KV<PendingDeposit, DepositFragment>> processContactHistories(
|
||||
PCollection<KV<String, PendingDeposit>> referencedContacts,
|
||||
PCollection<KV<String, Long>> contactHistories) {
|
||||
Counter contactFragmentCounter = Metrics.counter("RDE", "ContactFragment");
|
||||
return removeUnreferencedResource(referencedContacts, contactHistories, Contact.class)
|
||||
.apply(
|
||||
"Map Contact to DepositFragment",
|
||||
FlatMapElements.into(
|
||||
kvs(
|
||||
TypeDescriptor.of(PendingDeposit.class),
|
||||
TypeDescriptor.of(DepositFragment.class)))
|
||||
.via(
|
||||
(KV<String, CoGbkResult> kv) -> {
|
||||
Contact contact =
|
||||
(Contact)
|
||||
loadResourceByHistoryEntryId(
|
||||
ContactHistory.class,
|
||||
kv.getKey(),
|
||||
kv.getValue().getAll(REVISION_ID));
|
||||
DepositFragment fragment = marshaller.marshalContact(contact);
|
||||
ImmutableSet<KV<PendingDeposit, DepositFragment>> fragments =
|
||||
Streams.stream(kv.getValue().getAll(PENDING_DEPOSIT))
|
||||
// The same contact could be used by multiple domains, therefore
|
||||
// matched to the same pending deposit multiple times.
|
||||
.distinct()
|
||||
.map(pendingDeposit -> KV.of(pendingDeposit, fragment))
|
||||
.collect(toImmutableSet());
|
||||
contactFragmentCounter.inc(fragments.size());
|
||||
return fragments;
|
||||
}));
|
||||
}
|
||||
|
||||
private PCollectionTuple processHostHistories(
|
||||
PCollection<KV<String, PendingDeposit>> referencedHosts,
|
||||
PCollection<KV<String, Long>> hostHistories) {
|
||||
|
||||
@@ -1462,6 +1462,12 @@ public final class RegistryConfig {
|
||||
return ImmutableSet.copyOf(config.mosapi.services);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Config("mosapiTldThreadCnt")
|
||||
public static int provideMosapiTldThreads(RegistryConfigSettings config) {
|
||||
return config.mosapi.tldThreadCnt;
|
||||
}
|
||||
|
||||
private static String formatComments(String text) {
|
||||
return Splitter.on('\n').omitEmptyStrings().trimResults().splitToList(text).stream()
|
||||
.map(s -> "# " + s)
|
||||
|
||||
@@ -272,5 +272,6 @@ public class RegistryConfigSettings {
|
||||
public String entityType;
|
||||
public List<String> tlds;
|
||||
public List<String> services;
|
||||
public int tldThreadCnt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,4 +642,8 @@ mosapi:
|
||||
- "epp"
|
||||
- "dnssec"
|
||||
|
||||
# Provides a fixed thread pool for parallel TLD processing.
|
||||
# @see <a href="https://www.icann.org/mosapi-specification.pdf">
|
||||
# ICANN MoSAPI Specification, Section 12.3</a>
|
||||
tldThreadCnt: 4
|
||||
|
||||
|
||||
@@ -322,4 +322,15 @@
|
||||
<service>bsa</service>
|
||||
<schedule>23 8,20 * * *</schedule>
|
||||
</task>
|
||||
|
||||
<task>
|
||||
<url><![CDATA[/_dr/task/triggerMosApiServiceState]]></url>
|
||||
<name>triggerMosApiServiceState</name>
|
||||
<description>
|
||||
Fetches the service state from MosAPI and triggers the metrics status for all TLDs.
|
||||
</description>
|
||||
<!-- Runs every 5 minutes. -->
|
||||
<schedule>*/5 * * * *</schedule>
|
||||
</task>
|
||||
|
||||
</entries>
|
||||
|
||||
@@ -194,13 +194,27 @@ public final class ResourceFlowUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/** Check that the same values aren't being added and removed in an update command. */
|
||||
public static void checkSameValuesNotAddedAndRemoved(
|
||||
ImmutableSet<?> fieldsToAdd, ImmutableSet<?> fieldsToRemove)
|
||||
throws AddRemoveSameValueException {
|
||||
/**
|
||||
* Verifies the adds and removes on a resource.
|
||||
*
|
||||
* <p>This throws an exception in three different situations: if the same value is being both
|
||||
* added and removed, if a value is being added that is already present, or if a value is being
|
||||
* removed that isn't present.
|
||||
*/
|
||||
public static <T> void verifyAddsAndRemoves(
|
||||
ImmutableSet<T> existingFields, ImmutableSet<T> fieldsToAdd, ImmutableSet<T> fieldsToRemove)
|
||||
throws AddRemoveSameValueException,
|
||||
AddExistingValueException,
|
||||
RemoveNonexistentValueException {
|
||||
if (!intersection(fieldsToAdd, fieldsToRemove).isEmpty()) {
|
||||
throw new AddRemoveSameValueException();
|
||||
}
|
||||
if (!intersection(fieldsToAdd, existingFields).isEmpty()) {
|
||||
throw new AddExistingValueException();
|
||||
}
|
||||
if (intersection(fieldsToRemove, existingFields).size() != fieldsToRemove.size()) {
|
||||
throw new RemoveNonexistentValueException();
|
||||
}
|
||||
}
|
||||
|
||||
/** Check that all {@link StatusValue} objects in a set are client-settable. */
|
||||
@@ -266,6 +280,20 @@ public final class ResourceFlowUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/** Cannot add a value that is already present. */
|
||||
public static class AddExistingValueException extends ParameterValuePolicyErrorException {
|
||||
public AddExistingValueException() {
|
||||
super("Cannot add a value that is already present");
|
||||
}
|
||||
}
|
||||
|
||||
/** Cannot remove a value that does not exist. */
|
||||
public static class RemoveNonexistentValueException extends ParameterValuePolicyErrorException {
|
||||
public RemoveNonexistentValueException() {
|
||||
super("Cannot remove a value that does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
/** The specified status value cannot be set by clients. */
|
||||
public static class StatusNotClientSettableException extends ParameterValueRangeErrorException {
|
||||
public StatusNotClientSettableException(String statusValue) {
|
||||
|
||||
@@ -88,6 +88,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
@@ -298,11 +299,13 @@ public final class DomainCheckFlow implements TransactionalFlow {
|
||||
|
||||
boolean shouldUseTieredPricingPromotion =
|
||||
RegistryConfig.getTieredPricingPromotionRegistrarIds().contains(registrarId);
|
||||
ImmutableSet.Builder<CurrencyUnit> currenciesBuilder = new ImmutableSet.Builder<>();
|
||||
for (FeeCheckCommandExtensionItem feeCheckItem : feeCheck.getItems()) {
|
||||
for (String domainName : getDomainNamesToCheckForFee(feeCheckItem, domainNames.keySet())) {
|
||||
FeeCheckResponseExtensionItem.Builder<?> builder = feeCheckItem.createResponseBuilder();
|
||||
Optional<Domain> domain = Optional.ofNullable(domainObjs.get(domainName));
|
||||
Tld tld = Tld.get(domainNames.get(domainName).parent().toString());
|
||||
currenciesBuilder.add(tld.getCurrency());
|
||||
Optional<AllocationToken> token;
|
||||
try {
|
||||
// The precise token to use for this fee request may vary based on the domain or even the
|
||||
@@ -385,7 +388,8 @@ public final class DomainCheckFlow implements TransactionalFlow {
|
||||
responseItems.add(builder.setDomainNameIfSupported(domainName).build());
|
||||
}
|
||||
}
|
||||
return ImmutableList.of(feeCheck.createResponse(responseItems.build()));
|
||||
return ImmutableList.of(
|
||||
feeCheck.createResponse(responseItems.build(), currenciesBuilder.build()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -108,7 +108,8 @@ public final class DomainClaimsCheckFlow implements TransactionalFlow {
|
||||
verifyClaimsPeriodNotEnded(tld, now);
|
||||
}
|
||||
}
|
||||
Optional<String> claimKey = ClaimsListDao.get().getClaimKey(parsedDomain.parts().get(0));
|
||||
Optional<String> claimKey =
|
||||
ClaimsListDao.get(tldStr).getClaimKey(parsedDomain.parts().get(0));
|
||||
launchChecksBuilder.add(
|
||||
LaunchCheck.create(
|
||||
LaunchCheckName.create(claimKey.isPresent(), domainName), claimKey.orElse(null)));
|
||||
|
||||
@@ -280,7 +280,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
checkAllowedAccessToTld(registrarId, tld.getTldStr());
|
||||
checkHasBillingAccount(registrarId, tld.getTldStr());
|
||||
boolean isValidReservedCreate = isValidReservedCreate(domainName, allocationToken);
|
||||
ClaimsList claimsList = ClaimsListDao.get();
|
||||
ClaimsList claimsList = ClaimsListDao.get(tld.getTldStr());
|
||||
verifyIsGaOrSpecialCase(
|
||||
tld,
|
||||
claimsList,
|
||||
@@ -312,7 +312,8 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
// at this point so that we can verify it before the "after validation" extension point.
|
||||
signedMarkId =
|
||||
tmchUtils
|
||||
.verifySignedMarks(launchCreate.get().getSignedMarks(), domainLabel, now)
|
||||
.verifySignedMarks(
|
||||
tld.getTldStr(), launchCreate.get().getSignedMarks(), domainLabel, now)
|
||||
.getId();
|
||||
}
|
||||
verifyNotBlockedByBsa(domainName, tld, now, allocationToken);
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class DomainFlowTmchUtils {
|
||||
}
|
||||
|
||||
public SignedMark verifySignedMarks(
|
||||
ImmutableList<AbstractSignedMark> signedMarks, String domainLabel, DateTime now)
|
||||
String tld, ImmutableList<AbstractSignedMark> signedMarks, String domainLabel, DateTime now)
|
||||
throws EppException {
|
||||
if (signedMarks.size() > 1) {
|
||||
throw new TooManySignedMarksException();
|
||||
@@ -64,7 +64,7 @@ public final class DomainFlowTmchUtils {
|
||||
throw new SignedMarksMustBeEncodedException();
|
||||
}
|
||||
SignedMark signedMark =
|
||||
verifyEncodedSignedMark((EncodedSignedMark) signedMarks.get(0), now);
|
||||
verifyEncodedSignedMark(tld, (EncodedSignedMark) signedMarks.get(0), now);
|
||||
return verifySignedMarkValidForDomainLabel(signedMark, domainLabel);
|
||||
}
|
||||
|
||||
@@ -76,8 +76,9 @@ public final class DomainFlowTmchUtils {
|
||||
return signedMark;
|
||||
}
|
||||
|
||||
public SignedMark verifyEncodedSignedMark(EncodedSignedMark encodedSignedMark, DateTime now)
|
||||
throws EppException {
|
||||
// TODO(b/412715713): remove the tld parameter when RST completes.
|
||||
public SignedMark verifyEncodedSignedMark(
|
||||
String tld, EncodedSignedMark encodedSignedMark, DateTime now) throws EppException {
|
||||
if (!encodedSignedMark.getEncoding().equals("base64")) {
|
||||
throw new Base64RequiredForEncodedSignedMarksException();
|
||||
}
|
||||
@@ -95,7 +96,7 @@ public final class DomainFlowTmchUtils {
|
||||
throw new SignedMarkParsingErrorException();
|
||||
}
|
||||
|
||||
if (SignedMarkRevocationList.get().isSmdRevoked(signedMark.getId(), now)) {
|
||||
if (SignedMarkRevocationList.get(tld).isSmdRevoked(signedMark.getId(), now)) {
|
||||
throw new SignedMarkRevokedErrorException();
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ public class DomainFlowUtils {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
private static void validateFirstLabel(String firstLabel) throws EppException {
|
||||
public static void validateFirstLabel(String firstLabel) throws EppException {
|
||||
if (firstLabel.length() > MAX_LABEL_SIZE) {
|
||||
throw new DomainLabelTooLongException();
|
||||
}
|
||||
@@ -976,23 +976,21 @@ public class DomainFlowUtils {
|
||||
throw new UrgentAttributeNotSupportedException();
|
||||
}
|
||||
// There must be at least one of add/rem/chg, and chg isn't actually supported.
|
||||
if (secDnsUpdate.getChange() != null) {
|
||||
if (secDnsUpdate.getChange().isPresent()) {
|
||||
// The only thing you can change is maxSigLife, and we don't support that at all.
|
||||
throw new MaxSigLifeChangeNotSupportedException();
|
||||
}
|
||||
Add add = secDnsUpdate.getAdd();
|
||||
Remove remove = secDnsUpdate.getRemove();
|
||||
if (add == null && remove == null) {
|
||||
Optional<Add> add = secDnsUpdate.getAdd();
|
||||
Optional<Remove> remove = secDnsUpdate.getRemove();
|
||||
if (add.isEmpty() && remove.isEmpty()) {
|
||||
throw new EmptySecDnsUpdateException();
|
||||
}
|
||||
if (remove != null && Boolean.FALSE.equals(remove.getAll())) {
|
||||
if (remove.isPresent() && Boolean.FALSE.equals(remove.get().getAll())) {
|
||||
throw new SecDnsAllUsageException(); // Explicit all=false is meaningless.
|
||||
}
|
||||
Set<DomainDsData> toAdd = (add == null) ? ImmutableSet.of() : add.getDsData();
|
||||
Set<DomainDsData> toAdd = add.map(Add::getDsData).orElse(ImmutableSet.of());
|
||||
Set<DomainDsData> toRemove =
|
||||
(remove == null)
|
||||
? ImmutableSet.of()
|
||||
: (remove.getAll() == null) ? remove.getDsData() : oldDsData;
|
||||
remove.map(r -> (r.getAll() == null) ? r.getDsData() : oldDsData).orElse(ImmutableSet.of());
|
||||
// RFC 5910 specifies that removes are processed before adds.
|
||||
return ImmutableSet.copyOf(union(difference(oldDsData, toRemove), toAdd));
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import static com.google.common.collect.Sets.union;
|
||||
import static google.registry.dns.DnsUtils.requestDomainDnsRefresh;
|
||||
import static google.registry.flows.FlowUtils.persistEntityChanges;
|
||||
import static google.registry.flows.FlowUtils.validateRegistrarIsLoggedIn;
|
||||
import static google.registry.flows.ResourceFlowUtils.checkSameValuesNotAddedAndRemoved;
|
||||
import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyAddsAndRemoves;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyAllStatusesAreClientSettable;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyNoDisallowedStatuses;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo;
|
||||
@@ -75,6 +75,8 @@ import google.registry.model.domain.fee.FeeUpdateCommandExtension;
|
||||
import google.registry.model.domain.metadata.MetadataExtension;
|
||||
import google.registry.model.domain.secdns.DomainDsData;
|
||||
import google.registry.model.domain.secdns.SecDnsUpdateExtension;
|
||||
import google.registry.model.domain.secdns.SecDnsUpdateExtension.Add;
|
||||
import google.registry.model.domain.secdns.SecDnsUpdateExtension.Remove;
|
||||
import google.registry.model.domain.superuser.DomainUpdateSuperuserExtension;
|
||||
import google.registry.model.eppcommon.AuthInfo;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
@@ -245,12 +247,19 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
private Domain performUpdate(Update command, Domain domain, DateTime now) throws EppException {
|
||||
AddRemove add = command.getInnerAdd();
|
||||
AddRemove remove = command.getInnerRemove();
|
||||
checkSameValuesNotAddedAndRemoved(add.getNameservers(), remove.getNameservers());
|
||||
checkSameValuesNotAddedAndRemoved(add.getContacts(), remove.getContacts());
|
||||
checkSameValuesNotAddedAndRemoved(add.getStatusValues(), remove.getStatusValues());
|
||||
Change change = command.getInnerChange();
|
||||
Optional<SecDnsUpdateExtension> secDnsUpdate =
|
||||
eppInput.getSingleExtension(SecDnsUpdateExtension.class);
|
||||
verifyAddsAndRemoves(domain.getNameservers(), add.getNameservers(), remove.getNameservers());
|
||||
verifyAddsAndRemoves(domain.getContacts(), add.getContacts(), remove.getContacts());
|
||||
verifyAddsAndRemoves(domain.getStatusValues(), add.getStatusValues(), remove.getStatusValues());
|
||||
if (secDnsUpdate.isPresent()) {
|
||||
SecDnsUpdateExtension ext = secDnsUpdate.get();
|
||||
verifyAddsAndRemoves(
|
||||
domain.getDsData(),
|
||||
ext.getAdd().map(Add::getDsData).orElse(ImmutableSet.of()),
|
||||
ext.getRemove().map(Remove::getDsData).orElse(ImmutableSet.of()));
|
||||
}
|
||||
Change change = command.getInnerChange();
|
||||
|
||||
// We have to verify no duplicate contacts _before_ constructing the domain because it is
|
||||
// illegal to construct a domain with duplicate contacts.
|
||||
|
||||
@@ -65,6 +65,7 @@ public final class HostCheckFlow implements TransactionalFlow {
|
||||
ForeignKeyUtils.loadKeys(Host.class, hostnames, clock.nowUtc()).keySet();
|
||||
ImmutableList.Builder<HostCheck> checks = new ImmutableList.Builder<>();
|
||||
for (String hostname : hostnames) {
|
||||
HostFlowUtils.validateHostName(hostname);
|
||||
boolean unused = !existingIds.contains(hostname);
|
||||
checks.add(HostCheck.create(unused, hostname, unused ? null : "In use"));
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ public final class HostCreateFlow implements MutatingFlow {
|
||||
? new SubordinateHostMustHaveIpException()
|
||||
: new UnexpectedExternalHostIpException();
|
||||
}
|
||||
HostFlowUtils.validateInetAddresses(command.getInetAddresses());
|
||||
Host newHost =
|
||||
new Host.Builder()
|
||||
.setCreationRegistrarId(registrarId)
|
||||
|
||||
@@ -14,12 +14,16 @@
|
||||
|
||||
package google.registry.flows.host;
|
||||
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateFirstLabel;
|
||||
import static google.registry.model.EppResourceUtils.isActive;
|
||||
import static google.registry.model.tld.Tlds.findTldForName;
|
||||
import static google.registry.util.DomainNameUtils.canonicalizeHostname;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||
@@ -31,13 +35,17 @@ import google.registry.flows.EppException.StatusProhibitsOperationException;
|
||||
import google.registry.model.ForeignKeyUtils;
|
||||
import google.registry.model.domain.Domain;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.util.Idn;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** Static utility functions for host flows. */
|
||||
public class HostFlowUtils {
|
||||
|
||||
/** Validator for ASCII lowercase letters, digits, and "-_", allowing "." as a separator */
|
||||
private static final CharMatcher HOST_NAME_ALLOWED_CHARS =
|
||||
CharMatcher.inRange('a', 'z').or(CharMatcher.inRange('0', '9').or(CharMatcher.anyOf("-._")));
|
||||
|
||||
/** Checks that a host name is valid. */
|
||||
public static InternetDomainName validateHostName(String name) throws EppException {
|
||||
checkArgumentNotNull(name, "Must specify host name to validate");
|
||||
@@ -49,10 +57,13 @@ public class HostFlowUtils {
|
||||
throw new HostNameNotLowerCaseException(hostNameLowerCase);
|
||||
}
|
||||
try {
|
||||
String hostNamePunyCoded = Idn.toASCII(name);
|
||||
String hostNamePunyCoded = canonicalizeHostname(name);
|
||||
if (!name.equals(hostNamePunyCoded)) {
|
||||
throw new HostNameNotPunyCodedException(hostNamePunyCoded);
|
||||
}
|
||||
if (!HOST_NAME_ALLOWED_CHARS.matchesAllOf(name)) {
|
||||
throw new BadHostNameCharacterException();
|
||||
}
|
||||
InternetDomainName hostName = InternetDomainName.from(name);
|
||||
if (!name.equals(hostName.toString())) {
|
||||
throw new HostNameNotNormalizedException(hostName.toString());
|
||||
@@ -71,6 +82,7 @@ public class HostFlowUtils {
|
||||
if (hostName.parts().size() < effectiveTld.parts().size() + 2) {
|
||||
throw new HostNameTooShallowException();
|
||||
}
|
||||
validateFirstLabel(hostName.parts().getFirst());
|
||||
return hostName;
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new InvalidHostNameException();
|
||||
@@ -98,6 +110,24 @@ public class HostFlowUtils {
|
||||
return superordinateDomain;
|
||||
}
|
||||
|
||||
/** Makes sure that no provided IP addresses are local / loopback addresses. */
|
||||
public static void validateInetAddresses(ImmutableSet<InetAddress> inetAddresses)
|
||||
throws EppException {
|
||||
if (inetAddresses == null) {
|
||||
return;
|
||||
}
|
||||
if (inetAddresses.stream().anyMatch(InetAddress::isLoopbackAddress)) {
|
||||
throw new LoopbackIpNotValidForHostException();
|
||||
}
|
||||
}
|
||||
|
||||
/** Loopback IPs are not valid for hosts. */
|
||||
static class LoopbackIpNotValidForHostException extends ParameterValuePolicyErrorException {
|
||||
public LoopbackIpNotValidForHostException() {
|
||||
super("Loopback IPs are not valid for hosts");
|
||||
}
|
||||
}
|
||||
|
||||
/** Superordinate domain for this hostname does not exist. */
|
||||
static class SuperordinateDomainDoesNotExistException extends ObjectDoesNotExistException {
|
||||
public SuperordinateDomainDoesNotExistException(String domainName) {
|
||||
@@ -180,4 +210,11 @@ public class HostFlowUtils {
|
||||
String.format("Host names must be in normalized format; expected %s", expectedHostName));
|
||||
}
|
||||
}
|
||||
|
||||
/** Host names can only contain a-z, 0-9, '.', '_', and '-'. */
|
||||
static class BadHostNameCharacterException extends ParameterValueSyntaxErrorException {
|
||||
public BadHostNameCharacterException() {
|
||||
super("Host names can only contain a-z, 0-9, '.', '_', and '-'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ import static google.registry.dns.DnsUtils.requestHostDnsRefresh;
|
||||
import static google.registry.dns.RefreshDnsOnHostRenameAction.PARAM_HOST_KEY;
|
||||
import static google.registry.dns.RefreshDnsOnHostRenameAction.QUEUE_HOST_RENAME;
|
||||
import static google.registry.flows.FlowUtils.validateRegistrarIsLoggedIn;
|
||||
import static google.registry.flows.ResourceFlowUtils.checkSameValuesNotAddedAndRemoved;
|
||||
import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyAddsAndRemoves;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyAllStatusesAreClientSettable;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyNoDisallowedStatuses;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership;
|
||||
@@ -159,8 +159,11 @@ public final class HostUpdateFlow implements MutatingFlow {
|
||||
}
|
||||
AddRemove add = command.getInnerAdd();
|
||||
AddRemove remove = command.getInnerRemove();
|
||||
checkSameValuesNotAddedAndRemoved(add.getStatusValues(), remove.getStatusValues());
|
||||
checkSameValuesNotAddedAndRemoved(add.getInetAddresses(), remove.getInetAddresses());
|
||||
verifyAddsAndRemoves(
|
||||
existingHost.getStatusValues(), add.getStatusValues(), remove.getStatusValues());
|
||||
verifyAddsAndRemoves(
|
||||
existingHost.getInetAddresses(), add.getInetAddresses(), remove.getInetAddresses());
|
||||
HostFlowUtils.validateInetAddresses(add.getInetAddresses());
|
||||
VKey<Domain> newSuperordinateDomainKey =
|
||||
newSuperordinateDomain.map(Domain::createVKey).orElse(null);
|
||||
// If the superordinateDomain field is changing, set the lastSuperordinateChange to now.
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package google.registry.model.domain.fee;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.model.eppinput.EppInput.CommandExtension;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
|
||||
@@ -42,4 +44,11 @@ public interface FeeCheckCommandExtension<
|
||||
ImmutableList<C> getItems();
|
||||
|
||||
R createResponse(ImmutableList<? extends FeeCheckResponseExtensionItem> items);
|
||||
|
||||
default R createResponse(
|
||||
ImmutableList<? extends FeeCheckResponseExtensionItem> items,
|
||||
ImmutableSet<CurrencyUnit> currenciesSeen)
|
||||
throws EppException {
|
||||
return createResponse(items);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.google.common.base.Ascii;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.FeeCheckCommandExtensionItem;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
@@ -32,12 +31,13 @@ import org.joda.time.DateTime;
|
||||
* <pre>{@code
|
||||
* <fee:command name="renew" phase="sunrise" subphase="hello">
|
||||
* <fee:period unit="y">1</fee:period>
|
||||
* <fee:class>premium</fee:class>
|
||||
* <fee:date>2017-05-17T13:22:21.0Z</fee:date>
|
||||
* </fee:command>
|
||||
* }</pre>
|
||||
*
|
||||
* <p>The `feeClass` and `feeDate` attributes that are present in version 0.12 are removed from this
|
||||
* version.
|
||||
*/
|
||||
@XmlType(propOrder = {"period", "feeClass", "feeDate"})
|
||||
@XmlType(propOrder = {"period"})
|
||||
public class FeeCheckCommandExtensionItemStdV1 extends FeeCheckCommandExtensionItem {
|
||||
|
||||
/** The default validity period (if not specified) is 1 year for all operations. */
|
||||
@@ -50,12 +50,6 @@ public class FeeCheckCommandExtensionItemStdV1 extends FeeCheckCommandExtensionI
|
||||
|
||||
@XmlAttribute String subphase;
|
||||
|
||||
@XmlElement(name = "class")
|
||||
String feeClass;
|
||||
|
||||
@XmlElement(name = "date")
|
||||
DateTime feeDate;
|
||||
|
||||
/** Version 1.0 does not support domain name or currency in fee extension items. */
|
||||
@Override
|
||||
public boolean isDomainNameSupported() {
|
||||
@@ -107,6 +101,6 @@ public class FeeCheckCommandExtensionItemStdV1 extends FeeCheckCommandExtensionI
|
||||
|
||||
@Override
|
||||
public Optional<DateTime> getEffectiveDate() {
|
||||
return Optional.ofNullable(feeDate);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ package google.registry.model.domain.feestdv1;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.ParameterValuePolicyErrorException;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.domain.fee.FeeCheckCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
|
||||
@@ -51,13 +54,33 @@ public class FeeCheckCommandExtensionStdV1 extends ImmutableObject
|
||||
@Override
|
||||
public FeeCheckResponseExtensionStdV1 createResponse(
|
||||
ImmutableList<? extends FeeCheckResponseExtensionItem> items) {
|
||||
throw new UnsupportedOperationException("FeeCheckCommandExtensionStdV1 requires a currency");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeeCheckResponseExtensionStdV1 createResponse(
|
||||
ImmutableList<? extends FeeCheckResponseExtensionItem> items,
|
||||
ImmutableSet<CurrencyUnit> currenciesSeen)
|
||||
throws EppException {
|
||||
ImmutableList.Builder<FeeCheckResponseExtensionItemStdV1> builder =
|
||||
new ImmutableList.Builder<>();
|
||||
for (FeeCheckResponseExtensionItem item : items) {
|
||||
if (item instanceof FeeCheckResponseExtensionItemStdV1) {
|
||||
builder.add((FeeCheckResponseExtensionItemStdV1) item);
|
||||
if (item instanceof FeeCheckResponseExtensionItemStdV1 stdv1Item) {
|
||||
builder.add(stdv1Item);
|
||||
}
|
||||
}
|
||||
return FeeCheckResponseExtensionStdV1.create(currency, builder.build());
|
||||
if (currenciesSeen.size() > 1) {
|
||||
throw new MultipleCurrenciesCannotBeCheckedException();
|
||||
}
|
||||
return FeeCheckResponseExtensionStdV1.create(currenciesSeen.iterator().next(), builder.build());
|
||||
}
|
||||
|
||||
/** Domains across multiple currencies cannot be checked simultaneously. */
|
||||
public static class MultipleCurrenciesCannotBeCheckedException
|
||||
extends ParameterValuePolicyErrorException {
|
||||
public MultipleCurrenciesCannotBeCheckedException() {
|
||||
// The fee extension 1.0 only supports one currency shared across all results
|
||||
super("Domains across multiple currencies cannot be checked simultaneously");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,11 @@ import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import java.util.List;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** The version 1.0 response command entity for a domain check on a single resource. */
|
||||
@XmlType(propOrder = {"period", "fee", "feeClass", "effectiveDate", "notAfterDate"})
|
||||
@XmlType(propOrder = {"period", "fee"})
|
||||
public class FeeCheckResponseExtensionItemCommandStdV1 extends ImmutableObject {
|
||||
|
||||
/** The command that was checked. */
|
||||
@@ -53,26 +51,6 @@ public class FeeCheckResponseExtensionItemCommandStdV1 extends ImmutableObject {
|
||||
*/
|
||||
List<Fee> fee;
|
||||
|
||||
/**
|
||||
* The type of the fee.
|
||||
*
|
||||
* <p>We will use "premium" for fees on premium names, and omit the field otherwise.
|
||||
*/
|
||||
@XmlElement(name = "class")
|
||||
String feeClass;
|
||||
|
||||
/** The effective date that the check is to be performed on (if specified in the query). */
|
||||
@XmlElement(name = "date")
|
||||
DateTime effectiveDate;
|
||||
|
||||
/** The date after which the quoted fee is no longer valid (if applicable). */
|
||||
@XmlElement(name = "notAfter")
|
||||
DateTime notAfterDate;
|
||||
|
||||
public String getFeeClass() {
|
||||
return feeClass;
|
||||
}
|
||||
|
||||
/** Builder for {@link FeeCheckResponseExtensionItemCommandStdV1}. */
|
||||
public static class Builder extends Buildable.Builder<FeeCheckResponseExtensionItemCommandStdV1> {
|
||||
|
||||
@@ -96,24 +74,9 @@ public class FeeCheckResponseExtensionItemCommandStdV1 extends ImmutableObject {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setEffectiveDate(DateTime effectiveDate) {
|
||||
getInstance().effectiveDate = effectiveDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setNotAfterDate(DateTime notAfterDate) {
|
||||
getInstance().notAfterDate = notAfterDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setFee(List<Fee> fees) {
|
||||
getInstance().fee = forceEmptyToNull(ImmutableList.copyOf(fees));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setClass(String feeClass) {
|
||||
getInstance().feeClass = feeClass;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,20 +17,18 @@ package google.registry.model.domain.feestdv1;
|
||||
import static google.registry.util.CollectionUtils.forceEmptyToNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.domain.DomainObjectSpec;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
|
||||
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** The version 1.0 response for a domain check on a single resource. */
|
||||
@XmlType(propOrder = {"object", "command"})
|
||||
@XmlType(propOrder = {"objID", "feeClass", "command"})
|
||||
public class FeeCheckResponseExtensionItemStdV1 extends FeeCheckResponseExtensionItem {
|
||||
|
||||
/** The domain that was checked. */
|
||||
DomainObjectSpec object;
|
||||
String objID;
|
||||
|
||||
/** The command that was checked. */
|
||||
FeeCheckResponseExtensionItemCommandStdV1 command;
|
||||
@@ -53,15 +51,6 @@ public class FeeCheckResponseExtensionItemStdV1 extends FeeCheckResponseExtensio
|
||||
return super.getFees();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not annotated for JAXB because this version of the extension doesn't support
|
||||
* "feeClass" and because the data comes off of the command object rather than a field.
|
||||
*/
|
||||
@Override
|
||||
public String getFeeClass() {
|
||||
return command.getFeeClass();
|
||||
}
|
||||
|
||||
/** Builder for {@link FeeCheckResponseExtensionItemStdV1}. */
|
||||
public static class Builder
|
||||
extends FeeCheckResponseExtensionItem.Builder<FeeCheckResponseExtensionItemStdV1> {
|
||||
@@ -91,13 +80,13 @@ public class FeeCheckResponseExtensionItemStdV1 extends FeeCheckResponseExtensio
|
||||
|
||||
@Override
|
||||
public Builder setClass(String feeClass) {
|
||||
commandBuilder.setClass(feeClass);
|
||||
super.setClass(feeClass);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setDomainNameIfSupported(String name) {
|
||||
getInstance().object = new DomainObjectSpec(name);
|
||||
getInstance().objID = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -106,17 +95,5 @@ public class FeeCheckResponseExtensionItemStdV1 extends FeeCheckResponseExtensio
|
||||
getInstance().command = commandBuilder.build();
|
||||
return super.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setEffectiveDateIfSupported(DateTime effectiveDate) {
|
||||
commandBuilder.setEffectiveDate(effectiveDate);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setNotAfterDateIfSupported(DateTime notAfterDate) {
|
||||
commandBuilder.setNotAfterDate(notAfterDate);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
@Access(AccessType.FIELD)
|
||||
public abstract class DomainDsDataBase extends ImmutableObject implements UnsafeSerializable {
|
||||
|
||||
@XmlTransient @Transient String domainRepoId;
|
||||
@XmlTransient @Transient @Insignificant String domainRepoId;
|
||||
|
||||
/** The identifier for this particular key in the domain. */
|
||||
@Transient int keyTag;
|
||||
|
||||
@@ -24,6 +24,7 @@ import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlTransient;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/** The EPP secDNS extension that may be present on domain update commands. */
|
||||
@@ -55,16 +56,16 @@ public class SecDnsUpdateExtension extends ImmutableObject implements CommandExt
|
||||
return urgent;
|
||||
}
|
||||
|
||||
public Remove getRemove() {
|
||||
return remove;
|
||||
public Optional<Remove> getRemove() {
|
||||
return Optional.ofNullable(remove);
|
||||
}
|
||||
|
||||
public Add getAdd() {
|
||||
return add;
|
||||
public Optional<Add> getAdd() {
|
||||
return Optional.ofNullable(add);
|
||||
}
|
||||
|
||||
public Change getChange() {
|
||||
return change;
|
||||
public Optional<Change> getChange() {
|
||||
return Optional.ofNullable(change);
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
|
||||
@@ -14,13 +14,16 @@
|
||||
|
||||
package google.registry.model.eppcommon;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import google.registry.xml.ValidationMode;
|
||||
import google.registry.xml.XmlException;
|
||||
import google.registry.xml.XmlTransformer;
|
||||
@@ -31,7 +34,7 @@ import java.io.ByteArrayOutputStream;
|
||||
public class EppXmlTransformer {
|
||||
|
||||
// Hardcoded XML schemas, ordered with respect to dependency.
|
||||
private static final ImmutableList<String> SCHEMAS =
|
||||
private static final ImmutableList<String> ALL_SCHEMAS =
|
||||
ImmutableList.of(
|
||||
"eppcom.xsd",
|
||||
"epp.xsd",
|
||||
@@ -54,11 +57,24 @@ public class EppXmlTransformer {
|
||||
"allocationToken-1.0.xsd",
|
||||
"bulkToken.xsd");
|
||||
|
||||
// XML schemas that should not be used in production (yet)
|
||||
private static final ImmutableSet<String> NON_PROD_SCHEMAS = ImmutableSet.of("fee-std-v1.xsd");
|
||||
|
||||
private static final XmlTransformer INPUT_TRANSFORMER =
|
||||
new XmlTransformer(SCHEMAS, EppInput.class);
|
||||
new XmlTransformer(getSchemas(), EppInput.class);
|
||||
|
||||
private static final XmlTransformer OUTPUT_TRANSFORMER =
|
||||
new XmlTransformer(SCHEMAS, EppOutput.class);
|
||||
new XmlTransformer(getSchemas(), EppOutput.class);
|
||||
|
||||
@VisibleForTesting
|
||||
public static ImmutableList<String> getSchemas() {
|
||||
if (RegistryEnvironment.get().equals(RegistryEnvironment.PRODUCTION)) {
|
||||
return ALL_SCHEMAS.stream()
|
||||
.filter(s -> !NON_PROD_SCHEMAS.contains(s))
|
||||
.collect(toImmutableList());
|
||||
}
|
||||
return ALL_SCHEMAS;
|
||||
}
|
||||
|
||||
public static void validateOutput(String xml) throws XmlException {
|
||||
OUTPUT_TRANSFORMER.validate(xml);
|
||||
|
||||
@@ -17,6 +17,7 @@ package google.registry.model.eppcommon;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Maps.uniqueIndex;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.domain.fee06.FeeCheckCommandExtensionV06;
|
||||
@@ -33,6 +34,8 @@ import google.registry.model.domain.rgp.RgpUpdateExtension;
|
||||
import google.registry.model.domain.secdns.SecDnsCreateExtension;
|
||||
import google.registry.model.eppinput.EppInput.CommandExtension;
|
||||
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
|
||||
import google.registry.util.NonFinalForTesting;
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import jakarta.xml.bind.annotation.XmlSchema;
|
||||
import java.util.EnumSet;
|
||||
|
||||
@@ -48,30 +51,49 @@ public class ProtocolDefinition {
|
||||
"urn:ietf:params:xml:ns:domain-1.0",
|
||||
"urn:ietf:params:xml:ns:contact-1.0");
|
||||
|
||||
/** Enums repesenting valid service extensions that are recognized by the server. */
|
||||
/** Enum representing which environments should have which service extensions enabled. */
|
||||
private enum ServiceExtensionVisibility {
|
||||
ALL,
|
||||
ONLY_IN_NON_PRODUCTION,
|
||||
NONE
|
||||
}
|
||||
|
||||
/** Enum representing valid service extensions that are recognized by the server. */
|
||||
public enum ServiceExtension {
|
||||
LAUNCH_EXTENSION_1_0(LaunchCreateExtension.class, null, true),
|
||||
REDEMPTION_GRACE_PERIOD_1_0(RgpUpdateExtension.class, null, true),
|
||||
SECURE_DNS_1_1(SecDnsCreateExtension.class, null, true),
|
||||
FEE_0_6(FeeCheckCommandExtensionV06.class, FeeCheckResponseExtensionV06.class, true),
|
||||
FEE_0_11(FeeCheckCommandExtensionV11.class, FeeCheckResponseExtensionV11.class, true),
|
||||
FEE_0_12(FeeCheckCommandExtensionV12.class, FeeCheckResponseExtensionV12.class, true),
|
||||
FEE_1_00(FeeCheckCommandExtensionStdV1.class, FeeCheckResponseExtensionStdV1.class, false),
|
||||
METADATA_1_0(MetadataExtension.class, null, false);
|
||||
LAUNCH_EXTENSION_1_0(LaunchCreateExtension.class, null, ServiceExtensionVisibility.ALL),
|
||||
REDEMPTION_GRACE_PERIOD_1_0(RgpUpdateExtension.class, null, ServiceExtensionVisibility.ALL),
|
||||
SECURE_DNS_1_1(SecDnsCreateExtension.class, null, ServiceExtensionVisibility.ALL),
|
||||
FEE_0_6(
|
||||
FeeCheckCommandExtensionV06.class,
|
||||
FeeCheckResponseExtensionV06.class,
|
||||
ServiceExtensionVisibility.ALL),
|
||||
FEE_0_11(
|
||||
FeeCheckCommandExtensionV11.class,
|
||||
FeeCheckResponseExtensionV11.class,
|
||||
ServiceExtensionVisibility.ALL),
|
||||
FEE_0_12(
|
||||
FeeCheckCommandExtensionV12.class,
|
||||
FeeCheckResponseExtensionV12.class,
|
||||
ServiceExtensionVisibility.ALL),
|
||||
FEE_1_00(
|
||||
FeeCheckCommandExtensionStdV1.class,
|
||||
FeeCheckResponseExtensionStdV1.class,
|
||||
ServiceExtensionVisibility.ONLY_IN_NON_PRODUCTION),
|
||||
METADATA_1_0(MetadataExtension.class, null, ServiceExtensionVisibility.NONE);
|
||||
|
||||
private final Class<? extends CommandExtension> commandExtensionClass;
|
||||
private final Class<? extends ResponseExtension> responseExtensionClass;
|
||||
private final String uri;
|
||||
private final boolean visible;
|
||||
private final ServiceExtensionVisibility visibility;
|
||||
|
||||
ServiceExtension(
|
||||
Class<? extends CommandExtension> commandExtensionClass,
|
||||
Class<? extends ResponseExtension> responseExtensionClass,
|
||||
boolean visible) {
|
||||
ServiceExtensionVisibility visibility) {
|
||||
this.commandExtensionClass = commandExtensionClass;
|
||||
this.responseExtensionClass = responseExtensionClass;
|
||||
this.uri = getCommandExtensionUri(commandExtensionClass);
|
||||
this.visible = visible;
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
public Class<? extends CommandExtension> getCommandExtensionClass() {
|
||||
@@ -86,14 +108,19 @@ public class ProtocolDefinition {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public boolean getVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
/** Returns the namespace URI of the command extension class. */
|
||||
public static String getCommandExtensionUri(Class<? extends CommandExtension> clazz) {
|
||||
return clazz.getPackage().getAnnotation(XmlSchema.class).namespace();
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return switch (visibility) {
|
||||
case ALL -> true;
|
||||
case ONLY_IN_NON_PRODUCTION ->
|
||||
!RegistryEnvironment.get().equals(RegistryEnvironment.PRODUCTION);
|
||||
case NONE -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,15 +137,25 @@ public class ProtocolDefinition {
|
||||
}
|
||||
|
||||
/** A set of all the visible extension URIs. */
|
||||
private static final ImmutableSet<String> visibleServiceExtensionUris =
|
||||
EnumSet.allOf(ServiceExtension.class)
|
||||
.stream()
|
||||
.filter(ServiceExtension::getVisible)
|
||||
.map(ServiceExtension::getUri)
|
||||
.collect(toImmutableSet());
|
||||
// TODO(gbrodman): make this final when we can actually remove the old fee extensions and aren't
|
||||
// relying on switching by environment
|
||||
@NonFinalForTesting private static ImmutableSet<String> visibleServiceExtensionUris;
|
||||
|
||||
static {
|
||||
reloadServiceExtensionUris();
|
||||
}
|
||||
|
||||
/** Return the set of all visible service extension URIs. */
|
||||
public static ImmutableSet<String> getVisibleServiceExtensionUris() {
|
||||
return visibleServiceExtensionUris;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void reloadServiceExtensionUris() {
|
||||
visibleServiceExtensionUris =
|
||||
EnumSet.allOf(ServiceExtension.class).stream()
|
||||
.filter(ServiceExtension::isVisible)
|
||||
.map(ServiceExtension::getUri)
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.tmch.RstTmchUtils;
|
||||
import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
@@ -71,6 +72,11 @@ public class SignedMarkRevocationList extends ImmutableObject {
|
||||
return CACHE.get();
|
||||
}
|
||||
|
||||
// TODO(b/412715713): remove the tld parameter when RST completes.
|
||||
public static SignedMarkRevocationList get(String tld) {
|
||||
return RstTmchUtils.getSmdrList(tld).orElseGet(SignedMarkRevocationList::get);
|
||||
}
|
||||
|
||||
/** Create a new {@link SignedMarkRevocationList} without saving it. */
|
||||
public static SignedMarkRevocationList create(
|
||||
DateTime creationTime, ImmutableMap<String, DateTime> revokes) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.model.CacheUtils;
|
||||
import google.registry.tmch.RstTmchUtils;
|
||||
import java.time.Duration;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -72,6 +73,11 @@ public class ClaimsListDao {
|
||||
return CACHE.get(ClaimsListDao.class);
|
||||
}
|
||||
|
||||
// TODO(b/412715713): remove the tld parameter when RST completes.
|
||||
public static ClaimsList get(String tld) {
|
||||
return RstTmchUtils.getClaimsList(tld).orElseGet(ClaimsListDao::get);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the most recent revision of the {@link ClaimsList} in SQL or an empty list if it
|
||||
* doesn't exist.
|
||||
|
||||
@@ -62,6 +62,9 @@ import google.registry.module.ReadinessProbeAction.ReadinessProbeActionFrontend;
|
||||
import google.registry.module.ReadinessProbeAction.ReadinessProbeActionPubApi;
|
||||
import google.registry.module.ReadinessProbeAction.ReadinessProbeConsoleAction;
|
||||
import google.registry.monitoring.whitebox.WhiteboxModule;
|
||||
import google.registry.mosapi.GetServiceStateAction;
|
||||
import google.registry.mosapi.TriggerServiceStateAction;
|
||||
import google.registry.mosapi.module.MosApiRequestModule;
|
||||
import google.registry.rdap.RdapAutnumAction;
|
||||
import google.registry.rdap.RdapDomainAction;
|
||||
import google.registry.rdap.RdapDomainSearchAction;
|
||||
@@ -151,6 +154,7 @@ import google.registry.ui.server.console.settings.SecurityAction;
|
||||
EppToolModule.class,
|
||||
IcannReportingModule.class,
|
||||
LoadTestModule.class,
|
||||
MosApiRequestModule.class,
|
||||
RdapModule.class,
|
||||
RdeModule.class,
|
||||
ReportingModule.class,
|
||||
@@ -232,6 +236,8 @@ interface RequestComponent {
|
||||
|
||||
GenerateZoneFilesAction generateZoneFilesAction();
|
||||
|
||||
GetServiceStateAction getServiceStateAction();
|
||||
|
||||
IcannReportingStagingAction icannReportingStagingAction();
|
||||
|
||||
IcannReportingUploadAction icannReportingUploadAction();
|
||||
@@ -334,6 +340,8 @@ interface RequestComponent {
|
||||
|
||||
TmchSmdrlAction tmchSmdrlAction();
|
||||
|
||||
TriggerServiceStateAction triggerServiceStateAction();
|
||||
|
||||
UpdateRegistrarRdapBaseUrlsAction updateRegistrarRdapBaseUrlsAction();
|
||||
|
||||
UpdateUserGroupAction updateUserGroupAction();
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// Copyright 2017 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.monitoring.whitebox;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.monitoring.metrics.LabelDescriptor;
|
||||
import com.google.monitoring.metrics.MetricRegistry;
|
||||
import com.google.monitoring.metrics.MetricRegistryImpl;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
|
||||
/** Exposes JVM metrics. */
|
||||
@Singleton
|
||||
class JvmMetrics {
|
||||
|
||||
private static final ImmutableSet<LabelDescriptor> TYPE_LABEL_SET =
|
||||
ImmutableSet.of(LabelDescriptor.create("type", "Memory type (e.g., heap, non_heap)"));
|
||||
private final MemoryMXBean memoryMxBean;
|
||||
|
||||
@Inject
|
||||
JvmMetrics() {
|
||||
this(ManagementFactory.getMemoryMXBean());
|
||||
}
|
||||
|
||||
/** Constructor for testing. */
|
||||
JvmMetrics(MemoryMXBean memoryMxBean) {
|
||||
this.memoryMxBean = memoryMxBean;
|
||||
}
|
||||
|
||||
/** Registers JVM gauges with the default registry. */
|
||||
void register() {
|
||||
MetricRegistry registry = MetricRegistryImpl.getDefault();
|
||||
|
||||
registry.newGauge(
|
||||
"/jvm/memory/used",
|
||||
"Current memory usage in bytes",
|
||||
"bytes",
|
||||
TYPE_LABEL_SET,
|
||||
(Supplier<ImmutableMap<ImmutableList<String>, Long>>) this::getUsedMemory,
|
||||
Long.class);
|
||||
|
||||
registry.newGauge(
|
||||
"/jvm/memory/committed",
|
||||
"Committed memory in bytes",
|
||||
"bytes",
|
||||
TYPE_LABEL_SET,
|
||||
(Supplier<ImmutableMap<ImmutableList<String>, Long>>) this::getCommittedMemory,
|
||||
Long.class);
|
||||
|
||||
registry.newGauge(
|
||||
"/jvm/memory/max",
|
||||
"Maximum memory in bytes",
|
||||
"bytes",
|
||||
TYPE_LABEL_SET,
|
||||
(Supplier<ImmutableMap<ImmutableList<String>, Long>>) this::getMaxMemory,
|
||||
Long.class);
|
||||
}
|
||||
|
||||
ImmutableMap<ImmutableList<String>, Long> getUsedMemory() {
|
||||
MemoryUsage heapUsage = memoryMxBean.getHeapMemoryUsage();
|
||||
MemoryUsage nonHeapUsage = memoryMxBean.getNonHeapMemoryUsage();
|
||||
|
||||
return ImmutableMap.of(
|
||||
ImmutableList.of("heap"), heapUsage.getUsed(),
|
||||
ImmutableList.of("non_heap"), nonHeapUsage.getUsed());
|
||||
}
|
||||
|
||||
ImmutableMap<ImmutableList<String>, Long> getCommittedMemory() {
|
||||
MemoryUsage heapUsage = memoryMxBean.getHeapMemoryUsage();
|
||||
MemoryUsage nonHeapUsage = memoryMxBean.getNonHeapMemoryUsage();
|
||||
|
||||
return ImmutableMap.of(
|
||||
ImmutableList.of("heap"), heapUsage.getCommitted(),
|
||||
ImmutableList.of("non_heap"), nonHeapUsage.getCommitted());
|
||||
}
|
||||
|
||||
ImmutableMap<ImmutableList<String>, Long> getMaxMemory() {
|
||||
MemoryUsage heapUsage = memoryMxBean.getHeapMemoryUsage();
|
||||
MemoryUsage nonHeapUsage = memoryMxBean.getNonHeapMemoryUsage();
|
||||
|
||||
return ImmutableMap.of(
|
||||
ImmutableList.of("heap"), heapUsage.getMax(),
|
||||
ImmutableList.of("non_heap"), nonHeapUsage.getMax());
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
/** Dagger module for Google Stackdriver service connection objects. */
|
||||
/** Dagger module for monitoring and Google Stackdriver service connection objects. */
|
||||
@Module
|
||||
public final class StackdriverModule {
|
||||
|
||||
@@ -77,7 +77,11 @@ public final class StackdriverModule {
|
||||
|
||||
@Provides
|
||||
static MetricReporter provideMetricReporter(
|
||||
MetricWriter metricWriter, @Config("metricsWriteInterval") Duration writeInterval) {
|
||||
MetricWriter metricWriter,
|
||||
@Config("metricsWriteInterval") Duration writeInterval,
|
||||
JvmMetrics jvmMetrics) {
|
||||
jvmMetrics.register();
|
||||
|
||||
return new MetricReporter(
|
||||
metricWriter,
|
||||
writeInterval.getStandardSeconds(),
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2025 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.mosapi;
|
||||
|
||||
import com.google.common.net.MediaType;
|
||||
import com.google.gson.Gson;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.HttpException.ServiceUnavailableException;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
||||
import jakarta.inject.Inject;
|
||||
import java.util.Optional;
|
||||
|
||||
/** An action that returns the current MoSAPI service state for a given TLD or all TLDs. */
|
||||
@Action(
|
||||
service = Action.Service.BACKEND,
|
||||
path = GetServiceStateAction.PATH,
|
||||
method = Action.Method.GET,
|
||||
auth = Auth.AUTH_ADMIN)
|
||||
public class GetServiceStateAction implements Runnable {
|
||||
|
||||
public static final String PATH = "/_dr/mosapi/getServiceState";
|
||||
public static final String TLD_PARAM = "tld";
|
||||
|
||||
private final MosApiStateService stateService;
|
||||
private final Response response;
|
||||
private final Gson gson;
|
||||
private final Optional<String> tld;
|
||||
|
||||
@Inject
|
||||
public GetServiceStateAction(
|
||||
MosApiStateService stateService,
|
||||
Response response,
|
||||
Gson gson,
|
||||
@Parameter(TLD_PARAM) Optional<String> tld) {
|
||||
this.stateService = stateService;
|
||||
this.response = response;
|
||||
this.gson = gson;
|
||||
this.tld = tld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
response.setContentType(MediaType.JSON_UTF_8);
|
||||
try {
|
||||
if (tld.isPresent()) {
|
||||
response.setPayload(gson.toJson(stateService.getServiceStateSummary(tld.get())));
|
||||
} else {
|
||||
response.setPayload(gson.toJson(stateService.getAllServiceStateSummaries()));
|
||||
}
|
||||
} catch (MosApiException e) {
|
||||
throw new ServiceUnavailableException("Error fetching MoSAPI service state.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.mosapi.model;
|
||||
package google.registry.mosapi;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
/**
|
||||
* Represents the generic JSON error response from the MoSAPI service for a 400 Bad Request.
|
||||
@@ -20,4 +22,5 @@ package google.registry.mosapi.model;
|
||||
* @see <a href="https://www.icann.org/mosapi-specification.pdf">ICANN MoSAPI Specification, Section
|
||||
* 8</a>
|
||||
*/
|
||||
public record MosApiErrorResponse(String resultCode, String message, String description) {}
|
||||
public record MosApiErrorResponse(
|
||||
@Expose String resultCode, @Expose String message, @Expose String description) {}
|
||||
@@ -17,7 +17,6 @@ package google.registry.mosapi;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import google.registry.mosapi.model.MosApiErrorResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -42,6 +41,11 @@ public class MosApiException extends IOException {
|
||||
this.errorResponse = null;
|
||||
}
|
||||
|
||||
public MosApiException(String message) {
|
||||
super(message);
|
||||
this.errorResponse = null;
|
||||
}
|
||||
|
||||
public Optional<MosApiErrorResponse> getErrorResponse() {
|
||||
return Optional.ofNullable(errorResponse);
|
||||
}
|
||||
|
||||
34
core/src/main/java/google/registry/mosapi/MosApiMetrics.java
Normal file
34
core/src/main/java/google/registry/mosapi/MosApiMetrics.java
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2026 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.mosapi;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.mosapi.MosApiModels.TldServiceState;
|
||||
import jakarta.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
/** Metrics Exporter for MoSAPI. */
|
||||
public class MosApiMetrics {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject
|
||||
public MosApiMetrics() {}
|
||||
|
||||
public void recordStates(List<TldServiceState> states) {
|
||||
// b/467541269: Logic to push status to Cloud Monitoring goes here
|
||||
logger.atInfo().log("MoSAPI record metrics logic will be implemented from here");
|
||||
}
|
||||
}
|
||||
122
core/src/main/java/google/registry/mosapi/MosApiModels.java
Normal file
122
core/src/main/java/google/registry/mosapi/MosApiModels.java
Normal file
@@ -0,0 +1,122 @@
|
||||
// Copyright 2025 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.mosapi;
|
||||
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Data models for ICANN MoSAPI. */
|
||||
public final class MosApiModels {
|
||||
|
||||
private MosApiModels() {}
|
||||
|
||||
/**
|
||||
* A wrapper response containing the state summaries of all monitored services.
|
||||
*
|
||||
* <p>This corresponds to the collection of service statuses returned when monitoring the state of
|
||||
* a TLD
|
||||
*
|
||||
* @see <a href="https://www.icann.org/mosapi-specification.pdf">ICANN MoSAPI Specification,
|
||||
* Section 5.1</a>
|
||||
*/
|
||||
public record AllServicesStateResponse(
|
||||
// A list of state summaries for each monitored service (e.g. DNS, RDDS, etc.)
|
||||
@Expose List<ServiceStateSummary> serviceStates) {
|
||||
|
||||
public AllServicesStateResponse {
|
||||
serviceStates = nullToEmptyImmutableCopy(serviceStates);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A summary of a service incident.
|
||||
*
|
||||
* @see <a href="https://www.icann.org/mosapi-specification.pdf">ICANN MoSAPI Specification,
|
||||
* Section 5.1</a>
|
||||
*/
|
||||
public record IncidentSummary(
|
||||
@Expose String incidentID,
|
||||
@Expose long startTime,
|
||||
@Expose boolean falsePositive,
|
||||
@Expose String state,
|
||||
@Expose @Nullable Long endTime) {}
|
||||
|
||||
/**
|
||||
* A curated summary of the service state for a TLD.
|
||||
*
|
||||
* <p>This class aggregates the high-level status of a TLD and details of any active incidents
|
||||
* affecting specific services (like DNS or RDDS), based on the data structures defined in the
|
||||
* MoSAPI specification.
|
||||
*
|
||||
* @see <a href="https://www.icann.org/mosapi-specification.pdf">ICANN MoSAPI Specification,
|
||||
* Section 5.1</a>
|
||||
*/
|
||||
public record ServiceStateSummary(
|
||||
@Expose String tld,
|
||||
@Expose String overallStatus,
|
||||
@Expose List<ServiceStatus> activeIncidents) {
|
||||
|
||||
public ServiceStateSummary {
|
||||
activeIncidents = nullToEmptyImmutableCopy(activeIncidents);
|
||||
}
|
||||
}
|
||||
|
||||
/** Represents the status of a single monitored service. */
|
||||
public record ServiceStatus(
|
||||
/**
|
||||
* A JSON string that contains the status of the Service as seen from the monitoring system.
|
||||
* Possible values include "Up", "Down", "Disabled", "UP-inconclusive-no-data", etc.
|
||||
*/
|
||||
@Expose String status,
|
||||
|
||||
// A JSON number that contains the current percentage of the Emergency Threshold
|
||||
// of the Service. A value of "0" specifies that there are no Incidents
|
||||
// affecting the threshold.
|
||||
@Expose double emergencyThreshold,
|
||||
@Expose List<IncidentSummary> incidents) {
|
||||
|
||||
public ServiceStatus {
|
||||
incidents = nullToEmptyImmutableCopy(incidents);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the overall health of all monitored services for a TLD.
|
||||
*
|
||||
* @see <a href="https://www.icann.org/mosapi-specification.pdf">ICANN MoSAPI Specification,
|
||||
* Section 5.1</a>
|
||||
*/
|
||||
public record TldServiceState(
|
||||
@Expose String tld,
|
||||
long lastUpdateApiDatabase,
|
||||
|
||||
// A JSON string that contains the status of the TLD as seen from the monitoring system
|
||||
@Expose String status,
|
||||
|
||||
// A JSON object containing detailed information for each potential monitored service (i.e.,
|
||||
// DNS,
|
||||
// RDDS, EPP, DNSSEC, RDAP).
|
||||
@Expose @SerializedName("testedServices") Map<String, ServiceStatus> serviceStatuses) {
|
||||
|
||||
public TldServiceState {
|
||||
serviceStatuses = nullToEmptyImmutableCopy(serviceStatuses);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// Copyright 2025 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.mosapi;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.mosapi.MosApiModels.AllServicesStateResponse;
|
||||
import google.registry.mosapi.MosApiModels.ServiceStateSummary;
|
||||
import google.registry.mosapi.MosApiModels.ServiceStatus;
|
||||
import google.registry.mosapi.MosApiModels.TldServiceState;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/** A service that provides business logic for interacting with MoSAPI Service State. */
|
||||
public class MosApiStateService {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private final ServiceMonitoringClient serviceMonitoringClient;
|
||||
private final ExecutorService tldExecutor;
|
||||
|
||||
private final ImmutableSet<String> tlds;
|
||||
|
||||
private final MosApiMetrics mosApiMetrics;
|
||||
|
||||
private static final String DOWN_STATUS = "Down";
|
||||
private static final String FETCH_ERROR_STATUS = "ERROR";
|
||||
|
||||
@Inject
|
||||
public MosApiStateService(
|
||||
ServiceMonitoringClient serviceMonitoringClient,
|
||||
MosApiMetrics mosApiMetrics,
|
||||
@Config("mosapiTlds") ImmutableSet<String> tlds,
|
||||
@Named("mosapiTldExecutor") ExecutorService tldExecutor) {
|
||||
this.serviceMonitoringClient = serviceMonitoringClient;
|
||||
this.mosApiMetrics = mosApiMetrics;
|
||||
this.tlds = tlds;
|
||||
this.tldExecutor = tldExecutor;
|
||||
}
|
||||
|
||||
/** Fetches and transforms the service state for a given TLD into a summary. */
|
||||
public ServiceStateSummary getServiceStateSummary(String tld) throws MosApiException {
|
||||
TldServiceState rawState = serviceMonitoringClient.getTldServiceState(tld);
|
||||
return transformToSummary(rawState);
|
||||
}
|
||||
|
||||
/** Fetches and transforms the service state for all configured TLDs. */
|
||||
public AllServicesStateResponse getAllServiceStateSummaries() {
|
||||
ImmutableList<CompletableFuture<ServiceStateSummary>> futures =
|
||||
tlds.stream()
|
||||
.map(
|
||||
tld ->
|
||||
CompletableFuture.supplyAsync(
|
||||
() -> {
|
||||
try {
|
||||
return getServiceStateSummary(tld);
|
||||
} catch (MosApiException e) {
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Failed to get service state for TLD %s.", tld);
|
||||
// we don't want to throw exception if fetch failed
|
||||
return new ServiceStateSummary(tld, FETCH_ERROR_STATUS, null);
|
||||
}
|
||||
},
|
||||
tldExecutor))
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
|
||||
ImmutableList<ServiceStateSummary> summaries =
|
||||
futures.stream()
|
||||
.map(CompletableFuture::join) // Waits for all tasks to complete
|
||||
.collect(toImmutableList());
|
||||
|
||||
return new AllServicesStateResponse(summaries);
|
||||
}
|
||||
|
||||
private ServiceStateSummary transformToSummary(TldServiceState rawState) {
|
||||
ImmutableList<ServiceStatus> activeIncidents = ImmutableList.of();
|
||||
if (DOWN_STATUS.equalsIgnoreCase(rawState.status())) {
|
||||
activeIncidents =
|
||||
rawState.serviceStatuses().entrySet().stream()
|
||||
.filter(
|
||||
entry -> {
|
||||
ServiceStatus serviceStatus = entry.getValue();
|
||||
return serviceStatus.incidents() != null
|
||||
&& !serviceStatus.incidents().isEmpty();
|
||||
})
|
||||
.map(
|
||||
entry ->
|
||||
new ServiceStatus(
|
||||
// key is the service name
|
||||
entry.getKey(),
|
||||
entry.getValue().emergencyThreshold(),
|
||||
entry.getValue().incidents()))
|
||||
.collect(toImmutableList());
|
||||
}
|
||||
return new ServiceStateSummary(rawState.tld(), rawState.status(), activeIncidents);
|
||||
}
|
||||
|
||||
/** Triggers monitoring exposure for all configured TLDs. */
|
||||
public void triggerMetricsForAllServiceStateSummaries() {
|
||||
ImmutableList<CompletableFuture<TldServiceState>> futures =
|
||||
tlds.stream()
|
||||
.map(
|
||||
tld ->
|
||||
CompletableFuture.supplyAsync(
|
||||
() -> {
|
||||
try {
|
||||
return serviceMonitoringClient.getTldServiceState(tld);
|
||||
} catch (MosApiException e) {
|
||||
// Log the error but don't rethrow as RuntimeException
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Failed to fetch state for TLD: %s", tld);
|
||||
return null; // Return null so the stream keeps moving
|
||||
}
|
||||
},
|
||||
tldExecutor))
|
||||
.collect(toImmutableList());
|
||||
|
||||
List<TldServiceState> allStates =
|
||||
futures.stream()
|
||||
.map(CompletableFuture::join)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!allStates.isEmpty()) {
|
||||
try {
|
||||
logger.atInfo().log("Triggering MoSAPI status to cloud monitoring for all TLDs.");
|
||||
mosApiMetrics.recordStates(allStates);
|
||||
} catch (Exception e) {
|
||||
logger.atSevere().withCause(e).log("Failed to submit MoSAPI metrics batch.");
|
||||
}
|
||||
} else {
|
||||
logger.atWarning().log("No successful TLD states fetched; skipping metrics push.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// Copyright 2025 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.mosapi;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import google.registry.mosapi.MosApiModels.TldServiceState;
|
||||
import jakarta.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
/** Facade for MoSAPI's service monitoring endpoints. */
|
||||
public class ServiceMonitoringClient {
|
||||
|
||||
private static final String MONITORING_STATE_ENDPOINT = "v2/monitoring/state";
|
||||
private final MosApiClient mosApiClient;
|
||||
private final Gson gson;
|
||||
|
||||
@Inject
|
||||
public ServiceMonitoringClient(MosApiClient mosApiClient, Gson gson) {
|
||||
this.mosApiClient = mosApiClient;
|
||||
this.gson = gson;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the current state of all monitored services for a given TLD.
|
||||
*
|
||||
* @see <a href="https://www.icann.org/mosapi-specification.pdf">ICANN MoSAPI Specification,
|
||||
* Section 5.1</a>
|
||||
*/
|
||||
public TldServiceState getTldServiceState(String tld) throws MosApiException {
|
||||
try (Response response =
|
||||
mosApiClient.sendGetRequest(
|
||||
tld, MONITORING_STATE_ENDPOINT, Collections.emptyMap(), Collections.emptyMap())) {
|
||||
|
||||
ResponseBody responseBody = response.body();
|
||||
if (responseBody == null) {
|
||||
throw new MosApiException(
|
||||
String.format(
|
||||
"MoSAPI Service Monitoring API " + "returned an empty body with status: %d",
|
||||
response.code()));
|
||||
}
|
||||
String bodyString = responseBody.string();
|
||||
if (!response.isSuccessful()) {
|
||||
throw parseErrorResponse(response.code(), bodyString);
|
||||
}
|
||||
return gson.fromJson(bodyString, TldServiceState.class);
|
||||
} catch (IOException | JsonParseException e) {
|
||||
Throwables.throwIfInstanceOf(e, MosApiException.class);
|
||||
// Catch Gson's runtime exceptions (parsing errors) and wrap them
|
||||
throw new MosApiException("Failed to parse TLD service state response", e);
|
||||
}
|
||||
}
|
||||
|
||||
/** Parses an unsuccessful MoSAPI response into a domain-specific {@link MosApiException}. */
|
||||
private MosApiException parseErrorResponse(int statusCode, String bodyString) {
|
||||
try {
|
||||
MosApiErrorResponse error = gson.fromJson(bodyString, MosApiErrorResponse.class);
|
||||
return MosApiException.create(error);
|
||||
} catch (JsonParseException e) {
|
||||
return new MosApiException(
|
||||
String.format("MoSAPI json parsing error (%d): %s", statusCode, bodyString), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright 2026 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.mosapi;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
/**
|
||||
* An action that triggers Metrics action for the current MoSAPI service state result for all TLDs.
|
||||
*/
|
||||
@Action(
|
||||
service = Action.Service.BACKEND,
|
||||
path = TriggerServiceStateAction.PATH,
|
||||
method = Action.Method.GET,
|
||||
auth = Auth.AUTH_ADMIN)
|
||||
public class TriggerServiceStateAction implements Runnable {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public static final String PATH = "/_dr/task/triggerMosApiServiceState";
|
||||
private final MosApiStateService stateService;
|
||||
private final Response response;
|
||||
|
||||
@Inject
|
||||
public TriggerServiceStateAction(MosApiStateService stateService, Response response) {
|
||||
this.stateService = stateService;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
response.setContentType(MediaType.PLAIN_TEXT_UTF_8);
|
||||
try {
|
||||
logger.atInfo().log("Beginning to trigger MoSAPI metrics for all TLDs.");
|
||||
stateService.triggerMetricsForAllServiceStateSummaries();
|
||||
response.setStatus(200);
|
||||
response.setPayload("MoSAPI metrics triggered successfully for all TLDs.");
|
||||
} catch (Exception e) {
|
||||
logger.atSevere().withCause(e).log("Error triggering MoSAPI metrics.");
|
||||
throw new InternalServerErrorException("Failed to process MoSAPI metrics.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
@@ -184,4 +186,21 @@ public final class MosApiModule {
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), trustManager)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a fixed thread pool for parallel TLD processing.
|
||||
*
|
||||
* <p>Strictly bound to 4 threads to comply with MoSAPI session limits (4 concurrent sessions per
|
||||
* certificate). This is used by MosApiStateService to fetch data in parallel.
|
||||
*
|
||||
* @see <a href="https://www.icann.org/mosapi-specification.pdf">ICANN MoSAPI Specification,
|
||||
* Section 12.3</a>
|
||||
*/
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("mosapiTldExecutor")
|
||||
static ExecutorService provideMosapiTldExecutor(
|
||||
@Config("mosapiTldThreadCnt") int threadPoolSize) {
|
||||
return Executors.newFixedThreadPool(threadPoolSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2025 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.mosapi.module;
|
||||
|
||||
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import google.registry.request.Parameter;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Dagger module for MoSAPI requests. */
|
||||
@Module
|
||||
public final class MosApiRequestModule {
|
||||
@Provides
|
||||
@Parameter("tld")
|
||||
static Optional<String> provideTld(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "tld");
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.contact.Contact;
|
||||
import google.registry.model.domain.Domain;
|
||||
import google.registry.model.host.Host;
|
||||
import google.registry.model.rde.RdeMode;
|
||||
@@ -118,12 +117,6 @@ public final class RdeMarshaller implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/** Turns {@link Contact} object into an XML fragment. */
|
||||
public DepositFragment marshalContact(Contact contact) {
|
||||
return marshalResource(
|
||||
RdeResourceType.CONTACT, contact, ContactToXjcConverter.convert(contact));
|
||||
}
|
||||
|
||||
/** Turns {@link Domain} object into an XML fragment. */
|
||||
public DepositFragment marshalDomain(Domain domain, RdeMode mode) {
|
||||
return marshalResource(
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.EnumSet;
|
||||
|
||||
/** Types of objects that get embedded in an escrow deposit. */
|
||||
public enum RdeResourceType {
|
||||
CONTACT("urn:ietf:params:xml:ns:rdeContact-1.0", EnumSet.of(FULL)),
|
||||
DOMAIN("urn:ietf:params:xml:ns:rdeDomain-1.0", EnumSet.of(FULL, THIN)),
|
||||
HOST("urn:ietf:params:xml:ns:rdeHost-1.0", EnumSet.of(FULL)),
|
||||
REGISTRAR("urn:ietf:params:xml:ns:rdeRegistrar-1.0", EnumSet.of(FULL, THIN)),
|
||||
|
||||
120
core/src/main/java/google/registry/tmch/RstTmchUtils.java
Normal file
120
core/src/main/java/google/registry/tmch/RstTmchUtils.java
Normal file
@@ -0,0 +1,120 @@
|
||||
// Copyright 2025 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.tmch;
|
||||
|
||||
import static com.google.common.base.Suppliers.memoize;
|
||||
import static com.google.common.io.Resources.getResource;
|
||||
import static com.google.common.io.Resources.readLines;
|
||||
import static google.registry.tmch.RstTmchUtils.RstEnvironment.OTE;
|
||||
import static google.registry.tmch.RstTmchUtils.RstEnvironment.PROD;
|
||||
import static google.registry.util.RegistryEnvironment.SANDBOX;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.model.smd.SignedMarkRevocationList;
|
||||
import google.registry.model.tmch.ClaimsList;
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Utilities supporting TMCH-related RST testing in the Sandbox environment.
|
||||
*
|
||||
* <p>For logistic reasons we must conduct RST testing in the Sandbox environments. RST tests
|
||||
* require the use of special labels hosted on their website. To isolate these labels from regular
|
||||
* customers conducting onboarding tests, we manually download the test files as resources, and
|
||||
* serve them up only to RST TLDs.
|
||||
*/
|
||||
public class RstTmchUtils {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
/**
|
||||
* The RST environments.
|
||||
*
|
||||
* <p>We conduct both OTE and PROD RST tests in Sandbox.
|
||||
*/
|
||||
enum RstEnvironment {
|
||||
OTE,
|
||||
PROD
|
||||
}
|
||||
|
||||
private static final ImmutableMap<RstEnvironment, Supplier<Optional<ClaimsList>>> CLAIMS_CACHE =
|
||||
ImmutableMap.of(
|
||||
OTE, memoize(() -> getClaimsList(OTE)), PROD, memoize(() -> getClaimsList(PROD)));
|
||||
|
||||
private static final ImmutableMap<RstEnvironment, Supplier<Optional<SignedMarkRevocationList>>>
|
||||
SMDRL_CACHE =
|
||||
ImmutableMap.of(
|
||||
OTE, memoize(() -> getSmdrList(OTE)), PROD, memoize(() -> getSmdrList(PROD)));
|
||||
|
||||
/** Returns appropriate test labels if {@code tld} is for RST testing; otherwise returns empty. */
|
||||
public static Optional<ClaimsList> getClaimsList(String tld) {
|
||||
return getRstEnvironment(tld).map(CLAIMS_CACHE::get).flatMap(Supplier::get);
|
||||
}
|
||||
|
||||
/** Returns appropriate test labels if {@code tld} is for RST testing; otherwise returns empty. */
|
||||
public static Optional<SignedMarkRevocationList> getSmdrList(String tld) {
|
||||
return getRstEnvironment(tld).map(SMDRL_CACHE::get).flatMap(Supplier::get);
|
||||
}
|
||||
|
||||
static Optional<RstEnvironment> getRstEnvironment(String tld) {
|
||||
if (!RegistryEnvironment.get().equals(SANDBOX)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
if (tld.startsWith("cc-rst-test-")) {
|
||||
return Optional.of(OTE);
|
||||
}
|
||||
if (tld.startsWith("zz--")) {
|
||||
return Optional.of(PROD);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static Optional<ClaimsList> getClaimsList(RstEnvironment rstEnvironment) {
|
||||
if (!RegistryEnvironment.get().equals(SANDBOX)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
String resourceName = rstEnvironment.name().toLowerCase(Locale.ROOT) + ".rst.dnl.csv";
|
||||
URL resource = getResource(RstTmchUtils.class, resourceName);
|
||||
try {
|
||||
return Optional.of(ClaimsListParser.parse(readLines(resource, UTF_8)));
|
||||
} catch (IOException e) {
|
||||
// Do not throw.
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Could not load Claims list %s for %s in Sandbox.", resourceName, rstEnvironment);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private static Optional<SignedMarkRevocationList> getSmdrList(RstEnvironment rstEnvironment) {
|
||||
if (!RegistryEnvironment.get().equals(SANDBOX)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
String resourceName = rstEnvironment.name().toLowerCase(Locale.ROOT) + ".rst.smdrl.csv";
|
||||
URL resource = getResource(RstTmchUtils.class, resourceName);
|
||||
try {
|
||||
return Optional.of(SmdrlCsvParser.parse(readLines(resource, UTF_8)));
|
||||
} catch (IOException e) {
|
||||
// Do not throw.
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Could not load SMDR list %s for %s in Sandbox.", resourceName, rstEnvironment);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,6 @@ import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.xml.XMLConstants;
|
||||
@@ -82,7 +81,7 @@ public class XmlTransformer {
|
||||
* @param schemaFilenames schema files, used only for validating, and relative to this package.
|
||||
* @param recognizedClasses the classes that can be used to marshal to and from
|
||||
*/
|
||||
public XmlTransformer(List<String> schemaFilenames, Class<?>... recognizedClasses) {
|
||||
public XmlTransformer(ImmutableList<String> schemaFilenames, Class<?>... recognizedClasses) {
|
||||
try {
|
||||
this.jaxbContext = JAXBContext.newInstance(recognizedClasses);
|
||||
this.schema = loadXmlSchemas(schemaFilenames);
|
||||
@@ -251,7 +250,7 @@ public class XmlTransformer {
|
||||
}
|
||||
|
||||
/** Creates a single {@link Schema} from multiple {@code .xsd} files. */
|
||||
public static Schema loadXmlSchemas(List<String> schemaFilenames) {
|
||||
public static Schema loadXmlSchemas(ImmutableList<String> schemaFilenames) {
|
||||
try (Closer closer = Closer.create()) {
|
||||
StreamSource[] sources = new StreamSource[schemaFilenames.size()];
|
||||
for (int i = 0; i < schemaFilenames.size(); ++i) {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<element name="renew" type="fee:transformCommandType" />
|
||||
<element name="renData" type="fee:transformResultType" />
|
||||
<element name="transfer" type="fee:transformCommandType" />
|
||||
<element name="trnData" type="fee:transferResultType" />
|
||||
<element name="trnData" type="fee:transformResultType" />
|
||||
<element name="update" type="fee:transformCommandType" />
|
||||
<element name="updData" type="fee:transformResultType" />
|
||||
<element name="delData" type="fee:transformResultType" />
|
||||
@@ -33,32 +33,24 @@
|
||||
<sequence>
|
||||
<element name="currency" type="fee:currencyType"
|
||||
minOccurs="0" />
|
||||
<element name="command" type="fee:commandCheckType"
|
||||
maxOccurs="unbounded" />
|
||||
<element name="command" type="fee:commandType"
|
||||
minOccurs="1" maxOccurs="unbounded" />
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="commandCheckType">
|
||||
<sequence>
|
||||
<element name="period"
|
||||
type="domain:periodType"
|
||||
minOccurs="0" />
|
||||
<element name="class"
|
||||
type="token"
|
||||
minOccurs="0" />
|
||||
<element name="date"
|
||||
type="dateTime"
|
||||
minOccurs="0" />
|
||||
</sequence>
|
||||
<attribute name="name" type="fee:commandTypeValue" />
|
||||
<attribute name="phase" type="token" />
|
||||
<attribute name="subphase" type="token" />
|
||||
<complexType name="objectIdentifierType">
|
||||
<simpleContent>
|
||||
<extension base="eppcom:labelType">
|
||||
<attribute name="element"
|
||||
type="NMTOKEN" default="name" />
|
||||
</extension>
|
||||
</simpleContent>
|
||||
</complexType>
|
||||
|
||||
<!-- server <check> result -->
|
||||
<complexType name="chkDataType">
|
||||
<sequence>
|
||||
<element name="currency" type="fee:currencyType" minOccurs="0"/>
|
||||
<element name="currency" type="fee:currencyType" />
|
||||
<element name="cd" type="fee:objectCDType"
|
||||
maxOccurs="unbounded" />
|
||||
</sequence>
|
||||
@@ -66,47 +58,13 @@
|
||||
|
||||
<complexType name="objectCDType">
|
||||
<sequence>
|
||||
<element name="object">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<any namespace="##other" processContents="lax"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
<element name="command"
|
||||
type="fee:commandCDType"
|
||||
maxOccurs="unbounded" />
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="commandCDType">
|
||||
<sequence>
|
||||
<element name="period"
|
||||
type="domain:periodType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
<element name="fee"
|
||||
type="fee:feeType"
|
||||
<element name="objID" type="fee:objectIdentifierType" />
|
||||
<element name="class" type="token" minOccurs="0" />
|
||||
<element name="command" type="fee:commandDataType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
<element name="credit"
|
||||
type="fee:creditType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
<element name="class"
|
||||
type="token"
|
||||
minOccurs="0" />
|
||||
<element name="reason"
|
||||
type="token"
|
||||
minOccurs="0" />
|
||||
<element name="date"
|
||||
type="dateTime"
|
||||
minOccurs="0" />
|
||||
<element name="notAfter"
|
||||
type="dateTime"
|
||||
minOccurs="0" />
|
||||
<element name="reason" type="fee:reasonType" minOccurs="0" />
|
||||
</sequence>
|
||||
<attribute name="avail" type="boolean" default="1" />
|
||||
<attribute name="name" type="fee:commandTypeValue" />
|
||||
<attribute name="phase" type="token" />
|
||||
<attribute name="subphase" type="token" />
|
||||
</complexType>
|
||||
|
||||
<!-- general transform (create, renew, update, transfer) command-->
|
||||
@@ -121,32 +79,15 @@
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<!-- general transform (create, renew, update, delete) result -->
|
||||
<!-- general transform (create, renew, update) result -->
|
||||
<complexType name="transformResultType">
|
||||
<sequence>
|
||||
<element name="currency" type="fee:currencyType" />
|
||||
<element name="fee" type="fee:feeType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
<element name="credit" type="fee:creditType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
<element name="balance" type="fee:balanceType"
|
||||
<element name="currency" type="fee:currencyType"
|
||||
minOccurs="0" />
|
||||
<element name="creditLimit" type="fee:creditLimitType"
|
||||
minOccurs="0" />
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<!-- transfer result -->
|
||||
<complexType name="transferResultType">
|
||||
<sequence>
|
||||
<element name="currency" type="fee:currencyType" />
|
||||
|
||||
<!-- only used op="query" responses -->
|
||||
<element name="period" type="domain:periodType"
|
||||
minOccurs="0" />
|
||||
|
||||
<element name="fee" type="fee:feeType"
|
||||
maxOccurs="unbounded" />
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
<element name="credit" type="fee:creditType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
<element name="balance" type="fee:balanceType"
|
||||
@@ -163,10 +104,50 @@
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="commandTypeValue">
|
||||
<complexType name="commandType">
|
||||
<sequence>
|
||||
<element name="period" type="domain:periodType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
</sequence>
|
||||
<attribute name="name" type="fee:commandEnum" use="required"/>
|
||||
<attribute name="customName" type="token"/>
|
||||
<attribute name="phase" type="token" />
|
||||
<attribute name="subphase" type="token" />
|
||||
</complexType>
|
||||
|
||||
<complexType name="commandDataType">
|
||||
<complexContent>
|
||||
<extension base="fee:commandType">
|
||||
<sequence>
|
||||
<element name="fee" type="fee:feeType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
<element name="credit" type="fee:creditType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
<element name="reason" type="fee:reasonType"
|
||||
minOccurs="0" />
|
||||
</sequence>
|
||||
<attribute name="standard" type="boolean" default="0" />
|
||||
</extension>
|
||||
</complexContent>
|
||||
</complexType>
|
||||
|
||||
<complexType name="reasonType">
|
||||
<simpleContent>
|
||||
<extension base="token">
|
||||
<attribute name="lang" type="language" default="en"/>
|
||||
</extension>
|
||||
</simpleContent>
|
||||
</complexType>
|
||||
|
||||
<simpleType name="commandEnum">
|
||||
<restriction base="token">
|
||||
<minLength value="3"/>
|
||||
<maxLength value="16"/>
|
||||
<enumeration value="create"/>
|
||||
<enumeration value="delete"/>
|
||||
<enumeration value="renew"/>
|
||||
<enumeration value="update"/>
|
||||
<enumeration value="transfer"/>
|
||||
<enumeration value="restore"/>
|
||||
<enumeration value="custom"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
@@ -186,9 +167,10 @@
|
||||
<simpleContent>
|
||||
<extension base="fee:nonNegativeDecimal">
|
||||
<attribute name="description"/>
|
||||
<attribute name="lang" type="language" default="en"/>
|
||||
<attribute name="refundable" type="boolean" />
|
||||
<attribute name="grace-period" type="duration" />
|
||||
<attribute name="applied" default="immediate">
|
||||
<attribute name="applied">
|
||||
<simpleType>
|
||||
<restriction base="token">
|
||||
<enumeration value="immediate" />
|
||||
@@ -204,6 +186,7 @@
|
||||
<simpleContent>
|
||||
<extension base="fee:negativeDecimal">
|
||||
<attribute name="description"/>
|
||||
<attribute name="lang" type="language" default="en"/>
|
||||
</extension>
|
||||
</simpleContent>
|
||||
</complexType>
|
||||
|
||||
10
core/src/main/resources/google/registry/tmch/ote.rst.dnl.csv
Normal file
10
core/src/main/resources/google/registry/tmch/ote.rst.dnl.csv
Normal file
@@ -0,0 +1,10 @@
|
||||
1,2024-09-13T02:21:12.0Z
|
||||
DNL,lookup-key,insertion-datetime
|
||||
test---validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
test--validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
test-and-validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
test-andvalidate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
test-validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
testand-validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
testandvalidate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
testvalidate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
|
@@ -0,0 +1,7 @@
|
||||
1,2022-11-22T01:49:36.9Z
|
||||
smd-id,insertion-datetime
|
||||
0000001761385117375880-65535,2013-07-15T00:00:00.0Z
|
||||
0000001751501056761969-65535,2017-07-26T10:12:41.9Z
|
||||
000000541526299609231-65535,2018-05-14T17:52:23.7Z
|
||||
000000541602140609520-65535,2020-10-08T07:07:25.0Z
|
||||
000000541669081776937-65535,2022-11-22T01:49:36.9Z
|
||||
|
@@ -0,0 +1,10 @@
|
||||
1,2024-09-13T02:21:12.0Z
|
||||
DNL,lookup-key,insertion-datetime
|
||||
test---validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
test--validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
test-and-validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
test-andvalidate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
test-validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
testand-validate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
testandvalidate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
testvalidate,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
|
@@ -0,0 +1,7 @@
|
||||
1,2022-11-22T01:49:36.9Z
|
||||
smd-id,insertion-datetime
|
||||
0000001761385117375880-65535,2013-07-15T00:00:00.0Z
|
||||
0000001751501056761969-65535,2017-07-26T10:12:41.9Z
|
||||
000000541526299609231-65535,2018-05-14T17:52:23.7Z
|
||||
000000541602140609520-65535,2020-10-08T07:07:25.0Z
|
||||
000000541669081776937-65535,2022-11-22T01:49:36.9Z
|
||||
|
@@ -25,13 +25,11 @@ import static google.registry.model.rde.RdeMode.THIN;
|
||||
import static google.registry.persistence.transaction.JpaTransactionManagerExtension.makeRegistrar1;
|
||||
import static google.registry.persistence.transaction.JpaTransactionManagerExtension.makeRegistrar2;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.rde.RdeResourceType.CONTACT;
|
||||
import static google.registry.rde.RdeResourceType.DOMAIN;
|
||||
import static google.registry.rde.RdeResourceType.HOST;
|
||||
import static google.registry.rde.RdeResourceType.REGISTRAR;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.newDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatabaseHelper.persistEppResource;
|
||||
@@ -54,10 +52,6 @@ import google.registry.gcs.GcsUtils;
|
||||
import google.registry.keyring.api.PgpHelper;
|
||||
import google.registry.model.common.Cursor;
|
||||
import google.registry.model.common.Cursor.CursorType;
|
||||
import google.registry.model.contact.Contact;
|
||||
import google.registry.model.contact.ContactBase;
|
||||
import google.registry.model.contact.ContactHistory;
|
||||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.Domain;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.DomainHistory;
|
||||
@@ -114,8 +108,6 @@ public class RdePipelineTest {
|
||||
|
||||
private static final String DOMAIN_NAME_PATTERN = "<rdeDomain:name>(.*)</rdeDomain:name>";
|
||||
|
||||
private static final String CONTACT_ID_PATTERN = "<rdeContact:id>(.*)</rdeContact:id>";
|
||||
|
||||
private static final String HOST_NAME_PATTERN = "<rdeHost:name>(.*)</rdeHost:name>";
|
||||
|
||||
// This is the default creation time for test data.
|
||||
@@ -139,7 +131,6 @@ public class RdePipelineTest {
|
||||
ImmutableList.of(
|
||||
DepositFragment.create(DOMAIN, "<rdeDomain:domain/>\n", ""),
|
||||
DepositFragment.create(REGISTRAR, "<rdeRegistrar:registrar/>\n", ""),
|
||||
DepositFragment.create(CONTACT, "<rdeContact:contact/>\n", ""),
|
||||
DepositFragment.create(HOST, "<rdeHost:host/>\n", ""));
|
||||
|
||||
private final GcsUtils gcsUtils = new GcsUtils(LocalStorageHelper.getOptions());
|
||||
@@ -165,21 +156,6 @@ public class RdePipelineTest {
|
||||
|
||||
private RdePipeline rdePipeline;
|
||||
|
||||
private ContactHistory persistContactHistory(ContactBase contact) {
|
||||
return persistResource(
|
||||
new ContactHistory.Builder()
|
||||
.setType(HistoryEntry.Type.HOST_CREATE)
|
||||
.setXmlBytes("<xml></xml>".getBytes(UTF_8))
|
||||
.setModificationTime(clock.nowUtc())
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setTrid(Trid.create("ABC-123", "server-trid"))
|
||||
.setBySuperuser(false)
|
||||
.setReason("reason")
|
||||
.setRequestedByRegistrar(true)
|
||||
.setContact(contact)
|
||||
.build());
|
||||
}
|
||||
|
||||
private DomainHistory persistDomainHistory(DomainBase domain) {
|
||||
DomainTransactionRecord transactionRecord =
|
||||
new DomainTransactionRecord.Builder()
|
||||
@@ -254,20 +230,18 @@ public class RdePipelineTest {
|
||||
RdeRevision.saveRevision("soy", now, FULL, 0);
|
||||
});
|
||||
|
||||
// This contact is never referenced.
|
||||
persistContactHistory(persistActiveContact("contactX"));
|
||||
Contact contact1 = persistActiveContact("contact1234");
|
||||
persistContactHistory(contact1);
|
||||
Contact contact2 = persistActiveContact("contact456");
|
||||
persistContactHistory(contact2);
|
||||
|
||||
// This host is never referenced.
|
||||
persistHostHistory(persistActiveHost("ns0.domain.tld"));
|
||||
Host host1 = persistActiveHost("ns1.external.tld");
|
||||
persistHostHistory(host1);
|
||||
Domain helloDomain =
|
||||
persistEppResource(
|
||||
newDomain("hello.soy", contact1).asBuilder().addNameserver(host1.createVKey()).build());
|
||||
newDomain("hello.soy")
|
||||
.asBuilder()
|
||||
.addNameserver(host1.createVKey())
|
||||
.setRegistrant(Optional.empty())
|
||||
.setContacts(ImmutableSet.of())
|
||||
.build());
|
||||
persistDomainHistory(helloDomain);
|
||||
persistHostHistory(persistActiveHost("not-used-subordinate.hello.soy"));
|
||||
Host host2 = persistActiveHost("ns1.hello.soy");
|
||||
@@ -276,14 +250,15 @@ public class RdePipelineTest {
|
||||
// This domain has no registrant.
|
||||
Domain kittyDomain =
|
||||
persistEppResource(
|
||||
newDomain("kitty.fun", contact2)
|
||||
newDomain("kitty.fun")
|
||||
.asBuilder()
|
||||
.addNameservers(ImmutableSet.of(host1.createVKey(), host2.createVKey()))
|
||||
.setRegistrant(Optional.empty())
|
||||
.setContacts(ImmutableSet.of())
|
||||
.build());
|
||||
persistDomainHistory(kittyDomain);
|
||||
// Should not appear because the TLD is not included in a pending deposit.
|
||||
persistDomainHistory(persistEppResource(newDomain("lol.cat", contact1)));
|
||||
persistDomainHistory(persistEppResource(newDomain("lol.cat")));
|
||||
// To be deleted.
|
||||
Domain deletedDomain = persistActiveDomain("deleted.soy");
|
||||
persistDomainHistory(deletedDomain);
|
||||
@@ -293,8 +268,7 @@ public class RdePipelineTest {
|
||||
persistDomainHistory(deletedDomain.asBuilder().setDeletionTime(clock.nowUtc()).build());
|
||||
kittyDomain = kittyDomain.asBuilder().setDomainName("cat.fun").build();
|
||||
persistDomainHistory(kittyDomain);
|
||||
Contact contact3 = persistActiveContact("contact789");
|
||||
persistContactHistory(contact3);
|
||||
|
||||
// This is a subordinate domain in TLD .cat, which is not included in any pending deposit. But
|
||||
// it should still be included as a subordinate host in the pendign deposit for .soy.
|
||||
Host host3 = persistActiveHost("ns1.lol.cat");
|
||||
@@ -302,17 +276,8 @@ public class RdePipelineTest {
|
||||
persistDomainHistory(
|
||||
helloDomain
|
||||
.asBuilder()
|
||||
.removeContacts(
|
||||
helloDomain.getContacts().stream()
|
||||
.filter(dc -> dc.getType() == DesignatedContact.Type.ADMIN)
|
||||
.collect(toImmutableSet()))
|
||||
.addContacts(
|
||||
ImmutableSet.of(
|
||||
DesignatedContact.create(DesignatedContact.Type.ADMIN, contact3.createVKey())))
|
||||
.addNameserver(host3.createVKey())
|
||||
.build());
|
||||
// contact456 is renamed to contactABC.
|
||||
persistContactHistory(contact2.asBuilder().setContactId("contactABC").build());
|
||||
// ns1.hello.soy is renamed to ns2.hello.soy
|
||||
persistHostHistory(host2.asBuilder().setHostName("ns2.hello.soy").build());
|
||||
|
||||
@@ -320,18 +285,11 @@ public class RdePipelineTest {
|
||||
// resulting deposit fragments.
|
||||
clock.advanceBy(Duration.standardDays(2));
|
||||
persistDomainHistory(kittyDomain.asBuilder().setDeletionTime(clock.nowUtc()).build());
|
||||
Contact futureContact = persistActiveContact("future-contact");
|
||||
persistContactHistory(futureContact);
|
||||
Host futureHost = persistActiveHost("ns1.future.tld");
|
||||
persistHostHistory(futureHost);
|
||||
persistDomainHistory(
|
||||
persistEppResource(
|
||||
newDomain("future.soy", futureContact)
|
||||
.asBuilder()
|
||||
.setNameservers(futureHost.createVKey())
|
||||
.build()));
|
||||
// contactABC is renamed to contactXYZ.
|
||||
persistContactHistory(contact2.asBuilder().setContactId("contactXYZ").build());
|
||||
newDomain("future.soy").asBuilder().setNameservers(futureHost.createVKey()).build()));
|
||||
// ns2.hello.soy is renamed to ns3.hello.soy
|
||||
persistHostHistory(host2.asBuilder().setHostName("ns3.hello.soy").build());
|
||||
|
||||
@@ -390,11 +348,9 @@ public class RdePipelineTest {
|
||||
"""
|
||||
<rdeDomain:domain>
|
||||
<rdeDomain:name>cat.fun</rdeDomain:name>
|
||||
<rdeDomain:roid>15-FUN</rdeDomain:roid>
|
||||
<rdeDomain:roid>10-FUN</rdeDomain:roid>
|
||||
<rdeDomain:uName>cat.fun</rdeDomain:uName>
|
||||
<rdeDomain:status s="ok"/>
|
||||
<rdeDomain:contact type="admin">contact456</rdeDomain:contact>
|
||||
<rdeDomain:contact type="tech">contact456</rdeDomain:contact>
|
||||
<rdeDomain:ns>
|
||||
<domain:hostObj>ns1.external.tld</domain:hostObj>
|
||||
<domain:hostObj>ns1.hello.soy</domain:hostObj>
|
||||
@@ -407,14 +363,7 @@ public class RdePipelineTest {
|
||||
""");
|
||||
}
|
||||
if (kv.getKey().mode().equals(FULL)) {
|
||||
// Contact fragments for hello.soy.
|
||||
if ("soy".equals(kv.getKey().tld())) {
|
||||
assertThat(
|
||||
getFragmentForType(kv, CONTACT)
|
||||
.map(getXmlElement(CONTACT_ID_PATTERN))
|
||||
.collect(toImmutableSet()))
|
||||
.containsExactly("contact1234", "contact789");
|
||||
|
||||
// Host fragments for hello.soy.
|
||||
assertThat(
|
||||
getFragmentForType(kv, HOST)
|
||||
@@ -428,12 +377,9 @@ public class RdePipelineTest {
|
||||
"""
|
||||
<rdeDomain:domain>
|
||||
<rdeDomain:name>hello.soy</rdeDomain:name>
|
||||
<rdeDomain:roid>E-SOY</rdeDomain:roid>
|
||||
<rdeDomain:roid>8-SOY</rdeDomain:roid>
|
||||
<rdeDomain:uName>hello.soy</rdeDomain:uName>
|
||||
<rdeDomain:status s="ok"/>
|
||||
<rdeDomain:registrant>contact1234</rdeDomain:registrant>
|
||||
<rdeDomain:contact type="admin">contact789</rdeDomain:contact>
|
||||
<rdeDomain:contact type="tech">contact1234</rdeDomain:contact>
|
||||
<rdeDomain:ns>
|
||||
<domain:hostObj>ns1.external.tld</domain:hostObj>
|
||||
<domain:hostObj>ns1.lol.cat</domain:hostObj>
|
||||
@@ -445,13 +391,6 @@ public class RdePipelineTest {
|
||||
</rdeDomain:domain>\
|
||||
""");
|
||||
} else {
|
||||
// Contact fragments for cat.fun.
|
||||
assertThat(
|
||||
getFragmentForType(kv, CONTACT)
|
||||
.map(getXmlElement(CONTACT_ID_PATTERN))
|
||||
.collect(toImmutableSet()))
|
||||
.containsExactly("contactABC");
|
||||
|
||||
// Host fragments for cat.soy.
|
||||
assertThat(
|
||||
getFragmentForType(kv, HOST)
|
||||
@@ -460,22 +399,19 @@ public class RdePipelineTest {
|
||||
.containsExactly("ns1.external.tld", "ns2.hello.soy");
|
||||
}
|
||||
} else {
|
||||
// BRDA does not contain contact or hosts.
|
||||
// BRDA does not contain hosts.
|
||||
assertThat(
|
||||
Streams.stream(kv.getValue())
|
||||
.anyMatch(
|
||||
fragment ->
|
||||
fragment.type().equals(CONTACT)
|
||||
|| fragment.type().equals(HOST)))
|
||||
.anyMatch(fragment -> fragment.type().equals(HOST)))
|
||||
.isFalse();
|
||||
|
||||
// Domain fragments for hello.soy: Note that this contains no contact info.
|
||||
// Domain fragments for hello.soy.
|
||||
assertThat(domainFrags.stream().findFirst().get().xml().strip())
|
||||
.isEqualTo(
|
||||
"""
|
||||
<rdeDomain:domain>
|
||||
<rdeDomain:name>hello.soy</rdeDomain:name>
|
||||
<rdeDomain:roid>E-SOY</rdeDomain:roid>
|
||||
<rdeDomain:roid>8-SOY</rdeDomain:roid>
|
||||
<rdeDomain:uName>hello.soy</rdeDomain:uName>
|
||||
<rdeDomain:status s="ok"/>
|
||||
<rdeDomain:ns>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package google.registry.flows;
|
||||
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.joda.time.format.ISODateTimeFormat.dateTimeNoMillis;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -26,7 +25,7 @@ class EppLoggedOutTest extends EppTestCase {
|
||||
|
||||
@Test
|
||||
void testHello() throws Exception {
|
||||
DateTime now = DateTime.now(UTC);
|
||||
DateTime now = clock.nowUtc();
|
||||
assertThatCommand("hello.xml", null)
|
||||
.atTime(now)
|
||||
.hasResponse("greeting.xml", ImmutableMap.of("DATE", now.toString(dateTimeNoMillis())));
|
||||
|
||||
@@ -36,6 +36,7 @@ import google.registry.flows.EppTestComponent.FakesAndMocksModule;
|
||||
import google.registry.flows.picker.FlowPicker;
|
||||
import google.registry.model.billing.BillingBase;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.eppcommon.EppXmlTransformer;
|
||||
import google.registry.model.eppcommon.ProtocolDefinition;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
@@ -134,28 +135,6 @@ public abstract class FlowTestCase<F extends Flow> {
|
||||
return TestDataHelper.loadFile(getClass(), filename, substitutions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an input or response EPP message with draft fee extension v12 to std v1.
|
||||
*
|
||||
* <p>There is no practical changes between draft v12 and the v1 standard. This method allows us
|
||||
* to reuse v12 test data.
|
||||
*/
|
||||
protected String loadFeeV12FileAsStdV1(String filename) {
|
||||
String content = loadFile(filename);
|
||||
return content.replace("urn:ietf:params:xml:ns:fee-0.12", "urn:ietf:params:xml:ns:epp:fee-1.0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an input or response EPP message with draft fee extension v12 to std v1.
|
||||
*
|
||||
* <p>There is no practical changes between draft v12 and the v1 standard. This method allows us
|
||||
* to reuse v12 test data.
|
||||
*/
|
||||
protected String loadFeeV12FileAsStdV1(String filename, Map<String, String> substitutions) {
|
||||
String content = loadFile(filename, substitutions);
|
||||
return content.replace("urn:ietf:params:xml:ns:fee-0.12", "urn:ietf:params:xml:ns:epp:fee-1.0");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getClientTrid() throws Exception {
|
||||
return eppLoader.getEpp().getCommandWrapper().getClTrid().orElse(null);
|
||||
@@ -289,6 +268,8 @@ public abstract class FlowTestCase<F extends Flow> {
|
||||
if (output.isResponse()) {
|
||||
assertThat(output.isSuccess()).isTrue();
|
||||
}
|
||||
// Verify that expected xml is syntatically correct.
|
||||
EppXmlTransformer.validateOutput(xml);
|
||||
try {
|
||||
assertXmlEquals(
|
||||
xml, new String(marshal(output, ValidationMode.STRICT), UTF_8), ignoredPathsPlusTrid);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -123,11 +123,13 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
private static final DateTime A_MONTH_FROM_NOW = TIME_BEFORE_FLOW.plusMonths(1);
|
||||
|
||||
private static final ImmutableMap<String, String> FEE_06_MAP =
|
||||
ImmutableMap.of("FEE_VERSION", "0.6", "FEE_NS", "fee");
|
||||
ImmutableMap.of("FEE_VERSION", "fee-0.6", "FEE_NS", "fee");
|
||||
private static final ImmutableMap<String, String> FEE_11_MAP =
|
||||
ImmutableMap.of("FEE_VERSION", "0.11", "FEE_NS", "fee11");
|
||||
ImmutableMap.of("FEE_VERSION", "fee-0.11", "FEE_NS", "fee11");
|
||||
private static final ImmutableMap<String, String> FEE_12_MAP =
|
||||
ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12");
|
||||
ImmutableMap.of("FEE_VERSION", "fee-0.12", "FEE_NS", "fee12");
|
||||
private static final ImmutableMap<String, String> FEE_STD_1_0_MAP =
|
||||
ImmutableMap.of("FEE_VERSION", "epp:fee-1.0", "FEE_NS", "fee1_00");
|
||||
|
||||
DomainDeleteFlowTest() {
|
||||
setEppInput("domain_delete.xml");
|
||||
@@ -396,24 +398,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_12_MAP);
|
||||
void testSuccess_addGracePeriodCredit_std_v1() throws Exception {
|
||||
doAddGracePeriodDeleteTest(
|
||||
GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
private void doSuccessfulTest_noAddGracePeriod(String responseFilename) throws Exception {
|
||||
@@ -497,24 +484,8 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_12_MAP);
|
||||
void testSuccess_renewGracePeriodCredit_std_v1() throws Exception {
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -556,37 +527,14 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
void testSuccess_autoRenewGracePeriod_std_v1() throws Exception {
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_STD_1_0_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_std_v1() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
@@ -599,44 +547,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
.build());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
Money.of(USD, 11),
|
||||
TIME_BEFORE_FLOW.minusDays(5),
|
||||
Money.of(USD, 20)))
|
||||
.build());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
Money.of(USD, 11),
|
||||
TIME_BEFORE_FLOW.minusDays(5),
|
||||
Money.of(USD, 20)))
|
||||
.build());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_STD_1_0_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1296,7 +1207,6 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
|
||||
@Test
|
||||
void testSuccess_freeCreation_deletionDuringGracePeriod() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
// Deletion during the add grace period should still work even if the credit is 0
|
||||
setUpSuccessfulTest();
|
||||
BillingEvent graceBillingEvent =
|
||||
@@ -1304,7 +1214,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
setUpGracePeriods(
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.ADD, domain.getRepoId(), graceBillingEvent));
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_fee_free_grace.xml"));
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_fee_free_grace_stdv1.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1330,4 +1240,144 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
+ "history_registrar_id,history_modification_time,history_other_registrar_id,"
|
||||
+ "history_period_unit,history_period_value,history_reason,history");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v11() throws Exception {
|
||||
setEppInput("domain_delete.xml", FEE_11_MAP);
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
Money.of(USD, 11),
|
||||
TIME_BEFORE_FLOW.minusDays(5),
|
||||
Money.of(USD, 20)))
|
||||
.build());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
Money.of(USD, 11),
|
||||
TIME_BEFORE_FLOW.minusDays(5),
|
||||
Money.of(USD, 20)))
|
||||
.build());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
Money.of(USD, 11),
|
||||
TIME_BEFORE_FLOW.minusDays(5),
|
||||
Money.of(USD, 20)))
|
||||
.build());
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_freeCreation_deletionDuringGracePeriod_v12() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_1_00.getUri());
|
||||
// Deletion during the add grace period should still work even if the credit is 0
|
||||
setUpSuccessfulTest();
|
||||
BillingEvent graceBillingEvent =
|
||||
persistResource(createBillingEvent(Reason.CREATE, Money.of(USD, 0)));
|
||||
setUpGracePeriods(
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.ADD, domain.getRepoId(), graceBillingEvent));
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_fee_free_grace_v12.xml"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,6 +586,115 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistTestEntities(false);
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-dom-info");
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBulkInfoExtension_returnsBulkInfo() throws Exception {
|
||||
persistTestEntities(false);
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(TokenType.BULK_PRICING)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("foo"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
|
||||
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
|
||||
.setRenewalPrice(Money.of(USD, 0))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
|
||||
.setDiscountFraction(1.0)
|
||||
.build());
|
||||
domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build();
|
||||
persistResource(domain);
|
||||
setEppInput("domain_info_bulk.xml");
|
||||
doSuccessfulTest("domain_info_response_bulk.xml", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBulkInfoExtension_returnsBulkInfoForSuperUser() throws Exception {
|
||||
persistTestEntities(false);
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(TokenType.BULK_PRICING)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("foo"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
|
||||
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
|
||||
.setRenewalPrice(Money.of(USD, 0))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
|
||||
.setDiscountFraction(1.0)
|
||||
.build());
|
||||
domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build();
|
||||
persistResource(domain);
|
||||
sessionMetadata.setRegistrarId("TheRegistrar");
|
||||
setEppInput("domain_info_bulk.xml");
|
||||
EppOutput output = runFlowAsSuperuser();
|
||||
String expectedOutput =
|
||||
loadFile(
|
||||
"domain_info_response_superuser_bulk.xml",
|
||||
updateSubstitutions(ImmutableMap.of(), "ROID", "2FF-TLD"));
|
||||
assertXmlEquals(expectedOutput, new String(marshal(output, ValidationMode.LENIENT), UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBulkInfoExtension_nameNotInBulkPackage() throws Exception {
|
||||
setEppInput("domain_info_bulk.xml");
|
||||
doSuccessfulTest("domain_info_response_empty_bulk_package.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBulkInfoExtension_notCurrentSponsorRegistrar() throws Exception {
|
||||
persistTestEntities(false);
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(TokenType.BULK_PRICING)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("foo"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
|
||||
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
|
||||
.setRenewalPrice(Money.of(USD, 0))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
|
||||
.setDiscountFraction(1.0)
|
||||
.build());
|
||||
domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build();
|
||||
persistResource(domain);
|
||||
sessionMetadata.setRegistrarId("TheRegistrar");
|
||||
setEppInput("domain_info_bulk.xml");
|
||||
doSuccessfulTest("domain_info_response_unauthorized.xml", false);
|
||||
}
|
||||
|
||||
// The fee extension is no longer supported in domain:info commands as of version 1.0.
|
||||
// For now, we still support old versions.
|
||||
@Test
|
||||
void testFeeExtension_restoreCommand_pendingDelete_withRenewal() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
updateSubstitutions(
|
||||
SUBSTITUTION_BASE, "NAME", "rich.example", "COMMAND", "restore", "PERIOD", "1"));
|
||||
persistTestEntities("rich.example", false);
|
||||
setUpBillingEventForExistingDomain();
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.setDeletionTime(clock.nowUtc().plusDays(25))
|
||||
.setRegistrationExpirationTime(clock.nowUtc().minusDays(1))
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||
.build());
|
||||
doSuccessfulTest(
|
||||
"domain_info_fee_restore_response_with_renewal.xml", false, ImmutableMap.of(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create command. Fee extension version 6 is the only one which supports fee extensions on
|
||||
* info commands and responses, so we don't need to test the other versions.
|
||||
@@ -674,26 +783,6 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||
"domain_info_fee_restore_response_no_renewal.xml", false, ImmutableMap.of(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFeeExtension_restoreCommand_pendingDelete_withRenewal() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
updateSubstitutions(
|
||||
SUBSTITUTION_BASE, "NAME", "rich.example", "COMMAND", "restore", "PERIOD", "1"));
|
||||
persistTestEntities("rich.example", false);
|
||||
setUpBillingEventForExistingDomain();
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.setDeletionTime(clock.nowUtc().plusDays(25))
|
||||
.setRegistrationExpirationTime(clock.nowUtc().minusDays(1))
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||
.build());
|
||||
doSuccessfulTest(
|
||||
"domain_info_fee_restore_response_with_renewal.xml", false, ImmutableMap.of(), true);
|
||||
}
|
||||
|
||||
/** Test create command on a premium label. */
|
||||
@Test
|
||||
void testFeeExtension_createCommandPremium() throws Exception {
|
||||
@@ -867,16 +956,6 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFeeExtension_unknownCurrency() {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
updateSubstitutions(
|
||||
SUBSTITUTION_BASE, "COMMAND", "create", "CURRENCY", "BAD", "PERIOD", "1"));
|
||||
EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
/** Test requesting a period that isn't in years. */
|
||||
@Test
|
||||
void testFeeExtension_periodNotInYears() {
|
||||
@@ -934,89 +1013,12 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistTestEntities(false);
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-dom-info");
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBulkInfoExtension_returnsBulkInfo() throws Exception {
|
||||
persistTestEntities(false);
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(TokenType.BULK_PRICING)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("foo"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
|
||||
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
|
||||
.setRenewalPrice(Money.of(USD, 0))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
|
||||
.setDiscountFraction(1.0)
|
||||
.build());
|
||||
domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build();
|
||||
persistResource(domain);
|
||||
setEppInput("domain_info_bulk.xml");
|
||||
doSuccessfulTest("domain_info_response_bulk.xml", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBulkInfoExtension_returnsBulkInfoForSuperUser() throws Exception {
|
||||
persistTestEntities(false);
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(TokenType.BULK_PRICING)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("foo"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
|
||||
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
|
||||
.setRenewalPrice(Money.of(USD, 0))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
|
||||
.setDiscountFraction(1.0)
|
||||
.build());
|
||||
domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build();
|
||||
persistResource(domain);
|
||||
sessionMetadata.setRegistrarId("TheRegistrar");
|
||||
setEppInput("domain_info_bulk.xml");
|
||||
EppOutput output = runFlowAsSuperuser();
|
||||
String expectedOutput =
|
||||
loadFile(
|
||||
"domain_info_response_superuser_bulk.xml",
|
||||
updateSubstitutions(ImmutableMap.of(), "ROID", "2FF-TLD"));
|
||||
assertXmlEquals(expectedOutput, new String(marshal(output, ValidationMode.LENIENT), UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBulkInfoExtension_nameNotInBulkPackage() throws Exception {
|
||||
setEppInput("domain_info_bulk.xml");
|
||||
doSuccessfulTest("domain_info_response_empty_bulk_package.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBulkInfoExtension_notCurrentSponsorRegistrar() throws Exception {
|
||||
persistTestEntities(false);
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(TokenType.BULK_PRICING)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("foo"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
|
||||
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
|
||||
.setRenewalPrice(Money.of(USD, 0))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
|
||||
.setDiscountFraction(1.0)
|
||||
.build());
|
||||
domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build();
|
||||
persistResource(domain);
|
||||
sessionMetadata.setRegistrarId("TheRegistrar");
|
||||
setEppInput("domain_info_bulk.xml");
|
||||
doSuccessfulTest("domain_info_response_unauthorized.xml", false);
|
||||
void testFeeExtension_unknownCurrency() {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
updateSubstitutions(
|
||||
SUBSTITUTION_BASE, "COMMAND", "create", "CURRENCY", "BAD", "PERIOD", "1"));
|
||||
EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,11 +120,13 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
"CURRENCY", "USD");
|
||||
|
||||
private static final ImmutableMap<String, String> FEE_06_MAP =
|
||||
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "0.6", "FEE_NS", "fee");
|
||||
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "fee-0.6", "FEE_NS", "fee");
|
||||
private static final ImmutableMap<String, String> FEE_11_MAP =
|
||||
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "0.11", "FEE_NS", "fee11");
|
||||
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "fee-0.11", "FEE_NS", "fee11");
|
||||
private static final ImmutableMap<String, String> FEE_12_MAP =
|
||||
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "0.12", "FEE_NS", "fee12");
|
||||
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "fee-0.12", "FEE_NS", "fee12");
|
||||
private static final ImmutableMap<String, String> FEE_STD_1_0_MAP =
|
||||
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "epp:fee-1.0", "FEE_NS", "fee1_00");
|
||||
|
||||
private final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z");
|
||||
|
||||
@@ -390,7 +392,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_internalRegiration_premiumDomain() throws Exception {
|
||||
void testSuccess_internalRegiration_premiumDomain_std_v1() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
@@ -398,7 +400,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.build());
|
||||
persistDomain(SPECIFIED, Money.of(USD, 2));
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
ImmutableMap<String, String> customFeeMap = updateSubstitutions(FEE_06_MAP, "FEE", "10.00");
|
||||
ImmutableMap<String, String> customFeeMap =
|
||||
updateSubstitutions(FEE_STD_1_0_MAP, "FEE", "10.00");
|
||||
setEppInput("domain_renew_fee.xml", customFeeMap);
|
||||
doSuccessfulTest(
|
||||
"domain_renew_response_fee.xml",
|
||||
@@ -427,7 +430,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_anchorTenant_premiumDomain() throws Exception {
|
||||
void testSuccess_anchorTenant_premiumDomain_std_v1() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
@@ -435,7 +438,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.build());
|
||||
persistDomain(NONPREMIUM, null);
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
ImmutableMap<String, String> customFeeMap = updateSubstitutions(FEE_06_MAP, "FEE", "55.00");
|
||||
ImmutableMap<String, String> customFeeMap =
|
||||
updateSubstitutions(FEE_STD_1_0_MAP, "FEE", "55.00");
|
||||
setEppInput("domain_renew_fee.xml", customFeeMap);
|
||||
doSuccessfulTest(
|
||||
"domain_renew_response_fee.xml",
|
||||
@@ -449,12 +453,12 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_customLogicFee() throws Exception {
|
||||
void testSuccess_customLogicFee_std_v1() throws Exception {
|
||||
// The "costly-renew" domain has an additional RENEW fee of 100 from custom logic on top of the
|
||||
// normal $11 standard renew price for this TLD.
|
||||
ImmutableMap<String, String> customFeeMap =
|
||||
updateSubstitutions(
|
||||
FEE_06_MAP,
|
||||
FEE_STD_1_0_MAP,
|
||||
"NAME",
|
||||
"costly-renew.tld",
|
||||
"PERIOD",
|
||||
@@ -475,121 +479,45 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
void testSuccess_fee_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_STD_1_0_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_06_MAP);
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||
void testSuccess_fee_withDefaultAttributes_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee_defaults.xml", FEE_STD_1_0_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_defaults.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_defaults.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_defaults.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_12_MAP);
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_fee_unknownCurrency() {
|
||||
setEppInput("domain_renew_fee.xml", updateSubstitutions(FEE_06_MAP, "CURRENCY", "BAD"));
|
||||
setEppInput("domain_renew_fee.xml", updateSubstitutions(FEE_STD_1_0_MAP, "CURRENCY", "BAD"));
|
||||
EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::persistDomain);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_06_MAP);
|
||||
void testFailure_refundableFee_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_STD_1_0_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_11_MAP);
|
||||
void testFailure_gracePeriodFee_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_STD_1_0_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_12_MAP);
|
||||
void testFailure_appliedFee_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_STD_1_0_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
@@ -991,8 +919,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
void testFailure_wrongFeeAmount_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_STD_1_0_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
@@ -1004,34 +932,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
void testFailure_wrongCurrency_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_STD_1_0_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
@@ -1050,64 +952,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_12_MAP);
|
||||
void testFailure_feeGivenInWrongScale_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_STD_1_0_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
@@ -1522,8 +1368,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_doesNotApplyNonPremiumDefaultTokenToPremiumName() throws Exception {
|
||||
ImmutableMap<String, String> customFeeMap = updateSubstitutions(FEE_06_MAP, "FEE", "500");
|
||||
void testSuccess_doesNotApplyNonPremiumDefaultTokenToPremiumName_std_v1() throws Exception {
|
||||
ImmutableMap<String, String> customFeeMap = updateSubstitutions(FEE_STD_1_0_MAP, "FEE", "500");
|
||||
setEppInput("domain_renew_fee.xml", customFeeMap);
|
||||
persistDomain();
|
||||
AllocationToken defaultToken1 =
|
||||
@@ -1556,9 +1402,9 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
"CURRENCY",
|
||||
"USD",
|
||||
"FEE_VERSION",
|
||||
"0.6",
|
||||
"epp:fee-1.0",
|
||||
"FEE_NS",
|
||||
"fee")));
|
||||
"fee1_00")));
|
||||
BillingEvent billingEvent =
|
||||
Iterables.getOnlyElement(DatabaseHelper.loadAllOf(BillingEvent.class));
|
||||
assertThat(billingEvent.getTargetId()).isEqualTo("example.tld");
|
||||
@@ -1661,6 +1507,256 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
assertThat(billingEvent.getCost()).isEqualTo(Money.of(USD, 13.75));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_wrongFeeAmountTooHigh_defaultToken_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_STD_1_0_MAP);
|
||||
persistDomain();
|
||||
AllocationToken defaultToken1 =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("aaaaa")
|
||||
.setTokenType(DEFAULT_PROMO)
|
||||
.setDiscountFraction(0.5)
|
||||
.setDiscountYears(1)
|
||||
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||
.build());
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||
.build());
|
||||
runFlowAssertResponse(
|
||||
loadFile(
|
||||
"domain_renew_response_fee.xml",
|
||||
ImmutableMap.of(
|
||||
"NAME",
|
||||
"example.tld",
|
||||
"PERIOD",
|
||||
"5",
|
||||
"EX_DATE",
|
||||
"2005-04-03T22:00:00.0Z",
|
||||
"FEE",
|
||||
"49.50",
|
||||
"CURRENCY",
|
||||
"USD",
|
||||
"FEE_VERSION",
|
||||
"epp:fee-1.0",
|
||||
"FEE_NS",
|
||||
"fee1_00")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmountTooLow_defaultToken_std_v1() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_STD_1_0_MAP);
|
||||
persistDomain();
|
||||
AllocationToken defaultToken1 =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("aaaaa")
|
||||
.setTokenType(DEFAULT_PROMO)
|
||||
.setDiscountFraction(0.5)
|
||||
.setDiscountYears(1)
|
||||
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||
.build());
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_doesNotApplyNonPremiumDefaultTokenToPremiumName_v06() throws Exception {
|
||||
ImmutableMap<String, String> customFeeMap = updateSubstitutions(FEE_06_MAP, "FEE", "500");
|
||||
setEppInput("domain_renew_fee.xml", customFeeMap);
|
||||
persistDomain();
|
||||
AllocationToken defaultToken1 =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("aaaaa")
|
||||
.setTokenType(DEFAULT_PROMO)
|
||||
.setDiscountFraction(0.5)
|
||||
.setDiscountYears(1)
|
||||
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||
.build());
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||
.setPremiumList(persistPremiumList("tld", USD, "example,USD 100"))
|
||||
.build());
|
||||
runFlowAssertResponse(
|
||||
loadFile(
|
||||
"domain_renew_response_fee.xml",
|
||||
ImmutableMap.of(
|
||||
"NAME",
|
||||
"example.tld",
|
||||
"PERIOD",
|
||||
"5",
|
||||
"EX_DATE",
|
||||
"2005-04-03T22:00:00.0Z",
|
||||
"FEE",
|
||||
"500.00",
|
||||
"CURRENCY",
|
||||
"USD",
|
||||
"FEE_VERSION",
|
||||
"fee-0.6",
|
||||
"FEE_NS",
|
||||
"fee")));
|
||||
BillingEvent billingEvent =
|
||||
Iterables.getOnlyElement(DatabaseHelper.loadAllOf(BillingEvent.class));
|
||||
assertThat(billingEvent.getTargetId()).isEqualTo("example.tld");
|
||||
assertThat(billingEvent.getAllocationToken()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_internalRegiration_premiumDomain_v06() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setPremiumList(persistPremiumList("tld", USD, "example,USD 100"))
|
||||
.build());
|
||||
persistDomain(SPECIFIED, Money.of(USD, 2));
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
ImmutableMap<String, String> customFeeMap = updateSubstitutions(FEE_06_MAP, "FEE", "10.00");
|
||||
setEppInput("domain_renew_fee.xml", customFeeMap);
|
||||
doSuccessfulTest(
|
||||
"domain_renew_response_fee.xml",
|
||||
5,
|
||||
"NewRegistrar",
|
||||
UserPrivileges.SUPERUSER,
|
||||
customFeeMap,
|
||||
Money.of(USD, 10),
|
||||
SPECIFIED,
|
||||
Money.of(USD, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_wrongFeeAmountTooHigh_defaultToken_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
@@ -1694,7 +1790,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
"CURRENCY",
|
||||
"USD",
|
||||
"FEE_VERSION",
|
||||
"0.6",
|
||||
"fee-0.6",
|
||||
"FEE_NS",
|
||||
"fee")));
|
||||
}
|
||||
@@ -1755,7 +1851,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
"CURRENCY",
|
||||
"USD",
|
||||
"FEE_VERSION",
|
||||
"0.11",
|
||||
"fee-0.11",
|
||||
"FEE_NS",
|
||||
"fee")));
|
||||
}
|
||||
@@ -1816,7 +1912,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
"CURRENCY",
|
||||
"USD",
|
||||
"FEE_VERSION",
|
||||
"0.12",
|
||||
"fee-0.12",
|
||||
"FEE_NS",
|
||||
"fee")));
|
||||
}
|
||||
@@ -1843,4 +1939,166 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_defaults.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_defaults.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_defaults.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_anchorTenant_premiumDomain_v06() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setPremiumList(persistPremiumList("tld", USD, "example,USD 100"))
|
||||
.build());
|
||||
persistDomain(NONPREMIUM, null);
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
ImmutableMap<String, String> customFeeMap = updateSubstitutions(FEE_06_MAP, "FEE", "55.00");
|
||||
setEppInput("domain_renew_fee.xml", customFeeMap);
|
||||
doSuccessfulTest(
|
||||
"domain_renew_response_fee.xml",
|
||||
5,
|
||||
"NewRegistrar",
|
||||
UserPrivileges.SUPERUSER,
|
||||
customFeeMap,
|
||||
Money.of(USD, 55),
|
||||
NONPREMIUM,
|
||||
null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_customLogicFee_v06() throws Exception {
|
||||
// The "costly-renew" domain has an additional RENEW fee of 100 from custom logic on top of the
|
||||
// normal $11 standard renew price for this TLD.
|
||||
ImmutableMap<String, String> customFeeMap =
|
||||
updateSubstitutions(
|
||||
FEE_06_MAP,
|
||||
"NAME",
|
||||
"costly-renew.tld",
|
||||
"PERIOD",
|
||||
"1",
|
||||
"EX_DATE",
|
||||
"2001-04-03T22:00:00.0Z",
|
||||
"FEE",
|
||||
"111.00");
|
||||
setEppInput("domain_renew_fee.xml", customFeeMap);
|
||||
persistDomain();
|
||||
doSuccessfulTest(
|
||||
"domain_renew_response_fee.xml",
|
||||
1,
|
||||
"TheRegistrar",
|
||||
UserPrivileges.NORMAL,
|
||||
customFeeMap,
|
||||
Money.of(USD, 111));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,11 +87,13 @@ import org.junit.jupiter.api.Test;
|
||||
class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreRequestFlow, Domain> {
|
||||
|
||||
private static final ImmutableMap<String, String> FEE_06_MAP =
|
||||
ImmutableMap.of("FEE_VERSION", "0.6", "FEE_NS", "fee", "CURRENCY", "USD");
|
||||
ImmutableMap.of("FEE_VERSION", "fee-0.6", "FEE_NS", "fee", "CURRENCY", "USD");
|
||||
private static final ImmutableMap<String, String> FEE_11_MAP =
|
||||
ImmutableMap.of("FEE_VERSION", "0.11", "FEE_NS", "fee11", "CURRENCY", "USD");
|
||||
ImmutableMap.of("FEE_VERSION", "fee-0.11", "FEE_NS", "fee11", "CURRENCY", "USD");
|
||||
private static final ImmutableMap<String, String> FEE_12_MAP =
|
||||
ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12", "CURRENCY", "USD");
|
||||
ImmutableMap.of("FEE_VERSION", "fee-0.12", "FEE_NS", "fee12", "CURRENCY", "USD");
|
||||
private static final ImmutableMap<String, String> FEE_STD_1_0_MAP =
|
||||
ImmutableMap.of("FEE_VERSION", "epp:fee-1.0", "FEE_NS", "fee1_00", "CURRENCY", "USD");
|
||||
|
||||
@BeforeEach
|
||||
void initDomainTest() {
|
||||
@@ -308,7 +310,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
|
||||
@Test
|
||||
void testSuccess_autorenewEndTimeIsCleared() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(
|
||||
reloadResourceByForeignKey()
|
||||
@@ -316,64 +318,31 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
.setAutorenewEndTime(Optional.of(clock.nowUtc().plusYears(2)))
|
||||
.build());
|
||||
assertThat(reloadResourceByForeignKey().getAutorenewEndTime()).isPresent();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_update_restore_request_response_fee.xml", FEE_STD_1_0_MAP));
|
||||
assertThat(reloadResourceByForeignKey().getAutorenewEndTime()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
|
||||
void testSuccess_fee_std_v1() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v06_noRenewal() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_no_renewal.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain(clock.nowUtc().plusMonths(6));
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_06_MAP));
|
||||
loadFile("domain_update_restore_request_response_fee.xml", FEE_STD_1_0_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
|
||||
void testSuccess_fee_withDefaultAttributes_std_v1() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_update_restore_request_response_fee.xml", FEE_STD_1_0_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_fee_unknownCurrency() {
|
||||
void testFailure_fee_unknownCurrency_std_v1() {
|
||||
ImmutableMap<String, String> substitutions =
|
||||
ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12", "CURRENCY", "BAD");
|
||||
ImmutableMap.of("FEE_VERSION", "epp:fee-1.0", "FEE_NS", "fee1_00", "CURRENCY", "BAD");
|
||||
setEppInput("domain_update_restore_request_fee.xml", substitutions);
|
||||
EppException thrown =
|
||||
assertThrows(UnknownCurrencyEppException.class, this::persistPendingDeleteDomain);
|
||||
@@ -381,72 +350,24 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_06_MAP);
|
||||
void testFailure_refundableFee_std_v1() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_11_MAP);
|
||||
void testFailure_gracePeriodFee_std_v1() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_12_MAP);
|
||||
void testFailure_appliedFee_std_v1() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
@@ -455,18 +376,19 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
@Test
|
||||
void testSuccess_premiumNotBlocked() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium.xml");
|
||||
setEppInput("domain_update_restore_request_premium.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_premium.xml"));
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_update_restore_request_response_premium.xml", FEE_STD_1_0_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_premiumNotBlocked_andNoRenewal() throws Exception {
|
||||
void testSuccess_premiumNotBlocked_andNoRenewal_std_v1() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium_no_renewal.xml");
|
||||
setEppInput("domain_update_restore_request_premium_no_renewal.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain(clock.nowUtc().plusYears(2));
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_12_MAP));
|
||||
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_STD_1_0_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -484,14 +406,14 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
@Test
|
||||
void testSuccess_superuserOverridesPremiumNameBlock() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium.xml");
|
||||
setEppInput("domain_update_restore_request_premium.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
// Modify the Registrar to block premium names.
|
||||
persistResource(loadRegistrar("TheRegistrar").asBuilder().setBlockPremiumNames(true).build());
|
||||
runFlowAssertResponse(
|
||||
CommitMode.LIVE,
|
||||
UserPrivileges.SUPERUSER,
|
||||
loadFile("domain_update_restore_request_response_premium.xml"));
|
||||
loadFile("domain_update_restore_request_response_premium.xml", FEE_STD_1_0_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -538,26 +460,8 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP);
|
||||
void testFailure_wrongFeeAmount_std_v1() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
@@ -584,39 +488,13 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() throws Exception {
|
||||
runWrongCurrencyTest(FEE_06_MAP);
|
||||
void testFailure_wrongCurrency_std_v1() throws Exception {
|
||||
runWrongCurrencyTest(FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() throws Exception {
|
||||
runWrongCurrencyTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() throws Exception {
|
||||
runWrongCurrencyTest(FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_12_MAP);
|
||||
void testFailure_feeGivenInWrongScale_std_v1() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
@@ -738,9 +616,9 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_premiumBlocked() throws Exception {
|
||||
void testFailure_premiumBlocked_std_v1() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium.xml");
|
||||
setEppInput("domain_update_restore_request_premium.xml", FEE_STD_1_0_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
// Modify the Registrar to block premium names.
|
||||
persistResource(loadRegistrar("TheRegistrar").asBuilder().setBlockPremiumNames(true).build());
|
||||
@@ -805,4 +683,222 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
assertThat(thrown).hasMessageThat().contains("domain restore reports are not supported");
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v06_noRenewal() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_no_renewal.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain(clock.nowUtc().plusMonths(6));
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() throws Exception {
|
||||
runWrongCurrencyTest(FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() throws Exception {
|
||||
runWrongCurrencyTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() throws Exception {
|
||||
runWrongCurrencyTest(FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_premiumBlocked_v12() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
// Modify the Registrar to block premium names.
|
||||
persistResource(loadRegistrar("TheRegistrar").asBuilder().setBlockPremiumNames(true).build());
|
||||
EppException thrown = assertThrows(PremiumNameBlockedException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_premiumNotBlocked_andNoRenewal_v12() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium_no_renewal.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain(clock.nowUtc().plusYears(2));
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_fee_unknownCurrency_v12() {
|
||||
ImmutableMap<String, String> substitutions =
|
||||
ImmutableMap.of("FEE_VERSION", "fee-0.12", "FEE_NS", "fee12", "CURRENCY", "BAD");
|
||||
setEppInput("domain_update_restore_request_fee.xml", substitutions);
|
||||
EppException thrown =
|
||||
assertThrows(UnknownCurrencyEppException.class, this::persistPendingDeleteDomain);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static google.registry.testing.HostSubject.assertAboutHosts;
|
||||
import static google.registry.testing.TestDataHelper.updateSubstitutions;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
@@ -149,29 +150,31 @@ class DomainTransferRequestFlowTest
|
||||
private static final ImmutableMap<String, String> FEE_06_MAP =
|
||||
new ImmutableMap.Builder<String, String>()
|
||||
.putAll(BASE_FEE_MAP)
|
||||
.put("FEE_VERSION", "0.6")
|
||||
.put("FEE_VERSION", "fee-0.6")
|
||||
.put("FEE_NS", "fee")
|
||||
.build();
|
||||
private static final ImmutableMap<String, String> FEE_11_MAP =
|
||||
new ImmutableMap.Builder<String, String>()
|
||||
.putAll(BASE_FEE_MAP)
|
||||
.put("FEE_VERSION", "0.11")
|
||||
.put("FEE_VERSION", "fee-0.11")
|
||||
.put("FEE_NS", "fee11")
|
||||
.build();
|
||||
private static final ImmutableMap<String, String> FEE_12_MAP =
|
||||
new ImmutableMap.Builder<String, String>()
|
||||
.putAll(BASE_FEE_MAP)
|
||||
.put("FEE_VERSION", "0.12")
|
||||
.put("FEE_VERSION", "fee-0.12")
|
||||
.put("FEE_NS", "fee12")
|
||||
.build();
|
||||
private static final ImmutableMap<String, String> FEE_STD_1_0_MAP =
|
||||
updateSubstitutions(BASE_FEE_MAP, "FEE_VERSION", "epp:fee-1.0", "FEE_NS", "fee1_00");
|
||||
private static final ImmutableMap<String, String> RICH_DOMAIN_MAP =
|
||||
ImmutableMap.<String, String>builder()
|
||||
.put("DOMAIN", "rich.example")
|
||||
.put("YEARS", "1")
|
||||
.put("AMOUNT", "100.00")
|
||||
.put("CURRENCY", "USD")
|
||||
.put("FEE_VERSION", "0.12")
|
||||
.put("FEE_NS", "fee12")
|
||||
.put("FEE_VERSION", "epp:fee-1.0")
|
||||
.put("FEE_NS", "fee")
|
||||
.build();
|
||||
|
||||
@BeforeEach
|
||||
@@ -665,140 +668,50 @@ class DomainTransferRequestFlowTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v06() throws Exception {
|
||||
void testSuccess_fee_std_v1() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_06_MAP);
|
||||
"domain_transfer_request_fee.xml",
|
||||
"domain_transfer_request_response_fee.xml",
|
||||
FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v11() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v12() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
|
||||
void testSuccess_fee_withDefaultAttributes_std_v1() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee_defaults.xml",
|
||||
"domain_transfer_request_response_fee.xml",
|
||||
FEE_06_MAP);
|
||||
FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee_defaults.xml",
|
||||
"domain_transfer_request_response_fee.xml",
|
||||
FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee_defaults.xml",
|
||||
"domain_transfer_request_response_fee.xml",
|
||||
FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() {
|
||||
void testFailure_refundableFee_std_v1() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_06_MAP));
|
||||
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_STD_1_0_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() {
|
||||
void testFailure_gracePeriodFee_std_v1() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_11_MAP));
|
||||
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_STD_1_0_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() {
|
||||
void testFailure_appliedFee_std_v1() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_12_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_06_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_11_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_12_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_06_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_11_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_12_MAP));
|
||||
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_STD_1_0_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@@ -991,7 +904,7 @@ class DomainTransferRequestFlowTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_superuserExtension_zeroPeriod_feeTransferExtension() {
|
||||
void testFailure_superuserExtension_zeroPeriod_feeTransferExtension_std_v1() {
|
||||
setupDomain("example", "tld");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
clock.advanceOneMilli();
|
||||
@@ -1001,7 +914,11 @@ class DomainTransferRequestFlowTest
|
||||
runTest(
|
||||
"domain_transfer_request_fee_and_superuser_extension.xml",
|
||||
UserPrivileges.SUPERUSER,
|
||||
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "5")));
|
||||
new ImmutableMap.Builder<String, String>()
|
||||
.putAll(FEE_STD_1_0_MAP)
|
||||
.put("PERIOD", "0")
|
||||
.put("AUTOMATIC_TRANSFER_LENGTH", "5")
|
||||
.build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1063,7 +980,7 @@ class DomainTransferRequestFlowTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_customLogicFee() throws Exception {
|
||||
void testSuccess_customLogicFee_std_v1() throws Exception {
|
||||
setupDomain("expensive-domain", "foo");
|
||||
clock.advanceOneMilli();
|
||||
doSuccessfulTest(
|
||||
@@ -1075,7 +992,7 @@ class DomainTransferRequestFlowTest
|
||||
.put("YEARS", "1")
|
||||
.put("AMOUNT", "111.00")
|
||||
.put("EXDATE", "2002-09-08T22:00:00.0Z")
|
||||
.put("FEE_VERSION", "0.6")
|
||||
.put("FEE_VERSION", "epp:fee-1.0")
|
||||
.put("FEE_NS", "fee")
|
||||
.build(),
|
||||
Optional.of(Money.of(USD, 111)));
|
||||
@@ -1227,7 +1144,7 @@ class DomainTransferRequestFlowTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_premiumNotBlocked() throws Exception {
|
||||
void testSuccess_premiumNotBlocked_v06() throws Exception {
|
||||
setupDomain("rich", "example");
|
||||
clock.advanceOneMilli();
|
||||
// We don't verify the results; just check that the flow doesn't fail.
|
||||
@@ -1235,7 +1152,7 @@ class DomainTransferRequestFlowTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_premiumNotBlockedInSuperuserMode() throws Exception {
|
||||
void testSuccess_premiumNotBlockedInSuperuserMode_std_v1() throws Exception {
|
||||
setupDomain("rich", "example");
|
||||
clock.advanceOneMilli();
|
||||
// Modify the Registrar to block premium names.
|
||||
@@ -1525,24 +1442,14 @@ class DomainTransferRequestFlowTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() {
|
||||
runWrongCurrencyTest(FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() {
|
||||
runWrongCurrencyTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() {
|
||||
runWrongCurrencyTest(FEE_12_MAP);
|
||||
void testFailure_wrongCurrency_std_v1() {
|
||||
runWrongCurrencyTest(FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_unknownCurrency() {
|
||||
Map<String, String> substitutions = Maps.newHashMap();
|
||||
substitutions.putAll(FEE_06_MAP);
|
||||
substitutions.putAll(FEE_STD_1_0_MAP);
|
||||
substitutions.put("CURRENCY", "BAD");
|
||||
setupDomain("example", "tld");
|
||||
setEppInput("domain_transfer_request_fee.xml", substitutions);
|
||||
@@ -1551,32 +1458,12 @@ class DomainTransferRequestFlowTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() {
|
||||
void testFailure_feeGivenInWrongScale_std_v1() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
CurrencyValueScaleException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_06_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
CurrencyValueScaleException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_11_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
CurrencyValueScaleException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_12_MAP));
|
||||
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_STD_1_0_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@@ -1594,21 +1481,9 @@ class DomainTransferRequestFlowTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() {
|
||||
void testFailure_wrongFeeAmount_std_v1() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_12_MAP);
|
||||
runWrongFeeAmountTest(FEE_STD_1_0_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1969,4 +1844,250 @@ class DomainTransferRequestFlowTest
|
||||
assertThrows(AlreadyRedeemedAllocationTokenException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_06_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_11_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_12_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_06_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_11_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_12_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee_defaults.xml",
|
||||
"domain_transfer_request_response_fee.xml",
|
||||
FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee_defaults.xml",
|
||||
"domain_transfer_request_response_fee.xml",
|
||||
FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee_defaults.xml",
|
||||
"domain_transfer_request_response_fee.xml",
|
||||
FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_06_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_11_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
UnsupportedFeeAttributeException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_12_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() {
|
||||
runWrongCurrencyTest(FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() {
|
||||
runWrongCurrencyTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() {
|
||||
runWrongCurrencyTest(FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
CurrencyValueScaleException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_06_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
CurrencyValueScaleException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_11_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
CurrencyValueScaleException.class,
|
||||
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_12_MAP));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v06() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v11() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_fee_v12() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_12_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_customLogicFee_v06() throws Exception {
|
||||
setupDomain("expensive-domain", "foo");
|
||||
clock.advanceOneMilli();
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_separate_fees.xml",
|
||||
"domain_transfer_request_response_fees.xml",
|
||||
domain.getRegistrationExpirationTime().plusYears(1),
|
||||
new ImmutableMap.Builder<String, String>()
|
||||
.put("DOMAIN", "expensive-domain.foo")
|
||||
.put("YEARS", "1")
|
||||
.put("AMOUNT", "111.00")
|
||||
.put("EXDATE", "2002-09-08T22:00:00.0Z")
|
||||
.put("FEE_VERSION", "fee-0.6")
|
||||
.put("FEE_NS", "fee")
|
||||
.build(),
|
||||
Optional.of(Money.of(USD, 111)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_premiumNotBlocked_v12() throws Exception {
|
||||
setupDomain("rich", "example");
|
||||
clock.advanceOneMilli();
|
||||
// We don't verify the results; just check that the flow doesn't fail.
|
||||
runTest("domain_transfer_request_fee.xml", UserPrivileges.NORMAL, RICH_DOMAIN_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_superuserExtension_zeroPeriod_feeTransferExtension_v12() {
|
||||
setupDomain("example", "tld");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
clock.advanceOneMilli();
|
||||
assertThrows(
|
||||
TransferPeriodZeroAndFeeTransferExtensionException.class,
|
||||
() ->
|
||||
runTest(
|
||||
"domain_transfer_request_fee_and_superuser_extension.xml",
|
||||
UserPrivileges.SUPERUSER,
|
||||
new ImmutableMap.Builder<String, String>()
|
||||
.putAll(FEE_12_MAP)
|
||||
.put("PERIOD", "0")
|
||||
.put("AUTOMATIC_TRANSFER_LENGTH", "5")
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,16 +63,15 @@ import google.registry.config.RegistryConfig;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.FlowTestCase.CommitMode;
|
||||
import google.registry.flows.FlowTestCase.UserPrivileges;
|
||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.AddExistingValueException;
|
||||
import google.registry.flows.ResourceFlowUtils.AddRemoveSameValueException;
|
||||
import google.registry.flows.ResourceFlowUtils.RemoveNonexistentValueException;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceFlowUtils.StatusNotClientSettableException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.EmptySecDnsUpdateException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesMismatchException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeOperationException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.InvalidDsRecordException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.LinkedResourceInPendingDeleteProhibitsOperationException;
|
||||
@@ -359,10 +358,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
}
|
||||
}
|
||||
persistResource(
|
||||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.setNameservers(nameservers.build())
|
||||
.build());
|
||||
reloadResourceByForeignKey().asBuilder().setNameservers(nameservers.build()).build());
|
||||
clock.advanceOneMilli();
|
||||
assertMutatingFlow(true);
|
||||
runFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
@@ -452,6 +448,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
|
||||
@Test
|
||||
void testSuccess_removeClientUpdateProhibited() throws Exception {
|
||||
setEppInput("domain_update_remove_client_update_prohibited.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
persistDomain()
|
||||
@@ -547,21 +544,26 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_secDnsAddSameDoesNothing() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
ImmutableMap.of(
|
||||
"KEY_TAG",
|
||||
"1",
|
||||
"ALG",
|
||||
"2",
|
||||
"DIGEST_TYPE",
|
||||
"2",
|
||||
"DIGEST",
|
||||
"9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"),
|
||||
false);
|
||||
void testFailure_secDnsAddSame_throwsException() throws Exception {
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
AddExistingValueException.class,
|
||||
() ->
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
ImmutableMap.of(
|
||||
"KEY_TAG",
|
||||
"1",
|
||||
"ALG",
|
||||
"2",
|
||||
"DIGEST_TYPE",
|
||||
"2",
|
||||
"DIGEST",
|
||||
"9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"),
|
||||
false));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -679,7 +681,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
2,
|
||||
2,
|
||||
base16()
|
||||
.decode("9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"))),
|
||||
.decode("0F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"))),
|
||||
ImmutableMap.of(
|
||||
"KEY_TAG",
|
||||
"1",
|
||||
@@ -688,8 +690,8 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
"DIGEST_TYPE",
|
||||
"2",
|
||||
"DIGEST",
|
||||
"9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"),
|
||||
false);
|
||||
"0F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"),
|
||||
true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -797,29 +799,43 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
}
|
||||
|
||||
@Test
|
||||
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",
|
||||
ImmutableSet.of(
|
||||
SOME_DSDATA,
|
||||
DomainDsData.create(
|
||||
12345, 3, 1, base16().decode("A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"))),
|
||||
ImmutableSet.of(
|
||||
SOME_DSDATA,
|
||||
DomainDsData.create(
|
||||
12345, 3, 1, base16().decode("A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"))),
|
||||
false);
|
||||
void testFailure_secDnsAddRemoveSame_throwsException() throws Exception {
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
AddRemoveSameValueException.class,
|
||||
() ->
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add_rem_same.xml",
|
||||
ImmutableSet.of(
|
||||
SOME_DSDATA,
|
||||
DomainDsData.create(
|
||||
12345,
|
||||
3,
|
||||
1,
|
||||
base16().decode("A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"))),
|
||||
ImmutableSet.of(
|
||||
SOME_DSDATA,
|
||||
DomainDsData.create(
|
||||
12345,
|
||||
3,
|
||||
1,
|
||||
base16().decode("A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"))),
|
||||
false));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
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),
|
||||
false);
|
||||
void testFailure_secDnsRemoveAlreadyNotThere_throwsException() throws Exception {
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
RemoveNonexistentValueException.class,
|
||||
() ->
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_rem.xml",
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
ImmutableSet.of(SOME_DSDATA),
|
||||
false));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
void doServerStatusBillingTest(String xmlFilename, boolean isBillable) throws Exception {
|
||||
@@ -854,14 +870,6 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doServerStatusBillingTest("domain_update_add_server_status.xml", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_noBillingOnPreExistingServerStatus() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
Domain addStatusDomain = persistActiveDomain(getUniqueIdFromCommand());
|
||||
persistResource(addStatusDomain.asBuilder().addStatusValue(SERVER_RENEW_PROHIBITED).build());
|
||||
doServerStatusBillingTest("domain_update_add_server_status.xml", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_removeServerStatusBillingEvent() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
@@ -1373,6 +1381,52 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_addExistingNameserver() throws Exception {
|
||||
Host host = persistActiveHost("ns2.example.foo");
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain(getUniqueIdFromCommand())
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(host.createVKey()))
|
||||
.build());
|
||||
setEppInput("domain_update_add_nameserver.xml");
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(AddExistingValueException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_addExistingStatusValue() throws Exception {
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain(getUniqueIdFromCommand())
|
||||
.asBuilder()
|
||||
.setStatusValues(ImmutableSet.of(CLIENT_RENEW_PROHIBITED))
|
||||
.build());
|
||||
setEppInput("domain_update_add_non_server_status.xml");
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(AddExistingValueException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_removeNonexistentNameserver() throws Exception {
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
persistActiveHost("ns1.example.foo");
|
||||
setEppInput("domain_update_remove_nameserver.xml");
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(RemoveNonexistentValueException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_removeNonexistentStatusValue() throws Exception {
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
setEppInput("domain_update_remove_client_update_prohibited.xml");
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(RemoveNonexistentValueException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_minimumDataset_addingNewRegistrantFails() throws Exception {
|
||||
persistReferencedEntities();
|
||||
@@ -1476,15 +1530,6 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutDomains().that(reloadResourceByForeignKey()).hasExactlyStatusValues(CLIENT_HOLD);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_freePremium_wrongFee() throws Exception {
|
||||
setEppInput("domain_update_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
// This test should throw an exception, because the fee extension is required when the fee is not
|
||||
// zero.
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright 2026 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.flows.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import google.registry.model.eppcommon.ProtocolDefinition;
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Class for testing the XML extension definitions loaded in the prod environment. */
|
||||
public class ProductionSimulatingFeeExtensionsTest {
|
||||
|
||||
private RegistryEnvironment previousEnvironment;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
previousEnvironment = RegistryEnvironment.get();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
previousEnvironment.setup();
|
||||
ProtocolDefinition.reloadServiceExtensionUris();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonProdEnvironments() {
|
||||
for (RegistryEnvironment env : RegistryEnvironment.values()) {
|
||||
if (env.equals(RegistryEnvironment.PRODUCTION)) {
|
||||
continue;
|
||||
}
|
||||
env.setup();
|
||||
ProtocolDefinition.reloadServiceExtensionUris();
|
||||
assertThat(ProtocolDefinition.getVisibleServiceExtensionUris())
|
||||
.containsExactly(
|
||||
"urn:ietf:params:xml:ns:launch-1.0",
|
||||
"urn:ietf:params:xml:ns:rgp-1.0",
|
||||
"urn:ietf:params:xml:ns:secDNS-1.1",
|
||||
"urn:ietf:params:xml:ns:fee-0.6",
|
||||
"urn:ietf:params:xml:ns:fee-0.11",
|
||||
"urn:ietf:params:xml:ns:fee-0.12",
|
||||
"urn:ietf:params:xml:ns:epp:fee-1.0");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProdEnvironment() {
|
||||
RegistryEnvironment.PRODUCTION.setup();
|
||||
ProtocolDefinition.reloadServiceExtensionUris();
|
||||
// prod shouldn't have the fee extension version 1.0
|
||||
assertThat(ProtocolDefinition.getVisibleServiceExtensionUris())
|
||||
.containsExactly(
|
||||
"urn:ietf:params:xml:ns:launch-1.0",
|
||||
"urn:ietf:params:xml:ns:rgp-1.0",
|
||||
"urn:ietf:params:xml:ns:secDNS-1.1",
|
||||
"urn:ietf:params:xml:ns:fee-0.6",
|
||||
"urn:ietf:params:xml:ns:fee-0.11",
|
||||
"urn:ietf:params:xml:ns:fee-0.12");
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,9 @@ import static google.registry.testing.DatabaseHelper.persistDeletedHost;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.ParameterValueSyntaxErrorException;
|
||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.flows.ResourceCheckFlowTestCase;
|
||||
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
||||
@@ -95,4 +97,36 @@ class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, Host> {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-host-check");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_dotHost() throws Exception {
|
||||
setEppInput("host_check_generic.xml", ImmutableMap.of("HOSTNAME", ".host"));
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(ParameterValueSyntaxErrorException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_dashHost() {
|
||||
setEppInput("host_check_generic.xml", ImmutableMap.of("HOSTNAME", "-host"));
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(ParameterValueSyntaxErrorException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_underscoreHost() {
|
||||
setEppInput("host_check_generic.xml", ImmutableMap.of("HOSTNAME", "_host"));
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(ParameterValueSyntaxErrorException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_hostDash() {
|
||||
setEppInput("host_check_generic.xml", ImmutableMap.of("HOSTNAME", "host-"));
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(ParameterValueSyntaxErrorException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,12 +39,14 @@ import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientExcept
|
||||
import google.registry.flows.exceptions.ResourceCreateContentionException;
|
||||
import google.registry.flows.host.HostCreateFlow.SubordinateHostMustHaveIpException;
|
||||
import google.registry.flows.host.HostCreateFlow.UnexpectedExternalHostIpException;
|
||||
import google.registry.flows.host.HostFlowUtils.BadHostNameCharacterException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameTooLongException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
|
||||
import google.registry.flows.host.HostFlowUtils.InvalidHostNameException;
|
||||
import google.registry.flows.host.HostFlowUtils.LoopbackIpNotValidForHostException;
|
||||
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainDoesNotExistException;
|
||||
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainInPendingDeleteException;
|
||||
import google.registry.model.ForeignKeyUtils;
|
||||
@@ -81,9 +83,14 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
|
||||
}
|
||||
|
||||
private void doSuccessfulTest() throws Exception {
|
||||
doSuccessfulTest("host_create_response.xml", ImmutableMap.of());
|
||||
}
|
||||
|
||||
private void doSuccessfulTest(String responseFile, ImmutableMap<String, String> substitutions)
|
||||
throws Exception {
|
||||
clock.advanceOneMilli();
|
||||
assertMutatingFlow(true);
|
||||
runFlowAssertResponse(loadFile("host_create_response.xml"));
|
||||
runFlowAssertResponse(loadFile(responseFile, substitutions));
|
||||
Host host = reloadResourceByForeignKey();
|
||||
// Check that the host was created and persisted with a history entry.
|
||||
assertAboutHosts()
|
||||
@@ -133,6 +140,28 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
|
||||
assertHostDnsRequests("ns1.example.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_tldWithHyphenOn3And4() throws Exception {
|
||||
setEppHostCreateInput("ns1.example.zz--main-2262", null);
|
||||
doSuccessfulTest(
|
||||
"host_create_response_wildcard.xml",
|
||||
ImmutableMap.of("HOSTNAME", "ns1.example.zz--main-2262"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_domainWithHyphenOn3And4() throws Exception {
|
||||
setEppHostCreateInput("ns1.zz--main-2262.tld", null);
|
||||
EppException thrown = assertThrows(InvalidHostNameException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_hostnameWithHyphenOn3And4() throws Exception {
|
||||
setEppHostCreateInput("zz--ns1.domain.tld", null);
|
||||
EppException thrown = assertThrows(InvalidHostNameException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_multipartTLDsAndInvalidHost() {
|
||||
createTlds("bar.tld", "tld");
|
||||
@@ -286,7 +315,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
|
||||
|
||||
@Test
|
||||
void testFailure_badCharacter() {
|
||||
doFailingHostNameTest("foo bar", InvalidHostNameException.class);
|
||||
doFailingHostNameTest("foo bar", BadHostNameCharacterException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -322,6 +351,26 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_localhostInetAddress_ipv4() {
|
||||
createTld("tld");
|
||||
persistActiveDomain("example.tld");
|
||||
setEppHostCreateInput("ns1.example.tld", "<host:addr ip=\"v4\">127.0.0.1</host:addr>");
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(LoopbackIpNotValidForHostException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_localhostInetAddress_ipv6() {
|
||||
createTld("tld");
|
||||
persistActiveDomain("example.tld");
|
||||
setEppHostCreateInput("ns1.example.tld", "<host:addr ip=\"v6\">::1</host:addr>");
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(LoopbackIpNotValidForHostException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
|
||||
@@ -48,19 +48,22 @@ import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.AddExistingValueException;
|
||||
import google.registry.flows.ResourceFlowUtils.AddRemoveSameValueException;
|
||||
import google.registry.flows.ResourceFlowUtils.RemoveNonexistentValueException;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceFlowUtils.StatusNotClientSettableException;
|
||||
import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException;
|
||||
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
|
||||
import google.registry.flows.host.HostFlowUtils.BadHostNameCharacterException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostDomainNotOwnedException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameTooLongException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
|
||||
import google.registry.flows.host.HostFlowUtils.InvalidHostNameException;
|
||||
import google.registry.flows.host.HostFlowUtils.LoopbackIpNotValidForHostException;
|
||||
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainDoesNotExistException;
|
||||
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainInPendingDeleteException;
|
||||
import google.registry.flows.host.HostUpdateFlow.CannotAddIpToExternalHostException;
|
||||
@@ -521,6 +524,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.asBuilder()
|
||||
.setSuperordinateDomain(foo.createVKey())
|
||||
.setLastTransferTime(null)
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
|
||||
clock.advanceOneMilli();
|
||||
@@ -560,6 +565,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.setSuperordinateDomain(domain.createVKey())
|
||||
.setLastTransferTime(clock.nowUtc().minusDays(20))
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
DateTime lastTransferTime = host.getLastTransferTime();
|
||||
persistResource(domain.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
|
||||
@@ -597,6 +604,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.setSuperordinateDomain(foo.createVKey())
|
||||
.setLastTransferTime(lastTransferTime)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
|
||||
clock.advanceOneMilli();
|
||||
@@ -631,6 +640,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.setSuperordinateDomain(foo.createVKey())
|
||||
.setLastTransferTime(lastTransferTime)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(10))
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
|
||||
clock.advanceOneMilli();
|
||||
@@ -665,6 +676,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.setSuperordinateDomain(foo.createVKey())
|
||||
.setLastTransferTime(null)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
|
||||
Host renamedHost = doSuccessfulTest();
|
||||
@@ -686,7 +699,12 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
createTld("foo");
|
||||
Domain domain = persistActiveDomain("example.foo");
|
||||
persistResource(
|
||||
newHost(oldHostName()).asBuilder().setSuperordinateDomain(domain.createVKey()).build());
|
||||
newHost(oldHostName())
|
||||
.asBuilder()
|
||||
.setSuperordinateDomain(domain.createVKey())
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
DateTime lastTransferTime = clock.nowUtc().minusDays(2);
|
||||
persistResource(
|
||||
domain
|
||||
@@ -727,6 +745,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.setSuperordinateDomain(domain.createVKey())
|
||||
.setLastTransferTime(lastTransferTime)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
persistResource(
|
||||
domain
|
||||
@@ -762,6 +782,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.setSuperordinateDomain(domain.createVKey())
|
||||
.setLastTransferTime(clock.nowUtc().minusDays(12))
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
domain =
|
||||
persistResource(
|
||||
@@ -1006,6 +1028,50 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_addExistingInetAddress() throws Exception {
|
||||
createTld("tld");
|
||||
Domain domain = persistActiveDomain("example.tld");
|
||||
persistResource(
|
||||
newHost(oldHostName())
|
||||
.asBuilder()
|
||||
.setSuperordinateDomain(domain.createVKey())
|
||||
.setLastTransferTime(clock.nowUtc().minusDays(12))
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.tld",
|
||||
"ns2.example.tld",
|
||||
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>",
|
||||
null);
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(AddExistingValueException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_removeNonexistentInetAddress() throws Exception {
|
||||
createTld("tld");
|
||||
Domain domain = persistActiveDomain("example.tld");
|
||||
persistResource(
|
||||
newHost(oldHostName())
|
||||
.asBuilder()
|
||||
.setSuperordinateDomain(domain.createVKey())
|
||||
.setLastTransferTime(clock.nowUtc().minusDays(12))
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
||||
.build());
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.tld",
|
||||
"ns2.example.tld",
|
||||
null,
|
||||
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(RemoveNonexistentValueException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_clientUpdateProhibited_removed() throws Exception {
|
||||
setEppInput("host_update_remove_client_update_prohibited.xml");
|
||||
@@ -1077,7 +1143,12 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
setEppInput("host_update_prohibited_status.xml");
|
||||
createTld("tld");
|
||||
persistActiveDomain("example.tld");
|
||||
persistActiveHost("ns1.example.tld");
|
||||
persistResource(
|
||||
persistActiveHost("ns1.example.tld")
|
||||
.asBuilder()
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(
|
||||
@@ -1259,7 +1330,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
|
||||
@Test
|
||||
void testFailure_renameToBadCharacter() throws Exception {
|
||||
doFailingHostNameTest("foo bar", InvalidHostNameException.class);
|
||||
doFailingHostNameTest("foo bar", BadHostNameCharacterException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1306,6 +1377,28 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_localhostInetAddress_ipv4() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.tld", "ns2.example.tld", "<host:addr ip=\"v4\">127.0.0.1</host:addr>", null);
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(LoopbackIpNotValidForHostException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_localhostInetAddress_ipv6() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.tld", "ns2.example.tld", "<host:addr ip=\"v6\">::1</host:addr>", null);
|
||||
assertAboutEppExceptions()
|
||||
.that(assertThrows(LoopbackIpNotValidForHostException.class, this::runFlow))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_metadata() throws Exception {
|
||||
createTld("tld");
|
||||
|
||||
@@ -24,12 +24,9 @@ import google.registry.testing.EppLoader;
|
||||
/** Unit tests for {@code ResourceCommand}. */
|
||||
public abstract class ResourceCommandTestCase extends EntityTestCase {
|
||||
|
||||
protected void doXmlRoundtripTest(String inputFilename, String... ignoredPaths)
|
||||
throws Exception {
|
||||
protected void doXmlRoundtripTest(String inputFilename) throws Exception {
|
||||
EppLoader eppLoader = new EppLoader(this, inputFilename);
|
||||
assertXmlEquals(
|
||||
eppLoader.getEppXml(),
|
||||
new String(marshalInput(eppLoader.getEpp(), STRICT), UTF_8),
|
||||
ignoredPaths);
|
||||
eppLoader.getEppXml(), new String(marshalInput(eppLoader.getEpp(), STRICT), UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,11 +113,6 @@ class DomainCommandTest extends ResourceCommandTestCase {
|
||||
doXmlRoundtripTest("domain_update.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdate_fee() throws Exception {
|
||||
doXmlRoundtripTest("domain_update_fee.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdate_emptyCommand() throws Exception {
|
||||
// This EPP command wouldn't be allowed for policy reasons, but should marshal/unmarshal fine.
|
||||
@@ -153,11 +148,6 @@ class DomainCommandTest extends ResourceCommandTestCase {
|
||||
doXmlRoundtripTest("domain_info_sunrise.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInfo_feeExtension() throws Exception {
|
||||
doXmlRoundtripTest("domain_info_fee.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheck() throws Exception {
|
||||
doXmlRoundtripTest("domain_check.xml");
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests for {@link EppXmlTransformer}. */
|
||||
@@ -38,4 +39,26 @@ class EppXmlTransformerTest {
|
||||
ClassCastException.class,
|
||||
() -> unmarshal(EppOutput.class, loadBytes(getClass(), "contact_info.xml").read()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSchemas_inNonProduction_includesFee1Point0() {
|
||||
var currentEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
RegistryEnvironment.SANDBOX.setup();
|
||||
assertThat(EppXmlTransformer.getSchemas()).contains("fee-std-v1.xsd");
|
||||
} finally {
|
||||
currentEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSchemas_inProduction_skipsFee1Point0() {
|
||||
var currentEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
RegistryEnvironment.PRODUCTION.setup();
|
||||
assertThat(EppXmlTransformer.getSchemas()).doesNotContain("fee-std-v1.xsd");
|
||||
} finally {
|
||||
currentEnv.setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import google.registry.flows.TlsCredentials.EppTlsModule;
|
||||
import google.registry.flows.custom.CustomLogicModule;
|
||||
import google.registry.loadtest.LoadTestModule;
|
||||
import google.registry.monitoring.whitebox.WhiteboxModule;
|
||||
import google.registry.mosapi.module.MosApiRequestModule;
|
||||
import google.registry.rdap.RdapModule;
|
||||
import google.registry.rde.RdeModule;
|
||||
import google.registry.reporting.ReportingModule;
|
||||
@@ -60,6 +61,7 @@ import google.registry.ui.server.console.ConsoleModule;
|
||||
EppToolModule.class,
|
||||
IcannReportingModule.class,
|
||||
LoadTestModule.class,
|
||||
MosApiRequestModule.class,
|
||||
RdapModule.class,
|
||||
RdeModule.class,
|
||||
ReportingModule.class,
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
// Copyright 2017 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.monitoring.whitebox;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.monitoring.metrics.MetricRegistry;
|
||||
import com.google.monitoring.metrics.MetricRegistryImpl;
|
||||
import java.lang.management.MemoryMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link JvmMetrics}. */
|
||||
class JvmMetricsTests {
|
||||
|
||||
private MetricRegistry registry;
|
||||
private JvmMetrics jvmMetrics;
|
||||
private MemoryMXBean mockMemoryMXBean = mock(MemoryMXBean.class);
|
||||
|
||||
private static final MemoryUsage HEAP_USAGE =
|
||||
new MemoryUsage(/*init*/ 100, /*used*/ 200, /*commited*/ 500, /*max*/ 1000);
|
||||
private static final MemoryUsage NON_HEAP_USAGE =
|
||||
new MemoryUsage(/*init*/ 50, /*used*/ 100, /*commited*/ 250, /*max*/ 500);
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
MetricRegistryImpl.getDefault().unregisterAllMetrics();
|
||||
registry = MetricRegistryImpl.getDefault();
|
||||
|
||||
when(mockMemoryMXBean.getHeapMemoryUsage()).thenReturn(HEAP_USAGE);
|
||||
when(mockMemoryMXBean.getNonHeapMemoryUsage()).thenReturn(NON_HEAP_USAGE);
|
||||
|
||||
jvmMetrics = new JvmMetrics(mockMemoryMXBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void metricsRegistered() {
|
||||
jvmMetrics.register();
|
||||
|
||||
assertThat(registry.getRegisteredMetrics()).hasSize(3);
|
||||
|
||||
for (var metric : registry.getRegisteredMetrics()) {
|
||||
assertThat(metric).isInstanceOf(com.google.monitoring.metrics.VirtualMetric.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUsedMemory() {
|
||||
jvmMetrics.register();
|
||||
ImmutableMap<ImmutableList<String>, Long> values = jvmMetrics.getUsedMemory();
|
||||
|
||||
assertThat(values)
|
||||
.containsExactly(
|
||||
ImmutableList.of("heap"), 200L,
|
||||
ImmutableList.of("non_heap"), 100L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommittedMemory() {
|
||||
jvmMetrics.register();
|
||||
ImmutableMap<ImmutableList<String>, Long> values = jvmMetrics.getCommittedMemory();
|
||||
|
||||
assertThat(values)
|
||||
.containsExactly(
|
||||
ImmutableList.of("heap"), 500L,
|
||||
ImmutableList.of("non_heap"), 250L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMaxMemory() {
|
||||
jvmMetrics.register();
|
||||
ImmutableMap<ImmutableList<String>, Long> values = jvmMetrics.getMaxMemory();
|
||||
|
||||
assertThat(values)
|
||||
.containsExactly(
|
||||
ImmutableList.of("heap"), 1000L,
|
||||
ImmutableList.of("non_heap"), 500L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// Copyright 2025 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.mosapi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.MediaType;
|
||||
import com.google.gson.Gson;
|
||||
import google.registry.mosapi.MosApiModels.AllServicesStateResponse;
|
||||
import google.registry.mosapi.MosApiModels.ServiceStateSummary;
|
||||
import google.registry.request.HttpException.ServiceUnavailableException;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link GetServiceStateAction}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class GetServiceStateActionTest {
|
||||
|
||||
@Mock private MosApiStateService stateService;
|
||||
private final FakeResponse response = new FakeResponse();
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
@Test
|
||||
void testRun_singleTld_returnsStateForTld() throws Exception {
|
||||
GetServiceStateAction action =
|
||||
new GetServiceStateAction(stateService, response, gson, Optional.of("example"));
|
||||
|
||||
ServiceStateSummary summary = new ServiceStateSummary("example", "Up", null);
|
||||
when(stateService.getServiceStateSummary("example")).thenReturn(summary);
|
||||
|
||||
action.run();
|
||||
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.JSON_UTF_8);
|
||||
assertThat(response.getPayload())
|
||||
.contains(
|
||||
"""
|
||||
"overallStatus":"Up"
|
||||
"""
|
||||
.trim());
|
||||
verify(stateService).getServiceStateSummary("example");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRun_noTld_returnsStateForAll() {
|
||||
GetServiceStateAction action =
|
||||
new GetServiceStateAction(stateService, response, gson, Optional.empty());
|
||||
|
||||
AllServicesStateResponse allStates = new AllServicesStateResponse(ImmutableList.of());
|
||||
when(stateService.getAllServiceStateSummaries()).thenReturn(allStates);
|
||||
|
||||
action.run();
|
||||
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.JSON_UTF_8);
|
||||
assertThat(response.getPayload())
|
||||
.contains(
|
||||
"""
|
||||
"serviceStates":[]
|
||||
"""
|
||||
.trim());
|
||||
verify(stateService).getAllServiceStateSummaries();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRun_serviceThrowsException_throwsServiceUnavailable() throws Exception {
|
||||
GetServiceStateAction action =
|
||||
new GetServiceStateAction(stateService, response, gson, Optional.of("example"));
|
||||
|
||||
doThrow(new MosApiException("Backend error", null))
|
||||
.when(stateService)
|
||||
.getServiceStateSummary("example");
|
||||
|
||||
ServiceUnavailableException thrown =
|
||||
assertThrows(ServiceUnavailableException.class, action::run);
|
||||
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Error fetching MoSAPI service state.");
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
// 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.mosapi.model;
|
||||
package google.registry.mosapi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -20,7 +20,6 @@ import google.registry.mosapi.MosApiException.DateOrderInvalidException;
|
||||
import google.registry.mosapi.MosApiException.EndDateSyntaxInvalidException;
|
||||
import google.registry.mosapi.MosApiException.MosApiAuthorizationException;
|
||||
import google.registry.mosapi.MosApiException.StartDateSyntaxInvalidException;
|
||||
import google.registry.mosapi.model.MosApiErrorResponse;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link MosApiException}. */
|
||||
|
||||
172
core/src/test/java/google/registry/mosapi/MosApiModelsTest.java
Normal file
172
core/src/test/java/google/registry/mosapi/MosApiModelsTest.java
Normal file
@@ -0,0 +1,172 @@
|
||||
// Copyright 2025 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.mosapi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import google.registry.mosapi.MosApiModels.AllServicesStateResponse;
|
||||
import google.registry.mosapi.MosApiModels.IncidentSummary;
|
||||
import google.registry.mosapi.MosApiModels.ServiceStateSummary;
|
||||
import google.registry.mosapi.MosApiModels.ServiceStatus;
|
||||
import google.registry.mosapi.MosApiModels.TldServiceState;
|
||||
import org.junit.Test;
|
||||
|
||||
/** Tests for {@link MosApiModels}. */
|
||||
public final class MosApiModelsTest {
|
||||
|
||||
private static final Gson gson =
|
||||
new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||
|
||||
@Test
|
||||
public void testAllServicesStateResponse_nullCollection_initializedToEmpty() {
|
||||
AllServicesStateResponse response = new AllServicesStateResponse(null);
|
||||
assertThat(response.serviceStates()).isEmpty();
|
||||
assertThat(response.serviceStates()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServiceStateSummary_nullCollection_initializedToEmpty() {
|
||||
ServiceStateSummary summary = new ServiceStateSummary("example", "Up", null);
|
||||
assertThat(summary.activeIncidents()).isEmpty();
|
||||
assertThat(summary.activeIncidents()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServiceStatus_nullCollection_initializedToEmpty() {
|
||||
ServiceStatus status = new ServiceStatus("Up", 0.0, null);
|
||||
assertThat(status.incidents()).isEmpty();
|
||||
assertThat(status.incidents()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTldServiceState_nullCollection_initializedToEmpty() {
|
||||
TldServiceState state = new TldServiceState("example", 123456L, "Up", null);
|
||||
assertThat(state.serviceStatuses()).isEmpty();
|
||||
assertThat(state.serviceStatuses()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncidentSummary_jsonSerialization() {
|
||||
IncidentSummary incident = new IncidentSummary("inc-123", 1000L, false, "Active", 2000L);
|
||||
String json = gson.toJson(incident);
|
||||
// Using Text Blocks to avoid escaping quotes
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"incidentID":"inc-123"
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"startTime":1000
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"falsePositive":false
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"state":"Active"
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"endTime":2000
|
||||
"""
|
||||
.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServiceStatus_jsonSerialization() {
|
||||
IncidentSummary incident = new IncidentSummary("inc-1", 1000L, false, "Resolved", null);
|
||||
ServiceStatus status = new ServiceStatus("Down", 75.5, ImmutableList.of(incident));
|
||||
String json = gson.toJson(status);
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"status":"Down"
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"emergencyThreshold":75.5
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"incidents":[
|
||||
"""
|
||||
.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTldServiceState_jsonSerialization() {
|
||||
ServiceStatus dnsStatus = new ServiceStatus("Up", 0.0, ImmutableList.of());
|
||||
TldServiceState state =
|
||||
new TldServiceState("app", 1700000000L, "Up", ImmutableMap.of("DNS", dnsStatus));
|
||||
|
||||
String json = gson.toJson(state);
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"tld":"app"
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"status":"Up"
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"testedServices":{"DNS":{
|
||||
"""
|
||||
.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllServicesStateResponse_jsonSerialization() {
|
||||
ServiceStateSummary summary = new ServiceStateSummary("dev", "Up", ImmutableList.of());
|
||||
AllServicesStateResponse response = new AllServicesStateResponse(ImmutableList.of(summary));
|
||||
|
||||
String json = gson.toJson(response);
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"serviceStates":[
|
||||
"""
|
||||
.trim());
|
||||
assertThat(json)
|
||||
.contains(
|
||||
"""
|
||||
"tld":"dev"
|
||||
"""
|
||||
.trim());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
// Copyright 2025 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.mosapi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import google.registry.mosapi.MosApiModels.AllServicesStateResponse;
|
||||
import google.registry.mosapi.MosApiModels.IncidentSummary;
|
||||
import google.registry.mosapi.MosApiModels.ServiceStateSummary;
|
||||
import google.registry.mosapi.MosApiModels.ServiceStatus;
|
||||
import google.registry.mosapi.MosApiModels.TldServiceState;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link MosApiStateService}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class MosApiStateServiceTest {
|
||||
|
||||
@Mock private ServiceMonitoringClient client;
|
||||
@Mock private MosApiMetrics metrics;
|
||||
|
||||
private final ExecutorService executor = MoreExecutors.newDirectExecutorService();
|
||||
|
||||
private MosApiStateService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new MosApiStateService(client, metrics, ImmutableSet.of("tld1", "tld2"), executor);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetServiceStateSummary_upStatus_returnsEmptyIncidents() throws Exception {
|
||||
TldServiceState rawState = new TldServiceState("tld1", 12345L, "Up", ImmutableMap.of());
|
||||
when(client.getTldServiceState("tld1")).thenReturn(rawState);
|
||||
|
||||
ServiceStateSummary result = service.getServiceStateSummary("tld1");
|
||||
|
||||
assertThat(result.tld()).isEqualTo("tld1");
|
||||
assertThat(result.overallStatus()).isEqualTo("Up");
|
||||
assertThat(result.activeIncidents()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetServiceStateSummary_downStatus_filtersActiveIncidents() throws Exception {
|
||||
IncidentSummary dnsIncident = new IncidentSummary("inc-1", 100L, false, "Open", null);
|
||||
ServiceStatus dnsService = new ServiceStatus("Down", 50.0, ImmutableList.of(dnsIncident));
|
||||
|
||||
ServiceStatus rdapService = new ServiceStatus("Up", 0.0, ImmutableList.of());
|
||||
|
||||
TldServiceState rawState =
|
||||
new TldServiceState(
|
||||
"tld1", 12345L, "Down", ImmutableMap.of("DNS", dnsService, "RDAP", rdapService));
|
||||
|
||||
when(client.getTldServiceState("tld1")).thenReturn(rawState);
|
||||
|
||||
ServiceStateSummary result = service.getServiceStateSummary("tld1");
|
||||
|
||||
assertThat(result.overallStatus()).isEqualTo("Down");
|
||||
assertThat(result.activeIncidents()).hasSize(1);
|
||||
|
||||
ServiceStatus incidentSummary = result.activeIncidents().get(0);
|
||||
assertThat(incidentSummary.status()).isEqualTo("DNS");
|
||||
assertThat(incidentSummary.incidents()).containsExactly(dnsIncident);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetServiceStateSummary_throwsException_whenClientFails() throws Exception {
|
||||
when(client.getTldServiceState("tld1")).thenThrow(new MosApiException("Network error", null));
|
||||
|
||||
assertThrows(MosApiException.class, () -> service.getServiceStateSummary("tld1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllServiceStateSummaries_success() throws Exception {
|
||||
TldServiceState state1 = new TldServiceState("tld1", 1L, "Up", ImmutableMap.of());
|
||||
TldServiceState state2 = new TldServiceState("tld2", 2L, "Up", ImmutableMap.of());
|
||||
|
||||
when(client.getTldServiceState("tld1")).thenReturn(state1);
|
||||
when(client.getTldServiceState("tld2")).thenReturn(state2);
|
||||
|
||||
AllServicesStateResponse response = service.getAllServiceStateSummaries();
|
||||
|
||||
assertThat(response.serviceStates()).hasSize(2);
|
||||
assertThat(response.serviceStates().stream().map(ServiceStateSummary::tld))
|
||||
.containsExactly("tld1", "tld2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllServiceStateSummaries_partialFailure_returnsErrorState() throws Exception {
|
||||
TldServiceState state1 = new TldServiceState("tld1", 1L, "Up", ImmutableMap.of());
|
||||
when(client.getTldServiceState("tld1")).thenReturn(state1);
|
||||
|
||||
when(client.getTldServiceState("tld2")).thenThrow(new MosApiException("Failure", null));
|
||||
|
||||
AllServicesStateResponse response = service.getAllServiceStateSummaries();
|
||||
|
||||
assertThat(response.serviceStates()).hasSize(2);
|
||||
|
||||
ServiceStateSummary summary1 =
|
||||
response.serviceStates().stream().filter(s -> s.tld().equals("tld1")).findFirst().get();
|
||||
assertThat(summary1.overallStatus()).isEqualTo("Up");
|
||||
|
||||
ServiceStateSummary summary2 =
|
||||
response.serviceStates().stream().filter(s -> s.tld().equals("tld2")).findFirst().get();
|
||||
|
||||
assertThat(summary2.overallStatus()).isEqualTo("ERROR");
|
||||
assertThat(summary2.activeIncidents()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTriggerMetricsForAllServiceStateSummaries_success() throws Exception {
|
||||
TldServiceState state1 = new TldServiceState("tld1", 1L, "Up", ImmutableMap.of());
|
||||
TldServiceState state2 = new TldServiceState("tld2", 2L, "Up", ImmutableMap.of());
|
||||
|
||||
when(client.getTldServiceState("tld1")).thenReturn(state1);
|
||||
when(client.getTldServiceState("tld2")).thenReturn(state2);
|
||||
|
||||
service.triggerMetricsForAllServiceStateSummaries();
|
||||
|
||||
verify(metrics)
|
||||
.recordStates(
|
||||
argThat(
|
||||
states ->
|
||||
states.size() == 2
|
||||
&& states.stream()
|
||||
.anyMatch(s -> s.tld().equals("tld1") && s.status().equals("Up"))
|
||||
&& states.stream()
|
||||
.anyMatch(s -> s.tld().equals("tld2") && s.status().equals("Up"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTriggerMetricsForAllServiceStateSummaries_partialFailure_recordsErrorMetric()
|
||||
throws Exception {
|
||||
TldServiceState state1 = new TldServiceState("tld1", 1L, "Up", ImmutableMap.of());
|
||||
when(client.getTldServiceState("tld1")).thenReturn(state1);
|
||||
when(client.getTldServiceState("tld2")).thenThrow(new MosApiException("Network Error", null));
|
||||
|
||||
service.triggerMetricsForAllServiceStateSummaries();
|
||||
|
||||
verify(metrics)
|
||||
.recordStates(
|
||||
argThat(
|
||||
states ->
|
||||
states.size() == 1
|
||||
&& states.stream()
|
||||
.anyMatch(s -> s.tld().equals("tld1") && s.status().equals("Up"))));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
// Copyright 2025 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.mosapi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.anyMap;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import google.registry.mosapi.MosApiModels.TldServiceState;
|
||||
import google.registry.tools.GsonUtils;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ServiceMonitoringClientTest {
|
||||
|
||||
private static final String TLD = "example";
|
||||
private static final String ENDPOINT = "v2/monitoring/state";
|
||||
private final MosApiClient mosApiClient = mock(MosApiClient.class);
|
||||
private final Gson gson = GsonUtils.provideGson();
|
||||
private ServiceMonitoringClient client;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
client = new ServiceMonitoringClient(mosApiClient, gson);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetTldServiceState_success() throws Exception {
|
||||
String jsonResponse =
|
||||
"""
|
||||
{
|
||||
"tld": "example",
|
||||
"services": [
|
||||
{
|
||||
"service": "DNS",
|
||||
"status": "OPERATIONAL"
|
||||
}
|
||||
]
|
||||
}
|
||||
""";
|
||||
|
||||
try (Response response = createMockResponse(200, jsonResponse)) {
|
||||
when(mosApiClient.sendGetRequest(eq(TLD), eq(ENDPOINT), anyMap(), anyMap()))
|
||||
.thenReturn(response);
|
||||
|
||||
TldServiceState result = client.getTldServiceState(TLD);
|
||||
assertThat(gson.toJson(result)).contains("example");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetTldServiceState_apiError_throwsMosApiException() throws Exception {
|
||||
String errorJson =
|
||||
"""
|
||||
{
|
||||
"resultCode": "2011",
|
||||
"message": "Invalid duration"
|
||||
}
|
||||
""";
|
||||
|
||||
try (Response response = createMockResponse(400, errorJson)) {
|
||||
when(mosApiClient.sendGetRequest(eq(TLD), eq(ENDPOINT), anyMap(), anyMap()))
|
||||
.thenReturn(response);
|
||||
|
||||
MosApiException thrown =
|
||||
assertThrows(MosApiException.class, () -> client.getTldServiceState(TLD));
|
||||
assertThat(thrown.getMessage()).contains("2011");
|
||||
assertThat(thrown.getMessage()).contains("Invalid duration");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetTldServiceState_nonJsonError_throwsMosApiException() throws Exception {
|
||||
String htmlError =
|
||||
"""
|
||||
<html>
|
||||
<body>502 Bad Gateway</body>
|
||||
</html>
|
||||
""";
|
||||
|
||||
try (Response response = createMockResponse(502, htmlError)) {
|
||||
when(mosApiClient.sendGetRequest(eq(TLD), eq(ENDPOINT), anyMap(), anyMap()))
|
||||
.thenReturn(response);
|
||||
|
||||
MosApiException thrown =
|
||||
assertThrows(MosApiException.class, () -> client.getTldServiceState(TLD));
|
||||
assertThat(thrown.getMessage()).contains("MoSAPI json parsing error (502)");
|
||||
assertThat(thrown.getMessage()).contains("502 Bad Gateway");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetTldServiceState_emptyBody_throwsMosApiException() throws Exception {
|
||||
Response response =
|
||||
new Response.Builder()
|
||||
.request(new Request.Builder().url("http://localhost").build())
|
||||
.protocol(Protocol.HTTP_1_1)
|
||||
.code(204)
|
||||
.message("No Content")
|
||||
.build();
|
||||
|
||||
when(mosApiClient.sendGetRequest(eq(TLD), eq(ENDPOINT), anyMap(), anyMap()))
|
||||
.thenReturn(response);
|
||||
|
||||
MosApiException thrown =
|
||||
assertThrows(MosApiException.class, () -> client.getTldServiceState(TLD));
|
||||
assertThat(thrown.getMessage()).contains("returned an empty body");
|
||||
}
|
||||
|
||||
private Response createMockResponse(int code, String body) {
|
||||
return new Response.Builder()
|
||||
.request(new Request.Builder().url("http://localhost").build())
|
||||
.protocol(Protocol.HTTP_1_1)
|
||||
.code(code)
|
||||
.message(code == 200 ? "OK" : "Error")
|
||||
.body(ResponseBody.create(body, MediaType.parse("application/json")))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright 2026 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.mosapi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link TriggerServiceStateActionTest}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class TriggerServiceStateActionTest {
|
||||
|
||||
private final MosApiStateService stateService = mock(MosApiStateService.class);
|
||||
private final FakeResponse response = new FakeResponse();
|
||||
private TriggerServiceStateAction action;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
action = new TriggerServiceStateAction(stateService, response);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRun_success() {
|
||||
action.run();
|
||||
|
||||
verify(stateService).triggerMetricsForAllServiceStateSummaries();
|
||||
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.PLAIN_TEXT_UTF_8);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload())
|
||||
.isEqualTo("MoSAPI metrics triggered successfully for all TLDs.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRun_failure_throwsInternalServerError() {
|
||||
doThrow(new RuntimeException("Database error"))
|
||||
.when(stateService)
|
||||
.triggerMetricsForAllServiceStateSummaries();
|
||||
|
||||
InternalServerErrorException thrown =
|
||||
assertThrows(InternalServerErrorException.class, () -> action.run());
|
||||
|
||||
assertThat(thrown.getMessage()).contains("Failed to process MoSAPI metrics.");
|
||||
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.PLAIN_TEXT_UTF_8);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright 2025 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.mosapi.module;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link MosApiRequestModule}. */
|
||||
public class MosApiRequestModuleTest {
|
||||
|
||||
@Test
|
||||
void testProvideTld_paramPresent() {
|
||||
HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
when(req.getParameter("tld")).thenReturn("example.tld");
|
||||
|
||||
Optional<String> result = MosApiRequestModule.provideTld(req);
|
||||
|
||||
assertThat(result).hasValue("example.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProvideTld_paramMissing() {
|
||||
HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
when(req.getParameter("tld")).thenReturn(null);
|
||||
|
||||
Optional<String> result = MosApiRequestModule.provideTld(req);
|
||||
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProvideTld_paramEmptyString() {
|
||||
HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
when(req.getParameter("tld")).thenReturn("");
|
||||
|
||||
Optional<String> result = MosApiRequestModule.provideTld(req);
|
||||
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -298,9 +298,13 @@ have failed to comply with these terms.",
|
||||
}
|
||||
|
||||
JsonFileBuilder addNameserver(String name, String handle) {
|
||||
return addNameserver(Idn.toASCII(name), name, handle);
|
||||
}
|
||||
|
||||
JsonFileBuilder addNameserver(String punycodeName, String unicodeName, String handle) {
|
||||
return putNext(
|
||||
"NAMESERVER_NAME_", Idn.toASCII(name),
|
||||
"NAMESERVER_UNICODE_NAME_", name,
|
||||
"NAMESERVER_NAME_", punycodeName,
|
||||
"NAMESERVER_UNICODE_NAME_", unicodeName,
|
||||
"NAMESERVER_HANDLE_", handle);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ package google.registry.rdap;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makePunycodedHost;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
|
||||
import static google.registry.testing.GsonSubject.assertAboutJson;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -27,7 +29,6 @@ import google.registry.rdap.RdapMetrics.SearchType;
|
||||
import google.registry.rdap.RdapMetrics.WildcardType;
|
||||
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.testing.FullFieldsTestEntityHelper;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -43,20 +44,17 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverActi
|
||||
void beforeEach() {
|
||||
// normal
|
||||
createTld("lol");
|
||||
FullFieldsTestEntityHelper.makeAndPersistHost(
|
||||
"ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1));
|
||||
makeAndPersistHost("ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1));
|
||||
// idn
|
||||
createTld("xn--q9jyb4c");
|
||||
FullFieldsTestEntityHelper.makeAndPersistHost(
|
||||
makeAndPersistHost(
|
||||
"ns1.cat.xn--q9jyb4c", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(1));
|
||||
// multilevel
|
||||
createTld("1.tld");
|
||||
FullFieldsTestEntityHelper.makeAndPersistHost(
|
||||
"ns1.domain.1.tld", "5.6.7.8", clock.nowUtc().minusYears(1));
|
||||
makeAndPersistHost("ns1.domain.1.tld", "5.6.7.8", clock.nowUtc().minusYears(1));
|
||||
// deleted
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeAndPersistHost(
|
||||
"nsdeleted.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1))
|
||||
makeAndPersistHost("nsdeleted.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1))
|
||||
.asBuilder()
|
||||
.setDeletionTime(clock.nowUtc().minusMonths(1))
|
||||
.build());
|
||||
@@ -64,8 +62,7 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverActi
|
||||
persistResource(
|
||||
makeRegistrar("otherregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 102L));
|
||||
// external
|
||||
FullFieldsTestEntityHelper.makeAndPersistHost(
|
||||
"ns1.domain.external", "9.10.11.12", clock.nowUtc().minusYears(1));
|
||||
makeAndPersistHost("ns1.domain.external", "9.10.11.12", clock.nowUtc().minusYears(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,7 +71,17 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverActi
|
||||
.that(generateActualJson("invalid/host/name"))
|
||||
.isEqualTo(
|
||||
generateExpectedJsonError(
|
||||
"invalid/host/name is not a valid nameserver: Invalid host name", 400));
|
||||
"invalid/host/name is not a valid nameserver: Host names can only contain a-z, 0-9,"
|
||||
+ " '.', '_', and '-'",
|
||||
400));
|
||||
assertThat(response.getStatus()).isEqualTo(400);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvalidNameserver_domainWithHyphenOn3And4_returns400() {
|
||||
assertAboutJson()
|
||||
.that(generateActualJson("ns1.zz--main-2166.lol"))
|
||||
.isEqualTo(generateExpectedJsonError("Not a valid nameserver", 400));
|
||||
assertThat(response.getStatus()).isEqualTo(400);
|
||||
}
|
||||
|
||||
@@ -99,6 +106,21 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverActi
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNameserver_tldTithHyphenOn3And4_works() {
|
||||
createTld("zz--main-2166");
|
||||
persistResource(makePunycodedHost("ns1.cat.zz--main-2166", "1.2.3.4", null, "TheRegistrar"));
|
||||
assertAboutJson()
|
||||
.that(generateActualJson("ns1.cat.zz--main-2166"))
|
||||
.isEqualTo(
|
||||
addPermanentBoilerplateNotices(
|
||||
jsonFileBuilder()
|
||||
.addNameserver("ns1.cat.zz--main-2166", "ns1.cat.zz--main-2166", "F-ROID")
|
||||
.putAll("ADDRESSTYPE", "v4", "ADDRESS", "1.2.3.4", "STATUS", "active")
|
||||
.load("rdap_host.json")));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTrailingDot_getsIgnored() {
|
||||
assertAboutJson()
|
||||
|
||||
@@ -135,10 +135,15 @@ public final class FullFieldsTestEntityHelper {
|
||||
|
||||
public static Host makeHost(
|
||||
String fqhn, @Nullable String ip1, @Nullable String ip2, String registrarClientId) {
|
||||
return makePunycodedHost(Idn.toASCII(fqhn), ip1, ip2, registrarClientId);
|
||||
}
|
||||
|
||||
public static Host makePunycodedHost(
|
||||
String fqhn, @Nullable String ip1, @Nullable String ip2, String registrarClientId) {
|
||||
Host.Builder builder =
|
||||
new Host.Builder()
|
||||
.setRepoId(generateNewContactHostRoid())
|
||||
.setHostName(Idn.toASCII(fqhn))
|
||||
.setHostName(fqhn)
|
||||
.setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z"))
|
||||
.setPersistedCurrentSponsorRegistrarId(registrarClientId);
|
||||
if ((ip1 != null) || (ip2 != null)) {
|
||||
|
||||
161
core/src/test/java/google/registry/tmch/RstTmchUtilsIntTest.java
Normal file
161
core/src/test/java/google/registry/tmch/RstTmchUtilsIntTest.java
Normal file
@@ -0,0 +1,161 @@
|
||||
// Copyright 2025 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.tmch;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.RegistryEnvironment.PRODUCTION;
|
||||
import static google.registry.util.RegistryEnvironment.SANDBOX;
|
||||
import static org.joda.time.DateTime.now;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import google.registry.model.smd.SignedMarkRevocationList;
|
||||
import google.registry.model.smd.SignedMarkRevocationListDao;
|
||||
import google.registry.model.tmch.ClaimsListDao;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
public class RstTmchUtilsIntTest {
|
||||
private final FakeClock clock = new FakeClock();
|
||||
|
||||
@RegisterExtension
|
||||
final JpaTestExtensions.JpaIntegrationTestExtension jpa =
|
||||
new JpaTestExtensions.Builder().withClock(clock).buildIntegrationTestExtension();
|
||||
|
||||
private static final String TMCH_CLAIM_LABEL = "tmch";
|
||||
// RST label found in *.rst.dnl.csv resources. Currently both files are identical
|
||||
private static final String RST_CLAIM_LABEL = "test--validate";
|
||||
|
||||
private static final String TMCH_SMD_ID = "tmch";
|
||||
// RST label found in *.rst.smdrl.csv resources. Currently both files are identical
|
||||
private static final String RST_SMD_ID = "0000001761385117375880-65535";
|
||||
|
||||
private static final String TMCH_DNL =
|
||||
"""
|
||||
1,2024-09-13T02:21:12.0Z
|
||||
DNL,lookup-key,insertion-datetime
|
||||
LABEL,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
|
||||
"""
|
||||
.replace("LABEL", TMCH_CLAIM_LABEL);
|
||||
|
||||
private static final String TMCH_SMDRL =
|
||||
"""
|
||||
1,2022-11-22T01:49:36.9Z
|
||||
smd-id,insertion-datetime
|
||||
ID,2013-07-15T00:00:00.0Z
|
||||
"""
|
||||
.replace("ID", TMCH_SMD_ID);
|
||||
|
||||
@BeforeEach
|
||||
void setup() throws Exception {
|
||||
Splitter lineSplitter = Splitter.on("\n").omitEmptyStrings().trimResults();
|
||||
tm().transact(
|
||||
() -> ClaimsListDao.save(ClaimsListParser.parse(lineSplitter.splitToList(TMCH_DNL))));
|
||||
tm().transact(
|
||||
() ->
|
||||
SignedMarkRevocationListDao.save(
|
||||
SmdrlCsvParser.parse(lineSplitter.splitToList(TMCH_SMDRL))));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTestCases")
|
||||
@SuppressWarnings("unused") // testCaseName
|
||||
void getClaimsList_production(String testCaseName, String tld) {
|
||||
var currEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
PRODUCTION.setup();
|
||||
var claimsList = ClaimsListDao.get(tld);
|
||||
assertThat(claimsList.getClaimKey(TMCH_CLAIM_LABEL)).isPresent();
|
||||
assertThat(claimsList.getClaimKey(RST_CLAIM_LABEL)).isEmpty();
|
||||
} finally {
|
||||
currEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTestCases")
|
||||
@SuppressWarnings("unused") // testCaseName
|
||||
void getSmdrList_production(String testCaseName, String tld) {
|
||||
var currEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
PRODUCTION.setup();
|
||||
var smdrl = SignedMarkRevocationList.get(tld);
|
||||
assertThat(smdrl.isSmdRevoked(TMCH_SMD_ID, now(UTC))).isTrue();
|
||||
assertThat(smdrl.isSmdRevoked(RST_SMD_ID, now(UTC))).isFalse();
|
||||
assertThat(smdrl.size()).isEqualTo(1);
|
||||
} finally {
|
||||
currEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTestCases")
|
||||
@SuppressWarnings("unused") // testCaseName
|
||||
void getClaimsList_sandbox(String testCaseName, String tld) {
|
||||
var currEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
SANDBOX.setup();
|
||||
var claimsList = ClaimsListDao.get(tld);
|
||||
if (tld.equals("app")) {
|
||||
assertThat(claimsList.getClaimKey(TMCH_CLAIM_LABEL)).isPresent();
|
||||
assertThat(claimsList.getClaimKey(RST_CLAIM_LABEL)).isEmpty();
|
||||
} else {
|
||||
assertThat(claimsList.getClaimKey(TMCH_CLAIM_LABEL)).isEmpty();
|
||||
// Currently ote and prod have the same data.
|
||||
assertThat(claimsList.getClaimKey(RST_CLAIM_LABEL)).isPresent();
|
||||
}
|
||||
} finally {
|
||||
currEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTestCases")
|
||||
@SuppressWarnings("unused") // testCaseName
|
||||
void getSmdrList_sandbox(String testCaseName, String tld) {
|
||||
var currEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
SANDBOX.setup();
|
||||
var smdrList = SignedMarkRevocationList.get(tld);
|
||||
if (tld.equals("app")) {
|
||||
assertThat(smdrList.size()).isEqualTo(1);
|
||||
assertThat(smdrList.isSmdRevoked(TMCH_SMD_ID, now(UTC))).isTrue();
|
||||
assertThat(smdrList.isSmdRevoked(RST_SMD_ID, now(UTC))).isFalse();
|
||||
} else {
|
||||
// Currently ote and prod have the same data.
|
||||
assertThat(smdrList.size()).isEqualTo(5);
|
||||
assertThat(smdrList.isSmdRevoked(TMCH_SMD_ID, now())).isFalse();
|
||||
assertThat(smdrList.isSmdRevoked(RST_SMD_ID, now())).isTrue();
|
||||
}
|
||||
} finally {
|
||||
currEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
private static Stream<Arguments> provideTestCases() {
|
||||
return Stream.of(
|
||||
Arguments.of("NotRST", "app"),
|
||||
Arguments.of("OTE", "cc-rst-test-tld-1"),
|
||||
Arguments.of("PROD", "zz--idn-123"));
|
||||
}
|
||||
}
|
||||
117
core/src/test/java/google/registry/tmch/RstTmchUtilsTest.java
Normal file
117
core/src/test/java/google/registry/tmch/RstTmchUtilsTest.java
Normal file
@@ -0,0 +1,117 @@
|
||||
// Copyright 2025 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.tmch;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.tmch.RstTmchUtils.getClaimsList;
|
||||
import static google.registry.tmch.RstTmchUtils.getSmdrList;
|
||||
import static google.registry.util.RegistryEnvironment.PRODUCTION;
|
||||
import static google.registry.util.RegistryEnvironment.SANDBOX;
|
||||
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import java.util.stream.Stream;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
public class RstTmchUtilsTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTestCases")
|
||||
@SuppressWarnings("unused") // testCaseName
|
||||
void getClaimsList_production(String testCaseName, String tld) {
|
||||
var currEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
PRODUCTION.setup();
|
||||
assertThat(getClaimsList(tld)).isEmpty();
|
||||
} finally {
|
||||
currEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTestCases")
|
||||
@SuppressWarnings("unused") // testCaseName
|
||||
void getSmdrList_production(String testCaseName, String tld) {
|
||||
var currEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
PRODUCTION.setup();
|
||||
assertThat(getSmdrList(tld)).isEmpty();
|
||||
} finally {
|
||||
currEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTestCases")
|
||||
@SuppressWarnings("unused") // testCaseName
|
||||
void getClaimsList_sandbox(String testCaseName, String tld) {
|
||||
var currEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
SANDBOX.setup();
|
||||
var claimsListOptional = getClaimsList(tld);
|
||||
if (tld.equals("app")) {
|
||||
assertThat(claimsListOptional).isEmpty();
|
||||
} else {
|
||||
// Currently ote and prod have the same data.
|
||||
var claimsList = claimsListOptional.get();
|
||||
assertThat(claimsList.getClaimKey("test-and-validate")).isPresent();
|
||||
var labelsToKeys = claimsList.getLabelsToKeys();
|
||||
assertThat(labelsToKeys).hasSize(8);
|
||||
assertThat(labelsToKeys)
|
||||
.containsEntry(
|
||||
"test---validate", "2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001");
|
||||
}
|
||||
} finally {
|
||||
currEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideTestCases")
|
||||
@SuppressWarnings("unused") // testCaseName
|
||||
void getSmdrList_sandbox(String testCaseName, String tld) {
|
||||
var currEnv = RegistryEnvironment.get();
|
||||
try {
|
||||
SANDBOX.setup();
|
||||
var smdrListOptional = getSmdrList(tld);
|
||||
if (tld.equals("app")) {
|
||||
assertThat(smdrListOptional).isEmpty();
|
||||
} else {
|
||||
// Currently ote and prod have the same data.
|
||||
var smdrList = smdrListOptional.get();
|
||||
assertThat(smdrList.size()).isEqualTo(5);
|
||||
assertThat(
|
||||
smdrList.isSmdRevoked(
|
||||
"000000541526299609231-65535", DateTime.parse("2018-05-14T17:52:23.6Z")))
|
||||
.isFalse();
|
||||
assertThat(
|
||||
smdrList.isSmdRevoked(
|
||||
"000000541526299609231-65535", DateTime.parse("2018-05-14T17:52:23.7Z")))
|
||||
.isTrue();
|
||||
}
|
||||
} finally {
|
||||
currEnv.setup();
|
||||
}
|
||||
}
|
||||
|
||||
private static Stream<Arguments> provideTestCases() {
|
||||
return Stream.of(
|
||||
Arguments.of("NotRST", "app"),
|
||||
Arguments.of("OTE", "cc-rst-test-tld-1"),
|
||||
Arguments.of("PROD", "zz--idn-123"));
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class TmchTestDataExpirationTest {
|
||||
String tmchData = loadFile(TmchTestDataExpirationTest.class, filePath);
|
||||
EncodedSignedMark smd = TmchData.readEncodedSignedMark(tmchData);
|
||||
try {
|
||||
tmchUtils.verifyEncodedSignedMark(smd, DateTime.now(UTC));
|
||||
tmchUtils.verifyEncodedSignedMark("", smd, DateTime.now(UTC));
|
||||
} catch (EppException e) {
|
||||
throw new AssertionError("Error verifying signed mark " + filePath, e);
|
||||
}
|
||||
|
||||
@@ -31,35 +31,33 @@ class ValidateEscrowDepositCommandTest extends CommandTestCase<ValidateEscrowDep
|
||||
assertThat(getStdoutAsString())
|
||||
.isEqualTo(
|
||||
"""
|
||||
ID: 20101017001
|
||||
Previous ID: 20101010001
|
||||
Type: FULL
|
||||
Watermark: 2010-10-17T00:00:00.000Z
|
||||
RDE Version: 1.0
|
||||
ID: 20101017001
|
||||
Previous ID: 20101010001
|
||||
Type: FULL
|
||||
Watermark: 2010-10-17T00:00:00.000Z
|
||||
RDE Version: 1.0
|
||||
|
||||
RDE Object URIs:
|
||||
- urn:ietf:params:xml:ns:rdeContact-1.0
|
||||
- urn:ietf:params:xml:ns:rdeDomain-1.0
|
||||
- urn:ietf:params:xml:ns:rdeEppParams-1.0
|
||||
- urn:ietf:params:xml:ns:rdeHeader-1.0
|
||||
- urn:ietf:params:xml:ns:rdeHost-1.0
|
||||
- urn:ietf:params:xml:ns:rdeIDN-1.0
|
||||
- urn:ietf:params:xml:ns:rdeNNDN-1.0
|
||||
- urn:ietf:params:xml:ns:rdeRegistrar-1.0
|
||||
RDE Object URIs:
|
||||
- urn:ietf:params:xml:ns:rdeDomain-1.0
|
||||
- urn:ietf:params:xml:ns:rdeEppParams-1.0
|
||||
- urn:ietf:params:xml:ns:rdeHeader-1.0
|
||||
- urn:ietf:params:xml:ns:rdeHost-1.0
|
||||
- urn:ietf:params:xml:ns:rdeIDN-1.0
|
||||
- urn:ietf:params:xml:ns:rdeNNDN-1.0
|
||||
- urn:ietf:params:xml:ns:rdeRegistrar-1.0
|
||||
|
||||
Contents:
|
||||
- XjcRdeContact: 1 entry
|
||||
- XjcRdeDomain: 2 entries
|
||||
- XjcRdeEppParams: 1 entry
|
||||
- XjcRdeHeader: 1 entry
|
||||
- XjcRdeHost: 2 entries
|
||||
- XjcRdeIdn: 1 entry
|
||||
- XjcRdeNndn: 1 entry
|
||||
- XjcRdePolicy: 1 entry
|
||||
- XjcRdeRegistrar: 1 entry
|
||||
Contents:
|
||||
- XjcRdeDomain: 2 entries
|
||||
- XjcRdeEppParams: 1 entry
|
||||
- XjcRdeHeader: 1 entry
|
||||
- XjcRdeHost: 2 entries
|
||||
- XjcRdeIdn: 1 entry
|
||||
- XjcRdeNndn: 1 entry
|
||||
- XjcRdePolicy: 1 entry
|
||||
- XjcRdeRegistrar: 1 entry
|
||||
|
||||
RDE deposit is XML schema valid
|
||||
""");
|
||||
RDE deposit is XML schema valid
|
||||
""");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,46 +67,44 @@ class ValidateEscrowDepositCommandTest extends CommandTestCase<ValidateEscrowDep
|
||||
assertThat(getStdoutAsString())
|
||||
.isEqualTo(
|
||||
"""
|
||||
ID: 20101017001
|
||||
Previous ID: 20101010001
|
||||
Type: FULL
|
||||
Watermark: 2010-10-17T00:00:00.000Z
|
||||
RDE Version: 1.0
|
||||
ID: 20101017001
|
||||
Previous ID: 20101010001
|
||||
Type: FULL
|
||||
Watermark: 2010-10-17T00:00:00.000Z
|
||||
RDE Version: 1.0
|
||||
|
||||
RDE Object URIs:
|
||||
- urn:ietf:params:xml:ns:rdeContact-1.0
|
||||
- urn:ietf:params:xml:ns:rdeDomain-1.0
|
||||
- urn:ietf:params:xml:ns:rdeEppParams-1.0
|
||||
- urn:ietf:params:xml:ns:rdeHeader-1.0
|
||||
- urn:ietf:params:xml:ns:rdeHost-1.0
|
||||
- urn:ietf:params:xml:ns:rdeIDN-1.0
|
||||
- urn:ietf:params:xml:ns:rdeNNDN-1.0
|
||||
- urn:ietf:params:xml:ns:rdeRegistrar-1.0
|
||||
RDE Object URIs:
|
||||
- urn:ietf:params:xml:ns:rdeDomain-1.0
|
||||
- urn:ietf:params:xml:ns:rdeEppParams-1.0
|
||||
- urn:ietf:params:xml:ns:rdeHeader-1.0
|
||||
- urn:ietf:params:xml:ns:rdeHost-1.0
|
||||
- urn:ietf:params:xml:ns:rdeIDN-1.0
|
||||
- urn:ietf:params:xml:ns:rdeNNDN-1.0
|
||||
- urn:ietf:params:xml:ns:rdeRegistrar-1.0
|
||||
|
||||
Contents:
|
||||
- XjcRdeContact: 1 entry
|
||||
- XjcRdeDomain: 2 entries
|
||||
- XjcRdeEppParams: 1 entry
|
||||
- XjcRdeHeader: 1 entry
|
||||
- XjcRdeHost: 2 entries
|
||||
- XjcRdeIdn: 1 entry
|
||||
- XjcRdeNndn: 1 entry
|
||||
- XjcRdePolicy: 1 entry
|
||||
- XjcRdeRegistrar: 1 entry
|
||||
Contents:
|
||||
- XjcRdeDomain: 2 entries
|
||||
- XjcRdeEppParams: 1 entry
|
||||
- XjcRdeHeader: 1 entry
|
||||
- XjcRdeHost: 2 entries
|
||||
- XjcRdeIdn: 1 entry
|
||||
- XjcRdeNndn: 1 entry
|
||||
- XjcRdePolicy: 1 entry
|
||||
- XjcRdeRegistrar: 1 entry
|
||||
|
||||
Bad host refs: ns1.LAFFO.com
|
||||
RDE deposit is XML schema valid but has bad references
|
||||
""");
|
||||
Bad host refs: ns1.LAFFO.com
|
||||
RDE deposit is XML schema valid but has bad references
|
||||
""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRun_badXml() throws Exception {
|
||||
void testRun_badXml_truncatedFile() throws Exception {
|
||||
String file = writeToTmpFile(RdeTestData.loadFile("deposit_full.xml").substring(0, 2000));
|
||||
XmlException thrown = assertThrows(XmlException.class, () -> runCommand("--input=" + file));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"Syntax error at line 46, column 38: "
|
||||
"Syntax error at line 49, column 18: "
|
||||
+ "XML document structures must start and end within the same entity.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class XjcObjectTest {
|
||||
String xml = out.toString(UTF_8.toString());
|
||||
Pattern pat = Pattern.compile("^<\\?xml version=\"1\\.0\" encoding=\"UTF[-_]?8\"");
|
||||
assertWithMessage("bad xml declaration: " + xml).that(pat.matcher(xml).find()).isTrue();
|
||||
assertWithMessage("encode/decode didn't work: " + xml).that(xml).contains("Jane Doe");
|
||||
assertWithMessage("encode/decode didn't work: " + xml).that(xml).contains("jdoe@example.test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,7 +56,7 @@ class XjcObjectTest {
|
||||
String xml = out.toString(UTF_16.toString());
|
||||
Pattern pat = Pattern.compile("^<\\?xml version=\"1\\.0\" encoding=\"UTF[-_]?16\"");
|
||||
assertWithMessage(xml).that(pat.matcher(xml).find()).isTrue();
|
||||
assertWithMessage("encode/decode didn't work: " + xml).that(xml).contains("Jane Doe");
|
||||
assertWithMessage("encode/decode didn't work: " + xml).that(xml).contains("jdoe@example.test");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
<rde:watermark>2000-01-01T00:00:00Z</rde:watermark>
|
||||
<rde:rdeMenu>
|
||||
<rde:version>1.0</rde:version>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeContact-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeDomain-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeHeader-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeHost-1.0</rde:objURI>
|
||||
@@ -13,7 +12,6 @@
|
||||
<rde:contents>
|
||||
<rdeDomain:domain/>
|
||||
<rdeRegistrar:registrar/>
|
||||
<rdeContact:contact/>
|
||||
<rdeHost:host/>
|
||||
|
||||
<rdeIDN:idnTableRef id="extended_latin">
|
||||
@@ -38,7 +36,6 @@
|
||||
|
||||
<rdeHeader:header>
|
||||
<rdeHeader:tld>soy</rdeHeader:tld>
|
||||
<rdeHeader:count uri="urn:ietf:params:xml:ns:rdeContact-1.0">1</rdeHeader:count>
|
||||
<rdeHeader:count uri="urn:ietf:params:xml:ns:rdeDomain-1.0">1</rdeHeader:count>
|
||||
<rdeHeader:count uri="urn:ietf:params:xml:ns:rdeHost-1.0">1</rdeHeader:count>
|
||||
<rdeHeader:count uri="urn:ietf:params:xml:ns:rdeRegistrar-1.0">1</rdeHeader:count>
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<rdeReport:watermark>2000-01-01T00:00:00Z</rdeReport:watermark>
|
||||
<rdeHeader:header>
|
||||
<rdeHeader:tld>soy</rdeHeader:tld>
|
||||
<rdeHeader:count uri="urn:ietf:params:xml:ns:rdeContact-1.0">1</rdeHeader:count>
|
||||
<rdeHeader:count uri="urn:ietf:params:xml:ns:rdeDomain-1.0">1</rdeHeader:count>
|
||||
<rdeHeader:count uri="urn:ietf:params:xml:ns:rdeHost-1.0">1</rdeHeader:count>
|
||||
<rdeHeader:count uri="urn:ietf:params:xml:ns:rdeRegistrar-1.0">1</rdeHeader:count>
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<response>
|
||||
<result code="1000">
|
||||
<msg>Command completed successfully</msg>
|
||||
</result>
|
||||
<resData>
|
||||
<domain:chkData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:cd>
|
||||
<domain:name avail="true">example1.tld</domain:name>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="false">example2.example</domain:name>
|
||||
<domain:reason>Alloc token invalid for domain</domain:reason>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="false">reserved.tld</domain:name>
|
||||
<domain:reason>Alloc token invalid for domain</domain:reason>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="false">rich.example</domain:name>
|
||||
<domain:reason>Alloc token invalid for domain</domain:reason>
|
||||
</domain:cd>
|
||||
</domain:chkData>
|
||||
</resData>
|
||||
<extension>
|
||||
<fee:chkData xmlns:fee="urn:ietf:params:xml:ns:epp:fee-1.0">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:cd>
|
||||
<fee:objID>example1.tld</fee:objID>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">0.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>example2.example</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>reserved.tld</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>rich.example</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>example1.tld</fee:objID>
|
||||
<fee:class>premium</fee:class>
|
||||
<fee:command name="renew">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="renew">11.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>example2.example</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="renew">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>reserved.tld</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="renew">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>rich.example</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="renew">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
</fee:chkData>
|
||||
</extension>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>server-trid</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
||||
@@ -0,0 +1,91 @@
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<response>
|
||||
<result code="1000">
|
||||
<msg>Command completed successfully</msg>
|
||||
</result>
|
||||
<resData>
|
||||
<domain:chkData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:cd>
|
||||
<domain:name avail="true">example1.tld</domain:name>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="true">example2.example</domain:name>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="false">reserved.tld</domain:name>
|
||||
<domain:reason>Reserved</domain:reason>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="true">rich.example</domain:name>
|
||||
</domain:cd>
|
||||
</domain:chkData>
|
||||
</resData>
|
||||
<extension>
|
||||
<fee:chkData xmlns:fee="urn:ietf:params:xml:ns:epp:fee-1.0">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:cd>
|
||||
<fee:objID>example2.example</fee:objID>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">6.50</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>example1.tld</fee:objID>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">6.50</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>reserved.tld</fee:objID>
|
||||
<fee:class>reserved</fee:class>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>rich.example</fee:objID>
|
||||
<fee:class>premium</fee:class>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">100.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>example1.tld</fee:objID>
|
||||
<fee:command name="renew">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="renew">11.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>example2.example</fee:objID>
|
||||
<fee:command name="renew">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="renew">11.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>reserved.tld</fee:objID>
|
||||
<fee:command name="renew">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="renew">11.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>rich.example</fee:objID>
|
||||
<fee:class>premium</fee:class>
|
||||
<fee:command name="renew">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="renew">100.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
</fee:chkData>
|
||||
</extension>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>server-trid</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
||||
@@ -0,0 +1,63 @@
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<response>
|
||||
<result code="1000">
|
||||
<msg>Command completed successfully</msg>
|
||||
</result>
|
||||
<resData>
|
||||
<domain:chkData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:cd>
|
||||
<domain:name avail="false">example1.tld</domain:name>
|
||||
<domain:reason>Alloc token invalid for domain</domain:reason>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="false">example2.example</domain:name>
|
||||
<domain:reason>Alloc token invalid for domain</domain:reason>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="false">reserved.tld</domain:name>
|
||||
<domain:reason>Alloc token invalid for domain</domain:reason>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="true">specificuse.tld</domain:name>
|
||||
</domain:cd>
|
||||
</domain:chkData>
|
||||
</resData>
|
||||
<extension>
|
||||
<fee:chkData xmlns:fee="urn:ietf:params:xml:ns:epp:fee-1.0">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:cd>
|
||||
<fee:objID>example1.tld</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>example2.example</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>reserved.tld</fee:objID>
|
||||
<fee:class>token-not-supported</fee:class>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>specificuse.tld</fee:objID>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">13.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
</fee:chkData>
|
||||
</extension>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>server-trid</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
||||
@@ -0,0 +1,26 @@
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<check>
|
||||
<domain:check
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example1.tld</domain:name>
|
||||
<domain:name>example2.example</domain:name>
|
||||
<domain:name>reserved.tld</domain:name>
|
||||
<domain:name>specificuse.tld</domain:name>
|
||||
</domain:check>
|
||||
</check>
|
||||
<extension>
|
||||
<allocationToken:allocationToken
|
||||
xmlns:allocationToken=
|
||||
"urn:ietf:params:xml:ns:allocationToken-1.0">
|
||||
abc123
|
||||
</allocationToken:allocationToken>
|
||||
<fee:check
|
||||
xmlns:fee="urn:ietf:params:xml:ns:epp:fee-1.0">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:command name="create" />
|
||||
</fee:check>
|
||||
</extension>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
@@ -0,0 +1,27 @@
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<check>
|
||||
<domain:check
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example1.tld</domain:name>
|
||||
<domain:name>example2.example</domain:name>
|
||||
<domain:name>reserved.tld</domain:name>
|
||||
<domain:name>rich.example</domain:name>
|
||||
</domain:check>
|
||||
</check>
|
||||
<extension>
|
||||
<allocationToken:allocationToken
|
||||
xmlns:allocationToken=
|
||||
"urn:ietf:params:xml:ns:allocationToken-1.0">
|
||||
abc123
|
||||
</allocationToken:allocationToken>
|
||||
<fee:check
|
||||
xmlns:fee="urn:ietf:params:xml:ns:epp:fee-1.0">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:command name="create" />
|
||||
<fee:command name="renew" />
|
||||
</fee:check>
|
||||
</extension>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
@@ -17,4 +17,4 @@
|
||||
</extension>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
</epp>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<response>
|
||||
<result code="1000">
|
||||
<msg>Command completed successfully</msg>
|
||||
</result>
|
||||
<resData>
|
||||
<domain:chkData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:cd>
|
||||
<domain:name avail="true">%DOMAIN%</domain:name>
|
||||
</domain:cd>
|
||||
</domain:chkData>
|
||||
</resData>
|
||||
<extension>
|
||||
<fee:chkData xmlns:fee="urn:ietf:params:xml:ns:epp:fee-1.0">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:cd>
|
||||
<fee:objID>%DOMAIN%</fee:objID>
|
||||
%FEE_CLASS%
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">%COST_1YR%</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>%DOMAIN%</fee:objID>
|
||||
%FEE_CLASS%
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">2</fee:period>
|
||||
<fee:fee description="create">%COST_2YR%</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:objID>%DOMAIN%</fee:objID>
|
||||
%FEE_CLASS%
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">5</fee:period>
|
||||
<fee:fee description="create">%COST_5YR%</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
</fee:chkData>
|
||||
</extension>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>server-trid</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user