mongoid 9.0.12 → 9.0.13
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/lib/config/locales/en.yml +31 -11
- data/lib/mongoid/association/embedded/batchable.rb +8 -0
- data/lib/mongoid/clients/factory.rb +2 -0
- data/lib/mongoid/config/encryption.rb +148 -17
- data/lib/mongoid/encryptable.rb +42 -15
- data/lib/mongoid/errors/invalid_encryption_schema.rb +27 -0
- data/lib/mongoid/errors/no_encryption_schema.rb +5 -3
- data/lib/mongoid/errors.rb +1 -0
- data/lib/mongoid/persistence_context.rb +46 -4
- data/lib/mongoid/search_indexable.rb +5 -1
- data/lib/mongoid/tasks/database.rb +10 -7
- data/lib/mongoid/threaded.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid/warnings.rb +4 -0
- data/spec/integration/atomic/modifiers_spec.rb +57 -0
- data/spec/integration/encryption_spec.rb +149 -0
- data/spec/mongoid/clients/factory_spec.rb +36 -0
- data/spec/mongoid/config/encryption_spec.rb +223 -0
- data/spec/mongoid/encryptable_spec.rb +54 -0
- data/spec/mongoid/matcher/regexp_budget_spec.rb +6 -0
- data/spec/mongoid/search_indexable_spec.rb +34 -1
- data/spec/mongoid/tasks/database_spec.rb +13 -0
- data/spec/support/crypt/models.rb +96 -0
- data/spec/support/models/modifier_models.rb +32 -0
- metadata +5 -2
|
@@ -204,4 +204,100 @@ module Crypt
|
|
|
204
204
|
|
|
205
205
|
embeds_one :missing_note, class_name: 'Crypt::MissingNote'
|
|
206
206
|
end
|
|
207
|
+
|
|
208
|
+
# Two unrelated models stored in one collection, each with its own encrypted
|
|
209
|
+
# field.
|
|
210
|
+
class Badge
|
|
211
|
+
include Mongoid::Document
|
|
212
|
+
|
|
213
|
+
store_in collection: 'crypt_badges'
|
|
214
|
+
|
|
215
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
216
|
+
|
|
217
|
+
field :serial, type: String, encrypt: true
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
class BadgeScan
|
|
221
|
+
include Mongoid::Document
|
|
222
|
+
|
|
223
|
+
store_in collection: 'crypt_badges'
|
|
224
|
+
|
|
225
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
226
|
+
|
|
227
|
+
field :holder, type: String, encrypt: true
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Single collection inheritance. Only Member is registered in
|
|
231
|
+
# Mongoid.models; the subclasses are not.
|
|
232
|
+
class Member
|
|
233
|
+
include Mongoid::Document
|
|
234
|
+
|
|
235
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
236
|
+
|
|
237
|
+
field :ssn, type: String, encrypt: true
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
class Employee < Member
|
|
241
|
+
field :salary, type: String, encrypt: true
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
class Contractor < Member
|
|
245
|
+
field :rate, type: String, encrypt: true
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Single collection inheritance where only the subclass is encrypted.
|
|
249
|
+
class Listing
|
|
250
|
+
include Mongoid::Document
|
|
251
|
+
|
|
252
|
+
field :title, type: String
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
class PrivateListing < Listing
|
|
256
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
257
|
+
|
|
258
|
+
field :owner_ssn, type: String, encrypt: true
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# An embeds_one target whose subclass adds an encrypted field.
|
|
262
|
+
class Box
|
|
263
|
+
include Mongoid::Document
|
|
264
|
+
|
|
265
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
266
|
+
|
|
267
|
+
embeds_one :item, class_name: 'Crypt::Item'
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
class Item
|
|
271
|
+
include Mongoid::Document
|
|
272
|
+
|
|
273
|
+
field :label, type: String, encrypt: true
|
|
274
|
+
|
|
275
|
+
embedded_in :box, class_name: 'Crypt::Box'
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
class SealedItem < Item
|
|
279
|
+
field :seal, type: String, encrypt: true
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# An embeds_one target with no encrypted field, whose subclass has one.
|
|
283
|
+
# Nothing on Locker or Content declares encryption.
|
|
284
|
+
class Locker
|
|
285
|
+
include Mongoid::Document
|
|
286
|
+
|
|
287
|
+
embeds_one :content, class_name: 'Crypt::Content'
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
class Content
|
|
291
|
+
include Mongoid::Document
|
|
292
|
+
|
|
293
|
+
field :label, type: String
|
|
294
|
+
|
|
295
|
+
embedded_in :locker, class_name: 'Crypt::Locker'
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
class SecretContent < Content
|
|
299
|
+
encrypt_with key_id: 'grolrnFVSSW9Gq04Q87R9Q==', deterministic: true
|
|
300
|
+
|
|
301
|
+
field :code, type: String, encrypt: true
|
|
302
|
+
end
|
|
207
303
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ModifierModels
|
|
4
|
+
class Cabinet
|
|
5
|
+
include Mongoid::Document
|
|
6
|
+
|
|
7
|
+
embeds_one :drawer, class_name: 'ModifierModels::Drawer', autobuild: true
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Drawer
|
|
11
|
+
include Mongoid::Document
|
|
12
|
+
|
|
13
|
+
field :matcher, type: String
|
|
14
|
+
embedded_in :cabinet, class_name: 'ModifierModels::Cabinet'
|
|
15
|
+
embeds_many :items, class_name: 'ModifierModels::Item'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Item
|
|
19
|
+
include Mongoid::Document
|
|
20
|
+
|
|
21
|
+
field :name, type: String
|
|
22
|
+
embedded_in :drawer, class_name: 'ModifierModels::Drawer'
|
|
23
|
+
embeds_many :widgets, class_name: 'ModifierModels::Widget'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class Widget
|
|
27
|
+
include Mongoid::Document
|
|
28
|
+
|
|
29
|
+
field :label, type: String
|
|
30
|
+
embedded_in :item, class_name: 'ModifierModels::Item'
|
|
31
|
+
end
|
|
32
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 9.0.
|
|
4
|
+
version: 9.0.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- The MongoDB Ruby Team
|
|
@@ -303,6 +303,7 @@ files:
|
|
|
303
303
|
- lib/mongoid/errors/invalid_discriminator_key_target.rb
|
|
304
304
|
- lib/mongoid/errors/invalid_dot_dollar_assignment.rb
|
|
305
305
|
- lib/mongoid/errors/invalid_elem_match_operator.rb
|
|
306
|
+
- lib/mongoid/errors/invalid_encryption_schema.rb
|
|
306
307
|
- lib/mongoid/errors/invalid_estimated_count_criteria.rb
|
|
307
308
|
- lib/mongoid/errors/invalid_estimated_count_scoping.rb
|
|
308
309
|
- lib/mongoid/errors/invalid_expression_operator.rb
|
|
@@ -1088,6 +1089,7 @@ files:
|
|
|
1088
1089
|
- spec/support/models/message.rb
|
|
1089
1090
|
- spec/support/models/minim.rb
|
|
1090
1091
|
- spec/support/models/mixed_drink.rb
|
|
1092
|
+
- spec/support/models/modifier_models.rb
|
|
1091
1093
|
- spec/support/models/mop.rb
|
|
1092
1094
|
- spec/support/models/movie.rb
|
|
1093
1095
|
- spec/support/models/my_hash.rb
|
|
@@ -1253,7 +1255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1253
1255
|
- !ruby/object:Gem::Version
|
|
1254
1256
|
version: 1.3.6
|
|
1255
1257
|
requirements: []
|
|
1256
|
-
rubygems_version: 4.0.
|
|
1258
|
+
rubygems_version: 4.0.24
|
|
1257
1259
|
specification_version: 4
|
|
1258
1260
|
summary: Elegant Persistence in Ruby for MongoDB.
|
|
1259
1261
|
test_files:
|
|
@@ -1840,6 +1842,7 @@ test_files:
|
|
|
1840
1842
|
- spec/support/models/message.rb
|
|
1841
1843
|
- spec/support/models/minim.rb
|
|
1842
1844
|
- spec/support/models/mixed_drink.rb
|
|
1845
|
+
- spec/support/models/modifier_models.rb
|
|
1843
1846
|
- spec/support/models/mop.rb
|
|
1844
1847
|
- spec/support/models/movie.rb
|
|
1845
1848
|
- spec/support/models/my_hash.rb
|