Skip to content

DRIVERS-2624 Improve prose tests checking that neither mongocryptd nor its client are created when they are not supposed to be #1415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions source/client-side-encryption/tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,14 @@ Test cases
8. Bypass Spawning mongocryptd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note::

CONSIDER: To reduce the chances of tests interfering with each other,
drivers MAY use a different port for each test in this group,
and include it in ``--pidfilepath``. The interference
may come from the fact that once spawned by a test,
``mongocryptd`` stays up and running for some time.

Via loading shared library
``````````````````````````

Expand Down Expand Up @@ -1021,19 +1029,27 @@ The following tests that loading crypt_shared_ bypasses spawning mongocryptd.
.. note::

IMPORTANT: If crypt_shared_ is visible to the operating system's library
search mechanism, the expected server error generated by these
``mongocryptdBypassSpawn`` tests will not appear because libmongocrypt will
search mechanism, the expected server error generated by the
``Via mongocryptdBypassSpawn``, ``Via bypassAutoEncryption``, ``Via bypassQueryAnalysis``
tests will not appear because libmongocrypt will
load the ``crypt_shared`` library instead of consulting mongocryptd. For
the following tests, it is required that libmongocrypt *not* load ``crypt_shared``.
Refer to the client-side-encryption document for more information on
"disabling" ``crypt_shared``.
"disabling" ``crypt_shared``. Take into account that once loaded,
for example, by another test,
``crypt_shared`` cannot be unloaded and may be used by ``MongoClient``,
thus making the tests misbehave in unexpected ways.


Via mongocryptdBypassSpawn
``````````````````````````

The following tests that setting ``mongocryptdBypassSpawn=true`` really does bypass spawning mongocryptd.

#. Insert the document `external/external-key.json <../external/external-key.json>`_ into ``keyvault.datakeys`` with majority write concern.
This step is not required to run this test, and drivers MAY skip it. But if the driver misbehaves,
then not having the encryption fully set up may complicate the process of figuring out what is wrong.

#. Create a MongoClient configured with auto encryption (referred to as ``client_encrypted``)

Configure the required options. Use the ``local`` KMS provider as follows:
Expand Down Expand Up @@ -2490,7 +2506,7 @@ The following tests that a mongocryptd client is not created when shared library
.. code:: javascript

{
"mongocryptdURI": "mongodb://localhost:27021"
"mongocryptdURI": "mongodb://localhost:27021/?serverSelectionTimeoutMS=1000"
}

#. Use ``client_encrypted`` to insert the document ``{"unencrypted": "test"}`` into ``db.coll``.
Expand Down