Consolidate some domain creation / deletion EPPs in testdata

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183847223
This commit is contained in:
guyben 2018-01-30 09:58:48 -08:00 committed by Ben McIlwain
parent 169fd62da7
commit 4b23523d74
32 changed files with 266 additions and 316 deletions

View file

@ -24,6 +24,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC;
import static org.joda.time.Duration.standardDays;
import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key;
import google.registry.flows.EppTestComponent.FakesAndMocksModule;
import google.registry.model.domain.DomainResource;
@ -125,7 +126,7 @@ public class EppCommitLogsTest extends ShardableTestCase {
clock.advanceBy(standardDays(2));
DateTime timeAtDelete = clock.nowUtc(); // before 'add' grace period ends
eppLoader = new EppLoader(this, "domain_delete.xml");
eppLoader = new EppLoader(this, "domain_delete.xml", ImmutableMap.of("NAME", "example.tld"));
runFlow();
ofy().clearSessionCache();

View file

@ -43,7 +43,7 @@ public class EppLifecycleContactTest extends EppTestCase {
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertCommandAndResponse(
"contact_create_sh8013.xml",
null,
ImmutableMap.of(),
"contact_create_response_sh8013.xml",
ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"),
DateTime.parse("2000-06-01T00:00:00Z"));
@ -116,7 +116,7 @@ public class EppLifecycleContactTest extends EppTestCase {
"poll_ack.xml",
ImmutableMap.of("ID", "2-1-ROID-3-6-2000"),
"poll_ack_response_empty.xml",
null,
ImmutableMap.of(),
DateTime.parse("2000-06-08T22:02:00Z"));
assertThat(getRecordedEppMetric())
.hasClientId("NewRegistrar")

View file

@ -87,7 +87,11 @@ public class EppLifecycleDomainApplicationTest extends EppTestCase {
DateTime.parse("2014-01-01T00:00:00Z"));
assertCommandAndResponse(
"domain_info_testvalidate.xml",
"domain_info_response_testvalidate_doesnt_exist.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "The domain with given ID (test-validate.example) doesn't exist.",
"CODE", "2303"),
DateTime.parse("2014-01-01T00:01:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
}
@ -102,11 +106,17 @@ public class EppLifecycleDomainApplicationTest extends EppTestCase {
DateTime.parse("2014-01-01T00:00:00Z"));
assertCommandAndResponse(
"domain_info_testvalidate.xml",
"domain_info_response_testvalidate_doesnt_exist.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "The domain with given ID (test-validate.example) doesn't exist.",
"CODE", "2303"),
DateTime.parse("2014-01-01T00:01:00Z"));
assertCommandAndResponse(
"domain_allocate_testvalidate.xml",
"domain_allocate_response_testvalidate_only_superuser.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of("MSG", "Only a superuser can allocate domains", "CODE", "2201"),
START_OF_GA.plusDays(1));
setIsSuperuser(true);
assertCommandAndResponse(

View file

@ -108,7 +108,12 @@ public class EppLifecycleDomainTest extends EppTestCase {
createContactsAndHosts();
assertCommandAndResponse(
"domain_create_fakesite.xml",
"domain_create_response_fakesite.xml",
ImmutableMap.of(),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "fakesite.example",
"CRDATE", "2000-06-01T00:04:00.0Z",
"EXDATE", "2002-06-01T00:04:00.0Z"),
DateTime.parse("2000-06-01T00:04:00Z"));
assertCommandAndResponse(
"domain_info_fakesite.xml",
@ -148,13 +153,18 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Create domain example.tld
assertCommandAndResponse(
"domain_create_no_hosts_or_dsdata.xml",
ImmutableMap.of(),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
// Delete domain example.tld after its add grace period has expired.
assertCommandAndResponse(
"domain_delete.xml",
"generic_success_action_pending_response.xml",
"domain_delete.xml", ImmutableMap.of("NAME", "example.tld"),
"generic_success_action_pending_response.xml", ImmutableMap.of(),
DateTime.parse("2000-07-01T00:02:00Z"));
// Restore the domain.
@ -175,7 +185,12 @@ public class EppLifecycleDomainTest extends EppTestCase {
DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z");
assertCommandAndResponse(
"domain_create_no_hosts_or_dsdata.xml",
ImmutableMap.of(),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
createTime);
DomainResource domain =
@ -184,14 +199,17 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Delete domain example.tld within the add grace period.
DateTime deleteTime = createTime.plusDays(1);
assertCommandAndResponse(
"domain_delete.xml",
"generic_success_response.xml",
"domain_delete.xml", ImmutableMap.of("NAME", "example.tld"),
"generic_success_response.xml", ImmutableMap.of(),
deleteTime);
// Verify that it is immediately non-existent.
assertCommandAndResponse(
"domain_info.xml",
"domain_info_response_nonexistent.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "The domain with given ID (example.tld) doesn't exist.", "CODE", "2303"),
deleteTime.plusSeconds(1));
// The expected one-time billing event, that should have an associated Cancellation.
@ -218,14 +236,19 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Create domain example.tld
assertCommandAndResponse(
"domain_create_no_hosts_or_dsdata.xml",
ImmutableMap.of(),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
createTime);
DateTime deleteTime = DateTime.parse("2000-07-07T00:02:00Z"); // 1 month and 6 days after
// Delete domain example.tld after its add grace period has expired.
assertCommandAndResponse(
"domain_delete.xml",
"generic_success_action_pending_response.xml",
"domain_delete.xml", ImmutableMap.of("NAME", "example.tld"),
"generic_success_action_pending_response.xml", ImmutableMap.of(),
deleteTime);
// Verify that domain shows redemptionPeriod soon after deletion.
@ -247,7 +270,10 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Verify that the domain is non-existent (available for registration) later.
assertCommandAndResponse(
"domain_info.xml",
"domain_info_response_nonexistent.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "The domain with given ID (example.tld) doesn't exist.", "CODE", "2303"),
DateTime.parse("2000-09-01T00:00:00Z"));
DomainResource domain =
@ -292,8 +318,8 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Delete domain example.tld within the add grade period.
DateTime deleteTime = createTime.plusDays(1);
assertCommandAndResponse(
"domain_delete.xml",
"domain_delete_response_fee.xml",
"domain_delete.xml", ImmutableMap.of("NAME", "example.tld"),
"domain_delete_response_fee.xml", ImmutableMap.of(),
deleteTime);
// Verify that the OneTime billing event associated with the base fee of domain registration and
@ -404,8 +430,10 @@ public class EppLifecycleDomainTest extends EppTestCase {
createFakesite();
createSubordinateHost();
assertCommandAndResponse(
"domain_delete_fakesite.xml",
"domain_delete_response_prohibited.xml",
"domain_delete.xml",
ImmutableMap.of("NAME", "fakesite.example"),
"response_error.xml",
ImmutableMap.of("MSG", "Domain to be deleted has subordinate hosts", "CODE", "2305"),
DateTime.parse("2002-05-30T01:01:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
}
@ -439,8 +467,8 @@ public class EppLifecycleDomainTest extends EppTestCase {
.hasStatus(SUCCESS);
// Delete the fakesite.example domain (which should succeed since it no longer has subords).
assertCommandAndResponse(
"domain_delete_fakesite.xml",
"generic_success_action_pending_response.xml",
"domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example"),
"generic_success_action_pending_response.xml", ImmutableMap.of(),
DateTime.parse("2002-05-30T01:02:00Z"));
assertThat(getRecordedEppMetric())
.hasClientId("NewRegistrar")
@ -482,7 +510,12 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Create domain example.tld
assertCommandAndResponse(
"domain_create_no_hosts_or_dsdata.xml",
"domain_create_response_superordinate.xml",
ImmutableMap.of(),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.tld",
"CRDATE", "2000-06-02T00:00:00.0Z",
"EXDATE", "2002-06-02T00:00:00.0Z"),
DateTime.parse("2000-06-02T00:00:00Z"));
// Create nameserver ns1.example.tld
@ -499,8 +532,10 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Attempt to delete the fakesite.example domain (which should fail since it now has a
// subordinate host).
assertCommandAndResponse(
"domain_delete_fakesite.xml",
"domain_delete_response_prohibited.xml",
"domain_delete.xml",
ImmutableMap.of("NAME", "fakesite.example"),
"response_error.xml",
ImmutableMap.of("MSG", "Domain to be deleted has subordinate hosts", "CODE", "2305"),
DateTime.parse("2002-05-30T01:02:00Z"));
// Check info on the renamed host and verify that it's still around and wasn't deleted.
assertCommandAndResponse(
@ -534,12 +569,19 @@ public class EppLifecycleDomainTest extends EppTestCase {
assertCommandAndResponse(
"domain_create_sunrise_encoded_mark.xml",
"domain_create_testvalidate_invalid_phase.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "Command is not allowed in the current registry phase", "CODE", "2002"),
sunriseDate.minusDays(1));
assertCommandAndResponse(
"domain_info_testvalidate.xml",
"domain_info_response_testvalidate_doesnt_exist.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "The domain with given ID (test-validate.example) doesn't exist.",
"CODE", "2303"),
sunriseDate.plusDays(1));
assertCommandAndResponse("logout.xml", "logout_response.xml");
@ -598,7 +640,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
"poll_ack.xml",
ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2002"),
"poll_ack_response_empty.xml",
null,
ImmutableMap.of(),
DateTime.parse("2002-07-01T00:02:00Z"));
// The second autorenew poll message isn't seen until after another year, and it should have a
@ -621,7 +663,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
"poll_ack.xml",
ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2003"),
"poll_ack_response_empty.xml",
null,
ImmutableMap.of(),
DateTime.parse("2003-07-01T00:05:05Z"));
assertCommandAndResponse(
"poll.xml", "poll_response_empty.xml", DateTime.parse("2003-07-01T00:05:10Z"));
@ -658,7 +700,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
"poll_ack.xml",
ImmutableMap.of("ID", "1-C-EXAMPLE-17-23-2001"),
"poll_ack_response_empty.xml",
null,
ImmutableMap.of(),
DateTime.parse("2001-01-01T00:01:00Z"));
// Five days in the future, expect a server approval poll message to the loser, and ack it.
@ -670,7 +712,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
"poll_ack.xml",
ImmutableMap.of("ID", "1-C-EXAMPLE-17-22-2001"),
"poll_ack_response_empty.xml",
null,
ImmutableMap.of(),
DateTime.parse("2001-01-06T00:01:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
@ -678,7 +720,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
assertCommandAndResponse("login2_valid.xml", "login_response.xml");
assertCommandAndResponse(
"poll.xml",
null,
ImmutableMap.of(),
"poll_response_domain_transfer_server_approve_winner.xml",
ImmutableMap.of("SERVER_TRID", transferRequestTrid),
DateTime.parse("2001-01-06T00:02:00Z"));
@ -686,7 +728,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
"poll_ack.xml",
ImmutableMap.of("ID", "1-C-EXAMPLE-17-21-2001"),
"poll_ack_response_empty.xml",
null,
ImmutableMap.of(),
DateTime.parse("2001-01-06T00:02:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
}
@ -768,7 +810,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Verify that host's client ID was set to the new registrar and has the transfer date set.
assertCommandAndResponse(
"host_info_fakesite.xml",
null,
ImmutableMap.of(),
"host_info_response_fakesite_post_transfer.xml",
ImmutableMap.of("TRDATE", "2002-06-04T00:00:00Z"),
DateTime.parse("2002-06-09T00:01:00Z"));
@ -798,8 +840,8 @@ public class EppLifecycleDomainTest extends EppTestCase {
"domain_info_response_fakesite_pending_transfer.xml",
DateTime.parse("2002-05-30T01:00:00Z"));
assertCommandAndResponse(
"domain_delete_fakesite.xml",
"generic_success_action_pending_response.xml",
"domain_delete.xml", ImmutableMap.of("NAME", "fakesite.example"),
"generic_success_action_pending_response.xml", ImmutableMap.of(),
DateTime.parse("2002-05-30T01:01:00Z"));
assertCommandAndResponse(
"domain_info_fakesite.xml",
@ -826,7 +868,9 @@ public class EppLifecycleDomainTest extends EppTestCase {
createSubordinateHost();
assertCommandAndResponse(
"domain_transfer_query_fakesite.xml",
"domain_transfer_query_response_no_transfer_history.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of("MSG", "Object has no transfer history", "CODE", "2002"),
DateTime.parse("2000-09-02T00:00:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
@ -866,7 +910,9 @@ public class EppLifecycleDomainTest extends EppTestCase {
createSubordinateHost();
assertCommandAndResponse(
"domain_transfer_query_fakesite.xml",
"domain_transfer_query_response_no_transfer_history.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of("MSG", "Object has no transfer history", "CODE", "2002"),
DateTime.parse("2000-09-02T00:00:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
// Request a transfer of the domain to the second registrar.
@ -884,7 +930,12 @@ public class EppLifecycleDomainTest extends EppTestCase {
DateTime.parse("2001-01-07T00:00:00Z"));
assertCommandAndResponse(
"domain_create_secondsite.xml",
"domain_create_response_secondsite.xml",
ImmutableMap.of(),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "secondsite.example",
"CRDATE", "2001-01-08T00:00:00.0Z",
"EXDATE", "2003-01-08T00:00:00.0Z"),
DateTime.parse("2001-01-08T00:00:00Z"));
// Update the host to be subordinate to a different domain by renaming it to
// ns3.secondsite.example
@ -892,7 +943,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
"host_update_rename_only.xml",
ImmutableMap.of("oldName", "ns3.fakesite.example", "newName", "ns3.secondsite.example"),
"generic_success_response.xml",
null,
ImmutableMap.of(),
DateTime.parse("2002-05-30T01:01:00Z"));
// The last transfer time on the host should still be what it was from the transfer.
assertCommandAndResponse(
@ -919,7 +970,9 @@ public class EppLifecycleDomainTest extends EppTestCase {
createSubordinateHost();
assertCommandAndResponse(
"domain_transfer_query_fakesite.xml",
"domain_transfer_query_response_no_transfer_history.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of("MSG", "Object has no transfer history", "CODE", "2002"),
DateTime.parse("2000-09-02T00:00:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
// Request a transfer of the domain to the second registrar.
@ -931,7 +984,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
// Verify that the lastTransferTime now reflects the superordinate domain's transfer.
assertCommandAndResponse(
"host_info_fakesite.xml",
null,
ImmutableMap.of(),
"host_info_response_fakesite_post_transfer.xml",
ImmutableMap.of("TRDATE", "2001-01-06T00:00:00.000Z"),
DateTime.parse("2001-01-07T00:00:00Z"));
@ -942,7 +995,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
"oldName", "ns3.fakesite.example",
"newName", "ns3.notarealsite.external"),
"generic_success_response.xml",
null,
ImmutableMap.of(),
DateTime.parse("2002-05-30T01:01:00Z"));
// The last transfer time on the host should still be what it was from the transfer.
assertCommandAndResponse(
@ -967,24 +1020,33 @@ public class EppLifecycleDomainTest extends EppTestCase {
assertCommandAndResponse(
"domain_create_wildcard.xml",
ImmutableMap.of("HOSTNAME", "example.bar.foo.tld"),
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.bar.foo.tld"),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.bar.foo.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
// Create domain example.foo.tld
assertCommandAndResponse(
"domain_create_wildcard.xml",
ImmutableMap.of("HOSTNAME", "example.foo.tld"),
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.foo.tld"),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.foo.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
// Create domain example.tld
assertCommandAndResponse(
"domain_create_wildcard.xml",
ImmutableMap.of("HOSTNAME", "example.tld"),
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.tld"),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
@ -1001,16 +1063,22 @@ public class EppLifecycleDomainTest extends EppTestCase {
assertCommandAndResponse(
"domain_create_wildcard.xml",
ImmutableMap.of("HOSTNAME", "example.tld.foo"),
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.tld.foo"),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.tld.foo",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
// Create domain example.tld
assertCommandAndResponse(
"domain_create_wildcard.xml",
ImmutableMap.of("HOSTNAME", "example.tld"),
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.tld"),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");

View file

@ -123,7 +123,12 @@ public class EppLifecycleHostTest extends EppTestCase {
DateTime.parse("2000-06-01T00:01:00Z"));
assertCommandAndResponse(
"domain_create_fakesite_no_nameservers.xml",
"domain_create_response_fakesite.xml",
ImmutableMap.of(),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "fakesite.example",
"CRDATE", "2000-06-01T00:04:00.0Z",
"EXDATE", "2002-06-01T00:04:00.0Z"),
DateTime.parse("2000-06-01T00:04:00Z"));
assertCommandAndResponse(
"domain_info_fakesite.xml",
@ -142,7 +147,10 @@ public class EppLifecycleHostTest extends EppTestCase {
// Attempt overwriting of 2nd fakesite subordinate host with the 1st.
assertCommandAndResponse(
"host_update_fakesite1_to_fakesite2.xml",
"host_update_failed_response.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "Object with given ID (ns4.fakesite.example) already exists", "CODE", "2302"),
DateTime.parse("2000-06-10T00:01:00Z"));
// Verify that fakesite hosts still exist in their unmodified states.
assertCommandAndResponse(
@ -177,24 +185,33 @@ public class EppLifecycleHostTest extends EppTestCase {
assertCommandAndResponse(
"domain_create_wildcard.xml",
ImmutableMap.of("HOSTNAME", "example.bar.foo.tld"),
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.bar.foo.tld"),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.bar.foo.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
// Create domain example.foo.tld
assertCommandAndResponse(
"domain_create_wildcard.xml",
ImmutableMap.of("HOSTNAME", "example.foo.tld"),
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.foo.tld"),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.foo.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
// Create domain example.tld
assertCommandAndResponse(
"domain_create_wildcard.xml",
ImmutableMap.of("HOSTNAME", "example.tld"),
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.tld"),
"domain_create_response.xml",
ImmutableMap.of(
"NAME", "example.tld",
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"),
DateTime.parse("2000-06-01T00:02:00Z"));
// Create host ns1.example.bar.foo.tld

View file

@ -47,6 +47,15 @@ public class EppLoggedOutTest extends EppTestCase {
@Test
public void testSyntaxError() throws Exception {
assertCommandAndResponse("syntax_error.xml", "syntax_error_response.xml");
assertCommandAndResponse(
"syntax_error.xml",
ImmutableMap.of(),
"response_error_no_cltrid.xml",
ImmutableMap.of(
"MSG",
"Syntax error at line 4, column 65: cvc-complex-type.3.2.2: "
+ "Attribute 'xsi:schemaLocation' is not allowed to appear in element 'epp'.",
"CODE",
"2001"));
}
}

View file

@ -18,6 +18,7 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableMap;
import google.registry.testing.AppEngineRule;
import google.registry.testing.CertificateSamples;
import java.util.Optional;
@ -70,7 +71,10 @@ public class EppLoginTlsTest extends EppTestCase {
setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH);
// For TLS login, we also check the epp xml password.
assertCommandAndResponse(
"login_invalid_wrong_password.xml", "login_response_wrong_password.xml");
"login_invalid_wrong_password.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of("MSG", "Registrar password is incorrect", "CODE", "2200"));
}
@Test
@ -80,26 +84,45 @@ public class EppLoginTlsTest extends EppTestCase {
assertCommandAndResponse("logout.xml", "logout_response.xml");
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertCommandAndResponse("logout.xml", "logout_response.xml");
assertCommandAndResponse("login2_valid.xml", "login_response_bad_certificate.xml");
assertCommandAndResponse(
"login2_valid.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "Registrar certificate does not match stored certificate", "CODE", "2200"));
}
@Test
public void testNonAuthedLogin_fails() throws Exception {
setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH);
assertCommandAndResponse("login2_valid.xml", "login_response_bad_certificate.xml");
assertCommandAndResponse(
"login2_valid.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "Registrar certificate does not match stored certificate", "CODE", "2200"));
}
@Test
public void testBadCertificate_failsBadCertificate2200() throws Exception {
setClientCertificateHash("laffo");
assertCommandAndResponse("login_valid.xml", "login_response_bad_certificate.xml");
assertCommandAndResponse(
"login_valid.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "Registrar certificate does not match stored certificate", "CODE", "2200"));
}
@Test
public void testGfeDidntProvideClientCertificate_failsMissingCertificate2200() throws Exception {
setClientCertificateHash("");
assertCommandAndResponse("login_valid.xml", "login_response_missing_certificate.xml");
assertCommandAndResponse(
"login_valid.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of("MSG", "Registrar certificate not present", "CODE", "2200"));
}
@Test

View file

@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import com.google.appengine.api.users.User;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import google.registry.model.registrar.RegistrarContact;
import google.registry.testing.AppEngineRule;
@ -60,7 +61,13 @@ public class EppLoginUserTest extends EppTestCase {
@Test
public void testNonAuthedLogin_fails() throws Exception {
assertCommandAndResponse("login2_valid.xml", "login_response_unauthorized_role.xml");
assertCommandAndResponse(
"login2_valid.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "User id is not allowed to login as requested registrar: person@example.com",
"CODE", "2200"));
}
@Test
@ -69,7 +76,13 @@ public class EppLoginUserTest extends EppTestCase {
assertCommandAndResponse("logout.xml", "logout_response.xml");
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertCommandAndResponse("logout.xml", "logout_response.xml");
assertCommandAndResponse("login2_valid.xml", "login_response_unauthorized_role.xml");
assertCommandAndResponse(
"login2_valid.xml",
ImmutableMap.of(),
"response_error.xml",
ImmutableMap.of(
"MSG", "User id is not allowed to login as requested registrar: person@example.com",
"CODE", "2200"));
}
@Test

View file

@ -73,7 +73,7 @@ public class EppTestCase extends ShardableTestCase {
}
String assertCommandAndResponse(String inputFilename, String outputFilename) throws Exception {
return assertCommandAndResponse(inputFilename, outputFilename, DateTime.now(UTC));
return assertCommandAndResponse(inputFilename, null, outputFilename, null);
}
String assertCommandAndResponse(String inputFilename, String outputFilename, DateTime now)
@ -81,23 +81,36 @@ public class EppTestCase extends ShardableTestCase {
return assertCommandAndResponse(inputFilename, null, outputFilename, null, now);
}
String assertCommandAndResponse(
String inputFilename,
Map<String, String> inputSubstitutions,
String outputFilename,
Map<String, String> outputSubstitutions)
throws Exception {
return assertCommandAndResponse(
inputFilename, inputSubstitutions, outputFilename, outputSubstitutions, DateTime.now(UTC));
}
String assertCommandAndResponse(
String inputFilename,
Map<String, String> inputSubstitutions,
String outputFilename,
Map<String, String> outputSubstitutions,
DateTime now) throws Exception {
DateTime now)
throws Exception {
clock.setTo(now);
String input = loadFile(getClass(), inputFilename, inputSubstitutions);
String expectedOutput = loadFile(getClass(), outputFilename, outputSubstitutions);
if (sessionMetadata == null) {
sessionMetadata = new HttpSessionMetadata(new FakeHttpSession()) {
@Override
public void invalidate() {
// When a session is invalidated, reset the sessionMetadata field.
super.invalidate();
EppTestCase.this.sessionMetadata = null;
}};
sessionMetadata =
new HttpSessionMetadata(new FakeHttpSession()) {
@Override
public void invalidate() {
// When a session is invalidated, reset the sessionMetadata field.
super.invalidate();
EppTestCase.this.sessionMetadata = null;
}
};
}
String actualOutput = executeXmlCommand(input);
assertXmlEqualsWithMessage(
@ -106,7 +119,7 @@ public class EppTestCase extends ShardableTestCase {
"Running " + inputFilename + " => " + outputFilename,
"epp.response.resData.infData.roid",
"epp.response.trID.svTRID");
ofy().clearSessionCache(); // Clear the cache like OfyFilter would.
ofy().clearSessionCache(); // Clear the cache like OfyFilter would.
return actualOutput;
}

View file

@ -14,6 +14,7 @@
package google.registry.flows;
import com.google.common.collect.ImmutableMap;
import google.registry.testing.AppEngineRule;
import org.junit.Rule;
import org.junit.Test;
@ -37,7 +38,14 @@ public class EppXxeAttackTest extends EppTestCase {
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertCommandAndResponse(
"contact_create_remote_xxe.xml",
"contact_create_remote_response_xxe.xml");
ImmutableMap.of(),
"response_error_no_cltrid.xml",
ImmutableMap.of(
"MSG",
"Syntax error at line 11, column 34: "
+ "The entity &quot;remote&quot; was referenced, but not declared.",
"CODE",
"2001"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
}
@ -46,7 +54,14 @@ public class EppXxeAttackTest extends EppTestCase {
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertCommandAndResponse(
"contact_create_local_xxe.xml",
"contact_create_local_response_xxe.xml");
ImmutableMap.of(),
"response_error_no_cltrid.xml",
ImmutableMap.of(
"MSG",
"Syntax error at line 11, column 31: "
+ "The entity &quot;ent&quot; was referenced, but not declared.",
"CODE",
"2001"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
}
@ -55,7 +70,14 @@ public class EppXxeAttackTest extends EppTestCase {
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertCommandAndResponse(
"contact_create_billion_laughs.xml",
"contact_create_response_billion_laughs.xml");
ImmutableMap.of(),
"response_error_no_cltrid.xml",
ImmutableMap.of(
"MSG",
"Syntax error at line 20, column 32: "
+ "The entity &quot;lol9&quot; was referenced, but not declared.",
"CODE",
"2001"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
}
}

View file

@ -1,10 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2001">
<msg>Syntax error at line 11, column 31: The entity &quot;ent&quot; was referenced, but not declared.</msg>
</result>
<trID>
<svTRID>DkRx3F6iQAmx4nS1xOgYZw==-8</svTRID>
</trID>
</response>
</epp>

View file

@ -1,10 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2001">
<msg>Syntax error at line 11, column 34: The entity &quot;remote&quot; was referenced, but not declared.</msg>
</result>
<trID>
<svTRID>DkRx3F6iQAmx4nS1xOgYZw==-8</svTRID>
</trID>
</response>
</epp>

View file

@ -1,10 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2001">
<msg>Syntax error at line 20, column 32: The entity &quot;lol9&quot; was referenced, but not declared.</msg>
</result>
<trID>
<svTRID>HmioO3vzQN+XVIUfZJxHeQ==-11</svTRID>
</trID>
</response>
</epp>

View file

@ -1,11 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2201">
<msg>Only a superuser can allocate domains</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -6,9 +6,9 @@
<resData>
<domain:creData
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:crDate>2000-06-01T00:02:00.0Z</domain:crDate>
<domain:exDate>2002-06-01T00:02:00.0Z</domain:exDate>
<domain:name>%NAME%</domain:name>
<domain:crDate>%CRDATE%</domain:crDate>
<domain:exDate>%EXDATE%</domain:exDate>
</domain:creData>
</resData>
<trID>

View file

@ -1,18 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="1000">
<msg>Command completed successfully</msg>
</result>
<resData>
<domain:creData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>fakesite.example</domain:name>
<domain:crDate>2000-06-01T00:04:00.0Z</domain:crDate>
<domain:exDate>2002-06-01T00:04:00.0Z</domain:exDate>
</domain:creData>
</resData>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,18 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="1000">
<msg>Command completed successfully</msg>
</result>
<resData>
<domain:creData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>secondsite.example</domain:name>
<domain:crDate>2001-01-08T00:00:00.0Z</domain:crDate>
<domain:exDate>2003-01-08T00:00:00.0Z</domain:exDate>
</domain:creData>
</resData>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,19 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="1000">
<msg>Command completed successfully</msg>
</result>
<resData>
<domain:creData
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:crDate>2000-06-02T00:00:00.0Z</domain:crDate>
<domain:exDate>2002-06-02T00:00:00.0Z</domain:exDate>
</domain:creData>
</resData>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,19 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="1000">
<msg>Command completed successfully</msg>
</result>
<resData>
<domain:creData
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>%DOMAIN%</domain:name>
<domain:crDate>2000-06-01T00:02:00.0Z</domain:crDate>
<domain:exDate>2002-06-01T00:02:00.0Z</domain:exDate>
</domain:creData>
</resData>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,11 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2002">
<msg>Command is not allowed in the current registry phase</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,9 +1,8 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<delete>
<domain:delete
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:delete xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>%NAME%</domain:name>
</domain:delete>
</delete>
<clTRID>ABC-12345</clTRID>

View file

@ -1,10 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<delete>
<domain:delete xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>fakesite.example</domain:name>
</domain:delete>
</delete>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,11 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2305">
<msg>Domain to be deleted has subordinate hosts</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,12 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<response>
<result code="2303">
<msg>The domain with given ID (example.tld) doesn't exist.</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,11 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2303">
<msg>The domain with given ID (test-validate.example) doesn't exist.</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,11 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2302">
<msg>Object with given ID (ns4.fakesite.example) already exists</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,11 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2200">
<msg>Registrar certificate does not match stored certificate</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,11 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2200">
<msg>Registrar certificate not present</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>

View file

@ -1,11 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2200">
<msg>User id is not allowed to login as requested registrar: person@example.com</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>Mt2PuhrJTKO1nM/MbHxT4g==-2a</svTRID>
</trID>
</response>
</epp>

View file

@ -1,7 +1,7 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2002">
<msg>Object has no transfer history</msg>
<result code="%CODE%">
<msg>%MSG%</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>

View file

@ -1,10 +1,9 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2200">
<msg>Registrar password is incorrect</msg>
<result code="%CODE%">
<msg>%MSG%</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>

View file

@ -1,10 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:host="urn:ietf:params:xml:ns:host-1.0" xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1" xmlns:launch="urn:ietf:params:xml:ns:launch-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<response>
<result 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'.</msg>
</result>
<trID>
<svTRID>ABC-12345</svTRID>
</trID>
</response>
</epp>