Mercurial > stress-tester
changeset 723:62de3e39e249
in progress
author | Devel 1 |
---|---|
date | Fri, 01 Dec 2017 12:11:35 +0100 |
parents | 0141c466d2d3 |
children | 4e3b671d6cdf |
files | stress-tester/src/main/java/com/passus/st/client/http/HttpFlowContext.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestCacheHeadersCleanerFilter.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java stress-tester/src/main/java/com/passus/st/reader/nc/NcHttpDataUtils.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilterTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFormLoginFilterTest.java |
diffstat | 6 files changed, 47 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowContext.java Fri Dec 01 11:56:17 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowContext.java Fri Dec 01 12:11:35 2017 +0100 @@ -80,6 +80,10 @@ return scopes; } + public void setSentEvent(HttpSessionPayloadEvent sentEvent) { + this.sentEvent = sentEvent; + } + public HttpResponse origReponse() { if (sentEvent != null && sentEvent.getResponse() != null) { return sentEvent.getResponse();
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestCacheHeadersCleanerFilter.java Fri Dec 01 11:56:17 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestCacheHeadersCleanerFilter.java Fri Dec 01 12:11:35 2017 +0100 @@ -2,6 +2,7 @@ import com.passus.commons.annotations.Plugin; import com.passus.data.ByteString; +import static com.passus.net.http.HttpHeaders.*; import com.passus.st.plugin.PluginConstants; /** @@ -14,8 +15,7 @@ public static final String TYPE = "requestCacheHeadersCleaner"; public static final ByteString[] CACHE_HEADERS = { - ByteString.create("If-Modified-Since"), - ByteString.create("If-None-Match") + IF_MODIFIED_SINCE, IF_NONE_MATCH }; public HttpRequestCacheHeadersCleanerFilter() {
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java Fri Dec 01 11:56:17 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java Fri Dec 01 12:11:35 2017 +0100 @@ -2,6 +2,7 @@ import com.passus.commons.annotations.Plugin; import com.passus.data.ByteString; +import static com.passus.net.http.HttpHeaders.*; import com.passus.st.plugin.PluginConstants; /** @@ -14,12 +15,8 @@ public static final String TYPE = "requestProxyHeadersCleaner"; public static final ByteString[] PROXY_HEADERS = { - ByteString.create("Forwarded"), - ByteString.create("Proxy-Authorization"), - ByteString.create("Proxy-Connection"), - ByteString.create("X-Forwarded-For"), - ByteString.create("X-Forwarded-Host"), - ByteString.create("X-Forwarded-Proto") + FORWARDED, PROXY_AUTHORIZATION, PROXY_CONNECTION, + X_FORWARDED_FOR, X_FORWARDED_HOST, X_FORWARDED_PROTO }; public HttpRequestProxyHeadersCleanerFilter() {
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcHttpDataUtils.java Fri Dec 01 11:56:17 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcHttpDataUtils.java Fri Dec 01 12:11:35 2017 +0100 @@ -83,36 +83,37 @@ codeToHeader.put((byte) 49, HttpHeaders.PRAGMA); codeToHeader.put((byte) 50, HttpHeaders.PROXY_AUTHENTICATE); codeToHeader.put((byte) 51, HttpHeaders.PROXY_AUTHORIZATION); - codeToHeader.put((byte) 52, HttpHeaders.PUBLIC_KEY_PINS); - codeToHeader.put((byte) 53, HttpHeaders.PUBLIC_KEY_PINS_REPORT_ONLY); - codeToHeader.put((byte) 54, HttpHeaders.RANGE); - codeToHeader.put((byte) 55, HttpHeaders.REFERER); - codeToHeader.put((byte) 56, HttpHeaders.REFERRER_POLICY); - codeToHeader.put((byte) 57, HttpHeaders.RETRY_AFTER); - codeToHeader.put((byte) 58, HttpHeaders.SERVER); - codeToHeader.put((byte) 59, HttpHeaders.SET_COOKIE); - codeToHeader.put((byte) 60, HttpHeaders.SET_COOKIE2); - codeToHeader.put((byte) 61, HttpHeaders.SOURCEMAP); - codeToHeader.put((byte) 62, HttpHeaders.STRICT_TRANSPORT_SECURITY); - codeToHeader.put((byte) 63, HttpHeaders.TE); - codeToHeader.put((byte) 64, HttpHeaders.TIMING_ALLOW_ORIGIN); - codeToHeader.put((byte) 65, HttpHeaders.TK); - codeToHeader.put((byte) 66, HttpHeaders.TRAILER); - codeToHeader.put((byte) 67, HttpHeaders.TRANSFER_ENCODING); - codeToHeader.put((byte) 68, HttpHeaders.UPGRADE_INSECURE_REQUESTS); - codeToHeader.put((byte) 69, HttpHeaders.USER_AGENT); - codeToHeader.put((byte) 70, HttpHeaders.VARY); - codeToHeader.put((byte) 71, HttpHeaders.VIA); - codeToHeader.put((byte) 72, HttpHeaders.WWW_AUTHENTICATE); - codeToHeader.put((byte) 73, HttpHeaders.WARNING); - codeToHeader.put((byte) 74, HttpHeaders.X_CONTENT_TYPE_OPTIONS); - codeToHeader.put((byte) 75, HttpHeaders.X_DNS_PREFETCH_CONTROL); - codeToHeader.put((byte) 76, HttpHeaders.X_FORWARDED_FOR); - codeToHeader.put((byte) 77, HttpHeaders.X_FORWARDED_HOST); - codeToHeader.put((byte) 78, HttpHeaders.X_FORWARDED_PROTO); - codeToHeader.put((byte) 79, HttpHeaders.X_FRAME_OPTIONS); - codeToHeader.put((byte) 80, HttpHeaders.X_REQUESTED_WITH); - codeToHeader.put((byte) 81, HttpHeaders.X_XSS_PROTECTION); + codeToHeader.put((byte) 52, HttpHeaders.PROXY_CONNECTION); + codeToHeader.put((byte) 53, HttpHeaders.PUBLIC_KEY_PINS); + codeToHeader.put((byte) 54, HttpHeaders.PUBLIC_KEY_PINS_REPORT_ONLY); + codeToHeader.put((byte) 55, HttpHeaders.RANGE); + codeToHeader.put((byte) 56, HttpHeaders.REFERER); + codeToHeader.put((byte) 57, HttpHeaders.REFERRER_POLICY); + codeToHeader.put((byte) 58, HttpHeaders.RETRY_AFTER); + codeToHeader.put((byte) 59, HttpHeaders.SERVER); + codeToHeader.put((byte) 60, HttpHeaders.SET_COOKIE); + codeToHeader.put((byte) 61, HttpHeaders.SET_COOKIE2); + codeToHeader.put((byte) 62, HttpHeaders.SOURCEMAP); + codeToHeader.put((byte) 63, HttpHeaders.STRICT_TRANSPORT_SECURITY); + codeToHeader.put((byte) 64, HttpHeaders.TE); + codeToHeader.put((byte) 65, HttpHeaders.TIMING_ALLOW_ORIGIN); + codeToHeader.put((byte) 66, HttpHeaders.TK); + codeToHeader.put((byte) 67, HttpHeaders.TRAILER); + codeToHeader.put((byte) 68, HttpHeaders.TRANSFER_ENCODING); + codeToHeader.put((byte) 69, HttpHeaders.UPGRADE_INSECURE_REQUESTS); + codeToHeader.put((byte) 70, HttpHeaders.USER_AGENT); + codeToHeader.put((byte) 71, HttpHeaders.VARY); + codeToHeader.put((byte) 72, HttpHeaders.VIA); + codeToHeader.put((byte) 73, HttpHeaders.WWW_AUTHENTICATE); + codeToHeader.put((byte) 74, HttpHeaders.WARNING); + codeToHeader.put((byte) 75, HttpHeaders.X_CONTENT_TYPE_OPTIONS); + codeToHeader.put((byte) 76, HttpHeaders.X_DNS_PREFETCH_CONTROL); + codeToHeader.put((byte) 77, HttpHeaders.X_FORWARDED_FOR); + codeToHeader.put((byte) 78, HttpHeaders.X_FORWARDED_HOST); + codeToHeader.put((byte) 79, HttpHeaders.X_FORWARDED_PROTO); + codeToHeader.put((byte) 80, HttpHeaders.X_FRAME_OPTIONS); + codeToHeader.put((byte) 81, HttpHeaders.X_REQUESTED_WITH); + codeToHeader.put((byte) 82, HttpHeaders.X_XSS_PROTECTION); Map<ByteString, Byte> headerToCode = new HashMap<>(codeToHeader.size()); codeToHeader.forEach((code, header) -> headerToCode.put(header, code));
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilterTest.java Fri Dec 01 11:56:17 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilterTest.java Fri Dec 01 12:11:35 2017 +0100 @@ -27,8 +27,7 @@ private static final String RESP1S = "HTTP/1.1 401 Unauthorized\r\n" + "Date: Fri, 09 Jun 2017 06:25:27 GMT\r\n" + "WWW-Authenticate: Digest realm=\"realm\", nonce=\"old-nonce\", algorithm=MD5, qop=\"auth\"\r\n" - + "Content-Length: 12\r\n\r\n" - + "Unauthorized"; + + "Content-Length: 12\r\n\r\nUnauthorized"; private static final String REQ2S = "GET /html/digest/index2.html HTTP/1.1\r\n" + "Host: 172.16.60.101\r\n" @@ -37,10 +36,8 @@ + " qop=auth, nc=00000001, cnonce=\"cnonce\"\r\n\r\n"; private static final String RESP2S = "HTTP/1.1 200 OK\n" - + "Authentication-Info: rspauth=\"?\", cnonce=\"?\", nc=00000001, qop=auth\n" - + "Content-Length: 33\n" - + "Content-Type: text/html\r\n\r\n" - + "<html><body>content</body></html>"; + + "Authentication-Info: rspauth=\"?\", cnonce=\"?\", nc=00000001, qop=auth\r\n" + + "Content-Length: 33\r\n\r\n<html><body>content</body></html>"; public static HttpDigestAuthLoginFilter createFilter(Credentials cred) { ConfigurationImpl cfg = new ConfigurationImpl();
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFormLoginFilterTest.java Fri Dec 01 11:56:17 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFormLoginFilterTest.java Fri Dec 01 12:11:35 2017 +0100 @@ -8,7 +8,6 @@ import com.passus.net.http.HttpResponse; import com.passus.st.client.credentials.Credentials; import com.passus.st.client.credentials.CredentialsProvider; -import com.passus.st.client.credentials.SingleCredentialsProvider; import static com.passus.st.client.http.HttpConsts.PARAM_USERNAME; import static com.passus.st.client.http.HttpConsts.TAG_SESSION_ID; import com.passus.st.client.http.HttpFlowContext; @@ -29,17 +28,16 @@ public static final String REQS = "POST /login_check HTTP/1.1\r\n" + "Host: 172.16.60.23\r\n" - + "Referer: http://172.16.60.23/login\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 32\r\n" + "Cookie: PHPSESSID=4r7tg8275ih7p0uh79im6q5643\r\n\r\n" + "_username=admin&_password=qwerty"; - private final String RESPS = "HTTP/1.1 302 Found\r\n" + private static final String RESPS = "HTTP/1.1 302 Found\r\n" + "Set-Cookie: PHPSESSID=pcap_post; path=/; HttpOnly\r\n" + "Location: http://172.16.60.23/\r\n" - + "Content-Length: 106\r\n\r\n" - + "<!DOCTYPE html><html><body><a href=\"http://172.16.60.23/login\">http://172.16.60.23/login</a></body></html>"; + + "Content-Length: 2\r\n\r\n" + + "OK"; final HttpFlowContext mockContext = mock(HttpFlowContext.class); @@ -126,7 +124,7 @@ assertEquals(mockContext.scopes().getSession(request).get(PARAM_USERNAME), null); } - static void assertContent(HttpMessage msg, String content) throws IOException { + public static void assertContent(HttpMessage msg, String content) throws IOException { assertEquals(readDataSource(msg), content); assertEquals((int) HttpMessageHelper.get().getContentLength(msg), content.length()); }