@@ -147,25 +147,17 @@ def test_init(self):
147
147
def test_init_spawn_args (self ):
148
148
# User can override idleShutdownTimeoutSecs
149
149
opts = AutoEncryptionOpts (
150
- {},
151
- "keyvault.datakeys" ,
152
- mongocryptd_spawn_args = ["--idleShutdownTimeoutSecs=88" ],
150
+ {}, "keyvault.datakeys" , mongocryptd_spawn_args = ["--idleShutdownTimeoutSecs=88" ]
153
151
)
154
152
self .assertEqual (opts ._mongocryptd_spawn_args , ["--idleShutdownTimeoutSecs=88" ])
155
153
156
154
# idleShutdownTimeoutSecs is added by default
157
- opts = AutoEncryptionOpts (
158
- {},
159
- "keyvault.datakeys" ,
160
- mongocryptd_spawn_args = [],
161
- )
155
+ opts = AutoEncryptionOpts ({}, "keyvault.datakeys" , mongocryptd_spawn_args = [])
162
156
self .assertEqual (opts ._mongocryptd_spawn_args , ["--idleShutdownTimeoutSecs=60" ])
163
157
164
158
# Also added when other options are given
165
159
opts = AutoEncryptionOpts (
166
- {},
167
- "keyvault.datakeys" ,
168
- mongocryptd_spawn_args = ["--quiet" , "--port=27020" ],
160
+ {}, "keyvault.datakeys" , mongocryptd_spawn_args = ["--quiet" , "--port=27020" ]
169
161
)
170
162
self .assertEqual (
171
163
opts ._mongocryptd_spawn_args ,
@@ -190,21 +182,15 @@ def test_init_kms_tls_options(self):
190
182
opts ._parse_kms_tls_options (_IS_SYNC )
191
183
with self .assertRaises (FileNotFoundError ):
192
184
opts = AutoEncryptionOpts (
193
- {},
194
- "k.d" ,
195
- kms_tls_options = {"kmip" : {"tlsCAFile" : "does-not-exist" }},
185
+ {}, "k.d" , kms_tls_options = {"kmip" : {"tlsCAFile" : "does-not-exist" }}
196
186
)
197
187
opts ._parse_kms_tls_options (_IS_SYNC )
198
188
# Success cases:
199
189
tls_opts : Any
200
190
for tls_opts in [None , {}]:
201
191
opts = AutoEncryptionOpts ({}, "k.d" , kms_tls_options = tls_opts )
202
192
self .assertEqual (opts ._kms_ssl_contexts , {})
203
- opts = AutoEncryptionOpts (
204
- {},
205
- "k.d" ,
206
- kms_tls_options = {"kmip" : {"tls" : True }, "aws" : {}},
207
- )
193
+ opts = AutoEncryptionOpts ({}, "k.d" , kms_tls_options = {"kmip" : {"tls" : True }, "aws" : {}})
208
194
opts ._parse_kms_tls_options (_IS_SYNC )
209
195
ctx = opts ._kms_ssl_contexts ["kmip" ]
210
196
self .assertEqual (ctx .check_hostname , True )
@@ -382,20 +368,13 @@ async def test_auto_encrypt(self):
382
368
await create_with_schema (self .db .test , json_schema )
383
369
self .addAsyncCleanup (self .db .test .drop )
384
370
385
- opts = AutoEncryptionOpts (
386
- KMS_PROVIDERS ,
387
- "keyvault.datakeys" ,
388
- )
371
+ opts = AutoEncryptionOpts (KMS_PROVIDERS , "keyvault.datakeys" )
389
372
await self ._test_auto_encrypt (opts )
390
373
391
374
async def test_auto_encrypt_local_schema_map (self ):
392
375
# Configure the encrypted field via the local schema_map option.
393
376
schemas = {"pymongo_test.test" : json_data ("custom" , "schema.json" )}
394
- opts = AutoEncryptionOpts (
395
- KMS_PROVIDERS ,
396
- "keyvault.datakeys" ,
397
- schema_map = schemas ,
398
- )
377
+ opts = AutoEncryptionOpts (KMS_PROVIDERS , "keyvault.datakeys" , schema_map = schemas )
399
378
400
379
await self ._test_auto_encrypt (opts )
401
380
@@ -1190,9 +1169,7 @@ async def _test_corpus(self, opts):
1190
1169
1191
1170
async def test_corpus (self ):
1192
1171
opts = AutoEncryptionOpts (
1193
- self .kms_providers (),
1194
- "keyvault.datakeys" ,
1195
- kms_tls_options = KMS_TLS_OPTS ,
1172
+ self .kms_providers (), "keyvault.datakeys" , kms_tls_options = KMS_TLS_OPTS
1196
1173
)
1197
1174
await self ._test_corpus (opts )
1198
1175
@@ -1241,10 +1218,7 @@ async def asyncSetUp(self):
1241
1218
await coll .drop ()
1242
1219
await coll .insert_one (json_data ("limits" , "limits-key.json" ))
1243
1220
1244
- opts = AutoEncryptionOpts (
1245
- {"local" : {"key" : LOCAL_MASTER_KEY }},
1246
- "keyvault.datakeys" ,
1247
- )
1221
+ opts = AutoEncryptionOpts ({"local" : {"key" : LOCAL_MASTER_KEY }}, "keyvault.datakeys" )
1248
1222
self .listener = OvertCommandListener ()
1249
1223
self .client_encrypted = await self .async_rs_or_single_client (
1250
1224
auto_encryption_opts = opts , event_listeners = [self .listener ]
@@ -1699,9 +1673,7 @@ async def test_case_1(self):
1699
1673
await self ._run_test (
1700
1674
max_pool_size = 1 ,
1701
1675
auto_encryption_opts = AutoEncryptionOpts (
1702
- * self .optargs ,
1703
- bypass_auto_encryption = False ,
1704
- key_vault_client = None ,
1676
+ * self .optargs , bypass_auto_encryption = False , key_vault_client = None
1705
1677
),
1706
1678
)
1707
1679
@@ -1722,9 +1694,7 @@ async def test_case_2(self):
1722
1694
await self ._run_test (
1723
1695
max_pool_size = 1 ,
1724
1696
auto_encryption_opts = AutoEncryptionOpts (
1725
- * self .optargs ,
1726
- bypass_auto_encryption = False ,
1727
- key_vault_client = self .client_keyvault ,
1697
+ * self .optargs , bypass_auto_encryption = False , key_vault_client = self .client_keyvault
1728
1698
),
1729
1699
)
1730
1700
@@ -1748,9 +1718,7 @@ async def test_case_3(self):
1748
1718
await self ._run_test (
1749
1719
max_pool_size = 1 ,
1750
1720
auto_encryption_opts = AutoEncryptionOpts (
1751
- * self .optargs ,
1752
- bypass_auto_encryption = True ,
1753
- key_vault_client = None ,
1721
+ * self .optargs , bypass_auto_encryption = True , key_vault_client = None
1754
1722
),
1755
1723
)
1756
1724
@@ -1767,9 +1735,7 @@ async def test_case_4(self):
1767
1735
await self ._run_test (
1768
1736
max_pool_size = 1 ,
1769
1737
auto_encryption_opts = AutoEncryptionOpts (
1770
- * self .optargs ,
1771
- bypass_auto_encryption = True ,
1772
- key_vault_client = self .client_keyvault ,
1738
+ * self .optargs , bypass_auto_encryption = True , key_vault_client = self .client_keyvault
1773
1739
),
1774
1740
)
1775
1741
@@ -1789,9 +1755,7 @@ async def test_case_5(self):
1789
1755
await self ._run_test (
1790
1756
max_pool_size = None ,
1791
1757
auto_encryption_opts = AutoEncryptionOpts (
1792
- * self .optargs ,
1793
- bypass_auto_encryption = False ,
1794
- key_vault_client = None ,
1758
+ * self .optargs , bypass_auto_encryption = False , key_vault_client = None
1795
1759
),
1796
1760
)
1797
1761
@@ -1814,9 +1778,7 @@ async def test_case_6(self):
1814
1778
await self ._run_test (
1815
1779
max_pool_size = None ,
1816
1780
auto_encryption_opts = AutoEncryptionOpts (
1817
- * self .optargs ,
1818
- bypass_auto_encryption = False ,
1819
- key_vault_client = self .client_keyvault ,
1781
+ * self .optargs , bypass_auto_encryption = False , key_vault_client = self .client_keyvault
1820
1782
),
1821
1783
)
1822
1784
@@ -1840,9 +1802,7 @@ async def test_case_7(self):
1840
1802
await self ._run_test (
1841
1803
max_pool_size = None ,
1842
1804
auto_encryption_opts = AutoEncryptionOpts (
1843
- * self .optargs ,
1844
- bypass_auto_encryption = True ,
1845
- key_vault_client = None ,
1805
+ * self .optargs , bypass_auto_encryption = True , key_vault_client = None
1846
1806
),
1847
1807
)
1848
1808
@@ -1859,9 +1819,7 @@ async def test_case_8(self):
1859
1819
await self ._run_test (
1860
1820
max_pool_size = None ,
1861
1821
auto_encryption_opts = AutoEncryptionOpts (
1862
- * self .optargs ,
1863
- bypass_auto_encryption = True ,
1864
- key_vault_client = self .client_keyvault ,
1822
+ * self .optargs , bypass_auto_encryption = True , key_vault_client = self .client_keyvault
1865
1823
),
1866
1824
)
1867
1825
@@ -1899,8 +1857,7 @@ async def asyncSetUp(self):
1899
1857
)
1900
1858
self .malformed_cipher_text = Binary (self .malformed_cipher_text , 6 )
1901
1859
opts = AutoEncryptionOpts (
1902
- key_vault_namespace = "keyvault.datakeys" ,
1903
- kms_providers = kms_providers_map ,
1860
+ key_vault_namespace = "keyvault.datakeys" , kms_providers = kms_providers_map
1904
1861
)
1905
1862
self .listener = AllowListEventListener ("aggregate" )
1906
1863
self .encrypted_client = await self .async_rs_or_single_client (
@@ -2372,9 +2329,7 @@ async def asyncSetUp(self):
2372
2329
{"local" : {"key" : LOCAL_MASTER_KEY }}, key_vault .full_name , self .key_vault_client , OPTS
2373
2330
)
2374
2331
opts = AutoEncryptionOpts (
2375
- {"local" : {"key" : LOCAL_MASTER_KEY }},
2376
- key_vault .full_name ,
2377
- bypass_query_analysis = True ,
2332
+ {"local" : {"key" : LOCAL_MASTER_KEY }}, key_vault .full_name , bypass_query_analysis = True
2378
2333
)
2379
2334
self .encrypted_client = await self .async_rs_or_single_client (auto_encryption_opts = opts )
2380
2335
@@ -2941,9 +2896,7 @@ async def AsyncMongoClient(**kwargs):
2941
2896
2942
2897
# Create an Queryable Encryption collection.
2943
2898
opts = AutoEncryptionOpts (
2944
- kms_providers_map ,
2945
- "keyvault.datakeys" ,
2946
- encrypted_fields_map = encrypted_fields_map ,
2899
+ kms_providers_map , "keyvault.datakeys" , encrypted_fields_map = encrypted_fields_map
2947
2900
)
2948
2901
encrypted_client = await AsyncMongoClient (auto_encryption_opts = opts )
2949
2902
@@ -2995,9 +2948,7 @@ async def asyncSetUp(self):
2995
2948
{"local" : {"key" : LOCAL_MASTER_KEY }}, key_vault .full_name , self .key_vault_client , OPTS
2996
2949
)
2997
2950
opts = AutoEncryptionOpts (
2998
- {"local" : {"key" : LOCAL_MASTER_KEY }},
2999
- key_vault .full_name ,
3000
- bypass_query_analysis = True ,
2951
+ {"local" : {"key" : LOCAL_MASTER_KEY }}, key_vault .full_name , bypass_query_analysis = True
3001
2952
)
3002
2953
self .encrypted_client = await self .async_rs_or_single_client (auto_encryption_opts = opts )
3003
2954
self .db = self .encrypted_client .db
0 commit comments