annotate stream_upstream_zone_ssl.t @ 1728:6d5ecf445e57

Tests: added HTTP/2 test with big request body. Notably, it is useful with body buffering in filters, in which case the stream window is flow controlled based on the preread buffer.
author Sergey Kandaurov <pluknet@nginx.com>
date Sat, 04 Sep 2021 14:50:02 +0300
parents f3ba4c74de31
children 72d206b37df1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Stream tests for upstream zone with ssl backend.
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
1195
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
19 use Test::Nginx::Stream qw/ stream /;
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 ###############################################################################
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25
1195
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
26 my $t = Test::Nginx->new()->has(qw/stream stream_ssl stream_return/)
1197
155573499f20 Tests: more ssl session tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1195
diff changeset
27 ->has(qw/stream_upstream_zone/)->has_daemon('openssl')->plan(9);
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 $t->write_file_expand('nginx.conf', <<'EOF');
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 %%TEST_GLOBALS%%
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 daemon off;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 events {
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 stream {
1609
f3ba4c74de31 Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents: 1488
diff changeset
39 %%TEST_GLOBALS_STREAM%%
f3ba4c74de31 Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents: 1488
diff changeset
40
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 proxy_ssl on;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 proxy_ssl_session_reuse on;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 upstream u {
982
325db3d62466 Tests: increase upstream shared memory zone sizes for large pages.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
45 zone u 1m;
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
46 server 127.0.0.1:8084;
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 upstream u2 {
982
325db3d62466 Tests: increase upstream shared memory zone sizes for large pages.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
50 zone u2 1m;
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
51 server 127.0.0.1:8084 backup;
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
52 server 127.0.0.1:8085 down;
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
56 listen 127.0.0.1:8080;
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 proxy_pass u;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 proxy_ssl_session_reuse off;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
62 listen 127.0.0.1:8081;
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 proxy_pass u;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
67 listen 127.0.0.1:8082;
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 proxy_pass u2;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 proxy_ssl_session_reuse off;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
73 listen 127.0.0.1:8083;
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 proxy_pass u2;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 server {
1195
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
78 listen 127.0.0.1:8084 ssl;
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
79 return $ssl_session_reused;
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 ssl_certificate_key localhost.key;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 ssl_certificate localhost.crt;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 ssl_session_cache builtin;
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 EOF
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 $t->write_file('openssl.conf', <<EOF);
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 [ req ]
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1381
diff changeset
91 default_bits = 2048
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 encrypt_key = no
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 distinguished_name = req_distinguished_name
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 [ req_distinguished_name ]
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95 EOF
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97 my $d = $t->testdir();
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 foreach my $name ('localhost') {
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1197
diff changeset
101 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1197
diff changeset
102 . "-out $d/$name.crt -keyout $d/$name.key "
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103 . ">>$d/openssl.out 2>&1") == 0
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 or die "Can't create certificate for $name: $!\n";
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105 }
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 $t->run();
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109 ###############################################################################
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110
1195
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
111 is(stream('127.0.0.1:' . port(8080))->read(), '.', 'ssl');
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
112 is(stream('127.0.0.1:' . port(8080))->read(), '.', 'ssl 2');
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113
1195
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
114 is(stream('127.0.0.1:' . port(8081))->read(), '.', 'ssl session new');
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
115 is(stream('127.0.0.1:' . port(8081))->read(), 'r', 'ssl session reused');
1197
155573499f20 Tests: more ssl session tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1195
diff changeset
116 is(stream('127.0.0.1:' . port(8081))->read(), 'r', 'ssl session reused 2');
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117
1195
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
118 is(stream('127.0.0.1:' . port(8082))->read(), '.', 'backup ssl');
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
119 is(stream('127.0.0.1:' . port(8082))->read(), '.', 'backup ssl 2');
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120
1195
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
121 is(stream('127.0.0.1:' . port(8083))->read(), '.', 'backup ssl session new');
af7feabed82a Tests: stream proxy ssl session tests no longer use http backends.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
122 is(stream('127.0.0.1:' . port(8083))->read(), 'r', 'backup ssl session reused');
560
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123
f3434de79a7f Tests: upstream zone tests with ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 ###############################################################################