mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Support custom effective date for fee check command
Added support to specify custom effective date to run the fee check command. Such functionality is useful for TLDs with creation price as a function of time, such as those with EAP. However the implementation is not limited EAP or create price check. Any fee check can specify a date, as long as its XML schema supports a date. Currently conforming to fee extension v12, subject to schema changes. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133420255
This commit is contained in:
parent
aa7c05cb8b
commit
743ff99ca3
12 changed files with 134 additions and 5 deletions
|
@ -169,7 +169,9 @@ public class DomainCheckFlow extends BaseDomainCheckFlow {
|
|||
domainNames.get(domainName),
|
||||
getClientId(),
|
||||
feeCheck.getCurrency(),
|
||||
now,
|
||||
feeCheckItem.getEffectiveDate().isPresent()
|
||||
? feeCheckItem.getEffectiveDate().get()
|
||||
: now,
|
||||
eppInput);
|
||||
feeCheckResponseItemsBuilder
|
||||
.add(builder.setDomainNameIfSupported(domainName).build());
|
||||
|
|
|
@ -101,7 +101,7 @@ public class DomainInfoFlow extends BaseDomainInfoFlow<DomainResource, Builder>
|
|||
InternetDomainName.from(getTargetId()),
|
||||
getClientId(),
|
||||
null,
|
||||
now,
|
||||
feeInfo.getEffectiveDate().isPresent() ? feeInfo.getEffectiveDate().get() : now,
|
||||
eppInput);
|
||||
extensions.add(builder.build());
|
||||
}
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
package google.registry.model.domain.fee;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.model.domain.Period;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Interface for individual query items in Check and Info commands. Each item indicates the command
|
||||
|
@ -42,6 +44,9 @@ public interface FeeQueryCommandExtensionItem {
|
|||
*/
|
||||
public CurrencyUnit getCurrency();
|
||||
|
||||
/** The as-of date for the fee extension to run. */
|
||||
public Optional<DateTime> getEffectiveDate();
|
||||
|
||||
/** The name of the command being checked. */
|
||||
public CommandName getCommandName();
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
package google.registry.model.domain.fee06;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.model.domain.fee.FeeCheckCommandExtensionItem;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
|
||||
import google.registry.model.domain.fee.FeeQueryCommandExtensionItemImpl;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** An individual price check item in version 0.6 of the fee extension on Check commands. */
|
||||
@XmlType(propOrder = {"name", "currency", "command", "period"})
|
||||
|
@ -49,4 +51,9 @@ public class FeeCheckCommandExtensionItemV06
|
|||
public FeeCheckResponseExtensionItem.Builder createResponseBuilder() {
|
||||
return new FeeCheckResponseExtensionItemV06.Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DateTime> getEffectiveDate() {
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
package google.registry.model.domain.fee06;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.model.domain.fee.FeeQueryCommandExtensionItemImpl;
|
||||
import google.registry.model.eppinput.EppInput.CommandExtension;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** A fee extension that may be present on domain info commands. */
|
||||
@XmlRootElement(name = "info")
|
||||
|
@ -33,5 +35,10 @@ public class FeeInfoCommandExtensionV06
|
|||
public CurrencyUnit getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DateTime> getEffectiveDate() {
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Version 0.11 of the fee extension that may be present on domain check commands. Unlike other
|
||||
|
@ -137,5 +138,10 @@ public class FeeCheckCommandExtensionV11 extends ImmutableObject
|
|||
public Builder createResponseBuilder() {
|
||||
return new FeeCheckResponseExtensionItemV11.Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DateTime> getEffectiveDate() {
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,4 +118,9 @@ public class FeeCheckCommandExtensionItemV12
|
|||
public FeeCheckResponseExtensionItem.Builder createResponseBuilder() {
|
||||
return new FeeCheckResponseExtensionItemV12.Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DateTime> getEffectiveDate() {
|
||||
return Optional.fromNullable(feeDate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,17 @@
|
|||
xmlns = @XmlNs(prefix = "fee12", namespaceURI = "urn:ietf:params:xml:ns:fee-0.12"),
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapter(CurrencyUnitAdapter.class)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(CurrencyUnitAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class)})
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.translators.CurrencyUnitAdapter;
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlNs;
|
||||
import javax.xml.bind.annotation.XmlNsForm;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
|
||||
|
|
|
@ -776,7 +776,8 @@ public class DomainCheckFlowTest
|
|||
.setEapFeeSchedule(ImmutableSortedMap.of(
|
||||
START_OF_TIME, Money.of(USD, 0),
|
||||
clock.nowUtc().minusDays(1), Money.of(USD, 100),
|
||||
clock.nowUtc().plusDays(1), Money.of(USD, 0)))
|
||||
clock.nowUtc().plusDays(1), Money.of(USD, 50),
|
||||
clock.nowUtc().plusDays(2), Money.of(USD, 0)))
|
||||
.build());
|
||||
setEppInput(inputFile);
|
||||
runFlowAssertResponse(readFile(outputFile));
|
||||
|
@ -796,4 +797,11 @@ public class DomainCheckFlowTest
|
|||
public void testSuccess_eapFeeCheck_v12() throws Exception {
|
||||
runEapFeeCheckTest("domain_check_fee_v12.xml", "domain_check_eap_fee_response_v12.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_eapFeeCheck_date_v12() throws Exception {
|
||||
runEapFeeCheckTest("domain_check_fee_date_v12.xml",
|
||||
"domain_check_eap_fee_response_date_v12.xml");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
61
javatests/google/registry/flows/domain/testdata/domain_check_eap_fee_response_date_v12.xml
vendored
Normal file
61
javatests/google/registry/flows/domain/testdata/domain_check_eap_fee_response_date_v12.xml
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
<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="0">example1.tld</domain:name>
|
||||
<domain:reason>In use</domain:reason>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="1">example2.tld</domain:name>
|
||||
</domain:cd>
|
||||
<domain:cd>
|
||||
<domain:name avail="1">example3.tld</domain:name>
|
||||
</domain:cd>
|
||||
</domain:chkData>
|
||||
</resData>
|
||||
<extension>
|
||||
<fee:chkData xmlns:fee="urn:ietf:params:xml:ns:fee-0.12"
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:cd>
|
||||
<fee:object>
|
||||
<domain:name>example1.tld</domain:name>
|
||||
</fee:object>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">13.00</fee:fee>
|
||||
<fee:fee description="Early Access Period, fee expires: 2010-01-03T10:00:00.000Z">50.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:object>
|
||||
<domain:name>example2.tld</domain:name>
|
||||
</fee:object>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">13.00</fee:fee>
|
||||
<fee:fee description="Early Access Period, fee expires: 2010-01-03T10:00:00.000Z">50.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
<fee:cd>
|
||||
<fee:object>
|
||||
<domain:name>example3.tld</domain:name>
|
||||
</fee:object>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:fee description="create">13.00</fee:fee>
|
||||
<fee:fee description="Early Access Period, fee expires: 2010-01-03T10:00:00.000Z">50.00</fee:fee>
|
||||
</fee:command>
|
||||
</fee:cd>
|
||||
</fee:chkData>
|
||||
</extension>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>server-trid</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
25
javatests/google/registry/flows/domain/testdata/domain_check_fee_date_v12.xml
vendored
Normal file
25
javatests/google/registry/flows/domain/testdata/domain_check_fee_date_v12.xml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<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.tld</domain:name>
|
||||
<domain:name>example3.tld</domain:name>
|
||||
</domain:check>
|
||||
</check>
|
||||
<extension>
|
||||
<launch:check xmlns:launch="urn:ietf:params:xml:ns:launch-1.0" type="avail">
|
||||
<launch:phase name="foo">custom</launch:phase>
|
||||
</launch:check>
|
||||
<fee:check xmlns:fee="urn:ietf:params:xml:ns:fee-0.12">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:class>premium</fee:class>
|
||||
<fee:date>2010-01-02T13:22:21Z</fee:date>
|
||||
</fee:command>
|
||||
</fee:check>
|
||||
</extension>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
|
@ -16,7 +16,6 @@
|
|||
<fee:command name="create">
|
||||
<fee:period unit="y">1</fee:period>
|
||||
<fee:class>premium</fee:class>
|
||||
<fee:date>2017-05-17T13:22:21.0Z</fee:date>
|
||||
</fee:command>
|
||||
</fee:check>
|
||||
</extension>
|
||||
|
|
Loading…
Add table
Reference in a new issue