Skip to content

Commit 84db915

Browse files
authored
PYTHON-5361 Fix timeouts in CSE custom endpoint test (#2426)
1 parent 5ce53dc commit 84db915

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

test/asynchronous/test_encryption.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ async def asyncSetUp(self):
13061306
kms_providers_invalid = copy.deepcopy(kms_providers)
13071307
kms_providers_invalid["azure"]["identityPlatformEndpoint"] = "doesnotexist.invalid:443"
13081308
kms_providers_invalid["gcp"]["endpoint"] = "doesnotexist.invalid:443"
1309-
kms_providers_invalid["kmip"]["endpoint"] = "doesnotexist.local:5698"
1309+
kms_providers_invalid["kmip"]["endpoint"] = "doesnotexist.invalid:5698"
13101310
self.client_encryption_invalid = self.create_client_encryption(
13111311
kms_providers=kms_providers_invalid,
13121312
key_vault_namespace="keyvault.datakeys",
@@ -1364,15 +1364,10 @@ async def test_03_aws_region_key_endpoint_port(self):
13641364
},
13651365
)
13661366

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

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

14801475
async def test_12_kmip_master_key_invalid_endpoint(self):
1481-
key = {"keyId": "1", "endpoint": "doesnotexist.local:5698"}
1476+
key = {"keyId": "1", "endpoint": "doesnotexist.invalid:5698"}
14821477
with self.assertRaisesRegex(EncryptionError, self.kmip_host_error):
14831478
await self.client_encryption.create_data_key("kmip", key)
14841479

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

21682163
async def test_02_azure(self):
2169-
key = {"keyVaultEndpoint": "doesnotexist.local", "keyName": "foo"}
2164+
key = {"keyVaultEndpoint": "doesnotexist.invalid", "keyName": "foo"}
21702165
# Missing client cert error.
21712166
with self.assertRaisesRegex(EncryptionError, self.cert_error):
21722167
await self.client_encryption_no_client_cert.create_data_key("azure", key)
@@ -2241,7 +2236,7 @@ async def test_06_named_kms_providers_apply_tls_options_aws(self):
22412236
await self.client_encryption_with_names.create_data_key("aws:with_tls", key)
22422237

22432238
async def test_06_named_kms_providers_apply_tls_options_azure(self):
2244-
key = {"keyVaultEndpoint": "doesnotexist.local", "keyName": "foo"}
2239+
key = {"keyVaultEndpoint": "doesnotexist.invalid", "keyName": "foo"}
22452240
# Missing client cert error.
22462241
with self.assertRaisesRegex(EncryptionError, self.cert_error):
22472242
await self.client_encryption_with_names.create_data_key("azure:no_client_cert", key)

test/test_encryption.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ def setUp(self):
13021302
kms_providers_invalid = copy.deepcopy(kms_providers)
13031303
kms_providers_invalid["azure"]["identityPlatformEndpoint"] = "doesnotexist.invalid:443"
13041304
kms_providers_invalid["gcp"]["endpoint"] = "doesnotexist.invalid:443"
1305-
kms_providers_invalid["kmip"]["endpoint"] = "doesnotexist.local:5698"
1305+
kms_providers_invalid["kmip"]["endpoint"] = "doesnotexist.invalid:5698"
13061306
self.client_encryption_invalid = self.create_client_encryption(
13071307
kms_providers=kms_providers_invalid,
13081308
key_vault_namespace="keyvault.datakeys",
@@ -1358,15 +1358,10 @@ def test_03_aws_region_key_endpoint_port(self):
13581358
},
13591359
)
13601360

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

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

14741469
def test_12_kmip_master_key_invalid_endpoint(self):
1475-
key = {"keyId": "1", "endpoint": "doesnotexist.local:5698"}
1470+
key = {"keyId": "1", "endpoint": "doesnotexist.invalid:5698"}
14761471
with self.assertRaisesRegex(EncryptionError, self.kmip_host_error):
14771472
self.client_encryption.create_data_key("kmip", key)
14781473

@@ -2158,7 +2153,7 @@ def test_01_aws(self):
21582153
self.client_encryption_invalid_hostname.create_data_key("aws", key)
21592154

21602155
def test_02_azure(self):
2161-
key = {"keyVaultEndpoint": "doesnotexist.local", "keyName": "foo"}
2156+
key = {"keyVaultEndpoint": "doesnotexist.invalid", "keyName": "foo"}
21622157
# Missing client cert error.
21632158
with self.assertRaisesRegex(EncryptionError, self.cert_error):
21642159
self.client_encryption_no_client_cert.create_data_key("azure", key)
@@ -2233,7 +2228,7 @@ def test_06_named_kms_providers_apply_tls_options_aws(self):
22332228
self.client_encryption_with_names.create_data_key("aws:with_tls", key)
22342229

22352230
def test_06_named_kms_providers_apply_tls_options_azure(self):
2236-
key = {"keyVaultEndpoint": "doesnotexist.local", "keyName": "foo"}
2231+
key = {"keyVaultEndpoint": "doesnotexist.invalid", "keyName": "foo"}
22372232
# Missing client cert error.
22382233
with self.assertRaisesRegex(EncryptionError, self.cert_error):
22392234
self.client_encryption_with_names.create_data_key("azure:no_client_cert", key)

0 commit comments

Comments
 (0)