pwl 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -1
- data/Gemfile.lock +19 -5
- data/VERSION +1 -1
- data/bin/pwl +47 -228
- data/lib/pwl.rb +12 -0
- data/lib/pwl/commands/add.rb +36 -0
- data/lib/pwl/commands/base.rb +98 -0
- data/lib/pwl/commands/delete.rb +18 -0
- data/lib/pwl/commands/export.rb +22 -0
- data/lib/pwl/commands/get.rb +26 -0
- data/lib/pwl/commands/init.rb +35 -0
- data/lib/pwl/commands/list.rb +38 -0
- data/lib/pwl/commands/passwd.rb +42 -0
- data/lib/pwl/commands/stats.rb +59 -0
- data/lib/pwl/entry.rb +31 -0
- data/lib/pwl/entry_mapper.rb +30 -0
- data/lib/pwl/locker.rb +18 -10
- data/lib/pwl/presenter/json.rb +6 -10
- data/lib/pwl/presenter/yaml.rb +8 -4
- data/pwl.gemspec +24 -5
- data/templates/export.html.erb +5 -5
- data/test/acceptance/test_export.rb +6 -3
- data/test/acceptance/test_export_json.rb +9 -6
- data/test/acceptance/test_export_yaml.rb +8 -5
- data/test/acceptance/test_init.rb +24 -4
- data/test/acceptance/test_list.rb +1 -1
- data/test/fixtures/test_all.html +3 -3
- data/test/fixtures/test_all.json +9 -6
- data/test/fixtures/test_all.yaml +6 -3
- data/test/helper.rb +4 -2
- data/test/unit/test_entry.rb +67 -0
- data/test/unit/test_entry_mapper.rb +33 -0
- data/test/unit/test_store_crud.rb +25 -11
- data/test/unit/test_store_password_policy.rb +1 -1
- data/test/unit/test_store_security.rb +2 -1
- metadata +51 -6
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestEntryMapper < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@entry = Pwl::Entry.new
|
6
|
+
@entry.name = 'foobar'
|
7
|
+
@entry.password = 'barfoot'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_from_json
|
11
|
+
entry = Pwl::EntryMapper.from_json(%q|{"uuid" : "7a1fd920-97bb-012f-eee8-70def14c3504", "name" : "something"}|)
|
12
|
+
assert_not_nil(entry)
|
13
|
+
assert_not_nil(entry.uuid)
|
14
|
+
assert_equal('7a1fd920-97bb-012f-eee8-70def14c3504', entry.uuid)
|
15
|
+
assert_equal('something', entry.name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_to_json
|
19
|
+
json = Pwl::EntryMapper.to_json(@entry)
|
20
|
+
assert_not_nil(json)
|
21
|
+
entry = JSON(json)
|
22
|
+
assert_present(entry['uuid'])
|
23
|
+
assert_equal('foobar', entry['name'])
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_happy_path
|
27
|
+
entry = Pwl::EntryMapper.from_json(Pwl::EntryMapper.to_json(@entry))
|
28
|
+
assert_not_nil(entry)
|
29
|
+
assert_not_nil(entry.uuid)
|
30
|
+
assert_equal(@entry.uuid, entry.uuid)
|
31
|
+
assert_equal('foobar', entry.name)
|
32
|
+
end
|
33
|
+
end
|
@@ -3,7 +3,21 @@ require 'helper'
|
|
3
3
|
class TestLockerCRUD < Test::Pwl::TestCase
|
4
4
|
def test_add_get
|
5
5
|
locker.add('foo', 'bar')
|
6
|
-
assert_equal('bar', locker.get('foo'))
|
6
|
+
assert_equal('bar', locker.get('foo').password)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_add_entry
|
10
|
+
name = 'foo'
|
11
|
+
password = 'bar'
|
12
|
+
|
13
|
+
entry = Pwl::Entry.new
|
14
|
+
entry.name = name
|
15
|
+
entry.password = password
|
16
|
+
locker.add(entry)
|
17
|
+
|
18
|
+
entry = locker.get(name)
|
19
|
+
assert_not_nil(entry)
|
20
|
+
assert_equal(password, entry.password)
|
7
21
|
end
|
8
22
|
|
9
23
|
def test_get_blank
|
@@ -17,11 +31,11 @@ class TestLockerCRUD < Test::Pwl::TestCase
|
|
17
31
|
end
|
18
32
|
|
19
33
|
def test_add_get_blank
|
20
|
-
assert_raise Pwl::
|
34
|
+
assert_raise Pwl::InvalidEntryError do
|
21
35
|
locker.add('empty', '')
|
22
36
|
end
|
23
37
|
|
24
|
-
assert_raise Pwl::
|
38
|
+
assert_raise Pwl::InvalidEntryError do
|
25
39
|
locker.add('nil', nil)
|
26
40
|
end
|
27
41
|
end
|
@@ -41,16 +55,16 @@ class TestLockerCRUD < Test::Pwl::TestCase
|
|
41
55
|
test_vector.each{|k,v| locker.add(k, v)}
|
42
56
|
assert_equal(test_vector.keys, locker.list)
|
43
57
|
locker.list.each{|key|
|
44
|
-
assert_equal(test_vector[key], locker.get(key))
|
58
|
+
assert_equal(test_vector[key], locker.get(key).password)
|
45
59
|
}
|
46
60
|
end
|
47
61
|
|
48
62
|
def test_all
|
49
63
|
test_vector = Hash['foo', 'one', 'bar', 'two', 'Chuck Norris', 'Roundhouse Kick']
|
50
64
|
test_vector.each{|k,v| locker.add(k, v)}
|
51
|
-
|
52
|
-
locker.all.each{|
|
53
|
-
assert_equal(test_vector[
|
65
|
+
assert_present(locker.all)
|
66
|
+
locker.all.each{|entry|
|
67
|
+
assert_equal(test_vector[entry.name], entry.password)
|
54
68
|
}
|
55
69
|
end
|
56
70
|
|
@@ -62,16 +76,16 @@ class TestLockerCRUD < Test::Pwl::TestCase
|
|
62
76
|
expected = test_vector.keys.select{|k,v| k =~ /#{filter}/}
|
63
77
|
assert_equal(expected, locker.list(filter))
|
64
78
|
end
|
65
|
-
|
79
|
+
|
66
80
|
def test_delete
|
67
81
|
locker.add('foo', 'bar')
|
68
|
-
assert_equal('bar', locker.delete('foo'))
|
69
|
-
|
82
|
+
assert_equal('bar', locker.delete('foo').password)
|
83
|
+
|
70
84
|
assert_raise Pwl::Locker::KeyNotFoundError do
|
71
85
|
locker.get('foo')
|
72
86
|
end
|
73
87
|
end
|
74
|
-
|
88
|
+
|
75
89
|
def test_delete_blank
|
76
90
|
assert_raise Pwl::Locker::BlankKeyError do
|
77
91
|
locker.delete('')
|
@@ -50,7 +50,7 @@ class TestLockerPasswordPolicy < Test::Pwl::TestCase
|
|
50
50
|
def assert_valid(password)
|
51
51
|
locker = ::Pwl::Locker.new(@locker_file, password)
|
52
52
|
locker.add('foo', 'bar')
|
53
|
-
assert_equal('bar', locker.get('foo'))
|
53
|
+
assert_equal('bar', locker.get('foo').password)
|
54
54
|
end
|
55
55
|
|
56
56
|
def assert_invalid(password)
|
@@ -20,6 +20,7 @@ class TestLockerSecurity < Test::Pwl::TestCase
|
|
20
20
|
def test_change_password
|
21
21
|
assert(!locker.nil?, "Locker expected, but it is nil")
|
22
22
|
locker.add('Homer', 'Simpson')
|
23
|
+
assert_equal('Simpson', locker.get('Homer').password)
|
23
24
|
locker.change_password!(locker_password.reverse)
|
24
25
|
|
25
26
|
# the old password must not work anymore
|
@@ -29,6 +30,6 @@ class TestLockerSecurity < Test::Pwl::TestCase
|
|
29
30
|
|
30
31
|
# Read back with the changed password
|
31
32
|
reopened = Pwl::Locker.open(locker_file, locker_password.reverse)
|
32
|
-
assert_equal('Simpson', reopened.get('Homer'))
|
33
|
+
assert_equal('Simpson', reopened.get('Homer').password)
|
33
34
|
end
|
34
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05
|
12
|
+
date: 2012-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: encryptor
|
@@ -60,13 +60,29 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.2'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: activemodel
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '3.2'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.2'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: uuid
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.3'
|
70
86
|
type: :runtime
|
71
87
|
prerelease: false
|
72
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +90,7 @@ dependencies:
|
|
74
90
|
requirements:
|
75
91
|
- - ~>
|
76
92
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
93
|
+
version: '2.3'
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: rdoc
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +107,22 @@ dependencies:
|
|
91
107
|
- - ~>
|
92
108
|
- !ruby/object:Gem::Version
|
93
109
|
version: '3.1'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pry
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
94
126
|
- !ruby/object:Gem::Dependency
|
95
127
|
name: bundler
|
96
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,11 +174,22 @@ files:
|
|
142
174
|
- VERSION
|
143
175
|
- bin/pwl
|
144
176
|
- lib/pwl.rb
|
177
|
+
- lib/pwl/commands/add.rb
|
178
|
+
- lib/pwl/commands/base.rb
|
179
|
+
- lib/pwl/commands/delete.rb
|
180
|
+
- lib/pwl/commands/export.rb
|
181
|
+
- lib/pwl/commands/get.rb
|
182
|
+
- lib/pwl/commands/init.rb
|
183
|
+
- lib/pwl/commands/list.rb
|
184
|
+
- lib/pwl/commands/passwd.rb
|
185
|
+
- lib/pwl/commands/stats.rb
|
145
186
|
- lib/pwl/dialog.rb
|
146
187
|
- lib/pwl/dialog/base.rb
|
147
188
|
- lib/pwl/dialog/cocoa.rb
|
148
189
|
- lib/pwl/dialog/console.rb
|
149
190
|
- lib/pwl/dialog/gnome.rb
|
191
|
+
- lib/pwl/entry.rb
|
192
|
+
- lib/pwl/entry_mapper.rb
|
150
193
|
- lib/pwl/locker.rb
|
151
194
|
- lib/pwl/message.rb
|
152
195
|
- lib/pwl/password_policy.rb
|
@@ -173,6 +216,8 @@ files:
|
|
173
216
|
- test/fixtures/test_empty.json
|
174
217
|
- test/fixtures/test_empty.yaml
|
175
218
|
- test/helper.rb
|
219
|
+
- test/unit/test_entry.rb
|
220
|
+
- test/unit/test_entry_mapper.rb
|
176
221
|
- test/unit/test_error.rb
|
177
222
|
- test/unit/test_message.rb
|
178
223
|
- test/unit/test_store_construction.rb
|
@@ -195,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
240
|
version: '0'
|
196
241
|
segments:
|
197
242
|
- 0
|
198
|
-
hash: -
|
243
|
+
hash: -1227693264216826394
|
199
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
245
|
none: false
|
201
246
|
requirements:
|