mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Make Hello flows use the flow "now" time
This cleans up some of the tests, and helps with future injection CLs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=124208164
This commit is contained in:
parent
81dc55ceab
commit
5a2f63cf58
7 changed files with 30 additions and 19 deletions
|
@ -22,6 +22,6 @@ import google.registry.model.eppoutput.Greeting;
|
|||
public class HelloFlow extends Flow {
|
||||
@Override
|
||||
public EppOutput run() {
|
||||
return EppOutput.create(new Greeting());
|
||||
return EppOutput.create(Greeting.create(now));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
package google.registry.model.eppoutput;
|
||||
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.eppcommon.PresenceMarker;
|
||||
import google.registry.model.eppcommon.ProtocolDefinition;
|
||||
|
@ -37,7 +35,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
|
|||
public class Greeting extends ImmutableObject implements ResponseOrGreeting {
|
||||
|
||||
String svID = "Charleston Road Registry";
|
||||
DateTime svDate = DateTime.now(UTC);
|
||||
DateTime svDate;
|
||||
|
||||
/** This is never changed, so it might as well be static for efficiency. */
|
||||
@XmlElement
|
||||
|
@ -47,6 +45,12 @@ public class Greeting extends ImmutableObject implements ResponseOrGreeting {
|
|||
@XmlElement
|
||||
static Dcp dcp = new Dcp();
|
||||
|
||||
public static Greeting create(DateTime svDate) {
|
||||
Greeting instance = new Greeting();
|
||||
instance.svDate = svDate;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static class SvcMenu extends ImmutableObject {
|
||||
String version = ProtocolDefinition.VERSION;
|
||||
String lang = ProtocolDefinition.LANGUAGE;
|
||||
|
|
|
@ -16,8 +16,6 @@ package google.registry.flows;
|
|||
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static google.registry.xml.XmlTestUtils.assertXmlEquals;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -27,6 +25,7 @@ import google.registry.model.registry.Registry.TldState;
|
|||
import google.registry.util.DateTimeUtils;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
@ -41,10 +40,13 @@ public abstract class EppServletXmlLoginTestCase<S extends HttpServlet> extends
|
|||
|
||||
@Test
|
||||
public void testHello() throws Exception {
|
||||
assertXmlEquals(
|
||||
readResourceUtf8(getClass(), "testdata/greeting_crr.xml"),
|
||||
expectXmlCommand(readResourceUtf8(getClass(), "testdata/hello.xml"), DateTime.now(UTC)),
|
||||
"epp.greeting.svDate");
|
||||
DateTime now = DateTime.now(UTC);
|
||||
assertCommandAndResponse(
|
||||
"hello.xml",
|
||||
null,
|
||||
"greeting_crr.xml",
|
||||
ImmutableMap.of("DATE", now.toString(ISODateTimeFormat.dateTimeNoMillis())),
|
||||
now);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -288,7 +288,9 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
CommitMode commitMode, UserPrivileges userPrivileges, String xml, String... ignoredPaths)
|
||||
throws Exception {
|
||||
EppOutput eppOutput = getFlowRunner().run(commitMode, userPrivileges);
|
||||
assertThat(eppOutput.isSuccess()).isTrue();
|
||||
if (eppOutput.isResponse()) {
|
||||
assertThat(eppOutput.isSuccess()).isTrue();
|
||||
}
|
||||
try {
|
||||
assertXmlEquals(
|
||||
xml, new String(marshal(eppOutput, ValidationMode.STRICT), UTF_8), ignoredPaths);
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
package google.registry.flows.session;
|
||||
|
||||
import static google.registry.flows.EppXmlTransformer.marshal;
|
||||
import static google.registry.xml.ValidationMode.STRICT;
|
||||
import static google.registry.xml.XmlTestUtils.assertXmlEquals;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
||||
import static org.joda.time.format.ISODateTimeFormat.dateTimeNoMillis;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import google.registry.flows.FlowTestCase;
|
||||
|
||||
|
@ -29,8 +29,11 @@ public class HelloFlowTest extends FlowTestCase<HelloFlow> {
|
|||
public void testHello() throws Exception {
|
||||
setEppInput("hello.xml");
|
||||
assertTransactionalFlow(false);
|
||||
assertXmlEquals(readFile("greeting_crr.xml"), new String(marshal(runFlow(), STRICT), UTF_8),
|
||||
"epp.greeting.svDate");
|
||||
runFlowAssertResponse(
|
||||
loadFileWithSubstitutions(
|
||||
getClass(),
|
||||
"greeting_crr.xml",
|
||||
ImmutableMap.of("DATE", clock.nowUtc().toString(dateTimeNoMillis()))));
|
||||
}
|
||||
|
||||
// Extra methods so the test runner doesn't produce empty shards.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<greeting>
|
||||
<svID>Charleston Road Registry</svID>
|
||||
<svDate>2000-06-08T22:00:00.0Z</svDate>
|
||||
<svDate>%DATE%</svDate>
|
||||
<svcMenu>
|
||||
<version>1.0</version>
|
||||
<lang>en</lang>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<greeting>
|
||||
<svID>Charleston Road Registry</svID>
|
||||
<svDate>2000-06-08T22:00:00.0Z</svDate>
|
||||
<svDate>%DATE%</svDate>
|
||||
<svcMenu>
|
||||
<version>1.0</version>
|
||||
<lang>en</lang>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue