|
|
@@ -67,7 +67,7 @@ public class RegexFilterReaderTest { |
|
|
|
+ "\r\n" |
|
|
|
+ "<!DOCTYPE html>\n" |
|
|
|
+ "<html><meta charset=\"utf-8\">\n" |
|
|
|
+ "set-cookie: a=b; Domain=*.wrong.domain\r\n" |
|
|
|
+ "set-cookie: a=b; Domain=*.example.com\r\n" |
|
|
|
+ "</html>\n"; |
|
|
|
public static final String EXPECTED_STRING_INCLUDE_MATCH_LIMITED = "HTTP/2 200 OK\r\n" |
|
|
|
+ "server: nginx/1.18.0 (Ubuntu)\r\n" |
|
|
@@ -80,8 +80,20 @@ public class RegexFilterReaderTest { |
|
|
|
+ "\r\n" |
|
|
|
+ "<!DOCTYPE html>\n" |
|
|
|
+ "<html><meta charset=\"utf-8\">\n" |
|
|
|
+ "set-cookie: a=b; Domain=*.wrong.domain\r\n" |
|
|
|
+ "set-cookie: a=b; Domain=*.example.com\r\n" |
|
|
|
+ "</html>\n"; |
|
|
|
public static final String EXPECTED_STRING_INCLUDE_MATCH_FULL = "HTTP/2 200 OK\r\n" |
|
|
|
+ "server: nginx/1.18.0 (Ubuntu)\r\n" |
|
|
|
+ "date: Tue, 15 Sep 2020 11:40:14 GMT\r\n" |
|
|
|
+ "content-type: application/json\r\n" |
|
|
|
+ "content-encoding: UTF-8\r\n" |
|
|
|
+ "set-cookie: c=d; Domain=example.com\r\n" |
|
|
|
+ "zz-type: java.util.LinkedHashMap\r\n" |
|
|
|
+ "X-Firefox-Spdy: h2\r\n" |
|
|
|
+ "\r\n" |
|
|
|
+ "<!DOCTYPE html>\n" |
|
|
|
+ "<html><meta charset=\"utf-8\">\n" |
|
|
|
+ "</html>\n"; |
|
|
|
|
|
|
|
@Test public void testRegexReaderIncludeMatchLimited() throws Exception { |
|
|
|
final Reader reader = new StringReader(TEST_STRING_INCLUDE_MATCH_LIMITED); |
|
|
@@ -95,6 +107,17 @@ public class RegexFilterReaderTest { |
|
|
|
EXPECTED_STRING_INCLUDE_MATCH_LIMITED, result.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test public void testRegexReaderIncludeMatchLimitedWithoutLimit() throws Exception { |
|
|
|
final Reader reader = new StringReader(TEST_STRING_INCLUDE_MATCH_LIMITED); |
|
|
|
final RegexStreamFilter regexStreamFilter = |
|
|
|
new RegexLimitedReplacementFilter("Set-Cookie:.*; Domain=\\*.*\r?\n", 0, "", "NotExistingBoundary", 0); |
|
|
|
final RegexFilterReader regexFilterReader = new RegexFilterReader(reader, 1024, regexStreamFilter); |
|
|
|
final StringWriter result = new StringWriter(); |
|
|
|
IOUtils.copyLarge(regexFilterReader, result); |
|
|
|
assertEquals("multi reader failed to get expected output", |
|
|
|
EXPECTED_STRING_INCLUDE_MATCH_FULL, result.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
public static final String TEST_STRING_INCLUDE_MATCH_MIDDLE = "<!DOCTYPE html>\n<html dir=\"ltr\" lang=\"en\">\n<meta charset=\"utf-8\">something</html>\n"; |
|
|
|
public static final String EXPECTED_STRING_INCLUDE_MATCH_MIDDLE = "<!DOCTYPE html>\nINSERTED_<html dir=\"ltr\" lang=\"en\">DATA\n<meta charset=\"utf-8\">something</html>\n"; |
|
|
|
|
|
|
|