Welcome! Log In Create A New Profile

Advanced

[PATCH] http_try_files.t: extend test coverage

Damien Tournoud
January 20, 2015 07:00PM
# HG changeset patch
# User Damien Tournoud <damien@commerceguys.com>
# Date 1421798229 -3600
# Wed Jan 21 00:57:09 2015 +0100
# Node ID b99eb5bef46a7b7d9e7bcd32967041d287c80fdb
# Parent 4bcf8bc2bafe1515154e60710ea6ae674080b26c
http_try_files.t: extend test coverage

This extends the test coverage for all the cases of files
or directories matched against each other.

The test case "file doesn't match dir" currently fails,
fixed in http://mailman.nginx.org/pipermail/nginx-devel/2015-January/006468.html

diff -r 4bcf8bc2bafe -r b99eb5bef46a http_try_files.t
--- a/http_try_files.t Thu Jan 15 18:23:16 2015 +0300
+++ b/http_try_files.t Wed Jan 21 00:57:09 2015 +0100
@@ -21,7 +21,7 @@
select STDERR; $| = 1;
select STDOUT; $| = 1;

-my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(4)
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(8)
->write_file_expand('nginx.conf', <<'EOF');

%%TEST_GLOBALS%%
@@ -50,6 +50,22 @@
try_files /short $uri =404;
}

+ location /file-file/ {
+ try_files /found.html =404;
+ }
+
+ location /file-dir/ {
+ try_files /found.html/ =404;
+ }
+
+ location /dir-dir/ {
+ try_files /directory/ =404;
+ }
+
+ location /dir-file/ {
+ try_files /directory =404;
+ }
+
location /fallback {
proxy_pass http://127.0.0.1:8081/fallback;
}
@@ -72,6 +88,7 @@
EOF

$t->write_file('found.html', 'SEE THIS');
+mkdir $t->{_testdir} . '/directory';
$t->run();

###############################################################################
@@ -80,5 +97,9 @@
like(http_get('/uri/notfound'), qr!X-URI: /fallback!, 'not found uri');
like(http_get('/nouri/notfound'), qr!X-URI: /fallback!, 'not found nouri');
like(http_get('/short/long'), qr!404 Not!, 'short uri in try_files');
+like(http_get('/file-file/'), qr!SEE THIS!, 'file matches file');
+like(http_get('/file-dir/'), qr!404 Not!, 'file doesn\'t match dir');
+like(http_get('/dir-dir/'), qr!301 Moved Permanently!, 'dir matches dir');
+like(http_get('/dir-file/'), qr!404 Not!, 'dir doesn\'t match file');

###############################################################################

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] http_try_files.t: extend test coverage

Damien Tournoud 831 January 20, 2015 07:00PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 196
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready