You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/10/14 09:03:51 UTC

[GitHub] [apisix] spacewander commented on a change in pull request #2416: feat: use interceptors to protect plugin's route

spacewander commented on a change in pull request #2416:
URL: https://github.com/apache/apisix/pull/2416#discussion_r504519026



##########
File path: t/admin/plugin-metadata.t
##########
@@ -237,65 +237,217 @@ GET /t
 
 
 
-=== TEST 8: no plugin metadata schema
+=== TEST 8: verify metadata schema fail
 --- config
     location /t {
         content_by_lua_block {
             local t = require("lib.test_admin").test
-            local code, body = t('/apisix/admin/plugin_metadata/echo',
-                 ngx.HTTP_PUT,
-                 [[{"k": "v"}]],
+            local code, body = t('/apisix/admin/plugin_metadata/example-plugin',
+                ngx.HTTP_PUT,
+                [[{
+                    "skey": "val"
+                }]],
                 [[{
                     "node": {
-                        "value": "sdf"
+                        "value": {
+                            "skey": "val",
+                            "ikey": 1
+                        }
                     },
                     "action": "set"
                 }]]
                 )
 
             ngx.status = code
-            ngx.print(body)
+            ngx.say(body)
         }
     }
 --- request
 GET /t
 --- error_code: 400
+--- response_body eval
+qr/\{"error_msg":"invalid configuration: property \\"ikey\\" is required"\}/
+--- no_error_log
+[error]
+
+
+
+=== TEST 9: set plugin interceptors
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/plugin_metadata/prometheus',
+                ngx.HTTP_PUT,
+                [[{
+                    "interceptors": [
+                        {
+                        "name": "ip-restriction",

Review comment:
       @justinmclean 
   Tweak




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org