Skip to content

Commit cf08d46

Browse files
authored
PYTHON-3277 Rename csfle library to crypt_shared (#956)
1 parent 62a6302 commit cf08d46

File tree

5 files changed

+42
-41
lines changed

5 files changed

+42
-41
lines changed

.evergreen/config.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ functions:
450450
export LIBMONGOCRYPT_URL="${libmongocrypt_url}"
451451
export TEST_ENCRYPTION=1
452452
fi
453-
if [ -n "${test_csfle}" ]; then
454-
export TEST_CSFLE=1
453+
if [ -n "${test_crypt_shared}" ]; then
454+
export TEST_CRYPT_SHARED=1
455455
fi
456456
if [ -n "${test_pyopenssl}" ]; then
457457
export TEST_PYOPENSSL=1
@@ -2163,15 +2163,14 @@ axes:
21632163
variables:
21642164
test_encryption: true
21652165
batchtime: 10080 # 7 days
2166-
- id: "encryption_with_csfle"
2167-
display_name: "Encryption with CSFLE"
2168-
tags: ["encryption_tag", "csfle"]
2166+
- id: "encryption_crypt_shared"
2167+
display_name: "Encryption shared lib"
2168+
tags: ["encryption_tag"]
21692169
variables:
21702170
test_encryption: true
2171-
test_csfle: true
2171+
test_crypt_shared: true
21722172
batchtime: 10080 # 7 days
21732173

2174-
21752174
# Run pyopenssl tests?
21762175
- id: pyopenssl
21772176
display_name: "PyOpenSSL"
@@ -2306,7 +2305,7 @@ buildvariants:
23062305
platform: "*"
23072306
auth: "*"
23082307
ssl: "*"
2309-
encryption: [ "encryption_with_csfle" ]
2308+
encryption: [ "encryption_crypt_shared" ]
23102309
then:
23112310
remove_tasks:
23122311
- ".5.0"
@@ -2400,7 +2399,7 @@ buildvariants:
24002399
platform: "*"
24012400
python-version: "*"
24022401
auth-ssl: "*"
2403-
encryption: [ "encryption_with_csfle" ]
2402+
encryption: [ "encryption_crypt_shared" ]
24042403
then:
24052404
remove_tasks:
24062405
- ".5.0"
@@ -2509,7 +2508,7 @@ buildvariants:
25092508
platform: "*"
25102509
python-version-windows: "*"
25112510
auth-ssl: "*"
2512-
encryption: [ "encryption_with_csfle" ]
2511+
encryption: [ "encryption_crypt_shared" ]
25132512
then:
25142513
remove_tasks:
25152514
- ".5.0"

.evergreen/run-tests.sh

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -o errexit # Exit the script with error if any of the commands fail
1111
# COVERAGE If non-empty, run the test suite with coverage.
1212
# TEST_ENCRYPTION If non-empty, install pymongocrypt.
1313
# LIBMONGOCRYPT_URL The URL to download libmongocrypt.
14-
# TEST_CSFLE If non-empty, install CSFLE
14+
# TEST_CRYPT_SHARED If non-empty, install crypt_shared lib.
1515

1616
if [ -n "${SET_XTRACE_ON}" ]; then
1717
set -o xtrace
@@ -28,9 +28,10 @@ COVERAGE=${COVERAGE:-}
2828
COMPRESSORS=${COMPRESSORS:-}
2929
MONGODB_API_VERSION=${MONGODB_API_VERSION:-}
3030
TEST_ENCRYPTION=${TEST_ENCRYPTION:-}
31-
TEST_CSFLE=${TEST_CSFLE:-}
31+
TEST_CRYPT_SHARED=${TEST_CRYPT_SHARED:-}
3232
LIBMONGOCRYPT_URL=${LIBMONGOCRYPT_URL:-}
3333
DATA_LAKE=${DATA_LAKE:-}
34+
TEST_ARGS=""
3435

3536
if [ -n "$COMPRESSORS" ]; then
3637
export COMPRESSORS=$COMPRESSORS
@@ -148,23 +149,23 @@ if [ -n "$TEST_ENCRYPTION" ]; then
148149
# Get access to the AWS temporary credentials:
149150
# CSFLE_AWS_TEMP_ACCESS_KEY_ID, CSFLE_AWS_TEMP_SECRET_ACCESS_KEY, CSFLE_AWS_TEMP_SESSION_TOKEN
150151
. $DRIVERS_TOOLS/.evergreen/csfle/set-temp-creds.sh
152+
153+
if [ -n "$TEST_CRYPT_SHARED" ]; then
154+
echo "Testing CSFLE with crypt_shared lib"
155+
$PYTHON $DRIVERS_TOOLS/.evergreen/mongodl.py --component crypt_shared \
156+
--version latest --out ../crypt_shared/
157+
export DYLD_FALLBACK_LIBRARY_PATH=../crypt_shared/lib/:$DYLD_FALLBACK_LIBRARY_PATH
158+
export LD_LIBRARY_PATH=../crypt_shared/lib:$LD_LIBRARY_PATH
159+
export PATH=../crypt_shared/bin:$PATH
160+
fi
161+
# Only run the encryption tests.
162+
TEST_ARGS="-s test.test_encryption"
151163
fi
152164

153-
if [ -z "$DATA_LAKE" ]; then
154-
TEST_ARGS=""
155-
else
165+
if [ -n "$DATA_LAKE" ]; then
156166
TEST_ARGS="-s test.test_data_lake"
157167
fi
158-
if [ -z $TEST_CSFLE ]; then
159-
echo "CSFLE not being tested"
160-
else
161-
$PYTHON $DRIVERS_TOOLS/.evergreen/mongodl.py --component csfle \
162-
--version latest --out ../csfle/
163-
export DYLD_FALLBACK_LIBRARY_PATH=../csfle/lib/:$DYLD_FALLBACK_LIBRARY_PATH
164-
export LD_LIBRARY_PATH=../csfle/lib:$LD_LIBRARY_PATH
165-
export PATH=../csfle/bin:$PATH
166-
TEST_ARGS="-s test.test_encryption"
167-
fi
168+
168169
# Don't download unittest-xml-reporting from pypi, which often fails.
169170
if $PYTHON -c "import xmlrunner"; then
170171
# The xunit output dir must be a Python style absolute path.

pymongo/encryption.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ def _get_internal_client(encrypter, mongo_client):
300300
MongoCryptOptions(
301301
opts._kms_providers,
302302
schema_map,
303-
csfle_path=opts._csfle_path,
304-
csfle_required=opts._csfle_required,
303+
crypt_shared_lib_path=opts._crypt_shared_lib_path,
304+
crypt_shared_lib_required=opts._crypt_shared_lib_required,
305305
bypass_encryption=opts._bypass_auto_encryption,
306306
),
307307
)

pymongo/encryption_options.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def __init__(
4545
mongocryptd_spawn_path: str = "mongocryptd",
4646
mongocryptd_spawn_args: Optional[List[str]] = None,
4747
kms_tls_options: Optional[Mapping[str, Any]] = None,
48-
csfle_path: Optional[str] = None,
49-
csfle_required: bool = False,
48+
crypt_shared_lib_path: Optional[str] = None,
49+
crypt_shared_lib_required: bool = False,
5050
) -> None:
5151
"""Options to configure automatic client-side field level encryption.
5252
@@ -142,12 +142,12 @@ def __init__(
142142
Or to supply a client certificate::
143143
144144
kms_tls_options={'kmip': {'tlsCertificateKeyFile': 'client.pem'}}
145-
- `csfle_path` (optional): Override the path to load the CSFLE library.
146-
- `csfle_required` (optional): If 'true', refuse to continue encryption without a CSFLE
147-
library
145+
- `crypt_shared_lib_path` (optional): Override the path to load the crypt_shared library.
146+
- `crypt_shared_lib_required` (optional): If True, raise an error if libmongocrypt is
147+
unable to load the crypt_shared library.
148148
149149
.. versionchanged:: 4.2
150-
Added `csfle_path` and `csfle_required` parameters
150+
Added `crypt_shared_lib_path` and `crypt_shared_lib_required` parameters
151151
152152
.. versionchanged:: 4.0
153153
Added the `kms_tls_options` parameter and the "kmip" KMS provider.
@@ -160,8 +160,8 @@ def __init__(
160160
"install a compatible version with: "
161161
"python -m pip install 'pymongo[encryption]'"
162162
)
163-
self._csfle_path = csfle_path
164-
self._csfle_required = csfle_required
163+
self._crypt_shared_lib_path = crypt_shared_lib_path
164+
self._crypt_shared_lib_required = crypt_shared_lib_required
165165
self._kms_providers = kms_providers
166166
self._key_vault_namespace = key_vault_namespace
167167
self._key_vault_client = key_vault_client

test/test_encryption.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def get_client_opts(client):
8383

8484
class TestAutoEncryptionOpts(PyMongoTestCase):
8585
@unittest.skipUnless(_HAVE_PYMONGOCRYPT, "pymongocrypt is not installed")
86-
@unittest.skipUnless(os.environ.get("TEST_CSFLE"), "csfle is not installed")
87-
def test_csfle(self):
88-
# Test that we can pick up csfle automatically
86+
@unittest.skipUnless(os.environ.get("TEST_CRYPT_SHARED"), "crypt_shared lib is not installed")
87+
def test_crypt_shared(self):
88+
# Test that we can pick up crypt_shared lib automatically
8989
client = MongoClient(
9090
auto_encryption_opts=AutoEncryptionOpts(
91-
KMS_PROVIDERS, "keyvault.datakeys", csfle_required=True
91+
KMS_PROVIDERS, "keyvault.datakeys", crypt_shared_lib_required=True
9292
),
9393
connect=False,
9494
)
@@ -1762,8 +1762,9 @@ def test_case_8(self):
17621762
# https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#bypass-spawning-mongocryptd
17631763
class TestBypassSpawningMongocryptdProse(EncryptionIntegrationTest):
17641764
@unittest.skipIf(
1765-
os.environ.get("TEST_CSFLE"),
1766-
"this prose test does not work when CSFLE is on a system dynamic library search path.",
1765+
os.environ.get("TEST_CRYPT_SHARED"),
1766+
"this prose test does not work when crypt_shared is on a system dynamic "
1767+
"library search path.",
17671768
)
17681769
def test_mongocryptd_bypass_spawn(self):
17691770
# Lower the mongocryptd timeout to reduce the test run time.

0 commit comments

Comments
 (0)