s33r 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +15 -2
- data/README.txt +4 -1
- data/bin/config.yml +2 -2
- data/bin/s3cli.rb +46 -27
- data/lib/s33r.rb +2 -7
- data/lib/s33r/bucket_listing.rb +141 -0
- data/lib/s33r/client.rb +96 -65
- data/lib/s33r/core.rb +80 -2
- data/lib/s33r/libxml_extensions.rb +29 -0
- data/lib/s33r/{external/mimetypes.rb → mimetypes.rb} +0 -0
- data/lib/s33r/named_bucket.rb +34 -8
- data/lib/s33r/net_http_overrides.rb +23 -0
- data/lib/s33r/s3_exception.rb +14 -5
- data/lib/s33r/sync.rb +11 -0
- data/test/cases/spec_bucket_listing.rb +125 -0
- data/test/cases/spec_core.rb +130 -0
- data/test/cases/spec_sync.rb +29 -0
- data/test/cases/spec_xml.rb +22 -0
- data/test/cases/unit_client.rb +40 -0
- data/test/cases/unit_named_bucket.rb +12 -0
- data/test/files/bucket_listing.xml +1 -0
- data/test/files/bucket_listing2.xml +1 -0
- data/test/files/bucket_listing3.xml +8 -0
- data/test/files/bucket_listing_broken.xml +1 -0
- data/test/files/s3_object.xml +12 -0
- data/test/files/textfile.txt +10 -0
- data/test/files/wave.jpg +0 -0
- data/test/s3_test_constants.rb +25 -0
- data/test/test_bucket_setup.rb +41 -0
- metadata +27 -10
- data/lib/s33r/list_bucket_result.rb +0 -1
- data/test/spec/spec_core.rb +0 -87
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../s3_test_constants'
|
2
|
+
|
3
|
+
context 'S3 sync methods' do
|
4
|
+
setup do
|
5
|
+
@base_dir = File.dirname(__FILE__)
|
6
|
+
@text_filename = @base_dir + '/../files/textfile.txt'
|
7
|
+
@graphic_filename = @base_dir + '/../files/wave.jpg'
|
8
|
+
end
|
9
|
+
|
10
|
+
specify 'should return MD5 checksum for text files' do
|
11
|
+
md5sum(@text_filename).should.equal('bbf560d44f092d22a30d3a562436ad8c')
|
12
|
+
end
|
13
|
+
|
14
|
+
specify 'should return MD5 checksum for graphic files' do
|
15
|
+
md5sum(@graphic_filename).should.equal('80b669f252257eedd8a2606cb1a0df6a')
|
16
|
+
end
|
17
|
+
|
18
|
+
specify 'should be able to map a directory structure to S3 bucket keys' do
|
19
|
+
fix
|
20
|
+
end
|
21
|
+
|
22
|
+
specify 'should return an array of local files to put to S3 based on differences between MD5 checksums' do
|
23
|
+
fix
|
24
|
+
end
|
25
|
+
|
26
|
+
specify 'should convert S3 bucket keys into a "virtual" directory and file structure' do
|
27
|
+
fix
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
base = File.dirname(__FILE__)
|
2
|
+
require File.join(base, '../s3_test_constants')
|
3
|
+
|
4
|
+
context 'LibXML extensions' do
|
5
|
+
setup do
|
6
|
+
@with_xml_str = File.open(File.join(base, '../files/s3_object.xml')).read
|
7
|
+
@doc = XML.get_xml_doc(@with_xml_str)
|
8
|
+
end
|
9
|
+
|
10
|
+
specify 'should make it easy to get an XML::Document from an XML string' do
|
11
|
+
@doc.should_be_an_instance_of XML::Document
|
12
|
+
clean_xml(@doc.to_s).should.equal clean_xml(@with_xml_str)
|
13
|
+
end
|
14
|
+
|
15
|
+
specify 'should return content of the first node matching a path' do
|
16
|
+
@doc.xget('//Size').should.equal '14'
|
17
|
+
end
|
18
|
+
|
19
|
+
specify 'should return nil if no matching path' do
|
20
|
+
@doc.xget('//madeup').should.equal nil
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../s3_test_constants'
|
2
|
+
require_gem 'FakeWeb'
|
3
|
+
|
4
|
+
class TestClient < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@client = Client.new(S3Testing::ACCESS_KEY, S3Testing::SECRET_ACCESS_KEY, :ssl => false)
|
7
|
+
@client2 = Client.new(S3Testing::ACCESS_KEY, S3Testing::SECRET_ACCESS_KEY)
|
8
|
+
@bucket = 'testingtesting'
|
9
|
+
@url = url_join('http://', HOST, @bucket)
|
10
|
+
FakeWeb.register_uri(@url, :status => 200)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_returns_ssl_setting_correctly
|
14
|
+
assert !(@client.use_ssl?)
|
15
|
+
assert @client2.use_ssl?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_catches_max_keys_too_high_in_bucket_listing_request
|
19
|
+
assert_raise(S3Exception::BucketListingMaxKeysError) do
|
20
|
+
@client.list_bucket('duff', :max_keys => (S3::BUCKET_LIST_MAX_MAX_KEYS + 1))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_fetches_bucket_listing_ok
|
25
|
+
resp = @client.list_bucket(@bucket)
|
26
|
+
assert resp.ok?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_recursively_put_files_into_bucket_with_paths_as_keys
|
30
|
+
flunk 'Test conversion of paths to keys'
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_has_attached_bucket_listing_object_for_get_on_bucket
|
34
|
+
flunk 'Check that responses to list_bucket have an attached BucketListing instance'
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_keys_dont_have_leading_slashes_stripped_when_putting_resources
|
38
|
+
flunk 'Keys with leading slashes should not have the slash stripped'
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../s3_test_constants'
|
2
|
+
require_gem 'FakeWeb'
|
3
|
+
|
4
|
+
class TestNamedBucket < Test::Unit::TestCase
|
5
|
+
def test_should_wrap_bucket_listing
|
6
|
+
flunk 'Keep a copy of the current bucket listing inside as a property'
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_should_enable_easy_updates_on_bucket_listing
|
10
|
+
flunk 'Enable prefix, marker etc. to be reset from NamedBucket and refresh wrapped bucket listing object'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>testingtesting</Name><Prefix/><Marker/><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated><Contents><Key>/home/ell/dir1/four.txt</Key><LastModified>2006-08-19T22:53:29.000Z</LastModified><ETag>"24ce59274b89287b3960c184153ac24b"</ETag><Size>14</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir1/three.txt</Key><LastModified>2006-08-19T22:53:28.000Z</LastModified><ETag>"d01f8d7ad25e962f59f661126e4a5057"</ETag><Size>15</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/five.txt</Key><LastModified>2006-08-19T22:53:29.000Z</LastModified><ETag>"495f6ea4d6c70f64f767b08818c876dd"</ETag><Size>14</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/six.txt</Key><LastModified>2006-08-19T22:53:30.000Z</LastModified><ETag>"1d7407ec32f45f4ac15b121a45932059"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/subdir21/seven.txt</Key><LastModified>2006-08-19T22:53:31.000Z</LastModified><ETag>"b6bc8a2efb68c39c1e06469d32bc66f2"</ETag><Size>15</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/subdir22/eight.txt</Key><LastModified>2006-08-19T22:53:31.000Z</LastModified><ETag>"61fa424274f4caacbc7d4b6fd575ce1a"</ETag><Size>15</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/subdir22/subdir221/nine.txt</Key><LastModified>2006-08-19T22:53:32.000Z</LastModified><ETag>"d3dc4897b611eb4b0a2cd7bb99eb2f50"</ETag><Size>14</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/subdir22/subdir221/ten.txt</Key><LastModified>2006-08-19T22:53:32.000Z</LastModified><ETag>"5ecc5853945efc6448d17ea80d2aa4c0"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/one.txt</Key><LastModified>2006-08-19T22:53:27.000Z</LastModified><ETag>"420f7bf33402d3e6715d623bdac0dbcc"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/two.txt</Key><LastModified>2006-08-19T22:53:27.000Z</LastModified><ETag>"3be782e5229216c508fcb3be5fc8505d"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents></ListBucketResult>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>testing2</Name><Prefix>/home/ell/</Prefix><Marker></Marker><MaxKeys>100</MaxKeys><Delimiter>/</Delimiter><IsTruncated>false</IsTruncated><Contents><Key>/home/ell/one.txt</Key><LastModified>2006-08-19T22:53:27.000Z</LastModified><ETag>"420f7bf33402d3e6715d623bdac0dbcc"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/two.txt</Key><LastModified>2006-08-19T22:53:27.000Z</LastModified><ETag>"3be782e5229216c508fcb3be5fc8505d"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><CommonPrefixes><Prefix>/home/ell/dir1/</Prefix></CommonPrefixes><CommonPrefixes><Prefix>/home/ell/dir2/</Prefix></CommonPrefixes></ListBucketResult>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http:testing</Name><Prefix/><Marker/><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated><Contents><Key>/home/ell/dir1/four.txt</Key><LastModified>2006-08-19T22:53:29.000Z</LastModified><ETag>"24ce59274b89287b3960c184153ac24b"</ETag><Size>14</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir1/three.txt</Key><LastModified>2006-08-19T22:53:28.000Z</LastModified><ETag>"d01f8d7ad25e962f59f661126e4a5057"</ETag><Size>15</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/five.txt</Key><LastModified>2006-08-19T22:53:29.000Z</LastModified><ETag>"495f6ea4d6c70f64f767b08818c876dd"</ETag><Size>14</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/six.txt</Key><LastModified>2006-08-19T22:53:30.000Z</LastModified><ETag>"1d7407ec32f45f4ac15b121a45932059"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/subdir21/seven.txt</Key><LastModified>2006-08-19T22:53:31.000Z</LastModified><ETag>"b6bc8a2efb68c39c1e06469d32bc66f2"</ETag><Size>15</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/subdir22/eight.txt</Key><LastModified>2006-08-19T22:53:31.000Z</LastModified><ETag>"61fa424274f4caacbc7d4b6fd575ce1a"</ETag><Size>15</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/subdir22/subdir221/nine.txt</Key><LastModified>2006-08-19T22:53:32.000Z</LastModified><ETag>"d3dc4897b611eb4b0a2cd7bb99eb2f50"</ETag><Size>14</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/dir2/subdir22/subdir221/ten.txt</Key><LastModified>2006-08-19T22:53:32.000Z</LastModified><ETag>"5ecc5853945efc6448d17ea80d2aa4c0"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/one.txt</Key><LastModified>2006-08-19T22:53:27.000Z</LastModified><ETag>"420f7bf33402d3e6715d623bdac0dbcc"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>/home/ell/two.txt</Key><LastModified>2006-08-19T22:53:27.000Z</LastModified><ETag>"3be782e5229216c508fcb3be5fc8505d"</ETag><Size>13</Size><Owner><ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID><DisplayName>elliotsmith3</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents></ListBucketResult>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Contents>
|
3
|
+
<Key>/home/ell/dir1/four.txt</Key>
|
4
|
+
<LastModified>2006-08-19T22:53:29.000Z</LastModified>
|
5
|
+
<ETag>"24ce59274b89287b3960c184153ac24b"</ETag>
|
6
|
+
<Size>14</Size>
|
7
|
+
<Owner>
|
8
|
+
<ID>56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4</ID>
|
9
|
+
<DisplayName>elliotsmith3</DisplayName>
|
10
|
+
</Owner>
|
11
|
+
<StorageClass>STANDARD</StorageClass>
|
12
|
+
</Contents>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
|
10
|
+
require 'tasks/rails'
|
data/test/files/wave.jpg
ADDED
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# loaded by all test classes
|
2
|
+
require 'rubygems'
|
3
|
+
require_gem 'rspec'
|
4
|
+
|
5
|
+
require File.dirname(__FILE__) + '/../lib/s33r'
|
6
|
+
include S3
|
7
|
+
include S3::Sync
|
8
|
+
|
9
|
+
# set up some constants
|
10
|
+
module S3Testing
|
11
|
+
ACCESS_KEY = '44CF9590006BF252F707'
|
12
|
+
SECRET_ACCESS_KEY = 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
|
13
|
+
end
|
14
|
+
|
15
|
+
# convenience for highlighting todos
|
16
|
+
def fix
|
17
|
+
fail 'todo'
|
18
|
+
end
|
19
|
+
|
20
|
+
# clean newlines and tabs from XML to make comparisons easier
|
21
|
+
def clean_xml(xml_str)
|
22
|
+
xml_str.gsub!(/\t/, '')
|
23
|
+
xml_str.gsub!(/\n/, '')
|
24
|
+
xml_str
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: s33r
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2006-
|
6
|
+
version: "0.2"
|
7
|
+
date: 2006-08-23 00:00:00 +01:00
|
8
8
|
summary: A library for accessing Amazon S3
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- Elliot Smith
|
30
31
|
files:
|
@@ -32,21 +33,37 @@ files:
|
|
32
33
|
- bin/config.yml
|
33
34
|
- lib/s33r
|
34
35
|
- lib/s33r.rb
|
35
|
-
- lib/s33r/
|
36
|
+
- lib/s33r/sync.rb
|
36
37
|
- lib/s33r/client.rb
|
37
|
-
- lib/s33r/
|
38
|
+
- lib/s33r/mimetypes.rb
|
38
39
|
- lib/s33r/net_http_overrides.rb
|
40
|
+
- lib/s33r/bucket_listing.rb
|
39
41
|
- lib/s33r/s3_exception.rb
|
40
42
|
- lib/s33r/core.rb
|
41
43
|
- lib/s33r/named_bucket.rb
|
42
|
-
- lib/s33r/
|
43
|
-
- test/
|
44
|
-
- test/
|
44
|
+
- lib/s33r/libxml_extensions.rb
|
45
|
+
- test/files
|
46
|
+
- test/test_bucket_setup.rb
|
47
|
+
- test/s3_test_constants.rb
|
48
|
+
- test/cases
|
49
|
+
- test/files/wave.jpg
|
50
|
+
- test/files/textfile.txt
|
51
|
+
- test/files/bucket_listing.xml
|
52
|
+
- test/files/s3_object.xml
|
53
|
+
- test/files/bucket_listing_broken.xml
|
54
|
+
- test/files/bucket_listing2.xml
|
55
|
+
- test/files/bucket_listing3.xml
|
56
|
+
- test/cases/spec_core.rb
|
57
|
+
- test/cases/spec_sync.rb
|
58
|
+
- test/cases/unit_client.rb
|
59
|
+
- test/cases/spec_bucket_listing.rb
|
60
|
+
- test/cases/unit_named_bucket.rb
|
61
|
+
- test/cases/spec_xml.rb
|
45
62
|
- LICENSE.txt
|
46
63
|
- README.txt
|
47
64
|
- MIT-LICENSE
|
48
|
-
test_files:
|
49
|
-
|
65
|
+
test_files: []
|
66
|
+
|
50
67
|
rdoc_options: []
|
51
68
|
|
52
69
|
extra_rdoc_files: []
|
@@ -1 +0,0 @@
|
|
1
|
-
# TODO: parser to provide a tree representation of keys in a bucket
|
data/test/spec/spec_core.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require_gem 'rspec'
|
3
|
-
|
4
|
-
require File.dirname(__FILE__) + '/../../lib/s33r.rb'
|
5
|
-
include S3
|
6
|
-
|
7
|
-
context 'S3 module' do
|
8
|
-
|
9
|
-
setup do
|
10
|
-
@for_request_method = 'PUT'
|
11
|
-
@for_request_path = "/quotes/nelson"
|
12
|
-
@for_request_headers = {
|
13
|
-
"Content-Md5" => "c8fdb181845a4ca6b8fec737b3581d76",
|
14
|
-
"Content-Type" => "text/html",
|
15
|
-
"Date" => "Thu, 17 Nov 2005 18:49:58 GMT",
|
16
|
-
"X-Amz-Meta-Author" => "foo@bar.com",
|
17
|
-
"X-Amz-Magic" => "abracadabra"
|
18
|
-
}
|
19
|
-
@with_access_key = '44CF9590006BF252F707'
|
20
|
-
@with_secret_access_key = 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
|
21
|
-
|
22
|
-
@for_incomplete_headers = @for_request_headers.clone.delete_if do |key,value|
|
23
|
-
'Content-Type' == key or 'Date' == key
|
24
|
-
end
|
25
|
-
|
26
|
-
@correct_canonical_string = "PUT\nc8fdb181845a4ca6b8fec737b3581d76\n" +
|
27
|
-
"text/html\nThu, 17 Nov 2005 18:49:58 GMT\nx-amz-magic:abracadabra\n" +
|
28
|
-
"x-amz-meta-author:foo@bar.com\n/quotes/nelson"
|
29
|
-
@correct_signature = "jZNOcbfWmD/A/f3hSvVzXZjM2HU="
|
30
|
-
@correct_auth_header = "AWS #{@with_access_key}:#{@correct_signature}"
|
31
|
-
end
|
32
|
-
|
33
|
-
specify 'should generate correct canonical strings' do
|
34
|
-
generate_canonical_string(@for_request_method, @for_request_path,
|
35
|
-
@for_request_headers).should.equal @correct_canonical_string
|
36
|
-
end
|
37
|
-
|
38
|
-
specify 'should generate correct signatures' do
|
39
|
-
generate_signature(@with_secret_access_key,
|
40
|
-
@correct_canonical_string).should.equal @correct_signature
|
41
|
-
end
|
42
|
-
|
43
|
-
specify 'should generate correct auth headers' do
|
44
|
-
generate_auth_header_value(@for_request_method, @for_request_path, @for_request_headers,
|
45
|
-
@with_access_key, @with_secret_access_key).should.equal @correct_auth_header
|
46
|
-
end
|
47
|
-
|
48
|
-
specify 'should not generate auth header if bad HTTP method passed' do
|
49
|
-
lambda { generate_auth_header_value('duff', nil, nil, nil, nil) }.should.raise
|
50
|
-
S3Exception::MethodNotAvailable
|
51
|
-
end
|
52
|
-
|
53
|
-
specify 'should not generate auth header if required headers missing' do
|
54
|
-
lambda { generate_auth_header_value('PUT', '/', @for_incomplete_headers,
|
55
|
-
nil, nil) }.should.raise S3Exception::MissingRequiredHeaders
|
56
|
-
end
|
57
|
-
|
58
|
-
specify 'when generating auth header, should allow addition of Date and Content-Type headers' do
|
59
|
-
now = Time.now
|
60
|
-
|
61
|
-
fixed_headers = add_default_headers(@for_incomplete_headers, :date => now,
|
62
|
-
:content_type => 'text/html')
|
63
|
-
|
64
|
-
fixed_headers['Date'].should.equal now.httpdate
|
65
|
-
fixed_headers['Content-Type'].should.equal 'text/html'
|
66
|
-
end
|
67
|
-
|
68
|
-
specify 'should not generate canned ACL header if invalid canned ACL supplied' do
|
69
|
-
lambda { canned_acl_header('duff') }.should.raise
|
70
|
-
S3Exception::UnsupportedCannedACL
|
71
|
-
end
|
72
|
-
|
73
|
-
specify 'should correctly add canned ACL headers' do
|
74
|
-
new_headers = canned_acl_header('private', { 'Content-Type' => 'text/html' })
|
75
|
-
new_headers.should.have(2).keys
|
76
|
-
new_headers.keys.should.include 'Content-Type'
|
77
|
-
new_headers.keys.should.include 'x-amz-acl'
|
78
|
-
new_headers['x-amz-acl'].should.equal 'private'
|
79
|
-
end
|
80
|
-
|
81
|
-
specify 'should set sensible defaults for missing Content-Type and Date headers' do
|
82
|
-
fixed_headers = add_default_headers(@for_incomplete_headers)
|
83
|
-
fixed_headers['Content-Type'].should.equal ''
|
84
|
-
fixed_headers.include?('Date').should.not.be nil
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|