s33r 0.3.1 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/cli/acl_x.rb +41 -0
- data/examples/cli/logging_x.rb +20 -0
- data/{bin → examples/cli}/s3cli.rb +13 -20
- data/examples/fores33r/README +183 -0
- data/examples/fores33r/Rakefile +10 -0
- data/examples/fores33r/app/controllers/application.rb +4 -0
- data/examples/fores33r/app/controllers/browser_controller.rb +68 -0
- data/examples/fores33r/app/helpers/application_helper.rb +8 -0
- data/examples/fores33r/app/views/browser/index.rhtml +14 -0
- data/examples/fores33r/app/views/browser/show_bucket.rhtml +14 -0
- data/examples/fores33r/app/views/layouts/application.rhtml +29 -0
- data/examples/fores33r/config/boot.rb +44 -0
- data/examples/fores33r/config/database.yml +35 -0
- data/examples/fores33r/config/environment.rb +64 -0
- data/examples/fores33r/config/environments/development.rb +21 -0
- data/examples/fores33r/config/environments/production.rb +18 -0
- data/examples/fores33r/config/environments/test.rb +19 -0
- data/examples/fores33r/config/routes.rb +23 -0
- data/examples/fores33r/doc/README_FOR_APP +2 -0
- data/examples/fores33r/log/development.log +5507 -0
- data/examples/fores33r/log/production.log +0 -0
- data/examples/fores33r/log/server.log +0 -0
- data/examples/fores33r/log/test.log +0 -0
- data/examples/fores33r/public/404.html +8 -0
- data/examples/fores33r/public/500.html +8 -0
- data/examples/fores33r/public/dispatch.cgi +10 -0
- data/examples/fores33r/public/dispatch.fcgi +24 -0
- data/examples/fores33r/public/dispatch.rb +10 -0
- data/examples/fores33r/public/favicon.ico +0 -0
- data/examples/fores33r/public/images/rails.png +0 -0
- data/examples/fores33r/public/javascripts/application.js +2 -0
- data/examples/fores33r/public/javascripts/controls.js +815 -0
- data/examples/fores33r/public/javascripts/dragdrop.js +913 -0
- data/examples/fores33r/public/javascripts/effects.js +958 -0
- data/examples/fores33r/public/javascripts/prototype.js +2006 -0
- data/examples/fores33r/public/robots.txt +1 -0
- data/examples/fores33r/public/stylesheets/core.css +37 -0
- data/examples/fores33r/script/about +3 -0
- data/examples/fores33r/script/breakpointer +3 -0
- data/examples/fores33r/script/console +3 -0
- data/examples/fores33r/script/destroy +3 -0
- data/examples/fores33r/script/generate +3 -0
- data/examples/fores33r/script/performance/benchmarker +3 -0
- data/examples/fores33r/script/performance/profiler +3 -0
- data/examples/fores33r/script/plugin +3 -0
- data/examples/fores33r/script/process/reaper +3 -0
- data/examples/fores33r/script/process/spawner +3 -0
- data/examples/fores33r/script/runner +3 -0
- data/examples/fores33r/script/server +3 -0
- data/examples/fores33r/test/test_helper.rb +28 -0
- data/examples/fores33r/tmp/sessions/ruby_sess.39d37e054d21d545 +0 -0
- data/examples/fores33r/tmp/sessions/ruby_sess.acf71fc73aa74983 +0 -0
- data/examples/fores33r/tmp/sessions/ruby_sess.c1697b7d6670f3cd +0 -0
- data/examples/s3.yaml +11 -0
- data/html/classes/Net/HTTPGenericRequest.html +32 -32
- data/html/classes/Net/HTTPResponse.html +20 -19
- data/html/classes/S33r.html +422 -190
- data/html/classes/S33r/BucketListing.html +107 -70
- data/html/classes/S33r/Client.html +888 -414
- data/html/classes/S33r/LoggingResource.html +222 -0
- data/html/classes/S33r/NamedBucket.html +149 -150
- data/html/classes/S33r/OrderlyXmlMarkup.html +165 -0
- data/html/classes/S33r/S33rException.html +3 -0
- data/html/classes/S33r/S33rException/BucketNotLogTargetable.html +119 -0
- data/html/classes/S33r/S33rException/InvalidPermission.html +111 -0
- data/html/classes/S33r/S33rException/InvalidS3GroupType.html +111 -0
- data/html/classes/S33r/S3ACL.html +125 -0
- data/html/classes/S33r/S3ACL/ACLDoc.html +521 -0
- data/html/classes/S33r/{S3User.html → S3ACL/AmazonCustomer.html} +27 -30
- data/html/classes/S33r/S3ACL/CanonicalUser.html +212 -0
- data/html/classes/S33r/S3ACL/Grant.html +403 -0
- data/html/classes/S33r/S3ACL/Grantee.html +239 -0
- data/html/classes/S33r/S3ACL/Group.html +178 -0
- data/html/classes/S33r/S3Object.html +53 -50
- data/html/classes/S33r/Sync.html +6 -6
- data/html/classes/XML.html +4 -2
- data/html/created.rid +1 -1
- data/html/files/README_txt.html +82 -28
- data/html/files/lib/s33r/bucket_listing_rb.html +1 -8
- data/html/files/lib/s33r/builder_rb.html +108 -0
- data/html/files/lib/s33r/client_rb.html +2 -1
- data/html/files/lib/s33r/core_rb.html +2 -1
- data/html/files/lib/s33r/libxml_extensions_rb.html +1 -1
- data/html/files/lib/s33r/logging_rb.html +109 -0
- data/html/files/lib/s33r/named_bucket_rb.html +1 -1
- data/html/files/lib/s33r/s33r_exception_rb.html +1 -1
- data/html/files/lib/s33r/s33r_http_rb.html +1 -1
- data/html/files/lib/s33r/s3_acl_rb.html +109 -0
- data/html/fr_class_index.html +12 -1
- data/html/fr_file_index.html +3 -0
- data/html/fr_method_index.html +101 -57
- data/lib/s33r/bucket_listing.rb +21 -22
- data/lib/s33r/builder.rb +20 -0
- data/lib/s33r/client.rb +240 -42
- data/lib/s33r/core.rb +106 -36
- data/lib/s33r/libxml_extensions.rb +2 -2
- data/lib/s33r/logging.rb +43 -0
- data/lib/s33r/named_bucket.rb +16 -17
- data/lib/s33r/s33r_exception.rb +11 -0
- data/lib/s33r/s33r_http.rb +2 -1
- data/lib/s33r/s3_acl.rb +337 -0
- data/test/cases/spec_acl.rb +146 -0
- data/test/cases/spec_all_buckets.rb +28 -0
- data/test/cases/spec_bucket_listing.rb +2 -2
- data/test/cases/spec_client.rb +45 -18
- data/test/cases/spec_core.rb +0 -9
- data/test/cases/spec_namedbucket.rb +3 -3
- data/test/files/acl.xml +47 -0
- data/test/files/acl_grant1.xml +7 -0
- data/test/files/acl_grant2.xml +6 -0
- data/test/files/acl_grant3.xml +6 -0
- data/test/files/acl_grant4.xml +6 -0
- data/test/files/all_buckets.xml +21 -0
- data/test/files/bucket_listing.xml +138 -1
- data/test/files/client_config.yml +0 -1
- data/test/files/logging_acl.xml +34 -0
- data/test/files/namedbucket_config.yml +1 -5
- data/test/files/namedbucket_config2.yml +1 -5
- data/test/test_setup.rb +1 -0
- metadata +132 -7
@@ -0,0 +1,146 @@
|
|
1
|
+
base = File.dirname(__FILE__)
|
2
|
+
require base + '/../test_setup'
|
3
|
+
|
4
|
+
context 'S33r ACL functions' do
|
5
|
+
setup do
|
6
|
+
@acl_grant_xml1 = clean_xml(File.open(File.join(File.dirname(__FILE__), '../files/acl_grant1.xml')).read)
|
7
|
+
@canonical_user = CanonicalUser.new('a9a7b886d6fd24a52fe8ca5bef65f89a64e0193f23000e241bf9b1c61be666e9',
|
8
|
+
'chriscustomer')
|
9
|
+
@canonical_user_grant = Grant.new(@canonical_user, :all)
|
10
|
+
@canonical_user2 = CanonicalUser.new('baa7b886d6fd24a52fe8ca5bef65f89a64e0193f23000e241bf9b1c61be666e9',
|
11
|
+
'mimbo')
|
12
|
+
@canonical_user_grant2 = Grant.new(@canonical_user2, :read)
|
13
|
+
|
14
|
+
@acl_grant_xml2 = clean_xml(File.open(File.join(File.dirname(__FILE__), '../files/acl_grant2.xml')).read)
|
15
|
+
@amazon_grantee = AmazonCustomer.new('elliot@test.org')
|
16
|
+
@amazon_grant = Grant.new(@amazon_grantee, :read)
|
17
|
+
@amazon_grantee2 = AmazonCustomer.new('bingo@blinky.com')
|
18
|
+
@amazon_grant2 = Grant.new(@amazon_grantee2, :write)
|
19
|
+
|
20
|
+
@acl_grant_xml3 = clean_xml(File.open(File.join(File.dirname(__FILE__), '../files/acl_grant3.xml')).read)
|
21
|
+
@group_grantee = Group.new(:all_users)
|
22
|
+
@group_grant = Grant.new(@group_grantee, :write)
|
23
|
+
|
24
|
+
@acl_grant_xml4 = clean_xml(File.open(File.join(File.dirname(__FILE__), '../files/acl_grant4.xml')).read)
|
25
|
+
@group_grantee2 = Group.new(:authenticated_users)
|
26
|
+
@group_grant2 = Grant.new(@group_grantee2, :read_acl)
|
27
|
+
|
28
|
+
@full_acl_xml = clean_xml(File.open(File.join(File.dirname(__FILE__), '../files/acl.xml')).read)
|
29
|
+
@full_acl_doc = ACLDoc.new(@canonical_user)
|
30
|
+
@full_acl_doc.grants = [@canonical_user_grant, @canonical_user_grant2, @amazon_grant,
|
31
|
+
@amazon_grant2, @group_grant, @group_grant2]
|
32
|
+
|
33
|
+
# Grants created using convenience methods
|
34
|
+
@con_canonical_user_grant = Grant.for_canonical_user('a9a7b886d6fd24a52fe8ca5bef65f89a64e0193f23000e241bf9b1c61be666e9',
|
35
|
+
'chriscustomer', :all)
|
36
|
+
@con_canonical_user_grant2 = Grant.for_canonical_user('baa7b886d6fd24a52fe8ca5bef65f89a64e0193f23000e241bf9b1c61be666e9',
|
37
|
+
'mimbo', :read)
|
38
|
+
@con_amazon_grant = Grant.for_amazon_customer('elliot@test.org', :read)
|
39
|
+
@con_amazon_grant2 = Grant.for_amazon_customer('bingo@blinky.com', :write)
|
40
|
+
@con_group_grant1 = Grant.for_group(:all_users, :write)
|
41
|
+
@con_group_grant2 = Grant.for_group(:authenticated_users, :read_acl)
|
42
|
+
@con_full_acl_doc = ACLDoc.new(@canonical_user)
|
43
|
+
@con_full_acl_doc.grants = [@con_canonical_user_grant, @con_canonical_user_grant2,
|
44
|
+
@con_amazon_grant, @con_amazon_grant2, @con_group_grant1, @con_group_grant2]
|
45
|
+
|
46
|
+
# Tests for logging ACLs
|
47
|
+
@logging_acl_xml = clean_xml(File.open(File.join(File.dirname(__FILE__), '../files/logging_acl.xml')).read)
|
48
|
+
@logging_acl_doc = ACLDoc.from_xml(@logging_acl_xml)
|
49
|
+
@log_delivery_write = Grant.for_group(:log_delivery, :write)
|
50
|
+
@log_delivery_read_acl = Grant.for_group(:log_delivery, :read_acl)
|
51
|
+
|
52
|
+
# clone without the logging grants
|
53
|
+
@logging_acl_doc_no_grants = ACLDoc.from_xml(@logging_acl_xml)
|
54
|
+
@logging_acl_doc_no_grants.grants.delete_if { |g| @log_delivery_write == g or @log_delivery_read_acl == g }
|
55
|
+
end
|
56
|
+
|
57
|
+
specify 'should represent a grant for a CanonicalUser' do
|
58
|
+
clean_xml(@canonical_user_grant.to_xml).should.equal @acl_grant_xml1
|
59
|
+
end
|
60
|
+
|
61
|
+
specify 'should represent a grant for an AmazonUserByEmail' do
|
62
|
+
clean_xml(@amazon_grant.to_xml).should.equal @acl_grant_xml2
|
63
|
+
end
|
64
|
+
|
65
|
+
specify 'should represent a grant for AllUsers' do
|
66
|
+
clean_xml(@group_grant.to_xml).should.equal @acl_grant_xml3
|
67
|
+
end
|
68
|
+
|
69
|
+
specify 'should represent a grant for AuthenticatedUsers' do
|
70
|
+
clean_xml(@group_grant2.to_xml).should.equal @acl_grant_xml4
|
71
|
+
end
|
72
|
+
|
73
|
+
specify 'should generate a valid AccessControlPolicy document' do
|
74
|
+
clean_xml(@full_acl_doc.to_xml).should.equal @full_acl_xml
|
75
|
+
end
|
76
|
+
|
77
|
+
specify 'should provide convenience classes for grants' do
|
78
|
+
clean_xml(@con_full_acl_doc.to_xml).should.equal @full_acl_xml
|
79
|
+
end
|
80
|
+
|
81
|
+
specify 'needs equality method for grantees' do
|
82
|
+
test_grantee = Group.new(:all_users)
|
83
|
+
test_grantee.should.equal @group_grantee
|
84
|
+
test_grantee.should.not.equal @amazon_grantee
|
85
|
+
end
|
86
|
+
|
87
|
+
specify 'should only accept valid permission specifiers' do
|
88
|
+
lambda { Grant.new(@group_grantee, nil) }.should.raise InvalidPermission
|
89
|
+
lambda { Grant.new(@group_grantee, :broken) }.should.raise InvalidPermission
|
90
|
+
end
|
91
|
+
|
92
|
+
specify 'should correctly create AmazonCustomer grantee from XML node' do
|
93
|
+
xml = "<Grantee xsi:type='AmazonCustomerByEmail' xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
|
94
|
+
"<EmailAddress>elliot@test.org</EmailAddress>" +
|
95
|
+
"</Grantee>"
|
96
|
+
doc = XML.get_xml_doc(xml)
|
97
|
+
grantee = Grantee.from_xml(doc)
|
98
|
+
grantee.should.equal @amazon_grantee
|
99
|
+
end
|
100
|
+
|
101
|
+
specify 'should correctly create Group grantee from XML node' do
|
102
|
+
xml = "<Grantee xsi:type=\"Group\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
|
103
|
+
"<URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>" +
|
104
|
+
"</Grantee>"
|
105
|
+
doc = XML.get_xml_doc(xml)
|
106
|
+
grantee = Grantee.from_xml(doc)
|
107
|
+
grantee.should.equal @group_grantee
|
108
|
+
end
|
109
|
+
|
110
|
+
specify 'should correctly create Group grantee for AuthenticatedUsers from XML node' do
|
111
|
+
xml = "<Grantee xsi:type=\"Group\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
|
112
|
+
"<URI>http://acs.amazonaws.com/groups/global/AuthenticatedUsers</URI>" +
|
113
|
+
"</Grantee>"
|
114
|
+
doc = XML.get_xml_doc(xml)
|
115
|
+
grantee = Grantee.from_xml(doc)
|
116
|
+
grantee.should.equal @group_grantee2
|
117
|
+
p grantee.group_type
|
118
|
+
p @group_grantee2.group_type
|
119
|
+
end
|
120
|
+
|
121
|
+
specify 'should parse AccessControlPolicy documents' do
|
122
|
+
acl_doc_from_xml = ACLDoc.from_xml(@full_acl_xml)
|
123
|
+
acl_doc_from_xml.owner.should.equal @full_acl_doc.owner
|
124
|
+
@full_acl_doc.grants.each do |g|
|
125
|
+
acl_doc_from_xml.grants = acl_doc_from_xml.grants.delete_if { |i| i == g }
|
126
|
+
end
|
127
|
+
acl_doc_from_xml.grants.should.be.empty
|
128
|
+
end
|
129
|
+
|
130
|
+
specify 'should represent LogDelivery grants so buckets can act as logging targets' do
|
131
|
+
@logging_acl_doc.grants.should.include @log_delivery_write
|
132
|
+
@logging_acl_doc.grants.should.include @log_delivery_read_acl
|
133
|
+
end
|
134
|
+
|
135
|
+
specify 'should be able to report whether an ACL indicates bucket is a logging target' do
|
136
|
+
@logging_acl_doc.log_targetable?.should.be true
|
137
|
+
|
138
|
+
# check the variant where the grants have been removed
|
139
|
+
@logging_acl_doc_no_grants.log_targetable?.should.be false
|
140
|
+
end
|
141
|
+
|
142
|
+
specify 'should be able to simply add logging target grants to an ACL' do
|
143
|
+
@logging_acl_doc_no_grants.add_log_target_grants
|
144
|
+
clean_xml(@logging_acl_doc_no_grants.to_xml).should.equal @logging_acl_xml
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
base = File.dirname(__FILE__)
|
2
|
+
require base + '/../test_setup'
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require_gem 'FakeWeb'
|
6
|
+
|
7
|
+
context 'S33r list of all buckets' do
|
8
|
+
setup do
|
9
|
+
@client = Client.new(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY, :use_ssl => false, :dump_requests => true)
|
10
|
+
|
11
|
+
xml_file = File.join(File.dirname(__FILE__), '../files/all_buckets.xml')
|
12
|
+
@list_all_buckets_result = File.open(xml_file) { |f| f.read }
|
13
|
+
|
14
|
+
listallbuckets_response = Net::HTTPResponse.new('1.1', '200', 'OK')
|
15
|
+
listallbuckets_response.body = @list_all_buckets_result
|
16
|
+
|
17
|
+
base_url = s3_url('/')
|
18
|
+
FakeWeb.register_uri(base_url, :status => 200, :response => listallbuckets_response)
|
19
|
+
FakeWeb.register_uri(base_url + 'elliotsmith-backup', :status => 200)
|
20
|
+
FakeWeb.register_uri(base_url + 'elliotsmith-helloworld', :status => 200)
|
21
|
+
FakeWeb.register_uri(base_url + 'elliotsmith-herbert', :status => 200)
|
22
|
+
end
|
23
|
+
|
24
|
+
specify 'should parse ListAllMyBucketsResult and get right number of buckets' do
|
25
|
+
buckets = @client.list_buckets
|
26
|
+
buckets.size.should.be 3
|
27
|
+
end
|
28
|
+
end
|
@@ -103,9 +103,9 @@ context 'S3 object' do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
specify 'should treat the owner as an object in his/her own right' do
|
106
|
-
[@s3obj.owner.
|
106
|
+
[@s3obj.owner.user_id, @s3obj.owner.display_name].should.equal \
|
107
107
|
['56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4', 'elliotsmith3']
|
108
|
-
@s3obj.owner.should_be_instance_of
|
108
|
+
@s3obj.owner.should_be_instance_of S3ACL::CanonicalUser
|
109
109
|
end
|
110
110
|
|
111
111
|
specify 'can be associated with a NamedBucket' do
|
data/test/cases/spec_client.rb
CHANGED
@@ -7,31 +7,48 @@ require_gem 'FakeWeb'
|
|
7
7
|
context 'S33r Client' do
|
8
8
|
setup do
|
9
9
|
@base = File.dirname(__FILE__)
|
10
|
+
|
11
|
+
# client for testing: one without SSL, one with
|
10
12
|
@client = Client.new(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY, :use_ssl => false, :dump_requests => true)
|
11
13
|
@client2 = Client.new(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY)
|
12
|
-
@bucket = 'testingtesting'
|
13
|
-
@url = url_join('http://', HOST, @bucket)
|
14
14
|
|
15
|
+
# test config. files
|
15
16
|
@plain_config_file = File.join(@base, '../files/client_config.yml')
|
16
17
|
@custom_config_file = File.join(@base, '../files/namedbucket_config.yml')
|
17
18
|
|
19
|
+
# OK bucket with attached response
|
20
|
+
@bucket = 'testingtesting'
|
21
|
+
@url = s3_public_url(@bucket)
|
18
22
|
xml_file = File.join(@base, '../files/bucket_listing.xml')
|
19
23
|
@bucket_listing_xml = File.open(xml_file) { |f| f.read }
|
20
|
-
|
21
24
|
listbucket_response = Net::HTTPResponse.new('1.1', '200', 'OK')
|
22
25
|
listbucket_response.body = @bucket_listing_xml
|
23
|
-
|
24
26
|
FakeWeb.register_uri(@url, :status => 200, :response => listbucket_response)
|
25
27
|
|
26
|
-
# for testing behaviour if S3 is unavailable
|
28
|
+
# broken bucket: for testing behaviour if S3 is unavailable
|
27
29
|
@bucket2 = 's3broken'
|
28
|
-
@url2 =
|
30
|
+
@url2 = s3_public_url(@bucket2)
|
29
31
|
FakeWeb.register_uri(@url2, :status => 503)
|
32
|
+
|
33
|
+
# OK resource
|
34
|
+
@resource_key = 'iamhere'
|
35
|
+
@url3 = s3_public_url(@bucket, @resource_key)
|
36
|
+
FakeWeb.register_uri(@url3, :status => 200)
|
37
|
+
|
38
|
+
# missing resource
|
39
|
+
@missing_resource = 'iammissing'
|
40
|
+
@url4 = s3_public_url(@bucket, @missing_resource)
|
41
|
+
FakeWeb.register_uri(@url4, :status => 404)
|
42
|
+
|
43
|
+
# missing bucket
|
44
|
+
@missing_bucket = 'iamamissingbucket'
|
45
|
+
@url5 = s3_public_url(@missing_bucket)
|
46
|
+
FakeWeb.register_uri(@url5, :status => 404)
|
30
47
|
end
|
31
48
|
|
32
49
|
specify 'should return use_ssl setting correctly' do
|
33
|
-
@client.use_ssl
|
34
|
-
@client2.use_ssl
|
50
|
+
@client.use_ssl.should.not.be true
|
51
|
+
@client2.use_ssl.should.be true
|
35
52
|
end
|
36
53
|
|
37
54
|
specify 'should trap max_keys too high in bucket listing request' do
|
@@ -40,19 +57,22 @@ context 'S33r Client' do
|
|
40
57
|
end
|
41
58
|
|
42
59
|
specify 'should fetch bucket listing ok' do
|
43
|
-
resp,
|
60
|
+
resp, listing = @client.list_bucket(@bucket)
|
44
61
|
resp.ok?.should.be true
|
45
62
|
end
|
46
63
|
|
64
|
+
# NB tests for content of BucketListing in depth are done in spec_bucket_listing
|
65
|
+
specify 'should attach BucketListing instance to ListBucketResult responses' do
|
66
|
+
resp, listing = @client.list_bucket(@bucket)
|
67
|
+
listing.should.be.an_instance_of BucketListing
|
68
|
+
listing.contents.size.should.be 10
|
69
|
+
end
|
70
|
+
|
47
71
|
specify 'can be initialised from plain config file' do
|
48
72
|
c = Client.init(@plain_config_file)
|
49
73
|
c.aws_access_key.should.equal 'youraccesskey'
|
50
74
|
c.aws_secret_access_key.should.equal 'yoursecretkey'
|
51
75
|
end
|
52
|
-
|
53
|
-
specify 'should attach BucketListing instance to ListBucketResult responses' do
|
54
|
-
todo
|
55
|
-
end
|
56
76
|
|
57
77
|
specify 'should retain leading slashes on keys when constructing request URLs' do
|
58
78
|
todo
|
@@ -62,13 +82,20 @@ context 'S33r Client' do
|
|
62
82
|
lambda { @client.list_bucket(@bucket2) }.should.raise S3FallenOver
|
63
83
|
end
|
64
84
|
|
65
|
-
specify 'should return S3Object with metadata properties' do
|
85
|
+
specify 'should return S3Object with metadata properties when getting a resource key' do
|
66
86
|
todo
|
67
87
|
end
|
68
88
|
|
69
|
-
specify 'should
|
70
|
-
|
71
|
-
|
72
|
-
|
89
|
+
specify 'should identify whether resources exist' do
|
90
|
+
# resource_exists? should work just with a bucket name
|
91
|
+
@client.resource_exists?(@bucket).should.be true
|
92
|
+
|
93
|
+
# these ones exist
|
94
|
+
@client.bucket_exists?(@bucket).should.be true
|
95
|
+
@client.resource_exists?(@bucket, @resource_key).should.be true
|
96
|
+
|
97
|
+
# the missing ones
|
98
|
+
@client.resource_exists?(@bucket, @missing_resource).should.be false
|
99
|
+
@client.bucket_exists?(@missing_bucket).should.be false
|
73
100
|
end
|
74
101
|
end
|
data/test/cases/spec_core.rb
CHANGED
@@ -115,15 +115,6 @@ context 'S33r core' do
|
|
115
115
|
specify 'should convert integers to strings when generating querystrings' do
|
116
116
|
generate_querystring({ 'max-keys' => 400 }).should.equal('?max-keys=400')
|
117
117
|
end
|
118
|
-
|
119
|
-
specify 'should be able to construct correct URL paths from path fragments' do
|
120
|
-
url_join('http://', 'localhost/', 'test').should.equal('http://localhost/test')
|
121
|
-
url_join('ftp://test.com', '/public/', '/files').should.equal('ftp://test.com/public/files')
|
122
|
-
url_join('http://localhost/', '/index.html').should.equal('http://localhost/index.html')
|
123
|
-
url_join('http://', 'localhost', 'test').should.equal('http://localhost/test')
|
124
|
-
url_join('http://localhost:8080/test/', '/path/', 'element.html').should.equal('http://localhost:8080/test/path/element.html')
|
125
|
-
url_join('/test/', 'index.html').should.equal '/test/index.html'
|
126
|
-
end
|
127
118
|
|
128
119
|
specify 'should generate URLs with authentication parameters' do
|
129
120
|
s3_authenticated_url(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY, 'quotes', 'nelson', \
|
@@ -9,7 +9,7 @@ context 'NamedBucket client' do
|
|
9
9
|
@base = File.dirname(__FILE__)
|
10
10
|
@config_filename = @base + '/../files/namedbucket_config.yml'
|
11
11
|
@config_filename2 = @base + '/../files/namedbucket_config2.yml'
|
12
|
-
@url =
|
12
|
+
@url = s3_public_url('nobucket')
|
13
13
|
end
|
14
14
|
|
15
15
|
specify 'should keep a copy of the current bucket listing inside as a property' do
|
@@ -33,10 +33,10 @@ context 'NamedBucket client' do
|
|
33
33
|
client = NamedBucket.init(@config_filename)
|
34
34
|
client.aws_access_key.should.equal 'youraccesskey'
|
35
35
|
client.aws_secret_access_key.should.equal 'yoursecretkey'
|
36
|
-
client.
|
36
|
+
client.name.should.equal 'nobucket'
|
37
37
|
client.strict?.should.be false
|
38
38
|
client.public_contents?.should.be true
|
39
|
-
client.use_ssl
|
39
|
+
client.use_ssl.should.be false
|
40
40
|
end
|
41
41
|
|
42
42
|
specify 'cannot be initialised for non-existent bucket' do
|
data/test/files/acl.xml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
3
|
+
<Owner>
|
4
|
+
<ID>a9a7b886d6fd24a52fe8ca5bef65f89a64e0193f23000e241bf9b1c61be666e9</ID>
|
5
|
+
<DisplayName>chriscustomer</DisplayName>
|
6
|
+
</Owner>
|
7
|
+
<AccessControlList>
|
8
|
+
<Grant>
|
9
|
+
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
|
10
|
+
<ID>a9a7b886d6fd24a52fe8ca5bef65f89a64e0193f23000e241bf9b1c61be666e9</ID>
|
11
|
+
<DisplayName>chriscustomer</DisplayName>
|
12
|
+
</Grantee>
|
13
|
+
<Permission>FULL_CONTROL</Permission>
|
14
|
+
</Grant>
|
15
|
+
<Grant>
|
16
|
+
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
|
17
|
+
<ID>baa7b886d6fd24a52fe8ca5bef65f89a64e0193f23000e241bf9b1c61be666e9</ID>
|
18
|
+
<DisplayName>mimbo</DisplayName>
|
19
|
+
</Grantee>
|
20
|
+
<Permission>READ</Permission>
|
21
|
+
</Grant>
|
22
|
+
<Grant>
|
23
|
+
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AmazonCustomerByEmail">
|
24
|
+
<EmailAddress>elliot@test.org</EmailAddress>
|
25
|
+
</Grantee>
|
26
|
+
<Permission>READ</Permission>
|
27
|
+
</Grant>
|
28
|
+
<Grant>
|
29
|
+
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AmazonCustomerByEmail">
|
30
|
+
<EmailAddress>bingo@blinky.com</EmailAddress>
|
31
|
+
</Grantee>
|
32
|
+
<Permission>WRITE</Permission>
|
33
|
+
</Grant>
|
34
|
+
<Grant>
|
35
|
+
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
|
36
|
+
<URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>
|
37
|
+
</Grantee>
|
38
|
+
<Permission>WRITE</Permission>
|
39
|
+
</Grant>
|
40
|
+
<Grant>
|
41
|
+
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
|
42
|
+
<URI>http://acs.amazonaws.com/groups/global/AuthenticatedUsers</URI>
|
43
|
+
</Grantee>
|
44
|
+
<Permission>READ_ACP</Permission>
|
45
|
+
</Grant>
|
46
|
+
</AccessControlList>
|
47
|
+
</AccessControlPolicy>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<Grant>
|
2
|
+
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
|
3
|
+
<ID>a9a7b886d6fd24a52fe8ca5bef65f89a64e0193f23000e241bf9b1c61be666e9</ID>
|
4
|
+
<DisplayName>chriscustomer</DisplayName>
|
5
|
+
</Grantee>
|
6
|
+
<Permission>FULL_CONTROL</Permission>
|
7
|
+
</Grant>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
3
|
+
<Owner>
|
4
|
+
<ID>56efddfead5aa65da942f156fb2 b294f44d78fd932d701331edc5fba19620fd4</ID>
|
5
|
+
<DisplayName>elliotsmith3</DisplayName>
|
6
|
+
</Owner>
|
7
|
+
<Buckets>
|
8
|
+
<Bucket>
|
9
|
+
<Name>elliotsmith-backup</Name>
|
10
|
+
<CreationDate>2006-07-2 0T13:25:47.000Z</CreationDate>
|
11
|
+
</Bucket>
|
12
|
+
<Bucket>
|
13
|
+
<Name>elliotsmith-helloworld</Name>
|
14
|
+
<CreationDate>2006-09-06T14:35:36.000Z</CreationDate>
|
15
|
+
</Bucket>
|
16
|
+
<Bucket>
|
17
|
+
<Name>elliotsmith-herbert</Name>
|
18
|
+
<CreationDate>2006-04-18T22:37:06.000Z</CreationDate>
|
19
|
+
</Bucket>
|
20
|
+
</Buckets>
|
21
|
+
</ListAllMyBucketsResult>
|
@@ -1 +1,138 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
3
|
+
<Name>testingtesting</Name>
|
4
|
+
<Prefix />
|
5
|
+
<Marker />
|
6
|
+
<MaxKeys>1000</MaxKeys>
|
7
|
+
<IsTruncated>false</IsTruncated>
|
8
|
+
<Contents>
|
9
|
+
<Key>/home/ell/dir1/four.txt</Key>
|
10
|
+
<LastModified>2006-08-19T22:53:29.000Z</LastModified>
|
11
|
+
<ETag>"24ce59274b89287b3960c184153ac24b"</ETag>
|
12
|
+
<Size>14</Size>
|
13
|
+
<Owner>
|
14
|
+
<ID>
|
15
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
16
|
+
</ID>
|
17
|
+
<DisplayName>elliotsmith3</DisplayName>
|
18
|
+
</Owner>
|
19
|
+
<StorageClass>STANDARD</StorageClass>
|
20
|
+
</Contents>
|
21
|
+
<Contents>
|
22
|
+
<Key>/home/ell/dir1/three.txt</Key>
|
23
|
+
<LastModified>2006-08-19T22:53:28.000Z</LastModified>
|
24
|
+
<ETag>"d01f8d7ad25e962f59f661126e4a5057"</ETag>
|
25
|
+
<Size>15</Size>
|
26
|
+
<Owner>
|
27
|
+
<ID>
|
28
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
29
|
+
</ID>
|
30
|
+
<DisplayName>elliotsmith3</DisplayName>
|
31
|
+
</Owner>
|
32
|
+
<StorageClass>STANDARD</StorageClass>
|
33
|
+
</Contents>
|
34
|
+
<Contents>
|
35
|
+
<Key>/home/ell/dir2/five.txt</Key>
|
36
|
+
<LastModified>2006-08-19T22:53:29.000Z</LastModified>
|
37
|
+
<ETag>"495f6ea4d6c70f64f767b08818c876dd"</ETag>
|
38
|
+
<Size>14</Size>
|
39
|
+
<Owner>
|
40
|
+
<ID>
|
41
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
42
|
+
</ID>
|
43
|
+
<DisplayName>elliotsmith3</DisplayName>
|
44
|
+
</Owner>
|
45
|
+
<StorageClass>STANDARD</StorageClass>
|
46
|
+
</Contents>
|
47
|
+
<Contents>
|
48
|
+
<Key>/home/ell/dir2/six.txt</Key>
|
49
|
+
<LastModified>2006-08-19T22:53:30.000Z</LastModified>
|
50
|
+
<ETag>"1d7407ec32f45f4ac15b121a45932059"</ETag>
|
51
|
+
<Size>13</Size>
|
52
|
+
<Owner>
|
53
|
+
<ID>
|
54
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
55
|
+
</ID>
|
56
|
+
<DisplayName>elliotsmith3</DisplayName>
|
57
|
+
</Owner>
|
58
|
+
<StorageClass>STANDARD</StorageClass>
|
59
|
+
</Contents>
|
60
|
+
<Contents>
|
61
|
+
<Key>/home/ell/dir2/subdir21/seven.txt</Key>
|
62
|
+
<LastModified>2006-08-19T22:53:31.000Z</LastModified>
|
63
|
+
<ETag>"b6bc8a2efb68c39c1e06469d32bc66f2"</ETag>
|
64
|
+
<Size>15</Size>
|
65
|
+
<Owner>
|
66
|
+
<ID>
|
67
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
68
|
+
</ID>
|
69
|
+
<DisplayName>elliotsmith3</DisplayName>
|
70
|
+
</Owner>
|
71
|
+
<StorageClass>STANDARD</StorageClass>
|
72
|
+
</Contents>
|
73
|
+
<Contents>
|
74
|
+
<Key>/home/ell/dir2/subdir22/eight.txt</Key>
|
75
|
+
<LastModified>2006-08-19T22:53:31.000Z</LastModified>
|
76
|
+
<ETag>"61fa424274f4caacbc7d4b6fd575ce1a"</ETag>
|
77
|
+
<Size>15</Size>
|
78
|
+
<Owner>
|
79
|
+
<ID>
|
80
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
81
|
+
</ID>
|
82
|
+
<DisplayName>elliotsmith3</DisplayName>
|
83
|
+
</Owner>
|
84
|
+
<StorageClass>STANDARD</StorageClass>
|
85
|
+
</Contents>
|
86
|
+
<Contents>
|
87
|
+
<Key>/home/ell/dir2/subdir22/subdir221/nine.txt</Key>
|
88
|
+
<LastModified>2006-08-19T22:53:32.000Z</LastModified>
|
89
|
+
<ETag>"d3dc4897b611eb4b0a2cd7bb99eb2f50"</ETag>
|
90
|
+
<Size>14</Size>
|
91
|
+
<Owner>
|
92
|
+
<ID>
|
93
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
94
|
+
</ID>
|
95
|
+
<DisplayName>elliotsmith3</DisplayName>
|
96
|
+
</Owner>
|
97
|
+
<StorageClass>STANDARD</StorageClass>
|
98
|
+
</Contents>
|
99
|
+
<Contents>
|
100
|
+
<Key>/home/ell/dir2/subdir22/subdir221/ten.txt</Key>
|
101
|
+
<LastModified>2006-08-19T22:53:32.000Z</LastModified>
|
102
|
+
<ETag>"5ecc5853945efc6448d17ea80d2aa4c0"</ETag>
|
103
|
+
<Size>13</Size>
|
104
|
+
<Owner>
|
105
|
+
<ID>
|
106
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
107
|
+
</ID>
|
108
|
+
<DisplayName>elliotsmith3</DisplayName>
|
109
|
+
</Owner>
|
110
|
+
<StorageClass>STANDARD</StorageClass>
|
111
|
+
</Contents>
|
112
|
+
<Contents>
|
113
|
+
<Key>/home/ell/one.txt</Key>
|
114
|
+
<LastModified>2006-08-19T22:53:27.000Z</LastModified>
|
115
|
+
<ETag>"420f7bf33402d3e6715d623bdac0dbcc"</ETag>
|
116
|
+
<Size>13</Size>
|
117
|
+
<Owner>
|
118
|
+
<ID>
|
119
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
120
|
+
</ID>
|
121
|
+
<DisplayName>elliotsmith3</DisplayName>
|
122
|
+
</Owner>
|
123
|
+
<StorageClass>STANDARD</StorageClass>
|
124
|
+
</Contents>
|
125
|
+
<Contents>
|
126
|
+
<Key>/home/ell/two.txt</Key>
|
127
|
+
<LastModified>2006-08-19T22:53:27.000Z</LastModified>
|
128
|
+
<ETag>"3be782e5229216c508fcb3be5fc8505d"</ETag>
|
129
|
+
<Size>13</Size>
|
130
|
+
<Owner>
|
131
|
+
<ID>
|
132
|
+
56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4
|
133
|
+
</ID>
|
134
|
+
<DisplayName>elliotsmith3</DisplayName>
|
135
|
+
</Owner>
|
136
|
+
<StorageClass>STANDARD</StorageClass>
|
137
|
+
</Contents>
|
138
|
+
</ListBucketResult>
|