mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Re-add EppException marshalling assertions in host flow tests
Apologies for the reformatting, but this refactoring is quite rote and it's definitely a bigger use of total time to perform the reformatting individually than to simply do it file-wide. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179238745
This commit is contained in:
parent
e17109a0eb
commit
34699465d5
5 changed files with 514 additions and 390 deletions
|
@ -17,8 +17,10 @@ package google.registry.flows.host;
|
||||||
import static google.registry.model.eppoutput.CheckData.HostCheck.create;
|
import static google.registry.model.eppoutput.CheckData.HostCheck.create;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceCheckFlowTestCase;
|
import google.registry.flows.ResourceCheckFlowTestCase;
|
||||||
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
|
@ -76,7 +78,8 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow,
|
||||||
@Test
|
@Test
|
||||||
public void testTooManyIds() throws Exception {
|
public void testTooManyIds() throws Exception {
|
||||||
setEppInput("host_check_51.xml");
|
setEppInput("host_check_51.xml");
|
||||||
assertThrows(TooManyResourceChecksException.class, this::runFlow);
|
EppException thrown = expectThrows(TooManyResourceChecksException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -24,8 +24,8 @@ import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
|
||||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
|
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
|
||||||
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
||||||
|
@ -34,6 +34,7 @@ import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppXmlTransformer.IpAddressVersionMismatchException;
|
import google.registry.flows.EppXmlTransformer.IpAddressVersionMismatchException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.exceptions.ResourceAlreadyExistsException;
|
import google.registry.flows.exceptions.ResourceAlreadyExistsException;
|
||||||
|
@ -60,9 +61,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
private void setEppHostCreateInput(String hostName, String hostAddrs) {
|
private void setEppHostCreateInput(String hostName, String hostAddrs) {
|
||||||
setEppInput(
|
setEppInput(
|
||||||
"host_create.xml",
|
"host_create.xml",
|
||||||
ImmutableMap.of(
|
ImmutableMap.of("HOSTNAME", hostName, "HOSTADDRS", (hostAddrs == null) ? "" : hostAddrs));
|
||||||
"HOSTNAME", hostName,
|
|
||||||
"HOSTADDRS", (hostAddrs == null) ? "" : hostAddrs));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEppHostCreateInputWithIps(String hostName) {
|
private void setEppHostCreateInputWithIps(String hostName) {
|
||||||
|
@ -83,8 +82,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
assertTransactionalFlow(true);
|
assertTransactionalFlow(true);
|
||||||
runFlowAssertResponse(loadFile("host_create_response.xml"));
|
runFlowAssertResponse(loadFile("host_create_response.xml"));
|
||||||
// Check that the host was created and persisted with a history entry.
|
// Check that the host was created and persisted with a history entry.
|
||||||
assertAboutHosts().that(reloadResourceByForeignKey())
|
assertAboutHosts()
|
||||||
.hasLastSuperordinateChange(null).and()
|
.that(reloadResourceByForeignKey())
|
||||||
|
.hasLastSuperordinateChange(null)
|
||||||
|
.and()
|
||||||
.hasOnlyOneHistoryEntryWhich()
|
.hasOnlyOneHistoryEntryWhich()
|
||||||
.hasType(HistoryEntry.Type.HOST_CREATE);
|
.hasType(HistoryEntry.Type.HOST_CREATE);
|
||||||
assertNoBillingEvents();
|
assertNoBillingEvents();
|
||||||
|
@ -126,7 +127,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
createTlds("bar.tld", "tld");
|
createTlds("bar.tld", "tld");
|
||||||
|
|
||||||
setEppHostCreateInputWithIps("ns1.bar.tld");
|
setEppHostCreateInputWithIps("ns1.bar.tld");
|
||||||
assertThrows(HostNameTooShallowException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameTooShallowException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -154,7 +156,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
setEppHostCreateInput("ns1.example.tld", null);
|
setEppHostCreateInput("ns1.example.tld", null);
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
assertThrows(SubordinateHostMustHaveIpException.class, this::runFlow);
|
EppException thrown = expectThrows(SubordinateHostMustHaveIpException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -162,7 +165,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
setEppHostCreateInputWithIps("ns1.example.external");
|
setEppHostCreateInputWithIps("ns1.example.external");
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
assertThrows(UnexpectedExternalHostIpException.class, this::runFlow);
|
EppException thrown = expectThrows(UnexpectedExternalHostIpException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -178,11 +182,12 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
public void testFailure_superordinateInPendingDelete() throws Exception {
|
public void testFailure_superordinateInPendingDelete() throws Exception {
|
||||||
setEppHostCreateInputWithIps("ns1.example.tld");
|
setEppHostCreateInputWithIps("ns1.example.tld");
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(newDomainResource("example.tld")
|
persistResource(
|
||||||
.asBuilder()
|
newDomainResource("example.tld")
|
||||||
.setDeletionTime(clock.nowUtc().plusDays(35))
|
.asBuilder()
|
||||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
.setDeletionTime(clock.nowUtc().plusDays(35))
|
||||||
.build());
|
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||||
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
SuperordinateDomainInPendingDeleteException thrown =
|
SuperordinateDomainInPendingDeleteException thrown =
|
||||||
expectThrows(SuperordinateDomainInPendingDeleteException.class, this::runFlow);
|
expectThrows(SuperordinateDomainInPendingDeleteException.class, this::runFlow);
|
||||||
|
@ -206,7 +211,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonLowerCaseHostname() throws Exception {
|
public void testFailure_nonLowerCaseHostname() throws Exception {
|
||||||
setEppHostCreateInput("ns1.EXAMPLE.tld", null);
|
setEppHostCreateInput("ns1.EXAMPLE.tld", null);
|
||||||
assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -220,13 +226,15 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonCanonicalHostname() throws Exception {
|
public void testFailure_nonCanonicalHostname() throws Exception {
|
||||||
setEppHostCreateInput("ns1.example.tld.", null);
|
setEppHostCreateInput("ns1.example.tld.", null);
|
||||||
assertThrows(HostNameNotNormalizedException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameNotNormalizedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_longHostName() throws Exception {
|
public void testFailure_longHostName() throws Exception {
|
||||||
setEppHostCreateInputWithIps("a" + Strings.repeat(".labelpart", 25) + ".tld");
|
setEppHostCreateInputWithIps("a" + Strings.repeat(".labelpart", 25) + ".tld");
|
||||||
assertThrows(HostNameTooLongException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameTooLongException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -236,13 +244,15 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
"<host:addr ip=\"v4\">192.0.2.2</host:addr>\n"
|
"<host:addr ip=\"v4\">192.0.2.2</host:addr>\n"
|
||||||
+ "<host:addr ip=\"v6\">192.0.2.29</host:addr>\n"
|
+ "<host:addr ip=\"v6\">192.0.2.29</host:addr>\n"
|
||||||
+ "<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
|
+ "<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
|
||||||
assertThrows(IpAddressVersionMismatchException.class, this::runFlow);
|
EppException thrown = expectThrows(IpAddressVersionMismatchException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doFailingHostNameTest(String hostName, Class<? extends Throwable> exception)
|
private void doFailingHostNameTest(String hostName, Class<? extends EppException> exception)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
setEppHostCreateInputWithIps(hostName);
|
setEppHostCreateInputWithIps(hostName);
|
||||||
assertThrows(exception, this::runFlow);
|
EppException thrown = expectThrows(exception, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -279,7 +289,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
public void testFailure_ccTldInBailiwick() throws Exception {
|
public void testFailure_ccTldInBailiwick() throws Exception {
|
||||||
createTld("co.uk");
|
createTld("co.uk");
|
||||||
setEppHostCreateInputWithIps("foo.co.uk");
|
setEppHostCreateInputWithIps("foo.co.uk");
|
||||||
assertThrows(HostNameTooShallowException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameTooShallowException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,14 +23,15 @@ import static google.registry.testing.DatastoreHelper.newHostResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
|
||||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
|
@ -75,7 +76,8 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
assertAboutHosts().that(deletedHost).hasStatusValue(StatusValue.PENDING_DELETE);
|
assertAboutHosts().that(deletedHost).hasStatusValue(StatusValue.PENDING_DELETE);
|
||||||
assertAsyncDeletionTaskEnqueued(
|
assertAsyncDeletionTaskEnqueued(
|
||||||
deletedHost, "TheRegistrar", Trid.create("ABC-12345", "server-trid"), false);
|
deletedHost, "TheRegistrar", Trid.create("ABC-12345", "server-trid"), false);
|
||||||
assertAboutHosts().that(deletedHost)
|
assertAboutHosts()
|
||||||
|
.that(deletedHost)
|
||||||
.hasOnlyOneHistoryEntryWhich()
|
.hasOnlyOneHistoryEntryWhich()
|
||||||
.hasType(HistoryEntry.Type.HOST_PENDING_DELETE);
|
.hasType(HistoryEntry.Type.HOST_PENDING_DELETE);
|
||||||
assertNoBillingEvents();
|
assertNoBillingEvents();
|
||||||
|
@ -130,7 +132,8 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
public void testFailure_unauthorizedClient() throws Exception {
|
public void testFailure_unauthorizedClient() throws Exception {
|
||||||
sessionMetadata.setClientId("NewRegistrar");
|
sessionMetadata.setClientId("NewRegistrar");
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
assertThrows(ResourceNotOwnedException.class, this::runFlow);
|
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -144,7 +147,8 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
assertAboutHosts().that(deletedHost).hasStatusValue(StatusValue.PENDING_DELETE);
|
assertAboutHosts().that(deletedHost).hasStatusValue(StatusValue.PENDING_DELETE);
|
||||||
assertAsyncDeletionTaskEnqueued(
|
assertAsyncDeletionTaskEnqueued(
|
||||||
deletedHost, "NewRegistrar", Trid.create("ABC-12345", "server-trid"), true);
|
deletedHost, "NewRegistrar", Trid.create("ABC-12345", "server-trid"), true);
|
||||||
assertAboutHosts().that(deletedHost)
|
assertAboutHosts()
|
||||||
|
.that(deletedHost)
|
||||||
.hasOnlyOneHistoryEntryWhich()
|
.hasOnlyOneHistoryEntryWhich()
|
||||||
.hasType(HistoryEntry.Type.HOST_PENDING_DELETE);
|
.hasType(HistoryEntry.Type.HOST_PENDING_DELETE);
|
||||||
assertNoBillingEvents();
|
assertNoBillingEvents();
|
||||||
|
@ -155,13 +159,16 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
public void testSuccess_authorizedClientReadFromSuperordinate() throws Exception {
|
public void testSuccess_authorizedClientReadFromSuperordinate() throws Exception {
|
||||||
sessionMetadata.setClientId("TheRegistrar");
|
sessionMetadata.setClientId("TheRegistrar");
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
DomainResource domain = persistResource(
|
DomainResource domain =
|
||||||
newDomainResource("example.tld").asBuilder()
|
persistResource(
|
||||||
.setPersistedCurrentSponsorClientId("TheRegistrar")
|
newDomainResource("example.tld")
|
||||||
.build());
|
.asBuilder()
|
||||||
|
.setPersistedCurrentSponsorClientId("TheRegistrar")
|
||||||
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource("ns1.example.tld").asBuilder()
|
newHostResource("ns1.example.tld")
|
||||||
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't hurt.
|
.asBuilder()
|
||||||
|
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't hurt.
|
||||||
.setSuperordinateDomain(Key.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
@ -172,16 +179,20 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
public void testFailure_unauthorizedClientReadFromSuperordinate() throws Exception {
|
public void testFailure_unauthorizedClientReadFromSuperordinate() throws Exception {
|
||||||
sessionMetadata.setClientId("TheRegistrar");
|
sessionMetadata.setClientId("TheRegistrar");
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
DomainResource domain = persistResource(
|
DomainResource domain =
|
||||||
newDomainResource("example.tld").asBuilder()
|
persistResource(
|
||||||
.setPersistedCurrentSponsorClientId("NewRegistrar")
|
newDomainResource("example.tld")
|
||||||
.build());
|
.asBuilder()
|
||||||
|
.setPersistedCurrentSponsorClientId("NewRegistrar")
|
||||||
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource("ns1.example.tld").asBuilder()
|
newHostResource("ns1.example.tld")
|
||||||
.setPersistedCurrentSponsorClientId("TheRegistrar") // Shouldn't help.
|
.asBuilder()
|
||||||
|
.setPersistedCurrentSponsorClientId("TheRegistrar") // Shouldn't help.
|
||||||
.setSuperordinateDomain(Key.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(ResourceNotOwnedException.class, this::runFlow);
|
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -192,20 +203,25 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
DateTime now = clock.nowUtc();
|
DateTime now = clock.nowUtc();
|
||||||
DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
|
DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
|
||||||
DateTime transferExpirationTime = now.minusDays(1);
|
DateTime transferExpirationTime = now.minusDays(1);
|
||||||
DomainResource domain = persistResource(newDomainResource("example.tld").asBuilder()
|
DomainResource domain =
|
||||||
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't hurt.
|
persistResource(
|
||||||
.addStatusValue(StatusValue.PENDING_TRANSFER)
|
newDomainResource("example.tld")
|
||||||
.setTransferData(new TransferData.Builder()
|
.asBuilder()
|
||||||
.setTransferStatus(TransferStatus.PENDING)
|
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't hurt.
|
||||||
.setGainingClientId("NewRegistrar")
|
.addStatusValue(StatusValue.PENDING_TRANSFER)
|
||||||
.setTransferRequestTime(requestTime)
|
.setTransferData(
|
||||||
.setLosingClientId("TheRegistrar")
|
new TransferData.Builder()
|
||||||
.setPendingTransferExpirationTime(transferExpirationTime)
|
.setTransferStatus(TransferStatus.PENDING)
|
||||||
.build())
|
.setGainingClientId("NewRegistrar")
|
||||||
.build());
|
.setTransferRequestTime(requestTime)
|
||||||
|
.setLosingClientId("TheRegistrar")
|
||||||
|
.setPendingTransferExpirationTime(transferExpirationTime)
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource("ns1.example.tld").asBuilder()
|
newHostResource("ns1.example.tld")
|
||||||
.setPersistedCurrentSponsorClientId("TheRegistrar") // Shouldn't hurt.
|
.asBuilder()
|
||||||
|
.setPersistedCurrentSponsorClientId("TheRegistrar") // Shouldn't hurt.
|
||||||
.setSuperordinateDomain(Key.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
@ -220,49 +236,60 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
DateTime now = clock.nowUtc();
|
DateTime now = clock.nowUtc();
|
||||||
DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
|
DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
|
||||||
DateTime transferExpirationTime = now.minusDays(1);
|
DateTime transferExpirationTime = now.minusDays(1);
|
||||||
DomainResource domain = persistResource(newDomainResource("example.tld").asBuilder()
|
DomainResource domain =
|
||||||
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't help.
|
persistResource(
|
||||||
.addStatusValue(StatusValue.PENDING_TRANSFER)
|
newDomainResource("example.tld")
|
||||||
.setTransferData(new TransferData.Builder()
|
.asBuilder()
|
||||||
.setTransferStatus(TransferStatus.PENDING)
|
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't help.
|
||||||
.setGainingClientId("TheRegistrar")
|
.addStatusValue(StatusValue.PENDING_TRANSFER)
|
||||||
.setTransferRequestTime(requestTime)
|
.setTransferData(
|
||||||
.setLosingClientId("NewRegistrar")
|
new TransferData.Builder()
|
||||||
.setPendingTransferExpirationTime(transferExpirationTime)
|
.setTransferStatus(TransferStatus.PENDING)
|
||||||
.build())
|
.setGainingClientId("TheRegistrar")
|
||||||
.build());
|
.setTransferRequestTime(requestTime)
|
||||||
|
.setLosingClientId("NewRegistrar")
|
||||||
|
.setPendingTransferExpirationTime(transferExpirationTime)
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource("ns1.example.tld").asBuilder()
|
newHostResource("ns1.example.tld")
|
||||||
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't help.
|
.asBuilder()
|
||||||
|
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't help.
|
||||||
.setSuperordinateDomain(Key.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(ResourceNotOwnedException.class, this::runFlow);
|
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_failfastWhenLinkedToDomain() throws Exception {
|
public void testFailure_failfastWhenLinkedToDomain() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(newDomainResource("example.tld").asBuilder()
|
persistResource(
|
||||||
.setNameservers(ImmutableSet.of(
|
newDomainResource("example.tld")
|
||||||
Key.create(persistActiveHost("ns1.example.tld"))))
|
.asBuilder()
|
||||||
.build());
|
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
|
||||||
assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
|
.build());
|
||||||
|
EppException thrown = expectThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_failfastWhenLinkedToApplication() throws Exception {
|
public void testFailure_failfastWhenLinkedToApplication() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(newDomainApplication("example.tld").asBuilder()
|
persistResource(
|
||||||
.setNameservers(ImmutableSet.of(
|
newDomainApplication("example.tld")
|
||||||
Key.create(persistActiveHost("ns1.example.tld"))))
|
.asBuilder()
|
||||||
.build());
|
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
|
||||||
assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
|
.build());
|
||||||
|
EppException thrown = expectThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonLowerCaseHostname() throws Exception {
|
public void testFailure_nonLowerCaseHostname() throws Exception {
|
||||||
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
|
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
|
||||||
assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -276,7 +303,8 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonCanonicalHostname() throws Exception {
|
public void testFailure_nonCanonicalHostname() throws Exception {
|
||||||
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
|
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
|
||||||
assertThrows(HostNameNotNormalizedException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameNotNormalizedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -19,13 +19,14 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.net.InetAddresses;
|
import com.google.common.net.InetAddresses;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException;
|
import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException;
|
||||||
|
@ -57,12 +58,12 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
.setFullyQualifiedHostName(getUniqueIdFromCommand())
|
.setFullyQualifiedHostName(getUniqueIdFromCommand())
|
||||||
.setRepoId("1FF-FOOBAR")
|
.setRepoId("1FF-FOOBAR")
|
||||||
.setPersistedCurrentSponsorClientId("my sponsor")
|
.setPersistedCurrentSponsorClientId("my sponsor")
|
||||||
.setStatusValues(
|
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
||||||
ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
.setInetAddresses(
|
||||||
.setInetAddresses(ImmutableSet.of(
|
ImmutableSet.of(
|
||||||
InetAddresses.forString("192.0.2.2"),
|
InetAddresses.forString("192.0.2.2"),
|
||||||
InetAddresses.forString("1080:0:0:0:8:800:200C:417A"),
|
InetAddresses.forString("1080:0:0:0:8:800:200C:417A"),
|
||||||
InetAddresses.forString("192.0.2.29")))
|
InetAddresses.forString("192.0.2.29")))
|
||||||
.setPersistedCurrentSponsorClientId("TheRegistrar")
|
.setPersistedCurrentSponsorClientId("TheRegistrar")
|
||||||
.setCreationClientId("NewRegistrar")
|
.setCreationClientId("NewRegistrar")
|
||||||
.setLastEppUpdateClientId("NewRegistrar")
|
.setLastEppUpdateClientId("NewRegistrar")
|
||||||
|
@ -89,9 +90,10 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
public void testSuccess_linked() throws Exception {
|
public void testSuccess_linked() throws Exception {
|
||||||
persistHostResource();
|
persistHostResource();
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource("example.foobar").asBuilder()
|
newDomainResource("example.foobar")
|
||||||
.addNameservers(ImmutableSet.of(Key.create(persistHostResource())))
|
.asBuilder()
|
||||||
.build());
|
.addNameservers(ImmutableSet.of(Key.create(persistHostResource())))
|
||||||
|
.build());
|
||||||
assertTransactionalFlow(false);
|
assertTransactionalFlow(false);
|
||||||
// Check that the persisted host info was returned.
|
// Check that the persisted host info was returned.
|
||||||
runFlowAssertResponse(
|
runFlowAssertResponse(
|
||||||
|
@ -102,16 +104,19 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
assertNoBillingEvents();
|
assertNoBillingEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runTest_superordinateDomain(DateTime domainTransferTime,
|
private void runTest_superordinateDomain(
|
||||||
@Nullable DateTime lastSuperordinateChange) throws Exception {
|
DateTime domainTransferTime, @Nullable DateTime lastSuperordinateChange) throws Exception {
|
||||||
DomainResource domain = persistResource(
|
DomainResource domain =
|
||||||
newDomainResource("parent.foobar").asBuilder()
|
persistResource(
|
||||||
.setRepoId("BEEF-FOOBAR")
|
newDomainResource("parent.foobar")
|
||||||
.setLastTransferTime(domainTransferTime)
|
.asBuilder()
|
||||||
.setPersistedCurrentSponsorClientId("superclientid")
|
.setRepoId("BEEF-FOOBAR")
|
||||||
.build());
|
.setLastTransferTime(domainTransferTime)
|
||||||
|
.setPersistedCurrentSponsorClientId("superclientid")
|
||||||
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
persistHostResource().asBuilder()
|
persistHostResource()
|
||||||
|
.asBuilder()
|
||||||
.setRepoId("CEEF-FOOBAR")
|
.setRepoId("CEEF-FOOBAR")
|
||||||
.setSuperordinateDomain(Key.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.setLastSuperordinateChange(lastSuperordinateChange)
|
.setLastSuperordinateChange(lastSuperordinateChange)
|
||||||
|
@ -126,17 +131,15 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_withSuperordinateDomain_hostMovedAfterDomainTransfer()
|
public void testSuccess_withSuperordinateDomain_hostMovedAfterDomainTransfer() throws Exception {
|
||||||
throws Exception {
|
runTest_superordinateDomain(
|
||||||
runTest_superordinateDomain(DateTime.parse("2000-01-08T09:00:00.0Z"),
|
DateTime.parse("2000-01-08T09:00:00.0Z"), DateTime.parse("2000-03-01T01:00:00.0Z"));
|
||||||
DateTime.parse("2000-03-01T01:00:00.0Z"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_withSuperordinateDomain_hostMovedBeforeDomainTransfer()
|
public void testSuccess_withSuperordinateDomain_hostMovedBeforeDomainTransfer() throws Exception {
|
||||||
throws Exception {
|
runTest_superordinateDomain(
|
||||||
runTest_superordinateDomain(DateTime.parse("2000-04-08T09:00:00.0Z"),
|
DateTime.parse("2000-04-08T09:00:00.0Z"), DateTime.parse("2000-02-08T09:00:00.0Z"));
|
||||||
DateTime.parse("2000-02-08T09:00:00.0Z"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -154,7 +157,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_existedButWasDeleted() throws Exception {
|
public void testFailure_existedButWasDeleted() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
@ -163,7 +166,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonLowerCaseHostname() throws Exception {
|
public void testFailure_nonLowerCaseHostname() throws Exception {
|
||||||
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
|
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
|
||||||
assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameNotLowerCaseException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -177,7 +181,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonCanonicalHostname() throws Exception {
|
public void testFailure_nonCanonicalHostname() throws Exception {
|
||||||
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
|
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
|
||||||
assertThrows(HostNameNotNormalizedException.class, this::runFlow);
|
EppException thrown = expectThrows(HostNameNotNormalizedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue