Mercurial > hg > nginx-tests
annotate sub_filter.t @ 1689:dbd19195df8a
Tests: adjusted mail_smtp.t "long pipelined" TODO.
Prior to fixed reading with fully filled buffer in 2851e4c7de03 (1.21.0),
test for long pipelined commands leads to connection close by nginx, which
can result in RST and no response seen by the client, notably on win32.
While here, cleaned up permitted smtp_auth methods in that particular server.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 24 May 2021 22:09:54 +0300 |
parents | 196d33c2bb45 |
children |
rev | line source |
---|---|
304 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for sub filter. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
630
e6132dd8e341
Tests: added missing proxy prerequisite.
Sergey Kandaurov <pluknet@nginx.com>
parents:
579
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http rewrite sub proxy/)->plan(30) |
304 | 25 ->write_file_expand('nginx.conf', <<'EOF'); |
26 | |
27 %%TEST_GLOBALS%% | |
28 | |
29 daemon off; | |
30 | |
31 events { | |
32 } | |
33 | |
34 http { | |
35 %%TEST_GLOBALS_HTTP%% | |
36 | |
37 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
38 listen 127.0.0.1:8080; |
304 | 39 server_name localhost; |
40 | |
41 sub_filter_types *; | |
42 sub_filter foo bar; | |
43 | |
44 location / { | |
45 } | |
46 | |
47 location /once { | |
48 return 200 $arg_b; | |
49 } | |
50 | |
51 location /many { | |
52 sub_filter_once off; | |
53 return 200 $arg_b; | |
54 } | |
55 | |
56 location /complex { | |
57 sub_filter abac _replaced; | |
58 return 200 $arg_b; | |
59 } | |
60 | |
61 location /complex2 { | |
62 sub_filter ababX _replaced; | |
63 return 200 $arg_b; | |
64 } | |
65 | |
66 location /complex3 { | |
67 sub_filter aab _replaced; | |
68 return 200 $arg_b; | |
69 } | |
452
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
70 |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
71 location /single { |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
72 sub_filter A B; |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
73 return 200 $arg_b; |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
74 } |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
75 |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
76 location /single/many { |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
77 sub_filter A B; |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
78 sub_filter_once off; |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
79 return 200 $arg_b; |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
80 } |
575
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
81 |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
82 location /var/string { |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
83 sub_filter X$arg_a _replaced; |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
84 return 200 $arg_b; |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
85 } |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
86 |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
87 location /var/replacement { |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
88 sub_filter aab '${arg_a}_replaced'; |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
89 return 200 $arg_b; |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
90 } |
578
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
91 |
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
92 location /lm { |
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
93 sub_filter_last_modified on; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
94 proxy_pass http://127.0.0.1:8081/; |
578
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
95 } |
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
96 } |
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
97 |
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
98 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
99 listen 127.0.0.1:8081; |
578
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
100 server_name localhost; |
304 | 101 } |
102 } | |
103 | |
104 EOF | |
105 | |
106 $t->write_file('foo.html', 'foo'); | |
579
6d1b945c9c60
Tests: sub_filter caseless tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
578
diff
changeset
|
107 $t->write_file('foo_uc.html', 'FOO'); |
304 | 108 $t->write_file('foofoo.html', 'foofoo'); |
109 $t->run(); | |
110 | |
111 ############################################################################### | |
112 | |
113 like(http_get('/foo.html'), qr/bar/, 'sub_filter'); | |
579
6d1b945c9c60
Tests: sub_filter caseless tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
578
diff
changeset
|
114 like(http_get('/foo_uc.html'), qr/bar/, 'sub_filter caseless'); |
304 | 115 like(http_get('/foofoo.html'), qr/barfoo/, 'once default'); |
116 | |
117 like(http_get('/once?b=foofoo'), qr/barfoo/, 'once'); | |
118 like(http_get('/many?b=foofoo'), qr/barbar/, 'many'); | |
119 like(http_get('/many?b=fo'), qr/fo/, 'incomplete'); | |
120 like(http_get('/many?b=foofo'), qr/barfo/, 'incomplete long'); | |
121 | |
122 like(http_get('/complex?b=abac'), qr/_replaced/, 'complex'); | |
123 like(http_get('/complex?b=abaabac'), qr/aba_replaced/, 'complex 1st char'); | |
124 like(http_get('/complex?b=ababac'), qr/replaced/, 'complex 2nd char'); | |
125 like(http_get('/complex2?b=ababX'), qr/_replaced/, 'complex2'); | |
126 like(http_get('/complex2?b=abababX'), qr/ab_replaced/, 'complex2 long'); | |
127 like(http_get('/complex3?b=aab'), qr/_replaced/, 'complex3 aab in aab'); | |
128 like(http_get('/complex3?b=aaab'), qr/a_replaced/, 'complex3 aab in aaab'); | |
129 like(http_get('/complex3?b=aaaab'), qr/aa_replaced/, 'complex3 aab in aaaab'); | |
130 | |
452
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
131 like(http_get('/single?b=A'), qr/B/, 'single only'); |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
132 like(http_get('/single?b=AA'), qr/BA/, 'single begin'); |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
133 like(http_get('/single?b=CAAC'), qr/CBAC/, 'single middle'); |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
134 like(http_get('/single?b=CA'), qr/CB/, 'single end'); |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
135 |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
136 like(http_get('/single/many?b=A'), qr/B/, 'single many only'); |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
137 like(http_get('/single/many?b=AA'), qr/BB/, 'single many begin'); |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
138 like(http_get('/single/many?b=CAAC'), qr/CBBC/, 'single many middle'); |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
139 like(http_get('/single/many?b=CA'), qr/CB/, 'single many end'); |
4465c1cf6f75
Tests: sub filter tests for single character matching.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
140 |
575
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
141 like(http_get('/var/string?a=foo&b=Xfoo'), qr/_replaced/, 'complex string'); |
579
6d1b945c9c60
Tests: sub_filter caseless tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
578
diff
changeset
|
142 like(http_get('/var/string?a=foo&b=XFOO'), qr/_replaced/, |
6d1b945c9c60
Tests: sub_filter caseless tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
578
diff
changeset
|
143 'complex string caseless'); |
575
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
144 like(http_get('/var/string?a=abcdefghijklmnopq&b=Xabcdefghijklmnopq'), |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
145 qr/_replaced/, 'complex string long'); |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
146 |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
147 like(http_get('/var/replacement?a=ee&b=aaab'), qr/aee_replaced/, |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
148 'complex replacement'); |
eea2b0158b51
Tests: sub filter tests for complex variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
149 |
578
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
150 unlike(http_get('/foo.html'), qr/(Last-Modified|ETag)/, 'no last modified'); |
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
151 like(http_get('/lm/foo.html'), qr/Last-Modified/, 'last modified'); |
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
152 like(http_get('/lm/foo.html'), qr!ETag: W/"[^"]+"!, 'last modified weak'); |
8504a62496df
Tests: sub_filter last_modified tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
575
diff
changeset
|
153 |
304 | 154 ############################################################################### |