comparison js_fetch_https.t @ 1811:520fb74cce4c

Tests: improved njs version check to account multi digit versions.
author Dmitry Volyntsev <xeioex@nginx.com>
date Fri, 02 Dec 2022 17:46:22 -0800
parents f7a8997c46c7
children
comparison
equal deleted inserted replaced
1810:7cf848422b28 1811:520fb74cce4c
188 $t->run_daemon(\&dns_daemon, port(8981), $t); 188 $t->run_daemon(\&dns_daemon, port(8981), $t);
189 $t->waitforfile($t->testdir . '/' . port(8981)); 189 $t->waitforfile($t->testdir . '/' . port(8981));
190 190
191 ############################################################################### 191 ###############################################################################
192 192
193 local $TODO = 'not yet' 193 local $TODO = 'not yet' unless has_version('0.7.0');
194 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.0';
195 194
196 like(http_get('/https?domain=default.example.com&verify=false'), 195 like(http_get('/https?domain=default.example.com&verify=false'),
197 qr/You are at default.example.com.$/s, 'fetch https'); 196 qr/You are at default.example.com.$/s, 'fetch https');
198 like(http_get('/https?domain=127.0.0.1&verify=false'), 197 like(http_get('/https?domain=127.0.0.1&verify=false'),
199 qr/You are at default.example.com.$/s, 'fetch https by IP'); 198 qr/You are at default.example.com.$/s, 'fetch https by IP');
208 like(http_get('/https.myca.short?domain=default.example.com'), 207 like(http_get('/https.myca.short?domain=default.example.com'),
209 qr/connect failed/s, 'fetch https CA too far'); 208 qr/connect failed/s, 'fetch https CA too far');
210 209
211 ############################################################################### 210 ###############################################################################
212 211
212 sub has_version {
213 my $need = shift;
214
215 http_get('/njs') =~ /^([.0-9]+)$/m;
216
217 my @v = split(/\./, $1);
218 my ($n, $v);
219
220 for $n (split(/\./, $need)) {
221 $v = shift @v || 0;
222 return 0 if $n > $v;
223 return 1 if $v > $n;
224 }
225
226 return 1;
227 }
228
229 ###############################################################################
230
213 sub reply_handler { 231 sub reply_handler {
214 my ($recv_data, $port, %extra) = @_; 232 my ($recv_data, $port, %extra) = @_;
215 233
216 my (@name, @rdata); 234 my (@name, @rdata);
217 235