stevequinlan-aws-s3 0.6.3

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.rdoc +545 -0
  4. data/Rakefile +120 -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 +287 -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 +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 +341 -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 +110 -0
  58. metadata +159 -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,110 @@
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
+ # Data copied from http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAuthentication.html
15
+ module AmazonDocExampleData
16
+ module Example1
17
+ module_function
18
+
19
+ def request
20
+ request = Net::HTTP::Put.new('/quotes/nelson')
21
+ request['Content-Md5'] = 'c8fdb181845a4ca6b8fec737b3581d76'
22
+ request['Content-Type'] = 'text/html'
23
+ request['Date'] = 'Thu, 17 Nov 2005 18:49:58 GMT'
24
+ request['X-Amz-Meta-Author'] = 'foo@bar.com'
25
+ request['X-Amz-Magic'] = 'abracadabra'
26
+ request
27
+ end
28
+
29
+ def canonical_string
30
+ "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"
31
+ end
32
+
33
+ def access_key_id
34
+ '44CF9590006BF252F707'
35
+ end
36
+
37
+ def secret_access_key
38
+ 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
39
+ end
40
+
41
+ def signature
42
+ 'jZNOcbfWmD/A/f3hSvVzXZjM2HU='
43
+ end
44
+
45
+ def authorization_header
46
+ 'AWS 44CF9590006BF252F707:jZNOcbfWmD/A/f3hSvVzXZjM2HU='
47
+ end
48
+ end
49
+
50
+ module Example3
51
+ module_function
52
+
53
+ def request
54
+ request = Net::HTTP::Get.new('/quotes/nelson')
55
+ request['Date'] = date
56
+ request
57
+ end
58
+
59
+ def date
60
+ 'Thu Mar 9 01:24:20 CST 2006'
61
+ end
62
+
63
+ def access_key_id
64
+ Example1.access_key_id
65
+ end
66
+
67
+ def secret_access_key
68
+ Example1.secret_access_key
69
+ end
70
+
71
+ def expires
72
+ 1141889120
73
+ end
74
+
75
+ def query_string
76
+ 'AWSAccessKeyId=44CF9590006BF252F707&Expires=1141889120&Signature=vjbyPxybdZaNmGa%2ByT272YEAiv4%3D'
77
+ end
78
+
79
+ def canonical_string
80
+ "GET\n\n\n1141889120\n/quotes/nelson"
81
+ end
82
+
83
+ end
84
+ end
85
+
86
+ class Test::Unit::TestCase
87
+ include AWS::S3
88
+
89
+ def sample_proxy_settings
90
+ {:host => 'http://google.com', :port => 8080, :user => 'marcel', :password => 'secret'}
91
+ end
92
+
93
+ def mock_connection_for(klass, options = {})
94
+ data = options[:returns]
95
+ return_values = case data
96
+ when Hash
97
+ FakeResponse.new(data)
98
+ when Array
99
+ data.map {|hash| FakeResponse.new(hash)}
100
+ else
101
+ abort "Response data for mock connection must be a Hash or an Array. Was #{data.inspect}."
102
+ end
103
+
104
+ connection = flexmock('Mock connection') do |mock|
105
+ mock.should_receive(:request).and_return(*return_values).at_least.once
106
+ end
107
+
108
+ flexmock(klass).should_receive(:connection).and_return(connection)
109
+ end
110
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stevequinlan-aws-s3
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 6
8
+ - 3
9
+ version: 0.6.3
10
+ platform: ruby
11
+ authors:
12
+ - Marcel Molina Jr.
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-06 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: xml-simple
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: builder
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :runtime
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: mime-types
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ type: :runtime
55
+ version_requirements: *id003
56
+ description: Client library for Amazon's Simple Storage Service's REST API
57
+ email: marcel@vernix.org
58
+ executables:
59
+ - s3sh
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - README.rdoc
64
+ - COPYING
65
+ - INSTALL
66
+ files:
67
+ - Rakefile
68
+ - lib/aws/s3/acl.rb
69
+ - lib/aws/s3/authentication.rb
70
+ - lib/aws/s3/base.rb
71
+ - lib/aws/s3/bittorrent.rb
72
+ - lib/aws/s3/bucket.rb
73
+ - lib/aws/s3/connection.rb
74
+ - lib/aws/s3/error.rb
75
+ - lib/aws/s3/exceptions.rb
76
+ - lib/aws/s3/extensions.rb
77
+ - lib/aws/s3/logging.rb
78
+ - lib/aws/s3/object.rb
79
+ - lib/aws/s3/owner.rb
80
+ - lib/aws/s3/parsing.rb
81
+ - lib/aws/s3/response.rb
82
+ - lib/aws/s3/service.rb
83
+ - lib/aws/s3/version.rb
84
+ - lib/aws/s3.rb
85
+ - bin/s3sh
86
+ - bin/setup.rb
87
+ - support/faster-xml-simple/lib/faster_xml_simple.rb
88
+ - support/faster-xml-simple/test/regression_test.rb
89
+ - support/faster-xml-simple/test/test_helper.rb
90
+ - support/faster-xml-simple/test/xml_simple_comparison_test.rb
91
+ - support/rdoc/code_info.rb
92
+ - README.rdoc
93
+ - COPYING
94
+ - INSTALL
95
+ has_rdoc: true
96
+ homepage: http://amazon.rubyforge.org
97
+ licenses: []
98
+
99
+ post_install_message:
100
+ rdoc_options:
101
+ - --title
102
+ - AWS::S3 -- Support for Amazon S3's REST api
103
+ - --main
104
+ - README.rdoc
105
+ - --line-numbers
106
+ - --inline-source
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ requirements: []
124
+
125
+ rubyforge_project: amazon
126
+ rubygems_version: 1.3.6
127
+ signing_key:
128
+ specification_version: 3
129
+ summary: Client library for Amazon's Simple Storage Service's REST API
130
+ test_files:
131
+ - test/acl_test.rb
132
+ - test/authentication_test.rb
133
+ - test/base_test.rb
134
+ - test/bucket_test.rb
135
+ - test/connection_test.rb
136
+ - test/error_test.rb
137
+ - test/extensions_test.rb
138
+ - test/fixtures/buckets.yml
139
+ - test/fixtures/errors.yml
140
+ - test/fixtures/headers.yml
141
+ - test/fixtures/logging.yml
142
+ - test/fixtures/loglines.yml
143
+ - test/fixtures/logs.yml
144
+ - test/fixtures/policies.yml
145
+ - test/fixtures.rb
146
+ - test/logging_test.rb
147
+ - test/mocks/fake_response.rb
148
+ - test/object_test.rb
149
+ - test/parsing_test.rb
150
+ - test/remote/acl_test.rb
151
+ - test/remote/bittorrent_test.rb
152
+ - test/remote/bucket_test.rb
153
+ - test/remote/logging_test.rb
154
+ - test/remote/object_test.rb
155
+ - test/remote/test_file.data
156
+ - test/remote/test_helper.rb
157
+ - test/response_test.rb
158
+ - test/service_test.rb
159
+ - test/test_helper.rb