Skip to content
Open
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
15 changes: 6 additions & 9 deletions test/asynchronous/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -2236,6 +2236,10 @@ async def asyncSetUp(self):
await self.db.command(
"create", "explicit_encryption", encryptedFields=self.encrypted_fields
)
self.encrypted_fields_c10 = json_data("etc", "data", "encryptedFields-c10.json")
await self.db.command(
"create", "explicit_encryption_c10", encryptedFields=self.encrypted_fields_c10
)
key_vault = await create_key_vault(self.client.keyvault.datakeys, self.key1_document)
self.addCleanup(key_vault.drop)
self.key_vault_client = self.client
Expand Down Expand Up @@ -2271,20 +2275,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
for _ in range(contention):
insert_payload = await self.client_encryption.encrypt(
val, Algorithm.INDEXED, self.key1_id, contention_factor=contention
)
await self.encrypted_client[self.db.name].explicit_encryption.insert_one(
await self.encrypted_client[self.db.name].explicit_encryption_c10.insert_one(
{"encryptedIndexed": insert_payload}
)

Expand All @@ -2298,7 +2295,7 @@ async def test_02_insert_encrypted_indexed_and_find_contention(self):
)
docs = (
await self.encrypted_client[self.db.name]
.explicit_encryption.find({"encryptedIndexed": find_payload})
.explicit_encryption_c10.find({"encryptedIndexed": find_payload})
.to_list()
)

Expand Down
15 changes: 6 additions & 9 deletions test/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -2224,6 +2224,10 @@ def setUp(self):
self.db = self.client.test_queryable_encryption
self.client.drop_database(self.db)
self.db.command("create", "explicit_encryption", encryptedFields=self.encrypted_fields)
self.encrypted_fields_c10 = json_data("etc", "data", "encryptedFields-c10.json")
self.db.command(
"create", "explicit_encryption_c10", encryptedFields=self.encrypted_fields_c10
)
key_vault = create_key_vault(self.client.keyvault.datakeys, self.key1_document)
self.addCleanup(key_vault.drop)
self.key_vault_client = self.client
Expand Down Expand Up @@ -2259,20 +2263,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):
insert_payload = self.client_encryption.encrypt(
val, Algorithm.INDEXED, self.key1_id, contention_factor=contention
)
self.encrypted_client[self.db.name].explicit_encryption.insert_one(
self.encrypted_client[self.db.name].explicit_encryption_c10.insert_one(
{"encryptedIndexed": insert_payload}
)

Expand All @@ -2286,7 +2283,7 @@ def test_02_insert_encrypted_indexed_and_find_contention(self):
)
docs = (
self.encrypted_client[self.db.name]
.explicit_encryption.find({"encryptedIndexed": find_payload})
.explicit_encryption_c10.find({"encryptedIndexed": find_payload})
.to_list()
)

Expand Down
Loading