crypt_keeper 2.0.0.rc2 → 2.0.1

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
  SHA256:
3
- metadata.gz: 2d2c48e454fad3b2d938bbcabb028983954c991479524a7240acb772b46e37b1
4
- data.tar.gz: 907dd02f441238eaa0a3a77c8be9dd5f936a615630bc96c6759930f74da99f06
3
+ metadata.gz: a3487da836fa168664dc80667a7ec11cf0101b74724cc63d67ea47c67e46615e
4
+ data.tar.gz: 9bb8281e94f569254ff80c5e153a6291e8dbe0f40469a6e0fa2aeef058c745e6
5
5
  SHA512:
6
- metadata.gz: d9a292f9d37a60cf43a9f27c4981e6bfbfd7f603e5f53cbc08932103d9fd61c3c83c141ba56d67b26b7925a7f6d46b87885a9d595ce0b7eaa37ca7e846ee24ca
7
- data.tar.gz: 61def2dfc5d5deadb6b9f667d2b8490cc357e4956059abf45fedc7adae856a95d5f90fe2364da402dbcd0d00b791205e1a9222ce53c190b42b6fa92d0c65bb91
6
+ metadata.gz: 422a52090724c857b26fafe9db634c736f1d21c66fb4a51d4516e76414f66a3f84205ef64b5e83facbb856c5dc1ee633f6827ced22144691edf43f24e79b8eb9
7
+ data.tar.gz: d90f464be5ef20b854fa144b40dff7f081608f3e6384176b1ab8b8efb867dd98651a8d6d7b9785a0f37ef4687f229c1679731dd2a3925f885eedeb92e58eec5a
@@ -4,6 +4,8 @@ rvm:
4
4
  - 2.2.7
5
5
  - 2.3.4
6
6
  - 2.4.1
7
+ - 2.5.3
8
+ - 2.6.0
7
9
 
8
10
  gemfile:
9
11
  - gemfiles/activerecord_4_2.gemfile
@@ -35,7 +35,7 @@ Gem::Specification.new do |gem|
35
35
  gem.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
36
36
  gem.add_development_dependency 'activerecord-jdbcmysql-adapter'
37
37
  else
38
- gem.add_development_dependency 'sqlite3'
38
+ gem.add_development_dependency 'sqlite3', '~> 1.3', '< 1.4'
39
39
  gem.add_development_dependency 'pg', '~> 0.18.0'
40
40
  gem.add_development_dependency 'mysql2', '>= 0.3.13', '< 0.6.0'
41
41
  end
@@ -4,6 +4,5 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 4.2.0"
6
6
  gem "activesupport", "~> 4.2.0"
7
- gem "mysql2", ">= 0.3.13", "< 0.5"
8
7
 
9
8
  gemspec :path => "../"
@@ -4,6 +4,5 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.0.0"
6
6
  gem "activesupport", "~> 5.0.0"
7
- gem "mysql2", ">= 0.3.18", "< 0.6.0"
8
7
 
9
8
  gemspec :path => "../"
@@ -4,6 +4,5 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.1.0"
6
6
  gem "activesupport", "~> 5.1.0"
7
- gem "mysql2", ">= 0.3.18", "< 0.6.0"
8
7
 
9
8
  gemspec :path => "../"
@@ -4,6 +4,5 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.2.0"
6
6
  gem "activesupport", "~> 5.2.0"
7
- gem "mysql2", ">= 0.4.4", "< 0.6.0"
8
7
 
9
8
  gemspec :path => "../"
@@ -42,8 +42,14 @@ module CryptKeeper
42
42
  end
43
43
 
44
44
  def search(records, field, criteria)
45
- records.where("(pgp_sym_decrypt(cast(\"#{field}\" AS bytea), ?) = ?)",
46
- key, criteria)
45
+ if criteria.present?
46
+ records
47
+ .where.not("TRIM(BOTH FROM #{field}) = ?", "")
48
+ .where("(pgp_sym_decrypt(cast(\"#{field}\" AS bytea), ?) = ?)",
49
+ key, criteria)
50
+ else
51
+ records.where(field => criteria)
52
+ end
47
53
  end
48
54
 
49
55
  private
@@ -1,3 +1,3 @@
1
1
  module CryptKeeper
2
- VERSION = "2.0.0.rc2"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -64,6 +64,42 @@ describe CryptKeeper::Provider::PostgresPgp do
64
64
  match = subject.create!(storage: 'blah')
65
65
  expect(subject.search_by_plaintext(:storage, 'blah').first).to eq(match)
66
66
  end
67
+
68
+ it "successfully accesses result when the data has empty strings and nil" do
69
+ subject.create!(storage: nil)
70
+ subject.create!(storage: '')
71
+ subject.create!(storage: ' ')
72
+ match = subject.create!(storage: 'blah')
73
+
74
+ results = subject.search_by_plaintext(:storage, 'blah')
75
+
76
+ expect(results).to match_array([match])
77
+ end
78
+
79
+ it "finds an empty string" do
80
+ subject.create!(storage: nil)
81
+ subject.create!(storage: 'blah')
82
+ match = subject.create!(storage: '')
83
+
84
+ expect(subject.search_by_plaintext(:storage, '')).to match_array([match])
85
+ end
86
+
87
+ it "finds the empty string with the right number of spaces" do
88
+ subject.create!(storage: '')
89
+ match = subject.create!(storage: ' ')
90
+
91
+ results = subject.search_by_plaintext(:storage, ' ')
92
+
93
+ expect(results).to match_array([match])
94
+ end
95
+
96
+ it "finds nil results" do
97
+ subject.create!(storage: '')
98
+ subject.create!(storage: 'blah')
99
+ match = subject.create!(storage: nil)
100
+
101
+ expect(subject.search_by_plaintext(:storage, nil)).to match_array([match])
102
+ end
67
103
  end
68
104
 
69
105
  describe "Custom pgcrypto options" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crypt_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc2
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Mazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-10 00:00:00.000000000 Z
11
+ date: 2019-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -152,16 +152,22 @@ dependencies:
152
152
  name: sqlite3
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - ">="
155
+ - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: '0'
157
+ version: '1.3'
158
+ - - "<"
159
+ - !ruby/object:Gem::Version
160
+ version: '1.4'
158
161
  type: :development
159
162
  prerelease: false
160
163
  version_requirements: !ruby/object:Gem::Requirement
161
164
  requirements:
162
- - - ">="
165
+ - - "~>"
163
166
  - !ruby/object:Gem::Version
164
- version: '0'
167
+ version: '1.3'
168
+ - - "<"
169
+ - !ruby/object:Gem::Version
170
+ version: '1.4'
165
171
  - !ruby/object:Gem::Dependency
166
172
  name: pg
167
173
  requirement: !ruby/object:Gem::Requirement
@@ -261,9 +267,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
261
267
  version: '0'
262
268
  required_rubygems_version: !ruby/object:Gem::Requirement
263
269
  requirements:
264
- - - ">"
270
+ - - ">="
265
271
  - !ruby/object:Gem::Version
266
- version: 1.3.1
272
+ version: '0'
267
273
  requirements: []
268
274
  rubyforge_project:
269
275
  rubygems_version: 2.7.6