Mercurial > hg > nginx-tests
annotate index.t @ 1411:a8243ed8adcb
Tests: expect ssl_sni_reneg.t failures on stable in certain cases.
Notably, if built with OpenSSL 1.1.1 on Linux, SSL renegotiation could be
handled too late if client manages to keep recv buffer filled on server.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 05 Dec 2018 17:10:01 +0300 |
parents | 261f01ee5364 |
children | f0a9f5fecc8f |
rev | line source |
---|---|
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for index module. |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
1386
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http/)->plan(8) |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 http { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 listen 127.0.0.1:8080; |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 server_name localhost; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 add_header X-URI $uri; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 location / { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 # index index.html by default |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location /redirect/ { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 index /re.html; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location /loop/ { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 index /loop/; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 location /no_index/ { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 alias %%TESTDIR%%/; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 index nonexisting.html; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 location /many/ { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 alias %%TESTDIR%%/; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 index nonexisting.html many.html; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 location /var/ { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 alias %%TESTDIR%%/; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 index $server_name.html; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
1386
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
70 location /va2/ { |
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
71 alias %%TESTDIR%%/; |
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
72 # before 1.13.8, the token produced emerg: |
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
73 # directive "index" is not terminated by ";" |
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
74 index ${server_name}.html; |
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
75 } |
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
76 |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 location /var_redirect/ { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 index /$server_name.html; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 EOF |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 $t->write_file('index.html', 'body'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 $t->write_file('many.html', 'manybody'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 $t->write_file('re.html', 'rebody'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 $t->write_file('localhost.html', 'varbody'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 $t->run(); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 ############################################################################### |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 like(http_get('/'), qr/X-URI: \/index.html.*body/ms, 'default index'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 like(http_get('/no_index/'), qr/403 Forbidden/, 'no index'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 like(http_get('/redirect/'), qr/X-URI: \/re.html.*rebody/ms, 'redirect'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 like(http_get('/loop/'), qr/500 Internal/, 'redirect loop'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 like(http_get('/many/'), qr/X-URI: \/many\/many.html.*manybody/ms, 'many'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 like(http_get('/var/'), qr/X-URI: \/var\/localhost.html.*varbody/ms, 'var'); |
1386
261f01ee5364
Tests: index module tests merged.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
100 like(http_get('/va2/'), qr/X-URI: \/va2\/localhost.html.*varbody/ms, 'var 2'); |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 like(http_get('/var_redirect/'), qr/X-URI: \/localhost.html.*varbody/ms, |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 'var with redirect'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 ############################################################################### |