ftpd 0.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ftpd might be problematic. Click here for more details.
- data/Gemfile +9 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.md +9 -0
- data/README.md +57 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/features/command_errors.feature +33 -0
- data/features/delete.feature +34 -0
- data/features/directory_navigation.feature +34 -0
- data/features/file_structure.feature +40 -0
- data/features/get.feature +62 -0
- data/features/list.feature +77 -0
- data/features/login.feature +54 -0
- data/features/mode.feature +40 -0
- data/features/name_list.feature +77 -0
- data/features/noop.feature +14 -0
- data/features/port.feature +25 -0
- data/features/put.feature +65 -0
- data/features/quit.feature +20 -0
- data/features/step_definitions/client_and_server_files.rb +24 -0
- data/features/step_definitions/client_files.rb +9 -0
- data/features/step_definitions/command.rb +5 -0
- data/features/step_definitions/connect.rb +15 -0
- data/features/step_definitions/delete.rb +15 -0
- data/features/step_definitions/directories.rb +22 -0
- data/features/step_definitions/error.rb +87 -0
- data/features/step_definitions/file_structure.rb +16 -0
- data/features/step_definitions/get.rb +16 -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 +46 -0
- data/features/step_definitions/login.rb +69 -0
- data/features/step_definitions/mode.rb +15 -0
- data/features/step_definitions/noop.rb +13 -0
- data/features/step_definitions/passive.rb +3 -0
- data/features/step_definitions/port.rb +5 -0
- data/features/step_definitions/put.rb +16 -0
- data/features/step_definitions/quit.rb +15 -0
- data/features/step_definitions/server.rb +7 -0
- data/features/step_definitions/server_files.rb +18 -0
- data/features/step_definitions/type.rb +15 -0
- data/features/support/env.rb +4 -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 +89 -0
- data/features/support/test_file_templates.rb +33 -0
- data/features/support/test_server.rb +52 -0
- data/features/syntax_errors.feature +15 -0
- data/features/type.feature +53 -0
- data/ftpd.gemspec +112 -0
- data/insecure-test-cert.pem +29 -0
- data/lib/ftpd.rb +6 -0
- data/lib/ftpd/FakeFtpServer.rb +736 -0
- data/lib/ftpd/FakeServer.rb +57 -0
- data/lib/ftpd/FakeTlsServer.rb +52 -0
- data/lib/ftpd/ObjectUtil.rb +66 -0
- data/lib/ftpd/TempDir.rb +54 -0
- data/lib/ftpd/q.rb +92 -0
- data/rake_tasks/cucumber.rake +7 -0
- data/rake_tasks/jeweler.rake +25 -0
- metadata +164 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
builder (3.1.4)
|
5
|
+
cucumber (1.2.1)
|
6
|
+
builder (>= 2.1.2)
|
7
|
+
diff-lcs (>= 1.1.3)
|
8
|
+
gherkin (~> 2.11.0)
|
9
|
+
json (>= 1.4.6)
|
10
|
+
diff-lcs (1.2.0)
|
11
|
+
double-bag-ftps (0.1.0)
|
12
|
+
gherkin (2.11.6)
|
13
|
+
json (>= 1.7.6)
|
14
|
+
git (1.2.5)
|
15
|
+
jeweler (1.8.4)
|
16
|
+
bundler (~> 1.0)
|
17
|
+
git (>= 1.2.5)
|
18
|
+
rake
|
19
|
+
rdoc
|
20
|
+
json (1.7.6)
|
21
|
+
rake (10.0.3)
|
22
|
+
rdoc (3.12)
|
23
|
+
json (~> 1.4)
|
24
|
+
rspec (2.0.1)
|
25
|
+
rspec-core (~> 2.0.1)
|
26
|
+
rspec-expectations (~> 2.0.1)
|
27
|
+
rspec-mocks (~> 2.0.1)
|
28
|
+
rspec-core (2.0.1)
|
29
|
+
rspec-expectations (2.0.1)
|
30
|
+
diff-lcs (>= 1.1.2)
|
31
|
+
rspec-mocks (2.0.1)
|
32
|
+
rspec-core (~> 2.0.1)
|
33
|
+
rspec-expectations (~> 2.0.1)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
cucumber (~> 1.2.1)
|
40
|
+
double-bag-ftps (~> 0.1.0)
|
41
|
+
jeweler (~> 1.8.4)
|
42
|
+
rake (~> 10.0.3)
|
43
|
+
rspec (~> 2.0.1)
|
data/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Copyright 2012 Wayne Conrad
|
2
|
+
|
3
|
+
This software is distributed under the [MIT License](http://opensource.org/licenses/MIT):
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# FTPD
|
2
|
+
|
3
|
+
ftpd is a pure Ruby FTP server library. It supports implicit and
|
4
|
+
explicit TLS, and can be used by a text fixture or FTP daemon.
|
5
|
+
|
6
|
+
## UNFINISHED
|
7
|
+
|
8
|
+
I created ftpd to support the test framework I wrote for Databill,
|
9
|
+
LLC, which has given its kind permission to donate it to the
|
10
|
+
community.
|
11
|
+
|
12
|
+
I've moved the code from Databill's source tree, but it's not ready
|
13
|
+
for prime time yet. It needs pluggable authentication and file system
|
14
|
+
drivers, refactoring, and the removal of bits of the Databill source
|
15
|
+
tree which are temporarily included.
|
16
|
+
|
17
|
+
## LIMITATIONS
|
18
|
+
|
19
|
+
TLS is only supported in passive mode, not active. Either the FTPS
|
20
|
+
client used by the test doesn't work in active mode, or this server
|
21
|
+
doesn't work in FTPS active mode (or both).
|
22
|
+
|
23
|
+
## REFERENCES
|
24
|
+
|
25
|
+
(This list of references comes from the README of the em-ftpd gem,
|
26
|
+
which is licensed under the same MIT license as this gem, and is
|
27
|
+
Copyright (c) 2008 James Healy)
|
28
|
+
|
29
|
+
There are a range of RFCs that together specify the FTP protocol. In
|
30
|
+
chronological order, the more useful ones are:
|
31
|
+
|
32
|
+
http://tools.ietf.org/rfc/rfc959.txt
|
33
|
+
http://tools.ietf.org/rfc/rfc1123.txt
|
34
|
+
http://tools.ietf.org/rfc/rfc2228.txt
|
35
|
+
http://tools.ietf.org/rfc/rfc2389.txt
|
36
|
+
http://tools.ietf.org/rfc/rfc2428.txt
|
37
|
+
http://tools.ietf.org/rfc/rfc3659.txt
|
38
|
+
http://tools.ietf.org/rfc/rfc4217.txt
|
39
|
+
|
40
|
+
For an english summary that's somewhat more legible than the RFCs, and
|
41
|
+
provides some commentary on what features are actually useful or
|
42
|
+
relevant 24 years after RFC959 was published:
|
43
|
+
|
44
|
+
http://cr.yp.to/ftp.html
|
45
|
+
|
46
|
+
For a history lesson, check out Appendix III of RCF959. It lists the
|
47
|
+
preceding (obsolete) RFC documents that relate to file transfers,
|
48
|
+
including the ye old RFC114 from 1971, "A File Transfer Protocol"
|
49
|
+
|
50
|
+
## WHOAMI
|
51
|
+
|
52
|
+
Wayne Conrad <wconrad@yagni.com>
|
53
|
+
|
54
|
+
## CREDITS
|
55
|
+
|
56
|
+
Thanks to Databill, LLC, which supported the creation of this library,
|
57
|
+
and granted permission to donate it ot the community.
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0.pre1
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Feature: Command Errors
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want good error messages
|
5
|
+
So that I can figure out what went wrong
|
6
|
+
|
7
|
+
Scenario: Unknown command
|
8
|
+
Given a successful connection
|
9
|
+
When the client sends command "foo"
|
10
|
+
Then the server returns a command unrecognized error
|
11
|
+
|
12
|
+
Scenario Outline: Unimplemented command
|
13
|
+
Given a successful connection
|
14
|
+
When the client sends command "<command>"
|
15
|
+
Then the server returns an unimplemented command error
|
16
|
+
Examples:
|
17
|
+
| command |
|
18
|
+
| ABOR |
|
19
|
+
| ACCT |
|
20
|
+
| ALLO |
|
21
|
+
| APPE |
|
22
|
+
| HELP |
|
23
|
+
| MKD |
|
24
|
+
| REIN |
|
25
|
+
| REST |
|
26
|
+
| RMD |
|
27
|
+
| RNFR |
|
28
|
+
| RNTO |
|
29
|
+
| SITE |
|
30
|
+
| SMNT |
|
31
|
+
| STAT |
|
32
|
+
| STOU |
|
33
|
+
| SYST |
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Feature: Delete
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to delete files
|
5
|
+
So that nobody can fetch them from the server
|
6
|
+
|
7
|
+
Scenario: Delete a file
|
8
|
+
Given a successful login
|
9
|
+
And the server has file "foo"
|
10
|
+
When the client successfully deletes "foo"
|
11
|
+
Then the server should not have file "foo"
|
12
|
+
And the client lists the directory
|
13
|
+
And the file list should not contain "foo"
|
14
|
+
|
15
|
+
Scenario: Missing path
|
16
|
+
Given a successful login
|
17
|
+
And the server has file "foo"
|
18
|
+
When the client deletes with no path
|
19
|
+
Then the server returns a path required error
|
20
|
+
|
21
|
+
Scenario: No such file
|
22
|
+
Given a successful login
|
23
|
+
When the client deletes "foo"
|
24
|
+
Then the server returns a not found error
|
25
|
+
|
26
|
+
Scenario: Path outside tree
|
27
|
+
Given a successful login
|
28
|
+
When the client deletes "../usr/bin"
|
29
|
+
Then the server returns an access denied error
|
30
|
+
|
31
|
+
Scenario: Not logged in
|
32
|
+
Given a successful connection
|
33
|
+
When the client deletes "foo"
|
34
|
+
Then the server returns a not logged in error
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Feature: Change Directory
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to change the current directory
|
5
|
+
So that I can use shorter paths
|
6
|
+
|
7
|
+
Scenario: Change to subdirectory
|
8
|
+
Given a successful login
|
9
|
+
And the server has file "subdir/bar"
|
10
|
+
When the client successfully cd's to "subdir"
|
11
|
+
Then the current directory should be "/subdir"
|
12
|
+
|
13
|
+
Scenario: Change to parent
|
14
|
+
Given a successful login
|
15
|
+
And the server has file "subdir/bar"
|
16
|
+
And the server has file "baz"
|
17
|
+
And the client successfully cd's to "subdir"
|
18
|
+
When the client successfully cd's up
|
19
|
+
Then the current directory should be "/"
|
20
|
+
|
21
|
+
Scenario: No such directory
|
22
|
+
Given a successful login
|
23
|
+
When the client cd's to "subdir"
|
24
|
+
Then the server returns a no such file error
|
25
|
+
|
26
|
+
Scenario: Path outside tree
|
27
|
+
Given a successful login
|
28
|
+
When the client cd's to "../usr/bin"
|
29
|
+
Then the server returns an access denied error
|
30
|
+
|
31
|
+
Scenario: Not logged in
|
32
|
+
Given a successful connection
|
33
|
+
When the client cd's to "subdir"
|
34
|
+
Then the server returns a not logged in error
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: File Structure
|
2
|
+
|
3
|
+
As a server
|
4
|
+
I want to accept the obsolute file structure (STRU) command
|
5
|
+
For compatability
|
6
|
+
|
7
|
+
Scenario: File
|
8
|
+
Given a successful login
|
9
|
+
And the server has file "ascii_unix"
|
10
|
+
When the client successfully sets file structure "F"
|
11
|
+
And the client successfully gets text "ascii_unix"
|
12
|
+
Then the remote file "ascii_unix" should match the local file
|
13
|
+
|
14
|
+
Scenario: Record
|
15
|
+
Given a successful login
|
16
|
+
And the server has file "ascii_unix"
|
17
|
+
When the client sets file structure "R"
|
18
|
+
Then the server returns a file structure not implemented error
|
19
|
+
|
20
|
+
Scenario: Page
|
21
|
+
Given a successful login
|
22
|
+
And the server has file "ascii_unix"
|
23
|
+
When the client sets file structure "P"
|
24
|
+
Then the server returns a file structure not implemented error
|
25
|
+
|
26
|
+
Scenario: Invalid
|
27
|
+
Given a successful login
|
28
|
+
And the server has file "ascii_unix"
|
29
|
+
When the client sets file structure "*"
|
30
|
+
Then the server returns an invalid file structure error
|
31
|
+
|
32
|
+
Scenario: Not logged in
|
33
|
+
Given a successful connection
|
34
|
+
When the client sets file structure "F"
|
35
|
+
Then the server returns a not logged in error
|
36
|
+
|
37
|
+
Scenario: Missing parameter
|
38
|
+
Given a successful login
|
39
|
+
When the client sets file structure with no parameter
|
40
|
+
Then the server returns a syntax error
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Feature: Get
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to get a file
|
5
|
+
So that I have it on my computer
|
6
|
+
|
7
|
+
Scenario: ASCII file with *nix line endings
|
8
|
+
Given a successful login
|
9
|
+
And the server has file "ascii_unix"
|
10
|
+
When the client successfully gets text "ascii_unix"
|
11
|
+
Then the local file "ascii_unix" should match the remote file
|
12
|
+
And the local file "ascii_unix" should have unix line endings
|
13
|
+
|
14
|
+
Scenario: ASCII file with windows line endings
|
15
|
+
Given a successful login
|
16
|
+
And the server has file "ascii_windows"
|
17
|
+
When the client successfully gets text "ascii_windows"
|
18
|
+
Then the local file "ascii_windows" should match the remote file
|
19
|
+
And the local file "ascii_windows" should have unix line endings
|
20
|
+
|
21
|
+
Scenario: Binary file
|
22
|
+
Given a successful login
|
23
|
+
And the server has file "binary"
|
24
|
+
When the client successfully gets binary "binary"
|
25
|
+
Then the local file "binary" should exactly match the remote file
|
26
|
+
|
27
|
+
Scenario: Passive
|
28
|
+
Given a successful login
|
29
|
+
And the server has file "ascii_unix"
|
30
|
+
And the client is in passive mode
|
31
|
+
When the client successfully gets text "ascii_unix"
|
32
|
+
Then the local file "ascii_unix" should match the remote file
|
33
|
+
|
34
|
+
Scenario: TLS
|
35
|
+
pending "TLS not supported in active mode (see README)"
|
36
|
+
|
37
|
+
Scenario: TLS, Passive
|
38
|
+
Given a successful login with TLS
|
39
|
+
And the server has file "ascii_unix"
|
40
|
+
And the client is in passive mode
|
41
|
+
When the client successfully gets text "ascii_unix"
|
42
|
+
Then the local file "ascii_unix" should match the remote file
|
43
|
+
|
44
|
+
Scenario: Path outside tree
|
45
|
+
Given a successful login
|
46
|
+
When the client gets text "../foo"
|
47
|
+
Then the server returns an access denied error
|
48
|
+
|
49
|
+
Scenario: Missing file
|
50
|
+
Given a successful login
|
51
|
+
When the client gets text "foo"
|
52
|
+
Then the server returns a no such file error
|
53
|
+
|
54
|
+
Scenario: Not logged in
|
55
|
+
Given a successful connection
|
56
|
+
When the client gets text "foo"
|
57
|
+
Then the server returns a not logged in error
|
58
|
+
|
59
|
+
Scenario: Missing path
|
60
|
+
Given a successful login
|
61
|
+
When the client gets with no path
|
62
|
+
Then the server returns a syntax error
|
@@ -0,0 +1,77 @@
|
|
1
|
+
Feature: List
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to list files
|
5
|
+
So that I can see what file to transfer
|
6
|
+
|
7
|
+
Scenario: List implicit
|
8
|
+
Given a successful login
|
9
|
+
And the server has file "foo"
|
10
|
+
And the server has file "bar"
|
11
|
+
When the client lists the directory
|
12
|
+
Then the file list should be in long form
|
13
|
+
And the file list should contain "foo"
|
14
|
+
And the file list should contain "bar"
|
15
|
+
|
16
|
+
Scenario: List root
|
17
|
+
Given a successful login
|
18
|
+
And the server has file "foo"
|
19
|
+
And the server has file "bar"
|
20
|
+
When the client lists the directory "/"
|
21
|
+
Then the file list should be in long form
|
22
|
+
And the file list should contain "foo"
|
23
|
+
And the file list should contain "bar"
|
24
|
+
|
25
|
+
Scenario: List subdir
|
26
|
+
Given a successful login
|
27
|
+
And the server has file "subdir/foo"
|
28
|
+
When the client lists the directory "subdir"
|
29
|
+
Then the file list should be in long form
|
30
|
+
And the file list should contain "foo"
|
31
|
+
|
32
|
+
Scenario: List glob
|
33
|
+
Given a successful login
|
34
|
+
And the server has file "foo"
|
35
|
+
And the server has file "bar"
|
36
|
+
When the client lists the directory "f*"
|
37
|
+
Then the file list should be in long form
|
38
|
+
And the file list should contain "foo"
|
39
|
+
And the file list should not contain "bar"
|
40
|
+
|
41
|
+
Scenario: Passive
|
42
|
+
Given a successful login
|
43
|
+
And the server has file "foo"
|
44
|
+
And the server has file "bar"
|
45
|
+
And the client is in passive mode
|
46
|
+
When the client lists the directory
|
47
|
+
Then the file list should be in long form
|
48
|
+
And the file list should contain "foo"
|
49
|
+
And the file list should contain "bar"
|
50
|
+
|
51
|
+
Scenario: TLS
|
52
|
+
pending "TLS not supported in active mode (see README)"
|
53
|
+
|
54
|
+
Scenario: TLS, Passive
|
55
|
+
Given a successful login with TLS
|
56
|
+
And the server has file "foo"
|
57
|
+
And the server has file "bar"
|
58
|
+
And the client is in passive mode
|
59
|
+
When the client lists the directory
|
60
|
+
Then the file list should be in long form
|
61
|
+
And the file list should contain "foo"
|
62
|
+
And the file list should contain "bar"
|
63
|
+
|
64
|
+
Scenario: Path outside tree
|
65
|
+
Given a successful login
|
66
|
+
When the client lists the directory ".."
|
67
|
+
Then the server returns an access denied error
|
68
|
+
|
69
|
+
Scenario: Missing file
|
70
|
+
Given a successful login
|
71
|
+
When the client lists the directory "missing/file"
|
72
|
+
Then the server returns a no such file error
|
73
|
+
|
74
|
+
Scenario: Not logged in
|
75
|
+
Given a successful connection
|
76
|
+
When the client lists the directory
|
77
|
+
Then the server returns a not logged in error
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Feature: Login
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to log in
|
5
|
+
So that I can transfer files
|
6
|
+
|
7
|
+
Scenario: Normal connection
|
8
|
+
Given a successful login
|
9
|
+
Then the server returns no error
|
10
|
+
And the client should be logged in
|
11
|
+
|
12
|
+
Scenario: Bad user
|
13
|
+
Given the server is started
|
14
|
+
And the client connects
|
15
|
+
When the client logs in with a bad user
|
16
|
+
Then the server returns a login incorrect error
|
17
|
+
And the client should not be logged in
|
18
|
+
|
19
|
+
Scenario: Bad password
|
20
|
+
Given a successful connection
|
21
|
+
When the client logs in with a bad password
|
22
|
+
Then the server returns a login incorrect error
|
23
|
+
And the client should not be logged in
|
24
|
+
|
25
|
+
Scenario: Already logged in
|
26
|
+
Given a successful login
|
27
|
+
When the client logs in
|
28
|
+
Then the server returns a bad sequence error
|
29
|
+
And the client should be logged in
|
30
|
+
|
31
|
+
Scenario: PASS when already logged in
|
32
|
+
Given a successful login
|
33
|
+
When the client sends a password
|
34
|
+
Then the server returns a bad sequence error
|
35
|
+
|
36
|
+
Scenario: PASS after failed login
|
37
|
+
Given a failed login
|
38
|
+
When the client sends a password
|
39
|
+
Then the server returns a bad sequence error
|
40
|
+
|
41
|
+
Scenario: PASS without USER
|
42
|
+
Given a successful connection
|
43
|
+
And the client sends a password
|
44
|
+
Then the server returns a bad sequence error
|
45
|
+
|
46
|
+
Scenario: PASS without parameter
|
47
|
+
Given a successful connection
|
48
|
+
And the client sends a password with no parameter
|
49
|
+
Then the server returns a syntax error
|
50
|
+
|
51
|
+
Scenario: USRE without parameter
|
52
|
+
Given a successful connection
|
53
|
+
And the client sends a user with no parameter
|
54
|
+
Then the server returns a syntax error
|