You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2023/02/08 11:02:51 UTC

[shenyu] branch master updated: fix Cryptor-Response Plugin (#4331)

This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 9725874ea fix Cryptor-Response Plugin (#4331)
9725874ea is described below

commit 9725874eaa20ec87a3d8beea168f3a9ade9ba76d
Author: 愿凌飞 <ti...@foxmail.com>
AuthorDate: Wed Feb 8 19:02:43 2023 +0800

    fix Cryptor-Response Plugin (#4331)
    
    Co-authored-by: xiaoyu <xi...@apache.org>
---
 .../http/combination/CryptorRequestPluginTest.java |  6 ++--
 .../combination/CryptorResponsePluginTest.java     |  6 ++--
 .../plugin/base/support/ResponseDecorator.java}    | 35 +++++-----------------
 .../plugin/base/utils/ServerWebExchangeUtils.java  | 19 ++++++++++--
 .../cryptor/request/CryptorRequestPlugin.java      | 12 +-------
 .../cryptor/response/CryptorResponsePlugin.java    | 26 ++++++++++++++--
 .../shenyu/plugin/cryptor/utils/CryptorUtil.java   | 25 ++++++++++++++++
 .../response/CryptorResponsePluginTest.java        | 10 +++----
 8 files changed, 85 insertions(+), 54 deletions(-)

diff --git a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CryptorRequestPluginTest.java b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CryptorRequestPluginTest.java
index 7b00796b6..8b6590ecf 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CryptorRequestPluginTest.java
+++ b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CryptorRequestPluginTest.java
@@ -132,7 +132,7 @@ public final class CryptorRequestPluginTest extends AbstractPluginDataInit {
     @ValueSource(strings = {"decrypt", "encrypt"})
     public void testWhenDecryptionOrEncryptionIsFailed(final String way) throws Exception {
 
-        CryptorRuleHandler handler = buildRuleHandler("ras", way, "wrong_encrypt_key", "wrong_decrypt_key", "data");
+        CryptorRuleHandler handler = buildRuleHandler("rsa", way, "wrong_encrypt_key", "wrong_decrypt_key", "data");
         RuleLocalData ruleLocalData = ruleLocalData(handler, SINGLETON_CONDITION_LIST);
 
         initSelectorAndRules(PluginEnum.CRYPTOR_REQUEST.getName(), "", SINGLETON_CONDITION_LIST, Lists.newArrayList(ruleLocalData));
@@ -151,7 +151,7 @@ public final class CryptorRequestPluginTest extends AbstractPluginDataInit {
     @ValueSource(strings = {"decrypt", "encrypt"})
     public void testWhenKeyIsNull(final String way) throws Exception {
 
-        CryptorRuleHandler handler = buildRuleHandler("ras", way, null, null, "data");
+        CryptorRuleHandler handler = buildRuleHandler("rsa", way, null, null, "data");
 
         initSelectorAndRules(PluginEnum.CRYPTOR_REQUEST.getName(),
                 "", SINGLETON_CONDITION_LIST, singletonRuleLocalDataList(handler, SINGLETON_CONDITION_LIST));
@@ -167,7 +167,7 @@ public final class CryptorRequestPluginTest extends AbstractPluginDataInit {
     @Test
     public void testWhenFieldNamesIsNull() throws Exception {
 
-        CryptorRuleHandler handler = buildRuleHandler("ras", "decrypt", RSA_PUBLIC_KEY, RSA_PRIVATE_KEY, null);
+        CryptorRuleHandler handler = buildRuleHandler("rsa", "decrypt", RSA_PUBLIC_KEY, RSA_PRIVATE_KEY, null);
 
         initSelectorAndRules(PluginEnum.CRYPTOR_REQUEST.getName(), "", SINGLETON_CONDITION_LIST,
                 singletonRuleLocalDataList(handler, SINGLETON_CONDITION_LIST));
diff --git a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CryptorResponsePluginTest.java b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CryptorResponsePluginTest.java
index bd94ebf97..ec7fff8f9 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CryptorResponsePluginTest.java
+++ b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CryptorResponsePluginTest.java
@@ -134,7 +134,7 @@ public class CryptorResponsePluginTest extends AbstractPluginDataInit {
     @ValueSource(strings = {"decrypt", "encrypt"})
     public void testWhenDecryptionOrEncryptionIsFailed(final String way) throws Exception {
 
-        CryptorRuleHandler handler = buildRuleHandler("ras", way, "wrong_encrypt_key", "wrong_decrypt_key", "userId");
+        CryptorRuleHandler handler = buildRuleHandler("rsa", way, "wrong_encrypt_key", "wrong_decrypt_key", "userId");
         RuleLocalData ruleLocalData = ruleLocalData(handler, SINGLETON_CONDITION_LIST);
 
         initSelectorAndRules(PluginEnum.CRYPTOR_RESPONSE.getName(), "", SINGLETON_CONDITION_LIST, Lists.newArrayList(ruleLocalData));
@@ -150,7 +150,7 @@ public class CryptorResponsePluginTest extends AbstractPluginDataInit {
     @ValueSource(strings = {"decrypt", "encrypt"})
     public void testWhenKeyIsNull(final String way) throws Exception {
 
-        CryptorRuleHandler handler = buildRuleHandler("ras", way, null, null, "data");
+        CryptorRuleHandler handler = buildRuleHandler("rsa", way, null, null, "data");
 
         initSelectorAndRules(PluginEnum.CRYPTOR_RESPONSE.getName(),
                 "", SINGLETON_CONDITION_LIST, singletonRuleLocalDataList(handler, SINGLETON_CONDITION_LIST));
@@ -166,7 +166,7 @@ public class CryptorResponsePluginTest extends AbstractPluginDataInit {
     @Test
     public void testWhenFieldNamesIsNull() throws Exception {
 
-        CryptorRuleHandler handler = buildRuleHandler("ras", "decrypt", RSA_PUBLIC_KEY, RSA_PRIVATE_KEY, null);
+        CryptorRuleHandler handler = buildRuleHandler("rsa", "decrypt", RSA_PUBLIC_KEY, RSA_PRIVATE_KEY, null);
 
         initSelectorAndRules(PluginEnum.CRYPTOR_RESPONSE.getName(), "", SINGLETON_CONDITION_LIST,
                 singletonRuleLocalDataList(handler, SINGLETON_CONDITION_LIST));
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorResponseDecorator.java b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/support/ResponseDecorator.java
similarity index 54%
rename from shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorResponseDecorator.java
rename to shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/support/ResponseDecorator.java
index 8833e2313..cef8d77b4 100644
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorResponseDecorator.java
+++ b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/support/ResponseDecorator.java
@@ -15,13 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.shenyu.plugin.cryptor.decorator;
+package org.apache.shenyu.plugin.base.support;
 
 import org.apache.shenyu.plugin.base.utils.ResponseUtils;
-import org.apache.shenyu.plugin.cryptor.handler.CryptorRuleHandler;
-import org.apache.shenyu.plugin.cryptor.strategy.CryptorStrategyFactory;
-import org.apache.shenyu.plugin.cryptor.utils.CryptorUtil;
-import org.apache.shenyu.plugin.cryptor.utils.JsonUtil;
 import org.reactivestreams.Publisher;
 import org.springframework.core.io.buffer.DataBuffer;
 import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
@@ -30,44 +26,29 @@ import org.springframework.web.server.ServerWebExchange;
 import reactor.core.publisher.Mono;
 import reactor.util.annotation.NonNull;
 
-import java.util.Objects;
+import java.util.function.Function;
 
 /**
  * Build and modify the response class.
  */
-public class CryptorResponseDecorator extends ServerHttpResponseDecorator {
+public class ResponseDecorator extends ServerHttpResponseDecorator {
 
     private final ServerWebExchange exchange;
 
-    private final CryptorRuleHandler ruleHandle;
+    private final Function<String, String> convert;
 
-    public CryptorResponseDecorator(final ServerWebExchange exchange,
-                                    final CryptorRuleHandler ruleHandle) {
+    public ResponseDecorator(final ServerWebExchange exchange,
+                             final Function<String, String> convert) {
         super(exchange.getResponse());
         this.exchange = exchange;
-        this.ruleHandle = ruleHandle;
+        this.convert = convert;
     }
 
     @Override
     @NonNull
-    @SuppressWarnings("unchecked")
     public Mono<Void> writeWith(@NonNull final Publisher<? extends DataBuffer> body) {
         ClientResponse clientResponse = ResponseUtils.buildClientResponse(this.getDelegate(), body);
-        Mono<String> mono = clientResponse.bodyToMono(String.class).flatMap(originalBody ->
-                        strategyMatch(originalBody, this.ruleHandle, this.exchange));
+        Mono<String> mono = clientResponse.bodyToMono(String.class).map(convert);
         return ResponseUtils.writeWith(clientResponse, this.exchange, mono, String.class);
     }
-
-    @SuppressWarnings("rawtypes")
-    private Mono strategyMatch(final String originalBody, final CryptorRuleHandler ruleHandle, final ServerWebExchange exchange) {
-        String parseBody = JsonUtil.parser(originalBody, ruleHandle.getFieldNames());
-        if (Objects.isNull(parseBody)) {
-            return Mono.just(originalBody);
-        }
-        String modifiedBody = CryptorStrategyFactory.match(ruleHandle, parseBody);
-        if (Objects.isNull(modifiedBody)) {
-            return CryptorUtil.fail(ruleHandle.getWay(), exchange);
-        }
-        return Mono.just(CryptorUtil.replace(originalBody, modifiedBody, ruleHandle.getWay(), ruleHandle.getFieldNames()));
-    }
 }
diff --git a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/utils/ServerWebExchangeUtils.java b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/utils/ServerWebExchangeUtils.java
index e90e0e0f4..aec9c9b0a 100644
--- a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/utils/ServerWebExchangeUtils.java
+++ b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/utils/ServerWebExchangeUtils.java
@@ -20,6 +20,7 @@ package org.apache.shenyu.plugin.base.utils;
 import org.apache.shenyu.plugin.base.support.BodyInserterContext;
 import org.apache.shenyu.plugin.base.support.CachedBodyOutputMessage;
 import org.apache.shenyu.plugin.base.support.RequestDecorator;
+import org.apache.shenyu.plugin.base.support.ResponseDecorator;
 import org.springframework.http.ReactiveHttpOutputMessage;
 import org.springframework.http.codec.HttpMessageReader;
 import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
@@ -36,9 +37,10 @@ public class ServerWebExchangeUtils {
 
     /**
      * Rewrites Request Body.
+     *
      * @param exchange serverWebExchange
-     * @param readers reader to read request-body
-     * @param convert convert body to new body
+     * @param readers  reader to read request-body
+     * @param convert  convert body to new body
      * @return Mono.
      */
     public static Mono<ServerWebExchange> rewriteRequestBody(final ServerWebExchange exchange,
@@ -60,4 +62,17 @@ public class ServerWebExchangeUtils {
                 })).onErrorResume(throwable -> ResponseUtils.release(outputMessage, throwable));
 
     }
+
+    /**
+     * Rewrites Response Body.
+     *
+     * @param exchange serverWebExchange
+     * @param convert  convert body to new body
+     * @return Mono.
+     */
+    public static ServerWebExchange rewriteResponseBody(final ServerWebExchange exchange,
+                                                        final Function<String, String> convert) {
+        return exchange.mutate()
+                .response(new ResponseDecorator(exchange, convert)).build();
+    }
 }
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/request/CryptorRequestPlugin.java b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/request/CryptorRequestPlugin.java
index b4c5b306e..c1f42efa3 100644
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/request/CryptorRequestPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/request/CryptorRequestPlugin.java
@@ -30,7 +30,6 @@ import org.apache.shenyu.plugin.base.utils.CacheKeyUtils;
 import org.apache.shenyu.plugin.base.utils.ServerWebExchangeUtils;
 import org.apache.shenyu.plugin.cryptor.handler.CryptorRequestPluginDataHandler;
 import org.apache.shenyu.plugin.cryptor.handler.CryptorRuleHandler;
-import org.apache.shenyu.plugin.cryptor.strategy.CryptorStrategyFactory;
 import org.apache.shenyu.plugin.cryptor.utils.CryptorUtil;
 import org.apache.shenyu.plugin.cryptor.utils.JsonUtil;
 import org.slf4j.Logger;
@@ -41,7 +40,6 @@ import reactor.core.publisher.Mono;
 
 import java.util.List;
 import java.util.Objects;
-import java.util.Optional;
 
 /**
  * Cryptor request plugin.
@@ -102,14 +100,6 @@ public class CryptorRequestPlugin extends AbstractShenyuPlugin {
         if (Objects.isNull(parseBody)) {
             throw new ResponsiveException(ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION.getCode(), ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION.getMsg() + "[fieldNames]", exchange);
         }
-
-        String modifiedBody = CryptorStrategyFactory.match(ruleHandle, parseBody);
-        if (Objects.isNull(modifiedBody)) {
-            throw Optional.ofNullable(ruleHandle.getWay())
-                    .filter(CryptorStrategyFactory.DECRYPT::equals)
-                    .map(data -> new ResponsiveException(ShenyuResultEnum.DECRYPTION_ERROR, exchange))
-                    .orElse(new ResponsiveException(ShenyuResultEnum.ENCRYPTION_ERROR, exchange));
-        }
-        return CryptorUtil.replace(originalBody, modifiedBody, ruleHandle.getWay(), ruleHandle.getFieldNames());
+        return CryptorUtil.crypt(ruleHandle, parseBody, originalBody, exchange);
     }
 }
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/response/CryptorResponsePlugin.java b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/response/CryptorResponsePlugin.java
index e93f92cc9..5e9e4e448 100644
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/response/CryptorResponsePlugin.java
+++ b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/response/CryptorResponsePlugin.java
@@ -22,15 +22,17 @@ import org.apache.shenyu.common.dto.RuleData;
 import org.apache.shenyu.common.dto.SelectorData;
 import org.apache.shenyu.common.enums.PluginEnum;
 import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import org.apache.shenyu.plugin.api.exception.ResponsiveException;
 import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
 import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
 import org.apache.shenyu.plugin.api.utils.WebFluxResultUtils;
 import org.apache.shenyu.plugin.base.AbstractShenyuPlugin;
 import org.apache.shenyu.plugin.base.utils.CacheKeyUtils;
-import org.apache.shenyu.plugin.cryptor.decorator.CryptorResponseDecorator;
+import org.apache.shenyu.plugin.base.utils.ServerWebExchangeUtils;
 import org.apache.shenyu.plugin.cryptor.handler.CryptorResponsePluginDataHandler;
 import org.apache.shenyu.plugin.cryptor.handler.CryptorRuleHandler;
 import org.apache.shenyu.plugin.cryptor.utils.CryptorUtil;
+import org.apache.shenyu.plugin.cryptor.utils.JsonUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.web.server.ServerWebExchange;
@@ -58,8 +60,26 @@ public class CryptorResponsePlugin extends AbstractShenyuPlugin {
                     ShenyuResultEnum.CRYPTOR_RESPONSE_ERROR_CONFIGURATION.getMsg() + "[" + pair.getRight() + "]", null);
             return WebFluxResultUtils.result(exchange, error);
         }
-        return chain.execute(exchange.mutate()
-                .response(new CryptorResponseDecorator(exchange, ruleHandle)).build());
+
+        ServerWebExchange newExchange = ServerWebExchangeUtils.rewriteResponseBody(exchange, originalBody -> convert(originalBody, ruleHandle, exchange));
+
+        return chain.execute(newExchange).onErrorResume(error -> {
+            if (error instanceof ResponsiveException) {
+                return WebFluxResultUtils.failedResult((ResponsiveException) error);
+            }
+            return Mono.error(error);
+        });
+    }
+
+    private String convert(final String originalBody, final CryptorRuleHandler ruleHandle, final ServerWebExchange exchange) {
+
+        String parseBody = JsonUtil.parser(originalBody, ruleHandle.getFieldNames());
+
+        if (Objects.isNull(parseBody)) {
+            return originalBody;
+        }
+
+        return CryptorUtil.crypt(ruleHandle, parseBody, originalBody, exchange);
     }
 
     @Override
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/utils/CryptorUtil.java b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/utils/CryptorUtil.java
index ffd8c77a5..36e40b249 100644
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/utils/CryptorUtil.java
+++ b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/utils/CryptorUtil.java
@@ -21,6 +21,7 @@ import com.google.gson.JsonElement;
 import com.google.gson.JsonParser;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
+import org.apache.shenyu.plugin.api.exception.ResponsiveException;
 import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
 import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
 import org.apache.shenyu.plugin.api.utils.WebFluxResultUtils;
@@ -30,6 +31,7 @@ import org.springframework.web.server.ServerWebExchange;
 import reactor.core.publisher.Mono;
 
 import java.util.Arrays;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -108,4 +110,27 @@ public final class CryptorUtil {
         }
         return Pair.of(false, "");
     }
+
+    /**
+     * encrypt or decrypt the response body.
+     * @param ruleHandle ruleHandle
+     * @param originalData originalData
+     * @param originalBody originalBody
+     * @param exchange exchange
+     * @return new body
+     */
+    public static String crypt(final CryptorRuleHandler ruleHandle, final String originalData, final String originalBody, final ServerWebExchange exchange) {
+
+        String modifiedData = CryptorStrategyFactory.match(ruleHandle, originalData);
+
+        if (Objects.isNull(modifiedData)) {
+            throw Optional.ofNullable(ruleHandle.getWay())
+                    .filter(CryptorStrategyFactory.DECRYPT::equals)
+                    .map(data -> new ResponsiveException(ShenyuResultEnum.DECRYPTION_ERROR, exchange))
+                    .orElse(new ResponsiveException(ShenyuResultEnum.ENCRYPTION_ERROR, exchange));
+        }
+
+        return CryptorUtil.replace(originalBody, modifiedData, ruleHandle.getWay(), ruleHandle.getFieldNames());
+
+    }
 }
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/test/java/org/apache/shenyu/plugin/cryptor/response/CryptorResponsePluginTest.java b/shenyu-plugin/shenyu-plugin-cryptor/src/test/java/org/apache/shenyu/plugin/cryptor/response/CryptorResponsePluginTest.java
index 12368f1d8..cf605f85e 100644
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/test/java/org/apache/shenyu/plugin/cryptor/response/CryptorResponsePluginTest.java
+++ b/shenyu-plugin/shenyu-plugin-cryptor/src/test/java/org/apache/shenyu/plugin/cryptor/response/CryptorResponsePluginTest.java
@@ -22,7 +22,7 @@ import org.apache.shenyu.common.dto.RuleData;
 import org.apache.shenyu.common.dto.SelectorData;
 import org.apache.shenyu.common.enums.PluginEnum;
 import org.apache.shenyu.plugin.api.ShenyuPluginChain;
-import org.apache.shenyu.plugin.cryptor.decorator.CryptorResponseDecorator;
+import org.apache.shenyu.plugin.base.support.ResponseDecorator;
 import org.apache.shenyu.plugin.cryptor.handler.CryptorResponsePluginDataHandler;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -98,7 +98,7 @@ public class CryptorResponsePluginTest {
                 + "}\n");
         ServerWebExchange.Builder builder = mock(ServerWebExchange.Builder.class);
         when(exchange.mutate()).thenReturn(builder);
-        when(builder.response(any(CryptorResponseDecorator.class))).thenReturn(builder);
+        when(builder.response(any(ResponseDecorator.class))).thenReturn(builder);
         when(builder.build()).thenReturn(exchange);
         when(chain.execute(any())).thenReturn(Mono.empty());
         cryptorResponsePluginDataHandler.handlerRule(ruleData);
@@ -129,7 +129,7 @@ public class CryptorResponsePluginTest {
                 + "}\n");
         ServerWebExchange.Builder builder = mock(ServerWebExchange.Builder.class);
         when(exchange.mutate()).thenReturn(builder);
-        when(builder.response(any(CryptorResponseDecorator.class))).thenReturn(builder);
+        when(builder.response(any(ResponseDecorator.class))).thenReturn(builder);
         when(builder.build()).thenReturn(exchange);
         when(chain.execute(any())).thenReturn(Mono.empty());
         cryptorResponsePluginDataHandler.handlerRule(ruleData);
@@ -159,7 +159,7 @@ public class CryptorResponsePluginTest {
                 + "}\n");
         ServerWebExchange.Builder builder = mock(ServerWebExchange.Builder.class);
         when(exchange.mutate()).thenReturn(builder);
-        when(builder.response(any(CryptorResponseDecorator.class))).thenReturn(builder);
+        when(builder.response(any(ResponseDecorator.class))).thenReturn(builder);
         when(builder.build()).thenReturn(exchange);
         when(chain.execute(any())).thenReturn(Mono.empty());
         cryptorResponsePluginDataHandler.handlerRule(ruleData);
@@ -190,7 +190,7 @@ public class CryptorResponsePluginTest {
                 + "}\n");
         ServerWebExchange.Builder builder = mock(ServerWebExchange.Builder.class);
         when(exchange.mutate()).thenReturn(builder);
-        when(builder.response(any(CryptorResponseDecorator.class))).thenReturn(builder);
+        when(builder.response(any(ResponseDecorator.class))).thenReturn(builder);
         when(builder.build()).thenReturn(exchange);
         when(chain.execute(any())).thenReturn(Mono.empty());
         cryptorResponsePluginDataHandler.handlerRule(ruleData);