[PATCH] Tests: tests for DAV COPY with alias

Maxim Dounin mdounin at mdounin.ru
Mon Mar 30 02:28:09 UTC 2026


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1774837256 -10800
#      Mon Mar 30 05:20:56 2026 +0300
# Node ID 123afa1ea4ab41b10c1f5e16ade219f202d23095
# Parent  d7cbb4aa6548e5bcf520ada9053327600829f8dd
Tests: tests for DAV COPY with alias.

diff --git a/dav.t b/dav.t
--- a/dav.t
+++ b/dav.t
@@ -21,7 +21,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http dav/)->plan(28);
+my $t = Test::Nginx->new()->has(qw/http dav/)->plan(31);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -180,6 +180,8 @@ EOF
 like($r, qr/204 No Content/, 'copy file overwrite');
 is(-s $t->testdir() . '/file.exist', 10, 'target file truncated');
 
+# tests in location with alias
+
 $r = http(<<EOF . '0123456789');
 PUT /i/alias HTTP/1.1
 Host: localhost
@@ -192,6 +194,50 @@ like($r, qr/201 Created.*(Content-Length
 like($r, qr!Location: /i/alias\x0d?$!ms, 'location alias');
 is(-s $t->testdir() . '/alias', 10, 'put alias size');
 
+$r = http(<<EOF);
+COPY /i/file HTTP/1.1
+Host: localhost
+Connection: close
+Destination: /i/file.alias
+
+EOF
+
+like($r, qr/204 No Content/, 'copy alias');
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.29.7');
+
+$r = http(<<EOF);
+COPY /i/file HTTP/1.1
+Host: localhost
+Connection: close
+Destination: /x/file.alias
+
+EOF
+
+like($r, qr/400 Bad Request/, 'copy alias outside');
+
+}
+
+TODO: {
+local $TODO = 'not yet', $t->todo_alerts()
+	unless $t->has_version('1.29.7');
+todo_skip 'leaves coredump', 1
+	unless $t->has_version('1.29.7')
+	or $ENV{TEST_NGINX_UNSAFE};
+
+$r = http(<<EOF);
+COPY /i/file HTTP/1.1
+Host: localhost
+Connection: close
+Destination: /x
+
+EOF
+
+like($r, qr/400 Bad Request/, 'copy alias too short');
+
+}
+
 # request methods with unsupported request body
 
 $r = http(<<EOF . '0123456789');



More information about the nginx-devel mailing list