1#!/usr/bin/env perl
2
3# 2013-10-17 Andrea Urbani (matfanjol)
4# In this ftp test:
5# - the response of SYST command is
6#   215 Unknown ftp service
7# - the response of "LIST -a" command contains
8#   all the files
9# - the response of "LIST" command contains
10#   the normal files (hidden files are not present)
11# wget should use "LIST -a", but also "LIST".
12# After "LIST", wget will see more data is available
13# on "LIST -a", so it should go back to "LIST -a".
14# (See also Test-ftp-list-Unknown-a.px)
15
16use strict;
17use warnings;
18
19use FTPTest;
20
21
22###############################################################################
23
24my $normalfile = <<EOF;
25I'm a normal file
26EOF
27
28my $hiddenfile = <<EOF;
29I'm an hidden file
30EOF
31
32$normalfile =~ s/\n/\r\n/g;
33$hiddenfile =~ s/\n/\r\n/g;
34
35# code, msg, headers, content
36my %urls = (
37    '/normalfile.txt' => {
38        content => $normalfile,
39    },
40    '/hiddenfile.txt' => {
41        content => $hiddenfile,
42        attr => "H",
43    },
44);
45
46my $cmdline = $WgetTest::WGETPATH . " --no-directories --recursive --level=1 ftp://localhost:{{port}}/";
47
48my $expected_error_code = 0;
49
50my %expected_downloaded_files = (
51    'normalfile.txt' => {
52        content => $normalfile,
53    },
54    'hiddenfile.txt' => {
55        content => $hiddenfile,
56    },
57);
58
59###############################################################################
60
61my $the_test = FTPTest->new (
62                             input => \%urls,
63                             cmdline => $cmdline,
64                             errcode => $expected_error_code,
65                             output => \%expected_downloaded_files,
66                             server_behavior => {list_no_hidden_if_list => 1,
67                                                 syst_response => "215 Unknown ftp service"});
68exit $the_test->run();
69