mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Add more EPP metric lifecycle tests
This also refactors some of the existing EPP XML testdata files to use a consistent wildcard naming scheme. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154569632
This commit is contained in:
parent
44546a3480
commit
876552f1ce
15 changed files with 200 additions and 56 deletions
|
@ -14,6 +14,12 @@
|
|||
|
||||
package google.registry.flows;
|
||||
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACK_MESSAGE;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_NO_MESSAGES;
|
||||
import static google.registry.testing.EppMetricSubject.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -41,11 +47,35 @@ public class EppLifecycleContactTest extends EppTestCase {
|
|||
"contact_create_response_sh8013.xml",
|
||||
ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"),
|
||||
DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.hasCommandName("ContactCreate")
|
||||
.and()
|
||||
.hasEppTarget("sh8013")
|
||||
.and()
|
||||
.hasStatus(SUCCESS);
|
||||
assertCommandAndResponse(
|
||||
"contact_info.xml",
|
||||
"contact_info_from_create_response.xml",
|
||||
DateTime.parse("2000-06-01T00:01:00Z"));
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.hasCommandName("ContactInfo")
|
||||
.and()
|
||||
.hasEppTarget("sh8013")
|
||||
.and()
|
||||
.hasStatus(SUCCESS);
|
||||
assertCommandAndResponse("contact_delete_sh8013.xml", "contact_delete_response_sh8013.xml");
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.hasCommandName("ContactDelete")
|
||||
.and()
|
||||
.hasEppTarget("sh8013")
|
||||
.and()
|
||||
.hasStatus(SUCCESS_WITH_ACTION_PENDING);
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
}
|
||||
|
||||
|
@ -74,12 +104,24 @@ public class EppLifecycleContactTest extends EppTestCase {
|
|||
"poll.xml",
|
||||
"poll_response_contact_transfer.xml",
|
||||
DateTime.parse("2000-06-08T22:01:00Z"));
|
||||
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"),
|
||||
"poll_ack_response_empty.xml",
|
||||
null,
|
||||
DateTime.parse("2000-06-08T22:02:00Z"));
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.hasCommandName("PollAck")
|
||||
.and()
|
||||
.hasStatus(SUCCESS_WITH_NO_MESSAGES);
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,11 +62,17 @@ public class EppLifecycleDomainApplicationTest extends EppTestCase {
|
|||
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_create2.xml",
|
||||
"host_create2_response.xml",
|
||||
"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));
|
||||
}
|
||||
|
||||
|
|
|
@ -62,9 +62,19 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
"contact_create_response_jd1234.xml",
|
||||
startTime.plusMinutes(1));
|
||||
assertCommandAndResponse(
|
||||
"host_create.xml", "host_create_response.xml", startTime.plusMinutes(2));
|
||||
"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_create2.xml", "host_create2_response.xml", startTime.plusMinutes(3));
|
||||
"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));
|
||||
}
|
||||
|
||||
/** Creates the domain fakesite.example with two nameservers on it. */
|
||||
|
@ -336,6 +346,14 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
"domain_check_fee_premium.xml",
|
||||
"domain_check_fee_premium_response.xml",
|
||||
gaDate.plusDays(1));
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.hasCommandName("DomainCheck")
|
||||
.and()
|
||||
.hasEppTarget("rich.example")
|
||||
.and()
|
||||
.hasStatus(SUCCESS);
|
||||
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
}
|
||||
|
@ -481,7 +499,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
"host_info_fakesite.xml",
|
||||
null,
|
||||
"host_info_response_fakesite_post_transfer.xml",
|
||||
ImmutableMap.of("trDate", "2002-06-04T00:00:00Z"),
|
||||
ImmutableMap.of("TRDATE", "2002-06-04T00:00:00Z"),
|
||||
DateTime.parse("2002-06-09T00:01:00Z"));
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
}
|
||||
|
@ -589,9 +607,9 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
// Verify that the lastTransferTime now reflects the superordinate domain's transfer.
|
||||
assertCommandAndResponse(
|
||||
"host_info.xml",
|
||||
ImmutableMap.of("hostname", "ns3.fakesite.example"),
|
||||
ImmutableMap.of("HOSTNAME", "ns3.fakesite.example"),
|
||||
"host_info_response_fakesite_post_transfer.xml",
|
||||
ImmutableMap.of("trDate", "2001-01-06T00:00:00.000Z"),
|
||||
ImmutableMap.of("TRDATE", "2001-01-06T00:00:00.000Z"),
|
||||
DateTime.parse("2001-01-07T00:00:00Z"));
|
||||
assertCommandAndResponse(
|
||||
"domain_create_secondsite.xml",
|
||||
|
@ -608,11 +626,11 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
// 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"),
|
||||
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"),
|
||||
"HOSTNAME", "ns3.secondsite.example",
|
||||
"TRDATE", "2001-01-06T00:00:00.000Z"),
|
||||
DateTime.parse("2003-01-07T00:00:00Z"));
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
}
|
||||
|
@ -644,7 +662,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
"host_info_fakesite.xml",
|
||||
null,
|
||||
"host_info_response_fakesite_post_transfer.xml",
|
||||
ImmutableMap.of("trDate", "2001-01-06T00:00:00.000Z"),
|
||||
ImmutableMap.of("TRDATE", "2001-01-06T00:00:00.000Z"),
|
||||
DateTime.parse("2001-01-07T00:00:00Z"));
|
||||
// Update the host to be external by renaming it to ns3.notarealsite.external
|
||||
assertCommandAndResponse(
|
||||
|
@ -658,11 +676,11 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
// 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"),
|
||||
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"),
|
||||
"HOSTNAME", "ns3.notarealsite.external",
|
||||
"TRDATE", "2001-01-06T00:00:00.000Z"),
|
||||
DateTime.parse("2001-01-07T00:00:00Z"));
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
}
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
|
||||
package google.registry.flows;
|
||||
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.EppMetricSubject.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
|
@ -34,6 +37,68 @@ public class EppLifecycleHostTest extends EppTestCase {
|
|||
.withTaskQueue()
|
||||
.build();
|
||||
|
||||
@Test
|
||||
public void testLifecycle() throws Exception {
|
||||
assertCommandAndResponse("login_valid.xml", "login_response.xml");
|
||||
assertCommandAndResponse(
|
||||
"hello.xml",
|
||||
ImmutableMap.<String, String>of(),
|
||||
"greeting.xml",
|
||||
ImmutableMap.of("DATE", "2000-06-02T00:00:00Z"),
|
||||
DateTime.parse("2000-06-02T00:00:00Z"));
|
||||
// Note that Hello commands don't set a status code on the response.
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.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"));
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.hasCommandName("HostCreate")
|
||||
.and()
|
||||
.hasEppTarget("ns1.example.tld")
|
||||
.and()
|
||||
.hasStatus(SUCCESS);
|
||||
assertCommandAndResponse(
|
||||
"host_info.xml",
|
||||
ImmutableMap.of("HOSTNAME", "ns1.example.tld"),
|
||||
"host_info_response.xml",
|
||||
ImmutableMap.<String, String>of(
|
||||
"HOSTNAME", "ns1.example.tld", "ROID", "1-ROID", "CRDATE", "2000-06-02T00:01:00Z"),
|
||||
DateTime.parse("2000-06-02T00:02:00Z"));
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.hasCommandName("HostInfo")
|
||||
.and()
|
||||
.hasEppTarget("ns1.example.tld")
|
||||
.and()
|
||||
.hasStatus(SUCCESS);
|
||||
assertCommandAndResponse(
|
||||
"host_delete.xml",
|
||||
ImmutableMap.of("HOSTNAME", "ns1.example.tld"),
|
||||
"generic_success_action_pending_response.xml",
|
||||
ImmutableMap.<String, String>of(),
|
||||
DateTime.parse("2000-06-02T00:03:00Z"));
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
.and()
|
||||
.hasCommandName("HostDelete")
|
||||
.and()
|
||||
.hasEppTarget("ns1.example.tld")
|
||||
.and()
|
||||
.hasStatus(SUCCESS_WITH_ACTION_PENDING);
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenamingHostToExistingHost_fails() throws Exception {
|
||||
createTld("example");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<command>
|
||||
<create>
|
||||
<host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>ns1.example.external</host:name>
|
||||
<host:name>%HOSTNAME%</host:name>
|
||||
</host:create>
|
||||
</create>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
<host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>ns2.example.external</host:name>
|
||||
</host:create>
|
||||
</create>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
|
@ -1,17 +0,0 @@
|
|||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<response>
|
||||
<result code="1000">
|
||||
<msg>Command completed successfully</msg>
|
||||
</result>
|
||||
<resData>
|
||||
<host:creData xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>ns2.example.external</host:name>
|
||||
<host:crDate>2000-06-01T00:03:00Z</host:crDate>
|
||||
</host:creData>
|
||||
</resData>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>54322-XYZ</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
|
@ -5,13 +5,13 @@
|
|||
</result>
|
||||
<resData>
|
||||
<host:creData xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>ns1.example.external</host:name>
|
||||
<host:crDate>2000-06-01T00:02:00Z</host:crDate>
|
||||
<host:name>%HOSTNAME%</host:name>
|
||||
<host:crDate>%CRDATE%</host:crDate>
|
||||
</host:creData>
|
||||
</resData>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>54322-XYZ</svTRID>
|
||||
<svTRID>server-trid</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
||||
|
|
11
javatests/google/registry/flows/testdata/host_delete.xml
vendored
Normal file
11
javatests/google/registry/flows/testdata/host_delete.xml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<delete>
|
||||
<host:delete
|
||||
xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>%HOSTNAME%</host:name>
|
||||
</host:delete>
|
||||
</delete>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
|
@ -2,7 +2,7 @@
|
|||
<command>
|
||||
<info>
|
||||
<host:info xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>%hostname%</host:name>
|
||||
<host:name>%HOSTNAME%</host:name>
|
||||
</host:info>
|
||||
</info>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
|
|
22
javatests/google/registry/flows/testdata/host_info_response.xml
vendored
Normal file
22
javatests/google/registry/flows/testdata/host_info_response.xml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<response>
|
||||
<result code="1000">
|
||||
<msg>Command completed successfully</msg>
|
||||
</result>
|
||||
<resData>
|
||||
<host:infData
|
||||
xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>%HOSTNAME%</host:name>
|
||||
<host:roid>%ROID%</host:roid>
|
||||
<host:status s="ok"/>
|
||||
<host:clID>NewRegistrar</host:clID>
|
||||
<host:crID>NewRegistrar</host:crID>
|
||||
<host:crDate>%CRDATE%</host:crDate>
|
||||
</host:infData>
|
||||
</resData>
|
||||
<trID>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
<svTRID>server-trid</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
|
@ -16,7 +16,7 @@
|
|||
<host:clID>TheRegistrar</host:clID>
|
||||
<host:crID>NewRegistrar</host:crID>
|
||||
<host:crDate>2000-06-06T00:01:00Z</host:crDate>
|
||||
<host:trDate>%trDate%</host:trDate>
|
||||
<host:trDate>%TRDATE%</host:trDate>
|
||||
</host:infData>
|
||||
</resData>
|
||||
<trID>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<resData>
|
||||
<host:infData
|
||||
xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>%hostname%</host:name>
|
||||
<host:name>%HOSTNAME%</host:name>
|
||||
<host:roid>NS1_EXAMPLE1-REP</host:roid>
|
||||
<host:status s="ok"/>
|
||||
<host:status s="linked"/>
|
||||
|
@ -18,7 +18,7 @@
|
|||
<host:crDate>2000-06-06T00:01:00Z</host:crDate>
|
||||
<host:upID>TheRegistrar</host:upID>
|
||||
<host:upDate>2002-05-30T01:01:00Z</host:upDate>
|
||||
<host:trDate>%trDate%</host:trDate>
|
||||
<host:trDate>%TRDATE%</host:trDate>
|
||||
</host:infData>
|
||||
</resData>
|
||||
<trID>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<resData>
|
||||
<host:infData
|
||||
xmlns:host="urn:ietf:params:xml:ns:host-1.0">
|
||||
<host:name>%hostname%</host:name>
|
||||
<host:name>%HOSTNAME%</host:name>
|
||||
<host:roid>NS1_EXAMPLE1-REP</host:roid>
|
||||
<host:status s="ok"/>
|
||||
<host:status s="linked"/>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<host:crDate>2000-06-06T00:01:00Z</host:crDate>
|
||||
<host:upID>TheRegistrar</host:upID>
|
||||
<host:upDate>2002-05-30T01:01:00Z</host:upDate>
|
||||
<host:trDate>%trDate%</host:trDate>
|
||||
<host:trDate>%TRDATE%</host:trDate>
|
||||
</host:infData>
|
||||
</resData>
|
||||
<trID>
|
||||
|
|
|
@ -54,6 +54,13 @@ public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
|||
return hasValue(status, actual().getStatus(), "has status");
|
||||
}
|
||||
|
||||
public And<EppMetricSubject> hasNoStatus() {
|
||||
if (actual().getStatus().isPresent()) {
|
||||
fail("has no status");
|
||||
}
|
||||
return new And<>(this);
|
||||
}
|
||||
|
||||
private <E> And<EppMetricSubject> hasValue(E expected, Optional<E> actual, String verb) {
|
||||
checkArgumentNotNull(expected, "Expected value cannot be null");
|
||||
if (actual == null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue