]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test416: verify growing FTP file support
authorfractal-access <116177727+fractal-access@users.noreply.github.com>
Thu, 10 Nov 2022 15:20:28 +0000 (16:20 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 26 Nov 2022 16:06:28 +0000 (17:06 +0100)
Added setting: RETRSIZE [size] in the <servercmd> section. When set this
will cause the test FTP server to return the size set (rather than the
actual size) in the acknowledgement from a RETR request.

Closes #9772

tests/FILEFORMAT.md
tests/data/Makefile.inc
tests/data/test416 [new file with mode: 0644]
tests/ftpserver.pl

index 57fc2992725a5f733e10fff6532f804113d724a6..02628f67d893adcf80e42c52524c5dfee5e830c3 100644 (file)
@@ -307,6 +307,7 @@ about to issue.
    appear at once when a file is transferred
 - `RETRNOSIZE` - Make sure the RETR response doesn't contain the size of the
   file
+- `RETRSIZE [size]` - Force RETR response to contain the specified size
 - `NOSAVE` - Don't actually save what is received
 - `SLOWDOWN` - Send FTP responses with 0.01 sec delay between each byte
 - `PASVBADIP` - makes PASV send back an illegal IP in its 227 response
index 8d8d66e334ba8886253e6c3719894f508c82aa07..905e803e845c659a539f0676bc93f3a82c228f08 100644 (file)
@@ -67,7 +67,7 @@ test370 test371 test372 test373 test374 test375 test376 test378 test379 \
 test380 test381 test383 test384 test385 test386 test387 test388 test389 \
 test390 test391 test392 test393 test394 test395 test396 test397 test398 \
 test399 test400 test401 test402 test403 test404 test405 test406 test407 \
-test408 test409 test410 test411 test412 test413 test414 test415 \
+test408 test409 test410 test411 test412 test413 test414 test415 test416 \
 \
 test430 test431 test432 test433 test434 test435 test436 \
 \
diff --git a/tests/data/test416 b/tests/data/test416
new file mode 100644 (file)
index 0000000..93dc067
--- /dev/null
@@ -0,0 +1,51 @@
+<testcase>
+<info>
+<keywords>
+FTP
+EPSV
+RETR
+Range
+</keywords>
+</info>
+# Server-side
+<reply>
+<data>
+0123456789abcdef0123456789abcdef0123456789abcdef
+</data>
+<datacheck>
+0123456789abcdef0123456789abcdef0123456789abcdef
+</datacheck>
+<servercmd>
+RETRSIZE 7
+</servercmd>
+<size>
+8
+</size>
+</reply>
+
+# Client-side
+<client>
+<server>
+ftp
+</server>
+ <name>
+FTP growing file support
+ </name>
+ <command>
+--ignore-content-length ftp://%HOSTIP:%FTPPORT/%TESTNUMBER
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+USER anonymous\r
+PASS ftp@example.com\r
+PWD\r
+EPSV\r
+TYPE I\r
+RETR %TESTNUMBER\r
+QUIT\r
+</protocol>
+</verify>
+</testcase>
index 422fdc2ccc82d058e79859e6af22883bd7c9ba9c..095e8b76e2a28b39920609eb51689fedfb29bd07 100755 (executable)
@@ -141,6 +141,7 @@ my $ctrldelay;     # set if server should throttle ctrl stream
 my $datadelay;     # set if server should throttle data stream
 my $retrweirdo;    # set if ftp server should use RETRWEIRDO
 my $retrnosize;    # set if ftp server should use RETRNOSIZE
+my $retrsize;      # set if ftp server should use RETRSIZE
 my $pasvbadip;     # set if ftp server should use PASVBADIP
 my $nosave;        # set if ftp server should not save uploaded data
 my $nodataconn;    # set if ftp srvr doesn't establish or accepts data channel
@@ -2343,6 +2344,9 @@ sub RETR_ftp {
             if($retrnosize) {
                 $sz = "size?";
             }
+            elsif($retrsize > 0) {
+                $sz = "($retrsize bytes)";
+            }
 
             sendcontrol "150 Binary data connection for $testno () $sz.\r\n";
 
@@ -2795,6 +2799,7 @@ sub customize {
     $datadelay = 0;     # default is no throttling of the data stream
     $retrweirdo = 0;    # default is no use of RETRWEIRDO
     $retrnosize = 0;    # default is no use of RETRNOSIZE
+    $retrsize = 0;      # default is no use of RETRSIZE
     $pasvbadip = 0;     # default is no use of PASVBADIP
     $nosave = 0;        # default is to actually save uploaded data to file
     $nodataconn = 0;    # default is to establish or accept data channel
@@ -2862,6 +2867,10 @@ sub customize {
             logmsg "FTPD: instructed to use RETRNOSIZE\n";
             $retrnosize=1;
         }
+        elsif($_ =~ /RETRSIZE (\d+)/) {
+            $retrsize= $1;
+            logmsg "FTPD: instructed to use RETRSIZE = $1\n";
+        }
         elsif($_ =~ /PASVBADIP/) {
             logmsg "FTPD: instructed to use PASVBADIP\n";
             $pasvbadip=1;