backup 3.0.26 → 3.0.27
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.
- data/README.md +1 -3
- data/lib/backup/cli/helpers.rb +2 -0
- data/lib/backup/cli/utility.rb +4 -4
- data/lib/backup/compressor/bzip2.rb +8 -4
- data/lib/backup/compressor/gzip.rb +8 -4
- data/lib/backup/configuration/helpers.rb +30 -38
- data/lib/backup/database/mongodb.rb +2 -1
- data/lib/backup/database/mysql.rb +2 -1
- data/lib/backup/database/postgresql.rb +2 -1
- data/lib/backup/database/redis.rb +2 -1
- data/lib/backup/database/riak.rb +2 -1
- data/lib/backup/encryptor/gpg.rb +717 -37
- data/lib/backup/syncer/cloud/base.rb +2 -2
- data/lib/backup/version.rb +1 -1
- data/spec-live/backups/config.rb +14 -84
- data/spec-live/backups/config.yml.template +3 -0
- data/spec-live/backups/models.rb +184 -0
- data/spec-live/encryptor/gpg_keys.rb +239 -0
- data/spec-live/encryptor/gpg_spec.rb +287 -0
- data/spec-live/notifier/mail_spec.rb +58 -22
- data/spec-live/spec_helper.rb +69 -3
- data/spec/cli/helpers_spec.rb +25 -25
- data/spec/cli/utility_spec.rb +6 -3
- data/spec/compressor/bzip2_spec.rb +20 -41
- data/spec/compressor/gzip_spec.rb +20 -41
- data/spec/configuration/helpers_spec.rb +94 -253
- data/spec/database/mongodb_spec.rb +9 -10
- data/spec/database/mysql_spec.rb +9 -10
- data/spec/database/postgresql_spec.rb +9 -10
- data/spec/database/redis_spec.rb +9 -10
- data/spec/database/riak_spec.rb +9 -10
- data/spec/encryptor/gpg_spec.rb +830 -71
- data/spec/storage/dropbox_spec.rb +24 -36
- data/spec/syncer/cloud/base_spec.rb +1 -1
- data/templates/cli/utility/encryptor/gpg +16 -1
- metadata +63 -64
@@ -8,25 +8,30 @@ describe 'Backup::Configuration::Helpers' do
|
|
8
8
|
module Backup
|
9
9
|
class Foo
|
10
10
|
include Backup::Configuration::Helpers
|
11
|
-
attr_accessor :accessor
|
11
|
+
attr_accessor :accessor, :accessor_two
|
12
12
|
attr_reader :reader
|
13
|
+
|
13
14
|
attr_deprecate :removed,
|
14
15
|
:version => '1.1'
|
15
|
-
|
16
|
+
|
17
|
+
attr_deprecate :removed_with_message,
|
16
18
|
:version => '1.2',
|
17
|
-
:
|
18
|
-
|
19
|
+
:message => 'This has no replacement.'
|
20
|
+
|
21
|
+
attr_deprecate :removed_with_action,
|
19
22
|
:version => '1.3',
|
20
|
-
:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
attr_deprecate :replaced_with_lambda_nil,
|
23
|
+
:action => lambda {|klass, val|
|
24
|
+
klass.accessor = val ? '1' : '0'
|
25
|
+
klass.accessor_two = 'updated'
|
26
|
+
}
|
27
|
+
|
28
|
+
attr_deprecate :removed_with_action_and_message,
|
27
29
|
:version => '1.4',
|
28
|
-
:
|
29
|
-
:
|
30
|
+
:message => "Updating accessors.",
|
31
|
+
:action => lambda {|klass, val|
|
32
|
+
klass.accessor = val ? '1' : '0'
|
33
|
+
klass.accessor_two = 'updated'
|
34
|
+
}
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -55,7 +60,8 @@ describe 'Backup::Configuration::Helpers' do
|
|
55
60
|
it 'should cache the Configuration::Store for the class' do
|
56
61
|
Backup::Foo.instance_variable_get(:@configuration).should be_nil
|
57
62
|
Backup::Foo.defaults.should be(configuration)
|
58
|
-
Backup::Foo.instance_variable_get(
|
63
|
+
Backup::Foo.instance_variable_get(
|
64
|
+
:@configuration).should be(configuration)
|
59
65
|
Backup::Foo.defaults.should be(configuration)
|
60
66
|
end
|
61
67
|
end
|
@@ -75,7 +81,7 @@ describe 'Backup::Configuration::Helpers' do
|
|
75
81
|
describe '.deprecations' do
|
76
82
|
it 'should return @deprecations' do
|
77
83
|
Backup::Foo.deprecations.should be_a(Hash)
|
78
|
-
Backup::Foo.deprecations.keys.count.should be(
|
84
|
+
Backup::Foo.deprecations.keys.count.should be(4)
|
79
85
|
end
|
80
86
|
|
81
87
|
it 'should set @deprecations to an empty hash if not set' do
|
@@ -91,42 +97,40 @@ describe 'Backup::Configuration::Helpers' do
|
|
91
97
|
|
92
98
|
it 'should add deprected attributes' do
|
93
99
|
Backup::Foo.send(:attr_deprecate, :attr1)
|
94
|
-
Backup::Foo.send(:attr_deprecate, :attr2,
|
95
|
-
|
100
|
+
Backup::Foo.send(:attr_deprecate, :attr2,
|
101
|
+
:version => '2')
|
102
|
+
Backup::Foo.send(:attr_deprecate, :attr3,
|
103
|
+
:version => '3',
|
104
|
+
:message => 'attr3 message')
|
96
105
|
Backup::Foo.send(:attr_deprecate, :attr4,
|
97
|
-
:version => '
|
98
|
-
|
99
|
-
:
|
100
|
-
:replacement => :new_attr5,
|
101
|
-
:value => 'new_value')
|
106
|
+
:version => '4',
|
107
|
+
:message => 'attr4 message',
|
108
|
+
:action => 'attr4 action')
|
102
109
|
|
103
110
|
Backup::Foo.deprecations.should == {
|
104
111
|
:attr1 => { :version => nil,
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:attr2 => { :version => '
|
108
|
-
:
|
109
|
-
:
|
110
|
-
:attr3 => { :version =>
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:attr4 => { :version => '
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:attr5 => { :version => '1.5',
|
117
|
-
:replacement => :new_attr5,
|
118
|
-
:value => 'new_value' }
|
112
|
+
:message => nil,
|
113
|
+
:action => nil },
|
114
|
+
:attr2 => { :version => '2',
|
115
|
+
:message => nil,
|
116
|
+
:action => nil },
|
117
|
+
:attr3 => { :version => '3',
|
118
|
+
:message => 'attr3 message',
|
119
|
+
:action => nil },
|
120
|
+
:attr4 => { :version => '4',
|
121
|
+
:message => 'attr4 message',
|
122
|
+
:action => 'attr4 action' }
|
119
123
|
}
|
120
124
|
end
|
121
125
|
end
|
122
126
|
|
123
127
|
describe '.log_deprecation_warning' do
|
124
|
-
context 'when
|
128
|
+
context 'when no message given' do
|
125
129
|
it 'should log a warning that the attribute has been removed' do
|
126
130
|
Backup::Logger.expects(:warn).with do |err|
|
127
131
|
err.message.should ==
|
128
132
|
"ConfigurationError: [DEPRECATION WARNING]\n" +
|
129
|
-
" Backup::Foo
|
133
|
+
" Backup::Foo#removed has been deprecated as of backup v.1.1"
|
130
134
|
end
|
131
135
|
|
132
136
|
deprecation = Backup::Foo.deprecations[:removed]
|
@@ -134,21 +138,22 @@ describe 'Backup::Configuration::Helpers' do
|
|
134
138
|
end
|
135
139
|
end
|
136
140
|
|
137
|
-
context 'when
|
138
|
-
it 'should log
|
141
|
+
context 'when a message is given' do
|
142
|
+
it 'should log warning with the message' do
|
139
143
|
Backup::Logger.expects(:warn).with do |err|
|
140
144
|
err.message.should ==
|
141
145
|
"ConfigurationError: [DEPRECATION WARNING]\n" +
|
142
|
-
" Backup::Foo
|
143
|
-
"
|
144
|
-
"
|
146
|
+
" Backup::Foo#removed_with_message has been deprecated " +
|
147
|
+
"as of backup v.1.2\n" +
|
148
|
+
" This has no replacement."
|
145
149
|
end
|
146
150
|
|
147
|
-
deprecation = Backup::Foo.deprecations[:
|
148
|
-
Backup::Foo.log_deprecation_warning(:
|
151
|
+
deprecation = Backup::Foo.deprecations[:removed_with_message]
|
152
|
+
Backup::Foo.log_deprecation_warning(:removed_with_message, deprecation)
|
153
|
+
|
149
154
|
end
|
150
155
|
end
|
151
|
-
end
|
156
|
+
end # describe '.log_deprecation_warning'
|
152
157
|
|
153
158
|
describe '#load_defaults!' do
|
154
159
|
let(:klass) { Backup::Foo.new }
|
@@ -183,224 +188,60 @@ describe 'Backup::Configuration::Helpers' do
|
|
183
188
|
end
|
184
189
|
end
|
185
190
|
|
186
|
-
describe '#
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
Backup::Foo.defaults do |f|
|
194
|
-
f.replaced_with_value = 'attr_value'
|
195
|
-
end
|
196
|
-
|
197
|
-
Backup::Logger.expects(:warn).with(
|
198
|
-
instance_of(Backup::Errors::ConfigurationError)
|
199
|
-
)
|
200
|
-
Backup::Logger.expects(:warn).with(
|
201
|
-
"Backup::Foo.accessor is being set to 'new_value'"
|
202
|
-
)
|
203
|
-
|
204
|
-
klass = Backup::Foo.new
|
205
|
-
klass.send(:load_defaults!)
|
206
|
-
klass.accessor.should == 'new_value'
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
context 'and the replacement value is a lambda' do
|
211
|
-
it 'should set replacement value using the lambda' do
|
212
|
-
value = [true, false].shuffle.first
|
213
|
-
new_value = value ? '1' : '0'
|
214
|
-
|
215
|
-
Backup::Foo.defaults do |f|
|
216
|
-
f.replaced_with_lambda = value
|
217
|
-
end
|
218
|
-
|
219
|
-
Backup::Logger.expects(:warn).with(
|
220
|
-
instance_of(Backup::Errors::ConfigurationError)
|
221
|
-
)
|
222
|
-
Backup::Logger.expects(:warn).with(
|
223
|
-
"Backup::Foo.accessor is being set to '#{ new_value }'"
|
224
|
-
)
|
225
|
-
|
226
|
-
klass = Backup::Foo.new
|
227
|
-
klass.send(:load_defaults!)
|
228
|
-
klass.accessor.should == new_value
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'should not set the replacement if the lambda returns nil' do
|
232
|
-
Backup::Foo.defaults do |f|
|
233
|
-
f.replaced_with_lambda_nil = 'foo'
|
234
|
-
end
|
235
|
-
|
236
|
-
Backup::Foo.any_instance.expects(:accessor=).never
|
237
|
-
|
238
|
-
Backup::Logger.expects(:warn).with(
|
239
|
-
instance_of(Backup::Errors::ConfigurationError)
|
240
|
-
)
|
241
|
-
|
242
|
-
klass = Backup::Foo.new
|
243
|
-
klass.send(:load_defaults!)
|
244
|
-
klass.accessor.should be_nil
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
context 'and no replacement value is specified' do
|
249
|
-
it 'should set the original value on the replacement' do
|
250
|
-
Backup::Foo.defaults do |f|
|
251
|
-
f.replaced = 'attr_value'
|
252
|
-
end
|
253
|
-
|
254
|
-
Backup::Logger.expects(:warn).with(
|
255
|
-
instance_of(Backup::Errors::ConfigurationError)
|
256
|
-
)
|
257
|
-
Backup::Logger.expects(:warn).with(
|
258
|
-
"Backup::Foo.accessor is being set to 'attr_value'"
|
259
|
-
)
|
260
|
-
|
261
|
-
klass = Backup::Foo.new
|
262
|
-
klass.send(:load_defaults!)
|
263
|
-
klass.accessor.should == 'attr_value'
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
context 'and the deprecated method has no replacement' do
|
269
|
-
it 'should only log a warning' do
|
270
|
-
Backup::Foo.defaults do |f|
|
271
|
-
f.removed = 'attr_value'
|
272
|
-
end
|
273
|
-
|
274
|
-
Backup::Logger.expects(:warn).with(
|
275
|
-
instance_of(Backup::Errors::ConfigurationError)
|
276
|
-
)
|
277
|
-
|
278
|
-
klass = Backup::Foo.new
|
279
|
-
klass.send(:load_defaults!)
|
280
|
-
klass.accessor.should be_nil
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
191
|
+
describe '#method_missing' do
|
192
|
+
context 'when the method is a deprecated method' do
|
193
|
+
before do
|
194
|
+
Backup::Logger.expects(:warn).with(
|
195
|
+
instance_of(Backup::Errors::ConfigurationError)
|
196
|
+
)
|
197
|
+
end
|
284
198
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
end
|
199
|
+
context 'when an :action is specified' do
|
200
|
+
it 'should call the :action' do
|
201
|
+
value = [true, false].shuffle.first
|
202
|
+
expected_value = value ? '1' : '0'
|
290
203
|
|
291
|
-
|
204
|
+
klass = Backup::Foo.new
|
205
|
+
klass.removed_with_action = value
|
292
206
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
end.to raise_error(NoMethodError)
|
297
|
-
end
|
207
|
+
klass.accessor.should == expected_value
|
208
|
+
# lambda additionally sets :accessor_two
|
209
|
+
klass.accessor_two.should == 'updated'
|
298
210
|
end
|
299
211
|
end
|
300
|
-
end # describe 'instantiating a class when defaults have been set'
|
301
|
-
|
302
|
-
describe 'instantiating a new class and directly setting values' do
|
303
|
-
context 'when the missing method is an attribute set operator' do
|
304
|
-
context 'and the method has been deprecated' do
|
305
|
-
context 'and the deprecated method has a replacement' do
|
306
|
-
context 'and a replacement value is specified' do
|
307
|
-
it 'should set the the replacement value on the replacement' do
|
308
|
-
Backup::Logger.expects(:warn).with(
|
309
|
-
instance_of(Backup::Errors::ConfigurationError)
|
310
|
-
)
|
311
|
-
Backup::Logger.expects(:warn).with(
|
312
|
-
"Backup::Foo.accessor is being set to 'new_value'"
|
313
|
-
)
|
314
|
-
|
315
|
-
klass = Backup::Foo.new
|
316
|
-
klass.replaced_with_value = 'attr_value'
|
317
|
-
klass.accessor.should == 'new_value'
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
context 'and the replacement value is a lambda' do
|
322
|
-
it 'should set replacement value using the lambda' do
|
323
|
-
value = [true, false].shuffle.first
|
324
|
-
new_value = value ? '1' : '0'
|
325
|
-
|
326
|
-
Backup::Logger.expects(:warn).with(
|
327
|
-
instance_of(Backup::Errors::ConfigurationError)
|
328
|
-
)
|
329
|
-
Backup::Logger.expects(:warn).with(
|
330
|
-
"Backup::Foo.accessor is being set to '#{ new_value }'"
|
331
|
-
)
|
332
|
-
|
333
|
-
klass = Backup::Foo.new
|
334
|
-
klass.replaced_with_lambda = value
|
335
|
-
klass.accessor.should == new_value
|
336
|
-
end
|
337
|
-
|
338
|
-
it 'should not set the replacement if the lambda returns nil' do
|
339
|
-
Backup::Foo.any_instance.expects(:accessor=).never
|
340
|
-
|
341
|
-
Backup::Logger.expects(:warn).with(
|
342
|
-
instance_of(Backup::Errors::ConfigurationError)
|
343
|
-
)
|
344
|
-
|
345
|
-
klass = Backup::Foo.new
|
346
|
-
klass.replaced_with_lambda_nil = 'foo'
|
347
|
-
klass.accessor.should be_nil
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
context 'and no replacement value is specified' do
|
352
|
-
it 'should set the original value on the replacement' do
|
353
|
-
Backup::Logger.expects(:warn).with(
|
354
|
-
instance_of(Backup::Errors::ConfigurationError)
|
355
|
-
)
|
356
|
-
Backup::Logger.expects(:warn).with(
|
357
|
-
"Backup::Foo.accessor is being set to 'attr_value'"
|
358
|
-
)
|
359
|
-
|
360
|
-
klass = Backup::Foo.new
|
361
|
-
klass.replaced = 'attr_value'
|
362
|
-
klass.accessor.should == 'attr_value'
|
363
|
-
end
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
|
368
|
-
context 'and the deprecated method has no replacement' do
|
369
|
-
it 'should only log a warning' do
|
370
|
-
Backup::Logger.expects(:warn).with(
|
371
|
-
instance_of(Backup::Errors::ConfigurationError)
|
372
|
-
)
|
373
|
-
|
374
|
-
klass = Backup::Foo.new
|
375
|
-
klass.removed = 'attr_value'
|
376
|
-
klass.accessor.should be_nil
|
377
|
-
end
|
378
|
-
end
|
379
|
-
end
|
380
212
|
|
381
|
-
|
382
|
-
|
383
|
-
|
213
|
+
context 'when no :action is specified' do
|
214
|
+
it 'should only log the warning' do
|
215
|
+
Backup::Foo.any_instance.expects(:accessor=).never
|
384
216
|
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
end
|
217
|
+
klass = Backup::Foo.new
|
218
|
+
klass.removed = 'foo'
|
219
|
+
|
220
|
+
klass.accessor.should be_nil
|
390
221
|
end
|
391
222
|
end
|
223
|
+
end
|
392
224
|
|
393
|
-
|
394
|
-
|
395
|
-
|
225
|
+
context 'when the method is not a deprecated method' do
|
226
|
+
it 'should raise a NoMethodError' do
|
227
|
+
Backup::Logger.expects(:warn).never
|
396
228
|
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
end
|
229
|
+
klass = Backup::Foo.new
|
230
|
+
expect do
|
231
|
+
klass.foobar = 'attr_value'
|
232
|
+
end.to raise_error(NoMethodError)
|
402
233
|
end
|
403
|
-
end
|
404
|
-
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'when the method is not a set operation' do
|
237
|
+
it 'should raise a NoMethodError' do
|
238
|
+
Backup::Logger.expects(:warn).never
|
405
239
|
|
240
|
+
klass = Backup::Foo.new
|
241
|
+
expect do
|
242
|
+
klass.removed
|
243
|
+
end.to raise_error(NoMethodError)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end # describe '#method_missing'
|
406
247
|
end
|
@@ -473,19 +473,18 @@ describe Backup::Database::MongoDB do
|
|
473
473
|
end
|
474
474
|
|
475
475
|
describe 'deprecations' do
|
476
|
-
after do
|
477
|
-
Backup::Database::MongoDB.clear_defaults!
|
478
|
-
end
|
479
|
-
|
480
476
|
describe '#utility_path' do
|
481
477
|
before do
|
482
478
|
Backup::Database::MongoDB.any_instance.stubs(:utility)
|
483
|
-
Backup::Logger.expects(:warn).with
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
479
|
+
Backup::Logger.expects(:warn).with {|err|
|
480
|
+
err.should be_an_instance_of Backup::Errors::ConfigurationError
|
481
|
+
err.message.should match(
|
482
|
+
/Use MongoDB#mongodump_utility instead/
|
483
|
+
)
|
484
|
+
}
|
485
|
+
end
|
486
|
+
after do
|
487
|
+
Backup::Database::MongoDB.clear_defaults!
|
489
488
|
end
|
490
489
|
|
491
490
|
context 'when set directly' do
|