le88-aws-s3 0.6.3.1310482014

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/COPYING +19 -0
  2. data/INSTALL +55 -0
  3. data/README +545 -0
  4. data/Rakefile +334 -0
  5. data/bin/s3sh +6 -0
  6. data/bin/setup.rb +10 -0
  7. data/lib/aws/s3/acl.rb +636 -0
  8. data/lib/aws/s3/authentication.rb +221 -0
  9. data/lib/aws/s3/base.rb +240 -0
  10. data/lib/aws/s3/bittorrent.rb +58 -0
  11. data/lib/aws/s3/bucket.rb +319 -0
  12. data/lib/aws/s3/connection.rb +278 -0
  13. data/lib/aws/s3/error.rb +69 -0
  14. data/lib/aws/s3/exceptions.rb +133 -0
  15. data/lib/aws/s3/extensions.rb +340 -0
  16. data/lib/aws/s3/logging.rb +314 -0
  17. data/lib/aws/s3/object.rb +612 -0
  18. data/lib/aws/s3/owner.rb +44 -0
  19. data/lib/aws/s3/parsing.rb +99 -0
  20. data/lib/aws/s3/response.rb +180 -0
  21. data/lib/aws/s3/service.rb +51 -0
  22. data/lib/aws/s3/version.rb +12 -0
  23. data/lib/aws/s3.rb +60 -0
  24. data/support/faster-xml-simple/lib/faster_xml_simple.rb +187 -0
  25. data/support/faster-xml-simple/test/regression_test.rb +47 -0
  26. data/support/faster-xml-simple/test/test_helper.rb +17 -0
  27. data/support/faster-xml-simple/test/xml_simple_comparison_test.rb +46 -0
  28. data/support/rdoc/code_info.rb +211 -0
  29. data/test/acl_test.rb +254 -0
  30. data/test/authentication_test.rb +114 -0
  31. data/test/base_test.rb +136 -0
  32. data/test/bucket_test.rb +74 -0
  33. data/test/connection_test.rb +215 -0
  34. data/test/error_test.rb +70 -0
  35. data/test/extensions_test.rb +340 -0
  36. data/test/fixtures/buckets.yml +133 -0
  37. data/test/fixtures/errors.yml +34 -0
  38. data/test/fixtures/headers.yml +3 -0
  39. data/test/fixtures/logging.yml +15 -0
  40. data/test/fixtures/loglines.yml +5 -0
  41. data/test/fixtures/logs.yml +7 -0
  42. data/test/fixtures/policies.yml +16 -0
  43. data/test/fixtures.rb +89 -0
  44. data/test/logging_test.rb +89 -0
  45. data/test/mocks/fake_response.rb +26 -0
  46. data/test/object_test.rb +205 -0
  47. data/test/parsing_test.rb +66 -0
  48. data/test/remote/acl_test.rb +117 -0
  49. data/test/remote/bittorrent_test.rb +45 -0
  50. data/test/remote/bucket_test.rb +146 -0
  51. data/test/remote/logging_test.rb +82 -0
  52. data/test/remote/object_test.rb +371 -0
  53. data/test/remote/test_file.data +0 -0
  54. data/test/remote/test_helper.rb +33 -0
  55. data/test/response_test.rb +68 -0
  56. data/test/service_test.rb +23 -0
  57. data/test/test_helper.rb +110 -0
  58. metadata +179 -0
@@ -0,0 +1,340 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class HashExtensionsTest < Test::Unit::TestCase
4
+ def test_to_query_string
5
+ # Because hashes aren't ordered, I'm mostly testing against hashes with just one key
6
+ symbol_keys = {:one => 1}
7
+ string_keys = {'one' => 1}
8
+ expected = '?one=1'
9
+ [symbol_keys, string_keys].each do |hash|
10
+ assert_equal expected, hash.to_query_string
11
+ end
12
+ end
13
+
14
+ def test_empty_hash_returns_no_query_string
15
+ assert_equal '', {}.to_query_string
16
+ end
17
+
18
+ def test_include_question_mark
19
+ hash = {:one => 1}
20
+ assert_equal '?one=1', hash.to_query_string
21
+ assert_equal 'one=1', hash.to_query_string(false)
22
+ end
23
+
24
+ def test_elements_joined_by_ampersand
25
+ hash = {:one => 1, :two => 2}
26
+ qs = hash.to_query_string
27
+ assert qs['one=1&two=2'] || qs['two=2&one=1']
28
+ end
29
+
30
+ def test_normalized_options
31
+ expectations = [
32
+ [{:foo_bar => 1}, {'foo-bar' => '1'}],
33
+ [{'foo_bar' => 1}, {'foo-bar' => '1'}],
34
+ [{'foo-bar' => 1}, {'foo-bar' => '1'}],
35
+ [{}, {}]
36
+ ]
37
+
38
+ expectations.each do |(before, after)|
39
+ assert_equal after, before.to_normalized_options
40
+ end
41
+ end
42
+ end
43
+
44
+ class StringExtensionsTest < Test::Unit::TestCase
45
+ def test_previous
46
+ expectations = {'abc' => 'abb', '123' => '122', '1' => '0'}
47
+ expectations.each do |before, after|
48
+ assert_equal after, before.previous
49
+ end
50
+ end
51
+
52
+ def test_to_header
53
+ transformations = {
54
+ 'foo' => 'foo',
55
+ :foo => 'foo',
56
+ 'foo-bar' => 'foo-bar',
57
+ 'foo_bar' => 'foo-bar',
58
+ :foo_bar => 'foo-bar',
59
+ 'Foo-Bar' => 'foo-bar',
60
+ 'Foo_Bar' => 'foo-bar'
61
+ }
62
+
63
+ transformations.each do |before, after|
64
+ assert_equal after, before.to_header
65
+ end
66
+ end
67
+
68
+ def test_valid_utf8?
69
+ assert !"318597/620065/GTL_75\24300_A600_A610.zip".valid_utf8?
70
+ assert "318597/620065/GTL_75£00_A600_A610.zip".valid_utf8?
71
+ end
72
+
73
+ def test_remove_extended
74
+ assert "318597/620065/GTL_75\24300_A600_A610.zip".remove_extended.valid_utf8?
75
+ assert "318597/620065/GTL_75£00_A600_A610.zip".remove_extended.valid_utf8?
76
+ end
77
+ end
78
+
79
+ class CoercibleStringTest < Test::Unit::TestCase
80
+
81
+ def test_coerce
82
+ coercions = [
83
+ ['1', 1],
84
+ ['false', false],
85
+ ['true', true],
86
+ ['2006-10-29T23:14:47.000Z', Time.parse('2006-10-29T23:14:47.000Z')],
87
+ ['Hello!', 'Hello!'],
88
+ ['false23', 'false23'],
89
+ ['03 1-2-3-Apple-Tree.mp3', '03 1-2-3-Apple-Tree.mp3'],
90
+ ['0815', '0815'] # This number isn't coerced because the leading zero would be lost
91
+ ]
92
+
93
+ coercions.each do |before, after|
94
+ assert_nothing_raised do
95
+ assert_equal after, CoercibleString.coerce(before)
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ class KerneltExtensionsTest < Test::Unit::TestCase
102
+ class Foo
103
+ def foo
104
+ __method__
105
+ end
106
+
107
+ def bar
108
+ foo
109
+ end
110
+
111
+ def baz
112
+ bar
113
+ end
114
+ end
115
+
116
+ class Bar
117
+ def foo
118
+ calling_method
119
+ end
120
+
121
+ def bar
122
+ calling_method
123
+ end
124
+
125
+ def calling_method
126
+ __method__(1)
127
+ end
128
+ end
129
+
130
+ def test___method___works_regardless_of_nesting
131
+ f = Foo.new
132
+ [:foo, :bar, :baz].each do |method|
133
+ assert_equal 'foo', f.send(method)
134
+ end
135
+ end
136
+
137
+ def test___method___depth
138
+ b = Bar.new
139
+ assert_equal 'foo', b.foo
140
+ assert_equal 'bar', b.bar
141
+ end
142
+ end if RUBY_VERSION <= '1.8.7'
143
+
144
+ class ModuleExtensionsTest < Test::Unit::TestCase
145
+ class Foo
146
+ def foo(reload = false)
147
+ expirable_memoize(reload) do
148
+ Time.now
149
+ end
150
+ end
151
+
152
+ def bar(reload = false)
153
+ expirable_memoize(reload, :baz) do
154
+ Time.now
155
+ end
156
+ end
157
+
158
+ def quux
159
+ Time.now
160
+ end
161
+ memoized :quux
162
+ end
163
+
164
+ def setup
165
+ @instance = Foo.new
166
+ end
167
+
168
+ def test_memoize
169
+ assert !instance_variables_of(@instance).include?('@foo')
170
+ cached_result = @instance.foo
171
+ assert_equal cached_result, @instance.foo
172
+ assert instance_variables_of(@instance).include?('@foo')
173
+ assert_equal cached_result, @instance.send(:instance_variable_get, :@foo)
174
+ assert_not_equal cached_result, new_cache = @instance.foo(:reload)
175
+ assert_equal new_cache, @instance.foo
176
+ assert_equal new_cache, @instance.send(:instance_variable_get, :@foo)
177
+ end
178
+
179
+ def test_customizing_memoize_storage
180
+ assert !instance_variables_of(@instance).include?('@bar')
181
+ assert !instance_variables_of(@instance).include?('@baz')
182
+ cached_result = @instance.bar
183
+ assert !instance_variables_of(@instance).include?('@bar')
184
+ assert instance_variables_of(@instance).include?('@baz')
185
+ assert_equal cached_result, @instance.bar
186
+ assert_equal cached_result, @instance.send(:instance_variable_get, :@baz)
187
+ assert_nil @instance.send(:instance_variable_get, :@bar)
188
+ end
189
+
190
+ def test_memoized
191
+ assert !instance_variables_of(@instance).include?('@quux')
192
+ cached_result = @instance.quux
193
+ assert_equal cached_result, @instance.quux
194
+ assert instance_variables_of(@instance).include?('@quux')
195
+ assert_equal cached_result, @instance.send(:instance_variable_get, :@quux)
196
+ assert_not_equal cached_result, new_cache = @instance.quux(:reload)
197
+ assert_equal new_cache, @instance.quux
198
+ assert_equal new_cache, @instance.send(:instance_variable_get, :@quux)
199
+ end
200
+
201
+ def test_constant_setting
202
+ some_module = Module.new
203
+ assert !some_module.const_defined?(:FOO)
204
+ assert_nothing_raised do
205
+ some_module.constant :FOO, 'bar'
206
+ end
207
+
208
+ assert some_module.const_defined?(:FOO)
209
+ assert_nothing_raised do
210
+ some_module::FOO
211
+ some_module.foo
212
+ end
213
+ assert_equal 'bar', some_module::FOO
214
+ assert_equal 'bar', some_module.foo
215
+
216
+ assert_nothing_raised do
217
+ some_module.constant :FOO, 'baz'
218
+ end
219
+
220
+ assert_equal 'bar', some_module::FOO
221
+ assert_equal 'bar', some_module.foo
222
+ end
223
+
224
+ private
225
+ # For 1.9 compatibility
226
+ def instance_variables_of(object)
227
+ object.instance_variables.map do |instance_variable|
228
+ instance_variable.to_s
229
+ end
230
+ end
231
+
232
+ end
233
+
234
+ class AttributeProxyTest < Test::Unit::TestCase
235
+ class BlindProxyUsingDefaultAttributesHash
236
+ include SelectiveAttributeProxy
237
+ proxy_to :exlusively => false
238
+ end
239
+
240
+ class BlindProxyUsingCustomAttributeHash
241
+ include SelectiveAttributeProxy
242
+ proxy_to :settings
243
+ end
244
+
245
+ class ProxyUsingPassedInAttributeHash
246
+ include SelectiveAttributeProxy
247
+
248
+ def initialize(attributes = {})
249
+ @attributes = attributes
250
+ end
251
+ end
252
+
253
+ class RestrictedProxy
254
+ include SelectiveAttributeProxy
255
+
256
+ private
257
+ def proxiable_attribute?(name)
258
+ %w(foo bar baz).include?(name)
259
+ end
260
+ end
261
+
262
+ class NonExclusiveProxy
263
+ include SelectiveAttributeProxy
264
+ proxy_to :settings, :exclusively => false
265
+ end
266
+
267
+ def test_using_all_defaults
268
+ b = BlindProxyUsingDefaultAttributesHash.new
269
+ assert_nothing_raised do
270
+ b.foo = 'bar'
271
+ end
272
+
273
+ assert_nothing_raised do
274
+ b.foo
275
+ end
276
+
277
+ assert_equal 'bar', b.foo
278
+ end
279
+
280
+ def test_storage_is_autovivified
281
+ b = BlindProxyUsingDefaultAttributesHash.new
282
+ assert_nothing_raised do
283
+ b.send(:attributes)['foo'] = 'bar'
284
+ end
285
+
286
+ assert_nothing_raised do
287
+ b.foo
288
+ end
289
+
290
+ assert_equal 'bar', b.foo
291
+ end
292
+
293
+ def test_limiting_which_attributes_are_proxiable
294
+ r = RestrictedProxy.new
295
+ assert_nothing_raised do
296
+ r.foo = 'bar'
297
+ end
298
+
299
+ assert_nothing_raised do
300
+ r.foo
301
+ end
302
+
303
+ assert_equal 'bar', r.foo
304
+
305
+ assert_raises(NoMethodError) do
306
+ r.quux = 'foo'
307
+ end
308
+
309
+ assert_raises(NoMethodError) do
310
+ r.quux
311
+ end
312
+ end
313
+
314
+ def test_proxying_is_exclusive_by_default
315
+ p = ProxyUsingPassedInAttributeHash.new('foo' => 'bar')
316
+ assert_nothing_raised do
317
+ p.foo
318
+ p.foo = 'baz'
319
+ end
320
+
321
+ assert_equal 'baz', p.foo
322
+
323
+ assert_raises(NoMethodError) do
324
+ p.quux
325
+ end
326
+ end
327
+
328
+ def test_setting_the_proxy_as_non_exclusive
329
+ n = NonExclusiveProxy.new
330
+ assert_nothing_raised do
331
+ n.foo = 'baz'
332
+ end
333
+
334
+ assert_nothing_raised do
335
+ n.foo
336
+ end
337
+
338
+ assert_equal 'baz', n.foo
339
+ end
340
+ end
@@ -0,0 +1,133 @@
1
+ empty_bucket_list: >
2
+ <ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
3
+ <Owner>
4
+ <ID>ab00c3106e091f8fe23154c85678cda66628adb330bc00f02cf4a1c36d76bc48</ID>
5
+ <DisplayName>amazon</DisplayName>
6
+ </Owner>
7
+ <Buckets/>
8
+ </ListAllMyBucketsResult>
9
+
10
+
11
+ bucket_list_with_one_bucket: >
12
+ <ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
13
+ <Owner>
14
+ <ID>ab00c3106e091f8fe23154c85678cda66628adb330bc00f02cf4a1c36d76bc48</ID>
15
+ <DisplayName>amazon</DisplayName>
16
+ </Owner>
17
+ <Buckets>
18
+ <Bucket>
19
+ <Name>marcel_molina</Name>
20
+ <CreationDate>2006-10-04T15:58:38.000Z</CreationDate>
21
+ </Bucket>
22
+ </Buckets>
23
+ </ListAllMyBucketsResult>
24
+
25
+
26
+ bucket_list_with_more_than_one_bucket: >
27
+ <ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
28
+ <Owner>
29
+ <ID>ab00c3106e091f8fe23154c85678cda66628adb330bc00f02cf4a1c36d76bc48</ID>
30
+ <DisplayName>amazon</DisplayName>
31
+ </Owner>
32
+ <Buckets>
33
+ <Bucket>
34
+ <Name>marcel_molina</Name>
35
+ <CreationDate>2006-10-04T15:58:38.000Z</CreationDate>
36
+ </Bucket>
37
+ <Bucket>
38
+ <Name>marcel_molina_jr</Name>
39
+ <CreationDate>2006-10-04T16:01:30.000Z</CreationDate>
40
+ </Bucket>
41
+ </Buckets>
42
+ </ListAllMyBucketsResult>
43
+
44
+ empty_bucket: >
45
+ <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
46
+ <Name>marcel_molina</Name>
47
+ <Prefix></Prefix>
48
+ <Marker></Marker>
49
+ <MaxKeys>1000</MaxKeys>
50
+ <IsTruncated>false</IsTruncated>
51
+ </ListBucketResult>
52
+
53
+ bucket_with_one_key: >
54
+ <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
55
+ <Name>marcel_molina</Name>
56
+ <Prefix></Prefix>
57
+ <Marker></Marker>
58
+ <MaxKeys>1000</MaxKeys>
59
+ <IsTruncated>false</IsTruncated>
60
+ <Contents>
61
+ <Key>tongue_overload.jpg</Key>
62
+ <LastModified>2006-10-05T02:42:22.000Z</LastModified>
63
+ <ETag>&quot;f21f7c4e8ea6e34b268887b07d6da745&quot;</ETag>
64
+ <Size>60673</Size>
65
+ <Owner>
66
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
67
+ <DisplayName>mmolina@onramp.net</DisplayName>
68
+ </Owner>
69
+ <StorageClass>STANDARD</StorageClass>
70
+ </Contents>
71
+ </ListBucketResult>
72
+
73
+ bucket_with_more_than_one_key: >
74
+ <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
75
+ <Name>marcel_molina</Name>
76
+ <Prefix></Prefix>
77
+ <Marker></Marker>
78
+ <MaxKeys>1000</MaxKeys>
79
+ <IsTruncated>false</IsTruncated>
80
+ <Contents>
81
+ <Key>beluga_baby.jpg</Key>
82
+ <LastModified>2006-10-05T02:55:10.000Z</LastModified>
83
+ <ETag>&quot;b2453d4a39a7387674a8c505112a2f0b&quot;</ETag>
84
+ <Size>35807</Size>
85
+ <Owner>
86
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
87
+ <DisplayName>mmolina@onramp.net</DisplayName>
88
+ </Owner>
89
+ <StorageClass>STANDARD</StorageClass>
90
+ </Contents>
91
+ <Contents>
92
+ <Key>tongue_overload.jpg</Key>
93
+ <LastModified>2006-10-05T02:42:22.000Z</LastModified>
94
+ <ETag>&quot;f21f7c4e8ea6e34b268887b07d6da745&quot;</ETag>
95
+ <Size>60673</Size>
96
+ <Owner>
97
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
98
+ <DisplayName>mmolina@onramp.net</DisplayName>
99
+ </Owner>
100
+ <StorageClass>STANDARD</StorageClass>
101
+ </Contents>
102
+ </ListBucketResult>
103
+
104
+ truncated_bucket_with_more_than_one_key: >
105
+ <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
106
+ <Name>marcel_molina</Name>
107
+ <Prefix></Prefix>
108
+ <Marker></Marker>
109
+ <MaxKeys>2</MaxKeys>
110
+ <IsTruncated>true</IsTruncated>
111
+ <Contents>
112
+ <Key>beluga_baby.jpg</Key>
113
+ <LastModified>2006-10-05T02:55:10.000Z</LastModified>
114
+ <ETag>&quot;b2453d4a39a7387674a8c505112a2f0b&quot;</ETag>
115
+ <Size>35807</Size>
116
+ <Owner>
117
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
118
+ <DisplayName>mmolina@onramp.net</DisplayName>
119
+ </Owner>
120
+ <StorageClass>STANDARD</StorageClass>
121
+ </Contents>
122
+ <Contents>
123
+ <Key>tongue_overload.jpg</Key>
124
+ <LastModified>2006-10-05T02:42:22.000Z</LastModified>
125
+ <ETag>&quot;f21f7c4e8ea6e34b268887b07d6da745&quot;</ETag>
126
+ <Size>60673</Size>
127
+ <Owner>
128
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
129
+ <DisplayName>mmolina@onramp.net</DisplayName>
130
+ </Owner>
131
+ <StorageClass>STANDARD</StorageClass>
132
+ </Contents>
133
+ </ListBucketResult>
@@ -0,0 +1,34 @@
1
+ not_implemented: >
2
+ <Error>
3
+ <Code>NotImplemented</Code>
4
+ <Message>A header you provided implies functionality that is not implemented</Message>
5
+ <RequestId>D1D13A09AC92427F</RequestId>
6
+ <Header>Host</Header>
7
+ <HostId>oNZgzTTmWiovwGGwHXAzz+1vRmAJVAplS9TF7B0cuOGfEwoi7DYSTa/1Qhv90CfW</HostId>
8
+ </Error>
9
+
10
+ access_denied: >
11
+ <Error>
12
+ <Code>AccessDenied</Code>
13
+ <Message>Access Denied</Message>
14
+ <RequestId>F99F6D58B96C98E0</RequestId>
15
+ <HostId>XwCF7k3llrcEwtoHR7MusZ6ilCdF5DKDmwYpglvjKNjvwo24INCeXlEpo1M03Wxm</HostId>
16
+ </Error>
17
+
18
+ internal_error: >
19
+ <Error>
20
+ <Code>InternalError</Code>
21
+ <Message>Internal Error</Message>
22
+ <RequestId>F99F6D223B96C98E0</RequestId>
23
+ <HostId>XwCF7k3llrcEwtoHR7MusZ6ilCdF5DKDmwYpglvjKNjvwo24INCeXlEpo1M03Wxm</HostId>
24
+ </Error>
25
+
26
+ error_with_no_message: >
27
+ <Error>
28
+ <Code>InvalidArgument</Code>
29
+ <Message></Message>
30
+ <ArgumentValue>READ</ArgumentValue>
31
+ <RequestId>74A377B1C0FA2BCF</RequestId>
32
+ <HostId>cP4rqsAEtHpN6Ckv08Hr3LXjLzx15/YgyoSqzs779vMR8MrAFSodxZp96wtuMQuI</HostId>
33
+ <ArgumentName>x-amz-acl</ArgumentName>
34
+ </Error>
@@ -0,0 +1,3 @@
1
+ headers_including_one_piece_of_metadata:
2
+ x-amz-meta-test: foo
3
+ content_type: text/plain
@@ -0,0 +1,15 @@
1
+ logging_enabled: >
2
+ <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
3
+ <LoggingEnabled>
4
+ <TargetBucket>mylogs</TargetBucket>
5
+ <TargetPrefix>access_log-</TargetPrefix>
6
+ </LoggingEnabled>
7
+ </BucketLoggingStatus>
8
+
9
+ logging_disabled: >
10
+ <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
11
+ <!--<LoggingEnabled>
12
+ <TargetBucket>myLogsBucket</TargetBucket>
13
+ <TargetPrefix>add/this/prefix/to/my/log/files/access_log-</TargetPrefix>
14
+ </LoggingEnabled>-->
15
+ </BucketLoggingStatus>
@@ -0,0 +1,5 @@
1
+ bucket_get:
2
+ "bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 marcel [14/Nov/2006:06:36:48 +0000] 67.165.183.125 bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 8B5297D428A05432 REST.GET.BUCKET - \"GET /marcel HTTP/1.1\" 200 - 4534 - 398 395 \"-\" \"-\"\n"
3
+
4
+ browser_get:
5
+ "bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 marcel [25/Nov/2006:06:26:23 +0000] 67.165.183.125 65a011a29cdf8ec533ec3d1ccaae921c 41521D07CA012312 REST.GET.OBJECT kiss.jpg \"GET /marcel/kiss.jpg HTTP/1.1\" 200 - 67748 67748 259 104 \"-\" \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0\"\n"
@@ -0,0 +1,7 @@
1
+ simple_log:
2
+ - "bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 marcel [14/Nov/2006:06:36:48 +0000] 67.165.183.125 bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 8B5297D428A05432 REST.GET.BUCKET - \"GET /marcel HTTP/1.1\" 200 - 4534 - 398 395 \"-\" \"-\"\n"
3
+ - "bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 marcel [14/Nov/2006:06:38:58 +0000] 67.165.183.125 bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 8F6F3C4027849420 REST.GET.BUCKET - \"GET /marcel HTTP/1.1\" 200 - 4534 - 458 456 \"-\" \"-\"\n"
4
+
5
+ requests_from_a_browser:
6
+ - "bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 marcel [25/Nov/2006:06:26:23 +0000] 67.165.183.125 65a011a29cdf8ec533ec3d1ccaae921c 41521D07CA012312 REST.GET.OBJECT kiss.jpg \"GET /marcel/kiss.jpg HTTP/1.1\" 200 - 67748 67748 259 104 \"-\" \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0\"\n"
7
+ - "bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1 marcel [25/Nov/2006:06:26:27 +0000] 67.165.183.125 65a011a29cdf8ec533ec3d1ccaae921c 88629578AFDDD9B5 REST.GET.TORRENT kiss.jpg \"GET /marcel/kiss.jpg?torrent HTTP/1.1\" 200 - 215 - 379 - \"-\" \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0\"\n"
@@ -0,0 +1,16 @@
1
+ policy_with_one_grant: >
2
+ <AccessControlPolicy>
3
+ <Owner>
4
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
5
+ <DisplayName>mmolina@onramp.net</DisplayName>
6
+ </Owner>
7
+ <AccessControlList>
8
+ <Grant>
9
+ <Grantee xsi:type="CanonicalUser" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
10
+ <ID>bb2041a25975c3d4ce9775fe9e93e5b77a6a9fad97dc7e00686191f3790b13f1</ID>
11
+ <DisplayName>mmolina@onramp.net</DisplayName>
12
+ </Grantee>
13
+ <Permission>FULL_CONTROL</Permission>
14
+ </Grant>
15
+ </AccessControlList>
16
+ </AccessControlPolicy>
data/test/fixtures.rb ADDED
@@ -0,0 +1,89 @@
1
+ require 'yaml'
2
+
3
+ module AWS
4
+ module S3
5
+ # When this file is loaded, for each fixture file, a module is created within the Fixtures module
6
+ # with the same name as the fixture file. For each fixture in that fixture file, a singleton method is
7
+ # added to the module with the name of the given fixture, returning the value of the fixture.
8
+ #
9
+ # For example:
10
+ #
11
+ # A fixture in <tt>buckets.yml</tt> named <tt>empty_bucket_list</tt> with value <tt><foo>hi!</foo></tt>
12
+ # would be made available like so:
13
+ #
14
+ # Fixtures::Buckets.empty_bucket_list
15
+ # => "<foo>hi!</foo>"
16
+ #
17
+ # Alternatively you can treat the fixture module like a hash
18
+ #
19
+ # Fixtures::Buckets[:empty_bucket_list]
20
+ # => "<foo>hi!</foo>"
21
+ #
22
+ # You can find out all available fixtures by calling
23
+ #
24
+ # Fixtures.fixtures
25
+ # => ["Buckets"]
26
+ #
27
+ # And all the fixtures contained in a given fixture by calling
28
+ #
29
+ # Fixtures::Buckets.fixtures
30
+ # => ["bucket_list_with_more_than_one_bucket", "bucket_list_with_one_bucket", "empty_bucket_list"]
31
+ module Fixtures
32
+ class << self
33
+ def create_fixtures
34
+ files.each do |file|
35
+ create_fixture_for(file)
36
+ end
37
+ end
38
+
39
+ def create_fixture_for(file)
40
+ fixtures = YAML.load_file(path(file))
41
+ fixture_module = Module.new
42
+
43
+ fixtures.each do |name, value|
44
+ fixture_module.module_eval(<<-EVAL, __FILE__, __LINE__)
45
+ def #{name}
46
+ #{value.inspect}
47
+ end
48
+ module_function :#{name}
49
+ EVAL
50
+ end
51
+
52
+ fixture_module.module_eval(<<-EVAL, __FILE__, __LINE__)
53
+ module_function
54
+
55
+ def fixtures
56
+ #{fixtures.keys.sort.inspect}
57
+ end
58
+
59
+ def [](name)
60
+ send(name) if fixtures.include?(name.to_s)
61
+ end
62
+ EVAL
63
+
64
+ const_set(module_name(file), fixture_module)
65
+ end
66
+
67
+ def fixtures
68
+ constants.sort
69
+ end
70
+
71
+ private
72
+
73
+ def files
74
+ Dir.glob(File.dirname(__FILE__) + '/fixtures/*.yml').map {|fixture| File.basename(fixture)}
75
+ end
76
+
77
+ def module_name(file_name)
78
+ File.basename(file_name, '.*').capitalize
79
+ end
80
+
81
+ def path(file_name)
82
+ File.join(File.dirname(__FILE__), 'fixtures', file_name)
83
+ end
84
+ end
85
+
86
+ create_fixtures
87
+ end
88
+ end
89
+ end