strongbox 0.4.4 → 0.4.5
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/lib/strongbox.rb +1 -1
- data/lib/strongbox/lock.rb +1 -1
- data/test/strongbox_test.rb +0 -57
- data/test/validations_test.rb +101 -0
- metadata +7 -5
data/lib/strongbox.rb
CHANGED
data/lib/strongbox/lock.rb
CHANGED
data/test/strongbox_test.rb
CHANGED
@@ -191,63 +191,6 @@ class StrongboxTest < Test::Unit::TestCase
|
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
-
context 'with validations' do
|
195
|
-
context 'using validates_presence_of' do
|
196
|
-
setup do
|
197
|
-
rebuild_class(:key_pair => File.join(FIXTURES_DIR,'keypair.pem'))
|
198
|
-
Dummy.send(:validates_presence_of, :secret)
|
199
|
-
@valid = Dummy.new(:secret => 'Shhhh')
|
200
|
-
@invalid = Dummy.new(:secret => nil)
|
201
|
-
end
|
202
|
-
|
203
|
-
should 'not have an error on the secret when valid' do
|
204
|
-
assert @valid.valid?
|
205
|
-
assert_does_not_have_errors_on(@valid,:secret)
|
206
|
-
end
|
207
|
-
|
208
|
-
should 'have an error on the secret when invalid' do
|
209
|
-
assert !@invalid.valid?
|
210
|
-
assert_has_errors_on(@invalid,:secret)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
context 'using validates_length_of' do
|
215
|
-
setup do
|
216
|
-
rebuild_class(:key_pair => File.join(FIXTURES_DIR,'keypair.pem'))
|
217
|
-
Dummy.send(:validates_length_of,
|
218
|
-
:secret,
|
219
|
-
:in => 5..10,
|
220
|
-
:allow_nil => true,
|
221
|
-
:allow_blank => true
|
222
|
-
)
|
223
|
-
@valid = Dummy.new(:secret => 'Shhhh')
|
224
|
-
@valid_nil = Dummy.new(:secret => nil)
|
225
|
-
@valid_blank = Dummy.new(:secret => '')
|
226
|
-
@invalid = Dummy.new(:secret => '1')
|
227
|
-
end
|
228
|
-
|
229
|
-
should 'not have an error on the secret when in range' do
|
230
|
-
assert @valid.valid?
|
231
|
-
assert_does_not_have_errors_on(@valid,:secret)
|
232
|
-
end
|
233
|
-
|
234
|
-
should 'not have an error on the secret when nil' do
|
235
|
-
assert @valid_nil.valid?
|
236
|
-
assert_does_not_have_errors_on(@valid_nil,:secret)
|
237
|
-
end
|
238
|
-
|
239
|
-
should 'not have an error on the secret when blank' do
|
240
|
-
assert @valid_blank.valid?
|
241
|
-
assert_does_not_have_errors_on(@valid_blank,:secret)
|
242
|
-
end
|
243
|
-
|
244
|
-
should 'have an error on the secret when invalid' do
|
245
|
-
assert !@invalid.valid?
|
246
|
-
assert_has_errors_on(@invalid,:secret)
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
194
|
context 'A Class with two secured fields' do
|
252
195
|
setup do
|
253
196
|
@password = 'boost facile'
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'test/test_helper'
|
2
|
+
|
3
|
+
class ValidationsTest < Test::Unit::TestCase
|
4
|
+
context 'with validations' do
|
5
|
+
setup do
|
6
|
+
rebuild_model :key_pair => File.join(FIXTURES_DIR,'keypair.pem')
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'using validates_presence_of' do
|
10
|
+
setup do
|
11
|
+
Dummy.send(:validates_presence_of, :secret)
|
12
|
+
@valid = Dummy.new(:secret => 'Shhhh')
|
13
|
+
@invalid = Dummy.new(:secret => nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
should 'not have an error on the secret when valid' do
|
17
|
+
assert @valid.valid?
|
18
|
+
assert_does_not_have_errors_on(@valid,:secret)
|
19
|
+
end
|
20
|
+
|
21
|
+
should 'have an error on the secret when invalid' do
|
22
|
+
assert !@invalid.valid?
|
23
|
+
assert_has_errors_on(@invalid,:secret)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'using validates_length_of' do
|
28
|
+
setup do
|
29
|
+
rebuild_class(:key_pair => File.join(FIXTURES_DIR,'keypair.pem'))
|
30
|
+
Dummy.send(:validates_length_of,
|
31
|
+
:secret,
|
32
|
+
:in => 5..10,
|
33
|
+
:allow_nil => true,
|
34
|
+
:allow_blank => true
|
35
|
+
)
|
36
|
+
@valid = Dummy.new(:secret => 'Shhhh')
|
37
|
+
@valid_nil = Dummy.new(:secret => nil)
|
38
|
+
@valid_blank = Dummy.new(:secret => '')
|
39
|
+
@invalid = Dummy.new(:secret => '1')
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'not have an error on the secret when in range' do
|
43
|
+
assert @valid.valid?
|
44
|
+
assert_does_not_have_errors_on(@valid,:secret)
|
45
|
+
end
|
46
|
+
|
47
|
+
should 'not have an error on the secret when nil' do
|
48
|
+
assert @valid_nil.valid?
|
49
|
+
assert_does_not_have_errors_on(@valid_nil,:secret)
|
50
|
+
end
|
51
|
+
|
52
|
+
should 'not have an error on the secret when blank' do
|
53
|
+
assert @valid_blank.valid?
|
54
|
+
assert_does_not_have_errors_on(@valid_blank,:secret)
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'have an error on the secret when invalid' do
|
58
|
+
assert !@invalid.valid?
|
59
|
+
assert_has_errors_on(@invalid,:secret)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
if defined?(ActiveModel::Validations) # Rails 3
|
65
|
+
context 'using validates for length' do
|
66
|
+
setup do
|
67
|
+
rebuild_class(:key_pair => File.join(FIXTURES_DIR,'keypair.pem'))
|
68
|
+
Dummy.send(:validates,
|
69
|
+
:secret,
|
70
|
+
:length => {:minimum => 4, :maximum => 16})
|
71
|
+
@valid = Dummy.new(:secret => 'Shhhh')
|
72
|
+
@out_of_range = [Dummy.new(:secret => 'x' * 3),
|
73
|
+
Dummy.new(:secret => 'x' * 17)]
|
74
|
+
@blank = [Dummy.new(:secret => nil),
|
75
|
+
Dummy.new(:secret => '')]
|
76
|
+
end
|
77
|
+
|
78
|
+
should 'not have an error on the secret when in range' do
|
79
|
+
assert @valid.valid?
|
80
|
+
assert_does_not_have_errors_on(@valid,:secret)
|
81
|
+
end
|
82
|
+
|
83
|
+
should 'have an error on the secret when out of range' do
|
84
|
+
@out_of_range.each do |instance|
|
85
|
+
assert !instance.valid?
|
86
|
+
assert_has_errors_on(instance,:secret)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
should 'have an error on the secret when blank' do
|
91
|
+
@blank.each do |instance|
|
92
|
+
assert !instance.valid?
|
93
|
+
assert_has_errors_on(instance,:secret)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strongbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 5
|
10
|
+
version: 0.4.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Spike Ilacqua
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-18 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- test/missing_attributes_test.rb
|
86
86
|
- test/strongbox_test.rb
|
87
87
|
- test/test_helper.rb
|
88
|
+
- test/validations_test.rb
|
88
89
|
has_rdoc: true
|
89
90
|
homepage: http://stuff-things.net/strongbox
|
90
91
|
licenses: []
|
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
116
|
requirements: []
|
116
117
|
|
117
118
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.
|
119
|
+
rubygems_version: 1.6.2
|
119
120
|
signing_key:
|
120
121
|
specification_version: 3
|
121
122
|
summary: Secures ActiveRecord fields with public key encryption.
|
@@ -126,3 +127,4 @@ test_files:
|
|
126
127
|
- test/missing_attributes_test.rb
|
127
128
|
- test/strongbox_test.rb
|
128
129
|
- test/test_helper.rb
|
130
|
+
- test/validations_test.rb
|