Mercurial > hg > nginx-tests
comparison stream_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 | 564f74bf6e4d |
children | cdcd75657e52 |
comparison
equal
deleted
inserted
replaced
1810:7cf848422b28 | 1811:520fb74cce4c |
---|---|
268 $t->run_daemon(\&dns_daemon, port(8981), $t); | 268 $t->run_daemon(\&dns_daemon, port(8981), $t); |
269 $t->waitforfile($t->testdir . '/' . port(8981)); | 269 $t->waitforfile($t->testdir . '/' . port(8981)); |
270 | 270 |
271 ############################################################################### | 271 ############################################################################### |
272 | 272 |
273 local $TODO = 'not yet' | 273 local $TODO = 'not yet' unless has_version('0.7.0'); |
274 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.0'; | |
275 | 274 |
276 like(stream("127.0.0.1:$p2")->io('GOdefault.example.com'), | 275 like(stream("127.0.0.1:$p2")->io('GOdefault.example.com'), |
277 qr/connect failed/s, 'stream non trusted CA'); | 276 qr/connect failed/s, 'stream non trusted CA'); |
278 like(stream("127.0.0.1:$p3")->io('GOdefault.example.com'), | 277 like(stream("127.0.0.1:$p3")->io('GOdefault.example.com'), |
279 qr/https OK/s, 'stream trusted CA'); | 278 qr/https OK/s, 'stream trusted CA'); |
284 | 283 |
285 like(https_get('default.example.com', port(8085), '/backend'), | 284 like(https_get('default.example.com', port(8085), '/backend'), |
286 qr!BACKEND OK!, 'access https fetch'); | 285 qr!BACKEND OK!, 'access https fetch'); |
287 is(https_get('default.example.com', port(8086), '/backend'), '<conn failed>', | 286 is(https_get('default.example.com', port(8086), '/backend'), '<conn failed>', |
288 'access https fetch not'); | 287 'access https fetch not'); |
288 | |
289 ############################################################################### | |
290 | |
291 sub has_version { | |
292 my $need = shift; | |
293 | |
294 http_get('/njs') =~ /^([.0-9]+)$/m; | |
295 | |
296 my @v = split(/\./, $1); | |
297 my ($n, $v); | |
298 | |
299 for $n (split(/\./, $need)) { | |
300 $v = shift @v || 0; | |
301 return 0 if $n > $v; | |
302 return 1 if $v > $n; | |
303 } | |
304 | |
305 return 1; | |
306 } | |
289 | 307 |
290 ############################################################################### | 308 ############################################################################### |
291 | 309 |
292 sub get_ssl_socket { | 310 sub get_ssl_socket { |
293 my ($host, $port) = @_; | 311 my ($host, $port) = @_; |