Mercurial > hg > nginx-tests
annotate msie_refresh.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 05b2033f5377 |
children |
rev | line source |
---|---|
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
6 # Test for msie_refresh. |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http rewrite ssi/)->plan(5) |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 http { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 server { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 listen 127.0.0.1:8080; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 server_name localhost; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
42 msie_refresh on; |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
43 |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 location / { |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
45 return 301 text; |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
46 } |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
47 |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
48 location /space { |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
49 return 301 "space "; |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
51 |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
52 location /error_page { |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
53 return 301; |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
54 error_page 301 text; |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
55 } |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
56 |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
57 location /off { |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
58 msie_refresh off; |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
59 return 301 text; |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
60 } |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
61 |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 location /ssi { |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
63 ssi on; |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 EOF |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
70 $t->write_file('ssi.html', 'X<!--#include virtual="/" -->X'); |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $t->run(); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 ############################################################################### |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
75 like(get('/'), qr/Refresh.*URL=text"/, 'msie refresh'); |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
76 like(get('/space'), qr/URL=space%20"/, 'msie refresh escaped url'); |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
77 like(get('/error_page'), qr/URL=text"/, 'msie refresh error page'); |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
78 |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
79 unlike(get('/off'), qr/Refresh/, 'msie refresh disabled'); |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
80 |
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
81 unlike(get('/ssi.html'), qr/^0\x0d\x0a?\x0d\x0a?\w/m, 'only final chunk'); |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 ############################################################################### |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 sub get { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 my ($url, $extra) = @_; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 return http(<<EOF); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 GET $url HTTP/1.1 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 Host: localhost |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 Connection: close |
1257
05b2033f5377
Tests: msie_refresh generic tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
91 User-Agent: MSIE foo |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 EOF |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 ############################################################################### |