Mercurial > hg > nginx-tests
annotate sub_filter_multi2.t @ 1282:fd281e3a3df5
Tests: better test names in h2_server_push.t.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 12 Feb 2018 14:46:40 +0300 |
parents | 196d33c2bb45 |
children |
rev | line source |
---|---|
649
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
2 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
3 # (C) Dmitry Volyntsev |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
5 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
6 # Tests for sub filter with variables in search patterns. |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
7 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
9 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
11 use strict; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
12 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
14 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
16 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
19 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
21 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
24 |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http rewrite sub/)->plan(7) |
649
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
27 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
29 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
31 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
32 events { |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
33 } |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
34 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
35 http { |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
37 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
38 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 listen 127.0.0.1:8080; |
649
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
40 server_name localhost; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
41 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
42 sub_filter_types *; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
43 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
44 location /var/replacement { |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
45 sub_filter_once off; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
46 sub_filter '${arg_a}' '${arg_a}+'; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
47 sub_filter '${arg_b}' '${arg_b}-'; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
48 return 200 $arg_c; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
49 } |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
50 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
51 location /var/replacement2 { |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
52 sub_filter_once off; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
53 sub_filter '${arg_a}A${arg_b}' +; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
54 sub_filter '${arg_c}AA${arg_d}' -; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
55 return 200 $arg_e; |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
56 } |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
57 } |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
58 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
59 } |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
60 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
61 EOF |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
62 |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
63 $t->run(); |
649
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
64 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
65 ############################################################################### |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
66 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
67 like(http_get('/var/replacement?a=a&b=b&c=abXYaXbZ'), |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
68 qr/a\+b-XYa\+Xb-Z/, 'complex'); |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
69 like(http_get('/var/replacement?a=patt&b=abyz&c=pattabyzXYpattXabyzZpatt'), |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
70 qr/patt\+abyz-XYpatt\+Xabyz-Zpatt\+/, 'complex 2'); |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
71 like(http_get('/var/replacement?a=a&b=b&c=ABXYAXBZ'), |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
72 qr/a\+b-XYa\+Xb-Z/, 'case insensivity'); |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
73 like(http_get('/var/replacement?b=b&c=abXYaXbZ'), |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
74 qr/ab-XYaXb-Z/, 'one search string is empty'); |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
75 like(http_get('/var/replacement?c=abXYaXbZ'), |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
76 qr/abXYaXbZ/, 'all search strings are empty'); |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
77 like(http_get('/var/replacement2?a=aaa&b=bbb&c=yy&d=zz&e=AaaaAbbbZyyAAzzY'), |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
78 qr/A\+Z-Y/, 'multiple variables'); |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
79 like(http_get('/var/replacement2?b=bbb&c=yy&e=AAbbbZyyAAY'), |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
80 qr/A\+Z-Y/, 'multiple variables 2'); |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
81 |
17ddc69fd9b3
Tests: sub filter tests for variables in search patterns.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff
changeset
|
82 ############################################################################### |