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 9c3ee33ef fix(workflow): enhance schema check (#9782)
9c3ee33ef is described below

commit 9c3ee33ef085e0d27b65ca8b2de8ec809a02d6c0
Author: Fucheng Jiang <[email protected]>
AuthorDate: Fri Jul 7 11:48:48 2023 +0800

    fix(workflow): enhance schema check (#9782)
---
 apisix/plugins/workflow.lua |  3 ++-
 t/plugin/workflow2.t        | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/apisix/plugins/workflow.lua b/apisix/plugins/workflow.lua
index 4a8153f43..73d68375d 100644
--- a/apisix/plugins/workflow.lua
+++ b/apisix/plugins/workflow.lua
@@ -52,7 +52,8 @@ local schema = {
                 required = {"case", "actions"}
             }
         }
-    }
+    },
+    required = {"rules"}
 }
 
 local plugin_name = "workflow"
diff --git a/t/plugin/workflow2.t b/t/plugin/workflow2.t
index e2f158f13..686e4bb13 100644
--- a/t/plugin/workflow2.t
+++ b/t/plugin/workflow2.t
@@ -279,3 +279,40 @@ passed
 ["GET /hello", "GET /hello1", "GET /hello", "GET /hello1"]
 --- error_code eval
 [200, 200, 503, 200]
+
+
+
+=== TEST 8: test no rules
+--- config
+    location /t {
+        content_by_lua_block {
+            local json = require("toolkit.json")
+            local t = require("lib.test_admin").test
+            local data = {
+                uri = "/*",
+                plugins = {
+                    workflow = {
+                    }
+                },
+                upstream = {
+                    nodes = {
+                        ["127.0.0.1:1980"] = 1
+                    },
+                    type = "roundrobin"
+                }
+            }
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 json.encode(data)
+            )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+
+            ngx.print(body)
+        }
+    }
+--- error_code: 400
+--- response_body
+{"error_msg":"failed to check the configuration of plugin workflow err: 
property \"rules\" is required"}

Reply via email to