strongbox 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGZhNGI2ODYzOWFjYTk3MTYyNDdjNjIzMDJmMzc4NDc2ZGMyMGEzOQ==
4
+ MGRhOGUwMmEzNWU0MjFmNDBkZDdhZTc3MDhkZjllZjM3NThmOTRlYw==
5
5
  data.tar.gz: !binary |-
6
- Yzk0MDNlNWNjYzlmMjkyMDYwYjE2YjUwNjYzNWJhOGIxNzNkMWU4MQ==
6
+ OTJkNGY2YTEyNjI5ZTVlMDE3NDY4ZDlhN2NhMGRjMTg4NjAxYTY5NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTZlY2M1NmMwZjkzMjMyYTlmY2IzODc3MzM4NzIzMmYxYjllMjMxNTczZWYz
10
- ZTc2ZDc0ZjQyNTVmZDQwYzE0NmIxOWE4Y2FmOTFlY2I4OTlmOWZhN2MyMjE5
11
- ZGE2YTlhYTI0NGRmZDI3NzM3YjU0NTg0YWY1OGQyNTJlNzBmMjM=
9
+ YzU2YzRhM2MxZjI3NWYzNWY4ZjMyZDRiODA5MGQzMDZjZWU3ZjNhNmExYmJi
10
+ OWU1ODhiNDhmZDg4NzliMGZmNjZiNmUwYmE2YmQwMjk0ODE0MDczMWJjNTFl
11
+ YzQ4MzdmZWQ5ZDc0Y2RkZWNkNzkxMDNhNzQ4M2YzYzZjNzEzYmE=
12
12
  data.tar.gz: !binary |-
13
- ODZhNGYzZmJiMWNhNmVhMDU3MzdhNDVjNDI4MDgwMzE0OGI4YzRjZjEyYjQy
14
- Njc5NzkwMjliZDNhY2JjY2NkYzQ4Yzc5MjA1ODcwZTM2Y2U2NDA4YWE4M2M5
15
- ZjY0YzVjZDNiNzE2NzIyYjE2YzAyYzQwNGVmMmY5Yzg3ZmM0OWE=
13
+ Mjg5Y2I3NDViYWFkM2ZmMzgxNDBlMjc3NzAxZWZmZTY3ZWUwZTc3MDQyMjg2
14
+ MGRmNzU1YzgzNmRlYmRiODg5YTAzNTVjOGI0M2ZjZTg2ZDE5YjA3MTJmMGE3
15
+ ZjFhYWFmY2NmOWY3NDZmOTE5YjI3NTNkMjU0Mzk2OGNiMjI5YWI=
@@ -5,7 +5,7 @@ require 'strongbox/lock'
5
5
 
6
6
  module Strongbox
7
7
 
8
- VERSION = "0.7.1"
8
+ VERSION = "0.7.2"
9
9
 
10
10
  RSA_PKCS1_PADDING = OpenSSL::PKey::RSA::PKCS1_PADDING
11
11
  RSA_SSLV23_PADDING = OpenSSL::PKey::RSA::SSLV23_PADDING
@@ -25,6 +25,7 @@ module Strongbox
25
25
  end
26
26
 
27
27
  def content plaintext
28
+ @size = plaintext.size unless plaintext.nil? # For validations
28
29
  if @deferred_encryption
29
30
  @raw_content = plaintext
30
31
  else
@@ -43,7 +44,6 @@ module Strongbox
43
44
  raise StrongboxError.new("#{@instance.class} model does not have public key_file")
44
45
  end
45
46
  if !plaintext.blank?
46
- @size = plaintext.size # For validations
47
47
  # Using a blank password in OpenSSL::PKey::RSA.new prevents reading
48
48
  # the private key if the file is a key pair
49
49
  public_key = get_rsa_key(@public_key,"")
@@ -124,11 +124,11 @@ module Strongbox
124
124
 
125
125
  # Needed for validations
126
126
  def blank?
127
- @instance[@name].blank?
127
+ @raw_content.blank? and @instance[@name].blank?
128
128
  end
129
129
 
130
130
  def nil?
131
- @instance[@name].nil?
131
+ @raw_content.nil? and @instance[@name].nil?
132
132
  end
133
133
 
134
134
  def size
@@ -22,4 +22,5 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency 'sqlite3', '~> 1.3.7'
23
23
  s.add_development_dependency 'rake', '>= 10.0.0'
24
24
  s.add_development_dependency 'rdoc', '>= 2.4.0'
25
+ s.add_development_dependency 'test-unit', '>= 3.0.9'
25
26
  end
@@ -1,3 +1,4 @@
1
+ require 'yaml'
1
2
  require 'test/test_helper'
2
3
 
3
4
  class MethodKeyTest < Test::Unit::TestCase
@@ -132,7 +133,6 @@ class MethodKeyTest < Test::Unit::TestCase
132
133
  setup do
133
134
  Dummy.create!(:secret => 'Shhhh', :password => @password)
134
135
  @dummy = Dummy.first
135
- p 'XXXXXXXXXXXX'
136
136
  end
137
137
 
138
138
  should_encypted_and_decrypt
@@ -1,99 +1,104 @@
1
1
  require 'test/test_helper'
2
2
 
3
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
- Dummy.send(:validates_length_of,
30
- :secret,
31
- :in => 5..10,
32
- :allow_nil => true,
33
- :allow_blank => true
34
- )
35
- @valid = Dummy.new(:secret => 'Shhhh')
36
- @valid_nil = Dummy.new(:secret => nil)
37
- @valid_blank = Dummy.new(:secret => '')
38
- @invalid = Dummy.new(:secret => '1')
39
- end
40
-
41
- should 'not have an error on the secret when in range' do
42
- assert @valid.valid?
43
- assert_does_not_have_errors_on(@valid,:secret)
44
- end
45
-
46
- should 'not have an error on the secret when nil' do
47
- assert @valid_nil.valid?
48
- assert_does_not_have_errors_on(@valid_nil,:secret)
49
- end
50
-
51
- should 'not have an error on the secret when blank' do
52
- assert @valid_blank.valid?
53
- assert_does_not_have_errors_on(@valid_blank,:secret)
54
- end
55
-
56
- should 'have an error on the secret when invalid' do
57
- assert !@invalid.valid?
58
- assert_has_errors_on(@invalid,:secret)
59
- end
60
- end
61
-
62
-
63
- if defined?(ActiveModel::Validations) # Rails 3
64
- context 'using validates for length' do
4
+ [true, false].each do |deferred_encryption|
5
+ context "with :deferred_encryption => #{deferred_encryption}" do
6
+ context 'with validations' do
65
7
  setup do
66
- Dummy.send(:validates,
67
- :secret,
68
- :length => {:minimum => 4, :maximum => 16})
69
- @valid = Dummy.new(:secret => 'Shhhh')
70
- @out_of_range = [Dummy.new(:secret => 'x' * 3),
71
- Dummy.new(:secret => 'x' * 17)]
72
- @blank = [Dummy.new(:secret => nil),
73
- Dummy.new(:secret => '')]
8
+ rebuild_model({
9
+ :key_pair => File.join(FIXTURES_DIR,'keypair.pem'),
10
+ :deferred_encryption => deferred_encryption
11
+ })
74
12
  end
75
-
76
- should 'not have an error on the secret when in range' do
77
- assert @valid.valid?
78
- assert_does_not_have_errors_on(@valid,:secret)
13
+
14
+ context 'using validates_presence_of' do
15
+ setup do
16
+ Dummy.send(:validates_presence_of, :secret)
17
+ @valid = Dummy.new(:secret => 'Shhhh')
18
+ @invalid = Dummy.new(:secret => nil)
19
+ end
20
+
21
+ should 'not have an error on the secret when valid' do
22
+ assert @valid.valid?
23
+ assert_does_not_have_errors_on(@valid,:secret)
24
+ end
25
+
26
+ should 'have an error on the secret when invalid' do
27
+ assert !@invalid.valid?
28
+ assert_has_errors_on(@invalid,:secret)
29
+ end
79
30
  end
80
31
 
81
- should 'have an error on the secret when out of range' do
82
- @out_of_range.each do |instance|
83
- assert !instance.valid?
84
- assert_has_errors_on(instance,:secret)
32
+ context 'using validates_length_of' do
33
+ setup do
34
+ Dummy.send(:validates_length_of,
35
+ :secret,
36
+ :in => 5..10,
37
+ :allow_nil => true,
38
+ :allow_blank => true
39
+ )
40
+ @valid = Dummy.new(:secret => 'Shhhh')
41
+ @valid_nil = Dummy.new(:secret => nil)
42
+ @valid_blank = Dummy.new(:secret => '')
43
+ @invalid = Dummy.new(:secret => '1')
44
+ end
45
+
46
+ should 'not have an error on the secret when in range' do
47
+ assert @valid.valid?
48
+ assert_does_not_have_errors_on(@valid,:secret)
49
+ end
50
+
51
+ should 'not have an error on the secret when nil' do
52
+ assert @valid_nil.valid?
53
+ assert_does_not_have_errors_on(@valid_nil,:secret)
54
+ end
55
+
56
+ should 'not have an error on the secret when blank' do
57
+ assert @valid_blank.valid?
58
+ assert_does_not_have_errors_on(@valid_blank,:secret)
59
+ end
60
+
61
+ should 'have an error on the secret when invalid' do
62
+ assert !@invalid.valid?
63
+ assert_has_errors_on(@invalid,:secret)
85
64
  end
86
65
  end
87
66
 
88
- should 'have an error on the secret when blank' do
89
- @blank.each do |instance|
90
- assert !instance.valid?
91
- assert_has_errors_on(instance,:secret)
67
+
68
+ if defined?(ActiveModel::Validations) # Rails 3
69
+ context 'using validates for length' do
70
+ setup do
71
+ Dummy.send(:validates,
72
+ :secret,
73
+ :length => {:minimum => 4, :maximum => 16})
74
+ @valid = Dummy.new(:secret => 'Shhhh')
75
+ @out_of_range = [Dummy.new(:secret => 'x' * 3),
76
+ Dummy.new(:secret => 'x' * 17)]
77
+ @blank = [Dummy.new(:secret => nil),
78
+ Dummy.new(:secret => '')]
79
+ end
80
+
81
+ should 'not have an error on the secret when in range' do
82
+ assert @valid.valid?
83
+ assert_does_not_have_errors_on(@valid,:secret)
84
+ end
85
+
86
+ should 'have an error on the secret when out of range' do
87
+ @out_of_range.each do |instance|
88
+ assert !instance.valid?
89
+ assert_has_errors_on(instance,:secret)
90
+ end
91
+ end
92
+
93
+ should 'have an error on the secret when blank' do
94
+ @blank.each do |instance|
95
+ assert !instance.valid?
96
+ assert_has_errors_on(instance,:secret)
97
+ end
98
+ end
92
99
  end
93
100
  end
94
101
  end
95
102
  end
96
103
  end
97
-
98
104
  end
99
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spike Ilacqua
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.4.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-unit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.9
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.9
83
97
  description: ! " Strongbox provides Public Key Encryption for ActiveRecord. By
84
98
  using a\n public key sensitive information can be encrypted and stored automatically.\n
85
99
  \ Once stored a password is required to access the information. dependencies\n