@@ -215,17 +215,15 @@ def test_GIVEN_has_mpl_WHEN_attrs_post_init_THEN_calls_no_mpl_method(
215
215
@pytest .mark .parametrize (
216
216
"kwargs, stream_type" ,
217
217
(
218
- (dict (source = b"" , materials_manager = FakeCryptoMaterialsManager ()), io .BytesIO ),
219
- (dict (source = b"" , key_provider = FakeMasterKeyProvider ()), io .BytesIO ),
220
- (dict (source = "" , materials_manager = FakeCryptoMaterialsManager ()), io .BytesIO ),
221
- (dict (source = io .BytesIO (), materials_manager = FakeCryptoMaterialsManager ()), io .BytesIO ),
222
- (dict (source = six .StringIO (), materials_manager = FakeCryptoMaterialsManager ()), six .StringIO ),
223
- (dict (source = b"" , keyring = FakeKeyring ()), io .BytesIO ),
218
+ (dict (source = b"" , materials_manager = FakeCryptoMaterialsManager ())),
219
+ (dict (source = b"" , key_provider = FakeMasterKeyProvider ())),
220
+ (dict (source = "" , materials_manager = FakeCryptoMaterialsManager ())),
221
+ (dict (source = io .BytesIO (), materials_manager = FakeCryptoMaterialsManager ())),
222
+ (dict (source = six .StringIO (), materials_manager = FakeCryptoMaterialsManager ())),
224
223
),
225
224
)
226
225
def test_client_configs_with_mpl (
227
226
kwargs ,
228
- stream_type
229
227
):
230
228
kwargs ["commitment_policy" ] = CommitmentPolicy .REQUIRE_ENCRYPT_REQUIRE_DECRYPT
231
229
@@ -250,3 +248,29 @@ def test_client_configs_with_mpl(
250
248
assert test .key_provider is not None
251
249
assert test .key_provider == kwargs ["key_provider" ]
252
250
assert isinstance (test .materials_manager , DefaultCryptoMaterialsManager )
251
+
252
+
253
+ # This needs its own test; pytest parametrize cannot use a conditionally-loaded type
254
+ @pytest .mark .skipif (not HAS_MPL , reason = "Test should only be executed with MPL in installation" )
255
+ def test_keyring_client_config_with_mpl (
256
+ ):
257
+ kwargs = {
258
+ "source" : b"" ,
259
+ "keyring" : FakeKeyring ()
260
+ }
261
+
262
+ test = _ClientConfig (** kwargs )
263
+
264
+ # In all cases, config should have a materials manager
265
+ assert test .materials_manager is not None
266
+
267
+ # If materials manager was provided, it should be directly used
268
+ if hasattr (kwargs , "materials_manager" ):
269
+ assert kwargs ["materials_manager" ] == test .materials_manager
270
+
271
+ # If MPL keyring was provided, it should be wrapped in MPL materials manager
272
+ if hasattr (kwargs , "keyring" ):
273
+ assert test .keyring is not None
274
+ assert test .keyring == kwargs ["keyring" ]
275
+ assert isinstance (test .keyring , IKeyring )
276
+ assert isinstance (test .materials_manager , CryptoMaterialsManagerFromMPL )
0 commit comments