Skip to content

Commit a9953d0

Browse files
committed
PYTHON-1940 Implement views are prohibited prose test
1 parent dc33a61 commit a9953d0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test_encryption.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,27 @@ def test_external_key_vault_2(self):
609609
self._test_external_key_vault(False)
610610

611611

612+
class TestViews(EncryptionIntegrationTest):
613+
614+
@staticmethod
615+
def kms_providers():
616+
return {'local': {'key': LOCAL_MASTER_KEY}}
617+
618+
def test_views_are_prohibited(self):
619+
self.client.db.view.drop()
620+
self.client.db.create_collection('view', viewOn='coll')
621+
self.addCleanup(self.client.db.view.drop)
622+
623+
opts = AutoEncryptionOpts(self.kms_providers(), 'admin.datakeys')
624+
client_encrypted = rs_or_single_client(
625+
auto_encryption_opts=opts, uuidRepresentation='standard')
626+
self.addCleanup(client_encrypted.close)
627+
628+
with self.assertRaisesRegex(
629+
EncryptionError, 'cannot auto encrypt a view'):
630+
client_encrypted.db.view.insert_one({})
631+
632+
612633
class TestCorpus(EncryptionIntegrationTest):
613634

614635
@classmethod

0 commit comments

Comments
 (0)