Rename HostResource -> Host (#1733)

* Rename HostResource -> Host
This commit is contained in:
Ben McIlwain
2022-08-05 10:28:45 -04:00
committed by GitHub
parent ad06ba2e1e
commit 0e182546f9
119 changed files with 985 additions and 1032 deletions
@@ -37,7 +37,7 @@ import com.google.cloud.tasks.v2.HttpMethod;
import com.google.common.collect.ImmutableSet;
import google.registry.model.domain.Domain;
import google.registry.model.domain.RegistryLock;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.CloudTasksHelper;
import google.registry.testing.CloudTasksHelper.TaskMatcher;
@@ -95,7 +95,7 @@ public class RelockDomainActionTest {
@BeforeEach
void beforeEach() throws Exception {
createTlds("tld", "net");
HostResource host = persistActiveHost("ns1.example.net");
Host host = persistActiveHost("ns1.example.net");
domain = persistResource(DatabaseHelper.newDomain(DOMAIN_NAME, host));
oldLock = domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, POC_ID, false);
@@ -62,9 +62,9 @@ import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.Host;
import google.registry.model.host.HostBase;
import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource;
import google.registry.model.rde.RdeMode;
import google.registry.model.rde.RdeRevision;
import google.registry.model.rde.RdeRevision.RdeRevisionId;
@@ -272,7 +272,7 @@ public class RdePipelineTest {
// This host is never referenced.
persistHostHistory(persistActiveHost("ns0.domain.tld"));
HostResource host1 = persistActiveHost("ns1.external.tld");
Host host1 = persistActiveHost("ns1.external.tld");
persistHostHistory(host1);
Domain helloDomain =
persistEppResource(
@@ -282,7 +282,7 @@ public class RdePipelineTest {
.build());
persistDomainHistory(helloDomain);
persistHostHistory(persistActiveHost("not-used-subordinate.hello.soy"));
HostResource host2 = persistActiveHost("ns1.hello.soy");
Host host2 = persistActiveHost("ns1.hello.soy");
persistHostHistory(host2);
Domain kittyDomain =
persistEppResource(
@@ -306,7 +306,7 @@ public class RdePipelineTest {
persistContactHistory(contact3);
// This is a subordinate domain in TLD .cat, which is not included in any pending deposit. But
// it should still be included as a subordinate host in the pendign deposit for .soy.
HostResource host3 = persistActiveHost("ns1.lol.cat");
Host host3 = persistActiveHost("ns1.lol.cat");
persistHostHistory(host3);
persistDomainHistory(
helloDomain
@@ -331,7 +331,7 @@ public class RdePipelineTest {
persistDomainHistory(kittyDomain.asBuilder().setDeletionTime(clock.nowUtc()).build());
ContactResource futureContact = persistActiveContact("future-contact");
persistContactHistory(futureContact);
HostResource futureHost = persistActiveHost("ns1.future.tld");
Host futureHost = persistActiveHost("ns1.future.tld");
persistHostHistory(futureHost);
persistDomainHistory(
persistEppResource(
@@ -18,7 +18,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doThrow;
@@ -41,7 +41,7 @@ import google.registry.dns.writer.clouddns.CloudDnsWriter.ZoneStateException;
import google.registry.model.domain.Domain;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.persistence.VKey;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
@@ -283,31 +283,28 @@ public class CloudDnsWriterTest {
/** Returns a domain to be persisted in Datastore. */
private static Domain fakeDomain(
String domainName, ImmutableSet<HostResource> nameservers, int numDsRecords) {
String domainName, ImmutableSet<Host> nameservers, int numDsRecords) {
ImmutableSet.Builder<DelegationSignerData> dsDataBuilder = new ImmutableSet.Builder<>();
for (int i = 0; i < numDsRecords; i++) {
dsDataBuilder.add(DelegationSignerData.create(i, 3, 1, base16().decode("1234567890ABCDEF")));
}
ImmutableSet.Builder<VKey<HostResource>> hostResourceRefBuilder = new ImmutableSet.Builder<>();
for (HostResource nameserver : nameservers) {
hostResourceRefBuilder.add(nameserver.createVKey());
ImmutableSet.Builder<VKey<Host>> hostRefBuilder = new ImmutableSet.Builder<>();
for (Host nameserver : nameservers) {
hostRefBuilder.add(nameserver.createVKey());
}
return DatabaseHelper.newDomain(domainName)
.asBuilder()
.setNameservers(hostResourceRefBuilder.build())
.setNameservers(hostRefBuilder.build())
.setDsData(dsDataBuilder.build())
.build();
}
/** Returns a nameserver used for its NS record. */
private static HostResource fakeHost(String nameserver, InetAddress... addresses) {
return newHostResource(nameserver)
.asBuilder()
.setInetAddresses(ImmutableSet.copyOf(addresses))
.build();
private static Host fakeHost(String nameserver, InetAddress... addresses) {
return newHost(nameserver).asBuilder().setInetAddresses(ImmutableSet.copyOf(addresses)).build();
}
@MockitoSettings(strictness = Strictness.LENIENT)
@@ -18,7 +18,7 @@ import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistActiveSubordinateHost;
@@ -38,7 +38,7 @@ import com.google.common.net.InetAddresses;
import google.registry.model.domain.Domain;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.ofy.Ofy;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
@@ -98,8 +98,8 @@ public class DnsUpdateWriterTest {
@Test
void testPublishDomainCreate_publishesNameServers() throws Exception {
HostResource host1 = persistActiveHost("ns1.example.tld");
HostResource host2 = persistActiveHost("ns2.example.tld");
Host host1 = persistActiveHost("ns1.example.tld");
Host host2 = persistActiveHost("ns2.example.tld");
Domain domain =
persistActiveDomain("example.tld")
.asBuilder()
@@ -121,7 +121,7 @@ public class DnsUpdateWriterTest {
@MockitoSettings(strictness = Strictness.LENIENT)
@Test
void testPublishAtomic_noCommit() {
HostResource host1 = persistActiveHost("ns.example1.tld");
Host host1 = persistActiveHost("ns.example1.tld");
Domain domain1 =
persistActiveDomain("example1.tld")
.asBuilder()
@@ -129,7 +129,7 @@ public class DnsUpdateWriterTest {
.build();
persistResource(domain1);
HostResource host2 = persistActiveHost("ns.example2.tld");
Host host2 = persistActiveHost("ns.example2.tld");
Domain domain2 =
persistActiveDomain("example2.tld")
.asBuilder()
@@ -145,7 +145,7 @@ public class DnsUpdateWriterTest {
@Test
void testPublishAtomic_oneUpdate() throws Exception {
HostResource host1 = persistActiveHost("ns.example1.tld");
Host host1 = persistActiveHost("ns.example1.tld");
Domain domain1 =
persistActiveDomain("example1.tld")
.asBuilder()
@@ -153,7 +153,7 @@ public class DnsUpdateWriterTest {
.build();
persistResource(domain1);
HostResource host2 = persistActiveHost("ns.example2.tld");
Host host2 = persistActiveHost("ns.example2.tld");
Domain domain2 =
persistActiveDomain("example2.tld")
.asBuilder()
@@ -235,9 +235,9 @@ public class DnsUpdateWriterTest {
@Test
void testPublishHostCreate_publishesAddressRecords() throws Exception {
HostResource host =
Host host =
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setInetAddresses(
ImmutableSet.of(
@@ -305,10 +305,10 @@ public class DnsUpdateWriterTest {
@Test
void testPublishDomainExternalAndInBailiwickNameServer() throws Exception {
HostResource externalNameserver = persistResource(newHostResource("ns1.example.com"));
HostResource inBailiwickNameserver =
Host externalNameserver = persistResource(newHost("ns1.example.com"));
Host inBailiwickNameserver =
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setInetAddresses(
ImmutableSet.of(
@@ -342,9 +342,9 @@ public class DnsUpdateWriterTest {
@Test
void testPublishDomainDeleteOrphanGlues() throws Exception {
HostResource inBailiwickNameserver =
Host inBailiwickNameserver =
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setInetAddresses(
ImmutableSet.of(
@@ -401,7 +401,7 @@ public class DnsUpdateWriterTest {
@SuppressWarnings("AssertThrowsMultipleStatements")
@Test
void testPublishHostFails_whenDnsUpdateReturnsError() throws Exception {
HostResource host =
Host host =
persistActiveSubordinateHost("ns1.example.tld", persistActiveDomain("example.tld"))
.asBuilder()
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("10.0.0.1")))
@@ -20,11 +20,11 @@ import static google.registry.model.eppoutput.Result.Code.SUCCESS;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.EppMetricSubject.assertThat;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.HostSubject.assertAboutHosts;
import com.google.common.collect.ImmutableMap;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.testing.AppEngineExtension;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
@@ -210,8 +210,8 @@ class EppLifecycleHostTest extends EppTestCase {
DateTime timeAfterCreates = DateTime.parse("2000-06-01T00:06:00Z");
HostResource exampleBarFooTldHost =
loadByForeignKey(HostResource.class, "ns1.example.bar.foo.tld", timeAfterCreates).get();
Host exampleBarFooTldHost =
loadByForeignKey(Host.class, "ns1.example.bar.foo.tld", timeAfterCreates).get();
Domain exampleBarFooTldDomain =
loadByForeignKey(Domain.class, "example.bar.foo.tld", timeAfterCreates).get();
assertAboutHosts()
@@ -220,8 +220,8 @@ class EppLifecycleHostTest extends EppTestCase {
assertThat(exampleBarFooTldDomain.getSubordinateHosts())
.containsExactly("ns1.example.bar.foo.tld");
HostResource exampleFooTldHost =
loadByForeignKey(HostResource.class, "ns1.example.foo.tld", timeAfterCreates).get();
Host exampleFooTldHost =
loadByForeignKey(Host.class, "ns1.example.foo.tld", timeAfterCreates).get();
Domain exampleFooTldDomain =
loadByForeignKey(Domain.class, "example.foo.tld", timeAfterCreates).get();
assertAboutHosts()
@@ -229,8 +229,7 @@ class EppLifecycleHostTest extends EppTestCase {
.hasSuperordinateDomain(exampleFooTldDomain.createVKey());
assertThat(exampleFooTldDomain.getSubordinateHosts()).containsExactly("ns1.example.foo.tld");
HostResource exampleTldHost =
loadByForeignKey(HostResource.class, "ns1.example.tld", timeAfterCreates).get();
Host exampleTldHost = loadByForeignKey(Host.class, "ns1.example.tld", timeAfterCreates).get();
Domain exampleTldDomain = loadByForeignKey(Domain.class, "example.tld", timeAfterCreates).get();
assertAboutHosts().that(exampleTldHost).hasSuperordinateDomain(exampleTldDomain.createVKey());
assertThat(exampleTldDomain.getSubordinateHosts()).containsExactly("ns1.example.tld");
@@ -43,7 +43,7 @@ import static google.registry.testing.DatabaseHelper.deleteTld;
import static google.registry.testing.DatabaseHelper.getHistoryEntries;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newContactResource;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
@@ -1698,8 +1698,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistActiveHost("ns1.example.net");
persistActiveContact("jd1234");
persistActiveContact("sh8013");
persistResource(
newHostResource("ns2.example.net").asBuilder().addStatusValue(PENDING_DELETE).build());
persistResource(newHost("ns2.example.net").asBuilder().addStatusValue(PENDING_DELETE).build());
clock.advanceOneMilli();
LinkedResourceInPendingDeleteProhibitsOperationException thrown =
assertThrows(LinkedResourceInPendingDeleteProhibitsOperationException.class, this::runFlow);
@@ -44,7 +44,7 @@ import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.loadByKeyIfPresent;
import static google.registry.testing.DatabaseHelper.loadByKeysIfPresent;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
@@ -88,7 +88,7 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.poll.PendingActionNotificationResponse;
import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
import google.registry.model.poll.PollMessage;
@@ -732,7 +732,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
setUpGracePeriods(
GracePeriod.forBillingEvent(GracePeriodStatus.ADD, domain.getRepoId(), graceBillingEvent));
// Add a nameserver.
HostResource host = persistResource(newHostResource("ns1.example.tld"));
Host host = persistResource(newHost("ns1.example.tld"));
persistResource(
loadByForeignKey(Domain.class, getUniqueIdFromCommand(), clock.nowUtc())
.get()
@@ -763,7 +763,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
void testSuccess_deletedSubordinateDomain() throws Exception {
setUpSuccessfulTest();
persistResource(
newHostResource("ns1." + getUniqueIdFromCommand())
newHost("ns1." + getUniqueIdFromCommand())
.asBuilder()
.setSuperordinateDomain(reloadResourceByForeignKey().createVKey())
.setDeletionTime(clock.nowUtc().minusDays(1))
@@ -809,9 +809,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
@Test
void testFailure_hasSubordinateHosts() throws Exception {
Domain domain = persistActiveDomain(getUniqueIdFromCommand());
HostResource subordinateHost =
Host subordinateHost =
persistResource(
newHostResource("ns1." + getUniqueIdFromCommand())
newHost("ns1." + getUniqueIdFromCommand())
.asBuilder()
.setSuperordinateDomain(reloadResourceByForeignKey().createVKey())
.build());
@@ -64,7 +64,7 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
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.host.Host;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.persistence.VKey;
@@ -101,9 +101,9 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
private ContactResource registrant;
private ContactResource contact;
private HostResource host1;
private HostResource host2;
private HostResource host3;
private Host host1;
private Host host2;
private Host host3;
private Domain domain;
@BeforeEach
@@ -147,7 +147,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
// Create a subordinate host that is not delegated to by anyone.
host3 =
persistResource(
new HostResource.Builder()
new Host.Builder()
.setHostName("ns2.example.tld")
.setRepoId("3FF-TLD")
.setSuperordinateDomain(domain.createVKey())
@@ -39,7 +39,7 @@ import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.model.transfer.TransferData;
@@ -73,7 +73,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
protected ContactResource contact;
protected Domain domain;
HostResource subordinateHost;
Host subordinateHost;
private DomainHistory historyEntryDomainCreate;
DomainTransferFlowTestCase() {
@@ -111,7 +111,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
REGISTRATION_EXPIRATION_TIME);
subordinateHost =
persistResource(
new HostResource.Builder()
new Host.Builder()
.setRepoId("2-".concat(Ascii.toUpperCase(tld)))
.setHostName("ns1." + label + "." + tld)
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -41,7 +41,7 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.HostSubject.assertAboutHosts;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
@@ -99,7 +99,7 @@ import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.tld.Registry;
@@ -148,8 +148,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
}
private Domain persistDomainWithRegistrant() throws Exception {
HostResource host =
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get();
Host host = loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc()).get();
Domain domain =
persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand())
@@ -174,8 +173,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
}
private Domain persistDomain() throws Exception {
HostResource host =
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get();
Host host = loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc()).get();
Domain domain =
persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand())
@@ -289,12 +287,11 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
}
private void modifyDomainToHave13Nameservers() throws Exception {
ImmutableSet.Builder<VKey<HostResource>> nameservers = new ImmutableSet.Builder<>();
ImmutableSet.Builder<VKey<Host>> nameservers = new ImmutableSet.Builder<>();
for (int i = 1; i < 15; i++) {
if (i != 2) { // Skip 2 since that's the one that the tests will add.
nameservers.add(
loadByForeignKey(
HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc())
loadByForeignKey(Host.class, String.format("ns%d.example.foo", i), clock.nowUtc())
.get()
.createVKey());
}
@@ -318,9 +315,9 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistDomain();
setEppInput("domain_update_max_everything.xml");
// Create 26 hosts and 8 contacts. Start the domain with half of them.
ImmutableSet.Builder<VKey<HostResource>> nameservers = new ImmutableSet.Builder<>();
ImmutableSet.Builder<VKey<Host>> nameservers = new ImmutableSet.Builder<>();
for (int i = 0; i < 26; i++) {
HostResource host = persistActiveHost(String.format("max_test_%d.example.tld", i));
Host host = persistActiveHost(String.format("max_test_%d.example.tld", i));
if (i < 13) {
nameservers.add(host.createVKey());
}
@@ -394,7 +391,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistReferencedEntities();
Domain domain = persistDomain();
persistActiveSubordinateHost("ns1.example.tld", domain);
HostResource addedHost = persistActiveSubordinateHost("ns2.example.tld", domain);
Host addedHost = persistActiveSubordinateHost("ns2.example.tld", domain);
persistResource(
domain
.asBuilder()
@@ -402,7 +399,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.addSubordinateHost("ns2.example.tld")
.setNameservers(
ImmutableSet.of(
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc())
loadByForeignKey(Host.class, "ns1.example.tld", clock.nowUtc())
.get()
.createVKey()))
.build());
@@ -412,9 +409,8 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
domain = reloadResourceByForeignKey();
assertThat(domain.getNameservers()).containsExactly(addedHost.createVKey());
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
HostResource existingHost =
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()).get();
addedHost = loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get();
Host existingHost = loadByForeignKey(Host.class, "ns1.example.tld", clock.nowUtc()).get();
addedHost = loadByForeignKey(Host.class, "ns2.example.tld", clock.nowUtc()).get();
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(domain.createVKey());
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(domain.createVKey());
}
@@ -1421,7 +1417,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.asBuilder()
.setNameservers(
ImmutableSet.of(
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())
loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc())
.get()
.createVKey()))
.build());
@@ -1507,7 +1503,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistActiveContact("mak21");
persistActiveContact("sh8013");
persistResource(
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc())
.get()
.asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
@@ -1562,15 +1558,11 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.build());
assertThat(reloadResourceByForeignKey().getNameservers())
.doesNotContain(
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
.get()
.createVKey());
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc()).get().createVKey());
runFlow();
assertThat(reloadResourceByForeignKey().getNameservers())
.contains(
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
.get()
.createVKey());
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc()).get().createVKey());
}
@Test
@@ -1637,9 +1629,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
reloadResourceByForeignKey()
.asBuilder()
.addNameserver(
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
.get()
.createVKey())
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc()).get().createVKey())
.build());
persistResource(
Registry.get("tld")
@@ -1649,15 +1639,12 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.build());
assertThat(reloadResourceByForeignKey().getNameservers())
.contains(
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())
.get()
.createVKey());
loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc()).get().createVKey());
clock.advanceOneMilli();
runFlow();
assertThat(reloadResourceByForeignKey().getNameservers())
.doesNotContain(
Key.create(
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get()));
Key.create(loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc()).get()));
}
@Test
@@ -24,11 +24,11 @@ import google.registry.flows.EppException;
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.model.host.Host;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostCheckFlow}. */
class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, HostResource> {
class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, Host> {
HostCheckFlowTest() {
setEppInput("host_check.xml");
@@ -19,13 +19,13 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistDeletedHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.HostSubject.assertAboutHosts;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -51,14 +51,14 @@ import google.registry.flows.host.HostFlowUtils.SuperordinateDomainDoesNotExistE
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainInPendingDeleteException;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.DatabaseHelper;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostCreateFlow}. */
class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResource> {
class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
private void setEppHostCreateInput(String hostName, String hostAddrs) {
setEppInput(
@@ -83,7 +83,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("host_create_response.xml"));
HostResource host = reloadResourceByForeignKey();
Host host = reloadResourceByForeignKey();
// Check that the host was created and persisted with a history entry.
assertAboutHosts()
.that(host)
@@ -124,7 +124,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
@Test
void testSuccess_internalNeverExisted() throws Exception {
doSuccessfulInternalTest("tld");
HostResource host = reloadResourceByForeignKey();
Host host = reloadResourceByForeignKey();
Domain superordinateDomain =
loadByForeignKey(Domain.class, "example.tld", clock.nowUtc()).get();
assertAboutHosts().that(host).hasSuperordinateDomain(superordinateDomain.createVKey());
@@ -153,7 +153,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
void testSuccess_internalExistedButWasDeleted() throws Exception {
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
doSuccessfulInternalTest("tld");
HostResource host = reloadResourceByForeignKey();
Host host = reloadResourceByForeignKey();
Domain superordinateDomain =
loadByForeignKey(Domain.class, "example.tld", clock.nowUtc()).get();
assertAboutHosts().that(host).hasSuperordinateDomain(superordinateDomain.createVKey());
@@ -223,7 +223,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
setEppHostCreateInput("ns1.example.tld", null);
String targetId = getUniqueIdFromCommand();
persistResource(
newHostResource(targetId)
newHost(targetId)
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
@@ -19,12 +19,12 @@ import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_DELETE;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistDeletedHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.HostSubject.assertAboutHosts;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued;
@@ -44,7 +44,7 @@ import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.reporting.HistoryEntry.Type;
import google.registry.model.tld.Registry;
import google.registry.model.transfer.DomainTransferData;
@@ -55,7 +55,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostDeleteFlow}. */
class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResource> {
class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Host> {
@BeforeEach
void initFlowTest() {
@@ -111,7 +111,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
private void doFailingStatusTest(StatusValue statusValue, Class<? extends Exception> exception) {
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setStatusValues(ImmutableSet.of(statusValue))
.build());
@@ -166,7 +166,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") // Shouldn't hurt.
.setSuperordinateDomain(domain.createVKey())
@@ -187,7 +187,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't help.
.setSuperordinateDomain(domain.createVKey())
@@ -220,7 +220,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
.build())
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't hurt.
.setSuperordinateDomain(domain.createVKey())
@@ -254,7 +254,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
.build())
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") // Shouldn't help.
.setSuperordinateDomain(domain.createVKey())
@@ -307,7 +307,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
private void assertSqlDeleteSuccess(boolean isSubordinate) throws Exception {
assertThat(reloadResourceByForeignKey()).isNull();
HostResource deletedHost = reloadResourceByForeignKey(clock.nowUtc().minusMillis(1));
Host deletedHost = reloadResourceByForeignKey(clock.nowUtc().minusMillis(1));
assertAboutHosts()
.that(deletedHost)
.isNotActiveAt(clock.nowUtc())
@@ -35,7 +35,7 @@ import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.testing.DatabaseHelper;
import javax.annotation.Nullable;
import org.joda.time.DateTime;
@@ -43,7 +43,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostInfoFlow}. */
class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource> {
class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, Host> {
@BeforeEach
void initHostTest() {
@@ -51,9 +51,9 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld"));
}
private HostResource persistHostResource() throws Exception {
private Host persistHost() throws Exception {
return persistResource(
new HostResource.Builder()
new Host.Builder()
.setHostName(getUniqueIdFromCommand())
.setRepoId("1FF-FOOBAR")
.setPersistedCurrentSponsorRegistrarId("my sponsor")
@@ -81,7 +81,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
@Test
void testSuccess() throws Exception {
persistHostResource();
persistHost();
assertTransactionalFlow(false);
// Check that the persisted host info was returned.
runFlowAssertResponse(
@@ -94,11 +94,11 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
@Test
void testSuccess_linked() throws Exception {
persistHostResource();
persistHost();
persistResource(
DatabaseHelper.newDomain("example.foobar")
.asBuilder()
.addNameserver(persistHostResource().createVKey())
.addNameserver(persistHost().createVKey())
.build());
assertTransactionalFlow(false);
// Check that the persisted host info was returned.
@@ -121,7 +121,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
.setLastTransferTime(domainTransferTime)
.setPersistedCurrentSponsorRegistrarId("superclientid")
.build());
HostResource firstHost = persistHostResource();
Host firstHost = persistHost();
persistResource(
firstHost
.asBuilder()
@@ -166,8 +166,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
@Test
void testFailure_existedButWasDeleted() throws Exception {
persistResource(
persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(persistHost().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@@ -197,7 +196,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
@Test
void testIcannActivityReportField_getsLogged() throws Exception {
persistHostResource();
persistHost();
runFlow();
assertIcannReportingActivityFieldLogged("srs-host-info");
}
@@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistActiveSubordinateHost;
@@ -34,7 +34,7 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.HostSubject.assertAboutHosts;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
@@ -71,7 +71,7 @@ import google.registry.flows.host.HostUpdateFlow.HostAlreadyExistsException;
import google.registry.flows.host.HostUpdateFlow.RenameHostToExternalRemoveIpException;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
@@ -84,7 +84,7 @@ import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostUpdateFlow}. */
class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResource> {
class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
private void setEppHostUpdateInput(
String oldHostName, String newHostName, String ipOrStatusToAdd, String ipOrStatusToRem) {
@@ -148,15 +148,15 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
}
private HostResource doSuccessfulTest() throws Exception {
private Host doSuccessfulTest() throws Exception {
return doSuccessfulTest(false); // default to normal user privileges
}
private HostResource doSuccessfulTestAsSuperuser() throws Exception {
private Host doSuccessfulTestAsSuperuser() throws Exception {
return doSuccessfulTest(true);
}
private HostResource doSuccessfulTest(boolean isSuperuser) throws Exception {
private Host doSuccessfulTest(boolean isSuperuser) throws Exception {
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(
@@ -167,8 +167,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
// should now return null.
assertThat(reloadResourceByForeignKey()).isNull();
// However, it should load correctly if we use the new name (taken from the xml).
HostResource renamedHost =
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get();
Host renamedHost = loadByForeignKey(Host.class, "ns2.example.tld", clock.nowUtc()).get();
assertAboutHosts()
.that(renamedHost)
.hasOnlyOneHistoryEntryWhich()
@@ -182,11 +181,11 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_rename_noOtherHostEverUsedTheOldName() throws Exception {
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertThat(renamedHost.isSubordinate()).isTrue();
assertDnsTasksEnqueued("ns1.example.tld", "ns2.example.tld");
ForeignKeyIndex<HostResource> oldFkiAfterRename =
ForeignKeyIndex.load(HostResource.class, oldHostName(), clock.nowUtc());
ForeignKeyIndex<Host> oldFkiAfterRename =
ForeignKeyIndex.load(Host.class, oldHostName(), clock.nowUtc());
assertThat(oldFkiAfterRename).isNull();
}
@@ -194,15 +193,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_withReferencingDomain() throws Exception {
createTld("tld");
createTld("xn--q9jyb4c");
HostResource host =
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
Host host = persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
persistResource(
DatabaseHelper.newDomain("test.xn--q9jyb4c")
.asBuilder()
.setDeletionTime(END_OF_TIME)
.setNameservers(ImmutableSet.of(host.createVKey()))
.build());
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertThat(renamedHost.isSubordinate()).isTrue();
// Task enqueued to change the NS record of the referencing domain.
assertTasksEnqueued(
@@ -217,7 +215,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
setEppInput("host_update_name_unchanged.xml");
createTld("tld");
Domain domain = persistActiveDomain("example.tld");
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
Host oldHost = persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
// The example xml doesn't do a host rename, so reloading the host should work.
@@ -243,7 +241,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("tld");
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
Host oldHost = persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
// The example xml doesn't do a host rename, so reloading the host should work.
@@ -279,9 +277,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.setLastTransferTime(oneDayAgo)
.build());
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
Host oldHost = persistActiveSubordinateHost(oldHostName(), domain);
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld");
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasSuperordinateDomain(domain.createVKey())
@@ -314,7 +312,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
persistActiveSubordinateHost(oldHostName(), foo);
assertThat(foo.getSubordinateHosts()).containsExactly("ns2.foo.tld");
assertThat(example.getSubordinateHosts()).isEmpty();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
DateTime now = clock.nowUtc();
assertAboutHosts()
.that(renamedHost)
@@ -350,7 +348,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
persistActiveSubordinateHost(oldHostName(), fooDomain);
assertThat(fooDomain.getSubordinateHosts()).containsExactly("ns1.example.foo");
assertThat(tldDomain.getSubordinateHosts()).isEmpty();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
DateTime now = clock.nowUtc();
assertAboutHosts()
.that(renamedHost)
@@ -386,7 +384,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
assertThat(domain.getCurrentSponsorRegistrarId()).isEqualTo("TheRegistrar");
DateTime oneDayAgo = clock.nowUtc().minusDays(1);
HostResource oldHost =
Host oldHost =
persistResource(
persistActiveSubordinateHost(oldHostName(), domain)
.asBuilder()
@@ -395,7 +393,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
assertThat(oldHost.isSubordinate()).isTrue();
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.foo");
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasSuperordinateDomain(null)
@@ -431,7 +429,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
Domain domain = persistActiveDomain("example.tld");
persistActiveHost(oldHostName());
assertThat(domain.getSubordinateHosts()).isEmpty();
HostResource renamedHost = doSuccessfulTestAsSuperuser();
Host renamedHost = doSuccessfulTestAsSuperuser();
DateTime now = clock.nowUtc();
assertAboutHosts()
.that(renamedHost)
@@ -459,7 +457,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_superuserExternalToExternal() throws Exception {
setEppHostUpdateInput("ns1.example.foo", "ns2.example.tld", null, null);
persistActiveHost(oldHostName());
HostResource renamedHost = doSuccessfulTestAsSuperuser();
Host renamedHost = doSuccessfulTestAsSuperuser();
assertAboutHosts()
.that(renamedHost)
.hasSuperordinateDomain(null)
@@ -476,7 +474,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_superuserClientUpdateProhibited() throws Exception {
setEppInput("host_update_add_status.xml");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
@@ -519,14 +517,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(foo.createVKey())
.setLastTransferTime(null)
.build());
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -555,9 +553,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(10))
.build());
HostResource host =
Host host =
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(domain.createVKey())
.setLastTransferTime(clock.nowUtc().minusDays(20))
@@ -565,7 +563,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
DateTime lastTransferTime = host.getLastTransferTime();
persistResource(domain.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -594,7 +592,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
DateTime lastTransferTime = clock.nowUtc().minusDays(20);
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(foo.createVKey())
.setLastTransferTime(lastTransferTime)
@@ -602,7 +600,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -628,7 +626,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
DateTime lastTransferTime = clock.nowUtc().minusDays(20);
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(foo.createVKey())
.setLastTransferTime(lastTransferTime)
@@ -636,7 +634,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -662,14 +660,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
persistResource(
DatabaseHelper.newDomain("example.tld").asBuilder().setLastTransferTime(null).build());
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(foo.createVKey())
.setLastTransferTime(null)
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
.build());
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -688,10 +686,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("foo");
Domain domain = persistActiveDomain("example.foo");
persistResource(
newHostResource(oldHostName())
.asBuilder()
.setSuperordinateDomain(domain.createVKey())
.build());
newHost(oldHostName()).asBuilder().setSuperordinateDomain(domain.createVKey()).build());
DateTime lastTransferTime = clock.nowUtc().minusDays(2);
persistResource(
domain
@@ -700,7 +695,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
clock.advanceOneMilli();
persistResource(domain.asBuilder().setLastTransferTime(clock.nowUtc().minusDays(1)).build());
// The last transfer time should be what was on the superordinate domain at the time of the host
@@ -727,7 +722,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
Domain domain = persistActiveDomain("example.foo");
DateTime lastTransferTime = clock.nowUtc().minusDays(12);
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(domain.createVKey())
.setLastTransferTime(lastTransferTime)
@@ -740,7 +735,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
// The last transfer time should be what was on the host, because the host's old superordinate
// domain wasn't transferred more recently than when the host was changed to have that
// superordinate domain.
@@ -762,7 +757,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("foo");
Domain domain = persistActiveDomain("example.foo");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(domain.createVKey())
.setLastTransferTime(clock.nowUtc().minusDays(12))
@@ -775,7 +770,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setLastTransferTime(clock.nowUtc().minusDays(2))
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
// The last transfer time should be what was on the superordinate domain, because the domain
// was transferred more recently than the last time the host's superordinate domain was changed.
assertAboutHosts()
@@ -796,8 +791,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setLastTransferTime(domainTransferTime)
.build());
persistResource(
newHostResource(oldHostName()).asBuilder().setLastTransferTime(hostTransferTime).build());
HostResource renamedHost = doSuccessfulTestAsSuperuser();
newHost(oldHostName()).asBuilder().setLastTransferTime(hostTransferTime).build());
Host renamedHost = doSuccessfulTestAsSuperuser();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -1015,7 +1010,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_clientUpdateProhibited_removed() throws Exception {
setEppInput("host_update_remove_client_update_prohibited.xml");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
@@ -1030,7 +1025,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testFailure_clientUpdateProhibited() throws Exception {
createTld("tld");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.setSuperordinateDomain(persistActiveDomain("example.tld").createVKey())
@@ -1044,7 +1039,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testFailure_serverUpdateProhibited() throws Exception {
createTld("tld");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.setSuperordinateDomain(persistActiveDomain("example.tld").createVKey())
@@ -1058,7 +1053,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testFailure_pendingDelete() throws Exception {
createTld("tld");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.setSuperordinateDomain(persistActiveDomain("example.tld").createVKey())
@@ -1118,7 +1113,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't hurt.
.setSuperordinateDomain(domain.createVKey())
@@ -1140,7 +1135,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") // Shouldn't help.
.setSuperordinateDomain(domain.createVKey())
@@ -1158,7 +1153,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't hurt.
.setSuperordinateDomain(domain.createVKey())
@@ -1176,7 +1171,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't help.
.setSuperordinateDomain(domain.createVKey())
@@ -1199,8 +1194,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
HostResource host =
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
Host host = persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
assertAboutHosts().that(host).hasPersistedCurrentSponsorRegistrarId("TheRegistrar");
EppException thrown = assertThrows(HostDomainNotOwnedException.class, this::runFlow);
@@ -1214,8 +1208,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
sessionMetadata.setRegistrarId("TheRegistrar");
createTld("foo");
createTld("tld");
HostResource host =
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
Host host = persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
// The domain will belong to NewRegistrar after cloneProjectedAtTime is called.
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
assertAboutDomains().that(domain).hasPersistedCurrentSponsorRegistrarId("TheRegistrar");
@@ -1242,7 +1235,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
assertAboutDomains().that(domain).hasPersistedCurrentSponsorRegistrarId("TheRegistrar");
persistResource(
newHostResource("ns1.example.foo")
newHost("ns1.example.foo")
.asBuilder()
.setSuperordinateDomain(superordinate.createVKey())
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
@@ -31,8 +31,8 @@ import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.Host;
import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource;
import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
@@ -55,7 +55,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
private Domain domain;
private ContactResource contact;
private HostResource host;
private Host host;
@BeforeEach
void setUp() {
@@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import com.google.common.collect.ImmutableList;
import google.registry.model.contact.ContactResource;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.testing.TestCacheExtension;
import java.time.Duration;
import org.junit.jupiter.api.Test;
@@ -51,15 +51,15 @@ public class EppResourceTest extends EntityTestCase {
@Test
void test_loadCached_ignoresHostChange() {
HostResource originalHost = persistActiveHost("ns1.example.com");
Host originalHost = persistActiveHost("ns1.example.com");
assertThat(EppResource.loadCached(ImmutableList.of(originalHost.createVKey())))
.containsExactly(originalHost.createVKey(), originalHost);
HostResource modifiedHost =
Host modifiedHost =
persistResource(
originalHost.asBuilder().setLastTransferTime(fakeClock.nowUtc().minusDays(60)).build());
assertThat(EppResource.loadCached(ImmutableList.of(originalHost.createVKey())))
.containsExactly(originalHost.createVKey(), originalHost);
assertThat(loadByForeignKey(HostResource.class, "ns1.example.com", fakeClock.nowUtc()))
assertThat(loadByForeignKey(Host.class, "ns1.example.com", fakeClock.nowUtc()))
.hasValue(modifiedHost);
}
}
@@ -17,12 +17,12 @@ package google.registry.model;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadAtPointInTime;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.time.DateTimeZone.UTC;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.ofy.Ofy;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.FakeClock;
@@ -54,10 +54,9 @@ class EppResourceUtilsTest {
void testLoadAtPointInTime_beforeCreated_returnsNull() {
clock.advanceOneMilli();
// Don't save a commit log, we shouldn't need one.
HostResource host = persistResource(
newHostResource("ns1.cat.tld").asBuilder()
.setCreationTimeForTest(clock.nowUtc())
.build());
Host host =
persistResource(
newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(clock.nowUtc()).build());
assertThat(loadAtPointInTime(host, clock.nowUtc().minus(Duration.millis(1)))).isNull();
}
@@ -65,10 +64,9 @@ class EppResourceUtilsTest {
void testLoadAtPointInTime_atOrAfterLastAutoUpdateTime_returnsResource() {
clock.advanceOneMilli();
// Don't save a commit log, we shouldn't need one.
HostResource host = persistResource(
newHostResource("ns1.cat.tld").asBuilder()
.setCreationTimeForTest(START_OF_TIME)
.build());
Host host =
persistResource(
newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(START_OF_TIME).build());
assertThat(loadAtPointInTime(host, clock.nowUtc())).isEqualTo(host);
}
}
@@ -35,7 +35,7 @@ import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.model.reporting.DomainTransactionRecord;
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
@@ -75,7 +75,7 @@ public final class TestSetupHelper {
public ContactResource contact;
public Domain domain;
public DomainHistory domainHistory;
public HostResource host;
public Host host;
private JpaTransactionManager originalJpaTm;
private JpaTransactionManager bulkQueryJpaTm;
@@ -135,7 +135,7 @@ public final class TestSetupHelper {
.build();
}
static Domain createFullDomain(ContactResource contact, HostResource host, FakeClock fakeClock) {
static Domain createFullDomain(ContactResource contact, Host host, FakeClock fakeClock) {
return createSimpleDomain(contact)
.asBuilder()
.setDomainName(DOMAIN_NAME)
@@ -169,8 +169,8 @@ public final class TestSetupHelper {
.build();
}
static HostResource createHost() {
return new HostResource.Builder()
static Host createHost() {
return new Host.Builder()
.setRepoId("host1")
.setHostName("ns1.example.com")
.setCreationRegistrarId(REGISTRAR_ID)
@@ -21,7 +21,7 @@ import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.EppResourceIndexBucket;
import google.registry.model.index.ForeignKeyIndex.ForeignKeyContactIndex;
@@ -53,7 +53,7 @@ public class ClassPathManagerTest {
.isEqualTo(ForeignKeyContactIndex.class);
assertThat(ClassPathManager.getClass("AllocationToken")).isEqualTo(AllocationToken.class);
assertThat(ClassPathManager.getClass("RdeRevision")).isEqualTo(RdeRevision.class);
assertThat(ClassPathManager.getClass("HostResource")).isEqualTo(HostResource.class);
assertThat(ClassPathManager.getClass("Host")).isEqualTo(Host.class);
assertThat(ClassPathManager.getClass("Registrar")).isEqualTo(Registrar.class);
assertThat(ClassPathManager.getClass("ContactResource")).isEqualTo(ContactResource.class);
assertThat(ClassPathManager.getClass("GaeUserIdConverter")).isEqualTo(GaeUserIdConverter.class);
@@ -106,7 +106,7 @@ public class ClassPathManagerTest {
.isEqualTo("ForeignKeyContactIndex");
assertThat(ClassPathManager.getClassName(AllocationToken.class)).isEqualTo("AllocationToken");
assertThat(ClassPathManager.getClassName(RdeRevision.class)).isEqualTo("RdeRevision");
assertThat(ClassPathManager.getClassName(HostResource.class)).isEqualTo("HostResource");
assertThat(ClassPathManager.getClassName(Host.class)).isEqualTo("Host");
assertThat(ClassPathManager.getClassName(Registrar.class)).isEqualTo("Registrar");
assertThat(ClassPathManager.getClassName(ContactResource.class)).isEqualTo("ContactResource");
assertThat(ClassPathManager.getClassName(GaeUserIdConverter.class))
@@ -47,7 +47,7 @@ import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.ContactTransferData;
@@ -81,8 +81,8 @@ public class DomainSqlTest {
private DomainHistory historyEntry;
private VKey<ContactResource> contactKey;
private VKey<ContactResource> contact2Key;
private VKey<HostResource> host1VKey;
private HostResource host;
private VKey<Host> host1VKey;
private Host host;
private ContactResource contact;
private ContactResource contact2;
private ImmutableSet<GracePeriod> gracePeriods;
@@ -95,7 +95,7 @@ public class DomainSqlTest {
contactKey = createKey(ContactResource.class, "contact_id1");
contact2Key = createKey(ContactResource.class, "contact_id2");
host1VKey = createKey(HostResource.class, "host1");
host1VKey = createKey(Host.class, "host1");
domain =
new Domain.Builder()
@@ -130,7 +130,7 @@ public class DomainSqlTest {
.build();
host =
new HostResource.Builder()
new Host.Builder()
.setRepoId("host1")
.setHostName("ns1.example.com")
.setCreationRegistrarId("registrar1")
@@ -676,8 +676,8 @@ public class DomainSqlTest {
jpaTm()
.transact(
() -> {
HostResource host2 =
new HostResource.Builder()
Host host2 =
new Host.Builder()
.setRepoId("host2")
.setHostName("ns2.example.com")
.setCreationRegistrarId("registrar1")
@@ -22,7 +22,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.insertInDb;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
@@ -55,7 +55,7 @@ import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
@@ -100,7 +100,7 @@ public class DomainTest {
saveRegistrar("gaining");
createTld("com");
domain = persistActiveDomain("example.com");
VKey<HostResource> hostKey = persistActiveHost("ns1.example.com").createVKey();
VKey<Host> hostKey = persistActiveHost("ns1.example.com").createVKey();
contact1Key = persistActiveContact("contact_id1").createVKey();
contact2Key = persistActiveContact("contact_id1").createVKey();
domainHistory =
@@ -288,7 +288,7 @@ public class DomainTest {
assertThat(
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setNameservers(ImmutableSet.of(newHostResource("foo.example.tld").createVKey()))
.setNameservers(ImmutableSet.of(newHost("foo.example.tld").createVKey()))
.build()
.nsHosts)
.isNotNull();
@@ -336,8 +336,7 @@ public class DomainTest {
@Test
void testImplicitStatusValues() {
ImmutableSet<VKey<HostResource>> nameservers =
ImmutableSet.of(newHostResource("foo.example.tld").createVKey());
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(newHost("foo.example.tld").createVKey());
StatusValue[] statuses = {StatusValue.OK};
// OK is implicit if there's no other statuses but there are nameservers.
assertAboutDomains()
@@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.insertInDb;
import static google.registry.testing.DatabaseHelper.newContactResourceWithRoid;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.newHostResourceWithRoid;
import static google.registry.testing.DatabaseHelper.newHostWithRoid;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -36,7 +36,7 @@ import google.registry.model.domain.Period;
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.reporting.DomainTransactionRecord;
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
import google.registry.model.reporting.HistoryEntry;
@@ -102,7 +102,7 @@ public class DomainHistoryTest extends EntityTestCase {
static Domain createDomainWithContactsAndHosts() {
createTld("tld");
HostResource host = newHostResourceWithRoid("ns1.example.com", "host1");
Host host = newHostWithRoid("ns1.example.com", "host1");
ContactResource contact = newContactResourceWithRoid("contactId", "contact1");
jpaTm()
@@ -19,14 +19,14 @@ import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableO
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static google.registry.testing.DatabaseHelper.insertInDb;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newHostResourceWithRoid;
import static google.registry.testing.DatabaseHelper.newHostWithRoid;
import static java.nio.charset.StandardCharsets.UTF_8;
import google.registry.model.EntityTestCase;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.Host;
import google.registry.model.host.HostBase;
import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource;
import google.registry.model.reporting.HistoryEntry;
import google.registry.util.SerializeUtils;
import org.junit.jupiter.api.Test;
@@ -40,9 +40,9 @@ public class HostHistoryTest extends EntityTestCase {
@Test
void testPersistence() {
HostResource host = newHostResourceWithRoid("ns1.example.com", "host1");
Host host = newHostWithRoid("ns1.example.com", "host1");
insertInDb(host);
HostResource hostFromDb = loadByEntity(host);
Host hostFromDb = loadByEntity(host);
HostHistory hostHistory = createHostHistory(hostFromDb);
insertInDb(hostHistory);
jpaTm()
@@ -56,9 +56,9 @@ public class HostHistoryTest extends EntityTestCase {
@Test
void testSerializable() {
HostResource host = newHostResourceWithRoid("ns1.example.com", "host1");
Host host = newHostWithRoid("ns1.example.com", "host1");
insertInDb(host);
HostResource hostFromDb = loadByEntity(host);
Host hostFromDb = loadByEntity(host);
HostHistory hostHistory = createHostHistory(hostFromDb);
insertInDb(hostHistory);
HostHistory fromDatabase = jpaTm().transact(() -> jpaTm().loadByKey(hostHistory.createVKey()));
@@ -67,10 +67,10 @@ public class HostHistoryTest extends EntityTestCase {
@Test
void testLegacyPersistence_nullHostBase() {
HostResource host = newHostResourceWithRoid("ns1.example.com", "host1");
Host host = newHostWithRoid("ns1.example.com", "host1");
insertInDb(host);
HostResource hostFromDb = loadByEntity(host);
Host hostFromDb = loadByEntity(host);
HostHistory hostHistory = createHostHistory(hostFromDb).asBuilder().setHost(null).build();
insertInDb(hostHistory);
@@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistNewRegistrars;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.HostSubject.assertAboutHosts;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
@@ -40,15 +40,15 @@ import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostResource}. */
class HostResourceTest extends EntityTestCase {
/** Unit tests for {@link Host}. */
class HostTest extends EntityTestCase {
private final DateTime day3 = fakeClock.nowUtc();
private final DateTime day2 = day3.minusDays(1);
private final DateTime day1 = day2.minusDays(1);
private Domain domain;
private HostResource host;
private Host host;
@BeforeEach
void setUp() {
@@ -73,7 +73,7 @@ class HostResourceTest extends EntityTestCase {
host =
persistResource(
cloneAndSetAutoTimestamps(
new HostResource.Builder()
new Host.Builder()
.setRepoId("DEADBEEF-COM")
.setHostName("ns1.example.com")
.setCreationRegistrarId("thisRegistrar")
@@ -87,15 +87,15 @@ class HostResourceTest extends EntityTestCase {
}
@Test
void testHostBaseToHostResource() {
void testHostBaseToHost() {
ImmutableObjectSubject.assertAboutImmutableObjects()
.that(new HostResource.Builder().copyFrom(host).build())
.that(new Host.Builder().copyFrom(host).build())
.isEqualExceptFields(host, "updateTimestamp", "revisions");
}
@Test
void testPersistence() {
HostResource newHost = host.asBuilder().setRepoId("NEWHOST").build();
Host newHost = host.asBuilder().setRepoId("NEWHOST").build();
tm().transact(() -> tm().insert(newHost));
assertThat(ImmutableList.of(tm().transact(() -> tm().loadByKey(newHost.createVKey()))))
.comparingElementsUsing(immutableObjectCorrespondence("revisions"))
@@ -104,28 +104,28 @@ class HostResourceTest extends EntityTestCase {
@Test
void testSerializable() {
HostResource newHost = host.asBuilder().setRepoId("NEWHOST").build();
Host newHost = host.asBuilder().setRepoId("NEWHOST").build();
tm().transact(() -> tm().insert(newHost));
HostResource persisted = tm().transact(() -> tm().loadByEntity(newHost));
Host persisted = tm().transact(() -> tm().loadByEntity(newHost));
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
}
@Test
void testEmptyStringsBecomeNull() {
assertThat(
new HostResource.Builder()
new Host.Builder()
.setPersistedCurrentSponsorRegistrarId(null)
.build()
.getPersistedCurrentSponsorRegistrarId())
.isNull();
assertThat(
new HostResource.Builder()
new Host.Builder()
.setPersistedCurrentSponsorRegistrarId("")
.build()
.getPersistedCurrentSponsorRegistrarId())
.isNull();
assertThat(
new HostResource.Builder()
new Host.Builder()
.setPersistedCurrentSponsorRegistrarId(" ")
.build()
.getPersistedCurrentSponsorRegistrarId())
@@ -134,11 +134,11 @@ class HostResourceTest extends EntityTestCase {
@Test
void testEmptySetsBecomeNull() {
assertThat(new HostResource.Builder().setInetAddresses(null).build().inetAddresses).isNull();
assertThat(new HostResource.Builder().setInetAddresses(ImmutableSet.of()).build().inetAddresses)
assertThat(new Host.Builder().setInetAddresses(null).build().inetAddresses).isNull();
assertThat(new Host.Builder().setInetAddresses(ImmutableSet.of()).build().inetAddresses)
.isNull();
assertThat(
new HostResource.Builder()
new Host.Builder()
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
.build()
.inetAddresses)
@@ -148,20 +148,15 @@ class HostResourceTest extends EntityTestCase {
@Test
void testImplicitStatusValues() {
// OK is implicit if there's no other statuses.
assertAboutHosts()
.that(new HostResource.Builder().build())
.hasExactlyStatusValues(StatusValue.OK);
assertAboutHosts().that(new Host.Builder().build()).hasExactlyStatusValues(StatusValue.OK);
// If there are other status values, OK should be suppressed.
assertAboutHosts()
.that(
new HostResource.Builder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD))
.build())
.that(new Host.Builder().setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD)).build())
.hasExactlyStatusValues(StatusValue.CLIENT_HOLD);
// When OK is suppressed, it should be removed even if it was originally there.
assertAboutHosts()
.that(
new HostResource.Builder()
new Host.Builder()
.setStatusValues(ImmutableSet.of(StatusValue.OK, StatusValue.CLIENT_HOLD))
.build())
.hasExactlyStatusValues(StatusValue.CLIENT_HOLD);
@@ -223,7 +218,7 @@ class HostResourceTest extends EntityTestCase {
host =
persistResource(
cloneAndSetAutoTimestamps(
new HostResource.Builder()
new Host.Builder()
.setCreationTime(day2)
.setRepoId("DEADBEEF-COM")
.setHostName("ns1.example.com")
@@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import com.google.common.collect.ImmutableList;
import google.registry.model.EntityTestCase;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.TestCacheExtension;
@@ -56,25 +56,23 @@ class ForeignKeyIndexTest extends EntityTestCase {
@Test
void testLoadForNonexistentForeignKey_returnsNull() {
assertThat(ForeignKeyIndex.load(HostResource.class, "ns1.example.com", fakeClock.nowUtc()))
.isNull();
assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testLoadForDeletedForeignKey_returnsNull() {
HostResource host = persistActiveHost("ns1.example.com");
Host host = persistActiveHost("ns1.example.com");
if (tm().isOfy()) {
persistResource(ForeignKeyIndex.create(host, fakeClock.nowUtc().minusDays(1)));
} else {
persistResource(host.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build());
}
assertThat(ForeignKeyIndex.load(HostResource.class, "ns1.example.com", fakeClock.nowUtc()))
.isNull();
assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testLoad_newerKeyHasBeenSoftDeleted() {
HostResource host1 = persistActiveHost("ns1.example.com");
Host host1 = persistActiveHost("ns1.example.com");
fakeClock.advanceOneMilli();
if (tm().isOfy()) {
ForeignKeyHostIndex fki = new ForeignKeyHostIndex();
@@ -85,14 +83,13 @@ class ForeignKeyIndexTest extends EntityTestCase {
} else {
persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build());
}
assertThat(ForeignKeyIndex.load(HostResource.class, "ns1.example.com", fakeClock.nowUtc()))
.isNull();
assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull();
}
@Test
void testBatchLoad_skipsDeletedAndNonexistent() {
persistActiveHost("ns1.example.com");
HostResource host = persistActiveHost("ns2.example.com");
Host host = persistActiveHost("ns2.example.com");
if (tm().isOfy()) {
persistResource(ForeignKeyIndex.create(host, fakeClock.nowUtc().minusDays(1)));
} else {
@@ -100,7 +97,7 @@ class ForeignKeyIndexTest extends EntityTestCase {
}
assertThat(
ForeignKeyIndex.load(
HostResource.class,
Host.class,
ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"),
fakeClock.nowUtc())
.keySet())
@@ -110,7 +107,7 @@ class ForeignKeyIndexTest extends EntityTestCase {
@Test
void testDeadCodeThatDeletedScrapCommandsReference() {
persistActiveHost("omg");
assertThat(ForeignKeyIndex.load(HostResource.class, "omg", fakeClock.nowUtc()).getForeignKey())
assertThat(ForeignKeyIndex.load(Host.class, "omg", fakeClock.nowUtc()).getForeignKey())
.isEqualTo("omg");
}
}
@@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.transfer.ContactTransferData;
import google.registry.persistence.VKey;
import org.joda.time.LocalDate;
@@ -45,7 +45,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
private Spec11ThreatMatch threat;
private Domain domain;
private HostResource host;
private Host host;
private ContactResource registrantContact;
Spec11ThreatMatchTest() {
@@ -54,7 +54,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
@BeforeEach
void setUp() {
VKey<HostResource> hostVKey = VKey.createSql(HostResource.class, "host");
VKey<Host> hostVKey = VKey.createSql(Host.class, "host");
VKey<ContactResource> registrantContactVKey =
VKey.createSql(ContactResource.class, "contact_id");
String domainRepoId = "4-TLD";
@@ -84,7 +84,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
// Create a host for the purpose of testing a foreign key reference in the Domain table. */
host =
new HostResource.Builder()
new Host.Builder()
.setRepoId("host")
.setHostName("ns1.example.com")
.setCreationRegistrarId(REGISTRAR_ID)
@@ -36,7 +36,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
public class StatusValueAdapterTest {
// Needed to create HostResources.
// Needed to create Hosts.
@RegisterExtension
public AppEngineExtension appEngine = new AppEngineExtension.Builder().withCloudSql().build();
@@ -24,7 +24,7 @@ import com.googlecode.objectify.annotation.Entity;
import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.common.ClassPathManager;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.RegistrarPoc;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.TestObject;
@@ -185,25 +185,15 @@ class VKeyTest {
@Test
void testCreate_stringifiedVKey_resourceKeyFromTaskQueue() throws Exception {
VKey<HostResource> vkeyFromNewWebsafeKey =
VKey<Host> vkeyFromNewWebsafeKey =
VKey.create(
"kind:HostResource@sql:rO0ABXQADzZCQjJGNDc2LUdPT0dMRQ@ofy:ahdzfm"
"kind:Host@sql:rO0ABXQADzZCQjJGNDc2LUdPT0dMRQ@ofy:ahdzfm"
+ "RvbWFpbi1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM");
assertThat(vkeyFromNewWebsafeKey.getSqlKey()).isEqualTo("6BB2F476-GOOGLE");
assertThat(vkeyFromNewWebsafeKey.getOfyKey().getString())
.isEqualTo(
"ahdzfmRvbWFpb"
+ "i1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM");
// the ofy portion of the new vkey string representation was the old vkey string representation
VKey<HostResource> vkeyFromOldWebsafeString =
VKey.fromWebsafeKey(
"ahdzfmRvbW"
+ "Fpbi1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM");
// the following is assertion is ensure backwork compatibility
assertThat(vkeyFromNewWebsafeKey).isEqualTo(vkeyFromOldWebsafeString);
"ahdzfmRvbWFpbi1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM");
}
@Test
@@ -20,7 +20,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
@@ -31,7 +31,7 @@ import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.domain.Period;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
@@ -85,10 +85,10 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
"bog@cat.lol",
clock.nowUtc().minusYears(3),
registrarLol);
HostResource host1 = makeAndPersistHostResource(
"ns1.cat.lol", "1.2.3.4", null, clock.nowUtc().minusYears(1));
HostResource host2 = makeAndPersistHostResource(
"ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2));
Host host1 = makeAndPersistHost("ns1.cat.lol", "1.2.3.4", null, clock.nowUtc().minusYears(1));
Host host2 =
makeAndPersistHost(
"ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2));
persistResource(
makeDomain(
"cat.lol",
@@ -104,8 +104,9 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
.build());
// deleted domain in lol
HostResource hostDodo2 = makeAndPersistHostResource(
"ns2.dodo.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2));
Host hostDodo2 =
makeAndPersistHost(
"ns2.dodo.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2));
Domain domainDeleted =
persistResource(
makeDomain(
@@ -24,7 +24,6 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistResources;
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
@@ -40,7 +39,7 @@ import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.domain.Period;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
@@ -50,6 +49,7 @@ import google.registry.rdap.RdapMetrics.SearchType;
import google.registry.rdap.RdapMetrics.WildcardType;
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
import google.registry.testing.FakeResponse;
import google.registry.testing.FullFieldsTestEntityHelper;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Optional;
@@ -73,9 +73,9 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
private ContactResource contact1;
private ContactResource contact2;
private ContactResource contact3;
private HostResource hostNs1CatLol;
private HostResource hostNs2CatLol;
private HashMap<String, HostResource> hostNameToHostMap = new HashMap<>();
private Host hostNs1CatLol;
private Host hostNs2CatLol;
private HashMap<String, Host> hostNameToHostMap = new HashMap<>();
enum RequestType {
NONE,
@@ -120,7 +120,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
return parseJsonObject(response.getPayload());
}
private HostResource addHostToMap(HostResource host) {
private Host addHostToMap(Host host) {
hostNameToHostMap.put(host.getHostName(), host);
return host;
}
@@ -146,10 +146,11 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
"5372808-TRL", "The Raven", "bog@cat.lol", clock.nowUtc().minusYears(3), registrar);
hostNs1CatLol =
addHostToMap(
makeAndPersistHostResource("ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1)));
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1)));
hostNs2CatLol =
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2)));
domainCatLol =
persistResource(
@@ -194,10 +195,10 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(3),
registrar),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.example", "10.20.30.40", clock.nowUtc().minusYears(1))),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.dog.lol",
"12:feed:5000:0:0:0:15:beef",
clock.nowUtc().minusYears(2))),
@@ -236,7 +237,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
registrar),
hostNs1CatLol,
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.external.tld",
"bad:f00d:cafe:0:0:0:16:beef",
clock.nowUtc().minusYears(2))),
@@ -272,10 +273,10 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(3),
registrar),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1))),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.cat.みんな",
"bad:f00d:cafe:0:0:0:14:beef",
clock.nowUtc().minusYears(2))),
@@ -311,10 +312,10 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(3),
registrar),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.1.test", "1.2.3.5", clock.nowUtc().minusYears(1))),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.cat.2.test",
"bad:f00d:cafe:0:0:0:14:beef",
clock.nowUtc().minusYears(2))),
@@ -400,20 +401,20 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
private void createManyDomainsAndHosts(
int numActiveDomains, int numTotalDomainsPerActiveDomain, int numHosts) {
ImmutableSet.Builder<VKey<HostResource>> hostKeysBuilder = new ImmutableSet.Builder<>();
ImmutableSet.Builder<VKey<Host>> hostKeysBuilder = new ImmutableSet.Builder<>();
ImmutableSet.Builder<String> subordinateHostnamesBuilder = new ImmutableSet.Builder<>();
String mainDomainName = String.format("domain%d.lol", numTotalDomainsPerActiveDomain);
for (int i = numHosts; i >= 1; i--) {
String hostName = String.format("ns%d.%s", i, mainDomainName);
subordinateHostnamesBuilder.add(hostName);
HostResource host =
makeAndPersistHostResource(
Host host =
FullFieldsTestEntityHelper.makeAndPersistHost(
hostName,
String.format("5.5.%d.%d", 5 + i / 250, i % 250),
clock.nowUtc().minusYears(1));
hostKeysBuilder.add(host.createVKey());
}
ImmutableSet<VKey<HostResource>> hostKeys = hostKeysBuilder.build();
ImmutableSet<VKey<Host>> hostKeys = hostKeysBuilder.build();
// Create all the domains at once, then persist them in parallel, for increased efficiency.
ImmutableList.Builder<Domain> domainsBuilder = new ImmutableList.Builder<>();
for (int i = numActiveDomains * numTotalDomainsPerActiveDomain; i >= 1; i--) {
@@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHost;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static org.mockito.Mockito.verify;
@@ -31,7 +31,7 @@ import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.rdap.RdapMetrics.EndpointType;
import google.registry.rdap.RdapMetrics.SearchType;
@@ -85,10 +85,8 @@ class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
ImmutableList.of("1 Smiley Row", "Suite みんな"),
clock.nowUtc(),
registrarLol);
HostResource host1 =
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
HostResource host2 =
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef"));
Host host1 = persistResource(makeHost("ns1.cat.lol", "1.2.3.4"));
Host host2 = persistResource(makeHost("ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef"));
persistResource(
makeDomain("cat.lol", registrant, adminContact, techContact, host1, host2, registrarLol));
// xn--q9jyb4c
@@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
@@ -37,7 +37,7 @@ import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.ofy.Ofy;
import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarPoc;
@@ -72,12 +72,12 @@ class RdapJsonFormatterTest {
private Registrar registrar;
private Domain domainFull;
private Domain domainNoNameserversNoTransfers;
private HostResource hostResourceIpv4;
private HostResource hostResourceIpv6;
private HostResource hostResourceBoth;
private HostResource hostResourceNoAddresses;
private HostResource hostResourceNotLinked;
private HostResource hostResourceSuperordinatePendingTransfer;
private Host hostIpv4;
private Host hostIpv6;
private Host hostBoth;
private Host hostNoAddresses;
private Host hostNotLinked;
private Host hostSuperordinatePendingTransfer;
private ContactResource contactResourceRegistrant;
private ContactResource contactResourceAdmin;
private ContactResource contactResourceTech;
@@ -128,32 +128,32 @@ class RdapJsonFormatterTest {
ImmutableList.of("Somewhere", "Over the Rainbow"),
clock.nowUtc().minusYears(4),
registrar);
hostResourceIpv4 =
makeAndPersistHostResource(
hostIpv4 =
makeAndPersistHost(
"ns1.cat.みんな", "1.2.3.4", null, clock.nowUtc().minusYears(1), "unicoderegistrar");
hostResourceIpv6 =
makeAndPersistHostResource(
hostIpv6 =
makeAndPersistHost(
"ns2.cat.みんな",
"bad:f00d:cafe:0:0:0:15:beef",
null,
clock.nowUtc().minusYears(2),
"unicoderegistrar");
hostResourceBoth =
makeAndPersistHostResource(
hostBoth =
makeAndPersistHost(
"ns3.cat.みんな",
"1.2.3.4",
"bad:f00d:cafe:0:0:0:15:beef",
clock.nowUtc().minusYears(3),
"unicoderegistrar");
hostResourceNoAddresses =
makeAndPersistHostResource(
hostNoAddresses =
makeAndPersistHost(
"ns4.cat.みんな", null, null, clock.nowUtc().minusYears(4), "unicoderegistrar");
hostResourceNotLinked =
makeAndPersistHostResource(
hostNotLinked =
makeAndPersistHost(
"ns5.cat.みんな", null, null, clock.nowUtc().minusYears(5), "unicoderegistrar");
hostResourceSuperordinatePendingTransfer =
hostSuperordinatePendingTransfer =
persistResource(
makeAndPersistHostResource(
makeAndPersistHost(
"ns1.dog.みんな", null, null, clock.nowUtc().minusYears(6), "unicoderegistrar")
.asBuilder()
.setSuperordinateDomain(
@@ -189,8 +189,8 @@ class RdapJsonFormatterTest {
contactResourceRegistrant,
contactResourceAdmin,
contactResourceTech,
hostResourceIpv4,
hostResourceIpv6,
hostIpv4,
hostIpv6,
registrar)
.asBuilder()
.setCreationTimeForTest(clock.nowUtc().minusMonths(4))
@@ -210,7 +210,7 @@ class RdapJsonFormatterTest {
.setCreationTimeForTest(clock.nowUtc())
.setLastEppUpdateTime(null)
.build());
// Create an unused domain that references hostResourceBoth and hostResourceNoAddresses so that
// Create an unused domain that references hostBoth and hostNoAddresses so that
// they will have "associated" (ie, StatusValue.LINKED) status.
persistResource(
makeDomain(
@@ -218,8 +218,8 @@ class RdapJsonFormatterTest {
contactResourceRegistrant,
contactResourceAdmin,
contactResourceTech,
hostResourceBoth,
hostResourceNoAddresses,
hostBoth,
hostNoAddresses,
registrar));
// history entries
@@ -317,49 +317,38 @@ class RdapJsonFormatterTest {
@Test
void testHost_ipv4() {
assertThat(
rdapJsonFormatter.createRdapNameserver(hostResourceIpv4, OutputDataType.FULL).toJson())
assertThat(rdapJsonFormatter.createRdapNameserver(hostIpv4, OutputDataType.FULL).toJson())
.isEqualTo(loadJson("rdapjson_host_ipv4.json"));
}
@Test
void testHost_ipv6() {
assertThat(
rdapJsonFormatter.createRdapNameserver(hostResourceIpv6, OutputDataType.FULL).toJson())
assertThat(rdapJsonFormatter.createRdapNameserver(hostIpv6, OutputDataType.FULL).toJson())
.isEqualTo(loadJson("rdapjson_host_ipv6.json"));
}
@Test
void testHost_both() {
assertThat(
rdapJsonFormatter.createRdapNameserver(hostResourceBoth, OutputDataType.FULL).toJson())
assertThat(rdapJsonFormatter.createRdapNameserver(hostBoth, OutputDataType.FULL).toJson())
.isEqualTo(loadJson("rdapjson_host_both.json"));
}
@Test
void testHost_both_summary() {
assertThat(
rdapJsonFormatter
.createRdapNameserver(hostResourceBoth, OutputDataType.SUMMARY)
.toJson())
assertThat(rdapJsonFormatter.createRdapNameserver(hostBoth, OutputDataType.SUMMARY).toJson())
.isEqualTo(loadJson("rdapjson_host_both_summary.json"));
}
@Test
void testHost_noAddresses() {
assertThat(
rdapJsonFormatter
.createRdapNameserver(hostResourceNoAddresses, OutputDataType.FULL)
.toJson())
rdapJsonFormatter.createRdapNameserver(hostNoAddresses, OutputDataType.FULL).toJson())
.isEqualTo(loadJson("rdapjson_host_no_addresses.json"));
}
@Test
void testHost_notLinked() {
assertThat(
rdapJsonFormatter
.createRdapNameserver(hostResourceNotLinked, OutputDataType.FULL)
.toJson())
assertThat(rdapJsonFormatter.createRdapNameserver(hostNotLinked, OutputDataType.FULL).toJson())
.isEqualTo(loadJson("rdapjson_host_not_linked.json"));
}
@@ -367,7 +356,7 @@ class RdapJsonFormatterTest {
void testHost_superordinateHasPendingTransfer() {
assertThat(
rdapJsonFormatter
.createRdapNameserver(hostResourceSuperordinatePendingTransfer, OutputDataType.FULL)
.createRdapNameserver(hostSuperordinatePendingTransfer, OutputDataType.FULL)
.toJson())
.isEqualTo(loadJson("rdapjson_host_pending_transfer.json"));
}
@@ -19,7 +19,6 @@ import static google.registry.rdap.RdapTestHelper.assertThat;
import static google.registry.rdap.RdapTestHelper.loadJsonFile;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static org.mockito.Mockito.verify;
@@ -31,6 +30,7 @@ import google.registry.rdap.RdapMetrics.SearchType;
import google.registry.rdap.RdapMetrics.WildcardType;
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
import google.registry.request.Action;
import google.registry.testing.FullFieldsTestEntityHelper;
import java.util.Optional;
import javax.annotation.Nullable;
import org.junit.jupiter.api.BeforeEach;
@@ -47,19 +47,20 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverActi
void beforeEach() {
// normal
createTld("lol");
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1));
// idn
createTld("xn--q9jyb4c");
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.xn--q9jyb4c", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(1));
// multilevel
createTld("1.tld");
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.domain.1.tld", "5.6.7.8", clock.nowUtc().minusYears(1));
// deleted
persistResource(
makeAndPersistHostResource("nsdeleted.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1))
FullFieldsTestEntityHelper.makeAndPersistHost(
"nsdeleted.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1))
.asBuilder()
.setDeletionTime(clock.nowUtc().minusMonths(1))
.build());
@@ -67,7 +68,8 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverActi
persistResource(
makeRegistrar("otherregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 102L));
// external
makeAndPersistHostResource("ns1.domain.external", "9.10.11.12", clock.nowUtc().minusYears(1));
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.domain.external", "9.10.11.12", clock.nowUtc().minusYears(1));
}
private JsonObject generateExpectedJson(
@@ -23,10 +23,8 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistResources;
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
@@ -37,13 +35,14 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.rdap.RdapMetrics.EndpointType;
import google.registry.rdap.RdapMetrics.SearchType;
import google.registry.rdap.RdapMetrics.WildcardType;
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
import google.registry.testing.FakeResponse;
import google.registry.testing.FullFieldsTestEntityHelper;
import java.net.URLDecoder;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
@@ -57,8 +56,8 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
}
private Domain domainCatLol;
private HostResource hostNs1CatLol;
private HostResource hostNs2CatLol;
private Host hostNs1CatLol;
private Host hostNs2CatLol;
private JsonObject generateActualJsonWithName(String name) {
return generateActualJsonWithName(name, null);
@@ -107,25 +106,29 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
makeRegistrar("evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar));
hostNs1CatLol =
makeAndPersistHostResource("ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1));
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1));
hostNs2CatLol =
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.cat.lol", "bad:f00d:cafe::15:beef", clock.nowUtc().minusYears(1));
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat2.lol", "1.2.3.3", "bad:f00d:cafe::15:beef", clock.nowUtc().minusYears(1));
makeAndPersistHostResource("ns1.cat.external", null, null, clock.nowUtc().minusYears(1));
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.external", null, null, clock.nowUtc().minusYears(1));
// cat.みんな
createTld("xn--q9jyb4c");
registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar));
makeAndPersistHostResource("ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1));
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1));
// cat.1.test
createTld("1.test");
registrar = persistResource(makeRegistrar("multiregistrar", "1.test", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar));
makeAndPersistHostResource("ns1.cat.1.test", "1.2.3.6", clock.nowUtc().minusYears(1));
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.1.test", "1.2.3.6", clock.nowUtc().minusYears(1));
// create a domain so that we can use it as a test nameserver search string suffix
domainCatLol =
@@ -178,12 +181,12 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
}
private void createManyHosts(int numHosts) {
ImmutableList.Builder<HostResource> hostsBuilder = new ImmutableList.Builder<>();
ImmutableList.Builder<Host> hostsBuilder = new ImmutableList.Builder<>();
ImmutableSet.Builder<String> subordinateHostsBuilder = new ImmutableSet.Builder<>();
for (int i = 1; i <= numHosts; i++) {
String hostName = String.format("nsx%d.cat.lol", i);
subordinateHostsBuilder.add(hostName);
hostsBuilder.add(makeHostResource(hostName, "5.5.5.1", "5.5.5.2"));
hostsBuilder.add(FullFieldsTestEntityHelper.makeHost(hostName, "5.5.5.1", "5.5.5.2"));
}
persistResources(hostsBuilder.build());
domainCatLol =
@@ -193,7 +196,8 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
private void createDeletedHost() {
persistResource(
makeAndPersistHostResource("nsdeleted.cat.lol", "4.3.2.1", clock.nowUtc().minusYears(1))
FullFieldsTestEntityHelper.makeAndPersistHost(
"nsdeleted.cat.lol", "4.3.2.1", clock.nowUtc().minusYears(1))
.asBuilder()
.setDeletionTime(clock.nowUtc().minusMonths(1))
.build());
@@ -47,7 +47,7 @@ import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.poll.PollMessage;
import google.registry.model.poll.PollMessage.Autorenew;
import google.registry.model.rde.RdeMode;
@@ -275,9 +275,8 @@ public class DomainToXjcConverterTest {
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setNameservers(
ImmutableSet.of(
makeHostResource(clock, "3-Q9JYB4C", "bird.or.devil.みんな", "1.2.3.4")
.createVKey(),
makeHostResource(clock, "4-Q9JYB4C", "ns2.cat.みんな", "bad:f00d:cafe::15:beef")
makeHost(clock, "3-Q9JYB4C", "bird.or.devil.みんな", "1.2.3.4").createVKey(),
makeHost(clock, "4-Q9JYB4C", "ns2.cat.みんな", "bad:f00d:cafe::15:beef")
.createVKey()))
.setRegistrant(
makeContactResource(
@@ -412,11 +411,10 @@ public class DomainToXjcConverterTest {
.build());
}
private static HostResource makeHostResource(
FakeClock clock, String repoId, String fqhn, String ip) {
private static Host makeHost(FakeClock clock, String repoId, String fqhn, String ip) {
clock.advanceOneMilli();
return persistEppResource(
new HostResource.Builder()
new Host.Builder()
.setCreationRegistrarId("TheRegistrar")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.xjc.host.XjcHostStatusType;
@@ -38,12 +38,12 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Unit tests for {@link HostResourceToXjcConverter}.
* Unit tests for {@link HostToXjcConverter}.
*
* <p>This tests the mapping between {@link HostResource} and {@link XjcRdeHost} as well as some
* exceptional conditions.
* <p>This tests the mapping between {@link Host} and {@link XjcRdeHost} as well as some exceptional
* conditions.
*/
public class HostResourceToXjcConverterTest {
public class HostToXjcConverterTest {
@RegisterExtension
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
@@ -63,8 +63,8 @@ public class HostResourceToXjcConverterTest {
.addStatusValue(StatusValue.PENDING_TRANSFER)
.build();
XjcRdeHost bean =
HostResourceToXjcConverter.convertSubordinateHost(
new HostResource.Builder()
HostToXjcConverter.convertSubordinateHost(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
@@ -119,8 +119,8 @@ public class HostResourceToXjcConverterTest {
@Test
void testConvertExternalHost() {
XjcRdeHost bean =
HostResourceToXjcConverter.convertExternalHost(
new HostResource.Builder()
HostToXjcConverter.convertExternalHost(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
@@ -168,8 +168,8 @@ public class HostResourceToXjcConverterTest {
@Test
void testConvertExternalHost_ipv6() {
XjcRdeHost bean =
HostResourceToXjcConverter.convertExternalHost(
new HostResource.Builder()
HostToXjcConverter.convertExternalHost(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
@@ -191,8 +191,8 @@ public class HostResourceToXjcConverterTest {
assertThrows(
IllegalArgumentException.class,
() ->
HostResourceToXjcConverter.convertExternalHost(
new HostResource.Builder()
HostToXjcConverter.convertExternalHost(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
@@ -210,8 +210,8 @@ public class HostResourceToXjcConverterTest {
void testMarshal() throws Exception {
// Bean! Bean! Bean!
XjcRdeHostElement bean =
HostResourceToXjcConverter.convertExternal(
new HostResource.Builder()
HostToXjcConverter.convertExternal(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
@@ -42,7 +42,7 @@ import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.poll.PollMessage;
import google.registry.model.poll.PollMessage.Autorenew;
import google.registry.model.reporting.HistoryEntry;
@@ -121,8 +121,8 @@ final class RdeFixtures {
.setIdnTableName("extended_latin")
.setNameservers(
ImmutableSet.of(
makeHostResource(clock, "bird.or.devil.みんな", "1.2.3.4").createVKey(),
makeHostResource(clock, "ns2.cat.みんな", "bad:f00d:cafe::15:beef").createVKey()))
makeHost(clock, "bird.or.devil.みんな", "1.2.3.4").createVKey(),
makeHost(clock, "ns2.cat.みんな", "bad:f00d:cafe::15:beef").createVKey()))
.setRegistrationExpirationTime(DateTime.parse("1994-01-01T00:00:00Z"))
.setGracePeriods(
ImmutableSet.of(
@@ -253,10 +253,10 @@ final class RdeFixtures {
.build());
}
static HostResource makeHostResource(FakeClock clock, String fqhn, String ip) {
static Host makeHost(FakeClock clock, String fqhn, String ip) {
clock.advanceOneMilli();
return persistResource(
new HostResource.Builder()
new Host.Builder()
.setRepoId(generateNewContactHostRoid())
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(clock.nowUtc())
@@ -26,7 +26,7 @@ import org.junit.runner.RunWith;
DomainToXjcConverterTest.class,
GhostrydeGpgIntegrationTest.class,
GhostrydeTest.class,
HostResourceToXjcConverterTest.class,
HostToXjcConverterTest.class,
RdeStagingActionTest.class,
RdeUploadActionTest.class,
RdeReportActionTest.class,
@@ -35,7 +35,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.MediaType;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.reporting.spec11.soy.Spec11EmailSoyInfo;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
@@ -121,7 +121,7 @@ class Spec11EmailUtilsTest {
"Super Cool Registry");
createTld("com");
HostResource host = persistActiveHost("ns1.example.com");
Host host = persistActiveHost("ns1.example.com");
aDomain = persistDomainWithHost("a.com", host);
bDomain = persistDomainWithHost("b.com", host);
persistDomainWithHost("c.com", host);
@@ -238,7 +238,7 @@ class Spec11EmailUtilsTest {
void testSuccess_dealsWithDeletedDomains() throws Exception {
// Create an inactive domain and an active domain with the same name.
persistResource(loadByEntity(aDomain).asBuilder().addStatusValue(SERVER_HOLD).build());
HostResource host = persistActiveHost("ns1.example.com");
Host host = persistActiveHost("ns1.example.com");
aDomain = persistDomainWithHost("a.com", host);
emailUtils.emailSpec11Reports(
@@ -408,7 +408,7 @@ class Spec11EmailUtilsTest {
assertThat(message).isEqualTo(expectedContentBuilder.build());
}
private static Domain persistDomainWithHost(String domainName, HostResource host) {
private static Domain persistDomainWithHost(String domainName, Host host) {
return persistResource(
DatabaseHelper.newDomain(domainName)
.asBuilder()
@@ -88,7 +88,7 @@ import google.registry.model.domain.token.AllocationToken;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.EppResourceIndexBucket;
import google.registry.model.index.ForeignKeyIndex;
@@ -154,12 +154,12 @@ public class DatabaseHelper {
}
}
public static HostResource newHostResource(String hostName) {
return newHostResourceWithRoid(hostName, generateNewContactHostRoid());
public static Host newHost(String hostName) {
return newHostWithRoid(hostName, generateNewContactHostRoid());
}
public static HostResource newHostResourceWithRoid(String hostName, String repoId) {
return new HostResource.Builder()
public static Host newHostWithRoid(String hostName, String repoId) {
return new Host.Builder()
.setHostName(hostName)
.setCreationRegistrarId("TheRegistrar")
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -177,9 +177,9 @@ public class DatabaseHelper {
return newDomain(domainName, generateNewDomainRoid(getTldFromDomainName(domainName)), contact);
}
public static Domain newDomain(String domainName, HostResource... hosts) {
ImmutableSet<VKey<HostResource>> hostKeys =
Arrays.stream(hosts).map(HostResource::createVKey).collect(toImmutableSet());
public static Domain newDomain(String domainName, Host... hosts) {
ImmutableSet<VKey<Host>> hostKeys =
Arrays.stream(hosts).map(Host::createVKey).collect(toImmutableSet());
return newDomain(domainName).asBuilder().setNameservers(hostKeys).build();
}
@@ -269,15 +269,14 @@ public class DatabaseHelper {
newContactResource(contactId).asBuilder().setDeletionTime(deletionTime).build());
}
public static HostResource persistActiveHost(String hostName) {
return persistResource(newHostResource(hostName));
public static Host persistActiveHost(String hostName) {
return persistResource(newHost(hostName));
}
public static HostResource persistActiveSubordinateHost(
String hostName, Domain superordinateDomain) {
public static Host persistActiveSubordinateHost(String hostName, Domain superordinateDomain) {
checkNotNull(superordinateDomain);
return persistResource(
newHostResource(hostName)
newHost(hostName)
.asBuilder()
.setSuperordinateDomain(superordinateDomain.createVKey())
.setInetAddresses(
@@ -286,9 +285,8 @@ public class DatabaseHelper {
}
/** Persists a host resource with the given hostname deleted at the specified time. */
public static HostResource persistDeletedHost(String hostName, DateTime deletionTime) {
return persistResource(
newHostResource(hostName).asBuilder().setDeletionTime(deletionTime).build());
public static Host persistDeletedHost(String hostName, DateTime deletionTime) {
return persistResource(newHost(hostName).asBuilder().setDeletionTime(deletionTime).build());
}
public static Domain persistActiveDomain(String domainName) {
@@ -484,8 +482,7 @@ public class DatabaseHelper {
.forEach(
hostname ->
deleteResource(
EppResourceUtils.loadByForeignKey(HostResource.class, hostname, now)
.get()));
EppResourceUtils.loadByForeignKey(Host.class, hostname, now).get()));
for (HistoryEntry hist : historyEntries) {
deleteResource(hist);
}
@@ -1158,7 +1155,7 @@ public class DatabaseHelper {
return resource.getRepoId() != null
? HistoryEntry.Type.CONTACT_CREATE
: HistoryEntry.Type.CONTACT_UPDATE;
} else if (resource instanceof HostResource) {
} else if (resource instanceof Host) {
return resource.getRepoId() != null
? HistoryEntry.Type.HOST_CREATE
: HistoryEntry.Type.HOST_UPDATE;
@@ -34,7 +34,7 @@ import google.registry.model.domain.Period;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarAddress;
import google.registry.model.registrar.RegistrarPoc;
@@ -125,19 +125,18 @@ public final class FullFieldsTestEntityHelper {
.build());
}
public static HostResource makeHostResource(String fqhn, String ip) {
return makeHostResource(fqhn, ip, null);
public static Host makeHost(String fqhn, String ip) {
return makeHost(fqhn, ip, null);
}
public static HostResource makeHostResource(
String fqhn, @Nullable String ip1, @Nullable String ip2) {
return makeHostResource(fqhn, ip1, ip2, "TheRegistrar");
public static Host makeHost(String fqhn, @Nullable String ip1, @Nullable String ip2) {
return makeHost(fqhn, ip1, ip2, "TheRegistrar");
}
public static HostResource makeHostResource(
public static Host makeHost(
String fqhn, @Nullable String ip1, @Nullable String ip2, String registrarClientId) {
HostResource.Builder builder =
new HostResource.Builder()
Host.Builder builder =
new Host.Builder()
.setRepoId(generateNewContactHostRoid())
.setHostName(Idn.toASCII(fqhn))
.setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z"))
@@ -155,29 +154,28 @@ public final class FullFieldsTestEntityHelper {
return builder.build();
}
public static HostResource makeAndPersistHostResource(
public static Host makeAndPersistHost(
String fqhn, @Nullable String ip, @Nullable DateTime creationTime) {
return makeAndPersistHostResource(fqhn, ip, null, creationTime);
return makeAndPersistHost(fqhn, ip, null, creationTime);
}
public static HostResource makeAndPersistHostResource(
public static Host makeAndPersistHost(
String fqhn, @Nullable String ip1, @Nullable String ip2, @Nullable DateTime creationTime) {
return makeAndPersistHostResource(fqhn, ip1, ip2, creationTime, "TheRegistrar");
return makeAndPersistHost(fqhn, ip1, ip2, creationTime, "TheRegistrar");
}
public static HostResource makeAndPersistHostResource(
public static Host makeAndPersistHost(
String fqhn,
@Nullable String ip1,
@Nullable String ip2,
@Nullable DateTime creationTime,
String registrarClientId) {
HostResource hostResource =
persistResource(makeHostResource(fqhn, ip1, ip2, registrarClientId));
Host host = persistResource(makeHost(fqhn, ip1, ip2, registrarClientId));
if (creationTime != null) {
persistResource(makeHistoryEntry(
hostResource, HistoryEntry.Type.HOST_CREATE, null, "created", creationTime));
persistResource(
makeHistoryEntry(host, HistoryEntry.Type.HOST_CREATE, null, "created", creationTime));
}
return hostResource;
return host;
}
public static ContactResource makeContactResource(
@@ -335,8 +333,8 @@ public final class FullFieldsTestEntityHelper {
@Nullable ContactResource registrant,
@Nullable ContactResource admin,
@Nullable ContactResource tech,
@Nullable HostResource ns1,
@Nullable HostResource ns2,
@Nullable Host ns1,
@Nullable Host ns2,
Registrar registrar) {
Domain.Builder builder =
new Domain.Builder()
@@ -370,7 +368,7 @@ public final class FullFieldsTestEntityHelper {
builder.setContacts(contactsBuilder.build());
}
if ((ns1 != null) || (ns2 != null)) {
ImmutableSet.Builder<VKey<HostResource>> nsBuilder = new ImmutableSet.Builder<>();
ImmutableSet.Builder<VKey<Host>> nsBuilder = new ImmutableSet.Builder<>();
if (ns1 != null) {
nsBuilder.add(ns1.createVKey());
}
@@ -20,44 +20,42 @@ import static com.google.common.truth.Truth.assertAbout;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.SimpleSubjectBuilder;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.persistence.VKey;
import google.registry.testing.TruthChainer.And;
import javax.annotation.Nullable;
import org.joda.time.DateTime;
/** Truth subject for asserting things about {@link HostResource} instances. */
public final class HostResourceSubject
extends AbstractEppResourceSubject<HostResource, HostResourceSubject> {
/** Truth subject for asserting things about {@link Host} instances. */
public final class HostSubject extends AbstractEppResourceSubject<Host, HostSubject> {
private final HostResource actual;
private final Host actual;
public HostResourceSubject(FailureMetadata failureMetadata, HostResource subject) {
public HostSubject(FailureMetadata failureMetadata, Host subject) {
super(failureMetadata, checkNotNull(subject));
this.actual = subject;
}
public static SimpleSubjectBuilder<HostResourceSubject, HostResource> assertAboutHosts() {
return assertAbout(HostResourceSubject::new);
public static SimpleSubjectBuilder<HostSubject, Host> assertAboutHosts() {
return assertAbout(HostSubject::new);
}
public And<HostResourceSubject> hasLastTransferTime(DateTime lastTransferTime) {
public And<HostSubject> hasLastTransferTime(DateTime lastTransferTime) {
return hasValue(lastTransferTime, actual.getLastTransferTime(), "has lastTransferTime");
}
public And<HostResourceSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
public And<HostSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
return doesNotHaveValue(lastTransferTime, actual.getLastTransferTime(), "lastTransferTime");
}
public And<HostResourceSubject> hasLastSuperordinateChange(DateTime lastSuperordinateChange) {
public And<HostSubject> hasLastSuperordinateChange(DateTime lastSuperordinateChange) {
return hasValue(
lastSuperordinateChange,
actual.getLastSuperordinateChange(),
"has lastSuperordinateChange");
}
public And<HostResourceSubject> hasSuperordinateDomain(
@Nullable VKey<Domain> superordinateDomain) {
public And<HostSubject> hasSuperordinateDomain(@Nullable VKey<Domain> superordinateDomain) {
return hasValue(
superordinateDomain, actual.getSuperordinateDomain(), "has superordinateDomain");
}
@@ -40,7 +40,7 @@ import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.RegistryLock;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.testing.AppEngineExtension;
@@ -87,7 +87,7 @@ public final class DomainLockUtilsTest {
@BeforeEach
void setup() {
createTlds("tld", "net");
HostResource host = persistActiveHost("ns1.example.net");
Host host = persistActiveHost("ns1.example.net");
domain = persistResource(DatabaseHelper.newDomain(DOMAIN_NAME, host));
domainLockUtils =
@@ -17,7 +17,7 @@ package google.registry.tools;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -34,7 +34,7 @@ import com.google.common.net.InetAddresses;
import google.registry.model.domain.Domain;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import java.io.IOException;
@@ -61,10 +61,10 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
}
}
private HostResource nameserver1;
private HostResource nameserver2;
private HostResource nameserver3;
private HostResource nameserver4;
private Host nameserver1;
private Host nameserver2;
private Host nameserver3;
private Host nameserver4;
private Domain domain1;
private static final ImmutableList<?> DS_DATA_OUTPUT = ImmutableList.of(
@@ -121,20 +121,24 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
clock.setTo(now);
createTlds("xn--q9jyb4c", "example");
nameserver1 = persistResource(
newHostResource("ns1.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(ImmutableSet.of(
InetAddresses.forString("2607:f8b0:400d:c00::c0"),
InetAddresses.forString("192.168.1.2")))
.build());
nameserver2 = persistResource(
newHostResource("ns2.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(ImmutableSet.of(
InetAddresses.forString("192.168.1.1"),
InetAddresses.forString("2607:f8b0:400d:c00::c1")))
.build());
nameserver1 =
persistResource(
newHost("ns1.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(
ImmutableSet.of(
InetAddresses.forString("2607:f8b0:400d:c00::c0"),
InetAddresses.forString("192.168.1.2")))
.build());
nameserver2 =
persistResource(
newHost("ns2.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(
ImmutableSet.of(
InetAddresses.forString("192.168.1.1"),
InetAddresses.forString("2607:f8b0:400d:c00::c1")))
.build());
nameserver3 = persistActiveHost("ns1.google.com");
nameserver4 = persistActiveHost("ns2.google.com");
domain1 =
@@ -15,7 +15,7 @@
package google.registry.tools;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistDeletedHost;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -44,9 +44,9 @@ class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout(
"Websafe key: "
+ "kind:HostResource"
+ "kind:Host"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
+ "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM");
}
@Test
@@ -56,9 +56,9 @@ class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout(
"Websafe key: "
+ "kind:HostResource"
+ "kind:Host"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
+ "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM");
assertNotInStdout("LiveRef");
}
@@ -71,14 +71,14 @@ class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
assertInStdout("fullyQualifiedHostName=ns2.example.tld");
assertInStdout(
"Websafe key: "
+ "kind:HostResource"
+ "kind:Host"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
+ "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM");
assertInStdout(
"Websafe key: "
+ "kind:HostResource"
+ "@sql:rO0ABXQABjItUk9JRA"
+ "@ofy:agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
+ "kind:Host"
+ "@sql:rO0ABXQABjMtUk9JRA"
+ "@ofy:agR0ZXN0chALEgRIb3N0IgYzLVJPSUQM");
}
@Test
@@ -107,9 +107,7 @@ class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
@Test
void testSuccess_hostDeletedInFuture() throws Exception {
persistResource(
newHostResource("ns1.example.tld").asBuilder()
.setDeletionTime(now.plusDays(1))
.build());
newHost("ns1.example.tld").asBuilder().setDeletionTime(now.plusDays(1)).build());
runCommand("ns1.example.tld", "--read_timestamp=" + now.plusMonths(1));
assertInStdout("Host 'ns1.example.tld' does not exist or is deleted");
}
@@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
import com.googlecode.objectify.Key;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.persistence.VKey;
import google.registry.testing.AppEngineExtension;
@@ -50,10 +50,10 @@ public class MutatingCommandTest {
private Registrar registrar2;
private Registrar newRegistrar1;
private Registrar newRegistrar2;
private HostResource host1;
private HostResource host2;
private HostResource newHost1;
private HostResource newHost2;
private Host host1;
private Host host2;
private Host newHost1;
private Host newHost2;
@BeforeEach
void beforeEach() {
@@ -97,10 +97,10 @@ public class MutatingCommandTest {
String changes = command.prompt();
assertThat(changes)
.isEqualTo(
"Update HostResource@2-ROID\n"
"Update Host@2-ROID\n"
+ "lastEppUpdateTime: null -> 2014-09-09T09:09:09.000Z\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "Update Host@3-ROID\n"
+ "currentSponsorClientId: TheRegistrar -> Registrar2\n"
+ "\n"
+ "Update Registrar@Registrar1\n"
@@ -134,18 +134,23 @@ public class MutatingCommandTest {
};
command.init();
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Create HostResource@2-ROID\n"
+ newHost1 + "\n"
+ "\n"
+ "Create HostResource@3-ROID\n"
+ newHost2 + "\n"
+ "\n"
+ "Create Registrar@Registrar1\n"
+ newRegistrar1 + "\n"
+ "\n"
+ "Create Registrar@Registrar2\n"
+ newRegistrar2 + "\n");
assertThat(changes)
.isEqualTo(
"Create Host@2-ROID\n"
+ newHost1
+ "\n"
+ "\n"
+ "Create Host@3-ROID\n"
+ newHost2
+ "\n"
+ "\n"
+ "Create Registrar@Registrar1\n"
+ newRegistrar1
+ "\n"
+ "\n"
+ "Create Registrar@Registrar2\n"
+ newRegistrar2
+ "\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(loadByEntity(newHost1)).isEqualTo(newHost1);
@@ -167,18 +172,23 @@ public class MutatingCommandTest {
};
command.init();
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Delete HostResource@2-ROID\n"
+ host1 + "\n"
+ "\n"
+ "Delete HostResource@3-ROID\n"
+ host2 + "\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1 + "\n"
+ "\n"
+ "Delete Registrar@Registrar2\n"
+ registrar2 + "\n");
assertThat(changes)
.isEqualTo(
"Delete Host@2-ROID\n"
+ host1
+ "\n"
+ "\n"
+ "Delete Host@3-ROID\n"
+ host2
+ "\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1
+ "\n"
+ "\n"
+ "Delete Registrar@Registrar2\n"
+ registrar2
+ "\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(existsInDb(host1)).isFalse();
@@ -199,12 +209,13 @@ public class MutatingCommandTest {
command.init();
String changes = command.prompt();
System.out.println(changes);
assertThat(changes).isEqualTo(
"Update HostResource@2-ROID\n"
+ "[no changes]\n"
+ "\n"
+ "Update Registrar@Registrar1\n"
+ "[no changes]\n");
assertThat(changes)
.isEqualTo(
"Update Host@2-ROID\n"
+ "[no changes]\n"
+ "\n"
+ "Update Registrar@Registrar1\n"
+ "[no changes]\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 2 entities.\n");
assertThat(loadByEntity(host1)).isEqualTo(host1);
@@ -227,18 +238,21 @@ public class MutatingCommandTest {
};
command.init();
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Delete HostResource@2-ROID\n"
+ host1 + "\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "currentSponsorClientId: TheRegistrar -> Registrar2\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1 + "\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames: false -> true\n");
assertThat(changes)
.isEqualTo(
"Delete Host@2-ROID\n"
+ host1
+ "\n"
+ "\n"
+ "Update Host@3-ROID\n"
+ "currentSponsorClientId: TheRegistrar -> Registrar2\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1
+ "\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames: false -> true\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(existsInDb(host1)).isFalse();
@@ -267,18 +281,21 @@ public class MutatingCommandTest {
// resource has been updated since the command inited the resources to process.
registrar2 = persistResource(registrar2.asBuilder().setContactsRequireSyncing(false).build());
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Delete HostResource@2-ROID\n"
+ host1 + "\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "currentSponsorClientId: TheRegistrar -> Registrar2\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1 + "\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames: false -> true\n");
assertThat(changes)
.isEqualTo(
"Delete Host@2-ROID\n"
+ host1
+ "\n"
+ "\n"
+ "Update Host@3-ROID\n"
+ "currentSponsorClientId: TheRegistrar -> Registrar2\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1
+ "\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames: false -> true\n");
IllegalStateException thrown = assertThrows(IllegalStateException.class, command::execute);
assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called.");
@@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableSet;
import google.registry.model.domain.Domain;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
@@ -39,10 +39,10 @@ import org.junit.jupiter.api.Test;
class UniformRapidSuspensionCommandTest
extends EppToolCommandTestCase<UniformRapidSuspensionCommand> {
private HostResource ns1;
private HostResource ns2;
private HostResource urs1;
private HostResource urs2;
private Host ns1;
private Host ns2;
private Host urs1;
private Host urs2;
private Domain defaultDomain;
private ImmutableSet<DelegationSignerData> defaultDsData;
@@ -63,9 +63,9 @@ class UniformRapidSuspensionCommandTest
}
private void persistDomainWithHosts(
Domain domain, ImmutableSet<DelegationSignerData> dsData, HostResource... hosts) {
ImmutableSet.Builder<VKey<HostResource>> hostRefs = new ImmutableSet.Builder<>();
for (HostResource host : hosts) {
Domain domain, ImmutableSet<DelegationSignerData> dsData, Host... hosts) {
ImmutableSet.Builder<VKey<Host>> hostRefs = new ImmutableSet.Builder<>();
for (Host host : hosts) {
hostRefs.add(host.createVKey());
}
persistResource(domain.asBuilder().setNameservers(hostRefs.build()).setDsData(dsData).build());
@@ -41,7 +41,7 @@ import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.ofy.Ofy;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
@@ -159,8 +159,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
private void runTest_multipleDomains_setNameservers(String nsParam) throws Exception {
createTld("abc");
HostResource host1 = persistActiveHost("foo.bar.tld");
HostResource host2 = persistActiveHost("baz.bar.tld");
Host host1 = persistActiveHost("foo.bar.tld");
Host host2 = persistActiveHost("baz.bar.tld");
persistResource(
DatabaseHelper.newDomain("example.abc")
.asBuilder()
@@ -231,10 +231,9 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
@Test
void testSuccess_setNameservers() throws Exception {
HostResource host1 = persistActiveHost("ns1.zdns.google");
HostResource host2 = persistActiveHost("ns2.zdns.google");
ImmutableSet<VKey<HostResource>> nameservers =
ImmutableSet.of(host1.createVKey(), host2.createVKey());
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());
runCommandForced(
@@ -265,8 +264,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
@Test
void testSuccess_setStatuses() throws Exception {
HostResource host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
Host host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
DatabaseHelper.newDomain("example.tld")
.asBuilder()
@@ -398,8 +397,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
@Test
void testFailure_cantUpdateRegistryLockedDomainEvenAsSuperuser() {
HostResource host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
Host host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
DatabaseHelper.newDomain("example.tld")
.asBuilder()
@@ -423,8 +422,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
@Test
void testFailure_cantUpdatePendingDeleteDomainEvenAsSuperuser_withoutPassingOverrideFlag() {
HostResource host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
Host host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
DatabaseHelper.newDomain("example.tld")
.asBuilder()
@@ -16,7 +16,7 @@ package google.registry.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
@@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableSet;
import google.registry.gcs.GcsUtils;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.persistence.VKey;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
@@ -63,13 +63,10 @@ class GenerateZoneFilesActionTest {
ImmutableSet<InetAddress> ips =
ImmutableSet.of(InetAddress.getByName("127.0.0.1"), InetAddress.getByName("::1"));
HostResource host1 =
persistResource(newHostResource("ns.foo.tld").asBuilder().addInetAddresses(ips).build());
HostResource host2 =
persistResource(newHostResource("ns.bar.tld").asBuilder().addInetAddresses(ips).build());
Host host1 = persistResource(newHost("ns.foo.tld").asBuilder().addInetAddresses(ips).build());
Host host2 = persistResource(newHost("ns.bar.tld").asBuilder().addInetAddresses(ips).build());
ImmutableSet<VKey<HostResource>> nameservers =
ImmutableSet.of(host1.createVKey(), host2.createVKey());
ImmutableSet<VKey<Host>> nameservers = ImmutableSet.of(host1.createVKey(), host2.createVKey());
// This domain will have glue records, because it has a subordinate host which is its own
// nameserver. None of the other domains should have glue records, because their nameservers are
// subordinate to different domains.
@@ -118,7 +115,7 @@ class GenerateZoneFilesActionTest {
persistActiveContact("ignored_contact");
persistActiveHost("ignored.host.tld"); // No ips.
persistActiveDomain("ignored_domain.tld"); // No hosts or DS data.
persistResource(newHostResource("ignored.foo.com").asBuilder().addInetAddresses(ips).build());
persistResource(newHost("ignored.foo.com").asBuilder().addInetAddresses(ips).build());
persistResource(
DatabaseHelper.newDomain("ignored.com")
.asBuilder()
@@ -37,7 +37,7 @@ import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.RegistryLock;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.request.auth.AuthLevel;
@@ -89,7 +89,7 @@ final class RegistryLockVerifyActionTest {
@BeforeEach
void beforeEach() {
createTlds("tld", "net");
HostResource host = persistActiveHost("ns1.example.net");
Host host = persistActiveHost("ns1.example.net");
domain = persistResource(DatabaseHelper.newDomain("example.tld", host));
when(request.getRequestURI()).thenReturn("https://registry.example/registry-lock-verification");
action = createAction(lockId, true);
@@ -33,7 +33,7 @@ import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarPoc;
import google.registry.persistence.VKey;
@@ -51,8 +51,8 @@ class DomainWhoisResponseTest {
@RegisterExtension
final AppEngineExtension gae = AppEngineExtension.builder().withCloudSql().build();
private HostResource hostResource1;
private HostResource hostResource2;
private Host host1;
private Host host2;
private RegistrarPoc abuseContact;
private ContactResource adminContact;
private ContactResource registrant;
@@ -84,16 +84,16 @@ class DomainWhoisResponseTest {
createTld("tld");
hostResource1 =
host1 =
persistResource(
new HostResource.Builder()
new Host.Builder()
.setHostName("ns01.exampleregistrar.tld")
.setRepoId("1-ROID")
.build());
hostResource2 =
host2 =
persistResource(
new HostResource.Builder()
new Host.Builder()
.setHostName("ns02.exampleregistrar.tld")
.setRepoId("2-ROID")
.build());
@@ -239,8 +239,8 @@ class DomainWhoisResponseTest {
.setEmailAddress("EMAIL@EXAMPLE.tld")
.build());
VKey<HostResource> hostResource1Key = hostResource1.createVKey();
VKey<HostResource> hostResource2Key = hostResource2.createVKey();
VKey<Host> host1VKey = host1.createVKey();
VKey<Host> host2VKey = host2.createVKey();
VKey<ContactResource> registrantResourceKey = registrant.createVKey();
VKey<ContactResource> adminResourceKey = adminContact.createVKey();
VKey<ContactResource> techResourceKey = techContact.createVKey();
@@ -267,7 +267,7 @@ class DomainWhoisResponseTest {
ImmutableSet.of(
DesignatedContact.create(DesignatedContact.Type.ADMIN, adminResourceKey),
DesignatedContact.create(DesignatedContact.Type.TECH, techResourceKey)))
.setNameservers(ImmutableSet.of(hostResource1Key, hostResource2Key))
.setNameservers(ImmutableSet.of(host1VKey, host2VKey))
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, "deadface")))
.setGracePeriods(
ImmutableSet.of(
@@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
@@ -42,9 +42,9 @@ class NameserverWhoisResponseTest {
@RegisterExtension
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
private HostResource hostResource1;
private HostResource hostResource2;
private HostResource hostResource3;
private Host host1;
private Host host2;
private Host host3;
private final FakeClock clock = new FakeClock(DateTime.parse("2009-05-29T20:15:00Z"));
@@ -55,8 +55,8 @@ class NameserverWhoisResponseTest {
createTld("tld");
Domain domain = persistResource(DatabaseHelper.newDomain("zobo.tld"));
hostResource1 =
new HostResource.Builder()
host1 =
new Host.Builder()
.setHostName("ns1.example.tld")
.setPersistedCurrentSponsorRegistrarId("example")
.setInetAddresses(
@@ -66,8 +66,8 @@ class NameserverWhoisResponseTest {
.setRepoId("1-EXAMPLE")
.build();
hostResource2 =
new HostResource.Builder()
host2 =
new Host.Builder()
.setHostName("ns2.example.tld")
.setPersistedCurrentSponsorRegistrarId("example")
.setInetAddresses(
@@ -77,8 +77,8 @@ class NameserverWhoisResponseTest {
.setRepoId("2-EXAMPLE")
.build();
hostResource3 =
new HostResource.Builder()
host3 =
new Host.Builder()
.setHostName("ns1.zobo.tld")
.setSuperordinateDomain(domain.createVKey())
.setPersistedCurrentSponsorRegistrarId("example")
@@ -93,7 +93,7 @@ class NameserverWhoisResponseTest {
@Test
void testGetTextOutput() {
NameserverWhoisResponse nameserverWhoisResponse =
new NameserverWhoisResponse(hostResource1, clock.nowUtc());
new NameserverWhoisResponse(host1, clock.nowUtc());
assertThat(
nameserverWhoisResponse.getResponse(
false,
@@ -104,7 +104,7 @@ class NameserverWhoisResponseTest {
@Test
void testGetMultipleNameserversResponse() {
NameserverWhoisResponse nameserverWhoisResponse =
new NameserverWhoisResponse(ImmutableList.of(hostResource1, hostResource2), clock.nowUtc());
new NameserverWhoisResponse(ImmutableList.of(host1, host2), clock.nowUtc());
assertThat(
nameserverWhoisResponse.getResponse(
false,
@@ -115,7 +115,7 @@ class NameserverWhoisResponseTest {
@Test
void testSubordinateDomains() {
NameserverWhoisResponse nameserverWhoisResponse =
new NameserverWhoisResponse(hostResource3, clock.nowUtc());
new NameserverWhoisResponse(host3, clock.nowUtc());
assertThat(
nameserverWhoisResponse.getResponse(
false,
@@ -27,7 +27,6 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.whois.WhoisTestData.loadFile;
@@ -47,7 +46,7 @@ import com.google.common.net.InetAddresses;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.ofy.Ofy;
import google.registry.model.registrar.Registrar;
import google.registry.model.tld.Registry;
@@ -57,6 +56,7 @@ import google.registry.testing.AppEngineExtension;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeResponse;
import google.registry.testing.FakeSleeper;
import google.registry.testing.FullFieldsTestEntityHelper;
import google.registry.testing.InjectExtension;
import google.registry.testing.TestCacheExtension;
import google.registry.util.Retrier;
@@ -125,8 +125,9 @@ public class WhoisActionTest {
persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")),
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
registrar);
}
@@ -203,8 +204,9 @@ public class WhoisActionTest {
persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.みんな")),
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
registrar));
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisAction("domain cat.みんな\r\n").run();
@@ -222,8 +224,9 @@ public class WhoisActionTest {
persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.みんな")),
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
registrar));
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisAction("domain cat.xn--q9jyb4c\r\n").run();
@@ -262,8 +265,9 @@ public class WhoisActionTest {
persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")),
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
registrar));
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisAction("domain cat.lol\r\n").run();
@@ -280,8 +284,9 @@ public class WhoisActionTest {
persistResource(makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")),
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(
(registrar = makeRegistrar("example", "Example Registrar", ACTIVE))))
.asBuilder()
@@ -309,8 +314,10 @@ public class WhoisActionTest {
persistResource(
makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")),
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost(
"ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(makeRegistrar("example", "Example Registrar", ACTIVE)))
.asBuilder()
.setCreationTimeForTest(clock.nowUtc().minusDays(2))
@@ -327,8 +334,10 @@ public class WhoisActionTest {
makeContactResource("5372809-IRL", "Mr. Bob Crypto", "bob@example.lol")),
persistResource(
makeContactResource("5372809-TRL", "Dr. Pablo", "pmy@example.lol")),
persistResource(makeHostResource("ns1.google.lol", "9.9.9.9")),
persistResource(makeHostResource("ns2.google.lol", "4311::f143")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns1.google.lol", "9.9.9.9")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.google.lol", "4311::f143")),
persistResource(
(registrar = makeRegistrar("example", "Example Registrar", ACTIVE))))
.asBuilder()
@@ -344,7 +353,7 @@ public class WhoisActionTest {
@Test
void testRun_nameserverQuery_works() {
persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build());
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
newWhoisAction("nameserver ns1.cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver.txt"));
@@ -352,7 +361,7 @@ public class WhoisActionTest {
@Test
void testRun_ipv6_displaysInCollapsedReadableFormat() {
persistResource(makeHostResource("ns1.cat.lol", "bad:f00d:cafe::15:beef"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "bad:f00d:cafe::15:beef"));
newWhoisAction("nameserver ns1.cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).contains("ns1.cat.lol");
@@ -363,7 +372,7 @@ public class WhoisActionTest {
@Test
void testRun_idnNameserver_works() {
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4"));
newWhoisAction("nameserver ns1.cat.みんな\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).contains("ns1.cat.xn--q9jyb4c");
@@ -372,10 +381,9 @@ public class WhoisActionTest {
@Test
void testRun_nameserver_usesCache() {
persistResource(makeHostResource("ns1.cat.xn--q9jyb4c", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.xn--q9jyb4c", "1.2.3.4"));
// Populate the cache.
HostResource host =
loadByForeignKeyCached(HostResource.class, "ns1.cat.xn--q9jyb4c", clock.nowUtc()).get();
Host host = loadByForeignKeyCached(Host.class, "ns1.cat.xn--q9jyb4c", clock.nowUtc()).get();
// Make a change to the persisted host that won't be seen because the cache will be hit.
persistResource(
host.asBuilder()
@@ -389,7 +397,7 @@ public class WhoisActionTest {
@Test
void testRun_punycodeNameserver_works() {
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4"));
newWhoisAction("nameserver ns1.cat.xn--q9jyb4c\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).contains("ns1.cat.xn--q9jyb4c");
@@ -398,7 +406,7 @@ public class WhoisActionTest {
@Test
void testRun_nameserverNotFound_returns200AndText() {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
newWhoisAction("nameserver ns1.cat.lulz\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver_not_found.txt"));
@@ -407,8 +415,10 @@ public class WhoisActionTest {
@Test
void testRun_nameserverFlaggedAsDeletedInDatastore_doesntGetLeaked() {
persistResource(
makeHostResource("ns1.cat.lol", "1.2.3.4").asBuilder()
.setDeletionTime(clock.nowUtc().minusDays(1)).build());
FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")
.asBuilder()
.setDeletionTime(clock.nowUtc().minusDays(1))
.build());
newWhoisAction("nameserver ns1.cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver_not_found.txt"));
@@ -416,7 +426,7 @@ public class WhoisActionTest {
@Test
void testRun_ipNameserverLookup_works() {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
newWhoisAction("nameserver 1.2.3.4").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).contains("ns1.cat.lol");
@@ -424,8 +434,8 @@ public class WhoisActionTest {
@Test
void testRun_ipMapsToMultipleNameservers_theyAllGetReturned() {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(makeHostResource("ns2.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "1.2.3.4"));
newWhoisAction("nameserver 1.2.3.4").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).contains("ns1.cat.lol");
@@ -434,9 +444,8 @@ public class WhoisActionTest {
@Test
void testRun_ipMapsToMultipleNameserverInDifferentTlds_showsThemAll() {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(
makeHostResource("ns1.cat.xn--q9jyb4c", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.xn--q9jyb4c", "1.2.3.4"));
newWhoisAction("nameserver 1.2.3.4").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).contains("ns1.cat.lol");
@@ -453,7 +462,7 @@ public class WhoisActionTest {
@Test
void testRun_ipMapsToNameserverUnderNonAuthoritativeTld_notFound() {
assertThat(getTlds()).doesNotContain("com");
persistResource(makeHostResource("ns1.google.com", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.google.com", "1.2.3.4"));
newWhoisAction("nameserver 1.2.3.4").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_ip_not_found.txt"));
@@ -462,7 +471,7 @@ public class WhoisActionTest {
@Test
void testRun_nameserverUnderNonAuthoritativeTld_notFound() {
assertThat(getTlds()).doesNotContain("com");
persistResource(makeHostResource("ns1.google.com", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.google.com", "1.2.3.4"));
newWhoisAction("nameserver ns1.google.com").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver_not_found.txt"));
@@ -473,7 +482,7 @@ public class WhoisActionTest {
@Test
void testRun_nameserverInTestTld_notFound() {
persistResource(Registry.get("lol").asBuilder().setTldType(Registry.TldType.TEST).build());
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
newWhoisAction("nameserver ns1.cat.lol").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver_not_found.txt"));
@@ -540,8 +549,9 @@ public class WhoisActionTest {
persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.1.test")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.1.test")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.1.test")),
persistResource(makeHostResource("ns1.cat.1.test", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.1.test", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.1.test", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.1.test", "bad:f00d:cafe::15:beef")),
registrar));
persistSimpleResources(makeRegistrarContacts(registrar));
@@ -552,7 +562,7 @@ public class WhoisActionTest {
@Test
void testRun_hostnameWithMultilevelTld_isStillConsideredHostname() {
persistResource(makeHostResource("ns1.cat.1.test", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.1.test", "1.2.3.4"));
newWhoisAction("nameserver ns1.cat.1.test\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).contains("ns1.cat.1.test");
@@ -561,8 +571,8 @@ public class WhoisActionTest {
@Test
void testRun_metricsLoggedForSuccessfulCommand() {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(makeHostResource("ns2.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "1.2.3.4"));
WhoisAction action = newWhoisAction("nameserver 1.2.3.4");
action.whoisMetrics = mock(WhoisMetrics.class);
action.run();
@@ -591,7 +601,7 @@ public class WhoisActionTest {
@Test
void testRun_metricsLoggedForInternalServerError() throws Exception {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
WhoisAction action = newWhoisAction("ns1.cat.lol");
action.whoisReader = mock(WhoisReader.class);
when(action.whoisReader.readCommand(any(Reader.class), eq(false), any(DateTime.class)))
@@ -611,7 +621,7 @@ public class WhoisActionTest {
@Test
void testRun_retryOnTransientFailure() throws Exception {
persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build());
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
WhoisAction action = newWhoisAction("ns1.cat.lol");
WhoisResponse expectedResponse =
action
@@ -16,7 +16,7 @@ package google.registry.whois;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.newRegistry;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.net.InternetDomainName;
import google.registry.config.RegistryConfig;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
@@ -53,7 +53,7 @@ class WhoisCommandFactoryTest {
WhoisCommandFactory noncachedFactory = WhoisCommandFactory.createNonCached();
WhoisCommandFactory cachedFactory = WhoisCommandFactory.createCached();
Domain domain;
HostResource host;
Host host;
Registrar otherRegistrar;
int origSingletonCacheRefreshSeconds;
@@ -62,7 +62,7 @@ class WhoisCommandFactoryTest {
void setUp() throws Exception {
persistResource(newRegistry("tld", "TLD"));
host =
newHostResource("ns.example.tld")
newHost("ns.example.tld")
.asBuilder()
.setInetAddresses(ImmutableSet.of(InetAddress.getByName("1.2.3.4")))
.build();
@@ -22,7 +22,6 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.whois.WhoisTestData.loadFile;
@@ -43,6 +42,7 @@ import google.registry.model.tld.Registry;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeResponse;
import google.registry.testing.FullFieldsTestEntityHelper;
import google.registry.testing.InjectExtension;
import google.registry.whois.WhoisMetrics.WhoisMetric;
import java.io.IOException;
@@ -128,8 +128,9 @@ class WhoisHttpActionTest {
persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")),
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
registrar));
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisHttpAction("/domain/cat.lol").run();
@@ -148,8 +149,9 @@ class WhoisHttpActionTest {
persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.みんな")),
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
registrar));
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisHttpAction("/domain/cat.みんな").run();
@@ -175,8 +177,9 @@ class WhoisHttpActionTest {
trl,
trl,
trl,
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource(
makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE))));
newWhoisHttpAction("/domain/cat.みんな").run();
@@ -191,8 +194,9 @@ class WhoisHttpActionTest {
persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")),
persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.みんな")),
persistResource(makeContactResource("5372808-TRL", "Eric Schmidt", "bog@cat.みんな")),
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource(
makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE))));
newWhoisHttpAction("cat.みんな").run();
@@ -202,7 +206,7 @@ class WhoisHttpActionTest {
@Test
void testRun_hostnameOnly_works() {
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4"));
newWhoisHttpAction("ns1.cat.みんな").run();
assertThat(response.getPayload()).contains("Server Name: ns1.cat.みんな\r\n");
}
@@ -217,8 +221,9 @@ class WhoisHttpActionTest {
persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")),
persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")),
persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.みんな")),
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
registrar));
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisHttpAction("/domain/cat.xn--q9jyb4c").run();
@@ -228,7 +233,7 @@ class WhoisHttpActionTest {
@Test
void testRun_nameserverQuery_works() {
persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build());
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
newWhoisHttpAction("/nameserver/ns1.cat.lol").run();
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver.txt"));
}
@@ -237,7 +242,7 @@ class WhoisHttpActionTest {
@Disabled
@Test
void testRun_nameserverQueryInTestTld_notFound() {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
newWhoisHttpAction("/nameserver/ns1.cat.lol").run();
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver.txt"));
}
@@ -245,7 +250,7 @@ class WhoisHttpActionTest {
@Test
void testRun_lastUpdateTimestamp_isPresentInResponse() {
clock.setTo(DateTime.parse("2020-07-12T23:52:43Z"));
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
newWhoisHttpAction("/nameserver/ns1.cat.lol").run();
assertThat(response.getPayload())
.contains(">>> Last update of WHOIS database: 2020-07-12T23:52:43Z <<<");
@@ -253,7 +258,7 @@ class WhoisHttpActionTest {
@Test
void testRun_nameserverQueryIdn_works() {
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4"));
newWhoisHttpAction("/nameserver/ns1.cat.みんな").run();
assertThat(response.getPayload()).contains("ns1.cat.みんな");
assertThat(response.getPayload()).contains("1.2.3.4");
@@ -261,7 +266,7 @@ class WhoisHttpActionTest {
@Test
void testRun_nameserverQueryPunycode_works() {
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4"));
newWhoisHttpAction("/nameserver/ns1.cat.xn--q9jyb4c").run();
assertThat(response.getPayload()).contains("ns1.cat.みんな");
assertThat(response.getPayload()).contains("1.2.3.4");
@@ -269,7 +274,7 @@ class WhoisHttpActionTest {
@Test
void testRun_trailingSlashInPath_getsIgnored() {
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4"));
newWhoisHttpAction("/nameserver/ns1.cat.xn--q9jyb4c/").run();
assertThat(response.getPayload()).contains("ns1.cat.みんな");
assertThat(response.getPayload()).contains("1.2.3.4");
@@ -283,8 +288,9 @@ class WhoisHttpActionTest {
persistResource(makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")),
persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.lol")),
persistResource(makeContactResource("5372808-TRL", "Eric Schmidt", "bog@cat.lol")),
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(
makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE))));
newWhoisHttpAction("/domain/cat.LOL").run();
@@ -299,8 +305,9 @@ class WhoisHttpActionTest {
persistResource(makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")),
persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.lol")),
persistResource(makeContactResource("5372808-TRL", "Eric Schmidt", "bog@cat.lol")),
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
persistResource(
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
persistResource(
makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE))));
// python -c "print ''.join('%' + hex(ord(c))[2:] for c in 'cat.lol')"
@@ -342,7 +349,7 @@ class WhoisHttpActionTest {
@Test
void testRun_metricsLoggedForSuccessfulCommand() {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
WhoisHttpAction action = newWhoisHttpAction("/nameserver/ns1.cat.lol");
action.whoisMetrics = mock(WhoisMetrics.class);
action.run();
@@ -367,7 +374,7 @@ class WhoisHttpActionTest {
@Test
void testRun_metricsLoggedForInternalServerError() throws Exception {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
WhoisHttpAction action = newWhoisHttpAction("ns1.cat.lol");
action.whoisReader = mock(WhoisReader.class);
when(action.whoisReader.readCommand(any(Reader.class), eq(false), any(DateTime.class)))
@@ -17,13 +17,13 @@ package google.registry.whois;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import google.registry.request.RequestModule;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.FullFieldsTestEntityHelper;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.StringReader;
@@ -52,7 +52,7 @@ final class WhoisInjectionTest {
@Test
void testWhoisAction_injectsAndWorks() throws Exception {
createTld("lol");
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
when(req.getReader()).thenReturn(new BufferedReader(new StringReader("ns1.cat.lol\r\n")));
DaggerWhoisTestComponent.builder()
.requestModule(new RequestModule(req, rsp))
@@ -66,7 +66,7 @@ final class WhoisInjectionTest {
@Test
void testWhoisHttpAction_injectsAndWorks() {
createTld("lol");
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
when(req.getRequestURI()).thenReturn("/whois/ns1.cat.lol");
DaggerWhoisTestComponent.builder()
.requestModule(new RequestModule(req, rsp))
@@ -8,7 +8,7 @@ ForeignKeyContactIndex
ForeignKeyDomainIndex
ForeignKeyHostIndex
HistoryEntry
HostResource
Host
Modification
OneTime
PollMessage
@@ -7,7 +7,7 @@ ForeignKeyContactIndex
ForeignKeyDomainIndex
ForeignKeyHostIndex
HistoryEntry
HostResource
Host
Modification
OneTime
PollMessage
@@ -118,7 +118,7 @@ class google.registry.model.domain.Domain {
java.util.Set<google.registry.model.domain.GracePeriod> gracePeriods;
java.util.Set<google.registry.model.domain.secdns.DelegationSignerData> dsData;
java.util.Set<google.registry.model.eppcommon.StatusValue> status;
java.util.Set<google.registry.persistence.VKey<google.registry.model.host.HostResource>> nsHosts;
java.util.Set<google.registry.persistence.VKey<google.registry.model.host.Host>> nsHosts;
java.util.Set<java.lang.String> subordinateHosts;
org.joda.time.DateTime autorenewEndTime;
org.joda.time.DateTime deletionTime;
@@ -150,7 +150,7 @@ class google.registry.model.domain.DomainBase {
java.util.Set<google.registry.model.domain.GracePeriod> gracePeriods;
java.util.Set<google.registry.model.domain.secdns.DelegationSignerData> dsData;
java.util.Set<google.registry.model.eppcommon.StatusValue> status;
java.util.Set<google.registry.persistence.VKey<google.registry.model.host.HostResource>> nsHosts;
java.util.Set<google.registry.persistence.VKey<google.registry.model.host.Host>> nsHosts;
java.util.Set<java.lang.String> subordinateHosts;
org.joda.time.DateTime autorenewEndTime;
org.joda.time.DateTime deletionTime;
@@ -174,7 +174,7 @@ class google.registry.model.domain.DomainHistory {
java.util.Set<google.registry.model.domain.GracePeriod$GracePeriodHistory> gracePeriodHistories;
java.util.Set<google.registry.model.domain.secdns.DomainDsDataHistory> dsDataHistories;
java.util.Set<google.registry.model.reporting.DomainTransactionRecord> domainTransactionRecords;
java.util.Set<google.registry.persistence.VKey<google.registry.model.host.HostResource>> nsHosts;
java.util.Set<google.registry.persistence.VKey<google.registry.model.host.Host>> nsHosts;
org.joda.time.DateTime modificationTime;
}
class google.registry.model.domain.GracePeriod {
@@ -289,6 +289,20 @@ class google.registry.model.eppcommon.Trid {
java.lang.String clientTransactionId;
java.lang.String serverTransactionId;
}
class google.registry.model.host.Host {
@Id java.lang.String repoId;
google.registry.persistence.VKey<google.registry.model.domain.Domain> superordinateDomain;
java.lang.String creationClientId;
java.lang.String currentSponsorClientId;
java.lang.String fullyQualifiedHostName;
java.lang.String lastEppUpdateClientId;
java.util.Set<google.registry.model.eppcommon.StatusValue> status;
java.util.Set<java.net.InetAddress> inetAddresses;
org.joda.time.DateTime deletionTime;
org.joda.time.DateTime lastEppUpdateTime;
org.joda.time.DateTime lastSuperordinateChange;
org.joda.time.DateTime lastTransferTime;
}
class google.registry.model.host.HostBase {
@Id java.lang.String repoId;
google.registry.persistence.VKey<google.registry.model.domain.Domain> superordinateDomain;
@@ -319,20 +333,6 @@ class google.registry.model.host.HostHistory {
java.util.Set<google.registry.model.reporting.DomainTransactionRecord> domainTransactionRecords;
org.joda.time.DateTime modificationTime;
}
class google.registry.model.host.HostResource {
@Id java.lang.String repoId;
google.registry.persistence.VKey<google.registry.model.domain.Domain> superordinateDomain;
java.lang.String creationClientId;
java.lang.String currentSponsorClientId;
java.lang.String fullyQualifiedHostName;
java.lang.String lastEppUpdateClientId;
java.util.Set<google.registry.model.eppcommon.StatusValue> status;
java.util.Set<java.net.InetAddress> inetAddresses;
org.joda.time.DateTime deletionTime;
org.joda.time.DateTime lastEppUpdateTime;
org.joda.time.DateTime lastSuperordinateChange;
org.joda.time.DateTime lastTransferTime;
}
class google.registry.model.index.EppResourceIndex {
@Id java.lang.String id;
@Parent com.googlecode.objectify.Key<google.registry.model.index.EppResourceIndexBucket> bucket;