From e61d130477afa02dab5459f3054d0ba9ee7df2ad Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 4 Dec 2024 09:33:47 -0600 Subject: [PATCH 1/4] PYTHON-5006 Skip test_kms_retry withn using PyOpenSSL --- test/asynchronous/test_encryption.py | 6 ++++++ test/test_encryption.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index 559b06ddf4..94af030438 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -41,6 +41,7 @@ from pymongo.asynchronous.collection import AsyncCollection from pymongo.asynchronous.helpers import anext from pymongo.daemon import _spawn_daemon +from pymongo.pyopenssl_context import IS_PYOPENSSL sys.path[0:0] = [""] @@ -2860,6 +2861,7 @@ class TestKmsRetryProse(AsyncEncryptionIntegrationTest): @unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set") async def asyncSetUp(self): await super().asyncSetUp() + # 1, create client with only tlsCAFile. providers: dict = copy.deepcopy(ALL_KMS_PROVIDERS) providers["azure"]["identityPlatformEndpoint"] = "127.0.0.1:9003" @@ -2921,6 +2923,10 @@ async def _test(self, provider, master_key): await self.client_encryption.create_data_key(provider, master_key=master_key) async def test_kms_retry(self): + if IS_PYOPENSSL: + self.skipTest( + "PyOpenSSL does not support a required method for this test, Connection.makefile" + ) await self._test("aws", {"region": "foo", "key": "bar", "endpoint": "127.0.0.1:9003"}) await self._test("azure", {"keyVaultEndpoint": "127.0.0.1:9003", "keyName": "foo"}) await self._test( diff --git a/test/test_encryption.py b/test/test_encryption.py index 7a9929b7fd..61e178cbd0 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -39,6 +39,7 @@ import pytest from pymongo.daemon import _spawn_daemon +from pymongo.pyopenssl_context import IS_PYOPENSSL from pymongo.synchronous.collection import Collection from pymongo.synchronous.helpers import next @@ -2842,6 +2843,7 @@ class TestKmsRetryProse(EncryptionIntegrationTest): @unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set") def setUp(self): super().setUp() + # 1, create client with only tlsCAFile. providers: dict = copy.deepcopy(ALL_KMS_PROVIDERS) providers["azure"]["identityPlatformEndpoint"] = "127.0.0.1:9003" @@ -2903,6 +2905,10 @@ def _test(self, provider, master_key): self.client_encryption.create_data_key(provider, master_key=master_key) def test_kms_retry(self): + if IS_PYOPENSSL: + self.skipTest( + "PyOpenSSL does not support a required method for this test, Connection.makefile" + ) self._test("aws", {"region": "foo", "key": "bar", "endpoint": "127.0.0.1:9003"}) self._test("azure", {"keyVaultEndpoint": "127.0.0.1:9003", "keyName": "foo"}) self._test( From ba76e7b88c9bc3e6e3b45cc2ebe09eaf132dcbe8 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 4 Dec 2024 09:51:14 -0600 Subject: [PATCH 2/4] address comment --- test/asynchronous/test_encryption.py | 1 - test/test_encryption.py | 1 - 2 files changed, 2 deletions(-) diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index 94af030438..a7e2a3fcb5 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -2861,7 +2861,6 @@ class TestKmsRetryProse(AsyncEncryptionIntegrationTest): @unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set") async def asyncSetUp(self): await super().asyncSetUp() - # 1, create client with only tlsCAFile. providers: dict = copy.deepcopy(ALL_KMS_PROVIDERS) providers["azure"]["identityPlatformEndpoint"] = "127.0.0.1:9003" diff --git a/test/test_encryption.py b/test/test_encryption.py index 61e178cbd0..aea0c131c9 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -2843,7 +2843,6 @@ class TestKmsRetryProse(EncryptionIntegrationTest): @unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set") def setUp(self): super().setUp() - # 1, create client with only tlsCAFile. providers: dict = copy.deepcopy(ALL_KMS_PROVIDERS) providers["azure"]["identityPlatformEndpoint"] = "127.0.0.1:9003" From 1449f5d5e509e148124f8e42b0778d8d866f091b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 4 Dec 2024 09:59:07 -0600 Subject: [PATCH 3/4] fix check --- test/asynchronous/test_encryption.py | 4 ++-- test/test_encryption.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index a7e2a3fcb5..a35b344745 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -41,7 +41,7 @@ from pymongo.asynchronous.collection import AsyncCollection from pymongo.asynchronous.helpers import anext from pymongo.daemon import _spawn_daemon -from pymongo.pyopenssl_context import IS_PYOPENSSL +from pymongo.ssl_context import _ssl sys.path[0:0] = [""] @@ -2922,7 +2922,7 @@ async def _test(self, provider, master_key): await self.client_encryption.create_data_key(provider, master_key=master_key) async def test_kms_retry(self): - if IS_PYOPENSSL: + if _ssl.IS_PYOPENSSL: self.skipTest( "PyOpenSSL does not support a required method for this test, Connection.makefile" ) diff --git a/test/test_encryption.py b/test/test_encryption.py index aea0c131c9..8bc793dd65 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -39,7 +39,7 @@ import pytest from pymongo.daemon import _spawn_daemon -from pymongo.pyopenssl_context import IS_PYOPENSSL +from pymongo.ssl_context import _ssl from pymongo.synchronous.collection import Collection from pymongo.synchronous.helpers import next @@ -2904,7 +2904,7 @@ def _test(self, provider, master_key): self.client_encryption.create_data_key(provider, master_key=master_key) def test_kms_retry(self): - if IS_PYOPENSSL: + if _ssl.IS_PYOPENSSL: self.skipTest( "PyOpenSSL does not support a required method for this test, Connection.makefile" ) From a40f49722faf7bd27ae0b49a05bb786c4ad759b0 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 4 Dec 2024 10:16:11 -0600 Subject: [PATCH 4/4] fix check --- test/asynchronous/test_encryption.py | 8 ++++++-- test/test_encryption.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index a35b344745..48f791ac16 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -41,7 +41,11 @@ from pymongo.asynchronous.collection import AsyncCollection from pymongo.asynchronous.helpers import anext from pymongo.daemon import _spawn_daemon -from pymongo.ssl_context import _ssl + +try: + from pymongo.pyopenssl_context import IS_PYOPENSSL +except ImportError: + IS_PYOPENSSL = False sys.path[0:0] = [""] @@ -2922,7 +2926,7 @@ async def _test(self, provider, master_key): await self.client_encryption.create_data_key(provider, master_key=master_key) async def test_kms_retry(self): - if _ssl.IS_PYOPENSSL: + if IS_PYOPENSSL: self.skipTest( "PyOpenSSL does not support a required method for this test, Connection.makefile" ) diff --git a/test/test_encryption.py b/test/test_encryption.py index 8bc793dd65..daa5fd5d4c 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -39,10 +39,14 @@ import pytest from pymongo.daemon import _spawn_daemon -from pymongo.ssl_context import _ssl from pymongo.synchronous.collection import Collection from pymongo.synchronous.helpers import next +try: + from pymongo.pyopenssl_context import IS_PYOPENSSL +except ImportError: + IS_PYOPENSSL = False + sys.path[0:0] = [""] from test import ( @@ -2904,7 +2908,7 @@ def _test(self, provider, master_key): self.client_encryption.create_data_key(provider, master_key=master_key) def test_kms_retry(self): - if _ssl.IS_PYOPENSSL: + if IS_PYOPENSSL: self.skipTest( "PyOpenSSL does not support a required method for this test, Connection.makefile" )