MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_validation

Method test_validation

test/test_encryption.py:514–528  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

512 self.assertEqual(decrypted_ssn, doc["ssn"])
513
514 def test_validation(self):
515 client_encryption = self.create_client_encryption(
516 KMS_PROVIDERS, "keyvault.datakeys", client_context.client, OPTS
517 )
518
519 msg = "value to decrypt must be a bson.binary.Binary with subtype 6"
520 with self.assertRaisesRegex(TypeError, msg):
521 client_encryption.decrypt("str") # type: ignore[arg-type]
522 with self.assertRaisesRegex(TypeError, msg):
523 client_encryption.decrypt(Binary(b"123"))
524
525 msg = "key_id must be a bson.binary.Binary with subtype 4"
526 algo = Algorithm.AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic
527 with self.assertRaisesRegex(TypeError, msg):
528 client_encryption.encrypt("str", algo, key_id=Binary(b"123"))
529
530 def test_bson_errors(self):
531 client_encryption = self.create_client_encryption(

Callers

nothing calls this directly

Calls 4

BinaryClass · 0.90
decryptMethod · 0.45
encryptMethod · 0.45

Tested by

no test coverage detected