Skip to content

PYTHON-5361 Fix timeouts in CSE custom endpoint test #2426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 14, 2025
Merged
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
21 changes: 8 additions & 13 deletions test/asynchronous/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ async def asyncSetUp(self):
kms_providers_invalid = copy.deepcopy(kms_providers)
kms_providers_invalid["azure"]["identityPlatformEndpoint"] = "doesnotexist.invalid:443"
kms_providers_invalid["gcp"]["endpoint"] = "doesnotexist.invalid:443"
kms_providers_invalid["kmip"]["endpoint"] = "doesnotexist.local:5698"
kms_providers_invalid["kmip"]["endpoint"] = "doesnotexist.invalid:5698"
self.client_encryption_invalid = self.create_client_encryption(
kms_providers=kms_providers_invalid,
key_vault_namespace="keyvault.datakeys",
Expand Down Expand Up @@ -1364,15 +1364,10 @@ async def test_03_aws_region_key_endpoint_port(self):
},
)

@unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set")
async def test_04_aws_endpoint_invalid_port(self):
master_key = {
"region": "us-east-1",
"key": ("arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0"),
"endpoint": "kms.us-east-1.amazonaws.com:12345",
}
with self.assertRaisesRegex(EncryptionError, "kms.us-east-1.amazonaws.com:12345"):
await self.client_encryption.create_data_key("aws", master_key=master_key)
async def test_04_kmip_endpoint_invalid_port(self):
master_key = {"keyId": "1", "endpoint": "localhost:12345"}
with self.assertRaisesRegex(EncryptionError, "localhost:12345"):
await self.client_encryption.create_data_key("kmip", master_key=master_key)

@unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set")
async def test_05_aws_endpoint_wrong_region(self):
Expand Down Expand Up @@ -1478,7 +1473,7 @@ async def test_11_kmip_master_key_endpoint(self):
self.assertEqual("test", await self.client_encryption_invalid.decrypt(encrypted))

async def test_12_kmip_master_key_invalid_endpoint(self):
key = {"keyId": "1", "endpoint": "doesnotexist.local:5698"}
key = {"keyId": "1", "endpoint": "doesnotexist.invalid:5698"}
with self.assertRaisesRegex(EncryptionError, self.kmip_host_error):
await self.client_encryption.create_data_key("kmip", key)

Expand Down Expand Up @@ -2166,7 +2161,7 @@ async def test_01_aws(self):
await self.client_encryption_invalid_hostname.create_data_key("aws", key)

async def test_02_azure(self):
key = {"keyVaultEndpoint": "doesnotexist.local", "keyName": "foo"}
key = {"keyVaultEndpoint": "doesnotexist.invalid", "keyName": "foo"}
# Missing client cert error.
with self.assertRaisesRegex(EncryptionError, self.cert_error):
await self.client_encryption_no_client_cert.create_data_key("azure", key)
Expand Down Expand Up @@ -2241,7 +2236,7 @@ async def test_06_named_kms_providers_apply_tls_options_aws(self):
await self.client_encryption_with_names.create_data_key("aws:with_tls", key)

async def test_06_named_kms_providers_apply_tls_options_azure(self):
key = {"keyVaultEndpoint": "doesnotexist.local", "keyName": "foo"}
key = {"keyVaultEndpoint": "doesnotexist.invalid", "keyName": "foo"}
# Missing client cert error.
with self.assertRaisesRegex(EncryptionError, self.cert_error):
await self.client_encryption_with_names.create_data_key("azure:no_client_cert", key)
Expand Down
21 changes: 8 additions & 13 deletions test/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ def setUp(self):
kms_providers_invalid = copy.deepcopy(kms_providers)
kms_providers_invalid["azure"]["identityPlatformEndpoint"] = "doesnotexist.invalid:443"
kms_providers_invalid["gcp"]["endpoint"] = "doesnotexist.invalid:443"
kms_providers_invalid["kmip"]["endpoint"] = "doesnotexist.local:5698"
kms_providers_invalid["kmip"]["endpoint"] = "doesnotexist.invalid:5698"
self.client_encryption_invalid = self.create_client_encryption(
kms_providers=kms_providers_invalid,
key_vault_namespace="keyvault.datakeys",
Expand Down Expand Up @@ -1358,15 +1358,10 @@ def test_03_aws_region_key_endpoint_port(self):
},
)

@unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set")
def test_04_aws_endpoint_invalid_port(self):
master_key = {
"region": "us-east-1",
"key": ("arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0"),
"endpoint": "kms.us-east-1.amazonaws.com:12345",
}
with self.assertRaisesRegex(EncryptionError, "kms.us-east-1.amazonaws.com:12345"):
self.client_encryption.create_data_key("aws", master_key=master_key)
def test_04_kmip_endpoint_invalid_port(self):
master_key = {"keyId": "1", "endpoint": "localhost:12345"}
with self.assertRaisesRegex(EncryptionError, "localhost:12345"):
self.client_encryption.create_data_key("kmip", master_key=master_key)

@unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set")
def test_05_aws_endpoint_wrong_region(self):
Expand Down Expand Up @@ -1472,7 +1467,7 @@ def test_11_kmip_master_key_endpoint(self):
self.assertEqual("test", self.client_encryption_invalid.decrypt(encrypted))

def test_12_kmip_master_key_invalid_endpoint(self):
key = {"keyId": "1", "endpoint": "doesnotexist.local:5698"}
key = {"keyId": "1", "endpoint": "doesnotexist.invalid:5698"}
with self.assertRaisesRegex(EncryptionError, self.kmip_host_error):
self.client_encryption.create_data_key("kmip", key)

Expand Down Expand Up @@ -2158,7 +2153,7 @@ def test_01_aws(self):
self.client_encryption_invalid_hostname.create_data_key("aws", key)

def test_02_azure(self):
key = {"keyVaultEndpoint": "doesnotexist.local", "keyName": "foo"}
key = {"keyVaultEndpoint": "doesnotexist.invalid", "keyName": "foo"}
# Missing client cert error.
with self.assertRaisesRegex(EncryptionError, self.cert_error):
self.client_encryption_no_client_cert.create_data_key("azure", key)
Expand Down Expand Up @@ -2233,7 +2228,7 @@ def test_06_named_kms_providers_apply_tls_options_aws(self):
self.client_encryption_with_names.create_data_key("aws:with_tls", key)

def test_06_named_kms_providers_apply_tls_options_azure(self):
key = {"keyVaultEndpoint": "doesnotexist.local", "keyName": "foo"}
key = {"keyVaultEndpoint": "doesnotexist.invalid", "keyName": "foo"}
# Missing client cert error.
with self.assertRaisesRegex(EncryptionError, self.cert_error):
self.client_encryption_with_names.create_data_key("azure:no_client_cert", key)
Expand Down
Loading