Mercurial > hg > nginx-tests
comparison http_try_files.t @ 635:bc91b86a71ee
Tests: added test for try_files in regex location with alias.
It was broken by c985d90a8d1f.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 27 Jul 2015 13:01:41 +0300 |
parents | 907e89fba9c3 |
children | 68a95e3195f1 |
comparison
equal
deleted
inserted
replaced
634:40675bfad7d3 | 635:bc91b86a71ee |
---|---|
19 ############################################################################### | 19 ############################################################################### |
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(8) | 24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(9) |
25 ->write_file_expand('nginx.conf', <<'EOF'); | 25 ->write_file_expand('nginx.conf', <<'EOF'); |
26 | 26 |
27 %%TEST_GLOBALS%% | 27 %%TEST_GLOBALS%% |
28 | 28 |
29 daemon off; | 29 daemon off; |
64 | 64 |
65 location /dir-file/ { | 65 location /dir-file/ { |
66 try_files /directory =404; | 66 try_files /directory =404; |
67 } | 67 } |
68 | 68 |
69 location ~ /alias_re.html { | |
70 alias %%TESTDIR%%/directory; | |
71 try_files $uri =404; | |
72 } | |
73 | |
69 location /fallback { | 74 location /fallback { |
70 proxy_pass http://127.0.0.1:8081/fallback; | 75 proxy_pass http://127.0.0.1:8081/fallback; |
71 } | 76 } |
72 location /fallback_nouri { | 77 location /fallback_nouri { |
73 proxy_pass http://127.0.0.1:8081; | 78 proxy_pass http://127.0.0.1:8081; |
86 } | 91 } |
87 | 92 |
88 EOF | 93 EOF |
89 | 94 |
90 mkdir($t->testdir() . '/directory'); | 95 mkdir($t->testdir() . '/directory'); |
96 $t->write_file('directory/alias_re.html', 'SEE THIS'); | |
91 $t->write_file('found.html', 'SEE THIS'); | 97 $t->write_file('found.html', 'SEE THIS'); |
92 $t->run(); | 98 $t->run(); |
93 | 99 |
94 ############################################################################### | 100 ############################################################################### |
95 | 101 |
101 like(http_get('/file-file/'), qr!SEE THIS!, 'file matches file'); | 107 like(http_get('/file-file/'), qr!SEE THIS!, 'file matches file'); |
102 like(http_get('/file-dir/'), qr!404 Not!, 'file does not match dir'); | 108 like(http_get('/file-dir/'), qr!404 Not!, 'file does not match dir'); |
103 like(http_get('/dir-dir/'), qr!301 Moved Permanently!, 'dir matches dir'); | 109 like(http_get('/dir-dir/'), qr!301 Moved Permanently!, 'dir matches dir'); |
104 like(http_get('/dir-file/'), qr!404 Not!, 'dir does not match file'); | 110 like(http_get('/dir-file/'), qr!404 Not!, 'dir does not match file'); |
105 | 111 |
112 SKIP: { | |
113 skip 'leaves coredump', 1 unless $ENV{TEST_NGINX_UNSAFE}; | |
114 | |
115 like(http_get('/alias_re.html'), qr!SEE THIS!, 'alias in regex location'); | |
116 | |
117 } | |
118 | |
106 ############################################################################### | 119 ############################################################################### |