Mercurial > stress-tester
changeset 878:ad51a4cd465e
testEncodeInvalidMultipart
author | Devel 1 |
---|---|
date | Fri, 02 Feb 2018 15:12:41 +0100 |
parents | 145eb1d60983 |
children | 19a3babec5c5 |
files | stress-tester/src/test/java/com/passus/st/client/http/filter/HttpVarsFilterTest.java |
diffstat | 1 files changed, 47 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpVarsFilterTest.java Fri Feb 02 15:11:38 2018 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpVarsFilterTest.java Fri Feb 02 15:12:41 2018 +0100 @@ -102,6 +102,53 @@ assertEquals("x", content(parts.get(2), UTF_8)); } + @Test(enabled = false) + public void testEncodeInvalidMultipart() throws IOException { + String hdrs + = "POST /event_processing/edit/53ba69fcc2364828037a6bd7 HTTP/1.1\r\n" + + "Host: 172.16.60.159\r\n" + + "X-Requested-With: XMLHttpRequest\r\n" + + "Content-Length: 359\r\n" + + "Content-Type: multipart/form-data; boundary=------------------1456847137\r\n\r\n"; + String c1 + = "--------------------1456847137\r\n" + + "Content-Disposition: form-data; name=\"name\"\r\n\r\n" + + "Filter {@name}\r\n" + + "--------------------1456847137\r\n" + + "Content-Disposition: form-data; name=\"description\"\r\n\r\n" + + "Komputery korzystające z netu bez logowania do domeny\r\n" + + "--------------------1456847137\r\n" + + "Content-Disposition: form-data; name=\"type\"\r\n\r\n" + + "{@type}\r\n"; + String cn = "--------------------1456847137--\r\n"; + + byte[] bytes = (hdrs + c1 + cn).getBytes(UTF_8); + assertEquals(359, (c1 + cn).getBytes(UTF_8).length); + + HttpRequest request = TestHttpUtils.request(bytes); + List<HttpDataPart> parts = HttpMessageHelper.get().decodeMultipart(request); + assertEquals(3, parts.size()); + assertTrue(content(parts.get(1), UTF_8).contains("korzystające")); + + HttpVarsFilter filter = new HttpVarsFilter(appVars); + + filter.filterOutbound(request, null, null); + +// HeapByteBuff buffff = new HeapByteBuff(); +// HttpRequestEncoder encoder = new HttpRequestEncoder(); +// encoder.encode(request, buffff); +// String sssssssss = buffff.toString(); +// System.out.println("----------------"); +// System.out.println(sssssssss); +// System.out.println("----------------"); + + parts = HttpMessageHelper.get().decodeMultipart(request); + assertEquals(3, parts.size()); + assertEquals("Filter X", content(parts.get(0), UTF_8)); + assertTrue(content(parts.get(1), UTF_8).contains("korzystające")); + assertEquals("x", content(parts.get(2), UTF_8)); + } + @Test public void testPut() throws IOException { String content = "{\"abc\": \"{@appVars.var1}\", \"def\": \"{@req.url}\"}";