annotate proxy_cache_path.t @ 1571:1b4ceab9cb1c

Tests: fixed ssl_certificate.t with LibreSSL client. Net::SSLeay::connect() that manages TLS handshake could return unexpected error when receiving server alert, as seen in server certificate tests if it could not been selected. Typically, it returns the expected error -1, but with certain libssl implementations it can be 0, as explained below. The error is propagated from libssl's SSL_connect(), which is usually -1. In modern OpenSSL versions, it is the default error code used in the state machine returned when something went wrong with parsing TLS message header. In versions up to OpenSSL 1.0.2, with SSLv23_method() used by default, -1 is the only error code in the ssl_connect() method implementation which is used as well if receiving alert while parsing ServerHello. BoringSSL also seems to return -1. But it is not so with LibreSSL that returns zero. Previously, tests failed with client built with LibreSSL with SSLv3 removed. Here, the error is propagated directly from ssl_read_bytes() method, which is always implemented as ssl3_read_bytes() in all TLS methods. It could be also seen with OpenSSL up to 1.0.2 with non-default methods explicitly set.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 29 May 2020 23:10:20 +0300
parents 196d33c2bb45
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for http proxy cache with use_temp_path parameter.
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
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(6)
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 ->write_file_expand('nginx.conf', <<'EOF');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 %%TEST_GLOBALS%%
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 daemon off;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 events {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 http {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 %%TEST_GLOBALS_HTTP%%
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 proxy_cache_path %%TESTDIR%%/cache1
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 keys_zone=ON:1m use_temp_path=on;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 proxy_cache_path %%TESTDIR%%/cache2
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 keys_zone=OFF:1m use_temp_path=off;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 proxy_cache_path %%TESTDIR%%/cache4 levels=1:2
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 keys_zone=LEVELS:1m use_temp_path=off;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
46 listen 127.0.0.1:8080;
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 server_name localhost;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 location / {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
50 proxy_pass http://127.0.0.1:8081;
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 proxy_cache $arg_c;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 proxy_cache_valid any 1m;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 add_header X-Cache-Status $upstream_cache_status;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
61 listen 127.0.0.1:8081;
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 server_name localhost;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 location / {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 EOF
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 $t->write_file('t', 'SEE-THIS');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72
568
907e89fba9c3 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 522
diff changeset
73 $t->run();
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 ###############################################################################
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 like(http_get('/t?c=ON'), qr/MISS.*SEE-THIS/ms, 'temp path');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 like(http_get('/t?c=OFF'), qr/MISS.*SEE-THIS/ms, 'temp path off');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 like(http_get('/t?c=LEVELS'), qr/MISS.*SEE-THIS/ms, 'temp path levels');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 $t->write_file('t', 'SEE-THAT');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 like(http_get('/t?c=ON'), qr/HIT.*SEE-THIS/ms, 'temp path cached');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 like(http_get('/t?c=OFF'), qr/HIT.*SEE-THIS/ms, 'temp path cached off');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 like(http_get('/t?c=LEVELS'), qr/HIT.*SEE-THIS/ms, 'temp path cached levels');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 ###############################################################################