@@ -7,9 +7,18 @@ use Test::Nginx::Socket;
7
7
repeat_each(1);
8
8
9
9
# Each `TEST` in __DATA__ below generates a block for each pattern match
10
- # count
10
+ # count. Increase the magic number accordingly if adding new tests or
11
+ # expanding checks in existing tests (this will add more blocks).
11
12
plan tests => repeat_each() * (50);
12
13
14
+ # Populate config for the dynamic module, if requested
15
+ our $main_config = ' ' ;
16
+ my $SHIB_DYNAMIC_MODULE = $ENV {' SHIB_DYNAMIC_MODULE' };
17
+ if ($SHIB_DYNAMIC_MODULE && $SHIB_DYNAMIC_MODULE eq ' true' ) {
18
+ my $SHIB_MODULE_PATH = $ENV {' SHIB_MODULE_PATH' } ? $ENV {' SHIB_MODULE_PATH' } : ' modules' ;
19
+ $main_config = " load_module $SHIB_MODULE_PATH /ngx_http_headers_more_filter_module.so;
20
+ load_module $SHIB_MODULE_PATH /ngx_http_shibboleth_module.so;" ;
21
+ }
13
22
14
23
our $config = <<'_EOC_' ;
15
24
# 401 must be returned with WWW-Authenticate header
@@ -148,6 +157,7 @@ __DATA__
148
157
149
158
=== TEST 1: Testing 401 response
150
159
--- config eval: $::config
160
+ --- main_config eval: $::main_config
151
161
--- request
152
162
GET /test1
153
163
--- error_code: 401
@@ -159,6 +169,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
159
169
160
170
=== TEST 2: Testing 401 response with main request header
161
171
--- config eval: $::config
172
+ --- main_config eval: $::main_config
162
173
--- request
163
174
GET /test2
164
175
--- error_code: 401
@@ -171,6 +182,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
171
182
172
183
=== TEST 3: Testing 403 response with main request header
173
184
--- config eval: $::config
185
+ --- main_config eval: $::main_config
174
186
--- request
175
187
GET /test3
176
188
--- error_code: 403
@@ -182,6 +194,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
182
194
183
195
=== TEST 4: Testing 403 response with main request header
184
196
--- config eval: $::config
197
+ --- main_config eval: $::main_config
185
198
--- request
186
199
GET /test4
187
200
--- error_code: 403
@@ -193,6 +206,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
193
206
194
207
=== TEST 5: Testing redirection with in-built header addition
195
208
--- config eval: $::config
209
+ --- main_config eval: $::main_config
196
210
--- request
197
211
GET /test5
198
212
--- error_code: 301
@@ -205,6 +219,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
205
219
206
220
=== TEST 6: Testing redirection with subrequest header manipulation in main request
207
221
--- config eval: $::config
222
+ --- main_config eval: $::main_config
208
223
--- request
209
224
GET /test6
210
225
--- error_code: 301
@@ -218,6 +233,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
218
233
219
234
=== TEST 7: Testing successful auth, no leaked variables
220
235
--- config eval: $::config
236
+ --- main_config eval: $::main_config
221
237
--- user_files
222
238
>>> test7
223
239
Hello, world
@@ -237,6 +253,7 @@ qr/copied header/
237
253
238
254
=== TEST 8: Testing successful auth, no leaked variables, main request headers set
239
255
--- config eval: $::config
256
+ --- main_config eval: $::main_config
240
257
--- user_files
241
258
>>> test8
242
259
Hello, world
@@ -257,6 +274,7 @@ qr/shib request authorizer copied header:/
257
274
258
275
=== TEST 9: Testing no auth with correct headers; subrequest header changes are ignored
259
276
--- config eval: $::config
277
+ --- main_config eval: $::main_config
260
278
--- request
261
279
GET /test9
262
280
--- error_code: 403
@@ -270,6 +288,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
270
288
271
289
=== TEST 10: Testing no auth with overwritten headers; subrequest header changes are ignored
272
290
--- config eval: $::config
291
+ --- main_config eval: $::main_config
273
292
--- request
274
293
GET /test10
275
294
--- error_code: 403
@@ -283,6 +302,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
283
302
284
303
=== TEST 11: Testing successful auth, no leaked variables, no headers set
285
304
--- config eval: $::config
305
+ --- main_config eval: $::main_config
286
306
--- user_files
287
307
>>> test11
288
308
Hello, world
0 commit comments