From c6e5a20a818ae29ca91087ddff8fc2c531a8b1cb Mon Sep 17 00:00:00 2001 From: tanghc Date: Fri, 11 Sep 2020 15:45:13 +0800 Subject: [PATCH] 4.0.3 --- .../gitee/sop/gatewaycommon/validate/ApiValidator.java | 10 +++++----- .../src/test/java/com/gitee/sop/test/AllInOneTest.java | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java index 4f6c7549..63061a70 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java @@ -74,13 +74,13 @@ public class ApiValidator implements Validator { if (apiConfig.isIgnoreValidate() || BooleanUtils.toBoolean(targetRoute.getRouteDefinition().getIgnoreValidate())) { if (log.isDebugEnabled()) { - log.debug("忽略所有验证(ignoreValidate=true), name:{}, version:{}", param.fetchName(), param.fetchVersion()); + log.debug("忽略签名校验, name:{}, version:{}", param.fetchName(), param.fetchVersion()); } - return; + } else { + // 需要验证签名,先校验appKey,后校验签名,顺序不能变 + checkAppKey(param); + checkSign(param); } - // 需要验证签名,先校验appKey,后校验签名,顺序不能变 - checkAppKey(param); - checkSign(param); checkTimeout(param); checkFormat(param); checkUploadFile(param); diff --git a/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java b/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java index cae5bd1b..aa03b55c 100644 --- a/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java +++ b/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java @@ -1,6 +1,7 @@ package com.gitee.sop.test; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -285,9 +286,11 @@ public class AllInOneTest extends TestBase { .bizContent(new BizContent().add("id", "1").add("name", "葫芦娃")) .httpMethod(HttpTool.HTTPMethod.GET) .callback((requestInfo, responseData) -> { - int size = JSON.parseObject(responseData) - .getJSONObject("bigdata_get_response") - .getJSONArray("data").size(); + int size = Optional.ofNullable(JSON.parseObject(responseData)) + .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getJSONObject("bigdata_get_response"))) + .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getJSONArray("data"))) + .map(JSONArray::size) + .orElse(0); Assert.assertEquals(size, 2000); });