Skip to content

Commit

Permalink
remove enable_range_v2 option from MongoCryptOptions in Python bi…
Browse files Browse the repository at this point in the history
…ndings
  • Loading branch information
kevinAlbs committed Jul 12, 2024
1 parent 2076712 commit 423cefa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
3 changes: 0 additions & 3 deletions bindings/python/pymongocrypt/mongocrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ def __init__(self, options, callback):
self.__crypt = lib.mongocrypt_new()
if self.__crypt == ffi.NULL:
raise MongoCryptError("unable to create new mongocrypt object")
if options.enable_range_v2:
if not lib.mongocrypt_setopt_use_range_v2(self.__crypt):
raise MongoCryptError("unable to enable QE Range Protocol V2")

try:
self.__init()
Expand Down
6 changes: 3 additions & 3 deletions bindings/python/pymongocrypt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def __init__(
crypt_shared_lib_path=None,
crypt_shared_lib_required=False,
bypass_encryption=False,
enable_range_v2=False,
):
"""Options for :class:`MongoCrypt`.
Expand Down Expand Up @@ -54,7 +53,9 @@ def __init__(
- `crypt_shared_lib_required`: Whether to require a crypt_shared
library.
- `bypass_encryption`: Whether to bypass encryption.
- `enable_range_v2`: Whether to enable range V2.
.. versionremoved:: 1.11
Removed the ``enable_range_v2`` parameter.
.. versionadded:: 1.10
Added the ``enable_range_v2`` parameter.
Expand Down Expand Up @@ -143,7 +144,6 @@ def __init__(
self.crypt_shared_lib_path = crypt_shared_lib_path
self.crypt_shared_lib_required = crypt_shared_lib_required
self.bypass_encryption = bypass_encryption
self.enable_range_v2 = enable_range_v2


class ExplicitEncryptOpts:
Expand Down
4 changes: 1 addition & 3 deletions bindings/python/test/performance/perf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ def tearDownModule():

class TestBulkDecryption(unittest.TestCase):
def setUp(self):
opts = MongoCryptOptions(
{"local": {"key": LOCAL_MASTER_KEY}}, enable_range_v2=True
)
opts = MongoCryptOptions({"local": {"key": LOCAL_MASTER_KEY}})
callback = MockCallback(key_docs=[bson_data("keyDocument.json")])
self.mongocrypt = MongoCrypt(opts, callback)
self.encrypter = ExplicitEncrypter(callback, opts)
Expand Down
22 changes: 5 additions & 17 deletions bindings/python/test/test_mongocrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,6 @@ def test_mongocrypt_options_validation(self):
):
MongoCryptOptions(valid_kms, encrypted_fields_map={})

def test_mongocrypt_options_range(self):
opts = MongoCryptOptions({"local": {"key": b"\x00" * 96}})
self.assertFalse(opts.enable_range_v2)
opts.enable_range_v2 = True
self.assertTrue(opts.enable_range_v2)
opts = MongoCryptOptions({"local": {"key": b"\x00" * 96}}, enable_range_v2=True)
self.assertTrue(opts.enable_range_v2)


class TestMongoCrypt(unittest.TestCase):
maxDiff = None
Expand Down Expand Up @@ -381,9 +373,7 @@ def test_encrypt_encrypted_fields_map(self):
encrypted_fields_map = bson_data(
"compact/success/encrypted-field-config-map.json"
)
mc = self.create_mongocrypt(
encrypted_fields_map=encrypted_fields_map, enable_range_v2=True
)
mc = self.create_mongocrypt(encrypted_fields_map=encrypted_fields_map)
self.addCleanup(mc.close)
with mc.encryption_context("db", bson_data("compact/success/cmd.json")) as ctx:
self.assertEqual(ctx.state, lib.MONGOCRYPT_CTX_NEED_MONGO_KEYS)
Expand Down Expand Up @@ -782,8 +772,7 @@ def mongo_crypt_opts():
{
"aws": {"accessKeyId": "example", "secretAccessKey": "example"},
"local": {"key": b"\x00" * 96},
},
enable_range_v2=True,
}
)

async def _test_encrypt_decrypt(self, key_id=None, key_alt_name=None):
Expand Down Expand Up @@ -1212,13 +1201,12 @@ class TestExplicitEncryption(unittest.TestCase):
maxDiff = None

@staticmethod
def mongo_crypt_opts(enable_range_v2=True):
def mongo_crypt_opts():
return MongoCryptOptions(
{
"aws": {"accessKeyId": "example", "secretAccessKey": "example"},
"local": {"key": b"\x00" * 96},
},
enable_range_v2=enable_range_v2,
}
)

def _test_encrypt_decrypt(self, key_id=None, key_alt_name=None):
Expand Down Expand Up @@ -1435,7 +1423,7 @@ def test_rangePreview_query_int32(self):
MockCallback(
key_docs=[bson_data(key_path)], kms_reply=http_data("kms-reply.txt")
),
self.mongo_crypt_opts(enable_range_v2=False),
self.mongo_crypt_opts(),
)
self.addCleanup(encrypter.close)

Expand Down

0 comments on commit 423cefa

Please sign in to comment.