pod4 0.10.4 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 630728075021ff016e6ead3d63c58806821bc3ce
4
- data.tar.gz: 8545dc27e2f1f73a7fd4bc0589d4f751a44d3811
3
+ metadata.gz: 3438ad2d9f28358a99d1704f7b3f3fd39ec7a8bc
4
+ data.tar.gz: 12e1ca2d33bff64be209509c42c2695dad462d9f
5
5
  SHA512:
6
- metadata.gz: b93e6dc86f29c31acca757cb64392a23b406829f033e6db3a4c0158e951ce258a5abe874d6f6f3f393b03afc84b0a8d3db461d0fdf6e189cee545c201adc8d41
7
- data.tar.gz: f07ac222e7260b0fd94669640fc519a14604779982d659333da5de52577e590cf811665645fd2192ec277b80d56765ac35e57e1689c5dec21c27c712d58b6f02
6
+ metadata.gz: 76f2db877e9ef30b57409f7b9d31ef9fa718cd21e58ac4a58d9f8512378bd6d39a1cc574575a0b558d3d48d1cce2ebd2b0e03d173188b947ecbf316870902945
7
+ data.tar.gz: 677f152afb19ba659f2b6d1fe0ffa31c4e81c76eb1d3bb31e7c464895116630339ee76afff59930b646261f81d24040d94f12b2d7bc7d19cbaa9771682ae3936
data/.hgtags CHANGED
@@ -30,3 +30,4 @@ f1b3a814e7a8c7d818b57f6d35ce7ed749573d76 0.9.1
30
30
  7ac52e99228fe39ca59c87fad8fe2c1236fce4fa 0.10.1
31
31
  7a39c71dceaf05b9204e1f2870f904940fdac4d3 0.10.3
32
32
  e98232cdc6cbe61e2bf0513fcf578001a2931018 0.10.4
33
+ daae29a48272b5c3029b6509354bd3c3e6bf339a 0.10.5
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Pod4
2
- VERSION = '0.10.4'
2
+ VERSION = '0.10.5'
3
3
  end
@@ -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
- @Connection = Sequel.connect('jdbc:postgresql://centos7andy/pod4_test?user=pod4test&password=pod4test')
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
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-08 00:00:00.000000000 Z
11
+ date: 2018-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devnull