comparison ssl_password_file.t @ 1866:a797d7428fa5

Tests: simplified http SSL tests with IO::Socket::SSL. The http SSL tests which previously used IO::Socket::SSL were converted to use improved IO::Socket::SSL infrastructure in Test::Nginx.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 18 May 2023 18:07:19 +0300
parents cdcd75657e52
children b5036a0f9ae0
comparison
equal deleted inserted replaced
1865:0e1865aa9b33 1866:a797d7428fa5
47 47
48 # inherited by server "inherits" 48 # inherited by server "inherits"
49 ssl_password_file password_http; 49 ssl_password_file password_http;
50 50
51 server { 51 server {
52 listen 127.0.0.1:8081 ssl; 52 listen 127.0.0.1:8443 ssl;
53 listen 127.0.0.1:8080; 53 listen 127.0.0.1:8080;
54 server_name localhost; 54 server_name localhost;
55 55
56 ssl_password_file password; 56 ssl_password_file password;
57 57
130 is($@, '', 'ssl_password_file works'); 130 is($@, '', 'ssl_password_file works');
131 131
132 # simple tests to ensure that nothing broke with ssl_password_file directive 132 # simple tests to ensure that nothing broke with ssl_password_file directive
133 133
134 like(http_get('/'), qr/200 OK.*http/ms, 'http'); 134 like(http_get('/'), qr/200 OK.*http/ms, 'http');
135 like(http_get('/', socket => get_ssl_socket()), qr/200 OK.*https/ms, 'https'); 135 like(http_get('/', SSL => 1), qr/200 OK.*https/ms, 'https');
136 136
137 ############################################################################### 137 ###############################################################################
138
139 sub get_ssl_socket {
140 my $s;
141
142 eval {
143 local $SIG{ALRM} = sub { die "timeout\n" };
144 local $SIG{PIPE} = sub { die "sigpipe\n" };
145 alarm(8);
146 $s = IO::Socket::SSL->new(
147 Proto => 'tcp',
148 PeerAddr => '127.0.0.1:' . port(8081),
149 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
150 SSL_error_trap => sub { die $_[1] }
151 );
152 alarm(0);
153 };
154 alarm(0);
155
156 if ($@) {
157 log_in("died: $@");
158 return undef;
159 }
160
161 return $s;
162 }
163
164 ###############################################################################