Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workflow plugin should support operator #8121

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"}