diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-11 02:23:31 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-11 02:23:31 +0000 |
commit | 371192beb362a55b6d62bcae55d659e883b8c25a (patch) | |
tree | 9a6f83ce4e8fa69e4706599c7123fe9a5e1fce55 /test/net/ftp/test_ftp.rb | |
parent | 4629193b3c7d1e85de5085559094ac6384cf7fcf (diff) | |
download | ruby-371192beb362a55b6d62bcae55d659e883b8c25a.tar.gz |
* lib/net/ftp.rb (size, mdtm, system): parse responses according to
RFC 959 and 3659, where reply codes must be followed by SP.
* lib/net/ftp.rb (system): remove LF from the return value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/ftp/test_ftp.rb')
-rw-r--r-- | test/net/ftp/test_ftp.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index e42168e6dc..786f959212 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -1053,6 +1053,72 @@ EOF end end + def test_size + commands = [] + server = create_ftp_server { |sock| + sock.print("220 (test_ftp).\r\n") + commands.push(sock.gets) + sock.print("213 12345\r\n") + } + begin + begin + ftp = Net::FTP.new + ftp.connect(SERVER_ADDR, server.port) + assert_equal(12345, ftp.size("foo.txt")) + assert_match("SIZE foo.txt\r\n", commands.shift) + assert_equal(nil, commands.shift) + ensure + ftp.close if ftp + end + ensure + server.close + end + end + + def test_mdtm + commands = [] + server = create_ftp_server { |sock| + sock.print("220 (test_ftp).\r\n") + commands.push(sock.gets) + sock.print("213 20150910161739\r\n") + } + begin + begin + ftp = Net::FTP.new + ftp.connect(SERVER_ADDR, server.port) + assert_equal("20150910161739", ftp.mdtm("foo.txt")) + assert_match("MDTM foo.txt\r\n", commands.shift) + assert_equal(nil, commands.shift) + ensure + ftp.close if ftp + end + ensure + server.close + end + end + + def test_system + commands = [] + server = create_ftp_server { |sock| + sock.print("220 (test_ftp).\r\n") + commands.push(sock.gets) + sock.print("215 UNIX Type: L8\r\n") + } + begin + begin + ftp = Net::FTP.new + ftp.connect(SERVER_ADDR, server.port) + assert_equal("UNIX Type: L8", ftp.system) + assert_match("SYST\r\n", commands.shift) + assert_equal(nil, commands.shift) + ensure + ftp.close if ftp + end + ensure + server.close + end + end + private |