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/incubator-shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 51cc05f  [Integrated-Test] Init combination integrated test (#2363)
51cc05f is described below

commit 51cc05f28aa3e9595191196225ada9c4039ee73a
Author: Kunshuai Zhu <[email protected]>
AuthorDate: Mon Nov 15 16:14:46 2021 +0800

    [Integrated-Test] Init combination integrated test (#2363)
    
    * Init combination integrated test
    
    * remove dependency in shenyu-bootstrap
    
    * modify java doc
---
 .github/workflows/integrated-test.yml              |   1 +
 shenyu-integrated-test/pom.xml                     |   1 +
 .../shenyu-integrated-test-combination/Dockerfile  |  29 ++++
 .../docker-compose.yml                             |  97 +++++++++++++
 .../shenyu-integrated-test-combination/pom.xml     | 104 ++++++++++++++
 .../script/healthcheck.sh                          |  36 +++++
 .../script/services.list                           |  19 +++
 .../CombinationIntegratedBootstrap.java            |  37 +++++
 .../src/main/resources/application-local.yml       |  53 ++++++++
 .../src/main/resources/application.yml             |  18 +++
 .../test/combination/MultiRequestPluginTest.java   | 150 +++++++++++++++++++++
 11 files changed, 545 insertions(+)

diff --git a/.github/workflows/integrated-test.yml 
b/.github/workflows/integrated-test.yml
index 2251bba..3d0cef1 100644
--- a/.github/workflows/integrated-test.yml
+++ b/.github/workflows/integrated-test.yml
@@ -34,6 +34,7 @@ jobs:
           - shenyu-integrated-test-spring-cloud
           - shenyu-integrated-test-sofa
           - shenyu-integrated-test-websocket
+          - shenyu-integrated-test-combination
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
diff --git a/shenyu-integrated-test/pom.xml b/shenyu-integrated-test/pom.xml
index e1fb5b3..3813ee2 100644
--- a/shenyu-integrated-test/pom.xml
+++ b/shenyu-integrated-test/pom.xml
@@ -38,6 +38,7 @@
         <module>shenyu-integrated-test-motan</module>
         <module>shenyu-integrated-test-sofa</module>
         <module>shenyu-integrated-test-websocket</module>
+        <module>shenyu-integrated-test-combination</module>
     </modules>
 
     <properties>
diff --git 
a/shenyu-integrated-test/shenyu-integrated-test-combination/Dockerfile 
b/shenyu-integrated-test/shenyu-integrated-test-combination/Dockerfile
new file mode 100644
index 0000000..c3cf22e
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-combination/Dockerfile
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM java:openjdk-8-jre-alpine
+
+ENV APP_NAME shenyu-integrated-test-combination
+ENV LOCAL_PATH /opt/${APP_NAME}
+
+RUN mkdir -p ${LOCAL_PATH}
+
+ADD target/${APP_NAME}.jar ${LOCAL_PATH}
+
+WORKDIR ${LOCAL_PATH}
+EXPOSE 9195
+
+CMD java -jar ${APP_NAME}.jar
diff --git 
a/shenyu-integrated-test/shenyu-integrated-test-combination/docker-compose.yml 
b/shenyu-integrated-test/shenyu-integrated-test-combination/docker-compose.yml
new file mode 100644
index 0000000..efbd5d0
--- /dev/null
+++ 
b/shenyu-integrated-test/shenyu-integrated-test-combination/docker-compose.yml
@@ -0,0 +1,97 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+version: "3.9"
+services:
+  shenyu-zk:
+    container_name: shenyu-zk
+    image: zookeeper:3.5
+    restart: always
+    networks:
+      - shenyu
+  shenyu-redis:
+    image: redis:6.0-alpine
+    container_name: shenyu-redis
+    restart: always
+    command: redis-server --requirepass abc
+    networks:
+      - shenyu
+    healthcheck:
+      test: [ "CMD", "redis-cli", "ping" ]
+
+  shenyu-examples-http:
+    deploy:
+      resources:
+        limits:
+          memory: 2048M
+    container_name: shenyu-examples-http
+    image: shenyu-examples-http:latest
+    restart: always
+    environment:
+      - shenyu.register.serverLists=http://shenyu-admin:9095
+    healthcheck:
+      test: [ "CMD", "wget", 
"http://shenyu-examples-http:8189/test/path/123?name=tom"; ]
+      timeout: 2s
+      retries: 30
+    ports:
+      - 8189:8189
+    depends_on:
+      shenyu-integrated-test-combination:
+        condition: service_healthy
+    networks:
+      - shenyu
+
+  shenyu-admin:
+    image: apache/shenyu-admin:2.4.2-SNAPSHOT
+    container_name: shenyu-admin
+    restart: always
+    networks:
+      - shenyu
+    depends_on:
+      shenyu-redis:
+        condition: service_healthy
+    ports:
+      - 9095:9095
+    environment:
+      - SPRING_PROFILES_ACTIVE=h2
+      - "shenyu.database.init_script=sql-script/h2/schema.sql"
+    healthcheck:
+      test: ["CMD-SHELL", "wget -q -O - 
http://shenyu-admin:9095/actuator/health | grep UP || exit 1"]
+      timeout: 2s
+      retries: 30
+
+  shenyu-integrated-test-combination:
+    container_name: shenyu-integrated-test-combination
+    image: apache/shenyu-integrated-test-combination:latest
+    restart: always
+    deploy:
+      resources:
+        limits:
+          memory: 2048M
+    depends_on:
+      shenyu-admin:
+        condition: service_healthy
+    ports:
+      - 9195:9195
+    networks:
+      - shenyu
+    healthcheck:
+      test: [ "CMD", "wget", 
"http://shenyu-integrated-test-combination:9195/actuator/health"; ]
+      timeout: 2s
+      retries: 30
+
+networks:
+  shenyu:
+    name: shenyu
diff --git a/shenyu-integrated-test/shenyu-integrated-test-combination/pom.xml 
b/shenyu-integrated-test/shenyu-integrated-test-combination/pom.xml
new file mode 100644
index 0000000..3bafdfc
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-combination/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>shenyu-integrated-test</artifactId>
+        <groupId>org.apache.shenyu</groupId>
+        <version>2.4.2-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>shenyu-integrated-test-combination</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shenyu</groupId>
+            <artifactId>shenyu-integrated-test-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.shenyu</groupId>
+            <artifactId>shenyu-spring-boot-starter-plugin-divide</artifactId>
+            <version>${shenyu.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.shenyu</groupId>
+            <artifactId>shenyu-spring-boot-starter-plugin-cryptor</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.shenyu</groupId>
+            
<artifactId>shenyu-spring-boot-starter-plugin-param-mapping</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>shenyu-integrated-test-combination</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot.version}</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    
<mainClass>org.apache.shenyu.integrated.test.combination.CombinationIntegratedBootstrap</mainClass>
+                    <executable>true</executable>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>dockerfile-maven-plugin</artifactId>
+                <version>${dockerfile-maven-plugin.version}</version>
+                <executions>
+                    <execution>
+                        <id>shenyu-integrated-test-combination</id>
+                        <goals>
+                            <goal>build</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    
<repository>apache/shenyu-integrated-test-combination</repository>
+                    <tag>latest</tag>
+                    <buildArgs>
+                        <APP_NAME>shenyu-integrated-test-combination</APP_NAME>
+                    </buildArgs>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git 
a/shenyu-integrated-test/shenyu-integrated-test-combination/script/healthcheck.sh
 
b/shenyu-integrated-test/shenyu-integrated-test-combination/script/healthcheck.sh
new file mode 100644
index 0000000..22a7603
--- /dev/null
+++ 
b/shenyu-integrated-test/shenyu-integrated-test-combination/script/healthcheck.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+PRGDIR=`dirname "$0"`
+for service in `grep -v -E "^$|^#" ${PRGDIR}/services.list`
+do
+    for loop in `seq 1 30`
+    do
+        status=`curl -o /dev/null -s -w %{http_code} $service`
+        echo -e "curl $service response $status"
+
+        if [ $status -eq 200  ]; then
+            break
+        fi
+
+        sleep 2
+    done
+done
+
+sleep 3
+echo -e "\n-------------------"
diff --git 
a/shenyu-integrated-test/shenyu-integrated-test-combination/script/services.list
 
b/shenyu-integrated-test/shenyu-integrated-test-combination/script/services.list
new file mode 100644
index 0000000..e48dc7e
--- /dev/null
+++ 
b/shenyu-integrated-test/shenyu-integrated-test-combination/script/services.list
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+http://localhost:9095/actuator/health
+http://localhost:8189/test/path/123?name=tom
+http://localhost:9195/actuator/health
diff --git 
a/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/java/org/apache/shenyu/integrated/test/combination/CombinationIntegratedBootstrap.java
 
b/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/java/org/apache/shenyu/integrated/test/combination/CombinationIntegratedBootstrap.java
new file mode 100644
index 0000000..3f94b5d
--- /dev/null
+++ 
b/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/java/org/apache/shenyu/integrated/test/combination/CombinationIntegratedBootstrap.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.integrated.test.combination;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * The combination integrated bootstrap.
+ */
+@SpringBootApplication
+public class CombinationIntegratedBootstrap {
+
+    /**
+     * main method of App.
+     *
+     * @param args args
+     */
+    public static void main(final String[] args) {
+        SpringApplication.run(CombinationIntegratedBootstrap.class);
+    }
+}
diff --git 
a/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/resources/application-local.yml
 
b/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/resources/application-local.yml
new file mode 100644
index 0000000..c35f578
--- /dev/null
+++ 
b/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/resources/application-local.yml
@@ -0,0 +1,53 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+server:
+  port: 9195
+  address: 0.0.0.0
+
+spring:
+  main:
+    allow-bean-definition-overriding: true
+  application:
+    name: shenyu-bootstrap
+
+management:
+  health:
+    defaults:
+      enabled: false
+
+shenyu:
+  switchConfig:
+    local: true
+  cross:
+    enabled: true
+  sync:
+    websocket:
+      urls: ws://shenyu-admin:9095/websocket
+  exclude:
+    enabled: true
+    paths:
+      - /favicon.ico
+      - /actuator/health
+
+logging:
+  level:
+    root: info
+    org.springframework.boot: info
+    org.apache.ibatis: info
+    org.apache.shenyu.bonuspoint: info
+    org.apache.shenyu.lottery: info
+    org.apache.shenyu: info
+
diff --git 
a/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/resources/application.yml
 
b/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/resources/application.yml
new file mode 100644
index 0000000..393ad24
--- /dev/null
+++ 
b/shenyu-integrated-test/shenyu-integrated-test-combination/src/main/resources/application.yml
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+spring:
+  profiles:
+    active: local
diff --git 
a/shenyu-integrated-test/shenyu-integrated-test-combination/src/test/java/org/apache/shenyu/integrated/test/combination/MultiRequestPluginTest.java
 
b/shenyu-integrated-test/shenyu-integrated-test-combination/src/test/java/org/apache/shenyu/integrated/test/combination/MultiRequestPluginTest.java
new file mode 100644
index 0000000..95be896
--- /dev/null
+++ 
b/shenyu-integrated-test/shenyu-integrated-test-combination/src/test/java/org/apache/shenyu/integrated/test/combination/MultiRequestPluginTest.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.integrated.test.combination;
+
+import com.google.gson.JsonObject;
+import org.apache.shenyu.common.dto.ConditionData;
+import org.apache.shenyu.common.dto.convert.rule.RuleHandle;
+import org.apache.shenyu.common.dto.convert.rule.impl.ParamMappingRuleHandle;
+import org.apache.shenyu.common.enums.OperatorEnum;
+import org.apache.shenyu.common.enums.ParamTypeEnum;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.common.utils.JsonUtils;
+import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
+import org.apache.shenyu.integratedtest.common.dto.UserDTO;
+import org.apache.shenyu.integratedtest.common.helper.HttpHelper;
+import org.apache.shenyu.plugin.cryptor.handler.CryptorRuleHandler;
+import org.apache.shenyu.plugin.cryptor.strategy.RsaStrategy;
+import org.apache.shenyu.web.controller.LocalPluginController.RuleLocalData;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * The integrated test for combination plugins about request.
+ */
+public final class MultiRequestPluginTest extends AbstractPluginDataInit {
+
+    private static final String RSA_PRIVATE_KEY = 
"MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAvEXyUDh5qliWhM6KrpTFi1OXumoJQzMfSr8XjfKa/kHKb1uxr7N8lJd3I850m2IYrxckFCQW6nrnRKctm"
+            + 
"iMgZQIDAQABAkBEFbdvMz0sUST9mgOk5sAZhn1UOIxo9M/YJArMlnNehqQs3Pv8RD6ASisgs19XnBhcUNdl2ecfxddp7OVQ6PVxAiEA+XagQdbwkFrEjUsPqPQTweKkc7aoVGJfifEGWvCKtAcCIQDBNN0K5vlVV5YKnA5WtDAN"
+            + 
"K31oRGjTJe5D94IRYRHlMwIgQUH++jo4BAs6j5urJQ90e6vGSV7m+ewiAfvDJdb28dECIQCW9r9grWlVDcLnN1jc1p5VLA4pUoq1sYWjBdpTyg05kQIhAJUSfs1+gDFtCRekCwvn5QEnxJVJXD6SQPAPkEHS9Drb";
+
+    private static final String RSA_PUBLIC_KEY = 
"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALxF8lA4eapYloTOiq6UxYtTl7pqCUMzH0q/F43ymv5Bym9bsa+zfJSXdyPOdJtiGK8XJBQkFup650SnLZojIGUCAwEAAQ==";
+
+    private static final String TEST_PATH = "/http/test/payment";
+
+    private static final String TEST_USER_ID = "10001";
+
+    private static final String TEST_USER_NAME = "user_name";
+
+    private static final RsaStrategy RSA_STRATEGY = new RsaStrategy();
+
+    private void setupParamMapping() throws IOException {
+        String paramMappingRet = 
initPlugin(PluginEnum.PARAM_MAPPING.getName(), 
"{\"ruleHandlePageType\":\"custom\"}");
+        assertThat(paramMappingRet, is("success"));
+        String selectorAndRulesRet4ParamMapping = 
initSelectorAndRules(PluginEnum.PARAM_MAPPING.getName(), "", 
buildSelectorConditionList(), buildRuleLocalDataList4ParamMapping());
+        assertThat(selectorAndRulesRet4ParamMapping, is("success"));
+    }
+
+    private void setupCryptorRequest() throws IOException {
+        String cryptorRequestRet = 
initPlugin(PluginEnum.CRYPTOR_REQUEST.getName(), null);
+        assertThat(cryptorRequestRet, is("success"));
+        String selectorAndRulesResult = 
initSelectorAndRules(PluginEnum.CRYPTOR_REQUEST.getName(), "", 
buildSelectorConditionList(), buildRuleLocalDataList4CryptorRequest());
+        assertThat(selectorAndRulesResult, is("success"));
+    }
+
+    /**
+     * The combination test of cryptor request plugin and param mapping plugin.
+     */
+    @Test
+    public void testCryptorRequestAndParamMapping() throws Exception {
+        setupParamMapping();
+        setupCryptorRequest();
+
+        JsonObject request = new JsonObject();
+        request.addProperty("userId", TEST_USER_ID);
+        UserDTO actualUser = HttpHelper.INSTANCE.postGateway(TEST_PATH, 
request, UserDTO.class);
+
+        assertThat(RSA_STRATEGY.decrypt(RSA_PRIVATE_KEY, 
actualUser.getUserName()), is(TEST_USER_NAME));
+        assertThat(actualUser.getUserId(), is(TEST_USER_ID));
+
+        cleanParamMapping();
+        cleanCryptorRequest();
+    }
+
+    private List<ConditionData> buildSelectorConditionList() {
+        ConditionData conditionData = new ConditionData();
+        conditionData.setParamType(ParamTypeEnum.URI.getName());
+        conditionData.setOperator(OperatorEnum.MATCH.getAlias());
+        conditionData.setParamValue("/http/**");
+        return Collections.singletonList(conditionData);
+    }
+
+    private RuleLocalData buildRuleLocalData(final RuleHandle handle) {
+        RuleLocalData ruleLocalData = new RuleLocalData();
+        Optional.ofNullable(handle).ifPresent(ruleHandle -> 
ruleLocalData.setRuleHandler(JsonUtils.toJson(ruleHandle)));
+        ConditionData conditionData = new ConditionData();
+        conditionData.setParamType(ParamTypeEnum.URI.getName());
+        conditionData.setOperator(OperatorEnum.EQ.getAlias());
+        conditionData.setParamValue(TEST_PATH);
+        
ruleLocalData.setConditionDataList(Collections.singletonList(conditionData));
+        return ruleLocalData;
+    }
+
+    private List<RuleLocalData> buildRuleLocalDataList4ParamMapping() {
+        final List<RuleLocalData> ruleLocalDataList = new ArrayList<>();
+
+        // prepare for addParameterKeys
+        final ParamMappingRuleHandle addAndRemoveHandle = new 
ParamMappingRuleHandle();
+        ParamMappingRuleHandle.ParamMapInfo addInfo = new 
ParamMappingRuleHandle.ParamMapInfo();
+        addInfo.setPath("$");
+        addInfo.setKey("userName");
+        addInfo.setValue(TEST_USER_NAME);
+        
addAndRemoveHandle.setAddParameterKeys(Collections.singletonList(addInfo));
+        ruleLocalDataList.add(buildRuleLocalData(addAndRemoveHandle));
+
+        return ruleLocalDataList;
+    }
+
+    private List<RuleLocalData> buildRuleLocalDataList4CryptorRequest() {
+        CryptorRuleHandler cryptorRuleHandler = new CryptorRuleHandler();
+        cryptorRuleHandler.setDecryptKey(RSA_PRIVATE_KEY);
+        cryptorRuleHandler.setEncryptKey(RSA_PUBLIC_KEY);
+        cryptorRuleHandler.setStrategyName("rsa");
+        cryptorRuleHandler.setFieldNames("userName");
+        cryptorRuleHandler.setWay("encrypt");
+        return 
Collections.singletonList(buildRuleLocalData(cryptorRuleHandler));
+    }
+
+    private void cleanParamMapping() throws IOException {
+        String res = cleanPluginData(PluginEnum.PARAM_MAPPING.getName());
+        assertThat(res, is("success"));
+    }
+
+    private void cleanCryptorRequest() throws IOException {
+        String res = cleanPluginData(PluginEnum.CRYPTOR_REQUEST.getName());
+        assertThat(res, is("success"));
+    }
+}

Reply via email to