Mercurial > hg > nginx-tests
annotate index.t @ 1260:eadd24ccfda1
Tests: postponed startup in certain ssl certificate tests on win32.
At least, some win32 hosts exhibit a round-off error or some such in the
notBefore field of the certificate generated before starting nginx, such
that it can be set to the value one second ahead of the current time.
This manifests in spurious test failures due to certificate verify error
with a failure reason "certificate is not yet valid".
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 12 Dec 2017 12:53:53 +0300 |
parents | 882267679006 |
children | 261f01ee5364 |
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 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http/)->plan(7) |
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 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 location /var_redirect/ { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 index /$server_name.html; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 EOF |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 $t->write_file('index.html', 'body'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 $t->write_file('many.html', 'manybody'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 $t->write_file('re.html', 'rebody'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 $t->write_file('localhost.html', 'varbody'); |
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 $t->run(); |
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 ############################################################################### |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 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
|
88 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
|
89 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
|
90 like(http_get('/loop/'), qr/500 Internal/, 'redirect loop'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 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
|
92 like(http_get('/var/'), qr/X-URI: \/var\/localhost.html.*varbody/ms, 'var'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 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
|
94 'var with redirect'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 ############################################################################### |