spec/mongo/crypt/auto_encrypter_spec.rb in mongo-2.18.0 vs spec/mongo/crypt/auto_encrypter_spec.rb in mongo-2.18.1
- old
+ new
@@ -14,16 +14,20 @@
let(:auto_encrypter) do
described_class.new(
auto_encryption_options.merge(
client: authorized_client.use(:auto_encryption),
- # Spawn mongocryptd on non-default port for sharded cluster tests
- extra_options: extra_options
+ extra_options: auto_encrypter_extra_options
)
)
end
+ let(:auto_encrypter_extra_options) do
+ # Spawn mongocryptd on non-default port for sharded cluster tests
+ extra_options
+ end
+
let(:client) { authorized_client }
let(:db_name) { 'auto_encryption' }
let(:collection_name) { 'users' }
@@ -153,11 +157,11 @@
expect(auto_encrypter.metadata_client).not_to eq(client)
end
end
end
- context 'with schema map in auto encryption commands' do
+ shared_examples 'with schema map in auto encryption commands' do
include_context 'without jsonSchema validator'
let(:auto_encryption_options) do
{
kms_providers: kms_providers,
@@ -191,11 +195,11 @@
include_context 'with local kms_providers'
it_behaves_like 'a functioning auto encrypter'
end
end
- context 'with schema map file in auto encryption commands' do
+ shared_examples 'with schema map file in auto encryption commands' do
include_context 'without jsonSchema validator'
let(:schema_map_file) do
file = Tempfile.new('schema_map.json')
file.write(JSON.dump(
@@ -244,11 +248,11 @@
include_context 'with local kms_providers'
it_behaves_like 'a functioning auto encrypter'
end
end
- context 'with schema map collection validator' do
+ shared_examples 'with schema map collection validator' do
include_context 'with jsonSchema validator'
let(:auto_encryption_options) do
{
kms_providers: kms_providers,
@@ -300,11 +304,11 @@
include_context 'with local kms_providers'
it_behaves_like 'a functioning auto encrypter'
end
end
- context 'with no validator or client option' do
+ shared_examples 'with no validator or client option' do
include_context 'without jsonSchema validator'
let(:auto_encryption_options) do
{
kms_providers: kms_providers,
@@ -400,7 +404,38 @@
result = auto_encrypter.decrypt(encrypted_command)
expect(result).to eq(command)
end
end
end
+ end
+
+ context 'when using crypt shared library' do
+ min_server_version '6.0.0'
+
+ let(:auto_encrypter_extra_options) do
+ {
+ crypt_shared_lib_path: SpecConfig.instance.crypt_shared_lib_path
+ }
+ end
+
+ let(:auto_encryption_options) do
+ {
+ kms_providers: kms_providers,
+ kms_tls_options: kms_tls_options,
+ key_vault_namespace: key_vault_namespace,
+ schema_map: { "#{db_name}.#{collection_name}": schema_map },
+ }
+ end
+
+ it_behaves_like 'with schema map in auto encryption commands'
+ it_behaves_like 'with schema map file in auto encryption commands'
+ it_behaves_like 'with schema map collection validator'
+ it_behaves_like 'with no validator or client option'
+ end
+
+ context 'when using mongocryptd' do
+ it_behaves_like 'with schema map in auto encryption commands'
+ it_behaves_like 'with schema map file in auto encryption commands'
+ it_behaves_like 'with schema map collection validator'
+ it_behaves_like 'with no validator or client option'
end
end