summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-11 02:23:31 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-11 02:23:31 +0000
commit782e2148aff47d871e6079867fede4ea3f2526a1 (patch)
tree9a6f83ce4e8fa69e4706599c7123fe9a5e1fce55 /test/net
parenta7727448a180feeb50998b747b5b04a77aeb313b (diff)
* 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')
-rw-r--r--test/net/ftp/test_ftp.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb
index e42168e..786f959 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