okaybase commented on a change in pull request #4849:
URL: https://github.com/apache/apisix/pull/4849#discussion_r692820457



##########
File path: t/plugin/uri-blocker.t
##########
@@ -332,3 +332,59 @@ GET /hello?name=;union%20select%20
 GET /hello?cc=2
 --- no_error_log
 [error]
+
+
+
+=== TEST 16: invalid rejected_msg length or type
+--- config
+location /t {
+    content_by_lua_block {
+        local data = {
+            {
+                input = {
+                    plugins = {
+                        ["uri-blocker"] = {
+                            block_rules = { "^a" },
+                            rejected_msg = "",
+                        },
+                    },
+                    uri = "/hello",
+                },
+                output = {
+                    error_msg = "failed to check the configuration of plugin 
uri-blocker err: property \"rejected_msg\" validation failed: string too short, 
expected at least 1, got 0",
+                },
+            },
+            {
+                input = {
+                    plugins = {
+                        ["uri-blocker"] = {
+                            block_rules = { "^a" },
+                            rejected_msg = true,
+                        },
+                    },
+                    uri = "/hello",
+                },
+                output = {
+                    error_msg = "failed to check the configuration of plugin 
uri-blocker err: property \"rejected_msg\" validation failed: wrong type: 
expected string, got boolean",
+                },
+            },
+        }
+
+        local t = require("lib.test_admin").test
+        local err_count = 0
+        for i in ipairs(data) do
+            local code, body = t('/apisix/admin/routes/1', ngx.HTTP_PUT, 
data[i].input, data[i].output)
+
+            if code >= 300 then
+                err_count = err_count + 1
+            end
+            ngx.print(body)
+        end
+
+        assert(err_count == #data)
+    }
+}
+--- request
+GET /t
+--- no_error_log
+[error]

Review comment:
       okay, done~




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to