fakes3 0.1.6.1 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -1
- data/fakes3.gemspec +1 -1
- data/lib/fakes3/cli.rb +1 -1
- data/lib/fakes3/file_store.rb +0 -1
- data/lib/fakes3/server.rb +22 -2
- data/lib/fakes3/version.rb +1 -1
- data/test/aws_sdk_commands_test.rb +23 -0
- data/test/right_aws_commands_test.rb +40 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c929e6ff3d8522ac143785588c7fdc480d70ddde
|
4
|
+
data.tar.gz: 1c746e1eb8f08619a2a43cd8fddd8b3ce5287151
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a6199d155b318c48d28532aab032197bc5bb25cf73f4902dcb62c55898f75c5e8187c62da57cef0e4820d849558aa77b4b2ca6c21f9d65f3a566662f9af22c1
|
7
|
+
data.tar.gz: 3975513dbc9051c4fe1207261ff44efafef820d3c19e7e7fceaa7042e035a6da8bcdac83a7c87f90bb0194e95492e1a14c4647b4a39551512e923dba95440aa7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fakes3 (0.1.
|
4
|
+
fakes3 (0.1.7)
|
5
5
|
builder
|
6
6
|
thor
|
7
7
|
|
@@ -12,8 +12,15 @@ GEM
|
|
12
12
|
builder
|
13
13
|
mime-types
|
14
14
|
xml-simple
|
15
|
+
aws-sdk-v1 (1.59.0)
|
16
|
+
json (~> 1.4)
|
17
|
+
nokogiri (>= 1.4.4)
|
15
18
|
builder (3.2.2)
|
19
|
+
json (1.8.1)
|
16
20
|
mime-types (1.25)
|
21
|
+
mini_portile (0.6.1)
|
22
|
+
nokogiri (1.6.4.1)
|
23
|
+
mini_portile (~> 0.6.0)
|
17
24
|
rake (10.1.0)
|
18
25
|
rest-client (1.6.7)
|
19
26
|
mime-types (>= 1.16)
|
@@ -28,6 +35,7 @@ PLATFORMS
|
|
28
35
|
|
29
36
|
DEPENDENCIES
|
30
37
|
aws-s3
|
38
|
+
aws-sdk-v1
|
31
39
|
bundler (>= 1.0.0)
|
32
40
|
fakes3!
|
33
41
|
rake
|
data/fakes3.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_development_dependency "right_aws"
|
20
20
|
s.add_development_dependency "rest-client"
|
21
21
|
s.add_development_dependency "rake"
|
22
|
-
|
22
|
+
s.add_development_dependency "aws-sdk-v1"
|
23
23
|
#s.add_development_dependency "ruby-debug"
|
24
24
|
#s.add_development_dependency "debugger"
|
25
25
|
s.add_dependency "thor"
|
data/lib/fakes3/cli.rb
CHANGED
@@ -10,7 +10,7 @@ module FakeS3
|
|
10
10
|
method_option :root, :type => :string, :aliases => '-r', :required => true
|
11
11
|
method_option :port, :type => :numeric, :aliases => '-p', :required => true
|
12
12
|
method_option :address, :type => :string, :aliases => '-a', :required => false, :desc => "Bind to this address. Defaults to 0.0.0.0"
|
13
|
-
method_option :hostname, :type => :string, :aliases => '-
|
13
|
+
method_option :hostname, :type => :string, :aliases => '-H', :desc => "The root name of the host. Defaults to s3.amazonaws.com."
|
14
14
|
method_option :limit, :aliases => '-l', :type => :string, :desc => 'Rate limit for serving (ie. 50K, 1.0M)'
|
15
15
|
method_option :sslcert, :type => :string, :desc => 'Path to SSL certificate'
|
16
16
|
method_option :sslkey, :type => :string, :desc => 'Path to SSL certificate key'
|
data/lib/fakes3/file_store.rb
CHANGED
data/lib/fakes3/server.rb
CHANGED
@@ -90,6 +90,21 @@ module FakeS3
|
|
90
90
|
return
|
91
91
|
end
|
92
92
|
|
93
|
+
if_none_match = request["If-None-Match"]
|
94
|
+
if if_none_match == "\"#{real_obj.md5}\"" or if_none_match == "*"
|
95
|
+
response.status = 304
|
96
|
+
return
|
97
|
+
end
|
98
|
+
|
99
|
+
if_modified_since = request["If-Modified-Since"]
|
100
|
+
if if_modified_since
|
101
|
+
time = Time.httpdate(if_modified_since)
|
102
|
+
if time >= Time.iso8601(real_obj.modified_date)
|
103
|
+
response.status = 304
|
104
|
+
return
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
93
108
|
response.status = 200
|
94
109
|
response['Content-Type'] = real_obj.content_type
|
95
110
|
stat = File::Stat.new(real_obj.io.path)
|
@@ -98,6 +113,7 @@ module FakeS3
|
|
98
113
|
response.header['ETag'] = "\"#{real_obj.md5}\""
|
99
114
|
response['Accept-Ranges'] = "bytes"
|
100
115
|
response['Last-Ranges'] = "bytes"
|
116
|
+
response['Access-Control-Allow-Origin'] = '*'
|
101
117
|
|
102
118
|
real_obj.custom_metadata.each do |header, value|
|
103
119
|
response.header['x-amz-meta-' + header] = value
|
@@ -141,6 +157,7 @@ module FakeS3
|
|
141
157
|
response.status = 200
|
142
158
|
response.body = ""
|
143
159
|
response['Content-Type'] = "text/xml"
|
160
|
+
response['Access-Control-Allow-Origin'] = '*'
|
144
161
|
|
145
162
|
case s_req.type
|
146
163
|
when Request::COPY
|
@@ -197,7 +214,7 @@ module FakeS3
|
|
197
214
|
end
|
198
215
|
end
|
199
216
|
response['Content-Type'] = 'text/xml'
|
200
|
-
response['Access-Control-Allow-Origin']='*'
|
217
|
+
response['Access-Control-Allow-Origin'] = '*'
|
201
218
|
end
|
202
219
|
|
203
220
|
def do_DELETE(request,response)
|
@@ -217,7 +234,10 @@ module FakeS3
|
|
217
234
|
|
218
235
|
def do_OPTIONS(request, response)
|
219
236
|
super
|
220
|
-
response["Access-Control-Allow-Origin"]="*"
|
237
|
+
response["Access-Control-Allow-Origin"] = "*"
|
238
|
+
response["Access-Control-Allow-Methods"] = "HEAD, GET, PUT, POST"
|
239
|
+
response["Access-Control-Allow-Headers"] = "accept, content-type"
|
240
|
+
response["Access-Control-Expose-Headers"] = "ETag, x-amz-meta-custom-header"
|
221
241
|
end
|
222
242
|
|
223
243
|
private
|
data/lib/fakes3/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test/test_helper'
|
2
|
+
require 'aws-sdk-v1'
|
3
|
+
|
4
|
+
class AwsSdkCommandsTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@s3 = AWS::S3.new(:access_key_id => '123',
|
7
|
+
:secret_access_key => 'abc',
|
8
|
+
:s3_endpoint => 'localhost',
|
9
|
+
:s3_port => 10453,
|
10
|
+
:use_ssl => false)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_copy_to
|
14
|
+
bucket = @s3.buckets["test_copy_to"]
|
15
|
+
object = bucket.objects["key1"]
|
16
|
+
object.write("asdf")
|
17
|
+
|
18
|
+
assert object.exists?
|
19
|
+
object.copy_to("key2")
|
20
|
+
|
21
|
+
assert_equal 2, bucket.objects.count
|
22
|
+
end
|
23
|
+
end
|
@@ -2,6 +2,7 @@ require 'test/test_helper'
|
|
2
2
|
require 'fileutils'
|
3
3
|
#require 'fakes3/server'
|
4
4
|
require 'right_aws'
|
5
|
+
require 'time'
|
5
6
|
|
6
7
|
class RightAWSCommandsTest < Test::Unit::TestCase
|
7
8
|
|
@@ -117,4 +118,43 @@ class RightAWSCommandsTest < Test::Unit::TestCase
|
|
117
118
|
|
118
119
|
end
|
119
120
|
|
121
|
+
def test_if_none_match
|
122
|
+
@s3.put("s3media","if_none_match_test","Hello World 1!")
|
123
|
+
obj = @s3.get("s3media","if_none_match_test")
|
124
|
+
tag = obj[:headers]["etag"]
|
125
|
+
begin
|
126
|
+
@s3.get("s3media", "if_none_match_test", {"If-None-Match"=>tag})
|
127
|
+
rescue URI::InvalidURIError
|
128
|
+
# expected error for 304
|
129
|
+
else
|
130
|
+
fail 'Should have encountered an error due to the server not returning a response due to caching'
|
131
|
+
end
|
132
|
+
@s3.put("s3media","if_none_match_test","Hello World 2!")
|
133
|
+
obj = @s3.get("s3media", "if_none_match_test", {"If-None-Match"=>tag})
|
134
|
+
assert_equal "Hello World 2!",obj[:object]
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_if_modified_since
|
138
|
+
@s3.put("s3media","if_modified_since_test","Hello World 1!")
|
139
|
+
obj = @s3.get("s3media","if_modified_since_test")
|
140
|
+
modified = obj[:headers]["last-modified"]
|
141
|
+
begin
|
142
|
+
@s3.get("s3media", "if_modified_since_test", {"If-Modified-Since"=>modified})
|
143
|
+
rescue URI::InvalidURIError
|
144
|
+
# expected error for 304
|
145
|
+
else
|
146
|
+
fail 'Should have encountered an error due to the server not returning a response due to caching'
|
147
|
+
end
|
148
|
+
# Granularity of an HTTP Date is 1 second which isn't enough for the test
|
149
|
+
# so manually rewind the clock by a second
|
150
|
+
timeInThePast = Time.httpdate(modified) - 1
|
151
|
+
begin
|
152
|
+
obj = @s3.get("s3media", "if_modified_since_test", {"If-Modified-Since"=>timeInThePast.httpdate()})
|
153
|
+
rescue
|
154
|
+
fail 'Should have been downloaded since the date is in the past now'
|
155
|
+
else
|
156
|
+
#expected scenario
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
120
160
|
end
|
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: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Curtis Spencer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: aws-sdk-v1
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: thor
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,6 +152,7 @@ files:
|
|
138
152
|
- lib/fakes3/unsupported_operation.rb
|
139
153
|
- lib/fakes3/version.rb
|
140
154
|
- lib/fakes3/xml_adapter.rb
|
155
|
+
- test/aws_sdk_commands_test.rb
|
141
156
|
- test/boto_test.rb
|
142
157
|
- test/botocmd.py
|
143
158
|
- test/local_s3_cfg
|
@@ -172,6 +187,7 @@ specification_version: 4
|
|
172
187
|
summary: FakeS3 is a server that simulates S3 commands so you can test your S3 functionality
|
173
188
|
in your projects
|
174
189
|
test_files:
|
190
|
+
- test/aws_sdk_commands_test.rb
|
175
191
|
- test/boto_test.rb
|
176
192
|
- test/botocmd.py
|
177
193
|
- test/local_s3_cfg
|
@@ -180,3 +196,4 @@ test_files:
|
|
180
196
|
- test/s3_commands_test.rb
|
181
197
|
- test/s3cmd_test.rb
|
182
198
|
- test/test_helper.rb
|
199
|
+
has_rdoc:
|