mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Delete SetClockExtension (#1738)
We no longer write to commit logs, and the ReplayExtension that this extension is supposed to be used with is already deleted.
This commit is contained in:
parent
999f7d3cae
commit
2f9a45c91f
6 changed files with 16 additions and 98 deletions
|
@ -82,29 +82,21 @@ import google.registry.model.tld.Registry;
|
||||||
import google.registry.model.tld.Registry.TldState;
|
import google.registry.model.tld.Registry.TldState;
|
||||||
import google.registry.model.tld.label.ReservedList;
|
import google.registry.model.tld.label.ReservedList;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.SetClockExtension;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import org.joda.money.CurrencyUnit;
|
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link DomainCheckFlow}. */
|
/** Unit tests for {@link DomainCheckFlow}. */
|
||||||
class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Domain> {
|
class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Domain> {
|
||||||
|
|
||||||
@Order(value = Order.DEFAULT - 3)
|
|
||||||
@RegisterExtension
|
|
||||||
final SetClockExtension setClockExtension = new SetClockExtension(clock, "2009-01-01T10:00:00Z");
|
|
||||||
|
|
||||||
DomainCheckFlowTest() {
|
DomainCheckFlowTest() {
|
||||||
setEppInput("domain_check_one_tld.xml");
|
setEppInput("domain_check_one_tld.xml");
|
||||||
|
clock.setTo(DateTime.parse("2009-01-01T10:00:00Z"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReservedList createReservedList() {
|
private static ReservedList createReservedList() {
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
.setDomainName("anchor.tld")
|
.setDomainName("anchor.tld")
|
||||||
|
@ -951,10 +943,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||||
// This works because Money.getAmount(), used in the flow, returns a BigDecimal that is set to
|
// This works because Money.getAmount(), used in the flow, returns a BigDecimal that is set to
|
||||||
// display the number of digits that is conventional for the given currency.
|
// display the number of digits that is conventional for the given currency.
|
||||||
persistResource(
|
persistResource(
|
||||||
Registry.get("tld")
|
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 11.1)).build());
|
||||||
.asBuilder()
|
|
||||||
.setCreateBillingCost(Money.of(CurrencyUnit.USD, 11.1))
|
|
||||||
.build());
|
|
||||||
setEppInput("domain_check_fee_fractional.xml");
|
setEppInput("domain_check_fee_fractional.xml");
|
||||||
runFlowAssertResponse(loadFile("domain_check_fee_fractional_response.xml"));
|
runFlowAssertResponse(loadFile("domain_check_fee_fractional_response.xml"));
|
||||||
}
|
}
|
||||||
|
@ -1398,7 +1387,6 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||||
"domain_check_fee_date_v12.xml", "domain_check_eap_fee_response_date_v12.xml");
|
"domain_check_fee_date_v12.xml", "domain_check_eap_fee_response_date_v12.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled
|
|
||||||
@Test
|
@Test
|
||||||
void testSuccess_feeCheck_multipleRanges() {
|
void testSuccess_feeCheck_multipleRanges() {
|
||||||
// TODO: If at some point we have more than one type of fees that are time dependent, populate
|
// TODO: If at some point we have more than one type of fees that are time dependent, populate
|
||||||
|
|
|
@ -48,9 +48,9 @@ import google.registry.flows.domain.DomainFlowUtils.CurrencyUnitMismatchExceptio
|
||||||
import google.registry.flows.domain.DomainFlowUtils.FeeChecksDontSupportPhasesException;
|
import google.registry.flows.domain.DomainFlowUtils.FeeChecksDontSupportPhasesException;
|
||||||
import google.registry.flows.domain.DomainFlowUtils.RestoresAreAlwaysForOneYearException;
|
import google.registry.flows.domain.DomainFlowUtils.RestoresAreAlwaysForOneYearException;
|
||||||
import google.registry.flows.domain.DomainFlowUtils.TransfersAreAlwaysForOneYearException;
|
import google.registry.flows.domain.DomainFlowUtils.TransfersAreAlwaysForOneYearException;
|
||||||
import google.registry.model.billing.BillingEvent;
|
|
||||||
import google.registry.model.billing.BillingEvent.Flag;
|
import google.registry.model.billing.BillingEvent.Flag;
|
||||||
import google.registry.model.billing.BillingEvent.Reason;
|
import google.registry.model.billing.BillingEvent.Reason;
|
||||||
|
import google.registry.model.billing.BillingEvent.Recurring;
|
||||||
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
||||||
import google.registry.model.contact.ContactAuthInfo;
|
import google.registry.model.contact.ContactAuthInfo;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
|
@ -70,23 +70,16 @@ import google.registry.model.tld.Registry;
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.SetClockExtension;
|
import java.util.regex.Pattern;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link DomainInfoFlow}. */
|
/** Unit tests for {@link DomainInfoFlow}. */
|
||||||
class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||||
|
|
||||||
@Order(value = Order.DEFAULT - 3)
|
|
||||||
@RegisterExtension
|
|
||||||
final SetClockExtension setClockExtension =
|
|
||||||
new SetClockExtension(clock, "2005-03-03T22:00:00.000Z");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The domain_info_fee.xml default substitutions common to most tests.
|
* The domain_info_fee.xml default substitutions common to most tests.
|
||||||
*
|
*
|
||||||
|
@ -99,6 +92,8 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||||
"CURRENCY", "USD",
|
"CURRENCY", "USD",
|
||||||
"UNIT", "y");
|
"UNIT", "y");
|
||||||
|
|
||||||
|
private static final Pattern OK_PATTERN = Pattern.compile("\"ok\"");
|
||||||
|
|
||||||
private ContactResource registrant;
|
private ContactResource registrant;
|
||||||
private ContactResource contact;
|
private ContactResource contact;
|
||||||
private Host host1;
|
private Host host1;
|
||||||
|
@ -109,6 +104,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup() {
|
void setup() {
|
||||||
setEppInput("domain_info.xml");
|
setEppInput("domain_info.xml");
|
||||||
|
clock.setTo(DateTime.parse("2005-03-03T22:00:00.000Z"));
|
||||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -175,7 +171,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||||
String expected =
|
String expected =
|
||||||
loadFile(expectedXmlFilename, updateSubstitutions(substitutions, "ROID", "2FF-TLD"));
|
loadFile(expectedXmlFilename, updateSubstitutions(substitutions, "ROID", "2FF-TLD"));
|
||||||
if (inactive) {
|
if (inactive) {
|
||||||
expected = expected.replaceAll("\"ok\"", "\"inactive\"");
|
expected = OK_PATTERN.matcher(expected).replaceAll("\"inactive\"");
|
||||||
}
|
}
|
||||||
runFlowAssertResponse(expected);
|
runFlowAssertResponse(expected);
|
||||||
if (!expectHistoryAndBilling) {
|
if (!expectHistoryAndBilling) {
|
||||||
|
@ -379,9 +375,9 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||||
.setModificationTime(clock.nowUtc())
|
.setModificationTime(clock.nowUtc())
|
||||||
.setRegistrarId(domain.getCreationRegistrarId())
|
.setRegistrarId(domain.getCreationRegistrarId())
|
||||||
.build());
|
.build());
|
||||||
BillingEvent.Recurring renewEvent =
|
Recurring renewEvent =
|
||||||
persistResource(
|
persistResource(
|
||||||
new BillingEvent.Recurring.Builder()
|
new Recurring.Builder()
|
||||||
.setReason(Reason.RENEW)
|
.setReason(Reason.RENEW)
|
||||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||||
.setTargetId(getUniqueIdFromCommand())
|
.setTargetId(getUniqueIdFromCommand())
|
||||||
|
@ -390,7 +386,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||||
.setRecurrenceEndTime(END_OF_TIME)
|
.setRecurrenceEndTime(END_OF_TIME)
|
||||||
.setDomainHistory(historyEntry)
|
.setDomainHistory(historyEntry)
|
||||||
.build());
|
.build());
|
||||||
VKey<BillingEvent.Recurring> recurringVKey = renewEvent.createVKey();
|
VKey<Recurring> recurringVKey = renewEvent.createVKey();
|
||||||
// Add an AUTO_RENEW grace period to the saved resource.
|
// Add an AUTO_RENEW grace period to the saved resource.
|
||||||
persistResource(
|
persistResource(
|
||||||
domain
|
domain
|
||||||
|
|
|
@ -29,7 +29,6 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
|
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
|
||||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||||
import static google.registry.testing.DatabaseHelper.newDomain;
|
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||||
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
||||||
import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||||
|
@ -95,16 +94,13 @@ import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.SetClockExtension;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link DomainRenewFlow}. */
|
/** Unit tests for {@link DomainRenewFlow}. */
|
||||||
class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain> {
|
class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain> {
|
||||||
|
@ -126,13 +122,9 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
|
|
||||||
private final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z");
|
private final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z");
|
||||||
|
|
||||||
@Order(value = Order.DEFAULT - 3)
|
|
||||||
@RegisterExtension
|
|
||||||
final SetClockExtension setClockExtension =
|
|
||||||
new SetClockExtension(clock, expirationTime.minusMillis(20));
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void initDomainTest() {
|
void initDomainTest() {
|
||||||
|
clock.setTo(expirationTime.minusMillis(20));
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("TheRegistrar")
|
loadRegistrar("TheRegistrar")
|
||||||
|
|
|
@ -32,20 +32,13 @@ import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.SetClockExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link PollAckFlow}. */
|
/** Unit tests for {@link PollAckFlow}. */
|
||||||
class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||||
|
|
||||||
@Order(value = Order.DEFAULT - 3)
|
|
||||||
@RegisterExtension
|
|
||||||
final SetClockExtension setClockExtension = new SetClockExtension(clock, "2011-01-02T01:01:01Z");
|
|
||||||
|
|
||||||
/** This is the message id being sent in the ACK request. */
|
/** This is the message id being sent in the ACK request. */
|
||||||
private static final long MESSAGE_ID = 3;
|
private static final long MESSAGE_ID = 3;
|
||||||
|
|
||||||
|
@ -55,6 +48,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2011"));
|
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2011"));
|
||||||
|
clock.setTo(DateTime.parse("2011-01-02T01:01:01Z"));
|
||||||
setRegistrarIdForFlow("NewRegistrar");
|
setRegistrarIdForFlow("NewRegistrar");
|
||||||
createTld("example");
|
createTld("example");
|
||||||
contact = persistActiveContact("jd1234");
|
contact = persistActiveContact("jd1234");
|
||||||
|
|
|
@ -40,19 +40,13 @@ import google.registry.model.transfer.TransferResponse.ContactTransferResponse;
|
||||||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||||
import google.registry.model.transfer.TransferStatus;
|
import google.registry.model.transfer.TransferStatus;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.SetClockExtension;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link PollRequestFlow}. */
|
/** Unit tests for {@link PollRequestFlow}. */
|
||||||
class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||||
|
|
||||||
@Order(value = Order.DEFAULT - 3)
|
|
||||||
@RegisterExtension
|
|
||||||
final SetClockExtension setClockExtension = new SetClockExtension(clock, "2011-01-02T01:01:01Z");
|
|
||||||
|
|
||||||
private Domain domain;
|
private Domain domain;
|
||||||
private ContactResource contact;
|
private ContactResource contact;
|
||||||
private Host host;
|
private Host host;
|
||||||
|
@ -60,6 +54,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
setEppInput("poll.xml");
|
setEppInput("poll.xml");
|
||||||
|
clock.setTo(DateTime.parse("2011-01-02T01:01:01Z"));
|
||||||
setRegistrarIdForFlow("NewRegistrar");
|
setRegistrarIdForFlow("NewRegistrar");
|
||||||
createTld("example");
|
createTld("example");
|
||||||
persistNewRegistrar("BadRegistrar");
|
persistNewRegistrar("BadRegistrar");
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
// Copyright 2021 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.testing;
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension used for tests that a) set the clock to a specific time and b) make use of
|
|
||||||
* ReplayExtension or any other test feature that requires writing to a commit log from test
|
|
||||||
* utilities that aren't controlled by the ultimate test class (e.g. AppEngineExtension).
|
|
||||||
*/
|
|
||||||
public class SetClockExtension implements BeforeEachCallback {
|
|
||||||
|
|
||||||
private FakeClock clock;
|
|
||||||
private DateTime dateTime;
|
|
||||||
|
|
||||||
/** Construct from a DateTime, that being the time to set the clock to. */
|
|
||||||
public SetClockExtension(FakeClock clock, DateTime dateTime) {
|
|
||||||
this.clock = clock;
|
|
||||||
this.dateTime = dateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Construct from a dateTime (the time to set the clock to) represented as a string. */
|
|
||||||
public SetClockExtension(FakeClock clock, String dateTime) {
|
|
||||||
this.clock = clock;
|
|
||||||
this.dateTime = DateTime.parse(dateTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeEach(ExtensionContext context) {
|
|
||||||
clock.setTo(dateTime);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue