54
54
from test import (
55
55
unittest ,
56
56
)
57
- from test .asynchronous .test_bulk import AsyncBulkTestBase
58
- from test .asynchronous .unified_format import generate_test_classes
59
- from test .asynchronous .utils_spec_runner import AsyncSpecRunner
60
- from test .helpers import (
57
+ from test .asynchronous .helpers import (
58
+ ALL_KMS_PROVIDERS ,
61
59
AWS_CREDS ,
62
60
AZURE_CREDS ,
63
61
CA_PEM ,
64
62
CLIENT_PEM ,
63
+ DEFAULT_KMS_TLS ,
65
64
GCP_CREDS ,
66
65
KMIP_CREDS ,
67
66
LOCAL_MASTER_KEY ,
68
67
)
68
+ from test .asynchronous .test_bulk import AsyncBulkTestBase
69
+ from test .asynchronous .unified_format import generate_test_classes
70
+ from test .asynchronous .utils_spec_runner import AsyncSpecRunner
69
71
from test .utils_shared import (
70
72
AllowListEventListener ,
71
73
OvertCommandListener ,
@@ -204,7 +206,7 @@ async def test_init_kms_tls_options(self):
204
206
opts = AutoEncryptionOpts (
205
207
{},
206
208
"k.d" ,
207
- kms_tls_options = { "kmip" : { "tlsCAFile" : CA_PEM , "tlsCertificateKeyFile" : CLIENT_PEM }} ,
209
+ kms_tls_options = DEFAULT_KMS_TLS ,
208
210
)
209
211
_kms_ssl_contexts = _parse_kms_tls_options (opts ._kms_tls_options , _IS_SYNC )
210
212
ctx = _kms_ssl_contexts ["kmip" ]
@@ -626,7 +628,6 @@ async def test_with_statement(self):
626
628
"accessKeyId" : os .environ .get ("CSFLE_AWS_TEMP_ACCESS_KEY_ID" , "" ),
627
629
"secretAccessKey" : os .environ .get ("CSFLE_AWS_TEMP_SECRET_ACCESS_KEY" , "" ),
628
630
}
629
- KMS_TLS_OPTS = {"kmip" : {"tlsCAFile" : CA_PEM , "tlsCertificateKeyFile" : CLIENT_PEM }}
630
631
631
632
632
633
class AsyncTestSpec (AsyncSpecRunner ):
@@ -663,7 +664,7 @@ def parse_auto_encrypt_opts(self, opts):
663
664
self .skipTest ("GCP environment credentials are not set" )
664
665
if "kmip" in kms_providers :
665
666
kms_providers ["kmip" ] = KMIP_CREDS
666
- opts ["kms_tls_options" ] = KMS_TLS_OPTS
667
+ opts ["kms_tls_options" ] = DEFAULT_KMS_TLS
667
668
if "key_vault_namespace" not in opts :
668
669
opts ["key_vault_namespace" ] = "keyvault.datakeys"
669
670
if "extra_options" in opts :
@@ -757,14 +758,6 @@ async def run_scenario(self):
757
758
)
758
759
759
760
# Prose Tests
760
- ALL_KMS_PROVIDERS = {
761
- "aws" : AWS_CREDS ,
762
- "azure" : AZURE_CREDS ,
763
- "gcp" : GCP_CREDS ,
764
- "kmip" : KMIP_CREDS ,
765
- "local" : {"key" : LOCAL_MASTER_KEY },
766
- }
767
-
768
761
LOCAL_KEY_ID = Binary (base64 .b64decode (b"LOCALAAAAAAAAAAAAAAAAA==" ), UUID_SUBTYPE )
769
762
AWS_KEY_ID = Binary (base64 .b64decode (b"AWSAAAAAAAAAAAAAAAAAAA==" ), UUID_SUBTYPE )
770
763
AZURE_KEY_ID = Binary (base64 .b64decode (b"AZUREAAAAAAAAAAAAAAAAA==" ), UUID_SUBTYPE )
@@ -851,13 +844,17 @@ async def asyncSetUp(self):
851
844
self .KMS_PROVIDERS ,
852
845
"keyvault.datakeys" ,
853
846
schema_map = schemas ,
854
- kms_tls_options = KMS_TLS_OPTS ,
847
+ kms_tls_options = DEFAULT_KMS_TLS ,
855
848
)
856
849
self .client_encrypted = await self .async_rs_or_single_client (
857
850
auto_encryption_opts = opts , uuidRepresentation = "standard"
858
851
)
859
852
self .client_encryption = self .create_client_encryption (
860
- self .KMS_PROVIDERS , "keyvault.datakeys" , self .client , OPTS , kms_tls_options = KMS_TLS_OPTS
853
+ self .KMS_PROVIDERS ,
854
+ "keyvault.datakeys" ,
855
+ self .client ,
856
+ OPTS ,
857
+ kms_tls_options = DEFAULT_KMS_TLS ,
861
858
)
862
859
self .listener .reset ()
863
860
@@ -1066,7 +1063,7 @@ async def _test_corpus(self, opts):
1066
1063
"keyvault.datakeys" ,
1067
1064
async_client_context .client ,
1068
1065
OPTS ,
1069
- kms_tls_options = KMS_TLS_OPTS ,
1066
+ kms_tls_options = DEFAULT_KMS_TLS ,
1070
1067
)
1071
1068
1072
1069
corpus = self .fix_up_curpus (json_data ("corpus" , "corpus.json" ))
@@ -1158,7 +1155,7 @@ async def _test_corpus(self, opts):
1158
1155
1159
1156
async def test_corpus (self ):
1160
1157
opts = AutoEncryptionOpts (
1161
- self .kms_providers (), "keyvault.datakeys" , kms_tls_options = KMS_TLS_OPTS
1158
+ self .kms_providers (), "keyvault.datakeys" , kms_tls_options = DEFAULT_KMS_TLS
1162
1159
)
1163
1160
await self ._test_corpus (opts )
1164
1161
@@ -1169,7 +1166,7 @@ async def test_corpus_local_schema(self):
1169
1166
self .kms_providers (),
1170
1167
"keyvault.datakeys" ,
1171
1168
schema_map = schemas ,
1172
- kms_tls_options = KMS_TLS_OPTS ,
1169
+ kms_tls_options = DEFAULT_KMS_TLS ,
1173
1170
)
1174
1171
await self ._test_corpus (opts )
1175
1172
@@ -1300,7 +1297,7 @@ async def asyncSetUp(self):
1300
1297
key_vault_namespace = "keyvault.datakeys" ,
1301
1298
key_vault_client = async_client_context .client ,
1302
1299
codec_options = OPTS ,
1303
- kms_tls_options = KMS_TLS_OPTS ,
1300
+ kms_tls_options = DEFAULT_KMS_TLS ,
1304
1301
)
1305
1302
1306
1303
kms_providers_invalid = copy .deepcopy (kms_providers )
@@ -1312,7 +1309,7 @@ async def asyncSetUp(self):
1312
1309
key_vault_namespace = "keyvault.datakeys" ,
1313
1310
key_vault_client = async_client_context .client ,
1314
1311
codec_options = OPTS ,
1315
- kms_tls_options = KMS_TLS_OPTS ,
1312
+ kms_tls_options = DEFAULT_KMS_TLS ,
1316
1313
)
1317
1314
self ._kmip_host_error = None
1318
1315
self ._invalid_host_error = None
@@ -2752,7 +2749,7 @@ async def run_test(self, src_provider, dst_provider):
2752
2749
key_vault_client = self .client ,
2753
2750
key_vault_namespace = "keyvault.datakeys" ,
2754
2751
kms_providers = ALL_KMS_PROVIDERS ,
2755
- kms_tls_options = KMS_TLS_OPTS ,
2752
+ kms_tls_options = DEFAULT_KMS_TLS ,
2756
2753
codec_options = OPTS ,
2757
2754
)
2758
2755
@@ -2772,7 +2769,7 @@ async def run_test(self, src_provider, dst_provider):
2772
2769
key_vault_client = client2 ,
2773
2770
key_vault_namespace = "keyvault.datakeys" ,
2774
2771
kms_providers = ALL_KMS_PROVIDERS ,
2775
- kms_tls_options = KMS_TLS_OPTS ,
2772
+ kms_tls_options = DEFAULT_KMS_TLS ,
2776
2773
codec_options = OPTS ,
2777
2774
)
2778
2775
0 commit comments