Skip to content

Commit efc99dc

Browse files
membphisSaberMaster
authored andcommitted
test: added test cases. (apache#1752)
1 parent a4d23f8 commit efc99dc

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

t/plugin/uri-blocker.t

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,69 @@ GET /hello?c1=2
264264
GET /hello?cc=2
265265
--- no_error_log
266266
[error]
267+
268+
269+
270+
=== TEST 12: SQL injection
271+
--- config
272+
location /t {
273+
content_by_lua_block {
274+
local t = require("lib.test_admin").test
275+
local code, body = t('/apisix/admin/routes/1',
276+
ngx.HTTP_PUT,
277+
[[{
278+
"plugins": {
279+
"uri-blocker": {
280+
"block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
281+
}
282+
},
283+
"upstream": {
284+
"nodes": {
285+
"127.0.0.1:1980": 1
286+
},
287+
"type": "roundrobin"
288+
},
289+
"uri": "/hello"
290+
}]]
291+
)
292+
293+
if code >= 300 then
294+
ngx.status = code
295+
end
296+
ngx.say(body)
297+
}
298+
}
299+
--- request
300+
GET /t
301+
--- response_body
302+
passed
303+
--- no_error_log
304+
[error]
305+
--- error_log
306+
concat block_rules: select.+(from|limit)|(?:(union(.*?)select)),
307+
308+
309+
310+
=== TEST 13: hit block rule
311+
--- request
312+
GET /hello?name=;select%20from%20sys
313+
--- error_code: 403
314+
--- no_error_log
315+
[error]
316+
317+
318+
319+
=== TEST 14: hit block rule
320+
--- request
321+
GET /hello?name=;union%20select%20
322+
--- error_code: 403
323+
--- no_error_log
324+
[error]
325+
326+
327+
328+
=== TEST 15: not hit block rule
329+
--- request
330+
GET /hello?cc=2
331+
--- no_error_log
332+
[error]

0 commit comments

Comments
 (0)