Skip to content

Commit 33a03f2

Browse files
authored
DRIVERS-2451 add bypass spawn test with shared lib (#1342)
1 parent 77f9f66 commit 33a03f2

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

source/client-side-encryption/tests/README.rst

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,13 +971,52 @@ Test cases
971971
8. Bypass Spawning mongocryptd
972972
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
973973

974+
Via loading shared library
975+
``````````````````````````
976+
977+
The following tests that loading crypt_shared_ bypasses spawning mongocryptd.
978+
979+
.. note::
980+
981+
IMPORTANT: This test requires the crypt_shared_ library be loaded. If the crypt_shared_ library is
982+
not available, skip the test.
983+
984+
#. Create a MongoClient configured with auto encryption (referred to as ``client_encrypted``)
985+
986+
Configure the required options. Use the ``local`` KMS provider as follows:
987+
988+
.. code:: javascript
989+
990+
{ "local": { "key": <base64 decoding of LOCAL_MASTERKEY> } }
991+
992+
Configure with the ``keyVaultNamespace`` set to ``keyvault.datakeys``.
993+
994+
Configure ``client_encrypted`` to use the schema `external/external-schema.json <../external/external-schema.json>`_ for ``db.coll`` by setting a schema map like: ``{ "db.coll": <contents of external-schema.json>}``
995+
996+
Configure the following ``extraOptions``:
997+
998+
.. code:: javascript
999+
1000+
{
1001+
"mongocryptdURI": "mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000",
1002+
"mongocryptdSpawnArgs": [ "--pidfilepath=bypass-spawning-mongocryptd.pid", "--port=27021"],
1003+
"cryptSharedLibPath": "<path to shared library>",
1004+
"cryptSharedRequired": true
1005+
}
1006+
1007+
Drivers MAY pass a different port if they expect their testing infrastructure to be using port 27021. Pass a port that should be free.
1008+
1009+
#. Use ``client_encrypted`` to insert the document ``{"unencrypted": "test"}`` into ``db.coll``. Expect this to succeed.
1010+
1011+
#. Validate that mongocryptd was not spawned. Create a MongoClient to localhost:27021 (or whatever was passed via ``--port``) with serverSelectionTimeoutMS=1000. Run a handshake command and ensure it fails with a server selection timeout.
1012+
9741013
.. note::
9751014

9761015
IMPORTANT: If crypt_shared_ is visible to the operating system's library
9771016
search mechanism, the expected server error generated by these
9781017
``mongocryptdBypassSpawn`` tests will not appear because libmongocrypt will
9791018
load the ``crypt_shared`` library instead of consulting mongocryptd. For
980-
these tests, it is required that libmongocrypt *not* load ``crypt_shared``.
1019+
the following tests, it is required that libmongocrypt *not* load ``crypt_shared``.
9811020
Refer to the client-side-encryption document for more information on
9821021
"disabling" ``crypt_shared``.
9831022

0 commit comments

Comments
 (0)