Skip to content

Commit fa3c077

Browse files
authored
PYTHON-5882 Latest is now enforcing server-side QE (mongodb#2875)
1 parent 691dd72 commit fa3c077

2 files changed

Lines changed: 16 additions & 28 deletions

File tree

test/asynchronous/test_encryption.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,13 @@ async def test_01_insert_encrypted_indexed_and_find(self):
22072207
self.assertEqual(docs[0]["encryptedIndexed"], val)
22082208

22092209
async def test_02_insert_encrypted_indexed_and_find_contention(self):
2210+
# setUp creates the collection with contention=0 (from encryptedFields.json).
2211+
# This test uses contention_factor=10, so recreate the collection with contention=10.
2212+
await self.db.drop_collection("explicit_encryption", encrypted_fields=self.encrypted_fields)
2213+
encrypted_fields = copy.deepcopy(self.encrypted_fields)
2214+
encrypted_fields["fields"][0]["queries"]["contention"] = 10
2215+
await self.db.command("create", "explicit_encryption", encryptedFields=encrypted_fields)
2216+
22102217
val = "encrypted indexed value"
22112218
contention = 10
22122219
for _ in range(contention):
@@ -2217,20 +2224,7 @@ async def test_02_insert_encrypted_indexed_and_find_contention(self):
22172224
{"encryptedIndexed": insert_payload}
22182225
)
22192226

2220-
find_payload = await self.client_encryption.encrypt(
2221-
val, Algorithm.INDEXED, self.key1_id, query_type=QueryType.EQUALITY, contention_factor=0
2222-
)
2223-
docs = (
2224-
await self.encrypted_client[self.db.name]
2225-
.explicit_encryption.find({"encryptedIndexed": find_payload})
2226-
.to_list()
2227-
)
2228-
2229-
self.assertLessEqual(len(docs), 10)
2230-
for doc in docs:
2231-
self.assertEqual(doc["encryptedIndexed"], val)
2232-
2233-
# Find with contention_factor will return all 10 documents.
2227+
# Find with matching contention_factor returns all 10 documents.
22342228
find_payload = await self.client_encryption.encrypt(
22352229
val,
22362230
Algorithm.INDEXED,

test/test_encryption.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,6 +2195,13 @@ def test_01_insert_encrypted_indexed_and_find(self):
21952195
self.assertEqual(docs[0]["encryptedIndexed"], val)
21962196

21972197
def test_02_insert_encrypted_indexed_and_find_contention(self):
2198+
# setUp creates the collection with contention=0 (from encryptedFields.json).
2199+
# This test uses contention_factor=10, so recreate the collection with contention=10.
2200+
self.db.drop_collection("explicit_encryption", encrypted_fields=self.encrypted_fields)
2201+
encrypted_fields = copy.deepcopy(self.encrypted_fields)
2202+
encrypted_fields["fields"][0]["queries"]["contention"] = 10
2203+
self.db.command("create", "explicit_encryption", encryptedFields=encrypted_fields)
2204+
21982205
val = "encrypted indexed value"
21992206
contention = 10
22002207
for _ in range(contention):
@@ -2205,20 +2212,7 @@ def test_02_insert_encrypted_indexed_and_find_contention(self):
22052212
{"encryptedIndexed": insert_payload}
22062213
)
22072214

2208-
find_payload = self.client_encryption.encrypt(
2209-
val, Algorithm.INDEXED, self.key1_id, query_type=QueryType.EQUALITY, contention_factor=0
2210-
)
2211-
docs = (
2212-
self.encrypted_client[self.db.name]
2213-
.explicit_encryption.find({"encryptedIndexed": find_payload})
2214-
.to_list()
2215-
)
2216-
2217-
self.assertLessEqual(len(docs), 10)
2218-
for doc in docs:
2219-
self.assertEqual(doc["encryptedIndexed"], val)
2220-
2221-
# Find with contention_factor will return all 10 documents.
2215+
# Find with matching contention_factor returns all 10 documents.
22222216
find_payload = self.client_encryption.encrypt(
22232217
val,
22242218
Algorithm.INDEXED,

0 commit comments

Comments
 (0)