ftpd 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +6 -0
  3. data/Gemfile +2 -15
  4. data/Gemfile.lock +12 -51
  5. data/README.md +12 -0
  6. data/VERSION +1 -1
  7. data/bin/ftpdrb +17 -12
  8. data/examples/write_only.rb +61 -0
  9. data/ftpd.gemspec +59 -261
  10. data/lib/ftpd/session.rb +51 -51
  11. metadata +11 -153
  12. data/.travis.yml +0 -6
  13. data/features/example/eplf.feature +0 -14
  14. data/features/example/example.feature +0 -18
  15. data/features/example/read_only.feature +0 -63
  16. data/features/example/step_definitions/example_server.rb +0 -13
  17. data/features/ftp_server/abort.feature +0 -13
  18. data/features/ftp_server/allo.feature +0 -33
  19. data/features/ftp_server/append.feature +0 -94
  20. data/features/ftp_server/cdup.feature +0 -36
  21. data/features/ftp_server/command_errors.feature +0 -13
  22. data/features/ftp_server/concurrent_sessions.feature +0 -14
  23. data/features/ftp_server/delay_after_failed_login.feature +0 -23
  24. data/features/ftp_server/delete.feature +0 -60
  25. data/features/ftp_server/directory_navigation.feature +0 -59
  26. data/features/ftp_server/disconnect_after_failed_logins.feature +0 -25
  27. data/features/ftp_server/eprt.feature +0 -56
  28. data/features/ftp_server/epsv.feature +0 -37
  29. data/features/ftp_server/features.feature +0 -38
  30. data/features/ftp_server/file_structure.feature +0 -43
  31. data/features/ftp_server/get.feature +0 -80
  32. data/features/ftp_server/get_ipv6.feature +0 -46
  33. data/features/ftp_server/get_tls.feature +0 -23
  34. data/features/ftp_server/help.feature +0 -21
  35. data/features/ftp_server/implicit_tls.feature +0 -23
  36. data/features/ftp_server/invertability.feature +0 -15
  37. data/features/ftp_server/list.feature +0 -94
  38. data/features/ftp_server/list_tls.feature +0 -29
  39. data/features/ftp_server/logging.feature +0 -11
  40. data/features/ftp_server/login_auth_level_account.feature +0 -51
  41. data/features/ftp_server/login_auth_level_password.feature +0 -59
  42. data/features/ftp_server/login_auth_level_user.feature +0 -31
  43. data/features/ftp_server/max_connections.feature +0 -39
  44. data/features/ftp_server/mdtm.feature +0 -53
  45. data/features/ftp_server/mkdir.feature +0 -70
  46. data/features/ftp_server/mode.feature +0 -43
  47. data/features/ftp_server/name_list.feature +0 -77
  48. data/features/ftp_server/name_list_tls.feature +0 -30
  49. data/features/ftp_server/noop.feature +0 -17
  50. data/features/ftp_server/options.feature +0 -17
  51. data/features/ftp_server/pasv.feature +0 -30
  52. data/features/ftp_server/port.feature +0 -49
  53. data/features/ftp_server/put.feature +0 -79
  54. data/features/ftp_server/put_tls.feature +0 -23
  55. data/features/ftp_server/put_unique.feature +0 -56
  56. data/features/ftp_server/quit.feature +0 -23
  57. data/features/ftp_server/reinitialize.feature +0 -13
  58. data/features/ftp_server/rename.feature +0 -97
  59. data/features/ftp_server/rmdir.feature +0 -71
  60. data/features/ftp_server/site.feature +0 -13
  61. data/features/ftp_server/size.feature +0 -69
  62. data/features/ftp_server/status.feature +0 -18
  63. data/features/ftp_server/step_definitions/logging.rb +0 -10
  64. data/features/ftp_server/step_definitions/test_server.rb +0 -71
  65. data/features/ftp_server/structure_mount.feature +0 -13
  66. data/features/ftp_server/syntax_errors.feature +0 -18
  67. data/features/ftp_server/syst.feature +0 -18
  68. data/features/ftp_server/timeout.feature +0 -26
  69. data/features/ftp_server/type.feature +0 -59
  70. data/features/step_definitions/append.rb +0 -17
  71. data/features/step_definitions/client.rb +0 -27
  72. data/features/step_definitions/client_and_server_files.rb +0 -26
  73. data/features/step_definitions/client_files.rb +0 -16
  74. data/features/step_definitions/command.rb +0 -7
  75. data/features/step_definitions/connect.rb +0 -39
  76. data/features/step_definitions/delete.rb +0 -17
  77. data/features/step_definitions/directory_navigation.rb +0 -28
  78. data/features/step_definitions/error_replies.rb +0 -117
  79. data/features/step_definitions/features.rb +0 -23
  80. data/features/step_definitions/file_structure.rb +0 -18
  81. data/features/step_definitions/generic_send.rb +0 -11
  82. data/features/step_definitions/get.rb +0 -18
  83. data/features/step_definitions/help.rb +0 -20
  84. data/features/step_definitions/invalid_commands.rb +0 -13
  85. data/features/step_definitions/ipv6.rb +0 -11
  86. data/features/step_definitions/line_endings.rb +0 -9
  87. data/features/step_definitions/list.rb +0 -75
  88. data/features/step_definitions/login.rb +0 -84
  89. data/features/step_definitions/mkdir.rb +0 -11
  90. data/features/step_definitions/mode.rb +0 -17
  91. data/features/step_definitions/mtime.rb +0 -25
  92. data/features/step_definitions/noop.rb +0 -17
  93. data/features/step_definitions/options.rb +0 -11
  94. data/features/step_definitions/passive.rb +0 -10
  95. data/features/step_definitions/pending.rb +0 -5
  96. data/features/step_definitions/port.rb +0 -7
  97. data/features/step_definitions/put.rb +0 -31
  98. data/features/step_definitions/quit.rb +0 -17
  99. data/features/step_definitions/rename.rb +0 -13
  100. data/features/step_definitions/rmdir.rb +0 -11
  101. data/features/step_definitions/server_files.rb +0 -63
  102. data/features/step_definitions/server_title.rb +0 -14
  103. data/features/step_definitions/size.rb +0 -22
  104. data/features/step_definitions/status.rb +0 -11
  105. data/features/step_definitions/success_replies.rb +0 -9
  106. data/features/step_definitions/system.rb +0 -12
  107. data/features/step_definitions/timing.rb +0 -21
  108. data/features/step_definitions/type.rb +0 -17
  109. data/features/support/env.rb +0 -6
  110. data/features/support/example_server.rb +0 -69
  111. data/features/support/file_templates/ascii_unix +0 -4
  112. data/features/support/file_templates/ascii_windows +0 -4
  113. data/features/support/file_templates/binary +0 -0
  114. data/features/support/test_client.rb +0 -258
  115. data/features/support/test_file_templates.rb +0 -35
  116. data/features/support/test_server.rb +0 -304
  117. data/features/support/test_server_files.rb +0 -59
  118. data/rake_tasks/cucumber.rake +0 -9
  119. data/rake_tasks/default.rake +0 -1
  120. data/rake_tasks/jeweler.rake +0 -52
  121. data/rake_tasks/spec.rake +0 -3
  122. data/rake_tasks/test.rake +0 -2
  123. data/rake_tasks/yard.rake +0 -3
  124. data/spec/command_sequence_checker_spec.rb +0 -85
  125. data/spec/connection_throttle_spec.rb +0 -101
  126. data/spec/connection_tracker_spec.rb +0 -99
  127. data/spec/data_server_factory_spec.rb +0 -104
  128. data/spec/disk_file_system_spec.rb +0 -322
  129. data/spec/exception_translator_spec.rb +0 -38
  130. data/spec/file_info_spec.rb +0 -61
  131. data/spec/ftp_server_error_spec.rb +0 -15
  132. data/spec/list_format/eplf_spec.rb +0 -63
  133. data/spec/list_format/ls_spec.rb +0 -272
  134. data/spec/list_path_spec.rb +0 -23
  135. data/spec/null_logger_spec.rb +0 -26
  136. data/spec/protocols_spec.rb +0 -159
  137. data/spec/server_spec.rb +0 -83
  138. data/spec/spec_helper.rb +0 -17
  139. data/spec/telnet_spec.rb +0 -77
  140. data/spec/translate_exceptions_spec.rb +0 -42
  141. data/testlib/network.rb +0 -17
@@ -1,272 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../spec_helper', File.dirname(__FILE__))
4
-
5
- module Ftpd
6
- module ListFormat
7
-
8
- describe Ls do
9
-
10
- let(:file_info) do
11
- FileInfo.new(:ftype => 'file',
12
- :group => 'group',
13
- :mode => 0100644,
14
- :mtime => Time.mktime(2013, 3, 3, 8, 38, 0),
15
- :nlink => 1,
16
- :owner => 'user',
17
- :path => 'foo',
18
- :size => 1234)
19
- end
20
- subject(:formatter) {Ls.new(file_info)}
21
-
22
- it 'should approximate ls -l format' do
23
- Timecop.freeze(2013, 3, 3, 8, 38, 0) do
24
- expect(formatter.to_s).to eq \
25
- '-rw-r--r-- 1 user group 1234 Mar 3 08:38 foo'
26
- end
27
- end
28
-
29
- end
30
-
31
- describe Ls::FileType do
32
-
33
- [
34
- ['file', '-'],
35
- ['directory', 'd'],
36
- ['characterSpecial', 'c'],
37
- ['blockSpecial', 'b'],
38
- ['fifo', 'p'],
39
- ['link', 'l'],
40
- ['socket', 's'],
41
- ['unknown', '?'],
42
- ].each do |ftype, letter|
43
- context "(#{ftype})" do
44
- specify do
45
- expect(Ls::FileType.letter(ftype)).to eq letter
46
- end
47
- end
48
- end
49
-
50
- end
51
-
52
- describe Ls::FileMode do
53
-
54
- let(:other_execute) {0}
55
- let(:other_write) {0}
56
- let(:other_read) {0}
57
- let(:group_execute) {0}
58
- let(:group_write) {0}
59
- let(:group_read) {0}
60
- let(:owner_execute) {0}
61
- let(:owner_write) {0}
62
- let(:owner_read) {0}
63
- let(:sticky) {0}
64
- let(:setgid) {0}
65
- let(:setuid) {0}
66
- let(:mode) do
67
- other_execute << 0 |
68
- other_write << 1 |
69
- other_read << 2 |
70
- group_execute << 3 |
71
- group_write << 4 |
72
- group_read << 5 |
73
- owner_execute << 6 |
74
- owner_write << 7 |
75
- owner_read << 8 |
76
- sticky << 9 |
77
- setgid << 10 |
78
- setuid << 11
79
- end
80
-
81
- let(:letters) {Ls::FileMode.new(mode).letters}
82
-
83
- describe 'owner read' do
84
- subject {letters[0..0]}
85
- context '(0)' do
86
- let(:owner_read) {0}
87
- it {should == '-'}
88
- end
89
- context '(1)' do
90
- let(:owner_read) {1}
91
- it {should == 'r'}
92
- end
93
- end
94
-
95
- describe 'owner write' do
96
- subject {letters[1..1]}
97
- context '(0)' do
98
- let(:owner_write) {0}
99
- it {should == '-'}
100
- end
101
- context '(1)' do
102
- let(:owner_write) {1}
103
- it {should == 'w'}
104
- end
105
- end
106
-
107
- describe 'owner execute' do
108
-
109
- subject {letters[2..2]}
110
-
111
- context '(setuid 0)' do
112
- let(:setuid) {0}
113
- context '(execute 0)' do
114
- let(:owner_execute) {0}
115
- it {should == '-'}
116
- end
117
- context '(execute 1)' do
118
- let(:owner_execute) {1}
119
- it {should == 'x'}
120
- end
121
- end
122
-
123
- context '(setuid 1)' do
124
- let(:setuid) {1}
125
- context '(execute 0)' do
126
- let(:owner_execute) {0}
127
- it {should == 'S'}
128
- end
129
- context '(execute 1)' do
130
- let(:owner_execute) {1}
131
- it {should == 's'}
132
- end
133
- end
134
-
135
- end
136
-
137
- describe 'group read' do
138
- subject {letters[3..3]}
139
- context '(0)' do
140
- let(:group_read) {0}
141
- it {should == '-'}
142
- end
143
- context '(1)' do
144
- let(:group_read) {1}
145
- it {should == 'r'}
146
- end
147
- end
148
-
149
- describe 'group write' do
150
- subject {letters[4..4]}
151
- context '(0)' do
152
- let(:group_write) {0}
153
- it {should == '-'}
154
- end
155
- context '(1)' do
156
- let(:group_write) {1}
157
- it {should == 'w'}
158
- end
159
- end
160
-
161
- describe 'group execute' do
162
-
163
- subject {letters[5..5]}
164
-
165
- context '(setgid 0)' do
166
- let(:setgid) {0}
167
- context '(execute 0)' do
168
- let(:group_execute) {0}
169
- it {should == '-'}
170
- end
171
- context '(execute 1)' do
172
- let(:group_execute) {1}
173
- it {should == 'x'}
174
- end
175
- end
176
-
177
- context '(setgid 1)' do
178
- let(:setgid) {1}
179
- context '(execute 0)' do
180
- let(:group_execute) {0}
181
- it {should == 'S'}
182
- end
183
- context '(execute 1)' do
184
- let(:group_execute) {1}
185
- it {should == 's'}
186
- end
187
- end
188
-
189
- end
190
-
191
- describe 'other read' do
192
- subject {letters[6..6]}
193
- context '(0)' do
194
- let(:other_read) {0}
195
- it {should == '-'}
196
- end
197
- context '(1)' do
198
- let(:other_read) {1}
199
- it {should == 'r'}
200
- end
201
- end
202
-
203
- describe 'other write' do
204
- subject {letters[7..7]}
205
- context '(0)' do
206
- let(:other_write) {0}
207
- it {should == '-'}
208
- end
209
- context '(1)' do
210
- let(:other_write) {1}
211
- it {should == 'w'}
212
- end
213
- end
214
-
215
- describe 'other execute' do
216
-
217
- subject {letters[8..8]}
218
-
219
- context '(sticky 0)' do
220
- let(:sticky) {0}
221
- context '(execute 0)' do
222
- let(:other_execute) {0}
223
- it {should == '-'}
224
- end
225
- context '(execute 1)' do
226
- let(:other_execute) {1}
227
- it {should == 'x'}
228
- end
229
- end
230
-
231
- context '(sticky 1)' do
232
- let(:sticky) {1}
233
- context '(execute 0)' do
234
- let(:other_execute) {0}
235
- it {should == 'T'}
236
- end
237
- context '(execute 1)' do
238
- let(:other_execute) {1}
239
- it {should == 't'}
240
- end
241
- end
242
-
243
- end
244
-
245
- end
246
-
247
- describe '.format_time' do
248
-
249
- let(:mtime) {Time.mktime(2013, 6, 1, 13, 14, 15)}
250
-
251
- around(:each) { |block| Timecop.freeze(now, &block) }
252
- subject {Ls.format_time(mtime)}
253
-
254
- context '(recent)' do
255
- let(:now) {mtime}
256
- it {should == 'Jun 1 13:14'}
257
- end
258
-
259
- context '(old)' do
260
- let(:now) {Time.mktime(2014, 1, 1, 0, 0, 0)}
261
- it {should == 'Jun 1 2013'}
262
- end
263
-
264
- context '(future)' do
265
- let(:now) {Time.mktime(2013, 1, 1, 0, 0, 0)}
266
- it {should == 'Jun 1 2013'}
267
- end
268
-
269
- end
270
-
271
- end
272
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('spec_helper', File.dirname(__FILE__))
4
-
5
- module Ftpd
6
- describe ListPath do
7
-
8
- include ListPath
9
-
10
- it 'should replace a missing path with "."' do
11
- expect(list_path(nil)).to eq('.')
12
- end
13
-
14
- it 'should replace a switch with nothing' do
15
- expect(list_path('-a')).to eq('')
16
- end
17
-
18
- it 'should preserve a filename with a dash in it' do
19
- expect(list_path('foo-bar')).to eq('foo-bar')
20
- end
21
-
22
- end
23
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('spec_helper', File.dirname(__FILE__))
4
-
5
- module Ftpd
6
- describe NullLogger do
7
-
8
- subject {NullLogger.new}
9
-
10
- def self.should_stub(method)
11
- describe "#{method}" do
12
- specify do
13
- expect(subject).to respond_to method
14
- end
15
- end
16
- end
17
-
18
- should_stub :unknown
19
- should_stub :fatal
20
- should_stub :error
21
- should_stub :warn
22
- should_stub :info
23
- should_stub :debug
24
-
25
- end
26
- end
@@ -1,159 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('spec_helper', File.dirname(__FILE__))
4
-
5
- require_relative "../testlib/network"
6
-
7
- module Ftpd
8
- describe Protocols do
9
-
10
- extend TestLib::Network
11
-
12
- def self.if_stack_supports_ipv6
13
- if ipv6_supported?
14
- return yield
15
- else
16
- if !@ipv6_warning_issued
17
- warn "Stack does not support IPV6; skipping some tests"
18
- @ipv6_warning_issued = true
19
- end
20
- end
21
- end
22
-
23
- # A fake server that returns a connected server-side socket.
24
- class TestServer
25
-
26
- # The socket upon which the server is listening
27
-
28
- attr_reader :listening_socket
29
-
30
- # Returns the connected server-side socket
31
-
32
- attr_reader :connected_socket
33
-
34
- # @param bind_address [String] The address to which to bind the
35
- # server socket.
36
- # @param connect_address [String] The address to which the
37
- # client socket should connect.
38
-
39
- def initialize(bind_address, connect_address)
40
- queue = Queue.new
41
- @listening_socket = TCPServer.new(bind_address, 0)
42
- port = @listening_socket.addr[1]
43
- Thread.new do
44
- queue.enq @listening_socket.accept
45
- end
46
- client_socket = TCPSocket.new(connect_address, port)
47
- @connected_socket = queue.deq
48
- end
49
-
50
- end
51
-
52
- context 'IPV4 server' do
53
-
54
- let(:bind_address) {'127.0.0.1'}
55
- let(:connect_address) {'127.0.0.1'}
56
- let(:connected_socket) do
57
- TestServer.new(bind_address, connect_address).connected_socket
58
- end
59
- subject(:protocols) {Protocols.new(connected_socket)}
60
-
61
- it 'should support IPV4' do
62
- expect(protocols.supports_protocol?(Protocols::IPV4)).to be_truthy
63
- end
64
-
65
- it 'should not support IPV6' do
66
- expect(protocols.supports_protocol?(Protocols::IPV6)).to be_falsey
67
- end
68
-
69
- it 'should list the supported protocols' do
70
- expect(protocols.protocol_codes).to eq [
71
- Protocols::IPV4,
72
- ]
73
- end
74
-
75
- end
76
-
77
- if_stack_supports_ipv6 do
78
- context 'IPV6 server, IPV6 connection' do
79
-
80
- let(:bind_address) {'::1'}
81
- let(:connect_address) {'::1'}
82
- let(:connected_socket) do
83
- TestServer.new(bind_address, connect_address).connected_socket
84
- end
85
- subject(:protocols) {Protocols.new(connected_socket)}
86
-
87
- it 'should not support IPV4' do
88
- expect(protocols.supports_protocol?(Protocols::IPV4)).to be_falsey
89
- end
90
-
91
- it 'should support IPV6' do
92
- expect(protocols.supports_protocol?(Protocols::IPV6)).to be_truthy
93
- end
94
-
95
- it 'should list the supported protocols' do
96
- expect(protocols.protocol_codes).to eq [
97
- Protocols::IPV6,
98
- ]
99
- end
100
-
101
- end
102
- end
103
-
104
- context 'wildcard server, IPV4 connection' do
105
-
106
- let(:bind_address) {'::'}
107
- let(:connect_address) {'127.0.0.1'}
108
- let(:connected_socket) do
109
- TestServer.new(bind_address, connect_address).connected_socket
110
- end
111
- subject(:protocols) {Protocols.new(connected_socket)}
112
-
113
- it 'should support IPV4' do
114
- expect(protocols.supports_protocol?(Protocols::IPV4)).to be_truthy
115
- end
116
-
117
- it 'should support IPV6' do
118
- expect(protocols.supports_protocol?(Protocols::IPV6)).to be_truthy
119
- end
120
-
121
- it 'should list the supported protocols' do
122
- expect(protocols.protocol_codes).to eq [
123
- Protocols::IPV4,
124
- Protocols::IPV6,
125
- ]
126
- end
127
-
128
- end
129
-
130
- if_stack_supports_ipv6 do
131
- context 'wildcard server, IPV6 connection' do
132
-
133
- let(:bind_address) {'::'}
134
- let(:connect_address) {'::1'}
135
- let(:connected_socket) do
136
- TestServer.new(bind_address, connect_address).connected_socket
137
- end
138
- subject(:protocols) {Protocols.new(connected_socket)}
139
-
140
- it 'should support IPV4' do
141
- expect(protocols.supports_protocol?(Protocols::IPV4)).to be_truthy
142
- end
143
-
144
- it 'should support IPV6' do
145
- expect(protocols.supports_protocol?(Protocols::IPV6)).to be_truthy
146
- end
147
-
148
- it 'should list the supported protocols' do
149
- expect(protocols.protocol_codes).to eq [
150
- Protocols::IPV4,
151
- Protocols::IPV6,
152
- ]
153
- end
154
-
155
- end
156
- end
157
-
158
- end
159
- end