@@ -365,143 +365,7 @@ def test_GIVEN_verification_key_AND_has_mpl_AND_has_MPLCMM_WHEN_read_header_THEN
365
365
algorithm = self .mock_header .algorithm , encoded_point = mock_b64encoding ()
366
366
)
367
367
368
- @patch ("aws_encryption_sdk.streaming_client.derive_data_encryption_key" )
369
- @patch ("aws_encryption_sdk.streaming_client.DecryptionMaterialsRequest" )
370
- @patch ("aws_encryption_sdk.streaming_client.Verifier" )
371
- # Given: no MPL
372
- @pytest .mark .skipif (HAS_MPL , reason = "Test should only be executed without MPL in installation" )
373
- def test_GIVEN_decrypt_config_has_ec_WHEN_read_header_THEN_calls_decrypt_materials_with_reproduced_ec (
374
- self ,
375
- mock_verifier ,
376
- mock_decrypt_materials_request ,
377
- * _ ,
378
- ):
379
-
380
- mock_verifier_instance = MagicMock ()
381
- mock_verifier .from_key_bytes .return_value = mock_verifier_instance
382
- ct_stream = io .BytesIO (VALUES ["data_128" ])
383
- mock_commitment_policy = MagicMock (__class__ = CommitmentPolicy )
384
- test_decryptor = StreamDecryptor (
385
- materials_manager = self .mock_materials_manager ,
386
- source = ct_stream ,
387
- commitment_policy = mock_commitment_policy ,
388
- )
389
- test_decryptor .source_stream = ct_stream
390
- test_decryptor ._stream_length = len (VALUES ["data_128" ])
391
- # Given: self.config has "encryption_context"
392
- any_reproduced_ec = {"some" : "ec" }
393
- test_decryptor .config .encryption_context = any_reproduced_ec
394
-
395
- # When: read header
396
- test_decryptor ._read_header ()
397
-
398
- # Then: calls decrypt_materials with reproduced_encryption_context
399
- mock_decrypt_materials_request .assert_called_once_with (
400
- encrypted_data_keys = self .mock_header .encrypted_data_keys ,
401
- algorithm = self .mock_header .algorithm ,
402
- encryption_context = sentinel .encryption_context ,
403
- commitment_policy = mock_commitment_policy ,
404
- reproduced_encryption_context = any_reproduced_ec ,
405
- )
406
-
407
- @patch ("aws_encryption_sdk.streaming_client.DecryptionMaterialsRequest" )
408
- @patch ("aws_encryption_sdk.streaming_client.derive_data_encryption_key" )
409
- @patch ("aws_encryption_sdk.streaming_client.Verifier" )
410
- # Given: no MPL
411
- @pytest .mark .skipif (HAS_MPL , reason = "Test should only be executed without MPL in installation" )
412
- def test_GIVEN_verification_key_AND_no_mpl_WHEN_read_header_THEN_calls_from_key_bytes (
413
- self ,
414
- mock_verifier ,
415
- * _ ,
416
- ):
417
- # Given: verification key
418
- mock_verifier_instance = MagicMock ()
419
- mock_verifier .from_key_bytes .return_value = mock_verifier_instance
420
- ct_stream = io .BytesIO (VALUES ["data_128" ])
421
- mock_commitment_policy = MagicMock (__class__ = CommitmentPolicy )
422
- test_decryptor = StreamDecryptor (
423
- materials_manager = self .mock_materials_manager ,
424
- source = ct_stream ,
425
- commitment_policy = mock_commitment_policy ,
426
- )
427
- test_decryptor .source_stream = ct_stream
428
- test_decryptor ._stream_length = len (VALUES ["data_128" ])
429
-
430
- # When: read header
431
- test_decryptor ._read_header ()
432
-
433
- # Then: calls from_key_bytes
434
- mock_verifier .from_key_bytes .assert_called_once_with (
435
- algorithm = self .mock_header .algorithm , key_bytes = sentinel .verification_key
436
- )
437
-
438
- @patch ("aws_encryption_sdk.streaming_client.DecryptionMaterialsRequest" )
439
- @patch ("aws_encryption_sdk.streaming_client.derive_data_encryption_key" )
440
- @patch ("aws_encryption_sdk.streaming_client.Verifier" )
441
- # Given: has MPL
442
- @pytest .mark .skipif (not HAS_MPL , reason = "Test should only be executed with MPL in installation" )
443
- def test_GIVEN_verification_key_AND_has_mpl_AND_not_MPLCMM_WHEN_read_header_THEN_calls_from_key_bytes (
444
- self ,
445
- mock_verifier ,
446
- * _ ,
447
- ):
448
- # Given: verification key
449
- mock_verifier_instance = MagicMock ()
450
- mock_verifier .from_key_bytes .return_value = mock_verifier_instance
451
- ct_stream = io .BytesIO (VALUES ["data_128" ])
452
- mock_commitment_policy = MagicMock (__class__ = CommitmentPolicy )
453
- test_decryptor = StreamDecryptor (
454
- # Given: native CMM
455
- materials_manager = self .mock_materials_manager ,
456
- source = ct_stream ,
457
- commitment_policy = mock_commitment_policy ,
458
- )
459
- test_decryptor .source_stream = ct_stream
460
- test_decryptor ._stream_length = len (VALUES ["data_128" ])
461
-
462
- # When: read_header
463
- test_decryptor ._read_header ()
464
-
465
- # Then: calls from_key_bytess
466
- mock_verifier .from_key_bytes .assert_called_once_with (
467
- algorithm = self .mock_header .algorithm , key_bytes = sentinel .verification_key
468
- )
469
-
470
- @patch ("aws_encryption_sdk.streaming_client.DecryptionMaterialsRequest" )
471
- @patch ("aws_encryption_sdk.streaming_client.derive_data_encryption_key" )
472
- @patch ("aws_encryption_sdk.streaming_client.Verifier" )
473
- @patch ("base64.b64encode" )
474
- # Given: has MPL
475
- @pytest .mark .skipif (not HAS_MPL , reason = "Test should only be executed with MPL in installation" )
476
- def test_GIVEN_verification_key_AND_has_mpl_AND_has_MPLCMM_WHEN_read_header_THEN_calls_from_encoded_point (
477
- self ,
478
- mock_b64encoding ,
479
- mock_verifier ,
480
- * _ ,
481
- ):
482
- # Given: Verification key
483
- mock_verifier_instance = MagicMock ()
484
- mock_verifier .from_key_bytes .return_value = mock_verifier_instance
485
- ct_stream = io .BytesIO (VALUES ["data_128" ])
486
- mock_commitment_policy = MagicMock (__class__ = CommitmentPolicy )
487
- test_decryptor = StreamDecryptor (
488
- # Given: MPL CMM
489
- materials_manager = self .mock_mpl_materials_manager ,
490
- source = ct_stream ,
491
- commitment_policy = mock_commitment_policy ,
492
- )
493
- test_decryptor .source_stream = ct_stream
494
- test_decryptor ._stream_length = len (VALUES ["data_128" ])
495
-
496
- # When: read header
497
- test_decryptor ._read_header ()
498
-
499
- # Then: calls from_encoded_point
500
- mock_verifier .from_encoded_point .assert_called_once_with (
501
- algorithm = self .mock_header .algorithm , encoded_point = mock_b64encoding ()
502
- )
503
-
504
- @patch ("aws_encryption_sdk.streaming_client.derive_data_encryption_key" )
368
+ @patch ("aws_encryption_sdk.streaming_client.derive_data_encryption_key" )
505
369
def test_read_header_frame_too_large (self , mock_derive_datakey ):
506
370
self .mock_header .content_type = ContentType .FRAMED_DATA
507
371
self .mock_header .frame_length = 1024
0 commit comments