FTP: Test and fix handling of symbolic link name containing spaces
[elinks.git] / src / protocol / ftp / test-ftp-parser
blob370e22379d894eff6d75d5fa0b43d0b199a3172f
1 #!/bin/sh
3 # Copyright (c) 2005 Jonas Fonseca
6 test_description='Test parsing of FTP responses.
8 It tests responses from several different FTP servers.
11 . "$TEST_LIB"
13 CRNL="\r\n"
15 test_ftp_response_expect_success () {
16 desc="$1"; shift
17 response="$1"; shift
19 response="$(echo "$response" | sed -n '2,$p')"
21 test_expect_success "$desc" \
22 "ftp-parser --response \"$response\""
25 test_ftp_response_expect_failure () {
26 desc="$1"; shift
27 response="$1"; shift
29 response="$(echo "$response" | sed -n '2,$p')"
31 test_expect_failure "$desc" \
32 "ftp-parser --response \"$response\""
35 #############################################################################
37 # Parser for UNIX-style listing:
40 test_ftp_response_expect_success \
41 'ftp.freebsd.org response' \
43 drwxrwxr-x 3 0 0 512 Apr 17 2003 pub\r\n"
45 test_ftp_response_expect_success \
46 'UNIX-style listing, without inum and without blocks' \
48 -rw-r--r-- 1 root other 531 Jan 29 03:26 README\r\n
49 dr-xr-xr-x 2 root other 512 Apr 8 1994 etc\r\n
50 dr-xr-xr-x 2 root 512 Apr 8 1994 etc\r\n
51 lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin\r\n"
53 test_ftp_response_expect_success \
54 "Response produced by Microsoft's FTP servers for Windows" \
56 ---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z\r\n
57 d--------- 1 owner group 0 May 9 19:45 Softlib\r\n"
59 test_ftp_response_expect_success \
60 'Response from WFTPD for MSDOS' \
62 -rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp\r\n"
64 test_ftp_response_expect_success \
65 'Response from FreeBSD with symbolic link' \
67 lrwxrwx--x 1 110 1002 13 Oct 24 2006 5.3 has moved to ftp-archive -> ../README.TXT\r\n"
69 test_ftp_response_expect_success \
70 'Response from NetWare' \
72 d[R----F--] supervisor 512 Jan 16 18:53 login\r\n
73 - [R----F--] rhesus 214059 Oct 20 15:27 cx.exe\r\n"
75 test_ftp_response_expect_success \
76 'Response from NetPresenz for the Mac' \
78 -------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit\r\n
79 drwxrwxr-x folder 2 May 10 1996 network\r\n"
82 #############################################################################
84 # EPLF response
87 test_ftp_response_expect_success \
88 'EPLF responses' \
90 +i8388621.48594,m825718503,r,s280, djb.html\r\n
91 +i8388621.50690,m824255907,/, 514\r\n
92 +i8388621.48598,m824253270,r,s612, 514.html\r\n"
94 #############################################################################
96 # Parser for VMS-style MultiNet (some spaces removed from examples)
99 test_ftp_response_expect_success \
100 'Basic VMS responses' \
102 00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)\r\n
103 CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)\r\n"
105 test_ftp_response_expect_success \
106 'Response from non-MutliNet VMS' \
108 CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)\r\n"
110 test_ftp_response_expect_failure \
111 'A garbage line which should fail' \
113 EA95_0PS.GZ;1 No privilege for attempted operation\r\n"
115 #############################################################################
117 # Parser for the MSDOS-style format
120 test_ftp_response_expect_success \
121 'Basic MSDOS-style format' \
123 04-27-00 09:09PM <DIR> licensed\r\n
124 07-18-00 10:16AM <DIR> pub\r\n
125 04-14-00 03:47PM 589 readme.htm\r\n"
128 test_done