diff --git a/javatests/google/registry/flows/EppCommitLogsTest.java b/javatests/google/registry/flows/EppCommitLogsTest.java index 39c56d3fa..6599bd0cc 100644 --- a/javatests/google/registry/flows/EppCommitLogsTest.java +++ b/javatests/google/registry/flows/EppCommitLogsTest.java @@ -24,6 +24,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.Duration.standardDays; +import com.google.common.collect.ImmutableMap; import com.googlecode.objectify.Key; import google.registry.flows.EppTestComponent.FakesAndMocksModule; import google.registry.model.domain.DomainResource; @@ -125,7 +126,7 @@ public class EppCommitLogsTest extends ShardableTestCase { clock.advanceBy(standardDays(2)); DateTime timeAtDelete = clock.nowUtc(); // before 'add' grace period ends - eppLoader = new EppLoader(this, "domain_delete.xml"); + eppLoader = new EppLoader(this, "domain_delete.xml", ImmutableMap.of("NAME", "example.tld")); runFlow(); ofy().clearSessionCache(); diff --git a/javatests/google/registry/flows/EppLifecycleContactTest.java b/javatests/google/registry/flows/EppLifecycleContactTest.java index eb741b90a..cd63e2025 100644 --- a/javatests/google/registry/flows/EppLifecycleContactTest.java +++ b/javatests/google/registry/flows/EppLifecycleContactTest.java @@ -43,7 +43,7 @@ public class EppLifecycleContactTest extends EppTestCase { assertCommandAndResponse("login_valid.xml", "login_response.xml"); assertCommandAndResponse( "contact_create_sh8013.xml", - null, + ImmutableMap.of(), "contact_create_response_sh8013.xml", ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"), DateTime.parse("2000-06-01T00:00:00Z")); @@ -116,7 +116,7 @@ public class EppLifecycleContactTest extends EppTestCase { "poll_ack.xml", ImmutableMap.of("ID", "2-1-ROID-3-6-2000"), "poll_ack_response_empty.xml", - null, + ImmutableMap.of(), DateTime.parse("2000-06-08T22:02:00Z")); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") diff --git a/javatests/google/registry/flows/EppLifecycleDomainApplicationTest.java b/javatests/google/registry/flows/EppLifecycleDomainApplicationTest.java index 916e9df94..93984e395 100644 --- a/javatests/google/registry/flows/EppLifecycleDomainApplicationTest.java +++ b/javatests/google/registry/flows/EppLifecycleDomainApplicationTest.java @@ -87,7 +87,11 @@ public class EppLifecycleDomainApplicationTest extends EppTestCase { DateTime.parse("2014-01-01T00:00:00Z")); assertCommandAndResponse( "domain_info_testvalidate.xml", - "domain_info_response_testvalidate_doesnt_exist.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "The domain with given ID (test-validate.example) doesn't exist.", + "CODE", "2303"), DateTime.parse("2014-01-01T00:01:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); } @@ -102,11 +106,17 @@ public class EppLifecycleDomainApplicationTest extends EppTestCase { DateTime.parse("2014-01-01T00:00:00Z")); assertCommandAndResponse( "domain_info_testvalidate.xml", - "domain_info_response_testvalidate_doesnt_exist.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "The domain with given ID (test-validate.example) doesn't exist.", + "CODE", "2303"), DateTime.parse("2014-01-01T00:01:00Z")); assertCommandAndResponse( "domain_allocate_testvalidate.xml", - "domain_allocate_response_testvalidate_only_superuser.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of("MSG", "Only a superuser can allocate domains", "CODE", "2201"), START_OF_GA.plusDays(1)); setIsSuperuser(true); assertCommandAndResponse( diff --git a/javatests/google/registry/flows/EppLifecycleDomainTest.java b/javatests/google/registry/flows/EppLifecycleDomainTest.java index 70bf3d738..f0d5816cc 100644 --- a/javatests/google/registry/flows/EppLifecycleDomainTest.java +++ b/javatests/google/registry/flows/EppLifecycleDomainTest.java @@ -108,7 +108,12 @@ public class EppLifecycleDomainTest extends EppTestCase { createContactsAndHosts(); assertCommandAndResponse( "domain_create_fakesite.xml", - "domain_create_response_fakesite.xml", + ImmutableMap.of(), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "fakesite.example", + "CRDATE", "2000-06-01T00:04:00.0Z", + "EXDATE", "2002-06-01T00:04:00.0Z"), DateTime.parse("2000-06-01T00:04:00Z")); assertCommandAndResponse( "domain_info_fakesite.xml", @@ -148,13 +153,18 @@ public class EppLifecycleDomainTest extends EppTestCase { // Create domain example.tld assertCommandAndResponse( "domain_create_no_hosts_or_dsdata.xml", + ImmutableMap.of(), "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); // Delete domain example.tld after its add grace period has expired. assertCommandAndResponse( - "domain_delete.xml", - "generic_success_action_pending_response.xml", + "domain_delete.xml", ImmutableMap.of("NAME", "example.tld"), + "generic_success_action_pending_response.xml", ImmutableMap.of(), DateTime.parse("2000-07-01T00:02:00Z")); // Restore the domain. @@ -175,7 +185,12 @@ public class EppLifecycleDomainTest extends EppTestCase { DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z"); assertCommandAndResponse( "domain_create_no_hosts_or_dsdata.xml", + ImmutableMap.of(), "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), createTime); DomainResource domain = @@ -184,14 +199,17 @@ public class EppLifecycleDomainTest extends EppTestCase { // Delete domain example.tld within the add grace period. DateTime deleteTime = createTime.plusDays(1); assertCommandAndResponse( - "domain_delete.xml", - "generic_success_response.xml", + "domain_delete.xml", ImmutableMap.of("NAME", "example.tld"), + "generic_success_response.xml", ImmutableMap.of(), deleteTime); // Verify that it is immediately non-existent. assertCommandAndResponse( "domain_info.xml", - "domain_info_response_nonexistent.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "The domain with given ID (example.tld) doesn't exist.", "CODE", "2303"), deleteTime.plusSeconds(1)); // The expected one-time billing event, that should have an associated Cancellation. @@ -218,14 +236,19 @@ public class EppLifecycleDomainTest extends EppTestCase { // Create domain example.tld assertCommandAndResponse( "domain_create_no_hosts_or_dsdata.xml", + ImmutableMap.of(), "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), createTime); DateTime deleteTime = DateTime.parse("2000-07-07T00:02:00Z"); // 1 month and 6 days after // Delete domain example.tld after its add grace period has expired. assertCommandAndResponse( - "domain_delete.xml", - "generic_success_action_pending_response.xml", + "domain_delete.xml", ImmutableMap.of("NAME", "example.tld"), + "generic_success_action_pending_response.xml", ImmutableMap.of(), deleteTime); // Verify that domain shows redemptionPeriod soon after deletion. @@ -247,7 +270,10 @@ public class EppLifecycleDomainTest extends EppTestCase { // Verify that the domain is non-existent (available for registration) later. assertCommandAndResponse( "domain_info.xml", - "domain_info_response_nonexistent.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "The domain with given ID (example.tld) doesn't exist.", "CODE", "2303"), DateTime.parse("2000-09-01T00:00:00Z")); DomainResource domain = @@ -292,8 +318,8 @@ public class EppLifecycleDomainTest extends EppTestCase { // Delete domain example.tld within the add grade period. DateTime deleteTime = createTime.plusDays(1); assertCommandAndResponse( - "domain_delete.xml", - "domain_delete_response_fee.xml", + "domain_delete.xml", ImmutableMap.of("NAME", "example.tld"), + "domain_delete_response_fee.xml", ImmutableMap.of(), deleteTime); // Verify that the OneTime billing event associated with the base fee of domain registration and @@ -404,8 +430,10 @@ public class EppLifecycleDomainTest extends EppTestCase { createFakesite(); createSubordinateHost(); assertCommandAndResponse( - "domain_delete_fakesite.xml", - "domain_delete_response_prohibited.xml", + "domain_delete.xml", + ImmutableMap.of("NAME", "fakesite.example"), + "response_error.xml", + ImmutableMap.of("MSG", "Domain to be deleted has subordinate hosts", "CODE", "2305"), DateTime.parse("2002-05-30T01:01:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); } @@ -439,8 +467,8 @@ public class EppLifecycleDomainTest extends EppTestCase { .hasStatus(SUCCESS); // Delete the fakesite.example domain (which should succeed since it no longer has subords). assertCommandAndResponse( - "domain_delete_fakesite.xml", - "generic_success_action_pending_response.xml", + "domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example"), + "generic_success_action_pending_response.xml", ImmutableMap.of(), DateTime.parse("2002-05-30T01:02:00Z")); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") @@ -482,7 +510,12 @@ public class EppLifecycleDomainTest extends EppTestCase { // Create domain example.tld assertCommandAndResponse( "domain_create_no_hosts_or_dsdata.xml", - "domain_create_response_superordinate.xml", + ImmutableMap.of(), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-02T00:00:00.0Z", + "EXDATE", "2002-06-02T00:00:00.0Z"), DateTime.parse("2000-06-02T00:00:00Z")); // Create nameserver ns1.example.tld @@ -499,8 +532,10 @@ public class EppLifecycleDomainTest extends EppTestCase { // Attempt to delete the fakesite.example domain (which should fail since it now has a // subordinate host). assertCommandAndResponse( - "domain_delete_fakesite.xml", - "domain_delete_response_prohibited.xml", + "domain_delete.xml", + ImmutableMap.of("NAME", "fakesite.example"), + "response_error.xml", + ImmutableMap.of("MSG", "Domain to be deleted has subordinate hosts", "CODE", "2305"), DateTime.parse("2002-05-30T01:02:00Z")); // Check info on the renamed host and verify that it's still around and wasn't deleted. assertCommandAndResponse( @@ -534,12 +569,19 @@ public class EppLifecycleDomainTest extends EppTestCase { assertCommandAndResponse( "domain_create_sunrise_encoded_mark.xml", - "domain_create_testvalidate_invalid_phase.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "Command is not allowed in the current registry phase", "CODE", "2002"), sunriseDate.minusDays(1)); assertCommandAndResponse( "domain_info_testvalidate.xml", - "domain_info_response_testvalidate_doesnt_exist.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "The domain with given ID (test-validate.example) doesn't exist.", + "CODE", "2303"), sunriseDate.plusDays(1)); assertCommandAndResponse("logout.xml", "logout_response.xml"); @@ -598,7 +640,7 @@ public class EppLifecycleDomainTest extends EppTestCase { "poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2002"), "poll_ack_response_empty.xml", - null, + ImmutableMap.of(), DateTime.parse("2002-07-01T00:02:00Z")); // The second autorenew poll message isn't seen until after another year, and it should have a @@ -621,7 +663,7 @@ public class EppLifecycleDomainTest extends EppTestCase { "poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2003"), "poll_ack_response_empty.xml", - null, + ImmutableMap.of(), DateTime.parse("2003-07-01T00:05:05Z")); assertCommandAndResponse( "poll.xml", "poll_response_empty.xml", DateTime.parse("2003-07-01T00:05:10Z")); @@ -658,7 +700,7 @@ public class EppLifecycleDomainTest extends EppTestCase { "poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-17-23-2001"), "poll_ack_response_empty.xml", - null, + ImmutableMap.of(), DateTime.parse("2001-01-01T00:01:00Z")); // Five days in the future, expect a server approval poll message to the loser, and ack it. @@ -670,7 +712,7 @@ public class EppLifecycleDomainTest extends EppTestCase { "poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-17-22-2001"), "poll_ack_response_empty.xml", - null, + ImmutableMap.of(), DateTime.parse("2001-01-06T00:01:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); @@ -678,7 +720,7 @@ public class EppLifecycleDomainTest extends EppTestCase { assertCommandAndResponse("login2_valid.xml", "login_response.xml"); assertCommandAndResponse( "poll.xml", - null, + ImmutableMap.of(), "poll_response_domain_transfer_server_approve_winner.xml", ImmutableMap.of("SERVER_TRID", transferRequestTrid), DateTime.parse("2001-01-06T00:02:00Z")); @@ -686,7 +728,7 @@ public class EppLifecycleDomainTest extends EppTestCase { "poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-17-21-2001"), "poll_ack_response_empty.xml", - null, + ImmutableMap.of(), DateTime.parse("2001-01-06T00:02:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); } @@ -768,7 +810,7 @@ public class EppLifecycleDomainTest extends EppTestCase { // Verify that host's client ID was set to the new registrar and has the transfer date set. assertCommandAndResponse( "host_info_fakesite.xml", - null, + ImmutableMap.of(), "host_info_response_fakesite_post_transfer.xml", ImmutableMap.of("TRDATE", "2002-06-04T00:00:00Z"), DateTime.parse("2002-06-09T00:01:00Z")); @@ -798,8 +840,8 @@ public class EppLifecycleDomainTest extends EppTestCase { "domain_info_response_fakesite_pending_transfer.xml", DateTime.parse("2002-05-30T01:00:00Z")); assertCommandAndResponse( - "domain_delete_fakesite.xml", - "generic_success_action_pending_response.xml", + "domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example"), + "generic_success_action_pending_response.xml", ImmutableMap.of(), DateTime.parse("2002-05-30T01:01:00Z")); assertCommandAndResponse( "domain_info_fakesite.xml", @@ -826,7 +868,9 @@ public class EppLifecycleDomainTest extends EppTestCase { createSubordinateHost(); assertCommandAndResponse( "domain_transfer_query_fakesite.xml", - "domain_transfer_query_response_no_transfer_history.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of("MSG", "Object has no transfer history", "CODE", "2002"), DateTime.parse("2000-09-02T00:00:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); @@ -866,7 +910,9 @@ public class EppLifecycleDomainTest extends EppTestCase { createSubordinateHost(); assertCommandAndResponse( "domain_transfer_query_fakesite.xml", - "domain_transfer_query_response_no_transfer_history.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of("MSG", "Object has no transfer history", "CODE", "2002"), DateTime.parse("2000-09-02T00:00:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); // Request a transfer of the domain to the second registrar. @@ -884,7 +930,12 @@ public class EppLifecycleDomainTest extends EppTestCase { DateTime.parse("2001-01-07T00:00:00Z")); assertCommandAndResponse( "domain_create_secondsite.xml", - "domain_create_response_secondsite.xml", + ImmutableMap.of(), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "secondsite.example", + "CRDATE", "2001-01-08T00:00:00.0Z", + "EXDATE", "2003-01-08T00:00:00.0Z"), DateTime.parse("2001-01-08T00:00:00Z")); // Update the host to be subordinate to a different domain by renaming it to // ns3.secondsite.example @@ -892,7 +943,7 @@ public class EppLifecycleDomainTest extends EppTestCase { "host_update_rename_only.xml", ImmutableMap.of("oldName", "ns3.fakesite.example", "newName", "ns3.secondsite.example"), "generic_success_response.xml", - null, + ImmutableMap.of(), DateTime.parse("2002-05-30T01:01:00Z")); // The last transfer time on the host should still be what it was from the transfer. assertCommandAndResponse( @@ -919,7 +970,9 @@ public class EppLifecycleDomainTest extends EppTestCase { createSubordinateHost(); assertCommandAndResponse( "domain_transfer_query_fakesite.xml", - "domain_transfer_query_response_no_transfer_history.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of("MSG", "Object has no transfer history", "CODE", "2002"), DateTime.parse("2000-09-02T00:00:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); // Request a transfer of the domain to the second registrar. @@ -931,7 +984,7 @@ public class EppLifecycleDomainTest extends EppTestCase { // Verify that the lastTransferTime now reflects the superordinate domain's transfer. assertCommandAndResponse( "host_info_fakesite.xml", - null, + ImmutableMap.of(), "host_info_response_fakesite_post_transfer.xml", ImmutableMap.of("TRDATE", "2001-01-06T00:00:00.000Z"), DateTime.parse("2001-01-07T00:00:00Z")); @@ -942,7 +995,7 @@ public class EppLifecycleDomainTest extends EppTestCase { "oldName", "ns3.fakesite.example", "newName", "ns3.notarealsite.external"), "generic_success_response.xml", - null, + ImmutableMap.of(), DateTime.parse("2002-05-30T01:01:00Z")); // The last transfer time on the host should still be what it was from the transfer. assertCommandAndResponse( @@ -967,24 +1020,33 @@ public class EppLifecycleDomainTest extends EppTestCase { assertCommandAndResponse( "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.bar.foo.tld"), - "domain_create_response_wildcard.xml", - ImmutableMap.of("DOMAIN", "example.bar.foo.tld"), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.bar.foo.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); // Create domain example.foo.tld assertCommandAndResponse( "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.foo.tld"), - "domain_create_response_wildcard.xml", - ImmutableMap.of("DOMAIN", "example.foo.tld"), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.foo.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); // Create domain example.tld assertCommandAndResponse( "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.tld"), - "domain_create_response_wildcard.xml", - ImmutableMap.of("DOMAIN", "example.tld"), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); @@ -1001,16 +1063,22 @@ public class EppLifecycleDomainTest extends EppTestCase { assertCommandAndResponse( "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.tld.foo"), - "domain_create_response_wildcard.xml", - ImmutableMap.of("DOMAIN", "example.tld.foo"), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld.foo", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); // Create domain example.tld assertCommandAndResponse( "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.tld"), - "domain_create_response_wildcard.xml", - ImmutableMap.of("DOMAIN", "example.tld"), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); assertCommandAndResponse("logout.xml", "logout_response.xml"); diff --git a/javatests/google/registry/flows/EppLifecycleHostTest.java b/javatests/google/registry/flows/EppLifecycleHostTest.java index 0331268d9..9a296569e 100644 --- a/javatests/google/registry/flows/EppLifecycleHostTest.java +++ b/javatests/google/registry/flows/EppLifecycleHostTest.java @@ -123,7 +123,12 @@ public class EppLifecycleHostTest extends EppTestCase { DateTime.parse("2000-06-01T00:01:00Z")); assertCommandAndResponse( "domain_create_fakesite_no_nameservers.xml", - "domain_create_response_fakesite.xml", + ImmutableMap.of(), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "fakesite.example", + "CRDATE", "2000-06-01T00:04:00.0Z", + "EXDATE", "2002-06-01T00:04:00.0Z"), DateTime.parse("2000-06-01T00:04:00Z")); assertCommandAndResponse( "domain_info_fakesite.xml", @@ -142,7 +147,10 @@ public class EppLifecycleHostTest extends EppTestCase { // Attempt overwriting of 2nd fakesite subordinate host with the 1st. assertCommandAndResponse( "host_update_fakesite1_to_fakesite2.xml", - "host_update_failed_response.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "Object with given ID (ns4.fakesite.example) already exists", "CODE", "2302"), DateTime.parse("2000-06-10T00:01:00Z")); // Verify that fakesite hosts still exist in their unmodified states. assertCommandAndResponse( @@ -177,24 +185,33 @@ public class EppLifecycleHostTest extends EppTestCase { assertCommandAndResponse( "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.bar.foo.tld"), - "domain_create_response_wildcard.xml", - ImmutableMap.of("DOMAIN", "example.bar.foo.tld"), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.bar.foo.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); // Create domain example.foo.tld assertCommandAndResponse( "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.foo.tld"), - "domain_create_response_wildcard.xml", - ImmutableMap.of("DOMAIN", "example.foo.tld"), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.foo.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); // Create domain example.tld assertCommandAndResponse( "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.tld"), - "domain_create_response_wildcard.xml", - ImmutableMap.of("DOMAIN", "example.tld"), + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z"), DateTime.parse("2000-06-01T00:02:00Z")); // Create host ns1.example.bar.foo.tld diff --git a/javatests/google/registry/flows/EppLoggedOutTest.java b/javatests/google/registry/flows/EppLoggedOutTest.java index a1f5824b0..ca63d65bd 100644 --- a/javatests/google/registry/flows/EppLoggedOutTest.java +++ b/javatests/google/registry/flows/EppLoggedOutTest.java @@ -47,6 +47,15 @@ public class EppLoggedOutTest extends EppTestCase { @Test public void testSyntaxError() throws Exception { - assertCommandAndResponse("syntax_error.xml", "syntax_error_response.xml"); + assertCommandAndResponse( + "syntax_error.xml", + ImmutableMap.of(), + "response_error_no_cltrid.xml", + ImmutableMap.of( + "MSG", + "Syntax error at line 4, column 65: cvc-complex-type.3.2.2: " + + "Attribute 'xsi:schemaLocation' is not allowed to appear in element 'epp'.", + "CODE", + "2001")); } } diff --git a/javatests/google/registry/flows/EppLoginTlsTest.java b/javatests/google/registry/flows/EppLoginTlsTest.java index 149b543da..5060a44bf 100644 --- a/javatests/google/registry/flows/EppLoginTlsTest.java +++ b/javatests/google/registry/flows/EppLoginTlsTest.java @@ -18,6 +18,7 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static org.joda.time.DateTimeZone.UTC; +import com.google.common.collect.ImmutableMap; import google.registry.testing.AppEngineRule; import google.registry.testing.CertificateSamples; import java.util.Optional; @@ -70,7 +71,10 @@ public class EppLoginTlsTest extends EppTestCase { setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH); // For TLS login, we also check the epp xml password. assertCommandAndResponse( - "login_invalid_wrong_password.xml", "login_response_wrong_password.xml"); + "login_invalid_wrong_password.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of("MSG", "Registrar password is incorrect", "CODE", "2200")); } @Test @@ -80,26 +84,45 @@ public class EppLoginTlsTest extends EppTestCase { assertCommandAndResponse("logout.xml", "logout_response.xml"); assertCommandAndResponse("login_valid.xml", "login_response.xml"); assertCommandAndResponse("logout.xml", "logout_response.xml"); - assertCommandAndResponse("login2_valid.xml", "login_response_bad_certificate.xml"); + assertCommandAndResponse( + "login2_valid.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "Registrar certificate does not match stored certificate", "CODE", "2200")); } @Test public void testNonAuthedLogin_fails() throws Exception { setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH); - assertCommandAndResponse("login2_valid.xml", "login_response_bad_certificate.xml"); + assertCommandAndResponse( + "login2_valid.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "Registrar certificate does not match stored certificate", "CODE", "2200")); } @Test public void testBadCertificate_failsBadCertificate2200() throws Exception { setClientCertificateHash("laffo"); - assertCommandAndResponse("login_valid.xml", "login_response_bad_certificate.xml"); + assertCommandAndResponse( + "login_valid.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "Registrar certificate does not match stored certificate", "CODE", "2200")); } @Test public void testGfeDidntProvideClientCertificate_failsMissingCertificate2200() throws Exception { setClientCertificateHash(""); - assertCommandAndResponse("login_valid.xml", "login_response_missing_certificate.xml"); + assertCommandAndResponse( + "login_valid.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of("MSG", "Registrar certificate not present", "CODE", "2200")); } @Test diff --git a/javatests/google/registry/flows/EppLoginUserTest.java b/javatests/google/registry/flows/EppLoginUserTest.java index eec9627ee..4af73294b 100644 --- a/javatests/google/registry/flows/EppLoginUserTest.java +++ b/javatests/google/registry/flows/EppLoginUserTest.java @@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import com.google.appengine.api.users.User; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import google.registry.model.registrar.RegistrarContact; import google.registry.testing.AppEngineRule; @@ -60,7 +61,13 @@ public class EppLoginUserTest extends EppTestCase { @Test public void testNonAuthedLogin_fails() throws Exception { - assertCommandAndResponse("login2_valid.xml", "login_response_unauthorized_role.xml"); + assertCommandAndResponse( + "login2_valid.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "User id is not allowed to login as requested registrar: person@example.com", + "CODE", "2200")); } @Test @@ -69,7 +76,13 @@ public class EppLoginUserTest extends EppTestCase { assertCommandAndResponse("logout.xml", "logout_response.xml"); assertCommandAndResponse("login_valid.xml", "login_response.xml"); assertCommandAndResponse("logout.xml", "logout_response.xml"); - assertCommandAndResponse("login2_valid.xml", "login_response_unauthorized_role.xml"); + assertCommandAndResponse( + "login2_valid.xml", + ImmutableMap.of(), + "response_error.xml", + ImmutableMap.of( + "MSG", "User id is not allowed to login as requested registrar: person@example.com", + "CODE", "2200")); } @Test diff --git a/javatests/google/registry/flows/EppTestCase.java b/javatests/google/registry/flows/EppTestCase.java index ecd9bdb99..9429dd4a9 100644 --- a/javatests/google/registry/flows/EppTestCase.java +++ b/javatests/google/registry/flows/EppTestCase.java @@ -73,7 +73,7 @@ public class EppTestCase extends ShardableTestCase { } String assertCommandAndResponse(String inputFilename, String outputFilename) throws Exception { - return assertCommandAndResponse(inputFilename, outputFilename, DateTime.now(UTC)); + return assertCommandAndResponse(inputFilename, null, outputFilename, null); } String assertCommandAndResponse(String inputFilename, String outputFilename, DateTime now) @@ -81,23 +81,36 @@ public class EppTestCase extends ShardableTestCase { return assertCommandAndResponse(inputFilename, null, outputFilename, null, now); } + String assertCommandAndResponse( + String inputFilename, + Map inputSubstitutions, + String outputFilename, + Map outputSubstitutions) + throws Exception { + return assertCommandAndResponse( + inputFilename, inputSubstitutions, outputFilename, outputSubstitutions, DateTime.now(UTC)); + } + String assertCommandAndResponse( String inputFilename, Map inputSubstitutions, String outputFilename, Map outputSubstitutions, - DateTime now) throws Exception { + DateTime now) + throws Exception { clock.setTo(now); String input = loadFile(getClass(), inputFilename, inputSubstitutions); String expectedOutput = loadFile(getClass(), outputFilename, outputSubstitutions); if (sessionMetadata == null) { - sessionMetadata = new HttpSessionMetadata(new FakeHttpSession()) { - @Override - public void invalidate() { - // When a session is invalidated, reset the sessionMetadata field. - super.invalidate(); - EppTestCase.this.sessionMetadata = null; - }}; + sessionMetadata = + new HttpSessionMetadata(new FakeHttpSession()) { + @Override + public void invalidate() { + // When a session is invalidated, reset the sessionMetadata field. + super.invalidate(); + EppTestCase.this.sessionMetadata = null; + } + }; } String actualOutput = executeXmlCommand(input); assertXmlEqualsWithMessage( @@ -106,7 +119,7 @@ public class EppTestCase extends ShardableTestCase { "Running " + inputFilename + " => " + outputFilename, "epp.response.resData.infData.roid", "epp.response.trID.svTRID"); - ofy().clearSessionCache(); // Clear the cache like OfyFilter would. + ofy().clearSessionCache(); // Clear the cache like OfyFilter would. return actualOutput; } diff --git a/javatests/google/registry/flows/EppXxeAttackTest.java b/javatests/google/registry/flows/EppXxeAttackTest.java index 968edad53..f46c5ca5b 100644 --- a/javatests/google/registry/flows/EppXxeAttackTest.java +++ b/javatests/google/registry/flows/EppXxeAttackTest.java @@ -14,6 +14,7 @@ package google.registry.flows; +import com.google.common.collect.ImmutableMap; import google.registry.testing.AppEngineRule; import org.junit.Rule; import org.junit.Test; @@ -37,7 +38,14 @@ public class EppXxeAttackTest extends EppTestCase { assertCommandAndResponse("login_valid.xml", "login_response.xml"); assertCommandAndResponse( "contact_create_remote_xxe.xml", - "contact_create_remote_response_xxe.xml"); + ImmutableMap.of(), + "response_error_no_cltrid.xml", + ImmutableMap.of( + "MSG", + "Syntax error at line 11, column 34: " + + "The entity "remote" was referenced, but not declared.", + "CODE", + "2001")); assertCommandAndResponse("logout.xml", "logout_response.xml"); } @@ -46,7 +54,14 @@ public class EppXxeAttackTest extends EppTestCase { assertCommandAndResponse("login_valid.xml", "login_response.xml"); assertCommandAndResponse( "contact_create_local_xxe.xml", - "contact_create_local_response_xxe.xml"); + ImmutableMap.of(), + "response_error_no_cltrid.xml", + ImmutableMap.of( + "MSG", + "Syntax error at line 11, column 31: " + + "The entity "ent" was referenced, but not declared.", + "CODE", + "2001")); assertCommandAndResponse("logout.xml", "logout_response.xml"); } @@ -55,7 +70,14 @@ public class EppXxeAttackTest extends EppTestCase { assertCommandAndResponse("login_valid.xml", "login_response.xml"); assertCommandAndResponse( "contact_create_billion_laughs.xml", - "contact_create_response_billion_laughs.xml"); + ImmutableMap.of(), + "response_error_no_cltrid.xml", + ImmutableMap.of( + "MSG", + "Syntax error at line 20, column 32: " + + "The entity "lol9" was referenced, but not declared.", + "CODE", + "2001")); assertCommandAndResponse("logout.xml", "logout_response.xml"); } } diff --git a/javatests/google/registry/flows/testdata/contact_create_local_response_xxe.xml b/javatests/google/registry/flows/testdata/contact_create_local_response_xxe.xml deleted file mode 100644 index ba72a4edd..000000000 --- a/javatests/google/registry/flows/testdata/contact_create_local_response_xxe.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Syntax error at line 11, column 31: The entity "ent" was referenced, but not declared. - - - DkRx3F6iQAmx4nS1xOgYZw==-8 - - - diff --git a/javatests/google/registry/flows/testdata/contact_create_remote_response_xxe.xml b/javatests/google/registry/flows/testdata/contact_create_remote_response_xxe.xml deleted file mode 100644 index b34bd8054..000000000 --- a/javatests/google/registry/flows/testdata/contact_create_remote_response_xxe.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Syntax error at line 11, column 34: The entity "remote" was referenced, but not declared. - - - DkRx3F6iQAmx4nS1xOgYZw==-8 - - - diff --git a/javatests/google/registry/flows/testdata/contact_create_response_billion_laughs.xml b/javatests/google/registry/flows/testdata/contact_create_response_billion_laughs.xml deleted file mode 100644 index 71d912228..000000000 --- a/javatests/google/registry/flows/testdata/contact_create_response_billion_laughs.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Syntax error at line 20, column 32: The entity "lol9" was referenced, but not declared. - - - HmioO3vzQN+XVIUfZJxHeQ==-11 - - - diff --git a/javatests/google/registry/flows/testdata/domain_allocate_response_testvalidate_only_superuser.xml b/javatests/google/registry/flows/testdata/domain_allocate_response_testvalidate_only_superuser.xml deleted file mode 100644 index f120dde8e..000000000 --- a/javatests/google/registry/flows/testdata/domain_allocate_response_testvalidate_only_superuser.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Only a superuser can allocate domains - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/domain_create_response.xml b/javatests/google/registry/flows/testdata/domain_create_response.xml index 6df6fd6ab..2cdff5be6 100644 --- a/javatests/google/registry/flows/testdata/domain_create_response.xml +++ b/javatests/google/registry/flows/testdata/domain_create_response.xml @@ -6,9 +6,9 @@ - example.tld - 2000-06-01T00:02:00.0Z - 2002-06-01T00:02:00.0Z + %NAME% + %CRDATE% + %EXDATE% diff --git a/javatests/google/registry/flows/testdata/domain_create_response_fakesite.xml b/javatests/google/registry/flows/testdata/domain_create_response_fakesite.xml deleted file mode 100644 index 6355534dd..000000000 --- a/javatests/google/registry/flows/testdata/domain_create_response_fakesite.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - Command completed successfully - - - - fakesite.example - 2000-06-01T00:04:00.0Z - 2002-06-01T00:04:00.0Z - - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/domain_create_response_secondsite.xml b/javatests/google/registry/flows/testdata/domain_create_response_secondsite.xml deleted file mode 100644 index 990a350e5..000000000 --- a/javatests/google/registry/flows/testdata/domain_create_response_secondsite.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - Command completed successfully - - - - secondsite.example - 2001-01-08T00:00:00.0Z - 2003-01-08T00:00:00.0Z - - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/domain_create_response_superordinate.xml b/javatests/google/registry/flows/testdata/domain_create_response_superordinate.xml deleted file mode 100644 index eac14377e..000000000 --- a/javatests/google/registry/flows/testdata/domain_create_response_superordinate.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - Command completed successfully - - - - example.tld - 2000-06-02T00:00:00.0Z - 2002-06-02T00:00:00.0Z - - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/domain_create_response_wildcard.xml b/javatests/google/registry/flows/testdata/domain_create_response_wildcard.xml deleted file mode 100644 index 2d2a73911..000000000 --- a/javatests/google/registry/flows/testdata/domain_create_response_wildcard.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - Command completed successfully - - - - %DOMAIN% - 2000-06-01T00:02:00.0Z - 2002-06-01T00:02:00.0Z - - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/domain_create_testvalidate_invalid_phase.xml b/javatests/google/registry/flows/testdata/domain_create_testvalidate_invalid_phase.xml deleted file mode 100644 index a1f66d400..000000000 --- a/javatests/google/registry/flows/testdata/domain_create_testvalidate_invalid_phase.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Command is not allowed in the current registry phase - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/domain_delete.xml b/javatests/google/registry/flows/testdata/domain_delete.xml index a0f5cc345..8aff149ea 100644 --- a/javatests/google/registry/flows/testdata/domain_delete.xml +++ b/javatests/google/registry/flows/testdata/domain_delete.xml @@ -1,9 +1,8 @@ - - example.tld + + %NAME% ABC-12345 diff --git a/javatests/google/registry/flows/testdata/domain_delete_fakesite.xml b/javatests/google/registry/flows/testdata/domain_delete_fakesite.xml deleted file mode 100644 index 5aac41ae1..000000000 --- a/javatests/google/registry/flows/testdata/domain_delete_fakesite.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - fakesite.example - - - ABC-12345 - - diff --git a/javatests/google/registry/flows/testdata/domain_delete_response_prohibited.xml b/javatests/google/registry/flows/testdata/domain_delete_response_prohibited.xml deleted file mode 100644 index dcfe751db..000000000 --- a/javatests/google/registry/flows/testdata/domain_delete_response_prohibited.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Domain to be deleted has subordinate hosts - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/domain_info_response_nonexistent.xml b/javatests/google/registry/flows/testdata/domain_info_response_nonexistent.xml deleted file mode 100644 index e2672146e..000000000 --- a/javatests/google/registry/flows/testdata/domain_info_response_nonexistent.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - The domain with given ID (example.tld) doesn't exist. - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/domain_info_response_testvalidate_doesnt_exist.xml b/javatests/google/registry/flows/testdata/domain_info_response_testvalidate_doesnt_exist.xml deleted file mode 100644 index aa62acb59..000000000 --- a/javatests/google/registry/flows/testdata/domain_info_response_testvalidate_doesnt_exist.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - The domain with given ID (test-validate.example) doesn't exist. - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/host_update_failed_response.xml b/javatests/google/registry/flows/testdata/host_update_failed_response.xml deleted file mode 100644 index ecd601ec2..000000000 --- a/javatests/google/registry/flows/testdata/host_update_failed_response.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Object with given ID (ns4.fakesite.example) already exists - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/login_response_bad_certificate.xml b/javatests/google/registry/flows/testdata/login_response_bad_certificate.xml deleted file mode 100644 index 4061ea25c..000000000 --- a/javatests/google/registry/flows/testdata/login_response_bad_certificate.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Registrar certificate does not match stored certificate - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/login_response_missing_certificate.xml b/javatests/google/registry/flows/testdata/login_response_missing_certificate.xml deleted file mode 100644 index fa3f2301a..000000000 --- a/javatests/google/registry/flows/testdata/login_response_missing_certificate.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Registrar certificate not present - - - ABC-12345 - server-trid - - - diff --git a/javatests/google/registry/flows/testdata/login_response_unauthorized_role.xml b/javatests/google/registry/flows/testdata/login_response_unauthorized_role.xml deleted file mode 100644 index 49c7dfefb..000000000 --- a/javatests/google/registry/flows/testdata/login_response_unauthorized_role.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - User id is not allowed to login as requested registrar: person@example.com - - - ABC-12345 - Mt2PuhrJTKO1nM/MbHxT4g==-2a - - - diff --git a/javatests/google/registry/flows/testdata/domain_transfer_query_response_no_transfer_history.xml b/javatests/google/registry/flows/testdata/response_error.xml similarity index 71% rename from javatests/google/registry/flows/testdata/domain_transfer_query_response_no_transfer_history.xml rename to javatests/google/registry/flows/testdata/response_error.xml index c159d4d88..981604876 100644 --- a/javatests/google/registry/flows/testdata/domain_transfer_query_response_no_transfer_history.xml +++ b/javatests/google/registry/flows/testdata/response_error.xml @@ -1,7 +1,7 @@ - - Object has no transfer history + + %MSG% ABC-12345 diff --git a/javatests/google/registry/flows/testdata/login_response_wrong_password.xml b/javatests/google/registry/flows/testdata/response_error_no_cltrid.xml similarity index 58% rename from javatests/google/registry/flows/testdata/login_response_wrong_password.xml rename to javatests/google/registry/flows/testdata/response_error_no_cltrid.xml index d71584c3c..6942389cd 100644 --- a/javatests/google/registry/flows/testdata/login_response_wrong_password.xml +++ b/javatests/google/registry/flows/testdata/response_error_no_cltrid.xml @@ -1,10 +1,9 @@ - - Registrar password is incorrect + + %MSG% - ABC-12345 server-trid diff --git a/javatests/google/registry/flows/testdata/syntax_error_response.xml b/javatests/google/registry/flows/testdata/syntax_error_response.xml deleted file mode 100644 index 5ce68e6b0..000000000 --- a/javatests/google/registry/flows/testdata/syntax_error_response.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Syntax error at line 4, column 65: cvc-complex-type.3.2.2: Attribute 'xsi:schemaLocation' is not allowed to appear in element 'epp'. - - - ABC-12345 - - -