s3 0.3.25 → 0.3.26

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,31 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.25
4
+ version: 0.3.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Kuźma
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-19 00:00:00.000000000 Z
11
+ date: 2018-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: proxies
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.0
20
- type: :runtime
19
+ version: '1.16'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.0
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: test-unit
56
+ name: mocha
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,13 +67,13 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: mocha
70
+ name: addressable
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
- type: :development
76
+ type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
@@ -67,21 +81,20 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: bundler
84
+ name: proxies
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
- type: :development
90
+ type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
- description: 'S3 library provides access to Amazon''s Simple Storage Service. It supports
84
- both: European and US buckets through REST API.'
97
+ description: S3 library provides access to Amazon's Simple Storage Service.
85
98
  email:
86
99
  - kuba@jah.pl
87
100
  executables: []
@@ -90,11 +103,14 @@ extra_rdoc_files: []
90
103
  files:
91
104
  - ".gitignore"
92
105
  - ".travis.yml"
106
+ - CODE_OF_CONDUCT.md
93
107
  - Gemfile
94
108
  - Gemfile.lock
95
- - LICENSE
109
+ - LICENSE.txt
96
110
  - README.rdoc
97
111
  - Rakefile
112
+ - bin/console
113
+ - bin/setup
98
114
  - lib/s3.rb
99
115
  - lib/s3/bucket.rb
100
116
  - lib/s3/buckets_extension.rb
@@ -108,12 +124,6 @@ files:
108
124
  - lib/s3/signature.rb
109
125
  - lib/s3/version.rb
110
126
  - s3.gemspec
111
- - test/bucket_test.rb
112
- - test/connection_test.rb
113
- - test/object_test.rb
114
- - test/service_test.rb
115
- - test/signature_test.rb
116
- - test/test_helper.rb
117
127
  homepage: http://github.com/qoobaa/s3
118
128
  licenses:
119
129
  - MIT
@@ -131,10 +141,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
141
  requirements:
132
142
  - - ">="
133
143
  - !ruby/object:Gem::Version
134
- version: 1.3.6
144
+ version: '0'
135
145
  requirements: []
136
- rubyforge_project: s3
137
- rubygems_version: 2.5.1
146
+ rubyforge_project:
147
+ rubygems_version: 2.7.3
138
148
  signing_key:
139
149
  specification_version: 4
140
150
  summary: Library for accessing S3 objects and buckets
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Jakub Kuźma, Mirosław Boruta
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,245 +0,0 @@
1
- require "test_helper"
2
-
3
- class BucketTest < Test::Unit::TestCase
4
- def setup
5
- @bucket_vhost = S3::Bucket.send(:new, S3::Service.new(access_key_id: 'test', secret_access_key: 'secret'), "Data-Bucket")
6
- @bucket_path = S3::Bucket.send(:new, S3::Service.new(access_key_id: 'test', secret_access_key: 'secret', use_vhost: false), "Data_Bucket")
7
- @secure_bucket = S3::Bucket.send(:new, S3::Service.new(access_key_id: 'test', secret_access_key: 'secret', use_ssl: true), "Data-Secured")
8
- @bucket = @bucket_vhost
9
-
10
- @bucket_location = "EU"
11
- @bucket_location_body = <<-EOLocation
12
- <?xml version="1.0" encoding="UTF-8"?>\n<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/">EU</LocationConstraint>
13
- EOLocation
14
-
15
- @response_location = Net::HTTPOK.new("1.1", "200", "OK")
16
- @response_location.stubs(:body).returns(@bucket_location_body)
17
-
18
- @bucket_owned_by_you_body = <<-EOOwnedByYou
19
- <?xml version="1.0" encoding="UTF-8"?>\n<Error> <Code>BucketAlreadyOwnedByYou</Code> <Message>Your previous request to create the named bucket succeeded and you already own it.</Message> <BucketName>bucket</BucketName> <RequestId>117D08EA0EC6E860</RequestId> <HostId>4VpMSvmJ+G5+DLtVox6O5cZNgdPlYcjCu3l0n4HjDe01vPxxuk5eTAtcAkUynRyV</HostId> </Error>
20
- EOOwnedByYou
21
-
22
- @response_owned_by_you = Net::HTTPConflict.new("1.1", "409", "Conflict")
23
- @response_owned_by_you.stubs(:body).returns(@bucket_owned_by_you_body)
24
-
25
- @bucket_already_exists_body = <<-EOAlreadyExists
26
- <?xml version="1.0" encoding="UTF-8"?>\n<Error> <Code>BucketAlreadyExists</Code> <Message>The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.</Message> <BucketName>bucket</BucketName> <RequestId>4C154D32807C92BD</RequestId> <HostId>/xyHQgXcUXTZQhoO+NUBzbaxbFrIhKlyuaRHFnmcId0bMePvY9Zwg+dyk2LYE4g5</HostId> </Error>
27
- EOAlreadyExists
28
-
29
- @response_already_exists = Net::HTTPConflict.new("1.1", "409", "Conflict")
30
- @response_already_exists.stubs(:body).returns(@bucket_already_exists_body)
31
-
32
- @objects_list_empty = []
33
- @objects_list = [
34
- S3::Object.send(:new, @bucket, :key => "obj1"),
35
- S3::Object.send(:new, @bucket, :key => "obj2"),
36
- S3::Object.send(:new, @bucket, :key => "prefix/"),
37
- S3::Object.send(:new, @bucket, :key => "prefix/obj3")
38
- ]
39
-
40
- @objects_list_prefix = [
41
- S3::Object.send(:new, @bucket, :key => "prefix/"),
42
- S3::Object.send(:new, @bucket, :key => "prefix/obj3")
43
- ]
44
-
45
- @response_objects_list_empty_body = <<-EOEmpty
46
- <?xml version="1.0" encoding="UTF-8"?>\n<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Name>bucket</Name> <Prefix></Prefix> <Marker></Marker> <MaxKeys>1000</MaxKeys> <IsTruncated>false</IsTruncated> </ListBucketResult>
47
- EOEmpty
48
-
49
- @response_objects_list_empty = Net::HTTPOK.new("1.1", "200", "OK")
50
- @response_objects_list_empty.stubs(:body).returns(@response_objects_list_empty_body)
51
-
52
- @response_objects_list_body = <<-EOObjects
53
- <?xml version="1.0" encoding="UTF-8"?>\n<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Name>bucket</Name> <Prefix></Prefix> <Marker></Marker> <MaxKeys>1000</MaxKeys> <IsTruncated>false</IsTruncated> <Contents> <Key>obj1</Key> <LastModified>2009-07-03T10:17:33.000Z</LastModified> <ETag>&quot;99519cdf14c255e580e1b7bca85a458c&quot;</ETag> <Size>1729</Size> <Owner> <ID>df864aeb6f42be43f1d9e60aaabe3f15e245b035a4b79d1cfe36c4deaec67205</ID> <DisplayName>owner</DisplayName> </Owner> <StorageClass>STANDARD</StorageClass> </Contents> <Contents> <Key>obj2</Key> <LastModified>2009-07-03T11:17:33.000Z</LastModified> <ETag>&quot;99519cdf14c255e586e1b12bca85a458c&quot;</ETag> <Size>179</Size> <Owner> <ID>df864aeb6f42be43f1d9e60aaabe3f17e247b037a4b79d1cfe36c4deaec67205</ID> <DisplayName>owner</DisplayName> </Owner> <StorageClass>STANDARD</StorageClass> </Contents> <Contents> <Key>prefix/</Key> <LastModified>2009-07-03T10:17:33.000Z</LastModified> <ETag>&quot;99519cdf14c255e580e1b7bca85a458c&quot;</ETag> <Size>1729</Size> <Owner> <ID>df864aeb6f42be43f1d9e60aaabe3f15e245b035a4b79d1cfe36c4deaec67205</ID> <DisplayName>owner</DisplayName> </Owner> <StorageClass>STANDARD</StorageClass> </Contents> <Contents> <Key>prefix/obj3</Key> <LastModified>2009-07-03T10:17:33.000Z</LastModified> <ETag>&quot;99519cdf14c255e580e1b7bca85a458c&quot;</ETag> <Size>1729</Size> <Owner> <ID>df864aeb6f42be43f1d9e60aaabe3f15e245b035a4b79d1cfe36c4deaec67205</ID> <DisplayName>owner</DisplayName> </Owner> <StorageClass>STANDARD</StorageClass> </Contents> </ListBucketResult>
54
- EOObjects
55
-
56
- @response_objects_list = Net::HTTPOK.new("1.1", "200", "OK")
57
- @response_objects_list.stubs(:body).returns(@response_objects_list_body)
58
-
59
- @response_objects_list_body_prefix = <<-EOObjectsPrefix
60
- <?xml version="1.0" encoding="UTF-8"?>\n<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Name>bucket</Name> <Prefix>prefix</Prefix> <Marker></Marker> <MaxKeys>1000</MaxKeys> <IsTruncated>false</IsTruncated> <Contents> <Key>prefix/</Key> <LastModified>2009-07-03T10:17:33.000Z</LastModified> <ETag>&quot;99519cdf14c255e580e1b7bca85a458c&quot;</ETag> <Size>1729</Size> <Owner> <ID>df864aeb6f42be43f1d9e60aaabe3f15e245b035a4b79d1cfe36c4deaec67205</ID> <DisplayName>owner</DisplayName> </Owner> <StorageClass>STANDARD</StorageClass> </Contents> <Contents> <Key>prefix/obj3</Key> <LastModified>2009-07-03T10:17:33.000Z</LastModified> <ETag>&quot;99519cdf14c255e580e1b7bca85a458c&quot;</ETag> <Size>1729</Size> <Owner> <ID>df864aeb6f42be43f1d9e60aaabe3f15e245b035a4b79d1cfe36c4deaec67205</ID> <DisplayName>owner</DisplayName> </Owner> <StorageClass>STANDARD</StorageClass> </Contents> </ListBucketResult>
61
- EOObjectsPrefix
62
-
63
-
64
- @response_objects_list_prefix = Net::HTTPOK.new("1.1", "200", "OK")
65
- @response_objects_list_prefix.stubs(:body).returns(@response_objects_list_body_prefix)
66
- end
67
-
68
- test "name valid" do
69
- assert_raise ArgumentError do S3::Bucket.send(:new, nil, "") end # should not be valid with empty name
70
- assert_raise ArgumentError do S3::Bucket.send(:new, nil, "10.0.0.1") end # should not be valid with IP as name
71
- assert_raise ArgumentError do S3::Bucket.send(:new, nil, "as") end # should not be valid with name shorter than 3 characters
72
- assert_raise ArgumentError do S3::Bucket.send(:new, nil, "a" * 256) end # should not be valid with name longer than 255 characters
73
- assert_raise ArgumentError do S3::Bucket.send(:new, nil, ".asdf") end # should not allow special characters as first character
74
- assert_raise ArgumentError do S3::Bucket.send(:new, nil, "-asdf") end # should not allow special characters as first character
75
- assert_raise ArgumentError do S3::Bucket.send(:new, nil, "_asdf") end # should not allow special characters as first character
76
-
77
- assert_nothing_raised do
78
- S3::Bucket.send(:new, nil, "a-a-")
79
- S3::Bucket.send(:new, nil, "a.a.")
80
- S3::Bucket.send(:new, nil, "a_a_")
81
- end
82
- end
83
-
84
- test "path prefix" do
85
- expected = ""
86
- actual = @bucket_vhost.path_prefix
87
- assert_equal expected, actual
88
-
89
- expected = "Data_Bucket/"
90
- actual = @bucket_path.path_prefix
91
- assert_equal expected, actual
92
- end
93
-
94
- test "host" do
95
- expected = "Data-Bucket.s3.amazonaws.com"
96
- actual = @bucket_vhost.host
97
- assert_equal expected, actual
98
-
99
- expected = "s3.amazonaws.com"
100
- actual = @bucket_path.host
101
- assert_equal expected, actual
102
-
103
- expected = "s3.amazonaws.com"
104
- actual = @secure_bucket.host
105
- assert_equal expected, actual
106
- end
107
-
108
- test "vhost" do
109
- assert @bucket_vhost.vhost?
110
- assert ! @bucket_path.vhost?
111
- end
112
-
113
- test "exists" do
114
- @bucket.expects(:retrieve).returns(@bucket_vhost)
115
- assert @bucket.exists?
116
-
117
- @bucket.expects(:retrieve).raises(S3::Error::NoSuchBucket.new(nil, nil))
118
- assert ! @bucket.exists?
119
- end
120
-
121
- test "location and parse location" do
122
- @bucket.expects(:bucket_request).with(:get, { :params => { :location => nil } }).returns(@response_location)
123
-
124
- expected = @bucket_location
125
- actual = @bucket.location
126
- assert_equal expected, actual
127
-
128
- @bucket.stubs(:bucket_request).with(:get, { :params => { :location => nil } })
129
- actual = @bucket.location
130
- assert_equal expected, actual
131
- end
132
-
133
- test "save" do
134
- @bucket.expects(:bucket_request).with(:put, { :headers => {} })
135
- assert @bucket.save
136
- # mock ensures that bucket_request was called
137
- end
138
-
139
- test "save failure owned by you" do
140
- @bucket.expects(:bucket_request).with(:put, { :headers => {} }).raises(S3::Error::BucketAlreadyOwnedByYou.new(409, @response_owned_by_you))
141
- assert_raise S3::Error::BucketAlreadyOwnedByYou do
142
- @bucket.save
143
- end
144
-
145
- @bucket.expects(:bucket_request).with(:put, { :headers => {} }).raises(S3::Error::BucketAlreadyExists.new(409, @response_already_exists))
146
- assert_raise S3::Error::BucketAlreadyExists do
147
- @bucket.save
148
- end
149
- end
150
-
151
- test "objects" do
152
- @bucket.expects(:list_bucket).returns(@objects_list_empty)
153
- expected = @objects_list_empty
154
- actual = @bucket.objects
155
- assert_equal expected, actual
156
-
157
- @bucket.stubs(:list_bucket).returns(@objects_list_empty)
158
- actual = @bucket.objects
159
- assert_equal expected, actual
160
-
161
- @bucket.stubs(:list_bucket).returns(@objects_list)
162
-
163
- expected = @objects_list
164
- actual = @bucket.objects
165
- assert_equal expected, actual
166
-
167
- @bucket.stubs(:list_bucket).with(:prefix=>'prefix').returns(@objects_list_prefix)
168
- expected = @objects_list_prefix
169
- actual = @bucket.objects(:prefix => 'prefix')
170
- assert_equal expected, actual
171
- end
172
-
173
- test "list bucket and parse objects" do
174
- @bucket.expects(:bucket_request).with(:get, :params => { :test=>true }).returns(@response_objects_list_empty)
175
- expected = @objects_list_empty
176
- actual = @bucket.objects.find_all(:test => true)
177
- assert_equal expected, actual
178
-
179
- @bucket.expects(:bucket_request).with(:get, :params => { :test => true }).returns(@response_objects_list)
180
- expected = @objects_list
181
- actual = @bucket.objects.find_all(:test => true)
182
- assert_equal expected, actual
183
-
184
- @bucket.expects(:bucket_request).with(:get, :params => { :test => true }).returns(@response_objects_list_prefix)
185
- expected = @objects_list_prefix
186
- actual = @bucket.objects(:prefix => "prefix").find_all(:test => true)
187
- assert_equal expected, actual
188
- end
189
-
190
- test "destroy" do
191
- @bucket.expects(:bucket_request).with(:delete)
192
- assert @bucket.destroy
193
- end
194
-
195
- test "objects build" do
196
- @bucket.stubs(:bucket_request)
197
-
198
- expected = "object_name"
199
- actual = @bucket.objects.build("object_name")
200
- assert_kind_of S3::Object, actual
201
- assert_equal expected, actual.key
202
- end
203
-
204
- test "objects find first" do
205
- assert_nothing_raised do
206
- S3::Object.any_instance.stubs(:retrieve).returns(S3::Object.send(:new, nil, :key => "obj2"))
207
- expected = "obj2"
208
- actual = @bucket.objects.find_first("obj2")
209
- assert_equal "obj2", actual.key
210
- end
211
- end
212
-
213
- test "objects find first fail" do
214
- assert_raise S3::Error::NoSuchKey do
215
- S3::Object.any_instance.stubs(:retrieve).raises(S3::Error::NoSuchKey.new(404, nil))
216
- @bucket.objects.find_first("obj3")
217
- end
218
- end
219
-
220
- test "objects find all on empty list" do
221
- @bucket.stubs(:list_bucket).returns(@objects_list_empty)
222
- assert_nothing_raised do
223
- expected = @objects_list_empty
224
- actual = @bucket.objects.find_all
225
- assert_equal expected, actual
226
- end
227
- end
228
-
229
- test "objects find all" do
230
- @bucket.stubs(:list_bucket).returns(@objects_list)
231
- assert_nothing_raised do
232
- expected = @objects_list
233
- actual = @bucket.objects.find_all
234
- assert_equal expected, actual
235
- end
236
- end
237
-
238
- test "objects destroy all" do
239
- @bucket.stubs(:list_bucket).returns(@objects_list)
240
- @bucket.objects.each do |obj|
241
- obj.expects(:destroy)
242
- end
243
- @bucket.objects.destroy_all
244
- end
245
- end
@@ -1,214 +0,0 @@
1
- require "test_helper"
2
-
3
- class ConnectionTest < Test::Unit::TestCase
4
- def setup
5
- @connection = S3::Connection.new(
6
- :access_key_id => "12345678901234567890",
7
- :secret_access_key => "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDF"
8
- )
9
- @http_request = Net::HTTP.new("")
10
- @response_ok = Net::HTTPOK.new("1.1", "200", "OK")
11
- @response_not_found = Net::HTTPNotFound.new("1.1", "404", "Not Found")
12
- @response_error = Net::HTTPInternalServerError.new("1.1", "500", "Internal Server Error")
13
- @response_temporary_redirect = Net::HTTPInternalServerError.new("1.1", "307", "Temporary Redirect")
14
- @connection.stubs(:http).returns(@http_request)
15
-
16
- @http_request.stubs(:start).returns(@response_ok)
17
- end
18
-
19
- test "handle response not modify response when ok" do
20
- assert_nothing_raised do
21
- response = @connection.request(
22
- :get,
23
- :host => "s3.amazonaws.com",
24
- :path => "/"
25
- )
26
- assert_equal @response_ok, response
27
- end
28
- end
29
-
30
- test "handle response throws exception when error" do
31
- response_body = <<-EOFakeBody
32
- <?xml version=\"1.0\" encoding=\"UTF-8\"?>
33
- <Error>
34
- <Code>NoSuchBucket</Code>
35
- <Message>The specified bucket does not exist</Message>
36
- </Error>
37
- EOFakeBody
38
-
39
- @http_request.stubs(:start).returns(@response_not_found)
40
- @response_not_found.stubs(:body).returns(response_body)
41
-
42
- assert_raise S3::Error::NoSuchBucket do
43
- response = @connection.request(
44
- :get,
45
- :host => "data.example.com.s3.amazonaws.com",
46
- :path => "/"
47
- )
48
- end
49
- end
50
-
51
- test "handle response throws standard exception when error" do
52
- @http_request.stubs(:start).returns(@response_error)
53
- @response_error.stubs(:body)
54
- assert_raise S3::Error::ResponseError do
55
- response = @connection.request(
56
- :get,
57
- :host => "data.example.com.s3.amazonaws.com",
58
- :path => "/"
59
- )
60
- end
61
-
62
- @response_error.stubs(:body).returns("")
63
- assert_raise S3::Error::ResponseError do
64
- response = @connection.request(
65
- :get,
66
- :host => "data.example.com.s3.amazonaws.com",
67
- :path => "/"
68
- )
69
- end
70
- end
71
-
72
- test "parse params empty" do
73
- expected = ""
74
- actual = S3::Connection.parse_params({})
75
- assert_equal expected, actual
76
- end
77
-
78
- test "parse params only interesting params" do
79
- expected = ""
80
- actual = S3::Connection.parse_params(:param1 => "1", :maxkeys => "2")
81
- assert_equal expected, actual
82
- end
83
-
84
- test "parse params remove underscore" do
85
- expected = "max-keys=100"
86
- actual = S3::Connection.parse_params(:max_keys => 100)
87
- assert_equal expected, actual
88
- end
89
-
90
- test "parse params with and without values" do
91
- params = S3::Connection.parse_params(:max_keys => 100, :prefix => nil)
92
-
93
- splitted_params = params.split("&")
94
- assert_equal 2, splitted_params.length
95
- assert splitted_params.include?("max-keys=100")
96
- assert splitted_params.include?("prefix")
97
- end
98
-
99
- test "headers empty" do
100
- expected = {}
101
- actual = S3::Connection.parse_headers({})
102
- assert_equal expected, actual
103
- end
104
-
105
- test "parse only interesting headers" do
106
- expected = {}
107
- actual = S3::Connection.parse_headers(
108
- :accept => "text/*, text/html, text/html;level=1, */*",
109
- :accept_charset => "iso-8859-2, unicode-1-1;q=0.8"
110
- )
111
- assert_equal expected, actual
112
- end
113
-
114
- test "parse headers remove underscore" do
115
- expected = {
116
- "content-type" => nil,
117
- "x-amz-acl" => nil,
118
- "x-amz-storage-class" => nil,
119
- "if-modified-since" => nil,
120
- "if-unmodified-since" => nil,
121
- "if-match" => nil,
122
- "if-none-match" => nil,
123
- "content-disposition" => nil,
124
- "content-encoding" => nil
125
- }
126
- actual = S3::Connection.parse_headers(
127
- :content_type => nil,
128
- :x_amz_acl => nil,
129
- :x_amz_storage_class => nil,
130
- :if_modified_since => nil,
131
- :if_unmodified_since => nil,
132
- :if_match => nil,
133
- :if_none_match => nil,
134
- :content_disposition => nil,
135
- :content_encoding => nil
136
- )
137
- assert_equal expected, actual
138
- end
139
-
140
- test "parse headers with values" do
141
- expected = {
142
- "content-type" => "text/html",
143
- "x-amz-acl" => "public-read",
144
- "x-amz-storage-class" => "STANDARD",
145
- "if-modified-since" => "today",
146
- "if-unmodified-since" => "tomorrow",
147
- "if-match" => "1234",
148
- "if-none-match" => "1243",
149
- "content-disposition" => "inline",
150
- "content-encoding" => "gzip"
151
- }
152
- actual = S3::Connection.parse_headers(
153
- :content_type => "text/html",
154
- :x_amz_acl => "public-read",
155
- :x_amz_storage_class => "STANDARD",
156
- :if_modified_since => "today",
157
- :if_unmodified_since => "tomorrow",
158
- :if_match => "1234",
159
- :if_none_match => "1243",
160
- :content_disposition => "inline",
161
- :content_encoding => "gzip"
162
- )
163
- assert_equal expected, actual
164
- end
165
-
166
- test "parse headers with range" do
167
- expected = {
168
- "range" => "bytes=0-100"
169
- }
170
- actual = S3::Connection.parse_headers(
171
- :range => 0..100
172
- )
173
- assert_equal expected, actual
174
- end
175
-
176
- test "response.body is nil on TemporaryRedirect" do
177
- @http_request.stubs(:start).returns(@response_temporary_redirect)
178
- @response_temporary_redirect.stubs(:body).returns(nil)
179
-
180
- assert_nothing_raised do
181
- response = @connection.request(
182
- :get,
183
- :host => "data.example.com.s3.amazonaws.com",
184
- :path => "/"
185
- )
186
- assert_equal nil, response
187
- end
188
- end
189
-
190
- test "response body with new host on TemporaryRedirect" do
191
- response_body = <<-EOFakeBody
192
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
193
- <Error>
194
- <Code>TemporaryRedirect</Code>
195
- <Message>Please re-send this request to the specified temporary endpoint. Continue to use the original request endpoint for future requests.</Message>
196
- <RequestId>24A0BB91158D470B</RequestId>
197
- <Bucket>data.example.com</Bucket>
198
- <HostId>DFcq9ktw5HvWZLduutz8fnVzqtXLwIZcAezc7mgyS7lJ2ux+RChY4qAJGa2fQDjV</HostId>
199
- <Endpoint>data.example.com.s3-external-3.amazonaws.com</Endpoint>
200
- </Error>"
201
- EOFakeBody
202
-
203
- @response_temporary_redirect.stubs(:body).returns(response_body)
204
-
205
- assert_nothing_raised do
206
- response = @connection.request(
207
- :get,
208
- :host => "data.example.com.s3.amazonaws.com",
209
- :path => "/"
210
- )
211
- assert_equal @response_ok, response
212
- end
213
- end
214
- end