s33r 0.4.2 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/cli/instant_download_server.rb +88 -0
- data/examples/cli/s3cli.rb +31 -52
- data/examples/cli/simple.rb +16 -6
- data/examples/fores33r/app/controllers/browser_controller.rb +12 -10
- data/examples/fores33r/app/helpers/application_helper.rb +2 -1
- data/examples/fores33r/app/views/browser/_upload.rhtml +1 -1
- data/examples/fores33r/app/views/browser/index.rhtml +4 -4
- data/examples/fores33r/config/environment.rb +5 -3
- data/examples/fores33r/log/development.log +2259 -0
- data/examples/fores33r/log/mongrel.log +59 -0
- data/examples/s3.yaml +2 -6
- data/lib/s33r/bucket.rb +103 -0
- data/lib/s33r/bucket_listing.rb +33 -76
- data/lib/s33r/client.rb +305 -446
- data/lib/s33r/networking.rb +197 -0
- data/lib/s33r/s33r_exception.rb +29 -18
- data/lib/s33r/s33r_http.rb +36 -18
- data/lib/s33r/s3_acl.rb +32 -52
- data/lib/s33r/s3_logging.rb +117 -0
- data/lib/s33r/s3_obj.rb +124 -69
- data/lib/s33r/utility.rb +447 -0
- data/test/cases/spec_acl.rb +10 -40
- data/test/cases/spec_bucket_listing.rb +12 -32
- data/test/cases/spec_logging.rb +47 -0
- data/test/cases/spec_networking.rb +11 -0
- data/test/cases/spec_s3_object.rb +44 -5
- data/test/cases/spec_utility.rb +264 -0
- data/test/files/acl.xml +0 -6
- data/test/files/config.yaml +5 -0
- data/test/files/logging_status_disabled.xml +3 -0
- data/test/files/logging_status_enabled.xml +7 -0
- data/test/test_setup.rb +7 -2
- metadata +16 -94
- data/examples/cli/acl_x.rb +0 -41
- data/examples/cli/logging_x.rb +0 -20
- data/examples/fores33r/README +0 -183
- data/html/classes/MIME.html +0 -120
- data/html/classes/MIME/InvalidContentType.html +0 -119
- data/html/classes/MIME/Type.html +0 -1173
- data/html/classes/MIME/Types.html +0 -566
- data/html/classes/Net.html +0 -108
- data/html/classes/Net/HTTPGenericRequest.html +0 -233
- data/html/classes/Net/HTTPResponse.html +0 -271
- data/html/classes/S33r.html +0 -986
- data/html/classes/S33r/BucketListing.html +0 -434
- data/html/classes/S33r/Client.html +0 -1575
- data/html/classes/S33r/LoggingResource.html +0 -222
- data/html/classes/S33r/NamedBucket.html +0 -693
- data/html/classes/S33r/OrderlyXmlMarkup.html +0 -165
- data/html/classes/S33r/S33rException.html +0 -124
- data/html/classes/S33r/S33rException/BucketListingMaxKeysError.html +0 -111
- data/html/classes/S33r/S33rException/BucketNotLogTargetable.html +0 -119
- data/html/classes/S33r/S33rException/InvalidBucketListing.html +0 -111
- data/html/classes/S33r/S33rException/InvalidPermission.html +0 -111
- data/html/classes/S33r/S33rException/InvalidS3GroupType.html +0 -111
- data/html/classes/S33r/S33rException/MalformedBucketName.html +0 -111
- data/html/classes/S33r/S33rException/MethodNotAvailable.html +0 -111
- data/html/classes/S33r/S33rException/MissingBucketName.html +0 -111
- data/html/classes/S33r/S33rException/MissingRequiredHeaders.html +0 -111
- data/html/classes/S33r/S33rException/MissingResource.html +0 -111
- data/html/classes/S33r/S33rException/S3FallenOver.html +0 -111
- data/html/classes/S33r/S33rException/TryingToPutEmptyResource.html +0 -117
- data/html/classes/S33r/S33rException/UnsupportedCannedACL.html +0 -111
- data/html/classes/S33r/S33rException/UnsupportedHTTPMethod.html +0 -111
- data/html/classes/S33r/S3ACL.html +0 -125
- data/html/classes/S33r/S3ACL/ACLDoc.html +0 -521
- data/html/classes/S33r/S3ACL/AmazonCustomer.html +0 -168
- data/html/classes/S33r/S3ACL/CanonicalUser.html +0 -212
- data/html/classes/S33r/S3ACL/Grant.html +0 -403
- data/html/classes/S33r/S3ACL/Grantee.html +0 -239
- data/html/classes/S33r/S3ACL/Group.html +0 -178
- data/html/classes/S33r/S3Object.html +0 -618
- data/html/classes/S33r/Sync.html +0 -152
- data/html/classes/XML.html +0 -202
- data/html/classes/XML/Document.html +0 -125
- data/html/classes/XML/Node.html +0 -124
- data/html/created.rid +0 -1
- data/html/files/CHANGELOG.html +0 -107
- data/html/files/MIT-LICENSE.html +0 -129
- data/html/files/README_txt.html +0 -259
- data/html/files/lib/s33r/bucket_listing_rb.html +0 -101
- data/html/files/lib/s33r/builder_rb.html +0 -108
- data/html/files/lib/s33r/client_rb.html +0 -111
- data/html/files/lib/s33r/core_rb.html +0 -113
- data/html/files/lib/s33r/libxml_extensions_rb.html +0 -101
- data/html/files/lib/s33r/libxml_loader_rb.html +0 -109
- data/html/files/lib/s33r/logging_rb.html +0 -108
- data/html/files/lib/s33r/mimetypes_rb.html +0 -120
- data/html/files/lib/s33r/named_bucket_rb.html +0 -101
- data/html/files/lib/s33r/s33r_exception_rb.html +0 -101
- data/html/files/lib/s33r/s33r_http_rb.html +0 -108
- data/html/files/lib/s33r/s3_acl_rb.html +0 -108
- data/html/files/lib/s33r/s3_obj_rb.html +0 -108
- data/html/files/lib/s33r/sync_rb.html +0 -101
- data/html/files/lib/s33r_rb.html +0 -101
- data/html/fr_class_index.html +0 -66
- data/html/fr_file_index.html +0 -44
- data/html/fr_method_index.html +0 -183
- data/html/index.html +0 -24
- data/html/rdoc-style.css +0 -208
- data/lib/s33r/core.rb +0 -296
- data/lib/s33r/logging.rb +0 -43
- data/lib/s33r/named_bucket.rb +0 -148
- data/lib/s33r/sync.rb +0 -13
- data/test/cases/spec_all_buckets.rb +0 -28
- data/test/cases/spec_client.rb +0 -101
- data/test/cases/spec_core.rb +0 -128
- data/test/cases/spec_namedbucket.rb +0 -46
- data/test/cases/spec_sync.rb +0 -34
- data/test/files/all_buckets.xml +0 -21
- data/test/files/client_config.yml +0 -5
- data/test/files/namedbucket_config.yml +0 -8
- data/test/files/namedbucket_config2.yml +0 -8
- data/test/test_bucket_setup.rb +0 -41
data/lib/s33r/sync.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module S33r
|
2
|
-
# Woefully incomplete module for performing sync operations.
|
3
|
-
# Aim is to enable s33r to compare files on the filesystem to S3 objects.
|
4
|
-
module Sync
|
5
|
-
|
6
|
-
# Get the MD5 checksum for a local file (comparable to the ETag on S3 objects).
|
7
|
-
def md5sum(filename)
|
8
|
-
f = File.open(filename).binmode
|
9
|
-
OpenSSL::Digest::MD5.hexdigest(f.read)
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
@@ -1,28 +0,0 @@
|
|
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
|
data/test/cases/spec_client.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
base = File.dirname(__FILE__)
|
2
|
-
require File.join(base, '../test_setup')
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require_gem 'FakeWeb'
|
6
|
-
|
7
|
-
context 'S33r Client' do
|
8
|
-
setup do
|
9
|
-
@base = File.dirname(__FILE__)
|
10
|
-
|
11
|
-
# client for testing: one without SSL, one with
|
12
|
-
@client = Client.new(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY, :use_ssl => false, :dump_requests => true)
|
13
|
-
@client2 = Client.new(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY)
|
14
|
-
|
15
|
-
# test config. files
|
16
|
-
@plain_config_file = File.join(@base, '../files/client_config.yml')
|
17
|
-
@custom_config_file = File.join(@base, '../files/namedbucket_config.yml')
|
18
|
-
|
19
|
-
# OK bucket with attached response
|
20
|
-
@bucket = 'testingtesting'
|
21
|
-
@url = s3_public_url(@bucket)
|
22
|
-
xml_file = File.join(@base, '../files/bucket_listing.xml')
|
23
|
-
@bucket_listing_xml = File.open(xml_file) { |f| f.read }
|
24
|
-
listbucket_response = Net::HTTPResponse.new('1.1', '200', 'OK')
|
25
|
-
listbucket_response.body = @bucket_listing_xml
|
26
|
-
FakeWeb.register_uri(@url, :status => 200, :response => listbucket_response)
|
27
|
-
|
28
|
-
# broken bucket: for testing behaviour if S3 is unavailable
|
29
|
-
@bucket2 = 's3broken'
|
30
|
-
@url2 = s3_public_url(@bucket2)
|
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)
|
47
|
-
end
|
48
|
-
|
49
|
-
specify 'should return use_ssl setting correctly' do
|
50
|
-
@client.use_ssl.should.not.be true
|
51
|
-
@client2.use_ssl.should.be true
|
52
|
-
end
|
53
|
-
|
54
|
-
specify 'should trap max_keys too high in bucket listing request' do
|
55
|
-
lambda { @client.list_bucket('duff', :max_keys => (BUCKET_LIST_MAX_MAX_KEYS + 1)) }.should.raise \
|
56
|
-
BucketListingMaxKeysError
|
57
|
-
end
|
58
|
-
|
59
|
-
specify 'should fetch bucket listing ok' do
|
60
|
-
resp, listing = @client.list_bucket(@bucket)
|
61
|
-
resp.ok?.should.be true
|
62
|
-
end
|
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
|
-
|
71
|
-
specify 'can be initialised from plain config file' do
|
72
|
-
c = Client.init(@plain_config_file)
|
73
|
-
c.aws_access_key.should.equal 'youraccesskey'
|
74
|
-
c.aws_secret_access_key.should.equal 'yoursecretkey'
|
75
|
-
end
|
76
|
-
|
77
|
-
specify 'should retain leading slashes on keys when constructing request URLs' do
|
78
|
-
todo
|
79
|
-
end
|
80
|
-
|
81
|
-
specify 'should raise an error if S3 is down' do
|
82
|
-
lambda { @client.list_bucket(@bucket2) }.should.raise S3FallenOver
|
83
|
-
end
|
84
|
-
|
85
|
-
specify 'should return S3Object with metadata properties when getting a resource key' do
|
86
|
-
todo
|
87
|
-
end
|
88
|
-
|
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
|
100
|
-
end
|
101
|
-
end
|
data/test/cases/spec_core.rb
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
base = File.dirname(__FILE__)
|
2
|
-
require File.join(base, '../test_setup')
|
3
|
-
|
4
|
-
context 'S33r core' do
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@for_request_method = 'PUT'
|
8
|
-
@for_request_path = "/quotes/nelson"
|
9
|
-
@for_request_headers = {
|
10
|
-
"Content-Md5" => "c8fdb181845a4ca6b8fec737b3581d76",
|
11
|
-
"Content-Type" => "text/html",
|
12
|
-
"Date" => "Thu, 17 Nov 2005 18:49:58 GMT",
|
13
|
-
"X-Amz-Meta-Author" => "foo@bar.com",
|
14
|
-
"X-Amz-Magic" => "abracadabra"
|
15
|
-
}
|
16
|
-
|
17
|
-
# create broken request header hash
|
18
|
-
@for_incomplete_headers = @for_request_headers.clone.delete_if do |key,value|
|
19
|
-
'Content-Type' == key or 'Date' == key
|
20
|
-
end
|
21
|
-
|
22
|
-
@correct_canonical_string = "PUT\nc8fdb181845a4ca6b8fec737b3581d76\n" +
|
23
|
-
"text/html\nThu, 17 Nov 2005 18:49:58 GMT\nx-amz-magic:abracadabra\n" +
|
24
|
-
"x-amz-meta-author:foo@bar.com\n/quotes/nelson"
|
25
|
-
@correct_signature = "jZNOcbfWmD/A/f3hSvVzXZjM2HU="
|
26
|
-
@correct_auth_header = "AWS #{Testing::ACCESS_KEY}:#{@correct_signature}"
|
27
|
-
|
28
|
-
@with_invalid_bucket_name = '/badbucket'
|
29
|
-
@with_invalid_bucket_name2 = 'badbucket/'
|
30
|
-
|
31
|
-
@correct_authenticated_url = "http://s3.amazonaws.com/quotes/nelson?Signature=vjbyPxybdZaNmGa%2ByT272YEAiv4%3D&"+
|
32
|
-
"AWSAccessKeyId=44CF9590006BF252F707&Expires=1141889120"
|
33
|
-
|
34
|
-
@correct_public_url = "http://s3.amazonaws.com/quotes/nelson"
|
35
|
-
end
|
36
|
-
|
37
|
-
specify 'should generate correct canonical strings' do
|
38
|
-
generate_canonical_string(@for_request_method, @for_request_path,
|
39
|
-
@for_request_headers).should.equal @correct_canonical_string
|
40
|
-
end
|
41
|
-
|
42
|
-
specify 'should generate correct signatures' do
|
43
|
-
generate_signature(Testing::SECRET_ACCESS_KEY,
|
44
|
-
@correct_canonical_string).should.equal @correct_signature
|
45
|
-
end
|
46
|
-
|
47
|
-
specify 'should generate correct auth headers' do
|
48
|
-
generate_auth_header_value(@for_request_method, @for_request_path, @for_request_headers,
|
49
|
-
Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY).should.equal @correct_auth_header
|
50
|
-
end
|
51
|
-
|
52
|
-
specify 'should not generate auth header if bad HTTP method passed' do
|
53
|
-
lambda { generate_auth_header_value('duff', nil, nil, nil, nil) }.should.raise \
|
54
|
-
MethodNotAvailable
|
55
|
-
end
|
56
|
-
|
57
|
-
specify 'should not generate auth header if required headers missing' do
|
58
|
-
lambda { generate_auth_header_value('PUT', '/', @for_incomplete_headers,
|
59
|
-
nil, nil) }.should.raise MissingRequiredHeaders
|
60
|
-
end
|
61
|
-
|
62
|
-
specify 'when generating auth header, should allow addition of Date and Content-Type headers' do
|
63
|
-
now = Time.now
|
64
|
-
|
65
|
-
fixed_headers = add_default_headers(@for_incomplete_headers, :date => now,
|
66
|
-
:content_type => 'text/html')
|
67
|
-
|
68
|
-
fixed_headers['Date'].should.equal now.httpdate
|
69
|
-
fixed_headers['Content-Type'].should.equal 'text/html'
|
70
|
-
end
|
71
|
-
|
72
|
-
specify 'should not generate canned ACL header if invalid canned ACL supplied' do
|
73
|
-
lambda { canned_acl_header('duff') }.should.raise \
|
74
|
-
UnsupportedCannedACL
|
75
|
-
end
|
76
|
-
|
77
|
-
specify 'should correctly add canned ACL headers' do
|
78
|
-
new_headers = canned_acl_header('private', { 'Content-Type' => 'text/html' })
|
79
|
-
new_headers.should.have(2).keys
|
80
|
-
new_headers.keys.should.include 'Content-Type'
|
81
|
-
new_headers.keys.should.include 'x-amz-acl'
|
82
|
-
new_headers['x-amz-acl'].should.equal 'private'
|
83
|
-
end
|
84
|
-
|
85
|
-
specify 'should set sensible defaults for missing Content-Type and Date headers' do
|
86
|
-
fixed_headers = add_default_headers(@for_incomplete_headers)
|
87
|
-
fixed_headers['Content-Type'].should.equal ''
|
88
|
-
fixed_headers.include?('Date').should.not.be nil
|
89
|
-
end
|
90
|
-
|
91
|
-
specify 'should default to text/plain mimetype for unknown file types' do
|
92
|
-
guess_mime_type('hello.madeup').should.equal('text/plain')
|
93
|
-
end
|
94
|
-
|
95
|
-
specify 'should recognise invalid bucket names' do
|
96
|
-
lambda { bucket_name_valid?(@with_invalid_bucket_name) }.should.raise \
|
97
|
-
MalformedBucketName
|
98
|
-
lambda { bucket_name_valid?(@with_invalid_bucket_name2) }.should.raise \
|
99
|
-
MalformedBucketName
|
100
|
-
end
|
101
|
-
|
102
|
-
specify 'should return empty string if generating querystring with no key/value pairs' do
|
103
|
-
generate_querystring({}).should_equal ''
|
104
|
-
end
|
105
|
-
|
106
|
-
specify 'should correctly format querystring key/value pairs' do
|
107
|
-
generate_querystring({'message' => 'Hello world', 'id' => 1, 'page' => '[2,4]'}).should_equal \
|
108
|
-
'?message=Hello+world&id=1&page=%5B2%2C4%5D'
|
109
|
-
end
|
110
|
-
|
111
|
-
specify 'should allow symbols as names for querystring variables when generating querystrings' do
|
112
|
-
generate_querystring({ :prefix => '/home/ell' }).should.equal('?prefix=%2Fhome%2Fell')
|
113
|
-
end
|
114
|
-
|
115
|
-
specify 'should convert integers to strings when generating querystrings' do
|
116
|
-
generate_querystring({ 'max-keys' => 400 }).should.equal('?max-keys=400')
|
117
|
-
end
|
118
|
-
|
119
|
-
specify 'should generate URLs with authentication parameters' do
|
120
|
-
s3_authenticated_url(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY, 'quotes', 'nelson', \
|
121
|
-
1141889120).should.equal @correct_authenticated_url
|
122
|
-
end
|
123
|
-
|
124
|
-
specify 'should generate correct public URLs' do
|
125
|
-
s3_public_url('quotes', 'nelson').should.equal @correct_public_url
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
base = File.dirname(__FILE__)
|
2
|
-
require File.join(base, '../test_setup')
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require_gem 'FakeWeb'
|
6
|
-
|
7
|
-
context 'NamedBucket client' do
|
8
|
-
setup do
|
9
|
-
@base = File.dirname(__FILE__)
|
10
|
-
@config_filename = @base + '/../files/namedbucket_config.yml'
|
11
|
-
@config_filename2 = @base + '/../files/namedbucket_config2.yml'
|
12
|
-
@url = s3_public_url('nobucket')
|
13
|
-
end
|
14
|
-
|
15
|
-
specify 'should keep a copy of the current bucket listing inside as a property' do
|
16
|
-
todo
|
17
|
-
end
|
18
|
-
|
19
|
-
specify 'should enable prefix, marker etc. to be reset from NamedBucket and refresh wrapped bucket listing object' do
|
20
|
-
todo
|
21
|
-
end
|
22
|
-
|
23
|
-
specify 'should enable checking for existence of a resource by key' do
|
24
|
-
FakeWeb.register_uri(@url + '/existing_key', :status => 200)
|
25
|
-
FakeWeb.register_uri(@url + '/broken', :status => 404)
|
26
|
-
client = NamedBucket.init(@config_filename)
|
27
|
-
client.key_exists?('existing_key').should.be true
|
28
|
-
client.key_exists?('broken').should.be false
|
29
|
-
end
|
30
|
-
|
31
|
-
specify 'should be able to load config from a file' do
|
32
|
-
FakeWeb.register_uri(@url, :status => 200)
|
33
|
-
client = NamedBucket.init(@config_filename)
|
34
|
-
client.aws_access_key.should.equal 'youraccesskey'
|
35
|
-
client.aws_secret_access_key.should.equal 'yoursecretkey'
|
36
|
-
client.name.should.equal 'nobucket'
|
37
|
-
client.strict?.should.be false
|
38
|
-
client.public_contents?.should.be true
|
39
|
-
client.use_ssl.should.be false
|
40
|
-
end
|
41
|
-
|
42
|
-
specify 'cannot be initialised for non-existent bucket' do
|
43
|
-
FakeWeb.register_uri(@url, :status => 404)
|
44
|
-
lambda { client = NamedBucket.init(@config_filename2) }.should.raise MissingResource
|
45
|
-
end
|
46
|
-
end
|
data/test/cases/spec_sync.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
base = File.dirname(__FILE__)
|
2
|
-
require File.join(base, '../test_setup')
|
3
|
-
|
4
|
-
context 'S33r sync methods' do
|
5
|
-
setup do
|
6
|
-
@base_dir = File.dirname(__FILE__)
|
7
|
-
@text_filename = @base_dir + '/../files/textfile.txt'
|
8
|
-
@graphic_filename = @base_dir + '/../files/wave.jpg'
|
9
|
-
end
|
10
|
-
|
11
|
-
specify 'should return MD5 checksum for text files' do
|
12
|
-
md5sum(@text_filename).should.equal('bbf560d44f092d22a30d3a562436ad8c')
|
13
|
-
end
|
14
|
-
|
15
|
-
specify 'should return MD5 checksum for graphic files' do
|
16
|
-
md5sum(@graphic_filename).should.equal('80b669f252257eedd8a2606cb1a0df6a')
|
17
|
-
end
|
18
|
-
|
19
|
-
specify 'should be able to map a directory structure to S3 bucket keys' do
|
20
|
-
todo
|
21
|
-
end
|
22
|
-
|
23
|
-
specify 'should be able to convert paths to keys' do
|
24
|
-
todo
|
25
|
-
end
|
26
|
-
|
27
|
-
specify 'should return an array of local files to put to S3 based on differences between MD5 checksums' do
|
28
|
-
todo
|
29
|
-
end
|
30
|
-
|
31
|
-
specify 'should convert S3 bucket keys into a "virtual" directory and file structure' do
|
32
|
-
todo
|
33
|
-
end
|
34
|
-
end
|
data/test/files/all_buckets.xml
DELETED
@@ -1,21 +0,0 @@
|
|
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>
|
data/test/test_bucket_setup.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# for setting up test bucket, so can gather responses from the real S3
|
2
|
-
require 'yaml'
|
3
|
-
require File.dirname(__FILE__) + '/../lib/s33r.rb'
|
4
|
-
|
5
|
-
config_file = '/home/ell/.s33r'
|
6
|
-
|
7
|
-
options = YAML::load_file(config_file)
|
8
|
-
access_key = options['access_key']
|
9
|
-
secret_key = options['secret_key']
|
10
|
-
|
11
|
-
bucket = 'elliotsmith-testing'
|
12
|
-
|
13
|
-
def bucketeer(client, bucket)
|
14
|
-
lambda do |key, text|
|
15
|
-
client.put_text bucket, '/home/ell/' + key, text
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
S3::Client.new(access_key, secret_key) do |client|
|
20
|
-
|
21
|
-
if !client.bucket_exists?(bucket)
|
22
|
-
client.create_bucket(bucket)
|
23
|
-
|
24
|
-
b = bucketeer(client, bucket)
|
25
|
-
b.call 'one.txt', 'one text file'
|
26
|
-
b.call 'two.txt', 'two text file'
|
27
|
-
b.call 'dir1/three.txt', 'three text file'
|
28
|
-
b.call 'dir1/four.txt', 'four text file'
|
29
|
-
b.call 'dir2/five.txt', 'five text file'
|
30
|
-
b.call 'dir2/six.txt', 'six text file'
|
31
|
-
b.call 'dir2/subdir21/seven.txt', 'seven text file'
|
32
|
-
b.call 'dir2/subdir22/eight.txt', 'eight text file'
|
33
|
-
b.call 'dir2/subdir22/subdir221/nine.txt', 'nine text file'
|
34
|
-
b.call 'dir2/subdir22/subdir221/ten.txt', 'ten text file'
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
# p client.list_bucket(bucket, :prefix => '/home/ell/dir1').body
|
39
|
-
# p client.list_bucket(bucket, :marker => '/home/ell/dir2/six.txt').body
|
40
|
-
p client.list_bucket(bucket).body
|
41
|
-
end
|