mpw 4.1.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
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 = { gpg_key: 'test@example.com',
24
- lang: 'en',
25
- wallet_dir: '/tmp/test',
26
- gpg_exe: '',
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 = { pwd_alpha: false,
43
- pwd_numeric: false,
44
- pwd_special: true,
45
- pwd_length: 32,
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 test_01_add_new
28
- data = { group: @fixtures['add_new']['group'],
29
- host: @fixtures['add_new']['host'],
30
- protocol: @fixtures['add_new']['protocol'],
31
- user: @fixtures['add_new']['user'],
32
- port: @fixtures['add_new']['port'],
33
- comment: @fixtures['add_new']['comment'],
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['add_new']['group'], item.group)
42
- assert_equal(@fixtures['add_new']['host'], item.host)
43
- assert_equal(@fixtures['add_new']['protocol'], item.protocol)
44
- assert_equal(@fixtures['add_new']['user'], item.user)
45
- assert_equal(@fixtures['add_new']['port'].to_i, item.port)
46
- assert_equal(@fixtures['add_new']['comment'], item.comment)
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 test_02_add_existing
50
- data = { id: @fixtures['add_existing']['id'],
51
- group: @fixtures['add_existing']['group'],
52
- host: @fixtures['add_existing']['host'],
53
- protocol: @fixtures['add_existing']['protocol'],
54
- user: @fixtures['add_existing']['user'],
55
- port: @fixtures['add_existing']['port'],
56
- comment: @fixtures['add_existing']['comment'],
57
- created: @fixtures['add_existing']['created'],
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['add_existing']['id'], item.id)
66
- assert_equal(@fixtures['add_existing']['group'], item.group)
67
- assert_equal(@fixtures['add_existing']['host'], item.host)
68
- assert_equal(@fixtures['add_existing']['protocol'], item.protocol)
69
- assert_equal(@fixtures['add_existing']['user'], item.user)
70
- assert_equal(@fixtures['add_existing']['port'].to_i, item.port)
71
- assert_equal(@fixtures['add_existing']['comment'], item.comment)
72
- assert_equal(@fixtures['add_existing']['created'], item.created)
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 = { group: @fixtures['add_new']['group'],
77
- host: @fixtures['add_new']['host'],
78
- protocol: @fixtures['add_new']['protocol'],
79
- user: @fixtures['add_new']['user'],
80
- port: @fixtures['add_new']['port'],
81
- comment: @fixtures['add_new']['comment'],
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 = { 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
- }
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 = { group: @fixtures['add_new']['group'],
118
- host: @fixtures['add_new']['host'],
119
- protocol: @fixtures['add_new']['protocol'],
120
- user: @fixtures['add_new']['user'],
121
- port: @fixtures['add_new']['port'],
122
- comment: @fixtures['add_new']['comment'],
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({comment: @fixtures['update']['comment']}))
134
+ assert(item.update(comment: @fixtures['update']['comment']))
134
135
 
135
- assert_equal(@fixtures['add_new']['group'], item.group)
136
- assert_equal(@fixtures['add_new']['host'], item.host)
137
- assert_equal(@fixtures['add_new']['protocol'], item.protocol)
138
- assert_equal(@fixtures['add_new']['user'], item.user)
139
- assert_equal(@fixtures['add_new']['port'].to_i, item.port)
140
- assert_equal(@fixtures['update']['comment'], item.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 = { group: @fixtures['add_new']['group'],
147
- host: @fixtures['add_new']['host'],
148
- protocol: @fixtures['add_new']['protocol'],
149
- user: @fixtures['add_new']['user'],
150
- port: @fixtures['add_new']['port'],
151
- comment: @fixtures['add_new']['comment'],
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(fixture_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 = { group: @fixtures['add_new']['group'],
37
- host: @fixtures['add_new']['host'],
38
- protocol: @fixtures['add_new']['protocol'],
39
- user: @fixtures['add_new']['user'],
40
- port: @fixtures['add_new']['port'],
41
- comment: @fixtures['add_new']['comment'],
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['add_new']['password'])
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['add_new'].each do |k,v|
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['add_new'].each do |k,v|
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 do |item|
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 = { group: v['group'],
100
- host: v['host'],
101
- protocol: v['protocol'],
102
- user: v['user'],
103
- port: v['port'],
104
- comment: v['comment'],
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: @fixtures['add_new']['group']).length)
118
- assert_equal(1, @mpw.list(pattern: 'existing').length)
119
- assert_equal(2, @mpw.list(pattern: 'host_[eu]').length)
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
@@ -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
- `grep -r -o "I18n.t('.*)" bin/ lib/ | cut -d"'" -f2`.each_line do |line|
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.1.1
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-05-03 00:00:00.000000000 Z
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.5.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
data/test/tests.rb DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- require_relative 'init.rb'
4
- require_relative 'test_config.rb'
5
- require_relative 'test_item.rb'
6
- require_relative 'test_mpw.rb'
7
- require_relative 'test_translate.rb'