Welcome! Log In Create A New Profile

Advanced

Patch: tests for slash_redirect_temporary

Blake Williams
August 31, 2019 07:50PM
# HG changeset patch
# User Blake Williams <code@shabbyrobe.org>
# Date 1567294312 -36000
# Sun Sep 01 09:31:52 2019 +1000
# Node ID 9cdf1baf51d3b2ae8fb0d80d10148ba9605d1799
# Parent 44ce08f5259f034c102b7f99b37c423de848c75a
Tests: added slash_redirect_temporary

diff -r 44ce08f5259f -r 9cdf1baf51d3 http_slash_redirect_temporary.t
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/http_slash_redirect_temporary.t Sun Sep 01 09:31:52 2019 +1000
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+
+# (C) Sergey Kandaurov
+# (C) Nginx, Inc.
+
+# Tests for slash_redirect_temporary directive.
+
+###############################################################################
+
+use warnings;
+use strict;
+
+use Test::More;
+
+BEGIN { use FindBin; chdir($FindBin::Bin); }
+
+use lib 'lib';
+use Test::Nginx;
+
+###############################################################################
+
+select STDERR; $| = 1;
+select STDOUT; $| = 1;
+
+my $t = Test::Nginx->new()->has(qw/http/)
+ ->write_file_expand('nginx.conf', <<'EOF');
+
+%%TEST_GLOBALS%%
+
+daemon off;
+
+events {
+}
+
+http {
+ %%TEST_GLOBALS_HTTP%%
+
+ server {
+ listen 127.0.0.1:8080;
+ server_name on;
+
+ location /on/ {
+ slash_redirect_temporary on;
+ root %%TESTDIR%%/data;
+ }
+ location /off/ {
+ slash_redirect_temporary off;
+ root %%TESTDIR%%/data;
+ }
+ }
+}
+
+EOF
+
+mkdir($t->testdir() . '/data');
+mkdir($t->testdir() . '/data/on');
+mkdir($t->testdir() . '/data/on/dir');
+mkdir($t->write_file('/data/on/dir/index.html', ''));
+mkdir($t->testdir() . '/data/off');
+mkdir($t->testdir() . '/data/off/dir');
+mkdir($t->write_file('/data/off/dir/index.html', ''));
+
+$t->run()->plan(4);
+
+###############################################################################
+
+my $p = port(8080);
+
+like(http_get('/off/dir'), qr!HTTP/1.1 301.*Location: .*/off/dir/!sm, 'slash off permanent');
+like(http_get('/off/dir/'), qr!HTTP/1.1 200!m, 'slash off direct');
+like(http_get('/on/dir'), qr!HTTP/1.1 302.*Location: .*/on/dir/!sm, 'slash on permanent');
+like(http_get('/on/dir/'), qr!HTTP/1.1 200!m, 'slash on direct');
+
+###############################################################################

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

Patch: tests for slash_redirect_temporary

Blake Williams August 31, 2019 07:50PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 80
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready