Mercurial > hg > nginx-tests
comparison proxy_cache_bypass.t @ 1989:bf027a972ccf default tip
Tests: proxy_no_cache tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 25 Jun 2024 21:46:50 +0300 |
parents | 766bcbb632ee |
children |
comparison
equal
deleted
inserted
replaced
1988:b5c1c3ef2345 | 1989:bf027a972ccf |
---|---|
19 ############################################################################### | 19 ############################################################################### |
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)->plan(8) | 24 my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)->plan(12) |
25 ->write_file_expand('nginx.conf', <<'EOF'); | 25 ->write_file_expand('nginx.conf', <<'EOF'); |
26 | 26 |
27 %%TEST_GLOBALS%% | 27 %%TEST_GLOBALS%% |
28 | 28 |
29 daemon off; | 29 daemon off; |
63 listen 127.0.0.1:8081; | 63 listen 127.0.0.1:8081; |
64 server_name localhost; | 64 server_name localhost; |
65 | 65 |
66 location / { | 66 location / { |
67 } | 67 } |
68 | |
69 location /t3 { | |
70 add_header Transfer-Encoding $arg_bypass; | |
71 } | |
68 } | 72 } |
69 } | 73 } |
70 | 74 |
71 EOF | 75 EOF |
72 | 76 |
73 $t->write_file('t', 'SEE-THIS'); | 77 $t->write_file('t', 'SEE-THIS'); |
78 $t->write_file('t3', 'SEE-THIS'); | |
74 | 79 |
75 $t->run(); | 80 $t->run(); |
76 | 81 |
77 ############################################################################### | 82 ############################################################################### |
78 | 83 |
80 | 85 |
81 $t->write_file('t', 'NOOP'); | 86 $t->write_file('t', 'NOOP'); |
82 | 87 |
83 like(http_get('/t'), qr/SEE-THIS/, 'request cached'); | 88 like(http_get('/t'), qr/SEE-THIS/, 'request cached'); |
84 like(http_get('/t?bypass=1'), qr/NOOP/, 'cache bypassed'); | 89 like(http_get('/t?bypass=1'), qr/NOOP/, 'cache bypassed'); |
90 | |
91 unlink $t->testdir() . '/t'; | |
92 | |
85 like(http_get('/t'), qr/NOOP/, 'cached after bypass'); | 93 like(http_get('/t'), qr/NOOP/, 'cached after bypass'); |
86 | 94 |
87 # ticket #827, cache item "error" field was not cleared | 95 # ticket #827, cache item "error" field was not cleared |
88 # on cache bypass | 96 # on cache bypass |
89 | 97 |
91 | 99 |
92 $t->write_file('t2', 'NOOP'); | 100 $t->write_file('t2', 'NOOP'); |
93 | 101 |
94 like(http_get('/t2'), qr/403 Forbidden/, 'error cached'); | 102 like(http_get('/t2'), qr/403 Forbidden/, 'error cached'); |
95 like(http_get('/t2?bypass=1'), qr/NOOP/, 'error cache bypassed'); | 103 like(http_get('/t2?bypass=1'), qr/NOOP/, 'error cache bypassed'); |
96 like(http_get('/t2'), qr/NOOP/, 'error cached after bypass'); | 104 |
105 unlink $t->testdir() . '/t2'; | |
106 | |
107 like(http_get('/t2'), qr/NOOP/, 'file cached after bypass'); | |
108 | |
109 # make sure the error is cached after bypass | |
110 | |
111 like(http_get('/t2?bypass=1'), qr/403 Forbidden/, 'file cache bypassed'); | |
112 | |
113 $t->write_file('t2', 'NOOP'); | |
114 | |
115 TODO: { | |
116 local $TODO = 'not yet' unless $t->has_version('1.27.2'); | |
117 | |
118 like(http_get('/t2'), qr/403 Forbidden/, 'error cached again'); | |
119 | |
120 } | |
121 | |
122 # similarly, internal 502/504 is cached after bypass | |
123 | |
124 like(http_get('/t3?bypass=1'), qr/502 Bad/, 'internal 502'); | |
125 | |
126 TODO: { | |
127 local $TODO = 'not yet' unless $t->has_version('1.27.2'); | |
128 | |
129 like(http_get('/t3'), qr/502 Bad/, 'internal 502 cached'); | |
130 | |
131 } | |
97 | 132 |
98 ############################################################################### | 133 ############################################################################### |