Mercurial > hg > nginx-tests
comparison sub_filter.t @ 452:4465c1cf6f75
Tests: sub filter tests for single character matching.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 26 Aug 2014 11:56:18 +0400 |
parents | 847ea345becb |
children | 11d324ee4def |
comparison
equal
deleted
inserted
replaced
451:be98c162f8bc | 452:4465c1cf6f75 |
---|---|
21 ############################################################################### | 21 ############################################################################### |
22 | 22 |
23 select STDERR; $| = 1; | 23 select STDERR; $| = 1; |
24 select STDOUT; $| = 1; | 24 select STDOUT; $| = 1; |
25 | 25 |
26 my $t = Test::Nginx->new()->has(qw/http rewrite sub/)->plan(14) | 26 my $t = Test::Nginx->new()->has(qw/http rewrite sub/)->plan(22) |
27 ->write_file_expand('nginx.conf', <<'EOF'); | 27 ->write_file_expand('nginx.conf', <<'EOF'); |
28 | 28 |
29 %%TEST_GLOBALS%% | 29 %%TEST_GLOBALS%% |
30 | 30 |
31 daemon off; | 31 daemon off; |
67 | 67 |
68 location /complex3 { | 68 location /complex3 { |
69 sub_filter aab _replaced; | 69 sub_filter aab _replaced; |
70 return 200 $arg_b; | 70 return 200 $arg_b; |
71 } | 71 } |
72 | |
73 location /single { | |
74 sub_filter A B; | |
75 return 200 $arg_b; | |
76 } | |
77 | |
78 location /single/many { | |
79 sub_filter A B; | |
80 sub_filter_once off; | |
81 return 200 $arg_b; | |
82 } | |
72 } | 83 } |
73 } | 84 } |
74 | 85 |
75 EOF | 86 EOF |
76 | 87 |
95 like(http_get('/complex2?b=abababX'), qr/ab_replaced/, 'complex2 long'); | 106 like(http_get('/complex2?b=abababX'), qr/ab_replaced/, 'complex2 long'); |
96 like(http_get('/complex3?b=aab'), qr/_replaced/, 'complex3 aab in aab'); | 107 like(http_get('/complex3?b=aab'), qr/_replaced/, 'complex3 aab in aab'); |
97 like(http_get('/complex3?b=aaab'), qr/a_replaced/, 'complex3 aab in aaab'); | 108 like(http_get('/complex3?b=aaab'), qr/a_replaced/, 'complex3 aab in aaab'); |
98 like(http_get('/complex3?b=aaaab'), qr/aa_replaced/, 'complex3 aab in aaaab'); | 109 like(http_get('/complex3?b=aaaab'), qr/aa_replaced/, 'complex3 aab in aaaab'); |
99 | 110 |
111 TODO: { | |
112 local $TODO = 'not yet' unless $t->has_version('1.7.4'); | |
113 | |
114 SKIP: { | |
115 skip 'leaves coredump', 8 unless $t->has_version('1.7.4') | |
116 or $ENV{TEST_NGINX_UNSAFE}; | |
117 | |
118 like(http_get('/single?b=A'), qr/B/, 'single only'); | |
119 like(http_get('/single?b=AA'), qr/BA/, 'single begin'); | |
120 like(http_get('/single?b=CAAC'), qr/CBAC/, 'single middle'); | |
121 like(http_get('/single?b=CA'), qr/CB/, 'single end'); | |
122 | |
123 like(http_get('/single/many?b=A'), qr/B/, 'single many only'); | |
124 like(http_get('/single/many?b=AA'), qr/BB/, 'single many begin'); | |
125 like(http_get('/single/many?b=CAAC'), qr/CBBC/, 'single many middle'); | |
126 like(http_get('/single/many?b=CA'), qr/CB/, 'single many end'); | |
127 | |
128 } | |
129 | |
130 } | |
131 | |
100 ############################################################################### | 132 ############################################################################### |