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 07:38:05 UTC

[GitHub] [apisix] spacewander opened a new pull request #2416: feat: use interceptors to protect plugin's route

spacewander opened a new pull request #2416:
URL: https://github.com/apache/apisix/pull/2416


   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible?
   
   TODO: add doc


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #2416:
URL: https://github.com/apache/apisix/pull/2416#discussion_r504493370



##########
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:
       would be better to add spaces here




----------------------------------------------------------------
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



[GitHub] [apisix] spacewander merged pull request #2416: feat: use interceptors to protect plugin's route

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #2416:
URL: https://github.com/apache/apisix/pull/2416


   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
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 
   Updated




----------------------------------------------------------------
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