features/support/test_client.rb in ftpd-0.2.0 vs features/support/test_client.rb in ftpd-0.2.1
- old
+ new
@@ -22,14 +22,17 @@
:delete,
:getbinaryfile,
:gettextfile,
:login,
:ls,
+ :mkdir,
:nlst,
:noop,
:passive=,
:pwd,
+ :rename,
+ :rmdir,
:quit,
:system
def raw(*command)
@ftp.sendcmd command.compact.join(' ')
@@ -55,10 +58,15 @@
def file_contents(path)
File.open(temp_path(path), 'rb', &:read)
end
+ def xpwd
+ response = raw('XPWD')
+ response[/"(.+)"/, 1]
+ end
+
private
RAW_METHOD_REGEX = /^send_(.*)$/
def local_path(remote_path)
@@ -68,23 +76,29 @@
def temp_path(path)
File.expand_path(path, @temp_dir)
end
def make_ftp(opts)
- tls = opts[:tls]
- if tls
- make_tls_ftp
- else
+ tls_mode = opts[:tls] || :off
+ case tls_mode
+ when :off
make_non_tls_ftp
+ when :implicit
+ make_tls_ftp(:implicit)
+ when :explicit
+ make_tls_ftp(:explicit)
+ else
+ raise "Unknown TLS mode: #{tls_mode}"
end
end
- def make_tls_ftp
+ def make_tls_ftp(ftps_mode)
ftp = DoubleBagFTPS.new
context_opts = {
:verify_mode => OpenSSL::SSL::VERIFY_NONE
}
ftp.ssl_context = DoubleBagFTPS.create_ssl_context(context_opts)
+ ftp.ftps_mode = ftps_mode
ftp
end
def make_non_tls_ftp
Net::FTP.new