changeset 795:315469a3b03c

HttpMessageModificationFilter operations name changed
author Devel 2
date Thu, 21 Dec 2017 12:06:17 +0100
parents 3143f2ca9ee7
children caa4151f8679
files stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilter.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java stress-tester/src/test/resources/com/passus/st/client/http/filter/http_message_modify_filter.yml
diffstat 5 files changed, 56 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilter.java	Thu Dec 21 10:26:18 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilter.java	Thu Dec 21 12:06:17 2017 +0100
@@ -11,7 +11,6 @@
 import static com.passus.config.schema.ConfigurationSchemaBuilder.valueDef;
 import static com.passus.config.schema.ConfigurationSchemaBuilder.mappingDef;
 import com.passus.config.schema.KeyNameVaryListNodeDefinition;
-import com.passus.config.schema.MappingNodeDefinition;
 import com.passus.config.schema.NodeDefinition;
 import com.passus.config.schema.NodeDefinitionCreator;
 import com.passus.data.ByteString;
@@ -584,23 +583,21 @@
                     )
             );
 
-            MappingNodeDefinition contentNodeDef = new MappingNodeDefinition();
-
             KeyNameVaryListNodeDefinition operationsDef = new KeyNameVaryListNodeDefinition()
                     .setNodeTransformer(new HttpMessageModificationFilterTransformer())
-                    .add("$removeHeader", valueDef().addValidator(HeaderNameValidator.INSTANCE))
-                    .add("$addHeader", headerNodeDef)
-                    .add("$setHeader", headerNodeDef)
-                    .add("$removeCookie", valueDef())
-                    .add("$addCookie", headerNodeDef)
-                    .add("$setCookie", headerNodeDef)
-                    .add("$removePostParam", valueDef())
-                    .add("$addPostParam", paramNodeDef)
-                    .add("$setPostParam", paramNodeDef)
-                    .add("$removeQueryParam", paramNodeDef)
-                    .add("$addQueryParam", paramNodeDef)
-                    .add("$setQueryParam", paramNodeDef)
-                    .add("$setContent", mappingDef().setChildrenNum(1));
+                    .add("removeHeader", valueDef().addValidator(HeaderNameValidator.INSTANCE))
+                    .add("addHeader", headerNodeDef)
+                    .add("setHeader", headerNodeDef)
+                    .add("removeCookie", valueDef())
+                    .add("addCookie", headerNodeDef)
+                    .add("setCookie", headerNodeDef)
+                    .add("removePostParam", valueDef())
+                    .add("addPostParam", paramNodeDef)
+                    .add("setPostParam", paramNodeDef)
+                    .add("removeQueryParam", paramNodeDef)
+                    .add("addQueryParam", paramNodeDef)
+                    .add("setQueryParam", paramNodeDef)
+                    .add("setContent", mappingDef().setChildrenNum(1));
 
             return mapDef(
                     tupleDef("operations", operationsDef),
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java	Thu Dec 21 10:26:18 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java	Thu Dec 21 12:06:17 2017 +0100
@@ -131,43 +131,43 @@
                 errors.pushNestedPath(opName);
                 Operation op = null;
                 switch (opName.toLowerCase()) {
-                    case "$removeheader":
+                    case "removeheader":
                         op = createNameOperation(tuple, errors, RemoveHeaderOperation.class);
                         break;
-                    case "$addheader":
+                    case "addheader":
                         op = createNameValueOperation(tuple, errors, AddHeaderOperation.class);
                         break;
-                    case "$setheader":
+                    case "setheader":
                         op = createNameValueOperation(tuple, errors, SetHeaderOperation.class);
                         break;
-                    case "$removecookie":
+                    case "removecookie":
                         op = createNameOperation(tuple, errors, RemoveCookieOperation.class);
                         break;
-                    case "$addcookie":
+                    case "addcookie":
                         op = createNameValueOperation(tuple, errors, AddCookieOperation.class);
                         break;
-                    case "$setcookie":
+                    case "setcookie":
                         op = createNameValueOperation(tuple, errors, SetCookieOperation.class);
                         break;
-                    case "$removepostparam":
+                    case "removepostparam":
                         op = createNameOperation(tuple, errors, PostDataRemoveParamOperation.class);
                         break;
-                    case "$addpostparam":
+                    case "addpostparam":
                         op = createAddParamOperation(tuple, errors, PostDataAddParamOperation.class);
                         break;
-                    case "$setpostparam":
+                    case "setpostparam":
                         op = createAddParamOperation(tuple, errors, PostDataSetParamOperation.class);
                         break;
-                    case "$removequeryparam":
+                    case "removequeryparam":
                         op = createNameOperation(tuple, errors, RemoveQueryParameterOperation.class);
                         break;
-                    case "$addqueryparam":
+                    case "addqueryparam":
                         op = createNameValueOperation(tuple, errors, AddQueryParameterOperation.class);
                         break;
-                    case "$setqueryparam":
+                    case "setqueryparam":
                         op = createNameValueOperation(tuple, errors, SetQueryParameterOperation.class);
                         break;
-                    case "$setcontent":
+                    case "setcontent":
                         if (validateType(tuple.getNode(), NodeType.MAP, errors)) {
                             CTupleNode valTupleNode = ((CMapNode) tuple.getNode()).getFirstChild();
                             if (valTupleNode != null) {
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java	Thu Dec 21 10:26:18 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java	Thu Dec 21 12:06:17 2017 +0100
@@ -123,18 +123,18 @@
         String filterConfig = "filters:\n"
                 + "    - type: modifyMessage\n"
                 + "      operations:\n"
-                + "        $removeHeader: Header1\n"
-                + "        $addHeader: \n"
+                + "        removeHeader: Header1\n"
+                + "        addHeader: \n"
                 + "            Header4: HeaderValue4\n"
-                + "        $addHeader: \n"
+                + "        addHeader: \n"
                 + "            Header4: HeaderValue4a\n"
-                + "        $setHeader: \n"
+                + "        setHeader: \n"
                 + "            Header5: HeaderValue5\n"
-                + "        $setHeader: \n"
+                + "        setHeader: \n"
                 + "            Header3: Header1Value3a\n"
-                + "        $setHeader: \n"
+                + "        setHeader: \n"
                 + "            Header6: \"$scopes.getSession('testId').get('testParam')\"\n"
-                + "        $setHeader: \n"
+                + "        setHeader: \n"
                 + "            Header7: \"$httpSession.get('testParam')\"\n";
 
         Errors errors = new Errors();
@@ -173,9 +173,9 @@
         String filterConfig = "filters:\n"
                 + "    - type: modifyMessage\n"
                 + "      operations:\n"
-                + "        $setQueryParam: \n"
+                + "        setQueryParam: \n"
                 + "            v1: {$expr: \"$httpSession.get('testParam2') or 'aaa'\"}\n"
-                + "        $setQueryParam: \n"
+                + "        setQueryParam: \n"
                 + "            v2: {$expr: \"$httpSession.get('testParam2') or $httpSession.get('testParam')\"}\n";
 
         HttpRequest req = HttpRequestBuilder.get("http://test.com/path/test")
@@ -203,8 +203,8 @@
                 + "      applyIf:\n"
                 + "        \"req.uri\": /path/test\n"
                 + "      operations:\n"
-                + "        $removeHeader: Header1\n"
-                + "        $setContent:\n"
+                + "        removeHeader: Header1\n"
+                + "        setContent:\n"
                 + "          regexp:aaa(.+)bbb: aaaa\n";
 
         Errors errors = new Errors();
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java	Thu Dec 21 10:26:18 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java	Thu Dec 21 12:06:17 2017 +0100
@@ -26,27 +26,27 @@
     @Test
     public void testTransform() throws Exception {
         String config = "operations:\n"
-                + "  $removeHeader: H1\n"
-                + "  $setHeader:\n"
+                + "  removeHeader: H1\n"
+                + "  setHeader:\n"
                 + "    H2: value\n"
-                + "  $addHeader:\n"
+                + "  addHeader:\n"
                 + "    H3: value\n"
-                + "  $removeCookie: C1\n"
-                + "  $setCookie:\n"
+                + "  removeCookie: C1\n"
+                + "  setCookie:\n"
                 + "    C2: value\n"
-                + "  $addCookie:\n"
+                + "  addCookie:\n"
                 + "    C3: value\n"
-                + "  $removeQueryParam: Q1\n"
-                + "  $setQueryParam:\n"
+                + "  removeQueryParam: Q1\n"
+                + "  setQueryParam:\n"
                 + "    Q2: value\n"
-                + "  $addQueryParam:\n"
+                + "  addQueryParam:\n"
                 + "    Q3: value\n"
-                + "  $removePostParam: P1\n"
-                + "  $setPostParam:\n"
+                + "  removePostParam: P1\n"
+                + "  setPostParam:\n"
                 + "    P2: value\n"
-                + "  $addPostParam:\n"
+                + "  addPostParam:\n"
                 + "    P3: value\n"
-                + "  $setContent:\n"
+                + "  setContent:\n"
                 + "    regexp:aaa(.+)bbb: aaaa\n";
         CTupleNode node = read(config);
 
--- a/stress-tester/src/test/resources/com/passus/st/client/http/filter/http_message_modify_filter.yml	Thu Dec 21 10:26:18 2017 +0100
+++ b/stress-tester/src/test/resources/com/passus/st/client/http/filter/http_message_modify_filter.yml	Thu Dec 21 12:06:17 2017 +0100
@@ -1,15 +1,15 @@
 filters:
     - type: modifyMessage
       operations:
-        $removeHeader: Test
-        $addHeader: 
+        removeHeader: Test
+        addHeader: 
             Test-Header: Test Header Value
-        $setHeader:
+        setHeader:
             Test-Header2: Test Header Value2
-        $removeCookie: CookieName
-        $addCookie: 
+        removeCookie: CookieName
+        addCookie: 
             CookieName: CookieValue
-        $setCookie:
+        setCookie:
             CookieName: CookieValue
 
     - type: requestProxyHeadersCleaner