diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-12 09:16:21 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-12 09:16:21 +0000 |
commit | e74d1eea03dc60a547b14cc5c225e27625f5a893 (patch) | |
tree | 010b14c563f148ed4b0b9acaa5990dbe59b9f2ae /test/net/ftp | |
parent | cd9e8cb2efe4f04bad41ac39cb58835c7c2bb837 (diff) | |
download | ruby-e74d1eea03dc60a547b14cc5c225e27625f5a893.tar.gz |
* lib/net/ftp.rb (parse_mlsx_entry, mlst) raise an FTPProtoError
when parsing failed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/ftp')
-rw-r--r-- | test/net/ftp/test_ftp.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index 9fb2c1a03b..d347a30a1e 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -1127,12 +1127,23 @@ EOF sock.print("250- Listing foo\r\n") sock.print(" Type=file;Unique=FC00U1E554A;Size=1234567;Modify=20131220035929;Perm=r; /foo\r\n") sock.print("250 End\r\n") + commands.push(sock.gets) + sock.print("250 Malformed response\r\n") + commands.push(sock.gets) + sock.print("250- Listing foo\r\n") + sock.print("\r\n") + sock.print("250 End\r\n") + commands.push(sock.gets) + sock.print("250- Listing foo\r\n") + sock.print(" abc /foo\r\n") + sock.print("250 End\r\n") } begin begin ftp = Net::FTP.new ftp.connect(SERVER_ADDR, server.port) entry = ftp.mlst("foo") + assert_equal("/foo", entry.pathname) assert_equal("file", entry.facts["type"]) assert_equal("FC00U1E554A", entry.facts["unique"]) assert_equal(1234567, entry.facts["size"]) @@ -1146,6 +1157,17 @@ EOF assert_equal(29, modify.sec) assert_equal(true, modify.utc?) assert_match("MLST foo\r\n", commands.shift) + assert_raise(Net::FTPProtoError) do + ftp.mlst("foo") + end + assert_match("MLST foo\r\n", commands.shift) + assert_raise(Net::FTPProtoError) do + ftp.mlst("foo") + end + assert_match("MLST foo\r\n", commands.shift) + entry = ftp.mlst("foo") + assert_equal("/foo", entry.pathname) + assert_match("MLST foo\r\n", commands.shift) assert_equal(nil, commands.shift) ensure ftp.close if ftp @@ -1204,6 +1226,9 @@ EOF assert_equal("TYPE I\r\n", commands.shift) entries = ftp.mlsd("/") assert_equal(3, entries.size) + assert_equal("foo", entries[0].pathname) + assert_equal(".", entries[1].pathname) + assert_equal("..", entries[2].pathname) assert_equal("file", entries[0].facts["type"]) assert_equal("cdir", entries[1].facts["type"]) assert_equal("pdir", entries[2].facts["type"]) |