Skip to content

PYTHON-4673 - Add Async Encryption Tests #1818

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 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions pymongo/asynchronous/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
_HAVE_PYMONGOCRYPT = True
except ImportError:
_HAVE_PYMONGOCRYPT = False
MongoCryptCallback = object
AsyncMongoCryptCallback = object

from bson import _dict_to_bson, decode, encode
from bson.binary import STANDARD, UUID_SUBTYPE, Binary
Expand Down Expand Up @@ -207,10 +207,10 @@ async def collection_info(

:return: The first document from the listCollections command response as BSON.
"""
async with self.client_ref()[database].list_collections(
async with await self.client_ref()[database].list_collections(
filter=RawBSONDocument(filter)
) as cursor:
for doc in cursor:
async for doc in cursor:
return _dict_to_bson(doc, False, _DATA_KEY_OPTS)
return None

Expand Down
2 changes: 1 addition & 1 deletion pymongo/asynchronous/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ async def command(
)

if client and client._encrypter and reply:
decrypted = client._encrypter.decrypt(reply.raw_command_response())
decrypted = await client._encrypter.decrypt(reply.raw_command_response())
response_doc = cast(
"_DocumentOut", _decode_all_selective(decrypted, codec_options, user_fields)[0]
)
Expand Down
2 changes: 1 addition & 1 deletion pymongo/asynchronous/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ async def run_operation(
client = operation.client # type: ignore[assignment]
if client and client._encrypter:
if use_cmd:
decrypted = client._encrypter.decrypt(reply.raw_command_response())
decrypted = await client._encrypter.decrypt(reply.raw_command_response())
docs = _decode_all_selective(decrypted, operation.codec_options, user_fields)

response: Response
Expand Down
2 changes: 1 addition & 1 deletion pymongo/synchronous/mongo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ def close(self) -> None:

if not _IS_SYNC:
# Add support for contextlib.closing.
aclose = close
close = close

def _get_topology(self) -> Topology:
"""Get the internal :class:`~pymongo.topology.Topology` object.
Expand Down
Loading
Loading