Skip to content

Commit daa2c14

Browse files
thibaultchazhuizhuhaomeng
authored andcommitted
tests: add ngx.exit() input sanitization tests
See openresty/lua-nginx-module#969
1 parent 94836cf commit daa2c14

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

t/exit.t

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,94 @@ GET /t
7878
["[error]",
7979
qr/ -- NYI: (?!FastFunc coroutine.yield)/,
8080
" bad argument"]
81+
82+
83+
84+
=== TEST 3: accepts NGX_OK
85+
--- config
86+
location = /t {
87+
content_by_lua_block {
88+
ngx.exit(ngx.OK)
89+
}
90+
}
91+
--- request
92+
GET /t
93+
--- response_body
94+
--- no_error_log eval
95+
["[error]",
96+
qr/ -- NYI: (?!FastFunc coroutine.yield)/,
97+
" bad argument"]
98+
99+
100+
101+
=== TEST 4: accepts NGX_ERROR
102+
--- config
103+
location = /t {
104+
content_by_lua_block {
105+
ngx.exit(ngx.ERROR)
106+
}
107+
}
108+
--- request
109+
GET /t
110+
--- error_code:
111+
--- response_body
112+
--- no_error_log eval
113+
["[error]",
114+
qr/ -- NYI: (?!FastFunc coroutine.yield)/,
115+
" bad argument"]
116+
117+
118+
119+
=== TEST 5: accepts NGX_DECLINED
120+
--- config
121+
location = /t {
122+
content_by_lua_block {
123+
ngx.exit(ngx.DECLINED)
124+
}
125+
}
126+
--- request
127+
GET /t
128+
--- error_code:
129+
--- response_body
130+
--- no_error_log eval
131+
["[error]",
132+
qr/ -- NYI: (?!FastFunc coroutine.yield)/,
133+
" bad argument"]
134+
135+
136+
137+
=== TEST 6: refuses NGX_AGAIN
138+
--- config
139+
location = /t {
140+
content_by_lua_block {
141+
ngx.exit(ngx.AGAIN)
142+
}
143+
}
144+
--- request
145+
GET /t
146+
--- response_body_like: 500 Internal Server Error
147+
--- error_code: 500
148+
--- error_log eval
149+
qr/\[error\] .*? bad argument to 'ngx.exit': does not accept NGX_AGAIN or NGX_DONE/
150+
--- no_error_log eval
151+
qr/ -- NYI: (?!FastFunc coroutine.yield)/
152+
[crit]
153+
154+
155+
156+
=== TEST 7: refuses NGX_DONE
157+
--- config
158+
location = /t {
159+
content_by_lua_block {
160+
ngx.exit(ngx.DONE)
161+
}
162+
}
163+
--- request
164+
GET /t
165+
--- response_body_like: 500 Internal Server Error
166+
--- error_code: 500
167+
--- error_log eval
168+
qr/\[error\] .*? bad argument to 'ngx.exit': does not accept NGX_AGAIN or NGX_DONE/
169+
--- no_error_log eval
170+
qr/ -- NYI: (?!FastFunc coroutine.yield)/
171+
[crit]

0 commit comments

Comments
 (0)