diff --git a/javatests/google/registry/flows/EppLifecycleContactTest.java b/javatests/google/registry/flows/EppLifecycleContactTest.java index cd63e2025..aa6f91c73 100644 --- a/javatests/google/registry/flows/EppLifecycleContactTest.java +++ b/javatests/google/registry/flows/EppLifecycleContactTest.java @@ -22,7 +22,6 @@ import static google.registry.testing.EppMetricSubject.assertThat; import com.google.common.collect.ImmutableMap; import google.registry.testing.AppEngineRule; -import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -40,13 +39,12 @@ public class EppLifecycleContactTest extends EppTestCase { @Test public void testContactLifecycle() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "contact_create_sh8013.xml", - ImmutableMap.of(), - "contact_create_response_sh8013.xml", - ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"), - DateTime.parse("2000-06-01T00:00:00Z")); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("contact_create_sh8013.xml") + .atTime("2000-06-01T00:00:00Z") + .hasResponse( + "contact_create_response_sh8013.xml", + ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z")); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -57,10 +55,9 @@ public class EppLifecycleContactTest extends EppTestCase { .hasEppTarget("sh8013") .and() .hasStatus(SUCCESS); - assertCommandAndResponse( - "contact_info.xml", - "contact_info_from_create_response.xml", - DateTime.parse("2000-06-01T00:01:00Z")); + assertThatCommand("contact_info.xml") + .atTime("2000-06-01T00:01:00Z") + .hasResponse("contact_info_from_create_response.xml"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -69,7 +66,8 @@ public class EppLifecycleContactTest extends EppTestCase { .hasEppTarget("sh8013") .and() .hasStatus(SUCCESS); - assertCommandAndResponse("contact_delete_sh8013.xml", "contact_delete_response_sh8013.xml"); + assertThatCommand("contact_delete_sh8013.xml") + .hasResponse("contact_delete_response_sh8013.xml"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -78,52 +76,46 @@ public class EppLifecycleContactTest extends EppTestCase { .hasEppTarget("sh8013") .and() .hasStatus(SUCCESS_WITH_ACTION_PENDING); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test public void testContactTransferPollMessage() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "contact_create_sh8013.xml", - ImmutableMap.of(), - "contact_create_response_sh8013.xml", - ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"), - DateTime.parse("2000-06-01T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("contact_create_sh8013.xml") + .atTime("2000-06-01T00:00:00Z") + .hasResponse( + "contact_create_response_sh8013.xml", + ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z")); + assertThatLogoutSucceeds(); // Initiate a transfer of the newly created contact. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "contact_transfer_request.xml", - "contact_transfer_request_response_alternate.xml", - DateTime.parse("2000-06-08T22:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); + assertThatCommand("contact_transfer_request.xml") + .atTime("2000-06-08T22:00:00Z") + .hasResponse("contact_transfer_request_response_alternate.xml"); + assertThatLogoutSucceeds(); // Log back in with the losing registrar, read the poll message, and then ack it. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "poll.xml", - "poll_response_contact_transfer.xml", - DateTime.parse("2000-06-08T22:01:00Z")); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("poll.xml") + .atTime("2000-06-08T22:01:00Z") + .hasResponse("poll_response_contact_transfer.xml"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() .hasCommandName("PollRequest") .and() .hasStatus(SUCCESS_WITH_ACK_MESSAGE); - assertCommandAndResponse( - "poll_ack.xml", - ImmutableMap.of("ID", "2-1-ROID-3-6-2000"), - "poll_ack_response_empty.xml", - ImmutableMap.of(), - DateTime.parse("2000-06-08T22:02:00Z")); + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "2-1-ROID-3-6-2000")) + .atTime("2000-06-08T22:02:00Z") + .hasResponse("poll_ack_response_empty.xml"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() .hasCommandName("PollAck") .and() .hasStatus(SUCCESS_WITH_NO_MESSAGES); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } } diff --git a/javatests/google/registry/flows/EppLifecycleDomainApplicationTest.java b/javatests/google/registry/flows/EppLifecycleDomainApplicationTest.java index 93984e395..b9e043ab9 100644 --- a/javatests/google/registry/flows/EppLifecycleDomainApplicationTest.java +++ b/javatests/google/registry/flows/EppLifecycleDomainApplicationTest.java @@ -50,83 +50,72 @@ public class EppLifecycleDomainApplicationTest extends EppTestCase { /** Create the two administrative contacts and two hosts. */ void createContactsAndHosts() throws Exception { DateTime startTime = DateTime.parse("2000-06-01T00:00:00Z"); - assertCommandAndResponse( - "contact_create_sh8013.xml", - ImmutableMap.of(), - "contact_create_response_sh8013.xml", - ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"), - startTime); - assertCommandAndResponse( - "contact_create_jd1234.xml", - "contact_create_response_jd1234.xml", - startTime.plusMinutes(1)); - assertCommandAndResponse( - "host_create.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.external"), - "host_create_response.xml", - ImmutableMap.of( - "HOSTNAME", "ns1.example.external", "CRDATE", startTime.plusMinutes(2).toString()), - startTime.plusMinutes(2)); - assertCommandAndResponse( - "host_create.xml", - ImmutableMap.of("HOSTNAME", "ns2.example.external"), - "host_create_response.xml", - ImmutableMap.of( - "HOSTNAME", "ns2.example.external", "CRDATE", startTime.plusMinutes(3).toString()), - startTime.plusMinutes(3)); + assertThatCommand("contact_create_sh8013.xml") + .atTime(startTime) + .hasResponse( + "contact_create_response_sh8013.xml", + ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z")); + assertThatCommand("contact_create_jd1234.xml") + .atTime(startTime.plusMinutes(1)) + .hasResponse("contact_create_response_jd1234.xml"); + assertThatCommand("host_create.xml", ImmutableMap.of("HOSTNAME", "ns1.example.external")) + .atTime(startTime.plusMinutes(2)) + .hasResponse( + "host_create_response.xml", + ImmutableMap.of( + "HOSTNAME", "ns1.example.external", "CRDATE", startTime.plusMinutes(2).toString())); + assertThatCommand("host_create.xml", ImmutableMap.of("HOSTNAME", "ns2.example.external")) + .atTime(startTime.plusMinutes(3)) + .hasResponse( + "host_create_response.xml", + ImmutableMap.of( + "HOSTNAME", "ns2.example.external", "CRDATE", startTime.plusMinutes(3).toString())); } @Test public void testApplicationDuringSunrise_doesntCreateDomainWithoutAllocation() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createContactsAndHosts(); // Note that the trademark is valid from 2013-08-09 to 2017-07-23, hence the creation in 2014. - assertCommandAndResponse( - "domain_create_sunrise_encoded_mark.xml", - "domain_create_sunrise_encoded_signed_mark_response.xml", - DateTime.parse("2014-01-01T00:00:00Z")); - assertCommandAndResponse( - "domain_info_testvalidate.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"); + assertThatCommand("domain_create_sunrise_encoded_mark.xml") + .atTime("2014-01-01T00:00:00Z") + .hasResponse("domain_create_sunrise_encoded_signed_mark_response.xml"); + assertThatCommand("domain_info_testvalidate.xml") + .atTime("2014-01-01T00:01:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2303", + "MSG", "The domain with given ID (test-validate.example) doesn't exist.")); + assertThatLogoutSucceeds(); } @Test public void testDomainAllocation_succeedsOnlyAsSuperuser() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createContactsAndHosts(); - assertCommandAndResponse( - "domain_create_sunrise_encoded_mark.xml", - "domain_create_sunrise_encoded_signed_mark_response.xml", - DateTime.parse("2014-01-01T00:00:00Z")); - assertCommandAndResponse( - "domain_info_testvalidate.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", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of("MSG", "Only a superuser can allocate domains", "CODE", "2201"), - START_OF_GA.plusDays(1)); + assertThatCommand("domain_create_sunrise_encoded_mark.xml") + .atTime("2014-01-01T00:00:00Z") + .hasResponse("domain_create_sunrise_encoded_signed_mark_response.xml"); + assertThatCommand("domain_info_testvalidate.xml") + .atTime("2014-01-01T00:01:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2303", + "MSG", "The domain with given ID (test-validate.example) doesn't exist.")); + assertThatCommand("domain_allocate_testvalidate.xml") + .atTime(START_OF_GA.plusDays(1)) + .hasResponse( + "response_error.xml", + ImmutableMap.of("CODE", "2201", "MSG", "Only a superuser can allocate domains")); setIsSuperuser(true); - assertCommandAndResponse( - "domain_allocate_testvalidate.xml", - "domain_allocate_response_testvalidate.xml", - START_OF_GA.plusDays(1).plusMinutes(1)); + assertThatCommand("domain_allocate_testvalidate.xml") + .atTime(START_OF_GA.plusDays(1).plusMinutes(1)) + .hasResponse("domain_allocate_response_testvalidate.xml"); setIsSuperuser(false); - assertCommandAndResponse( - "domain_info_testvalidate.xml", - "domain_info_response_testvalidate_ok.xml", - START_OF_GA.plusDays(1).plusMinutes(2)); + assertThatCommand("domain_info_testvalidate.xml") + .atTime(START_OF_GA.plusDays(1).plusMinutes(2)) + .hasResponse("domain_info_response_testvalidate_ok.xml"); } } diff --git a/javatests/google/registry/flows/EppLifecycleDomainTest.java b/javatests/google/registry/flows/EppLifecycleDomainTest.java index 531468372..2da45646e 100644 --- a/javatests/google/registry/flows/EppLifecycleDomainTest.java +++ b/javatests/google/registry/flows/EppLifecycleDomainTest.java @@ -72,145 +72,130 @@ public class EppLifecycleDomainTest extends EppTestCase { void createContactsAndHosts() throws Exception { DateTime createTime = DateTime.parse("2000-06-01T00:00:00Z"); createContacts(createTime); - assertCommandAndResponse( - "host_create.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.external"), - "host_create_response.xml", - ImmutableMap.of( - "HOSTNAME", "ns1.example.external", "CRDATE", createTime.plusMinutes(2).toString()), - createTime.plusMinutes(2)); - assertCommandAndResponse( - "host_create.xml", - ImmutableMap.of("HOSTNAME", "ns2.example.external"), - "host_create_response.xml", - ImmutableMap.of( - "HOSTNAME", "ns2.example.external", "CRDATE", createTime.plusMinutes(3).toString()), - createTime.plusMinutes(3)); + assertThatCommand("host_create.xml", ImmutableMap.of("HOSTNAME", "ns1.example.external")) + .atTime(createTime.plusMinutes(2)) + .hasResponse( + "host_create_response.xml", + ImmutableMap.of( + "HOSTNAME", "ns1.example.external", + "CRDATE", createTime.plusMinutes(2).toString())); + assertThatCommand("host_create.xml", ImmutableMap.of("HOSTNAME", "ns2.example.external")) + .atTime(createTime.plusMinutes(3)) + .hasResponse( + "host_create_response.xml", + ImmutableMap.of( + "HOSTNAME", "ns2.example.external", + "CRDATE", createTime.plusMinutes(3).toString())); } private void createContacts(DateTime createTime) throws Exception { - assertCommandAndResponse( - "contact_create_sh8013.xml", - ImmutableMap.of(), - "contact_create_response_sh8013.xml", - ImmutableMap.of("CRDATE", createTime.toString()), - createTime); - assertCommandAndResponse( - "contact_create_jd1234.xml", - ImmutableMap.of(), - "contact_create_response_jd1234.xml", - ImmutableMap.of("CRDATE", createTime.plusMinutes(1).toString()), - createTime.plusMinutes(1)); + assertThatCommand("contact_create_sh8013.xml") + .atTime(createTime) + .hasResponse( + "contact_create_response_sh8013.xml", ImmutableMap.of("CRDATE", createTime.toString())); + assertThatCommand("contact_create_jd1234.xml") + .atTime(createTime.plusMinutes(1)) + .hasResponse( + "contact_create_response_jd1234.xml", + ImmutableMap.of("CRDATE", createTime.plusMinutes(1).toString())); } /** Creates the domain fakesite.example with two nameservers on it. */ void createFakesite() throws Exception { createContactsAndHosts(); - assertCommandAndResponse( - "domain_create_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", - "domain_info_response_fakesite_ok.xml", - DateTime.parse("2000-06-06T00:00:00Z")); + assertThatCommand("domain_create_fakesite.xml") + .atTime("2000-06-01T00:04:00Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "fakesite.example", + "CRDATE", "2000-06-01T00:04:00.0Z", + "EXDATE", "2002-06-01T00:04:00.0Z")); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2000-06-06T00:00:00Z") + .hasResponse("domain_info_response_fakesite_ok.xml"); } /** Creates ns3.fakesite.example as a host, then adds it to fakesite. */ void createSubordinateHost() throws Exception { // Add the fakesite nameserver (requires that domain is already created). - assertCommandAndResponse( - "host_create_fakesite.xml", - "host_create_response_fakesite.xml", - DateTime.parse("2000-06-06T00:01:00Z")); + assertThatCommand("host_create_fakesite.xml") + .atTime("2000-06-06T00:01:00Z") + .hasResponse("host_create_response_fakesite.xml"); // Add new nameserver to domain. - assertCommandAndResponse( - "domain_update_add_nameserver_fakesite.xml", - "domain_update_add_nameserver_response_fakesite.xml", - DateTime.parse("2000-06-08T00:00:00Z")); + assertThatCommand("domain_update_add_nameserver_fakesite.xml") + .atTime("2000-06-08T00:00:00Z") + .hasResponse("domain_update_add_nameserver_response_fakesite.xml"); // Verify new nameserver was added. - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_3_nameservers.xml", - DateTime.parse("2000-06-08T00:01:00Z")); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2000-06-08T00:01:00Z") + .hasResponse("domain_info_response_fakesite_3_nameservers.xml"); // Verify that nameserver's data was set correctly. - assertCommandAndResponse( - "host_info_fakesite.xml", - "host_info_response_fakesite_linked.xml", - DateTime.parse("2000-06-08T00:02:00Z")); + assertThatCommand("host_info_fakesite.xml") + .atTime("2000-06-08T00:02:00Z") + .hasResponse("host_info_response_fakesite_linked.xml"); } @Test public void testDomainDeleteRestore() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createContacts(DateTime.parse("2000-06-01T00:00:00Z")); // 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")); + assertThatCommand("domain_create_no_hosts_or_dsdata.xml") + .atTime("2000-06-01T00:02:00Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z")); // Delete domain example.tld after its add grace period has expired. - assertCommandAndResponse( - "domain_delete.xml", ImmutableMap.of("NAME", "example.tld"), - "generic_success_action_pending_response.xml", ImmutableMap.of(), - DateTime.parse("2000-07-01T00:02:00Z")); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "example.tld")) + .atTime("2000-07-01T00:02:00Z") + .hasResponse("generic_success_action_pending_response.xml"); // Restore the domain. - assertCommandAndResponse( - "domain_update_restore_request.xml", - "domain_update_restore_request_response.xml", - DateTime.parse("2000-07-01T00:03:00Z")); + assertThatCommand("domain_update_restore_request.xml") + .atTime("2000-07-01T00:03:00Z") + .hasResponse("domain_update_restore_request_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test public void testDomainDeletion_withinAddGracePeriod_deletesImmediately() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createContacts(DateTime.parse("2000-06-01T00:00:00Z")); // Create domain example.tld 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); + assertThatCommand("domain_create_no_hosts_or_dsdata.xml") + .atTime(createTime) + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z")); DomainResource domain = loadByForeignKey(DomainResource.class, "example.tld", createTime.plusHours(1)); // Delete domain example.tld within the add grace period. DateTime deleteTime = createTime.plusDays(1); - assertCommandAndResponse( - "domain_delete.xml", ImmutableMap.of("NAME", "example.tld"), - "generic_success_response.xml", ImmutableMap.of(), - deleteTime); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "example.tld")) + .atTime(deleteTime) + .hasResponse("generic_success_response.xml"); // Verify that it is immediately non-existent. - assertCommandAndResponse( - "domain_info.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of( - "MSG", "The domain with given ID (example.tld) doesn't exist.", "CODE", "2303"), - deleteTime.plusSeconds(1)); + assertThatCommand("domain_info.xml") + .atTime(deleteTime.plusSeconds(1)) + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2303", "MSG", "The domain with given ID (example.tld) doesn't exist.")); // The expected one-time billing event, that should have an associated Cancellation. OneTime oneTimeCreateBillingEvent = makeOneTimeCreateBillingEvent(domain, createTime); @@ -224,57 +209,50 @@ public class EppLifecycleDomainTest extends EppTestCase { makeCancellationBillingEventFor( domain, oneTimeCreateBillingEvent, createTime, deleteTime)); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test public void testDomainDeletion_outsideAddGracePeriod_showsRedemptionPeriod() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createContacts(DateTime.parse("2000-06-01T00:00:00Z")); DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z"); // 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); + assertThatCommand("domain_create_no_hosts_or_dsdata.xml") + .atTime(createTime) + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00.0Z", + "EXDATE", "2002-06-01T00:02:00.0Z")); 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", ImmutableMap.of("NAME", "example.tld"), - "generic_success_action_pending_response.xml", ImmutableMap.of(), - deleteTime); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "example.tld")) + .atTime(deleteTime) + .hasResponse("generic_success_action_pending_response.xml"); // Verify that domain shows redemptionPeriod soon after deletion. - assertCommandAndResponse( - "domain_info.xml", - ImmutableMap.of(), - "domain_info_response_wildcard.xml", - ImmutableMap.of("STATUS", "redemptionPeriod"), - DateTime.parse("2000-07-08T00:00:00Z")); + assertThatCommand("domain_info.xml") + .atTime("2000-07-08T00:00:00Z") + .hasResponse( + "domain_info_response_wildcard.xml", ImmutableMap.of("STATUS", "redemptionPeriod")); // Verify that the domain shows pendingDelete next. - assertCommandAndResponse( - "domain_info.xml", - ImmutableMap.of(), - "domain_info_response_wildcard.xml", - ImmutableMap.of("STATUS", "pendingDelete"), - DateTime.parse("2000-08-08T00:00:00Z")); + assertThatCommand("domain_info.xml") + .atTime("2000-08-08T00:00:00Z") + .hasResponse( + "domain_info_response_wildcard.xml", ImmutableMap.of("STATUS", "pendingDelete")); // Verify that the domain is non-existent (available for registration) later. - assertCommandAndResponse( - "domain_info.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")); + assertThatCommand("domain_info.xml") + .atTime("2000-09-01T00:00:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2303", "MSG", "The domain with given ID (example.tld) doesn't exist.")); DomainResource domain = loadByForeignKey( @@ -285,12 +263,12 @@ public class EppLifecycleDomainTest extends EppTestCase { makeOneTimeCreateBillingEvent(domain, createTime), makeRecurringCreateBillingEvent(domain, createTime, deleteTime)); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test public void testEapDomainDeletion_withinAddGracePeriod_eapFeeIsNotRefunded() throws Exception { - assertCommandAndResponse("login_valid_fee_extension.xml", "login_response.xml"); + assertThatCommand("login_valid_fee_extension.xml").hasResponse("login_response.xml"); createContacts(DateTime.parse("2000-06-01T00:00:00Z")); // Set the EAP schedule. @@ -306,10 +284,9 @@ public class EppLifecycleDomainTest extends EppTestCase { // Create domain example.tld, which should have an EAP fee of USD 100. DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z"); - assertCommandAndResponse( - "domain_create_eap_fee.xml", - "domain_create_response_eap_fee.xml", - createTime); + assertThatCommand("domain_create_eap_fee.xml") + .atTime(createTime) + .hasResponse("domain_create_response_eap_fee.xml"); DomainResource domain = loadByForeignKey( @@ -317,10 +294,9 @@ public class EppLifecycleDomainTest extends EppTestCase { // Delete domain example.tld within the add grade period. DateTime deleteTime = createTime.plusDays(1); - assertCommandAndResponse( - "domain_delete.xml", ImmutableMap.of("NAME", "example.tld"), - "domain_delete_response_fee.xml", ImmutableMap.of(), - deleteTime); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "example.tld")) + .atTime(deleteTime) + .hasResponse("domain_delete_response_fee.xml"); // Verify that the OneTime billing event associated with the base fee of domain registration and // is canceled and the autorenew is ended, but that the EAP fee is not canceled. @@ -350,7 +326,7 @@ public class EppLifecycleDomainTest extends EppTestCase { // ... but there was NOT a Cancellation for the EAP fee, as this would fail if additional // billing events were present. - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } /** Makes a one-time billing event corresponding to the given domain's creation. */ @@ -426,21 +402,20 @@ public class EppLifecycleDomainTest extends EppTestCase { @Test public void testDomainDeletionWithSubordinateHost_fails() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createFakesite(); createSubordinateHost(); - assertCommandAndResponse( - "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"); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example")) + .atTime("2002-05-30T01:01:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of("CODE", "2305", "MSG", "Domain to be deleted has subordinate hosts")); + assertThatLogoutSucceeds(); } @Test public void testDeletionOfDomain_afterRenameOfSubordinateHost_succeeds() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -452,10 +427,9 @@ public class EppLifecycleDomainTest extends EppTestCase { createFakesite(); createSubordinateHost(); // Update the ns3 host to no longer be on fakesite.example domain. - assertCommandAndResponse( - "host_update_fakesite.xml", - "generic_success_response.xml", - DateTime.parse("2002-05-30T01:01:00Z")); + assertThatCommand("host_update_fakesite.xml") + .atTime("2002-05-30T01:01:00Z") + .hasResponse("generic_success_response.xml"); // Add assert about EppMetric assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") @@ -466,10 +440,9 @@ public class EppLifecycleDomainTest extends EppTestCase { .and() .hasStatus(SUCCESS); // Delete the fakesite.example domain (which should succeed since it no longer has subords). - assertCommandAndResponse( - "domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example"), - "generic_success_action_pending_response.xml", ImmutableMap.of(), - DateTime.parse("2002-05-30T01:02:00Z")); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example")) + .atTime("2002-05-30T01:02:00Z") + .hasResponse("generic_success_action_pending_response.xml"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -481,10 +454,9 @@ public class EppLifecycleDomainTest extends EppTestCase { .and() .hasStatus(SUCCESS_WITH_ACTION_PENDING); // Check info on the renamed host and verify that it's still around and wasn't deleted. - assertCommandAndResponse( - "host_info_ns9000_example.xml", - "host_info_response_ns9000_example.xml", - DateTime.parse("2002-06-30T01:03:00Z")); + assertThatCommand("host_info_ns9000_example.xml") + .atTime("2002-06-30T01:03:00Z") + .hasResponse("host_info_response_ns9000_example.xml"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -493,7 +465,7 @@ public class EppLifecycleDomainTest extends EppTestCase { .hasEppTarget("ns9000.example.external") .and() .hasStatus(SUCCESS); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -504,50 +476,44 @@ public class EppLifecycleDomainTest extends EppTestCase { @Test public void testDeletionOfDomain_afterUpdateThatCreatesSubordinateHost_fails() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createFakesite(); // 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-02T00:00:00.0Z", - "EXDATE", "2002-06-02T00:00:00.0Z"), - DateTime.parse("2000-06-02T00:00:00Z")); + assertThatCommand("domain_create_no_hosts_or_dsdata.xml") + .atTime("2000-06-02T00:00:00Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-02T00:00:00.0Z", + "EXDATE", "2002-06-02T00:00:00.0Z")); // Create nameserver ns1.example.tld - assertCommandAndResponse( - "host_create_example.xml", - "host_create_response_example.xml", - DateTime.parse("2000-06-02T00:01:00Z")); + assertThatCommand("host_create_example.xml") + .atTime("2000-06-02T00:01:00Z") + .hasResponse("host_create_response_example.xml"); // Update the ns1 host to be on the fakesite.example domain. - assertCommandAndResponse( - "host_update_ns1_to_fakesite.xml", - "generic_success_response.xml", - DateTime.parse("2002-05-30T01:01:00Z")); + assertThatCommand("host_update_ns1_to_fakesite.xml") + .atTime("2002-05-30T01:01:00Z") + .hasResponse("generic_success_response.xml"); // Attempt to delete the fakesite.example domain (which should fail since it now has a // subordinate host). - assertCommandAndResponse( - "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")); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example")) + .atTime("2002-05-30T01:02:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of("CODE", "2305", "MSG", "Domain to be deleted has subordinate hosts")); // Check info on the renamed host and verify that it's still around and wasn't deleted. - assertCommandAndResponse( - "host_info_fakesite.xml", - "host_info_response_fakesite_post_update.xml", - DateTime.parse("2002-06-30T01:03:00Z")); + assertThatCommand("host_info_fakesite.xml") + .atTime("2002-06-30T01:03:00Z") + .hasResponse("host_info_response_fakesite_post_update.xml"); // Verify that fakesite.example domain is still around and wasn't deleted. - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_ok_post_host_update.xml", - DateTime.parse("2002-05-30T01:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-05-30T01:00:00Z") + .hasResponse("domain_info_response_fakesite_ok_post_host_update.xml"); + assertThatLogoutSucceeds(); } @Test @@ -563,28 +529,26 @@ public class EppLifecycleDomainTest extends EppTestCase { sunriseDate.plusMonths(2), TldState.GENERAL_AVAILABILITY)); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createContactsAndHosts(); - assertCommandAndResponse( - "domain_create_sunrise_encoded_mark.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of( - "MSG", "Command is not allowed in the current registry phase", "CODE", "2002"), - sunriseDate.minusDays(1)); + assertThatCommand("domain_create_sunrise_encoded_mark.xml") + .atTime(sunriseDate.minusDays(1)) + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2002", "MSG", "Command is not allowed in the current registry phase")); - assertCommandAndResponse( - "domain_info_testvalidate.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)); + assertThatCommand("domain_info_testvalidate.xml") + .atTime(sunriseDate.plusDays(1)) + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2303", + "MSG", "The domain with given ID (test-validate.example) doesn't exist.")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test @@ -596,12 +560,11 @@ public class EppLifecycleDomainTest extends EppTestCase { START_OF_TIME, TldState.PREDELEGATION, gaDate, TldState.GENERAL_AVAILABILITY)); - assertCommandAndResponse("login_valid_fee_extension.xml", "login_response.xml"); + assertThatCommand("login_valid_fee_extension.xml").hasResponse("login_response.xml"); - assertCommandAndResponse( - "domain_check_fee_premium.xml", - "domain_check_fee_premium_response.xml", - gaDate.plusDays(1)); + assertThatCommand("domain_check_fee_premium.xml") + .atTime(gaDate.plusDays(1)) + .hasResponse("domain_check_fee_premium_response.xml"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -613,302 +576,264 @@ public class EppLifecycleDomainTest extends EppTestCase { .and() .hasStatus(SUCCESS); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test public void testDomainCreate_annualAutoRenewPollMessages_haveUniqueIds() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); // Create the domain. createFakesite(); // The first autorenew poll message isn't seen until after the initial two years of registration // are up. - assertCommandAndResponse( - "poll.xml", "poll_response_empty.xml", DateTime.parse("2001-01-01T00:01:00Z")); - assertCommandAndResponse( - "poll.xml", - ImmutableMap.of(), - "poll_response_autorenew.xml", - ImmutableMap.of( - "ID", "1-C-EXAMPLE-13-16-2002", - "QDATE", "2002-06-01T00:04:00Z", - "DOMAIN", "fakesite.example", - "EXDATE", "2003-06-01T00:04:00Z"), - DateTime.parse("2002-07-01T00:01:00Z")); - assertCommandAndResponse( - "poll_ack.xml", - ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2002"), - "poll_ack_response_empty.xml", - ImmutableMap.of(), - DateTime.parse("2002-07-01T00:02:00Z")); + assertThatCommand("poll.xml") + .atTime("2001-01-01T00:01:00Z") + .hasResponse("poll_response_empty.xml"); + assertThatCommand("poll.xml") + .atTime("2002-07-01T00:01:00Z") + .hasResponse( + "poll_response_autorenew.xml", + ImmutableMap.of( + "ID", "1-C-EXAMPLE-13-16-2002", + "QDATE", "2002-06-01T00:04:00Z", + "DOMAIN", "fakesite.example", + "EXDATE", "2003-06-01T00:04:00Z")); + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2002")) + .atTime("2002-07-01T00:02:00Z") + .hasResponse("poll_ack_response_empty.xml"); // The second autorenew poll message isn't seen until after another year, and it should have a // different ID. - assertCommandAndResponse( - "poll.xml", "poll_response_empty.xml", DateTime.parse("2002-07-01T00:05:00Z")); - assertCommandAndResponse( - "poll.xml", - ImmutableMap.of(), - "poll_response_autorenew.xml", - ImmutableMap.of( - "ID", "1-C-EXAMPLE-13-16-2003", // Note -- Year is different from previous ID. - "QDATE", "2003-06-01T00:04:00Z", - "DOMAIN", "fakesite.example", - "EXDATE", "2004-06-01T00:04:00Z"), - DateTime.parse("2003-07-01T00:05:00Z")); + assertThatCommand("poll.xml") + .atTime("2002-07-01T00:05:00Z") + .hasResponse("poll_response_empty.xml"); + assertThatCommand("poll.xml") + .atTime("2003-07-01T00:05:00Z") + .hasResponse( + "poll_response_autorenew.xml", + ImmutableMap.of( + "ID", "1-C-EXAMPLE-13-16-2003", // Note -- Year is different from previous ID. + "QDATE", "2003-06-01T00:04:00Z", + "DOMAIN", "fakesite.example", + "EXDATE", "2004-06-01T00:04:00Z")); // Ack the second poll message and verify that none remain. - assertCommandAndResponse( - "poll_ack.xml", - ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2003"), - "poll_ack_response_empty.xml", - ImmutableMap.of(), - DateTime.parse("2003-07-01T00:05:05Z")); - assertCommandAndResponse( - "poll.xml", "poll_response_empty.xml", DateTime.parse("2003-07-01T00:05:10Z")); + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2003")) + .atTime("2003-07-01T00:05:05Z") + .hasResponse("poll_ack_response_empty.xml"); + assertThatCommand("poll.xml") + .atTime("2003-07-01T00:05:10Z") + .hasResponse("poll_response_empty.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test public void testDomainTransferPollMessage_serverApproved() throws Exception { // As the losing registrar, create the domain. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createFakesite(); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); // As the winning registrar, request a transfer. Capture the server trid; we'll need it later. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); String response = - assertCommandAndResponse( - "domain_transfer_request_1_year.xml", - "domain_transfer_response_1_year.xml", - DateTime.parse("2001-01-01T00:00:00Z")); + assertThatCommand("domain_transfer_request_1_year.xml") + .atTime("2001-01-01T00:00:00Z") + .hasResponse("domain_transfer_response_1_year.xml"); Matcher matcher = Pattern.compile("(.*)").matcher(response); matcher.find(); String transferRequestTrid = matcher.group(1); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); // As the losing registrar, read the request poll message, and then ack it. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "poll.xml", - "poll_response_domain_transfer_request.xml", - DateTime.parse("2001-01-01T00:01:00Z")); - assertCommandAndResponse( - "poll_ack.xml", - ImmutableMap.of("ID", "1-C-EXAMPLE-17-23-2001"), - "poll_ack_response_empty.xml", - ImmutableMap.of(), - DateTime.parse("2001-01-01T00:01:00Z")); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("poll.xml") + .atTime("2001-01-01T00:01:00Z") + .hasResponse("poll_response_domain_transfer_request.xml"); + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-17-23-2001")) + .atTime("2001-01-01T00:01:00Z") + .hasResponse("poll_ack_response_empty.xml"); // Five days in the future, expect a server approval poll message to the loser, and ack it. - assertCommandAndResponse( - "poll.xml", - "poll_response_domain_transfer_server_approve_loser.xml", - DateTime.parse("2001-01-06T00:01:00Z")); - assertCommandAndResponse( - "poll_ack.xml", - ImmutableMap.of("ID", "1-C-EXAMPLE-17-22-2001"), - "poll_ack_response_empty.xml", - ImmutableMap.of(), - DateTime.parse("2001-01-06T00:01:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("poll.xml") + .atTime("2001-01-06T00:01:00Z") + .hasResponse("poll_response_domain_transfer_server_approve_loser.xml"); + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-17-22-2001")) + .atTime("2001-01-06T00:01:00Z") + .hasResponse("poll_ack_response_empty.xml"); + assertThatLogoutSucceeds(); // Also expect a server approval poll message to the winner, with the transfer request trid. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "poll.xml", - ImmutableMap.of(), - "poll_response_domain_transfer_server_approve_winner.xml", - ImmutableMap.of("SERVER_TRID", transferRequestTrid), - DateTime.parse("2001-01-06T00:02:00Z")); - assertCommandAndResponse( - "poll_ack.xml", - ImmutableMap.of("ID", "1-C-EXAMPLE-17-21-2001"), - "poll_ack_response_empty.xml", - ImmutableMap.of(), - DateTime.parse("2001-01-06T00:02:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); + assertThatCommand("poll.xml") + .atTime("2001-01-06T00:02:00Z") + .hasResponse( + "poll_response_domain_transfer_server_approve_winner.xml", + ImmutableMap.of("SERVER_TRID", transferRequestTrid)); + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-17-21-2001")) + .atTime("2001-01-06T00:02:00Z") + .hasResponse("poll_ack_response_empty.xml"); + assertThatLogoutSucceeds(); } @Test public void testTransfer_autoRenewGraceActive_onlyAtAutomaticTransferTime_getsSubsumed() throws Exception { // Register the domain as the first registrar. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createFakesite(); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); // Request a transfer of the domain to the second registrar. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_transfer_request.xml", - "domain_transfer_response.xml", - DateTime.parse("2002-05-30T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); + assertThatCommand("domain_transfer_request.xml") + .atTime("2002-05-30T00:00:00Z") + .hasResponse("domain_transfer_response.xml"); + assertThatLogoutSucceeds(); // Log back in as the first registrar and verify things. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_pending_transfer.xml", - DateTime.parse("2002-05-30T01:00:00Z")); - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_pending_transfer_autorenew.xml", - DateTime.parse("2002-06-02T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-05-30T01:00:00Z") + .hasResponse("domain_info_response_fakesite_pending_transfer.xml"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-06-02T00:00:00Z") + .hasResponse("domain_info_response_fakesite_pending_transfer_autorenew.xml"); + assertThatLogoutSucceeds(); // Log back in as the second registrar and verify transfer details. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); // Verify that domain is in the transfer period now with expiration date still one year out, // since the transfer should subsume the autorenew that happened during the transfer window. - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_transfer_period.xml", - DateTime.parse("2002-06-06T00:00:00Z")); - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_transfer_complete.xml", - DateTime.parse("2002-06-12T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-06-06T00:00:00Z") + .hasResponse("domain_info_response_fakesite_transfer_period.xml"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-06-12T00:00:00Z") + .hasResponse("domain_info_response_fakesite_transfer_complete.xml"); + assertThatLogoutSucceeds(); } @Test public void testNameserversTransferWithDomain_successfully() throws Exception { // Log in as the first registrar and set up domains with hosts. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createFakesite(); createSubordinateHost(); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); // Request a transfer of the domain to the second registrar. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_transfer_request.xml", - "domain_transfer_response.xml", - DateTime.parse("2002-05-30T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); + assertThatCommand("domain_transfer_request.xml") + .atTime("2002-05-30T00:00:00Z") + .hasResponse("domain_transfer_response.xml"); + assertThatLogoutSucceeds(); // Log back in as the first registrar and verify domain is pending transfer. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_3_nameservers_pending_transfer.xml", - DateTime.parse("2002-05-30T01:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-05-30T01:00:00Z") + .hasResponse("domain_info_response_fakesite_3_nameservers_pending_transfer.xml"); + assertThatLogoutSucceeds(); // Log back in as second registrar and verify transfer was successful. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); // Expect transfer complete with all three nameservers on it. - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_3_nameservers_transfer_successful.xml", - DateTime.parse("2002-06-09T00:00:00Z")); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-06-09T00:00:00Z") + .hasResponse("domain_info_response_fakesite_3_nameservers_transfer_successful.xml"); // Verify that host's client ID was set to the new registrar and has the transfer date set. - assertCommandAndResponse( - "host_info_fakesite.xml", - ImmutableMap.of(), - "host_info_response_fakesite_post_transfer.xml", - ImmutableMap.of("TRDATE", "2002-06-04T00:00:00Z"), - DateTime.parse("2002-06-09T00:01:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("host_info_fakesite.xml") + .atTime("2002-06-09T00:01:00Z") + .hasResponse( + "host_info_response_fakesite_post_transfer.xml", + ImmutableMap.of("TRDATE", "2002-06-04T00:00:00Z")); + assertThatLogoutSucceeds(); } @Test public void testRenewalFails_whenTotalTermExceeds10Years() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); // Creates domain with 2 year expiration. createFakesite(); // Attempt to renew for 9 years, adding up to a total greater than the allowed max of 10 years. - assertCommandAndResponse( - "domain_renew.xml", - ImmutableMap.of("DOMAIN", "fakesite.example", "EXPDATE", "2002-06-01", "YEARS", "9"), - "domain_renew_response_exceeds_max_years.xml", - ImmutableMap.of(), - DateTime.parse("2000-06-07T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand( + "domain_renew.xml", + ImmutableMap.of("DOMAIN", "fakesite.example", "EXPDATE", "2002-06-01", "YEARS", "9")) + .atTime("2000-06-07T00:00:00Z") + .hasResponse("domain_renew_response_exceeds_max_years.xml"); + assertThatLogoutSucceeds(); } @Test public void testDomainDeletionCancelsPendingTransfer() throws Exception { // Register the domain as the first registrar. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createFakesite(); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); // Request a transfer of the domain to the second registrar. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_transfer_request.xml", - "domain_transfer_response.xml", - DateTime.parse("2002-05-30T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); + assertThatCommand("domain_transfer_request.xml") + .atTime("2002-05-30T00:00:00Z") + .hasResponse("domain_transfer_response.xml"); + assertThatLogoutSucceeds(); // Log back in as the first registrar and delete then restore the domain while the transfer // is still pending. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_pending_transfer.xml", - DateTime.parse("2002-05-30T01:00:00Z")); - assertCommandAndResponse( - "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", - "domain_info_response_fakesite_pending_delete.xml", - DateTime.parse("2002-05-30T01:02:00Z")); - assertCommandAndResponse( - "domain_update_restore_fakesite.xml", - "domain_update_restore_request_response.xml", - DateTime.parse("2002-05-30T01:03:00Z")); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-05-30T01:00:00Z") + .hasResponse("domain_info_response_fakesite_pending_transfer.xml"); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example")) + .atTime("2002-05-30T01:01:00Z") + .hasResponse("generic_success_action_pending_response.xml"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-05-30T01:02:00Z") + .hasResponse("domain_info_response_fakesite_pending_delete.xml"); + assertThatCommand("domain_update_restore_fakesite.xml") + .atTime("2002-05-30T01:03:00Z") + .hasResponse("domain_update_restore_request_response.xml"); // Expect domain is ok now, not pending delete or transfer, and has been extended by a year from // the date of the restore. (Not from the original expiration date.) - assertCommandAndResponse( - "domain_info_fakesite.xml", - "domain_info_response_fakesite_restored_ok.xml", - DateTime.parse("2002-05-30T01:04:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2002-05-30T01:04:00Z") + .hasResponse("domain_info_response_fakesite_restored_ok.xml"); + assertThatLogoutSucceeds(); } @Test public void testDomainTransfer_subordinateHost_showsChangeInTransferQuery() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createFakesite(); createSubordinateHost(); - assertCommandAndResponse( - "domain_transfer_query_fakesite.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"); + assertThatCommand("domain_transfer_query_fakesite.xml") + .atTime("2000-09-02T00:00:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of("CODE", "2002", "MSG", "Object has no transfer history")); + assertThatLogoutSucceeds(); // Request a transfer of the domain to the second registrar. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_transfer_request_1_year.xml", - "domain_transfer_response_1_year.xml", - DateTime.parse("2001-01-01T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); + assertThatCommand("domain_transfer_request_1_year.xml") + .atTime("2001-01-01T00:00:00Z") + .hasResponse("domain_transfer_response_1_year.xml"); + assertThatLogoutSucceeds(); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); // Verify that reID is set correctly. - assertCommandAndResponse( - "domain_transfer_query_fakesite.xml", - "domain_transfer_query_response_fakesite.xml", - DateTime.parse("2001-01-02T00:00:00Z")); + assertThatCommand("domain_transfer_query_fakesite.xml") + .atTime("2001-01-02T00:00:00Z") + .hasResponse("domain_transfer_query_response_fakesite.xml"); // Verify that status went from 'pending' to 'serverApproved'. - assertCommandAndResponse( - "domain_transfer_query_fakesite.xml", - "domain_transfer_query_response_completed_fakesite.xml", - DateTime.parse("2001-01-08T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("domain_transfer_query_fakesite.xml") + .atTime("2001-01-08T00:00:00Z") + .hasResponse("domain_transfer_query_response_completed_fakesite.xml"); + assertThatLogoutSucceeds(); } /** @@ -919,57 +844,51 @@ public class EppLifecycleDomainTest extends EppTestCase { @Test public void testSuccess_lastTransferTime_superordinateDomainTransferFollowedByHostUpdate() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); // Create fakesite.example with subordinate host ns3.fakesite.example createFakesite(); createSubordinateHost(); - assertCommandAndResponse( - "domain_transfer_query_fakesite.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"); + assertThatCommand("domain_transfer_query_fakesite.xml") + .atTime("2000-09-02T00:00:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of("CODE", "2002", "MSG", "Object has no transfer history")); + assertThatLogoutSucceeds(); // Request a transfer of the domain to the second registrar. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_transfer_request_1_year.xml", - "domain_transfer_response_1_year.xml", - DateTime.parse("2001-01-01T00:00:00Z")); + assertThatLoginSucceeds("TheRegistrar", "password2"); + assertThatCommand("domain_transfer_request_1_year.xml") + .atTime("2001-01-01T00:00:00Z") + .hasResponse("domain_transfer_response_1_year.xml"); // Verify that the lastTransferTime now reflects the superordinate domain's transfer. - assertCommandAndResponse( - "host_info.xml", - ImmutableMap.of("HOSTNAME", "ns3.fakesite.example"), - "host_info_response_fakesite_post_transfer.xml", - ImmutableMap.of("TRDATE", "2001-01-06T00:00:00.000Z"), - DateTime.parse("2001-01-07T00:00:00Z")); - assertCommandAndResponse( - "domain_create_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")); + assertThatCommand("host_info.xml", ImmutableMap.of("HOSTNAME", "ns3.fakesite.example")) + .atTime("2001-01-07T00:00:00Z") + .hasResponse( + "host_info_response_fakesite_post_transfer.xml", + ImmutableMap.of("TRDATE", "2001-01-06T00:00:00.000Z")); + assertThatCommand("domain_create_secondsite.xml") + .atTime("2001-01-08T00:00:00Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "secondsite.example", + "CRDATE", "2001-01-08T00:00:00.0Z", + "EXDATE", "2003-01-08T00:00:00.0Z")); // Update the host to be subordinate to a different domain by renaming it to // ns3.secondsite.example - assertCommandAndResponse( - "host_update_rename_only.xml", - ImmutableMap.of("oldName", "ns3.fakesite.example", "newName", "ns3.secondsite.example"), - "generic_success_response.xml", - ImmutableMap.of(), - DateTime.parse("2002-05-30T01:01:00Z")); + assertThatCommand( + "host_update_rename_only.xml", + ImmutableMap.of("oldName", "ns3.fakesite.example", "newName", "ns3.secondsite.example")) + .atTime("2002-05-30T01:01:00Z") + .hasResponse("generic_success_response.xml"); // The last transfer time on the host should still be what it was from the transfer. - assertCommandAndResponse( - "host_info.xml", - ImmutableMap.of("HOSTNAME", "ns3.secondsite.example"), - "host_info_response_fakesite_post_transfer_and_update.xml", - ImmutableMap.of( - "HOSTNAME", "ns3.secondsite.example", - "TRDATE", "2001-01-06T00:00:00.000Z"), - DateTime.parse("2003-01-07T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("host_info.xml", ImmutableMap.of("HOSTNAME", "ns3.secondsite.example")) + .atTime("2003-01-07T00:00:00Z") + .hasResponse( + "host_info_response_fakesite_post_transfer_and_update.xml", + ImmutableMap.of( + "HOSTNAME", "ns3.secondsite.example", + "TRDATE", "2001-01-06T00:00:00.000Z")); + assertThatLogoutSucceeds(); } /** @@ -979,124 +898,115 @@ public class EppLifecycleDomainTest extends EppTestCase { @Test public void testSuccess_lastTransferTime_superordinateDomainTransferThenHostUpdateToExternal() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); // Create fakesite.example with subordinate host ns3.fakesite.example createFakesite(); createSubordinateHost(); - assertCommandAndResponse( - "domain_transfer_query_fakesite.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"); + assertThatCommand("domain_transfer_query_fakesite.xml") + .atTime("2000-09-02T00:00:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of("CODE", "2002", "MSG", "Object has no transfer history")); + assertThatLogoutSucceeds(); // Request a transfer of the domain to the second registrar. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "domain_transfer_request_1_year.xml", - "domain_transfer_response_1_year.xml", - DateTime.parse("2001-01-01T00:00:00Z")); + assertThatLoginSucceeds("TheRegistrar", "password2"); + assertThatCommand("domain_transfer_request_1_year.xml") + .atTime("2001-01-01T00:00:00Z") + .hasResponse("domain_transfer_response_1_year.xml"); // Verify that the lastTransferTime now reflects the superordinate domain's transfer. - assertCommandAndResponse( - "host_info_fakesite.xml", - 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")); + assertThatCommand("host_info_fakesite.xml") + .atTime("2001-01-07T00:00:00Z") + .hasResponse( + "host_info_response_fakesite_post_transfer.xml", + ImmutableMap.of("TRDATE", "2001-01-06T00:00:00.000Z")); // Update the host to be external by renaming it to ns3.notarealsite.external - assertCommandAndResponse( - "host_update_rename_and_remove_addresses.xml", - ImmutableMap.of( - "oldName", "ns3.fakesite.example", - "newName", "ns3.notarealsite.external"), - "generic_success_response.xml", - ImmutableMap.of(), - DateTime.parse("2002-05-30T01:01:00Z")); + assertThatCommand( + "host_update_rename_and_remove_addresses.xml", + ImmutableMap.of( + "oldName", "ns3.fakesite.example", + "newName", "ns3.notarealsite.external")) + .atTime("2002-05-30T01:01:00Z") + .hasResponse("generic_success_response.xml"); // The last transfer time on the host should still be what it was from the transfer. - assertCommandAndResponse( - "host_info.xml", - ImmutableMap.of("HOSTNAME", "ns3.notarealsite.external"), - "host_info_response_fakesite_post_transfer_and_update_no_addresses.xml", - ImmutableMap.of( - "HOSTNAME", "ns3.notarealsite.external", - "TRDATE", "2001-01-06T00:00:00.000Z"), - DateTime.parse("2001-01-07T00:00:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("host_info.xml", ImmutableMap.of("HOSTNAME", "ns3.notarealsite.external")) + .atTime("2001-01-07T00:00:00Z") + .hasResponse( + "host_info_response_fakesite_post_transfer_and_update_no_addresses.xml", + ImmutableMap.of( + "HOSTNAME", "ns3.notarealsite.external", + "TRDATE", "2001-01-06T00:00:00.000Z")); + assertThatLogoutSucceeds(); } @Test public void testSuccess_multipartTldsWithSharedSuffixes() throws Exception { createTlds("bar.foo.tld", "foo.tld"); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createContacts(DateTime.parse("2000-06-01T00:00:00.000Z")); // Create domain example.bar.foo.tld - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "example.bar.foo.tld"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "example.bar.foo.tld", - "CRDATE", "2000-06-01T00:02:00Z", - "EXDATE", "2002-06-01T00:02:00Z"), - DateTime.parse("2000-06-01T00:02:00.001Z")); + assertThatCommand( + "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.bar.foo.tld")) + .atTime("2000-06-01T00:02:00.001Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.bar.foo.tld", + "CRDATE", "2000-06-01T00:02:00Z", + "EXDATE", "2002-06-01T00:02:00Z")); // Create domain example.foo.tld - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "example.foo.tld"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "example.foo.tld", - "CRDATE", "2000-06-01T00:02:00Z", - "EXDATE", "2002-06-01T00:02:00Z"), - DateTime.parse("2000-06-01T00:02:00.002Z")); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.foo.tld")) + .atTime("2000-06-01T00:02:00.002Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.foo.tld", + "CRDATE", "2000-06-01T00:02:00Z", + "EXDATE", "2002-06-01T00:02:00Z")); // Create domain example.tld - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "example.tld"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "example.tld", - "CRDATE", "2000-06-01T00:02:00Z", - "EXDATE", "2002-06-01T00:02:00Z"), - DateTime.parse("2000-06-01T00:02:00.003Z")); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.tld")) + .atTime("2000-06-01T00:02:00.003Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00Z", + "EXDATE", "2002-06-01T00:02:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test public void testSuccess_multipartTldsWithSharedPrefixes() throws Exception { createTld("tld.foo"); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); createContacts(DateTime.parse("2000-06-01T00:00:00.000Z")); // Create domain example.tld.foo - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "example.tld.foo"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "example.tld.foo", - "CRDATE", "2000-06-01T00:02:00Z", - "EXDATE", "2002-06-01T00:02:00Z"), - DateTime.parse("2000-06-01T00:02:00.001Z")); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.tld.foo")) + .atTime("2000-06-01T00:02:00.001Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld.foo", + "CRDATE", "2000-06-01T00:02:00Z", + "EXDATE", "2002-06-01T00:02:00Z")); // Create domain example.tld - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "example.tld"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "example.tld", - "CRDATE", "2000-06-01T00:02:00Z", - "EXDATE", "2002-06-01T00:02:00Z"), - DateTime.parse("2000-06-01T00:02:00.002Z")); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.tld")) + .atTime("2000-06-01T00:02:00.002Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00Z", + "EXDATE", "2002-06-01T00:02:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } /** @@ -1118,76 +1028,73 @@ public class EppLifecycleDomainTest extends EppTestCase { sunriseDate, TldState.START_DATE_SUNRISE, gaDate, TldState.GENERAL_AVAILABILITY)); - assertCommandAndResponse("login_valid.xml", "login_response.xml", sunriseDate.minusDays(3)); + assertThatLogin("NewRegistrar", "foo-BAR2") + .atTime(sunriseDate.minusDays(3)) + .hasResponse("login_response.xml"); createContactsAndHosts(); // During pre-delegation, any create should fail both with and without mark - assertCommandAndResponse( - "domain_create_start_date_sunrise_encoded_mark.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of( - "MSG", "Declared launch extension phase does not match the current registry phase", - "CODE", "2306"), - sunriseDate.minusDays(2)); + assertThatCommand("domain_create_start_date_sunrise_encoded_mark.xml") + .atTime(sunriseDate.minusDays(2)) + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2306", + "MSG", + "Declared launch extension phase does not match the current registry phase")); - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "general.example"), - "response_error.xml", - ImmutableMap.of( - "MSG", "The current registry phase does not allow for general registrations", - "CODE", "2002"), - sunriseDate.minusDays(1)); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "general.example")) + .atTime(sunriseDate.minusDays(1)) + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2002", + "MSG", "The current registry phase does not allow for general registrations")); // During start-date sunrise, create with mark will succeed but without will fail. // We also test we can delete without a mark. - assertCommandAndResponse( - "domain_create_start_date_sunrise_encoded_mark.xml", - ImmutableMap.of(), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "test-validate.example", - "CRDATE", "2014-09-09T09:09:09Z", - "EXDATE", "2015-09-09T09:09:09Z"), - sunriseDate.plusDays(1)); + assertThatCommand("domain_create_start_date_sunrise_encoded_mark.xml") + .atTime(sunriseDate.plusDays(1)) + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "test-validate.example", + "CRDATE", "2014-09-09T09:09:09Z", + "EXDATE", "2015-09-09T09:09:09Z")); - assertCommandAndResponse( - "domain_delete.xml", ImmutableMap.of("NAME", "test-validate.example"), - "generic_success_response.xml", ImmutableMap.of(), - sunriseDate.plusDays(1).plusMinutes(1)); + assertThatCommand("domain_delete.xml", ImmutableMap.of("NAME", "test-validate.example")) + .atTime(sunriseDate.plusDays(1).plusMinutes(1)) + .hasResponse("generic_success_response.xml"); - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "general.example"), - "response_error.xml", - ImmutableMap.of( - "MSG", "The current registry phase requires a signed mark for registrations", - "CODE", "2002"), - sunriseDate.plusDays(2)); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "general.example")) + .atTime(sunriseDate.plusDays(2)) + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2002", + "MSG", "The current registry phase requires a signed mark for registrations")); // During general availability, sunrise creates will fail but regular creates succeed - assertCommandAndResponse( - "domain_create_start_date_sunrise_encoded_mark.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of( - "MSG", "Declared launch extension phase does not match the current registry phase", - "CODE", "2306"), - gaDate.plusDays(1)); + assertThatCommand("domain_create_start_date_sunrise_encoded_mark.xml") + .atTime(gaDate.plusDays(1)) + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2306", + "MSG", + "Declared launch extension phase does not match the current registry phase")); - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "general.example"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "general.example", - "CRDATE", "2014-10-10T09:09:09Z", - "EXDATE", "2016-10-10T09:09:09Z"), - gaDate.plusDays(2)); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "general.example")) + .atTime(gaDate.plusDays(2)) + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "general.example", + "CRDATE", "2014-10-10T09:09:09Z", + "EXDATE", "2016-10-10T09:09:09Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } /** @@ -1208,40 +1115,39 @@ public class EppLifecycleDomainTest extends EppTestCase { sunriseDate, TldState.START_DATE_SUNRISE, gaDate, TldState.GENERAL_AVAILABILITY)); - assertCommandAndResponse("login_valid.xml", "login_response.xml", sunriseDate.minusDays(3)); + assertThatLogin("NewRegistrar", "foo-BAR2") + .atTime(sunriseDate.minusDays(3)) + .hasResponse("login_response.xml"); createContactsAndHosts(); // During start-date sunrise, create with mark will succeed but without will fail. // We also test we can delete without a mark. - assertCommandAndResponse( - "domain_info.xml", - ImmutableMap.of("NAME", "test-validate.example"), - "response_error.xml", - ImmutableMap.of( - "MSG", "The domain with given ID (example.tld) doesn't exist.", "CODE", "2303"), - sunriseDate.plusDays(1)); + assertThatCommand("domain_info.xml", ImmutableMap.of("NAME", "test-validate.example")) + .atTime(sunriseDate.plusDays(1)) + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2303", "MSG", "The domain with given ID (example.tld) doesn't exist.")); - assertCommandAndResponse( - "domain_create_start_date_sunrise_encoded_mark_no_type.xml", - ImmutableMap.of(), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "test-validate.example", - "CRDATE", "2014-09-09T09:10:09Z", - "EXDATE", "2015-09-09T09:10:09Z"), - sunriseDate.plusDays(1).plusMinutes(1)); + assertThatCommand("domain_create_start_date_sunrise_encoded_mark_no_type.xml") + .atTime(sunriseDate.plusDays(1).plusMinutes(1)) + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "test-validate.example", + "CRDATE", "2014-09-09T09:10:09Z", + "EXDATE", "2015-09-09T09:10:09Z")); - assertCommandAndResponse( - "domain_info_wildcard.xml", - ImmutableMap.of("NAME", "test-validate.example"), - "domain_info_response_ok_wildcard.xml", - ImmutableMap.of( - "NAME", "test-validate.example", - "CRDATE", "2014-09-09T09:10:09Z", - "EXDATE", "2015-09-09T09:10:09Z"), - sunriseDate.plusDays(1).plusMinutes(2)); + assertThatCommand("domain_info_wildcard.xml", ImmutableMap.of("NAME", "test-validate.example")) + .atTime(sunriseDate.plusDays(1).plusMinutes(2)) + .hasResponse( + "domain_info_response_ok_wildcard.xml", + ImmutableMap.of( + "NAME", "test-validate.example", + "CRDATE", "2014-09-09T09:10:09Z", + "EXDATE", "2015-09-09T09:10:09Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } } diff --git a/javatests/google/registry/flows/EppLifecycleHostTest.java b/javatests/google/registry/flows/EppLifecycleHostTest.java index e56a041a9..10889d8fd 100644 --- a/javatests/google/registry/flows/EppLifecycleHostTest.java +++ b/javatests/google/registry/flows/EppLifecycleHostTest.java @@ -46,13 +46,10 @@ public class EppLifecycleHostTest extends EppTestCase { @Test public void testLifecycle() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "hello.xml", - ImmutableMap.of(), - "greeting.xml", - ImmutableMap.of("DATE", "2000-06-02T00:00:00Z"), - DateTime.parse("2000-06-02T00:00:00Z")); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("hello.xml") + .atTime("2000-06-02T00:00:00Z") + .hasResponse("greeting.xml", ImmutableMap.of("DATE", "2000-06-02T00:00:00Z")); // Note that Hello commands don't set a status code on the response. assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") @@ -60,12 +57,11 @@ public class EppLifecycleHostTest extends EppTestCase { .hasCommandName("Hello") .and() .hasNoStatus(); - assertCommandAndResponse( - "host_create.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.tld"), - "host_create_response.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.tld", "CRDATE", "2000-06-02T00:01:00Z"), - DateTime.parse("2000-06-02T00:01:00Z")); + assertThatCommand("host_create.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld")) + .atTime("2000-06-02T00:01:00Z") + .hasResponse( + "host_create_response.xml", + ImmutableMap.of("HOSTNAME", "ns1.example.tld", "CRDATE", "2000-06-02T00:01:00Z")); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -74,13 +70,12 @@ public class EppLifecycleHostTest extends EppTestCase { .hasEppTarget("ns1.example.tld") .and() .hasStatus(SUCCESS); - assertCommandAndResponse( - "host_info.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.tld"), - "host_info_response.xml", - ImmutableMap.of( - "HOSTNAME", "ns1.example.tld", "ROID", "1-ROID", "CRDATE", "2000-06-02T00:01:00Z"), - DateTime.parse("2000-06-02T00:02:00Z")); + assertThatCommand("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld")) + .atTime("2000-06-02T00:02:00Z") + .hasResponse( + "host_info_response.xml", + ImmutableMap.of( + "HOSTNAME", "ns1.example.tld", "ROID", "1-ROID", "CRDATE", "2000-06-02T00:01:00Z")); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -89,12 +84,9 @@ public class EppLifecycleHostTest extends EppTestCase { .hasEppTarget("ns1.example.tld") .and() .hasStatus(SUCCESS); - assertCommandAndResponse( - "host_delete.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.tld"), - "generic_success_action_pending_response.xml", - ImmutableMap.of(), - DateTime.parse("2000-06-02T00:03:00Z")); + assertThatCommand("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld")) + .atTime("2000-06-02T00:03:00Z") + .hasResponse("generic_success_action_pending_response.xml"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() @@ -103,140 +95,128 @@ public class EppLifecycleHostTest extends EppTestCase { .hasEppTarget("ns1.example.tld") .and() .hasStatus(SUCCESS_WITH_ACTION_PENDING); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } @Test public void testRenamingHostToExistingHost_fails() throws Exception { createTld("example"); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); // Create the fakesite domain. - assertCommandAndResponse( - "contact_create_sh8013.xml", - ImmutableMap.of(), - "contact_create_response_sh8013.xml", - ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"), - DateTime.parse("2000-06-01T00:00:00Z")); - assertCommandAndResponse( - "contact_create_jd1234.xml", - "contact_create_response_jd1234.xml", - DateTime.parse("2000-06-01T00:01:00Z")); - assertCommandAndResponse( - "domain_create_fakesite_no_nameservers.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", - "domain_info_response_fakesite_inactive.xml", - DateTime.parse("2000-06-05T00:02:00Z")); + assertThatCommand("contact_create_sh8013.xml") + .atTime("2000-06-01T00:00:00Z") + .hasResponse( + "contact_create_response_sh8013.xml", + ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z")); + assertThatCommand("contact_create_jd1234.xml") + .atTime("2000-06-01T00:01:00Z") + .hasResponse("contact_create_response_jd1234.xml"); + assertThatCommand("domain_create_fakesite_no_nameservers.xml") + .atTime("2000-06-01T00:04:00Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "fakesite.example", + "CRDATE", "2000-06-01T00:04:00.0Z", + "EXDATE", "2002-06-01T00:04:00.0Z")); + assertThatCommand("domain_info_fakesite.xml") + .atTime("2000-06-05T00:02:00Z") + .hasResponse("domain_info_response_fakesite_inactive.xml"); // Add the fakesite subordinate host (requires that domain is already created). - assertCommandAndResponse( - "host_create_fakesite.xml", - "host_create_response_fakesite.xml", - DateTime.parse("2000-06-06T00:01:00Z")); + assertThatCommand("host_create_fakesite.xml") + .atTime("2000-06-06T00:01:00Z") + .hasResponse("host_create_response_fakesite.xml"); // Add the 2nd fakesite subordinate host. - assertCommandAndResponse( - "host_create_fakesite2.xml", - "host_create_response_fakesite2.xml", - DateTime.parse("2000-06-09T00:01:00Z")); + assertThatCommand("host_create_fakesite2.xml") + .atTime("2000-06-09T00:01:00Z") + .hasResponse("host_create_response_fakesite2.xml"); // Attempt overwriting of 2nd fakesite subordinate host with the 1st. - assertCommandAndResponse( - "host_update_fakesite1_to_fakesite2.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")); + assertThatCommand("host_update_fakesite1_to_fakesite2.xml") + .atTime("2000-06-10T00:01:00Z") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2302", + "MSG", "Object with given ID (ns4.fakesite.example) already exists")); // Verify that fakesite hosts still exist in their unmodified states. - assertCommandAndResponse( - "host_info_fakesite.xml", - "host_info_response_fakesite_ok.xml", - DateTime.parse("2000-06-11T00:07:00Z")); - assertCommandAndResponse( - "host_info_fakesite2.xml", - "host_info_response_fakesite2.xml", - DateTime.parse("2000-06-11T00:08:00Z")); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatCommand("host_info_fakesite.xml") + .atTime("2000-06-11T00:07:00Z") + .hasResponse("host_info_response_fakesite_ok.xml"); + assertThatCommand("host_info_fakesite2.xml") + .atTime("2000-06-11T00:08:00Z") + .hasResponse("host_info_response_fakesite2.xml"); + assertThatLogoutSucceeds(); } @Test public void testSuccess_multipartTldsWithSharedSuffixes() throws Exception { createTlds("bar.foo.tld", "foo.tld", "tld"); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); - assertCommandAndResponse( - "contact_create_sh8013.xml", - ImmutableMap.of(), - "contact_create_response_sh8013.xml", - ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"), - DateTime.parse("2000-06-01T00:00:00Z")); - assertCommandAndResponse( - "contact_create_jd1234.xml", - "contact_create_response_jd1234.xml", - DateTime.parse("2000-06-01T00:01:00Z")); + assertThatCommand("contact_create_sh8013.xml") + .atTime("2000-06-01T00:00:00Z") + .hasResponse( + "contact_create_response_sh8013.xml", + ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z")); + assertThatCommand("contact_create_jd1234.xml") + .atTime("2000-06-01T00:01:00Z") + .hasResponse("contact_create_response_jd1234.xml"); // Create domain example.bar.foo.tld - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "example.bar.foo.tld"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "example.bar.foo.tld", - "CRDATE", "2000-06-01T00:02:00Z", - "EXDATE", "2002-06-01T00:02:00Z"), - DateTime.parse("2000-06-01T00:02:00.000Z")); + assertThatCommand( + "domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.bar.foo.tld")) + .atTime("2000-06-01T00:02:00.000Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.bar.foo.tld", + "CRDATE", "2000-06-01T00:02:00Z", + "EXDATE", "2002-06-01T00:02:00Z")); // Create domain example.foo.tld - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "example.foo.tld"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "example.foo.tld", - "CRDATE", "2000-06-01T00:02:00Z", - "EXDATE", "2002-06-01T00:02:00Z"), - DateTime.parse("2000-06-01T00:02:00.001Z")); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.foo.tld")) + .atTime("2000-06-01T00:02:00.001Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.foo.tld", + "CRDATE", "2000-06-01T00:02:00Z", + "EXDATE", "2002-06-01T00:02:00Z")); // Create domain example.tld - assertCommandAndResponse( - "domain_create_wildcard.xml", - ImmutableMap.of("HOSTNAME", "example.tld"), - "domain_create_response.xml", - ImmutableMap.of( - "NAME", "example.tld", - "CRDATE", "2000-06-01T00:02:00Z", - "EXDATE", "2002-06-01T00:02:00Z"), - DateTime.parse("2000-06-01T00:02:00.002Z")); + assertThatCommand("domain_create_wildcard.xml", ImmutableMap.of("HOSTNAME", "example.tld")) + .atTime("2000-06-01T00:02:00.002Z") + .hasResponse( + "domain_create_response.xml", + ImmutableMap.of( + "NAME", "example.tld", + "CRDATE", "2000-06-01T00:02:00Z", + "EXDATE", "2002-06-01T00:02:00Z")); // Create host ns1.example.bar.foo.tld - assertCommandAndResponse( - "host_create_with_ips.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.bar.foo.tld"), - "host_create_response.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.bar.foo.tld", "CRDATE", "2000-06-01T00:03:00Z"), - DateTime.parse("2000-06-01T00:03:00Z")); + assertThatCommand( + "host_create_with_ips.xml", ImmutableMap.of("HOSTNAME", "ns1.example.bar.foo.tld")) + .atTime("2000-06-01T00:03:00Z") + .hasResponse( + "host_create_response.xml", + ImmutableMap.of( + "HOSTNAME", "ns1.example.bar.foo.tld", "CRDATE", "2000-06-01T00:03:00Z")); // Create host ns1.example.foo.tld - assertCommandAndResponse( - "host_create_with_ips.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.foo.tld"), - "host_create_response.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.foo.tld", "CRDATE", "2000-06-01T00:04:00Z"), - DateTime.parse("2000-06-01T00:04:00Z")); + assertThatCommand( + "host_create_with_ips.xml", ImmutableMap.of("HOSTNAME", "ns1.example.foo.tld")) + .atTime("2000-06-01T00:04:00Z") + .hasResponse( + "host_create_response.xml", + ImmutableMap.of("HOSTNAME", "ns1.example.foo.tld", "CRDATE", "2000-06-01T00:04:00Z")); // Create host ns1.example.tld - assertCommandAndResponse( - "host_create_with_ips.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.tld"), - "host_create_response.xml", - ImmutableMap.of("HOSTNAME", "ns1.example.tld", "CRDATE", "2000-06-01T00:05:00Z"), - DateTime.parse("2000-06-01T00:05:00Z")); + assertThatCommand("host_create_with_ips.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld")) + .atTime("2000-06-01T00:05:00Z") + .hasResponse( + "host_create_response.xml", + ImmutableMap.of("HOSTNAME", "ns1.example.tld", "CRDATE", "2000-06-01T00:05:00Z")); DateTime timeAfterCreates = DateTime.parse("2000-06-01T00:06:00Z"); @@ -266,6 +246,6 @@ public class EppLifecycleHostTest extends EppTestCase { assertAboutHosts().that(exampleTldHost).hasSuperordinateDomain(Key.create(exampleTldDomain)); assertThat(exampleTldDomain.getSubordinateHosts()).containsExactly("ns1.example.tld"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); } } diff --git a/javatests/google/registry/flows/EppLifecycleLoginTest.java b/javatests/google/registry/flows/EppLifecycleLoginTest.java index 21e9b691b..ee5b3a378 100644 --- a/javatests/google/registry/flows/EppLifecycleLoginTest.java +++ b/javatests/google/registry/flows/EppLifecycleLoginTest.java @@ -34,14 +34,14 @@ public class EppLifecycleLoginTest extends EppTestCase { @Test public void testLoginAndLogout_recordsEppMetric() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() .hasCommandName("Login") .and() .hasStatus(SUCCESS); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLogoutSucceeds(); assertThat(getRecordedEppMetric()) .hasClientId("NewRegistrar") .and() diff --git a/javatests/google/registry/flows/EppLoggedOutTest.java b/javatests/google/registry/flows/EppLoggedOutTest.java index ca63d65bd..e3fd823fc 100644 --- a/javatests/google/registry/flows/EppLoggedOutTest.java +++ b/javatests/google/registry/flows/EppLoggedOutTest.java @@ -37,25 +37,19 @@ public class EppLoggedOutTest extends EppTestCase { @Test public void testHello() throws Exception { DateTime now = DateTime.now(UTC); - assertCommandAndResponse( - "hello.xml", - null, - "greeting.xml", - ImmutableMap.of("DATE", now.toString(dateTimeNoMillis())), - now); + assertThatCommand("hello.xml", null) + .atTime(now) + .hasResponse("greeting.xml", ImmutableMap.of("DATE", now.toString(dateTimeNoMillis()))); } @Test public void testSyntaxError() throws Exception { - 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")); + assertThatCommand("syntax_error.xml") + .hasResponse( + "response_error_no_cltrid.xml", + ImmutableMap.of( + "CODE", "2001", + "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'.")); } } diff --git a/javatests/google/registry/flows/EppLoginAdminUserTest.java b/javatests/google/registry/flows/EppLoginAdminUserTest.java index 3effe5a6a..76f21974f 100644 --- a/javatests/google/registry/flows/EppLoginAdminUserTest.java +++ b/javatests/google/registry/flows/EppLoginAdminUserTest.java @@ -42,23 +42,23 @@ public class EppLoginAdminUserTest extends EppTestCase { @Test public void testNonAuthedLogin_succeedsAsAdmin() throws Exception { // Login succeeds even though this user isn't listed on the registrar. - assertCommandAndResponse("login2_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("TheRegistrar", "password2"); } @Test public void testLoginLogout_wrongPasswordStillWorks() throws Exception { // For user-based logins the password in the epp xml is ignored. - assertCommandAndResponse("login_invalid_wrong_password.xml", "login_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "incorrect"); + assertThatLogoutSucceeds(); } @Test public void testNonAuthedMultiLogin_succeedsAsAdmin() throws Exception { // The admin can log in as different registrars. - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - 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.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatLogoutSucceeds(); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatLogoutSucceeds(); + assertThatLoginSucceeds("TheRegistrar", "password2"); } } diff --git a/javatests/google/registry/flows/EppLoginTlsTest.java b/javatests/google/registry/flows/EppLoginTlsTest.java index 5060a44bf..e2bbb06e1 100644 --- a/javatests/google/registry/flows/EppLoginTlsTest.java +++ b/javatests/google/registry/flows/EppLoginTlsTest.java @@ -62,67 +62,62 @@ public class EppLoginTlsTest extends EppTestCase { @Test public void testLoginLogout() throws Exception { setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatLogoutSucceeds(); } @Test public void testLogin_wrongPasswordFails() throws Exception { setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH); // For TLS login, we also check the epp xml password. - assertCommandAndResponse( - "login_invalid_wrong_password.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of("MSG", "Registrar password is incorrect", "CODE", "2200")); + assertThatLogin("NewRegistrar", "incorrect") + .hasResponse( + "response_error.xml", + ImmutableMap.of("CODE", "2200", "MSG", "Registrar password is incorrect")); } @Test public void testMultiLogin() throws Exception { setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); - assertCommandAndResponse( - "login2_valid.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of( - "MSG", "Registrar certificate does not match stored certificate", "CODE", "2200")); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatLogoutSucceeds(); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatLogoutSucceeds(); + assertThatLogin("TheRegistrar", "password2") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2200", "MSG", "Registrar certificate does not match stored certificate")); } @Test public void testNonAuthedLogin_fails() throws Exception { setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH); - assertCommandAndResponse( - "login2_valid.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of( - "MSG", "Registrar certificate does not match stored certificate", "CODE", "2200")); + assertThatLogin("TheRegistrar", "password2") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2200", "MSG", "Registrar certificate does not match stored certificate")); } @Test public void testBadCertificate_failsBadCertificate2200() throws Exception { setClientCertificateHash("laffo"); - assertCommandAndResponse( - "login_valid.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of( - "MSG", "Registrar certificate does not match stored certificate", "CODE", "2200")); + assertThatLogin("NewRegistrar", "foo-BAR2") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2200", "MSG", "Registrar certificate does not match stored certificate")); } @Test public void testGfeDidntProvideClientCertificate_failsMissingCertificate2200() throws Exception { setClientCertificateHash(""); - assertCommandAndResponse( - "login_valid.xml", - ImmutableMap.of(), - "response_error.xml", - ImmutableMap.of("MSG", "Registrar certificate not present", "CODE", "2200")); + assertThatLogin("NewRegistrar", "foo-BAR2") + .hasResponse( + "response_error.xml", + ImmutableMap.of("CODE", "2200", "MSG", "Registrar certificate not present")); } @Test @@ -135,7 +130,7 @@ public class EppLoginTlsTest extends EppTestCase { .setClientCertificate(CertificateSamples.SAMPLE_CERT, now) .setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, now) .build()); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); } @Test @@ -148,7 +143,7 @@ public class EppLoginTlsTest extends EppTestCase { .setClientCertificate(CertificateSamples.SAMPLE_CERT, now) .setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, now) .build()); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); } @Test @@ -161,7 +156,7 @@ public class EppLoginTlsTest extends EppTestCase { .setClientCertificate(null, now) .setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, now) .build()); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); } @Test @@ -174,6 +169,6 @@ public class EppLoginTlsTest extends EppTestCase { .setClientCertificate(null, now) .setFailoverClientCertificate(null, now) .build()); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); } } diff --git a/javatests/google/registry/flows/EppLoginUserTest.java b/javatests/google/registry/flows/EppLoginUserTest.java index 4af73294b..58e8c9363 100644 --- a/javatests/google/registry/flows/EppLoginUserTest.java +++ b/javatests/google/registry/flows/EppLoginUserTest.java @@ -37,7 +37,7 @@ public class EppLoginUserTest extends EppTestCase { @Rule public final AppEngineRule appEngine = AppEngineRule.builder() .withDatastore() - .withUserService(UserInfo.create("person@example.com", "12345")) + .withUserService(UserInfo.create("user@example.com", "12345")) .build(); @Before @@ -55,40 +55,38 @@ public class EppLoginUserTest extends EppTestCase { @Test public void testLoginLogout() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatLogoutSucceeds(); } @Test public void testNonAuthedLogin_fails() throws Exception { - 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")); + assertThatLogin("TheRegistrar", "password2") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2200", + "MSG", "User id is not allowed to login as requested registrar: user@example.com")); } @Test public void testMultiLogin() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.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")); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatLogoutSucceeds(); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatLogoutSucceeds(); + assertThatLogin("TheRegistrar", "password2") + .hasResponse( + "response_error.xml", + ImmutableMap.of( + "CODE", "2200", + "MSG", "User id is not allowed to login as requested registrar: user@example.com")); } @Test public void testLoginLogout_wrongPasswordStillWorks() throws Exception { // For user-based logins the password in the epp xml is ignored. - assertCommandAndResponse("login_invalid_wrong_password.xml", "login_response.xml"); - assertCommandAndResponse("logout.xml", "logout_response.xml"); + assertThatLoginSucceeds("NewRegistrar", "incorrect"); + assertThatLogoutSucceeds(); } } diff --git a/javatests/google/registry/flows/EppTestCase.java b/javatests/google/registry/flows/EppTestCase.java index 9429dd4a9..5e08d84ba 100644 --- a/javatests/google/registry/flows/EppTestCase.java +++ b/javatests/google/registry/flows/EppTestCase.java @@ -22,6 +22,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static javax.servlet.http.HttpServletResponse.SC_OK; import static org.joda.time.DateTimeZone.UTC; +import com.google.common.collect.ImmutableMap; import com.google.common.net.MediaType; import google.registry.flows.EppTestComponent.FakesAndMocksModule; import google.registry.model.ofy.Ofy; @@ -32,6 +33,7 @@ import google.registry.testing.FakeResponse; import google.registry.testing.InjectRule; import google.registry.testing.ShardableTestCase; import java.util.Map; +import javax.annotation.Nullable; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; @@ -72,30 +74,64 @@ public class EppTestCase extends ShardableTestCase { this.isSuperuser = isSuperuser; } - String assertCommandAndResponse(String inputFilename, String outputFilename) throws Exception { - return assertCommandAndResponse(inputFilename, null, outputFilename, null); + class CommandAsserter { + private final String inputFilename; + private @Nullable final Map inputSubstitutions; + private DateTime now; + + private CommandAsserter( + String inputFilename, @Nullable Map inputSubstitutions) { + this.inputFilename = inputFilename; + this.inputSubstitutions = inputSubstitutions; + this.now = DateTime.now(UTC); + } + + CommandAsserter atTime(DateTime now) { + this.now = now; + return this; + } + + CommandAsserter atTime(String now) { + return atTime(DateTime.parse(now)); + } + + String hasResponse(String outputFilename) throws Exception { + return hasResponse(outputFilename, null); + } + + String hasResponse(String outputFilename, @Nullable Map outputSubstitutions) + throws Exception { + return assertCommandAndResponse( + inputFilename, inputSubstitutions, outputFilename, outputSubstitutions, now); + } } - String assertCommandAndResponse(String inputFilename, String outputFilename, DateTime now) - throws Exception { - return assertCommandAndResponse(inputFilename, null, outputFilename, null, now); + CommandAsserter assertThatCommand(String inputFilename) { + return assertThatCommand(inputFilename, null); } - String assertCommandAndResponse( + CommandAsserter assertThatCommand( + String inputFilename, @Nullable Map inputSubstitutions) { + return new CommandAsserter(inputFilename, inputSubstitutions); + } + + CommandAsserter assertThatLogin(String clientId, String password) throws Exception { + return assertThatCommand("login.xml", ImmutableMap.of("CLID", clientId, "PW", password)); + } + + void assertThatLoginSucceeds(String clientId, String password) throws Exception { + assertThatLogin(clientId, password).hasResponse("login_response.xml"); + } + + void assertThatLogoutSucceeds() throws Exception { + assertThatCommand("logout.xml").hasResponse("logout_response.xml"); + } + + private String assertCommandAndResponse( String inputFilename, - Map inputSubstitutions, + @Nullable 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, + @Nullable Map outputSubstitutions, DateTime now) throws Exception { clock.setTo(now); diff --git a/javatests/google/registry/flows/EppXxeAttackTest.java b/javatests/google/registry/flows/EppXxeAttackTest.java index f46c5ca5b..7ec22f4ae 100644 --- a/javatests/google/registry/flows/EppXxeAttackTest.java +++ b/javatests/google/registry/flows/EppXxeAttackTest.java @@ -35,49 +35,40 @@ public class EppXxeAttackTest extends EppTestCase { @Test public void testRemoteXmlExternalEntity() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "contact_create_remote_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"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("contact_create_remote_xxe.xml") + .hasResponse( + "response_error_no_cltrid.xml", + ImmutableMap.of( + "CODE", "2001", + "MSG", "Syntax error at line 11, column 34: " + + "The entity "remote" was referenced, but not declared.")); + assertThatLogoutSucceeds(); } @Test public void testLocalXmlExtrernalEntity() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "contact_create_local_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"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("contact_create_local_xxe.xml") + .hasResponse( + "response_error_no_cltrid.xml", + ImmutableMap.of( + "CODE", "2001", + "MSG", "Syntax error at line 11, column 31: " + + "The entity "ent" was referenced, but not declared.")); + assertThatLogoutSucceeds(); } @Test public void testBillionLaughsAttack() throws Exception { - assertCommandAndResponse("login_valid.xml", "login_response.xml"); - assertCommandAndResponse( - "contact_create_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"); + assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); + assertThatCommand("contact_create_billion_laughs.xml") + .hasResponse( + "response_error_no_cltrid.xml", + ImmutableMap.of( + "CODE", "2001", + "MSG", "Syntax error at line 20, column 32: " + + "The entity "lol9" was referenced, but not declared.")); + assertThatLogoutSucceeds(); } } diff --git a/javatests/google/registry/flows/testdata/login_valid.xml b/javatests/google/registry/flows/testdata/login.xml similarity index 91% rename from javatests/google/registry/flows/testdata/login_valid.xml rename to javatests/google/registry/flows/testdata/login.xml index 9844b2f7a..00dd038af 100644 --- a/javatests/google/registry/flows/testdata/login_valid.xml +++ b/javatests/google/registry/flows/testdata/login.xml @@ -1,8 +1,8 @@ - NewRegistrar - foo-BAR2 + %CLID% + %PW% 1.0 en diff --git a/javatests/google/registry/flows/testdata/login2_valid.xml b/javatests/google/registry/flows/testdata/login2_valid.xml deleted file mode 100644 index 5e92979b4..000000000 --- a/javatests/google/registry/flows/testdata/login2_valid.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - TheRegistrar - password2 - - 1.0 - en - - - urn:ietf:params:xml:ns:host-1.0 - urn:ietf:params:xml:ns:domain-1.0 - urn:ietf:params:xml:ns:contact-1.0 - - urn:ietf:params:xml:ns:launch-1.0 - urn:ietf:params:xml:ns:rgp-1.0 - - - - ABC-12345 - - diff --git a/javatests/google/registry/flows/testdata/login_invalid_wrong_password.xml b/javatests/google/registry/flows/testdata/login_invalid_wrong_password.xml deleted file mode 100644 index bb95c0274..000000000 --- a/javatests/google/registry/flows/testdata/login_invalid_wrong_password.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - NewRegistrar - incorrect - - 1.0 - en - - - urn:ietf:params:xml:ns:host-1.0 - urn:ietf:params:xml:ns:domain-1.0 - urn:ietf:params:xml:ns:contact-1.0 - - urn:ietf:params:xml:ns:launch-1.0 - urn:ietf:params:xml:ns:rgp-1.0 - - - - ABC-12345 - - diff --git a/javatests/google/registry/testing/TestDataHelper.java b/javatests/google/registry/testing/TestDataHelper.java index 061802fe3..c7730bdc8 100644 --- a/javatests/google/registry/testing/TestDataHelper.java +++ b/javatests/google/registry/testing/TestDataHelper.java @@ -23,6 +23,7 @@ import com.google.common.io.ByteSource; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; +import javax.annotation.Nullable; /** Contains helper methods for dealing with test data. */ public final class TestDataHelper { @@ -56,7 +57,7 @@ public final class TestDataHelper { * context class, and substitutes in values for placeholders of the form %tagname%. */ public static String loadFile( - Class context, String filename, Map substitutions) { + Class context, String filename, @Nullable Map substitutions) { String fileContents = loadFile(context, filename); for (Entry entry : nullToEmpty(substitutions).entrySet()) { fileContents = fileContents.replaceAll("%" + entry.getKey() + "%", entry.getValue());