~spuul/nginx/trunk

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/t/045-ngx-var.t

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-02-15 03:05:42 UTC
  • mfrom: (4.3.10 sid)
  • Revision ID: package-import@ubuntu.com-20140215030542-71ubtowl24vf7nfn
Tags: 1.4.5-1ubuntu1
* Resynchronise with Debian (LP: #1280511).  Remaining changes:
  - debian/patches/ubuntu-branding.patch:
    + Add Ubuntu branding to server_tokens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# vim:set ft= ts=4 sw=4 et fdm=marker:
2
2
use lib 'lib';
3
 
use Test::Nginx::Socket;
 
3
use Test::Nginx::Socket::Lua;
4
4
 
5
5
#worker_connections(1014);
6
6
#master_process_enabled(1);
8
8
 
9
9
repeat_each(2);
10
10
 
11
 
plan tests => repeat_each() * (blocks() * 2);
 
11
plan tests => repeat_each() * (blocks() * 2 + 7);
12
12
 
13
13
#no_diff();
14
 
no_long_string();
 
14
#no_long_string();
15
15
#master_on();
16
16
#workers(2);
17
17
run_tests();
103
103
--- response_body
104
104
value: 32
105
105
 
 
106
 
 
107
 
 
108
=== TEST 6: true $invalid_referer variable value in Lua
 
109
github issue #239
 
110
--- config
 
111
    location = /t {
 
112
        valid_referers www.foo.com;
 
113
        content_by_lua '
 
114
            ngx.say("invalid referer: ", ngx.var.invalid_referer)
 
115
            ngx.exit(200)
 
116
        ';
 
117
        #echo $invalid_referer;
 
118
    }
 
119
 
 
120
--- request
 
121
GET /t
 
122
--- more_headers
 
123
Referer: http://www.foo.com/
 
124
 
 
125
--- response_body
 
126
invalid referer: 
 
127
 
 
128
--- no_error_log
 
129
[error]
 
130
 
 
131
 
 
132
 
 
133
=== TEST 7: false $invalid_referer variable value in Lua
 
134
github issue #239
 
135
--- config
 
136
    location = /t {
 
137
        valid_referers www.foo.com;
 
138
        content_by_lua '
 
139
            ngx.say("invalid referer: ", ngx.var.invalid_referer)
 
140
            ngx.exit(200)
 
141
        ';
 
142
        #echo $invalid_referer;
 
143
    }
 
144
 
 
145
--- request
 
146
GET /t
 
147
--- more_headers
 
148
Referer: http://www.bar.com
 
149
 
 
150
--- response_body
 
151
invalid referer: 1
 
152
 
 
153
--- no_error_log
 
154
[error]
 
155
 
 
156
 
 
157
 
 
158
=== TEST 8: $proxy_host & $proxy_port
 
159
--- config
 
160
    location = /t {
 
161
        proxy_pass http://127.0.0.1:$server_port/back;
 
162
        header_filter_by_lua '
 
163
            ngx.header["Proxy-Host"] = ngx.var.proxy_host
 
164
            ngx.header["Proxy-Port"] = ngx.var.proxy_port
 
165
        ';
 
166
    }
 
167
 
 
168
    location = /back {
 
169
        echo hello;
 
170
    }
 
171
--- request
 
172
GET /t
 
173
--- raw_response_headers_like
 
174
Proxy-Host: 127.0.0.1\:\d+\r
 
175
Proxy-Port: \d+\r
 
176
--- response_body
 
177
hello
 
178
--- no_error_log
 
179
[error]
 
180
 
 
181
 
 
182
 
 
183
=== TEST 9: get a bad variable name
 
184
--- config
 
185
    location = /test {
 
186
        set $true 32;
 
187
        content_by_lua '
 
188
            ngx.say("value: ", ngx.var[true])
 
189
        ';
 
190
    }
 
191
--- request
 
192
GET /test
 
193
--- response_body_like: 500 Internal Server Error
 
194
--- error_log
 
195
bad variable name
 
196
--- error_code: 500
 
197
 
 
198
 
 
199
 
 
200
=== TEST 10: set a bad variable name
 
201
--- config
 
202
    location = /test {
 
203
        set $true 32;
 
204
        content_by_lua '
 
205
            ngx.var[true] = 56
 
206
        ';
 
207
    }
 
208
--- request
 
209
GET /test
 
210
--- response_body_like: 500 Internal Server Error
 
211
--- error_log
 
212
bad variable name
 
213
--- error_code: 500
 
214
 
 
215
 
 
216
 
 
217
=== TEST 11: set a variable that is not changeable
 
218
--- config
 
219
    location = /test {
 
220
        content_by_lua '
 
221
            ngx.var.query_string = 56
 
222
        ';
 
223
    }
 
224
--- request
 
225
GET /test?hello
 
226
--- response_body_like: 500 Internal Server Error
 
227
--- error_log
 
228
variable "query_string" not changeable
 
229
--- error_code: 500
 
230