ftpd 0.2.0 → 0.2.1

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.

Files changed (49) hide show
  1. data/Changelog.md +24 -3
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +9 -2
  4. data/README.md +20 -9
  5. data/VERSION +1 -1
  6. data/doc/rfc.md +277 -0
  7. data/features/ftp_server/cdup.feature +36 -0
  8. data/features/ftp_server/command_errors.feature +0 -4
  9. data/features/ftp_server/delete.feature +1 -1
  10. data/features/ftp_server/directory_navigation.feature +18 -6
  11. data/features/ftp_server/get.feature +1 -1
  12. data/features/ftp_server/get_tls.feature +2 -2
  13. data/features/ftp_server/implicit_tls.feature +18 -0
  14. data/features/ftp_server/list_tls.feature +2 -2
  15. data/features/ftp_server/mkdir.feature +70 -0
  16. data/features/ftp_server/name_list_tls.feature +2 -2
  17. data/features/ftp_server/put.feature +1 -1
  18. data/features/ftp_server/put_tls.feature +2 -2
  19. data/features/ftp_server/rename.feature +90 -0
  20. data/features/ftp_server/rmdir.feature +71 -0
  21. data/features/ftp_server/step_definitions/debug.rb +6 -6
  22. data/features/ftp_server/step_definitions/test_server.rb +3 -2
  23. data/features/step_definitions/connect.rb +4 -3
  24. data/features/step_definitions/{directories.rb → directory_navigation.rb} +4 -0
  25. data/features/step_definitions/error_replies.rb +5 -5
  26. data/features/step_definitions/login.rb +2 -2
  27. data/features/step_definitions/mkdir.rb +9 -0
  28. data/features/step_definitions/rename.rb +11 -0
  29. data/features/step_definitions/rmdir.rb +9 -0
  30. data/features/step_definitions/server_files.rb +9 -0
  31. data/features/support/test_client.rb +19 -5
  32. data/features/support/test_server.rb +28 -3
  33. data/features/support/test_server_files.rb +5 -0
  34. data/ftpd.gemspec +17 -6
  35. data/lib/ftpd.rb +1 -0
  36. data/lib/ftpd/disk_file_system.rb +97 -16
  37. data/lib/ftpd/error.rb +16 -0
  38. data/lib/ftpd/exception_translator.rb +1 -1
  39. data/lib/ftpd/exceptions.rb +10 -4
  40. data/lib/ftpd/file_system_error_translator.rb +8 -4
  41. data/lib/ftpd/ftp_server.rb +1 -0
  42. data/lib/ftpd/session.rb +98 -87
  43. data/rake_tasks/yard.rake +1 -0
  44. data/spec/disk_file_system_spec.rb +55 -8
  45. data/spec/exception_translator_spec.rb +1 -1
  46. data/spec/file_system_error_translator_spec.rb +20 -4
  47. data/spec/translate_exceptions_spec.rb +1 -1
  48. metadata +32 -7
  49. data/sandbox/em-server.rb +0 -37
@@ -22,12 +22,8 @@ Feature: Command Errors
22
22
  | ACCT |
23
23
  | APPE |
24
24
  | HELP |
25
- | MKD |
26
25
  | REIN |
27
26
  | REST |
28
- | RMD |
29
- | RNFR |
30
- | RNTO |
31
27
  | SITE |
32
28
  | SMNT |
33
29
  | STAT |
@@ -32,7 +32,7 @@ Feature: Delete
32
32
  When the client deletes with no path
33
33
  Then the server returns a path required error
34
34
 
35
- Scenario: No such file
35
+ Scenario: not found
36
36
  Given a successful login
37
37
  When the client deletes "foo"
38
38
  Then the server returns a not found error
@@ -7,24 +7,36 @@ Feature: Change Directory
7
7
  Background:
8
8
  Given the test server is started
9
9
 
10
- Scenario: Change to subdirectory
10
+ Scenario: Down to subdir
11
11
  Given a successful login
12
12
  And the server has file "subdir/bar"
13
13
  When the client successfully cd's to "subdir"
14
14
  Then the current directory should be "/subdir"
15
15
 
16
- Scenario: Change to parent from subdir
16
+ Scenario: Up from subdir
17
17
  Given a successful login
18
18
  And the server has file "subdir/bar"
19
19
  And the client successfully cd's to "subdir"
20
- When the client successfully cd's up
20
+ When the client successfully cd's to ".."
21
21
  Then the current directory should be "/"
22
22
 
23
- Scenario: Change to parent from root
23
+ Scenario: Up from root
24
24
  Given a successful login
25
- When the client successfully cd's up
25
+ When the client successfully cd's to ".."
26
26
  Then the current directory should be "/"
27
27
 
28
+ Scenario: XPWD
29
+ Given a successful login
30
+ And the server has directory "subdir"
31
+ When the client successfully cd's to "subdir"
32
+ Then the XPWD directory should be "/subdir"
33
+
34
+ Scenario: XCWD
35
+ Given a successful login
36
+ And the server has directory "subdir"
37
+ When the client successfully sends "XCWD subdir"
38
+ Then the current directory should be "/subdir"
39
+
28
40
  Scenario: Change to file
29
41
  Given a successful login
30
42
  And the server has file "baz"
@@ -34,7 +46,7 @@ Feature: Change Directory
34
46
  Scenario: No such directory
35
47
  Given a successful login
36
48
  When the client cd's to "subdir"
37
- Then the server returns a no such file error
49
+ Then the server returns a not found error
38
50
 
39
51
  Scenario: Access denied
40
52
  Given a successful login
@@ -55,7 +55,7 @@ Feature: Get
55
55
  Scenario: Missing file
56
56
  Given a successful login
57
57
  When the client gets text "foo"
58
- Then the server returns a no such file error
58
+ Then the server returns a not found error
59
59
 
60
60
  Scenario: Not logged in
61
61
  Given a successful connection
@@ -5,13 +5,13 @@ Feature: Get TLS
5
5
  So that I have it on my computer
6
6
 
7
7
  Background:
8
- Given the test server is started with TLS
8
+ Given the test server is started with explicit TLS
9
9
 
10
10
  Scenario: TLS
11
11
  pending "TLS not supported in active mode (see README)"
12
12
 
13
13
  Scenario: TLS, Passive
14
- Given a successful login with TLS
14
+ Given a successful login with explicit TLS
15
15
  And the server has file "ascii_unix"
16
16
  And the client is in passive mode
17
17
  When the client successfully gets text "ascii_unix"
@@ -0,0 +1,18 @@
1
+ Feature: Put TLS
2
+
3
+ As a server
4
+ I want to use implicit TLS
5
+ Because I must serve out-of-date clients
6
+
7
+ Background:
8
+ Given the test server is started with implicit TLS
9
+
10
+ Scenario: Get
11
+ pending "TLS not supported in active mode (see README)"
12
+
13
+ Scenario: Get (passive)
14
+ Given a successful login with implicit TLS
15
+ And the client has file "ascii_unix"
16
+ And the client is in passive mode
17
+ When the client successfully puts text "ascii_unix"
18
+ Then the remote file "ascii_unix" should match the local file
@@ -5,13 +5,13 @@ Feature: List TLS
5
5
  So that I can see what file to transfer
6
6
 
7
7
  Background:
8
- Given the test server is started with TLS
8
+ Given the test server is started with explicit TLS
9
9
 
10
10
  Scenario: TLS
11
11
  pending "TLS not supported in active mode (see README)"
12
12
 
13
13
  Scenario: TLS, Passive
14
- Given a successful login with TLS
14
+ Given a successful login with explicit TLS
15
15
  And the server has file "foo"
16
16
  And the server has file "bar"
17
17
  And the client is in passive mode
@@ -0,0 +1,70 @@
1
+ Feature: Make directory
2
+
3
+ As a client
4
+ I want to create a directory
5
+ So that I can categorize my uploads
6
+
7
+ Background:
8
+ Given the test server is started
9
+
10
+ Scenario: Make directory
11
+ Given a successful login
12
+ When the client successfully makes directory "foo"
13
+ Then the server has directory "foo"
14
+
15
+ Scenario: Directory of a directory
16
+ Given a successful login
17
+ And the server has directory "foo"
18
+ When the client successfully makes directory "foo/bar"
19
+ Then the server has directory "foo/bar"
20
+
21
+ Scenario: After cwd
22
+ Given a successful login
23
+ And the server has directory "foo"
24
+ And the client successfully cd's to "foo"
25
+ When the client successfully makes directory "bar"
26
+ Then the server has directory "foo/bar"
27
+
28
+ Scenario: XMKD
29
+ Given a successful login
30
+ When the client successfully sends "XMKD foo"
31
+ Then the server has directory "foo"
32
+
33
+ Scenario: Missing directory
34
+ Given a successful login
35
+ When the client makes directory "foo/bar"
36
+ Then the server returns a not found error
37
+
38
+ Scenario: Not logged in
39
+ Given a successful connection
40
+ When the client makes directory "foo"
41
+ Then the server returns a not logged in error
42
+
43
+ Scenario: Already exists
44
+ Given a successful login
45
+ And the server has directory "foo"
46
+ When the client makes directory "foo"
47
+ Then the server returns an already exists error
48
+
49
+ Scenario: Directory of a file
50
+ Given a successful login
51
+ And the server has file "foo"
52
+ When the client makes directory "foo/bar"
53
+ Then the server returns a not a directory error
54
+
55
+ Scenario: Mkdir not enabled
56
+ Given the test server is started without mkdir
57
+ And a successful login
58
+ When the client makes directory "foo"
59
+ Then the server returns an unimplemented command error
60
+
61
+ Scenario: Missing path
62
+ Given a successful login
63
+ When the client sends "MKD"
64
+ Then the server returns a syntax error
65
+
66
+ Scenario: Access denied
67
+ Given a successful login
68
+ When the client makes directory "forbidden"
69
+ Then the server returns an access denied error
70
+
@@ -6,13 +6,13 @@ Feature: Name List TLS
6
6
  And nobody else can
7
7
 
8
8
  Background:
9
- Given the test server is started with TLS
9
+ Given the test server is started with explicit TLS
10
10
 
11
11
  Scenario: TLS
12
12
  pending "TLS not supported in active mode (see README)"
13
13
 
14
14
  Scenario: TLS, Passive
15
- Given a successful login with TLS
15
+ Given a successful login with explicit TLS
16
16
  And the server has file "foo"
17
17
  And the server has file "bar"
18
18
  And the client is in passive mode
@@ -53,7 +53,7 @@ Feature: Put
53
53
  Given a successful login
54
54
  And the client has file "bar"
55
55
  When the client puts text "foo/bar"
56
- Then the server returns a no such file error
56
+ Then the server returns a not found error
57
57
 
58
58
  Scenario: Not logged in
59
59
  Given a successful connection
@@ -5,13 +5,13 @@ Feature: Put TLS
5
5
  So that someone else can have it
6
6
 
7
7
  Background:
8
- Given the test server is started with TLS
8
+ Given the test server is started with explicit TLS
9
9
 
10
10
  Scenario: TLS
11
11
  pending "TLS not supported in active mode (see README)"
12
12
 
13
13
  Scenario: TLS, Passive
14
- Given a successful login with TLS
14
+ Given a successful login with explicit TLS
15
15
  And the client has file "ascii_unix"
16
16
  And the client is in passive mode
17
17
  When the client successfully puts text "ascii_unix"
@@ -0,0 +1,90 @@
1
+ Feature: Rename
2
+
3
+ As a client
4
+ I want to rename a file
5
+ To correct an improper name
6
+
7
+ Background:
8
+ Given the test server is started
9
+
10
+ Scenario: Rename
11
+ Given a successful login
12
+ And the server has file "foo"
13
+ When the client successfully renames "foo" to "bar"
14
+ Then the server should not have file "foo"
15
+ And the server should have file "bar"
16
+
17
+ Scenario: Move
18
+ Given a successful login
19
+ And the server has file "foo/bar"
20
+ And the server has directory "baz"
21
+ When the client successfully renames "foo/bar" to "baz/qux"
22
+ Then the server should not have file "foo/bar"
23
+ And the server should have file "baz/qux"
24
+
25
+ Scenario: Non-root working directory
26
+ Given a successful login
27
+ And the server has file "foo/bar"
28
+ And the client successfully cd's to "foo"
29
+ When the client successfully renames "bar" to "baz"
30
+ Then the server should not have file "foo/bar"
31
+ Then the server should have file "foo/baz"
32
+
33
+ Scenario: Access denied (source)
34
+ Given a successful login
35
+ When the client renames "forbidden" to "foo"
36
+ Then the server returns an access denied error
37
+
38
+ Scenario: Access denied (destination)
39
+ Given a successful login
40
+ And the server has file "foo"
41
+ When the client renames "foo" to "forbidden"
42
+ Then the server returns an access denied error
43
+
44
+ Scenario: Source missing
45
+ Given a successful login
46
+ When the client renames "foo" to "bar"
47
+ Then the server returns a not found error
48
+
49
+ Scenario: Destination exists
50
+ Given a successful login
51
+ And the server has file "foo"
52
+ And the server has file "bar"
53
+ When the client renames "foo" to "bar"
54
+ Then the server returns an already exists error
55
+
56
+ Scenario: Not logged in (RNFR)
57
+ Given a successful connection
58
+ When the client sends "RNFR foo"
59
+ Then the server returns a not logged in error
60
+
61
+ Scenario: Not logged in (RNTO)
62
+ Given a successful connection
63
+ When the client sends "RNTO foo"
64
+ # Although the RNTO command checks for logged in, sequence error
65
+ # gets triggered first.
66
+ Then the server returns a bad sequence error
67
+
68
+ Scenario: Missing path (RNFR)
69
+ Given a successful login
70
+ When the client sends "RNFR"
71
+ Then the server returns a syntax error
72
+
73
+ Scenario: Missing path (RNTO)
74
+ Given a successful login
75
+ And the server has file "foo"
76
+ And the client successfully sends "RNFR foo"
77
+ When the client sends "RNTO"
78
+ Then the server returns a syntax error
79
+
80
+ Scenario: Rename not enabled
81
+ Given the test server is started without rename
82
+ And a successful login
83
+ And the server has file "foo"
84
+ When the client renames "foo" to "bar"
85
+ Then the server returns an unimplemented command error
86
+
87
+ Scenario: RNTO without RNFR
88
+ Given a successful login
89
+ When the client sends "RNTO bar"
90
+ Then the server returns a bad sequence error
@@ -0,0 +1,71 @@
1
+ Feature: Remove directory
2
+
3
+ As a client
4
+ I want to remove a directory
5
+ To reduce clutter
6
+
7
+ Background:
8
+ Given the test server is started
9
+
10
+ Scenario: Make directory
11
+ Given a successful login
12
+ And the server has directory "foo"
13
+ When the client successfully removes directory "foo"
14
+ Then the server should not have directory "foo"
15
+
16
+ Scenario: Directory of a directory
17
+ Given a successful login
18
+ And the server has directory "foo/bar"
19
+ When the client successfully removes directory "foo/bar"
20
+ Then the server should not have directory "foo/bar"
21
+ And the server has directory "foo"
22
+
23
+ Scenario: After cwd
24
+ Given a successful login
25
+ And the server has directory "foo/bar"
26
+ And the client successfully cd's to "foo"
27
+ When the client successfully removes directory "bar"
28
+ Then the server should not have directory "foo/bar"
29
+
30
+ Scenario: XRMD
31
+ Given a successful login
32
+ And the server has directory "foo"
33
+ When the client successfully sends "XRMD foo"
34
+ Then the server should not have directory "foo"
35
+
36
+ Scenario: Missing directory
37
+ Given a successful login
38
+ When the client removes directory "foo/bar"
39
+ Then the server returns a not found error
40
+
41
+ Scenario: Not logged in
42
+ Given a successful connection
43
+ When the client removes directory "foo"
44
+ Then the server returns a not logged in error
45
+
46
+ Scenario: Does not exist
47
+ Given a successful login
48
+ When the client removes directory "foo"
49
+ Then the server returns a not found error
50
+
51
+ Scenario: Remove a file
52
+ Given a successful login
53
+ And the server has file "foo"
54
+ When the client removes directory "foo"
55
+ Then the server returns a not a directory error
56
+
57
+ Scenario: Rmdir not enabled
58
+ Given the test server is started without rmdir
59
+ And a successful login
60
+ When the client removes directory "foo"
61
+ Then the server returns an unimplemented command error
62
+
63
+ Scenario: Missing path
64
+ Given a successful login
65
+ When the client sends "RMD"
66
+ Then the server returns a syntax error
67
+
68
+ Scenario: Access denied
69
+ Given a successful login
70
+ When the client removes directory "forbidden"
71
+ Then the server returns an access denied error
@@ -1,8 +1,8 @@
1
1
  Then /^the server should have written( no)? debug output$/ do |neg|
2
- matcher = if neg
3
- be_false
4
- else
5
- be_true
6
- end
7
- @server.wrote_debug_output?.should matcher
2
+ method = if neg
3
+ :should
4
+ else
5
+ :should_not
6
+ end
7
+ @server.debug_output.send(method) == ''
8
8
  end
@@ -3,9 +3,10 @@ Given /^the test server is started$/ do
3
3
  @server.start
4
4
  end
5
5
 
6
- Given /^the test server is started with TLS$/ do
6
+ Given /^the test server is started with(?: (\w+) TLS)?$/ do |mode|
7
+ mode ||= 'explicit'
7
8
  @server = TestServer.new
8
- @server.tls = :explicit
9
+ @server.tls = mode.to_sym
9
10
  @server.start
10
11
  end
11
12
 
@@ -1,9 +1,10 @@
1
1
  require 'double_bag_ftps'
2
2
  require 'net/ftp'
3
3
 
4
- When /^the( \w+)? client connects( with TLS)?$/ do
5
- |client_name, with_tls|
6
- client = TestClient.new(:tls => with_tls)
4
+ When /^the( \w+)? client connects(?: with (\w+) TLS)?$/ do
5
+ |client_name, tls_mode|
6
+ tls_mode ||= :off
7
+ client = TestClient.new(:tls => tls_mode.to_sym)
7
8
  client.connect(@server.host, @server.port)
8
9
  set_client client_name, client
9
10
  end