heirloom 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/catalog/add_spec.rb
CHANGED
@@ -5,24 +5,24 @@ describe Heirloom::Catalog::Add do
|
|
5
5
|
before do
|
6
6
|
@regions = ['us-west-1', 'us-west-2']
|
7
7
|
@bucket_prefix = 'bucket_prefix'
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
8
|
+
@logger_double = double 'logger', :info => true
|
9
|
+
@config_double = double 'config', :logger => @logger_double
|
10
|
+
@verify_double = double 'verify'
|
11
11
|
|
12
|
-
@add = Heirloom::Catalog::Add.new :config => @
|
12
|
+
@add = Heirloom::Catalog::Add.new :config => @config_double,
|
13
13
|
:name => 'new_archive'
|
14
14
|
Heirloom::Catalog::Verify.should_receive(:new).
|
15
|
-
with(:config => @
|
16
|
-
and_return @
|
15
|
+
with(:config => @config_double).
|
16
|
+
and_return @verify_double
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should call sdb to add the entry to the catalog" do
|
20
|
-
@
|
21
|
-
@
|
20
|
+
@sdb_double = double 'sdb'
|
21
|
+
@verify_double.stub :entry_exists_in_catalog? => false
|
22
22
|
Heirloom::AWS::SimpleDB.should_receive(:new).
|
23
|
-
with(:config => @
|
24
|
-
and_return @
|
25
|
-
@
|
23
|
+
with(:config => @config_double).
|
24
|
+
and_return @sdb_double
|
25
|
+
@sdb_double.should_receive(:put_attributes).
|
26
26
|
with 'heirloom',
|
27
27
|
'heirloom_new_archive',
|
28
28
|
"regions" => @regions, "bucket_prefix" => @bucket_prefix
|
@@ -31,7 +31,7 @@ describe Heirloom::Catalog::Add do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should not add the entry to the catalog if it's already there" do
|
34
|
-
@
|
34
|
+
@verify_double.stub :entry_exists_in_catalog? => true
|
35
35
|
Heirloom::AWS::SimpleDB.should_receive(:new).never
|
36
36
|
@add.add_to_catalog :regions => @regions,
|
37
37
|
:bucket_prefix => @bucket_prefix
|
data/spec/catalog/delete_spec.rb
CHANGED
@@ -3,30 +3,30 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom::Catalog::Delete do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
6
|
+
@logger_double = double 'logger', :info => true
|
7
|
+
@config_double = double 'config', :logger => @logger_double
|
8
|
+
@verify_double = double 'verify'
|
9
9
|
Heirloom::Catalog::Verify.should_receive(:new).
|
10
|
-
with(:config => @
|
11
|
-
and_return @
|
12
|
-
@delete = Heirloom::Catalog::Delete.new :config => @
|
10
|
+
with(:config => @config_double).
|
11
|
+
and_return @verify_double
|
12
|
+
@delete = Heirloom::Catalog::Delete.new :config => @config_double,
|
13
13
|
:name => 'old_archive'
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should delete the entry from the catalog" do
|
17
|
-
@
|
18
|
-
@
|
17
|
+
@verify_double.stub :catalog_domain_exists? => true
|
18
|
+
@sdb_double = double 'sdb'
|
19
19
|
Heirloom::AWS::SimpleDB.should_receive(:new).
|
20
|
-
with(:config => @
|
21
|
-
and_return @
|
22
|
-
@
|
23
|
-
|
24
|
-
|
20
|
+
with(:config => @config_double).
|
21
|
+
and_return @sdb_double
|
22
|
+
@sdb_double.should_receive(:delete).
|
23
|
+
with('heirloom', 'heirloom_old_archive').
|
24
|
+
and_return true
|
25
25
|
@delete.delete_from_catalog.should be_true
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return false if an entry does not exist in catalog" do
|
29
|
-
@
|
29
|
+
@verify_double.stub :catalog_domain_exists? => false
|
30
30
|
@delete.delete_from_catalog.should be_false
|
31
31
|
end
|
32
32
|
|
data/spec/catalog/list_spec.rb
CHANGED
@@ -3,18 +3,18 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom::Catalog::List do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
6
|
+
@config_double = double 'config'
|
7
|
+
@sdb_double = double 'sdb'
|
8
8
|
Heirloom::AWS::SimpleDB.should_receive(:new).
|
9
|
-
with(:config => @
|
10
|
-
and_return @
|
11
|
-
@list = Heirloom::Catalog::List.new :config => @
|
9
|
+
with(:config => @config_double).
|
10
|
+
and_return @sdb_double
|
11
|
+
@list = Heirloom::Catalog::List.new :config => @config_double
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should list all heirlooms in the catalog" do
|
15
|
-
@
|
16
|
-
|
17
|
-
|
15
|
+
@sdb_double.should_receive(:select).
|
16
|
+
with("SELECT * FROM heirloom").
|
17
|
+
and_return 'result'
|
18
18
|
@list.all.should == 'result'
|
19
19
|
end
|
20
20
|
|
data/spec/catalog/setup_spec.rb
CHANGED
@@ -3,24 +3,24 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom::Catalog::Setup do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
6
|
+
@logger_double = double 'logger', :info => true
|
7
|
+
@config_double = double 'config', :logger => @logger_double,
|
8
8
|
:metadata_region => 'us-west-1'
|
9
|
-
@
|
9
|
+
@verify_double = double 'verify', :catalog_domain_exists? => false
|
10
10
|
Heirloom::Catalog::Verify.should_receive(:new).
|
11
|
-
with(:config => @
|
12
|
-
and_return @
|
13
|
-
@setup = Heirloom::Catalog::Setup.new :config => @
|
11
|
+
with(:config => @config_double).
|
12
|
+
and_return @verify_double
|
13
|
+
@setup = Heirloom::Catalog::Setup.new :config => @config_double,
|
14
14
|
:name => 'new_archive'
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should call sdb to create the catalog domain" do
|
18
|
-
@
|
18
|
+
@sdb_double = double 'sdb'
|
19
19
|
Heirloom::AWS::SimpleDB.should_receive(:new).
|
20
|
-
with(:config => @
|
21
|
-
and_return @
|
22
|
-
@
|
23
|
-
|
20
|
+
with(:config => @config_double).
|
21
|
+
and_return @sdb_double
|
22
|
+
@sdb_double.should_receive(:create_domain).
|
23
|
+
with 'heirloom'
|
24
24
|
@setup.create_catalog_domain
|
25
25
|
end
|
26
26
|
|
data/spec/catalog/show_spec.rb
CHANGED
@@ -3,31 +3,31 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom::Catalog::Show do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
6
|
+
@config_double = double 'config'
|
7
|
+
@sdb_double = double 'sdb'
|
8
8
|
Heirloom::AWS::SimpleDB.should_receive(:new).
|
9
|
-
with(:config => @
|
10
|
-
and_return @
|
11
|
-
@show = Heirloom::Catalog::Show.new :config => @
|
9
|
+
with(:config => @config_double).
|
10
|
+
and_return @sdb_double
|
11
|
+
@show = Heirloom::Catalog::Show.new :config => @config_double,
|
12
12
|
:name => 'a_archive'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should return the bucket_prefix" do
|
16
|
-
result = { 'heirloom_a_archive' =>
|
17
|
-
{ 'bucket_prefix' => [ 'bp' ] }
|
16
|
+
result = { 'heirloom_a_archive' =>
|
17
|
+
{ 'bucket_prefix' => [ 'bp' ] }
|
18
18
|
}
|
19
|
-
@
|
20
|
-
|
21
|
-
|
19
|
+
@sdb_double.should_receive(:select).
|
20
|
+
with("select bucket_prefix from heirloom where itemName() = 'heirloom_a_archive'").
|
21
|
+
and_return result
|
22
22
|
@show.bucket_prefix.should == 'bp'
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should return the regions" do
|
26
26
|
regions = ['us-west-1', 'us-west-2']
|
27
27
|
result = { 'heirloom_a_archive' => { 'regions' => @regions } }
|
28
|
-
@
|
29
|
-
|
30
|
-
|
28
|
+
@sdb_double.should_receive(:select).
|
29
|
+
with("select regions from heirloom where itemName() = 'heirloom_a_archive'").
|
30
|
+
and_return result
|
31
31
|
@show.regions.should == @regions
|
32
32
|
end
|
33
33
|
|
data/spec/catalog/verify_spec.rb
CHANGED
@@ -3,43 +3,43 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom::Catalog::Verify do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
|
9
|
-
@
|
10
|
-
|
6
|
+
@sdb_double = double 'sdb'
|
7
|
+
@logger_double = double 'logger', :info => true,
|
8
|
+
:debug => true
|
9
|
+
@config_double = double 'config', :logger => @logger_double,
|
10
|
+
:metadata_region => 'us-west-1'
|
11
11
|
Heirloom::AWS::SimpleDB.should_receive(:new).
|
12
|
-
with(:config => @
|
13
|
-
and_return @
|
14
|
-
@verify = Heirloom::Catalog::Verify.new :config => @
|
12
|
+
with(:config => @config_double).
|
13
|
+
and_return @sdb_double
|
14
|
+
@verify = Heirloom::Catalog::Verify.new :config => @config_double,
|
15
15
|
:name => 'a_archive'
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
19
|
context "testing catalog_domain_exists" do
|
20
20
|
it "should return true if heirloom domain exists" do
|
21
|
-
@
|
22
|
-
|
21
|
+
@sdb_double.should_receive(:domain_exists?).
|
22
|
+
with('heirloom').and_return true
|
23
23
|
@verify.catalog_domain_exists?.should be_true
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should return false if heirloom domain does not exists" do
|
27
|
-
@
|
28
|
-
|
27
|
+
@sdb_double.should_receive(:domain_exists?).
|
28
|
+
with('heirloom').and_return false
|
29
29
|
@verify.catalog_domain_exists?.should be_false
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "testing entry_exists_in_catalog?" do
|
34
34
|
it "should return true if an entry exists in catalog" do
|
35
|
-
@
|
36
|
-
|
35
|
+
@sdb_double.should_receive(:item_count).
|
36
|
+
with('heirloom', 'heirloom_a_archive').and_return 1
|
37
37
|
@verify.entry_exists_in_catalog?('a_archive').should be_true
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should return false if an entry does not exist in catalog" do
|
41
|
-
@
|
42
|
-
|
41
|
+
@sdb_double.should_receive(:item_count).
|
42
|
+
with('heirloom', 'heirloom_a_archive').and_return 0
|
43
43
|
@verify.entry_exists_in_catalog?('a_archive').should be_false
|
44
44
|
end
|
45
45
|
end
|
data/spec/catalog_spec.rb
CHANGED
@@ -2,18 +2,18 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Heirloom::Catalog do
|
4
4
|
|
5
|
-
before do
|
6
|
-
@
|
5
|
+
before do
|
6
|
+
@config_double = double 'catalog'
|
7
7
|
@regions = ['us-west-1', 'us-west-2']
|
8
8
|
@bucket_prefix = 'bp'
|
9
|
-
@catalog = Heirloom::Catalog.new :config => @
|
9
|
+
@catalog = Heirloom::Catalog.new :config => @config_double, :name => 'new_archive'
|
10
10
|
|
11
|
-
Heirloom.stub :log =>
|
11
|
+
Heirloom.stub :log => double_log
|
12
12
|
end
|
13
13
|
|
14
14
|
context "cleanup" do
|
15
15
|
before do
|
16
|
-
@sdb =
|
16
|
+
@sdb = double 'sdb'
|
17
17
|
@sdb.stub(:select)
|
18
18
|
.and_yield('123', { 'preserve' => ['true'] })
|
19
19
|
.and_yield('abc', { 'preserve' => ['true'] })
|
@@ -22,7 +22,7 @@ describe Heirloom::Catalog do
|
|
22
22
|
|
23
23
|
it "should not destroy archives marked with 'preserve'" do
|
24
24
|
|
25
|
-
archive =
|
25
|
+
archive = double 'archive', :destroy => true
|
26
26
|
@catalog.stub :sdb => @sdb
|
27
27
|
|
28
28
|
Heirloom::Archive.should_receive(:new)
|
@@ -33,7 +33,7 @@ describe Heirloom::Catalog do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should destroy archives when removed_preserved is true" do
|
36
|
-
archive =
|
36
|
+
archive = double 'archive', :destroy => true
|
37
37
|
@catalog.stub :sdb => @sdb
|
38
38
|
|
39
39
|
Heirloom::Archive.should_receive(:new)
|
@@ -50,31 +50,31 @@ describe Heirloom::Catalog do
|
|
50
50
|
|
51
51
|
@catalog.cleanup :num_to_keep => 10, :remove_preserved => true
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
end
|
55
55
|
|
56
56
|
context "testing add" do
|
57
57
|
it "should call setup to create catalog_domain" do
|
58
|
-
@
|
59
|
-
@
|
58
|
+
@catalog_setup_double = double 'setup'
|
59
|
+
@catalog_setup_double.stub :create_catalog_domain => true
|
60
60
|
Heirloom::Catalog::Setup.should_receive(:new).
|
61
|
-
with(:config => @
|
62
|
-
and_return @
|
61
|
+
with(:config => @config_double).
|
62
|
+
and_return @catalog_setup_double
|
63
63
|
@catalog.create_catalog_domain.should be_true
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
context "testing setup" do
|
68
68
|
it "should call setup to add_to_catalog" do
|
69
|
-
@
|
69
|
+
@catalog_add_double = double 'add'
|
70
70
|
Heirloom::Catalog::Add.should_receive(:new).
|
71
|
-
with(:config => @
|
71
|
+
with(:config => @config_double,
|
72
72
|
:name => 'new_archive').
|
73
|
-
and_return @
|
74
|
-
@
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
and_return @catalog_add_double
|
74
|
+
@catalog_add_double.should_receive(:add_to_catalog).
|
75
|
+
with(:bucket_prefix => @bucket_prefix,
|
76
|
+
:regions => @regions).
|
77
|
+
and_return true
|
78
78
|
@catalog.add_to_catalog(:bucket_prefix => @bucket_prefix,
|
79
79
|
:regions => @regions).
|
80
80
|
should be_true
|
@@ -83,12 +83,12 @@ describe Heirloom::Catalog do
|
|
83
83
|
|
84
84
|
context "testing show" do
|
85
85
|
before do
|
86
|
-
@
|
86
|
+
@catalog_show_double = double 'show', :regions => @regions,
|
87
87
|
:bucket_prefix => @bucket_prefix
|
88
88
|
Heirloom::Catalog::Show.should_receive(:new).
|
89
|
-
with(:config => @
|
89
|
+
with(:config => @config_double,
|
90
90
|
:name => 'new_archive').
|
91
|
-
and_return @
|
91
|
+
and_return @catalog_show_double
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should call regions from show object" do
|
@@ -102,40 +102,40 @@ describe Heirloom::Catalog do
|
|
102
102
|
|
103
103
|
context "testing catalog_domain_exists?" do
|
104
104
|
before do
|
105
|
-
@
|
105
|
+
@catalog_verify_double = double 'show'
|
106
106
|
Heirloom::Catalog::Verify.should_receive(:new).
|
107
|
-
with(:config => @
|
108
|
-
and_return @
|
107
|
+
with(:config => @config_double).
|
108
|
+
and_return @catalog_verify_double
|
109
109
|
end
|
110
110
|
it "should return true if the catalog domain exists" do
|
111
|
-
@
|
111
|
+
@catalog_verify_double.stub :catalog_domain_exists? => true
|
112
112
|
@catalog.catalog_domain_exists?.should be_true
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should return false if the catalog domain does not exist" do
|
116
|
-
@
|
116
|
+
@catalog_verify_double.stub :catalog_domain_exists? => false
|
117
117
|
@catalog.catalog_domain_exists?.should be_false
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
121
|
context "testing entry_exists_in_catalog?" do
|
122
122
|
before do
|
123
|
-
@
|
123
|
+
@catalog_verify_double = double 'show'
|
124
124
|
Heirloom::Catalog::Verify.should_receive(:new).
|
125
|
-
with(:config => @
|
126
|
-
and_return @
|
125
|
+
with(:config => @config_double).
|
126
|
+
and_return @catalog_verify_double
|
127
127
|
end
|
128
128
|
it "should return true if the entry exists in the catalog" do
|
129
|
-
@
|
130
|
-
|
131
|
-
|
129
|
+
@catalog_verify_double.should_receive(:entry_exists_in_catalog?).
|
130
|
+
with('entry').
|
131
|
+
and_return true
|
132
132
|
@catalog.entry_exists_in_catalog?('entry').should be_true
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should return false if the entry does not exists in the catalog" do
|
136
|
-
@
|
137
|
-
|
138
|
-
|
136
|
+
@catalog_verify_double.should_receive(:entry_exists_in_catalog?).
|
137
|
+
with('entry').
|
138
|
+
and_return false
|
139
139
|
@catalog.entry_exists_in_catalog?('entry').should be_false
|
140
140
|
end
|
141
141
|
end
|
data/spec/cipher/data_spec.rb
CHANGED
@@ -2,17 +2,17 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Heirloom do
|
4
4
|
before do
|
5
|
-
@
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
@
|
11
|
-
@
|
12
|
-
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@data = Heirloom::Cipher::Data.new :config => @
|
5
|
+
@encrypted_file_double = double 'encrypted mock'
|
6
|
+
@decrypted_file_double = double 'decrypted mock'
|
7
|
+
@encrypted_file_double.stub :path => '/tmp/enc'
|
8
|
+
@decrypted_file_double.stub :path => '/tmp/dec',
|
9
|
+
:read => 'plaintext'
|
10
|
+
@logger_double = double 'logger', :info => true
|
11
|
+
@logger_double.stub :info => true,
|
12
|
+
:debug => true
|
13
|
+
@config_double = double 'config'
|
14
|
+
@config_double.stub :logger => @logger_double
|
15
|
+
@data = Heirloom::Cipher::Data.new :config => @config_double
|
16
16
|
end
|
17
17
|
|
18
18
|
context "when succesful" do
|
@@ -20,11 +20,11 @@ describe Heirloom do
|
|
20
20
|
it "should decrypt the given data" do
|
21
21
|
@data.should_receive(:which).with('gpg').and_return true
|
22
22
|
Tempfile.should_receive(:new).with('archive.tar.gz.gpg').
|
23
|
-
and_return @
|
23
|
+
and_return @encrypted_file_double
|
24
24
|
Tempfile.should_receive(:new).with('archive.tar.gz').
|
25
|
-
and_return @
|
25
|
+
and_return @decrypted_file_double
|
26
26
|
::File.should_receive(:open).
|
27
|
-
with(@
|
27
|
+
with(@encrypted_file_double,'w')
|
28
28
|
$?.stub :success? => true
|
29
29
|
|
30
30
|
command = 'gpg --batch --yes --cipher-algo AES256 --passphrase password --output /tmp/dec /tmp/enc 2>&1'
|
@@ -45,21 +45,21 @@ describe Heirloom do
|
|
45
45
|
context "when unsuccesful" do
|
46
46
|
context "with secret given" do
|
47
47
|
it "should return false if gpg not in path" do
|
48
|
-
@
|
48
|
+
@logger_double.should_receive(:error)
|
49
49
|
@data.should_receive(:which).with('gpg').and_return false
|
50
50
|
@data.decrypt_data(:data => 'crypted',
|
51
51
|
:secret => 'password').should be_false
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should return false if decrypted fails" do
|
55
|
-
@
|
55
|
+
@logger_double.should_receive(:error)
|
56
56
|
@data.should_receive(:which).with('gpg').and_return true
|
57
57
|
Tempfile.should_receive(:new).with('archive.tar.gz.gpg').
|
58
|
-
and_return @
|
58
|
+
and_return @encrypted_file_double
|
59
59
|
Tempfile.should_receive(:new).with('archive.tar.gz').
|
60
|
-
and_return @
|
60
|
+
and_return @decrypted_file_double
|
61
61
|
::File.should_receive(:open).
|
62
|
-
with(@
|
62
|
+
with(@encrypted_file_double,'w')
|
63
63
|
$?.stub :success? => false
|
64
64
|
|
65
65
|
command = 'gpg --batch --yes --cipher-algo AES256 --passphrase password --output /tmp/dec /tmp/enc 2>&1'
|