heirloom 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +12 -6
- data/heirloom.gemspec +3 -5
- data/lib/heirloom/catalog/verify.rb +2 -2
- data/lib/heirloom/cli/authorize.rb +1 -2
- data/lib/heirloom/cli/catalog.rb +62 -19
- data/lib/heirloom/cli/cleanup.rb +1 -2
- data/lib/heirloom/cli/destroy.rb +1 -2
- data/lib/heirloom/cli/download.rb +2 -3
- data/lib/heirloom/cli/formatter/catalog.rb +25 -11
- data/lib/heirloom/cli/list.rb +1 -3
- data/lib/heirloom/cli/rotate.rb +1 -2
- data/lib/heirloom/cli/setup.rb +1 -2
- data/lib/heirloom/cli/shared.rb +3 -0
- data/lib/heirloom/cli/show.rb +1 -3
- data/lib/heirloom/cli/tag.rb +1 -2
- data/lib/heirloom/cli/teardown.rb +1 -2
- data/lib/heirloom/cli/upload.rb +1 -2
- data/lib/heirloom/version.rb +1 -1
- data/spec/acl/s3_spec.rb +11 -11
- data/spec/archive/authorizer_spec.rb +20 -20
- data/spec/archive/builder_spec.rb +13 -13
- data/spec/archive/checker_spec.rb +24 -24
- data/spec/archive/destroyer_spec.rb +20 -20
- data/spec/archive/downloader_spec.rb +30 -30
- data/spec/archive/lister_spec.rb +7 -7
- data/spec/archive/reader_spec.rb +65 -65
- data/spec/archive/setup_spec.rb +27 -27
- data/spec/archive/teardowner_spec.rb +19 -19
- data/spec/archive/updater_spec.rb +10 -10
- data/spec/archive/uploader_spec.rb +26 -26
- data/spec/archive/verifier_spec.rb +25 -25
- data/spec/archive/writer_spec.rb +11 -11
- data/spec/archive_spec.rb +91 -93
- data/spec/aws/s3_spec.rb +102 -102
- data/spec/aws/simpledb_spec.rb +33 -63
- data/spec/catalog/add_spec.rb +12 -12
- data/spec/catalog/delete_spec.rb +14 -14
- data/spec/catalog/list_spec.rb +8 -8
- data/spec/catalog/setup_spec.rb +11 -11
- data/spec/catalog/show_spec.rb +13 -13
- data/spec/catalog/verify_spec.rb +16 -16
- data/spec/catalog_spec.rb +36 -36
- data/spec/cipher/data_spec.rb +19 -19
- data/spec/cipher/file_spec.rb +11 -11
- data/spec/cli/authorize_spec.rb +16 -16
- data/spec/cli/catalog_spec.rb +18 -34
- data/spec/cli/destroy_spec.rb +13 -13
- data/spec/cli/download_spec.rb +31 -31
- data/spec/cli/formatter/catalog_spec.rb +19 -17
- data/spec/cli/list_spec.rb +14 -14
- data/spec/cli/rotate_spec.rb +9 -9
- data/spec/cli/setup_spec.rb +29 -29
- data/spec/cli/shared_spec.rb +119 -119
- data/spec/cli/show_spec.rb +20 -20
- data/spec/cli/tag_spec.rb +18 -18
- data/spec/cli/teardown_spec.rb +28 -28
- data/spec/cli/upload_spec.rb +38 -38
- data/spec/config_spec.rb +21 -21
- data/spec/destroyer/s3_spec.rb +6 -6
- data/spec/directory/directory_spec.rb +19 -19
- data/spec/downloader/s3_spec.rb +18 -18
- data/spec/logger_spec.rb +9 -9
- data/spec/spec_helper.rb +4 -80
- data/spec/uploader/s3_spec.rb +35 -35
- metadata +23 -56
- data/spec/integration/authorize_spec.rb +0 -79
- data/spec/integration/cleanup_spec.rb +0 -77
- data/watchr.rb +0 -101
@@ -3,38 +3,38 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@authorizer = Heirloom::Authorizer.new :config => @
|
6
|
+
@config_double = double 'config'
|
7
|
+
@logger_double = double 'logger'
|
8
|
+
@logger_double.stub :info => true, :debug => true
|
9
|
+
@config_double.should_receive(:logger).and_return(@logger_double)
|
10
|
+
@authorizer = Heirloom::Authorizer.new :config => @config_double,
|
11
11
|
:name => 'tim',
|
12
12
|
:id => '123.tar.gz'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should authorize access to an archive in all regions for email or longid" do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
s3_acl_double = double 's3 acl'
|
17
|
+
reader_double = double 'reader mock'
|
18
|
+
reader_double.stub :key_name => '123.tar.gz'
|
19
|
+
reader_double.should_receive(:get_bucket).exactly(2).times.
|
20
20
|
and_return('the-bucket')
|
21
21
|
|
22
22
|
accounts = [ "test@a.com", "a@test.com", "test@test.co", "test@test.co.uk","08b21b085ca99e70859487d685191f40d951daa0fbcb5bec51bf5ea6023e445d" ]
|
23
23
|
|
24
24
|
Heirloom::Reader.should_receive(:new).
|
25
|
-
with(:config => @
|
25
|
+
with(:config => @config_double,
|
26
26
|
:name => 'tim',
|
27
27
|
:id => '123.tar.gz').
|
28
|
-
and_return
|
28
|
+
and_return reader_double
|
29
29
|
Heirloom::ACL::S3.should_receive(:new).
|
30
|
-
with(:config => @
|
30
|
+
with(:config => @config_double,
|
31
31
|
:region => 'us-west-1').
|
32
|
-
and_return
|
32
|
+
and_return s3_acl_double
|
33
33
|
Heirloom::ACL::S3.should_receive(:new).
|
34
|
-
with(:config => @
|
34
|
+
with(:config => @config_double,
|
35
35
|
:region => 'us-west-2').
|
36
|
-
and_return
|
37
|
-
|
36
|
+
and_return s3_acl_double
|
37
|
+
s3_acl_double.should_receive(:allow_read_access_from_accounts).
|
38
38
|
exactly(2).times.
|
39
39
|
with(:key_name => '123.tar.gz',
|
40
40
|
:key_folder => 'tim',
|
@@ -46,28 +46,28 @@ describe Heirloom do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should exit when an account is a shortid" do
|
49
|
-
@
|
49
|
+
@logger_double.should_receive(:error)
|
50
50
|
@authorizer.authorize(:accounts => [ '123456789_1234', 'good@good.com'],
|
51
51
|
:regions => ['us-west-1', 'us-west-2']).
|
52
52
|
should be_false
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should exit when a bad email is given" do
|
56
|
-
@
|
56
|
+
@logger_double.should_receive(:error)
|
57
57
|
@authorizer.authorize(:accounts => ['bad@bad', 'good@good.com'],
|
58
58
|
:regions => ['us-west-1', 'us-west-2']).
|
59
59
|
should be_false
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should exit when an id which is not long(64) or short(16)" do
|
63
|
-
@
|
63
|
+
@logger_double.should_receive(:error)
|
64
64
|
@authorizer.authorize(:accounts => ['123456789_123456789_1', 'good@good.com'],
|
65
65
|
:regions => ['us-west-1', 'us-west-2']).
|
66
66
|
should be_false
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should exit even when the first value is valid" do
|
70
|
-
@
|
70
|
+
@logger_double.should_receive(:error)
|
71
71
|
@authorizer.authorize(:accounts => ['good@good.com', '123456789_123456789_1'],
|
72
72
|
:regions => ['us-west-1', 'us-west-2']).
|
73
73
|
should be_false
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Heirloom::Builder do
|
4
4
|
before do
|
5
|
-
@
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@builder
|
5
|
+
@config_double = double 'config'
|
6
|
+
@logger_double = double :debug => 'true', :info => 'true', :warn => 'true'
|
7
|
+
@config_double.stub(:logger).and_return(@logger_double)
|
8
|
+
@simpledb_double = double 'simple db'
|
9
|
+
@builder = Heirloom::Builder.new :config => @config_double,
|
10
10
|
:name => 'tim',
|
11
11
|
:id => '123'
|
12
12
|
end
|
@@ -14,28 +14,28 @@ describe Heirloom::Builder do
|
|
14
14
|
describe 'build' do
|
15
15
|
context 'when successful' do
|
16
16
|
before do
|
17
|
-
@
|
18
|
-
@
|
19
|
-
|
17
|
+
@author_double = double :name => 'weaver'
|
18
|
+
@directory_double = double :build_artifact_from_directory => '/tmp/build_dir',
|
19
|
+
:local_build => '/var/tmp/file.tar.gz'
|
20
20
|
|
21
21
|
Heirloom::Directory.should_receive(:new).
|
22
22
|
with(:path => 'path_to_build',
|
23
23
|
:exclude => ['.dir_to_exclude'],
|
24
24
|
:file => '/tmp/file.tar.gz',
|
25
|
-
:config => @
|
26
|
-
and_return @
|
25
|
+
:config => @config_double).
|
26
|
+
and_return @directory_double
|
27
27
|
@builder.should_receive(:create_artifact_record)
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should return false if the build fails" do
|
33
|
-
|
33
|
+
directory_double = double :build_artifact_from_directory => false
|
34
34
|
Heirloom::Directory.should_receive(:new).with(:path => 'path_to_build',
|
35
35
|
:exclude => ['.dir_to_exclude'],
|
36
36
|
:file => '/tmp/file.tar.gz',
|
37
|
-
:config => @
|
38
|
-
and_return
|
37
|
+
:config => @config_double).
|
38
|
+
and_return directory_double
|
39
39
|
@builder.build(:exclude => ['.dir_to_exclude'],
|
40
40
|
:directory => 'path_to_build',
|
41
41
|
:file => '/tmp/file.tar.gz').should be_false
|
@@ -3,50 +3,50 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
@checker = Heirloom::Checker.new :config => @
|
6
|
+
@config_double = double 'config'
|
7
|
+
@logger_double = double 'logger', :debug => true,
|
8
|
+
:info => true,
|
9
|
+
:warn => true
|
10
|
+
@config_double.stub :logger => @logger_double
|
11
|
+
@checker = Heirloom::Checker.new :config => @config_double
|
12
12
|
@regions = ['us-west-1', 'us-west-2']
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should return true if all bucket names are available" do
|
16
|
-
|
16
|
+
s3_double = double 's3'
|
17
17
|
Heirloom::AWS::S3.should_receive(:new).
|
18
|
-
with(:config => @
|
18
|
+
with(:config => @config_double,
|
19
19
|
:region => 'us-west-1').
|
20
|
-
and_return
|
20
|
+
and_return s3_double
|
21
21
|
Heirloom::AWS::S3.should_receive(:new).
|
22
|
-
with(:config => @
|
22
|
+
with(:config => @config_double,
|
23
23
|
:region => 'us-west-2').
|
24
|
-
and_return
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
and_return s3_double
|
25
|
+
s3_double.should_receive(:bucket_name_available?).
|
26
|
+
with('bp-us-west-1').
|
27
|
+
and_return true
|
28
|
+
s3_double.should_receive(:bucket_name_available?).
|
29
|
+
with('bp-us-west-2').
|
30
|
+
and_return true
|
31
31
|
@checker.bucket_name_available?(:bucket_prefix => 'bp',
|
32
32
|
:regions => @regions).
|
33
33
|
should be_true
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should return false if any buckets are unavailable" do
|
37
|
-
|
37
|
+
s3_double = double 's3'
|
38
38
|
Heirloom::AWS::S3.should_receive(:new).
|
39
|
-
with(:config => @
|
39
|
+
with(:config => @config_double,
|
40
40
|
:region => 'us-west-1').
|
41
|
-
and_return
|
41
|
+
and_return s3_double
|
42
42
|
Heirloom::AWS::S3.should_receive(:new).
|
43
|
-
with(:config => @
|
43
|
+
with(:config => @config_double,
|
44
44
|
:region => 'us-west-2').
|
45
|
-
and_return
|
46
|
-
|
45
|
+
and_return s3_double
|
46
|
+
s3_double.should_receive(:bucket_name_available?).
|
47
47
|
with('bp-us-west-1').
|
48
48
|
and_return false
|
49
|
-
|
49
|
+
s3_double.should_receive(:bucket_name_available?).
|
50
50
|
with('bp-us-west-2').
|
51
51
|
and_return true
|
52
52
|
@checker.bucket_name_available?(:bucket_prefix => 'bp',
|
@@ -3,37 +3,37 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@destroyer = Heirloom::Destroyer.new :config => @
|
6
|
+
@config_double = double 'config'
|
7
|
+
@logger_double = double 'logger', :info => true, :debug => true
|
8
|
+
@config_double.stub :logger => @logger_double
|
9
|
+
@destroyer = Heirloom::Destroyer.new :config => @config_double,
|
10
10
|
:name => 'tim',
|
11
11
|
:id => '123'
|
12
12
|
end
|
13
13
|
|
14
14
|
before do
|
15
|
-
@
|
16
|
-
@destroyer.stub :reader => @
|
17
|
-
@
|
18
|
-
|
19
|
-
|
20
|
-
@
|
15
|
+
@reader_double = double 'archive reader'
|
16
|
+
@destroyer.stub :reader => @reader_double
|
17
|
+
@reader_double.should_receive(:get_bucket).
|
18
|
+
with(:region => 'us-west-1').
|
19
|
+
and_return 'bucket-us-west-1'
|
20
|
+
@reader_double.stub :key_name => '123.tar.gz'
|
21
21
|
|
22
|
-
@
|
22
|
+
@s3_destroyer_double = double 's3 destroyer'
|
23
23
|
Heirloom::Destroyer::S3.should_receive(:new).
|
24
|
-
with(:config => @
|
24
|
+
with(:config => @config_double,
|
25
25
|
:region => 'us-west-1').
|
26
|
-
and_return @
|
27
|
-
@
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@
|
32
|
-
@destroyer.stub :sdb => @
|
26
|
+
and_return @s3_destroyer_double
|
27
|
+
@s3_destroyer_double.should_receive(:destroy_file).
|
28
|
+
with :key_name => '123.tar.gz',
|
29
|
+
:key_folder => 'tim',
|
30
|
+
:bucket => 'bucket-us-west-1'
|
31
|
+
@sdb_double = double 'sdb'
|
32
|
+
@destroyer.stub :sdb => @sdb_double
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should destroy the given archive" do
|
36
|
-
@
|
36
|
+
@sdb_double.should_receive(:delete).with 'heirloom_tim', '123'
|
37
37
|
@destroyer.destroy :regions => ['us-west-1']
|
38
38
|
end
|
39
39
|
|
@@ -3,42 +3,42 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@downloader = Heirloom::Downloader.new :config => @
|
6
|
+
@config_double = double 'config'
|
7
|
+
@logger_double = double 'logger', :info => true, :debug => true
|
8
|
+
@config_double.stub :logger => @logger_double
|
9
|
+
@downloader = Heirloom::Downloader.new :config => @config_double,
|
10
10
|
:name => 'tim',
|
11
11
|
:id => '123'
|
12
|
-
@
|
12
|
+
@s3_downloader_double = double 's3 downloader'
|
13
13
|
Heirloom::Downloader::S3.should_receive(:new).
|
14
|
-
with(:config => @
|
15
|
-
:logger => @
|
14
|
+
with(:config => @config_double,
|
15
|
+
:logger => @logger_double,
|
16
16
|
:region => 'us-west-1').
|
17
|
-
and_return @
|
18
|
-
@
|
17
|
+
and_return @s3_downloader_double
|
18
|
+
@cipher_double = double 'cipher'
|
19
19
|
end
|
20
20
|
|
21
21
|
context "no secret given" do
|
22
22
|
context "when succesful" do
|
23
23
|
before do
|
24
|
-
@
|
24
|
+
@writer_double = double 'writer'
|
25
25
|
Heirloom::Writer.should_receive(:new).
|
26
|
-
with(:config => @
|
27
|
-
and_return @
|
28
|
-
@
|
26
|
+
with(:config => @config_double).
|
27
|
+
and_return @writer_double
|
28
|
+
@s3_downloader_double.should_receive(:download_file).
|
29
29
|
with(:bucket => 'bucket-us-west-1',
|
30
30
|
:key => 'tim/123.tar.gz').
|
31
31
|
and_return 'plaintext'
|
32
|
-
@
|
32
|
+
@cipher_double.should_receive(:decrypt_data).
|
33
33
|
with(:secret => nil,
|
34
34
|
:data => 'plaintext').and_return 'plaintext'
|
35
35
|
Heirloom::Cipher::Data.should_receive(:new).
|
36
|
-
with(:config => @
|
37
|
-
and_return @
|
36
|
+
with(:config => @config_double).
|
37
|
+
and_return @cipher_double
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should download to the current path if output is not specified" do
|
41
|
-
@
|
41
|
+
@writer_double.should_receive(:save_archive).
|
42
42
|
with(:archive => 'plaintext',
|
43
43
|
:file => "123.tar.gz",
|
44
44
|
:output => './',
|
@@ -50,7 +50,7 @@ describe Heirloom do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should download arhcive to specified output" do
|
53
|
-
@
|
53
|
+
@writer_double.should_receive(:save_archive).
|
54
54
|
with(:archive => 'plaintext',
|
55
55
|
:file => "123.tar.gz",
|
56
56
|
:output => '/tmp/dir',
|
@@ -65,7 +65,7 @@ describe Heirloom do
|
|
65
65
|
|
66
66
|
context "when unsuccesful" do
|
67
67
|
before do
|
68
|
-
@
|
68
|
+
@s3_downloader_double.should_receive(:download_file).
|
69
69
|
with(:bucket => 'bucket-us-west-1',
|
70
70
|
:key => 'tim/123.tar.gz').
|
71
71
|
and_return false
|
@@ -83,28 +83,28 @@ describe Heirloom do
|
|
83
83
|
|
84
84
|
context "secret given" do
|
85
85
|
before do
|
86
|
-
@
|
86
|
+
@s3_downloader_double.should_receive(:download_file).
|
87
87
|
with(:bucket => 'bucket-us-west-1',
|
88
88
|
:key => 'tim/123.tar.gz.gpg').
|
89
89
|
and_return 'encrypted_data'
|
90
90
|
Heirloom::Cipher::Data.should_receive(:new).
|
91
|
-
with(:config => @
|
92
|
-
and_return @
|
91
|
+
with(:config => @config_double).
|
92
|
+
and_return @cipher_double
|
93
93
|
end
|
94
94
|
|
95
95
|
context "valid secret" do
|
96
96
|
before do
|
97
|
-
@
|
97
|
+
@writer_double = double 'writer'
|
98
98
|
Heirloom::Writer.should_receive(:new).
|
99
|
-
with(:config => @
|
100
|
-
and_return @
|
101
|
-
@
|
99
|
+
with(:config => @config_double).
|
100
|
+
and_return @writer_double
|
101
|
+
@cipher_double.should_receive(:decrypt_data).
|
102
102
|
with(:secret => 'supersecret',
|
103
103
|
:data => 'encrypted_data').and_return 'plaintext'
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should decrypt and save the downloaded file with secret" do
|
107
|
-
@
|
107
|
+
@writer_double.should_receive(:save_archive).
|
108
108
|
with(:archive => 'plaintext',
|
109
109
|
:file => "123.tar.gz",
|
110
110
|
:output => './',
|
@@ -116,7 +116,7 @@ describe Heirloom do
|
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should decrypt and extract the downloaded file with secret" do
|
119
|
-
@
|
119
|
+
@writer_double.should_receive(:save_archive).
|
120
120
|
with(:archive => 'plaintext',
|
121
121
|
:file => "123.tar.gz",
|
122
122
|
:output => './',
|
@@ -130,7 +130,7 @@ describe Heirloom do
|
|
130
130
|
|
131
131
|
context "invalid secret" do
|
132
132
|
before do
|
133
|
-
@
|
133
|
+
@cipher_double.should_receive(:decrypt_data).
|
134
134
|
with(:secret => 'badsecret',
|
135
135
|
:data => 'encrypted_data').and_return false
|
136
136
|
end
|
@@ -140,7 +140,7 @@ describe Heirloom do
|
|
140
140
|
:bucket_prefix => 'bucket',
|
141
141
|
:extract => false,
|
142
142
|
:secret => 'badsecret').should be_false
|
143
|
-
end
|
143
|
+
end
|
144
144
|
|
145
145
|
end
|
146
146
|
end
|
data/spec/archive/lister_spec.rb
CHANGED
@@ -3,18 +3,18 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@lister = Heirloom::Lister.new :config => @
|
6
|
+
@config_double = double 'config'
|
7
|
+
@lister = Heirloom::Lister.new :config => @config_double,
|
8
8
|
:name => 'test123'
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should list the known archive" do
|
12
|
-
|
13
|
-
@lister.should_receive(:sdb).and_return
|
14
|
-
|
15
|
-
|
12
|
+
sdb_double = double 'sdb'
|
13
|
+
@lister.should_receive(:sdb).and_return sdb_double
|
14
|
+
sdb_double.should_receive(:select).
|
15
|
+
with("select * from `heirloom_test123` where built_at > '2000-01-01T00:00:00.000Z' \
|
16
16
|
order by built_at desc limit 10").
|
17
|
-
|
17
|
+
and_return( {'1' => 'one', '2' => 'two', '3' => 'three'} )
|
18
18
|
@lister.list.should == ['1', '2', '3']
|
19
19
|
end
|
20
20
|
|
data/spec/archive/reader_spec.rb
CHANGED
@@ -3,113 +3,113 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@reader = Heirloom::Reader.new :config => @
|
6
|
+
@sdb_double = double 'sdb'
|
7
|
+
@config_double = double 'config'
|
8
|
+
@logger_double = double :debug => true
|
9
|
+
@config_double.stub :logger => @logger_double
|
10
|
+
@reader = Heirloom::Reader.new :config => @config_double,
|
11
11
|
:name => 'tim',
|
12
12
|
:id => '123'
|
13
13
|
end
|
14
14
|
|
15
15
|
context "domain does exist" do
|
16
16
|
before do
|
17
|
-
Heirloom::AWS::SimpleDB.stub :new => @
|
18
|
-
@
|
17
|
+
Heirloom::AWS::SimpleDB.stub :new => @sdb_double
|
18
|
+
@sdb_double.stub :domain_exists? => true
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should show the item record" do
|
22
|
-
@
|
23
|
-
|
24
|
-
|
22
|
+
@sdb_double.should_receive(:select).
|
23
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
24
|
+
and_return( { '123' => { 'value' => [ 'details' ] } } )
|
25
25
|
@reader.show.should == { 'value' => 'details' }
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return an empty hash if item does not exist" do
|
29
|
-
@
|
30
|
-
|
31
|
-
|
29
|
+
@sdb_double.should_receive(:select).
|
30
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
31
|
+
and_return({})
|
32
32
|
@reader.show.should == {}
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return true if the record exists" do
|
36
|
-
@
|
37
|
-
|
38
|
-
|
36
|
+
@sdb_double.should_receive(:select).
|
37
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
38
|
+
and_return( { '123' => { 'value' => [ 'details' ] } } )
|
39
39
|
@reader.exists?.should == true
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should return false if the record does not exist" do
|
43
|
-
@
|
44
|
-
|
45
|
-
|
43
|
+
@sdb_double.should_receive(:select).
|
44
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
45
|
+
and_return({})
|
46
46
|
@reader.exists?.should == false
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should return the bucket if it exists" do
|
50
|
-
@
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
@sdb_double.should_receive(:select).
|
51
|
+
at_least(:once).
|
52
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
53
|
+
and_return( { '123' =>
|
54
|
+
{ 'us-west-1-s3-url' =>
|
55
|
+
[ 's3://the-bucket/the-name/123.tar.gz' ]
|
56
|
+
}
|
57
|
+
} )
|
58
58
|
@reader.get_bucket(:region => 'us-west-1').should == 'the-bucket'
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should return nil if the key does not exist" do
|
62
|
-
@
|
62
|
+
@sdb_double.should_receive(:select).
|
63
63
|
with("select * from `heirloom_tim` where itemName() = '123'").
|
64
64
|
and_return( { } )
|
65
65
|
@reader.get_key(:region => 'us-west-1').should == nil
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should return nil if the bucket does not exist" do
|
69
|
-
@
|
70
|
-
|
71
|
-
|
69
|
+
@sdb_double.should_receive(:select).
|
70
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
71
|
+
and_return( { } )
|
72
72
|
@reader.get_bucket(:region => 'us-west-1').should == nil
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should return the key if it exists" do
|
76
|
-
@
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
76
|
+
@sdb_double.should_receive(:select).
|
77
|
+
at_least(:once).
|
78
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
79
|
+
and_return( { '123' =>
|
80
|
+
{ 'us-west-1-s3-url' =>
|
81
|
+
['s3://the-url/the-bucket/123.tar.gz']
|
82
|
+
}
|
83
|
+
} )
|
84
84
|
@reader.get_key(:region => 'us-west-1').should == 'the-bucket/123.tar.gz'
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should return the encrypted key name" do
|
88
|
-
@
|
89
|
-
|
90
|
-
|
88
|
+
@sdb_double.should_receive(:select).
|
89
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
90
|
+
and_return( { '123' => { 'encrypted' => [ 'true' ] } } )
|
91
91
|
@reader.key_name.should == '123.tar.gz.gpg'
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should return the unencrypted key name" do
|
95
|
-
@
|
96
|
-
|
97
|
-
|
95
|
+
@sdb_double.should_receive(:select).
|
96
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
97
|
+
and_return( { '123' => { 'encrypted' => [ 'false' ] } } )
|
98
98
|
@reader.key_name.should == '123.tar.gz'
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should return the regions the archive has been uploaded to" do
|
102
|
-
@
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
102
|
+
@sdb_double.should_receive(:select).
|
103
|
+
with("select * from `heirloom_tim` where itemName() = '123'").
|
104
|
+
and_return( { '123' =>
|
105
|
+
{ 'us-west-1-s3-url' =>
|
106
|
+
['s3://the-url-us-west-1/the-bucket/123.tar.gz'],
|
107
|
+
'build_by' =>
|
108
|
+
['user'],
|
109
|
+
'us-east-1-s3-url' =>
|
110
|
+
['s3://the-url-us-east-1/the-bucket/123.tar.gz']
|
111
|
+
}
|
112
|
+
} )
|
113
113
|
@reader.regions.should == ['us-west-1', 'us-east-1']
|
114
114
|
end
|
115
115
|
|
@@ -117,8 +117,8 @@ describe Heirloom do
|
|
117
117
|
|
118
118
|
context "domain does not exist" do
|
119
119
|
before do
|
120
|
-
Heirloom::AWS::SimpleDB.stub :new => @
|
121
|
-
@
|
120
|
+
Heirloom::AWS::SimpleDB.stub :new => @sdb_double
|
121
|
+
@sdb_double.stub :domain_exists? => false
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should return false if the simpledb domain does not exist" do
|
@@ -129,11 +129,11 @@ describe Heirloom do
|
|
129
129
|
context "object_acl verify" do
|
130
130
|
it "should get object_acls" do
|
131
131
|
regions = ['us-west-1', 'us-west-2']
|
132
|
-
@
|
133
|
-
|
132
|
+
@config_double.stub :access_key => 'the-key',
|
133
|
+
:secret_key => 'the-secret'
|
134
134
|
@reader.stub :regions => regions,
|
135
|
-
:key_name => '
|
136
|
-
:get_bucket => '
|
135
|
+
:key_name => 'doublevalue',
|
136
|
+
:get_bucket => 'doublevalue'
|
137
137
|
data = { "Owner" => { "ID" => "123", "DisplayName" => "lc" },
|
138
138
|
"AccessControlList" => [
|
139
139
|
{ "Grantee" => { "ID" => "321", "DisplayName" => "rickybobby" },
|
@@ -141,13 +141,13 @@ describe Heirloom do
|
|
141
141
|
{ "Grantee" => { "ID" => "123", "DisplayName" => "lc" },
|
142
142
|
"Permission" => "FULL_CONTROL" }]
|
143
143
|
}
|
144
|
-
|
144
|
+
s3_double = double 's3', :get_object_acl => data
|
145
145
|
|
146
146
|
regions.each do |region|
|
147
147
|
Heirloom::AWS::S3.should_receive(:new).
|
148
|
-
with(:config => @
|
148
|
+
with(:config => @config_double,
|
149
149
|
:region => region).
|
150
|
-
and_return
|
150
|
+
and_return s3_double
|
151
151
|
end
|
152
152
|
|
153
153
|
@reader.object_acls.should == { 'us-west-1-permissions' => 'rickybobby:read, lc:full_control',
|