Mercurial > hg > nginx-tests
annotate proxy_cache_convert_head.t @ 1453:6f53ec0cf591
Tests: simplified stream_proxy_ssl_verify.t using return directive.
Due to changed connection processing, it no longer triggers "phantom event"
alerts previously seen with Solaris devpoll on connections closed by client
in test cases with failed verification of the proxied server certificate.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 25 Mar 2019 19:11:11 +0300 |
parents | 196d33c2bb45 |
children |
rev | line source |
---|---|
780
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for http proxy cache with proxy_cache_convert_head directive. |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@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 proxy cache/)->plan(8) |
780
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 http { |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 proxy_cache_path %%TESTDIR%%/cache levels=1:2 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 keys_zone=NAME:1m; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
42 listen 127.0.0.1:8080; |
780
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 proxy_cache NAME; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 proxy_cache_key $request_uri; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 proxy_cache_valid 200 302 2s; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 add_header X-Cache-Status $upstream_cache_status; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
54 proxy_pass http://127.0.0.1:8081/t.html; |
780
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 proxy_cache_convert_head off; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 location /inner { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
58 proxy_pass http://127.0.0.1:8081/t.html; |
780
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 proxy_cache_convert_head on; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 location /on { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
64 proxy_pass http://127.0.0.1:8081/t.html; |
780
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 proxy_cache_convert_head on; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
69 listen 127.0.0.1:8081; |
780
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 server_name localhost; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 location / { |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 add_header X-Method $request_method; |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 } |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 EOF |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 $t->write_file('t.html', 'SEE-THIS'); |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
81 $t->run(); |
780
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 ############################################################################### |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 like(http_get('/'), qr/X-Method: GET/, 'get'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 like(http_head('/?2'), qr/X-Method: HEAD/, 'head'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 like(http_head('/?2'), qr/HIT/, 'head cached'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 unlike(http_get('/?2'), qr/SEE-THIS/, 'get after head'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 like(http_get('/on'), qr/X-Method: GET/, 'on - get'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 like(http_head('/on?2'), qr/X-Method: GET/, 'on - head'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 like(http_get('/inner'), qr/X-Method: GET/, 'inner - get'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 like(http_head('/inner?2'), qr/X-Method: GET/, 'inner - head'); |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
5a0bba53854b
Tests: proxy_cache_convert_head tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 ############################################################################### |