Skip to content

Commit

Permalink
MONGOID-5739 Support BSON 5 (#2848)
Browse files Browse the repository at this point in the history
* MONGOID-5739 support BSON 5

* point at my personal branch to test this

* normalize values before comparing

* switch back to the official spec/shared repo

* actually bump spec/shared (why are submodules so impossible?)

* use pessimistic versioning
  • Loading branch information
jamis authored Mar 12, 2024
1 parent d332cd9 commit 0c65ebf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 1 addition & 7 deletions mongo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,5 @@ Gem::Specification.new do |s|

s.required_ruby_version = ">= 2.5"

# For testing driver against bson master we need to depend on bson < 6.0.0
# but in release version we want to depend on bson < 5.0.0.
if %w(1 yes true).include?(ENV['MONGO_RUBY_DRIVER_BSON_MASTER'])
s.add_dependency 'bson', '>=4.13.0', '<6.0.0'
else
s.add_dependency 'bson', '>=4.14.1', '<5.0.0'
end
s.add_dependency 'bson', '>=4.14.1', '<6.0.0'
end
12 changes: 10 additions & 2 deletions spec/integration/client_side_encryption/corpus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@
key_vault_collection.insert_one(kmip_data_key)
end

# This method compensates for an API change between BSON 4 and
# BSON 5.
def normalize_cse_value(a)
case a
when BSON::Decimal128 then a.to_d
else a
end
end

shared_context 'with jsonSchema collection validator' do
let(:local_schema_map) { nil }

Expand Down Expand Up @@ -228,12 +237,11 @@
.find(_id: corpus_encrypted_id)
.first


corpus_encrypted_actual.each do |key, value|
# If it was deterministically encrypted, test the encrypted values
# for equality.
if value['algo'] == 'det'
expect(value['value']).to eq(corpus_encrypted_expected[key]['value'])
expect(normalize_cse_value(value['value'])).to eq(normalize_cse_value(corpus_encrypted_expected[key]['value']))
else
# If the document was randomly encrypted, the two encrypted values
# will not be equal. Ensure that they are equal when decrypted.
Expand Down
2 changes: 1 addition & 1 deletion spec/shared

0 comments on commit 0c65ebf

Please sign in to comment.