em-ftpd-memory 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f956464e630343b641be99ed93084dcb2a611315
4
- data.tar.gz: 29590d20f13333be333625911bd2e926b72f8d00
3
+ metadata.gz: 59b7c1d4a65d038d0a2addbbccbf1697a1f4e6c4
4
+ data.tar.gz: 605868d7a3280ff3f5b0ad062acee5f31b8a97cb
5
5
  SHA512:
6
- metadata.gz: 478ecd65ede2e791ce9e15379feecc04766b5e5896ca9c77cc3a8b885df3dc4d408dd233cd48c3674d3463a989124b3d107b19bdedf6d0892eadbc3050d6131e
7
- data.tar.gz: 88f9881f706324244c08740de23803f298e14b52ff57ee4d88b7a2b43c46b957b4f9744e369721b343a77766197eb8e05b9aa9d1f3b054aeeba985e8bfb963c2
6
+ metadata.gz: f2d538c602e0060ebcc469f81bb8d33a583b8a825e13ea060583bbb270535e8aec86080757536b48bd096fb90af20c0ee6eadad6e5c84e7c2e1497c4bdb904f7
7
+ data.tar.gz: d811d57df20890c04e1687c8a32cd3b0b88680a705fd34d70bd3ee7533b29c23f143d73b221c7c639a7c7876662c17b4a3cd42e7d3f0fcac79cd15227e346a5d
data/README.md CHANGED
@@ -28,11 +28,23 @@ Or install it yourself as:
28
28
  "pwalgo" => "otp",
29
29
 
30
30
  }
31
- auth = EM::FTPD::Memory::Authenticator.getAuthenticatorByRealm(options["authentication_realm"], options)
32
- auth << EM::FTPD::Memory::User.new("test", "test1\ntest2\ntest3\ntest4\ntest5")
33
- fs = EM::FTPD::Memory::FileSystem.getFileSystemByName(options["filesystem_name"])
34
- fs.create_dir("/pub")
35
- fs.create_file("/pub/helper.rb", "test/helper.rb")
31
+ auth = Authenticator.getAuthenticatorByRealm(options["authentication_realm"], options)
32
+ auth << User.new("test", "test1\ntest2\ntest3\ntest4\ntest5")
33
+ fs = FileSystem.getFileSystem(options["filesystem_name"])
34
+ fs.create_dir("/pub", 'root')
35
+ fs.create_file("/pub/helper.rb", "test/helper.rb", 'root')
36
+ fs.set_permissions("/pub", 'rwxr.xr.x', "root")
37
+ fs.create_dir("/uploads", 'root')
38
+ fs.set_permissions("/uploads", "rwxrwxrwx", "root")
39
+
40
+ fs.create_dir("/users", 'root')
41
+ fs.set_permissions("/users", "rwxr.xr.x", "root")
42
+ ["hiro", "miyako", "pilar"].each do |username|
43
+ fs.create_dir("/users/#{username}", 'root')
44
+ fs.set_permissions("/users/#{username}", "rwx......", "root")
45
+ fs.set_owner("/users/#{username}", username, 'root')
46
+ auth << User.new(username, username)
47
+ end
36
48
 
37
49
  EM.run {
38
50
  EventMachine::start_server("0.0.0.0", 2021, EM::FTPD::Server, EM::FTPD::Memory::Driver, options)
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "em-ftpd-memory"
7
- spec.version = "0.0.4"
7
+ spec.version = "0.0.5"
8
8
  spec.authors = ["chrislee35"]
9
9
  spec.email = ["rubygems@chrislee.dhs.org"]
10
10
  spec.summary = %q{Memory-based backing store for em-ftpd}
@@ -1,6 +1,22 @@
1
1
  module EM::FTPD::Memory
2
2
  class InvalidPermissionsError < StandardError; end
3
3
 
4
+ class MemoryDirectoryItem
5
+ ATTRS = [:name, :owner, :group, :size, :time, :permissions, :directory, :contents]
6
+ attr_accessor(*ATTRS)
7
+
8
+ def initialize(options)
9
+ options.each do |attr, value|
10
+ self.send("#{attr}=", value)
11
+ end
12
+ @size ||= 0
13
+ @time ||= Time.now
14
+ @owner ||= "nobody"
15
+ @group ||= "nogroup"
16
+ raise ArgumentError.new("MemoryDirectoryItem requires a :name") unless @name
17
+ end
18
+ end
19
+
4
20
  class FileSystem
5
21
  @@filesystems = Hash.new
6
22
  def self.getFileSystem(name)
@@ -23,61 +39,84 @@ module EM::FTPD::Memory
23
39
  end
24
40
  end
25
41
  end
42
+
43
+
44
+ # TODO: support groups
26
45
 
27
- def initialize()
28
- @root_entry = EM::FTPD::DirectoryItem.new(:name => 'root', :directory => true, :size => 0, :permissions => 'rwxrwxrwx', :owner => 'root', :group => 'root')
29
- @root = {
30
- '/' => Array.new
31
- }
32
- @contents = Hash.new
46
+ def initialize
47
+ @root = MemoryDirectoryItem.new(:name => '/', :owner => 'root', :directory => true, :permissions => "rwxr.xr.x", :contents => Hash.new)
33
48
  end
34
49
 
35
50
  def exist?(path)
36
- is_dir(path) || is_file(path)
51
+ item = get_item(path)
52
+ if item
53
+ return true
54
+ else
55
+ return false
56
+ end
57
+ end
58
+
59
+ def is_dir?(path)
60
+ item = get_item(path)
61
+ return false unless item and item.directory
62
+ true
63
+ end
64
+
65
+ def is_file?(path)
66
+ item = get_item(path)
67
+ return false unless item and not item.directory
68
+ true
37
69
  end
38
70
 
39
71
  def change_dir(path, user = nil)
40
- is_dir(path) && use_allowed?(path, :list, user)
72
+ item = get_item(path)
73
+ item.directory && use_allowed?(path, :list, user)
41
74
  end
42
75
 
43
76
  def list_files(path, user = nil)
44
77
  return [] unless use_allowed?(path, :list, user)
45
- @root[path] || [] # should this return false?
78
+ item = get_item(path)
79
+ if item.directory
80
+ return item.contents.values
81
+ end
82
+ return []
46
83
  end
47
84
 
48
85
  def file_size(path, user = nil)
49
86
  return false unless use_allowed?(path, :size, user)
50
- f = get_file(path)
87
+ f = get_item(path)
51
88
  return false unless f
52
89
  f.size
53
90
  end
54
91
 
55
92
  def modified_time(path, user = nil)
56
93
  return nil unless use_allowed?(path, :time, user)
57
- f = get_file(path)
94
+ f = get_item(path)
58
95
  return nil unless f
59
96
  f.time
60
97
  end
61
98
 
62
99
  def file_contents(path, user = nil)
63
100
  return false unless use_allowed?(path, :read, user)
64
- # nil || false => false
65
- @contents[path] || false
101
+ item = get_item(path)
102
+ item.contents || false
66
103
  end
67
104
 
68
105
  def create_file(path, data, user = "nobody")
69
106
  return false unless use_allowed?(path, :create, user)
70
107
  dirname = File.dirname(path)
71
108
  basename = File.basename(path)
72
- if is_dir(dirname)
109
+ dir = get_item(dirname)
110
+ if dir and dir.directory
111
+ item = get_item(path)
73
112
  contents = File.open(data,'r').read
74
- f = get_file(path)
75
- if f
76
- f.size = contents.length
77
- else
78
- @root[dirname] << EM::FTPD::DirectoryItem.new(:name => basename, :directory => false, :size => contents.length)
113
+ permissions = "rwxrwxrwx" # FIXME
114
+ if item # overwrite
115
+ item.contents = contents
116
+ item.size = contents.length
117
+ else # create new
118
+ dir.contents[basename] = MemoryDirectoryItem.new(:name => basename, :owner => user, :size => contents.length, :contents => contents, :permissions => permissions)
79
119
  end
80
- @contents[path] = contents
81
120
  return true
82
121
  else
83
122
  return false
@@ -85,37 +124,39 @@ module EM::FTPD::Memory
85
124
  end
86
125
 
87
126
  def delete_file(path, user = nil)
88
- if is_file(path)
89
- return false unless use_allowed?(path, :delete, user)
90
- dirname = File.dirname(path)
91
- basename = File.basename(path)
92
- @root[dirname].reject! {|file| file.directory == false && file.name == basename}
93
- @contents.delete(path)
127
+ return false unless use_allowed?(path, :delete, user)
128
+ dirname = File.dirname(path)
129
+ basename = File.basename(path)
130
+ dir = get_item(dirname)
131
+ if dir and dir.directory and dir.contents[basename]
132
+ dir.contents.delete(basename)
94
133
  return true
95
134
  end
96
135
  false
97
136
  end
98
137
 
99
138
  def delete_dir(path, user = nil)
100
- if is_dir(path) && @root[path].empty?
139
+ dir = get_item(path)
140
+ if dir and dir.directory and dir.contents.empty?
101
141
  return false unless use_allowed?(path, :delete, user)
102
- @root.delete(path)
103
142
  dirname = File.dirname(path)
104
143
  basename = File.basename(path)
105
- @root[dirname].reject! {|file| file.directory == true && file.name == basename}
144
+ parent = get_item(dirname)
145
+ parent.contents.delete(basename)
106
146
  return true
107
147
  end
108
148
  false
109
149
  end
110
150
 
111
151
  def create_dir(path, user = "nobody")
112
- if not exist?(path)
152
+ dir = get_item(path)
153
+ if dir.nil?
113
154
  return false unless use_allowed?(path, :create, user)
114
155
  dirname = File.dirname(path)
115
156
  basename = File.basename(path)
116
- if is_dir(dirname)
117
- @root[path] = Array.new
118
- @root[dirname] << EM::FTPD::DirectoryItem.new(:name => basename, :directory => true, :size => 0)
157
+ parent = get_item(dirname)
158
+ if parent and parent.directory
159
+ parent.contents[basename] = MemoryDirectoryItem.new(:name => basename, :directory => true, :owner => user, :contents => Hash.new)
119
160
  return true
120
161
  end
121
162
  end
@@ -123,8 +164,10 @@ module EM::FTPD::Memory
123
164
  end
124
165
 
125
166
  def rename(from, to, user = nil)
126
- return false if exist?(to)
127
- return false unless exist?(from)
167
+ titem = get_item(to)
168
+ return false if titem
169
+ fitem = get_item(from)
170
+ return false unless fitem
128
171
  return false unless use_allowed?(from, :delete, user)
129
172
  return false unless use_allowed?(to, :create, user)
130
173
 
@@ -133,86 +176,52 @@ module EM::FTPD::Memory
133
176
  to_dirname = File.dirname(to)
134
177
  to_basename = File.basename(to)
135
178
 
136
- if from_dirname == to_dirname
137
- @root[from_dirname].find {|file| file.name == from_basename}.name = to_basename
138
- else
139
- entry = @root[from_dirname].find {|file| file.name == from_basename}
140
- @root[from_dirname] -= [entry]
141
- entry.name = to_basename
142
- @root[to_dirname] << entry
143
- end
179
+ dir1 = get_item(from_dirname)
180
+ dir2 = get_item(to_dirname)
181
+ fitem.name = to_basename
182
+ dir2.contents[to_basename] = fitem
183
+ dir1.contents.delete(from_basename)
144
184
 
145
- if is_dir(from)
146
- @root[to] = @root[from]
147
- @root.delete(from)
148
- else
149
- # @contents[to] points to the same reference/pointer as @contents[from]
150
- # i.e., this is not a copy, they point to the same object
151
- @contents[to] = @contents[from]
152
- @contents.delete(from)
153
- end
154
185
  return true
155
186
  end
156
187
 
157
188
  def destroy
158
- @root.each_key do |d|
159
- @root.delete(d)
160
- end
161
- @contents.each_key do |f|
162
- @contents.delete(f)
163
- end
189
+ @root = MemoryDirectoryItem.new(:name => '/', :owner => 'root', :directory => true, :permissions => "rwxr.xr.x", :contents => Hash.new)
164
190
  GC.start
165
191
  end
166
192
 
167
193
  def set_permissions(path, permissions, user = nil)
168
- return false unless exist?(path)
194
+ item = get_item(path)
195
+ return false unless item
169
196
  raise InvalidPermissionsError.new if permissions.nil?
170
197
  raise InvalidPermissionsError.new(permissions.to_s) unless permissions.class == String
171
198
  raise InvalidPermissionsError.new(permissions) unless permissions =~ /^[r\.][w\.][x\.][r\.][w\.][x\.][r\.][w\.][x\.]$/
172
199
  if use_allowed?(path, :chmod, user)
173
- entry = get_entry(path)
174
- entry.permissions = permissions
200
+ item.permissions = permissions
175
201
  return true
176
202
  end
177
203
  false
178
204
  end
179
205
 
180
206
  def set_owner(path, owner, user = nil)
181
- return false unless exist?(path) and owner and owner.class == String
182
- entry = get_entry(path)
207
+ item = get_item(path)
208
+ return false unless item and owner and owner.class == String
183
209
  return false unless user and user == "root"
184
- return false unless entry
185
- entry.owner = owner
210
+ item.owner = owner
186
211
  true
187
212
  end
188
213
 
189
- #private
190
-
191
- def get_entry(path)
192
- return @root_entry if path == '/'
193
- dirname = File.dirname(path)
194
- basename = File.basename(path)
195
- if is_dir(dirname)
196
- return @root[dirname].find {|entry| entry.name == basename}
197
- end
198
- nil
199
- end
214
+ #private
200
215
 
201
- def get_file(path)
202
- dirname = File.dirname(path)
203
- basename = File.basename(path)
204
- if is_dir(dirname)
205
- return @root[dirname].find {|file| file.directory == false && file.name == basename}
216
+ def get_item(path)
217
+ cur = @root
218
+ path.split(/\//).each do |part|
219
+ next if part == ""
220
+ raise ArgumentError.new("Use of . and .. are forbidden") if part == "." or part == ".."
221
+ cur = cur.contents[part]
222
+ return nil if cur.nil?
206
223
  end
207
- nil
208
- end
209
-
210
- def is_file(path)
211
- @contents[path] || false
212
- end
213
-
214
- def is_dir(path)
215
- @root[path] != nil
224
+ cur
216
225
  end
217
226
 
218
227
  def use_allowed?(path, use, username)
@@ -241,8 +250,8 @@ module EM::FTPD::Memory
241
250
  when :time
242
251
  return true # since we've already checked everything
243
252
  when :chmod
244
- entry = get_entry(path)
245
- return entry.owner == username
253
+ item = get_item(path)
254
+ return item.owner == username
246
255
  when :delete
247
256
  return allowed?(dirname, "rwx", username)
248
257
  when :create
@@ -253,12 +262,12 @@ module EM::FTPD::Memory
253
262
  end
254
263
 
255
264
  def allowed?(path, required_permissions, username)
256
- entry = get_entry(path)
257
- permissions = entry.permissions || 'rwxrwxrwx'
258
- return false unless entry
265
+ item = get_item(path)
266
+ return false unless item
267
+ permissions = item.permissions || 'rwxrwxrwx'
259
268
  if username.nil?
260
269
  perms = permissions[6,3]
261
- elsif entry.owner == username
270
+ elsif item.owner == username
262
271
  perms = permissions[0,3]
263
272
  else
264
273
  perms = permissions[6,3]
@@ -20,11 +20,35 @@ class TestFTPDMemory < Minitest::Test
20
20
  "pwalgo" => "otp",
21
21
 
22
22
  }
23
+ # set up the authentication
23
24
  auth = Authenticator.getAuthenticatorByRealm(options["authentication_realm"], options)
25
+ # add a test user
24
26
  auth << User.new("test", "test1\ntest2\ntest3\ntest4\ntest5")
27
+ # create the filesystem
25
28
  fs = FileSystem.getFileSystem(options["filesystem_name"])
26
- fs.create_dir("/pub")
27
- fs.create_file("/pub/helper.rb", "test/helper.rb")
29
+ # add a pub folder
30
+ fs.create_dir("/pub", 'root')
31
+ # add a file to the pub folder as root
32
+ fs.create_file("/pub/helper.rb", "test/helper.rb", 'root')
33
+ # chmod 755 /pub
34
+ fs.set_permissions("/pub", 'rwxr.xr.x', "root")
35
+ # create /uploads as root
36
+ fs.create_dir("/uploads", 'root')
37
+ # chmod 777 /uploads
38
+ fs.set_permissions("/uploads", "rwxrwxrwx", "root")
39
+ # create /users as root
40
+ fs.create_dir("/users", 'root')
41
+ # chmod 755 /users
42
+ fs.set_permissions("/users", "rwxr.xr.x", "root")
43
+ # create a personal directory for hiro, miyako, and pilar, (and add their test user)
44
+ ["hiro", "miyako", "pilar"].each do |username|
45
+ fs.create_dir("/users/#{username}", 'root')
46
+ # set the permissions so that no one else can access it
47
+ fs.set_permissions("/users/#{username}", "rwx......", "root")
48
+ # set the owner to the user
49
+ fs.set_owner("/users/#{username}", username, 'root')
50
+ auth << User.new(username, username)
51
+ end
28
52
 
29
53
  EM.run {
30
54
  EventMachine::start_server("0.0.0.0", 2021, EM::FTPD::Server, EM::FTPD::Memory::Driver, options)
@@ -23,70 +23,76 @@ class TestMemoryFilesystem < Minitest::Test
23
23
 
24
24
  def test_file_creation
25
25
  fs = FileSystem.getFileSystem(__method__)
26
- fs.create_file("/helper.rb", "test/helper.rb")
26
+ assert(fs.set_permissions("/", "rwxrwxrwx", "root"))
27
+ assert(fs.create_file("/helper.rb", "test/helper.rb"))
27
28
  assert(fs.exist?("/helper.rb"))
28
- refute(fs.is_dir("/helper.rb"))
29
- assert(fs.is_file("/helper.rb"))
29
+ refute(fs.is_dir?("/helper.rb"))
30
+ assert(fs.is_file?("/helper.rb"))
30
31
  assert_equal(169, fs.file_size("/helper.rb"))
31
32
  FileSystem.destroyFileSystem(__method__)
32
33
  end
33
34
 
34
35
  def test_file_deletion
35
36
  fs = FileSystem.getFileSystem(__method__)
36
- fs.create_file("/helper.rb", "test/helper.rb")
37
+ assert(fs.set_permissions("/", "rwxrwxrwx", "root"))
38
+ assert(fs.create_file("/helper.rb", "test/helper.rb"))
37
39
  assert(fs.exist?("/helper.rb"))
38
- refute(fs.is_dir("/helper.rb"))
39
- assert(fs.is_file("/helper.rb"))
40
+ refute(fs.is_dir?("/helper.rb"))
41
+ assert(fs.is_file?("/helper.rb"))
40
42
  assert_equal(169, fs.file_size("/helper.rb"))
41
- fs.delete_file("/helper.rb")
43
+ assert(fs.delete_file("/helper.rb"))
42
44
  refute(fs.exist?("/helper.rb"))
43
45
  FileSystem.destroyFileSystem(__method__)
44
46
  end
45
47
 
46
48
  def test_create_directory
47
49
  fs = FileSystem.getFileSystem(__method__)
48
- fs.create_dir("/pub")
50
+ assert(fs.set_permissions("/", "rwxrwxrwx", "root"))
51
+
52
+ assert(fs.create_dir("/pub"))
49
53
  assert(fs.exist?("/pub"))
50
- assert(fs.is_dir("/pub"))
51
- refute(fs.is_file("/pub"))
54
+ assert(fs.is_dir?("/pub"))
55
+ refute(fs.is_file?("/pub"))
52
56
 
53
- fs.create_file("/pub/helper.rb", "test/helper.rb")
57
+ assert(fs.create_file("/pub/helper.rb", "test/helper.rb"))
54
58
  assert(fs.exist?("/pub/helper.rb"))
55
59
  assert_equal(169, fs.file_size("/pub/helper.rb"))
56
- fs.delete_file("/pub/helper.rb")
60
+ assert(fs.delete_file("/pub/helper.rb"))
57
61
  refute(fs.exist?("/pub/helper.rb"))
58
62
  FileSystem.destroyFileSystem(__method__)
59
63
  end
60
64
 
61
65
  def test_delete_directory
62
66
  fs = FileSystem.getFileSystem(__method__)
63
- fs.create_dir("/pub")
67
+ assert(fs.set_permissions("/", "rwxrwxrwx", "root"))
68
+ assert(fs.create_dir("/pub"))
64
69
  assert(fs.exist?("/pub"))
65
- assert(fs.is_dir("/pub"))
66
- refute(fs.is_file("/pub"))
70
+ assert(fs.is_dir?("/pub"))
71
+ refute(fs.is_file?("/pub"))
67
72
 
68
- fs.create_file("/pub/helper.rb", "test/helper.rb")
73
+ assert(fs.create_file("/pub/helper.rb", "test/helper.rb", "root"))
69
74
  assert(fs.exist?("/pub/helper.rb"))
70
- assert_equal(169, fs.file_size("/pub/helper.rb"))
71
- refute(fs.delete_dir("/pub"))
72
- fs.delete_file("/pub/helper.rb")
75
+ assert_equal(169, fs.file_size("/pub/helper.rb", "root"))
76
+ refute(fs.delete_dir("/pub", "root"))
77
+ assert(fs.delete_file("/pub/helper.rb", "root"))
73
78
  refute(fs.exist?("/pub/helper.rb"))
74
- assert(fs.delete_dir("/pub"))
79
+ assert(fs.delete_dir("/pub", "root"))
75
80
  refute(fs.exist?("/pub"))
76
81
  FileSystem.destroyFileSystem(__method__)
77
82
  end
78
83
 
79
84
  def test_file_rename
80
85
  fs = FileSystem.getFileSystem(__method__)
81
- fs.create_dir("/pub")
86
+ assert(fs.set_permissions("/", "rwxrwxrwx", "root"))
87
+ assert(fs.create_dir("/pub"))
82
88
  assert(fs.exist?("/pub"))
83
- assert(fs.is_dir("/pub"))
84
- refute(fs.is_file("/pub"))
89
+ assert(fs.is_dir?("/pub"))
90
+ refute(fs.is_file?("/pub"))
85
91
 
86
- fs.create_file("/pub/helper.rb", "test/helper.rb")
92
+ assert(fs.create_file("/pub/helper.rb", "test/helper.rb"))
87
93
  assert(fs.exist?("/pub/helper.rb"))
88
94
  assert_equal(169, fs.file_size("/pub/helper.rb"))
89
- fs.rename("/pub/helper.rb", "/pub/helper.txt")
95
+ assert(fs.rename("/pub/helper.rb", "/pub/helper.txt"))
90
96
  refute(fs.exist?("/pub/helper.rb"))
91
97
  assert(fs.exist?("/pub/helper.txt"))
92
98
  assert_equal(169, fs.file_size("/pub/helper.txt"))
@@ -96,19 +102,20 @@ class TestMemoryFilesystem < Minitest::Test
96
102
 
97
103
  def test_file_move_between_directories
98
104
  fs = FileSystem.getFileSystem(__method__)
99
- fs.create_dir("/pub")
105
+ assert(fs.set_permissions("/", "rwxrwxrwx", "root"))
106
+ assert(fs.create_dir("/pub"))
100
107
  assert(fs.exist?("/pub"))
101
- assert(fs.is_dir("/pub"))
102
- refute(fs.is_file("/pub"))
103
- fs.create_dir("/pub2")
108
+ assert(fs.is_dir?("/pub"))
109
+ refute(fs.is_file?("/pub"))
110
+ assert(fs.create_dir("/pub2"))
104
111
  assert(fs.exist?("/pub2"))
105
- assert(fs.is_dir("/pub2"))
106
- refute(fs.is_file("/pub2"))
112
+ assert(fs.is_dir?("/pub2"))
113
+ refute(fs.is_file?("/pub2"))
107
114
 
108
- fs.create_file("/pub/helper.rb", "test/helper.rb")
115
+ assert(fs.create_file("/pub/helper.rb", "test/helper.rb"))
109
116
  assert(fs.exist?("/pub/helper.rb"))
110
117
  assert_equal(169, fs.file_size("/pub/helper.rb"))
111
- fs.rename("/pub/helper.rb", "/pub2/helper.txt")
118
+ assert(fs.rename("/pub/helper.rb", "/pub2/helper.txt"))
112
119
  refute(fs.exist?("/pub/helper.rb"))
113
120
  assert(fs.exist?("/pub2/helper.txt"))
114
121
  assert_equal(169, fs.file_size("/pub2/helper.txt"))
@@ -118,23 +125,24 @@ class TestMemoryFilesystem < Minitest::Test
118
125
 
119
126
  def test_rename_directory
120
127
  fs = FileSystem.getFileSystem(__method__)
121
- fs.create_dir("/pub")
128
+ assert(fs.set_permissions("/", "rwxrwxrwx", "root"))
129
+ assert(fs.create_dir("/pub"))
122
130
  assert(fs.exist?("/pub"))
123
- assert(fs.is_dir("/pub"))
124
- refute(fs.is_file("/pub"))
125
- fs.create_dir("/pub2")
131
+ assert(fs.is_dir?("/pub"))
132
+ refute(fs.is_file?("/pub"))
133
+ assert(fs.create_dir("/pub2", "root"))
126
134
  assert(fs.exist?("/pub2"))
127
- assert(fs.is_dir("/pub2"))
128
- refute(fs.is_file("/pub2"))
129
- fs.create_file("/pub3", "test/helper.rb")
135
+ assert(fs.is_dir?("/pub2"))
136
+ refute(fs.is_file?("/pub2"))
137
+ assert(fs.create_file("/pub3", "test/helper.rb"))
130
138
  assert(fs.exist?("/pub3"))
131
- refute(fs.is_dir("/pub3"))
132
- assert(fs.is_file("/pub3"))
139
+ refute(fs.is_dir?("/pub3"))
140
+ assert(fs.is_file?("/pub3"))
133
141
  assert_equal(169, fs.file_size("/pub3"))
134
142
 
135
143
  refute(fs.rename("/pub", "/pub2"))
136
144
  refute(fs.rename("/pub", "/pub3"))
137
- assert(fs.delete_file("/pub3"))
145
+ assert(fs.delete_file("/pub3", "root"))
138
146
  assert(fs.rename("/pub", "/pub3"))
139
147
 
140
148
  FileSystem.destroyFileSystem(__method__)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-ftpd-memory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-ftpd