kerryb-right_aws 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,87 @@
1
+ =begin
2
+ Copyright (c) 2007 RightScale, Inc.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ 'Software'), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ =end
23
+
24
+ # Stub extension/redefinition of RightHttpConnection for testing purposes.
25
+ require 'net/http'
26
+ require 'rubygems'
27
+ require 'right_http_connection'
28
+
29
+ module Net
30
+ class HTTPResponse
31
+ alias_method :real_body, :body
32
+ def setmsg(msg)
33
+ @mymsg = msg
34
+ end
35
+
36
+ def body
37
+ # defined?() helps us to get rid of a bunch of 'warnings'
38
+ (defined?(@mymsg) && @mymsg) ? @mymsg : real_body
39
+ end
40
+ end
41
+ end
42
+
43
+ module Rightscale
44
+
45
+ class HttpConnection
46
+ @@response_stack = []
47
+
48
+ alias_method :real_request, :request
49
+
50
+ def request(request_params, &block)
51
+ if(@@response_stack.length == 0)
52
+ return real_request(request_params, &block)
53
+ end
54
+
55
+ if(block)
56
+ # Do something special
57
+ else
58
+ next_response = HttpConnection::pop()
59
+ classname = Net::HTTPResponse::CODE_TO_OBJ["#{next_response[:code]}"]
60
+ response = classname.new("1.1", next_response[:code], next_response[:msg])
61
+ if(next_response[:msg])
62
+ response.setmsg(next_response[:msg])
63
+ end
64
+ response
65
+ end
66
+ end
67
+
68
+ def self.reset
69
+ @@response_stack = []
70
+ end
71
+
72
+ def self.push(code, msg=nil)
73
+ response = {:code => code, :msg => msg}
74
+ @@response_stack << response
75
+ end
76
+
77
+ def self.pop
78
+ @@response_stack.pop
79
+ end
80
+
81
+ def self.length
82
+ @@response_stack.length
83
+ end
84
+
85
+ end
86
+
87
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/right_aws'
@@ -0,0 +1,388 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestS3 < Test::Unit::TestCase
4
+
5
+ RIGHT_OBJECT_TEXT = 'Right test message'
6
+
7
+ def setup
8
+ @s3 = Rightscale::S3Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
9
+ @bucket = 'right_s3_awesome_test_bucket_00001'
10
+ @key1 = 'test/woohoo1/'
11
+ @key2 = 'test1/key/woohoo2'
12
+ @key3 = 'test2/A%B@C_D&E?F+G=H"I'
13
+ @key1_copy = 'test/woohoo1_2'
14
+ @key1_new_name = 'test/woohoo1_3'
15
+ @key2_new_name = 'test1/key/woohoo2_new'
16
+ @s = Rightscale::S3.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
17
+ end
18
+
19
+ #---------------------------
20
+ # Rightscale::S3Interface
21
+ #---------------------------
22
+
23
+ def test_01_create_bucket
24
+ assert @s3.create_bucket(@bucket), 'Create_bucket fail'
25
+ end
26
+
27
+ def test_02_list_all_my_buckets
28
+ assert @s3.list_all_my_buckets.map{|bucket| bucket[:name]}.include?(@bucket), "#{@bucket} must exist in bucket list"
29
+ end
30
+
31
+ def test_03_list_empty_bucket
32
+ assert_equal 0, @s3.list_bucket(@bucket).size, "#{@bucket} isn't empty, arrgh!"
33
+ end
34
+
35
+ def test_04_put
36
+ assert @s3.put(@bucket, @key1, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo1!'), 'Put bucket fail'
37
+ assert @s3.put(@bucket, @key2, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo2!'), 'Put bucket fail'
38
+ assert @s3.put(@bucket, @key3, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo3!'), 'Put bucket fail'
39
+ end
40
+
41
+ def test_05_get_and_get_object
42
+ assert_raise(Rightscale::AwsError) { @s3.get(@bucket, 'undefined/key') }
43
+ data1 = @s3.get(@bucket, @key1)
44
+ assert_equal RIGHT_OBJECT_TEXT, data1[:object], "Object text must be equal to '#{RIGHT_OBJECT_TEXT}'"
45
+ assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key1), "Get_object text must return '#{RIGHT_OBJECT_TEXT}'"
46
+ assert_equal 'Woohoo1!', data1[:headers]['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
47
+ assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key3), "Get_object text must return '#{RIGHT_OBJECT_TEXT}'"
48
+ end
49
+
50
+ def test_06_head
51
+ assert_equal 'Woohoo1!', @s3.head(@bucket,@key1)['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
52
+ end
53
+
54
+
55
+ def test_07_streaming_get
56
+ resp = String.new
57
+ assert_raise(Rightscale::AwsError) do
58
+ @s3.get(@bucket, 'undefined/key') do |chunk|
59
+ resp += chunk
60
+ end
61
+ end
62
+
63
+ resp = String.new
64
+ data1 = @s3.get(@bucket, @key1) do |chunk|
65
+ resp += chunk
66
+ end
67
+ assert_equal RIGHT_OBJECT_TEXT, resp, "Object text must be equal to '#{RIGHT_OBJECT_TEXT}'"
68
+ assert_equal @s3.get_object(@bucket, @key1), resp, "Streaming iface must return same as non-streaming"
69
+ assert_equal 'Woohoo1!', data1[:headers]['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
70
+ end
71
+
72
+ def test_08_keys
73
+ keys = @s3.list_bucket(@bucket).map{|b| b[:key]}
74
+ assert_equal keys.size, 3, "There should be 3 keys"
75
+ assert(keys.include? @key1)
76
+ assert(keys.include? @key2)
77
+ assert(keys.include? @key3)
78
+ end
79
+
80
+ def test_09_copy_key
81
+ #--- test COPY
82
+ # copy a key
83
+ assert @s3.copy(@bucket, @key1, @bucket, @key1_copy)
84
+ # check it was copied well
85
+ assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key1_copy), "copied object must have the same data"
86
+ # check meta-headers were copied
87
+ headers = @s3.head(@bucket, @key1_copy)
88
+ assert_equal 'Woohoo1!', headers['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
89
+ #--- test REPLACE
90
+ assert @s3.copy(@bucket, @key1, @bucket, @key1_copy, :replace, 'x-amz-meta-family' => 'oooops!')
91
+ # check it was copied well
92
+ assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key1_copy), "copied object must have the same data"
93
+ # check meta-headers were overwrittenn
94
+ headers = @s3.head(@bucket, @key1_copy)
95
+ assert_equal 'oooops!', headers['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'oooops!'"
96
+ end
97
+
98
+ def test_10_move_key
99
+ # move a key
100
+ assert @s3.move(@bucket, @key1, @bucket, @key1_new_name)
101
+ # check it's data was moved correctly
102
+ assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key1_new_name), "moved object must have the same data"
103
+ # check meta-headers were moved
104
+ headers = @s3.head(@bucket, @key1_new_name)
105
+ assert_equal 'Woohoo1!', headers['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
106
+ # check the original key is not exists any more
107
+ keys = @s3.list_bucket(@bucket).map{|b| b[:key]}
108
+ assert(!keys.include?(@key1))
109
+ end
110
+
111
+ def test_11_rename_key
112
+ # rename a key
113
+ assert @s3.rename(@bucket, @key2, @key2_new_name)
114
+ # check the new key data
115
+ assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key2_new_name), "moved object must have the same data"
116
+ # check meta-headers
117
+ headers = @s3.head(@bucket, @key2_new_name)
118
+ assert_equal 'Woohoo2!', headers['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo2!'"
119
+ # check the original key is not exists any more
120
+ keys = @s3.list_bucket(@bucket).map{|b| b[:key]}
121
+ assert(!keys.include?(@key2))
122
+ end
123
+
124
+ def test_12_delete_folder
125
+ assert_equal 1, @s3.delete_folder(@bucket, 'test').size, "Only one key(#{@key1}) must be deleted!"
126
+ end
127
+
128
+ def test_13_delete_bucket
129
+ assert_raise(Rightscale::AwsError) { @s3.delete_bucket(@bucket) }
130
+ assert @s3.clear_bucket(@bucket), 'Clear_bucket fail'
131
+ assert_equal 0, @s3.list_bucket(@bucket).size, 'Bucket must be empty'
132
+ assert @s3.delete_bucket(@bucket)
133
+ assert !@s3.list_all_my_buckets.map{|bucket| bucket[:name]}.include?(@bucket), "#{@bucket} must not exist"
134
+ end
135
+
136
+ #---------------------------
137
+ # Rightscale::S3 classes
138
+ #---------------------------
139
+
140
+ def test_20_s3
141
+ # create bucket
142
+ bucket = @s.bucket(@bucket, true)
143
+ assert bucket
144
+ # check that the bucket exists
145
+ assert @s.buckets.map{|b| b.name}.include?(@bucket)
146
+ # delete bucket
147
+ assert bucket.clear
148
+ assert bucket.delete
149
+ end
150
+
151
+ def test_21_bucket_create_put_get_key
152
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, true)
153
+ # check that the bucket exists
154
+ assert @s.buckets.map{|b| b.name}.include?(@bucket)
155
+ assert bucket.keys.empty?
156
+ # put data
157
+ assert bucket.put(@key3, RIGHT_OBJECT_TEXT, {'family'=>'123456'})
158
+ # get data and compare
159
+ assert_equal RIGHT_OBJECT_TEXT, bucket.get(@key3)
160
+ # get key object
161
+ key = bucket.key(@key3, true)
162
+ assert_equal Rightscale::S3::Key, key.class
163
+ assert key.exists?
164
+ assert_equal '123456', key.meta_headers['family']
165
+ end
166
+
167
+ def test_22_keys
168
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
169
+ # create first key
170
+ key3 = Rightscale::S3::Key.create(bucket, @key3)
171
+ key3.refresh
172
+ assert key3.exists?
173
+ assert_equal '123456', key3.meta_headers['family']
174
+ # create second key
175
+ key2 = Rightscale::S3::Key.create(bucket, @key2)
176
+ assert !key2.refresh
177
+ assert !key2.exists?
178
+ assert_raise(Rightscale::AwsError) { key2.head }
179
+ # store key
180
+ key2.meta_headers = {'family'=>'111222333'}
181
+ assert key2.put(RIGHT_OBJECT_TEXT)
182
+ # make sure that the key exists
183
+ assert key2.refresh
184
+ assert key2.exists?
185
+ assert key2.head
186
+ # get its data
187
+ assert_equal RIGHT_OBJECT_TEXT, key2.get
188
+ # drop key
189
+ assert key2.delete
190
+ assert !key2.exists?
191
+ end
192
+
193
+ def test_23_rename_key
194
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
195
+ # -- 1 -- (key based rename)
196
+ # create a key
197
+ key = bucket.key('test/copy/1')
198
+ key.put(RIGHT_OBJECT_TEXT)
199
+ original_key = key.clone
200
+ assert key.exists?, "'test/copy/1' should exist"
201
+ # rename it
202
+ key.rename('test/copy/2')
203
+ assert_equal 'test/copy/2', key.name
204
+ assert key.exists?, "'test/copy/2' should exist"
205
+ # the original key should not exist
206
+ assert !original_key.exists?, "'test/copy/1' should not exist"
207
+ # -- 2 -- (bucket based rename)
208
+ bucket.rename_key('test/copy/2', 'test/copy/3')
209
+ assert bucket.key('test/copy/3').exists?, "'test/copy/3' should exist"
210
+ assert !bucket.key('test/copy/2').exists?, "'test/copy/2' should not exist"
211
+ end
212
+
213
+ def test_24_copy_key
214
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
215
+ # -- 1 -- (key based copy)
216
+ # create a key
217
+ key = bucket.key('test/copy/10')
218
+ key.put(RIGHT_OBJECT_TEXT)
219
+ # make copy
220
+ new_key = key.copy('test/copy/11')
221
+ # make sure both the keys exist and have a correct data
222
+ assert key.exists?, "'test/copy/10' should exist"
223
+ assert new_key.exists?, "'test/copy/11' should exist"
224
+ assert_equal RIGHT_OBJECT_TEXT, key.get
225
+ assert_equal RIGHT_OBJECT_TEXT, new_key.get
226
+ # -- 2 -- (bucket based copy)
227
+ bucket.copy_key('test/copy/11', 'test/copy/12')
228
+ assert bucket.key('test/copy/11').exists?, "'test/copy/11' should exist"
229
+ assert bucket.key('test/copy/12').exists?, "'test/copy/12' should exist"
230
+ assert_equal RIGHT_OBJECT_TEXT, bucket.key('test/copy/11').get
231
+ assert_equal RIGHT_OBJECT_TEXT, bucket.key('test/copy/12').get
232
+ end
233
+
234
+ def test_25_move_key
235
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
236
+ # -- 1 -- (key based copy)
237
+ # create a key
238
+ key = bucket.key('test/copy/20')
239
+ key.put(RIGHT_OBJECT_TEXT)
240
+ # move
241
+ new_key = key.move('test/copy/21')
242
+ # make sure both the keys exist and have a correct data
243
+ assert !key.exists?, "'test/copy/20' should not exist"
244
+ assert new_key.exists?, "'test/copy/21' should exist"
245
+ assert_equal RIGHT_OBJECT_TEXT, new_key.get
246
+ # -- 2 -- (bucket based copy)
247
+ bucket.copy_key('test/copy/21', 'test/copy/22')
248
+ assert bucket.key('test/copy/21').exists?, "'test/copy/21' should not exist"
249
+ assert bucket.key('test/copy/22').exists?, "'test/copy/22' should exist"
250
+ assert_equal RIGHT_OBJECT_TEXT, bucket.key('test/copy/22').get
251
+ end
252
+
253
+ def test_26_save_meta
254
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
255
+ # create a key
256
+ key = bucket.key('test/copy/30')
257
+ key.put(RIGHT_OBJECT_TEXT)
258
+ assert key.meta_headers.blank?
259
+ # store some meta keys
260
+ meta = {'family' => 'oops','race' => 'troll'}
261
+ assert_equal meta, key.save_meta(meta)
262
+ # reload meta
263
+ assert_equal meta, key.reload_meta
264
+ end
265
+
266
+ def test_27_clear_delete
267
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
268
+ # add another key
269
+ bucket.put(@key2, RIGHT_OBJECT_TEXT)
270
+ # delete 'folder'
271
+ assert_equal 1, bucket.delete_folder(@key1).size
272
+ # delete
273
+ assert_raise(Rightscale::AwsError) { bucket.delete }
274
+ bucket.delete(true)
275
+ end
276
+
277
+ # Grantees
278
+
279
+ def test_30_create_bucket
280
+ bucket = @s.bucket(@bucket, true, 'public-read')
281
+ assert bucket
282
+ end
283
+
284
+ def test_31_list_grantees
285
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
286
+ # get grantees list
287
+ grantees = bucket.grantees
288
+ # check that the grantees count equal to 2 (root, AllUsers)
289
+ assert_equal 2, grantees.size
290
+ end
291
+
292
+ def test_32_grant_revoke_drop
293
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
294
+ # Take 'AllUsers' grantee
295
+ grantee = Rightscale::S3::Grantee.new(bucket,'http://acs.amazonaws.com/groups/global/AllUsers')
296
+ # Check exists?
297
+ assert grantee.exists?
298
+ # Add grant as String
299
+ assert grantee.grant('WRITE')
300
+ # Add grants as Array
301
+ assert grantee.grant(['READ_ACP', 'WRITE_ACP'])
302
+ # Check perms count
303
+ assert_equal 4, grantee.perms.size
304
+ # revoke 'WRITE_ACP'
305
+ assert grantee.revoke('WRITE_ACP')
306
+ # Check manual perm removal method
307
+ grantee.perms -= ['READ_ACP']
308
+ grantee.apply
309
+ assert_equal 2, grantee.perms.size
310
+ # Check grantee removal if it has no permissions
311
+ assert grantee.perms = []
312
+ assert grantee.apply
313
+ assert !grantee.exists?
314
+ # Check multiple perms assignment
315
+ assert grantee.grant 'FULL_CONTROL', 'READ', 'WRITE'
316
+ assert_equal ['FULL_CONTROL','READ','WRITE'].sort, grantee.perms.sort
317
+ # Check multiple perms removal
318
+ assert grantee.revoke 'FULL_CONTROL', 'WRITE'
319
+ assert_equal ['READ'], grantee.perms
320
+ # check 'Drop' method
321
+ assert grantee.drop
322
+ assert !grantee.exists?
323
+ assert_equal 1, bucket.grantees.size
324
+ # Delete bucket
325
+ bucket.delete(true)
326
+ end
327
+
328
+ def test_33_key_grantees
329
+ # Create bucket
330
+ bucket = @s.bucket(@bucket, true)
331
+ # Create key
332
+ key = bucket.key(@key1)
333
+ assert key.put(RIGHT_OBJECT_TEXT, 'public-read')
334
+ # Get grantees list (must be == 2)
335
+ grantees = key.grantees
336
+ assert grantees
337
+ assert_equal 2, grantees.size
338
+ # Take one of grantees and give him 'Write' perms
339
+ grantee = grantees[0]
340
+ assert grantee.grant('WRITE')
341
+ # Drop grantee
342
+ assert grantee.drop
343
+ # Drop bucket
344
+ bucket.delete(true)
345
+ end
346
+
347
+ def test_34_bucket_create_put_with_perms
348
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, true)
349
+ # check that the bucket exists
350
+ assert @s.buckets.map{|b| b.name}.include?(@bucket)
351
+ assert bucket.keys.empty?
352
+ # put data (with canned ACL)
353
+ assert bucket.put(@key1, RIGHT_OBJECT_TEXT, {'family'=>'123456'}, "public-read")
354
+ # get data and compare
355
+ assert_equal RIGHT_OBJECT_TEXT, bucket.get(@key1)
356
+ # get key object
357
+ key = bucket.key(@key1, true)
358
+ assert_equal Rightscale::S3::Key, key.class
359
+ assert key.exists?
360
+ assert_equal '123456', key.meta_headers['family']
361
+ end
362
+
363
+ def test_35_key_put_with_perms
364
+ bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
365
+ # create first key
366
+ key1 = Rightscale::S3::Key.create(bucket, @key1)
367
+ key1.refresh
368
+ assert key1.exists?
369
+ assert key1.put(RIGHT_OBJECT_TEXT, "public-read")
370
+ # get its data
371
+ assert_equal RIGHT_OBJECT_TEXT, key1.get
372
+ # drop key
373
+ assert key1.delete
374
+ assert !key1.exists?
375
+ end
376
+
377
+ def test_36_set_amazon_problems
378
+ original_problems = RightAws::S3Interface.amazon_problems
379
+ assert(original_problems.length > 0)
380
+ RightAws::S3Interface.amazon_problems= original_problems << "A New Problem"
381
+ new_problems = RightAws::S3Interface.amazon_problems
382
+ assert_equal(new_problems, original_problems)
383
+
384
+ RightAws::S3Interface.amazon_problems= nil
385
+ assert_nil(RightAws::S3Interface.amazon_problems)
386
+ end
387
+
388
+ end
@@ -0,0 +1,95 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestS3Stubbed < Test::Unit::TestCase
4
+
5
+ RIGHT_OBJECT_TEXT = 'Right test message'
6
+
7
+ def setup
8
+ @s3 = Rightscale::S3Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
9
+ @bucket = 'right_s3_awesome_test_bucket'
10
+ @key1 = 'test/woohoo1'
11
+ @key2 = 'test1/key/woohoo2'
12
+ @s = Rightscale::S3.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
13
+ Rightscale::HttpConnection.reset
14
+ end
15
+
16
+ # Non-remote tests: these use the stub version of Rightscale::HTTPConnection
17
+ def test_101_create_bucket
18
+ Rightscale::HttpConnection.push(409, 'The named bucket you tried to create already exists')
19
+ Rightscale::HttpConnection.push(500, 'We encountered an internal error. Please try again.')
20
+ Rightscale::HttpConnection.push(500, 'We encountered an internal error. Please try again.')
21
+ assert_raise RightAws::AwsError do
22
+ @s3.create_bucket(@bucket)
23
+ end
24
+ end
25
+
26
+ def test_102_list_all_my_buckets_failure
27
+ Rightscale::HttpConnection.push(401, 'Unauthorized')
28
+ assert_raise RightAws::AwsError do
29
+ @s3.list_all_my_buckets
30
+ end
31
+ end
32
+
33
+ def test_103_list_empty_bucket
34
+ Rightscale::HttpConnection.push(403, 'Access Denied')
35
+ assert_raise RightAws::AwsError do
36
+ @s3.list_bucket(@bucket)
37
+ end
38
+ end
39
+
40
+ def test_104_put
41
+ Rightscale::HttpConnection.push(400, 'Your proposed upload exceeds the maximum allowed object size.')
42
+ Rightscale::HttpConnection.push(400, 'The Content-MD5 you specified was an invalid.')
43
+ Rightscale::HttpConnection.push(409, 'Please try again')
44
+ assert_raise RightAws::AwsError do
45
+ assert @s3.put(@bucket, @key1, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo1!'), 'Put bucket fail'
46
+ end
47
+ assert_raise RightAws::AwsError do
48
+ assert @s3.put(@bucket, @key2, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo2!'), 'Put bucket fail'
49
+ end
50
+ end
51
+
52
+ def test_105_get_and_get_object
53
+ Rightscale::HttpConnection.push(404, 'not found')
54
+ assert_raise(Rightscale::AwsError) { @s3.get(@bucket, 'undefined/key') }
55
+ end
56
+
57
+ def test_106_head
58
+ Rightscale::HttpConnection.push(404, 'Good Luck!')
59
+ assert_raise RightAws::AwsError do
60
+ @s3.head(@bucket,@key1)
61
+ end
62
+ end
63
+
64
+
65
+ def test_109_delete_bucket
66
+ Rightscale::HttpConnection.push(403, 'Good Luck!')
67
+ assert_raise(Rightscale::AwsError) { @s3.delete_bucket(@bucket) }
68
+ end
69
+
70
+ def test_115_copy_key
71
+
72
+ Rightscale::HttpConnection.push(500, 'not found')
73
+ #--- test COPY
74
+ # copy a key
75
+ assert_raise RightAws::AwsError do
76
+ @s3.copy(@bucket, @key1, @bucket, @key1_copy)
77
+ end
78
+
79
+ end
80
+
81
+ def test_116_move_key
82
+ # move a key
83
+ Rightscale::HttpConnection.push(413, 'not found')
84
+ assert @s3.move(@bucket, @key1, @bucket, @key1_new_name)
85
+
86
+ end
87
+
88
+ def test_117_rename_key
89
+ # rename a key
90
+ Rightscale::HttpConnection.push(500, 'not found')
91
+ assert @s3.rename(@bucket, @key2, @key2_new_name)
92
+
93
+ end
94
+
95
+ end