Mercurial > hg > nginx-tests
comparison ssl.t @ 1067:4606a2ec3d7c
Tests: ssl.t cleanup, no functional changes.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 21 Oct 2016 16:32:30 +0300 |
parents | 882267679006 |
children | d0ec761774a5 |
comparison
equal
deleted
inserted
replaced
1066:23418577df58 | 1067:4606a2ec3d7c |
---|---|
148 | 148 |
149 $t->run(); | 149 $t->run(); |
150 | 150 |
151 ############################################################################### | 151 ############################################################################### |
152 | 152 |
153 like(http_get('/reuse', socket => get_ssl_socket($ctx, port(8085))), | 153 like(get('/reuse', 8085), qr/^body \.$/m, 'shared initial session'); |
154 qr/^body \.$/m, 'shared initial session'); | 154 like(get('/reuse', 8085), qr/^body r$/m, 'shared session reused'); |
155 like(http_get('/reuse', socket => get_ssl_socket($ctx, port(8085))), | 155 |
156 qr/^body r$/m, 'shared session reused'); | 156 like(get('/', 8081), qr/^body \.$/m, 'builtin initial session'); |
157 | 157 like(get('/', 8081), qr/^body r$/m, 'builtin session reused'); |
158 like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body \.$/m, | 158 |
159 'builtin initial session'); | 159 like(get('/', 8082), qr/^body \.$/m, 'builtin size initial session'); |
160 like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body r$/m, | 160 like(get('/', 8082), qr/^body r$/m, 'builtin size session reused'); |
161 'builtin session reused'); | 161 |
162 | 162 like(get('/', 8083), qr/^body \.$/m, 'reused none initial session'); |
163 like(http_get('/', socket => get_ssl_socket($ctx, port(8082))), qr/^body \.$/m, | 163 like(get('/', 8083), qr/^body \.$/m, 'session not reused 1'); |
164 'builtin size initial session'); | 164 |
165 like(http_get('/', socket => get_ssl_socket($ctx, port(8082))), qr/^body r$/m, | 165 like(get('/', 8084), qr/^body \.$/m, 'reused off initial session'); |
166 'builtin size session reused'); | 166 like(get('/', 8084), qr/^body \.$/m, 'session not reused 2'); |
167 | |
168 like(http_get('/', socket => get_ssl_socket($ctx, port(8083))), qr/^body \.$/m, | |
169 'reused none initial session'); | |
170 like(http_get('/', socket => get_ssl_socket($ctx, port(8083))), qr/^body \.$/m, | |
171 'session not reused 1'); | |
172 | |
173 like(http_get('/', socket => get_ssl_socket($ctx, port(8084))), qr/^body \.$/m, | |
174 'reused off initial session'); | |
175 like(http_get('/', socket => get_ssl_socket($ctx, port(8084))), qr/^body \.$/m, | |
176 'session not reused 2'); | |
177 | 167 |
178 # ssl certificate inheritance | 168 # ssl certificate inheritance |
179 | 169 |
180 my $s = get_ssl_socket($ctx, port(8081)); | 170 my $s = get_ssl_socket($ctx, port(8081)); |
181 like($s->dump_peer_certificate(), qr/CN=localhost/, 'CN'); | 171 like($s->dump_peer_certificate(), qr/CN=localhost/, 'CN'); |
189 | 179 |
190 # session timeout | 180 # session timeout |
191 | 181 |
192 select undef, undef, undef, 2.1; | 182 select undef, undef, undef, 2.1; |
193 | 183 |
194 like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body \.$/m, | 184 like(get('/', 8081), qr/^body \.$/m, 'session timeout'); |
195 'session timeout'); | |
196 | 185 |
197 # embedded variables | 186 # embedded variables |
198 | 187 |
199 my ($sid) = http_get('/id', | 188 like(get('/id', 8085), qr/^body \w{64}$/m, 'session id'); |
200 socket => get_ssl_socket($ctx, port(8085))) =~ /^body (\w+)$/m; | |
201 is(length $sid, 64, 'session id'); | |
202 | |
203 unlike(http_get('/id'), qr/body \w/, 'session id no ssl'); | 189 unlike(http_get('/id'), qr/body \w/, 'session id no ssl'); |
204 | 190 like(get('/cipher', 8085), qr/^body [\w-]+$/m, 'cipher'); |
205 like(http_get('/cipher', socket => get_ssl_socket($ctx, port(8085))), | 191 like(get('/client_verify', 8085), qr/^body NONE$/m, 'client verify'); |
206 qr/^body [\w-]+$/m, 'cipher'); | 192 like(get('/protocol', 8085), qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol'); |
207 | 193 |
208 like(http_get('/client_verify', socket => get_ssl_socket($ctx, port(8085))), | 194 ############################################################################### |
209 qr/^body NONE$/m, 'client verify'); | 195 |
210 | 196 sub get { |
211 like(http_get('/protocol', socket => get_ssl_socket($ctx, port(8085))), | 197 my ($uri, $port) = @_; |
212 qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol'); | 198 my $s = get_ssl_socket($ctx, port($port)) or return; |
213 | 199 http_get($uri, socket => $s); |
214 ############################################################################### | 200 } |
215 | 201 |
216 sub get_ssl_socket { | 202 sub get_ssl_socket { |
217 my ($ctx, $port) = @_; | 203 my ($ctx, $port) = @_; |
218 my $s; | 204 my $s; |
219 | 205 |