You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/10/19 11:24:54 UTC
[apisix] branch master updated: fix: workflow plugin should support operator (#8121)
This is an automated email from the ASF dual-hosted git repository.
spacewander 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 332928e0d fix: workflow plugin should support operator (#8121)
332928e0d is described below
commit 332928e0d2c519b68279273394687ac72e492c38
Author: levy liu <37...@qq.com>
AuthorDate: Wed Oct 19 19:24:45 2022 +0800
fix: workflow plugin should support operator (#8121)
---
apisix/plugins/workflow.lua | 9 ++++++-
t/plugin/workflow.t | 60 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/apisix/plugins/workflow.lua b/apisix/plugins/workflow.lua
index a586a923b..5adb5b455 100644
--- a/apisix/plugins/workflow.lua
+++ b/apisix/plugins/workflow.lua
@@ -30,7 +30,14 @@ local schema = {
case = {
type = "array",
items = {
- type = "array",
+ anyOf = {
+ {
+ type = "array",
+ },
+ {
+ type = "string",
+ },
+ }
},
minItems = 1,
},
diff --git a/t/plugin/workflow.t b/t/plugin/workflow.t
index e1bf77a1f..422577b27 100644
--- a/t/plugin/workflow.t
+++ b/t/plugin/workflow.t
@@ -687,3 +687,63 @@ passed
"GET /hello", "GET /hello1", "GET /hello", "GET /hello1"]
--- error_code eval
[200, 200, 200, 200, 200, 200, 503, 503]
+
+
+
+=== TEST 19: multiple conditions in one case
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "workflow": {
+ "rules": [
+ {
+ "case": [
+ "OR",
+ ["arg_foo", "==", "bar"],
+ ["uri", "==", "/hello"]
+ ],
+ "actions": [
+ [
+ "return",
+ {
+ "code": 403
+ }
+ ]
+ ]
+ }
+ ]
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin"
+ },
+ "uri": "/hello"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+
+ ngx.say(body)
+ }
+ }
+--- response_body
+passed
+
+
+
+=== TEST 20: trigger workflow
+--- request
+GET /hello
+--- error_code: 403
+--- response_body
+{"error_msg":"rejected by workflow"}