changeset 1295:cd90b24c9f64

sequences - optional URI normalization
author Devel 1
date Wed, 15 Jul 2020 13:06:10 +0200
parents 8396548d1a78
children dcb1f063650c
files stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java stress-tester/src/main/java/com/passus/st/scanner/SequenceConverter.java stress-tester/src/test/java/com/passus/st/client/http/HttpUrlUtilsTest.java
diffstat 3 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java	Wed Jul 15 12:39:20 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java	Wed Jul 15 13:06:10 2020 +0200
@@ -55,6 +55,8 @@
 
     private CSVWriter dataWriter;
 
+    private boolean normPathSegments;
+
     public String getType() {
         return TYPE;
     }
@@ -130,7 +132,9 @@
         HttpResponse resp = (HttpResponse) event.getResponse();
         if (req != null) {
             String uri = req.getUri().toString();
-            uri = HttpUrlUtils.normalizePathSegments(uri);
+            if (normPathSegments) {
+                uri = HttpUrlUtils.normalizePathSegments(uri);
+            }
             String method = req.getMethod().toString();
             String datetime = sdf.format(new Date(req.getTimestamp()));
             String userId = userIdExtractor.extract(event);
--- a/stress-tester/src/main/java/com/passus/st/scanner/SequenceConverter.java	Wed Jul 15 12:39:20 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/scanner/SequenceConverter.java	Wed Jul 15 13:06:10 2020 +0200
@@ -35,6 +35,7 @@
     String idKey;
     int multiplier = 10;
     int maxRepeats = 10;
+    boolean normPathSegments;
 
     static Map<String, Object> prepareMatchFilter(List<String> ignoredUrls) {
         List<Map<String, Object>> matches = new ArrayList<>(ignoredUrls.size());
@@ -50,8 +51,9 @@
     Map<String, Object> prepareSequenceFilter(List<String> steps) {
         List<Map<String, Object>> sequence = new ArrayList<>(steps.size());
         boolean first = true;
+        String uriKey = normPathSegments ? "@req.normUri" : "@req.uri";
         for (String step : steps) {
-            Map<String, Object> matcher = lmap(e("@req.uri", step));
+            Map<String, Object> matcher = lmap(e(uriKey, step));
             if (first) {
                 first = false;
             } else {
--- a/stress-tester/src/test/java/com/passus/st/client/http/HttpUrlUtilsTest.java	Wed Jul 15 12:39:20 2020 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/HttpUrlUtilsTest.java	Wed Jul 15 13:06:10 2020 +0200
@@ -13,10 +13,15 @@
     @Test
     public void testNormalizePathSegments() {
         assertEquals("/user/check/login", normalizePathSegments("/user/check/./login"));
+        assertEquals("/user/check/login", normalizePathSegments("/user/check//login"));
         assertEquals("/user/login", normalizePathSegments("/user/check/../login"));
+
         assertEquals("beta.bilkom.pl/user/check/login", normalizePathSegments("beta.bilkom.pl/user/check/./login"));
+        assertEquals("beta.bilkom.pl/user/check/login", normalizePathSegments("beta.bilkom.pl/user/check//login"));
         assertEquals("beta.bilkom.pl/user/login", normalizePathSegments("beta.bilkom.pl/user/check/../login"));
+
         assertEquals("/stacje/szukaj/search?q=Czy%C5%BC", normalizePathSegments("/stacje/szukaj/./search?q=Czy%C5%BC"));
+        assertEquals("/stacje/szukaj/search?q=Czy%C5%BC", normalizePathSegments("/stacje/szukaj//search?q=Czy%C5%BC"));
         assertEquals("/stacje/search?q=Czy%C5%BC", normalizePathSegments("/stacje/szukaj/../search?q=Czy%C5%BC"));
     }