Skip to content
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
22 changes: 8 additions & 14 deletions test/asynchronous/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,13 @@ async def test_01_insert_encrypted_indexed_and_find(self):
self.assertEqual(docs[0]["encryptedIndexed"], val)

async def test_02_insert_encrypted_indexed_and_find_contention(self):
# setUp creates the collection with contention=0 (from encryptedFields.json).
# This test uses contention_factor=10, so recreate the collection with contention=10.
await self.db.drop_collection("explicit_encryption", encrypted_fields=self.encrypted_fields)
encrypted_fields = copy.deepcopy(self.encrypted_fields)
encrypted_fields["fields"][0]["queries"]["contention"] = 10
await self.db.command("create", "explicit_encryption", encryptedFields=encrypted_fields)

val = "encrypted indexed value"
contention = 10
Comment thread
aclark4life marked this conversation as resolved.
Resolved
for _ in range(contention):
Expand All @@ -2217,20 +2224,7 @@ async def test_02_insert_encrypted_indexed_and_find_contention(self):
{"encryptedIndexed": insert_payload}
)

find_payload = await self.client_encryption.encrypt(
val, Algorithm.INDEXED, self.key1_id, query_type=QueryType.EQUALITY, contention_factor=0
)
docs = (
await self.encrypted_client[self.db.name]
.explicit_encryption.find({"encryptedIndexed": find_payload})
.to_list()
)

self.assertLessEqual(len(docs), 10)
for doc in docs:
self.assertEqual(doc["encryptedIndexed"], val)

# Find with contention_factor will return all 10 documents.
# Find with matching contention_factor returns all 10 documents.
find_payload = await self.client_encryption.encrypt(
val,
Algorithm.INDEXED,
Expand Down
22 changes: 8 additions & 14 deletions test/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,13 @@ def test_01_insert_encrypted_indexed_and_find(self):
self.assertEqual(docs[0]["encryptedIndexed"], val)

def test_02_insert_encrypted_indexed_and_find_contention(self):
# setUp creates the collection with contention=0 (from encryptedFields.json).
# This test uses contention_factor=10, so recreate the collection with contention=10.
self.db.drop_collection("explicit_encryption", encrypted_fields=self.encrypted_fields)
encrypted_fields = copy.deepcopy(self.encrypted_fields)
encrypted_fields["fields"][0]["queries"]["contention"] = 10
self.db.command("create", "explicit_encryption", encryptedFields=encrypted_fields)

val = "encrypted indexed value"
contention = 10
for _ in range(contention):
Expand All @@ -2205,20 +2212,7 @@ def test_02_insert_encrypted_indexed_and_find_contention(self):
{"encryptedIndexed": insert_payload}
)

find_payload = self.client_encryption.encrypt(
val, Algorithm.INDEXED, self.key1_id, query_type=QueryType.EQUALITY, contention_factor=0
)
docs = (
self.encrypted_client[self.db.name]
.explicit_encryption.find({"encryptedIndexed": find_payload})
.to_list()
)

self.assertLessEqual(len(docs), 10)
for doc in docs:
self.assertEqual(doc["encryptedIndexed"], val)

# Find with contention_factor will return all 10 documents.
# Find with matching contention_factor returns all 10 documents.
find_payload = self.client_encryption.encrypt(
val,
Algorithm.INDEXED,
Expand Down
Loading