croaker-aws-s3 0.5.2.20090127001

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.
Files changed (57) 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 +222 -0
  9. data/lib/aws/s3/base.rb +257 -0
  10. data/lib/aws/s3/bittorrent.rb +58 -0
  11. data/lib/aws/s3/bucket.rb +329 -0
  12. data/lib/aws/s3/connection.rb +349 -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 +324 -0
  16. data/lib/aws/s3/logging.rb +311 -0
  17. data/lib/aws/s3/object.rb +613 -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 +61 -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 +217 -0
  34. data/test/error_test.rb +70 -0
  35. data/test/extensions_test.rb +331 -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_helper.rb +30 -0
  54. data/test/response_test.rb +68 -0
  55. data/test/service_test.rb +23 -0
  56. data/test/test_helper.rb +111 -0
  57. metadata +143 -0
@@ -0,0 +1,331 @@
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_utf8?
69
+ assert !"318597/620065/GTL_75\24300_A600_A610.zip".utf8?
70
+ assert "318597/620065/GTL_75£00_A600_A610.zip".utf8?
71
+ end
72
+
73
+ def test_remove_extended
74
+ assert "318597/620065/GTL_75\24300_A600_A610.zip".remove_extended.utf8?
75
+ assert "318597/620065/GTL_75£00_A600_A610.zip".remove_extended.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
143
+
144
+ class ModuleExtensionsTest < Test::Unit::TestCase
145
+ class Foo
146
+ def foo(reload = false)
147
+ memoize(reload) do
148
+ Time.now
149
+ end
150
+ end
151
+
152
+ def bar(reload = false)
153
+ 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.instance_variables.include?('@foo')
170
+ cached_result = @instance.foo
171
+ assert_equal cached_result, @instance.foo
172
+ assert @instance.instance_variables.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.instance_variables.include?('@bar')
181
+ assert !@instance.instance_variables.include?('@baz')
182
+ cached_result = @instance.bar
183
+ assert !@instance.instance_variables.include?('@bar')
184
+ assert @instance.instance_variables.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.instance_variables.include?('@quux')
192
+ cached_result = @instance.quux
193
+ assert_equal cached_result, @instance.quux
194
+ assert @instance.instance_variables.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
+ end
224
+
225
+ class AttributeProxyTest < Test::Unit::TestCase
226
+ class BlindProxyUsingDefaultAttributesHash
227
+ include SelectiveAttributeProxy
228
+ proxy_to :exlusively => false
229
+ end
230
+
231
+ class BlindProxyUsingCustomAttributeHash
232
+ include SelectiveAttributeProxy
233
+ proxy_to :settings
234
+ end
235
+
236
+ class ProxyUsingPassedInAttributeHash
237
+ include SelectiveAttributeProxy
238
+
239
+ def initialize(attributes = {})
240
+ @attributes = attributes
241
+ end
242
+ end
243
+
244
+ class RestrictedProxy
245
+ include SelectiveAttributeProxy
246
+
247
+ private
248
+ def proxiable_attribute?(name)
249
+ %w(foo bar baz).include?(name)
250
+ end
251
+ end
252
+
253
+ class NonExclusiveProxy
254
+ include SelectiveAttributeProxy
255
+ proxy_to :settings, :exclusively => false
256
+ end
257
+
258
+ def test_using_all_defaults
259
+ b = BlindProxyUsingDefaultAttributesHash.new
260
+ assert_nothing_raised do
261
+ b.foo = 'bar'
262
+ end
263
+
264
+ assert_nothing_raised do
265
+ b.foo
266
+ end
267
+
268
+ assert_equal 'bar', b.foo
269
+ end
270
+
271
+ def test_storage_is_autovivified
272
+ b = BlindProxyUsingDefaultAttributesHash.new
273
+ assert_nothing_raised do
274
+ b.send(:attributes)['foo'] = 'bar'
275
+ end
276
+
277
+ assert_nothing_raised do
278
+ b.foo
279
+ end
280
+
281
+ assert_equal 'bar', b.foo
282
+ end
283
+
284
+ def test_limiting_which_attributes_are_proxiable
285
+ r = RestrictedProxy.new
286
+ assert_nothing_raised do
287
+ r.foo = 'bar'
288
+ end
289
+
290
+ assert_nothing_raised do
291
+ r.foo
292
+ end
293
+
294
+ assert_equal 'bar', r.foo
295
+
296
+ assert_raises(NoMethodError) do
297
+ r.quux = 'foo'
298
+ end
299
+
300
+ assert_raises(NoMethodError) do
301
+ r.quux
302
+ end
303
+ end
304
+
305
+ def test_proxying_is_exclusive_by_default
306
+ p = ProxyUsingPassedInAttributeHash.new('foo' => 'bar')
307
+ assert_nothing_raised do
308
+ p.foo
309
+ p.foo = 'baz'
310
+ end
311
+
312
+ assert_equal 'baz', p.foo
313
+
314
+ assert_raises(NoMethodError) do
315
+ p.quux
316
+ end
317
+ end
318
+
319
+ def test_setting_the_proxy_as_non_exclusive
320
+ n = NonExclusiveProxy.new
321
+ assert_nothing_raised do
322
+ n.foo = 'baz'
323
+ end
324
+
325
+ assert_nothing_raised do
326
+ n.foo
327
+ end
328
+
329
+ assert_equal 'baz', n.foo
330
+ end
331
+ 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