ftpd 0.0.1.pre → 0.1.0
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 +3 -1
- data/Gemfile.lock +14 -14
- data/README.md +71 -23
- data/Rakefile +9 -3
- data/VERSION +1 -1
- data/examples/example.rb +132 -53
- data/examples/hello_world.rb +32 -0
- data/features/example/example.feature +18 -0
- data/features/example/step_definitions/example_server.rb +3 -0
- data/features/{command_errors.feature → ftp_server/command_errors.feature} +3 -0
- data/features/ftp_server/concurrent_sessions.feature +14 -0
- data/features/ftp_server/debug.feature +15 -0
- data/features/{delete.feature → ftp_server/delete.feature} +23 -2
- data/features/{directory_navigation.feature → ftp_server/directory_navigation.feature} +17 -4
- data/features/ftp_server/file_structure.feature +43 -0
- data/features/{get.feature → ftp_server/get.feature} +21 -10
- data/features/ftp_server/get_tls.feature +18 -0
- data/features/{list.feature → ftp_server/list.feature} +24 -30
- data/features/ftp_server/list_tls.feature +21 -0
- data/features/{login.feature → ftp_server/login.feature} +4 -2
- data/features/ftp_server/mode.feature +43 -0
- data/features/{name_list.feature → ftp_server/name_list.feature} +25 -31
- data/features/ftp_server/name_list_tls.feature +22 -0
- data/features/{noop.feature → ftp_server/noop.feature} +3 -0
- data/features/{port.feature → ftp_server/port.feature} +3 -0
- data/features/{put.feature → ftp_server/put.feature} +19 -11
- data/features/ftp_server/put_tls.feature +18 -0
- data/features/{quit.feature → ftp_server/quit.feature} +3 -0
- data/features/ftp_server/step_definitions/debug.rb +8 -0
- data/features/ftp_server/step_definitions/test_server.rb +12 -0
- data/features/{syntax_errors.feature → ftp_server/syntax_errors.feature} +3 -0
- data/features/ftp_server/type.feature +56 -0
- data/features/step_definitions/error.rb +10 -3
- data/features/step_definitions/list.rb +21 -4
- data/features/step_definitions/login.rb +0 -2
- data/features/step_definitions/server_files.rb +4 -0
- data/features/step_definitions/stop_server.rb +3 -0
- data/features/support/example_server.rb +58 -0
- data/features/support/test_client.rb +1 -1
- data/features/support/test_server.rb +106 -24
- data/features/support/test_server_files.rb +30 -0
- data/ftpd.gemspec +56 -25
- data/lib/ftpd.rb +22 -4
- data/lib/ftpd/disk_file_system.rb +137 -0
- data/lib/ftpd/error.rb +9 -0
- data/lib/ftpd/exception_translator.rb +29 -0
- data/lib/ftpd/exceptions.rb +13 -0
- data/lib/ftpd/file_system_error_translator.rb +21 -0
- data/lib/ftpd/ftp_server.rb +8 -645
- data/lib/ftpd/insecure_certificate.rb +10 -0
- data/lib/ftpd/server.rb +15 -12
- data/lib/ftpd/session.rb +569 -0
- data/lib/ftpd/temp_dir.rb +10 -11
- data/lib/ftpd/tls_server.rb +27 -15
- data/lib/ftpd/translate_exceptions.rb +44 -0
- data/rake_tasks/cucumber.rake +4 -2
- data/rake_tasks/default.rake +1 -0
- data/rake_tasks/spec.rake +3 -0
- data/rake_tasks/test.rake +2 -0
- data/sandbox/em-server.rb +37 -0
- data/spec/disk_file_system_spec.rb +239 -0
- data/spec/exception_translator_spec.rb +35 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/translate_exceptions_spec.rb +40 -0
- metadata +143 -115
- data/features/concurrent_sessions.feature +0 -11
- data/features/file_structure.feature +0 -40
- data/features/mode.feature +0 -40
- data/features/step_definitions/server.rb +0 -7
- data/features/type.feature +0 -53
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: Example
|
2
|
+
|
3
|
+
As a programmer
|
4
|
+
I want to connect to the example
|
5
|
+
So that I can try this libary with an arbitrary FTP client
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given the example server is started
|
9
|
+
|
10
|
+
Scenario: Normal connection
|
11
|
+
Given a successful login
|
12
|
+
Then the server returns no error
|
13
|
+
And the client should be logged in
|
14
|
+
|
15
|
+
Scenario: Fetch README
|
16
|
+
Given a successful login
|
17
|
+
When the client successfully gets text "README"
|
18
|
+
Then the local file "README" should match the remote file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Mode
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to start a session when there is another session
|
5
|
+
So that my session doesn't have to wait on the other
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given the test server is started
|
9
|
+
|
10
|
+
Scenario: Stream
|
11
|
+
Given a successful login
|
12
|
+
And the server has file "ascii_unix"
|
13
|
+
And the second client connects and logs in
|
14
|
+
Then the second client successfully does nothing
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: Debug
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to see debug output
|
5
|
+
So that I can fix FTP protocol problems
|
6
|
+
|
7
|
+
Scenario: Debug enabled
|
8
|
+
Given the test server is started with debug
|
9
|
+
And a successful login
|
10
|
+
Then the server should have written debug output
|
11
|
+
|
12
|
+
Scenario: Debug disabled
|
13
|
+
Given the test server is started
|
14
|
+
And a successful login
|
15
|
+
Then the server should have written no debug output
|
@@ -4,12 +4,28 @@ Feature: Delete
|
|
4
4
|
I want to delete files
|
5
5
|
So that nobody can fetch them from the server
|
6
6
|
|
7
|
+
Background:
|
8
|
+
Given the test server is started
|
9
|
+
|
7
10
|
Scenario: Delete a file
|
8
11
|
Given a successful login
|
9
12
|
And the server has file "foo"
|
10
13
|
When the client successfully deletes "foo"
|
11
14
|
Then the server should not have file "foo"
|
12
15
|
|
16
|
+
Scenario: Delete a file in a subdirectory
|
17
|
+
Given a successful login
|
18
|
+
And the server has file "foo/bar"
|
19
|
+
When the client successfully deletes "foo/bar"
|
20
|
+
Then the server should not have file "foo/bar"
|
21
|
+
|
22
|
+
Scenario: Change current directory
|
23
|
+
Given a successful login
|
24
|
+
And the server has file "foo/bar"
|
25
|
+
And the client successfully cd's to "foo"
|
26
|
+
When the client successfully deletes "bar"
|
27
|
+
Then the server should not have file "foo/bar"
|
28
|
+
|
13
29
|
Scenario: Missing path
|
14
30
|
Given a successful login
|
15
31
|
And the server has file "foo"
|
@@ -21,11 +37,16 @@ Feature: Delete
|
|
21
37
|
When the client deletes "foo"
|
22
38
|
Then the server returns a not found error
|
23
39
|
|
24
|
-
Scenario:
|
40
|
+
Scenario: Access denied
|
25
41
|
Given a successful login
|
26
|
-
When the client deletes "
|
42
|
+
When the client deletes "forbidden"
|
27
43
|
Then the server returns an access denied error
|
28
44
|
|
45
|
+
Scenario: File system error
|
46
|
+
Given a successful login
|
47
|
+
When the client deletes "unable"
|
48
|
+
Then the server returns an action not taken error
|
49
|
+
|
29
50
|
Scenario: Not logged in
|
30
51
|
Given a successful connection
|
31
52
|
When the client deletes "foo"
|
@@ -4,28 +4,41 @@ Feature: Change Directory
|
|
4
4
|
I want to change the current directory
|
5
5
|
So that I can use shorter paths
|
6
6
|
|
7
|
+
Background:
|
8
|
+
Given the test server is started
|
9
|
+
|
7
10
|
Scenario: Change to subdirectory
|
8
11
|
Given a successful login
|
9
12
|
And the server has file "subdir/bar"
|
10
13
|
When the client successfully cd's to "subdir"
|
11
14
|
Then the current directory should be "/subdir"
|
12
15
|
|
13
|
-
Scenario: Change to parent
|
16
|
+
Scenario: Change to parent from subdir
|
14
17
|
Given a successful login
|
15
18
|
And the server has file "subdir/bar"
|
16
|
-
And the server has file "baz"
|
17
19
|
And the client successfully cd's to "subdir"
|
18
20
|
When the client successfully cd's up
|
19
21
|
Then the current directory should be "/"
|
20
22
|
|
23
|
+
Scenario: Change to parent from root
|
24
|
+
Given a successful login
|
25
|
+
When the client successfully cd's up
|
26
|
+
Then the current directory should be "/"
|
27
|
+
|
28
|
+
Scenario: Change to file
|
29
|
+
Given a successful login
|
30
|
+
And the server has file "baz"
|
31
|
+
When the client cd's to "baz"
|
32
|
+
Then the server returns a not a directory error
|
33
|
+
|
21
34
|
Scenario: No such directory
|
22
35
|
Given a successful login
|
23
36
|
When the client cd's to "subdir"
|
24
37
|
Then the server returns a no such file error
|
25
38
|
|
26
|
-
Scenario:
|
39
|
+
Scenario: Access denied
|
27
40
|
Given a successful login
|
28
|
-
When the client cd's to "
|
41
|
+
When the client cd's to "forbidden"
|
29
42
|
Then the server returns an access denied error
|
30
43
|
|
31
44
|
Scenario: Not logged in
|
@@ -0,0 +1,43 @@
|
|
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
|
+
Background:
|
8
|
+
Given the test server is started
|
9
|
+
|
10
|
+
Scenario: File
|
11
|
+
Given a successful login
|
12
|
+
And the server has file "ascii_unix"
|
13
|
+
When the client successfully sets file structure "F"
|
14
|
+
And the client successfully gets text "ascii_unix"
|
15
|
+
Then the remote file "ascii_unix" should match the local file
|
16
|
+
|
17
|
+
Scenario: Record
|
18
|
+
Given a successful login
|
19
|
+
And the server has file "ascii_unix"
|
20
|
+
When the client sets file structure "R"
|
21
|
+
Then the server returns a file structure not implemented error
|
22
|
+
|
23
|
+
Scenario: Page
|
24
|
+
Given a successful login
|
25
|
+
And the server has file "ascii_unix"
|
26
|
+
When the client sets file structure "P"
|
27
|
+
Then the server returns a file structure not implemented error
|
28
|
+
|
29
|
+
Scenario: Invalid
|
30
|
+
Given a successful login
|
31
|
+
And the server has file "ascii_unix"
|
32
|
+
When the client sets file structure "*"
|
33
|
+
Then the server returns an invalid file structure error
|
34
|
+
|
35
|
+
Scenario: Not logged in
|
36
|
+
Given a successful connection
|
37
|
+
When the client sets file structure "F"
|
38
|
+
Then the server returns a not logged in error
|
39
|
+
|
40
|
+
Scenario: Missing parameter
|
41
|
+
Given a successful login
|
42
|
+
When the client sets file structure with no parameter
|
43
|
+
Then the server returns a syntax error
|
@@ -1,8 +1,12 @@
|
|
1
1
|
Feature: Get
|
2
2
|
|
3
3
|
As a client
|
4
|
-
I want to get a file
|
4
|
+
I want to securely get a file
|
5
5
|
So that I have it on my computer
|
6
|
+
But nobody else can
|
7
|
+
|
8
|
+
Background:
|
9
|
+
Given the test server is started
|
6
10
|
|
7
11
|
Scenario: ASCII file with *nix line endings
|
8
12
|
Given a successful login
|
@@ -31,19 +35,21 @@ Feature: Get
|
|
31
35
|
When the client successfully gets text "ascii_unix"
|
32
36
|
Then the local file "ascii_unix" should match the remote file
|
33
37
|
|
34
|
-
Scenario:
|
35
|
-
|
38
|
+
Scenario: File in subdirectory
|
39
|
+
Given a successful login
|
40
|
+
And the server has file "foo/ascii_unix"
|
41
|
+
Then the client successfully gets text "foo/ascii_unix"
|
36
42
|
|
37
|
-
Scenario:
|
38
|
-
Given a successful login
|
39
|
-
And the server has file "ascii_unix"
|
40
|
-
And the client
|
43
|
+
Scenario: Non-root working directory
|
44
|
+
Given a successful login
|
45
|
+
And the server has file "foo/ascii_unix"
|
46
|
+
And the client successfully cd's to "foo"
|
41
47
|
When the client successfully gets text "ascii_unix"
|
42
|
-
Then the
|
48
|
+
Then the remote file "foo/ascii_unix" should match the local file
|
43
49
|
|
44
|
-
Scenario:
|
50
|
+
Scenario: Access denied
|
45
51
|
Given a successful login
|
46
|
-
When the client gets text "
|
52
|
+
When the client gets text "forbidden"
|
47
53
|
Then the server returns an access denied error
|
48
54
|
|
49
55
|
Scenario: Missing file
|
@@ -60,3 +66,8 @@ Feature: Get
|
|
60
66
|
Given a successful login
|
61
67
|
When the client gets with no path
|
62
68
|
Then the server returns a syntax error
|
69
|
+
|
70
|
+
Scenario: File system error
|
71
|
+
Given a successful login
|
72
|
+
When the client gets text "unable"
|
73
|
+
Then the server returns an action not taken error
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: Get TLS
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to get a file
|
5
|
+
So that I have it on my computer
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given the test server is started with TLS
|
9
|
+
|
10
|
+
Scenario: TLS
|
11
|
+
pending "TLS not supported in active mode (see README)"
|
12
|
+
|
13
|
+
Scenario: TLS, Passive
|
14
|
+
Given a successful login with TLS
|
15
|
+
And the server has file "ascii_unix"
|
16
|
+
And the client is in passive mode
|
17
|
+
When the client successfully gets text "ascii_unix"
|
18
|
+
Then the local file "ascii_unix" should match the remote file
|
@@ -4,72 +4,66 @@ Feature: List
|
|
4
4
|
I want to list files
|
5
5
|
So that I can see what file to transfer
|
6
6
|
|
7
|
-
|
7
|
+
Background:
|
8
|
+
Given the test server is started
|
9
|
+
|
10
|
+
Scenario: Implicit
|
8
11
|
Given a successful login
|
9
12
|
And the server has file "foo"
|
10
13
|
And the server has file "bar"
|
11
|
-
When the client lists the directory
|
14
|
+
When the client successfully lists the directory
|
12
15
|
Then the file list should be in long form
|
13
16
|
And the file list should contain "foo"
|
14
17
|
And the file list should contain "bar"
|
15
18
|
|
16
|
-
Scenario:
|
19
|
+
Scenario: Root
|
17
20
|
Given a successful login
|
18
21
|
And the server has file "foo"
|
19
22
|
And the server has file "bar"
|
20
|
-
When the client lists the directory "/"
|
23
|
+
When the client successfully lists the directory "/"
|
21
24
|
Then the file list should be in long form
|
22
25
|
And the file list should contain "foo"
|
23
26
|
And the file list should contain "bar"
|
24
27
|
|
25
|
-
Scenario:
|
28
|
+
Scenario: Parent of root
|
26
29
|
Given a successful login
|
27
|
-
And the server has file "
|
28
|
-
|
30
|
+
And the server has file "foo"
|
31
|
+
And the server has file "bar"
|
32
|
+
When the client successfully lists the directory "/.."
|
29
33
|
Then the file list should be in long form
|
30
34
|
And the file list should contain "foo"
|
35
|
+
And the file list should contain "bar"
|
31
36
|
|
32
|
-
Scenario:
|
37
|
+
Scenario: Subdir
|
33
38
|
Given a successful login
|
34
|
-
And the server has file "foo"
|
35
|
-
|
36
|
-
When the client lists the directory "f*"
|
39
|
+
And the server has file "subdir/foo"
|
40
|
+
When the client successfully lists the directory "subdir"
|
37
41
|
Then the file list should be in long form
|
38
42
|
And the file list should contain "foo"
|
39
|
-
And the file list should not contain "bar"
|
40
43
|
|
41
|
-
Scenario:
|
44
|
+
Scenario: Glob
|
42
45
|
Given a successful login
|
43
46
|
And the server has file "foo"
|
44
47
|
And the server has file "bar"
|
45
|
-
|
46
|
-
When the client lists the directory
|
48
|
+
When the client successfully lists the directory "f*"
|
47
49
|
Then the file list should be in long form
|
48
50
|
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)"
|
51
|
+
And the file list should not contain "bar"
|
53
52
|
|
54
|
-
Scenario:
|
55
|
-
Given a successful login
|
53
|
+
Scenario: Passive
|
54
|
+
Given a successful login
|
56
55
|
And the server has file "foo"
|
57
56
|
And the server has file "bar"
|
58
57
|
And the client is in passive mode
|
59
|
-
When the client lists the directory
|
58
|
+
When the client successfully lists the directory
|
60
59
|
Then the file list should be in long form
|
61
60
|
And the file list should contain "foo"
|
62
61
|
And the file list should contain "bar"
|
63
62
|
|
64
|
-
Scenario:
|
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
|
63
|
+
Scenario: Missing directory
|
70
64
|
Given a successful login
|
71
|
-
When the client lists the directory "missing/file"
|
72
|
-
Then the
|
65
|
+
When the client successfully lists the directory "missing/file"
|
66
|
+
Then the file list should be empty
|
73
67
|
|
74
68
|
Scenario: Not logged in
|
75
69
|
Given a successful connection
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: List TLS
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to list files
|
5
|
+
So that I can see what file to transfer
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given the test server is started with TLS
|
9
|
+
|
10
|
+
Scenario: TLS
|
11
|
+
pending "TLS not supported in active mode (see README)"
|
12
|
+
|
13
|
+
Scenario: TLS, Passive
|
14
|
+
Given a successful login with TLS
|
15
|
+
And the server has file "foo"
|
16
|
+
And the server has file "bar"
|
17
|
+
And the client is in passive mode
|
18
|
+
When the client successfully lists the directory
|
19
|
+
Then the file list should be in long form
|
20
|
+
And the file list should contain "foo"
|
21
|
+
And the file list should contain "bar"
|
@@ -4,14 +4,16 @@ Feature: Login
|
|
4
4
|
I want to log in
|
5
5
|
So that I can transfer files
|
6
6
|
|
7
|
+
Background:
|
8
|
+
Given the test server is started
|
9
|
+
|
7
10
|
Scenario: Normal connection
|
8
11
|
Given a successful login
|
9
12
|
Then the server returns no error
|
10
13
|
And the client should be logged in
|
11
14
|
|
12
15
|
Scenario: Bad user
|
13
|
-
Given the
|
14
|
-
And the client connects
|
16
|
+
Given the client connects
|
15
17
|
When the client logs in with a bad user
|
16
18
|
Then the server returns a login incorrect error
|
17
19
|
And the client should not be logged in
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Feature: Mode
|
2
|
+
|
3
|
+
As a client
|
4
|
+
I want to set the file transfer mode
|
5
|
+
So that can optimize the transfer
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given the test server is started
|
9
|
+
|
10
|
+
Scenario: Stream
|
11
|
+
Given a successful login
|
12
|
+
And the server has file "ascii_unix"
|
13
|
+
When the client successfully sets mode "S"
|
14
|
+
And the client successfully gets text "ascii_unix"
|
15
|
+
Then the remote file "ascii_unix" should match the local file
|
16
|
+
|
17
|
+
Scenario: Block
|
18
|
+
Given a successful login
|
19
|
+
And the server has file "ascii_unix"
|
20
|
+
When the client sets mode "B"
|
21
|
+
Then the server returns a mode not implemented error
|
22
|
+
|
23
|
+
Scenario: Compressed
|
24
|
+
Given a successful login
|
25
|
+
And the server has file "ascii_unix"
|
26
|
+
When the client sets mode "C"
|
27
|
+
Then the server returns a mode not implemented error
|
28
|
+
|
29
|
+
Scenario: Invalid
|
30
|
+
Given a successful login
|
31
|
+
And the server has file "ascii_unix"
|
32
|
+
When the client sets mode "*"
|
33
|
+
Then the server returns an invalid mode error
|
34
|
+
|
35
|
+
Scenario: Not logged in
|
36
|
+
Given a successful connection
|
37
|
+
When the client sets mode "S"
|
38
|
+
Then the server returns a not logged in error
|
39
|
+
|
40
|
+
Scenario: Missing parameter
|
41
|
+
Given a successful login
|
42
|
+
When the client sets mode with no parameter
|
43
|
+
Then the server returns a syntax error
|