aws-s3 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/COPYING +19 -0
  2. data/INSTALL +35 -0
  3. data/README +529 -0
  4. data/Rakefile +284 -0
  5. data/bin/s3sh +4 -0
  6. data/bin/setup.rb +10 -0
  7. data/lib/aws/s3.rb +64 -0
  8. data/lib/aws/s3/acl.rb +631 -0
  9. data/lib/aws/s3/authentication.rb +218 -0
  10. data/lib/aws/s3/base.rb +232 -0
  11. data/lib/aws/s3/bittorrent.rb +58 -0
  12. data/lib/aws/s3/bucket.rb +323 -0
  13. data/lib/aws/s3/connection.rb +212 -0
  14. data/lib/aws/s3/error.rb +69 -0
  15. data/lib/aws/s3/exceptions.rb +130 -0
  16. data/lib/aws/s3/extensions.rb +186 -0
  17. data/lib/aws/s3/logging.rb +163 -0
  18. data/lib/aws/s3/object.rb +565 -0
  19. data/lib/aws/s3/owner.rb +44 -0
  20. data/lib/aws/s3/parsing.rb +138 -0
  21. data/lib/aws/s3/response.rb +180 -0
  22. data/lib/aws/s3/service.rb +43 -0
  23. data/lib/aws/s3/version.rb +12 -0
  24. data/support/faster-xml-simple/lib/faster_xml_simple.rb +115 -0
  25. data/support/faster-xml-simple/test/regression_test.rb +16 -0
  26. data/support/faster-xml-simple/test/xml_simple_comparison_test.rb +22 -0
  27. data/support/rdoc/code_info.rb +211 -0
  28. data/test/acl_test.rb +243 -0
  29. data/test/authentication_test.rb +96 -0
  30. data/test/base_test.rb +143 -0
  31. data/test/bucket_test.rb +48 -0
  32. data/test/connection_test.rb +120 -0
  33. data/test/error_test.rb +75 -0
  34. data/test/extensions_test.rb +282 -0
  35. data/test/fixtures.rb +89 -0
  36. data/test/fixtures/buckets.yml +102 -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/policies.yml +16 -0
  41. data/test/logging_test.rb +36 -0
  42. data/test/mocks/base.rb +89 -0
  43. data/test/object_test.rb +177 -0
  44. data/test/parsing_test.rb +82 -0
  45. data/test/remote/acl_test.rb +117 -0
  46. data/test/remote/bittorrent_test.rb +45 -0
  47. data/test/remote/bucket_test.rb +127 -0
  48. data/test/remote/logging_test.rb +82 -0
  49. data/test/remote/object_test.rb +267 -0
  50. data/test/remote/test_file.data +0 -0
  51. data/test/remote/test_helper.rb +30 -0
  52. data/test/response_test.rb +70 -0
  53. data/test/service_test.rb +26 -0
  54. data/test/test_helper.rb +82 -0
  55. metadata +125 -0
@@ -0,0 +1,30 @@
1
+ require 'test/unit'
2
+ require 'uri'
3
+ $:.unshift File.dirname(__FILE__) + '/../../lib'
4
+ require 'aws/s3'
5
+ require_library_or_gem 'breakpoint'
6
+
7
+ TEST_BUCKET = 'aws-s3-tests'
8
+ TEST_FILE = File.dirname(__FILE__) + '/test_file.data'
9
+
10
+ class Test::Unit::TestCase
11
+ include AWS::S3
12
+ def establish_real_connection
13
+ Base.establish_connection!(
14
+ :access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
15
+ :secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
16
+ )
17
+ end
18
+
19
+ def disconnect!
20
+ Base.disconnect
21
+ end
22
+
23
+ class TestBucket < Bucket
24
+ set_current_bucket_to TEST_BUCKET
25
+ end
26
+
27
+ class TestS3Object < S3Object
28
+ set_current_bucket_to TEST_BUCKET
29
+ end
30
+ end
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ class BaseResponseTest < Test::Unit::TestCase
3
+ def setup
4
+ @headers = {'content-type' => 'text/plain', 'date' => Time.now}
5
+ @response = FakeResponse.new()
6
+ @base_response = Base::Response.new(@response)
7
+ end
8
+
9
+ def test_status_predicates
10
+ response = Proc.new {|code| Base::Response.new(FakeResponse.new(:code => code))}
11
+ assert response[200].success?
12
+ assert response[300].redirect?
13
+ assert response[400].client_error?
14
+ assert response[500].server_error?
15
+ end
16
+
17
+ def test_headers_passed_along_from_original_response
18
+ assert_equal @response.headers, @base_response.headers
19
+ assert_equal @response['date'], @base_response['date']
20
+ original_headers, new_headers = {}, {}
21
+ @response.headers.each {|k,v| original_headers[k] = v}
22
+ @base_response.each {|k,v| new_headers[k] = v}
23
+ assert_equal original_headers, new_headers
24
+ end
25
+ end
26
+
27
+ class ErrorResponseTest < Test::Unit::TestCase
28
+ def test_error_responses_are_always_in_error
29
+ assert Error::Response.new(FakeResponse.new).error?
30
+ assert Error::Response.new(FakeResponse.new(:code => 200)).error?
31
+ assert Error::Response.new(FakeResponse.new(:headers => {'content-type' => 'text/plain'})).error?
32
+ end
33
+ end
34
+
35
+ class S3ObjectResponseTest < Test::Unit::TestCase
36
+ def test_etag_extracted
37
+ S3Object.in_test_mode do
38
+ S3Object.request_returns :headers => {"etag"=>"\"acbd18db4cc2f85cedef654fccc4a4d8\""}
39
+ object_response = S3Object.create('name_does_not_matter', 'data does not matter', 'bucket does not matter')
40
+ assert_equal "acbd18db4cc2f85cedef654fccc4a4d8", object_response.etag
41
+ end
42
+ end
43
+ end
44
+
45
+ class ResponseClassFinderTest < Test::Unit::TestCase
46
+ class CampfireBucket < Bucket
47
+ end
48
+
49
+ class BabyBase < Base
50
+ end
51
+
52
+ def test_on_base
53
+ assert_equal Base::Response, FindResponseClass.for(Base)
54
+ assert_equal Base::Response, FindResponseClass.for(AWS::S3::Base)
55
+
56
+ end
57
+
58
+ def test_on_subclass_with_corresponding_response_class
59
+ assert_equal Bucket::Response, FindResponseClass.for(Bucket)
60
+ assert_equal Bucket::Response, FindResponseClass.for(AWS::S3::Bucket)
61
+ end
62
+
63
+ def test_on_subclass_with_intermediary_parent_that_has_corresponding_response_class
64
+ assert_equal Bucket::Response, FindResponseClass.for(CampfireBucket)
65
+ end
66
+
67
+ def test_on_subclass_with_no_corresponding_response_class_and_no_intermediary_parent
68
+ assert_equal Base::Response, FindResponseClass.for(BabyBase)
69
+ end
70
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ServiceTest < Test::Unit::TestCase
4
+ def test_bucket_list_with_empty_bucket_list
5
+ Service.request_always_returns :body => Fixtures::Buckets.empty_bucket_list, :code => 200 do
6
+ list = Service.buckets(:reload)
7
+ assert_equal [], list
8
+ end
9
+ end
10
+
11
+ def test_bucket_list_with_bucket_list_containing_one_bucket
12
+ Service.request_always_returns :body => Fixtures::Buckets.bucket_list_with_one_bucket, :code => 200 do
13
+ list = Service.buckets(:reload)
14
+ assert_equal 1, list.size
15
+ assert_equal 'marcel_molina', list.first.name
16
+ end
17
+ end
18
+
19
+ def test_bucket_list_with_bucket_list_containing_more_than_one_bucket
20
+ Service.request_always_returns :body => Fixtures::Buckets.bucket_list_with_more_than_one_bucket, :code => 200 do
21
+ list = Service.buckets(:reload)
22
+ assert_equal 2, list.size
23
+ assert_equal %w(marcel_molina marcel_molina_jr), list.map {|bucket| bucket.name}.sort
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,82 @@
1
+ require 'test/unit'
2
+ $:.unshift File.dirname(__FILE__) + '/../lib'
3
+ require 'aws/s3'
4
+ require File.dirname(__FILE__) + '/mocks/base'
5
+ require File.dirname(__FILE__) + '/fixtures'
6
+ require_library_or_gem 'breakpoint'
7
+
8
+ # Data copied from http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAuthentication.html
9
+ module AmazonDocExampleData
10
+ module Example1
11
+ module_function
12
+
13
+ def request
14
+ request = Net::HTTP::Put.new('/quotes/nelson')
15
+ request['Content-Md5'] = 'c8fdb181845a4ca6b8fec737b3581d76'
16
+ request['Content-Type'] = 'text/html'
17
+ request['Date'] = 'Thu, 17 Nov 2005 18:49:58 GMT'
18
+ request['X-Amz-Meta-Author'] = 'foo@bar.com'
19
+ request['X-Amz-Magic'] = 'abracadabra'
20
+ request
21
+ end
22
+
23
+ def canonical_string
24
+ "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"
25
+ end
26
+
27
+ def access_key_id
28
+ '44CF9590006BF252F707'
29
+ end
30
+
31
+ def secret_access_key
32
+ 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
33
+ end
34
+
35
+ def signature
36
+ 'jZNOcbfWmD/A/f3hSvVzXZjM2HU='
37
+ end
38
+
39
+ def authorization_header
40
+ 'AWS 44CF9590006BF252F707:jZNOcbfWmD/A/f3hSvVzXZjM2HU='
41
+ end
42
+ end
43
+
44
+ module Example3
45
+ module_function
46
+
47
+ def request
48
+ request = Net::HTTP::Get.new('/quotes/nelson')
49
+ request['Date'] = date
50
+ request
51
+ end
52
+
53
+ def date
54
+ 'Thu Mar 9 01:24:20 CST 2006'
55
+ end
56
+
57
+ def access_key_id
58
+ Example1.access_key_id
59
+ end
60
+
61
+ def secret_access_key
62
+ Example1.secret_access_key
63
+ end
64
+
65
+ def expires
66
+ 1141889120
67
+ end
68
+
69
+ def query_string
70
+ 'AWSAccessKeyId=44CF9590006BF252F707&Expires=1141889120&Signature=vjbyPxybdZaNmGa%2ByT272YEAiv4%3D'
71
+ end
72
+
73
+ def canonical_string
74
+ "GET\n\n\n1141889120\n/quotes/nelson"
75
+ end
76
+
77
+ end
78
+ end
79
+
80
+ class Test::Unit::TestCase
81
+ include AWS::S3
82
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: aws-s3
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2006-11-28 00:00:00 -06:00
8
+ summary: Client library for Amazon's Simple Storage Service's REST API
9
+ require_paths:
10
+ - lib
11
+ email: marcel@vernix.org
12
+ homepage: http://amazon.rubyforge.org
13
+ rubyforge_project: amazon
14
+ description: Client library for Amazon's Simple Storage Service's REST API
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Marcel Molina Jr.
31
+ files:
32
+ - Rakefile
33
+ - lib/aws/s3.rb
34
+ - lib/aws/s3/acl.rb
35
+ - lib/aws/s3/authentication.rb
36
+ - lib/aws/s3/base.rb
37
+ - lib/aws/s3/bittorrent.rb
38
+ - lib/aws/s3/bucket.rb
39
+ - lib/aws/s3/connection.rb
40
+ - lib/aws/s3/error.rb
41
+ - lib/aws/s3/exceptions.rb
42
+ - lib/aws/s3/extensions.rb
43
+ - lib/aws/s3/logging.rb
44
+ - lib/aws/s3/object.rb
45
+ - lib/aws/s3/owner.rb
46
+ - lib/aws/s3/parsing.rb
47
+ - lib/aws/s3/response.rb
48
+ - lib/aws/s3/service.rb
49
+ - lib/aws/s3/version.rb
50
+ - bin/s3sh
51
+ - bin/setup.rb
52
+ - support/faster-xml-simple/lib/faster_xml_simple.rb
53
+ - support/faster-xml-simple/test/regression_test.rb
54
+ - support/faster-xml-simple/test/xml_simple_comparison_test.rb
55
+ - support/rdoc/code_info.rb
56
+ - README
57
+ - COPYING
58
+ - INSTALL
59
+ test_files:
60
+ - test/acl_test.rb
61
+ - test/authentication_test.rb
62
+ - test/base_test.rb
63
+ - test/bucket_test.rb
64
+ - test/connection_test.rb
65
+ - test/error_test.rb
66
+ - test/extensions_test.rb
67
+ - test/fixtures
68
+ - test/fixtures.rb
69
+ - test/logging_test.rb
70
+ - test/mocks
71
+ - test/object_test.rb
72
+ - test/parsing_test.rb
73
+ - test/remote
74
+ - test/response_test.rb
75
+ - test/service_test.rb
76
+ - test/test_helper.rb
77
+ - test/fixtures/buckets.yml
78
+ - test/fixtures/errors.yml
79
+ - test/fixtures/headers.yml
80
+ - test/fixtures/logging.yml
81
+ - test/fixtures/policies.yml
82
+ - test/mocks/base.rb
83
+ - test/remote/acl_test.rb
84
+ - test/remote/bittorrent_test.rb
85
+ - test/remote/bucket_test.rb
86
+ - test/remote/logging_test.rb
87
+ - test/remote/object_test.rb
88
+ - test/remote/test_file.data
89
+ - test/remote/test_helper.rb
90
+ rdoc_options:
91
+ - --title
92
+ - AWS::S3 -- Support for Amazon S3's REST api
93
+ - --main
94
+ - README
95
+ - --line-numbers
96
+ - --inline-source
97
+ extra_rdoc_files:
98
+ - README
99
+ - COPYING
100
+ - INSTALL
101
+ executables:
102
+ - s3sh
103
+ extensions: []
104
+
105
+ requirements: []
106
+
107
+ dependencies:
108
+ - !ruby/object:Gem::Dependency
109
+ name: xml-simple
110
+ version_requirement:
111
+ version_requirements: !ruby/object:Gem::Version::Requirement
112
+ requirements:
113
+ - - ">"
114
+ - !ruby/object:Gem::Version
115
+ version: 0.0.0
116
+ version:
117
+ - !ruby/object:Gem::Dependency
118
+ name: builder
119
+ version_requirement:
120
+ version_requirements: !ruby/object:Gem::Version::Requirement
121
+ requirements:
122
+ - - ">"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.0
125
+ version: