Skip to content

Commit 7469195

Browse files
authored
PHPC-2131: Ensure CRYPT_SHARED_LIB_PATH is exported for tests (#1352)
This also fixes the injection logic in create_test_manager(), which should only kick in when "autoEncryption" opts are specified (as PHPLIB does) and check for a valid $driverOptions structure (to accomodate manager-ctor error tests).
1 parent e9bab1e commit 7469195

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ functions:
388388
working_dir: "src"
389389
script: |
390390
${PREPARE_SHELL}
391+
export CRYPT_SHARED_LIB_PATH="${client_side_encryption_crypt_shared_lib_path}"
391392
API_VERSION=${API_VERSION} TESTS=${TESTS} SSL=${SSL} MONGODB_URI="${MONGODB_URI}${APPEND_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
392393
393394
"cleanup":
@@ -605,8 +606,6 @@ tasks:
605606
TOPOLOGY: "replica_set"
606607
- func: "fetch crypt_shared"
607608
- func: "run tests"
608-
vars:
609-
CRYPT_SHARED_LIB_PATH: "${client_side_encryption_crypt_shared_lib_path}"
610609

611610
- name: "test-loadBalanced"
612611
tags: ["loadbalanced"]

tests/utils/tools.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ function create_test_manager(string $uri = null, array $options = [], array $dri
9898
$driverOptions['serverApi'] = new ServerApi(getenv('API_VERSION'));
9999
}
100100

101-
if (getenv('CRYPT_SHARED_LIB_PATH') && ! isset($driverOptions['autoEncryption']['extraOptions']['cryptSharedLibPath'])) {
102-
$driverOptions['autoEncryption']['extraOptions']['cryptSharedLibPath'] = getenv('CRYPT_SHARED_LIB_PATH');
101+
if (getenv('CRYPT_SHARED_LIB_PATH') && isset($driverOptions['autoEncryption'])) {
102+
if (is_array($driverOptions['autoEncryption']) &&
103+
(! isset($driverOptions['autoEncryption']['extraOptions']) || is_array($driverOptions['autoEncryption']['extraOptions'])) &&
104+
! isset($driverOptions['autoEncryption']['extraOptions']['cryptSharedLibPath'])) {
105+
$driverOptions['autoEncryption']['extraOptions']['cryptSharedLibPath'] = getenv('CRYPT_SHARED_LIB_PATH');
106+
}
103107
}
104108

105109
return new Manager($uri ?? URI, $options, $driverOptions);

0 commit comments

Comments
 (0)