siba 0.5.6 → 0.5.7
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 +3 -3
- data/Rakefile +6 -6
- data/lib/siba/backup.rb +2 -2
- data/lib/siba/console.rb +13 -13
- data/lib/siba/generator.rb +4 -5
- data/lib/siba/helpers/file_helper.rb +6 -6
- data/lib/siba/helpers/password_strength.rb +5 -5
- data/lib/siba/helpers/security_helper.rb +9 -9
- data/lib/siba/helpers/test/extend_test.rb +7 -7
- data/lib/siba/helpers/test/helper.rb +3 -3
- data/lib/siba/logger_plug.rb +1 -1
- data/lib/siba/plugins/archive/tar/archive.rb +8 -8
- data/lib/siba/plugins/archive/tar/init.rb +3 -3
- data/lib/siba/plugins/destination/dir/dest_dir.rb +7 -7
- data/lib/siba/plugins/destination/dir/init.rb +2 -2
- data/lib/siba/plugins/encryption/gpg/encryption.rb +10 -10
- data/lib/siba/plugins/encryption/gpg/init.rb +1 -1
- data/lib/siba/plugins/installed_plugins.rb +10 -6
- data/lib/siba/plugins/plugin_loader.rb +6 -5
- data/lib/siba/plugins/source/files/files.rb +7 -7
- data/lib/siba/plugins/source/files/init.rb +2 -2
- data/lib/siba/restore.rb +5 -5
- data/lib/siba/scaffold.rb +17 -17
- data/lib/siba/siba_check.rb +3 -3
- data/lib/siba/siba_file.rb +6 -6
- data/lib/siba/siba_logger.rb +11 -11
- data/lib/siba/tasks/siba_task.rb +1 -1
- data/lib/siba/tasks/siba_tasks.rb +7 -7
- data/lib/siba/test_files.rb +4 -4
- data/lib/siba/tmp_dir.rb +4 -4
- data/lib/siba/version.rb +1 -1
- data/scaffolds/archive.rb +3 -3
- data/scaffolds/destination.rb +4 -4
- data/scaffolds/encryption.rb +3 -3
- data/scaffolds/project/siba-c6y-demo.gemspec +2 -2
- data/scaffolds/project/test/helper/require_integration.rb +1 -1
- data/scaffolds/project/test/integration/i9n_init.rb +4 -4
- data/scaffolds/project/test/unit/test_init.rb +8 -8
- data/scaffolds/shared/examples.rb +4 -4
- data/scaffolds/source.rb +4 -4
- data/siba.gemspec +1 -1
- data/test/integration/helpers/i9n_file_helper.rb +1 -1
- data/test/integration/i9n_backup.rb +1 -1
- data/test/integration/i9n_scaffold.rb +1 -1
- data/test/integration/i9n_test_unicode_files.rb +1 -1
- data/test/integration/i9n_tmp_dir.rb +2 -2
- data/test/integration/plugins/destination/dir/i9n_dest_dir.rb +1 -1
- data/test/integration/plugins/encryption/gpg/i9n_encryption.rb +4 -4
- data/test/integration/plugins/source/files/i9n_files.rb +6 -6
- data/test/integration/tasks/i9n_siba_tasks.rb +2 -2
- data/test/unit/helpers/test_encoding_helper.rb +1 -1
- data/test/unit/helpers/test_gem_helper.rb +1 -1
- data/test/unit/helpers/test_security_helper.rb +1 -1
- data/test/unit/helpers/test_string_helper.rb +1 -1
- data/test/unit/plugins/archive/tar/test_archive.rb +2 -2
- data/test/unit/plugins/archive/tar/test_init.rb +2 -2
- data/test/unit/plugins/destination/dir/test_dest_dir.rb +1 -1
- data/test/unit/plugins/destination/dir/test_init.rb +1 -1
- data/test/unit/plugins/encryption/gpg/test_encryption.rb +2 -14
- data/test/unit/plugins/encryption/gpg/test_init.rb +3 -3
- data/test/unit/plugins/source/files/test_files.rb +2 -2
- data/test/unit/plugins/source/files/test_init.rb +3 -3
- data/test/unit/plugins/source/files/test_path_match.rb +6 -6
- data/test/unit/plugins/test_installed_plugins.rb +4 -0
- data/test/unit/plugins/test_plugin_loader.rb +6 -3
- data/test/unit/tasks/test_siba_task.rb +2 -2
- data/test/unit/tasks/test_siba_tasks.rb +3 -3
- data/test/unit/test_backup.rb +2 -2
- data/test/unit/test_console.rb +5 -5
- data/test/unit/test_generator.rb +1 -1
- data/test/unit/test_globals.rb +1 -1
- data/test/unit/test_log_message.rb +1 -1
- data/test/unit/test_logger_plug.rb +1 -1
- data/test/unit/test_options_backup.rb +1 -1
- data/test/unit/test_options_loader.rb +27 -39
- data/test/unit/test_password_strength.rb +14 -14
- data/test/unit/test_restore.rb +2 -2
- data/test/unit/test_siba_logger.rb +18 -18
- data/test/unit/test_tmp_dir.rb +1 -1
- metadata +5 -5
data/siba.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.required_rubygems_version = '~>1.8'
|
21
21
|
|
22
|
-
s.add_development_dependency 'minitest', '~>
|
22
|
+
s.add_development_dependency 'minitest', '~>3.0'
|
23
23
|
s.add_development_dependency 'rake', '~>0.9'
|
24
24
|
s.add_development_dependency 'guard-minitest', '~>0.4'
|
25
25
|
|
@@ -16,7 +16,7 @@ describe Siba::Backup do
|
|
16
16
|
src_file = prepare_test_file "bf-src-file"
|
17
17
|
dest_dir = mkdir_in_tmp_dir "bf-dest-dir"
|
18
18
|
|
19
|
-
test_yml_path = prepare_yml @path_to_src_yml,
|
19
|
+
test_yml_path = prepare_yml @path_to_src_yml,
|
20
20
|
{ src_dir: src_dir,
|
21
21
|
src_file: src_file,
|
22
22
|
dest_dir: dest_dir,
|
@@ -27,7 +27,7 @@ describe Siba::Backup do
|
|
27
27
|
src_file = prepare_test_file "bf-src-file-#{SibaTest::UNICODE_FILE_NAME}"
|
28
28
|
dest_dir = mkdir_in_tmp_dir "bf-dest-dir-#{SibaTest::UNICODE_FILE_NAME}"
|
29
29
|
|
30
|
-
test_yml_path = prepare_yml @path_to_src_yml,
|
30
|
+
test_yml_path = prepare_yml @path_to_src_yml,
|
31
31
|
{ src_dir: src_dir,
|
32
32
|
src_file: src_file,
|
33
33
|
dest_dir: dest_dir,
|
@@ -14,7 +14,7 @@ describe Siba::TmpDir do
|
|
14
14
|
it "should get tmp dir" do
|
15
15
|
siba_file.file_directory?(@tmp_dir.get).must_equal true
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should get the same tmp on second call" do
|
19
19
|
dir1 = @tmp_dir.get
|
20
20
|
dir2 = @tmp_dir.get
|
@@ -22,7 +22,7 @@ describe Siba::TmpDir do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should use dir specified in settings" do
|
25
|
-
test_dir = prepare_test_dir "tmp-dir"
|
25
|
+
test_dir = prepare_test_dir "tmp-dir"
|
26
26
|
Siba.settings = {"tmp_dir"=>test_dir}
|
27
27
|
dir1 = @tmp_dir.get
|
28
28
|
dir1.must_match /^#{test_dir}/
|
@@ -11,7 +11,7 @@ describe Siba::Encryption::Gpg::Encryption do
|
|
11
11
|
it "init should fail if cipher is not supported" do
|
12
12
|
->{Siba::Encryption::Gpg::Encryption.new @passphrase, "unknown_cipher"}.must_raise Siba::CheckError
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "init should assign default cipher if it's not supplied" do
|
16
16
|
encryption = Siba::Encryption::Gpg::Encryption.new @passphrase
|
17
17
|
encryption.cipher.wont_be_nil
|
@@ -31,14 +31,14 @@ describe Siba::Encryption::Gpg::Encryption do
|
|
31
31
|
path_to_decrypted_file.must_equal path_to_output_file
|
32
32
|
siba_file.file_utils_compare_file(path_to_source_file, path_to_decrypted_file).must_equal true
|
33
33
|
|
34
|
-
|
34
|
+
|
35
35
|
# decrypt without output file parameter
|
36
36
|
->{encryption.decrypt path_to_encrypted_file}.must_raise Siba::Error, "Should fail to decrypt if file already exists"
|
37
37
|
FileUtils.mv path_to_source_file, path_to_source_file + "new"
|
38
38
|
path_to_decrypted_file = encryption.decrypt path_to_encrypted_file
|
39
39
|
path_to_decrypted_file.must_equal path_to_source_file
|
40
40
|
|
41
|
-
# should fail to decrypt with incorrect passphrase
|
41
|
+
# should fail to decrypt with incorrect passphrase
|
42
42
|
encryption.passphrase = "incorrect"
|
43
43
|
->{encryption.decrypt path_to_encrypted_file}.must_raise Siba::Error
|
44
44
|
end
|
@@ -80,7 +80,7 @@ describe Siba::Encryption::Gpg::Encryption do
|
|
80
80
|
->{Siba::Encryption::Gpg::Encryption.check_cipher(nil)}.must_raise Siba::CheckError
|
81
81
|
SibaTest::RemovableConstants.redef_without_warning Siba::Encryption::Gpg::Encryption, "DEFAULT_CIPHER", old_cipher
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
it "check_cipher must fail if unknown cipher is used" do
|
85
85
|
->{Siba::Encryption::Gpg::Encryption.check_cipher("incorrect")}.must_raise Siba::CheckError
|
86
86
|
end
|
@@ -47,7 +47,7 @@ describe Siba::Source::Files::Files do
|
|
47
47
|
dest_sub_dir = File.join dest_dir, File.basename(src_dir)
|
48
48
|
Siba::FileHelper.entries(src_dir).each do |entry|
|
49
49
|
entry_path = File.join src_dir, entry
|
50
|
-
siba_file.file_utils_remove_entry_secure entry_path if siba_file.file_directory?(entry_path)
|
50
|
+
siba_file.file_utils_remove_entry_secure entry_path if siba_file.file_directory?(entry_path)
|
51
51
|
end
|
52
52
|
siba_file.file_directory?(dest_sub_dir).must_equal true
|
53
53
|
dirs_same? src_dir, dest_sub_dir
|
@@ -77,8 +77,8 @@ describe Siba::Source::Files::Files do
|
|
77
77
|
|
78
78
|
dest_dir = mkdir_in_tmp_dir "s-f-dest-dir"
|
79
79
|
f.backup dest_dir
|
80
|
-
|
81
|
-
# compare dir
|
80
|
+
|
81
|
+
# compare dir
|
82
82
|
backup_dir = @files.sub_dir_name 1, 1, false, File.basename(src_dir), dest_dir
|
83
83
|
dirs_same? src_dir, backup_dir
|
84
84
|
|
@@ -89,7 +89,7 @@ describe Siba::Source::Files::Files do
|
|
89
89
|
|
90
90
|
Siba::FileHelper.dirs_count(dest_dir).must_equal 2, "Should create two folders for each source"
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
it "backup should log error message if one of the sources is not found" do
|
94
94
|
src_dir = prepare_test_dir "s-f-src-dir"
|
95
95
|
f = @files.new ["/non-existing-file", src_dir],[],true
|
@@ -97,7 +97,7 @@ describe Siba::Source::Files::Files do
|
|
97
97
|
dest_dir = mkdir_in_tmp_dir "s-f-dest-dir"
|
98
98
|
f.backup dest_dir
|
99
99
|
|
100
|
-
# The existing dir must be copied
|
100
|
+
# The existing dir must be copied
|
101
101
|
backup_dir = @files.sub_dir_name 2, 1, false, File.basename(src_dir), dest_dir
|
102
102
|
dirs_same? src_dir, backup_dir
|
103
103
|
|
@@ -136,7 +136,7 @@ describe Siba::Source::Files::Files do
|
|
136
136
|
|
137
137
|
# Compare dirs
|
138
138
|
restore_dir1.wont_equal backup_dir1
|
139
|
-
dirs_same? restore_dir1, backup_dir1
|
139
|
+
dirs_same? restore_dir1, backup_dir1
|
140
140
|
|
141
141
|
# Compare file
|
142
142
|
restore_file.wont_equal backup_file
|
@@ -9,7 +9,7 @@ describe Siba::SibaTasks do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should backup and testore tasks" do
|
12
|
-
src_dir = prepare_test_dir "b-src-dir"
|
12
|
+
src_dir = prepare_test_dir "b-src-dir"
|
13
13
|
src_file = prepare_test_file "b-src-file"
|
14
14
|
dest_dir = mkdir_in_tmp_dir "b-dest-dir"
|
15
15
|
|
@@ -22,7 +22,7 @@ describe Siba::SibaTasks do
|
|
22
22
|
options = SibaTest.load_options path_to_test_yml
|
23
23
|
|
24
24
|
tasks = Siba::SibaTasks.new options, path_to_test_yml, false
|
25
|
-
tasks.backup
|
25
|
+
tasks.backup
|
26
26
|
|
27
27
|
# restore into original source
|
28
28
|
backup_file_name = Siba::FileHelper.entries(dest_dir)[0]
|
@@ -4,7 +4,7 @@ require 'helper/require_unit'
|
|
4
4
|
require 'siba/plugins/archive/tar/init'
|
5
5
|
|
6
6
|
describe Siba::Archive::Tar::Init do
|
7
|
-
before do
|
7
|
+
before do
|
8
8
|
@yml_path = File.expand_path('../yml/archive', __FILE__)
|
9
9
|
end
|
10
10
|
|
@@ -25,7 +25,7 @@ describe Siba::Archive::Tar::Init do
|
|
25
25
|
Siba::Archive::Tar::Archive.new("gzip")
|
26
26
|
.archive("",dest_dir,file_name)
|
27
27
|
.must_match /^#{file_name}\.tar.gz$/
|
28
|
-
|
28
|
+
|
29
29
|
Siba::Archive::Tar::Archive.new("bzip2")
|
30
30
|
.archive("",dest_dir,file_name)
|
31
31
|
.must_match /^#{file_name}\.tar.bz2$/
|
@@ -4,7 +4,7 @@ require 'helper/require_unit'
|
|
4
4
|
require 'siba/plugins/archive/tar/init'
|
5
5
|
|
6
6
|
describe Siba::Archive::Tar::Init do
|
7
|
-
before do
|
7
|
+
before do
|
8
8
|
@yml_path = File.expand_path('../yml/init', __FILE__)
|
9
9
|
@plugin_category="archive"
|
10
10
|
@plugin_type="tar"
|
@@ -28,7 +28,7 @@ describe Siba::Archive::Tar::Init do
|
|
28
28
|
archive = create_plugin("valid")
|
29
29
|
archive.backup("/src-dir", "/dst-dir", "file_name").must_be_instance_of String
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "should run restore" do
|
33
33
|
archive = create_plugin("valid")
|
34
34
|
archive.restore "/path-to-archive", "/to_dir"
|
@@ -8,18 +8,6 @@ describe Siba::Encryption::Gpg::Encryption do
|
|
8
8
|
@passphrase = "aj(dJ6Hja2Jj$kjask"
|
9
9
|
end
|
10
10
|
|
11
|
-
it "init should call test_encryption" do
|
12
|
-
fmock = mock_file :run_this, nil, ["test_encryption"]
|
13
|
-
Siba::Encryption::Gpg::Encryption.new(@passphrase)
|
14
|
-
fmock.verify
|
15
|
-
end
|
16
|
-
|
17
|
-
it "init should call check_cipher" do
|
18
|
-
fmock = mock_file :run_this, nil, ["check_cipher"]
|
19
|
-
Siba::Encryption::Gpg::Encryption.new(@passphrase)
|
20
|
-
fmock.verify
|
21
|
-
end
|
22
|
-
|
23
11
|
it "must call encrypt" do
|
24
12
|
encryption = Siba::Encryption::Gpg::Encryption.new(@passphrase)
|
25
13
|
path_to_archive = "/path/to/archive.tar.gz"
|
@@ -33,7 +21,7 @@ describe Siba::Encryption::Gpg::Encryption do
|
|
33
21
|
path_to_decrypted_file = encryption.decrypt(path + ".gpg")
|
34
22
|
path_to_decrypted_file.must_equal path
|
35
23
|
end
|
36
|
-
|
24
|
+
|
37
25
|
it "must call decrypt with output file parameter" do
|
38
26
|
encryption = Siba::Encryption::Gpg::Encryption.new(@passphrase)
|
39
27
|
path = "/path/to/archive.tar.gz.gz"
|
@@ -51,7 +39,7 @@ describe Siba::Encryption::Gpg::Encryption do
|
|
51
39
|
Siba::Encryption::Gpg::Encryption.parse_cipher_names(a[0]).must_equal a[1]
|
52
40
|
end
|
53
41
|
end
|
54
|
-
|
42
|
+
|
55
43
|
it "init must warn if the password is weak" do
|
56
44
|
Siba::Encryption::Gpg::Encryption.new "passwordisweak"
|
57
45
|
must_log "warn"
|
@@ -15,8 +15,8 @@ describe Siba::Encryption::Gpg::Init do
|
|
15
15
|
plugin.encryption.wont_be_nil
|
16
16
|
plugin.encryption.passphrase.wont_be_nil
|
17
17
|
plugin.encryption.cipher.wont_be_nil
|
18
|
-
plugin.encryption.passphrase.must_equal @options["passphrase"]
|
19
|
-
plugin.encryption.cipher.must_equal @options["cipher"]
|
18
|
+
plugin.encryption.passphrase.must_equal @options["passphrase"]
|
19
|
+
plugin.encryption.cipher.must_equal @options["cipher"]
|
20
20
|
end
|
21
21
|
|
22
22
|
it "must init with missing" do
|
@@ -34,7 +34,7 @@ describe Siba::Encryption::Gpg::Init do
|
|
34
34
|
->{create_plugin({'passphrase' => ""})}.must_raise Siba::CheckError
|
35
35
|
->{create_plugin({'passphrase' => " "})}.must_raise Siba::CheckError
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "must call backup" do
|
39
39
|
plugin = create_plugin(@options)
|
40
40
|
plugin.backup("/path/to/archive", "/dest_dir").must_be_instance_of String
|
@@ -9,12 +9,12 @@ describe Siba::Source::Files::Files do
|
|
9
9
|
end
|
10
10
|
it "ignored? must NOT log if no files are excluded" do
|
11
11
|
@f.new([], [], true).ignored?("/.hidden")
|
12
|
-
wont_log "info"
|
12
|
+
wont_log "info"
|
13
13
|
end
|
14
14
|
|
15
15
|
it "ignored? must log if files are excluded" do
|
16
16
|
@f.new([], ["*"], true).ignored?("/.hidden")
|
17
|
-
must_log "info"
|
17
|
+
must_log "info"
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should call backup" do
|
@@ -4,7 +4,7 @@ require 'helper/require_unit'
|
|
4
4
|
require 'siba/plugins/source/files/init'
|
5
5
|
|
6
6
|
describe Siba::Source::Files::Init do
|
7
|
-
before do
|
7
|
+
before do
|
8
8
|
@yml_path = File.expand_path('../yml', __FILE__)
|
9
9
|
@plugin_category="source"
|
10
10
|
@plugin_type="files"
|
@@ -25,7 +25,7 @@ describe Siba::Source::Files::Init do
|
|
25
25
|
it "should load ignore list" do
|
26
26
|
create_plugin("valid").files.ignore.must_be_instance_of Array
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "load should fail ignore is not array" do
|
30
30
|
-> {create_plugin("ignore_not_array")}.must_raise Siba::CheckError
|
31
31
|
end
|
@@ -37,7 +37,7 @@ describe Siba::Source::Files::Init do
|
|
37
37
|
it "should load include_subdirs=false" do
|
38
38
|
create_plugin("include_subdirs_false").files.include_subdirs.must_equal false
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "backup should copy file" do
|
42
42
|
create_plugin("valid").backup "dir"
|
43
43
|
end
|
@@ -4,7 +4,7 @@ require 'helper/require_unit'
|
|
4
4
|
require 'siba/plugins/source/files/init'
|
5
5
|
|
6
6
|
describe Siba::Source::Files do
|
7
|
-
before do
|
7
|
+
before do
|
8
8
|
@yml_path = File.expand_path('../yml', __FILE__)
|
9
9
|
@plugin_category="source"
|
10
10
|
@plugin_type="files"
|
@@ -13,7 +13,7 @@ describe Siba::Source::Files do
|
|
13
13
|
it "should call path_match?" do
|
14
14
|
Siba::Source::Files::Files.path_match? "file", "include"
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "must match path" do
|
18
18
|
match_list = [
|
19
19
|
# ----------------------
|
@@ -102,7 +102,7 @@ describe Siba::Source::Files do
|
|
102
102
|
# ----------------------
|
103
103
|
# match basenames against pattern
|
104
104
|
["name*", "/somename"],
|
105
|
-
|
105
|
+
|
106
106
|
# ----------------------
|
107
107
|
# match whole path against pattern
|
108
108
|
[".*", "/.hidden/file"],
|
@@ -111,9 +111,9 @@ describe Siba::Source::Files do
|
|
111
111
|
["dir", "/dir1/dir/file"],
|
112
112
|
["dir", "/dir/name/file"],
|
113
113
|
["dir/name", "/name"],
|
114
|
-
["dir/name", "/root/dir/name"],
|
115
|
-
["/file*", "/root/file"],
|
116
|
-
["/file/*", "/file"],
|
114
|
+
["dir/name", "/root/dir/name"],
|
115
|
+
["/file*", "/root/file"],
|
116
|
+
["/file/*", "/file"],
|
117
117
|
]
|
118
118
|
|
119
119
|
must_not_match_list.each do |item|
|
@@ -12,9 +12,12 @@ describe Siba::LogMessage do
|
|
12
12
|
@loader.load "archive", "tar", @options
|
13
13
|
end
|
14
14
|
|
15
|
-
it "should fail when plugin name is incorrect" do
|
16
|
-
|
17
|
-
|
15
|
+
it "should fail when plugin name is incorrect or note installed" do
|
16
|
+
begin
|
17
|
+
@loader.load "source", "incorrect", @options
|
18
|
+
rescue Siba::PluginLoadError => e
|
19
|
+
e.message.must_match /\A'incorrect' plugin is not installed/
|
20
|
+
end
|
18
21
|
end
|
19
22
|
|
20
23
|
it "should fail when plugin type is unknown" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require 'helper/require_unit'
|
3
|
+
require 'helper/require_unit'
|
4
4
|
|
5
5
|
describe Siba::SibaTask do
|
6
6
|
before do
|
@@ -11,7 +11,7 @@ describe Siba::SibaTask do
|
|
11
11
|
task_category = "archive"
|
12
12
|
options = load_options "valid"
|
13
13
|
new_task = Siba::SibaTask.new options, task_category
|
14
|
-
new_task.wont_be_nil
|
14
|
+
new_task.wont_be_nil
|
15
15
|
new_task.plugin.wont_be_nil
|
16
16
|
new_task.category.must_equal task_category
|
17
17
|
new_task.type.must_equal "tar"
|