mpw 4.1.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +0 -1
- data/.travis.yml +10 -6
- data/CHANGELOG.md +32 -11
- data/Gemfile +6 -0
- data/README.md +32 -31
- data/VERSION +1 -1
- data/bin/mpw-config +1 -1
- data/bin/mpw-update +2 -0
- data/bin/mpw-wallet +4 -4
- data/i18n/en.yml +50 -48
- data/i18n/fr.yml +2 -0
- data/lib/mpw/cli.rb +81 -56
- data/lib/mpw/config.rb +17 -18
- data/lib/mpw/item.rb +14 -5
- data/lib/mpw/mpw.rb +34 -31
- data/test/files/fixtures-import.yml +19 -0
- data/test/files/fixtures.yml +23 -23
- data/test/init.rb +6 -2
- data/test/test_cli.rb +265 -0
- data/test/test_config.rb +13 -11
- data/test/test_item.rb +75 -73
- data/test/test_mpw.rb +24 -28
- data/test/test_translate.rb +1 -1
- metadata +7 -5
- data/test/tests.rb +0 -7
data/test/test_config.rb
CHANGED
@@ -20,17 +20,18 @@ class TestConfig < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_00_config
|
23
|
-
data = {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
data = {
|
24
|
+
gpg_key: 'test@example.com',
|
25
|
+
lang: 'en',
|
26
|
+
wallet_dir: '/tmp/test',
|
27
|
+
gpg_exe: ''
|
28
|
+
}
|
28
29
|
|
29
30
|
@config = MPW::Config.new
|
30
31
|
@config.setup(data)
|
31
32
|
@config.load_config
|
32
33
|
|
33
|
-
data.each do |k,v|
|
34
|
+
data.each do |k, v|
|
34
35
|
assert_equal(v, @config.send(k))
|
35
36
|
end
|
36
37
|
|
@@ -39,11 +40,12 @@ class TestConfig < Test::Unit::TestCase
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def test_01_password
|
42
|
-
data = {
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
data = {
|
44
|
+
pwd_alpha: false,
|
45
|
+
pwd_numeric: false,
|
46
|
+
pwd_special: true,
|
47
|
+
pwd_length: 32
|
48
|
+
}
|
47
49
|
|
48
50
|
@config = MPW::Config.new
|
49
51
|
@config.load_config
|
data/test/test_item.rb
CHANGED
@@ -6,9 +6,6 @@ require 'yaml'
|
|
6
6
|
|
7
7
|
class TestItem < Test::Unit::TestCase
|
8
8
|
def setup
|
9
|
-
@fixture_file = 'test/files/fixtures.yml'
|
10
|
-
@fixtures = YAML.load_file(@fixture_file)
|
11
|
-
|
12
9
|
if defined?(I18n.enforce_available_locales)
|
13
10
|
I18n.enforce_available_locales = false
|
14
11
|
end
|
@@ -16,70 +13,72 @@ class TestItem < Test::Unit::TestCase
|
|
16
13
|
I18n.load_path = Dir['./i18n/cli/*.yml']
|
17
14
|
I18n.default_locale = :en
|
18
15
|
|
19
|
-
|
20
|
-
puts
|
16
|
+
@fixtures = YAML.load_file('./test/files/fixtures.yml')
|
21
17
|
end
|
22
18
|
|
23
19
|
def test_00_add_without_name
|
24
|
-
assert_raise(RuntimeError){MPW::Item.new}
|
20
|
+
assert_raise(RuntimeError) { MPW::Item.new }
|
25
21
|
end
|
26
22
|
|
27
|
-
def
|
28
|
-
data = {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
def test_01_add
|
24
|
+
data = {
|
25
|
+
group: @fixtures['add']['group'],
|
26
|
+
host: @fixtures['add']['host'],
|
27
|
+
protocol: @fixtures['add']['protocol'],
|
28
|
+
user: @fixtures['add']['user'],
|
29
|
+
port: @fixtures['add']['port'],
|
30
|
+
comment: @fixtures['add']['comment']
|
31
|
+
}
|
35
32
|
|
36
33
|
item = MPW::Item.new(data)
|
37
34
|
|
38
35
|
assert(!item.nil?)
|
39
36
|
assert(!item.empty?)
|
40
37
|
|
41
|
-
assert_equal(@fixtures['
|
42
|
-
assert_equal(@fixtures['
|
43
|
-
assert_equal(@fixtures['
|
44
|
-
assert_equal(@fixtures['
|
45
|
-
assert_equal(@fixtures['
|
46
|
-
assert_equal(@fixtures['
|
38
|
+
assert_equal(@fixtures['add']['group'], item.group)
|
39
|
+
assert_equal(@fixtures['add']['host'], item.host)
|
40
|
+
assert_equal(@fixtures['add']['protocol'], item.protocol)
|
41
|
+
assert_equal(@fixtures['add']['user'], item.user)
|
42
|
+
assert_equal(@fixtures['add']['port'].to_i, item.port)
|
43
|
+
assert_equal(@fixtures['add']['comment'], item.comment)
|
47
44
|
end
|
48
45
|
|
49
|
-
def
|
50
|
-
data = {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
46
|
+
def test_02_import
|
47
|
+
data = {
|
48
|
+
id: @fixtures['import']['id'],
|
49
|
+
group: @fixtures['import']['group'],
|
50
|
+
host: @fixtures['import']['host'],
|
51
|
+
protocol: @fixtures['import']['protocol'],
|
52
|
+
user: @fixtures['import']['user'],
|
53
|
+
port: @fixtures['import']['port'],
|
54
|
+
comment: @fixtures['import']['comment'],
|
55
|
+
created: @fixtures['import']['created']
|
56
|
+
}
|
59
57
|
|
60
58
|
item = MPW::Item.new(data)
|
61
59
|
|
62
60
|
assert(!item.nil?)
|
63
61
|
assert(!item.empty?)
|
64
62
|
|
65
|
-
assert_equal(@fixtures['
|
66
|
-
assert_equal(@fixtures['
|
67
|
-
assert_equal(@fixtures['
|
68
|
-
assert_equal(@fixtures['
|
69
|
-
assert_equal(@fixtures['
|
70
|
-
assert_equal(@fixtures['
|
71
|
-
assert_equal(@fixtures['
|
72
|
-
assert_equal(@fixtures['
|
63
|
+
assert_equal(@fixtures['import']['id'], item.id)
|
64
|
+
assert_equal(@fixtures['import']['group'], item.group)
|
65
|
+
assert_equal(@fixtures['import']['host'], item.host)
|
66
|
+
assert_equal(@fixtures['import']['protocol'], item.protocol)
|
67
|
+
assert_equal(@fixtures['import']['user'], item.user)
|
68
|
+
assert_equal(@fixtures['import']['port'].to_i, item.port)
|
69
|
+
assert_equal(@fixtures['import']['comment'], item.comment)
|
70
|
+
assert_equal(@fixtures['import']['created'], item.created)
|
73
71
|
end
|
74
72
|
|
75
73
|
def test_03_update
|
76
|
-
data = {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
74
|
+
data = {
|
75
|
+
group: @fixtures['add']['group'],
|
76
|
+
host: @fixtures['add']['host'],
|
77
|
+
protocol: @fixtures['add']['protocol'],
|
78
|
+
user: @fixtures['add']['user'],
|
79
|
+
port: @fixtures['add']['port'],
|
80
|
+
comment: @fixtures['add']['comment']
|
81
|
+
}
|
83
82
|
|
84
83
|
item = MPW::Item.new(data)
|
85
84
|
|
@@ -89,13 +88,14 @@ class TestItem < Test::Unit::TestCase
|
|
89
88
|
created = item.created
|
90
89
|
last_edit = item.last_edit
|
91
90
|
|
92
|
-
data = {
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
91
|
+
data = {
|
92
|
+
group: @fixtures['update']['group'],
|
93
|
+
host: @fixtures['update']['host'],
|
94
|
+
protocol: @fixtures['update']['protocol'],
|
95
|
+
user: @fixtures['update']['user'],
|
96
|
+
port: @fixtures['update']['port'],
|
97
|
+
comment: @fixtures['update']['comment']
|
98
|
+
}
|
99
99
|
|
100
100
|
sleep(1)
|
101
101
|
assert(item.update(data))
|
@@ -114,13 +114,14 @@ class TestItem < Test::Unit::TestCase
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def test_05_update_one_element
|
117
|
-
data = {
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
117
|
+
data = {
|
118
|
+
group: @fixtures['add']['group'],
|
119
|
+
host: @fixtures['add']['host'],
|
120
|
+
protocol: @fixtures['add']['protocol'],
|
121
|
+
user: @fixtures['add']['user'],
|
122
|
+
port: @fixtures['add']['port'],
|
123
|
+
comment: @fixtures['add']['comment']
|
124
|
+
}
|
124
125
|
|
125
126
|
item = MPW::Item.new(data)
|
126
127
|
|
@@ -130,26 +131,27 @@ class TestItem < Test::Unit::TestCase
|
|
130
131
|
last_edit = item.last_edit
|
131
132
|
|
132
133
|
sleep(1)
|
133
|
-
assert(item.update(
|
134
|
+
assert(item.update(comment: @fixtures['update']['comment']))
|
134
135
|
|
135
|
-
assert_equal(@fixtures['
|
136
|
-
assert_equal(@fixtures['
|
137
|
-
assert_equal(@fixtures['
|
138
|
-
assert_equal(@fixtures['
|
139
|
-
assert_equal(@fixtures['
|
140
|
-
assert_equal(@fixtures['update']['comment'],
|
136
|
+
assert_equal(@fixtures['add']['group'], item.group)
|
137
|
+
assert_equal(@fixtures['add']['host'], item.host)
|
138
|
+
assert_equal(@fixtures['add']['protocol'], item.protocol)
|
139
|
+
assert_equal(@fixtures['add']['user'], item.user)
|
140
|
+
assert_equal(@fixtures['add']['port'].to_i, item.port)
|
141
|
+
assert_equal(@fixtures['update']['comment'], item.comment)
|
141
142
|
|
142
143
|
assert_not_equal(last_edit, item.last_edit)
|
143
144
|
end
|
144
145
|
|
145
146
|
def test_05_delete
|
146
|
-
data = {
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
147
|
+
data = {
|
148
|
+
group: @fixtures['add']['group'],
|
149
|
+
host: @fixtures['add']['host'],
|
150
|
+
protocol: @fixtures['add']['protocol'],
|
151
|
+
user: @fixtures['add']['user'],
|
152
|
+
port: @fixtures['add']['port'],
|
153
|
+
comment: @fixtures['add']['comment']
|
154
|
+
}
|
153
155
|
|
154
156
|
item = MPW::Item.new(data)
|
155
157
|
|
data/test/test_mpw.rb
CHANGED
@@ -8,8 +8,6 @@ require 'csv'
|
|
8
8
|
|
9
9
|
class TestMPW < Test::Unit::TestCase
|
10
10
|
def setup
|
11
|
-
fixture_file = './test/files/fixtures.yml'
|
12
|
-
|
13
11
|
wallet_file = 'default.gpg'
|
14
12
|
key = 'test@example.com'
|
15
13
|
password = 'password'
|
@@ -19,7 +17,7 @@ class TestMPW < Test::Unit::TestCase
|
|
19
17
|
end
|
20
18
|
|
21
19
|
@mpw = MPW::MPW.new(key, wallet_file, password)
|
22
|
-
@fixtures = YAML.load_file(
|
20
|
+
@fixtures = YAML.load_file('./test/files/fixtures.yml')
|
23
21
|
end
|
24
22
|
|
25
23
|
def test_00_decrypt_empty_file
|
@@ -33,13 +31,14 @@ class TestMPW < Test::Unit::TestCase
|
|
33
31
|
end
|
34
32
|
|
35
33
|
def test_02_add_item
|
36
|
-
data = {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
data = {
|
35
|
+
group: @fixtures['add']['group'],
|
36
|
+
host: @fixtures['add']['host'],
|
37
|
+
protocol: @fixtures['add']['protocol'],
|
38
|
+
user: @fixtures['add']['user'],
|
39
|
+
port: @fixtures['add']['port'],
|
40
|
+
comment: @fixtures['add']['comment']
|
41
|
+
}
|
43
42
|
|
44
43
|
item = MPW::Item.new(data)
|
45
44
|
|
@@ -48,12 +47,12 @@ class TestMPW < Test::Unit::TestCase
|
|
48
47
|
|
49
48
|
@mpw.read_data
|
50
49
|
@mpw.add(item)
|
51
|
-
@mpw.set_password(item.id, @fixtures['
|
50
|
+
@mpw.set_password(item.id, @fixtures['add']['password'])
|
52
51
|
|
53
52
|
assert_equal(1, @mpw.list.length)
|
54
53
|
|
55
54
|
item = @mpw.list[0]
|
56
|
-
@fixtures['
|
55
|
+
@fixtures['add'].each do |k, v|
|
57
56
|
if k == 'password'
|
58
57
|
assert_equal(v, @mpw.get_password(item.id))
|
59
58
|
else
|
@@ -69,7 +68,7 @@ class TestMPW < Test::Unit::TestCase
|
|
69
68
|
assert_equal(1, @mpw.list.length)
|
70
69
|
|
71
70
|
item = @mpw.list[0]
|
72
|
-
@fixtures['
|
71
|
+
@fixtures['add'].each do |k, v|
|
73
72
|
if k == 'password'
|
74
73
|
assert_equal(v, @mpw.get_password(item.id))
|
75
74
|
else
|
@@ -80,13 +79,9 @@ class TestMPW < Test::Unit::TestCase
|
|
80
79
|
|
81
80
|
def test_04_delete_item
|
82
81
|
@mpw.read_data
|
83
|
-
|
84
82
|
assert_equal(1, @mpw.list.length)
|
85
83
|
|
86
|
-
@mpw.list.each
|
87
|
-
item.delete
|
88
|
-
end
|
89
|
-
|
84
|
+
@mpw.list.each(&:delete)
|
90
85
|
assert_equal(0, @mpw.list.length)
|
91
86
|
|
92
87
|
@mpw.write_data
|
@@ -96,13 +91,14 @@ class TestMPW < Test::Unit::TestCase
|
|
96
91
|
@mpw.read_data
|
97
92
|
|
98
93
|
@fixtures.each_value do |v|
|
99
|
-
data = {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
94
|
+
data = {
|
95
|
+
group: v['group'],
|
96
|
+
host: v['host'],
|
97
|
+
protocol: v['protocol'],
|
98
|
+
user: v['user'],
|
99
|
+
port: v['port'],
|
100
|
+
comment: v['comment']
|
101
|
+
}
|
106
102
|
|
107
103
|
item = MPW::Item.new(data)
|
108
104
|
|
@@ -114,9 +110,9 @@ class TestMPW < Test::Unit::TestCase
|
|
114
110
|
end
|
115
111
|
|
116
112
|
assert_equal(3, @mpw.list.length)
|
117
|
-
assert_equal(1, @mpw.list(group:
|
118
|
-
assert_equal(1, @mpw.list(pattern:
|
119
|
-
assert_equal(2, @mpw.list(pattern:
|
113
|
+
assert_equal(1, @mpw.list(group: @fixtures['add']['group']).length)
|
114
|
+
assert_equal(1, @mpw.list(pattern: 'gogole').length)
|
115
|
+
assert_equal(2, @mpw.list(pattern: 'example[2\.]').length)
|
120
116
|
end
|
121
117
|
|
122
118
|
def test_06_add_gpg_key
|
data/test/test_translate.rb
CHANGED
@@ -11,7 +11,7 @@ class TestTranslate < Test::Unit::TestCase
|
|
11
11
|
lang = File.basename(yaml, '.yml')
|
12
12
|
translate = YAML.load_file(yaml)
|
13
13
|
|
14
|
-
|
14
|
+
%x(grep -r -o "I18n.t('.*)" bin/ lib/ | cut -d"'" -f2).each_line do |line|
|
15
15
|
begin
|
16
16
|
t = translate[lang]
|
17
17
|
line.strip.split('.').each do |v|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrien Waksberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -187,13 +187,14 @@ files:
|
|
187
187
|
- mpw.gemspec
|
188
188
|
- templates/add_form.erb
|
189
189
|
- templates/update_form.erb
|
190
|
+
- test/files/fixtures-import.yml
|
190
191
|
- test/files/fixtures.yml
|
191
192
|
- test/init.rb
|
193
|
+
- test/test_cli.rb
|
192
194
|
- test/test_config.rb
|
193
195
|
- test/test_item.rb
|
194
196
|
- test/test_mpw.rb
|
195
197
|
- test/test_translate.rb
|
196
|
-
- test/tests.rb
|
197
198
|
homepage: https://github.com/nishiki/manage-password
|
198
199
|
licenses:
|
199
200
|
- GPL-2.0
|
@@ -214,15 +215,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
215
|
version: '0'
|
215
216
|
requirements: []
|
216
217
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.
|
218
|
+
rubygems_version: 2.6.11
|
218
219
|
signing_key:
|
219
220
|
specification_version: 4
|
220
221
|
summary: MPW is a software to crypt and manage your passwords
|
221
222
|
test_files:
|
223
|
+
- test/files/fixtures-import.yml
|
222
224
|
- test/files/fixtures.yml
|
223
225
|
- test/init.rb
|
226
|
+
- test/test_cli.rb
|
224
227
|
- test/test_config.rb
|
225
228
|
- test/test_item.rb
|
226
229
|
- test/test_mpw.rb
|
227
230
|
- test/test_translate.rb
|
228
|
-
- test/tests.rb
|