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:
Corey Goldfeder 2016-06-06 20:41:37 -07:00 committed by Justine Tunney
parent 81dc55ceab
commit 5a2f63cf58
7 changed files with 30 additions and 19 deletions

View file

@ -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

View file

@ -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);

View file

@ -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.

View file

@ -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>

View file

@ -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>