Skip to content

Commit

Permalink
fix: workflow plugin should support operator (apache#8121)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyDluffy6017 authored and Liu-Junlin committed Nov 4, 2022
1 parent fd4695b commit 41d7dae
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apisix/plugins/workflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ local schema = {
case = {
type = "array",
items = {
type = "array",
anyOf = {
{
type = "array",
},
{
type = "string",
},
}
},
minItems = 1,
},
Expand Down
60 changes: 60 additions & 0 deletions t/plugin/workflow.t
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

0 comments on commit 41d7dae

Please sign in to comment.