Skip to content

Commit 0fe26a4

Browse files
committed
try to account for crypt shared location
1 parent 43c2660 commit 0fe26a4

4 files changed

Lines changed: 20 additions & 28 deletions

File tree

.evergreen/run-tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ if test -n "$FLE"; then
213213
cd -
214214
fi
215215

216+
# work around error about trying to load a different crypt_shared lib when one
217+
# is already loaded. Note that putting the shared library in the current directory
218+
# means it will always be located, even if crypt_shared_lib_path is not set.
219+
cp ${MONGO_RUBY_DRIVER_CRYPT_SHARED_LIB_PATH} ${PROJECT_DIRECTORY}
220+
export MONGO_RUBY_DRIVER_CRYPT_SHARED_LIB_PATH=${PROJECT_DIRECTORY}/mongo_crypt_v1.so
221+
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PROJECT_DIRECTORY}
222+
216223
# Start the KMS servers first so that they are launching while we are
217224
# fetching libmongocrypt.
218225
if test "$DOCKER_PRELOAD" != 1; then
@@ -344,6 +351,7 @@ if test "$COMPRESSOR" = zstd; then
344351
add_uri_option compressors=zstd
345352
fi
346353

354+
# TEST_CMD="bundle exec rspec -f d spec/mongo/client_construction_spec.rb"
347355

348356
echo "Running tests"
349357
set +e

spec/integration/client_side_encryption/kms_tls_options_spec.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
)
1818
end
1919

20-
# 6.0 mongocrypt expects a JSON-compatible error message from the KMS, but
21-
# the mock KMS server returns an HTML error page.
22-
let(:affected_by_mock_kms_server_change) do
23-
(kms_provider == 'azure' || kms_provider == 'gcp') &&
24-
ClusterConfig.instance.server_version < '7.0'
25-
end
26-
2720
let(:client_encryption_no_client_cert) do
2821
Mongo::ClientEncryption.new(
2922
client,
@@ -320,7 +313,7 @@
320313
end
321314

322315
it 'raises KmsError directly without wrapping CryptError' do
323-
if should_raise_with_tls && !affected_by_mock_kms_server_change
316+
if should_raise_with_tls
324317
begin
325318
client_encryption_with_tls.create_data_key(
326319
kms_provider,
@@ -329,9 +322,8 @@
329322
}
330323
)
331324
rescue Mongo::Error::KmsError => exc
332-
exc.message.should =~ /Error when connecting to KMS provider|Empty KMS response/
333-
exc.message.should =~ /libmongocrypt error code/
334-
exc.message.should_not =~ /CryptError/
325+
expect(exc.message).to include('libmongocrypt error code')
326+
expect(exc.message).not_to include('CryptError')
335327
else
336328
fail 'Expected to raise KmsError'
337329
end

spec/mongo/client_construction_spec.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@
178178

179179
let(:extra_options) do
180180
{
181+
crypt_shared_lib_path: SpecConfig.instance.crypt_shared_lib_path,
182+
crypt_shared_lib_required: SpecConfig.instance.crypt_shared_lib_required,
181183
mongocryptd_uri: mongocryptd_uri,
182184
mongocryptd_bypass_spawn: mongocryptd_bypass_spawn,
183185
mongocryptd_spawn_path: mongocryptd_spawn_path,
@@ -299,7 +301,12 @@
299301
expect(encryption_options[:extra_options][:mongocryptd_spawn_path]).to eq(mongocryptd_spawn_path)
300302
expect(encryption_options[:extra_options][:mongocryptd_spawn_args]).to eq(mongocryptd_spawn_args)
301303

302-
expect(client.encrypter.mongocryptd_client.options[:monitoring_io]).to be false
304+
if (SpecConfig.instance.crypt_shared_lib_path || '').strip.length > 0
305+
expect(client.encrypter.mongocryptd_client).to be_nil
306+
else
307+
expect(client.encrypter.mongocryptd_client).not_to be_nil
308+
expect(client.encrypter.mongocryptd_client.options[:monitoring_io]).to be false
309+
end
303310
end
304311

305312
context 'with default extra options' do
@@ -1998,7 +2005,7 @@
19982005
block_client.encrypter.mongocryptd_client,
19992006
block_client.encrypter.key_vault_client,
20002007
block_client.encrypter.metadata_client
2001-
].each do |crypt_client|
2008+
].compact.each do |crypt_client|
20022009
expect(crypt_client.cluster.connected?).to be false
20032010
end
20042011
end

spec/support/crypt.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,6 @@ module Crypt
2323

2424
# For all FLE-related tests
2525
shared_context 'define shared FLE helpers' do
26-
# SERVER-118428 -- mongocryptd rejects large messages
27-
# DRIVERS-3382 -- once SERVER-118428 is fixed, remove these checks
28-
before do
29-
if extra_options[:mongocryptd_uri]
30-
version = ClusterConfig.instance.server_version
31-
bad_mongocryptd = case version
32-
when /^8\.2/ then version >= '8.2.4'
33-
when /^8\.0/ then version >= '8.0.18'
34-
when /^7\.0/ then version >= '7.0.29'
35-
else false
36-
end
37-
skip 'Bad mongocryptd version -- see DRIVERS-3382' if bad_mongocryptd
38-
end
39-
end
40-
4126
# 96-byte binary string, base64-encoded local master key
4227
let(:local_master_key_b64) do
4328
Crypt::LOCAL_MASTER_KEY_B64

0 commit comments

Comments
 (0)