Mercurial > hg > nginx-tests
comparison js_internal_redirect.t @ 1757:ce8b0c9452ae
Tests: added extended js internalRedirect tests.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Thu, 28 Apr 2022 17:20:27 -0700 |
parents | 18ac4d9e5a2a |
children | 3580ad4b575f |
comparison
equal
deleted
inserted
replaced
1756:6966f099068d | 1757:ce8b0c9452ae |
---|---|
61 $t->write_file('test.js', <<EOF); | 61 $t->write_file('test.js', <<EOF); |
62 function redirect(r) { | 62 function redirect(r) { |
63 if (r.variables.arg_dest == 'named') { | 63 if (r.variables.arg_dest == 'named') { |
64 r.internalRedirect('\@named'); | 64 r.internalRedirect('\@named'); |
65 | 65 |
66 } else if (r.variables.arg_unsafe) { | |
67 r.internalRedirect('/red\0rect'); | |
68 | |
69 } else if (r.variables.arg_quoted) { | |
70 r.internalRedirect('/red%69rect'); | |
71 | |
66 } else { | 72 } else { |
67 if (r.variables.arg_a) { | 73 if (r.variables.arg_a) { |
68 r.internalRedirect('/redirect?b=' + r.variables.arg_a); | 74 r.internalRedirect('/redirect?b=' + r.variables.arg_a); |
69 | 75 |
70 } else { | 76 } else { |
75 | 81 |
76 export default {redirect}; | 82 export default {redirect}; |
77 | 83 |
78 EOF | 84 EOF |
79 | 85 |
80 $t->try_run('no njs available')->plan(3); | 86 $t->try_run('no njs available')->plan(5); |
81 | 87 |
82 ############################################################################### | 88 ############################################################################### |
83 | 89 |
84 like(http_get('/test'), qr/redirect/s, 'redirect'); | 90 like(http_get('/test'), qr/redirect/s, 'redirect'); |
85 like(http_get('/test?a=A'), qr/redirectA/s, 'redirect with args'); | 91 like(http_get('/test?a=A'), qr/redirectA/s, 'redirect with args'); |
86 like(http_get('/test?dest=named'), qr/named/s, 'redirect to named location'); | 92 like(http_get('/test?dest=named'), qr/named/s, 'redirect to named location'); |
87 | 93 |
94 TODO: { | |
95 local $TODO = 'not yet' | |
96 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.4'; | |
97 | |
98 like(http_get('/test?unsafe=1'), qr/500 Internal Server/s, | |
99 'unsafe redirect'); | |
100 like(http_get('/test?quoted=1'), qr/200 .*redirect/s, | |
101 'quoted redirect'); | |
102 } | |
103 | |
88 ############################################################################### | 104 ############################################################################### |