Mercurial > hg > nginx-tests
comparison js_internal_redirect.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 | 3580ad4b575f |
children |
comparison
equal
deleted
inserted
replaced
1810:7cf848422b28 | 1811:520fb74cce4c |
---|---|
98 like(http_get('/test'), qr/redirect/s, 'redirect'); | 98 like(http_get('/test'), qr/redirect/s, 'redirect'); |
99 like(http_get('/test?a=A'), qr/redirectA/s, 'redirect with args'); | 99 like(http_get('/test?a=A'), qr/redirectA/s, 'redirect with args'); |
100 like(http_get('/test?dest=named'), qr/named/s, 'redirect to named location'); | 100 like(http_get('/test?dest=named'), qr/named/s, 'redirect to named location'); |
101 | 101 |
102 TODO: { | 102 TODO: { |
103 local $TODO = 'not yet' | 103 local $TODO = 'not yet' unless has_version('0.7.4'); |
104 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.4'; | |
105 | 104 |
106 like(http_get('/test?unsafe=1'), qr/500 Internal Server/s, | 105 like(http_get('/test?unsafe=1'), qr/500 Internal Server/s, |
107 'unsafe redirect'); | 106 'unsafe redirect'); |
108 like(http_get('/test?quoted=1'), qr/200 .*redirect/s, | 107 like(http_get('/test?quoted=1'), qr/200 .*redirect/s, |
109 'quoted redirect'); | 108 'quoted redirect'); |
110 } | 109 } |
111 | 110 |
112 ############################################################################### | 111 ############################################################################### |
112 | |
113 sub has_version { | |
114 my $need = shift; | |
115 | |
116 http_get('/njs') =~ /^([.0-9]+)$/m; | |
117 | |
118 my @v = split(/\./, $1); | |
119 my ($n, $v); | |
120 | |
121 for $n (split(/\./, $need)) { | |
122 $v = shift @v || 0; | |
123 return 0 if $n > $v; | |
124 return 1 if $v > $n; | |
125 } | |
126 | |
127 return 1; | |
128 } | |
129 | |
130 ############################################################################### |