fakes3 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/fakes3.gemspec +2 -2
- data/lib/fakes3/cli.rb +1 -1
- data/lib/fakes3/file_store.rb +19 -10
- data/lib/fakes3/server.rb +7 -2
- data/lib/fakes3/version.rb +1 -1
- data/test/post_test.rb +3 -3
- data/test/right_aws_commands_test.rb +16 -6
- data/test/s3_commands_test.rb +2 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ac47d99abf4623ccf2a5a740d3eaf13c399de93
|
4
|
+
data.tar.gz: fc625c2b3ef6c954b81ac3002477abd61fa0e378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78738e022fbdc49460e9abeb3f9b65c66ecf18de3d7f8b336aeb259f5e791c5653ce86200748e0c8d7d74f54ef33ed01d59880a7f6f07c25543bdfe0f183466f
|
7
|
+
data.tar.gz: 6f2e4df7a1d351315f59595a5c94605deebbc5346add671a47ef3503dda69533111cee1a8b662e639e529c23b9980267412fc63010423856ce2e4a4ffbcfc0a0
|
data/README.md
CHANGED
@@ -23,9 +23,9 @@ To run the server, you just specify a root and a port.
|
|
23
23
|
|
24
24
|
## Licensing
|
25
25
|
|
26
|
-
As of the latest version, we are licensing with
|
26
|
+
As of the latest version, we are licensing with Super Source. To get a license, visit:
|
27
27
|
|
28
|
-
https://
|
28
|
+
https://supso.org/projects/fake-s3
|
29
29
|
|
30
30
|
Depending on your company's size, the license may be free. It is also free for individuals.
|
31
31
|
|
data/fakes3.gemspec
CHANGED
@@ -6,12 +6,12 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.version = FakeS3::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Curtis Spencer"]
|
9
|
-
s.email = ["fakes3@
|
9
|
+
s.email = ["fakes3@supso.org"]
|
10
10
|
s.homepage = "https://github.com/jubos/fake-s3"
|
11
11
|
s.summary = %q{Fake S3 is a server that simulates Amazon S3 commands so you can test your S3 functionality in your projects}
|
12
12
|
s.description = %q{Use Fake S3 to test basic Amazon S3 functionality without actually connecting to AWS}
|
13
13
|
s.license = "Supported-Source"
|
14
|
-
s.post_install_message = "Fake S3: if you don't already have a license for Fake S3, you can get one at https://
|
14
|
+
s.post_install_message = "Fake S3: if you don't already have a license for Fake S3, you can get one at https://supso.org/projects/fake-s3"
|
15
15
|
|
16
16
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
17
17
|
s.add_development_dependency "aws-s3"
|
data/lib/fakes3/cli.rb
CHANGED
data/lib/fakes3/file_store.rb
CHANGED
@@ -16,10 +16,11 @@ module FakeS3
|
|
16
16
|
# sub second precision.
|
17
17
|
SUBSECOND_PRECISION = 3
|
18
18
|
|
19
|
-
def initialize(root)
|
19
|
+
def initialize(root, quiet_mode)
|
20
20
|
@root = root
|
21
21
|
@buckets = []
|
22
22
|
@bucket_hash = {}
|
23
|
+
@quiet_mode = quiet_mode
|
23
24
|
Dir[File.join(root,"*")].each do |bucket|
|
24
25
|
bucket_name = File.basename(bucket)
|
25
26
|
bucket_obj = Bucket.new(bucket_name,Time.now,[])
|
@@ -85,7 +86,7 @@ module FakeS3
|
|
85
86
|
real_obj.name = object_name
|
86
87
|
real_obj.md5 = metadata[:md5]
|
87
88
|
real_obj.content_type = metadata.fetch(:content_type) { "application/octet-stream" }
|
88
|
-
real_obj.content_encoding = metadata.fetch(:content_encoding)
|
89
|
+
real_obj.content_encoding = metadata.fetch(:content_encoding) # if metadata.fetch(:content_encoding)
|
89
90
|
real_obj.io = RateLimitableFile.open(File.join(obj_root, "content"), 'rb')
|
90
91
|
real_obj.size = metadata.fetch(:size) { 0 }
|
91
92
|
real_obj.creation_date = File.ctime(obj_root).utc.iso8601(SUBSECOND_PRECISION)
|
@@ -95,8 +96,10 @@ module FakeS3
|
|
95
96
|
real_obj.custom_metadata = metadata.fetch(:custom_metadata) { {} }
|
96
97
|
return real_obj
|
97
98
|
rescue
|
98
|
-
|
99
|
-
|
99
|
+
unless @quiet_mode
|
100
|
+
puts $!
|
101
|
+
$!.backtrace.each { |line| puts line }
|
102
|
+
end
|
100
103
|
return nil
|
101
104
|
end
|
102
105
|
end
|
@@ -135,7 +138,7 @@ module FakeS3
|
|
135
138
|
|
136
139
|
metadata_directive = request.header["x-amz-metadata-directive"].first
|
137
140
|
if metadata_directive == "REPLACE"
|
138
|
-
metadata_struct = create_metadata(content,request)
|
141
|
+
metadata_struct = create_metadata(content, request)
|
139
142
|
File.open(metadata,'w') do |f|
|
140
143
|
f << YAML::dump(metadata_struct)
|
141
144
|
end
|
@@ -148,7 +151,7 @@ module FakeS3
|
|
148
151
|
obj.name = dst_name
|
149
152
|
obj.md5 = src_metadata[:md5]
|
150
153
|
obj.content_type = src_metadata[:content_type]
|
151
|
-
obj.content_encoding = src_metadata[:content_encoding]
|
154
|
+
obj.content_encoding = src_metadata[:content_encoding] # if src_metadata[:content_encoding]
|
152
155
|
obj.size = src_metadata[:size]
|
153
156
|
obj.modified_date = src_metadata[:modified_date]
|
154
157
|
|
@@ -203,15 +206,17 @@ module FakeS3
|
|
203
206
|
obj.name = object_name
|
204
207
|
obj.md5 = metadata_struct[:md5]
|
205
208
|
obj.content_type = metadata_struct[:content_type]
|
206
|
-
obj.content_encoding = metadata_struct[:content_encoding]
|
209
|
+
obj.content_encoding = metadata_struct[:content_encoding] # if metadata_struct[:content_encoding]
|
207
210
|
obj.size = metadata_struct[:size]
|
208
211
|
obj.modified_date = metadata_struct[:modified_date]
|
209
212
|
|
210
213
|
bucket.add(obj)
|
211
214
|
return obj
|
212
215
|
rescue
|
213
|
-
|
214
|
-
|
216
|
+
unless @quiet_mode
|
217
|
+
puts $!
|
218
|
+
$!.backtrace.each { |line| puts line }
|
219
|
+
end
|
215
220
|
return nil
|
216
221
|
end
|
217
222
|
end
|
@@ -264,7 +269,11 @@ module FakeS3
|
|
264
269
|
metadata = {}
|
265
270
|
metadata[:md5] = Digest::MD5.file(content).hexdigest
|
266
271
|
metadata[:content_type] = request.header["content-type"].first
|
267
|
-
|
272
|
+
content_encoding = request.header["content-encoding"].first
|
273
|
+
metadata[:content_encoding] = content_encoding
|
274
|
+
#if content_encoding
|
275
|
+
# metadata[:content_encoding] = content_encoding
|
276
|
+
#end
|
268
277
|
metadata[:size] = File.size(content)
|
269
278
|
metadata[:modified_date] = File.mtime(content).utc.iso8601(SUBSECOND_PRECISION)
|
270
279
|
metadata[:amazon_metadata] = {}
|
data/lib/fakes3/server.rb
CHANGED
@@ -282,9 +282,14 @@ module FakeS3
|
|
282
282
|
response['Etag'] = "\"#{real_obj.md5}\""
|
283
283
|
|
284
284
|
if success_action_redirect
|
285
|
-
|
285
|
+
object_params = [ [ :bucket, s_req.bucket ], [ :key, key ] ]
|
286
|
+
location_uri = URI.parse(success_action_redirect)
|
287
|
+
original_location_params = URI.decode_www_form(String(location_uri.query))
|
288
|
+
location_uri.query = URI.encode_www_form(original_location_params + object_params)
|
289
|
+
|
290
|
+
response.status = 303
|
286
291
|
response.body = ""
|
287
|
-
response['Location'] =
|
292
|
+
response['Location'] = location_uri.to_s
|
288
293
|
else
|
289
294
|
response.status = success_action_status || 204
|
290
295
|
if response.status == "201"
|
data/lib/fakes3/version.rb
CHANGED
data/test/post_test.rb
CHANGED
@@ -24,11 +24,11 @@ class PostTest < Test::Unit::TestCase
|
|
24
24
|
res = RestClient.post(
|
25
25
|
@url,
|
26
26
|
'key'=>'uploads/12345/${filename}',
|
27
|
-
'success_action_redirect'=>'http://somewhere.else.com
|
27
|
+
'success_action_redirect'=>'http://somewhere.else.com/?foo=bar',
|
28
28
|
'file'=>File.new(__FILE__,"rb")
|
29
29
|
) { |response|
|
30
|
-
assert_equal(response.code,
|
31
|
-
assert_equal(response.headers[:location], 'http://somewhere.else.com
|
30
|
+
assert_equal(response.code, 303)
|
31
|
+
assert_equal(response.headers[:location], 'http://somewhere.else.com/?foo=bar&bucket=posttest&key=uploads%2F12345%2Fpost_test.rb')
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'test/test_helper'
|
2
2
|
require 'fileutils'
|
3
|
-
#require 'fakes3/server'
|
4
3
|
require 'right_aws'
|
5
4
|
require 'time'
|
6
5
|
|
@@ -22,13 +21,21 @@ class RightAWSCommandsTest < Test::Unit::TestCase
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def test_store
|
25
|
-
@s3.put("s3media","helloworld", "Hello World Man!")
|
24
|
+
@s3.put("s3media", "helloworld", "Hello World Man!")
|
26
25
|
obj = @s3.get("s3media", "helloworld")
|
27
26
|
assert_equal "Hello World Man!", obj[:object]
|
28
|
-
|
29
|
-
obj = @s3.get("s3media", "helloworld")
|
30
27
|
end
|
31
28
|
|
29
|
+
# TODO - get Chinese to work
|
30
|
+
#def test_store_chinese
|
31
|
+
# ni_hao = "你好"
|
32
|
+
# great_wall = "中国的长城"
|
33
|
+
#
|
34
|
+
# @s3.put("s3media", ni_hao, great_wall)
|
35
|
+
# obj = @s3.get("s3media", ni_hao)
|
36
|
+
# assert_equal(great_wall, obj[:object])
|
37
|
+
#end
|
38
|
+
|
32
39
|
def test_store_not_found
|
33
40
|
begin
|
34
41
|
obj = @s3.get("s3media", "helloworldnotexist")
|
@@ -47,13 +54,17 @@ class RightAWSCommandsTest < Test::Unit::TestCase
|
|
47
54
|
end
|
48
55
|
|
49
56
|
buf_len = buffer.length
|
57
|
+
time_before = Time.now
|
50
58
|
@s3.put("s3media", "big", buffer)
|
51
59
|
|
52
60
|
output = ""
|
53
61
|
@s3.get("s3media","big") do |chunk|
|
54
62
|
output << chunk
|
55
63
|
end
|
56
|
-
|
64
|
+
time_after = Time.now
|
65
|
+
|
66
|
+
assert(time_after - time_before < 2) # Should run in under 2 seconds on normal machines
|
67
|
+
assert_equal(buf_len, output.size)
|
57
68
|
end
|
58
69
|
|
59
70
|
# Test that GET requests with a delimiter return a list of
|
@@ -164,7 +175,6 @@ class RightAWSCommandsTest < Test::Unit::TestCase
|
|
164
175
|
rescue
|
165
176
|
fail 'Should have caught NoSuchBucket Exception'
|
166
177
|
end
|
167
|
-
|
168
178
|
end
|
169
179
|
|
170
180
|
def test_if_none_match
|
data/test/s3_commands_test.rb
CHANGED
@@ -41,10 +41,10 @@ class S3CommandsTest < Test::Unit::TestCase
|
|
41
41
|
|
42
42
|
def test_store
|
43
43
|
bucket = Bucket.create("ruby_aws_s3")
|
44
|
-
S3Object.store("hello","world","ruby_aws_s3")
|
44
|
+
S3Object.store("hello", "world", "ruby_aws_s3")
|
45
45
|
|
46
46
|
output = ""
|
47
|
-
obj = S3Object.stream("hello","ruby_aws_s3") do |chunk|
|
47
|
+
obj = S3Object.stream("hello", "ruby_aws_s3") do |chunk|
|
48
48
|
output << chunk
|
49
49
|
end
|
50
50
|
assert_equal "world", output
|
@@ -109,7 +109,6 @@ class S3CommandsTest < Test::Unit::TestCase
|
|
109
109
|
assert_equal "two, three", obj.metadata[:param2]
|
110
110
|
end
|
111
111
|
|
112
|
-
|
113
112
|
def test_multi_directory
|
114
113
|
bucket = Bucket.create("ruby_aws_s3")
|
115
114
|
S3Object.store("dir/myfile/123.txt","recursive","ruby_aws_s3")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakes3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Curtis Spencer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -167,7 +167,7 @@ dependencies:
|
|
167
167
|
description: Use Fake S3 to test basic Amazon S3 functionality without actually connecting
|
168
168
|
to AWS
|
169
169
|
email:
|
170
|
-
- fakes3@
|
170
|
+
- fakes3@supso.org
|
171
171
|
executables:
|
172
172
|
- fakes3
|
173
173
|
extensions: []
|
@@ -219,7 +219,7 @@ licenses:
|
|
219
219
|
- Supported-Source
|
220
220
|
metadata: {}
|
221
221
|
post_install_message: 'Fake S3: if you don''t already have a license for Fake S3,
|
222
|
-
you can get one at https://
|
222
|
+
you can get one at https://supso.org/projects/fake-s3'
|
223
223
|
rdoc_options: []
|
224
224
|
require_paths:
|
225
225
|
- lib
|
@@ -235,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
235
|
version: '0'
|
236
236
|
requirements: []
|
237
237
|
rubyforge_project:
|
238
|
-
rubygems_version: 2.6.
|
238
|
+
rubygems_version: 2.6.11
|
239
239
|
signing_key:
|
240
240
|
specification_version: 4
|
241
241
|
summary: Fake S3 is a server that simulates Amazon S3 commands so you can test your
|