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,139 @@
|
|
1
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Ftpd
|
4
|
+
describe Protocols do
|
5
|
+
|
6
|
+
# A fake server that returns a connected server-side socket.
|
7
|
+
|
8
|
+
class TestServer
|
9
|
+
|
10
|
+
# The socket upon which the server is listening
|
11
|
+
|
12
|
+
attr_reader :listening_socket
|
13
|
+
|
14
|
+
# Returns the connected server-side socket
|
15
|
+
|
16
|
+
attr_reader :connected_socket
|
17
|
+
|
18
|
+
# @param bind_address [String] The address to which to bind the
|
19
|
+
# server socket.
|
20
|
+
# @param connect_address [String] The address to which the
|
21
|
+
# client socket should connect.
|
22
|
+
|
23
|
+
def initialize(bind_address, connect_address)
|
24
|
+
queue = Queue.new
|
25
|
+
@listening_socket = TCPServer.new(bind_address, 0)
|
26
|
+
port = @listening_socket.addr[1]
|
27
|
+
Thread.new do
|
28
|
+
queue.enq @listening_socket.accept
|
29
|
+
end
|
30
|
+
client_socket = TCPSocket.new(connect_address, port)
|
31
|
+
@connected_socket = queue.deq
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'IPV4 server' do
|
37
|
+
|
38
|
+
let(:bind_address) {'127.0.0.1'}
|
39
|
+
let(:connect_address) {'127.0.0.1'}
|
40
|
+
let(:connected_socket) do
|
41
|
+
TestServer.new(bind_address, connect_address).connected_socket
|
42
|
+
end
|
43
|
+
subject(:protocols) {Protocols.new(connected_socket)}
|
44
|
+
|
45
|
+
it 'should support IPV4' do
|
46
|
+
expect(protocols.supports_protocol?(Protocols::IPV4)).to be_truthy
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should not support IPV6' do
|
50
|
+
expect(protocols.supports_protocol?(Protocols::IPV6)).to be_falsey
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should list the supported protocols' do
|
54
|
+
expect(protocols.protocol_codes).to eq [
|
55
|
+
Protocols::IPV4,
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'IPV6 server, IPV6 connection' do
|
62
|
+
|
63
|
+
let(:bind_address) {'::1'}
|
64
|
+
let(:connect_address) {'::1'}
|
65
|
+
let(:connected_socket) do
|
66
|
+
TestServer.new(bind_address, connect_address).connected_socket
|
67
|
+
end
|
68
|
+
subject(:protocols) {Protocols.new(connected_socket)}
|
69
|
+
|
70
|
+
it 'should not support IPV4' do
|
71
|
+
expect(protocols.supports_protocol?(Protocols::IPV4)).to be_falsey
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should support IPV6' do
|
75
|
+
expect(protocols.supports_protocol?(Protocols::IPV6)).to be_truthy
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should list the supported protocols' do
|
79
|
+
expect(protocols.protocol_codes).to eq [
|
80
|
+
Protocols::IPV6,
|
81
|
+
]
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'wildcard server, IPV4 connection' do
|
87
|
+
|
88
|
+
let(:bind_address) {'::'}
|
89
|
+
let(:connect_address) {'127.0.0.1'}
|
90
|
+
let(:connected_socket) do
|
91
|
+
TestServer.new(bind_address, connect_address).connected_socket
|
92
|
+
end
|
93
|
+
subject(:protocols) {Protocols.new(connected_socket)}
|
94
|
+
|
95
|
+
it 'should support IPV4' do
|
96
|
+
expect(protocols.supports_protocol?(Protocols::IPV4)).to be_truthy
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should support IPV6' do
|
100
|
+
expect(protocols.supports_protocol?(Protocols::IPV6)).to be_truthy
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should list the supported protocols' do
|
104
|
+
expect(protocols.protocol_codes).to eq [
|
105
|
+
Protocols::IPV4,
|
106
|
+
Protocols::IPV6,
|
107
|
+
]
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'wildcard server, IPV6 connection' do
|
113
|
+
|
114
|
+
let(:bind_address) {'::'}
|
115
|
+
let(:connect_address) {'::1'}
|
116
|
+
let(:connected_socket) do
|
117
|
+
TestServer.new(bind_address, connect_address).connected_socket
|
118
|
+
end
|
119
|
+
subject(:protocols) {Protocols.new(connected_socket)}
|
120
|
+
|
121
|
+
it 'should support IPV4' do
|
122
|
+
expect(protocols.supports_protocol?(Protocols::IPV4)).to be_truthy
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should support IPV6' do
|
126
|
+
expect(protocols.supports_protocol?(Protocols::IPV6)).to be_truthy
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should list the supported protocols' do
|
130
|
+
expect(protocols.protocol_codes).to eq [
|
131
|
+
Protocols::IPV4,
|
132
|
+
Protocols::IPV6,
|
133
|
+
]
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Ftpd
|
4
|
+
|
5
|
+
describe Server do
|
6
|
+
|
7
|
+
describe '#join' do
|
8
|
+
it 'calls server_thread#join' do
|
9
|
+
expect_any_instance_of(Thread).to receive(:join)
|
10
|
+
server = Server.new
|
11
|
+
server.start
|
12
|
+
server.join
|
13
|
+
end
|
14
|
+
context 'when server is not started' do
|
15
|
+
it 'raises an error' do
|
16
|
+
server = Server.new
|
17
|
+
expect { server.join }.to raise_error('Server is not started!')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'reuse explicit port (github #23)' do
|
23
|
+
|
24
|
+
# The bug being tested involves a race condition. Monkey patch
|
25
|
+
# the server so that start does not return until "accept" has
|
26
|
+
# been called on the server socket. This causes the test to
|
27
|
+
# reliably expose the bug.
|
28
|
+
|
29
|
+
def monkey_patch_server(server)
|
30
|
+
|
31
|
+
class << server
|
32
|
+
|
33
|
+
def start
|
34
|
+
@accepting = Queue.new
|
35
|
+
super
|
36
|
+
wait_for_accept
|
37
|
+
end
|
38
|
+
|
39
|
+
def accept
|
40
|
+
@accepting.enq true
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def wait_for_accept
|
47
|
+
@accepting.deq
|
48
|
+
# There's a potential race condition in _this_ code:
|
49
|
+
# @accepting is triggered just before the accept is done
|
50
|
+
# on the socket, but it's possible that the server thread
|
51
|
+
# has been preempted and accept has not yet been called.
|
52
|
+
# A little sleep gives the server thread another shot at
|
53
|
+
# actually getting the accept done before we continue.
|
54
|
+
sleep 0.01
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
it do
|
62
|
+
port = find_open_port
|
63
|
+
2.times do
|
64
|
+
server = Server.new
|
65
|
+
monkey_patch_server server
|
66
|
+
server.port = port
|
67
|
+
server.start
|
68
|
+
server.stop
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def find_open_port
|
73
|
+
socket = TCPServer.new('localhost', 0)
|
74
|
+
socket.addr[1].tap {socket.close}
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
unless $:.include?(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'ftpd'
|
6
|
+
require 'rspec/its'
|
7
|
+
require 'stringio'
|
8
|
+
require 'thread'
|
9
|
+
require 'timecop'
|
10
|
+
require 'tmpdir'
|
11
|
+
|
12
|
+
glob = File.expand_path('helpers/*.rb', File.dirname(__FILE__))
|
13
|
+
Dir[glob].sort.each do |helper_path|
|
14
|
+
require helper_path
|
15
|
+
end
|
data/spec/telnet_spec.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# -*- ruby encoding: us-ascii -*-
|
2
|
+
|
3
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
4
|
+
|
5
|
+
module Ftpd
|
6
|
+
describe Telnet do
|
7
|
+
|
8
|
+
IAC = 255.chr # 0xff
|
9
|
+
DONT = 254.chr # 0xfe
|
10
|
+
DO = 253.chr # 0xfd
|
11
|
+
WONT = 252.chr # 0xfc
|
12
|
+
WILL = 251.chr # 0xfb
|
13
|
+
IP = 244.chr # 0xf4
|
14
|
+
DM = 242.chr # 0xf2
|
15
|
+
|
16
|
+
subject {Telnet.new(command)}
|
17
|
+
let(:plain_command) {"NOOP\r\n"}
|
18
|
+
let(:command) {codes + plain_command}
|
19
|
+
|
20
|
+
context '(plain command)' do
|
21
|
+
let(:codes) {''}
|
22
|
+
its(:reply) {should == ''}
|
23
|
+
its(:plain) {should == plain_command}
|
24
|
+
end
|
25
|
+
|
26
|
+
context '(escaped IAC)' do
|
27
|
+
let(:codes) {"#{IAC}#{IAC}"}
|
28
|
+
its(:reply) {should == ''}
|
29
|
+
its(:plain) {should == "#{IAC}" + plain_command}
|
30
|
+
end
|
31
|
+
|
32
|
+
context '(IAC + unknown code)' do
|
33
|
+
let(:codes) {"#{IAC}\x01"}
|
34
|
+
its(:reply) {should == ''}
|
35
|
+
its(:plain) {should == codes + plain_command}
|
36
|
+
end
|
37
|
+
|
38
|
+
context '(WILL)' do
|
39
|
+
let(:codes) {"#{IAC}#{WILL}\x01"}
|
40
|
+
its(:reply) {should == "#{IAC}#{DONT}\x01"}
|
41
|
+
its(:plain) {should == plain_command}
|
42
|
+
end
|
43
|
+
|
44
|
+
context '(WONT)' do
|
45
|
+
let(:codes) {"#{IAC}#{WONT}\x01"}
|
46
|
+
its(:reply) {should == ''}
|
47
|
+
its(:plain) {should == plain_command}
|
48
|
+
end
|
49
|
+
|
50
|
+
context '(DO)' do
|
51
|
+
let(:codes) {"#{IAC}#{DO}\x01"}
|
52
|
+
its(:reply) {should == "#{IAC}#{WONT}\x01"}
|
53
|
+
its(:plain) {should == plain_command}
|
54
|
+
end
|
55
|
+
|
56
|
+
context '(DONT)' do
|
57
|
+
let(:codes) {"#{IAC}#{DONT}\x01"}
|
58
|
+
its(:reply) {should == ''}
|
59
|
+
its(:plain) {should == plain_command}
|
60
|
+
end
|
61
|
+
|
62
|
+
context '(interrupt process)' do
|
63
|
+
let(:codes) {"#{IAC}#{IP}"}
|
64
|
+
its(:reply) {should == ''}
|
65
|
+
its(:plain) {should == plain_command}
|
66
|
+
end
|
67
|
+
|
68
|
+
context '(data mark)' do
|
69
|
+
let(:codes) {"#{IAC}#{DM}"}
|
70
|
+
its(:reply) {should == ''}
|
71
|
+
its(:plain) {should == plain_command}
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Ftpd
|
4
|
+
describe TranslateExceptions do
|
5
|
+
|
6
|
+
class FooError < StandardError ; end
|
7
|
+
class BarError < StandardError ; end
|
8
|
+
|
9
|
+
class Subject
|
10
|
+
|
11
|
+
include TranslateExceptions
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
translate_exception FooError
|
15
|
+
end
|
16
|
+
|
17
|
+
def raise_error(error, message)
|
18
|
+
raise error, message
|
19
|
+
end
|
20
|
+
translate_exceptions :raise_error
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:subject) {Subject.new}
|
25
|
+
let(:message) {'An error happened'}
|
26
|
+
|
27
|
+
it 'should translate a registered error' do
|
28
|
+
expect {
|
29
|
+
subject.raise_error(FooError, message)
|
30
|
+
}.to raise_error PermanentFileSystemError, message
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should pass through an unregistered error' do
|
34
|
+
expect {
|
35
|
+
subject.raise_error(BarError, message)
|
36
|
+
}.to raise_error BarError, message
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,404 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: investtools-ftpd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wayne Conrad
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: memoizer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cucumber
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: double-bag-ftps
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: redcarpet
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.1'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec-its
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: timecop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.7'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.7'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: yard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.8.7
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.8.7
|
153
|
+
description: ftpd is a pure Ruby FTP server library. It supports implicit and explicit
|
154
|
+
TLS, IPV6, passive and active mode, and is unconditionally compliant per RFC-1123. It
|
155
|
+
can be used as part of a test fixture or embedded in a program.
|
156
|
+
email: wconrad@yagni.com
|
157
|
+
executables: []
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files:
|
160
|
+
- LICENSE.md
|
161
|
+
- README.md
|
162
|
+
files:
|
163
|
+
- ".travis.yml"
|
164
|
+
- ".yardopts"
|
165
|
+
- Changelog.md
|
166
|
+
- Gemfile
|
167
|
+
- Gemfile.lock
|
168
|
+
- LICENSE.md
|
169
|
+
- README.md
|
170
|
+
- Rakefile
|
171
|
+
- VERSION
|
172
|
+
- doc/benchmarks.md
|
173
|
+
- doc/references.md
|
174
|
+
- doc/rfc-compliance.md
|
175
|
+
- examples/example.rb
|
176
|
+
- examples/example_spec.rb
|
177
|
+
- examples/hello_world.rb
|
178
|
+
- features/example/eplf.feature
|
179
|
+
- features/example/example.feature
|
180
|
+
- features/example/read_only.feature
|
181
|
+
- features/example/step_definitions/example_server.rb
|
182
|
+
- features/ftp_server/abort.feature
|
183
|
+
- features/ftp_server/allo.feature
|
184
|
+
- features/ftp_server/append.feature
|
185
|
+
- features/ftp_server/cdup.feature
|
186
|
+
- features/ftp_server/command_errors.feature
|
187
|
+
- features/ftp_server/concurrent_sessions.feature
|
188
|
+
- features/ftp_server/delay_after_failed_login.feature
|
189
|
+
- features/ftp_server/delete.feature
|
190
|
+
- features/ftp_server/directory_navigation.feature
|
191
|
+
- features/ftp_server/disconnect_after_failed_logins.feature
|
192
|
+
- features/ftp_server/eprt.feature
|
193
|
+
- features/ftp_server/epsv.feature
|
194
|
+
- features/ftp_server/features.feature
|
195
|
+
- features/ftp_server/file_structure.feature
|
196
|
+
- features/ftp_server/get.feature
|
197
|
+
- features/ftp_server/get_ipv6.feature
|
198
|
+
- features/ftp_server/get_tls.feature
|
199
|
+
- features/ftp_server/help.feature
|
200
|
+
- features/ftp_server/implicit_tls.feature
|
201
|
+
- features/ftp_server/invertability.feature
|
202
|
+
- features/ftp_server/list.feature
|
203
|
+
- features/ftp_server/list_tls.feature
|
204
|
+
- features/ftp_server/logging.feature
|
205
|
+
- features/ftp_server/login_auth_level_account.feature
|
206
|
+
- features/ftp_server/login_auth_level_password.feature
|
207
|
+
- features/ftp_server/login_auth_level_user.feature
|
208
|
+
- features/ftp_server/max_connections.feature
|
209
|
+
- features/ftp_server/mdtm.feature
|
210
|
+
- features/ftp_server/mkdir.feature
|
211
|
+
- features/ftp_server/mode.feature
|
212
|
+
- features/ftp_server/name_list.feature
|
213
|
+
- features/ftp_server/name_list_tls.feature
|
214
|
+
- features/ftp_server/noop.feature
|
215
|
+
- features/ftp_server/options.feature
|
216
|
+
- features/ftp_server/pasv.feature
|
217
|
+
- features/ftp_server/port.feature
|
218
|
+
- features/ftp_server/put.feature
|
219
|
+
- features/ftp_server/put_tls.feature
|
220
|
+
- features/ftp_server/put_unique.feature
|
221
|
+
- features/ftp_server/quit.feature
|
222
|
+
- features/ftp_server/reinitialize.feature
|
223
|
+
- features/ftp_server/rename.feature
|
224
|
+
- features/ftp_server/rmdir.feature
|
225
|
+
- features/ftp_server/site.feature
|
226
|
+
- features/ftp_server/size.feature
|
227
|
+
- features/ftp_server/status.feature
|
228
|
+
- features/ftp_server/step_definitions/logging.rb
|
229
|
+
- features/ftp_server/step_definitions/test_server.rb
|
230
|
+
- features/ftp_server/structure_mount.feature
|
231
|
+
- features/ftp_server/syntax_errors.feature
|
232
|
+
- features/ftp_server/syst.feature
|
233
|
+
- features/ftp_server/timeout.feature
|
234
|
+
- features/ftp_server/type.feature
|
235
|
+
- features/step_definitions/append.rb
|
236
|
+
- features/step_definitions/client.rb
|
237
|
+
- features/step_definitions/client_and_server_files.rb
|
238
|
+
- features/step_definitions/client_files.rb
|
239
|
+
- features/step_definitions/command.rb
|
240
|
+
- features/step_definitions/connect.rb
|
241
|
+
- features/step_definitions/delete.rb
|
242
|
+
- features/step_definitions/directory_navigation.rb
|
243
|
+
- features/step_definitions/error_replies.rb
|
244
|
+
- features/step_definitions/features.rb
|
245
|
+
- features/step_definitions/file_structure.rb
|
246
|
+
- features/step_definitions/generic_send.rb
|
247
|
+
- features/step_definitions/get.rb
|
248
|
+
- features/step_definitions/help.rb
|
249
|
+
- features/step_definitions/invalid_commands.rb
|
250
|
+
- features/step_definitions/line_endings.rb
|
251
|
+
- features/step_definitions/list.rb
|
252
|
+
- features/step_definitions/login.rb
|
253
|
+
- features/step_definitions/mkdir.rb
|
254
|
+
- features/step_definitions/mode.rb
|
255
|
+
- features/step_definitions/mtime.rb
|
256
|
+
- features/step_definitions/noop.rb
|
257
|
+
- features/step_definitions/options.rb
|
258
|
+
- features/step_definitions/passive.rb
|
259
|
+
- features/step_definitions/pending.rb
|
260
|
+
- features/step_definitions/port.rb
|
261
|
+
- features/step_definitions/put.rb
|
262
|
+
- features/step_definitions/quit.rb
|
263
|
+
- features/step_definitions/rename.rb
|
264
|
+
- features/step_definitions/rmdir.rb
|
265
|
+
- features/step_definitions/server_files.rb
|
266
|
+
- features/step_definitions/server_title.rb
|
267
|
+
- features/step_definitions/size.rb
|
268
|
+
- features/step_definitions/status.rb
|
269
|
+
- features/step_definitions/success_replies.rb
|
270
|
+
- features/step_definitions/system.rb
|
271
|
+
- features/step_definitions/timing.rb
|
272
|
+
- features/step_definitions/type.rb
|
273
|
+
- features/support/env.rb
|
274
|
+
- features/support/example_server.rb
|
275
|
+
- features/support/file_templates/ascii_unix
|
276
|
+
- features/support/file_templates/ascii_windows
|
277
|
+
- features/support/file_templates/binary
|
278
|
+
- features/support/test_client.rb
|
279
|
+
- features/support/test_file_templates.rb
|
280
|
+
- features/support/test_server.rb
|
281
|
+
- features/support/test_server_files.rb
|
282
|
+
- ftpd.gemspec
|
283
|
+
- insecure-test-cert.pem
|
284
|
+
- investtools-ftpd.gemspec
|
285
|
+
- lib/ftpd.rb
|
286
|
+
- lib/ftpd/auth_levels.rb
|
287
|
+
- lib/ftpd/cmd_abor.rb
|
288
|
+
- lib/ftpd/cmd_allo.rb
|
289
|
+
- lib/ftpd/cmd_appe.rb
|
290
|
+
- lib/ftpd/cmd_auth.rb
|
291
|
+
- lib/ftpd/cmd_cdup.rb
|
292
|
+
- lib/ftpd/cmd_cwd.rb
|
293
|
+
- lib/ftpd/cmd_dele.rb
|
294
|
+
- lib/ftpd/cmd_eprt.rb
|
295
|
+
- lib/ftpd/cmd_epsv.rb
|
296
|
+
- lib/ftpd/cmd_feat.rb
|
297
|
+
- lib/ftpd/cmd_help.rb
|
298
|
+
- lib/ftpd/cmd_list.rb
|
299
|
+
- lib/ftpd/cmd_login.rb
|
300
|
+
- lib/ftpd/cmd_mdtm.rb
|
301
|
+
- lib/ftpd/cmd_mkd.rb
|
302
|
+
- lib/ftpd/cmd_mode.rb
|
303
|
+
- lib/ftpd/cmd_nlst.rb
|
304
|
+
- lib/ftpd/cmd_noop.rb
|
305
|
+
- lib/ftpd/cmd_opts.rb
|
306
|
+
- lib/ftpd/cmd_pasv.rb
|
307
|
+
- lib/ftpd/cmd_pbsz.rb
|
308
|
+
- lib/ftpd/cmd_port.rb
|
309
|
+
- lib/ftpd/cmd_prot.rb
|
310
|
+
- lib/ftpd/cmd_pwd.rb
|
311
|
+
- lib/ftpd/cmd_quit.rb
|
312
|
+
- lib/ftpd/cmd_rein.rb
|
313
|
+
- lib/ftpd/cmd_rename.rb
|
314
|
+
- lib/ftpd/cmd_rest.rb
|
315
|
+
- lib/ftpd/cmd_retr.rb
|
316
|
+
- lib/ftpd/cmd_rmd.rb
|
317
|
+
- lib/ftpd/cmd_site.rb
|
318
|
+
- lib/ftpd/cmd_size.rb
|
319
|
+
- lib/ftpd/cmd_smnt.rb
|
320
|
+
- lib/ftpd/cmd_stat.rb
|
321
|
+
- lib/ftpd/cmd_stor.rb
|
322
|
+
- lib/ftpd/cmd_stou.rb
|
323
|
+
- lib/ftpd/cmd_stru.rb
|
324
|
+
- lib/ftpd/cmd_syst.rb
|
325
|
+
- lib/ftpd/cmd_type.rb
|
326
|
+
- lib/ftpd/command_handler.rb
|
327
|
+
- lib/ftpd/command_handler_factory.rb
|
328
|
+
- lib/ftpd/command_handlers.rb
|
329
|
+
- lib/ftpd/command_loop.rb
|
330
|
+
- lib/ftpd/command_sequence_checker.rb
|
331
|
+
- lib/ftpd/config.rb
|
332
|
+
- lib/ftpd/connection_throttle.rb
|
333
|
+
- lib/ftpd/connection_tracker.rb
|
334
|
+
- lib/ftpd/data_connection_helper.rb
|
335
|
+
- lib/ftpd/disk_file_system.rb
|
336
|
+
- lib/ftpd/error.rb
|
337
|
+
- lib/ftpd/exception_translator.rb
|
338
|
+
- lib/ftpd/exceptions.rb
|
339
|
+
- lib/ftpd/file_info.rb
|
340
|
+
- lib/ftpd/file_system_helper.rb
|
341
|
+
- lib/ftpd/ftp_server.rb
|
342
|
+
- lib/ftpd/gets_peer_address.rb
|
343
|
+
- lib/ftpd/insecure_certificate.rb
|
344
|
+
- lib/ftpd/list_format/eplf.rb
|
345
|
+
- lib/ftpd/list_format/ls.rb
|
346
|
+
- lib/ftpd/list_path.rb
|
347
|
+
- lib/ftpd/null_logger.rb
|
348
|
+
- lib/ftpd/protocols.rb
|
349
|
+
- lib/ftpd/read_only_disk_file_system.rb
|
350
|
+
- lib/ftpd/server.rb
|
351
|
+
- lib/ftpd/session.rb
|
352
|
+
- lib/ftpd/session_config.rb
|
353
|
+
- lib/ftpd/stream.rb
|
354
|
+
- lib/ftpd/telnet.rb
|
355
|
+
- lib/ftpd/temp_dir.rb
|
356
|
+
- lib/ftpd/tls_server.rb
|
357
|
+
- lib/ftpd/translate_exceptions.rb
|
358
|
+
- rake_tasks/cucumber.rake
|
359
|
+
- rake_tasks/default.rake
|
360
|
+
- rake_tasks/jeweler.rake
|
361
|
+
- rake_tasks/spec.rake
|
362
|
+
- rake_tasks/test.rake
|
363
|
+
- rake_tasks/yard.rake
|
364
|
+
- spec/command_sequence_checker_spec.rb
|
365
|
+
- spec/connection_throttle_spec.rb
|
366
|
+
- spec/connection_tracker_spec.rb
|
367
|
+
- spec/disk_file_system_spec.rb
|
368
|
+
- spec/exception_translator_spec.rb
|
369
|
+
- spec/file_info_spec.rb
|
370
|
+
- spec/ftp_server_error_spec.rb
|
371
|
+
- spec/list_format/eplf_spec.rb
|
372
|
+
- spec/list_format/ls_spec.rb
|
373
|
+
- spec/list_path_spec.rb
|
374
|
+
- spec/null_logger_spec.rb
|
375
|
+
- spec/protocols_spec.rb
|
376
|
+
- spec/server_spec.rb
|
377
|
+
- spec/spec_helper.rb
|
378
|
+
- spec/telnet_spec.rb
|
379
|
+
- spec/translate_exceptions_spec.rb
|
380
|
+
homepage: http://github.com/wconrad/ftpd
|
381
|
+
licenses:
|
382
|
+
- MIT
|
383
|
+
metadata: {}
|
384
|
+
post_install_message:
|
385
|
+
rdoc_options: []
|
386
|
+
require_paths:
|
387
|
+
- lib
|
388
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
389
|
+
requirements:
|
390
|
+
- - ">="
|
391
|
+
- !ruby/object:Gem::Version
|
392
|
+
version: '0'
|
393
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
394
|
+
requirements:
|
395
|
+
- - ">="
|
396
|
+
- !ruby/object:Gem::Version
|
397
|
+
version: '0'
|
398
|
+
requirements: []
|
399
|
+
rubyforge_project:
|
400
|
+
rubygems_version: 2.2.2
|
401
|
+
signing_key:
|
402
|
+
specification_version: 4
|
403
|
+
summary: Pure Ruby FTP server library
|
404
|
+
test_files: []
|