Mercurial > hg > nginx-tests
comparison stream_ssl_preread.t @ 1199:08f6eacf1cfe
Tests: stream proxy next upstream with ssl_preread (ticket #1317).
Ensure that next TCP upstream can be selected with pending buffers.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Wed, 26 Jul 2017 16:42:48 +0300 |
parents | cd153f1bbaad |
children | cbda704b3093 |
comparison
equal
deleted
inserted
replaced
1198:cd153f1bbaad | 1199:08f6eacf1cfe |
---|---|
48 | 48 |
49 upstream bar { | 49 upstream bar { |
50 server 127.0.0.1:8092; | 50 server 127.0.0.1:8092; |
51 } | 51 } |
52 | 52 |
53 upstream next { | |
54 server 127.0.0.1:8094; | |
55 server 127.0.0.1:8080; | |
56 } | |
57 | |
53 ssl_preread on; | 58 ssl_preread on; |
54 | 59 |
55 server { | 60 server { |
56 listen 127.0.0.1:8080; | 61 listen 127.0.0.1:8080; |
57 return $name; | 62 return $name; |
74 | 79 |
75 preread_timeout 2s; | 80 preread_timeout 2s; |
76 preread_buffer_size 42; | 81 preread_buffer_size 42; |
77 | 82 |
78 access_log %%TESTDIR%%/status.log status; | 83 access_log %%TESTDIR%%/status.log status; |
84 } | |
85 | |
86 server { | |
87 listen 127.0.0.1:8084; | |
88 proxy_pass next; | |
89 | |
90 proxy_connect_timeout 2s; | |
91 preread_buffer_size 8; | |
79 } | 92 } |
80 | 93 |
81 ssl_certificate_key localhost.key; | 94 ssl_certificate_key localhost.key; |
82 ssl_certificate localhost.crt; | 95 ssl_certificate localhost.crt; |
83 | 96 |
107 my $ssl = Net::SSLeay::new($ctx) or die; | 120 my $ssl = Net::SSLeay::new($ctx) or die; |
108 Net::SSLeay::set_tlsext_host_name($ssl, 'example.org') == 1 or die; | 121 Net::SSLeay::set_tlsext_host_name($ssl, 'example.org') == 1 or die; |
109 }; | 122 }; |
110 plan(skip_all => 'Net::SSLeay with OpenSSL SNI support required') if $@; | 123 plan(skip_all => 'Net::SSLeay with OpenSSL SNI support required') if $@; |
111 | 124 |
112 $t->plan(11); | 125 $t->plan(12); |
113 | 126 |
114 $t->write_file('openssl.conf', <<EOF); | 127 $t->write_file('openssl.conf', <<EOF); |
115 [ req ] | 128 [ req ] |
116 default_bits = 1024 | 129 default_bits = 1024 |
117 encrypt_key = no | 130 encrypt_key = no |
131 | 144 |
132 $t->run(); | 145 $t->run(); |
133 | 146 |
134 ############################################################################### | 147 ############################################################################### |
135 | 148 |
136 my ($p1, $p2, $p3) = (port(8091), port(8092), port(8093)); | 149 my ($p1, $p2, $p3, $p4) = (port(8091), port(8092), port(8093), port(8084)); |
137 | 150 |
138 is(get_ssl('foo', 8081), $p1, 'sni'); | 151 is(get_ssl('foo', 8081), $p1, 'sni'); |
139 is(get_ssl('foo', 8081), $p1, 'sni again'); | 152 is(get_ssl('foo', 8081), $p1, 'sni again'); |
140 | 153 |
141 is(get_ssl('bar', 8081), $p2, 'sni 2'); | 154 is(get_ssl('bar', 8081), $p2, 'sni 2'); |
145 | 158 |
146 is(get_ssl('', 8081), $p3, 'no sni'); | 159 is(get_ssl('', 8081), $p3, 'no sni'); |
147 is(get_ssl('foo', 8082), $p3, 'preread off'); | 160 is(get_ssl('foo', 8082), $p3, 'preread off'); |
148 is(get_ssl('foo', 8083), undef, 'preread buffer full'); | 161 is(get_ssl('foo', 8083), undef, 'preread buffer full'); |
149 is(stream()->io('x' x 1000), "127.0.0.1:$p3", 'not a handshake'); | 162 is(stream()->io('x' x 1000), "127.0.0.1:$p3", 'not a handshake'); |
163 | |
164 TODO: { | |
165 local $TODO = 'not yet'; | |
166 | |
167 is(stream("127.0.0.1:$p4")->io('x' x 16), "127.0.0.1:$p3", | |
168 'pending buffers on next upstream'); | |
169 | |
170 } | |
150 | 171 |
151 # no junk in variable due to short ClientHello length value | 172 # no junk in variable due to short ClientHello length value |
152 | 173 |
153 is(get_short(), "127.0.0.1:$p3", 'short client hello'); | 174 is(get_short(), "127.0.0.1:$p3", 'short client hello'); |
154 | 175 |