mongoid-kms 0.0.23 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/kms/version.rb +1 -1
- data/lib/mongoid/kms.rb +3 -1
- data/spec/lib/mongoid/kms_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cba610372bec2c46d28489f6e0737cf25506410b
|
4
|
+
data.tar.gz: 3f20a95f9c302c52aead878c8e5a54c0121140b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f4d37ff69f49ef3408a110e77301336725a7159516796296cf7fce419fe5745cab4e338343e824789136e0163b5d5c3b5e56edaa97a5b3c4eb3fe86b419122
|
7
|
+
data.tar.gz: a82993500ff34c743a44a973d9ffc49b7f27c74f018c28bf6766080fe7a54df57fd7c61cacc747f6ff40db35f8b5ffcd16bbc0dfe0a33fb86feeb001b59dec4d
|
data/lib/mongoid/kms/version.rb
CHANGED
data/lib/mongoid/kms.rb
CHANGED
@@ -52,7 +52,9 @@ module Mongoid
|
|
52
52
|
# Instance methods
|
53
53
|
def set_kms_values
|
54
54
|
self.class.kms_field_map.each do |field_name, settings|
|
55
|
-
if self.new_record? ||
|
55
|
+
if self.new_record? || # always run new records through this
|
56
|
+
changed_attributes.keys.include?(field_name.to_sym) || # this is a hack to get around Mongoid's weakass dirty hack
|
57
|
+
kms_context_value_changed?(field_name) # checks if any of the context fields have changed
|
56
58
|
encrypted_field_name = self.class.get_encrypted_field_name(field_name)
|
57
59
|
|
58
60
|
if instance_variable_get("@#{field_name}").nil? && kms_context_value_changed?(field_name)
|
@@ -40,6 +40,18 @@ describe Mongoid::Kms do
|
|
40
40
|
expect(o.secure).to eq("other")
|
41
41
|
end
|
42
42
|
|
43
|
+
it "updates properly" do
|
44
|
+
o = MyClass.new(unsecure: "robin", secure: "other")
|
45
|
+
o.save!
|
46
|
+
|
47
|
+
o = MyClass.find(o.id)
|
48
|
+
o.secure = 'salted-other'
|
49
|
+
o.save!
|
50
|
+
|
51
|
+
o = MyClass.find(o.id)
|
52
|
+
expect(o.secure).to eq("salted-other")
|
53
|
+
end
|
54
|
+
|
43
55
|
it "handles a class without context" do
|
44
56
|
o = MyClass.new(secure: "bla", unsecure: "blatoo")
|
45
57
|
o.save!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-kms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Winslett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|