pod4 0.10.4 → 0.10.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.
- checksums.yaml +4 -4
- data/.hgtags +1 -0
- data/lib/pod4/encrypting.rb +7 -0
- data/lib/pod4/version.rb +1 -1
- data/spec/common/model_plus_encrypting_spec.rb +54 -0
- data/spec/jruby/sequel_encrypting_jdbc_pg_spec.rb +1 -1
- 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: 3438ad2d9f28358a99d1704f7b3f3fd39ec7a8bc
|
4
|
+
data.tar.gz: 12e1ca2d33bff64be209509c42c2695dad462d9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76f2db877e9ef30b57409f7b9d31ef9fa718cd21e58ac4a58d9f8512378bd6d39a1cc574575a0b558d3d48d1cce2ebd2b0e03d173188b947ecbf316870902945
|
7
|
+
data.tar.gz: 677f152afb19ba659f2b6d1fe0ffa31c4e81c76eb1d3bb31e7c464895116630339ee76afff59930b646261f81d24040d94f12b2d7bc7d19cbaa9771682ae3936
|
data/.hgtags
CHANGED
data/lib/pod4/encrypting.rb
CHANGED
@@ -35,6 +35,9 @@ module Pod4
|
|
35
35
|
# You probably have a single key for the entire database and pass it to your application via an
|
36
36
|
# environment variable. But we don't care about that.
|
37
37
|
#
|
38
|
+
# If you set the key to nil, then the model should work exactly as if the encryption mixin was
|
39
|
+
# not present.
|
40
|
+
#
|
38
41
|
# set_iv_column
|
39
42
|
# -------------
|
40
43
|
#
|
@@ -136,6 +139,8 @@ module Pod4
|
|
136
139
|
# When mapping to the interface, encrypt the encryptable columns from the model
|
137
140
|
#
|
138
141
|
def map_to_interface
|
142
|
+
return super if self.class.encryption_key.nil?
|
143
|
+
|
139
144
|
hash = super.to_h
|
140
145
|
cipher = get_cipher(:encrypt)
|
141
146
|
|
@@ -157,6 +162,8 @@ module Pod4
|
|
157
162
|
# When mapping to the model, decrypt the encrypted columns from the interface
|
158
163
|
#
|
159
164
|
def map_to_model(ot)
|
165
|
+
return super(ot) if self.class.encryption_key.nil?
|
166
|
+
|
160
167
|
hash = ot.to_h
|
161
168
|
cipher = get_cipher(:decrypt)
|
162
169
|
|
data/lib/pod4/version.rb
CHANGED
@@ -48,6 +48,17 @@ describe "(Model with Encryption)" do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
let(:medical_model_nokey_class) do # model with no encryption key
|
52
|
+
Class.new Pod4::Model do
|
53
|
+
include Pod4::Encrypting
|
54
|
+
attr_columns :id, :nhs_no
|
55
|
+
encrypted_columns :name, :ailment, :prescription
|
56
|
+
set_key nil
|
57
|
+
set_iv_column :nonce
|
58
|
+
set_interface NullInterface.new(:id, :nhs_no, :name, :ailment, :prescription, :nonce, [])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
51
62
|
let(:diary_model_class) do # model without an IV column
|
52
63
|
Class.new Pod4::Model do
|
53
64
|
include Pod4::Encrypting
|
@@ -183,6 +194,27 @@ describe "(Model with Encryption)" do
|
|
183
194
|
|
184
195
|
describe "(Creating a record)" do
|
185
196
|
|
197
|
+
context "when we don't have a key" do
|
198
|
+
|
199
|
+
it "writes the record without freaking out" do
|
200
|
+
m = medical_model_nokey_class.new
|
201
|
+
m.id = 666
|
202
|
+
m.nhs_no = "666666"
|
203
|
+
m.name = "joe"
|
204
|
+
m.ailment = "brain cloud"
|
205
|
+
m.prescription = "volcano"
|
206
|
+
|
207
|
+
expect{ m.create }.not_to raise_exception
|
208
|
+
|
209
|
+
record = m.interface.read(666)
|
210
|
+
expect( record.>>.nhs_no ).to eq "666666"
|
211
|
+
expect( record.>>.name ).to eq "joe"
|
212
|
+
expect( record.>>.ailment ).to eq "brain cloud"
|
213
|
+
expect( record.>>.prescription ).to eq "volcano"
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
|
186
218
|
context "when we don't have an IV column" do
|
187
219
|
|
188
220
|
it "scrambles the encrypted columns and leaves the others alone" do
|
@@ -220,6 +252,28 @@ describe "(Model with Encryption)" do
|
|
220
252
|
|
221
253
|
describe "(reading a record)" do
|
222
254
|
|
255
|
+
context "when we don't have a key" do
|
256
|
+
|
257
|
+
it "reads the record without freaking out" do
|
258
|
+
m = medical_model_nokey_class.new
|
259
|
+
m.id = 666
|
260
|
+
m.nhs_no = "666666"
|
261
|
+
m.name = "joe"
|
262
|
+
m.ailment = "brain cloud"
|
263
|
+
m.prescription = "volcano"
|
264
|
+
expect{ m.create }.not_to raise_exception
|
265
|
+
|
266
|
+
m666 = medical_model_nokey_class.new(666)
|
267
|
+
expect{ m666.read }.not_to raise_exception
|
268
|
+
expect( m666.model_status ).not_to eq :error
|
269
|
+
expect( m666.nhs_no ).to eq "666666"
|
270
|
+
expect( m666.name ).to eq "joe"
|
271
|
+
expect( m666.ailment ).to eq "brain cloud"
|
272
|
+
expect( m666.prescription ).to eq "volcano"
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
276
|
+
|
223
277
|
context "when we have no IV column" do
|
224
278
|
before(:each) { d44.create }
|
225
279
|
|
@@ -23,7 +23,7 @@ describe "(writing encrypted data via sequel_interface)" do
|
|
23
23
|
|
24
24
|
|
25
25
|
before(:all) do
|
26
|
-
@
|
26
|
+
@connection = Sequel.connect('jdbc:postgresql://centos7andy/pod4_test?user=pod4test&password=pod4test')
|
27
27
|
db_setup(@connection)
|
28
28
|
end
|
29
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pod4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devnull
|