Refactor ForeignKeyIndex into ForeignKeyUtils (#1783)

The old class is modeled after datastore with some logic jammed in for it to work with SQL as well. As of #1777, the ofy related logic is deleted, however the general structure of the class remained datastore oriented.

This PR refactors the existing class into a ForeignKeyUtils helper class that does away wit the index subclasses and provides static helper methods to do the same, in a SQL-idiomatic fashion.

Some minor changes are made to the EPP resource classes to make it possible to create them in a SQL only environment in tests.
This commit is contained in:
Lai Jiang
2022-09-19 14:41:19 -04:00
committed by GitHub
parent 775f672f2a
commit c4c1c72306
31 changed files with 487 additions and 573 deletions
@@ -98,7 +98,7 @@ public class ResaveEntityActionTest {
clock.advanceOneMilli();
assertThat(domain.getCurrentSponsorRegistrarId()).isEqualTo("TheRegistrar");
runAction(
domain.createVKey().getOfyKey().getString(),
domain.createVKey().stringify(),
DateTime.parse("2016-02-06T10:00:01Z"),
ImmutableSortedSet.of());
Domain resavedDomain = loadByEntity(domain);
@@ -128,7 +128,7 @@ public class ResaveEntityActionTest {
assertThat(domain.getGracePeriods()).isNotEmpty();
runAction(
domain.createVKey().getOfyKey().getString(),
domain.createVKey().stringify(),
requestedTime,
ImmutableSortedSet.of(requestedTime.plusDays(5)));
Domain resavedDomain = loadByEntity(domain);
@@ -104,7 +104,7 @@ public class PublishDnsUpdatesActionTest {
persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain1);
persistActiveSubordinateHost("ns2.example.xn--q9jyb4c", domain1);
Domain domain2 = persistActiveDomain("example2.xn--q9jyb4c");
persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain2);
persistActiveSubordinateHost("ns1.example2.xn--q9jyb4c", domain2);
clock.advanceOneMilli();
}
@@ -52,7 +52,6 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
}
private void doSuccessfulTest() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
@@ -83,6 +82,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
@Test
void testSuccess() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
doSuccessfulTest();
}
@@ -403,6 +403,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
@Test
void testSuccess_nonAsciiInLocAddress() throws Exception {
setEppInput("contact_update_hebrew_loc.xml");
persistActiveContact(getUniqueIdFromCommand());
doSuccessfulTest();
}
@@ -442,7 +442,6 @@ class DomainTransferApproveFlowTest
.setLabelsToPrices(ImmutableMap.of("example", new BigDecimal("67.89")))
.build());
persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build());
setupDomainWithPendingTransfer("example", "tld");
domain = loadByEntity(domain);
persistResource(
loadByKey(domain.getAutorenewBillingEvent())
@@ -489,7 +488,6 @@ class DomainTransferApproveFlowTest
.setLabelsToPrices(ImmutableMap.of("example", new BigDecimal("67.89")))
.build());
persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build());
setupDomainWithPendingTransfer("example", "tld");
domain = loadByEntity(domain);
persistResource(
loadByKey(domain.getAutorenewBillingEvent())
@@ -1475,9 +1475,6 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_addPendingDeleteContact() throws Exception {
persistReferencedEntities();
persistDomain();
persistActiveHost("ns1.example.foo");
persistActiveHost("ns2.example.foo");
persistActiveContact("sh8013");
persistResource(
loadByForeignKey(Contact.class, "mak21", clock.nowUtc())
.get()
@@ -1494,9 +1491,6 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_addPendingDeleteHost() throws Exception {
persistReferencedEntities();
persistDomain();
persistActiveHost("ns1.example.foo");
persistActiveContact("mak21");
persistActiveContact("sh8013");
persistResource(
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc())
.get()
@@ -69,14 +69,15 @@ import google.registry.flows.host.HostUpdateFlow.CannotRemoveSubordinateHostLast
import google.registry.flows.host.HostUpdateFlow.CannotRenameExternalHostException;
import google.registry.flows.host.HostUpdateFlow.HostAlreadyExistsException;
import google.registry.flows.host.HostUpdateFlow.RenameHostToExternalRemoveIpException;
import google.registry.model.ForeignKeyUtils;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.Host;
import google.registry.model.index.ForeignKeyIndex;
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.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.TaskQueueHelper.TaskMatcher;
import javax.annotation.Nullable;
@@ -184,9 +185,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
Host renamedHost = doSuccessfulTest();
assertThat(renamedHost.isSubordinate()).isTrue();
assertDnsTasksEnqueued("ns1.example.tld", "ns2.example.tld");
ForeignKeyIndex<Host> oldFkiAfterRename =
ForeignKeyIndex.load(Host.class, oldHostName(), clock.nowUtc());
assertThat(oldFkiAfterRename).isNull();
VKey<Host> oldVKeyAfterRename = ForeignKeyUtils.load(Host.class, oldHostName(), clock.nowUtc());
assertThat(oldVKeyAfterRename).isNull();
}
@Test
@@ -982,13 +982,13 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
@Test
void testFailure_addRemoveSameStatusValues() throws Exception {
createTld("tld");
persistActiveDomain("example.tld");
Domain domain = persistActiveDomain("example.tld");
setEppHostUpdateInput(
"ns1.example.tld",
"ns2.example.tld",
"<host:status s=\"clientUpdateProhibited\"/>",
"<host:status s=\"clientUpdateProhibited\"/>");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
persistActiveSubordinateHost(oldHostName(), domain);
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@@ -0,0 +1,153 @@
// Copyright 2022 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.model;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain;
import google.registry.model.host.Host;
import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
import google.registry.testing.FakeClock;
import google.registry.testing.TestCacheExtension;
import java.time.Duration;
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 ForeignKeyUtils}. */
class ForeignKeyUtilsTest {
private final FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
@RegisterExtension
public final JpaIntegrationTestExtension jpaIntegrationTestExtension =
new JpaTestExtensions.Builder().withClock(fakeClock).buildIntegrationTestExtension();
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withForeignKeyCache(Duration.ofDays(1)).build();
@BeforeEach
void setUp() {
createTld("com");
}
@Test
void testSuccess_loadHost() {
Host host = persistActiveHost("ns1.example.com");
assertThat(ForeignKeyUtils.load(Host.class, "ns1.example.com", fakeClock.nowUtc()))
.isEqualTo(host.createVKey());
}
@Test
void testSuccess_loadDomain() {
Domain domain = persistActiveDomain("example.com");
assertThat(ForeignKeyUtils.load(Domain.class, "example.com", fakeClock.nowUtc()))
.isEqualTo(domain.createVKey());
}
@Test
void testSuccess_loadContact() {
Contact contact = persistActiveContact("john-doe");
assertThat(ForeignKeyUtils.load(Contact.class, "john-doe", fakeClock.nowUtc()))
.isEqualTo(contact.createVKey());
}
@Test
void testSuccess_loadMostRecentResource() {
Host host = persistActiveHost("ns1.example.com");
persistResource(host.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build());
fakeClock.advanceOneMilli();
Host newHost = persistActiveHost("ns1.example.com");
assertThat(ForeignKeyUtils.load(Host.class, "ns1.example.com", fakeClock.nowUtc()))
.isEqualTo(newHost.createVKey());
}
@Test
void testSuccess_loadNonexistentForeignKey_returnsNull() {
assertThat(ForeignKeyUtils.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testSuccess_loadDeletedForeignKey_returnsNull() {
Host host = persistActiveHost("ns1.example.com");
persistResource(host.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build());
assertThat(ForeignKeyUtils.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testSuccess_mostRecentKeySoftDeleted_returnsNull() {
Host host1 = persistActiveHost("ns1.example.com");
fakeClock.advanceOneMilli();
persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build());
assertThat(ForeignKeyUtils.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testSuccess_batchLoad_skipsDeletedAndNonexistent() {
Host host1 = persistActiveHost("ns1.example.com");
Host host2 = persistActiveHost("ns2.example.com");
persistResource(host2.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build());
assertThat(
ForeignKeyUtils.load(
Host.class,
ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"),
fakeClock.nowUtc()))
.containsExactlyEntriesIn(ImmutableMap.of("ns1.example.com", host1.createVKey()));
persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build());
fakeClock.advanceOneMilli();
Host newHost1 = persistActiveHost("ns1.example.com");
assertThat(
ForeignKeyUtils.loadCached(
Host.class,
ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"),
fakeClock.nowUtc()))
.containsExactlyEntriesIn(ImmutableMap.of("ns1.example.com", newHost1.createVKey()));
}
@Test
void testSuccess_loadHostsCached_cacheIsStale() {
Host host1 = persistActiveHost("ns1.example.com");
Host host2 = persistActiveHost("ns2.example.com");
persistResource(host2.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build());
assertThat(
ForeignKeyUtils.loadCached(
Host.class,
ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"),
fakeClock.nowUtc()))
.containsExactlyEntriesIn(ImmutableMap.of("ns1.example.com", host1.createVKey()));
persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build());
fakeClock.advanceOneMilli();
persistActiveHost("ns1.example.com");
// Even though a new host1 is now live, the cache still returns the VKey to the old one.
assertThat(
ForeignKeyUtils.loadCached(
Host.class,
ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"),
fakeClock.nowUtc()))
.containsExactlyEntriesIn(ImmutableMap.of("ns1.example.com", host1.createVKey()));
}
}
@@ -168,9 +168,8 @@ public class DomainTest {
domain =
persistResource(
cloneAndSetAutoTimestamps(
new Domain.Builder()
.setDomainName("example.com")
.setRepoId("4-COM")
domain
.asBuilder()
.setCreationRegistrarId("TheRegistrar")
.setLastEppUpdateTime(fakeClock.nowUtc())
.setLastEppUpdateRegistrarId("NewRegistrar")
@@ -1,83 +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.model.index;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import com.google.common.collect.ImmutableList;
import google.registry.model.EntityTestCase;
import google.registry.model.host.Host;
import google.registry.testing.TestCacheExtension;
import java.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link ForeignKeyIndex}. */
class ForeignKeyIndexTest extends EntityTestCase {
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withForeignIndexKeyCache(Duration.ofDays(1)).build();
@BeforeEach
void setUp() {
createTld("com");
}
@Test
void testLoadForNonexistentForeignKey_returnsNull() {
assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testLoadForDeletedForeignKey_returnsNull() {
Host host = persistActiveHost("ns1.example.com");
persistResource(host.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build());
assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testLoad_newerKeyHasBeenSoftDeleted() {
Host host1 = persistActiveHost("ns1.example.com");
fakeClock.advanceOneMilli();
persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build());
assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testBatchLoad_skipsDeletedAndNonexistent() {
persistActiveHost("ns1.example.com");
Host host = persistActiveHost("ns2.example.com");
persistResource(host.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build());
assertThat(
ForeignKeyIndex.load(
Host.class,
ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"),
fakeClock.nowUtc())
.keySet())
.containsExactly("ns1.example.com");
}
@Test
void testDeadCodeThatDeletedScrapCommandsReference() {
persistActiveHost("omg");
assertThat(ForeignKeyIndex.load(Host.class, "omg", fakeClock.nowUtc()).getForeignKey())
.isEqualTo("omg");
}
}
@@ -15,13 +15,13 @@
package google.registry.testing;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import google.registry.model.EppResource;
import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.ForeignKeyUtils;
import google.registry.model.tld.label.PremiumListDao;
import google.registry.model.tmch.ClaimsListDao;
import java.time.Duration;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
@@ -53,37 +53,30 @@ public class TestCacheExtension implements BeforeEachCallback, AfterEachCallback
/** Builder for {@link TestCacheExtension}. */
public static class Builder {
private final Map<String, TestCacheHandler> cacheHandlerMap = Maps.newHashMap();
private final List<TestCacheHandler> cacheHandlers = new ArrayList<>();
public Builder withEppResourceCache(Duration expiry) {
cacheHandlerMap.put(
"EppResource.cacheEppResources",
new TestCacheHandler(EppResource::setCacheForTest, expiry));
cacheHandlers.add(new TestCacheHandler(EppResource::setCacheForTest, expiry));
return this;
}
public Builder withForeignIndexKeyCache(Duration expiry) {
cacheHandlerMap.put(
"ForeignKeyIndex.cacheForeignKeyIndexes",
new TestCacheHandler(ForeignKeyIndex::setCacheForTest, expiry));
public Builder withForeignKeyCache(Duration expiry) {
cacheHandlers.add(new TestCacheHandler(ForeignKeyUtils::setCacheForTest, expiry));
return this;
}
public Builder withPremiumListsCache(Duration expiry) {
cacheHandlerMap.put(
"PremiumListSqlDao.premiumListCache",
new TestCacheHandler(PremiumListDao::setPremiumListCacheForTest, expiry));
cacheHandlers.add(new TestCacheHandler(PremiumListDao::setPremiumListCacheForTest, expiry));
return this;
}
public Builder withClaimsListCache(Duration expiry) {
cacheHandlerMap.put(
"ClaimsListDao.CACHE", new TestCacheHandler(ClaimsListDao::setCacheForTest, expiry));
cacheHandlers.add(new TestCacheHandler(ClaimsListDao::setCacheForTest, expiry));
return this;
}
public TestCacheExtension build() {
return new TestCacheExtension(ImmutableList.copyOf(cacheHandlerMap.values()));
return new TestCacheExtension(ImmutableList.copyOf(cacheHandlers));
}
}
@@ -42,11 +42,7 @@ class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
persistActiveContact("sh8013");
runCommand("sh8013");
assertInStdout("contactId=sh8013");
assertInStdout(
"Websafe key: "
+ "kind:Contact"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chMLEgdDb250YWN0IgYyLVJPSUQM");
assertInStdout("Websafe key: " + "kind:Contact" + "@sql:rO0ABXQABjItUk9JRA");
}
@Test
@@ -54,11 +50,7 @@ class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
persistActiveContact("sh8013");
runCommand("sh8013", "--expand");
assertInStdout("contactId=sh8013");
assertInStdout(
"Websafe key: "
+ "kind:Contact"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chMLEgdDb250YWN0IgYyLVJPSUQM");
assertInStdout("Websafe key: " + "kind:Contact" + "@sql:rO0ABXQABjItUk9JRA");
assertNotInStdout("LiveRef");
}
@@ -69,16 +61,8 @@ class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
runCommand("sh8013", "jd1234");
assertInStdout("contactId=sh8013");
assertInStdout("contactId=jd1234");
assertInStdout(
"Websafe key: "
+ "kind:Contact"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chMLEgdDb250YWN0IgYyLVJPSUQM");
assertInStdout(
"Websafe key: "
+ "kind:Contact"
+ "@sql:rO0ABXQABjMtUk9JRA"
+ "@ofy:agR0ZXN0chMLEgdDb250YWN0IgYzLVJPSUQM");
assertInStdout("Websafe key: " + "kind:Contact" + "@sql:rO0ABXQABjItUk9JRA");
assertInStdout("Websafe key: " + "kind:Contact" + "@sql:rO0ABXQABjMtUk9JRA");
}
@Test
@@ -39,11 +39,7 @@ class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
runCommand("example.tld");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("Contact=VKey<Contact>(sql:3-ROID");
assertInStdout(
"Websafe key: "
+ "kind:Domain"
+ "@sql:rO0ABXQABTItVExE"
+ "@ofy:agR0ZXN0chELEgZEb21haW4iBTItVExEDA");
assertInStdout("Websafe key: " + "kind:Domain" + "@sql:rO0ABXQABTItVExE");
}
@Test
@@ -52,11 +48,7 @@ class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
runCommand("example.tld", "--expand");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("sqlKey=3-ROID");
assertInStdout(
"Websafe key: "
+ "kind:Domain"
+ "@sql:rO0ABXQABTItVExE"
+ "@ofy:agR0ZXN0chELEgZEb21haW4iBTItVExEDA");
assertInStdout("Websafe key: " + "kind:Domain" + "@sql:rO0ABXQABTItVExE");
assertNotInStdout("LiveRef");
}
@@ -76,16 +68,8 @@ class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
runCommand("example.tld", "example2.tld");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("fullyQualifiedDomainName=example2.tld");
assertInStdout(
"Websafe key: "
+ "kind:Domain"
+ "@sql:rO0ABXQABTItVExE"
+ "@ofy:agR0ZXN0chELEgZEb21haW4iBTItVExEDA");
assertInStdout(
"Websafe key: "
+ "kind:Domain"
+ "@sql:rO0ABXQABTQtVExE"
+ "@ofy:agR0ZXN0chELEgZEb21haW4iBTQtVExEDA");
assertInStdout("Websafe key: " + "kind:Domain" + "@sql:rO0ABXQABTItVExE");
assertInStdout("Websafe key: " + "kind:Domain" + "@sql:rO0ABXQABTQtVExE");
}
@Test
@@ -42,11 +42,7 @@ class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
persistActiveHost("ns1.example.tld");
runCommand("ns1.example.tld");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout(
"Websafe key: "
+ "kind:Host"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM");
assertInStdout("Websafe key: " + "kind:Host" + "@sql:rO0ABXQABjItUk9JRA");
}
@Test
@@ -54,11 +50,7 @@ class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
persistActiveHost("ns1.example.tld");
runCommand("ns1.example.tld", "--expand");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout(
"Websafe key: "
+ "kind:Host"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM");
assertInStdout("Websafe key: " + "kind:Host" + "@sql:rO0ABXQABjItUk9JRA");
assertNotInStdout("LiveRef");
}
@@ -69,16 +61,8 @@ class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
runCommand("ns1.example.tld", "ns2.example.tld");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout("fullyQualifiedHostName=ns2.example.tld");
assertInStdout(
"Websafe key: "
+ "kind:Host"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM");
assertInStdout(
"Websafe key: "
+ "kind:Host"
+ "@sql:rO0ABXQABjMtUk9JRA"
+ "@ofy:agR0ZXN0chALEgRIb3N0IgYzLVJPSUQM");
assertInStdout("Websafe key: " + "kind:Host" + "@sql:rO0ABXQABjItUk9JRA");
assertInStdout("Websafe key: " + "kind:Host" + "@sql:rO0ABXQABjMtUk9JRA");
}
@Test
@@ -160,11 +160,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
.asBuilder()
.setNameservers(ImmutableSet.of(host1.createVKey()))
.build());
persistResource(
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(host2.createVKey()))
.build());
persistResource(domain.asBuilder().setNameservers(ImmutableSet.of(host2.createVKey())).build());
runCommandForced(
"--client=NewRegistrar", nsParam, "example.abc", "example.tld");
eppVerifier
@@ -228,8 +224,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
Host host1 = persistActiveHost("ns1.zdns.google");
Host host2 = persistActiveHost("ns2.zdns.google");
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(host1.createVKey(), host2.createVKey());
persistResource(
DatabaseHelper.newDomain("example.tld").asBuilder().setNameservers(nameservers).build());
persistResource(domain.asBuilder().setNameservers(nameservers).build());
runCommandForced(
"--client=NewRegistrar", "--nameservers=ns2.zdns.google,ns3.zdns.google", "example.tld");
eppVerifier.verifySent("domain_update_set_nameservers.xml");
@@ -243,7 +238,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
VKey<Contact> techContactKey = techContact.createVKey();
persistResource(
DatabaseHelper.newDomain("example.tld")
domain
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -261,7 +256,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
Host host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
DatabaseHelper.newDomain("example.tld")
domain
.asBuilder()
.setStatusValues(
ImmutableSet.of(
@@ -370,7 +365,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
VKey<Contact> techContactKey = techContact.createVKey();
persistResource(
DatabaseHelper.newDomain("example.tld")
domain
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -394,7 +389,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
Host host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
DatabaseHelper.newDomain("example.tld")
domain
.asBuilder()
.setStatusValues(ImmutableSet.of(SERVER_UPDATE_PROHIBITED))
.setNameservers(nameservers)
@@ -419,7 +414,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
Host host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
DatabaseHelper.newDomain("example.tld")
domain
.asBuilder()
.setStatusValues(ImmutableSet.of(PENDING_DELETE))
.setNameservers(nameservers)
@@ -398,7 +398,7 @@ class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
server.runInAppEngineEnvironment(
() -> {
createTld("tld");
persistResource(DatabaseHelper.newDomain("example.tld"));
persistResource(DatabaseHelper.newDomain("example-lock.tld"));
saveRegistryLock(
new RegistryLock.Builder()
.setRegistrarPocId("johndoe@theregistrar.com")
@@ -406,7 +406,7 @@ class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
.setRegistrarId("TheRegistrar")
.setVerificationCode("f1be78a2-2d61-458c-80f0-9dd8f2f8625f")
.isSuperuser(false)
.setDomainName("example.tld")
.setDomainName("example-lock.tld")
.build());
return null;
});
@@ -81,7 +81,7 @@ public class WhoisActionTest {
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder()
.withEppResourceCache(Duration.ofDays(1))
.withForeignIndexKeyCache(Duration.ofDays(1))
.withForeignKeyCache(Duration.ofDays(1))
.build();
private final FakeResponse response = new FakeResponse();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB