codders-aws-s3 0.6.2

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.rb +60 -0
  8. data/lib/aws/s3/acl.rb +636 -0
  9. data/lib/aws/s3/authentication.rb +221 -0
  10. data/lib/aws/s3/base.rb +240 -0
  11. data/lib/aws/s3/bittorrent.rb +58 -0
  12. data/lib/aws/s3/bucket.rb +319 -0
  13. data/lib/aws/s3/connection.rb +279 -0
  14. data/lib/aws/s3/error.rb +69 -0
  15. data/lib/aws/s3/exceptions.rb +133 -0
  16. data/lib/aws/s3/extensions.rb +356 -0
  17. data/lib/aws/s3/logging.rb +314 -0
  18. data/lib/aws/s3/object.rb +612 -0
  19. data/lib/aws/s3/owner.rb +44 -0
  20. data/lib/aws/s3/parsing.rb +99 -0
  21. data/lib/aws/s3/response.rb +180 -0
  22. data/lib/aws/s3/service.rb +51 -0
  23. data/lib/aws/s3/version.rb +12 -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 +136 -0
  31. data/test/base_test.rb +136 -0
  32. data/test/bucket_test.rb +74 -0
  33. data/test/connection_test.rb +220 -0
  34. data/test/error_test.rb +70 -0
  35. data/test/extensions_test.rb +340 -0
  36. data/test/fixtures.rb +89 -0
  37. data/test/fixtures/buckets.yml +133 -0
  38. data/test/fixtures/errors.yml +34 -0
  39. data/test/fixtures/headers.yml +3 -0
  40. data/test/fixtures/logging.yml +15 -0
  41. data/test/fixtures/loglines.yml +5 -0
  42. data/test/fixtures/logs.yml +7 -0
  43. data/test/fixtures/policies.yml +16 -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 +152 -0
  58. metadata +199 -0
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ServiceTest < Test::Unit::TestCase
4
+ def test_bucket_list_with_empty_bucket_list
5
+ mock_connection_for(Service, :returns => {:body => Fixtures::Buckets.empty_bucket_list, :code => 200})
6
+ list = Service.buckets(:reload)
7
+ assert_equal [], list
8
+ end
9
+
10
+ def test_bucket_list_with_bucket_list_containing_one_bucket
11
+ mock_connection_for(Service, :returns => {:body => Fixtures::Buckets.bucket_list_with_one_bucket, :code => 200})
12
+ list = Service.buckets(:reload)
13
+ assert_equal 1, list.size
14
+ assert_equal 'marcel_molina', list.first.name
15
+ end
16
+
17
+ def test_bucket_list_with_bucket_list_containing_more_than_one_bucket
18
+ mock_connection_for(Service, :returns => {:body => Fixtures::Buckets.bucket_list_with_more_than_one_bucket, :code => 200})
19
+ list = Service.buckets(:reload)
20
+ assert_equal 2, list.size
21
+ assert_equal %w(marcel_molina marcel_molina_jr), list.map {|bucket| bucket.name}.sort
22
+ end
23
+ end
@@ -0,0 +1,152 @@
1
+ require 'test/unit'
2
+ $:.unshift File.dirname(__FILE__) + '/../lib'
3
+ require 'aws/s3'
4
+ require File.dirname(__FILE__) + '/mocks/fake_response'
5
+ require File.dirname(__FILE__) + '/fixtures'
6
+ begin
7
+ require_library_or_gem 'ruby-debug'
8
+ rescue LoadError
9
+ end
10
+ require_library_or_gem 'flexmock'
11
+ require_library_or_gem 'flexmock/test_unit'
12
+
13
+
14
+ module ExampleData
15
+ module Example1
16
+ module_function
17
+
18
+ def request
19
+ request = Net::HTTP::Head.new('/quotes/nelson')
20
+ request['Content-Type'] = 'text/html'
21
+ request['Date'] = 'Thu, 17 Nov 2005 18:49:58 GMT'
22
+ request['X-Amz-Magic'] = 'abracadabra'
23
+ request
24
+ end
25
+
26
+ def canonical_string_query
27
+ "HEAD\n\ntext/html\n1132253458\nx-amz-magic:abracadabra\n/quotes/nelson"
28
+ end
29
+
30
+ def canonical_string_header
31
+ "HEAD\n\ntext/html\nThu, 17 Nov 2005 18:49:58 GMT\nx-amz-magic:abracadabra\n/quotes/nelson"
32
+ end
33
+
34
+ def access_key_id
35
+ '44CF9590006BF252F707'
36
+ end
37
+
38
+ def secret_access_key
39
+ 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
40
+ end
41
+
42
+ def signature
43
+ 'jZNOcbfWmD/A/f3hSvVzXZjM2HU='
44
+ end
45
+
46
+ def query_string
47
+ 'AWSAccessKeyId=44CF9590006BF252F707&Expires=1132253458&Signature=mfm9VGIfnfKc20fYJAaYSuYXPpk%3D'
48
+ end
49
+
50
+ def authorization_header
51
+ 'AWS 44CF9590006BF252F707:hDwh8uo1zH9XTfSQKiyw4j9QyXs='
52
+ end
53
+ end
54
+ end
55
+
56
+ # Data copied from http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAuthentication.html
57
+ module AmazonDocExampleData
58
+ module Example1
59
+ module_function
60
+
61
+ def request
62
+ request = Net::HTTP::Put.new('/quotes/nelson')
63
+ request['Content-Md5'] = 'c8fdb181845a4ca6b8fec737b3581d76'
64
+ request['Content-Type'] = 'text/html'
65
+ request['Date'] = 'Thu, 17 Nov 2005 18:49:58 GMT'
66
+ request['X-Amz-Meta-Author'] = 'foo@bar.com'
67
+ request['X-Amz-Magic'] = 'abracadabra'
68
+ request
69
+ end
70
+
71
+ def canonical_string
72
+ "PUT\nc8fdb181845a4ca6b8fec737b3581d76\ntext/html\nThu, 17 Nov 2005 18:49:58 GMT\nx-amz-magic:abracadabra\nx-amz-meta-author:foo@bar.com\n/quotes/nelson"
73
+ end
74
+
75
+ def access_key_id
76
+ '44CF9590006BF252F707'
77
+ end
78
+
79
+ def secret_access_key
80
+ 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
81
+ end
82
+
83
+ def signature
84
+ 'jZNOcbfWmD/A/f3hSvVzXZjM2HU='
85
+ end
86
+
87
+ def authorization_header
88
+ 'AWS 44CF9590006BF252F707:jZNOcbfWmD/A/f3hSvVzXZjM2HU='
89
+ end
90
+ end
91
+
92
+ module Example3
93
+ module_function
94
+
95
+ def request
96
+ request = Net::HTTP::Get.new('/quotes/nelson')
97
+ request['Date'] = date
98
+ request
99
+ end
100
+
101
+ def date
102
+ 'Thu Mar 9 01:24:20 CST 2006'
103
+ end
104
+
105
+ def access_key_id
106
+ Example1.access_key_id
107
+ end
108
+
109
+ def secret_access_key
110
+ Example1.secret_access_key
111
+ end
112
+
113
+ def expires
114
+ 1141889120
115
+ end
116
+
117
+ def query_string
118
+ 'AWSAccessKeyId=44CF9590006BF252F707&Expires=1141889120&Signature=vjbyPxybdZaNmGa%2ByT272YEAiv4%3D'
119
+ end
120
+
121
+ def canonical_string
122
+ "GET\n\n\n1141889120\n/quotes/nelson"
123
+ end
124
+
125
+ end
126
+ end
127
+
128
+ class Test::Unit::TestCase
129
+ include AWS::S3
130
+
131
+ def sample_proxy_settings
132
+ {:host => 'http://google.com', :port => 8080, :user => 'marcel', :password => 'secret'}
133
+ end
134
+
135
+ def mock_connection_for(klass, options = {})
136
+ data = options[:returns]
137
+ return_values = case data
138
+ when Hash
139
+ FakeResponse.new(data)
140
+ when Array
141
+ data.map {|hash| FakeResponse.new(hash)}
142
+ else
143
+ abort "Response data for mock connection must be a Hash or an Array. Was #{data.inspect}."
144
+ end
145
+
146
+ connection = flexmock('Mock connection') do |mock|
147
+ mock.should_receive(:request).and_return(*return_values).at_least.once
148
+ end
149
+
150
+ flexmock(klass).should_receive(:connection).and_return(connection)
151
+ end
152
+ end
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: codders-aws-s3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 2
10
+ version: 0.6.2
11
+ platform: ruby
12
+ authors:
13
+ - Marcel Molina Jr.
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-15 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: xml-simple
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: builder
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: mime-types
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ description: Client library for Amazon's Simple Storage Service's REST API
64
+ email: marcel@vernix.org
65
+ executables:
66
+ - s3sh
67
+ extensions: []
68
+
69
+ extra_rdoc_files:
70
+ - README
71
+ - COPYING
72
+ - INSTALL
73
+ files:
74
+ - Rakefile
75
+ - lib/aws/s3/object.rb
76
+ - lib/aws/s3/base.rb
77
+ - lib/aws/s3/parsing.rb
78
+ - lib/aws/s3/logging.rb
79
+ - lib/aws/s3/exceptions.rb
80
+ - lib/aws/s3/bittorrent.rb
81
+ - lib/aws/s3/version.rb
82
+ - lib/aws/s3/owner.rb
83
+ - lib/aws/s3/authentication.rb
84
+ - lib/aws/s3/extensions.rb
85
+ - lib/aws/s3/bucket.rb
86
+ - lib/aws/s3/service.rb
87
+ - lib/aws/s3/acl.rb
88
+ - lib/aws/s3/response.rb
89
+ - lib/aws/s3/connection.rb
90
+ - lib/aws/s3/error.rb
91
+ - lib/aws/s3.rb
92
+ - bin/s3sh
93
+ - bin/setup.rb
94
+ - support/faster-xml-simple/lib/faster_xml_simple.rb
95
+ - support/faster-xml-simple/test/regression_test.rb
96
+ - support/faster-xml-simple/test/test_helper.rb
97
+ - support/faster-xml-simple/test/xml_simple_comparison_test.rb
98
+ - support/rdoc/code_info.rb
99
+ - test/logging_test.rb
100
+ - test/service_test.rb
101
+ - test/remote/logging_test.rb
102
+ - test/remote/test_file.data
103
+ - test/remote/bucket_test.rb
104
+ - test/remote/object_test.rb
105
+ - test/remote/test_helper.rb
106
+ - test/remote/bittorrent_test.rb
107
+ - test/remote/acl_test.rb
108
+ - test/fixtures.rb
109
+ - test/bucket_test.rb
110
+ - test/response_test.rb
111
+ - test/parsing_test.rb
112
+ - test/authentication_test.rb
113
+ - test/object_test.rb
114
+ - test/test_helper.rb
115
+ - test/fixtures/errors.yml
116
+ - test/fixtures/logging.yml
117
+ - test/fixtures/buckets.yml
118
+ - test/fixtures/policies.yml
119
+ - test/fixtures/headers.yml
120
+ - test/fixtures/logs.yml
121
+ - test/fixtures/loglines.yml
122
+ - test/extensions_test.rb
123
+ - test/base_test.rb
124
+ - test/error_test.rb
125
+ - test/acl_test.rb
126
+ - test/connection_test.rb
127
+ - test/mocks/fake_response.rb
128
+ - README
129
+ - COPYING
130
+ - INSTALL
131
+ has_rdoc: true
132
+ homepage: http://amazon.rubyforge.org
133
+ licenses: []
134
+
135
+ post_install_message:
136
+ rdoc_options:
137
+ - --title
138
+ - AWS::S3 -- Support for Amazon S3's REST api
139
+ - --main
140
+ - README
141
+ - --line-numbers
142
+ - --inline-source
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ hash: 3
151
+ segments:
152
+ - 0
153
+ version: "0"
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ hash: 3
160
+ segments:
161
+ - 0
162
+ version: "0"
163
+ requirements: []
164
+
165
+ rubyforge_project: amazon
166
+ rubygems_version: 1.6.2
167
+ signing_key:
168
+ specification_version: 3
169
+ summary: Client library for Amazon's Simple Storage Service's REST API
170
+ test_files:
171
+ - test/logging_test.rb
172
+ - test/service_test.rb
173
+ - test/remote/logging_test.rb
174
+ - test/remote/test_file.data
175
+ - test/remote/bucket_test.rb
176
+ - test/remote/object_test.rb
177
+ - test/remote/test_helper.rb
178
+ - test/remote/bittorrent_test.rb
179
+ - test/remote/acl_test.rb
180
+ - test/fixtures.rb
181
+ - test/bucket_test.rb
182
+ - test/response_test.rb
183
+ - test/parsing_test.rb
184
+ - test/authentication_test.rb
185
+ - test/object_test.rb
186
+ - test/test_helper.rb
187
+ - test/fixtures/errors.yml
188
+ - test/fixtures/logging.yml
189
+ - test/fixtures/buckets.yml
190
+ - test/fixtures/policies.yml
191
+ - test/fixtures/headers.yml
192
+ - test/fixtures/logs.yml
193
+ - test/fixtures/loglines.yml
194
+ - test/extensions_test.rb
195
+ - test/base_test.rb
196
+ - test/error_test.rb
197
+ - test/acl_test.rb
198
+ - test/connection_test.rb
199
+ - test/mocks/fake_response.rb