Mercurial > hg > nginx-tests
comparison ssl.t @ 1382:cb1346b553aa
Tests: simple https tests merged back.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 09 Oct 2018 18:33:01 +0300 |
parents | f80176242a7e |
children | 965bddf88b8f |
comparison
equal
deleted
inserted
replaced
1381:97c8280de681 | 1382:cb1346b553aa |
---|---|
29 plan(skip_all => 'IO::Socket::SSL not installed') if $@; | 29 plan(skip_all => 'IO::Socket::SSL not installed') if $@; |
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; | 30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; |
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; | 31 plan(skip_all => 'IO::Socket::SSL too old') if $@; |
32 | 32 |
33 my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/) | 33 my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/) |
34 ->has_daemon('openssl')->plan(21); | 34 ->has_daemon('openssl')->plan(23); |
35 | 35 |
36 $t->write_file_expand('nginx.conf', <<'EOF'); | 36 $t->write_file_expand('nginx.conf', <<'EOF'); |
37 | 37 |
38 %%TEST_GLOBALS%% | 38 %%TEST_GLOBALS%% |
39 | 39 |
66 return 200 "body $ssl_session_id"; | 66 return 200 "body $ssl_session_id"; |
67 } | 67 } |
68 location /cipher { | 68 location /cipher { |
69 return 200 "body $ssl_cipher"; | 69 return 200 "body $ssl_cipher"; |
70 } | 70 } |
71 location /ciphers { | |
72 return 200 "body $ssl_ciphers"; | |
73 } | |
71 location /client_verify { | 74 location /client_verify { |
72 return 200 "body $ssl_client_verify"; | 75 return 200 "body $ssl_client_verify"; |
73 } | 76 } |
74 location /protocol { | 77 location /protocol { |
75 return 200 "body $ssl_protocol"; | 78 return 200 "body $ssl_protocol"; |
76 } | 79 } |
77 location /issuer { | 80 location /issuer { |
78 return 200 "body $ssl_client_i_dn"; | 81 return 200 "body $ssl_client_i_dn:$ssl_client_i_dn_legacy"; |
79 } | 82 } |
80 location /subject { | 83 location /subject { |
81 return 200 "body $ssl_client_s_dn"; | 84 return 200 "body $ssl_client_s_dn:$ssl_client_s_dn_legacy"; |
85 } | |
86 location /time { | |
87 return 200 "body $ssl_client_v_start!$ssl_client_v_end!$ssl_client_v_remain"; | |
82 } | 88 } |
83 | 89 |
84 location /body { | 90 location /body { |
85 add_header X-Body $request_body always; | 91 add_header X-Body $request_body always; |
86 proxy_pass http://127.0.0.1:8080/; | 92 proxy_pass http://127.0.0.1:8080/; |
239 # embedded variables | 245 # embedded variables |
240 | 246 |
241 like(get('/id', 8085), qr/^body \w{64}$/m, 'session id'); | 247 like(get('/id', 8085), qr/^body \w{64}$/m, 'session id'); |
242 unlike(http_get('/id'), qr/body \w/, 'session id no ssl'); | 248 unlike(http_get('/id'), qr/body \w/, 'session id no ssl'); |
243 like(get('/cipher', 8085), qr/^body [\w-]+$/m, 'cipher'); | 249 like(get('/cipher', 8085), qr/^body [\w-]+$/m, 'cipher'); |
250 like(get('/ciphers', 8085), qr/^body [:\w-]+$/m, 'ciphers'); | |
244 like(get('/client_verify', 8085), qr/^body NONE$/m, 'client verify'); | 251 like(get('/client_verify', 8085), qr/^body NONE$/m, 'client verify'); |
245 like(get('/protocol', 8085), qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol'); | 252 like(get('/protocol', 8085), qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol'); |
246 like(cert('/issuer', 8085), qr!^body CN=issuer$!m, 'issuer'); | 253 like(cert('/issuer', 8085), qr!^body CN=issuer:/CN=issuer$!m, 'issuer'); |
247 like(cert('/subject', 8085), qr!^body CN=subject$!m, 'subject'); | 254 like(cert('/subject', 8085), qr!^body CN=subject:/CN=subject$!m, 'subject'); |
255 like(cert('/time', 8085), qr/^body [:\s\w]+![:\s\w]+![23]$/m, 'time'); | |
248 | 256 |
249 # c->read->ready handling bug in ngx_ssl_recv(), triggered with chunked body | 257 # c->read->ready handling bug in ngx_ssl_recv(), triggered with chunked body |
250 | 258 |
251 like(get_body('/body', '0123456789', 20, 5), qr/X-Body: (0123456789){100}/, | 259 like(get_body('/body', '0123456789', 20, 5), qr/X-Body: (0123456789){100}/, |
252 'request body chunked'); | 260 'request body chunked'); |