2006-01-02 19:28:44 -05:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2005 Jonas Fonseca
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Test parsing of FTP responses.
|
|
|
|
|
|
|
|
It tests responses from several different FTP servers.
|
|
|
|
'
|
|
|
|
|
|
|
|
. "$TEST_LIB"
|
|
|
|
|
|
|
|
CRNL="\r\n"
|
|
|
|
|
|
|
|
test_ftp_response_expect_success () {
|
|
|
|
desc="$1"; shift
|
|
|
|
response="$1"; shift
|
|
|
|
|
|
|
|
response="$(echo "$response" | sed -n '2,$p')"
|
|
|
|
|
|
|
|
test_expect_success "$desc" \
|
2006-01-02 19:55:18 -05:00
|
|
|
"ftp-parser --response \"$response\""
|
2006-01-02 19:28:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
test_ftp_response_expect_failure () {
|
|
|
|
desc="$1"; shift
|
|
|
|
response="$1"; shift
|
|
|
|
|
|
|
|
response="$(echo "$response" | sed -n '2,$p')"
|
|
|
|
|
|
|
|
test_expect_failure "$desc" \
|
2006-01-02 19:55:18 -05:00
|
|
|
"ftp-parser --response \"$response\""
|
2006-01-02 19:28:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
#
|
|
|
|
# Parser for UNIX-style listing:
|
|
|
|
#
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'ftp.freebsd.org response' \
|
|
|
|
"
|
|
|
|
drwxrwxr-x 3 0 0 512 Apr 17 2003 pub\r\n"
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'UNIX-style listing, without inum and without blocks' \
|
|
|
|
"
|
|
|
|
-rw-r--r-- 1 root other 531 Jan 29 03:26 README\r\n
|
|
|
|
dr-xr-xr-x 2 root other 512 Apr 8 1994 etc\r\n
|
|
|
|
dr-xr-xr-x 2 root 512 Apr 8 1994 etc\r\n
|
|
|
|
lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin\r\n"
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
"Response produced by Microsoft's FTP servers for Windows" \
|
|
|
|
"
|
|
|
|
---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z\r\n
|
|
|
|
d--------- 1 owner group 0 May 9 19:45 Softlib\r\n"
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'Response from WFTPD for MSDOS' \
|
|
|
|
"
|
|
|
|
-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp\r\n"
|
|
|
|
|
2008-02-27 07:22:12 -05:00
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'Response from FreeBSD with symbolic link' \
|
|
|
|
"
|
|
|
|
lrwxrwx--x 1 110 1002 13 Oct 24 2006 5.3 has moved to ftp-archive -> ../README.TXT\r\n"
|
|
|
|
|
2006-01-02 19:28:44 -05:00
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'Response from NetWare' \
|
|
|
|
"
|
|
|
|
d[R----F--] supervisor 512 Jan 16 18:53 login\r\n
|
|
|
|
- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe\r\n"
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'Response from NetPresenz for the Mac' \
|
|
|
|
"
|
|
|
|
-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit\r\n
|
|
|
|
drwxrwxr-x folder 2 May 10 1996 network\r\n"
|
|
|
|
|
2006-12-15 16:34:56 -05:00
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'Response from server mentioned in debian bug 403139' \
|
|
|
|
"
|
|
|
|
-rw-r--r-- 1 root root 1126400 Jul 28 2003 client.tar\r\n
|
|
|
|
-rw-r--r-- 1 root root 3146776576 Dec 15 19:08 dontlook\r\n"
|
2006-01-02 19:28:44 -05:00
|
|
|
|
2006-01-02 19:55:18 -05:00
|
|
|
#############################################################################
|
|
|
|
#
|
|
|
|
# EPLF response
|
|
|
|
#
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'EPLF responses' \
|
2006-01-21 02:28:57 -05:00
|
|
|
"
|
|
|
|
+i8388621.48594,m825718503,r,s280, djb.html\r\n
|
|
|
|
+i8388621.50690,m824255907,/, 514\r\n
|
|
|
|
+i8388621.48598,m824253270,r,s612, 514.html\r\n"
|
2006-01-02 19:55:18 -05:00
|
|
|
|
2006-01-02 19:28:44 -05:00
|
|
|
#############################################################################
|
|
|
|
#
|
|
|
|
# Parser for VMS-style MultiNet (some spaces removed from examples)
|
|
|
|
#
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'Basic VMS responses' \
|
|
|
|
"
|
|
|
|
00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)\r\n
|
|
|
|
CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)\r\n"
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'Response from non-MutliNet VMS' \
|
|
|
|
"
|
|
|
|
CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)\r\n"
|
|
|
|
|
|
|
|
test_ftp_response_expect_failure \
|
|
|
|
'A garbage line which should fail' \
|
|
|
|
"
|
|
|
|
EA95_0PS.GZ;1 No privilege for attempted operation\r\n"
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
#
|
|
|
|
# Parser for the MSDOS-style format
|
|
|
|
#
|
|
|
|
|
|
|
|
test_ftp_response_expect_success \
|
|
|
|
'Basic MSDOS-style format' \
|
|
|
|
"
|
|
|
|
04-27-00 09:09PM <DIR> licensed\r\n
|
|
|
|
07-18-00 10:16AM <DIR> pub\r\n
|
|
|
|
04-14-00 03:47PM 589 readme.htm\r\n"
|
|
|
|
|
|
|
|
|
|
|
|
test_done
|