mirror of
https://github.com/google/nomulus
synced 2026-09-25 17:34:20 +00:00
Refactor assertCommandAndResponse to be "fluent"
This is in preparation for automatic EPP consolidation.
The assertion will now look like:
assertThatCommand("file.xml"[, substitution])
.atTime(time)
.hasResponse("file2.xml"[, substitution]);
Also, added convenience functions for often reused commands (login and logout)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190617505
This commit is contained in:
@@ -35,49 +35,40 @@ public class EppXxeAttackTest extends EppTestCase {
|
||||
|
||||
@Test
|
||||
public void testRemoteXmlExternalEntity() throws Exception {
|
||||
assertCommandAndResponse("login_valid.xml", "login_response.xml");
|
||||
assertCommandAndResponse(
|
||||
"contact_create_remote_xxe.xml",
|
||||
ImmutableMap.of(),
|
||||
"response_error_no_cltrid.xml",
|
||||
ImmutableMap.of(
|
||||
"MSG",
|
||||
"Syntax error at line 11, column 34: "
|
||||
+ "The entity "remote" was referenced, but not declared.",
|
||||
"CODE",
|
||||
"2001"));
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_remote_xxe.xml")
|
||||
.hasResponse(
|
||||
"response_error_no_cltrid.xml",
|
||||
ImmutableMap.of(
|
||||
"CODE", "2001",
|
||||
"MSG", "Syntax error at line 11, column 34: "
|
||||
+ "The entity "remote" was referenced, but not declared."));
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalXmlExtrernalEntity() throws Exception {
|
||||
assertCommandAndResponse("login_valid.xml", "login_response.xml");
|
||||
assertCommandAndResponse(
|
||||
"contact_create_local_xxe.xml",
|
||||
ImmutableMap.of(),
|
||||
"response_error_no_cltrid.xml",
|
||||
ImmutableMap.of(
|
||||
"MSG",
|
||||
"Syntax error at line 11, column 31: "
|
||||
+ "The entity "ent" was referenced, but not declared.",
|
||||
"CODE",
|
||||
"2001"));
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_local_xxe.xml")
|
||||
.hasResponse(
|
||||
"response_error_no_cltrid.xml",
|
||||
ImmutableMap.of(
|
||||
"CODE", "2001",
|
||||
"MSG", "Syntax error at line 11, column 31: "
|
||||
+ "The entity "ent" was referenced, but not declared."));
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBillionLaughsAttack() throws Exception {
|
||||
assertCommandAndResponse("login_valid.xml", "login_response.xml");
|
||||
assertCommandAndResponse(
|
||||
"contact_create_billion_laughs.xml",
|
||||
ImmutableMap.of(),
|
||||
"response_error_no_cltrid.xml",
|
||||
ImmutableMap.of(
|
||||
"MSG",
|
||||
"Syntax error at line 20, column 32: "
|
||||
+ "The entity "lol9" was referenced, but not declared.",
|
||||
"CODE",
|
||||
"2001"));
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_billion_laughs.xml")
|
||||
.hasResponse(
|
||||
"response_error_no_cltrid.xml",
|
||||
ImmutableMap.of(
|
||||
"CODE", "2001",
|
||||
"MSG", "Syntax error at line 20, column 32: "
|
||||
+ "The entity "lol9" was referenced, but not declared."));
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user