Mercurial > hg > nginx-tests
annotate autoindex_format.t @ 540:481d705b8610
Tests: SSL support in mail backends.
Socket is now embedded into every mail module.
Socket methods are wrapped where appropriate.
The new "SSL" extra flag specifies to accept connection over SSL.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 03 Apr 2015 00:11:38 +0300 |
parents | 7fa91726cc7d |
children | 907e89fba9c3 |
rev | line source |
---|---|
518
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Sergey Kandaurov |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 # (C) Nginx, Inc. |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 # Tests for autoindex module with autoindex_format directive. |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 ############################################################################### |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use warnings; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use strict; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 use Test::More; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use lib 'lib'; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
534
7fa91726cc7d
Tests: skipped autoindex_format.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
518
diff
changeset
|
26 plan(skip_all => 'no symlinks on win32') if $^O eq 'MSWin32'; |
7fa91726cc7d
Tests: skipped autoindex_format.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
518
diff
changeset
|
27 |
518
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/http autoindex/) |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 ->write_file_expand('nginx.conf', <<'EOF'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 autoindex on; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location /xml/ { |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 autoindex_format xml; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 alias %%TESTDIR%%/; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location /json/ { |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 autoindex_format json; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 alias %%TESTDIR%%/; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 } |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 location /jsonp/ { |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 autoindex_format jsonp; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 alias %%TESTDIR%%/; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 EOF |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 my $d = $t->testdir(); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 mkdir("$d/test-dir"); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 symlink("$d/test-dir", "$d/test-dir-link"); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 $t->write_file('test-file', 'x' x 42); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 symlink("$d/test-file", "$d/test-file-link"); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 $t->write_file('test-\'-quote', ''); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 $t->write_file('test-"-double', ''); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 $t->write_file('test-<>-angle', ''); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 mkdir($d . '/utf8'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 $t->write_file('utf8/test-utf8-' . ("\xd1\x84" x 3), ''); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 $t->write_file('utf8/test-utf8-' . ("\xd1\x84" x 45), ''); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 $t->try_run('no autoindex_format')->plan(37); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 ############################################################################### |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 my ($r, $mtime, $data); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 $r = http_get('/xml/'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 $mtime = qr/mtime="\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ"/; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 like($r, qr!Content-Type: text/xml; charset=utf-8!, 'xml content type'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 like($r, qr!<file(\s+\w+="[^=]*?")+\s*>test-file</file>!, |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 'xml file format'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 like($r, qr!<directory(\s+\w+="[^=]*?")+\s*>test-dir</directory>!, |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 'xml dir format'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 ($data) = $r =~ qr!<file\s+(.*?)>test-file</file>!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 like($data, $mtime, 'xml file mtime'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 like($data, qr!size="42"!, 'xml file size'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 ($data) = $r =~ qr!<file\s+(.*?)>test-file-link</file>!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 like($data, $mtime, 'xml file link mtime'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 like($data, qr!size="42"!, 'xml file link size'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 ($data) = $r =~ qr!<directory\s+(.*?)>test-dir</directory>!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 like($data, $mtime, 'xml dir mtime'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 unlike($data, qr!size="\d+"!, 'xml dir size'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 ($data) = $r =~ qr!<directory\s+(.*?)>test-dir-link</directory>!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 like($data, $mtime, 'xml dir link mtime'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 unlike($data, qr!size="\d+"!, 'xml dir link size'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 like($r, qr!<file.*?>test-\'-quote</file>!, 'xml quote'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 like($r, qr!<file.*?>test-\"-double</file>!, 'xml double'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 like($r, qr!<file.*?>test-<>-angle</file>!, 'xml angle'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 $r = http_get('/json/'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 $mtime = qr/"mtime"\s*:\s*"\w{3}, \d\d \w{3} \d{4} \d\d:\d\d:\d\d \w{3}"/; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 my $string = qr!"(?:[^\\"]+|\\["\\/bfnrt])*"!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 my $number = qr!-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 my $kv = qr!\s*$string\s*:\s*($string|$number)\s*!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 like($r, qr!Content-Type: application/json!, 'json content type'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 like($r, qr!{$kv(,$kv)*}!, 'json format'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 ($data) = $r =~ qr!({[^}]*?"name"\s*:\s*"test-file".*?})!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 like($data, qr!"type"\s*:\s*"file"!, 'json file'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 like($data, $mtime, 'json file mtime'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 like($data, qr!"size"\s*:\s*42!, 'json file size'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 ($data) = $r =~ qr!({[^}]*?"name"\s*:\s*"test-file-link".*?})!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 like($data, qr!"type"\s*:\s*"file"!, 'json file link'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 like($data, $mtime, 'json file link mtime'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 like($data, qr!"size"\s*:\s*42!, 'json file link size'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 ($data) = $r =~ qr!({[^}]*?"name"\s*:\s*"test-dir".*?})!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 like($data, qr!"type"\s*:\s*"directory"!, 'json dir'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 like($data, $mtime, 'json dir mtime'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 unlike($data, qr!"size"\s*:\s*$number!, 'json dir size'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 ($data) = $r =~ qr!({[^}]*?"name"\s*:\s*"test-dir-link".*?})!; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 like($data, qr!"type"\s*:\s*"directory"!, 'json dir link'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 like($data, $mtime, 'json dir link mtime'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 unlike($data, qr!"size"\s*:\s*$number!, 'json dir link size'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 like($r, qr!"name"\s*:\s*"test-'-quote"!, 'json quote'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 like($r, qr!"name"\s*:\s*"test-\\\"-double"!, 'json double'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 like($r, qr!"name"\s*:\s*"test-<>-angle"!, 'json angle'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 like(http_get_body('/jsonp/test-dir/?callback=foo'), |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 qr/^\s*foo\s*\(\s*\[\s*\]\s*\)\s*;\s*$/ms, 'jsonp callback'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 like(http_get_body('/jsonp/test-dir/?callback='), |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 qr/^\s*\[\s*\s*\]\s*$/ms, 'jsonp callback empty'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 # utf8 tests |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 $r = http_get('/xml/utf8/'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 like($r, qr!test-utf8-(\xd1\x84){3}</file>!ms, 'xml utf8'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 like($r, qr!test-utf8-(\xd1\x84){45}</file>!ms, 'xml utf8 long'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 $r = http_get('/json/utf8/'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 like($r, qr!test-utf8-(\xd1\x84){3}"!ms, 'json utf8'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 like($r, qr!test-utf8-(\xd1\x84){45}"!ms, 'json utf8 long'); |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 ############################################################################### |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 sub http_get_body { |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 my ($uri) = @_; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 return undef if !defined $uri; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 http_get($uri) =~ /(.*?)\x0d\x0a?\x0d\x0a?(.*)/ms; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 return $2; |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 } |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 |
9edb609a2642
Tests: autoindex module tests with autoindex_format.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 ############################################################################### |