@@ -1108,20 +1108,16 @@ def test_05_endpoint_invalid_host(self):
1108
1108
1109
1109
1110
1110
class AzureGCPEncryptionTestMixin (object ):
1111
+ DEK = None
1111
1112
KMS_PROVIDER_MAP = None
1112
1113
KEYVAULT_DB = 'keyvault'
1113
1114
KEYVAULT_COLL = 'datakeys'
1114
1115
1115
- def read_extjson (self , filename ):
1116
- with open (os .path .join (BASE , 'custom' , filename ), 'r' ) as fp :
1117
- return json_util .loads (fp .read (), json_options = JSON_OPTS )
1118
-
1119
- def setup_keyvault (self , DEK ):
1120
- keyvault = self .client .get_database (self .KEYVAULT_DB ).get_collection (
1121
- self .KEYVAULT_COLL , codec_options = OPTS ,
1122
- write_concern = WriteConcern ('majority' ))
1123
- keyvault .drop ()
1124
- keyvault .insert_one (DEK )
1116
+ def setUp (self ):
1117
+ keyvault = self .client .get_database (
1118
+ self .KEYVAULT_DB ).get_collection (
1119
+ self .KEYVAULT_COLL )
1120
+ create_key_vault (keyvault , self .DEK )
1125
1121
1126
1122
def _test_explicit (self , expectation ):
1127
1123
client_encryption = ClientEncryption (
@@ -1141,10 +1137,11 @@ def _test_explicit(self, expectation):
1141
1137
def _test_automatic (self , expectation_extjson , payload ):
1142
1138
encrypted_db = "db"
1143
1139
encrypted_coll = "coll"
1140
+ keyvault_namespace = '.' .join ([self .KEYVAULT_DB , self .KEYVAULT_COLL ])
1144
1141
1145
1142
encryption_opts = AutoEncryptionOpts (
1146
1143
self .KMS_PROVIDER_MAP ,
1147
- '.' . join ([ self . KEYVAULT_DB , self . KEYVAULT_COLL ]) ,
1144
+ keyvault_namespace ,
1148
1145
schema_map = self .SCHEMA_MAP )
1149
1146
1150
1147
insert_listener = WhiteListEventListener ('insert' )
@@ -1181,7 +1178,6 @@ def _test_automatic(self, expectation_extjson, payload):
1181
1178
class TestAzureEncryption (AzureGCPEncryptionTestMixin ,
1182
1179
EncryptionIntegrationTest ):
1183
1180
@classmethod
1184
- @unittest .skipUnless (_HAVE_PYMONGOCRYPT , 'pymongocrypt is not installed' )
1185
1181
@unittest .skipUnless (any (AZURE_CREDS .values ()),
1186
1182
'Azure environment credentials are not set' )
1187
1183
def setUpClass (cls ):
@@ -1190,9 +1186,6 @@ def setUpClass(cls):
1190
1186
cls .SCHEMA_MAP = json_data (BASE , 'custom' , 'azure-gcp-schema.json' )
1191
1187
super (TestAzureEncryption , cls ).setUpClass ()
1192
1188
1193
- def setUp (self ):
1194
- self .setup_keyvault (self .DEK )
1195
-
1196
1189
def test_explicit (self ):
1197
1190
return self ._test_explicit (
1198
1191
'AQLN1ERNY0XMhzj42i1hzlwC8/OSU9bHfaQRmmRF5l7d5ZpqJX13qF5zSyExo8N9c1b6uS/LoKrHNzcEMKNrkpi3jf2HiShTFRF0xi8AOD9yfw==' )
@@ -1216,7 +1209,6 @@ def test_automatic(self):
1216
1209
class TestGCPEncryption (AzureGCPEncryptionTestMixin ,
1217
1210
EncryptionIntegrationTest ):
1218
1211
@classmethod
1219
- @unittest .skipUnless (_HAVE_PYMONGOCRYPT , 'pymongocrypt is not installed' )
1220
1212
@unittest .skipUnless (any (GCP_CREDS .values ()),
1221
1213
'GCP environment credentials are not set' )
1222
1214
def setUpClass (cls ):
@@ -1225,9 +1217,6 @@ def setUpClass(cls):
1225
1217
cls .SCHEMA_MAP = json_data (BASE , 'custom' , 'azure-gcp-schema.json' )
1226
1218
super (TestGCPEncryption , cls ).setUpClass ()
1227
1219
1228
- def setUp (self ):
1229
- self .setup_keyvault (self .DEK )
1230
-
1231
1220
def test_explicit (self ):
1232
1221
return self ._test_explicit (
1233
1222
'AaLFPEi8SURzjW5fDoeaPnoCGcOFAmFOPpn5584VPJJ8iXIgml3YDxMRZD9IWv5otyoft8fBzL1LsDEp0lTeB32cV1gOj0IYeAKHhGIleuHZtA==' )
0 commit comments