Skip to content

Commit

Permalink
fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
lilien1010 committed Feb 12, 2021
1 parent 6bbe7ea commit c0f146e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions apisix/plugins/response-rewrite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ local _M = {

local function vars_matched(conf, ctx)
if not conf.vars then
return false
return true
end

if not conf.response_expr then
local response_expr, _ = expr.new(conf.vars)
conf.response_expr = response_expr
end

local match_result = conf.response_expr:eval(ctx.vars)
local match_result = conf.response_expr:eval(ctx.var)

return match_result
end
Expand Down Expand Up @@ -128,7 +128,7 @@ do
function _M.body_filter(conf, ctx)

local ok = vars_matched(conf, ctx)
if ok then
if not ok then
return
end

Expand All @@ -147,7 +147,7 @@ end
function _M.header_filter(conf, ctx)

local ok = vars_matched(conf, ctx)
if ok then
if not ok then
return
end

Expand Down
4 changes: 4 additions & 0 deletions t/APISIX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ apisix:
tcp:
- 9100
admin_key: null
etcd:
host:
- "http://172.19.4.10:2479"
prefix: "/apisix"
_EOC_

my $etcd_enable_auth = $ENV{"ETCD_ENABLE_AUTH"} || "false";
Expand Down
6 changes: 3 additions & 3 deletions t/plugin/response-rewrite.t
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ property "body" validation failed: wrong type: expected string, got number
"headers" : {
"X-Server-id": 3,
"X-Server-status": "on",
"Content-Type": "22"
"Content-Type": ""
},
"body": "new body\n"
}
Expand Down Expand Up @@ -561,8 +561,8 @@ GET /server_error
new body3
--- error_code eval
403
--- no_error_log
[error]
--- error_log
500 Internal Server Error



Expand Down

0 comments on commit c0f146e

Please sign in to comment.