Add generic XML syntax testing to a flow test

Adding it to one test is sufficient because we use the same loading logic across all flows.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=239506003
This commit is contained in:
gbrodman 2019-03-20 17:02:43 -07:00 committed by jianglai
parent 36fd13f8e0
commit 2a18e705a2
5 changed files with 26 additions and 13 deletions

View file

@ -785,6 +785,8 @@ A flow for an Epp "hello".
### Errors
* 2001
* Generic XML syntax error that can be thrown by any flow.
## HostCheckFlow

View file

@ -22,7 +22,11 @@ import google.registry.model.eppoutput.Greeting;
import google.registry.util.Clock;
import javax.inject.Inject;
/** A flow for an Epp "hello". */
/**
* A flow for an Epp "hello".
*
* @error {@link google.registry.flows.FlowUtils.GenericXmlSyntaxErrorException}
*/
public class HelloFlow implements Flow {
@Inject ExtensionManager extensionManager;

View file

@ -226,13 +226,6 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
assertPollMessagesHelper(getPollMessages(clientId), expected);
}
public void assertPollMessages(
String clientId,
DateTime now,
PollMessage... expected) {
assertPollMessagesHelper(getPollMessages(clientId, now), expected);
}
public void assertPollMessages(PollMessage... expected) {
assertPollMessagesHelper(getPollMessages(), expected);
}
@ -326,10 +319,6 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
private TmchCaMode tmchCaMode = TmchCaMode.PILOT;
protected void useTmchProdCert() {
tmchCaMode = TmchCaMode.PRODUCTION;
}
public EppOutput dryRunFlowAssertResponse(String xml, String... ignoredPaths) throws Exception {
List<Object> beforeEntities = ofy().load().list();
EppOutput output =

View file

@ -14,10 +14,14 @@
package google.registry.flows.session;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.assertThrows;
import static org.joda.time.format.ISODateTimeFormat.dateTimeNoMillis;
import com.google.common.collect.ImmutableMap;
import google.registry.flows.EppException;
import google.registry.flows.FlowTestCase;
import google.registry.flows.FlowUtils.GenericXmlSyntaxErrorException;
import org.junit.Test;
/** Unit tests for {@link HelloFlow}. */
@ -31,4 +35,13 @@ public class HelloFlowTest extends FlowTestCase<HelloFlow> {
loadFile(
"greeting.xml", ImmutableMap.of("DATE", clock.nowUtc().toString(dateTimeNoMillis()))));
}
@Test
public void testGenericSyntaxException() {
// This is a generic syntax test--we don't have a generic flow test case so this simple
// test class will do. Note: the logic this tests is common to all flows.
setEppInput("generic_syntax_exception.xml");
EppException thrown = assertThrows(GenericXmlSyntaxErrorException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
}

View file

@ -0,0 +1,5 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
this is some bad XML
</command>
</epp>