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
data/spec/cli/rotate_spec.rb
CHANGED
@@ -14,19 +14,19 @@ describe Heirloom do
|
|
14
14
|
:aws_secret_key => 'secret' }
|
15
15
|
Trollop.stub(:options).and_return options
|
16
16
|
|
17
|
-
|
18
|
-
Heirloom::Catalog.stub(:new).and_return
|
17
|
+
catalog_double = double :regions => ['us-east-1', 'us-west-1']
|
18
|
+
Heirloom::Catalog.stub(:new).and_return catalog_double
|
19
19
|
|
20
|
-
@
|
21
|
-
@
|
22
|
-
Heirloom::HeirloomLogger.stub :new => @
|
23
|
-
Heirloom::Archive.stub(:new).and_return @
|
20
|
+
@archive_double = double 'archive'
|
21
|
+
@logger_double = double_log
|
22
|
+
Heirloom::HeirloomLogger.stub :new => @logger_double
|
23
|
+
Heirloom::Archive.stub(:new).and_return @archive_double
|
24
24
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should delegate to archive object" do
|
28
28
|
|
29
|
-
@
|
29
|
+
@archive_double.should_receive :rotate
|
30
30
|
|
31
31
|
Heirloom::CLI::Rotate.new.rotate
|
32
32
|
|
@@ -34,9 +34,9 @@ describe Heirloom do
|
|
34
34
|
|
35
35
|
it "should log and do a SystemExit when a rotate fails" do
|
36
36
|
|
37
|
-
@
|
37
|
+
@archive_double.stub(:rotate).and_raise Heirloom::Exceptions::RotateFailed.new("failed")
|
38
38
|
|
39
|
-
@
|
39
|
+
@logger_double.should_receive(:error).with "failed"
|
40
40
|
expect {
|
41
41
|
Heirloom::CLI::Rotate.new.rotate
|
42
42
|
}.to raise_error SystemExit
|
data/spec/cli/setup_spec.rb
CHANGED
@@ -11,48 +11,48 @@ describe Heirloom do
|
|
11
11
|
:name => 'archive_name',
|
12
12
|
:metadata_region => 'us-west-1' }
|
13
13
|
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
14
|
+
@logger_double = double 'logger', :error => true, :info => true
|
15
|
+
@config_double = double_config :logger => @logger_double
|
16
|
+
@archive_double = double 'archive'
|
17
|
+
@catalog_double = double 'catalog'
|
18
|
+
@checker_double = double 'checker'
|
19
19
|
Trollop.stub(:options).and_return options
|
20
20
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
21
|
-
and_return @
|
21
|
+
and_return @logger_double
|
22
22
|
Heirloom::CLI::Setup.any_instance.should_receive(:load_config).
|
23
|
-
with(:logger => @
|
23
|
+
with(:logger => @logger_double,
|
24
24
|
:opts => options).
|
25
|
-
|
25
|
+
and_return @config_double
|
26
26
|
Heirloom::Archive.should_receive(:new).
|
27
27
|
with(:name => 'archive_name',
|
28
|
-
:config => @
|
29
|
-
and_return @
|
28
|
+
:config => @config_double).
|
29
|
+
and_return @archive_double
|
30
30
|
Heirloom::Catalog.should_receive(:new).
|
31
31
|
with(:name => 'archive_name',
|
32
|
-
:config => @
|
33
|
-
and_return @
|
32
|
+
:config => @config_double).
|
33
|
+
and_return @catalog_double
|
34
34
|
Heirloom::Checker.should_receive(:new).
|
35
|
-
with(:config => @
|
36
|
-
and_return @
|
35
|
+
with(:config => @config_double).
|
36
|
+
and_return @checker_double
|
37
37
|
@setup = Heirloom::CLI::Setup.new
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should setup s3 buckets, catalog and simpledb domain" do
|
41
|
-
@
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
@
|
53
|
-
|
54
|
-
|
55
|
-
@setup.setup
|
41
|
+
@checker_double.should_receive(:bucket_name_available?).
|
42
|
+
with(:bucket_prefix => "bp",
|
43
|
+
:regions => @regions,
|
44
|
+
:config => @config_double).
|
45
|
+
and_return true
|
46
|
+
@catalog_double.should_receive(:create_catalog_domain)
|
47
|
+
@catalog_double.stub :entry_exists_in_catalog? => false
|
48
|
+
@catalog_double.should_receive(:add_to_catalog).
|
49
|
+
with(:regions => @regions,
|
50
|
+
:bucket_prefix => 'bp').
|
51
|
+
and_return true
|
52
|
+
@archive_double.should_receive(:setup).
|
53
|
+
with(:regions => @regions,
|
54
|
+
:bucket_prefix => 'bp')
|
55
|
+
@setup.setup
|
56
56
|
end
|
57
57
|
|
58
58
|
end
|
data/spec/cli/shared_spec.rb
CHANGED
@@ -7,104 +7,104 @@ describe Heirloom do
|
|
7
7
|
context "testing ensure_valid_options" do
|
8
8
|
|
9
9
|
before do
|
10
|
-
@
|
11
|
-
@
|
10
|
+
@logger_double = double 'logger'
|
11
|
+
@config_double = double_config(:logger => @logger_double)
|
12
12
|
@object = Object.new
|
13
13
|
@object.extend Heirloom::CLI::Shared
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should exit if the secret is given and under 8 characters" do
|
17
|
-
@
|
18
|
-
@
|
17
|
+
@logger_double.should_receive(:error)
|
18
|
+
@logger_double.stub :info => true
|
19
19
|
lambda { @object.ensure_valid_secret(:secret => 'shorty',
|
20
|
-
:config => @
|
20
|
+
:config => @config_double) }.
|
21
21
|
should raise_error SystemExit
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should return false if a required array is emtpy" do
|
25
|
-
@
|
25
|
+
@logger_double.should_receive(:error)
|
26
26
|
lambda { @object.ensure_valid_options(:provided => {
|
27
27
|
:array => [],
|
28
28
|
:string => 'present'
|
29
29
|
},
|
30
30
|
:required => [:array, :string],
|
31
|
-
:config => @
|
31
|
+
:config => @config_double) }.
|
32
32
|
should raise_error SystemExit
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return false if a required string is nil" do
|
36
|
-
@
|
36
|
+
@logger_double.should_receive(:error)
|
37
37
|
lambda { @object.ensure_valid_options(:provided => {
|
38
38
|
:array => ['present'],
|
39
39
|
:string => nil
|
40
40
|
},
|
41
41
|
:required => [:array, :string],
|
42
|
-
:config => @
|
42
|
+
:config => @config_double) }.
|
43
43
|
should raise_error SystemExit
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should return false if a require string is nil & array is empty" do
|
47
|
-
@
|
47
|
+
@logger_double.should_receive(:error).exactly(2).times
|
48
48
|
lambda { @object.ensure_valid_options(:provided => {
|
49
49
|
:array => [],
|
50
50
|
:string => nil
|
51
51
|
},
|
52
52
|
:required => [:array, :string],
|
53
|
-
:config => @
|
53
|
+
:config => @config_double) }.
|
54
54
|
should raise_error SystemExit
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should return true if all options are present" do
|
58
|
-
@
|
58
|
+
@logger_double.should_receive(:error).exactly(0).times
|
59
59
|
@object.ensure_valid_options(:provided => { :array => ['present'],
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
:string => 'present' },
|
61
|
+
:required => [:array, :string],
|
62
|
+
:config => @config_double)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
context "testing load_config" do
|
67
67
|
|
68
68
|
before do
|
69
|
-
@
|
70
|
-
@
|
69
|
+
@config_double = double 'config'
|
70
|
+
@logger_double = double 'logger', :debug => true
|
71
71
|
@object = Object.new
|
72
72
|
@object.extend Heirloom::CLI::Shared
|
73
|
-
Heirloom::Config.should_receive(:new).with(:logger => @
|
74
|
-
and_return @
|
75
|
-
@
|
73
|
+
Heirloom::Config.should_receive(:new).with(:logger => @logger_double, :environment => nil).
|
74
|
+
and_return @config_double
|
75
|
+
@config_double.stub :proxy => nil
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should return the configuration" do
|
79
|
-
@object.load_config(:logger => @
|
80
|
-
:opts => {}).should == @
|
79
|
+
@object.load_config(:logger => @logger_double,
|
80
|
+
:opts => {}).should == @config_double
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should set the metadata region if specified" do
|
84
84
|
opts = { :metadata_region => 'us-west-1' }
|
85
|
-
@
|
86
|
-
@object.load_config :logger => @
|
85
|
+
@config_double.should_receive(:metadata_region=).with 'us-west-1'
|
86
|
+
@object.load_config :logger => @logger_double, :opts => opts
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should set the access key if specified" do
|
90
90
|
opts = { :aws_access_key => 'the_key' }
|
91
|
-
@
|
92
|
-
@object.load_config :logger => @
|
91
|
+
@config_double.should_receive(:access_key=).with 'the_key'
|
92
|
+
@object.load_config :logger => @logger_double, :opts => opts
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should set the secret key if specified" do
|
96
96
|
opts = { :aws_secret_key => 'the_secret' }
|
97
|
-
@
|
98
|
-
@object.load_config :logger => @
|
97
|
+
@config_double.should_receive(:secret_key=).with 'the_secret'
|
98
|
+
@object.load_config :logger => @logger_double, :opts => opts
|
99
99
|
end
|
100
100
|
|
101
101
|
end
|
102
102
|
|
103
103
|
context "test ensure directory" do
|
104
104
|
before do
|
105
|
-
@
|
106
|
-
@
|
107
|
-
@
|
105
|
+
@logger_double = double 'logger', :error => true
|
106
|
+
@config_double = double 'config'
|
107
|
+
@config_double.stub :logger => @logger_double
|
108
108
|
@object = Object.new
|
109
109
|
@object.extend Heirloom::CLI::Shared
|
110
110
|
end
|
@@ -113,48 +113,48 @@ describe Heirloom do
|
|
113
113
|
File.should_receive(:directory?).with('/tmp/test').
|
114
114
|
and_return false
|
115
115
|
lambda { @object.ensure_path_is_directory(:path => '/tmp/test',
|
116
|
-
:config => @
|
116
|
+
:config => @config_double) }.
|
117
117
|
should raise_error SystemExit
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should not exit when path is a directory" do
|
121
121
|
File.should_receive(:directory?).with('/tmp/test').
|
122
122
|
and_return true
|
123
|
-
@object.ensure_path_is_directory :path => '/tmp/test', :config => @
|
123
|
+
@object.ensure_path_is_directory :path => '/tmp/test', :config => @config_double
|
124
124
|
end
|
125
125
|
|
126
126
|
it "should exit when directory is not writable" do
|
127
127
|
File.should_receive(:writable?).with('/tmp/test').
|
128
128
|
and_return false
|
129
129
|
lambda { @object.ensure_directory_is_writable(:path => '/tmp/test',
|
130
|
-
:config => @
|
130
|
+
:config => @config_double) }.
|
131
131
|
should raise_error SystemExit
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should not exit when directory is writable" do
|
135
135
|
File.should_receive(:writable?).with('/tmp/test').
|
136
|
-
|
137
|
-
@object.ensure_directory_is_writable :path => '/tmp/test', :config => @
|
136
|
+
and_return true
|
137
|
+
@object.ensure_directory_is_writable :path => '/tmp/test', :config => @config_double
|
138
138
|
end
|
139
139
|
|
140
140
|
end
|
141
141
|
|
142
142
|
context "testing ensure domain" do
|
143
143
|
before do
|
144
|
-
@
|
145
|
-
@
|
146
|
-
@
|
144
|
+
@archive_double = double 'archive'
|
145
|
+
@logger_double = double 'logger', :error => true
|
146
|
+
@config_double = double 'config', :logger => @logger_double,
|
147
147
|
:metadata_region => 'us-west-1'
|
148
148
|
@object = Object.new
|
149
149
|
@object.extend Heirloom::CLI::Shared
|
150
150
|
Heirloom::Archive.should_receive(:new).
|
151
|
-
with(:name => 'test', :config => @
|
152
|
-
and_return @
|
151
|
+
with(:name => 'test', :config => @config_double).
|
152
|
+
and_return @archive_double
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should exit if the domain does not exist" do
|
156
|
-
@
|
157
|
-
lambda { @object.ensure_domain_exists :config => @
|
156
|
+
@archive_double.stub :domain_exists? => false
|
157
|
+
lambda { @object.ensure_domain_exists :config => @config_double,
|
158
158
|
:name => 'test'}.
|
159
159
|
should raise_error SystemExit
|
160
160
|
end
|
@@ -162,16 +162,16 @@ describe Heirloom do
|
|
162
162
|
|
163
163
|
context "testing ensure metadata domain" do
|
164
164
|
before do
|
165
|
-
@
|
166
|
-
@
|
167
|
-
@
|
165
|
+
@archive_double = double 'archive'
|
166
|
+
@logger_double = double 'logger', :error => true
|
167
|
+
@config_double = double 'config', :logger => @logger_double,
|
168
168
|
:metadata_region => 'us-west-1'
|
169
169
|
@object = Object.new
|
170
170
|
@object.extend Heirloom::CLI::Shared
|
171
171
|
end
|
172
172
|
|
173
173
|
it "should exit if the metadata region is not in an upload region" do
|
174
|
-
options = { :config => @
|
174
|
+
options = { :config => @config_double, :regions => ['us-west-2', 'us-east-1'] }
|
175
175
|
lambda { @object.ensure_metadata_in_upload_region options }.
|
176
176
|
should raise_error SystemExit
|
177
177
|
end
|
@@ -179,15 +179,15 @@ describe Heirloom do
|
|
179
179
|
|
180
180
|
context "testing ensure valid regions" do
|
181
181
|
before do
|
182
|
-
@
|
183
|
-
@
|
182
|
+
@logger_double = double 'logger', :error => true
|
183
|
+
@config_double = double 'config', :logger => @logger_double,
|
184
184
|
:metadata_region => 'us-west-1'
|
185
185
|
@object = Object.new
|
186
186
|
@object.extend Heirloom::CLI::Shared
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should exit if the region is not valid" do
|
190
|
-
options = { :config => @
|
190
|
+
options = { :config => @config_double, :regions => ['us-west-2', 'us-bad-1'] }
|
191
191
|
lambda { @object.ensure_valid_regions options }.
|
192
192
|
should raise_error SystemExit
|
193
193
|
end
|
@@ -196,17 +196,17 @@ describe Heirloom do
|
|
196
196
|
|
197
197
|
context "testing ensure archive exists" do
|
198
198
|
before do
|
199
|
-
@
|
200
|
-
@
|
201
|
-
@
|
199
|
+
@archive_double = double 'archive'
|
200
|
+
@logger_double = double 'logger', :error => true
|
201
|
+
@config_double = double 'config', :logger => @logger_double,
|
202
202
|
:metadata_region => 'us-west-1'
|
203
203
|
@object = Object.new
|
204
204
|
@object.extend Heirloom::CLI::Shared
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should exit if the archive does not exist" do
|
208
|
-
@
|
209
|
-
options = { :config => @
|
208
|
+
@archive_double.should_receive(:exists?).and_return false
|
209
|
+
options = { :config => @config_double, :archive => @archive_double }
|
210
210
|
lambda { @object.ensure_archive_exists options }.
|
211
211
|
should raise_error SystemExit
|
212
212
|
end
|
@@ -214,17 +214,17 @@ describe Heirloom do
|
|
214
214
|
|
215
215
|
context "testing ensure archive domain empty" do
|
216
216
|
before do
|
217
|
-
@
|
218
|
-
@
|
219
|
-
@
|
217
|
+
@archive_double = double 'archive'
|
218
|
+
@logger_double = double 'logger', :error => true
|
219
|
+
@config_double = double 'config', :logger => @logger_double,
|
220
220
|
:metadata_region => 'us-west-1'
|
221
|
-
@options = { :config => @
|
221
|
+
@options = { :config => @config_double, :archive => @archive_double }
|
222
222
|
@object = Object.new
|
223
223
|
@object.extend Heirloom::CLI::Shared
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should exit if the domain is not empty" do
|
227
|
-
@
|
227
|
+
@archive_double.stub :count => 200
|
228
228
|
lambda { @object.ensure_archive_domain_empty @options }.
|
229
229
|
should raise_error SystemExit
|
230
230
|
end
|
@@ -232,17 +232,17 @@ describe Heirloom do
|
|
232
232
|
|
233
233
|
context "testing ensure catalog domain exists" do
|
234
234
|
before do
|
235
|
-
@
|
236
|
-
@
|
237
|
-
@
|
235
|
+
@catalog_double = double 'catalog'
|
236
|
+
@logger_double = double 'logger', :error => true
|
237
|
+
@config_double = double 'config', :logger => @logger_double,
|
238
238
|
:metadata_region => 'us-west-1'
|
239
|
-
@options = { :config => @
|
239
|
+
@options = { :config => @config_double, :catalog => @catalog_double }
|
240
240
|
@object = Object.new
|
241
241
|
@object.extend Heirloom::CLI::Shared
|
242
242
|
end
|
243
243
|
|
244
244
|
it "should exit if the catlog domain does not exist" do
|
245
|
-
@
|
245
|
+
@catalog_double.stub :catalog_domain_exists? => false
|
246
246
|
lambda { @object.ensure_catalog_domain_exists @options }.
|
247
247
|
should raise_error SystemExit
|
248
248
|
end
|
@@ -250,21 +250,21 @@ describe Heirloom do
|
|
250
250
|
|
251
251
|
context "testing ensure entry (does not) exists in catalog" do
|
252
252
|
before do
|
253
|
-
@
|
254
|
-
@
|
255
|
-
@
|
253
|
+
@catalog_double = double 'catalog'
|
254
|
+
@logger_double = double 'logger', :error => true
|
255
|
+
@config_double = double 'config', :logger => @logger_double,
|
256
256
|
:metadata_region => 'us-west-1'
|
257
|
-
@options = { :config => @
|
258
|
-
:catalog => @
|
257
|
+
@options = { :config => @config_double,
|
258
|
+
:catalog => @catalog_double,
|
259
259
|
:entry => 'entry' }
|
260
260
|
@object = Object.new
|
261
261
|
@object.extend Heirloom::CLI::Shared
|
262
262
|
end
|
263
263
|
|
264
264
|
it "should exit if the entry does not exist in catalog" do
|
265
|
-
@
|
266
|
-
|
267
|
-
|
265
|
+
@catalog_double.should_receive(:entry_exists_in_catalog?).
|
266
|
+
with('entry').
|
267
|
+
and_return false
|
268
268
|
lambda { @object.ensure_entry_exists_in_catalog @options }.
|
269
269
|
should raise_error SystemExit
|
270
270
|
end
|
@@ -273,9 +273,9 @@ describe Heirloom do
|
|
273
273
|
|
274
274
|
context "testing latest id" do
|
275
275
|
before do
|
276
|
-
@
|
277
|
-
@
|
278
|
-
@options = { :config => @
|
276
|
+
@archive_double = double 'archive'
|
277
|
+
@config_double = double 'config'
|
278
|
+
@options = { :config => @config_double, :archive => @archive_double }
|
279
279
|
@object = Object.new
|
280
280
|
@object.extend Heirloom::CLI::Shared
|
281
281
|
end
|
@@ -283,13 +283,13 @@ describe Heirloom do
|
|
283
283
|
it "should return the latest id" do
|
284
284
|
Heirloom::Archive.should_receive(:new).
|
285
285
|
with(:name => 'test',
|
286
|
-
:config => @
|
287
|
-
and_return @
|
288
|
-
@
|
286
|
+
:config => @config_double).
|
287
|
+
and_return @archive_double
|
288
|
+
@archive_double.should_receive(:list).
|
289
289
|
with(1).
|
290
290
|
and_return ['id']
|
291
291
|
@object.latest_id(:name => 'test',
|
292
|
-
:config => @
|
292
|
+
:config => @config_double).
|
293
293
|
should == 'id'
|
294
294
|
end
|
295
295
|
|
@@ -297,10 +297,10 @@ describe Heirloom do
|
|
297
297
|
|
298
298
|
context "read secret from file" do
|
299
299
|
before do
|
300
|
-
@
|
301
|
-
@
|
302
|
-
@
|
303
|
-
@options = { :config => @
|
300
|
+
@archive_double = double 'archive'
|
301
|
+
@logger_double = double 'logger', :error => true
|
302
|
+
@config_double = double 'config', :logger => @logger_double
|
303
|
+
@options = { :config => @config_double, :opts => {} }
|
304
304
|
@object = Object.new
|
305
305
|
@object.extend Heirloom::CLI::Shared
|
306
306
|
end
|
@@ -313,7 +313,7 @@ describe Heirloom do
|
|
313
313
|
end
|
314
314
|
|
315
315
|
it "should return the contents of the file with newline removed" do
|
316
|
-
|
316
|
+
file_double = double 'file'
|
317
317
|
@options[:opts][:secret_file] = '/good/file'
|
318
318
|
File.stub :exists? => true
|
319
319
|
File.should_receive(:read).
|
@@ -332,33 +332,33 @@ describe Heirloom do
|
|
332
332
|
|
333
333
|
context "ensure buckets are available or owned by account" do
|
334
334
|
before do
|
335
|
-
@
|
336
|
-
@
|
337
|
-
@
|
338
|
-
@args = { :config => @
|
335
|
+
@logger_double = double 'logger', :error => true
|
336
|
+
@config_double = double 'config', :logger => @logger_double
|
337
|
+
@checker_double = double 'checker'
|
338
|
+
@args = { :config => @config_double,
|
339
339
|
:bucket_prefix => 'intu-lc',
|
340
340
|
:regions => ['us-west-1', 'us-west-2'] }
|
341
341
|
@object = Object.new
|
342
342
|
@object.extend Heirloom::CLI::Shared
|
343
343
|
Heirloom::Checker.should_receive(:new).
|
344
|
-
with(:config => @
|
345
|
-
and_return @
|
344
|
+
with(:config => @config_double).
|
345
|
+
and_return @checker_double
|
346
346
|
end
|
347
347
|
|
348
348
|
it "should return true if buckets available in all regions" do
|
349
|
-
@
|
349
|
+
@checker_double.should_receive(:bucket_name_available?).
|
350
350
|
with(:bucket_prefix => 'intu-lc',
|
351
351
|
:regions => ['us-west-1', 'us-west-2'],
|
352
|
-
:config => @
|
352
|
+
:config => @config_double).
|
353
353
|
and_return true
|
354
354
|
@object.ensure_buckets_available(@args).should be_true
|
355
355
|
end
|
356
356
|
|
357
357
|
it "should return raise and error if any bucket un-available in all regions" do
|
358
|
-
@
|
358
|
+
@checker_double.should_receive(:bucket_name_available?).
|
359
359
|
with(:bucket_prefix => 'intu-lc',
|
360
360
|
:regions => ['us-west-1', 'us-west-2'],
|
361
|
-
:config => @
|
361
|
+
:config => @config_double).
|
362
362
|
and_return false
|
363
363
|
lambda { @object.ensure_buckets_available(@args) }.
|
364
364
|
should raise_error SystemExit
|
@@ -367,20 +367,20 @@ describe Heirloom do
|
|
367
367
|
|
368
368
|
context "testing ensure entry does not exist in catalog unless forced" do
|
369
369
|
before do
|
370
|
-
@
|
371
|
-
@
|
372
|
-
@
|
370
|
+
@catalog_double = double 'catalog'
|
371
|
+
@logger_double = double 'logger', :error => true
|
372
|
+
@config_double = double 'config', :logger => @logger_double,
|
373
373
|
:metadata_region => 'us-west-1'
|
374
374
|
@object = Object.new
|
375
375
|
@object.extend Heirloom::CLI::Shared
|
376
376
|
end
|
377
377
|
|
378
378
|
it "should exit if the entry exists in catalog and not forced" do
|
379
|
-
options = { :config => @
|
380
|
-
:catalog => @
|
379
|
+
options = { :config => @config_double,
|
380
|
+
:catalog => @catalog_double,
|
381
381
|
:entry => 'entry',
|
382
382
|
:force => false }
|
383
|
-
@
|
383
|
+
@catalog_double.should_receive(:entry_exists_in_catalog?).
|
384
384
|
with('entry').
|
385
385
|
and_return true
|
386
386
|
lambda { @object.ensure_entry_does_not_exist_in_catalog options }.
|
@@ -388,22 +388,22 @@ describe Heirloom do
|
|
388
388
|
end
|
389
389
|
|
390
390
|
it "should not exit if the entry exists in catalog and forced" do
|
391
|
-
options = { :config => @
|
392
|
-
:catalog => @
|
391
|
+
options = { :config => @config_double,
|
392
|
+
:catalog => @catalog_double,
|
393
393
|
:entry => 'entry',
|
394
394
|
:force => true }
|
395
|
-
@
|
395
|
+
@catalog_double.should_receive(:entry_exists_in_catalog?).
|
396
396
|
with('entry').
|
397
397
|
and_return true
|
398
398
|
@object.ensure_entry_does_not_exist_in_catalog options
|
399
399
|
end
|
400
400
|
|
401
401
|
it "should not exit if the does not exists in catalog" do
|
402
|
-
options = { :config => @
|
403
|
-
:catalog => @
|
402
|
+
options = { :config => @config_double,
|
403
|
+
:catalog => @catalog_double,
|
404
404
|
:entry => 'entry',
|
405
405
|
:force => false }
|
406
|
-
@
|
406
|
+
@catalog_double.should_receive(:entry_exists_in_catalog?).
|
407
407
|
with('entry').
|
408
408
|
and_return false
|
409
409
|
@object.ensure_entry_does_not_exist_in_catalog options
|
@@ -412,32 +412,32 @@ describe Heirloom do
|
|
412
412
|
|
413
413
|
context "testing ensure valid name" do
|
414
414
|
before do
|
415
|
-
@
|
416
|
-
@
|
415
|
+
@logger_double = double 'logger', :error => true
|
416
|
+
@config_double = double 'config', :logger => @logger_double,
|
417
417
|
:metadata_region => 'us-west-1'
|
418
418
|
@object = Object.new
|
419
419
|
@object.extend Heirloom::CLI::Shared
|
420
420
|
end
|
421
421
|
|
422
422
|
it "should not exit if name is valid" do
|
423
|
-
@object.ensure_valid_name :config => @
|
423
|
+
@object.ensure_valid_name :config => @config_double,
|
424
424
|
:name => 'test-123_test'
|
425
425
|
end
|
426
426
|
|
427
427
|
it "should exit if name contains a upper case" do
|
428
|
-
lambda { @object.ensure_valid_name :config => @
|
428
|
+
lambda { @object.ensure_valid_name :config => @config_double,
|
429
429
|
:name => 'TEST-123' }.
|
430
430
|
should raise_error SystemExit
|
431
431
|
end
|
432
432
|
|
433
433
|
it "should exit if name contains a space" do
|
434
|
-
lambda { @object.ensure_valid_name :config => @
|
434
|
+
lambda { @object.ensure_valid_name :config => @config_double,
|
435
435
|
:name => 'test 123' }.
|
436
436
|
should raise_error SystemExit
|
437
437
|
end
|
438
438
|
|
439
439
|
it "should exit if name contains invalid characters" do
|
440
|
-
lambda { @object.ensure_valid_name :config => @
|
440
|
+
lambda { @object.ensure_valid_name :config => @config_double,
|
441
441
|
:name => 'test,123' }.
|
442
442
|
should raise_error SystemExit
|
443
443
|
end
|
@@ -445,32 +445,32 @@ describe Heirloom do
|
|
445
445
|
|
446
446
|
context "testing ensure valid bucket prefix" do
|
447
447
|
before do
|
448
|
-
@
|
449
|
-
@
|
448
|
+
@logger_double = double 'logger', :error => true
|
449
|
+
@config_double = double 'config', :logger => @logger_double,
|
450
450
|
:metadata_region => 'us-west-1'
|
451
451
|
@object = Object.new
|
452
452
|
@object.extend Heirloom::CLI::Shared
|
453
453
|
end
|
454
454
|
|
455
455
|
it "should not exit if bucket_prefix is valid" do
|
456
|
-
@object.ensure_valid_bucket_prefix :config => @
|
456
|
+
@object.ensure_valid_bucket_prefix :config => @config_double,
|
457
457
|
:bucket_prefix => 'test-123'
|
458
458
|
end
|
459
459
|
|
460
460
|
it "should exit if bucket_prefix contains uppercase" do
|
461
|
-
lambda { @object.ensure_valid_bucket_prefix :config => @
|
461
|
+
lambda { @object.ensure_valid_bucket_prefix :config => @config_double,
|
462
462
|
:bucket_prefix => 'TEST-123' }.
|
463
463
|
should raise_error SystemExit
|
464
464
|
end
|
465
465
|
|
466
466
|
it "should exit if bucket_prefix contains a space" do
|
467
|
-
lambda { @object.ensure_valid_bucket_prefix :config => @
|
467
|
+
lambda { @object.ensure_valid_bucket_prefix :config => @config_double,
|
468
468
|
:bucket_prefix => 'test 123' }.
|
469
469
|
should raise_error SystemExit
|
470
470
|
end
|
471
471
|
|
472
472
|
it "should exit if bucket_prefix contains invalid characters" do
|
473
|
-
lambda { @object.ensure_valid_bucket_prefix :config => @
|
473
|
+
lambda { @object.ensure_valid_bucket_prefix :config => @config_double,
|
474
474
|
:bucket_prefix => 'test,123' }.
|
475
475
|
should raise_error SystemExit
|
476
476
|
end
|