investtools-ftpd 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +5 -0
- data/.yardopts +7 -0
- data/Changelog.md +310 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +93 -0
- data/LICENSE.md +9 -0
- data/README.md +371 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/doc/benchmarks.md +82 -0
- data/doc/references.md +66 -0
- data/doc/rfc-compliance.md +292 -0
- data/examples/example.rb +275 -0
- data/examples/example_spec.rb +93 -0
- data/examples/hello_world.rb +32 -0
- data/features/example/eplf.feature +14 -0
- data/features/example/example.feature +18 -0
- data/features/example/read_only.feature +63 -0
- data/features/example/step_definitions/example_server.rb +11 -0
- data/features/ftp_server/abort.feature +13 -0
- data/features/ftp_server/allo.feature +33 -0
- data/features/ftp_server/append.feature +94 -0
- data/features/ftp_server/cdup.feature +36 -0
- data/features/ftp_server/command_errors.feature +13 -0
- data/features/ftp_server/concurrent_sessions.feature +14 -0
- data/features/ftp_server/delay_after_failed_login.feature +23 -0
- data/features/ftp_server/delete.feature +60 -0
- data/features/ftp_server/directory_navigation.feature +59 -0
- data/features/ftp_server/disconnect_after_failed_logins.feature +25 -0
- data/features/ftp_server/eprt.feature +55 -0
- data/features/ftp_server/epsv.feature +36 -0
- data/features/ftp_server/features.feature +38 -0
- data/features/ftp_server/file_structure.feature +43 -0
- data/features/ftp_server/get.feature +80 -0
- data/features/ftp_server/get_ipv6.feature +43 -0
- data/features/ftp_server/get_tls.feature +23 -0
- data/features/ftp_server/help.feature +21 -0
- data/features/ftp_server/implicit_tls.feature +23 -0
- data/features/ftp_server/invertability.feature +15 -0
- data/features/ftp_server/list.feature +94 -0
- data/features/ftp_server/list_tls.feature +29 -0
- data/features/ftp_server/logging.feature +11 -0
- data/features/ftp_server/login_auth_level_account.feature +51 -0
- data/features/ftp_server/login_auth_level_password.feature +59 -0
- data/features/ftp_server/login_auth_level_user.feature +31 -0
- data/features/ftp_server/max_connections.feature +39 -0
- data/features/ftp_server/mdtm.feature +53 -0
- data/features/ftp_server/mkdir.feature +70 -0
- data/features/ftp_server/mode.feature +43 -0
- data/features/ftp_server/name_list.feature +77 -0
- data/features/ftp_server/name_list_tls.feature +30 -0
- data/features/ftp_server/noop.feature +17 -0
- data/features/ftp_server/options.feature +17 -0
- data/features/ftp_server/pasv.feature +23 -0
- data/features/ftp_server/port.feature +49 -0
- data/features/ftp_server/put.feature +79 -0
- data/features/ftp_server/put_tls.feature +23 -0
- data/features/ftp_server/put_unique.feature +56 -0
- data/features/ftp_server/quit.feature +23 -0
- data/features/ftp_server/reinitialize.feature +13 -0
- data/features/ftp_server/rename.feature +97 -0
- data/features/ftp_server/rmdir.feature +71 -0
- data/features/ftp_server/site.feature +13 -0
- data/features/ftp_server/size.feature +69 -0
- data/features/ftp_server/status.feature +18 -0
- data/features/ftp_server/step_definitions/logging.rb +8 -0
- data/features/ftp_server/step_definitions/test_server.rb +65 -0
- data/features/ftp_server/structure_mount.feature +13 -0
- data/features/ftp_server/syntax_errors.feature +18 -0
- data/features/ftp_server/syst.feature +18 -0
- data/features/ftp_server/timeout.feature +26 -0
- data/features/ftp_server/type.feature +59 -0
- data/features/step_definitions/append.rb +15 -0
- data/features/step_definitions/client.rb +24 -0
- data/features/step_definitions/client_and_server_files.rb +24 -0
- data/features/step_definitions/client_files.rb +14 -0
- data/features/step_definitions/command.rb +5 -0
- data/features/step_definitions/connect.rb +37 -0
- data/features/step_definitions/delete.rb +15 -0
- data/features/step_definitions/directory_navigation.rb +26 -0
- data/features/step_definitions/error_replies.rb +115 -0
- data/features/step_definitions/features.rb +21 -0
- data/features/step_definitions/file_structure.rb +16 -0
- data/features/step_definitions/generic_send.rb +9 -0
- data/features/step_definitions/get.rb +16 -0
- data/features/step_definitions/help.rb +18 -0
- data/features/step_definitions/invalid_commands.rb +11 -0
- data/features/step_definitions/line_endings.rb +7 -0
- data/features/step_definitions/list.rb +73 -0
- data/features/step_definitions/login.rb +82 -0
- data/features/step_definitions/mkdir.rb +9 -0
- data/features/step_definitions/mode.rb +15 -0
- data/features/step_definitions/mtime.rb +23 -0
- data/features/step_definitions/noop.rb +15 -0
- data/features/step_definitions/options.rb +9 -0
- data/features/step_definitions/passive.rb +3 -0
- data/features/step_definitions/pending.rb +3 -0
- data/features/step_definitions/port.rb +5 -0
- data/features/step_definitions/put.rb +29 -0
- data/features/step_definitions/quit.rb +15 -0
- data/features/step_definitions/rename.rb +11 -0
- data/features/step_definitions/rmdir.rb +9 -0
- data/features/step_definitions/server_files.rb +61 -0
- data/features/step_definitions/server_title.rb +12 -0
- data/features/step_definitions/size.rb +20 -0
- data/features/step_definitions/status.rb +9 -0
- data/features/step_definitions/success_replies.rb +7 -0
- data/features/step_definitions/system.rb +7 -0
- data/features/step_definitions/timing.rb +19 -0
- data/features/step_definitions/type.rb +15 -0
- data/features/support/env.rb +4 -0
- data/features/support/example_server.rb +67 -0
- data/features/support/file_templates/ascii_unix +4 -0
- data/features/support/file_templates/ascii_windows +4 -0
- data/features/support/file_templates/binary +0 -0
- data/features/support/test_client.rb +250 -0
- data/features/support/test_file_templates.rb +33 -0
- data/features/support/test_server.rb +293 -0
- data/features/support/test_server_files.rb +57 -0
- data/ftpd.gemspec +283 -0
- data/insecure-test-cert.pem +29 -0
- data/investtools-ftpd.gemspec +284 -0
- data/lib/ftpd.rb +86 -0
- data/lib/ftpd/auth_levels.rb +9 -0
- data/lib/ftpd/cmd_abor.rb +13 -0
- data/lib/ftpd/cmd_allo.rb +20 -0
- data/lib/ftpd/cmd_appe.rb +24 -0
- data/lib/ftpd/cmd_auth.rb +21 -0
- data/lib/ftpd/cmd_cdup.rb +16 -0
- data/lib/ftpd/cmd_cwd.rb +20 -0
- data/lib/ftpd/cmd_dele.rb +21 -0
- data/lib/ftpd/cmd_eprt.rb +23 -0
- data/lib/ftpd/cmd_epsv.rb +30 -0
- data/lib/ftpd/cmd_feat.rb +44 -0
- data/lib/ftpd/cmd_help.rb +29 -0
- data/lib/ftpd/cmd_list.rb +33 -0
- data/lib/ftpd/cmd_login.rb +60 -0
- data/lib/ftpd/cmd_mdtm.rb +27 -0
- data/lib/ftpd/cmd_mkd.rb +23 -0
- data/lib/ftpd/cmd_mode.rb +27 -0
- data/lib/ftpd/cmd_nlst.rb +27 -0
- data/lib/ftpd/cmd_noop.rb +14 -0
- data/lib/ftpd/cmd_opts.rb +14 -0
- data/lib/ftpd/cmd_pasv.rb +28 -0
- data/lib/ftpd/cmd_pbsz.rb +23 -0
- data/lib/ftpd/cmd_port.rb +28 -0
- data/lib/ftpd/cmd_prot.rb +34 -0
- data/lib/ftpd/cmd_pwd.rb +15 -0
- data/lib/ftpd/cmd_quit.rb +18 -0
- data/lib/ftpd/cmd_rein.rb +13 -0
- data/lib/ftpd/cmd_rename.rb +32 -0
- data/lib/ftpd/cmd_rest.rb +13 -0
- data/lib/ftpd/cmd_retr.rb +24 -0
- data/lib/ftpd/cmd_rmd.rb +22 -0
- data/lib/ftpd/cmd_site.rb +13 -0
- data/lib/ftpd/cmd_size.rb +29 -0
- data/lib/ftpd/cmd_smnt.rb +13 -0
- data/lib/ftpd/cmd_stat.rb +15 -0
- data/lib/ftpd/cmd_stor.rb +25 -0
- data/lib/ftpd/cmd_stou.rb +25 -0
- data/lib/ftpd/cmd_stru.rb +27 -0
- data/lib/ftpd/cmd_syst.rb +16 -0
- data/lib/ftpd/cmd_type.rb +28 -0
- data/lib/ftpd/command_handler.rb +90 -0
- data/lib/ftpd/command_handler_factory.rb +51 -0
- data/lib/ftpd/command_handlers.rb +60 -0
- data/lib/ftpd/command_loop.rb +80 -0
- data/lib/ftpd/command_sequence_checker.rb +58 -0
- data/lib/ftpd/config.rb +13 -0
- data/lib/ftpd/connection_throttle.rb +56 -0
- data/lib/ftpd/connection_tracker.rb +82 -0
- data/lib/ftpd/data_connection_helper.rb +123 -0
- data/lib/ftpd/disk_file_system.rb +434 -0
- data/lib/ftpd/error.rb +21 -0
- data/lib/ftpd/exception_translator.rb +32 -0
- data/lib/ftpd/exceptions.rb +62 -0
- data/lib/ftpd/file_info.rb +115 -0
- data/lib/ftpd/file_system_helper.rb +67 -0
- data/lib/ftpd/ftp_server.rb +214 -0
- data/lib/ftpd/gets_peer_address.rb +41 -0
- data/lib/ftpd/insecure_certificate.rb +16 -0
- data/lib/ftpd/list_format/eplf.rb +74 -0
- data/lib/ftpd/list_format/ls.rb +154 -0
- data/lib/ftpd/list_path.rb +28 -0
- data/lib/ftpd/null_logger.rb +22 -0
- data/lib/ftpd/protocols.rb +60 -0
- data/lib/ftpd/read_only_disk_file_system.rb +22 -0
- data/lib/ftpd/server.rb +139 -0
- data/lib/ftpd/session.rb +220 -0
- data/lib/ftpd/session_config.rb +111 -0
- data/lib/ftpd/stream.rb +80 -0
- data/lib/ftpd/telnet.rb +114 -0
- data/lib/ftpd/temp_dir.rb +22 -0
- data/lib/ftpd/tls_server.rb +111 -0
- data/lib/ftpd/translate_exceptions.rb +68 -0
- data/rake_tasks/cucumber.rake +9 -0
- data/rake_tasks/default.rake +1 -0
- data/rake_tasks/jeweler.rake +52 -0
- data/rake_tasks/spec.rake +3 -0
- data/rake_tasks/test.rake +2 -0
- data/rake_tasks/yard.rake +3 -0
- data/spec/command_sequence_checker_spec.rb +83 -0
- data/spec/connection_throttle_spec.rb +99 -0
- data/spec/connection_tracker_spec.rb +97 -0
- data/spec/disk_file_system_spec.rb +320 -0
- data/spec/exception_translator_spec.rb +36 -0
- data/spec/file_info_spec.rb +59 -0
- data/spec/ftp_server_error_spec.rb +13 -0
- data/spec/list_format/eplf_spec.rb +61 -0
- data/spec/list_format/ls_spec.rb +270 -0
- data/spec/list_path_spec.rb +21 -0
- data/spec/null_logger_spec.rb +24 -0
- data/spec/protocols_spec.rb +139 -0
- data/spec/server_spec.rb +81 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/telnet_spec.rb +75 -0
- data/spec/translate_exceptions_spec.rb +40 -0
- metadata +404 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
class FileList
|
2
|
+
|
3
|
+
def initialize(lines)
|
4
|
+
@lines = lines
|
5
|
+
end
|
6
|
+
|
7
|
+
def filenames
|
8
|
+
@lines.map(&:split).map(&:last)
|
9
|
+
end
|
10
|
+
|
11
|
+
def long_form?
|
12
|
+
@lines.all? do |line|
|
13
|
+
line =~ /^[rwxSst-]{10}/
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def short_form?
|
18
|
+
!long_form?
|
19
|
+
end
|
20
|
+
|
21
|
+
def eplf_format?
|
22
|
+
@lines.all? do |line|
|
23
|
+
line =~ /^\+.*\t.*$/
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def empty?
|
28
|
+
@lines.empty?
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
When /^the client successfully lists the directory(?: "(.*?)")?$/ do |directory|
|
34
|
+
@list = FileList.new(client.ls(*[directory].compact))
|
35
|
+
end
|
36
|
+
|
37
|
+
When /^the client lists the directory( "(?:.*?)")?$/ do |directory|
|
38
|
+
capture_error do
|
39
|
+
step "the client successfully lists the directory#{directory}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
When /^the client successfully name-lists the directory(?: "(.*?)")?$/ do
|
44
|
+
|directory|
|
45
|
+
@list = FileList.new(client.nlst(*[directory].compact))
|
46
|
+
end
|
47
|
+
|
48
|
+
When /^the client name-lists the directory( "(?:.*?)")?$/ do |directory|
|
49
|
+
capture_error do
|
50
|
+
step "the client successfully name-lists the directory#{directory}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Then /^the file list should( not)? contain "(.*?)"$/ do |neg, filename|
|
55
|
+
verb = if neg
|
56
|
+
:to_not
|
57
|
+
else
|
58
|
+
:to
|
59
|
+
end
|
60
|
+
expect(@list.filenames).send(verb, include(filename))
|
61
|
+
end
|
62
|
+
|
63
|
+
Then /^the file list should be in (long|short) form$/ do |form|
|
64
|
+
expect(@list).to send("be_#{form}_form")
|
65
|
+
end
|
66
|
+
|
67
|
+
Then /^the file list should be empty$/ do
|
68
|
+
expect(@list).to be_empty
|
69
|
+
end
|
70
|
+
|
71
|
+
Then /^the list should be in EPLF format$/ do
|
72
|
+
expect(@list).to be_eplf_format
|
73
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
def logged_in?
|
2
|
+
step "the client lists the directory"
|
3
|
+
@error.nil?
|
4
|
+
end
|
5
|
+
|
6
|
+
def login(tokens, client_name = nil)
|
7
|
+
capture_error do
|
8
|
+
client(client_name).login *tokens
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Given /^a successful connection( with \w+ TLS)?$/ do |with_tls|
|
13
|
+
step "the client connects#{with_tls}"
|
14
|
+
end
|
15
|
+
|
16
|
+
Given /^a successful login( with \w+ TLS)?$/ do |with_tls|
|
17
|
+
step "a successful connection#{with_tls}"
|
18
|
+
step 'the client logs in'
|
19
|
+
end
|
20
|
+
|
21
|
+
Given /^a failed login$/ do
|
22
|
+
step 'the client connects'
|
23
|
+
step 'the client logs in with bad user'
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^the(?: (\w+))? client logs in(?: with bad (\w+))?$/ do
|
27
|
+
|client_name, bad|
|
28
|
+
tokens = [
|
29
|
+
if bad == 'user'
|
30
|
+
'bad_user'
|
31
|
+
else
|
32
|
+
@server.user
|
33
|
+
end,
|
34
|
+
if bad == 'password'
|
35
|
+
'bad_password'
|
36
|
+
else
|
37
|
+
@server.password
|
38
|
+
end,
|
39
|
+
if bad == 'account'
|
40
|
+
'bad_account'
|
41
|
+
else
|
42
|
+
@server.account
|
43
|
+
end,
|
44
|
+
][0..server.auth_level]
|
45
|
+
@error = login(tokens, client_name)
|
46
|
+
end
|
47
|
+
|
48
|
+
Then /^the client should( not)? be logged in$/ do |neg|
|
49
|
+
matcher_method = if neg
|
50
|
+
:be_falsey
|
51
|
+
else
|
52
|
+
:be_truthy
|
53
|
+
end
|
54
|
+
expect(logged_in?).to send(matcher_method)
|
55
|
+
end
|
56
|
+
|
57
|
+
When /^the client sends a password( with no parameter)?$/ do |no_param|
|
58
|
+
capture_error do
|
59
|
+
args = if no_param
|
60
|
+
[]
|
61
|
+
else
|
62
|
+
[server.password]
|
63
|
+
end
|
64
|
+
client.raw 'PASS', *args
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
When /^the client sends a user( with no parameter)?$/ do |no_param|
|
69
|
+
capture_error do
|
70
|
+
args = if no_param
|
71
|
+
[]
|
72
|
+
else
|
73
|
+
[server.user]
|
74
|
+
end
|
75
|
+
client.raw 'USER', *args
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
Given /^the (\w+) client connects and logs in$/ do |client_name|
|
80
|
+
step "the #{client_name} client connects"
|
81
|
+
step "the #{client_name} client logs in"
|
82
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
When /^the client successfully sets mode "(.*?)"$/ do |mode|
|
2
|
+
client.raw 'MODE', mode
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^the client sets mode "(.*?)"$/ do |mode|
|
6
|
+
capture_error do
|
7
|
+
step %Q'the client successfully sets mode "#{mode}"'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
When /^the client sets mode with no parameter$/ do
|
12
|
+
capture_error do
|
13
|
+
client.raw 'MODE'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
When /^the client successfully gets mtime of "(.*?)"$/ \
|
4
|
+
do |remote_path|
|
5
|
+
@mtime = client.get_mtime remote_path
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^the client gets mtime of "(.*?)"$/ do |path|
|
9
|
+
capture_error do
|
10
|
+
step %Q(the client successfully gets mtime of "#{path}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^the client gets mtime with no path$/ do
|
15
|
+
capture_error do
|
16
|
+
client.raw 'MDTM'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Then(/^the reported mtime should be "(.*?)"$/) do |mtime|
|
21
|
+
expected_time = DateTime.parse(mtime).to_time.utc
|
22
|
+
expect(@mtime).to eq expected_time
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
When /^the( \w+)? client successfully does nothing( with a parameter)?$/ do
|
2
|
+
|client_name, with_param|
|
3
|
+
if with_param
|
4
|
+
client(client_name).raw 'NOOP', 'foo'
|
5
|
+
else
|
6
|
+
client(client_name).noop
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^the( \w+)? client does nothing( with a parameter)?$/ do
|
11
|
+
|client_name, with_param|
|
12
|
+
capture_error do
|
13
|
+
step "the#{client_name} client successfully does nothing#{with_param}"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
When /^the client successfully puts (text|binary) "(.*?)"$/ do
|
2
|
+
|mode, local_path|
|
3
|
+
client.put mode, local_path
|
4
|
+
end
|
5
|
+
|
6
|
+
When /^the client puts (\S+) "(.*?)"$/ do |mode, path|
|
7
|
+
capture_error do
|
8
|
+
step %Q(the client successfully puts #{mode} "#{path}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^the client puts with no path$/ do
|
13
|
+
capture_error do
|
14
|
+
client.raw 'STOR'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^the client successfully stores unique "(.*?)"(?: to "(.*?)")?$/ do
|
19
|
+
|local_path, remote_path|
|
20
|
+
client.store_unique local_path, remote_path
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^the client stores unique "(.*?)"( to ".*?")?$/ do
|
24
|
+
|local_path, remote_path|
|
25
|
+
capture_error do
|
26
|
+
step(%Q'the client successfully stores unique ' +
|
27
|
+
%Q'"#{local_path}"#{remote_path}')
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
When /^the client successfully quits$/ do
|
2
|
+
client.quit
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^the client quits$/ do
|
6
|
+
capture_error do
|
7
|
+
step 'the client successfully quits'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
When /^the client quits with a parameter$/ do
|
12
|
+
capture_error do
|
13
|
+
client.raw 'QUIT', 'foo'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
When /^the client renames "(.*?)" to "(.*?)"$/ do
|
2
|
+
|from_path, to_path|
|
3
|
+
capture_error do
|
4
|
+
step %Q'the client successfully renames "#{from_path}" to "#{to_path}"'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^the client successfully renames "(.*?)" to "(.*?)"$/ do
|
9
|
+
|from_path, to_path|
|
10
|
+
client.rename(from_path, to_path)
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
When /^the client removes directory "(.*?)"$/ do |path|
|
2
|
+
capture_error do
|
3
|
+
step %Q(the client successfully removes directory "#{path}")
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^the client successfully removes directory "(.*?)"$/ do |path|
|
8
|
+
mkdir_response = client.rmdir path
|
9
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
Given /^the server has directory "(.*?)"$/ do |remote_path|
|
4
|
+
server.add_directory remote_path
|
5
|
+
end
|
6
|
+
|
7
|
+
Given /^the server has file "(.*?)"$/ do |remote_path|
|
8
|
+
server.add_file remote_path
|
9
|
+
end
|
10
|
+
|
11
|
+
Given(/^the file "(.*?)" has mtime "(.*?)"$/) do |remote_path, mtime|
|
12
|
+
mtime = DateTime.parse(mtime).to_time.utc
|
13
|
+
server.set_mtime remote_path, mtime
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^the server should( not)? have file "(.*?)"$/ do |neg, path|
|
17
|
+
matcher = if neg
|
18
|
+
:be_falsey
|
19
|
+
else
|
20
|
+
:be_truthy
|
21
|
+
end
|
22
|
+
expect(server.has_file?(path)).to send(matcher)
|
23
|
+
end
|
24
|
+
|
25
|
+
Then /^the server should( not)? have directory "(.*?)"$/ do |neg, path|
|
26
|
+
matcher = if neg
|
27
|
+
:be_falsey
|
28
|
+
else
|
29
|
+
:be_truthy
|
30
|
+
end
|
31
|
+
expect(server.has_directory?(path)).to send(matcher)
|
32
|
+
end
|
33
|
+
|
34
|
+
Then /^the remote file "(.*?)" should have (unix|windows) line endings$/ do
|
35
|
+
|remote_path, line_ending_type|
|
36
|
+
expect(line_ending_type(server.file_contents(remote_path))).to eq \
|
37
|
+
line_ending_type.to_sym
|
38
|
+
end
|
39
|
+
|
40
|
+
Then /^the server should have a file with the contents of "(.*?)"$/ do
|
41
|
+
|path|
|
42
|
+
expect(server.has_file_with_contents_of?(path)).to be_truthy
|
43
|
+
end
|
44
|
+
|
45
|
+
Then /^the server should have (\d+) files? with "(.*?)" in the name$/ do
|
46
|
+
|count, name|
|
47
|
+
expect(server.files_named_like(name).size).to eq count.to_i
|
48
|
+
end
|
49
|
+
|
50
|
+
Then /^the remote file "(.*?)" should match "(\w+)" \+ "(\w+)"$/ do
|
51
|
+
|remote_path, template1, template2|
|
52
|
+
expected = @server.template(template1) + @server.template(template2)
|
53
|
+
actual = @server.file_contents(remote_path)
|
54
|
+
expect(actual).to eq expected
|
55
|
+
end
|
56
|
+
|
57
|
+
Then /^the remote file "(.*?)" should match "(\w+)"$/ do |remote_path, template|
|
58
|
+
expected = @server.template(template)
|
59
|
+
actual = @server.file_contents(remote_path)
|
60
|
+
expect(actual).to eq expected
|
61
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Then /^the server returns its title$/ do
|
2
|
+
step 'the server returns its name'
|
3
|
+
step 'the server returns its version'
|
4
|
+
end
|
5
|
+
|
6
|
+
Then /^the server returns its name$/ do
|
7
|
+
expect(@response).to include @server.server_name
|
8
|
+
end
|
9
|
+
|
10
|
+
Then /^the server returns its version$/ do
|
11
|
+
expect(@response).to match /\b\d+\.\d+\.\d+\b/
|
12
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
When /^the client successfully gets size of (text|binary) "(.*?)"$/ \
|
2
|
+
do |mode, remote_path|
|
3
|
+
@size = client.get_size mode, remote_path
|
4
|
+
end
|
5
|
+
|
6
|
+
When /^the client gets size of (\S+) "(.*?)"$/ do |mode, path|
|
7
|
+
capture_error do
|
8
|
+
step %Q(the client successfully gets size of #{mode} "#{path}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^the client gets size with no path$/ do
|
13
|
+
capture_error do
|
14
|
+
client.raw 'SIZE'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Then(/^the reported size should be "(.*?)"$/) do |size|
|
19
|
+
expect(@size).to eq size.to_i
|
20
|
+
end
|