Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of MongoDB Extended JSON to Mongo::Crypt::Handle #2429

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/mongo/crypt/handle.rb
Expand Up @@ -49,9 +49,21 @@ def initialize(kms_providers, kms_tls_options, options={})
Binding.method(:mongocrypt_destroy)
)

@kms_tls_options = kms_tls_options
@kms_tls_options = kms_tls_options

@schema_map =
case options[:schema_map].class
when String
begin
# Rebuild to raw JSON string as schema map implementation requires BSON variable instances
BSON::ExtJSON.parse(options[:schema_map])
rescue JSON::ParserError
nil
end
else
options[:schema_map]
end

@schema_map = options[:schema_map]
set_schema_map if @schema_map

@logger = options[:logger]
Expand Down
10 changes: 10 additions & 0 deletions spec/mongo/crypt/handle_spec.rb
Expand Up @@ -22,6 +22,16 @@
end
end

context 'with schema map in JSON string' do
let(:schema_map) do
File.read 'spec/support/crypt/schema_maps/schema_map_local.json'
end

it 'does not raise an exception' do
expect { handle }.not_to raise_error
end
end

context 'with invalid schema map' do
let(:schema_map) { '' }

Expand Down