mirror of
https://github.com/google/nomulus
synced 2026-09-08 17:17:02 +00:00
Delete DatastoreTM and most other references to Datastore (#1681)
This includes: - deletion of helper DB methods in tests - deletion of various old Datastore-only classes and removal of any endpoints - removal of the dual-database test concept - removal of 'ofy' from the AppEngineExtension
This commit is contained in:
@@ -55,7 +55,7 @@ public class AsyncTaskEnqueuerTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
||||
@@ -41,30 +40,24 @@ import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.transaction.QueryComposer.Comparator;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeLockHandler;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DeleteExpiredDomainsAction}. */
|
||||
@DualDatabaseTest
|
||||
class DeleteExpiredDomainsActionTest {
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2016-06-13T20:21:22Z"));
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withClock(clock)
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@@ -86,7 +79,7 @@ class DeleteExpiredDomainsActionTest {
|
||||
eppController, "NewRegistrar", clock, new FakeLockHandler(true), response);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_deletesOnlyExpiredDomain() {
|
||||
// A normal, active autorenewing domain that shouldn't be touched.
|
||||
DomainBase activeDomain = persistActiveDomain("foo.tld");
|
||||
@@ -131,7 +124,7 @@ class DeleteExpiredDomainsActionTest {
|
||||
assertThat(reloadedExpiredDomain.getDeletionTime()).isEqualTo(clock.nowUtc().plusDays(35));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_deletesThreeDomainsInOneRun() throws Exception {
|
||||
DomainBase domain1 = persistNonAutorenewingDomain("ecck1.tld");
|
||||
DomainBase domain2 = persistNonAutorenewingDomain("veee2.tld");
|
||||
@@ -143,14 +136,14 @@ class DeleteExpiredDomainsActionTest {
|
||||
int maxRetries = 5;
|
||||
while (true) {
|
||||
ImmutableSet<String> matchingDomains =
|
||||
transactIfJpaTm(
|
||||
() ->
|
||||
tm()
|
||||
.createQueryComposer(DomainBase.class)
|
||||
.where("autorenewEndTime", Comparator.LTE, clock.nowUtc())
|
||||
.stream()
|
||||
.map(DomainBase::getDomainName)
|
||||
.collect(toImmutableSet()));
|
||||
tm().transact(
|
||||
() ->
|
||||
tm()
|
||||
.createQueryComposer(DomainBase.class)
|
||||
.where("autorenewEndTime", Comparator.LTE, clock.nowUtc())
|
||||
.stream()
|
||||
.map(DomainBase::getDomainName)
|
||||
.collect(toImmutableSet()));
|
||||
if (matchingDomains.containsAll(ImmutableSet.of("ecck1.tld", "veee2.tld", "tarm3.tld"))) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -51,32 +51,25 @@ import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tld.Registry.TldType;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.SystemPropertyExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DeleteProberDataAction}. */
|
||||
@DualDatabaseTest
|
||||
class DeleteProberDataActionTest {
|
||||
|
||||
private static final DateTime DELETION_TIME = DateTime.parse("2010-01-01T00:00:00.000Z");
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withLocalModules()
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withLocalModules().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension
|
||||
final SystemPropertyExtension systemPropertyExtension = new SystemPropertyExtension();
|
||||
@@ -108,7 +101,6 @@ class DeleteProberDataActionTest {
|
||||
private void resetAction() {
|
||||
action = new DeleteProberDataAction();
|
||||
action.dnsQueue = DnsQueue.createForTesting(new FakeClock());
|
||||
action.response = new FakeResponse();
|
||||
action.isDryRun = false;
|
||||
action.tlds = ImmutableSet.of();
|
||||
action.registryAdminRegistrarId = "TheRegistrar";
|
||||
@@ -120,7 +112,7 @@ class DeleteProberDataActionTest {
|
||||
RegistryEnvironment.UNITTEST.setup(systemPropertyExtension);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_deletesAllAndOnlyProberData() throws Exception {
|
||||
Set<ImmutableObject> tldEntities = persistLotsOfDomains("tld");
|
||||
Set<ImmutableObject> exampleEntities = persistLotsOfDomains("example");
|
||||
@@ -135,7 +127,7 @@ class DeleteProberDataActionTest {
|
||||
assertAllAbsent(oaEntities);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_deletesAllAndOnlyGivenTlds() throws Exception {
|
||||
Set<ImmutableObject> tldEntities = persistLotsOfDomains("tld");
|
||||
Set<ImmutableObject> exampleEntities = persistLotsOfDomains("example");
|
||||
@@ -151,7 +143,7 @@ class DeleteProberDataActionTest {
|
||||
assertAllAbsent(ibEntities);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFail_givenNonTestTld() {
|
||||
action.tlds = ImmutableSet.of("not-test.test");
|
||||
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, action::run);
|
||||
@@ -160,7 +152,7 @@ class DeleteProberDataActionTest {
|
||||
.contains("If tlds are given, they must all exist and be TEST tlds");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFail_givenNonExistentTld() {
|
||||
action.tlds = ImmutableSet.of("non-existent.test");
|
||||
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, action::run);
|
||||
@@ -169,7 +161,7 @@ class DeleteProberDataActionTest {
|
||||
.contains("If tlds are given, they must all exist and be TEST tlds");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFail_givenNonDotTestTldOnProd() {
|
||||
action.tlds = ImmutableSet.of("example");
|
||||
RegistryEnvironment.PRODUCTION.setup(systemPropertyExtension);
|
||||
@@ -179,7 +171,7 @@ class DeleteProberDataActionTest {
|
||||
.contains("On production, can only work on TLDs that end with .test");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_doesntDeleteNicDomainForProbers() throws Exception {
|
||||
DomainBase nic = persistActiveDomain("nic.ib-any.test");
|
||||
Set<ImmutableObject> ibEntities = persistLotsOfDomains("ib-any.test");
|
||||
@@ -188,7 +180,7 @@ class DeleteProberDataActionTest {
|
||||
assertAllExist(ImmutableSet.of(nic));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun_doesntDeleteData() throws Exception {
|
||||
Set<ImmutableObject> tldEntities = persistLotsOfDomains("tld");
|
||||
Set<ImmutableObject> oaEntities = persistLotsOfDomains("oa-canary.test");
|
||||
@@ -198,7 +190,7 @@ class DeleteProberDataActionTest {
|
||||
assertAllExist(oaEntities);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_activeDomain_isSoftDeleted() throws Exception {
|
||||
DomainBase domain =
|
||||
persistResource(
|
||||
@@ -213,7 +205,7 @@ class DeleteProberDataActionTest {
|
||||
assertDnsTasksEnqueued("blah.ib-any.test");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_activeDomain_doubleMapSoftDeletes() throws Exception {
|
||||
DomainBase domain = persistResource(
|
||||
newDomainBase("blah.ib-any.test")
|
||||
@@ -230,7 +222,7 @@ class DeleteProberDataActionTest {
|
||||
assertDnsTasksEnqueued("blah.ib-any.test");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_recentlyCreatedDomain_isntDeletedYet() throws Exception {
|
||||
persistResource(
|
||||
newDomainBase("blah.ib-any.test")
|
||||
@@ -244,7 +236,7 @@ class DeleteProberDataActionTest {
|
||||
assertThat(domain.get().getDeletionTime()).isEqualTo(END_OF_TIME);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun_doesntSoftDeleteData() throws Exception {
|
||||
DomainBase domain =
|
||||
persistResource(
|
||||
@@ -257,7 +249,7 @@ class DeleteProberDataActionTest {
|
||||
assertThat(loadByEntity(domain).getDeletionTime()).isEqualTo(END_OF_TIME);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_domainWithSubordinateHosts_isSkipped() throws Exception {
|
||||
persistActiveHost("ns1.blah.ib-any.test");
|
||||
DomainBase nakedDomain =
|
||||
@@ -275,7 +267,7 @@ class DeleteProberDataActionTest {
|
||||
assertAllAbsent(ImmutableSet.of(nakedDomain));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_registryAdminClientId_isRequiredForSoftDeletion() {
|
||||
persistResource(
|
||||
newDomainBase("blah.ib-any.test")
|
||||
|
||||
+39
-47
@@ -22,7 +22,6 @@ import static google.registry.model.domain.Period.Unit.YEARS;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_AUTORENEW;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.testing.DatabaseHelper.assertBillingEventsForResource;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.getHistoryEntriesOfType;
|
||||
@@ -55,29 +54,23 @@ import google.registry.model.reporting.DomainTransactionRecord.TransactionReport
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link ExpandRecurringBillingEventsAction}. */
|
||||
@DualDatabaseTest
|
||||
public class ExpandRecurringBillingEventsActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withLocalModules()
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withLocalModules().withTaskQueue().build();
|
||||
|
||||
private DateTime currentTestTime = DateTime.parse("1999-01-05T00:00:00Z");
|
||||
private final FakeClock clock = new FakeClock(currentTestTime);
|
||||
@@ -139,8 +132,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
}
|
||||
|
||||
private void assertCursorAt(DateTime expectedCursorTime) {
|
||||
Cursor cursor =
|
||||
transactIfJpaTm(() -> tm().loadByKey(Cursor.createGlobalVKey(RECURRING_BILLING)));
|
||||
Cursor cursor = tm().transact(() -> tm().loadByKey(Cursor.createGlobalVKey(RECURRING_BILLING)));
|
||||
assertThat(cursor).isNotNull();
|
||||
assertThat(cursor.getCursorTime()).isEqualTo(expectedCursorTime);
|
||||
}
|
||||
@@ -183,7 +175,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
.setTargetId(domain.getDomainName());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(START_OF_TIME);
|
||||
@@ -197,7 +189,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_deletedDomain() throws Exception {
|
||||
DateTime deletionTime = DateTime.parse("2000-08-01T00:00:00Z");
|
||||
DomainBase deletedDomain = persistDeletedDomain("deleted.tld", deletionTime);
|
||||
@@ -240,7 +232,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_idempotentForDuplicateRuns() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(START_OF_TIME);
|
||||
@@ -258,7 +250,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertBillingEventsForResource(domain, expected, recurring);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_idempotentForExistingOneTime() throws Exception {
|
||||
persistResource(recurring);
|
||||
BillingEvent.OneTime persisted =
|
||||
@@ -272,7 +264,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertBillingEventsForResource(domain, persisted, recurring);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_notIdempotentForDifferentBillingTime() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(START_OF_TIME);
|
||||
@@ -295,7 +287,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertBillingEventsForResource(domain, persisted, expected, recurring);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_notIdempotentForDifferentRecurring() throws Exception {
|
||||
persistResource(recurring);
|
||||
BillingEvent.Recurring recurring2 = persistResource(recurring.asBuilder().setId(3L).build());
|
||||
@@ -321,7 +313,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertBillingEventsForResource(domain, persisted, expected, recurring, recurring2);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_ignoreRecurringBeforeWindow() throws Exception {
|
||||
recurring =
|
||||
persistResource(
|
||||
@@ -338,7 +330,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_ignoreRecurringAfterWindow() throws Exception {
|
||||
recurring =
|
||||
persistResource(recurring.asBuilder().setEventTime(clock.nowUtc().plusYears(2)).build());
|
||||
@@ -349,7 +341,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertBillingEventsForResource(domain, recurring);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_billingTimeAtCursorTime() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(DateTime.parse("2000-02-19T00:00:00Z"));
|
||||
@@ -363,7 +355,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_cursorTimeBetweenEventAndBillingTime() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.cursorTimeParam = Optional.of(DateTime.parse("2000-01-12T00:00:00Z"));
|
||||
@@ -377,7 +369,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_billingTimeAtExecutionTime() throws Exception {
|
||||
clock.setTo(currentTestTime);
|
||||
persistResource(recurring);
|
||||
@@ -393,7 +385,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_multipleYearCreate() throws Exception {
|
||||
action.cursorTimeParam = Optional.of(recurring.getEventTime());
|
||||
recurring =
|
||||
@@ -415,7 +407,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_withCursor() throws Exception {
|
||||
persistResource(recurring);
|
||||
saveCursor(START_OF_TIME);
|
||||
@@ -429,7 +421,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_withCursorPastExpected() throws Exception {
|
||||
persistResource(recurring);
|
||||
// Simulate a quick second run of the action (this should be a no-op).
|
||||
@@ -441,7 +433,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_recurrenceEndBeforeEvent() throws Exception {
|
||||
// This can occur when a domain is transferred or deleted before a domain comes up for renewal.
|
||||
recurring =
|
||||
@@ -458,7 +450,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_dryRun() throws Exception {
|
||||
persistResource(recurring);
|
||||
action.isDryRun = true;
|
||||
@@ -470,7 +462,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(START_OF_TIME); // Cursor doesn't move on a dry run.
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_multipleYears() throws Exception {
|
||||
clock.setTo(clock.nowUtc().plusYears(5));
|
||||
List<BillingEvent> expectedEvents = new ArrayList<>();
|
||||
@@ -497,7 +489,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_multipleYears_cursorInBetweenYears() throws Exception {
|
||||
clock.setTo(clock.nowUtc().plusYears(5));
|
||||
List<BillingEvent> expectedEvents = new ArrayList<>();
|
||||
@@ -524,7 +516,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_singleEvent_beforeRenewal() throws Exception {
|
||||
// Need to restore to the time before the clock was advanced so that the commit log's timestamp
|
||||
// is not inverted when the clock is later reverted.
|
||||
@@ -539,7 +531,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_singleEvent_afterRecurrenceEnd_inAutorenewGracePeriod() throws Exception {
|
||||
// The domain creation date is 1999-01-05, and the first renewal date is thus 2000-01-05.
|
||||
clock.setTo(DateTime.parse("2001-02-06T00:00:00Z"));
|
||||
@@ -568,7 +560,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_singleEvent_afterRecurrenceEnd_outsideAutorenewGracePeriod() throws Exception {
|
||||
// The domain creation date is 1999-01-05, and the first renewal date is thus 2000-01-05.
|
||||
clock.setTo(DateTime.parse("2001-02-06T00:00:00Z"));
|
||||
@@ -597,7 +589,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_billingTimeOnLeapYear() throws Exception {
|
||||
recurring =
|
||||
persistResource(
|
||||
@@ -618,7 +610,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_billingTimeNotOnLeapYear() throws Exception {
|
||||
recurring =
|
||||
persistResource(
|
||||
@@ -640,7 +632,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandMultipleEvents() throws Exception {
|
||||
persistResource(recurring);
|
||||
DomainBase domain2 =
|
||||
@@ -735,7 +727,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandMultipleEvents_anchorTenant() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -783,7 +775,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expandMultipleEvents_premiumDomain_internalRegistration() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -841,7 +833,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_premiumDomain() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -861,7 +853,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_premiumDomain_forAnchorTenant() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -881,7 +873,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_standardDomain_forAnchorTenant() throws Exception {
|
||||
recurring = persistResource(recurring.asBuilder().setRenewalPriceBehavior(NONPREMIUM).build());
|
||||
action.cursorTimeParam = Optional.of(START_OF_TIME);
|
||||
@@ -895,7 +887,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_premiumDomain_forInternalRegistration() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -921,7 +913,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_standardDomain_forInternalRegistration() throws Exception {
|
||||
recurring =
|
||||
persistResource(
|
||||
@@ -942,7 +934,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_varyingRenewPrices() throws Exception {
|
||||
clock.setTo(currentTestTime);
|
||||
persistResource(
|
||||
@@ -986,7 +978,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_varyingRenewPrices_anchorTenant() throws Exception {
|
||||
clock.setTo(currentTestTime);
|
||||
persistResource(
|
||||
@@ -1031,7 +1023,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_varyingRenewPrices_internalRegistration() throws Exception {
|
||||
clock.setTo(currentTestTime);
|
||||
persistResource(
|
||||
@@ -1082,7 +1074,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
assertCursorAt(currentTestTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_cursorAfterExecutionTime() {
|
||||
action.cursorTimeParam = Optional.of(clock.nowUtc().plusYears(1));
|
||||
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, this::runAction);
|
||||
@@ -1091,7 +1083,7 @@ public class ExpandRecurringBillingEventsActionTest {
|
||||
.contains("Cursor time must be earlier than execution time.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_cursorAtExecutionTime() {
|
||||
// The clock advances one milli on run.
|
||||
action.cursorTimeParam = Optional.of(clock.nowUtc().plusMillis(1));
|
||||
|
||||
@@ -43,10 +43,8 @@ import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.CloudTasksHelper;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.testing.UserInfo;
|
||||
import google.registry.tools.DomainLockUtils;
|
||||
import google.registry.util.EmailMessage;
|
||||
@@ -58,6 +56,7 @@ import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
@@ -65,7 +64,6 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link RelockDomainAction}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@DualDatabaseTest
|
||||
public class RelockDomainActionTest {
|
||||
|
||||
private static final String DOMAIN_NAME = "example.tld";
|
||||
@@ -84,7 +82,7 @@ public class RelockDomainActionTest {
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngineExtension =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withCloudSql()
|
||||
.withTaskQueue()
|
||||
.withUserService(UserInfo.create(POC_ID, "12345"))
|
||||
.build();
|
||||
@@ -116,7 +114,7 @@ public class RelockDomainActionTest {
|
||||
verifyNoMoreInteractions(sendEmailService);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLock() {
|
||||
action.run();
|
||||
assertThat(loadByEntity(domain).getStatusValues())
|
||||
@@ -128,7 +126,7 @@ public class RelockDomainActionTest {
|
||||
.isEqualTo(newLock);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unknownCode() throws Exception {
|
||||
action = createAction(12128675309L);
|
||||
action.run();
|
||||
@@ -137,7 +135,7 @@ public class RelockDomainActionTest {
|
||||
assertTaskEnqueued(1, 12128675309L, Duration.standardMinutes(10)); // should retry, transient
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDelete() throws Exception {
|
||||
persistResource(domain.asBuilder().setStatusValues(ImmutableSet.of(PENDING_DELETE)).build());
|
||||
action.run();
|
||||
@@ -149,7 +147,7 @@ public class RelockDomainActionTest {
|
||||
cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingTransfer() throws Exception {
|
||||
persistResource(domain.asBuilder().setStatusValues(ImmutableSet.of(PENDING_TRANSFER)).build());
|
||||
action.run();
|
||||
@@ -161,7 +159,7 @@ public class RelockDomainActionTest {
|
||||
cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_domainAlreadyLocked() {
|
||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, null, true);
|
||||
action.run();
|
||||
@@ -171,7 +169,7 @@ public class RelockDomainActionTest {
|
||||
cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_domainDeleted() throws Exception {
|
||||
persistDomainAsDeleted(domain, clock.nowUtc());
|
||||
action.run();
|
||||
@@ -183,7 +181,7 @@ public class RelockDomainActionTest {
|
||||
cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_domainTransferred() throws Exception {
|
||||
persistResource(
|
||||
domain.asBuilder().setPersistedCurrentSponsorRegistrarId("NewRegistrar").build());
|
||||
@@ -198,7 +196,7 @@ public class RelockDomainActionTest {
|
||||
cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
public void testFailure_transientFailure_enqueuesTask() {
|
||||
// Hard-delete the domain to simulate a DB failure
|
||||
deleteTestDomain(domain, clock.nowUtc());
|
||||
@@ -209,7 +207,7 @@ public class RelockDomainActionTest {
|
||||
assertTaskEnqueued(1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_sufficientTransientFailures_sendsEmail() throws Exception {
|
||||
// Hard-delete the domain to simulate a DB failure
|
||||
deleteTestDomain(domain, clock.nowUtc());
|
||||
@@ -222,7 +220,7 @@ public class RelockDomainActionTest {
|
||||
assertThat(response.getPayload()).startsWith("Re-lock failed: VKey");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_afterSufficientFailures_sendsEmail() throws Exception {
|
||||
action = createAction(oldLock.getRevisionId(), RelockDomainAction.FAILURES_BEFORE_EMAIL + 1);
|
||||
action.run();
|
||||
@@ -230,7 +228,7 @@ public class RelockDomainActionTest {
|
||||
assertSuccessEmailSent();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_relockAlreadySet() {
|
||||
RegistryLock newLock =
|
||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, null, true);
|
||||
@@ -244,7 +242,7 @@ public class RelockDomainActionTest {
|
||||
cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_slowsDown() throws Exception {
|
||||
deleteTestDomain(domain, clock.nowUtc());
|
||||
action = createAction(oldLock.getRevisionId(), RelockDomainAction.ATTEMPTS_BEFORE_SLOWDOWN);
|
||||
|
||||
+1
-2
@@ -35,8 +35,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
public class ResaveAllEppResourcesPipelineActionTest extends BeamActionTestBase {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
private final FakeClock fakeClock = new FakeClock();
|
||||
|
||||
|
||||
@@ -40,13 +40,12 @@ import google.registry.request.Response;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.CloudTasksHelper;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
@@ -56,12 +55,11 @@ import org.mockito.quality.Strictness;
|
||||
|
||||
/** Unit tests for {@link ResaveEntityAction}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@DualDatabaseTest
|
||||
public class ResaveEntityActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@@ -88,7 +86,7 @@ public class ResaveEntityActionTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_domainPendingTransfer_isResavedAndTransferCompleted() {
|
||||
DomainBase domain =
|
||||
persistDomainWithPendingTransfer(
|
||||
@@ -113,7 +111,7 @@ public class ResaveEntityActionTest {
|
||||
verify(response).setPayload("Entity re-saved.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_domainPendingDeletion_isResavedAndReenqueued() {
|
||||
DomainBase newDomain = newDomainBase("domain.tld");
|
||||
DomainBase domain =
|
||||
|
||||
+29
-31
@@ -38,11 +38,9 @@ import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.registrar.RegistrarPoc.Type;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.util.SelfSignedCaCertificate;
|
||||
import google.registry.util.SendEmailService;
|
||||
import java.security.cert.X509Certificate;
|
||||
@@ -51,10 +49,10 @@ import javax.annotation.Nullable;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link SendExpiringCertificateNotificationEmailAction}. */
|
||||
@DualDatabaseTest
|
||||
class SendExpiringCertificateNotificationEmailActionTest {
|
||||
|
||||
private static final String EXPIRATION_WARNING_EMAIL_BODY_TEXT =
|
||||
@@ -75,7 +73,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2021-05-24T20:21:22Z"));
|
||||
@@ -111,7 +109,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
persistResource(createRegistrar("clientId", "sampleRegistrar", null, null).build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmail_techEMailAsRecipient_returnsTrue() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -133,7 +131,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmail_adminEMailAsRecipient_returnsTrue() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -155,7 +153,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmail_returnsFalse_unsupportedEmailType() throws Exception {
|
||||
Registrar registrar =
|
||||
persistResource(
|
||||
@@ -185,7 +183,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmail_returnsFalse_noEmailRecipients() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -201,7 +199,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmail_throwsRunTimeException() throws Exception {
|
||||
doThrow(new RuntimeException("this is a runtime exception"))
|
||||
.when(sendEmailService)
|
||||
@@ -247,7 +245,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
registrar.getRegistrarName()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmail_returnsFalse_noCertificate() {
|
||||
assertThat(
|
||||
action.sendNotificationEmail(
|
||||
@@ -255,7 +253,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmails_allEmailsBeingSent_onlyMainCertificates() throws Exception {
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
Registrar registrar =
|
||||
@@ -275,7 +273,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(action.sendNotificationEmails()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmails_allEmailsBeingSent_onlyFailOverCertificates() throws Exception {
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
Registrar registrar =
|
||||
@@ -295,7 +293,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(action.sendNotificationEmails()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void sendNotificationEmails_allEmailsBeingSent_mixedOfCertificates() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -334,7 +332,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(action.sendNotificationEmails()).isEqualTo(16);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void updateLastNotificationSentDate_updatedSuccessfully_primaryCertificate() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -350,7 +348,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(clock.nowUtc());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void updateLastNotificationSentDate_updatedSuccessfully_failOverCertificate() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -366,7 +364,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(clock.nowUtc());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void updateLastNotificationSentDate_noUpdates_noLastNotificationSentDate() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -386,7 +384,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.contains("Failed to update the last notification sent date to Registrar");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void updateLastNotificationSentDate_noUpdates_invalidCertificateType() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -406,7 +404,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(thrown).hasMessageThat().contains("No enum constant");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getRegistrarsWithExpiringCertificates_returnsPartOfRegistrars() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -434,7 +432,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(results).hasSize(numOfRegistrarsWithExpiringCertificates);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getRegistrarsWithExpiringCertificates_returnsPartOfRegistrars_failOverCertificateBranch()
|
||||
throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
@@ -463,7 +461,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(numOfRegistrarsWithExpiringCertificates);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getRegistrarsWithExpiringCertificates_returnsAllRegistrars() throws Exception {
|
||||
X509Certificate expiringCertificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -481,7 +479,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo(numOfRegistrarsWithExpiringCertificates);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getRegistrarsWithExpiringCertificates_returnsNoRegistrars() throws Exception {
|
||||
X509Certificate certificate =
|
||||
SelfSignedCaCertificate.create(
|
||||
@@ -496,18 +494,18 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(action.getRegistrarsWithExpiringCertificates()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getRegistrarsWithExpiringCertificates_noRegistrarsInDatabase() {
|
||||
assertThat(action.getRegistrarsWithExpiringCertificates()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getEmailAddresses_success_returnsAnEmptyList() {
|
||||
assertThat(action.getEmailAddresses(sampleRegistrar, Type.TECH)).isEmpty();
|
||||
assertThat(action.getEmailAddresses(sampleRegistrar, Type.ADMIN)).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getEmailAddresses_success_returnsAListOfEmails() throws Exception {
|
||||
Registrar registrar = persistResource(makeRegistrar1());
|
||||
ImmutableList<RegistrarPoc> contacts =
|
||||
@@ -570,7 +568,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
new InternetAddress("john@example-registrar.tld"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getEmailAddresses_failure_returnsPartialListOfEmails_skipInvalidEmails() {
|
||||
// when building a new RegistrarContact object, there's already an email validation process.
|
||||
// if the registrarContact is created successful, the email address of the contact object
|
||||
@@ -578,7 +576,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
// a new InternetAddress using the email address string of the contact object.
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getEmailBody_returnsEmailBodyText() {
|
||||
String registrarName = "good registrar";
|
||||
String certExpirationDateStr = "2021-06-15";
|
||||
@@ -600,7 +598,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(emailBody).doesNotContain("%4$s");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getEmailBody_throwsIllegalArgumentException_noExpirationDate() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
@@ -611,7 +609,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(thrown).hasMessageThat().contains("Expiration date cannot be null");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getEmailBody_throwsIllegalArgumentException_noCertificateType() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
@@ -622,7 +620,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(thrown).hasMessageThat().contains("Certificate type cannot be null");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void getEmailBody_throwsIllegalArgumentException_noRegistrarId() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
@@ -636,7 +634,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar Id cannot be null");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void run_sentZeroEmail_responseStatusIs200() {
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
@@ -644,7 +642,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.isEqualTo("Done. Sent 0 expiring certificate notification emails in total.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void run_sentEmails_responseStatusIs200() throws Exception {
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
Registrar registrar =
|
||||
|
||||
@@ -36,17 +36,15 @@ import google.registry.model.eppcommon.PresenceMarker;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestSqlOnly;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link WipeOutContactHistoryPiiAction}. */
|
||||
@DualDatabaseTest
|
||||
class WipeOutContactHistoryPiiActionTest {
|
||||
|
||||
private static final int TEST_BATCH_SIZE = 20;
|
||||
@@ -102,7 +100,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2021-08-26T20:21:22Z"));
|
||||
@@ -118,7 +116,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
clock, MIN_MONTHS_BEFORE_WIPE_OUT, TEST_BATCH_SIZE, response);
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void getAllHistoryEntitiesOlderThan_returnsAllPersistedEntities() {
|
||||
ImmutableList<ContactHistory> expectedToBeWipedOut =
|
||||
persistLotsOfContactHistoryEntities(
|
||||
@@ -132,7 +130,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
.containsExactlyElementsIn(expectedToBeWipedOut));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void getAllHistoryEntitiesOlderThan_returnsOnlyOldEnoughPersistedEntities() {
|
||||
ImmutableList<ContactHistory> expectedToBeWipedOut =
|
||||
persistLotsOfContactHistoryEntities(
|
||||
@@ -151,7 +149,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
.containsExactlyElementsIn(expectedToBeWipedOut));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void run_withNoEntitiesToWipeOut_success() {
|
||||
assertThat(
|
||||
jpaTm()
|
||||
@@ -179,7 +177,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
.isEqualTo("Done. Wiped out PII of 0 ContactHistory entities in total.");
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void run_withOneBatchOfEntities_success() {
|
||||
int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2;
|
||||
ImmutableList<ContactHistory> expectedToBeWipedOut =
|
||||
@@ -216,7 +214,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
assertAllPiiFieldsAreWipedOut(DatabaseHelper.loadByEntitiesIfPresent(expectedToBeWipedOut));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void run_withMultipleBatches_numOfEntitiesAsNonMultipleOfBatchSize_success() {
|
||||
int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2;
|
||||
ImmutableList<ContactHistory> expectedToBeWipedOut =
|
||||
@@ -252,7 +250,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
assertAllPiiFieldsAreWipedOut(DatabaseHelper.loadByEntitiesIfPresent(expectedToBeWipedOut));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void run_withMultipleBatches_numOfEntitiesAsMultiplesOfBatchSize_success() {
|
||||
int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2;
|
||||
ImmutableList<ContactHistory> expectedToBeWipedOut =
|
||||
@@ -289,7 +287,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
assertAllPiiFieldsAreWipedOut(DatabaseHelper.loadByEntitiesIfPresent(expectedToBeWipedOut));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void wipeOutContactHistoryData_wipesOutNoEntity() {
|
||||
jpaTm()
|
||||
.transact(
|
||||
@@ -302,7 +300,7 @@ class WipeOutContactHistoryPiiActionTest {
|
||||
});
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void wipeOutContactHistoryData_wipesOutMultipleEntities() {
|
||||
int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 3;
|
||||
ImmutableList<ContactHistory> expectedToBeWipedOut =
|
||||
|
||||
@@ -1,79 +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.batch;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
|
||||
import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
||||
import static org.apache.http.HttpStatus.SC_OK;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import google.registry.beam.BeamActionTestBase;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.testing.FakeClock;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link WipeoutDatastoreAction}. */
|
||||
class WipeOutDatastoreActionTest extends BeamActionTestBase {
|
||||
|
||||
private final FakeClock clock = new FakeClock();
|
||||
|
||||
@Test
|
||||
void run_projectNotAllowed() {
|
||||
try {
|
||||
RegistryEnvironment.SANDBOX.setup();
|
||||
WipeoutDatastoreAction action =
|
||||
new WipeoutDatastoreAction(
|
||||
"domain-registry-sandbox",
|
||||
"us-central1",
|
||||
"gs://some-bucket",
|
||||
clock,
|
||||
response,
|
||||
dataflow);
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_FORBIDDEN);
|
||||
verifyNoInteractions(dataflow);
|
||||
} finally {
|
||||
RegistryEnvironment.UNITTEST.setup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void run_projectAllowed() throws Exception {
|
||||
WipeoutDatastoreAction action =
|
||||
new WipeoutDatastoreAction(
|
||||
"domain-registry-qa", "us-central1", "gs://some-bucket", clock, response, dataflow);
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
verify(launch, times(1)).execute();
|
||||
verifyNoMoreInteractions(launch);
|
||||
}
|
||||
|
||||
@Test
|
||||
void run_failure() throws Exception {
|
||||
when(launch.execute()).thenThrow(new RuntimeException());
|
||||
WipeoutDatastoreAction action =
|
||||
new WipeoutDatastoreAction(
|
||||
"domain-registry-qa", "us-central1", "gs://some-bucket", clock, response, dataflow);
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_INTERNAL_SERVER_ERROR);
|
||||
verify(launch, times(1)).execute();
|
||||
verifyNoMoreInteractions(launch);
|
||||
}
|
||||
}
|
||||
-152
@@ -1,152 +0,0 @@
|
||||
// Copyright 2020 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.beam.datastore;
|
||||
|
||||
import static google.registry.beam.datastore.BulkDeleteDatastorePipeline.discoverEntityKinds;
|
||||
import static google.registry.beam.datastore.BulkDeleteDatastorePipeline.getDeletionTags;
|
||||
import static google.registry.beam.datastore.BulkDeleteDatastorePipeline.getOneDeletionTag;
|
||||
|
||||
import com.google.common.base.Verify;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.datastore.v1.Entity;
|
||||
import com.google.datastore.v1.Key;
|
||||
import com.google.datastore.v1.Key.PathElement;
|
||||
import google.registry.beam.TestPipelineExtension;
|
||||
import google.registry.beam.datastore.BulkDeleteDatastorePipeline.GenerateQueries;
|
||||
import google.registry.beam.datastore.BulkDeleteDatastorePipeline.SplitEntities;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import org.apache.beam.sdk.testing.PAssert;
|
||||
import org.apache.beam.sdk.transforms.Count;
|
||||
import org.apache.beam.sdk.transforms.Create;
|
||||
import org.apache.beam.sdk.transforms.ParDo;
|
||||
import org.apache.beam.sdk.transforms.View;
|
||||
import org.apache.beam.sdk.values.KV;
|
||||
import org.apache.beam.sdk.values.PCollection;
|
||||
import org.apache.beam.sdk.values.PCollectionTuple;
|
||||
import org.apache.beam.sdk.values.PCollectionView;
|
||||
import org.apache.beam.sdk.values.TupleTag;
|
||||
import org.apache.beam.sdk.values.TupleTagList;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link BulkDeleteDatastorePipeline}. */
|
||||
class BulkDeleteDatastorePipelineTest implements Serializable {
|
||||
|
||||
@RegisterExtension
|
||||
final transient TestPipelineExtension testPipeline =
|
||||
TestPipelineExtension.create().enableAbandonedNodeEnforcement(true);
|
||||
|
||||
@Test
|
||||
void generateQueries() {
|
||||
PCollection<String> queries =
|
||||
testPipeline
|
||||
.apply("InjectKinds", Create.of("A", "B"))
|
||||
.apply("GenerateQueries", ParDo.of(new GenerateQueries()));
|
||||
|
||||
PAssert.that(queries).containsInAnyOrder("select __key__ from `A`", "select __key__ from `B`");
|
||||
testPipeline.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapKindsToTags() {
|
||||
TupleTagList tags = getDeletionTags(2);
|
||||
PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B"));
|
||||
PCollection<KV<String, TupleTag<Entity>>> kindToTagMapping =
|
||||
BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags);
|
||||
PAssert.thatMap(kindToTagMapping)
|
||||
.isEqualTo(
|
||||
ImmutableMap.of(
|
||||
"A", new TupleTag<Entity>("0"),
|
||||
"B", new TupleTag<Entity>("1")));
|
||||
testPipeline.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapKindsToTags_fewerKindsThanTags() {
|
||||
TupleTagList tags = getDeletionTags(3);
|
||||
PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B"));
|
||||
PCollection<KV<String, TupleTag<Entity>>> kindToTagMapping =
|
||||
BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags);
|
||||
PAssert.thatMap(kindToTagMapping)
|
||||
.isEqualTo(
|
||||
ImmutableMap.of(
|
||||
"A", new TupleTag<Entity>("0"),
|
||||
"B", new TupleTag<Entity>("1")));
|
||||
testPipeline.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapKindsToTags_moreKindsThanTags() {
|
||||
TupleTagList tags = getDeletionTags(2);
|
||||
PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B", "C"));
|
||||
PCollection<KV<String, TupleTag<Entity>>> kindToTagMapping =
|
||||
BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags);
|
||||
PAssert.thatMap(kindToTagMapping)
|
||||
.isEqualTo(
|
||||
ImmutableMap.of(
|
||||
"A", new TupleTag<Entity>("0"),
|
||||
"B", new TupleTag<Entity>("1"),
|
||||
"C", new TupleTag<Entity>("0")));
|
||||
testPipeline.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
void splitEntitiesByKind() {
|
||||
TupleTagList tags = getDeletionTags(2);
|
||||
PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B"));
|
||||
PCollectionView<Map<String, TupleTag<Entity>>> kindToTagMapping =
|
||||
BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags).apply(View.asMap());
|
||||
Entity entityA = createTestEntity("A", 1);
|
||||
Entity entityB = createTestEntity("B", 2);
|
||||
PCollection<Entity> entities =
|
||||
testPipeline.apply("InjectEntities", Create.of(entityA, entityB));
|
||||
PCollectionTuple allCollections =
|
||||
entities.apply(
|
||||
"SplitByKind",
|
||||
ParDo.of(new SplitEntities(kindToTagMapping))
|
||||
.withSideInputs(kindToTagMapping)
|
||||
.withOutputTags(getOneDeletionTag("placeholder"), tags));
|
||||
PAssert.that(allCollections.get((TupleTag<Entity>) tags.get(0))).containsInAnyOrder(entityA);
|
||||
PAssert.that(allCollections.get((TupleTag<Entity>) tags.get(1))).containsInAnyOrder(entityB);
|
||||
testPipeline.run();
|
||||
}
|
||||
|
||||
private static Entity createTestEntity(String kind, long id) {
|
||||
return Entity.newBuilder()
|
||||
.setKey(Key.newBuilder().addPath(PathElement.newBuilder().setId(id).setKind(kind)))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIfSystemProperty(named = "test.gcp_integration.env", matches = "\\S+")
|
||||
void discoverKindsFromDatastore() {
|
||||
String environmentName = System.getProperty("test.gcp_integration.env");
|
||||
String project = "domain-registry-" + environmentName;
|
||||
|
||||
PCollection<String> kinds =
|
||||
testPipeline.apply("DiscoverEntityKinds", discoverEntityKinds(project));
|
||||
|
||||
PAssert.that(kinds.apply(Count.globally()))
|
||||
.satisfies(
|
||||
longs -> {
|
||||
Verify.verify(Iterables.size(longs) == 1 && Iterables.getFirst(longs, -1L) > 0);
|
||||
return null;
|
||||
});
|
||||
testPipeline.run();
|
||||
}
|
||||
}
|
||||
@@ -48,8 +48,7 @@ class TldFanoutActionTest {
|
||||
private final CloudTasksHelper cloudTasksHelper = new CloudTasksHelper(new FakeClock());
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
private static ImmutableListMultimap<String, String> getParamsMap(String... keysAndValues) {
|
||||
ImmutableListMultimap.Builder<String, String> params = new ImmutableListMultimap.Builder<>();
|
||||
|
||||
@@ -45,7 +45,7 @@ public final class DnsInjectionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class DnsQueueTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
private DnsQueue dnsQueue;
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2010-01-01T10:00:00Z"));
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PublishDnsUpdatesActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ"));
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ReadDnsQueueActionTest {
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withCloudSql()
|
||||
.withTaskQueue(
|
||||
Joiner.on('\n')
|
||||
.join(
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RefreshDnsActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
private final DnsQueue dnsQueue = mock(DnsQueue.class);
|
||||
private final FakeClock clock = new FakeClock();
|
||||
|
||||
@@ -45,8 +45,6 @@ import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.util.Retrier;
|
||||
import google.registry.util.SystemClock;
|
||||
import google.registry.util.SystemSleeper;
|
||||
@@ -56,6 +54,7 @@ import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -68,12 +67,10 @@ import org.mockito.quality.Strictness;
|
||||
|
||||
/** Test case for {@link CloudDnsWriter}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@DualDatabaseTest
|
||||
public class CloudDnsWriterTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
private static final Inet4Address IPv4 = (Inet4Address) InetAddresses.forString("127.0.0.1");
|
||||
private static final Inet6Address IPv6 = (Inet6Address) InetAddresses.forString("::1");
|
||||
@@ -314,7 +311,7 @@ public class CloudDnsWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_nonExistentDomain() {
|
||||
writer.publishDomain("example.tld");
|
||||
|
||||
@@ -322,7 +319,7 @@ public class CloudDnsWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_noDsDataOrNameservers() {
|
||||
persistResource(fakeDomain("example.tld", ImmutableSet.of(), 0));
|
||||
writer.publishDomain("example.tld");
|
||||
@@ -330,7 +327,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(fakeDomainRecords("example.tld", 0, 0, 0, 0));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_deleteOldData() {
|
||||
stubZone = fakeDomainRecords("example.tld", 2, 2, 2, 2);
|
||||
persistResource(fakeDomain("example.tld", ImmutableSet.of(), 0));
|
||||
@@ -339,7 +336,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(fakeDomainRecords("example.tld", 0, 0, 0, 0));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_withExternalNs() {
|
||||
persistResource(
|
||||
fakeDomain("example.tld", ImmutableSet.of(persistResource(fakeHost("0.external"))), 0));
|
||||
@@ -348,7 +345,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(fakeDomainRecords("example.tld", 0, 0, 1, 0));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_withDsData() {
|
||||
persistResource(
|
||||
fakeDomain("example.tld", ImmutableSet.of(persistResource(fakeHost("0.external"))), 1));
|
||||
@@ -357,7 +354,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(fakeDomainRecords("example.tld", 0, 0, 1, 1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_withInBailiwickNs_IPv4() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
@@ -372,7 +369,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(fakeDomainRecords("example.tld", 1, 0, 0, 0));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_withInBailiwickNs_IPv6() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
@@ -387,7 +384,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(fakeDomainRecords("example.tld", 0, 1, 0, 0));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_withNameserveThatEndsWithDomainName() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
@@ -400,7 +397,7 @@ public class CloudDnsWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadHost_externalHost() {
|
||||
writer.publishHost("ns1.example.com");
|
||||
|
||||
@@ -408,7 +405,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(ImmutableSet.of());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadHost_removeStaleNsRecords() {
|
||||
// Initialize the zone with both NS records
|
||||
stubZone = fakeDomainRecords("example.tld", 2, 0, 0, 0);
|
||||
@@ -431,7 +428,7 @@ public class CloudDnsWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void retryMutateZoneOnError() {
|
||||
CloudDnsWriter spyWriter = spy(writer);
|
||||
// First call - throw. Second call - do nothing.
|
||||
@@ -445,7 +442,7 @@ public class CloudDnsWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_withClientHold() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
@@ -461,7 +458,7 @@ public class CloudDnsWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_withServerHold() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
@@ -478,7 +475,7 @@ public class CloudDnsWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadDomain_withPendingDelete() {
|
||||
persistResource(
|
||||
fakeDomain(
|
||||
@@ -493,7 +490,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(ImmutableSet.of());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDuplicateRecords() {
|
||||
// In publishing DNS records, we can end up publishing information on the same host twice
|
||||
// (through a domain change and a host change), so this scenario needs to work.
|
||||
@@ -511,7 +508,7 @@ public class CloudDnsWriterTest {
|
||||
verifyZone(fakeDomainRecords("example.tld", 1, 0, 0, 0));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testInvalidZoneNames() {
|
||||
createTld("triple.secret.tld");
|
||||
persistResource(
|
||||
@@ -527,7 +524,7 @@ public class CloudDnsWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testEmptyCommit() {
|
||||
writer.commit();
|
||||
verify(dnsConnection, times(0)).changes();
|
||||
|
||||
@@ -42,15 +42,14 @@ import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -71,12 +70,11 @@ import org.xbill.DNS.Update;
|
||||
|
||||
/** Unit tests for {@link DnsUpdateWriter}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@DualDatabaseTest
|
||||
public class DnsUpdateWriterTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@@ -98,7 +96,7 @@ public class DnsUpdateWriterTest {
|
||||
"tld", Duration.ZERO, Duration.ZERO, Duration.ZERO, mockResolver, clock);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishDomainCreate_publishesNameServers() throws Exception {
|
||||
HostResource host1 = persistActiveHost("ns1.example.tld");
|
||||
HostResource host2 = persistActiveHost("ns2.example.tld");
|
||||
@@ -121,7 +119,7 @@ public class DnsUpdateWriterTest {
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishAtomic_noCommit() {
|
||||
HostResource host1 = persistActiveHost("ns.example1.tld");
|
||||
DomainBase domain1 =
|
||||
@@ -145,7 +143,7 @@ public class DnsUpdateWriterTest {
|
||||
verifyNoInteractions(mockResolver);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishAtomic_oneUpdate() throws Exception {
|
||||
HostResource host1 = persistActiveHost("ns.example1.tld");
|
||||
DomainBase domain1 =
|
||||
@@ -177,7 +175,7 @@ public class DnsUpdateWriterTest {
|
||||
assertThatTotalUpdateSetsIs(update, 4); // The delete and NS sets for each TLD
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishDomainCreate_publishesDelegationSigner() throws Exception {
|
||||
DomainBase domain =
|
||||
persistActiveDomain("example.tld")
|
||||
@@ -201,7 +199,7 @@ public class DnsUpdateWriterTest {
|
||||
assertThatTotalUpdateSetsIs(update, 3); // The delete, the NS, and DS sets
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishDomainWhenNotActive_removesDnsRecords() throws Exception {
|
||||
DomainBase domain =
|
||||
persistActiveDomain("example.tld")
|
||||
@@ -221,7 +219,7 @@ public class DnsUpdateWriterTest {
|
||||
assertThatTotalUpdateSetsIs(update, 1); // Just the delete set
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishDomainDelete_removesDnsRecords() throws Exception {
|
||||
persistDeletedDomain("example.tld", clock.nowUtc().minusDays(1));
|
||||
|
||||
@@ -235,7 +233,7 @@ public class DnsUpdateWriterTest {
|
||||
assertThatTotalUpdateSetsIs(update, 1); // Just the delete set
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishHostCreate_publishesAddressRecords() throws Exception {
|
||||
HostResource host =
|
||||
persistResource(
|
||||
@@ -268,7 +266,7 @@ public class DnsUpdateWriterTest {
|
||||
assertThatTotalUpdateSetsIs(update, 5);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishHostDelete_removesDnsRecords() throws Exception {
|
||||
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
|
||||
persistActiveDomain("example.tld");
|
||||
@@ -284,7 +282,7 @@ public class DnsUpdateWriterTest {
|
||||
assertThatTotalUpdateSetsIs(update, 2); // Just the delete set
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishHostDelete_removesGlueRecords() throws Exception {
|
||||
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
|
||||
persistResource(
|
||||
@@ -305,7 +303,7 @@ public class DnsUpdateWriterTest {
|
||||
assertThatTotalUpdateSetsIs(update, 3);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishDomainExternalAndInBailiwickNameServer() throws Exception {
|
||||
HostResource externalNameserver = persistResource(newHostResource("ns1.example.com"));
|
||||
HostResource inBailiwickNameserver =
|
||||
@@ -342,7 +340,7 @@ public class DnsUpdateWriterTest {
|
||||
assertThatTotalUpdateSetsIs(update, 5);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishDomainDeleteOrphanGlues() throws Exception {
|
||||
HostResource inBailiwickNameserver =
|
||||
persistResource(
|
||||
@@ -380,7 +378,7 @@ public class DnsUpdateWriterTest {
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@SuppressWarnings("AssertThrowsMultipleStatements")
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception {
|
||||
DomainBase domain =
|
||||
persistActiveDomain("example.tld")
|
||||
@@ -401,7 +399,7 @@ public class DnsUpdateWriterTest {
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@SuppressWarnings("AssertThrowsMultipleStatements")
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPublishHostFails_whenDnsUpdateReturnsError() throws Exception {
|
||||
HostResource host =
|
||||
persistActiveSubordinateHost("ns1.example.tld", persistActiveDomain("example.tld"))
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
// 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.export;
|
||||
|
||||
import static com.google.common.base.Strings.repeat;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.io.Resources.getResource;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.export.AnnotatedEntities.getBackupKinds;
|
||||
import static google.registry.export.AnnotatedEntities.getCrossTldKinds;
|
||||
import static google.registry.export.AnnotatedEntities.getReportingKinds;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.re2j.Pattern;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link AnnotatedEntities}. */
|
||||
class AnnotatedEntitiesTest {
|
||||
|
||||
private static final String GOLDEN_BACKUP_KINDS_FILENAME = "backup_kinds.txt";
|
||||
|
||||
private static final String GOLDEN_REPORTING_KINDS_FILENAME = "reporting_kinds.txt";
|
||||
|
||||
private static final String GOLDEN_CROSSTLD_KINDS_FILENAME = "crosstld_kinds.txt";
|
||||
|
||||
private static final String UPDATE_INSTRUCTIONS_TEMPLATE = Joiner.on('\n').join(
|
||||
"",
|
||||
repeat("-", 80),
|
||||
"Your changes affect the list of %s kinds in the golden file:",
|
||||
" %s",
|
||||
"If these changes are desired, update the golden file with the following contents:",
|
||||
repeat("=", 80),
|
||||
"%s",
|
||||
repeat("=", 80),
|
||||
"");
|
||||
|
||||
@Test
|
||||
void testBackupKinds_matchGoldenFile() {
|
||||
checkKindsMatchGoldenFile("backed-up", GOLDEN_BACKUP_KINDS_FILENAME, getBackupKinds());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReportingKinds_matchGoldenFile() {
|
||||
checkKindsMatchGoldenFile("reporting", GOLDEN_REPORTING_KINDS_FILENAME, getReportingKinds());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCrossTldKinds_matchGoldenFile() {
|
||||
checkKindsMatchGoldenFile("crosstld", GOLDEN_CROSSTLD_KINDS_FILENAME, getCrossTldKinds());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReportingKinds_areSubsetOfBackupKinds() {
|
||||
assertThat(getBackupKinds()).containsAtLeastElementsIn(getReportingKinds());
|
||||
}
|
||||
|
||||
private static void checkKindsMatchGoldenFile(
|
||||
String kindsName, String goldenFilename, ImmutableSet<String> actualKinds) {
|
||||
String updateInstructions =
|
||||
String.format(
|
||||
UPDATE_INSTRUCTIONS_TEMPLATE,
|
||||
kindsName,
|
||||
getResource(AnnotatedEntitiesTest.class, goldenFilename).toString(),
|
||||
Joiner.on('\n').join(actualKinds));
|
||||
assertWithMessage(updateInstructions)
|
||||
.that(actualKinds)
|
||||
.containsExactlyElementsIn(extractListFromFile(goldenFilename))
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to extract list from file
|
||||
*
|
||||
* @param filename
|
||||
* @return ImmutableList<String>
|
||||
*/
|
||||
private static ImmutableList<String> extractListFromFile(String filename) {
|
||||
String fileContents = readResourceUtf8(AnnotatedEntitiesTest.class, filename);
|
||||
final Pattern stripComments = Pattern.compile("\\s*#.*$");
|
||||
return Streams.stream(Splitter.on('\n').split(fileContents.trim()))
|
||||
.map(line -> stripComments.matcher(line).replaceFirst(""))
|
||||
.collect(toImmutableList());
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
// Copyright 2018 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.export;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.export.CheckBackupAction.CHECK_BACKUP_KINDS_TO_LOAD_PARAM;
|
||||
import static google.registry.export.CheckBackupAction.CHECK_BACKUP_NAME_PARAM;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.cloud.tasks.v2.HttpMethod;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.protobuf.util.Timestamps;
|
||||
import google.registry.export.datastore.DatastoreAdmin;
|
||||
import google.registry.export.datastore.DatastoreAdmin.Export;
|
||||
import google.registry.export.datastore.Operation;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.CloudTasksHelper;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.FakeClock;
|
||||
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.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link BackupDatastoreAction}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class BackupDatastoreActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withTaskQueue().build();
|
||||
|
||||
@Mock private DatastoreAdmin datastoreAdmin;
|
||||
@Mock private Export exportRequest;
|
||||
@Mock private Operation backupOperation;
|
||||
|
||||
private final FakeResponse response = new FakeResponse();
|
||||
private CloudTasksHelper cloudTasksHelper = new CloudTasksHelper();
|
||||
private final BackupDatastoreAction action = new BackupDatastoreAction();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
action.datastoreAdmin = datastoreAdmin;
|
||||
action.response = response;
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
action.clock = new FakeClock();
|
||||
when(datastoreAdmin.export(
|
||||
"gs://registry-project-id-datastore-backups", AnnotatedEntities.getBackupKinds()))
|
||||
.thenReturn(exportRequest);
|
||||
when(exportRequest.execute()).thenReturn(backupOperation);
|
||||
when(backupOperation.getName())
|
||||
.thenReturn("projects/registry-project-id/operations/ASA1ODYwNjc");
|
||||
when(backupOperation.getExportFolderUrl())
|
||||
.thenReturn("gs://registry-project-id-datastore-backups/some-id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBackup_enqueuesPollTask() {
|
||||
action.run();
|
||||
cloudTasksHelper.assertTasksEnqueued(
|
||||
CheckBackupAction.QUEUE,
|
||||
new TaskMatcher()
|
||||
.url(CheckBackupAction.PATH)
|
||||
.param(CHECK_BACKUP_NAME_PARAM, "projects/registry-project-id/operations/ASA1ODYwNjc")
|
||||
.param(
|
||||
CHECK_BACKUP_KINDS_TO_LOAD_PARAM,
|
||||
Joiner.on(",").join(AnnotatedEntities.getReportingKinds()))
|
||||
.method(HttpMethod.POST)
|
||||
.scheduleTime(
|
||||
Timestamps.fromMillis(
|
||||
action.clock.nowUtc().plus(CheckBackupAction.POLL_COUNTDOWN).getMillis())));
|
||||
assertThat(response.getPayload())
|
||||
.isEqualTo(
|
||||
"Datastore backup started with name: "
|
||||
+ "projects/registry-project-id/operations/ASA1ODYwNjc\n"
|
||||
+ "Saving to gs://registry-project-id-datastore-backups/some-id");
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
// 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.export;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.TestLogHandlerUtils.assertLogMessage;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.SEVERE;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.api.services.bigquery.Bigquery;
|
||||
import com.google.api.services.bigquery.model.ErrorProto;
|
||||
import com.google.api.services.bigquery.model.Job;
|
||||
import com.google.api.services.bigquery.model.JobStatus;
|
||||
import com.google.cloud.tasks.v2.AppEngineHttpRequest;
|
||||
import com.google.cloud.tasks.v2.HttpMethod;
|
||||
import com.google.cloud.tasks.v2.Task;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
import com.google.common.net.MediaType;
|
||||
import com.google.protobuf.ByteString;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.HttpException.NotModifiedException;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.CloudTasksHelper;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.util.CapturingLogHandler;
|
||||
import google.registry.util.JdkLoggerConfig;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link BigqueryPollJobAction}. */
|
||||
public class BigqueryPollJobActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
private static final String PROJECT_ID = "project_id";
|
||||
private static final String JOB_ID = "job_id";
|
||||
private static final String CHAINED_QUEUE_NAME = UpdateSnapshotViewAction.QUEUE;
|
||||
|
||||
private final Bigquery bigquery = mock(Bigquery.class);
|
||||
private final Bigquery.Jobs bigqueryJobs = mock(Bigquery.Jobs.class);
|
||||
private final Bigquery.Jobs.Get bigqueryJobsGet = mock(Bigquery.Jobs.Get.class);
|
||||
|
||||
private final CapturingLogHandler logHandler = new CapturingLogHandler();
|
||||
private BigqueryPollJobAction action = new BigqueryPollJobAction();
|
||||
private CloudTasksHelper cloudTasksHelper = new CloudTasksHelper();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
action.bigquery = bigquery;
|
||||
when(bigquery.jobs()).thenReturn(bigqueryJobs);
|
||||
when(bigqueryJobs.get(PROJECT_ID, JOB_ID)).thenReturn(bigqueryJobsGet);
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
action.projectId = PROJECT_ID;
|
||||
action.jobId = JOB_ID;
|
||||
action.chainedQueueName = () -> CHAINED_QUEUE_NAME;
|
||||
JdkLoggerConfig.getConfig(BigqueryPollJobAction.class).addHandler(logHandler);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_jobCompletedSuccessfully() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(
|
||||
new Job().setStatus(new JobStatus().setState("DONE")));
|
||||
action.run();
|
||||
assertLogMessage(
|
||||
logHandler, INFO, String.format("Bigquery job succeeded - %s:%s", PROJECT_ID, JOB_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_chainedPayloadAndJobSucceeded_enqueuesChainedTask() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(
|
||||
new Job().setStatus(new JobStatus().setState("DONE")));
|
||||
|
||||
Task chainedTask =
|
||||
Task.newBuilder()
|
||||
.setName("my_task_name")
|
||||
.setAppEngineHttpRequest(
|
||||
AppEngineHttpRequest.newBuilder()
|
||||
.setHttpMethod(HttpMethod.POST)
|
||||
.setRelativeUri("/_dr/something")
|
||||
.putHeaders("X-Test", "foo")
|
||||
.putHeaders(HttpHeaders.CONTENT_TYPE, MediaType.FORM_DATA.toString())
|
||||
.setBody(ByteString.copyFromUtf8("testing=bar")))
|
||||
.build();
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
new ObjectOutputStream(bytes).writeObject(chainedTask);
|
||||
action.payload = ByteString.copyFrom(bytes.toByteArray());
|
||||
|
||||
action.run();
|
||||
assertLogMessage(
|
||||
logHandler, INFO, String.format("Bigquery job succeeded - %s:%s", PROJECT_ID, JOB_ID));
|
||||
assertLogMessage(
|
||||
logHandler,
|
||||
INFO,
|
||||
"Added chained task my_task_name for /_dr/something to queue " + CHAINED_QUEUE_NAME);
|
||||
cloudTasksHelper.assertTasksEnqueued(
|
||||
CHAINED_QUEUE_NAME,
|
||||
new TaskMatcher()
|
||||
.url("/_dr/something")
|
||||
.header("X-Test", "foo")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.FORM_DATA.toString())
|
||||
.param("testing", "bar")
|
||||
.taskName("my_task_name")
|
||||
.method(HttpMethod.POST));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJobFailed() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(new Job().setStatus(
|
||||
new JobStatus()
|
||||
.setState("DONE")
|
||||
.setErrorResult(new ErrorProto().setMessage("Job failed"))));
|
||||
action.run();
|
||||
assertLogMessage(
|
||||
logHandler, SEVERE, String.format("Bigquery job failed - %s:%s", PROJECT_ID, JOB_ID));
|
||||
cloudTasksHelper.assertNoTasksEnqueued(CHAINED_QUEUE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJobPending() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(
|
||||
new Job().setStatus(new JobStatus().setState("PENDING")));
|
||||
assertThrows(NotModifiedException.class, action::run);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJobStatusUnreadable() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenThrow(IOException.class);
|
||||
assertThrows(NotModifiedException.class, action::run);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_badChainedTaskPayload() throws Exception {
|
||||
when(bigqueryJobsGet.execute()).thenReturn(
|
||||
new Job().setStatus(new JobStatus().setState("DONE")));
|
||||
action.payload = ByteString.copyFrom("payload".getBytes(UTF_8));
|
||||
BadRequestException thrown = assertThrows(BadRequestException.class, action::run);
|
||||
assertThat(thrown).hasMessageThat().contains("Cannot deserialize task from payload");
|
||||
}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
// Copyright 2018 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.export;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
|
||||
import com.google.api.client.http.HttpHeaders;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.google.cloud.tasks.v2.HttpMethod;
|
||||
import google.registry.export.datastore.DatastoreAdmin;
|
||||
import google.registry.export.datastore.DatastoreAdmin.Get;
|
||||
import google.registry.export.datastore.Operation;
|
||||
import google.registry.request.Action.Method;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.HttpException.NoContentException;
|
||||
import google.registry.request.HttpException.NotModifiedException;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.CloudTasksHelper;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.TestDataHelper;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
/** Unit tests for {@link CheckBackupAction}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class CheckBackupActionTest {
|
||||
|
||||
private static final DateTime START_TIME = DateTime.parse("2014-08-01T01:02:03Z");
|
||||
private static final DateTime COMPLETE_TIME = START_TIME.plus(Duration.standardMinutes(30));
|
||||
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withTaskQueue().build();
|
||||
|
||||
@Mock private DatastoreAdmin datastoreAdmin;
|
||||
@Mock private Get getNotFoundBackupProgressRequest;
|
||||
@Mock private Get getBackupProgressRequest;
|
||||
private Operation backupOperation;
|
||||
|
||||
private final FakeResponse response = new FakeResponse();
|
||||
private final FakeClock clock = new FakeClock(COMPLETE_TIME.plusMillis(1000));
|
||||
private final CheckBackupAction action = new CheckBackupAction();
|
||||
private final CloudTasksHelper cloudTasksHelper = new CloudTasksHelper();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
action.requestMethod = Method.POST;
|
||||
action.datastoreAdmin = datastoreAdmin;
|
||||
action.clock = clock;
|
||||
action.backupName = "some_backup";
|
||||
action.kindsToLoadParam = "one,two";
|
||||
action.response = response;
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
|
||||
when(datastoreAdmin.get(anyString())).thenReturn(getBackupProgressRequest);
|
||||
when(getBackupProgressRequest.execute()).thenAnswer(arg -> backupOperation);
|
||||
}
|
||||
|
||||
private void setPendingBackup() throws Exception {
|
||||
backupOperation =
|
||||
JSON_FACTORY.fromString(
|
||||
TestDataHelper.loadFile(
|
||||
CheckBackupActionTest.class, "backup_operation_in_progress.json"),
|
||||
Operation.class);
|
||||
}
|
||||
|
||||
private void setCompleteBackup() throws Exception {
|
||||
backupOperation =
|
||||
JSON_FACTORY.fromString(
|
||||
TestDataHelper.loadFile(CheckBackupActionTest.class, "backup_operation_success.json"),
|
||||
Operation.class);
|
||||
}
|
||||
|
||||
private void setBackupNotFound() throws Exception {
|
||||
when(datastoreAdmin.get(anyString())).thenReturn(getNotFoundBackupProgressRequest);
|
||||
when(getNotFoundBackupProgressRequest.execute())
|
||||
.thenThrow(
|
||||
new GoogleJsonResponseException(
|
||||
new GoogleJsonResponseException.Builder(404, "NOT_FOUND", new HttpHeaders())
|
||||
.setMessage("No backup found"),
|
||||
null));
|
||||
}
|
||||
|
||||
private void assertLoadTaskEnqueued(String id, String folder, String kinds) {
|
||||
cloudTasksHelper.assertTasksEnqueued(
|
||||
"export-snapshot",
|
||||
new TaskMatcher()
|
||||
.url("/_dr/task/uploadDatastoreBackup")
|
||||
.method(HttpMethod.POST)
|
||||
.param("id", id)
|
||||
.param("folder", folder)
|
||||
.param("kinds", kinds));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPost_forPendingBackup_returnsNotModified() throws Exception {
|
||||
setPendingBackup();
|
||||
|
||||
NotModifiedException thrown = assertThrows(NotModifiedException.class, action::run);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Datastore backup some_backup still in progress: Progress: N/A");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPost_forStalePendingBackupBackup_returnsNoContent() throws Exception {
|
||||
setPendingBackup();
|
||||
clock.setTo(
|
||||
START_TIME
|
||||
.plus(Duration.standardHours(20))
|
||||
.plus(Duration.standardMinutes(3))
|
||||
.plus(Duration.millis(1234)));
|
||||
|
||||
NoContentException thrown = assertThrows(NoContentException.class, action::run);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"Datastore backup some_backup abandoned - "
|
||||
+ "not complete after 20 hours, 3 minutes and 1 second. Progress: Progress: N/A");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPost_forCompleteBackup_enqueuesLoadTask() throws Exception {
|
||||
setCompleteBackup();
|
||||
action.run();
|
||||
assertLoadTaskEnqueued(
|
||||
"2014-08-01T01:02:03_99364",
|
||||
"gs://registry-project-id-datastore-export-test/2014-08-01T01:02:03_99364",
|
||||
"one,two");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPost_forCompleteBackup_withExtraKindsToLoad_enqueuesLoadTask() throws Exception {
|
||||
setCompleteBackup();
|
||||
action.kindsToLoadParam = "one,foo";
|
||||
|
||||
action.run();
|
||||
assertLoadTaskEnqueued(
|
||||
"2014-08-01T01:02:03_99364",
|
||||
"gs://registry-project-id-datastore-export-test/2014-08-01T01:02:03_99364",
|
||||
"one");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPost_forCompleteBackup_withEmptyKindsToLoad_skipsLoadTask() throws Exception {
|
||||
setCompleteBackup();
|
||||
action.kindsToLoadParam = "";
|
||||
|
||||
action.run();
|
||||
cloudTasksHelper.assertNoTasksEnqueued("export-snapshot");
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
void testPost_forBadBackup_returnsBadRequest() throws Exception {
|
||||
setBackupNotFound();
|
||||
|
||||
BadRequestException thrown = assertThrows(BadRequestException.class, action::run);
|
||||
assertThat(thrown).hasMessageThat().contains("Bad backup name some_backup: No backup found");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGet_returnsInformation() throws Exception {
|
||||
setCompleteBackup();
|
||||
action.requestMethod = Method.GET;
|
||||
|
||||
action.run();
|
||||
assertThat(response.getPayload())
|
||||
.isEqualTo(
|
||||
TestDataHelper.loadFile(
|
||||
CheckBackupActionTest.class, "pretty_printed_success_backup_operation.json")
|
||||
.trim());
|
||||
}
|
||||
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@Test
|
||||
void testGet_forBadBackup_returnsError() throws Exception {
|
||||
setBackupNotFound();
|
||||
action.requestMethod = Method.GET;
|
||||
|
||||
BadRequestException thrown = assertThrows(BadRequestException.class, action::run);
|
||||
assertThat(thrown).hasMessageThat().contains("Bad backup name some_backup: No backup found");
|
||||
}
|
||||
}
|
||||
@@ -38,18 +38,16 @@ import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tld.Registry.TldType;
|
||||
import google.registry.storage.drive.DriveConnection;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
/** Unit tests for {@link ExportDomainListsAction}. */
|
||||
@DualDatabaseTest
|
||||
class ExportDomainListsActionTest {
|
||||
|
||||
private final GcsUtils gcsUtils = new GcsUtils(LocalStorageHelper.getOptions());
|
||||
@@ -60,11 +58,7 @@ class ExportDomainListsActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withLocalModules()
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withLocalModules().withTaskQueue().build();
|
||||
|
||||
@Order(Order.DEFAULT - 1)
|
||||
@RegisterExtension
|
||||
@@ -95,7 +89,7 @@ class ExportDomainListsActionTest {
|
||||
assertThat(new String(bytesExportedToDrive.getValue(), UTF_8)).isEqualTo(domains);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_outputsOnlyActiveDomains() throws Exception {
|
||||
persistActiveDomain("onetwo.tld");
|
||||
persistActiveDomain("rudnitzky.tld");
|
||||
@@ -109,7 +103,7 @@ class ExportDomainListsActionTest {
|
||||
verifyNoMoreInteractions(driveConnection);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_outputsOnlyDomainsOnRealTlds() throws Exception {
|
||||
persistActiveDomain("onetwo.tld");
|
||||
persistActiveDomain("rudnitzky.tld");
|
||||
@@ -128,7 +122,7 @@ class ExportDomainListsActionTest {
|
||||
verifyNoMoreInteractions(driveConnection);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_outputsDomainsFromDifferentTldsToMultipleFiles() throws Exception {
|
||||
createTld("tldtwo");
|
||||
persistResource(Registry.get("tldtwo").asBuilder().setDriveFolderId("hooray").build());
|
||||
|
||||
@@ -58,8 +58,7 @@ public class ExportPremiumTermsActionTest {
|
||||
DISCLAIMER_WITH_NEWLINE + "0, 549.00\n" + "2048, 549.00\n";
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
private final DriveConnection driveConnection = mock(DriveConnection.class);
|
||||
private final Response response = mock(Response.class);
|
||||
|
||||
@@ -46,8 +46,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
public class ExportReservedTermsActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
private final DriveConnection driveConnection = mock(DriveConnection.class);
|
||||
private final Response response = mock(Response.class);
|
||||
|
||||
@@ -29,8 +29,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
class ExportUtilsTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@Test
|
||||
void test_exportReservedTerms() {
|
||||
|
||||
@@ -40,13 +40,12 @@ import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeSleeper;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.util.Retrier;
|
||||
import java.io.IOException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/**
|
||||
@@ -55,12 +54,10 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
* <p>Note that this relies on the registrars NewRegistrar and TheRegistrar created by default in
|
||||
* {@link AppEngineExtension}.
|
||||
*/
|
||||
@DualDatabaseTest
|
||||
public class SyncGroupMembersActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@@ -76,7 +73,7 @@ public class SyncGroupMembersActionTest {
|
||||
action.run();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_getGroupEmailAddressForContactType_convertsToLowercase() {
|
||||
assertThat(
|
||||
getGroupEmailAddressForContactType(
|
||||
@@ -84,7 +81,7 @@ public class SyncGroupMembersActionTest {
|
||||
.isEqualTo("someregistrar-primary-contacts@domain-registry.example");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_getGroupEmailAddressForContactType_convertsNonAlphanumericChars() {
|
||||
assertThat(getGroupEmailAddressForContactType(
|
||||
"Weird.ಠ_ಠRegistrar",
|
||||
@@ -93,7 +90,7 @@ public class SyncGroupMembersActionTest {
|
||||
.isEqualTo("weirdregistrar-marketing-contacts@domain-registry.example");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_doPost_noneModified() {
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar").asBuilder().setContactsRequireSyncing(false).build());
|
||||
@@ -106,7 +103,7 @@ public class SyncGroupMembersActionTest {
|
||||
assertThat(loadRegistrar("NewRegistrar").getContactsRequireSyncing()).isFalse();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_doPost_syncsNewContact() throws Exception {
|
||||
runAction();
|
||||
verify(connection).addMemberToGroup(
|
||||
@@ -118,7 +115,7 @@ public class SyncGroupMembersActionTest {
|
||||
assertThat(loadRegistrar("NewRegistrar").getContactsRequireSyncing()).isFalse();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_doPost_removesOldContact() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
|
||||
@@ -129,7 +126,7 @@ public class SyncGroupMembersActionTest {
|
||||
assertThat(loadRegistrar("NewRegistrar").getContactsRequireSyncing()).isFalse();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_doPost_removesAllContactsFromGroup() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
|
||||
@@ -144,7 +141,7 @@ public class SyncGroupMembersActionTest {
|
||||
assertThat(loadRegistrar("NewRegistrar").getContactsRequireSyncing()).isFalse();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_doPost_addsAndRemovesContacts_acrossMultipleRegistrars() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
|
||||
@@ -192,7 +189,7 @@ public class SyncGroupMembersActionTest {
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_doPost_gracefullyHandlesExceptionForSingleRegistrar() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of());
|
||||
@@ -211,7 +208,7 @@ public class SyncGroupMembersActionTest {
|
||||
assertThat(loadRegistrar("TheRegistrar").getContactsRequireSyncing()).isTrue();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_doPost_retriesOnTransientException() throws Exception {
|
||||
doThrow(IOException.class)
|
||||
.doNothing()
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
// 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.export;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.api.services.bigquery.Bigquery;
|
||||
import com.google.api.services.bigquery.model.Dataset;
|
||||
import com.google.api.services.bigquery.model.Table;
|
||||
import com.google.common.collect.Iterables;
|
||||
import google.registry.bigquery.CheckedBigquery;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import java.io.IOException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InOrder;
|
||||
|
||||
/** Unit tests for {@link UpdateSnapshotViewAction}. */
|
||||
public class UpdateSnapshotViewActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withTaskQueue().build();
|
||||
|
||||
private final CheckedBigquery checkedBigquery = mock(CheckedBigquery.class);
|
||||
private final Bigquery bigquery = mock(Bigquery.class);
|
||||
private final Bigquery.Datasets bigqueryDatasets = mock(Bigquery.Datasets.class);
|
||||
private final Bigquery.Datasets.Insert bigqueryDatasetsInsert =
|
||||
mock(Bigquery.Datasets.Insert.class);
|
||||
private final Bigquery.Tables bigqueryTables = mock(Bigquery.Tables.class);
|
||||
private final Bigquery.Tables.Update bigqueryTablesUpdate = mock(Bigquery.Tables.Update.class);
|
||||
|
||||
private UpdateSnapshotViewAction action;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
when(checkedBigquery.ensureDataSetExists(anyString(), anyString())).thenReturn(bigquery);
|
||||
when(bigquery.datasets()).thenReturn(bigqueryDatasets);
|
||||
when(bigqueryDatasets.insert(anyString(), any(Dataset.class)))
|
||||
.thenReturn(bigqueryDatasetsInsert);
|
||||
when(bigquery.tables()).thenReturn(bigqueryTables);
|
||||
when(bigqueryTables.update(anyString(), anyString(), anyString(), any(Table.class)))
|
||||
.thenReturn(bigqueryTablesUpdate);
|
||||
|
||||
action = new UpdateSnapshotViewAction();
|
||||
action.checkedBigquery = checkedBigquery;
|
||||
action.datasetId = "some_dataset";
|
||||
action.kindName = "fookind";
|
||||
action.viewName = "latest_datastore_export";
|
||||
action.projectId = "myproject";
|
||||
action.tableId = "12345_fookind";
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_doPost() throws Exception {
|
||||
action.run();
|
||||
|
||||
InOrder factoryOrder = inOrder(checkedBigquery);
|
||||
// Check that the BigQuery factory was called in such a way that the dataset would be created
|
||||
// if it didn't already exist.
|
||||
factoryOrder
|
||||
.verify(checkedBigquery)
|
||||
.ensureDataSetExists("myproject", "latest_datastore_export");
|
||||
|
||||
// Check that we updated both views
|
||||
InOrder tableOrder = inOrder(bigqueryTables);
|
||||
ArgumentCaptor<Table> tableArg = ArgumentCaptor.forClass(Table.class);
|
||||
tableOrder
|
||||
.verify(bigqueryTables)
|
||||
.update(eq("myproject"), eq("latest_datastore_export"), eq("fookind"), tableArg.capture());
|
||||
Iterable<String> actualQueries =
|
||||
Iterables.transform(tableArg.getAllValues(), table -> table.getView().getQuery());
|
||||
assertThat(actualQueries)
|
||||
.containsExactly("#standardSQL\nSELECT * FROM `myproject.some_dataset.12345_fookind`");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_bigqueryConnectionThrowsError() throws Exception {
|
||||
when(bigqueryTables.update(anyString(), anyString(), anyString(), any(Table.class)))
|
||||
.thenThrow(new IOException("I'm sorry Dave, I can't let you do that"));
|
||||
InternalServerErrorException thrown =
|
||||
assertThrows(InternalServerErrorException.class, action::run);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
"Could not update snapshot view latest_datastore_export for table 12345_fookind");
|
||||
assertThat(thrown).hasCauseThat().hasMessageThat().contains("I'm sorry Dave");
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
// 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.export;
|
||||
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.export.BigqueryPollJobAction.CHAINED_TASK_QUEUE_HEADER;
|
||||
import static google.registry.export.BigqueryPollJobAction.JOB_ID_HEADER;
|
||||
import static google.registry.export.BigqueryPollJobAction.PROJECT_ID_HEADER;
|
||||
import static google.registry.export.UpdateSnapshotViewAction.UPDATE_SNAPSHOT_DATASET_ID_PARAM;
|
||||
import static google.registry.export.UpdateSnapshotViewAction.UPDATE_SNAPSHOT_KIND_PARAM;
|
||||
import static google.registry.export.UpdateSnapshotViewAction.UPDATE_SNAPSHOT_TABLE_ID_PARAM;
|
||||
import static google.registry.export.UpdateSnapshotViewAction.UPDATE_SNAPSHOT_VIEWNAME_PARAM;
|
||||
import static google.registry.export.UploadDatastoreBackupAction.BACKUP_DATASET;
|
||||
import static google.registry.export.UploadDatastoreBackupAction.getBackupInfoFileForKind;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.api.services.bigquery.Bigquery;
|
||||
import com.google.api.services.bigquery.model.Dataset;
|
||||
import com.google.api.services.bigquery.model.Job;
|
||||
import com.google.api.services.bigquery.model.JobConfigurationLoad;
|
||||
import com.google.cloud.tasks.v2.HttpMethod;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.protobuf.util.Timestamps;
|
||||
import google.registry.bigquery.CheckedBigquery;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.CloudTasksHelper;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
/** Unit tests for {@link UploadDatastoreBackupAction}. */
|
||||
public class UploadDatastoreBackupActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withTaskQueue().build();
|
||||
|
||||
private final CheckedBigquery checkedBigquery = mock(CheckedBigquery.class);
|
||||
private final Bigquery bigquery = mock(Bigquery.class);
|
||||
private final Bigquery.Jobs bigqueryJobs = mock(Bigquery.Jobs.class);
|
||||
private final Bigquery.Jobs.Insert bigqueryJobsInsert = mock(Bigquery.Jobs.Insert.class);
|
||||
private final Bigquery.Datasets bigqueryDatasets = mock(Bigquery.Datasets.class);
|
||||
private final Bigquery.Datasets.Insert bigqueryDatasetsInsert =
|
||||
mock(Bigquery.Datasets.Insert.class);
|
||||
private UploadDatastoreBackupAction action;
|
||||
private CloudTasksHelper cloudTasksHelper = new CloudTasksHelper();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
when(checkedBigquery.ensureDataSetExists("Project-Id", BACKUP_DATASET)).thenReturn(bigquery);
|
||||
when(bigquery.jobs()).thenReturn(bigqueryJobs);
|
||||
when(bigqueryJobs.insert(eq("Project-Id"), any(Job.class))).thenReturn(bigqueryJobsInsert);
|
||||
when(bigquery.datasets()).thenReturn(bigqueryDatasets);
|
||||
when(bigqueryDatasets.insert(eq("Project-Id"), any(Dataset.class)))
|
||||
.thenReturn(bigqueryDatasetsInsert);
|
||||
action = new UploadDatastoreBackupAction();
|
||||
action.checkedBigquery = checkedBigquery;
|
||||
action.projectId = "Project-Id";
|
||||
action.backupFolderUrl = "gs://bucket/path";
|
||||
action.backupId = "2018-12-05T17:46:39_92612";
|
||||
action.backupKinds = "one,two,three";
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
action.clock = new FakeClock();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testSuccess_doPost() throws Exception {
|
||||
action.run();
|
||||
|
||||
// Verify that checkedBigquery was called in a way that would create the dataset if it didn't
|
||||
// already exist.
|
||||
verify(checkedBigquery).ensureDataSetExists("Project-Id", BACKUP_DATASET);
|
||||
|
||||
// Capture the load jobs we inserted to do additional checking on them.
|
||||
ArgumentCaptor<Job> jobArgument = ArgumentCaptor.forClass(Job.class);
|
||||
verify(bigqueryJobs, times(3)).insert(eq("Project-Id"), jobArgument.capture());
|
||||
List<Job> jobs = jobArgument.getAllValues();
|
||||
assertThat(jobs).hasSize(3);
|
||||
|
||||
// Check properties that should be common to all load jobs.
|
||||
for (Job job : jobs) {
|
||||
assertThat(job.getJobReference().getProjectId()).isEqualTo("Project-Id");
|
||||
JobConfigurationLoad config = job.getConfiguration().getLoad();
|
||||
assertThat(config.getSourceFormat()).isEqualTo("DATASTORE_BACKUP");
|
||||
assertThat(config.getDestinationTable().getProjectId()).isEqualTo("Project-Id");
|
||||
assertThat(config.getDestinationTable().getDatasetId()).isEqualTo(BACKUP_DATASET);
|
||||
}
|
||||
|
||||
// Check the job IDs for each load job.
|
||||
assertThat(transform(jobs, job -> job.getJobReference().getJobId()))
|
||||
.containsExactly(
|
||||
"load-backup-2018_12_05T17_46_39_92612-one",
|
||||
"load-backup-2018_12_05T17_46_39_92612-two",
|
||||
"load-backup-2018_12_05T17_46_39_92612-three");
|
||||
|
||||
// Check the source URI for each load job.
|
||||
assertThat(
|
||||
transform(
|
||||
jobs,
|
||||
job -> Iterables.getOnlyElement(job.getConfiguration().getLoad().getSourceUris())))
|
||||
.containsExactly(
|
||||
"gs://bucket/path/all_namespaces/kind_one/all_namespaces_kind_one.export_metadata",
|
||||
"gs://bucket/path/all_namespaces/kind_two/all_namespaces_kind_two.export_metadata",
|
||||
"gs://bucket/path/all_namespaces/kind_three/all_namespaces_kind_three.export_metadata");
|
||||
|
||||
// Check the destination table ID for each load job.
|
||||
assertThat(
|
||||
transform(
|
||||
jobs, job -> job.getConfiguration().getLoad().getDestinationTable().getTableId()))
|
||||
.containsExactly(
|
||||
"2018_12_05T17_46_39_92612_one",
|
||||
"2018_12_05T17_46_39_92612_two",
|
||||
"2018_12_05T17_46_39_92612_three");
|
||||
|
||||
// Check that we executed the inserted jobs.
|
||||
verify(bigqueryJobsInsert, times(3)).execute();
|
||||
|
||||
// Check that the poll tasks for each load job were enqueued.
|
||||
cloudTasksHelper.assertTasksEnqueued(
|
||||
BigqueryPollJobAction.QUEUE,
|
||||
new TaskMatcher()
|
||||
.method(HttpMethod.POST)
|
||||
.header(PROJECT_ID_HEADER, "Project-Id")
|
||||
.header(JOB_ID_HEADER, "load-backup-2018_12_05T17_46_39_92612-one")
|
||||
.header(CHAINED_TASK_QUEUE_HEADER, UpdateSnapshotViewAction.QUEUE)
|
||||
.scheduleTime(
|
||||
Timestamps.fromMillis(
|
||||
action.clock.nowUtc().plus(BigqueryPollJobAction.POLL_COUNTDOWN).getMillis())),
|
||||
new TaskMatcher()
|
||||
.method(HttpMethod.POST)
|
||||
.header(PROJECT_ID_HEADER, "Project-Id")
|
||||
.header(JOB_ID_HEADER, "load-backup-2018_12_05T17_46_39_92612-two")
|
||||
.header(CHAINED_TASK_QUEUE_HEADER, UpdateSnapshotViewAction.QUEUE)
|
||||
.scheduleTime(
|
||||
Timestamps.fromMillis(
|
||||
action.clock.nowUtc().plus(BigqueryPollJobAction.POLL_COUNTDOWN).getMillis())),
|
||||
new TaskMatcher()
|
||||
.method(HttpMethod.POST)
|
||||
.header(PROJECT_ID_HEADER, "Project-Id")
|
||||
.header(JOB_ID_HEADER, "load-backup-2018_12_05T17_46_39_92612-three")
|
||||
.header(CHAINED_TASK_QUEUE_HEADER, UpdateSnapshotViewAction.QUEUE)
|
||||
.scheduleTime(
|
||||
Timestamps.fromMillis(
|
||||
action.clock.nowUtc().plus(BigqueryPollJobAction.POLL_COUNTDOWN).getMillis())));
|
||||
|
||||
// assert the chained task of each enqueud task is correct
|
||||
assertThat(
|
||||
cloudTasksHelper.getTestTasksFor(BigqueryPollJobAction.QUEUE).stream()
|
||||
.map(
|
||||
testTask -> {
|
||||
try {
|
||||
return new ObjectInputStream(
|
||||
new ByteArrayInputStream(
|
||||
testTask.getAppEngineHttpRequest().getBody().toByteArray()))
|
||||
.readObject();
|
||||
} catch (ClassNotFoundException | IOException e) {
|
||||
return null;
|
||||
}
|
||||
}))
|
||||
.containsExactly(
|
||||
cloudTasksHelper
|
||||
.getTestCloudTasksUtils()
|
||||
.createPostTask(
|
||||
UpdateSnapshotViewAction.PATH,
|
||||
"BACKEND",
|
||||
ImmutableMultimap.of(
|
||||
UPDATE_SNAPSHOT_DATASET_ID_PARAM,
|
||||
"datastore_backups",
|
||||
UPDATE_SNAPSHOT_TABLE_ID_PARAM,
|
||||
"2018_12_05T17_46_39_92612_one",
|
||||
UPDATE_SNAPSHOT_KIND_PARAM,
|
||||
"one",
|
||||
UPDATE_SNAPSHOT_VIEWNAME_PARAM,
|
||||
"latest_datastore_export")),
|
||||
cloudTasksHelper
|
||||
.getTestCloudTasksUtils()
|
||||
.createPostTask(
|
||||
UpdateSnapshotViewAction.PATH,
|
||||
"BACKEND",
|
||||
ImmutableMultimap.of(
|
||||
UPDATE_SNAPSHOT_DATASET_ID_PARAM,
|
||||
"datastore_backups",
|
||||
UPDATE_SNAPSHOT_TABLE_ID_PARAM,
|
||||
"2018_12_05T17_46_39_92612_two",
|
||||
UPDATE_SNAPSHOT_KIND_PARAM,
|
||||
"two",
|
||||
UPDATE_SNAPSHOT_VIEWNAME_PARAM,
|
||||
"latest_datastore_export")),
|
||||
cloudTasksHelper
|
||||
.getTestCloudTasksUtils()
|
||||
.createPostTask(
|
||||
UpdateSnapshotViewAction.PATH,
|
||||
"BACKEND",
|
||||
ImmutableMultimap.of(
|
||||
UPDATE_SNAPSHOT_DATASET_ID_PARAM,
|
||||
"datastore_backups",
|
||||
UPDATE_SNAPSHOT_TABLE_ID_PARAM,
|
||||
"2018_12_05T17_46_39_92612_three",
|
||||
UPDATE_SNAPSHOT_KIND_PARAM,
|
||||
"three",
|
||||
UPDATE_SNAPSHOT_VIEWNAME_PARAM,
|
||||
"latest_datastore_export")))
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_doPost_bigqueryThrowsException() throws Exception {
|
||||
when(bigqueryJobsInsert.execute()).thenThrow(new IOException("The Internet has gone missing"));
|
||||
InternalServerErrorException thrown =
|
||||
assertThrows(InternalServerErrorException.class, action::run);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Error loading backup: The Internet has gone missing");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testgetBackupInfoFileForKind() {
|
||||
assertThat(
|
||||
getBackupInfoFileForKind(
|
||||
"gs://BucketName/2018-11-11T00:00:00_12345", "AllocationToken"))
|
||||
.isEqualTo(
|
||||
"gs://BucketName/2018-11-11T00:00:00_12345/"
|
||||
+ "all_namespaces/kind_AllocationToken/"
|
||||
+ "all_namespaces_kind_AllocationToken.export_metadata");
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
// Copyright 2018 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.export.datastore;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
|
||||
import com.google.api.client.http.GenericUrl;
|
||||
import com.google.api.client.http.HttpRequest;
|
||||
import com.google.auth.oauth2.AccessToken;
|
||||
import com.google.auth.oauth2.GoogleCredentials;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.testing.TestDataHelper;
|
||||
import google.registry.util.GoogleCredentialsBundle;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
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 DatastoreAdmin}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DatastoreAdminTest {
|
||||
|
||||
private static final String AUTH_HEADER_PREFIX = "Bearer ";
|
||||
private static final String ACCESS_TOKEN = "MyAccessToken";
|
||||
private static final ImmutableList<String> KINDS =
|
||||
ImmutableList.of("Registry", "Registrar", "DomainBase");
|
||||
|
||||
private DatastoreAdmin datastoreAdmin;
|
||||
|
||||
private static HttpRequest simulateSendRequest(HttpRequest httpRequest) {
|
||||
try {
|
||||
httpRequest.setUrl(new GenericUrl("https://localhost:65537")).execute();
|
||||
} catch (Exception expected) {
|
||||
}
|
||||
return httpRequest;
|
||||
}
|
||||
|
||||
private static Optional<String> getAccessToken(HttpRequest httpRequest) {
|
||||
return httpRequest.getHeaders().getAuthorizationAsList().stream()
|
||||
.filter(header -> header.startsWith(AUTH_HEADER_PREFIX))
|
||||
.map(header -> header.substring(AUTH_HEADER_PREFIX.length()))
|
||||
.findAny();
|
||||
}
|
||||
|
||||
private static Optional<String> getRequestContent(HttpRequest httpRequest) throws IOException {
|
||||
if (httpRequest.getContent() == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
httpRequest.getContent().writeTo(outputStream);
|
||||
outputStream.close();
|
||||
return Optional.of(outputStream.toString(StandardCharsets.UTF_8.name()));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Date oneHourLater = new Date(System.currentTimeMillis() + 3_600_000);
|
||||
GoogleCredentials googleCredentials = GoogleCredentials
|
||||
.create(new AccessToken(ACCESS_TOKEN, oneHourLater));
|
||||
GoogleCredentialsBundle credentialsBundle = GoogleCredentialsBundle.create(googleCredentials);
|
||||
datastoreAdmin =
|
||||
new DatastoreAdmin.Builder(
|
||||
credentialsBundle.getHttpTransport(),
|
||||
credentialsBundle.getJsonFactory(),
|
||||
credentialsBundle.getHttpRequestInitializer())
|
||||
.setApplicationName("MyApplication")
|
||||
.setProjectId("MyCloudProject")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExport() throws IOException {
|
||||
DatastoreAdmin.Export export = datastoreAdmin.export("gs://mybucket/path", KINDS);
|
||||
HttpRequest httpRequest = export.buildHttpRequest();
|
||||
assertThat(httpRequest.getUrl().toString())
|
||||
.isEqualTo("https://datastore.googleapis.com/v1/projects/MyCloudProject:export");
|
||||
assertThat(httpRequest.getRequestMethod()).isEqualTo("POST");
|
||||
|
||||
assertThat(getRequestContent(httpRequest))
|
||||
.hasValue(
|
||||
TestDataHelper.loadFile(getClass(), "export_request_content.json")
|
||||
.replaceAll("[\\s\\n]+", ""));
|
||||
|
||||
simulateSendRequest(httpRequest);
|
||||
assertThat(getAccessToken(httpRequest)).hasValue(ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetOperation() throws IOException {
|
||||
DatastoreAdmin.Get get =
|
||||
datastoreAdmin.get("projects/MyCloudProject/operations/ASAzNjMwOTEyNjUJ");
|
||||
HttpRequest httpRequest = get.buildHttpRequest();
|
||||
assertThat(httpRequest.getUrl().toString())
|
||||
.isEqualTo(
|
||||
"https://datastore.googleapis.com/v1/projects/MyCloudProject/operations/ASAzNjMwOTEyNjUJ");
|
||||
assertThat(httpRequest.getRequestMethod()).isEqualTo("GET");
|
||||
assertThat(httpRequest.getContent()).isNull();
|
||||
|
||||
simulateSendRequest(httpRequest);
|
||||
assertThat(getAccessToken(httpRequest)).hasValue(ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testListOperations_all() throws IOException {
|
||||
DatastoreAdmin.ListOperations listOperations = datastoreAdmin.listAll();
|
||||
HttpRequest httpRequest = listOperations.buildHttpRequest();
|
||||
assertThat(httpRequest.getUrl().toString())
|
||||
.isEqualTo("https://datastore.googleapis.com/v1/projects/MyCloudProject/operations");
|
||||
assertThat(httpRequest.getRequestMethod()).isEqualTo("GET");
|
||||
assertThat(httpRequest.getContent()).isNull();
|
||||
|
||||
simulateSendRequest(httpRequest);
|
||||
assertThat(getAccessToken(httpRequest)).hasValue(ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testListOperations_filterByStartTime() throws IOException {
|
||||
DatastoreAdmin.ListOperations listOperations =
|
||||
datastoreAdmin.list("metadata.common.startTime>\"2018-10-31T00:00:00.0Z\"");
|
||||
HttpRequest httpRequest = listOperations.buildHttpRequest();
|
||||
assertThat(httpRequest.getUrl().toString())
|
||||
.isEqualTo(
|
||||
"https://datastore.googleapis.com/v1/projects/MyCloudProject/operations"
|
||||
+ "?filter=metadata.common.startTime%3E%222018-10-31T00:00:00.0Z%22");
|
||||
assertThat(httpRequest.getRequestMethod()).isEqualTo("GET");
|
||||
assertThat(httpRequest.getContent()).isNull();
|
||||
|
||||
simulateSendRequest(httpRequest);
|
||||
assertThat(getAccessToken(httpRequest)).hasValue(ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testListOperations_filterByState() throws IOException {
|
||||
// TODO(weiminyu): consider adding a method to DatastoreAdmin to support query by state.
|
||||
DatastoreAdmin.ListOperations listOperations =
|
||||
datastoreAdmin.list("metadata.common.state=PROCESSING");
|
||||
HttpRequest httpRequest = listOperations.buildHttpRequest();
|
||||
assertThat(httpRequest.getUrl().toString())
|
||||
.isEqualTo(
|
||||
"https://datastore.googleapis.com/v1/projects/MyCloudProject/operations"
|
||||
+ "?filter=metadata.common.state%3DPROCESSING");
|
||||
assertThat(httpRequest.getRequestMethod()).isEqualTo("GET");
|
||||
assertThat(httpRequest.getContent()).isNull();
|
||||
|
||||
simulateSendRequest(httpRequest);
|
||||
assertThat(getAccessToken(httpRequest)).hasValue(ACCESS_TOKEN);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2018 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.export.datastore;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.testing.TestDataHelper;
|
||||
import java.io.IOException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for the instantiation, marshalling and unmarshalling of {@link EntityFilter}. */
|
||||
class EntityFilterTest {
|
||||
|
||||
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
|
||||
|
||||
@Test
|
||||
void testEntityFilter_create_nullKinds() {
|
||||
assertThrows(NullPointerException.class, () -> new EntityFilter(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEntityFilter_marshall() throws IOException {
|
||||
EntityFilter entityFilter =
|
||||
new EntityFilter(ImmutableList.of("Registry", "Registrar", "DomainBase"));
|
||||
assertThat(JSON_FACTORY.toString(entityFilter))
|
||||
.isEqualTo(loadJsonString("entity_filter.json").replaceAll("[\\s\\n]+", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEntityFilter_unmarshall() throws IOException {
|
||||
EntityFilter entityFilter = loadJson("entity_filter.json", EntityFilter.class);
|
||||
assertThat(entityFilter.getKinds())
|
||||
.containsExactly("Registry", "Registrar", "DomainBase")
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEntityFilter_unmarshall_noKinds() throws IOException {
|
||||
EntityFilter entityFilter = JSON_FACTORY.fromString("{}", EntityFilter.class);
|
||||
assertThat(entityFilter.getKinds()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEntityFilter_unmarshall_emptyKinds() throws IOException {
|
||||
EntityFilter entityFilter = JSON_FACTORY.fromString("{ \"kinds\" : [] }", EntityFilter.class);
|
||||
assertThat(entityFilter.getKinds()).isEmpty();
|
||||
}
|
||||
|
||||
private static <T> T loadJson(String fileName, Class<T> type) throws IOException {
|
||||
return JSON_FACTORY.fromString(loadJsonString(fileName), type);
|
||||
}
|
||||
|
||||
private static String loadJsonString(String fileName) {
|
||||
return TestDataHelper.loadFile(EntityFilterTest.class, fileName);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
// Copyright 2018 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.export.datastore;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import google.registry.export.datastore.Operation.CommonMetadata;
|
||||
import google.registry.export.datastore.Operation.Metadata;
|
||||
import google.registry.export.datastore.Operation.Progress;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.TestDataHelper;
|
||||
import java.io.IOException;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for unmarshalling {@link Operation} and its member types. */
|
||||
class OperationTest {
|
||||
|
||||
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
|
||||
|
||||
@Test
|
||||
void testCommonMetadata_unmarshall() throws IOException {
|
||||
CommonMetadata commonMetadata = loadJson("common_metadata.json", CommonMetadata.class);
|
||||
assertThat(commonMetadata.getState()).isEqualTo("SUCCESSFUL");
|
||||
assertThat(commonMetadata.getOperationType()).isEqualTo("EXPORT_ENTITIES");
|
||||
assertThat(commonMetadata.getStartTime())
|
||||
.isEqualTo(DateTime.parse("2018-10-29T16:01:04.645299Z"));
|
||||
assertThat(commonMetadata.getEndTime()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProgress_unmarshall() throws IOException {
|
||||
Progress progress = loadJson("progress.json", Progress.class);
|
||||
assertThat(progress.getWorkCompleted()).isEqualTo(51797);
|
||||
assertThat(progress.getWorkEstimated()).isEqualTo(54513);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMetadata_unmarshall() throws IOException {
|
||||
Metadata metadata = loadJson("metadata.json", Metadata.class);
|
||||
assertThat(metadata.getCommonMetadata().getOperationType()).isEqualTo("EXPORT_ENTITIES");
|
||||
assertThat(metadata.getCommonMetadata().getState()).isEqualTo("SUCCESSFUL");
|
||||
assertThat(metadata.getCommonMetadata().getStartTime())
|
||||
.isEqualTo(DateTime.parse("2018-10-29T16:01:04.645299Z"));
|
||||
assertThat(metadata.getCommonMetadata().getEndTime())
|
||||
.hasValue(DateTime.parse("2018-10-29T16:02:19.009859Z"));
|
||||
assertThat(metadata.getOutputUrlPrefix())
|
||||
.isEqualTo("gs://domain-registry-alpha-datastore-export-test/2018-10-29T16:01:04_99364");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOperation_unmarshall() throws IOException {
|
||||
Operation operation = loadJson("operation.json", Operation.class);
|
||||
assertThat(operation.getName())
|
||||
.startsWith("projects/domain-registry-alpha/operations/ASAzNjMwOTEyNjUJ");
|
||||
assertThat(operation.isProcessing()).isTrue();
|
||||
assertThat(operation.isSuccessful()).isFalse();
|
||||
assertThat(operation.isDone()).isFalse();
|
||||
assertThat(operation.getStartTime()).isEqualTo(DateTime.parse("2018-10-29T16:01:04.645299Z"));
|
||||
assertThat(operation.getExportFolderUrl())
|
||||
.isEqualTo("gs://domain-registry-alpha-datastore-export-test/2018-10-29T16:01:04_99364");
|
||||
assertThat(operation.getExportId()).isEqualTo("2018-10-29T16:01:04_99364");
|
||||
assertThat(operation.getKinds()).containsExactly("Registry", "Registrar", "DomainBase");
|
||||
assertThat(operation.toPrettyString())
|
||||
.isEqualTo(
|
||||
TestDataHelper.loadFile(OperationTest.class, "prettyprinted_operation.json").trim());
|
||||
assertThat(operation.getProgress()).isEqualTo("Progress: N/A");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOperationList_unmarshall() throws IOException {
|
||||
Operation.OperationList operationList =
|
||||
loadJson("operation_list.json", Operation.OperationList.class);
|
||||
assertThat(operationList.toList()).hasSize(2);
|
||||
FakeClock clock = new FakeClock(DateTime.parse("2018-10-29T16:01:04.645299Z"));
|
||||
clock.advanceOneMilli();
|
||||
assertThat(operationList.toList().get(0).getRunningTime(clock)).isEqualTo(Duration.millis(1));
|
||||
assertThat(operationList.toList().get(0).getProgress())
|
||||
.isEqualTo("Progress: [51797/54513 entities]");
|
||||
assertThat(operationList.toList().get(1).getRunningTime(clock))
|
||||
.isEqualTo(Duration.standardMinutes(1));
|
||||
// Work completed may exceed work estimated
|
||||
assertThat(operationList.toList().get(1).getProgress())
|
||||
.isEqualTo("Progress: [96908367/73773755 bytes] [51797/54513 entities]");
|
||||
}
|
||||
|
||||
private static <T> T loadJson(String fileName, Class<T> type) throws IOException {
|
||||
return JSON_FACTORY.fromString(TestDataHelper.loadFile(OperationTest.class, fileName), type);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class SyncRegistrarsSheetActionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
private final FakeResponse response = new FakeResponse();
|
||||
private final SyncRegistrarsSheet syncRegistrarsSheet = mock(SyncRegistrarsSheet.class);
|
||||
|
||||
@@ -41,12 +41,11 @@ import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -56,12 +55,10 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link SyncRegistrarsSheet}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@DualDatabaseTest
|
||||
public class SyncRegistrarsSheetTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@@ -91,12 +88,12 @@ public class SyncRegistrarsSheetTest {
|
||||
Registrar.loadAll().forEach(DatabaseHelper::deleteResource);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_wereRegistrarsModified_noRegistrars_returnsFalse() {
|
||||
assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isFalse();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_wereRegistrarsModified_atDifferentCursorTimes() {
|
||||
persistNewRegistrar("SomeRegistrar", "Some Registrar Inc.", Registrar.Type.REAL, 8L);
|
||||
persistResource(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.nowUtc().minusHours(1)));
|
||||
@@ -105,7 +102,7 @@ public class SyncRegistrarsSheetTest {
|
||||
assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isFalse();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testRun() throws Exception {
|
||||
persistResource(
|
||||
new Registrar.Builder()
|
||||
@@ -333,7 +330,7 @@ public class SyncRegistrarsSheetTest {
|
||||
assertThat(cursor.getCursorTime()).isGreaterThan(registrarCreationTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testRun_missingValues_stillWorks() throws Exception {
|
||||
persistResource(
|
||||
persistNewRegistrar("SomeRegistrar", "Some Registrar", Registrar.Type.REAL, 8L)
|
||||
|
||||
@@ -55,8 +55,7 @@ class CheckApiActionTest {
|
||||
private static final DateTime START_TIME = DateTime.parse("2000-01-01T00:00:00.0Z");
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@Mock private CheckApiMetrics checkApiMetrics;
|
||||
@Captor private ArgumentCaptor<CheckApiMetric> metricCaptor;
|
||||
|
||||
@@ -67,8 +67,7 @@ import org.mockito.quality.Strictness;
|
||||
class EppControllerTest {
|
||||
|
||||
@RegisterExtension
|
||||
AppEngineExtension appEngineExtension =
|
||||
new AppEngineExtension.Builder().withDatastoreAndCloudSql().build();
|
||||
AppEngineExtension appEngineExtension = new AppEngineExtension.Builder().withCloudSql().build();
|
||||
|
||||
@Mock SessionMetadata sessionMetadata;
|
||||
@Mock TransportCredentials transportCredentials;
|
||||
|
||||
@@ -21,23 +21,17 @@ import static google.registry.testing.EppMetricSubject.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for contact lifecycle. */
|
||||
@DualDatabaseTest
|
||||
class EppLifecycleContactTest extends EppTestCase {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withClock(clock)
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testContactLifecycle() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_sh8013.xml")
|
||||
@@ -73,7 +67,7 @@ class EppLifecycleContactTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testContactTransferPollMessage() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_sh8013.xml")
|
||||
|
||||
@@ -47,15 +47,13 @@ import google.registry.model.reporting.HistoryEntry.Type;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tld.Registry.TldState;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for domain lifecycle. */
|
||||
@DualDatabaseTest
|
||||
class EppLifecycleDomainTest extends EppTestCase {
|
||||
|
||||
private static final ImmutableMap<String, String> DEFAULT_TRANSFER_RESPONSE_PARMS =
|
||||
@@ -66,18 +64,14 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withClock(clock)
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTlds("example", "tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainDeleteRestore() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
@@ -137,7 +131,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainDeleteRestore_duringAutorenewGracePeriod() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
@@ -211,7 +205,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainDeleteRestore_duringRenewalGracePeriod() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
@@ -293,7 +287,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainDelete_duringAddAndRenewalGracePeriod_deletesImmediately() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
@@ -388,7 +382,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainDeletion_withinAddGracePeriod_deletesImmediately() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
@@ -444,7 +438,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainDeletion_outsideAddGracePeriod_showsRedemptionPeriod() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
@@ -506,7 +500,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
.isEqualTo(createTime.plusYears(2));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testEapDomainDeletion_withinAddGracePeriod_eapFeeIsNotRefunded() throws Exception {
|
||||
assertThatCommand("login_valid_fee_extension.xml").hasSuccessfulLogin();
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
@@ -571,7 +565,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainDeletionWithSubordinateHost_fails() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
@@ -584,7 +578,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDeletionOfDomain_afterRenameOfSubordinateHost_succeeds() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThat(getRecordedEppMetric())
|
||||
@@ -639,7 +633,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
.hasStatus(SUCCESS_AND_CLOSE);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDeletionOfDomain_afterUpdateThatCreatesSubordinateHost_fails() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
@@ -682,7 +676,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainCreation_failsBeforeSunrise() throws Exception {
|
||||
DateTime sunriseDate = DateTime.parse("2000-05-30T00:00:00Z");
|
||||
createTld(
|
||||
@@ -716,7 +710,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainCheckFee_succeeds() throws Exception {
|
||||
DateTime gaDate = DateTime.parse("2000-05-30T00:00:00Z");
|
||||
createTld(
|
||||
@@ -742,7 +736,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainCreate_annualAutoRenewPollMessages_haveUniqueIds() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
// Create the domain.
|
||||
@@ -792,7 +786,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainTransferPollMessage_serverApproved() throws Exception {
|
||||
// As the losing registrar, create the domain.
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
@@ -846,7 +840,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testTransfer_autoRenewGraceActive_onlyAtAutomaticTransferTime_getsSubsumed()
|
||||
throws Exception {
|
||||
// Register the domain as the first registrar.
|
||||
@@ -884,7 +878,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNameserversTransferWithDomain_successfully() throws Exception {
|
||||
// Log in as the first registrar and set up domains with hosts.
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
@@ -921,7 +915,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testRenewalFails_whenTotalTermExceeds10Years() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
// Creates domain with 2 year expiration.
|
||||
@@ -935,7 +929,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainDeletionCancelsPendingTransfer() throws Exception {
|
||||
// Register the domain as the first registrar.
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
@@ -973,7 +967,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainTransfer_subordinateHost_showsChangeInTransferQuery() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
@@ -1009,7 +1003,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
* to be subordinate to a different domain, that the host retains the transfer time of the first
|
||||
* superordinate domain, not whatever the transfer time from the second domain is.
|
||||
*/
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_lastTransferTime_superordinateDomainTransferFollowedByHostUpdate()
|
||||
throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
@@ -1063,7 +1057,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
* Tests that when a superordinate domain of a host is transferred, and then the host is updated
|
||||
* to be external, that the host retains the transfer time of the first superordinate domain.
|
||||
*/
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_lastTransferTime_superordinateDomainTransferThenHostUpdateToExternal()
|
||||
throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
@@ -1106,7 +1100,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_multipartTldsWithSharedSuffixes() throws Exception {
|
||||
createTlds("bar.foo.tld", "foo.tld");
|
||||
|
||||
@@ -1150,7 +1144,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_multipartTldsWithSharedPrefixes() throws Exception {
|
||||
createTld("tld.foo");
|
||||
|
||||
@@ -1189,7 +1183,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
* during start-date sunrise - which we can then delete "as normal" (no need for a signed mark or
|
||||
* anything for delete), and then use "regular" create during general-availability.
|
||||
*/
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainCreation_startDateSunriseFull() throws Exception {
|
||||
// The signed mark is valid between 2013 and 2017
|
||||
DateTime sunriseDate = DateTime.parse("2014-09-08T09:09:09Z");
|
||||
@@ -1285,7 +1279,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
}
|
||||
|
||||
/** Test that missing type= argument on launch create works in start-date sunrise. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainCreation_startDateSunrise_noType() throws Exception {
|
||||
// The signed mark is valid between 2013 and 2017
|
||||
DateTime sunriseDate = DateTime.parse("2014-09-08T09:09:09Z");
|
||||
@@ -1334,7 +1328,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainTransfer_duringAutorenewGrace() throws Exception {
|
||||
// Creation date of fakesite: 2000-06-01T00:04:00.0Z
|
||||
// Expiration date: 2002-06-01T00:04:00.0Z
|
||||
@@ -1420,7 +1414,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"EXDATE", "2003-06-01T00:04:00Z"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainTransfer_queryForServerApproved() throws Exception {
|
||||
// Creation date of fakesite: 2000-06-01T00:04:00.0Z
|
||||
// Expiration date: 2002-06-01T00:04:00.0Z
|
||||
@@ -1450,7 +1444,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
.hasResponse("domain_transfer_query_response_completed_fakesite.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDomainUpdateBySuperuser_sendsPollMessage() throws Exception {
|
||||
setIsSuperuser(false);
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
||||
@@ -26,24 +26,18 @@ import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for host lifecycle. */
|
||||
@DualDatabaseTest
|
||||
class EppLifecycleHostTest extends EppTestCase {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withClock(clock)
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLifecycle() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("hello.xml")
|
||||
@@ -91,7 +85,7 @@ class EppLifecycleHostTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testRenamingHostToExistingHost_fails() throws Exception {
|
||||
createTld("example");
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
@@ -141,7 +135,7 @@ class EppLifecycleHostTest extends EppTestCase {
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_multipartTldsWithSharedSuffixes() throws Exception {
|
||||
createTlds("bar.foo.tld", "foo.tld", "tld");
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class EppLifecycleLoginTest extends EppTestCase {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||
|
||||
@Test
|
||||
void testLoginAndLogout_recordsEppMetric() throws Exception {
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
class EppLoggedOutTest extends EppTestCase {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@Test
|
||||
void testHello() throws Exception {
|
||||
|
||||
@@ -44,8 +44,7 @@ import org.testcontainers.shaded.org.bouncycastle.util.io.pem.PemWriter;
|
||||
class EppLoginTlsTest extends EppTestCase {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@RegisterExtension
|
||||
@Order(value = Integer.MAX_VALUE)
|
||||
|
||||
@@ -34,29 +34,23 @@ import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.EppLoader;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeHttpSession;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Test that we can reload EPP resources as they were in the past. */
|
||||
@DualDatabaseTest
|
||||
class EppPointInTimeTest {
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withClock(clock)
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||
|
||||
@RegisterExtension final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@@ -91,7 +85,7 @@ class EppPointInTimeTest {
|
||||
.run(EppMetric.builder());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadAtPointInTime() throws Exception {
|
||||
clock.setTo(DateTime.parse("1984-12-18T12:30Z")); // not midnight
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
class EppXxeAttackTest extends EppTestCase {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@Test
|
||||
void testRemoteXmlExternalEntity() throws Exception {
|
||||
|
||||
@@ -45,8 +45,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
class ExtensionManagerTest {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@Test
|
||||
void testDuplicateExtensionsForbidden() {
|
||||
|
||||
@@ -52,7 +52,7 @@ class FlowRunnerTest {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngineExtension =
|
||||
new AppEngineExtension.Builder().withDatastoreAndCloudSql().build();
|
||||
new AppEngineExtension.Builder().withCloudSql().build();
|
||||
|
||||
private final FlowRunner flowRunner = new FlowRunner();
|
||||
private final EppMetric.Builder eppMetricBuilder = EppMetric.builderForRequest(new FakeClock());
|
||||
|
||||
@@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.model.eppcommon.EppXmlTransformer.marshal;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.testing.DatabaseHelper.stripBillingEventId;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
@@ -69,7 +68,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
*/
|
||||
public abstract class FlowTestCase<F extends Flow> {
|
||||
|
||||
/** Whether to actually write to Datastore or just simulate. */
|
||||
/** Whether to actually write to the database or just simulate. */
|
||||
public enum CommitMode {
|
||||
LIVE,
|
||||
DRY_RUN
|
||||
@@ -99,11 +98,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withClock(clock)
|
||||
.withDatastoreAndCloudSql()
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withClock(clock).withCloudSql().withTaskQueue().build();
|
||||
|
||||
@BeforeEach
|
||||
public void beforeEachFlowTestCase() {
|
||||
@@ -202,12 +197,12 @@ public abstract class FlowTestCase<F extends Flow> {
|
||||
assertWithMessage("Billing event is present for grace period: " + gracePeriod)
|
||||
.that(gracePeriod.hasBillingEvent())
|
||||
.isTrue();
|
||||
return transactIfJpaTm(
|
||||
() ->
|
||||
tm().loadByKey(
|
||||
firstNonNull(
|
||||
gracePeriod.getOneTimeBillingEvent(),
|
||||
gracePeriod.getRecurringBillingEvent())));
|
||||
return tm().transact(
|
||||
() ->
|
||||
tm().loadByKey(
|
||||
firstNonNull(
|
||||
gracePeriod.getOneTimeBillingEvent(),
|
||||
gracePeriod.getRecurringBillingEvent())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ import static google.registry.batch.AsyncTaskEnqueuer.PARAM_RESOURCE_KEY;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.testing.LogsSubject.assertAboutLogs;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||
|
||||
@@ -87,7 +86,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
||||
tm().clearSessionCache();
|
||||
@SuppressWarnings("unchecked")
|
||||
T refreshedResource =
|
||||
(T) transactIfJpaTm(() -> tm().loadByEntity(resource)).cloneProjectedAtTime(now);
|
||||
(T) tm().transact(() -> tm().loadByEntity(resource)).cloneProjectedAtTime(now);
|
||||
return refreshedResource;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
final class TlsCredentialsTest {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
protected final FakeClock clock = new FakeClock();
|
||||
|
||||
|
||||
@@ -25,25 +25,23 @@ import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.flows.ResourceCheckFlowTestCase;
|
||||
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactCheckFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactCheckFlowTest extends ResourceCheckFlowTestCase<ContactCheckFlow, ContactResource> {
|
||||
|
||||
ContactCheckFlowTest() {
|
||||
setEppInput("contact_check.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNothingExists() throws Exception {
|
||||
// These ids come from the check xml.
|
||||
doCheckTest(
|
||||
@@ -52,7 +50,7 @@ class ContactCheckFlowTest extends ResourceCheckFlowTestCase<ContactCheckFlow, C
|
||||
create(true, "8013sah", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testOneExists() throws Exception {
|
||||
persistActiveContact("sh8013");
|
||||
// These ids come from the check xml.
|
||||
@@ -62,7 +60,7 @@ class ContactCheckFlowTest extends ResourceCheckFlowTestCase<ContactCheckFlow, C
|
||||
create(true, "8013sah", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testOneExistsButWasDeleted() throws Exception {
|
||||
persistDeletedContact("sh8013", clock.nowUtc().minusDays(1));
|
||||
// These ids come from the check xml.
|
||||
@@ -72,27 +70,27 @@ class ContactCheckFlowTest extends ResourceCheckFlowTestCase<ContactCheckFlow, C
|
||||
create(true, "8013sah", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testXmlMatches() throws Exception {
|
||||
persistActiveContact("sah8013");
|
||||
runFlowAssertResponse(loadFile("contact_check_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test50IdsAllowed() throws Exception {
|
||||
// Make sure we don't have a regression that reduces the number of allowed checks.
|
||||
setEppInput("contact_check_50.xml");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testTooManyIds() {
|
||||
setEppInput("contact_check_51.xml");
|
||||
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-cont-check");
|
||||
|
||||
@@ -32,12 +32,10 @@ import google.registry.flows.contact.ContactFlowUtils.DeclineContactDisclosureFi
|
||||
import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientException;
|
||||
import google.registry.flows.exceptions.ResourceCreateContentionException;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactCreateFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, ContactResource> {
|
||||
|
||||
ContactCreateFlowTest() {
|
||||
@@ -55,31 +53,31 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
|
||||
assertLastHistoryContainsResource(contact);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
dryRunFlowAssertResponse(loadFile("contact_create_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_neverExisted() throws Exception {
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_existedButWasDeleted() throws Exception {
|
||||
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
clock.advanceOneMilli();
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_alreadyExists() throws Exception {
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
ResourceAlreadyExistsForThisClientException thrown =
|
||||
@@ -91,7 +89,7 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_resourceContention() throws Exception {
|
||||
String targetId = getUniqueIdFromCommand();
|
||||
persistResource(
|
||||
@@ -107,13 +105,13 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nonAsciiInLocAddress() throws Exception {
|
||||
setEppInput("contact_create_hebrew_loc.xml");
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonAsciiInIntAddress() {
|
||||
setEppInput("contact_create_hebrew_int.xml");
|
||||
EppException thrown =
|
||||
@@ -121,7 +119,7 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_declineDisclosure() {
|
||||
setEppInput("contact_create_decline_disclosure.xml");
|
||||
EppException thrown =
|
||||
@@ -129,7 +127,7 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-cont-create");
|
||||
|
||||
@@ -51,14 +51,11 @@ import google.registry.model.tld.Registry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.testing.TestSqlOnly;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactDeleteFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, ContactResource> {
|
||||
|
||||
@BeforeEach
|
||||
@@ -66,20 +63,20 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
setEppInput("contact_delete.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
dryRunFlowAssertResponse(loadFile("contact_delete_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
clock.advanceOneMilli();
|
||||
@@ -88,7 +85,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertSqlDeleteSuccess();
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testSuccess_pendingTransfer_sql() throws Exception {
|
||||
DateTime transferRequestTime = clock.nowUtc().minusDays(3);
|
||||
TransferData oldTransferData =
|
||||
@@ -130,7 +127,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertThat(panData.getActionResult()).isFalse();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clTridNotSpecified() throws Exception {
|
||||
setEppInput("contact_delete_no_cltrid.xml");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -140,7 +137,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertSqlDeleteSuccess();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
@@ -148,7 +145,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -157,19 +154,19 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasClientDeleteProhibited() throws Exception {
|
||||
doFailingStatusTest(
|
||||
StatusValue.CLIENT_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasServerDeleteProhibited() throws Exception {
|
||||
doFailingStatusTest(
|
||||
StatusValue.SERVER_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasPendingDelete() throws Exception {
|
||||
doFailingStatusTest(
|
||||
StatusValue.PENDING_DELETE, ResourceStatusProhibitsOperationException.class);
|
||||
@@ -187,7 +184,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -195,7 +192,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -205,7 +202,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertSqlDeleteSuccess();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_failfastWhenLinkedToDomain() throws Exception {
|
||||
createTld("tld");
|
||||
persistResource(newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand())));
|
||||
@@ -213,7 +210,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
clock.advanceOneMilli();
|
||||
|
||||
@@ -40,12 +40,10 @@ import google.registry.model.contact.PostalInfo.Type;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.eppcommon.PresenceMarker;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactInfoFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactResource> {
|
||||
|
||||
ContactInfoFlowTest() {
|
||||
@@ -100,14 +98,14 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
return contact;
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
persistContactResource(true);
|
||||
// Check that the persisted contact info was returned.
|
||||
@@ -120,7 +118,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
assertNoBillingEvents();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_linked() throws Exception {
|
||||
createTld("foobar");
|
||||
persistResource(newDomainBase("example.foobar", persistContactResource(true)));
|
||||
@@ -134,7 +132,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
assertNoBillingEvents();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_owningRegistrarWithoutAuthInfo_seesAuthInfo() throws Exception {
|
||||
setEppInput("contact_info_no_authinfo.xml");
|
||||
persistContactResource(true);
|
||||
@@ -148,7 +146,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
assertNoBillingEvents();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_otherRegistrar_notAuthorized() throws Exception {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
persistContactResource(true);
|
||||
@@ -158,7 +156,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_otherRegistrarWithoutAuthInfoAsSuperuser_doesNotSeeAuthInfo() throws Exception {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
setEppInput("contact_info_no_authinfo.xml");
|
||||
@@ -175,7 +173,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
assertNoBillingEvents();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_otherRegistrarWithAuthInfoAsSuperuser_seesAuthInfo() throws Exception {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
persistContactResource(true);
|
||||
@@ -191,7 +189,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
assertNoBillingEvents();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
@@ -199,7 +197,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistContactResource(false);
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -208,7 +206,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistContactResource(true);
|
||||
runFlow();
|
||||
|
||||
+17
-19
@@ -41,12 +41,10 @@ import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactTransferApproveFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactTransferApproveFlowTest
|
||||
extends ContactTransferFlowTestCase<ContactTransferApproveFlow, ContactResource> {
|
||||
|
||||
@@ -126,31 +124,31 @@ class ContactTransferApproveFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setEppInput("contact_transfer_approve.xml");
|
||||
dryRunFlowAssertResponse(loadFile("contact_transfer_approve_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_approve.xml", "contact_transfer_approve_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_withAuthinfo() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_approve_with_authinfo.xml",
|
||||
"contact_transfer_approve_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact = persistResource(
|
||||
@@ -164,7 +162,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
@@ -173,7 +171,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientApproved() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -182,7 +180,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientRejected() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
EppException thrown =
|
||||
@@ -191,7 +189,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientCancelled() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -200,7 +198,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverApproved() {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -209,7 +207,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverCancelled() {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -218,7 +216,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gainingClient() {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
EppException thrown =
|
||||
@@ -227,7 +225,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedClient() {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
@@ -236,7 +234,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedContact() throws Exception {
|
||||
contact = persistResource(
|
||||
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -248,7 +246,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentContact() throws Exception {
|
||||
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
contact = persistResource(
|
||||
@@ -261,7 +259,7 @@ class ContactTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-cont-transfer-approve");
|
||||
|
||||
+17
-19
@@ -38,12 +38,10 @@ import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactTransferCancelFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactTransferCancelFlowTest
|
||||
extends ContactTransferFlowTestCase<ContactTransferCancelFlow, ContactResource> {
|
||||
|
||||
@@ -110,31 +108,31 @@ class ContactTransferCancelFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setEppInput("contact_transfer_cancel.xml");
|
||||
dryRunFlowAssertResponse(loadFile("contact_transfer_cancel_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_cancel.xml", "contact_transfer_cancel_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_withAuthinfo() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_cancel_with_authinfo.xml",
|
||||
"contact_transfer_cancel_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
@@ -150,7 +148,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
@@ -159,7 +157,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientApproved() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -168,7 +166,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientRejected() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
EppException thrown =
|
||||
@@ -177,7 +175,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientCancelled() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -186,7 +184,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverApproved() {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -195,7 +193,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverCancelled() {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -204,7 +202,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_sponsoringClient() {
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
EppException thrown =
|
||||
@@ -214,7 +212,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedClient() {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
@@ -224,7 +222,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedContact() throws Exception {
|
||||
contact =
|
||||
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -236,7 +234,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentContact() throws Exception {
|
||||
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -247,7 +245,7 @@ class ContactTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-cont-transfer-cancel");
|
||||
|
||||
+19
-21
@@ -32,13 +32,11 @@ import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactTransferQueryFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactTransferQueryFlowTest
|
||||
extends ContactTransferFlowTestCase<ContactTransferQueryFlow, ContactResource> {
|
||||
|
||||
@@ -70,72 +68,72 @@ class ContactTransferQueryFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_query.xml", "contact_transfer_query_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_withContactRoid() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_query_with_roid.xml", "contact_transfer_query_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_sponsoringClient() throws Exception {
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
doSuccessfulTest("contact_transfer_query.xml", "contact_transfer_query_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_withAuthinfo() throws Exception {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
doSuccessfulTest("contact_transfer_query_with_authinfo.xml",
|
||||
"contact_transfer_query_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
doSuccessfulTest("contact_transfer_query.xml",
|
||||
"contact_transfer_query_response_client_approved.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientRejected() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
doSuccessfulTest("contact_transfer_query.xml",
|
||||
"contact_transfer_query_response_client_rejected.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
doSuccessfulTest("contact_transfer_query.xml",
|
||||
"contact_transfer_query_response_client_cancelled.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
doSuccessfulTest("contact_transfer_query.xml",
|
||||
"contact_transfer_query_response_server_approved.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
doSuccessfulTest("contact_transfer_query.xml",
|
||||
"contact_transfer_query_response_server_cancelled.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDeleteContact() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
contact = persistResource(
|
||||
@@ -144,7 +142,7 @@ class ContactTransferQueryFlowTest
|
||||
"contact_transfer_query_response_server_cancelled.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
@@ -160,7 +158,7 @@ class ContactTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactRoid() {
|
||||
// Set the contact to a different ROID, but don't persist it; this is just so the substitution
|
||||
// code above will write the wrong ROID into the file.
|
||||
@@ -172,7 +170,7 @@ class ContactTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
@@ -182,7 +180,7 @@ class ContactTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedClient() {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
@@ -192,7 +190,7 @@ class ContactTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedContact() throws Exception {
|
||||
contact =
|
||||
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -203,7 +201,7 @@ class ContactTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentContact() throws Exception {
|
||||
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -213,7 +211,7 @@ class ContactTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-cont-transfer-query");
|
||||
|
||||
+17
-19
@@ -40,12 +40,10 @@ import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactTransferRejectFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactTransferRejectFlowTest
|
||||
extends ContactTransferFlowTestCase<ContactTransferRejectFlow, ContactResource> {
|
||||
|
||||
@@ -125,31 +123,31 @@ class ContactTransferRejectFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setEppInput("contact_transfer_reject.xml");
|
||||
dryRunFlowAssertResponse(loadFile("contact_transfer_reject_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_reject.xml", "contact_transfer_reject_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainAuthInfo() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_reject_with_authinfo.xml",
|
||||
"contact_transfer_reject_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
@@ -165,7 +163,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
@@ -174,7 +172,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientApproved() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -183,7 +181,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientRejected() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
EppException thrown =
|
||||
@@ -192,7 +190,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientCancelled() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -201,7 +199,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverApproved() {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -210,7 +208,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverCancelled() {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -219,7 +217,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gainingClient() {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
EppException thrown =
|
||||
@@ -228,7 +226,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedClient() {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
@@ -237,7 +235,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedContact() throws Exception {
|
||||
contact =
|
||||
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -249,7 +247,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentContact() throws Exception {
|
||||
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -260,7 +258,7 @@ class ContactTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-cont-transfer-reject");
|
||||
|
||||
+19
-21
@@ -51,13 +51,11 @@ import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.ContactTransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactTransferRequestFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactTransferRequestFlowTest
|
||||
extends ContactTransferFlowTestCase<ContactTransferRequestFlow, ContactResource> {
|
||||
|
||||
@@ -146,25 +144,25 @@ class ContactTransferRequestFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setEppInput("contact_transfer_request.xml");
|
||||
dryRunFlowAssertResponse(loadFile("contact_transfer_request_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_noAuthInfo() {
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
@@ -173,7 +171,7 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
@@ -189,37 +187,37 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientRejected() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pending() {
|
||||
contact =
|
||||
persistResource(
|
||||
@@ -240,7 +238,7 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_sponsoringClient() {
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
EppException thrown =
|
||||
@@ -250,7 +248,7 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedContact() throws Exception {
|
||||
contact =
|
||||
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -262,7 +260,7 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentContact() throws Exception {
|
||||
deleteResource(contact);
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -273,7 +271,7 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientTransferProhibited() {
|
||||
contact =
|
||||
persistResource(
|
||||
@@ -286,7 +284,7 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverTransferProhibited() {
|
||||
contact =
|
||||
persistResource(
|
||||
@@ -299,7 +297,7 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDelete() {
|
||||
contact =
|
||||
persistResource(contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
|
||||
@@ -311,7 +309,7 @@ class ContactTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-cont-transfer-request");
|
||||
|
||||
@@ -42,11 +42,9 @@ import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.contact.PostalInfo;
|
||||
import google.registry.model.contact.PostalInfo.Type;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactUpdateFlow}. */
|
||||
@DualDatabaseTest
|
||||
class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, ContactResource> {
|
||||
|
||||
ContactUpdateFlowTest() {
|
||||
@@ -70,25 +68,25 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertLastHistoryContainsResource(contact);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_updatingInternationalizedPostalInfoDeletesLocalized() throws Exception {
|
||||
ContactResource contact =
|
||||
persistResource(
|
||||
@@ -126,7 +124,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_updatingLocalizedPostalInfoDeletesInternationalized() throws Exception {
|
||||
setEppInput("contact_update_localized.xml");
|
||||
ContactResource contact =
|
||||
@@ -165,7 +163,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_partialPostalInfoUpdate() throws Exception {
|
||||
setEppInput("contact_update_partial_postalinfo.xml");
|
||||
persistResource(
|
||||
@@ -201,7 +199,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_updateOnePostalInfo_touchOtherPostalInfoPreservesIt() throws Exception {
|
||||
setEppInput("contact_update_partial_postalinfo_preserve_int.xml");
|
||||
persistResource(
|
||||
@@ -267,7 +265,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
@@ -275,7 +273,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -284,7 +282,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_statusValueNotClientSettable() throws Exception {
|
||||
setEppInput("contact_update_prohibited_status.xml");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -292,7 +290,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserStatusValueNotClientSettable() throws Exception {
|
||||
setEppInput("contact_update_prohibited_status.xml");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -301,7 +299,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -309,7 +307,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -318,7 +316,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientUpdateProhibited_removed() throws Exception {
|
||||
setEppInput("contact_update_remove_client_update_prohibited.xml");
|
||||
persistResource(
|
||||
@@ -332,7 +330,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
.doesNotHaveStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserClientUpdateProhibited_notRemoved() throws Exception {
|
||||
setEppInput("contact_update_prohibited_status.xml");
|
||||
persistResource(
|
||||
@@ -350,7 +348,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
.hasStatusValue(StatusValue.SERVER_DELETE_PROHIBITED);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientUpdateProhibited_notRemoved() throws Exception {
|
||||
persistResource(
|
||||
newContactResource(getUniqueIdFromCommand())
|
||||
@@ -362,7 +360,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverUpdateProhibited() throws Exception {
|
||||
persistResource(
|
||||
newContactResource(getUniqueIdFromCommand())
|
||||
@@ -375,7 +373,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDeleteProhibited() throws Exception {
|
||||
persistResource(
|
||||
newContactResource(getUniqueIdFromCommand())
|
||||
@@ -388,13 +386,13 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nonAsciiInLocAddress() throws Exception {
|
||||
setEppInput("contact_update_hebrew_loc.xml");
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonAsciiInIntAddress() throws Exception {
|
||||
setEppInput("contact_update_hebrew_int.xml");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -403,7 +401,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_declineDisclosure() throws Exception {
|
||||
setEppInput("contact_update_decline_disclosure.xml");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -412,7 +410,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_addRemoveSameValue() throws Exception {
|
||||
setEppInput("contact_update_add_remove_same.xml");
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
@@ -420,7 +418,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistActiveContact(getUniqueIdFromCommand());
|
||||
clock.advanceOneMilli();
|
||||
|
||||
@@ -74,19 +74,17 @@ import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tld.Registry.TldState;
|
||||
import google.registry.model.tld.label.ReservedList;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
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.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DomainCheckFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, DomainBase> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@@ -120,14 +118,14 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
persistResource(Registry.get("tld").asBuilder().setReservedLists(createReservedList()).build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn_takesPrecedenceOverUndeclaredExtensions() {
|
||||
// Attempt to use the fee extension, but there is no login session and no supported extensions.
|
||||
setEppInput("domain_check_fee_v06.xml", ImmutableMap.of("CURRENCY", "USD"));
|
||||
@@ -138,7 +136,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nothingExists() throws Exception {
|
||||
doCheckTest(
|
||||
create(true, "example1.tld", null),
|
||||
@@ -146,7 +144,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example3.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneExists() throws Exception {
|
||||
persistActiveDomain("example1.tld");
|
||||
doCheckTest(
|
||||
@@ -155,7 +153,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example3.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clTridNotSpecified() throws Exception {
|
||||
setEppInput("domain_check_no_cltrid.xml");
|
||||
persistActiveDomain("example1.tld");
|
||||
@@ -165,7 +163,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example3.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneExists_allocationTokenIsInvalid() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistActiveDomain("example1.tld");
|
||||
@@ -176,7 +174,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "specificuse.tld", "Reserved; alloc. token required"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneExists_allocationTokenIsValid() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistActiveDomain("example1.tld");
|
||||
@@ -189,7 +187,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "specificuse.tld", "Reserved; alloc. token required"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneExists_allocationTokenIsRedeemed() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
DomainBase domain = persistActiveDomain("example1.tld");
|
||||
@@ -207,7 +205,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "specificuse.tld", "Reserved; alloc. token required"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneExists_allocationTokenForReservedDomain() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistActiveDomain("example1.tld");
|
||||
@@ -224,7 +222,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "specificuse.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_allocationTokenForReservedDomain_showsFee() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken_fee_specificuse.xml");
|
||||
createTld("example");
|
||||
@@ -239,7 +237,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_allocationtoken_fee_specificuse_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneExists_allocationTokenForWrongDomain() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistActiveDomain("example1.tld");
|
||||
@@ -256,7 +254,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "specificuse.tld", "Reserved; alloc. token required"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_notOutOfDateToken_forSpecificDomain() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistResource(
|
||||
@@ -278,7 +276,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "specificuse.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_outOfDateToken_forSpecificDomain() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistResource(
|
||||
@@ -300,7 +298,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "specificuse.tld", "Alloc token not in promo period"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nothingExists_reservationsOverrideInvalidAllocationTokens() throws Exception {
|
||||
setEppInput("domain_check_reserved_allocationtoken.xml");
|
||||
// Fill out these reasons
|
||||
@@ -312,7 +310,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "premiumcollision.tld", "Cannot be delegated"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_allocationTokenPromotion_singleYear() throws Exception {
|
||||
createTld("example");
|
||||
persistResource(
|
||||
@@ -332,7 +330,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_allocationtoken_fee_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_allocationTokenPromotion_multiYearAndPremiums() throws Exception {
|
||||
createTld("example");
|
||||
persistResource(
|
||||
@@ -364,7 +362,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
.build()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_allocationTokenPromotion_multiYear() throws Exception {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
@@ -395,7 +393,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
.build()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_promotionNotActive() throws Exception {
|
||||
createTld("example");
|
||||
persistResource(
|
||||
@@ -417,7 +415,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "reserved.tld", "Reserved"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_promoTokenNotValidForTld() throws Exception {
|
||||
createTld("example");
|
||||
persistResource(
|
||||
@@ -440,7 +438,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "reserved.tld", "Reserved"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_promoTokenNotValidForRegistrar() throws Exception {
|
||||
createTld("example");
|
||||
persistResource(
|
||||
@@ -463,7 +461,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "reserved.tld", "Reserved"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneReservedInSunrise() throws Exception {
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
persistResource(Registry.get("tld").asBuilder().setReservedLists(createReservedList()).build());
|
||||
@@ -475,7 +473,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example3.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_twoReservedOutsideSunrise() throws Exception {
|
||||
setEppInput("domain_check_one_tld_reserved.xml");
|
||||
doCheckTest(
|
||||
@@ -485,7 +483,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example3.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainWithMultipleReservationType_useMostSevereMessage() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -502,13 +500,13 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example3.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_anchorTenantReserved() throws Exception {
|
||||
setEppInput("domain_check_anchor.xml");
|
||||
doCheckTest(create(false, "anchor.tld", "Reserved; alloc. token required"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_anchorTenantWithToken() throws Exception {
|
||||
setEppInput("domain_check_anchor_allocationtoken.xml");
|
||||
persistResource(
|
||||
@@ -520,7 +518,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
doCheckTest(create(true, "anchor.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_multipartTld_oneReserved() throws Exception {
|
||||
createTld("tld.foo");
|
||||
persistResource(
|
||||
@@ -538,7 +536,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example3.tld.foo", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneExistsButWasDeleted() throws Exception {
|
||||
persistDeletedDomain("example1.tld", clock.nowUtc().minusDays(1));
|
||||
doCheckTest(
|
||||
@@ -547,7 +545,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example3.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_duplicatesAllowed() throws Exception {
|
||||
setEppInput("domain_check_duplicates.xml");
|
||||
doCheckTest(
|
||||
@@ -556,40 +554,40 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(true, "example1.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_xmlMatches() throws Exception {
|
||||
persistActiveDomain("example2.tld");
|
||||
runFlowAssertResponse(loadFile("domain_check_one_tld_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_50IdsAllowed() throws Exception {
|
||||
// Make sure we don't have a regression that reduces the number of allowed checks.
|
||||
setEppInput("domain_check_50.xml");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_50IdsAllowed_withAllocationToken() throws Exception {
|
||||
setEppInput("domain_check_50_allocationtoken.xml");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tooManyIds() {
|
||||
setEppInput("domain_check_51.xml");
|
||||
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongTld() {
|
||||
setEppInput("domain_check.xml");
|
||||
EppException thrown = assertThrows(TldDoesNotExistException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -597,7 +595,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingBillingAccount() {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -615,7 +613,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistActiveDomain("example2.tld");
|
||||
persistResource(
|
||||
@@ -631,92 +629,92 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_uppercase() {
|
||||
doFailingBadLabelTest("FOO.tld", BadDomainNameCharacterException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badCharacter() {
|
||||
doFailingBadLabelTest("test_example.tld", BadDomainNameCharacterException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_leadingDash() {
|
||||
doFailingBadLabelTest("-example.tld", LeadingDashException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_trailingDash() {
|
||||
doFailingBadLabelTest("example-.tld", TrailingDashException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tooLong() {
|
||||
doFailingBadLabelTest(Strings.repeat("a", 64) + ".tld", DomainLabelTooLongException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_leadingDot() {
|
||||
doFailingBadLabelTest(".example.tld", EmptyDomainNamePartException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_leadingDotTld() {
|
||||
doFailingBadLabelTest("foo..tld", EmptyDomainNamePartException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tooManyParts() {
|
||||
doFailingBadLabelTest("foo.example.tld", BadDomainNamePartsCountException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tooFewParts() {
|
||||
doFailingBadLabelTest("tld", BadDomainNamePartsCountException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_domainNameExistsAsTld_lowercase() {
|
||||
createTlds("foo.tld", "tld");
|
||||
doFailingBadLabelTest("foo.tld", DomainNameExistsAsTldException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_domainNameExistsAsTld_uppercase() {
|
||||
createTlds("foo.tld", "tld");
|
||||
doFailingBadLabelTest("FOO.TLD", BadDomainNameCharacterException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_invalidPunycode() {
|
||||
doFailingBadLabelTest("xn--abcdefg.tld", InvalidPunycodeException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_dashesInThirdAndFourthPosition() {
|
||||
doFailingBadLabelTest("ab--cdefg.tld", DashesInThirdAndFourthException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tldDoesNotExist() {
|
||||
doFailingBadLabelTest("foo.nosuchtld", TldDoesNotExistException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_invalidIdnCodePoints() {
|
||||
// ❤☀☆☂☻♞☯.tld
|
||||
doFailingBadLabelTest("xn--k3hel9n7bxlu1e.tld", InvalidIdnDomainLabelException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_predelegation() {
|
||||
createTld("tld", PREDELEGATION);
|
||||
EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testAvailExtension() throws Exception {
|
||||
persistActiveDomain("example1.tld");
|
||||
setEppInput("domain_check_avail.xml");
|
||||
@@ -727,7 +725,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
}
|
||||
|
||||
/** Test that premium names are shown as available even if the fee extension is not used. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testAvailExtension_premiumDomainsAreAvailableWithoutExtension() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_premium.xml");
|
||||
@@ -735,14 +733,14 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
}
|
||||
|
||||
/** Test multiyear periods and explicitly correct currency and that the avail extension is ok. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_v06() throws Exception {
|
||||
persistActiveDomain("example1.tld");
|
||||
setEppInput("domain_check_fee_v06.xml", ImmutableMap.of("CURRENCY", "USD"));
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_response_v06.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multipleReservations() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -755,21 +753,21 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_response_v06.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_v11() throws Exception {
|
||||
persistActiveDomain("example1.tld");
|
||||
setEppInput("domain_check_fee_v11.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_response_v11.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_v12() throws Exception {
|
||||
persistActiveDomain("example1.tld");
|
||||
setEppInput("domain_check_fee_v12.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_response_v12.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_thirtyDomains_restoreFees() throws Exception {
|
||||
// Note that 30 is more than 25, which is the maximum # of entity groups you can enlist in a
|
||||
// single Datastore transaction (each DomainBase entity is in a separate entity group).
|
||||
@@ -786,7 +784,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
* Test commands for create, renew, transfer, restore and update with implicit period and
|
||||
* currency.
|
||||
*/
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multipleCommands_v06() throws Exception {
|
||||
setEppInput("domain_check_fee_multiple_commands_v06.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_multiple_commands_response_v06.xml"));
|
||||
@@ -794,21 +792,21 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
|
||||
// Version 11 cannot have multiple commands.
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multipleCommands_v12() throws Exception {
|
||||
setEppInput("domain_check_fee_multiple_commands_v12.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_multiple_commands_response_v12.xml"));
|
||||
}
|
||||
|
||||
/** Test the same as {@link #testFeeExtension_multipleCommands_v06} with premium labels. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v06() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v06.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v06.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premium_eap_v06() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v06.xml");
|
||||
@@ -828,7 +826,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_eap_response_v06.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premium_eap_v06_withRenewalOnRestore() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v06.xml");
|
||||
@@ -849,35 +847,35 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_eap_response_v06_with_renewal.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v11_create() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v11_create.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_create.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v11_renew() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v11_renew.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_renew.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v11_transfer() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v11_transfer.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_transfer.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v11_restore() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v11_restore.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_restore.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v11_restore_withRenewal() throws Exception {
|
||||
setEppInput("domain_check_fee_premium_v11_restore.xml");
|
||||
createTld("example");
|
||||
@@ -886,21 +884,21 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
loadFile("domain_check_fee_premium_response_v11_restore_with_renewal.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v11_update() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v11_update.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_update.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v12() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v12.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v12.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_premiumLabels_v12_withRenewalOnRestore() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_check_fee_premium_v12.xml");
|
||||
@@ -908,7 +906,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v12_with_renewal.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_fractionalCost() throws Exception {
|
||||
// Note that the response xml expects to see "11.10" with two digits after the decimal point.
|
||||
// This works because Money.getAmount(), used in the flow, returns a BigDecimal that is set to
|
||||
@@ -923,7 +921,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
}
|
||||
|
||||
/** Test that create fees are properly omitted/classed on names on reserved lists. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_v06() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -935,7 +933,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v06.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_restoreFeeWithDupes_v06() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -950,7 +948,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
}
|
||||
|
||||
/** The tests must be split up for version 11, which allows only one command at a time. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_v11_create() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -962,7 +960,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_create.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_v11_renew() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -974,7 +972,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_renew.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_v11_transfer() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -986,7 +984,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_transfer.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_v11_restore() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -998,7 +996,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_restore.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_v11_restore_withRenewals() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -1015,7 +1013,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
loadFile("domain_check_fee_reserved_response_v11_restore_with_renewals.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_v12() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -1027,7 +1025,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v12.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_reservedName_restoreFeeWithDupes_v12() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -1041,7 +1039,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_dupes_response_v12.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v06() throws Exception {
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
persistResource(
|
||||
@@ -1054,7 +1052,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v06.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v06_withRestoreRenewals()
|
||||
throws Exception {
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
@@ -1073,7 +1071,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
loadFile("domain_check_fee_reserved_sunrise_response_v06_with_renewals.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_create() throws Exception {
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
persistResource(
|
||||
@@ -1086,7 +1084,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_create.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_renew() throws Exception {
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
persistResource(
|
||||
@@ -1099,7 +1097,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_renew.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_transfer() throws Exception {
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
persistResource(
|
||||
@@ -1112,7 +1110,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_transfer.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_restore() throws Exception {
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
persistResource(
|
||||
@@ -1125,7 +1123,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_restore.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v12() throws Exception {
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
persistResource(
|
||||
@@ -1138,91 +1136,91 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v12.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_wrongCurrency_v06() {
|
||||
setEppInput("domain_check_fee_euro_v06.xml");
|
||||
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_wrongCurrency_v11() {
|
||||
setEppInput("domain_check_fee_euro_v11.xml");
|
||||
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_wrongCurrency_v12() {
|
||||
setEppInput("domain_check_fee_euro_v12.xml");
|
||||
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_badCurrencyType() {
|
||||
setEppInput("domain_check_fee_v06.xml", ImmutableMap.of("CURRENCY", "BAD"));
|
||||
EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_periodNotInYears_v06() {
|
||||
setEppInput("domain_check_fee_bad_period_v06.xml");
|
||||
EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_periodNotInYears_v11() {
|
||||
setEppInput("domain_check_fee_bad_period_v11.xml");
|
||||
EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_periodNotInYears_v12() {
|
||||
setEppInput("domain_check_fee_bad_period_v12.xml");
|
||||
EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_commandWithPhase_v06() {
|
||||
setEppInput("domain_check_fee_command_phase_v06.xml");
|
||||
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_commandWithPhase_v11() {
|
||||
setEppInput("domain_check_fee_command_phase_v11.xml");
|
||||
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_commandWithPhase_v12() {
|
||||
setEppInput("domain_check_fee_command_phase_v12.xml");
|
||||
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_commandSubphase_v06() {
|
||||
setEppInput("domain_check_fee_command_subphase_v06.xml");
|
||||
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_commandSubphase_v11() {
|
||||
setEppInput("domain_check_fee_command_subphase_v11.xml");
|
||||
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_commandSubphase_v12() {
|
||||
setEppInput("domain_check_fee_command_subphase_v12.xml");
|
||||
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
|
||||
@@ -1230,7 +1228,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
}
|
||||
|
||||
// This test is only relevant for v06, since domain names are not specified in v11 or v12.
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_feeCheckNotInAvailabilityCheck() {
|
||||
setEppInput("domain_check_fee_not_in_avail.xml");
|
||||
EppException thrown =
|
||||
@@ -1238,84 +1236,84 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multiyearRestore_v06() {
|
||||
setEppInput("domain_check_fee_multiyear_restore_v06.xml");
|
||||
EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multiyearRestore_v11() {
|
||||
setEppInput("domain_check_fee_multiyear_restore_v11.xml");
|
||||
EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multiyearRestore_v12() {
|
||||
setEppInput("domain_check_fee_multiyear_restore_v12.xml");
|
||||
EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multiyearTransfer_v06() {
|
||||
setEppInput("domain_check_fee_multiyear_transfer_v06.xml");
|
||||
EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multiyearTransfer_v11() {
|
||||
setEppInput("domain_check_fee_multiyear_transfer_v11.xml");
|
||||
EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multiyearTransfer_v12() {
|
||||
setEppInput("domain_check_fee_multiyear_transfer_v12.xml");
|
||||
EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_unknownCommand_v06() {
|
||||
setEppInput("domain_check_fee_unknown_command_v06.xml");
|
||||
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_unknownCommand_v11() {
|
||||
setEppInput("domain_check_fee_unknown_command_v11.xml");
|
||||
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_unknownCommand_v12() {
|
||||
setEppInput("domain_check_fee_unknown_command_v12.xml");
|
||||
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_invalidCommand_v06() {
|
||||
setEppInput("domain_check_fee_invalid_command_v06.xml");
|
||||
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_invalidCommand_v11() {
|
||||
setEppInput("domain_check_fee_invalid_command_v11.xml");
|
||||
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_invalidCommand_v12() {
|
||||
setEppInput("domain_check_fee_invalid_command_v12.xml");
|
||||
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
|
||||
@@ -1340,35 +1338,35 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
runFlowAssertResponse(loadFile(outputFile));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_eapFeeCheck_v06() throws Exception {
|
||||
runEapFeeCheckTest("domain_check_fee_v06.xml", "domain_check_eap_fee_response_v06.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_eapFeeCheck_v11() throws Exception {
|
||||
runEapFeeCheckTest("domain_check_fee_v11.xml", "domain_check_eap_fee_response_v11.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_eapFeeCheck_v12() throws Exception {
|
||||
runEapFeeCheckTest("domain_check_fee_v12.xml", "domain_check_eap_fee_response_v12.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_eapFeeCheck_date_v12() throws Exception {
|
||||
runEapFeeCheckTest(
|
||||
"domain_check_fee_date_v12.xml", "domain_check_eap_fee_response_date_v12.xml");
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_feeCheck_multipleRanges() {
|
||||
// TODO: If at some point we have more than one type of fees that are time dependent, populate
|
||||
// this test to test if the notAfter date is the earliest of the end points of the ranges.
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
createTlds("com", "net", "org");
|
||||
setEppInput("domain_check.xml");
|
||||
|
||||
@@ -41,13 +41,11 @@ import google.registry.flows.exceptions.TooManyResourceChecksException;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tld.Registry.TldState;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.money.Money;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainClaimsCheckFlow}. */
|
||||
@DualDatabaseTest
|
||||
public class DomainClaimsCheckFlowTest
|
||||
extends ResourceFlowTestCase<DomainClaimsCheckFlow, DomainBase> {
|
||||
|
||||
@@ -67,32 +65,32 @@ public class DomainClaimsCheckFlowTest
|
||||
runFlowAssertResponse(loadFile(expectedXmlFilename));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noClaims() throws Exception {
|
||||
doSuccessfulTest("domain_check_claims_response_none.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_quietPeriod() throws Exception {
|
||||
createTld("tld", TldState.QUIET_PERIOD);
|
||||
doSuccessfulTest("domain_check_claims_response_none.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oneClaim() throws Exception {
|
||||
persistClaimsList(
|
||||
ImmutableMap.of("example2", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001"));
|
||||
doSuccessfulTest("domain_check_claims_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_multipleTlds() throws Exception {
|
||||
setEppInput("domain_check_claims_multiple_tlds.xml");
|
||||
createTld("tld1");
|
||||
@@ -102,28 +100,28 @@ public class DomainClaimsCheckFlowTest
|
||||
doSuccessfulTest("domain_check_claims_response_multiple_tlds.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_50IdsAllowed() throws Exception {
|
||||
// Make sure we don't have a regression that reduces the number of allowed checks.
|
||||
setEppInput("domain_check_claims_50.xml");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_TooManyIds() {
|
||||
setEppInput("domain_check_claims_51.xml");
|
||||
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tldDoesntExist() {
|
||||
setEppInput("domain_check_claims_bad_tld.xml");
|
||||
EppException thrown = assertThrows(TldDoesNotExistException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -131,7 +129,7 @@ public class DomainClaimsCheckFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingBillingAccount() {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -149,7 +147,7 @@ public class DomainClaimsCheckFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistClaimsList(
|
||||
ImmutableMap.of("example2", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001"));
|
||||
@@ -162,7 +160,7 @@ public class DomainClaimsCheckFlowTest
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_check_claims_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_predelgation() {
|
||||
createTld("tld", PREDELEGATION);
|
||||
setEppInput("domain_check_claims.xml");
|
||||
@@ -170,7 +168,7 @@ public class DomainClaimsCheckFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_allocationToken() {
|
||||
createTld("tld");
|
||||
setEppInput("domain_check_claims_allocationtoken.xml");
|
||||
@@ -179,7 +177,7 @@ public class DomainClaimsCheckFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_multipleTlds_oneHasEndedClaims() {
|
||||
createTlds("tld1", "tld2");
|
||||
persistResource(
|
||||
@@ -189,7 +187,7 @@ public class DomainClaimsCheckFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-dom-check");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,16 +101,14 @@ import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Map;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainDeleteFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, DomainBase> {
|
||||
|
||||
private DomainBase domain;
|
||||
@@ -286,14 +284,14 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
.setHistoryEntry(earlierHistoryEntry);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_asyncActionsAreEnqueued() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -318,7 +316,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
.scheduleTime(clock.nowUtc().plus(when)));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
setUpGracePeriods(
|
||||
@@ -331,7 +329,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun_noGracePeriods() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
dryRunFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
|
||||
@@ -367,7 +365,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(getPollMessages("TheRegistrar")).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_updatedEppUpdateTimeAfterPendingRedemption() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -391,26 +389,26 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
.hasLastEppUpdateTime(redemptionEndTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addGracePeriodResultsInImmediateDelete() throws Exception {
|
||||
sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "generic_success_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_06_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v12() throws Exception {
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_12_MAP);
|
||||
}
|
||||
@@ -489,31 +487,31 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(deletePollMessage.getMsg()).isEqualTo(expectedMessage);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noAddGracePeriodResultsInPendingDelete() throws Exception {
|
||||
sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_06_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_renewGracePeriodCredit_v12() throws Exception {
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_12_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autorenewPollMessageIsNotDeleted() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
// Modify the autorenew poll message so that it has unacked messages in the past. This should
|
||||
@@ -532,7 +530,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(getPollMessages("TheRegistrar", deletionTime)).hasSize(2);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nonDefaultRedemptionGracePeriod() throws Exception {
|
||||
sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
|
||||
persistResource(
|
||||
@@ -543,7 +541,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nonDefaultPendingDeleteLength() throws Exception {
|
||||
sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
|
||||
persistResource(
|
||||
@@ -554,7 +552,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
@@ -563,7 +561,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
setUpAutorenewGracePeriod();
|
||||
@@ -571,14 +569,14 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_v12() throws Exception {
|
||||
setUpAutorenewGracePeriod();
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
@@ -597,7 +595,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
persistResource(
|
||||
@@ -615,7 +613,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod_priceChanges_v12() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -632,7 +630,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noPendingTransfer_deletedAndHasNoTransferData() throws Exception {
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
setUpSuccessfulTest();
|
||||
@@ -642,7 +640,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(domain.getTransferData()).isEqualTo(DomainTransferData.EMPTY);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_pendingTransfer() throws Exception {
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
setUpSuccessfulTest();
|
||||
@@ -723,7 +721,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(loadByKeysIfPresent(oldTransferData.getServerApproveEntities())).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testUnlinkingOfResources() throws Exception {
|
||||
sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
|
||||
setUpSuccessfulTest();
|
||||
@@ -761,7 +759,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
eventTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_deletedSubordinateDomain() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
persistResource(
|
||||
@@ -776,7 +774,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertOnlyBillingEventIsClosedAutorenew("TheRegistrar");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_predelegation() throws Exception {
|
||||
createTld("tld", PREDELEGATION);
|
||||
setUpSuccessfulTest();
|
||||
@@ -784,7 +782,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserPredelegation() throws Exception {
|
||||
createTld("tld", PREDELEGATION);
|
||||
setUpSuccessfulTest();
|
||||
@@ -793,14 +791,14 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -808,7 +806,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_hasSubordinateHosts() throws Exception {
|
||||
DomainBase domain = persistActiveDomain(getUniqueIdFromCommand());
|
||||
HostResource subordinateHost =
|
||||
@@ -822,7 +820,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
@@ -830,7 +828,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
setUpSuccessfulTest();
|
||||
@@ -868,7 +866,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
persistResource(
|
||||
@@ -877,7 +875,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
persistResource(
|
||||
@@ -887,7 +885,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientDeleteProhibited() throws Exception {
|
||||
persistResource(
|
||||
newDomainBase(getUniqueIdFromCommand())
|
||||
@@ -899,7 +897,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("clientDeleteProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverDeleteProhibited() throws Exception {
|
||||
persistResource(
|
||||
newDomainBase(getUniqueIdFromCommand())
|
||||
@@ -911,7 +909,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("serverDeleteProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDelete() throws Exception {
|
||||
persistResource(
|
||||
newDomainBase(getUniqueIdFromCommand())
|
||||
@@ -923,7 +921,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_metadata() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_delete_metadata.xml");
|
||||
@@ -946,7 +944,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
.hasMetadataRequestedByRegistrar(false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_metadataNotFromTool() throws Exception {
|
||||
setEppInput("domain_delete_metadata.xml");
|
||||
persistResource(newDomainBase(getUniqueIdFromCommand()));
|
||||
@@ -954,7 +952,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
clock.advanceOneMilli();
|
||||
@@ -963,7 +961,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_testTld_notStored() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
setUpGracePeriodDurations();
|
||||
@@ -986,7 +984,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertThat(persistedEntry.getDomainTransactionRecords()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_noGrace_entryOutsideMaxGracePeriod() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
setUpGracePeriodDurations();
|
||||
@@ -1011,7 +1009,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
"tld", clock.nowUtc().plusHours(3), DELETED_DOMAINS_NOGRACE, 1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_noGrace_noAddOrRenewRecords() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
setUpGracePeriodDurations();
|
||||
@@ -1038,7 +1036,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
}
|
||||
|
||||
/** Verifies that if there's no add grace period, we still cancel out valid renew records */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_noGrace_hasRenewRecord() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
setUpGracePeriodDurations();
|
||||
@@ -1066,7 +1064,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
renewRecord.asBuilder().setReportAmount(-1).build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_inGrace_noRecords() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
setUpGracePeriods(
|
||||
@@ -1086,7 +1084,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
DomainTransactionRecord.create("tld", clock.nowUtc(), DELETED_DOMAINS_GRACE, 1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_inGrace_multipleRecords() throws Exception {
|
||||
setUpSuccessfulTest();
|
||||
setUpGracePeriods(
|
||||
@@ -1130,7 +1128,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
existingRecord.asBuilder().setReportAmount(-1).build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_nonZeroDayGrace_nonZeroDayPendingDelete() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput(
|
||||
@@ -1158,7 +1156,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertDeletionPollMessageFor(resource, "Deleted by registry administrator.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_zeroDayGrace_nonZeroDayPendingDelete() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput(
|
||||
@@ -1178,7 +1176,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertDeletionPollMessageFor(resource, "Deleted by registry administrator.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_nonZeroDayGrace_zeroDayPendingDelete() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput(
|
||||
@@ -1206,7 +1204,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertDeletionPollMessageFor(resource, "Deleted by registry administrator.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_zeroDayGrace_zeroDayPendingDelete() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput(
|
||||
@@ -1221,7 +1219,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
assertDeletionPollMessageFor(resavedDomain, "Deleted by registry administrator.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_immediateDelete_withSuperuserAndMetadataExtension() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
@@ -1237,7 +1235,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
loadByEntity(domain), "Deleted by registry administrator: Broke world.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_allocationTokenNotSupportedOnDelete() {
|
||||
setEppInput("domain_delete_allocationtoken.xml");
|
||||
EppException thrown = assertThrows(UnimplementedExtensionException.class, this::runFlow);
|
||||
|
||||
@@ -40,13 +40,11 @@ import google.registry.flows.domain.DomainFlowUtils.TrailingDashException;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.tld.Registry.TldType;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.money.Money;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainFlowUtils}. */
|
||||
@DualDatabaseTest
|
||||
class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase> {
|
||||
|
||||
@BeforeEach
|
||||
@@ -56,12 +54,12 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
persistResource(AppEngineExtension.makeRegistrar1().asBuilder().build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainNameAcceptsValidName() throws EppException {
|
||||
assertThat(DomainFlowUtils.validateDomainName("example.tld")).isNotNull();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_IllegalCharacters() {
|
||||
BadDomainNameCharacterException thrown =
|
||||
assertThrows(
|
||||
@@ -73,7 +71,7 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_DomainNameWithEmptyParts() {
|
||||
EmptyDomainNamePartException thrown =
|
||||
assertThrows(
|
||||
@@ -83,7 +81,7 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_DomainNameWithLessThanTwoParts() {
|
||||
BadDomainNamePartsCountException thrown =
|
||||
assertThrows(
|
||||
@@ -95,7 +93,7 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_invalidTLD() {
|
||||
TldDoesNotExistException thrown =
|
||||
assertThrows(
|
||||
@@ -107,7 +105,7 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_DomainNameIsTooLong() {
|
||||
DomainLabelTooLongException thrown =
|
||||
assertThrows(
|
||||
@@ -121,7 +119,7 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_leadingDash() {
|
||||
LeadingDashException thrown =
|
||||
assertThrows(
|
||||
@@ -130,7 +128,7 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_trailingDash() {
|
||||
TrailingDashException thrown =
|
||||
assertThrows(
|
||||
@@ -139,7 +137,7 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_invalidIDN() {
|
||||
InvalidPunycodeException thrown =
|
||||
assertThrows(
|
||||
@@ -151,7 +149,7 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testValidateDomainName_containsInvalidDashes() {
|
||||
DashesInThirdAndFourthException thrown =
|
||||
assertThrows(
|
||||
@@ -163,13 +161,13 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCheckHasBillingAccount_ignoresTestTlds() throws EppException {
|
||||
persistFoobarTld(TldType.TEST);
|
||||
checkHasBillingAccount("TheRegistrar", "foobar");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCheckHasBillingAccount_failsOnRealTld() throws EppException {
|
||||
persistFoobarTld(TldType.REAL);
|
||||
MissingBillingAccountMapException thrown =
|
||||
|
||||
@@ -17,7 +17,6 @@ package google.registry.flows.domain;
|
||||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
||||
@@ -30,11 +29,9 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.flows.FlowUtils.UnknownCurrencyEppException;
|
||||
@@ -62,22 +59,18 @@ import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.ofy.RequestCapturingAsyncDatastoreService;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.testing.TestOfyOnly;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DomainInfoFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@@ -202,94 +195,94 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest(expectedXmlFilename, true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_allHosts() throws Exception {
|
||||
doSuccessfulTest("domain_info_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clTridNotSpecified() throws Exception {
|
||||
setEppInput("domain_info_no_cltrid.xml");
|
||||
doSuccessfulTest("domain_info_response_no_cltrid.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_allHosts_noDelegatedHosts() throws Exception {
|
||||
// There aren't any delegated hosts.
|
||||
doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_defaultHosts() throws Exception {
|
||||
setEppInput("domain_info_default_hosts.xml");
|
||||
doSuccessfulTest("domain_info_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_defaultHosts_noDelegatedHosts() throws Exception {
|
||||
setEppInput("domain_info_default_hosts.xml");
|
||||
// There aren't any delegated hosts.
|
||||
doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_delegatedHosts() throws Exception {
|
||||
setEppInput("domain_info_delegated_hosts.xml");
|
||||
doSuccessfulTest("domain_info_response_delegated_hosts.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_delegatedHosts_noDelegatedHosts() throws Exception {
|
||||
setEppInput("domain_info_delegated_hosts.xml");
|
||||
// There aren't any delegated hosts.
|
||||
doSuccessfulTestNoNameservers("domain_info_response_none_hosts.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_subordinateHosts() throws Exception {
|
||||
setEppInput("domain_info_subordinate_hosts.xml");
|
||||
doSuccessfulTest("domain_info_response_subordinate_hosts.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_subordinateHosts_noDelegatedHosts() throws Exception {
|
||||
setEppInput("domain_info_subordinate_hosts.xml");
|
||||
doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noneHosts() throws Exception {
|
||||
setEppInput("domain_info_none_hosts.xml");
|
||||
doSuccessfulTest("domain_info_response_none_hosts.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noneHosts_noDelegatedHosts() throws Exception {
|
||||
setEppInput("domain_info_none_hosts.xml");
|
||||
doSuccessfulTestNoNameservers("domain_info_response_none_hosts.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_unauthorized() throws Exception {
|
||||
sessionMetadata.setRegistrarId("ClientZ");
|
||||
doSuccessfulTest("domain_info_response_unauthorized.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_differentRegistrarWithAuthInfo() throws Exception {
|
||||
setEppInput("domain_info_with_auth.xml");
|
||||
sessionMetadata.setRegistrarId("ClientZ");
|
||||
doSuccessfulTest("domain_info_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_differentRegistrarWithRegistrantAuthInfo() throws Exception {
|
||||
persistTestEntities(false);
|
||||
setEppInput("domain_info_with_contact_auth.xml");
|
||||
@@ -298,7 +291,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_differentRegistrarWithContactAuthInfo() throws Exception {
|
||||
persistTestEntities(false);
|
||||
setEppInput("domain_info_with_contact_auth.xml");
|
||||
@@ -307,7 +300,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_inQuietPeriod() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -317,7 +310,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDns() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Add the dsData to the saved resource and change the nameservers to match the sample xml.
|
||||
@@ -357,12 +350,12 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_addperiod.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addGracePeriod() throws Exception {
|
||||
doAddPeriodTest(GracePeriodStatus.ADD);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autoRenewGracePeriod() throws Exception {
|
||||
persistTestEntities(false);
|
||||
DomainHistory historyEntry =
|
||||
@@ -400,7 +393,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_autorenewperiod.xml", false, ImmutableMap.of(), true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_redemptionGracePeriod() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Add an REDEMPTION grace period to the saved resource, and change a few other fields to match
|
||||
@@ -420,7 +413,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_redemptionperiod.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_renewGracePeriod() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Add an RENEW grace period to the saved resource.
|
||||
@@ -438,7 +431,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_renewperiod.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_multipleRenewGracePeriods() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Add multiple RENEW grace periods to the saved resource.
|
||||
@@ -463,7 +456,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_renewperiod.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_transferGracePeriod() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Add an TRANSFER grace period to the saved resource.
|
||||
@@ -481,7 +474,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_transferperiod.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_pendingDelete() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Set the domain to be pending delete with no grace period, which will cause an RGP status of
|
||||
@@ -491,7 +484,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_pendingdelete.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_stackedAddRenewGracePeriods() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Add both an ADD and RENEW grace period, both which should show up in the RGP status.
|
||||
@@ -516,7 +509,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_stackedaddrenewperiod.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAndAddGracePeriod() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Add both an ADD grace period and SecDNS data.
|
||||
@@ -538,14 +531,14 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_response_dsdata_addperiod.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistResource(
|
||||
newDomainBase("example.tld")
|
||||
@@ -557,7 +550,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_differentRegistrarWrongAuthInfo() {
|
||||
persistTestEntities(false);
|
||||
// Change the password of the domain so that it does not match the file.
|
||||
@@ -572,7 +565,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongAuthInfo() {
|
||||
persistTestEntities(false);
|
||||
// Change the password of the domain so that it does not match the file.
|
||||
@@ -586,7 +579,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_differentRegistrarWrongRegistrantAuthInfo() {
|
||||
persistTestEntities(false);
|
||||
// Change the password of the registrant so that it does not match the file.
|
||||
@@ -604,7 +597,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongRegistrantAuthInfo() {
|
||||
persistTestEntities(false);
|
||||
// Change the password of the registrant so that it does not match the file.
|
||||
@@ -621,7 +614,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_differentRegistrarWrongContactAuthInfo() {
|
||||
persistTestEntities(false);
|
||||
// Change the password of the contact so that it does not match the file.
|
||||
@@ -639,7 +632,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongContactAuthInfo() {
|
||||
persistTestEntities(false);
|
||||
// Change the password of the contact so that it does not match the file.
|
||||
@@ -656,7 +649,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_differentRegistrarUnrelatedContactAuthInfo() {
|
||||
persistTestEntities(false);
|
||||
ContactResource unrelatedContact = persistActiveContact("foo1234");
|
||||
@@ -668,7 +661,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedContactAuthInfo() {
|
||||
persistTestEntities(false);
|
||||
ContactResource unrelatedContact = persistActiveContact("foo1234");
|
||||
@@ -683,7 +676,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
* 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.
|
||||
*/
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_createCommand() throws Exception {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -703,7 +696,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test renew command. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_renewCommand() throws Exception {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -723,7 +716,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test transfer command. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_transferCommand() throws Exception {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -743,7 +736,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test restore command. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_restoreCommand() throws Exception {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -755,7 +748,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_fee_restore_response.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_restoreCommand_pendingDelete_noRenewal() throws Exception {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -770,7 +763,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
doSuccessfulTest("domain_info_fee_restore_response_no_renewal.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_restoreCommand_pendingDelete_withRenewal() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput(
|
||||
@@ -789,7 +782,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test create command on a premium label. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_createCommandPremium() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput(
|
||||
@@ -807,7 +800,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test renew command on a premium label. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_renewCommandPremium() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput(
|
||||
@@ -825,7 +818,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test transfer command on a premium label. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_transferCommandPremium() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput(
|
||||
@@ -843,7 +836,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test restore command on a premium label. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_restoreCommandPremium() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput(
|
||||
@@ -858,7 +851,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test setting the currency explicitly to a wrong value. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_wrongCurrency() {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -872,7 +865,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_unknownCurrency() {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -886,7 +879,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test requesting a period that isn't in years. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_periodNotInYears() {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -901,7 +894,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test a command that specifies a phase. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_commandPhase() {
|
||||
setEppInput("domain_info_fee_command_phase.xml");
|
||||
persistTestEntities(false);
|
||||
@@ -910,7 +903,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test a command that specifies a subphase. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_commandSubphase() {
|
||||
setEppInput("domain_info_fee_command_subphase.xml");
|
||||
persistTestEntities(false);
|
||||
@@ -919,7 +912,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test a restore for more than one year. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multiyearRestore() {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -933,7 +926,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
}
|
||||
|
||||
/** Test a transfer for more than one year. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFeeExtension_multiyearTransfer() {
|
||||
setEppInput(
|
||||
"domain_info_fee.xml",
|
||||
@@ -946,36 +939,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
/** Test that we load contacts and hosts as a batch rather than individually. */
|
||||
@TestOfyOnly // batching only relevant for Datastore
|
||||
void testBatchLoadingOfReferences() throws Exception {
|
||||
persistTestEntities(false);
|
||||
// Clear out the session cache so that we count actual Datastore calls.
|
||||
tm().clearSessionCache();
|
||||
int numPreviousReads = RequestCapturingAsyncDatastoreService.getReads().size();
|
||||
doSuccessfulTest("domain_info_response.xml", false);
|
||||
// Get all of the keys loaded in the flow, with each distinct load() call as a list of keys.
|
||||
int numReadsWithContactsOrHosts =
|
||||
(int)
|
||||
RequestCapturingAsyncDatastoreService.getReads()
|
||||
.stream()
|
||||
.skip(numPreviousReads)
|
||||
.filter(
|
||||
keys ->
|
||||
keys.stream()
|
||||
.map(com.google.appengine.api.datastore.Key::getKind)
|
||||
.anyMatch(
|
||||
Predicates.in(
|
||||
ImmutableSet.of(
|
||||
Key.getKind(ContactResource.class),
|
||||
Key.getKind(HostResource.class)))))
|
||||
.count();
|
||||
// Nameserver keys now get persisted twice (because they are stored in nsHostsVKeys), so we
|
||||
// check for two loads instead of 1.
|
||||
assertThat(numReadsWithContactsOrHosts).isEqualTo(2);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistTestEntities(false);
|
||||
runFlow();
|
||||
|
||||
@@ -48,27 +48,24 @@ import google.registry.model.domain.fee.Fee;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeHttpSession;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.util.Clock;
|
||||
import java.util.Optional;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/** Unit tests for {@link DomainPricingLogic}. */
|
||||
@DualDatabaseTest
|
||||
public class DomainPricingLogicTest {
|
||||
DomainPricingLogic domainPricingLogic;
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@Inject Clock clock = new FakeClock(DateTime.now(UTC));
|
||||
@Mock EppInput eppInput;
|
||||
@@ -130,7 +127,7 @@ public class DomainPricingLogicTest {
|
||||
return recurring;
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_oneYear_standardDomain_noBilling_isStandardPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -142,7 +139,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_multiYear_standardDomain_noBilling_isStandardPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -154,7 +151,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_oneYear_premiumDomain_noBilling_isPremiumPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -166,7 +163,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_multiYear_premiumDomain_noBilling_isPremiumPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -178,7 +175,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_oneYear_premiumDomain_default_isPremiumPrice() throws EppException {
|
||||
assertThat(
|
||||
domainPricingLogic.getRenewPrice(
|
||||
@@ -195,7 +192,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_multiYear_premiumDomain_default_isPremiumCost() throws EppException {
|
||||
assertThat(
|
||||
domainPricingLogic.getRenewPrice(
|
||||
@@ -212,7 +209,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_oneYear_standardDomain_default_isNonPremiumPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -230,7 +227,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_multiYear_standardDomain_default_isNonPremiumCost()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -248,7 +245,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_oneYear_premiumDomain_anchorTenant_isNonPremiumPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -266,7 +263,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_multiYear_premiumDomain_anchorTenant_isNonPremiumCost()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -284,7 +281,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_oneYear_standardDomain_anchorTenant_isNonPremiumPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -302,7 +299,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_multiYear_standardDomain_anchorTenant_isNonPremiumCost()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -320,7 +317,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_oneYear_standardDomain_internalRegistration_isSpecifiedPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -338,7 +335,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_multiYear_standardDomain_internalRegistration_isSpecifiedPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -356,7 +353,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_oneYear_premiumDomain_internalRegistration_isSpecifiedPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -374,7 +371,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_multiYear_premiumDomain_internalRegistration_isSpecifiedPrice()
|
||||
throws EppException {
|
||||
assertThat(
|
||||
@@ -392,7 +389,7 @@ public class DomainPricingLogicTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetDomainRenewPrice_negativeYear_throwsException() throws EppException {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
|
||||
@@ -81,9 +81,7 @@ import google.registry.model.reporting.DomainTransactionRecord;
|
||||
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.money.Money;
|
||||
@@ -91,10 +89,10 @@ import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DomainRenewFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBase> {
|
||||
|
||||
private static final ImmutableMap<String, String> FEE_BASE_MAP =
|
||||
@@ -323,14 +321,14 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
renewBillingEvent));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
persistDomain();
|
||||
dryRunFlowAssertResponse(
|
||||
@@ -339,7 +337,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z")));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
clock.advanceOneMilli();
|
||||
persistDomain();
|
||||
@@ -349,7 +347,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_recurringClientIdIsSame_whenSuperuserOverridesRenewal() throws Exception {
|
||||
persistDomain();
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
@@ -362,7 +360,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
Money.of(USD, 55));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalRegistration_standardDomain() throws Exception {
|
||||
persistDomain(SPECIFIED, Money.of(USD, 2));
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
@@ -377,7 +375,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
Money.of(USD, 2));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalRegiration_premiumDomain() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -399,7 +397,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
Money.of(USD, 2));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_anchorTenant_standardDomain() throws Exception {
|
||||
persistDomain(NONPREMIUM, null);
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
@@ -414,7 +412,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
null);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_anchorTenant_premiumDomain() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -436,7 +434,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
null);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_customLogicFee() 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.
|
||||
@@ -458,56 +456,56 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
Money.of(USD, 111));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_fee_unknownCurrency() {
|
||||
setEppInput("domain_renew_fee.xml", updateSubstitutions(FEE_06_MAP, "CURRENCY", "BAD"));
|
||||
EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::persistDomain);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
@@ -515,7 +513,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
@@ -523,7 +521,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_refundable.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
@@ -531,7 +529,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
@@ -539,7 +537,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
@@ -547,7 +545,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_grace_period.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
@@ -555,7 +553,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
@@ -563,7 +561,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
@@ -571,7 +569,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_applied.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
@@ -579,17 +577,17 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_suspendedRegistrarCantRenewDomain() {
|
||||
doFailingTest_invalidRegistrarState(State.SUSPENDED);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingRegistrarCantRenewDomain() {
|
||||
doFailingTest_invalidRegistrarState(State.PENDING);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_disabledRegistrarCantRenewDomain() {
|
||||
doFailingTest_invalidRegistrarState(State.DISABLED);
|
||||
}
|
||||
@@ -606,7 +604,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nonDefaultRenewGracePeriod() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -620,14 +618,14 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_missingPeriod() throws Exception {
|
||||
setEppInput("domain_renew_missing_period.xml");
|
||||
persistDomain();
|
||||
doSuccessfulTest("domain_renew_response_missing_period.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autorenewPollMessageIsNotDeleted() throws Exception {
|
||||
persistDomain();
|
||||
// Modify the autorenew poll message so that it has an undelivered message in the past.
|
||||
@@ -663,7 +661,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_metaData_withReasonAndRequestedByRegistrar() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput(
|
||||
@@ -693,7 +691,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
.hasMetadataRequestedByRegistrar(false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_metaData_withRequestedByRegistrarOnly() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_renew_metadata_with_requestedByRegistrar_only.xml");
|
||||
@@ -712,14 +710,14 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
.hasMetadataRequestedByRegistrar(true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -727,7 +725,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientRenewProhibited() throws Exception {
|
||||
persistDomain(StatusValue.CLIENT_RENEW_PROHIBITED);
|
||||
ResourceStatusProhibitsOperationException thrown =
|
||||
@@ -735,7 +733,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertThat(thrown).hasMessageThat().contains("clientRenewProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverRenewProhibited() throws Exception {
|
||||
persistDomain(StatusValue.SERVER_RENEW_PROHIBITED);
|
||||
ResourceStatusProhibitsOperationException thrown =
|
||||
@@ -743,7 +741,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertThat(thrown).hasMessageThat().contains("serverRenewProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDelete() throws Exception {
|
||||
persistResource(
|
||||
newDomainBase(getUniqueIdFromCommand())
|
||||
@@ -757,7 +755,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
persistResource(
|
||||
@@ -770,7 +768,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||
persistResource(
|
||||
@@ -783,7 +781,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||
persistResource(
|
||||
@@ -796,7 +794,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||
persistResource(
|
||||
@@ -815,7 +813,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||
persistResource(
|
||||
@@ -834,7 +832,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||
persistResource(
|
||||
@@ -853,7 +851,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_06_MAP);
|
||||
persistDomain();
|
||||
@@ -861,7 +859,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_11_MAP);
|
||||
persistDomain();
|
||||
@@ -869,7 +867,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() throws Exception {
|
||||
setEppInput("domain_renew_fee_bad_scale.xml", FEE_12_MAP);
|
||||
persistDomain();
|
||||
@@ -877,7 +875,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingBillingAccountMap() throws Exception {
|
||||
persistDomain();
|
||||
persistResource(
|
||||
@@ -896,7 +894,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingTransfer() throws Exception {
|
||||
persistDomain();
|
||||
persistWithPendingTransfer(
|
||||
@@ -909,7 +907,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertThat(thrown).hasMessageThat().contains("pendingTransfer");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_periodInMonths() throws Exception {
|
||||
setEppInput("domain_renew_months.xml");
|
||||
persistDomain();
|
||||
@@ -917,7 +915,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_max10Years() throws Exception {
|
||||
setEppInput("domain_renew_11_years.xml");
|
||||
persistDomain();
|
||||
@@ -925,7 +923,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_curExpDateMustMatch() throws Exception {
|
||||
persistDomain();
|
||||
// Note expiration time is off by one day.
|
||||
@@ -939,7 +937,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClient() throws Exception {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
@@ -947,7 +945,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
persistDomain();
|
||||
@@ -959,7 +957,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z")));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -968,7 +966,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -981,7 +979,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z")));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeNotProvidedOnPremiumName() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_renew_premium.xml");
|
||||
@@ -990,7 +988,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistDomain();
|
||||
runFlow();
|
||||
@@ -998,7 +996,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_getsStored() throws Exception {
|
||||
persistDomain();
|
||||
// Test with a nonstandard Renew period to ensure the reporting time is correct regardless
|
||||
|
||||
@@ -75,16 +75,14 @@ import google.registry.model.reporting.DomainTransactionRecord;
|
||||
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainRestoreRequestFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainRestoreRequestFlowTest
|
||||
extends ResourceFlowTestCase<DomainRestoreRequestFlow, DomainBase> {
|
||||
|
||||
@@ -146,21 +144,21 @@ class DomainRestoreRequestFlowTest
|
||||
clock.advanceOneMilli();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
persistPendingDeleteDomain();
|
||||
dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expiryStillInFuture_notExtended() throws Exception {
|
||||
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
DateTime expirationTime = clock.nowUtc().plusYears(5).plusDays(45);
|
||||
@@ -228,7 +226,7 @@ class DomainRestoreRequestFlowTest
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_expiryInPast_extendedByOneYear() throws Exception {
|
||||
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
DateTime expirationTime = clock.nowUtc().minusDays(20);
|
||||
@@ -307,7 +305,7 @@ class DomainRestoreRequestFlowTest
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autorenewEndTimeIsCleared() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -321,14 +319,14 @@ class DomainRestoreRequestFlowTest
|
||||
assertThat(reloadResourceByForeignKey().getAutorenewEndTime()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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));
|
||||
@@ -336,42 +334,42 @@ class DomainRestoreRequestFlowTest
|
||||
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_06_MAP));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_fee_unknownCurrency() {
|
||||
ImmutableMap<String, String> substitutions =
|
||||
ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12", "CURRENCY", "BAD");
|
||||
@@ -381,7 +379,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -389,7 +387,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -397,7 +395,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -405,7 +403,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -413,7 +411,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -421,7 +419,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -429,7 +427,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -437,7 +435,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -445,7 +443,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -453,7 +451,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_premiumNotBlocked() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium.xml");
|
||||
@@ -461,7 +459,7 @@ class DomainRestoreRequestFlowTest
|
||||
runFlowAssertResponse(loadFile("domain_update_restore_request_response_premium.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_premiumNotBlocked_andNoRenewal() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium_no_renewal.xml");
|
||||
@@ -470,7 +468,7 @@ class DomainRestoreRequestFlowTest
|
||||
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_12_MAP));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserOverridesReservedList() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -482,7 +480,7 @@ class DomainRestoreRequestFlowTest
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserOverridesPremiumNameBlock() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium.xml");
|
||||
@@ -495,7 +493,7 @@ class DomainRestoreRequestFlowTest
|
||||
loadFile("domain_update_restore_request_response_premium.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_doesNotExist() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
@@ -503,7 +501,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_suspendedRegistrarCantRestoreDomain() {
|
||||
persistResource(
|
||||
Registrar.loadByRegistrarId("TheRegistrar")
|
||||
@@ -516,7 +514,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingRegistrarCantRestoreDomain() {
|
||||
persistResource(
|
||||
Registrar.loadByRegistrarId("TheRegistrar")
|
||||
@@ -529,7 +527,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -539,7 +537,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -549,7 +547,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -577,22 +575,22 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() throws Exception {
|
||||
runWrongCurrencyTest(FEE_06_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() throws Exception {
|
||||
runWrongCurrencyTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() throws Exception {
|
||||
runWrongCurrencyTest(FEE_12_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_06_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -600,7 +598,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_11_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -608,7 +606,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() throws Exception {
|
||||
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_12_MAP);
|
||||
persistPendingDeleteDomain();
|
||||
@@ -616,7 +614,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notInRedemptionPeriod() throws Exception {
|
||||
persistResource(
|
||||
newDomainBase(getUniqueIdFromCommand())
|
||||
@@ -628,21 +626,21 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notDeleted() throws Exception {
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
EppException thrown = assertThrows(DomainNotEligibleForRestoreException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_fullyDeleted() throws Exception {
|
||||
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
EppException thrown = assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_withChange() throws Exception {
|
||||
persistPendingDeleteDomain();
|
||||
setEppInput("domain_update_restore_request_with_change.xml");
|
||||
@@ -650,7 +648,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_withAdd() throws Exception {
|
||||
persistPendingDeleteDomain();
|
||||
setEppInput("domain_update_restore_request_with_add.xml");
|
||||
@@ -658,7 +656,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_withRemove() throws Exception {
|
||||
persistPendingDeleteDomain();
|
||||
setEppInput("domain_update_restore_request_with_remove.xml");
|
||||
@@ -666,7 +664,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_withSecDnsExtension() throws Exception {
|
||||
persistPendingDeleteDomain();
|
||||
setEppInput("domain_update_restore_request_with_secdns.xml");
|
||||
@@ -674,7 +672,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistPendingDeleteDomain();
|
||||
@@ -682,7 +680,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistPendingDeleteDomain();
|
||||
@@ -693,7 +691,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -702,7 +700,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingBillingAccount() throws Exception {
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(
|
||||
@@ -721,7 +719,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -730,7 +728,7 @@ class DomainRestoreRequestFlowTest
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_premiumBlocked() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request_premium.xml");
|
||||
@@ -741,7 +739,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_reservedBlocked() throws Exception {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
@@ -754,7 +752,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_premiumNotAcked() throws Exception {
|
||||
createTld("example");
|
||||
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "rich.example"));
|
||||
@@ -763,7 +761,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistPendingDeleteDomain();
|
||||
runFlow();
|
||||
@@ -771,7 +769,7 @@ class DomainRestoreRequestFlowTest
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionReportField_getsStored() throws Exception {
|
||||
persistPendingDeleteDomain();
|
||||
runFlow();
|
||||
@@ -787,7 +785,7 @@ class DomainRestoreRequestFlowTest
|
||||
1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_restoreReportsAreNotSupported() {
|
||||
setEppInput("domain_update_restore_report.xml");
|
||||
// This exception is referred to by its fully qualified path (rather than being imported) so
|
||||
|
||||
+27
-29
@@ -73,17 +73,15 @@ import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainTransferApproveFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainTransferApproveFlowTest
|
||||
extends DomainTransferFlowTestCase<DomainTransferApproveFlow, DomainBase> {
|
||||
|
||||
@@ -344,25 +342,25 @@ class DomainTransferApproveFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setEppLoader("domain_transfer_approve.xml");
|
||||
dryRunFlowAssertResponse(loadFile("domain_transfer_approve_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("tld", "domain_transfer_approve.xml", "domain_transfer_approve_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nonDefaultTransferGracePeriod() throws Exception {
|
||||
// We have to set up a new domain in a different TLD so that the billing event will be persisted
|
||||
// with the new transfer grace period in mind.
|
||||
@@ -377,7 +375,7 @@ class DomainTransferApproveFlowTest
|
||||
"net", "domain_transfer_approve_net.xml", "domain_transfer_approve_response_net.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainAuthInfo() throws Exception {
|
||||
doSuccessfulTest(
|
||||
"tld",
|
||||
@@ -385,7 +383,7 @@ class DomainTransferApproveFlowTest
|
||||
"domain_transfer_approve_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_contactAuthInfo() throws Exception {
|
||||
doSuccessfulTest(
|
||||
"tld",
|
||||
@@ -393,7 +391,7 @@ class DomainTransferApproveFlowTest
|
||||
"domain_transfer_approve_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autorenewBeforeTransfer() throws Exception {
|
||||
domain = reloadResourceByForeignKey();
|
||||
DateTime oldExpirationTime = clock.nowUtc().minusDays(1);
|
||||
@@ -417,7 +415,7 @@ class DomainTransferApproveFlowTest
|
||||
.setRecurringEventKey(domain.getAutorenewBillingEvent()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
@@ -433,7 +431,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badDomainPassword() {
|
||||
// Change the domain's password so it does not match the password in the file.
|
||||
persistResource(
|
||||
@@ -448,7 +446,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
@@ -457,7 +455,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientApproved() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -466,7 +464,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientRejected() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
EppException thrown =
|
||||
@@ -475,7 +473,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientCancelled() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -484,7 +482,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverApproved() {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -493,7 +491,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverCancelled() {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -502,7 +500,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gainingClient() {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
EppException thrown =
|
||||
@@ -511,7 +509,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedClient() {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
@@ -520,7 +518,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedDomain() throws Exception {
|
||||
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -530,7 +528,7 @@ class DomainTransferApproveFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentDomain() throws Exception {
|
||||
deleteTestDomain(domain, clock.nowUtc());
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -540,7 +538,7 @@ class DomainTransferApproveFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -553,7 +551,7 @@ class DomainTransferApproveFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -566,7 +564,7 @@ class DomainTransferApproveFlowTest
|
||||
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
||||
// entering pending delete phase. So it's already handled in that test case.
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-dom-transfer-approve");
|
||||
@@ -582,7 +580,7 @@ class DomainTransferApproveFlowTest
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_noRecordsToCancel() throws Exception {
|
||||
setUpGracePeriodDurations();
|
||||
clock.advanceOneMilli();
|
||||
@@ -595,7 +593,7 @@ class DomainTransferApproveFlowTest
|
||||
"tld", clock.nowUtc().plusDays(3), TRANSFER_SUCCESSFUL, 1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception {
|
||||
clock.advanceOneMilli();
|
||||
setUpGracePeriodDurations();
|
||||
@@ -624,7 +622,7 @@ class DomainTransferApproveFlowTest
|
||||
"tld", clock.nowUtc().plusDays(3), TRANSFER_SUCCESSFUL, 1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_transferPeriodZero() throws Exception {
|
||||
domain = reloadResourceByForeignKey();
|
||||
DomainTransferData.Builder transferDataBuilder = domain.getTransferData().asBuilder();
|
||||
@@ -643,7 +641,7 @@ class DomainTransferApproveFlowTest
|
||||
assertHistoryEntriesDoNotContainTransferBillingEventsOrGracePeriods();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_transferPeriodZero_autorenewGraceActive() throws Exception {
|
||||
DomainBase domain = reloadResourceByForeignKey();
|
||||
VKey<Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
|
||||
@@ -56,14 +56,12 @@ import google.registry.model.tld.Registry;
|
||||
import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainTransferCancelFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainTransferCancelFlowTest
|
||||
extends DomainTransferFlowTestCase<DomainTransferCancelFlow, DomainBase> {
|
||||
|
||||
@@ -196,36 +194,36 @@ class DomainTransferCancelFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setEppInput("domain_transfer_cancel.xml");
|
||||
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
|
||||
dryRunFlowAssertResponse(loadFile("domain_transfer_cancel_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("domain_transfer_cancel.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainAuthInfo() throws Exception {
|
||||
doSuccessfulTest("domain_transfer_cancel_domain_authinfo.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_contactAuthInfo() throws Exception {
|
||||
doSuccessfulTest("domain_transfer_cancel_contact_authinfo.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
@@ -241,7 +239,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badDomainPassword() {
|
||||
// Change the domain's password so it does not match the password in the file.
|
||||
domain =
|
||||
@@ -257,7 +255,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
@@ -266,7 +264,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientApproved() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -275,7 +273,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientRejected() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
EppException thrown =
|
||||
@@ -284,7 +282,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientCancelled() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -293,7 +291,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverApproved() {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -302,7 +300,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverCancelled() {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -311,7 +309,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_sponsoringClient() {
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
EppException thrown =
|
||||
@@ -320,7 +318,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedClient() {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
@@ -329,7 +327,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedDomain() throws Exception {
|
||||
domain =
|
||||
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -339,7 +337,7 @@ class DomainTransferCancelFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentDomain() throws Exception {
|
||||
deleteTestDomain(domain, clock.nowUtc());
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -348,7 +346,7 @@ class DomainTransferCancelFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() {
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -359,7 +357,7 @@ class DomainTransferCancelFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -371,7 +369,7 @@ class DomainTransferCancelFlowTest
|
||||
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
||||
// entering pending delete phase. So it's already handled in that test case.
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
clock.advanceOneMilli();
|
||||
runFlow();
|
||||
@@ -379,7 +377,7 @@ class DomainTransferCancelFlowTest
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_noRecordsToCancel() throws Exception {
|
||||
clock.advanceOneMilli();
|
||||
runFlow();
|
||||
@@ -388,7 +386,7 @@ class DomainTransferCancelFlowTest
|
||||
assertThat(persistedEntry.getDomainTransactionRecords()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception {
|
||||
clock.advanceOneMilli();
|
||||
persistResource(
|
||||
|
||||
@@ -35,12 +35,10 @@ import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainTransferQueryFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainTransferQueryFlowTest
|
||||
extends DomainTransferFlowTestCase<DomainTransferQueryFlow, DomainBase> {
|
||||
|
||||
@@ -82,74 +80,74 @@ class DomainTransferQueryFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_sponsoringClient() throws Exception {
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainAuthInfo() throws Exception {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query_domain_authinfo.xml", "domain_transfer_query_response.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_contactAuthInfo() throws Exception {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query_contact_authinfo.xml", "domain_transfer_query_response.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml", "domain_transfer_query_response_client_approved.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientRejected() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml", "domain_transfer_query_response_client_rejected.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml", "domain_transfer_query_response_client_cancelled.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml", "domain_transfer_query_response_server_approved.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml", "domain_transfer_query_response_server_cancelled.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_tenYears() throws Exception {
|
||||
// Extend registration by 9 years here; with the extra 1 year from the transfer, we should
|
||||
// hit the 10-year capping.
|
||||
@@ -162,7 +160,7 @@ class DomainTransferQueryFlowTest
|
||||
doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response_10_years.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDeleteDomain() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
domain =
|
||||
@@ -171,7 +169,7 @@ class DomainTransferQueryFlowTest
|
||||
"domain_transfer_query.xml", "domain_transfer_query_response_server_cancelled.xml", 1);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
@@ -187,7 +185,7 @@ class DomainTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badDomainPassword() {
|
||||
// Change the domain's password so it does not match the password in the file.
|
||||
domain =
|
||||
@@ -203,7 +201,7 @@ class DomainTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
@@ -213,7 +211,7 @@ class DomainTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedClient() {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
@@ -223,7 +221,7 @@ class DomainTransferQueryFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedDomain() throws Exception {
|
||||
domain =
|
||||
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -233,7 +231,7 @@ class DomainTransferQueryFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentDomain() throws Exception {
|
||||
deleteTestDomain(domain, clock.nowUtc());
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -242,14 +240,14 @@ class DomainTransferQueryFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-dom-transfer-query");
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverApproved_afterAutorenews() throws Exception {
|
||||
// Set the clock to just past the extended registration time. We'd expect the domain to have
|
||||
// auto-renewed once, but the transfer query response should be the same.
|
||||
|
||||
@@ -58,14 +58,12 @@ import google.registry.model.tld.Registry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainTransferRejectFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainTransferRejectFlowTest
|
||||
extends DomainTransferFlowTestCase<DomainTransferRejectFlow, DomainBase> {
|
||||
|
||||
@@ -156,38 +154,38 @@ class DomainTransferRejectFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("domain_transfer_reject.xml", "domain_transfer_reject_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setEppInput("domain_transfer_reject.xml");
|
||||
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
|
||||
dryRunFlowAssertResponse(loadFile("domain_transfer_reject_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainAuthInfo() throws Exception {
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_reject_domain_authinfo.xml", "domain_transfer_reject_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_contactAuthInfo() throws Exception {
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_reject_contact_authinfo.xml", "domain_transfer_reject_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -200,7 +198,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -208,7 +206,7 @@ class DomainTransferRejectFlowTest
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_transfer_reject_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
@@ -224,7 +222,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badDomainPassword() {
|
||||
// Change the domain's password so it does not match the password in the file.
|
||||
domain =
|
||||
@@ -240,7 +238,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
@@ -249,7 +247,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientApproved() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -258,7 +256,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientRejected() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
EppException thrown =
|
||||
@@ -267,7 +265,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientCancelled() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -276,7 +274,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverApproved() {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
EppException thrown =
|
||||
@@ -285,7 +283,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverCancelled() {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
EppException thrown =
|
||||
@@ -294,7 +292,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gainingClient() {
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
EppException thrown =
|
||||
@@ -303,7 +301,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unrelatedClient() {
|
||||
setRegistrarIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
@@ -312,7 +310,7 @@ class DomainTransferRejectFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedDomain() throws Exception {
|
||||
domain =
|
||||
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -322,7 +320,7 @@ class DomainTransferRejectFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentDomain() throws Exception {
|
||||
persistDomainAsDeleted(domain, clock.nowUtc());
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -334,7 +332,7 @@ class DomainTransferRejectFlowTest
|
||||
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
||||
// entering pending delete phase. So it's already handled in that test case.
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-dom-transfer-reject");
|
||||
@@ -350,7 +348,7 @@ class DomainTransferRejectFlowTest
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_noRecordsToCancel() throws Exception {
|
||||
setUpGracePeriodDurations();
|
||||
runFlow();
|
||||
@@ -360,7 +358,7 @@ class DomainTransferRejectFlowTest
|
||||
.containsExactly(DomainTransactionRecord.create("tld", clock.nowUtc(), TRANSFER_NACKED, 1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception {
|
||||
setUpGracePeriodDurations();
|
||||
DomainTransactionRecord previousSuccessRecord =
|
||||
|
||||
+77
-80
@@ -26,7 +26,6 @@ import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST;
|
||||
import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.testing.DatabaseHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatabaseHelper.assertBillingEventsEqual;
|
||||
import static google.registry.testing.DatabaseHelper.assertPollMessagesEqual;
|
||||
@@ -107,8 +106,6 @@ import google.registry.model.transfer.TransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
@@ -116,9 +113,9 @@ import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainTransferRequestFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainTransferRequestFlowTest
|
||||
extends DomainTransferFlowTestCase<DomainTransferRequestFlow, DomainBase> {
|
||||
|
||||
@@ -578,7 +575,7 @@ class DomainTransferRequestFlowTest
|
||||
if (expectedAutomaticTransferLength.equals(Duration.ZERO)) {
|
||||
// The transfer is going to happen immediately. To observe the domain in the pending transfer
|
||||
// state, grab it directly from the database.
|
||||
domain = Iterables.getOnlyElement(transactIfJpaTm(() -> tm().loadAllOf(DomainBase.class)));
|
||||
domain = Iterables.getOnlyElement(tm().transact(() -> tm().loadAllOf(DomainBase.class)));
|
||||
assertThat(domain.getDomainName()).isEqualTo("example.tld");
|
||||
} else {
|
||||
// Transfer should have been requested.
|
||||
@@ -639,14 +636,14 @@ class DomainTransferRequestFlowTest
|
||||
runTest(commandFilename, UserPrivileges.NORMAL, ImmutableMap.of());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
setEppInput("domain_transfer_request.xml");
|
||||
@@ -654,34 +651,34 @@ class DomainTransferRequestFlowTest
|
||||
dryRunFlowAssertResponse(loadFile("domain_transfer_request_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@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);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
@@ -690,7 +687,7 @@ class DomainTransferRequestFlowTest
|
||||
FEE_06_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
@@ -699,7 +696,7 @@ class DomainTransferRequestFlowTest
|
||||
FEE_11_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
@@ -708,7 +705,7 @@ class DomainTransferRequestFlowTest
|
||||
FEE_12_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -718,7 +715,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -728,7 +725,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_refundableFee_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -738,7 +735,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -748,7 +745,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -758,7 +755,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_gracePeriodFee_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -768,7 +765,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -778,7 +775,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -788,7 +785,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_appliedFee_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -798,7 +795,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_suspendedRegistrarCantTransferDomain() {
|
||||
setupDomain("example", "tld");
|
||||
clock.advanceOneMilli();
|
||||
@@ -815,7 +812,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingRegistrarCantTransferDomain() {
|
||||
setupDomain("example", "tld");
|
||||
clock.advanceOneMilli();
|
||||
@@ -832,7 +829,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nonDefaultAutomaticTransferLength() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
persistResource(
|
||||
@@ -844,7 +841,7 @@ class DomainTransferRequestFlowTest
|
||||
"domain_transfer_request.xml", "domain_transfer_request_response_15_minutes.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nonDefaultTransferGracePeriod() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
persistResource(
|
||||
@@ -855,14 +852,14 @@ class DomainTransferRequestFlowTest
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_missingPeriod_defaultsToOneYear() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_missing_period.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_canTransferAwayFromSuspendedRegistrar() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
clock.advanceOneMilli();
|
||||
@@ -875,7 +872,7 @@ class DomainTransferRequestFlowTest
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_inQuietPeriod() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
persistResource(
|
||||
@@ -886,7 +883,7 @@ class DomainTransferRequestFlowTest
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_multiYearPeriod() {
|
||||
setupDomain("example", "tld");
|
||||
clock.advanceOneMilli();
|
||||
@@ -897,7 +894,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_zeroPeriod_nonZeroAutomaticTransferLength() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
clock.advanceOneMilli();
|
||||
@@ -911,7 +908,7 @@ class DomainTransferRequestFlowTest
|
||||
Duration.standardDays(5));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_zeroPeriod_zeroAutomaticTransferLength() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
clock.advanceOneMilli();
|
||||
@@ -925,7 +922,7 @@ class DomainTransferRequestFlowTest
|
||||
Duration.ZERO);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_nonZeroPeriod_nonZeroAutomaticTransferLength()
|
||||
throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
@@ -940,7 +937,7 @@ class DomainTransferRequestFlowTest
|
||||
Duration.standardDays(5));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExtension_zeroPeriod_autorenewGraceActive() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
VKey<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
@@ -972,7 +969,7 @@ class DomainTransferRequestFlowTest
|
||||
Duration.ZERO);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_superuserExtension_twoYearPeriod() {
|
||||
setupDomain("example", "tld");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
@@ -986,7 +983,7 @@ class DomainTransferRequestFlowTest
|
||||
ImmutableMap.of("PERIOD", "2", "AUTOMATIC_TRANSFER_LENGTH", "5")));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_superuserExtension_zeroPeriod_feeTransferExtension() {
|
||||
setupDomain("example", "tld");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
@@ -1000,7 +997,7 @@ class DomainTransferRequestFlowTest
|
||||
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "5")));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_cappedExpiration() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
// Set the domain to expire 10 years from now (as if it were just created with a 10-year term).
|
||||
@@ -1017,14 +1014,14 @@ class DomainTransferRequestFlowTest
|
||||
clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength()).plusYears(10));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainAuthInfo() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request_domain_authinfo.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_customLogicFee() throws Exception {
|
||||
setupDomain("expensive-domain", "foo");
|
||||
clock.advanceOneMilli();
|
||||
@@ -1043,7 +1040,7 @@ class DomainTransferRequestFlowTest
|
||||
Optional.of(Money.of(USD, 111)));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() {
|
||||
setupDomain("example", "tld");
|
||||
persistResource(
|
||||
@@ -1057,7 +1054,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingBillingAccount() {
|
||||
setupDomain("example", "tld");
|
||||
persistResource(
|
||||
@@ -1081,7 +1078,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
persistResource(
|
||||
@@ -1091,7 +1088,7 @@ class DomainTransferRequestFlowTest
|
||||
runTest("domain_transfer_request.xml", UserPrivileges.SUPERUSER);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autorenewGraceActive_onlyAtTransferRequestTime() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
// Set the domain to have auto-renewed long enough ago that it is still in the autorenew grace
|
||||
@@ -1121,7 +1118,7 @@ class DomainTransferRequestFlowTest
|
||||
expirationTime.plusYears(1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autorenewGraceActive_throughoutTransferWindow() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
VKey<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
@@ -1160,7 +1157,7 @@ class DomainTransferRequestFlowTest
|
||||
.setRecurringEventKey(existingAutorenewEvent));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_autorenewGraceActive_onlyAtAutomaticTransferTime() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
VKey<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
@@ -1188,7 +1185,7 @@ class DomainTransferRequestFlowTest
|
||||
.setRecurringEventKey(existingAutorenewEvent));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_premiumNotBlocked() throws Exception {
|
||||
setupDomain("rich", "example");
|
||||
clock.advanceOneMilli();
|
||||
@@ -1196,7 +1193,7 @@ class DomainTransferRequestFlowTest
|
||||
runTest("domain_transfer_request_fee.xml", UserPrivileges.NORMAL, RICH_DOMAIN_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_premiumNotBlockedInSuperuserMode() throws Exception {
|
||||
setupDomain("rich", "example");
|
||||
clock.advanceOneMilli();
|
||||
@@ -1218,22 +1215,22 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v06() {
|
||||
runWrongCurrencyTest(FEE_06_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v11() {
|
||||
runWrongCurrencyTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongCurrency_v12() {
|
||||
runWrongCurrencyTest(FEE_12_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unknownCurrency() {
|
||||
Map<String, String> substitutions = Maps.newHashMap();
|
||||
substitutions.putAll(FEE_06_MAP);
|
||||
@@ -1244,7 +1241,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v06() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -1254,7 +1251,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v11() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -1264,7 +1261,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeGivenInWrongScale_v12() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -1287,25 +1284,25 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v06() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_06_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v11() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_11_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongFeeAmount_v12() {
|
||||
setupDomain("example", "tld");
|
||||
runWrongFeeAmountTest(FEE_12_MAP);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_premiumBlocked() {
|
||||
setupDomain("rich", "example");
|
||||
// Modify the Registrar to block premium names.
|
||||
@@ -1317,7 +1314,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_feeNotProvidedOnPremiumName() {
|
||||
setupDomain("rich", "example");
|
||||
EppException thrown =
|
||||
@@ -1327,7 +1324,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_noAuthInfo() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -1337,7 +1334,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactPassword() {
|
||||
setupDomain("example", "tld");
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
@@ -1354,7 +1351,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badContactRepoId() {
|
||||
setupDomain("example", "tld");
|
||||
// Set the contact to a different ROID, but don't persist it; this is just so the substitution
|
||||
@@ -1367,42 +1364,42 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientApproved() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientRejected() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientCancelled() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverApproved() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverCancelled() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pending() {
|
||||
setupDomain("example", "tld");
|
||||
domain =
|
||||
@@ -1424,7 +1421,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badDomainPassword() {
|
||||
setupDomain("example", "tld");
|
||||
// Change the domain's password so it does not match the password in the file.
|
||||
@@ -1441,7 +1438,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_sponsoringClient() {
|
||||
setupDomain("example", "tld");
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
@@ -1452,7 +1449,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_deletedDomain() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
domain =
|
||||
@@ -1464,7 +1461,7 @@ class DomainTransferRequestFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_invalidDomain() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
setEppInput(
|
||||
@@ -1479,7 +1476,7 @@ class DomainTransferRequestFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains("(--invalid)");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonexistentDomain() {
|
||||
createTld("tld");
|
||||
contact = persistActiveContact("jd1234");
|
||||
@@ -1490,7 +1487,7 @@ class DomainTransferRequestFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", "example.tld"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_periodInMonths() {
|
||||
setupDomain("example", "tld");
|
||||
EppException thrown =
|
||||
@@ -1500,7 +1497,7 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientTransferProhibited() {
|
||||
setupDomain("example", "tld");
|
||||
domain =
|
||||
@@ -1513,7 +1510,7 @@ class DomainTransferRequestFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains("clientTransferProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverTransferProhibited() {
|
||||
setupDomain("example", "tld");
|
||||
domain =
|
||||
@@ -1526,7 +1523,7 @@ class DomainTransferRequestFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains("serverTransferProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDelete() {
|
||||
setupDomain("example", "tld");
|
||||
domain = persistResource(domain.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
|
||||
@@ -1537,7 +1534,7 @@ class DomainTransferRequestFlowTest
|
||||
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
clock.advanceOneMilli();
|
||||
@@ -1546,7 +1543,7 @@ class DomainTransferRequestFlowTest
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannTransactionRecord_getsStored() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
persistResource(
|
||||
|
||||
@@ -105,15 +105,13 @@ import google.registry.model.poll.PendingActionNotificationResponse.DomainPendin
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainUpdateFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, DomainBase> {
|
||||
|
||||
private static final DelegationSignerData SOME_DSDATA =
|
||||
@@ -226,28 +224,28 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertLastHistoryContainsResource(reloadResourceByForeignKey());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clTridNotSpecified() throws Exception {
|
||||
setEppInput("domain_update_no_cltrid.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -255,7 +253,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doSuccessfulTest("generic_success_response_no_cltrid.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_cachingDisabled() throws Exception {
|
||||
boolean origIsCachingEnabled = RegistryConfig.isEppResourceCachingEnabled();
|
||||
try {
|
||||
@@ -268,7 +266,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
}
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_inQuietPeriod() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
@@ -280,7 +278,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_emptyRegistrant() throws Exception {
|
||||
setEppInput("domain_update_empty_registrant.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -305,7 +303,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
reloadResourceByForeignKey().asBuilder().setNameservers(nameservers.build()).build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_maxNumberOfNameservers() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -314,7 +312,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addAndRemoveLargeNumberOfNameserversAndContacts() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -355,7 +353,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertDnsTasksEnqueued("example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_metadata() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_update_metadata.xml");
|
||||
@@ -371,7 +369,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.hasMetadataRequestedByRegistrar(true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_metadataNotFromTool() throws Exception {
|
||||
setEppInput("domain_update_metadata.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -380,7 +378,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_removeContact() throws Exception {
|
||||
setEppInput("domain_update_remove_contact.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -388,7 +386,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addAndRemoveSubordinateHostNameservers() throws Exception {
|
||||
// Test that operations involving subordinate hosts as nameservers do not change the subordinate
|
||||
// host relationship itself.
|
||||
@@ -421,7 +419,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(domain.createVKey());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_registrantMovedToTechContact() throws Exception {
|
||||
setEppInput("domain_update_registrant_to_tech.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -436,7 +434,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
runFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_multipleReferencesToSameContactRemoved() throws Exception {
|
||||
setEppInput("domain_update_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -457,7 +455,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
runFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_removeClientUpdateProhibited() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
@@ -502,7 +500,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertDnsTasksEnqueued("example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAdd() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
@@ -521,7 +519,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
"A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddPreservesExisting() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
@@ -541,7 +539,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
"A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddSameDoesNothing() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
@@ -558,7 +556,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
"9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddOnlyKeyTagRemainsSame() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
@@ -584,7 +582,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
}
|
||||
|
||||
// Changing any of the four fields in DelegationSignerData should result in a new object
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddOnlyChangeKeyTag() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
@@ -608,7 +606,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
"9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddOnlyChangeAlgorithm() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
@@ -632,7 +630,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
"9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddOnlyChangeDigestType() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
@@ -657,7 +655,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
"768412320F7B0AA5812FCE428DC4706B3CAE50E02A64CAA16A782249BFE8EFC4B7EF1CCB126255D196047DFEDF17A0A9"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddOnlyChangeDigest() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add.xml",
|
||||
@@ -681,7 +679,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
"9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddToMaxRecords() throws Exception {
|
||||
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
@@ -708,7 +706,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
base16().decode("A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"))))));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsRemove() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_rem.xml",
|
||||
@@ -719,7 +717,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
ImmutableSet.of(SOME_DSDATA));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsRemoveAll() throws Exception {
|
||||
// As an aside, this test also validates that it's ok to set the 'urgent' attribute to false.
|
||||
doSecDnsSuccessfulTest(
|
||||
@@ -731,7 +729,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
ImmutableSet.of());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddRemove() throws Exception {
|
||||
doSecDnsSuccessfulTest(
|
||||
"domain_update_dsdata_add_rem.xml",
|
||||
@@ -745,7 +743,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
12346, 3, 1, base16().decode("A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"))));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddRemoveToMaxRecords() throws Exception {
|
||||
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
@@ -780,7 +778,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
base16().decode("A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"))))));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsAddRemoveSame() throws Exception {
|
||||
// Adding and removing the same dsData is a no-op because removes are processed first.
|
||||
doSecDnsSuccessfulTest(
|
||||
@@ -795,7 +793,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
12345, 3, 1, base16().decode("A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"))));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_secDnsRemoveAlreadyNotThere() throws Exception {
|
||||
// Removing a dsData that isn't there is a no-op.
|
||||
doSecDnsSuccessfulTest(
|
||||
@@ -826,7 +824,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
}
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addServerStatusBillingEvent() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
@@ -834,7 +832,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doServerStatusBillingTest("domain_update_add_server_status.xml", true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noBillingOnPreExistingServerStatus() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
DomainBase addStatusDomain = persistActiveDomain(getUniqueIdFromCommand());
|
||||
@@ -843,7 +841,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doServerStatusBillingTest("domain_update_add_server_status.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_removeServerStatusBillingEvent() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
@@ -853,7 +851,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doServerStatusBillingTest("domain_update_remove_server_status.xml", true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_changeServerStatusBillingEvent() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
@@ -863,26 +861,26 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doServerStatusBillingTest("domain_update_change_server_status.xml", true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noBillingEventOnNonServerStatusChange() throws Exception {
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
doServerStatusBillingTest("domain_update_add_non_server_status.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noBillingEventOnServerHoldStatusChange() throws Exception {
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
doServerStatusBillingTest("domain_update_add_server_hold_status.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_noBillingEventOnServerStatusChangeNotFromRegistrar() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
doServerStatusBillingTest("domain_update_add_server_status_non_registrar.xml", false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserClientUpdateProhibited() throws Exception {
|
||||
setEppInput("domain_update_add_server_hold_status.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -910,29 +908,29 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsAllCannotBeFalse() throws Exception {
|
||||
doSecDnsFailingTest(SecDnsAllUsageException.class, "domain_update_dsdata_rem_all_false.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsEmptyNotAllowed() throws Exception {
|
||||
doSecDnsFailingTest(EmptySecDnsUpdateException.class, "domain_update_dsdata_empty.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsUrgentNotSupported() throws Exception {
|
||||
doSecDnsFailingTest(
|
||||
UrgentAttributeNotSupportedException.class, "domain_update_dsdata_urgent.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsChangeNotSupported() throws Exception {
|
||||
doSecDnsFailingTest(
|
||||
MaxSigLifeChangeNotSupportedException.class, "domain_update_maxsiglife.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsInvalidDigestType() throws Exception {
|
||||
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
|
||||
persistResource(
|
||||
@@ -944,7 +942,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsMultipleInvalidDigestTypes() throws Exception {
|
||||
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
|
||||
persistResource(
|
||||
@@ -961,7 +959,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsInvalidDigestLength() throws Exception {
|
||||
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
|
||||
persistResource(
|
||||
@@ -976,7 +974,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.contains("Domain contains DS record(s) with an invalid digest length");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsMultipleInvalidDigestLengths() throws Exception {
|
||||
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
|
||||
persistResource(
|
||||
@@ -996,7 +994,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsInvalidAlgorithm() throws Exception {
|
||||
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
|
||||
persistResource(
|
||||
@@ -1008,7 +1006,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsMultipleInvalidAlgorithms() throws Exception {
|
||||
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
|
||||
persistResource(
|
||||
@@ -1025,7 +1023,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_secDnsTooManyDsRecords() throws Exception {
|
||||
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
@@ -1039,7 +1037,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tooManyNameservers() throws Exception {
|
||||
setEppInput("domain_update_add_nameserver.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1050,7 +1048,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_wrongExtension() throws Exception {
|
||||
setEppInput("domain_update_wrong_extension.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1059,7 +1057,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
persistReferencedEntities();
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -1067,7 +1065,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
@@ -1076,7 +1074,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingHost() throws Exception {
|
||||
persistActiveHost("ns1.example.foo");
|
||||
persistActiveContact("sh8013");
|
||||
@@ -1087,7 +1085,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("(ns2.example.foo)");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingContact() throws Exception {
|
||||
persistActiveHost("ns1.example.foo");
|
||||
persistActiveHost("ns2.example.foo");
|
||||
@@ -1098,7 +1096,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("(sh8013)");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_addingDuplicateContact() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistActiveContact("foo");
|
||||
@@ -1123,7 +1121,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
+ "role [tech] has contacts [foo, mak21]");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_statusValueNotClientSettable() throws Exception {
|
||||
setEppInput("domain_update_prohibited_status.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1132,7 +1130,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserCanSetServerStatusValues() throws Exception {
|
||||
setEppInput("domain_update_prohibited_status.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1143,7 +1141,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(getPollMessages()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addingServerStatusValue_sendsPollMessage() throws Exception {
|
||||
setEppInput("domain_update_prohibited_status.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1173,7 +1171,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_removingServerStatusValue_sendsPollMessage() throws Exception {
|
||||
setEppInput("domain_update_remove_server_statuses.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1214,7 +1212,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_addingAndRemovingServerStatusValues_sendsPollMessage() throws Exception {
|
||||
setEppInput("domain_update_change_server_statuses.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1253,7 +1251,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverUpdateProhibited_prohibitsNonSuperuserUpdates() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
@@ -1265,7 +1263,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(e).hasMessageThat().contains("serverUpdateProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverUpdateProhibited_allowsSuperuserUpdates() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(persistDomain().asBuilder().addStatusValue(SERVER_UPDATE_PROHIBITED).build());
|
||||
@@ -1274,7 +1272,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverUpdateProhibited_notSettableWithoutSuperuser() throws Exception {
|
||||
setEppInput("domain_update_add_registry_lock.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1283,7 +1281,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(e).hasMessageThat().contains("serverUpdateProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_serverUpdateProhibited_isSettableWithSuperuser() throws Exception {
|
||||
setEppInput("domain_update_add_registry_lock.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1292,7 +1290,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientUpdateProhibited() throws Exception {
|
||||
createTld("com");
|
||||
setEppInput("domain_update_authinfo.xml");
|
||||
@@ -1307,7 +1305,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverUpdateProhibited() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
@@ -1320,7 +1318,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDelete() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
@@ -1334,7 +1332,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_duplicateContactInCommand() throws Exception {
|
||||
setEppInput("domain_update_duplicate_contact.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1343,7 +1341,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_multipleDuplicateContactInCommand() throws Exception {
|
||||
setEppInput("domain_update_multiple_duplicate_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1358,7 +1356,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingContactType() throws Exception {
|
||||
// We need to test for missing type, but not for invalid - the schema enforces that for us.
|
||||
setEppInput("domain_update_missing_contact_type.xml");
|
||||
@@ -1368,7 +1366,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistReferencedEntities();
|
||||
@@ -1377,7 +1375,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistReferencedEntities();
|
||||
@@ -1387,7 +1385,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_notAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -1397,7 +1395,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
@@ -1408,7 +1406,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_sameNameserverAddedAndRemoved() throws Exception {
|
||||
setEppInput("domain_update_add_remove_same_host.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1426,7 +1424,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
}
|
||||
|
||||
// Contacts mismatch.
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_sameContactAddedAndRemoved() throws Exception {
|
||||
setEppInput("domain_update_add_remove_same_contact.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1444,7 +1442,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_removeAdmin() throws Exception {
|
||||
setEppInput("domain_update_remove_admin.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1460,7 +1458,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_removeTech() throws Exception {
|
||||
setEppInput("domain_update_remove_tech.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1476,7 +1474,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_addPendingDeleteContact() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -1495,7 +1493,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("mak21");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_addPendingDeleteHost() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -1514,7 +1512,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertThat(thrown).hasMessageThat().contains("ns2.example.foo");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_newRegistrantNotAllowListed() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -1528,7 +1526,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_addedNameserverDisallowedInTld() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -1543,7 +1541,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_newNameserverAllowListed() throws Exception {
|
||||
setEppInput("domain_update_add_nameserver.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1569,7 +1567,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.createVKey());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_changeRegistrantAllowListed() throws Exception {
|
||||
setEppInput("domain_update_registrant.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1586,7 +1584,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.isEqualTo("sh8013");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_changeContactsAndRegistrant() throws Exception {
|
||||
setEppInput("domain_update_contacts_and_registrant.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1611,7 +1609,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.isEqualTo("sh8013");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nameserverAndRegistrantAllowListed() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -1624,7 +1622,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_tldWithNameserverAllowList_removeNameserver() throws Exception {
|
||||
setEppInput("domain_update_remove_nameserver.xml");
|
||||
persistReferencedEntities();
|
||||
@@ -1656,7 +1654,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tldWithNameserverAllowList_removeLastNameserver() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -1672,7 +1670,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainCreateNotRestricted_doNotApplyServerProhibitedStatusCodes()
|
||||
throws Exception {
|
||||
persistReferencedEntities();
|
||||
@@ -1683,7 +1681,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
.hasExactlyStatusValues(StatusValue.CLIENT_HOLD);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_freePremium_wrongFee() throws Exception {
|
||||
setEppInput("domain_update_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
|
||||
persistReferencedEntities();
|
||||
@@ -1694,7 +1692,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
|
||||
// This test should throw an exception, because the fee extension is required when the fee is not
|
||||
// zero.
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingFeeOnNonFreeUpdate() throws Exception {
|
||||
setEppInput("domain_update_wildcard.xml", ImmutableMap.of("DOMAIN", "non-free-update.tld"));
|
||||
persistReferencedEntities();
|
||||
@@ -1704,7 +1702,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
@@ -1713,7 +1711,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertTldsFieldLogged("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuperuserExtension_turnsOffAutorenew() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_update_superuser_extension.xml", ImmutableMap.of("AUTORENEWS", "false"));
|
||||
@@ -1726,7 +1724,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
assertAboutDomains().that(reloadResourceByForeignKey()).hasAutorenewEndTime(expirationTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuperuserExtension_turnsOnAutorenew() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_update_superuser_extension.xml", ImmutableMap.of("AUTORENEWS", "true"));
|
||||
|
||||
+15
-18
@@ -50,29 +50,26 @@ import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link AllocationTokenFlowUtils}. */
|
||||
@DualDatabaseTest
|
||||
class AllocationTokenFlowUtilsTest {
|
||||
|
||||
private final AllocationTokenFlowUtils flowUtils =
|
||||
new AllocationTokenFlowUtils(new AllocationTokenCustomLogic());
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTld("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_successfullyVerifiesValidToken() throws Exception {
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
@@ -87,12 +84,12 @@ class AllocationTokenFlowUtilsTest {
|
||||
.isEqualTo(token);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_failsOnNonexistentToken() {
|
||||
assertValidateThrowsEppException(InvalidAllocationTokenException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_failsOnNullToken() {
|
||||
assertAboutEppExceptions()
|
||||
.that(
|
||||
@@ -108,7 +105,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_callsCustomLogic() {
|
||||
AllocationTokenFlowUtils failingFlowUtils =
|
||||
new AllocationTokenFlowUtils(new FailingAllocationTokenCustomLogic());
|
||||
@@ -127,7 +124,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("failed for tests");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_invalidForClientId() {
|
||||
persistResource(
|
||||
createOneMonthPromoTokenBuilder(DateTime.now(UTC).minusDays(1))
|
||||
@@ -136,7 +133,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertValidateThrowsEppException(AllocationTokenNotValidForRegistrarException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_invalidForTld() {
|
||||
persistResource(
|
||||
createOneMonthPromoTokenBuilder(DateTime.now(UTC).minusDays(1))
|
||||
@@ -145,19 +142,19 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertValidateThrowsEppException(AllocationTokenNotValidForTldException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_beforePromoStart() {
|
||||
persistResource(createOneMonthPromoTokenBuilder(DateTime.now(UTC).plusDays(1)).build());
|
||||
assertValidateThrowsEppException(AllocationTokenNotInPromotionException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_afterPromoEnd() {
|
||||
persistResource(createOneMonthPromoTokenBuilder(DateTime.now(UTC).minusMonths(2)).build());
|
||||
assertValidateThrowsEppException(AllocationTokenNotInPromotionException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateToken_promoCancelled() {
|
||||
// the promo would be valid but it was cancelled 12 hours ago
|
||||
persistResource(
|
||||
@@ -172,7 +169,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertValidateThrowsEppException(AllocationTokenNotInPromotionException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_checkDomainsWithToken_successfullyVerifiesValidToken() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
@@ -191,7 +188,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_checkDomainsWithToken_showsFailureMessageForRedeemedToken() {
|
||||
DomainBase domain = persistActiveDomain("example.tld");
|
||||
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1051L);
|
||||
@@ -219,7 +216,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_checkDomainsWithToken_callsCustomLogic() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
@@ -238,7 +235,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("failed for tests");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_checkDomainsWithToken_resultsFromCustomLogicAreIntegrated() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
|
||||
@@ -25,25 +25,23 @@ import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.flows.ResourceCheckFlowTestCase;
|
||||
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link HostCheckFlow}. */
|
||||
@DualDatabaseTest
|
||||
class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, HostResource> {
|
||||
|
||||
HostCheckFlowTest() {
|
||||
setEppInput("host_check.xml");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNothingExists() throws Exception {
|
||||
// These ids come from the check xml.
|
||||
doCheckTest(
|
||||
@@ -52,7 +50,7 @@ class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, HostRes
|
||||
create(true, "ns3.example.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testOneExists() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
// These ids come from the check xml.
|
||||
@@ -62,7 +60,7 @@ class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, HostRes
|
||||
create(true, "ns3.example.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testOneExistsButWasDeleted() throws Exception {
|
||||
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
|
||||
// These ids come from the check xml.
|
||||
@@ -72,27 +70,27 @@ class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, HostRes
|
||||
create(true, "ns3.example.tld", null));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testXmlMatches() throws Exception {
|
||||
persistActiveHost("ns2.example.tld");
|
||||
runFlowAssertResponse(loadFile("host_check_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test50IdsAllowed() throws Exception {
|
||||
// Make sure we don't have a regression that reduces the number of allowed checks.
|
||||
setEppInput("host_check_50.xml");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testTooManyIds() {
|
||||
setEppInput("host_check_51.xml");
|
||||
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-host-check");
|
||||
|
||||
@@ -54,12 +54,10 @@ import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link HostCreateFlow}. */
|
||||
@DualDatabaseTest
|
||||
class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResource> {
|
||||
|
||||
private void setEppHostCreateInput(String hostName, String hostAddrs) {
|
||||
@@ -104,26 +102,26 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
dryRunFlowAssertResponse(loadFile("host_create_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_externalNeverExisted() throws Exception {
|
||||
doSuccessfulTest();
|
||||
assertAboutHosts().that(reloadResourceByForeignKey()).hasSuperordinateDomain(null);
|
||||
assertNoDnsTasksEnqueued();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalNeverExisted() throws Exception {
|
||||
doSuccessfulInternalTest("tld");
|
||||
HostResource host = reloadResourceByForeignKey();
|
||||
@@ -134,7 +132,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns1.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_multipartTLDsAndInvalidHost() {
|
||||
createTlds("bar.tld", "tld");
|
||||
|
||||
@@ -143,7 +141,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_externalExistedButWasDeleted() throws Exception {
|
||||
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
doSuccessfulTest();
|
||||
@@ -151,7 +149,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertNoDnsTasksEnqueued();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalExistedButWasDeleted() throws Exception {
|
||||
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
|
||||
doSuccessfulInternalTest("tld");
|
||||
@@ -163,7 +161,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns1.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_subordinateNeedsIps() {
|
||||
setEppHostCreateInput("ns1.example.tld", null);
|
||||
createTld("tld");
|
||||
@@ -172,7 +170,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_externalMustNotHaveIps() {
|
||||
setEppHostCreateInputWithIps("ns1.example.external");
|
||||
createTld("tld");
|
||||
@@ -181,7 +179,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_superordinateMissing() {
|
||||
setEppHostCreateInput("ns1.example.tld", null);
|
||||
createTld("tld");
|
||||
@@ -190,7 +188,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("(example.tld)");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_superordinateInPendingDelete() {
|
||||
setEppHostCreateInputWithIps("ns1.example.tld");
|
||||
createTld("tld");
|
||||
@@ -208,7 +206,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
.contains("Superordinate domain for this hostname is in pending delete");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_alreadyExists() throws Exception {
|
||||
setEppHostCreateInput("ns1.example.tld", null);
|
||||
persistActiveHost(getUniqueIdFromCommand());
|
||||
@@ -220,7 +218,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_resourceContention() throws Exception {
|
||||
setEppHostCreateInput("ns1.example.tld", null);
|
||||
String targetId = getUniqueIdFromCommand();
|
||||
@@ -237,14 +235,14 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonLowerCaseHostname() {
|
||||
setEppHostCreateInput("ns1.EXAMPLE.tld", null);
|
||||
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonPunyCodedHostname() {
|
||||
setEppHostCreateInput("ns1.çauçalito.みんな", null);
|
||||
HostNameNotPunyCodedException thrown =
|
||||
@@ -252,21 +250,21 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonCanonicalHostname() {
|
||||
setEppHostCreateInput("ns1.example.tld.", null);
|
||||
EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_longHostName() {
|
||||
setEppHostCreateInputWithIps("a" + Strings.repeat(".labelpart", 25) + ".tld");
|
||||
EppException thrown = assertThrows(HostNameTooLongException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_ip4AddressWithIp6Declaration() {
|
||||
setEppHostCreateInput(
|
||||
"ns1.example.tld",
|
||||
@@ -283,37 +281,37 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_badCharacter() {
|
||||
doFailingHostNameTest("foo bar", InvalidHostNameException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tooShallowPublicSuffix() {
|
||||
doFailingHostNameTest("example.tld", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tooShallowCcTld() {
|
||||
doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_barePublicSuffix() {
|
||||
doFailingHostNameTest("com", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_bareCcTld() {
|
||||
doFailingHostNameTest("co.uk", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_tooShallowNewTld() {
|
||||
doFailingHostNameTest("example.lol", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_ccTldInBailiwick() {
|
||||
createTld("co.uk");
|
||||
setEppHostCreateInputWithIps("foo.co.uk");
|
||||
@@ -321,7 +319,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-host-create");
|
||||
|
||||
@@ -50,13 +50,11 @@ import google.registry.model.reporting.HistoryEntry.Type;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link HostDeleteFlow}. */
|
||||
@DualDatabaseTest
|
||||
class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResource> {
|
||||
|
||||
@BeforeEach
|
||||
@@ -64,20 +62,20 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
dryRunFlowAssertResponse(loadFile("host_delete_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
clock.advanceOneMilli();
|
||||
@@ -86,7 +84,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertSqlDeleteSuccess();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clTridNotSpecified() throws Exception {
|
||||
setEppInput("host_delete_no_cltrid.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld"));
|
||||
persistActiveHost("ns1.example.tld");
|
||||
@@ -96,14 +94,14 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertSqlDeleteSuccess();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
assertThat(thrown).hasMessageThat().contains("(ns1.example.tld)");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() {
|
||||
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -121,25 +119,25 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertThat(e).hasMessageThat().contains(statusValue.getXmlName());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasClientDeleteProhibited() {
|
||||
doFailingStatusTest(
|
||||
StatusValue.CLIENT_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasServerDeleteProhibited() {
|
||||
doFailingStatusTest(
|
||||
StatusValue.SERVER_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasPendingDelete() {
|
||||
doFailingStatusTest(
|
||||
StatusValue.PENDING_DELETE, ResourceStatusProhibitsOperationException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClient() {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveHost("ns1.example.tld");
|
||||
@@ -147,7 +145,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveHost("ns1.example.tld");
|
||||
@@ -157,7 +155,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertSqlDeleteSuccess();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_authorizedClientReadFromSuperordinate() throws Exception {
|
||||
sessionMetadata.setRegistrarId("TheRegistrar");
|
||||
createTld("tld");
|
||||
@@ -178,7 +176,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertSqlDeleteSuccess(true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClientReadFromSuperordinate() {
|
||||
sessionMetadata.setRegistrarId("TheRegistrar");
|
||||
createTld("tld");
|
||||
@@ -198,7 +196,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
createTld("tld");
|
||||
@@ -232,7 +230,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertSqlDeleteSuccess(true);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClientReadFromTransferredSuperordinate() {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
createTld("tld");
|
||||
@@ -265,7 +263,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_failfastWhenLinkedToDomain() {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
@@ -277,14 +275,14 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonLowerCaseHostname() {
|
||||
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
|
||||
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonPunyCodedHostname() {
|
||||
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
|
||||
HostNameNotPunyCodedException thrown =
|
||||
@@ -292,14 +290,14 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonCanonicalHostname() {
|
||||
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
|
||||
EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
clock.advanceOneMilli();
|
||||
|
||||
@@ -26,68 +26,65 @@ import google.registry.flows.host.HostFlowUtils.HostNameTooLongException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
|
||||
import google.registry.flows.host.HostFlowUtils.InvalidHostNameException;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link HostFlowUtils}. */
|
||||
@DualDatabaseTest
|
||||
class HostFlowUtilsTest {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validExternalHostName_validates() throws Exception {
|
||||
assertThat(validateHostName("host.example.com").toString()).isEqualTo("host.example.com");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validExternalHostNameOnRegistrySuffixList_validates() throws Exception {
|
||||
assertThat(validateHostName("host.blogspot.com").toString()).isEqualTo("host.blogspot.com");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validExternalHostNameOnRegistrySuffixList_multipartTLD_validates() throws Exception {
|
||||
assertThat(validateHostName("ns1.host.co.uk").toString()).isEqualTo("ns1.host.co.uk");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validExternalHostNameOnRegistrySuffixList_multipartTLD_tooShallow() {
|
||||
assertThrows(
|
||||
HostNameTooShallowException.class, () -> validateHostName("host.co.uk").toString());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateHostName_hostNameTooLong() {
|
||||
assertThrows(
|
||||
HostNameTooLongException.class,
|
||||
() -> validateHostName(Strings.repeat("na", 200) + ".wat.man"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateHostName_hostNameNotLowerCase() {
|
||||
assertThrows(HostNameNotLowerCaseException.class, () -> validateHostName("NA.CAPS.TLD"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateHostName_hostNameNotPunyCoded() {
|
||||
assertThrows(
|
||||
HostNameNotPunyCodedException.class, () -> validateHostName("motörhead.death.metal"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateHostName_hostNameNotNormalized() {
|
||||
assertThrows(HostNameNotNormalizedException.class, () -> validateHostName("root.node.yeah."));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateHostName_hostNameHasLeadingHyphen() {
|
||||
assertThrows(InvalidHostNameException.class, () -> validateHostName("-giga.mega.tld"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void test_validateHostName_hostNameTooShallow() {
|
||||
assertThrows(HostNameTooShallowException.class, () -> validateHostName("domain.tld"));
|
||||
}
|
||||
|
||||
@@ -37,14 +37,12 @@ import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link HostInfoFlow}. */
|
||||
@DualDatabaseTest
|
||||
class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource> {
|
||||
|
||||
@BeforeEach
|
||||
@@ -74,14 +72,14 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
persistHostResource();
|
||||
assertTransactionalFlow(false);
|
||||
@@ -94,7 +92,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
|
||||
assertNoBillingEvents();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_linked() throws Exception {
|
||||
persistHostResource();
|
||||
persistResource(
|
||||
@@ -142,31 +140,31 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
|
||||
assertNoBillingEvents();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_withSuperordinateDomain_hostMovedAfterDomainTransfer() throws Exception {
|
||||
runTest_superordinateDomain(
|
||||
DateTime.parse("2000-01-08T09:00:00.0Z"), DateTime.parse("2000-03-01T01:00:00.0Z"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_withSuperordinateDomain_hostMovedBeforeDomainTransfer() throws Exception {
|
||||
runTest_superordinateDomain(
|
||||
DateTime.parse("2000-04-08T09:00:00.0Z"), DateTime.parse("2000-02-08T09:00:00.0Z"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_withSuperordinateDomain() throws Exception {
|
||||
runTest_superordinateDomain(DateTime.parse("2000-04-08T09:00:00.0Z"), null);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistResource(
|
||||
persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
@@ -175,14 +173,14 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonLowerCaseHostname() {
|
||||
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
|
||||
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonPunyCodedHostname() {
|
||||
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
|
||||
HostNameNotPunyCodedException thrown =
|
||||
@@ -190,14 +188,14 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
|
||||
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_nonCanonicalHostname() {
|
||||
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
|
||||
EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
persistHostResource();
|
||||
runFlow();
|
||||
|
||||
@@ -78,14 +78,12 @@ import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link HostUpdateFlow}. */
|
||||
@DualDatabaseTest
|
||||
class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResource> {
|
||||
|
||||
private void setEppHostUpdateInput(
|
||||
@@ -136,14 +134,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
return getUniqueIdFromCommand();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testNotLoggedIn() {
|
||||
sessionMetadata.setRegistrarId(null);
|
||||
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
@@ -180,7 +178,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
return renamedHost;
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_rename_noOtherHostEverUsedTheOldName() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
@@ -192,7 +190,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(oldFkiAfterRename).isNull();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_withReferencingDomain() throws Exception {
|
||||
createTld("tld");
|
||||
createTld("xn--q9jyb4c");
|
||||
@@ -214,7 +212,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.param("requestedTime", clock.nowUtc().toString()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nameUnchanged_superordinateDomainNeverTransferred() throws Exception {
|
||||
setEppInput("host_update_name_unchanged.xml");
|
||||
createTld("tld");
|
||||
@@ -238,7 +236,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns1.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_nameUnchanged_superordinateDomainWasTransferred() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
setEppInput("host_update_name_unchanged.xml");
|
||||
@@ -264,7 +262,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns1.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalToInternalOnSameDomain() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.tld",
|
||||
@@ -298,7 +296,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns1.example.tld", "ns2.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalToInternalOnSameTld() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns2.foo.tld",
|
||||
@@ -333,7 +331,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns2.foo.tld", "ns2.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalToInternalOnDifferentTld() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.foo",
|
||||
@@ -370,7 +368,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns1.example.foo", "ns2.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalToExternal() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.foo",
|
||||
@@ -413,7 +411,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns1.example.foo");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_externalToInternal() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
|
||||
@@ -425,7 +423,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertNoDnsTasksEnqueued();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExternalToInternal() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
|
||||
@@ -449,7 +447,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertDnsTasksEnqueued("ns2.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_externalToExternal() throws Exception {
|
||||
setEppHostUpdateInput("ns1.example.foo", "ns2.example.tld", null, null);
|
||||
persistActiveHost(oldHostName());
|
||||
@@ -457,7 +455,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserExternalToExternal() throws Exception {
|
||||
setEppHostUpdateInput("ns1.example.foo", "ns2.example.tld", null, null);
|
||||
persistActiveHost(oldHostName());
|
||||
@@ -474,7 +472,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertNoDnsTasksEnqueued();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserClientUpdateProhibited() throws Exception {
|
||||
setEppInput("host_update_add_status.xml");
|
||||
persistResource(
|
||||
@@ -496,7 +494,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasStatusValue(StatusValue.SERVER_UPDATE_PROHIBITED);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_subordToSubord_lastTransferTimeFromPreviousSuperordinateWinsOut()
|
||||
throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
@@ -533,7 +531,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasLastTransferTime(lastTransferTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns2.foo.tld",
|
||||
@@ -572,7 +570,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasLastTransferTime(lastTransferTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut_whenNullOnNewDomain()
|
||||
throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
@@ -608,7 +606,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasLastTransferTime(lastTransferTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWins_whenNullOnBothDomains()
|
||||
throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
@@ -640,7 +638,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasLastTransferTime(lastTransferTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_subordToSubord_lastTransferTimeIsNull_whenNullOnBoth() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns2.foo.tld",
|
||||
@@ -672,7 +670,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasLastTransferTime(null);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromSuperordinate()
|
||||
throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
@@ -711,7 +709,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasLastSuperordinateChange(clock.nowUtc().minusMillis(2));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromHost() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.foo",
|
||||
@@ -746,7 +744,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasLastTransferTime(lastTransferTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_internalToExternal_lastTransferTimeFrozenWhenDomainOverridesHost()
|
||||
throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
@@ -800,14 +798,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasLastTransferTime(hostTransferTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenLessRecent()
|
||||
throws Exception {
|
||||
doExternalToInternalLastTransferTimeTest(
|
||||
clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenMoreRecent()
|
||||
throws Exception {
|
||||
doExternalToInternalLastTransferTimeTest(
|
||||
@@ -815,12 +813,12 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
}
|
||||
|
||||
/** Test when the new superdordinate domain has never been transferred before. */
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenNull() throws Exception {
|
||||
doExternalToInternalLastTransferTimeTest(clock.nowUtc().minusDays(2), null);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_superordinateMissing() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveHost(oldHostName());
|
||||
@@ -829,7 +827,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("(example.tld)");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_superordinateInPendingDelete() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.tld",
|
||||
@@ -854,14 +852,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.contains("Superordinate domain for this hostname is in pending delete");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted() throws Exception {
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_neverExisted_updateWithoutNameChange() throws Exception {
|
||||
setEppInput("host_update_name_unchanged.xml");
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -869,7 +867,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1));
|
||||
ResourceDoesNotExistException thrown =
|
||||
@@ -877,7 +875,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToCurrentName() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
@@ -888,7 +886,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("ns1.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToNameOfExistingOtherHost() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
@@ -898,14 +896,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("ns2.example.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_referToNonLowerCaseHostname() {
|
||||
setEppHostUpdateInput("ns1.EXAMPLE.tld", "ns2.example.tld", null, null);
|
||||
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToNonLowerCaseHostname() {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
setEppHostUpdateInput("ns1.example.tld", "ns2.EXAMPLE.tld", null, null);
|
||||
@@ -913,7 +911,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_referToNonPunyCodedHostname() {
|
||||
setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null);
|
||||
HostNameNotPunyCodedException thrown =
|
||||
@@ -921,7 +919,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToNonPunyCodedHostname() {
|
||||
persistActiveHost("ns1.sausalito.tld");
|
||||
setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null);
|
||||
@@ -930,7 +928,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_referToNonCanonicalHostname() {
|
||||
persistActiveHost("ns1.example.tld.");
|
||||
setEppHostUpdateInput("ns1.example.tld.", "ns2.example.tld", null, null);
|
||||
@@ -938,7 +936,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToNonCanonicalHostname() {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
setEppHostUpdateInput("ns1.example.tld", "ns2.example.tld.", null, null);
|
||||
@@ -946,7 +944,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_subordinateNeedsIps() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.tld",
|
||||
@@ -960,7 +958,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_subordinateToExternal_mustRemoveAllIps() throws Exception {
|
||||
setEppHostUpdateInput("ns1.example.tld", "ns2.example.com", null, null);
|
||||
createTld("tld");
|
||||
@@ -969,7 +967,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_subordinateToExternal_cantAddAnIp() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.tld", "ns2.example.com", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
|
||||
@@ -979,7 +977,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_addRemoveSameStatusValues() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveDomain("example.tld");
|
||||
@@ -993,7 +991,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_addRemoveSameInetAddresses() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
@@ -1006,7 +1004,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clientUpdateProhibited_removed() throws Exception {
|
||||
setEppInput("host_update_remove_client_update_prohibited.xml");
|
||||
persistResource(
|
||||
@@ -1021,7 +1019,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.doesNotHaveStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_clientUpdateProhibited() throws Exception {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
@@ -1035,7 +1033,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_serverUpdateProhibited() throws Exception {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
@@ -1049,7 +1047,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_pendingDelete() throws Exception {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
@@ -1063,7 +1061,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_statusValueNotClientSettable() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
@@ -1072,7 +1070,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserStatusValueNotClientSettable() throws Exception {
|
||||
setEppInput("host_update_prohibited_status.xml");
|
||||
createTld("tld");
|
||||
@@ -1084,7 +1082,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClient() {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveHost("ns1.example.tld");
|
||||
@@ -1092,7 +1090,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_superuserUnauthorizedClient() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
persistActiveHost(oldHostName());
|
||||
@@ -1102,7 +1100,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
CommitMode.DRY_RUN, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_authorizedClientReadFromSuperordinate() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
createTld("tld");
|
||||
@@ -1124,7 +1122,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
runFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClientReadFromSuperordinate() {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
createTld("tld");
|
||||
@@ -1146,7 +1144,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Exception {
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
createTld("tld");
|
||||
@@ -1164,7 +1162,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
runFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_unauthorizedClientReadFromTransferredSuperordinate() {
|
||||
sessionMetadata.setRegistrarId("TheRegistrar");
|
||||
createTld("tld");
|
||||
@@ -1182,7 +1180,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_newSuperordinateOwnedByDifferentRegistrar() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
|
||||
@@ -1202,7 +1200,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_newSuperordinateWasTransferredToDifferentRegistrar() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
|
||||
@@ -1220,7 +1218,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_newSuperordinateWasTransferredToCorrectRegistrar() throws Exception {
|
||||
setEppHostUpdateInput(
|
||||
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
|
||||
@@ -1259,17 +1257,17 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToBadCharacter() throws Exception {
|
||||
doFailingHostNameTest("foo bar", InvalidHostNameException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToNotPunyCoded() throws Exception {
|
||||
doFailingHostNameTest("みんな", HostNameNotPunyCodedException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToTooLong() throws Exception {
|
||||
// Host names can be max 253 chars.
|
||||
String suffix = ".example.tld";
|
||||
@@ -1277,38 +1275,38 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
doFailingHostNameTest(tooLong, HostNameTooLongException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToTooShallowPublicSuffix() throws Exception {
|
||||
doFailingHostNameTest("example.com", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToTooShallowCcTld() throws Exception {
|
||||
doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToBarePublicSuffix() throws Exception {
|
||||
doFailingHostNameTest("com", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToBareCcTld() throws Exception {
|
||||
doFailingHostNameTest("co.uk", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_renameToTooShallowNewTld() throws Exception {
|
||||
doFailingHostNameTest("example.lol", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_ccTldInBailiwick() throws Exception {
|
||||
createTld("co.uk");
|
||||
doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_metadata() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
@@ -1324,7 +1322,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
|
||||
.hasMetadataRequestedByRegistrar(false);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
|
||||
@@ -32,16 +32,14 @@ import google.registry.flows.poll.PollAckFlow.NotAuthorizedToAckMessageException
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link PollAckFlow}. */
|
||||
@DualDatabaseTest
|
||||
class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@@ -87,13 +85,13 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDryRun() throws Exception {
|
||||
persistOneTimePollMessage(MESSAGE_ID);
|
||||
dryRunFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_contactPollMessage() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-2011"));
|
||||
persistResource(
|
||||
@@ -108,7 +106,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_contactPollMessage_withIncorrectYearField() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-1999"));
|
||||
persistResource(
|
||||
@@ -123,14 +121,14 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
assertThrows(MessageDoesNotExistException.class, this::runFlow);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_messageOnContactResource() throws Exception {
|
||||
persistOneTimePollMessage(MESSAGE_ID);
|
||||
assertTransactionalFlow(true);
|
||||
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_recentActiveAutorenew() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2010"));
|
||||
persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), END_OF_TIME);
|
||||
@@ -138,7 +136,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oldActiveAutorenew() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2009"));
|
||||
persistAutorenewPollMessage(clock.nowUtc().minusYears(2), END_OF_TIME);
|
||||
@@ -154,7 +152,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2009", "COUNT", "4")));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_oldInactiveAutorenew() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2010"));
|
||||
persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), clock.nowUtc());
|
||||
@@ -162,7 +160,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_moreMessages() throws Exception {
|
||||
// Create five messages to be queued for retrieval, one of which will be acked.
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@@ -175,28 +173,28 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2011", "COUNT", "4")));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_noSuchMessage() throws Exception {
|
||||
assertTransactionalFlow(true);
|
||||
Exception e = assertThrows(MessageDoesNotExistException.class, this::runFlow);
|
||||
assertThat(e).hasMessageThat().contains(String.format("(1-3-EXAMPLE-4-%d-2011)", MESSAGE_ID));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_invalidId_tooFewComponents() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-2-3"));
|
||||
assertTransactionalFlow(true);
|
||||
assertThrows(InvalidMessageIdException.class, this::runFlow);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_invalidId_tooManyComponents() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-1999-2007"));
|
||||
assertTransactionalFlow(true);
|
||||
assertThrows(InvalidMessageIdException.class, this::runFlow);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_contactPollMessage_withMissingYearField() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3"));
|
||||
persistResource(
|
||||
@@ -211,28 +209,28 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
assertThrows(InvalidMessageIdException.class, this::runFlow);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_invalidId_stringInsteadOfNumeric() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "ABC-12345"));
|
||||
assertTransactionalFlow(true);
|
||||
assertThrows(InvalidMessageIdException.class, this::runFlow);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_invalidEppResourceClassId() throws Exception {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "999-1-1-1"));
|
||||
assertTransactionalFlow(true);
|
||||
assertThrows(InvalidMessageIdException.class, this::runFlow);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_missingId() throws Exception {
|
||||
setEppInput("poll_ack_missing_id.xml");
|
||||
assertTransactionalFlow(true);
|
||||
assertThrows(MissingMessageIdException.class, this::runFlow);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_differentRegistrar() throws Exception {
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
@@ -246,7 +244,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
assertThrows(NotAuthorizedToAckMessageException.class, this::runFlow);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_messageInFuture() throws Exception {
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
|
||||
@@ -40,15 +40,13 @@ import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferResponse.ContactTransferResponse;
|
||||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link PollRequestFlow}. */
|
||||
@DualDatabaseTest
|
||||
class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@@ -91,14 +89,14 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainTransferApproved() throws Exception {
|
||||
persistPendingTransferPollMessage();
|
||||
assertTransactionalFlow(false);
|
||||
runFlowAssertResponse(loadFile("poll_response_domain_transfer.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_clTridNotSpecified() throws Exception {
|
||||
setEppInput("poll_no_cltrid.xml");
|
||||
persistPendingTransferPollMessage();
|
||||
@@ -106,7 +104,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_domain_transfer_no_cltrid.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_contactTransferPending() throws Exception {
|
||||
setRegistrarIdForFlow("TheRegistrar");
|
||||
persistResource(
|
||||
@@ -131,7 +129,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_contact_transfer.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainPendingActionComplete() throws Exception {
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
@@ -151,7 +149,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_domain_pending_notification.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainPendingActionImmediateDelete() throws Exception {
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
@@ -175,7 +173,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_message_domain_pending_action_immediate_delete.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_domainAutorenewMessage() throws Exception {
|
||||
persistResource(
|
||||
new PollMessage.Autorenew.Builder()
|
||||
@@ -189,12 +187,12 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_autorenew.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_empty() throws Exception {
|
||||
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_wrongRegistrar() throws Exception {
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
@@ -206,7 +204,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_futurePollMessage() throws Exception {
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
@@ -218,7 +216,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_futureAutorenew() throws Exception {
|
||||
persistResource(
|
||||
new PollMessage.Autorenew.Builder()
|
||||
@@ -232,7 +230,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_contactDelete() throws Exception {
|
||||
// Contact delete poll messages do not have any response data, so ensure that no
|
||||
// response data block is produced in the poll message.
|
||||
@@ -255,7 +253,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_contact_delete.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_hostDelete() throws Exception {
|
||||
// Host delete poll messages do not have any response data, so ensure that no
|
||||
// response data block is produced in the poll message.
|
||||
@@ -279,7 +277,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
runFlowAssertResponse(loadFile("poll_response_host_delete.xml"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_messageIdProvided() throws Exception {
|
||||
setEppInput("poll_with_id.xml");
|
||||
assertTransactionalFlow(false);
|
||||
|
||||
@@ -23,19 +23,17 @@ import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Ignore;
|
||||
import google.registry.model.common.CrossTldSingleton;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link CreateAutoTimestamp}. */
|
||||
@DualDatabaseTest
|
||||
public class CreateAutoTimestampTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withCloudSql()
|
||||
.withOfyTestEntities(CreateAutoTimestampTestObject.class)
|
||||
.withJpaUnitTestEntities(CreateAutoTimestampTestObject.class)
|
||||
.build();
|
||||
@@ -52,7 +50,7 @@ public class CreateAutoTimestampTest {
|
||||
return loadByEntity(new CreateAutoTimestampTestObject());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSaveSetsTime() {
|
||||
DateTime transactionTime =
|
||||
tm().transact(
|
||||
@@ -66,7 +64,7 @@ public class CreateAutoTimestampTest {
|
||||
assertThat(reload().createTime.timestamp).isEqualTo(transactionTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testResavingRespectsOriginalTime() {
|
||||
final DateTime oldCreateTime = DateTime.now(UTC).minusDays(1);
|
||||
tm().transact(
|
||||
|
||||
@@ -14,33 +14,12 @@
|
||||
|
||||
package google.registry.model;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import com.googlecode.objectify.annotation.Ignore;
|
||||
import com.googlecode.objectify.annotation.Parent;
|
||||
import com.googlecode.objectify.annotation.Serialize;
|
||||
import com.googlecode.objectify.cmd.Query;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.persistence.EppHistoryVKey;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.util.CidrAddressBlock;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@@ -71,7 +50,7 @@ public abstract class EntityTestCase {
|
||||
protected EntityTestCase(JpaEntityCoverageCheck jpaEntityCoverageCheck) {
|
||||
appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withCloudSql()
|
||||
.enableJpaEntityCoverageCheck(jpaEntityCoverageCheck == JpaEntityCoverageCheck.ENABLED)
|
||||
.withClock(fakeClock)
|
||||
.build();
|
||||
@@ -81,121 +60,4 @@ public abstract class EntityTestCase {
|
||||
public void injectClock() {
|
||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
||||
}
|
||||
|
||||
// Helper method to find private fields including inherited ones.
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
while (clazz != Object.class) {
|
||||
try {
|
||||
return clazz.getDeclaredField(name);
|
||||
} catch (NoSuchFieldException e) {
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Verify that fields are either indexed or not, depending on the parameter. */
|
||||
private void verifyIndexingHelper(Object obj, boolean indexed, Collection<String> fieldPaths)
|
||||
throws Exception {
|
||||
outer:
|
||||
for (String fieldPath : fieldPaths) {
|
||||
// Walk the field path and grab the value referred to on the object using reflection.
|
||||
Object fieldValue = obj;
|
||||
for (String fieldName : Splitter.on('.').split(fieldPath)) {
|
||||
if (fieldValue == null) {
|
||||
throw new RuntimeException(
|
||||
String.format(
|
||||
"field '%s' not found on %s", fieldPath, obj.getClass().getSimpleName()));
|
||||
}
|
||||
Field field = getField(fieldValue.getClass(), fieldName);
|
||||
field.setAccessible(true);
|
||||
// Check if the field is annotated with @Id. If it is, it's always indexed. Although we
|
||||
// might want to double check that fact, it's a bad idea, because filtering on a @Id field
|
||||
// will fail if the class also contains an @Parent field.
|
||||
if (field.isAnnotationPresent(Id.class)) {
|
||||
continue outer;
|
||||
}
|
||||
fieldValue = field.get(fieldValue);
|
||||
// Check if the field is a collection. If so, take the first value from the collection,
|
||||
// since we can't query on collections themselves.
|
||||
if (fieldValue instanceof Collection<?>) {
|
||||
fieldValue = ((Collection<?>) fieldValue).iterator().next();
|
||||
}
|
||||
// Same for an array.
|
||||
if (fieldValue != null && fieldValue.getClass().isArray()) {
|
||||
fieldValue = Array.getLength(fieldValue) == 0 ? null : Array.get(fieldValue, 0);
|
||||
}
|
||||
// CidrAddressBlock objects implement the Iterable<InetAddress> interface, which makes
|
||||
// Objectify think we're querying for a list (which is not allowed unless we use the IN
|
||||
// keyword). Convert the object to a String to make sure we do a query for a single value.
|
||||
if (fieldValue instanceof CidrAddressBlock) {
|
||||
fieldValue = fieldValue.toString();
|
||||
}
|
||||
}
|
||||
try {
|
||||
// Objectify happily filters on an unindexed field, and just returns zero results.
|
||||
// Do a query for that value and verify that the expected number of results are returned.
|
||||
Query<?> query = auditedOfy().load().type(obj.getClass());
|
||||
int results = query.filter(fieldPath, fieldValue).count();
|
||||
assertWithMessage(String.format("%s was %sindexed", fieldPath, indexed ? "not " : ""))
|
||||
.that(indexed)
|
||||
.isEqualTo(results != 0);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// If the field's type was not indexable (because it's not a supported Datastore type) then
|
||||
// this error will be thrown. If we expected no indexing, that's fine. Otherwise, fail.
|
||||
if (indexed || !e.getMessage().endsWith(" is not a supported property type.")) {
|
||||
assertWithMessage("%s was %sindexed", fieldPath, indexed ? "not " : "").fail();
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
assertWithMessage("%s (indexed=%b): %s", fieldPath, indexed, e.getMessage()).fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** List all field paths so we can verify that we checked everything. */
|
||||
private Set<String> getAllPotentiallyIndexedFieldPaths(Class<?> clazz) {
|
||||
Set<String> fields = Sets.newHashSet();
|
||||
for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
|
||||
for (final Field field : clazz.getDeclaredFields()) {
|
||||
// Ignore static, @Serialize, @Parent and @Ignore fields, since these are never indexed.
|
||||
if (!Modifier.isStatic(field.getModifiers())
|
||||
&& !field.isAnnotationPresent(Ignore.class)
|
||||
&& !field.isAnnotationPresent(Parent.class)
|
||||
&& !field.isAnnotationPresent(Serialize.class)) {
|
||||
Class<?> fieldClass = field.getType();
|
||||
// If the field is a collection, just pretend that it was a field of that type,
|
||||
// because verifyIndexingHelper knows how to descend into collections.
|
||||
if (Collection.class.isAssignableFrom(fieldClass)) {
|
||||
Type inner = ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0];
|
||||
fieldClass =
|
||||
inner instanceof ParameterizedType
|
||||
? (Class<?>) ((ParameterizedType) inner).getRawType()
|
||||
: (Class<?>) inner;
|
||||
}
|
||||
// Descend into persisted ImmutableObject classes, but not anything else.
|
||||
if (ImmutableObject.class.isAssignableFrom(fieldClass)
|
||||
&& !VKey.class.isAssignableFrom(fieldClass)
|
||||
&& !EppHistoryVKey.class.isAssignableFrom(fieldClass)) {
|
||||
getAllPotentiallyIndexedFieldPaths(fieldClass).stream()
|
||||
.map(subfield -> field.getName() + "." + subfield)
|
||||
.distinct()
|
||||
.forEachOrdered(fields::add);
|
||||
} else {
|
||||
fields.add(field.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
/** Verify Datastore indexing for an entity. */
|
||||
public void verifyDatastoreIndexing(Object obj, String... indexed) throws Exception {
|
||||
Set<String> indexedSet = ImmutableSet.copyOf(indexed);
|
||||
Set<String> allSet = getAllPotentiallyIndexedFieldPaths(obj.getClass());
|
||||
// Sanity test that the indexed fields we listed were found.
|
||||
assertThat(Sets.intersection(allSet, indexedSet)).containsExactlyElementsIn(indexedSet);
|
||||
verifyIndexingHelper(obj, true, indexedSet);
|
||||
verifyIndexingHelper(obj, false, Sets.difference(allSet, indexedSet));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,28 +25,22 @@ import static org.joda.time.DateTimeZone.UTC;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for {@link EppResourceUtils}. */
|
||||
@DualDatabaseTest
|
||||
class EppResourceUtilsTest {
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withClock(clock)
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
||||
@@ -56,7 +50,7 @@ class EppResourceUtilsTest {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadAtPointInTime_beforeCreated_returnsNull() {
|
||||
clock.advanceOneMilli();
|
||||
// Don't save a commit log, we shouldn't need one.
|
||||
@@ -67,7 +61,7 @@ class EppResourceUtilsTest {
|
||||
assertThat(loadAtPointInTime(host, clock.nowUtc().minus(Duration.millis(1)))).isNull();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testLoadAtPointInTime_atOrAfterLastAutoUpdateTime_returnsResource() {
|
||||
clock.advanceOneMilli();
|
||||
// Don't save a commit log, we shouldn't need one.
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ImmutableObjectTest {
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withCloudSql()
|
||||
.withJpaUnitTestEntities(ValueObject.class)
|
||||
.withOfyTestEntities(ValueObject.class)
|
||||
.build();
|
||||
|
||||
@@ -34,8 +34,6 @@ import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tld.Registry.TldState;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.util.CidrAddressBlock;
|
||||
import google.registry.util.SystemClock;
|
||||
import org.joda.money.Money;
|
||||
@@ -43,16 +41,15 @@ import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@DualDatabaseTest
|
||||
public final class OteAccountBuilderTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetRegistrarToTldMap() {
|
||||
assertThat(OteAccountBuilder.forRegistrarId("myclientid").getRegistrarIdToTldMap())
|
||||
.containsExactly(
|
||||
@@ -103,7 +100,7 @@ public final class OteAccountBuilderTest {
|
||||
assertThat(contact.getGaeUserId()).isNotEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_success() {
|
||||
OteAccountBuilder.forRegistrarId("myclientid")
|
||||
.addContact("email@example.com")
|
||||
@@ -122,7 +119,7 @@ public final class OteAccountBuilderTest {
|
||||
assertContactExists("myclientid-5", "email@example.com");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_multipleContacts_success() {
|
||||
OteAccountBuilder.forRegistrarId("myclientid")
|
||||
.addContact("email@example.com")
|
||||
@@ -151,7 +148,7 @@ public final class OteAccountBuilderTest {
|
||||
assertContactExists("myclientid-5", "someone@example.com");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_setPassword() {
|
||||
OteAccountBuilder.forRegistrarId("myclientid").setPassword("myPassword").buildAndPersist();
|
||||
|
||||
@@ -159,7 +156,7 @@ public final class OteAccountBuilderTest {
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_setCertificate() {
|
||||
OteAccountBuilder.forRegistrarId("myclientid")
|
||||
.setCertificate(SAMPLE_CERT, new SystemClock().nowUtc())
|
||||
@@ -171,7 +168,7 @@ public final class OteAccountBuilderTest {
|
||||
.hasValue(SAMPLE_CERT);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_setIpAllowList() {
|
||||
OteAccountBuilder.forRegistrarId("myclientid")
|
||||
.setIpAllowList(ImmutableList.of("1.1.1.0/24"))
|
||||
@@ -181,7 +178,7 @@ public final class OteAccountBuilderTest {
|
||||
.containsExactly(CidrAddressBlock.create("1.1.1.0/24"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_invalidRegistrarId_fails() {
|
||||
assertThat(
|
||||
assertThrows(
|
||||
@@ -190,7 +187,7 @@ public final class OteAccountBuilderTest {
|
||||
.isEqualTo("Invalid registrar name: 3blo-bio");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_clientIdTooShort_fails() {
|
||||
assertThat(
|
||||
assertThrows(
|
||||
@@ -199,7 +196,7 @@ public final class OteAccountBuilderTest {
|
||||
.isEqualTo("Invalid registrar name: bl");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_clientIdTooLong_fails() {
|
||||
assertThat(
|
||||
assertThrows(
|
||||
@@ -209,7 +206,7 @@ public final class OteAccountBuilderTest {
|
||||
.isEqualTo("Invalid registrar name: blobiotoooolong");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_clientIdBadCharacter_fails() {
|
||||
assertThat(
|
||||
assertThrows(
|
||||
@@ -218,7 +215,7 @@ public final class OteAccountBuilderTest {
|
||||
.isEqualTo("Invalid registrar name: blo#bio");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_registrarExists_failsWhenNotReplaceExisting() {
|
||||
persistSimpleResource(makeRegistrar1().asBuilder().setRegistrarId("myclientid-1").build());
|
||||
|
||||
@@ -231,7 +228,7 @@ public final class OteAccountBuilderTest {
|
||||
.contains("Found existing object(s) conflicting with OT&E objects");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_tldExists_failsWhenNotReplaceExisting() {
|
||||
createTld("myclientid-ga", START_DATE_SUNRISE);
|
||||
|
||||
@@ -244,7 +241,7 @@ public final class OteAccountBuilderTest {
|
||||
.contains("Found existing object(s) conflicting with OT&E objects");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_entitiesExist_succeedsWhenReplaceExisting() {
|
||||
persistSimpleResource(makeRegistrar1().asBuilder().setRegistrarId("myclientid-1").build());
|
||||
// we intentionally create the -ga TLD with the wrong state, to make sure it's overwritten.
|
||||
@@ -259,7 +256,7 @@ public final class OteAccountBuilderTest {
|
||||
assertRegistrarExists("myclientid-3", "myclientid-ga");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_doubleCreation_actuallyReplaces() {
|
||||
OteAccountBuilder.forRegistrarId("myclientid")
|
||||
.setPassword("oldPassword")
|
||||
@@ -281,7 +278,7 @@ public final class OteAccountBuilderTest {
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateOteEntities_doubleCreation_keepsOldContacts() {
|
||||
OteAccountBuilder.forRegistrarId("myclientid")
|
||||
.addContact("email@example.com")
|
||||
@@ -298,7 +295,7 @@ public final class OteAccountBuilderTest {
|
||||
assertContactExists("myclientid-3", "email@example.com");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateRegistrarIdToTldMap_validEntries() {
|
||||
assertThat(OteAccountBuilder.createRegistrarIdToTldMap("myclientid"))
|
||||
.containsExactly(
|
||||
@@ -308,7 +305,7 @@ public final class OteAccountBuilderTest {
|
||||
"myclientid-5", "myclientid-eap");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCreateRegistrarIdToTldMap_invalidId() {
|
||||
IllegalArgumentException exception =
|
||||
assertThrows(
|
||||
@@ -316,12 +313,12 @@ public final class OteAccountBuilderTest {
|
||||
assertThat(exception).hasMessageThat().isEqualTo("Invalid registrar name: a");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetBaseRegistrarId_validOteId() {
|
||||
assertThat(OteAccountBuilder.getBaseRegistrarId("myclientid-4")).isEqualTo("myclientid");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetBaseRegistrarId_invalidInput_malformed() {
|
||||
assertThat(
|
||||
assertThrows(
|
||||
@@ -331,7 +328,7 @@ public final class OteAccountBuilderTest {
|
||||
.isEqualTo("Invalid OT&E registrar ID: myclientid");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testGetBaseRegistrarId_invalidInput_wrongForBase() {
|
||||
assertThat(
|
||||
assertThrows(
|
||||
|
||||
@@ -19,24 +19,21 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
|
||||
import google.registry.model.OteStats.StatType;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@DualDatabaseTest
|
||||
public final class OteStatsTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTld("tld");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_allPass() throws Exception {
|
||||
OteStatsTestHelper.setupCompleteOte("blobio");
|
||||
OteStats stats = OteStats.getFromRegistrar("blobio");
|
||||
@@ -44,7 +41,7 @@ public final class OteStatsTest {
|
||||
assertThat(stats.getSize()).isEqualTo(30);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_incomplete() throws Exception {
|
||||
OteStatsTestHelper.setupIncompleteOte("blobio");
|
||||
OteStats stats = OteStats.getFromRegistrar("blobio");
|
||||
@@ -55,7 +52,7 @@ public final class OteStatsTest {
|
||||
assertThat(stats.getSize()).isEqualTo(34);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_toString() throws Exception {
|
||||
OteStatsTestHelper.setupCompleteOte("blobio");
|
||||
OteStats stats = OteStats.getFromRegistrar("blobio");
|
||||
@@ -96,7 +93,7 @@ public final class OteStatsTest {
|
||||
assertThat(stats.toString()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testIncomplete_toString() throws Exception {
|
||||
OteStatsTestHelper.setupIncompleteOte("blobio");
|
||||
OteStats stats = OteStats.getFromRegistrar("blobio");
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
public class SchemaVersionTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@Test
|
||||
void testGoldenSchemaFile() {
|
||||
|
||||
@@ -25,16 +25,14 @@ import google.registry.model.common.CrossTldSingleton;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link UpdateAutoTimestamp}. */
|
||||
@DualDatabaseTest
|
||||
public class UpdateAutoTimestampTest {
|
||||
|
||||
FakeClock clock = new FakeClock();
|
||||
@@ -42,7 +40,7 @@ public class UpdateAutoTimestampTest {
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withCloudSql()
|
||||
.withJpaUnitTestEntities(UpdateAutoTimestampTestObject.class)
|
||||
.withOfyTestEntities(UpdateAutoTimestampTestObject.class)
|
||||
.withClock(clock)
|
||||
@@ -73,7 +71,7 @@ public class UpdateAutoTimestampTest {
|
||||
Key.create(new UpdateAutoTimestampTestObject()))));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSaveSetsTime() {
|
||||
DateTime transactionTime =
|
||||
tm().transact(
|
||||
@@ -88,7 +86,7 @@ public class UpdateAutoTimestampTest {
|
||||
assertThat(reload().updateTime.timestamp).isEqualTo(transactionTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDisabledUpdates() throws Exception {
|
||||
DateTime initialTime =
|
||||
tm().transact(
|
||||
@@ -114,7 +112,7 @@ public class UpdateAutoTimestampTest {
|
||||
assertThat(reload().updateTime.timestamp).isEqualTo(initialTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testResavingOverwritesOriginalTime() {
|
||||
DateTime transactionTime =
|
||||
tm().transact(
|
||||
@@ -129,7 +127,7 @@ public class UpdateAutoTimestampTest {
|
||||
assertThat(reload().updateTime.timestamp).isEqualTo(transactionTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testReadingTwiceDoesNotModify() {
|
||||
DateTime originalTime = DateTime.parse("1999-01-01T00:00:00Z");
|
||||
clock.setTo(originalTime);
|
||||
|
||||
@@ -17,9 +17,6 @@ package google.registry.model.billing;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.ofyTmOrDoNothing;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
@@ -46,18 +43,14 @@ import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.testing.TestOfyOnly;
|
||||
import google.registry.testing.TestSqlOnly;
|
||||
import google.registry.util.DateTimeUtils;
|
||||
import java.math.BigDecimal;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link BillingEvent}. */
|
||||
@DualDatabaseTest
|
||||
public class BillingEventTest extends EntityTestCase {
|
||||
private final DateTime now = DateTime.now(UTC);
|
||||
|
||||
@@ -73,7 +66,6 @@ public class BillingEventTest extends EntityTestCase {
|
||||
private BillingEvent.Recurring recurring;
|
||||
private BillingEvent.Cancellation cancellationOneTime;
|
||||
private BillingEvent.Cancellation cancellationRecurring;
|
||||
private BillingEvent.Modification modification;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
@@ -171,36 +163,22 @@ public class BillingEventTest extends EntityTestCase {
|
||||
.setEventTime(now.plusDays(1))
|
||||
.setBillingTime(now.plusYears(1).plusDays(45))
|
||||
.setRecurringEventKey(recurring.createVKey())));
|
||||
modification =
|
||||
ofyTmOrDoNothing(
|
||||
() ->
|
||||
persistResource(
|
||||
commonInit(
|
||||
new BillingEvent.Modification.Builder()
|
||||
.setParent(domainHistory2)
|
||||
.setReason(Reason.CREATE)
|
||||
.setCost(Money.of(USD, 1))
|
||||
.setDescription("Something happened")
|
||||
.setEventTime(now.plusDays(1))
|
||||
.setEventKey(Key.create(oneTime)))));
|
||||
}
|
||||
|
||||
private <E extends BillingEvent, B extends BillingEvent.Builder<E, B>> E commonInit(B builder) {
|
||||
return builder.setRegistrarId("TheRegistrar").setTargetId("foo.tld").build();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPersistence() {
|
||||
assertThat(loadByEntity(oneTime)).isEqualTo(oneTime);
|
||||
assertThat(loadByEntity(oneTimeSynthetic)).isEqualTo(oneTimeSynthetic);
|
||||
assertThat(loadByEntity(recurring)).isEqualTo(recurring);
|
||||
assertThat(loadByEntity(cancellationOneTime)).isEqualTo(cancellationOneTime);
|
||||
assertThat(loadByEntity(cancellationRecurring)).isEqualTo(cancellationRecurring);
|
||||
|
||||
ofyTmOrDoNothing(() -> assertThat(tm().loadByEntity(modification)).isEqualTo(modification));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testSerializable() {
|
||||
BillingEvent persisted = loadByEntity(oneTime);
|
||||
assertThat(serializeDeserialize(persisted)).isEqualTo(persisted);
|
||||
@@ -214,68 +192,13 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(serializeDeserialize(persisted)).isEqualTo(persisted);
|
||||
}
|
||||
|
||||
@TestOfyOnly
|
||||
void testParenting() {
|
||||
// Note that these are all tested separately because BillingEvent is an abstract base class that
|
||||
// lacks the @Entity annotation, and thus we cannot call .type(BillingEvent.class)
|
||||
assertThat(auditedOfy().load().type(BillingEvent.OneTime.class).ancestor(domain).list())
|
||||
.containsExactly(oneTime, oneTimeSynthetic);
|
||||
assertThat(auditedOfy().load().type(BillingEvent.Recurring.class).ancestor(domain).list())
|
||||
.containsExactly(recurring);
|
||||
assertThat(auditedOfy().load().type(BillingEvent.Cancellation.class).ancestor(domain).list())
|
||||
.containsExactly(cancellationOneTime, cancellationRecurring);
|
||||
assertThat(auditedOfy().load().type(BillingEvent.Modification.class).ancestor(domain).list())
|
||||
.containsExactly(modification);
|
||||
assertThat(auditedOfy().load().type(BillingEvent.OneTime.class).ancestor(domainHistory).list())
|
||||
.containsExactly(oneTime, oneTimeSynthetic);
|
||||
assertThat(
|
||||
auditedOfy().load().type(BillingEvent.Recurring.class).ancestor(domainHistory).list())
|
||||
.containsExactly(recurring);
|
||||
assertThat(
|
||||
auditedOfy()
|
||||
.load()
|
||||
.type(BillingEvent.Cancellation.class)
|
||||
.ancestor(domainHistory2)
|
||||
.list())
|
||||
.containsExactly(cancellationOneTime, cancellationRecurring);
|
||||
assertThat(
|
||||
auditedOfy()
|
||||
.load()
|
||||
.type(BillingEvent.Modification.class)
|
||||
.ancestor(domainHistory2)
|
||||
.list())
|
||||
.containsExactly(modification);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testCancellationMatching() {
|
||||
VKey<?> recurringKey = loadByEntity(oneTimeSynthetic).getCancellationMatchingBillingEvent();
|
||||
assertThat(loadByKey(recurringKey)).isEqualTo(recurring);
|
||||
}
|
||||
|
||||
@TestOfyOnly
|
||||
void testIndexing() throws Exception {
|
||||
verifyDatastoreIndexing(
|
||||
oneTime,
|
||||
"clientId",
|
||||
"eventTime",
|
||||
"billingTime",
|
||||
"syntheticCreationTime",
|
||||
"allocationToken");
|
||||
verifyDatastoreIndexing(
|
||||
oneTimeSynthetic,
|
||||
"clientId",
|
||||
"eventTime",
|
||||
"billingTime",
|
||||
"syntheticCreationTime",
|
||||
"allocationToken");
|
||||
verifyDatastoreIndexing(
|
||||
recurring, "clientId", "eventTime", "recurrenceEndTime", "recurrenceTimeOfYear.timeString");
|
||||
verifyDatastoreIndexing(cancellationOneTime, "clientId", "eventTime", "billingTime");
|
||||
verifyDatastoreIndexing(modification, "clientId", "eventTime");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_syntheticFlagWithoutCreationTime() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -291,7 +214,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
.contains("Synthetic creation time must be set if and only if the SYNTHETIC flag is set.");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_syntheticCreationTimeWithoutFlag() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -302,7 +225,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
.contains("Synthetic creation time must be set if and only if the SYNTHETIC flag is set");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_syntheticFlagWithoutCancellationMatchingKey() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -320,7 +243,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "if and only if the SYNTHETIC flag is set");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_cancellationMatchingKeyWithoutFlag() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -337,7 +260,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "if and only if the SYNTHETIC flag is set");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_cancellation_forGracePeriod_withOneTime() {
|
||||
BillingEvent.Cancellation newCancellation =
|
||||
BillingEvent.Cancellation.forGracePeriod(
|
||||
@@ -350,7 +273,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
.isEqualTo(cancellationOneTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_cancellation_forGracePeriod_withRecurring() {
|
||||
BillingEvent.Cancellation newCancellation =
|
||||
BillingEvent.Cancellation.forGracePeriod(
|
||||
@@ -368,7 +291,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
.isEqualTo(cancellationRecurring);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_cancellation_forGracePeriodWithoutBillingEvent() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
@@ -386,7 +309,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(thrown).hasMessageThat().contains("grace period without billing event");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_cancellationWithNoBillingEvent() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -400,7 +323,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(thrown).hasMessageThat().contains("exactly one billing event");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_cancellationWithBothBillingEvents() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -414,13 +337,13 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(thrown).hasMessageThat().contains("exactly one billing event");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testDeadCodeThatDeletedScrapCommandsReference() {
|
||||
assertThat(recurring.getParentKey()).isEqualTo(Key.create(domainHistory));
|
||||
new BillingEvent.OneTime.Builder().setParent(Key.create(domainHistory));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testReasonRequiringPeriodYears_missingPeriodYears_throwsException() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -441,7 +364,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
.contains("Period years must be set if and only if reason is");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testReasonNotRequiringPeriodYears_havingPeriodYears_throwsException() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -463,7 +386,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
.contains("Period years must be set if and only if reason is");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testReasonRequiringPeriodYears_missingPeriodYears_isAllowedOnOldData() {
|
||||
// This won't throw even though periodYears is missing on a RESTORE because the event time
|
||||
// is before 2019.
|
||||
@@ -478,13 +401,13 @@ public class BillingEventTest extends EntityTestCase {
|
||||
.build();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_defaultRenewalPriceBehavior_assertsIsDefault() {
|
||||
assertThat(recurring.getRenewalPriceBehavior()).isEqualTo(RenewalPriceBehavior.DEFAULT);
|
||||
assertThat(recurring.getRenewalPrice()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_getRenewalPriceBehavior_returnsRightBehavior() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -500,7 +423,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(recurringEvent.getRenewalPrice()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_setRenewalPriceBehaviorThenBuild_defaultToSpecified() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -527,7 +450,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(loadByEntity(recurringEvent).getRenewalPrice()).hasValue(Money.of(USD, 100));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_setRenewalPriceBehaviorThenBuild_defaultToNonPremium() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -550,7 +473,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(loadByEntity(recurringEvent).getRenewalPrice()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_setRenewalPriceBehaviorThenBuild_nonPremiumToSpecified() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -577,7 +500,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(loadByEntity(recurringEvent).getRenewalPrice()).hasValue(Money.of(USD, 100));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_setRenewalPriceBehaviorThenBuild_nonPremiumToDefault() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -600,7 +523,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(loadByEntity(recurringEvent).getRenewalPrice()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_setRenewalPriceBehaviorThenBuild_specifiedToDefault() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -628,7 +551,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(loadByEntity(recurringEvent).getRenewalPrice()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_setRenewalPriceBehaviorThenBuild_specifiedToNonPremium() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -656,7 +579,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(loadByEntity(recurringEvent).getRenewalPrice()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_setRenewalPriceBehaviorThenBuild_defaultToSpecified_needRenewalPrice() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -687,7 +610,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "renewal price behavior is SPECIFIED");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_setRenewalPriceBehaviorThenBuild_defaultToPremium_noNeedToAddRenewalPrice() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -719,7 +642,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "renewal price behavior is SPECIFIED");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_setRenewalPriceBehaviorThenBuild_nonPremiumToDefault_noNeedToAddRenewalPrice() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -751,7 +674,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "renewal price behavior is SPECIFIED");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_setRenewalPriceBehaviorThenBuild_nonPremiumToSpecified_needRenewalPrice() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -782,7 +705,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "renewal price behavior is SPECIFIED");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_setRenewalPriceBehaviorThenBuild_specifiedToNonPremium_removeRenewalPrice() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -814,7 +737,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "renewal price behavior is SPECIFIED");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_setRenewalPriceBehaviorThenBuild_specifiedToDefault_removeRenewalPrice() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -846,7 +769,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "renewal price behavior is SPECIFIED");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_buildWithDefaultRenewalBehavior() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -863,7 +786,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(recurringEvent.getRenewalPrice()).hasValue(Money.of(USD, 100));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_buildWithNonPremiumRenewalBehavior() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -879,7 +802,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(loadByEntity(recurringEvent).getRenewalPrice()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess_buildWithSpecifiedRenewalBehavior() {
|
||||
BillingEvent.Recurring recurringEvent =
|
||||
persistResource(
|
||||
@@ -896,7 +819,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
assertThat(recurringEvent.getRenewalPrice()).hasValue(Money.of(USD, 100));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_buildWithSpecifiedRenewalBehavior_requiresNonNullRenewalPrice() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
@@ -917,7 +840,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "renewal price behavior is SPECIFIED");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_buildWithNonPremiumRenewalBehavior_requiresNullRenewalPrice() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
@@ -939,7 +862,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||
+ "renewal price behavior is SPECIFIED");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testFailure_buildWithDefaultRenewalBehavior_requiresNullRenewalPrice() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
|
||||
@@ -40,7 +40,7 @@ class DomainBaseLiteTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withClock(fakeClock).build();
|
||||
AppEngineExtension.builder().withCloudSql().withClock(fakeClock).build();
|
||||
|
||||
private final TestSetupHelper setupHelper = new TestSetupHelper(fakeClock);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DomainHistoryLiteTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().withClock(fakeClock).build();
|
||||
AppEngineExtension.builder().withCloudSql().withClock(fakeClock).build();
|
||||
|
||||
private final TestSetupHelper setupHelper = new TestSetupHelper(fakeClock);
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
public class GaeUserIdConverterTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
@AfterEach
|
||||
void verifyNoLingeringEntities() {
|
||||
|
||||
@@ -34,8 +34,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
public class ContactCommandTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
|
||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||
|
||||
private void doXmlRoundtripTest(String inputFilename) throws Exception {
|
||||
EppLoader eppLoader = new EppLoader(this, inputFilename);
|
||||
|
||||
@@ -39,15 +39,11 @@ import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.transfer.ContactTransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import google.registry.testing.TestOfyOnly;
|
||||
import google.registry.testing.TestSqlOnly;
|
||||
import google.registry.util.SerializeUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link ContactResource}. */
|
||||
@DualDatabaseTest
|
||||
public class ContactResourceTest extends EntityTestCase {
|
||||
|
||||
private ContactResource originalContact;
|
||||
@@ -126,14 +122,14 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
contactResource = persistResource(cloneAndSetAutoTimestamps(originalContact));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testContactBaseToContactResource() {
|
||||
assertAboutImmutableObjects()
|
||||
.that(new ContactResource.Builder().copyFrom(contactResource).build())
|
||||
.isEqualExceptFields(contactResource, "updateTimestamp", "revisions");
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testCloudSqlPersistence_failWhenViolateForeignKeyConstraint() {
|
||||
assertThrowForeignKeyViolation(
|
||||
() ->
|
||||
@@ -145,7 +141,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
.build()));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testCloudSqlPersistence_succeed() {
|
||||
ContactResource persisted = loadByEntity(originalContact);
|
||||
ContactResource fixed =
|
||||
@@ -162,7 +158,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
assertAboutImmutableObjects().that(persisted).isEqualExceptFields(fixed, "updateTimestamp");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testPersistence() {
|
||||
assertThat(
|
||||
loadByForeignKey(
|
||||
@@ -170,7 +166,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
.hasValue(contactResource);
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testSerializable() {
|
||||
ContactResource persisted =
|
||||
loadByForeignKey(ContactResource.class, contactResource.getForeignKey(), fakeClock.nowUtc())
|
||||
@@ -178,13 +174,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
|
||||
}
|
||||
|
||||
@TestOfyOnly
|
||||
void testIndexing() throws Exception {
|
||||
verifyDatastoreIndexing(
|
||||
contactResource, "deletionTime", "currentSponsorClientId", "searchName");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testEmptyStringsBecomeNull() {
|
||||
assertThat(new ContactResource.Builder().setContactId(null).build().getContactId()).isNull();
|
||||
assertThat(new ContactResource.Builder().setContactId("").build().getContactId()).isNull();
|
||||
@@ -216,7 +206,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testEmptyTransferDataBecomesNull() {
|
||||
ContactResource withNull = new ContactResource.Builder().setTransferData(null).build();
|
||||
ContactResource withEmpty =
|
||||
@@ -225,7 +215,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
assertThat(withEmpty.transferData).isNull();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testImplicitStatusValues() {
|
||||
// OK is implicit if there's no other statuses.
|
||||
assertAboutContacts()
|
||||
@@ -247,7 +237,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
.hasExactlyStatusValues(StatusValue.CLIENT_HOLD);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testExpiredTransfer() {
|
||||
ContactResource afterTransfer =
|
||||
contactResource
|
||||
@@ -268,7 +258,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
assertThat(afterTransfer.getLastTransferTime()).isEqualTo(fakeClock.nowUtc().plusDays(1));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSetCreationTime_cantBeCalledTwice() {
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
@@ -277,7 +267,7 @@ public class ContactResourceTest extends EntityTestCase {
|
||||
assertThat(thrown).hasMessageThat().contains("creationTime can only be set once");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testToHydratedString_notCircular() {
|
||||
// If there are circular references, this will overflow the stack.
|
||||
contactResource.toHydratedString();
|
||||
|
||||
@@ -53,19 +53,17 @@ import google.registry.model.transfer.ContactTransferData;
|
||||
import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.TestSqlOnly;
|
||||
import google.registry.util.SerializeUtils;
|
||||
import java.util.Arrays;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
|
||||
|
||||
/** Verify that we can store/retrieve DomainBase objects from a SQL database. */
|
||||
@DualDatabaseTest
|
||||
public class DomainBaseSqlTest {
|
||||
|
||||
protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
|
||||
@@ -73,7 +71,7 @@ public class DomainBaseSqlTest {
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withCloudSql()
|
||||
.enableJpaEntityCoverageCheck(true)
|
||||
.withClock(fakeClock)
|
||||
.build();
|
||||
@@ -141,25 +139,25 @@ public class DomainBaseSqlTest {
|
||||
contact2 = makeContact("contact_id2");
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testDomainBasePersistence() {
|
||||
persistDomain();
|
||||
assertEqualDomainExcept(loadByKey(domain.createVKey()));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testHostForeignKeyConstraints() {
|
||||
// Persist the domain without the associated host object.
|
||||
assertThrowForeignKeyViolation(() -> insertInDb(contact, contact2, domain));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testContactForeignKeyConstraints() {
|
||||
// Persist the domain without the associated contact objects.
|
||||
assertThrowForeignKeyViolation(() -> insertInDb(domain, host));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testResaveDomain_succeeds() {
|
||||
persistDomain();
|
||||
jpaTm()
|
||||
@@ -172,7 +170,7 @@ public class DomainBaseSqlTest {
|
||||
assertEqualDomainExcept(loadByKey(domain.createVKey()));
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testModifyGracePeriod_setEmptyCollectionSuccessfully() {
|
||||
persistDomain();
|
||||
jpaTm()
|
||||
@@ -192,7 +190,7 @@ public class DomainBaseSqlTest {
|
||||
});
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testModifyGracePeriod_setNullCollectionSuccessfully() {
|
||||
persistDomain();
|
||||
jpaTm()
|
||||
@@ -211,7 +209,7 @@ public class DomainBaseSqlTest {
|
||||
});
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testModifyGracePeriod_addThenRemoveSuccessfully() {
|
||||
persistDomain();
|
||||
jpaTm()
|
||||
@@ -267,7 +265,7 @@ public class DomainBaseSqlTest {
|
||||
});
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testModifyGracePeriod_removeThenAddSuccessfully() {
|
||||
persistDomain();
|
||||
jpaTm()
|
||||
@@ -311,7 +309,7 @@ public class DomainBaseSqlTest {
|
||||
});
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testModifyDsData_addThenRemoveSuccessfully() {
|
||||
persistDomain();
|
||||
DelegationSignerData extraDsData =
|
||||
@@ -355,7 +353,7 @@ public class DomainBaseSqlTest {
|
||||
});
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testSerializable() {
|
||||
createTld("com");
|
||||
insertInDb(contact, contact2, domain, host);
|
||||
@@ -363,7 +361,7 @@ public class DomainBaseSqlTest {
|
||||
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testUpdates() {
|
||||
createTld("com");
|
||||
insertInDb(contact, contact2, domain, host);
|
||||
@@ -388,7 +386,7 @@ public class DomainBaseSqlTest {
|
||||
insertInDb(contact, contact2, domain, host);
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void persistDomainWithCompositeVKeys() {
|
||||
createTld("com");
|
||||
historyEntry =
|
||||
@@ -515,7 +513,7 @@ public class DomainBaseSqlTest {
|
||||
assertThat(persisted.getGracePeriods()).isEqualTo(gracePeriods);
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void persistDomainWithLegacyVKeys() {
|
||||
createTld("com");
|
||||
historyEntry =
|
||||
@@ -676,7 +674,7 @@ public class DomainBaseSqlTest {
|
||||
.isEqualExceptFields(thatDomain.getTransferData(), "serverApproveEntities");
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testUpdateTimeAfterNameserverUpdate() {
|
||||
persistDomain();
|
||||
DomainBase persisted = loadByKey(domain.createVKey());
|
||||
@@ -703,7 +701,7 @@ public class DomainBaseSqlTest {
|
||||
assertThat(domain.getUpdateTimestamp().getTimestamp()).isNotEqualTo(originalUpdateTime);
|
||||
}
|
||||
|
||||
@TestSqlOnly
|
||||
@Test
|
||||
void testUpdateTimeAfterDsDataUpdate() {
|
||||
persistDomain();
|
||||
DomainBase persisted = loadByKey(domain.createVKey());
|
||||
|
||||
@@ -81,7 +81,7 @@ public class DomainBaseTest {
|
||||
@RegisterExtension
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withCloudSql()
|
||||
.enableJpaEntityCoverageCheck(true)
|
||||
.withClock(fakeClock)
|
||||
.build();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user