mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Add EAP fee to domain check flow
(Original from mmuller@: [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=126911443
This commit is contained in:
parent
5ebfb87651
commit
262aab22b9
4 changed files with 77 additions and 15 deletions
|
@ -79,7 +79,6 @@ import google.registry.model.mark.Mark;
|
|||
import google.registry.model.mark.ProtectedMark;
|
||||
import google.registry.model.mark.Trademark;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.pricing.PremiumPricingEngine.DomainPrices;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
|
@ -89,6 +88,7 @@ import google.registry.model.smd.AbstractSignedMark;
|
|||
import google.registry.model.smd.EncodedSignedMark;
|
||||
import google.registry.model.smd.SignedMark;
|
||||
import google.registry.model.smd.SignedMarkRevocationList;
|
||||
import google.registry.pricing.TldSpecificLogicEngine;
|
||||
import google.registry.tmch.TmchXmlSignature;
|
||||
import google.registry.tmch.TmchXmlSignature.CertificateSignatureException;
|
||||
import google.registry.util.Idn;
|
||||
|
@ -576,13 +576,11 @@ public class DomainFlowUtils {
|
|||
throw new CurrencyUnitMismatchException();
|
||||
}
|
||||
|
||||
DomainPrices prices = getPricesForDomainName(domainName, now);
|
||||
builder
|
||||
.setCommand(feeCommand)
|
||||
.setCurrency(registry.getCurrency())
|
||||
.setPeriod(feeRequest.getPeriod())
|
||||
// Choose from four classes: premium, premium-collision, collision, or null (standard case).
|
||||
.setClass(prices.getFeeClass().orNull());
|
||||
.setClass(TldSpecificLogicEngine.getFeeClass(domainName, now).orNull());
|
||||
|
||||
switch (feeCommand.getCommand()) {
|
||||
case UNKNOWN:
|
||||
|
@ -592,25 +590,20 @@ public class DomainFlowUtils {
|
|||
builder.setClass("reserved"); // Override whatever class we've set above.
|
||||
} else {
|
||||
builder.setFees(
|
||||
ImmutableList.of(
|
||||
Fee.create(prices.getCreateCost().multipliedBy(years).getAmount(), "create")));
|
||||
TldSpecificLogicEngine.getCreatePrice(registry, domainName, now, years).getFees());
|
||||
}
|
||||
break;
|
||||
case RESTORE:
|
||||
if (years != 1) {
|
||||
throw new RestoresAreAlwaysForOneYearException();
|
||||
}
|
||||
// Restores have a "renew" and a "restore" fee.
|
||||
builder.setFees(
|
||||
ImmutableList.of(
|
||||
Fee.create(prices.getRenewCost().multipliedBy(years).getAmount(), "renew"),
|
||||
Fee.create(registry.getStandardRestoreCost().getAmount(), "restore")));
|
||||
TldSpecificLogicEngine.getRestorePrice(registry, domainName, now, years).getFees());
|
||||
break;
|
||||
default:
|
||||
// Anything else (transfer|renew) will have a "renew" fee.
|
||||
builder.setFees(
|
||||
ImmutableList.of(
|
||||
Fee.create(prices.getRenewCost().multipliedBy(years).getAmount(), "renew")));
|
||||
TldSpecificLogicEngine.getRenewPrice(registry, domainName, now, years).getFees());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
|
@ -122,9 +123,7 @@ public final class TldSpecificLogicEngine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a new restore price for the pricer.
|
||||
*
|
||||
* <p>TODO: This probably needs to include the renew price.
|
||||
* Returns a new restore price (including the renew price) for the pricer.
|
||||
*
|
||||
* <p>domain name, number of years and date must be defined before calling this.
|
||||
*/
|
||||
|
@ -138,5 +137,12 @@ public final class TldSpecificLogicEngine {
|
|||
Fee.create(registry.getStandardRestoreCost().getAmount(), "restore")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fee class for a given domain and date.
|
||||
*/
|
||||
public static Optional<String> getFeeClass(String domainName, DateTime date) {
|
||||
return getPricesForDomainName(domainName, date).getFeeClass();
|
||||
}
|
||||
|
||||
// TODO(b/29089413): Add support for transfer prices once this is plumbed through the flows.
|
||||
}
|
||||
|
|
|
@ -22,10 +22,13 @@ import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
|
|||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
|
||||
import google.registry.flows.ResourceCheckFlow.TooManyResourceChecksException;
|
||||
import google.registry.flows.ResourceCheckFlowTestCase;
|
||||
|
@ -57,6 +60,7 @@ import google.registry.testing.DatastoreHelper;
|
|||
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -502,4 +506,18 @@ public class DomainCheckFlowTest
|
|||
create(true, "example2.tld", null),
|
||||
create(true, "example3.tld", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_eapFeeCheck() throws Exception {
|
||||
clock.setTo(DateTime.parse("2010-01-01T10:00:00Z"));
|
||||
persistActiveDomain("example1.tld");
|
||||
persistResource(Registry.get("tld").asBuilder()
|
||||
.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)))
|
||||
.build());
|
||||
setEppInput("domain_check_fee.xml");
|
||||
runFlowAssertResponse(readFile("domain_check_eap_fee_response.xml"));
|
||||
}
|
||||
}
|
||||
|
|
45
javatests/google/registry/flows/domain/testdata/domain_check_eap_fee_response.xml
vendored
Normal file
45
javatests/google/registry/flows/domain/testdata/domain_check_eap_fee_response.xml
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
<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.6">
|
||||
<fee:cd xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
|
||||
<fee:name>example2.tld</fee:name>
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:command>create</fee:command>
|
||||
<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-02T10:00:00.000Z">100.00</fee:fee>
|
||||
</fee:cd>
|
||||
<fee:cd xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
|
||||
<fee:name>example3.tld</fee:name>
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:command>create</fee:command>
|
||||
<fee:period unit="y">2</fee:period>
|
||||
<fee:fee description="create">26.00</fee:fee>
|
||||
<fee:fee description="Early Access Period, fee expires: 2010-01-02T10:00:00.000Z">100.00</fee:fee>
|
||||
</fee:cd>
|
||||
</fee:chkData>
|
||||
</extension>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>server-trid</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
Loading…
Add table
Add a link
Reference in a new issue