comparison ssl_password_file.t @ 431:05c46688b54b

Tests: ssl_password_file.t fixes. Make sure to always specify listen socket in all servers as the default vary (under root, nginx will try to listen on 80). Make sure to detect if an https request was processed by http.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 09 Jul 2014 05:19:51 +0400
parents a82b02635614
children 384c05af0ef9
comparison
equal deleted inserted replaced
430:a82b02635614 431:05c46688b54b
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 plan(skip_all => 'win32') if $^O eq 'MSWin32'; 33 plan(skip_all => 'win32') if $^O eq 'MSWin32';
34 34
35 my $t = Test::Nginx->new()->has(qw/http http_ssl/)->has_daemon('openssl'); 35 my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite/)
36 ->has_daemon('openssl');
36 37
37 plan(skip_all => 'no ssl_password_file') unless $t->has_version('1.7.2'); 38 plan(skip_all => 'no ssl_password_file') unless $t->has_version('1.7.2');
38 39
39 $t->plan(3)->write_file_expand('nginx.conf', <<'EOF'); 40 $t->plan(3)->write_file_expand('nginx.conf', <<'EOF');
40 41
60 server_name localhost; 61 server_name localhost;
61 62
62 ssl_password_file password; 63 ssl_password_file password;
63 64
64 location / { 65 location / {
66 return 200 "$scheme";
65 } 67 }
66 } 68 }
67 69
68 server { 70 server {
71 listen 127.0.0.1:8080;
69 server_name two_entries; 72 server_name two_entries;
70 73
71 ssl_password_file password_many; 74 ssl_password_file password_many;
72 } 75 }
73 76
74 server { 77 server {
78 listen 127.0.0.1:8080;
75 server_name file_is_fifo; 79 server_name file_is_fifo;
76 80
77 ssl_password_file password_fifo; 81 ssl_password_file password_fifo;
78 } 82 }
79 83
80 server { 84 server {
85 listen 127.0.0.1:8080;
81 server_name inherits; 86 server_name inherits;
82 87
83 ssl_certificate_key inherits.key; 88 ssl_certificate_key inherits.key;
84 ssl_certificate inherits.crt; 89 ssl_certificate inherits.crt;
85 } 90 }
129 134
130 is($@, '', 'ssl_password_file works'); 135 is($@, '', 'ssl_password_file works');
131 136
132 # simple tests to ensure that nothing broke with ssl_password_file directive 137 # simple tests to ensure that nothing broke with ssl_password_file directive
133 138
134 like(http_get('/password'), qr/200 OK/, 'http'); 139 like(http_get('/'), qr/200 OK.*http/ms, 'http');
135 like(http_get('/password', socket => get_ssl_socket()), qr/200 OK/, 'https'); 140 like(http_get('/', socket => get_ssl_socket()), qr/200 OK.*https/ms, 'https');
136 141
137 ############################################################################### 142 ###############################################################################
138 143
139 sub get_ssl_socket { 144 sub get_ssl_socket {
140 my $s; 145 my $s;