You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by we...@apache.org on 2020/10/21 12:34:43 UTC

[apisix] branch master updated: fix: compare if the interceptors are injected by ourselves (#2484)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0f15939  fix: compare if the interceptors are injected by ourselves (#2484)
0f15939 is described below

commit 0f15939a9cc5906cffc58e9963d6e703a576e3d4
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Wed Oct 21 20:34:32 2020 +0800

    fix: compare if the interceptors are injected by ourselves (#2484)
    
    fix #2482.
---
 apisix/admin/plugin_metadata.lua |  4 +++-
 apisix/api_router.lua            |  1 +
 t/admin/plugin-metadata.t        | 23 +++++++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/apisix/admin/plugin_metadata.lua b/apisix/admin/plugin_metadata.lua
index cc59b56..be9b796 100644
--- a/apisix/admin/plugin_metadata.lua
+++ b/apisix/admin/plugin_metadata.lua
@@ -61,7 +61,9 @@ local function check_conf(plugin_name, conf)
     end
 
     -- inject interceptors schema to each plugins
-    if schema.properties.interceptors then
+    if schema.properties.interceptors
+      and api_router.interceptors_schema['$comment'] ~= schema.properties.interceptors['$comment']
+    then
         error("'interceptors' can not be used as the name of metadata schema's field")
     end
     schema.properties.interceptors = api_router.interceptors_schema
diff --git a/apisix/api_router.lua b/apisix/api_router.lua
index b805af5..264c478 100644
--- a/apisix/api_router.lua
+++ b/apisix/api_router.lua
@@ -35,6 +35,7 @@ local interceptors = {
 
 
 _M.interceptors_schema = {
+    ["$comment"] = "this is the mark for our interceptors schema",
     type = "array",
     items = {
         type = "object",
diff --git a/t/admin/plugin-metadata.t b/t/admin/plugin-metadata.t
index 233fbf6..834daea 100644
--- a/t/admin/plugin-metadata.t
+++ b/t/admin/plugin-metadata.t
@@ -85,12 +85,35 @@ passed
 
             ngx.status = code
             ngx.say(body)
+
+            -- hit again
+            local code, body = t('/apisix/admin/plugin_metadata/example-plugin',
+                 ngx.HTTP_PUT,
+                 [[{
+                    "skey": "val2",
+                    "ikey": 2
+                 }]],
+                [[{
+                    "node": {
+                        "value": {
+                            "skey": "val2",
+                            "ikey": 2
+                        }
+                    },
+                    "action": "set"
+                }]]
+                )
+
+            ngx.say(code)
+            ngx.say(body)
         }
     }
 --- request
 GET /t
 --- response_body
 passed
+200
+passed
 --- no_error_log
 [error]