11
11
# ANY KIND, either express or implied. See the License for the specific
12
12
# language governing permissions and limitations under the License.
13
13
"""Unit test suite for aws_encryption_sdk.streaming_client.StreamEncryptor"""
14
+ # noqa pylint: disable=too-many-lines
14
15
import io
15
16
16
17
import pytest
@@ -453,7 +454,9 @@ def test_GIVEN_has_mpl_AND_has_MPLCMM_AND_uses_signer_WHEN_prep_message_THEN_sig
453
454
454
455
# Given: has MPL
455
456
@pytest .mark .skipif (not HAS_MPL , reason = "Test should only be executed with MPL in installation" )
456
- def test_GIVEN_has_mpl_AND_encryption_materials_has_required_EC_keys_WHEN_prep_message_THEN_paritions_stored_and_required_EC (self ):
457
+ def test_GIVEN_has_mpl_AND_encryption_materials_has_required_EC_keys_WHEN_prep_message_THEN_paritions_stored_and_required_EC ( # noqa pylint: disable=line-too-long
458
+ self
459
+ ):
457
460
# Create explicit values to explicitly test logic in smaller cases
458
461
required_encryption_context_keys_values = [
459
462
# Case of empty encryption context list is not allowed;
@@ -492,7 +495,7 @@ def test_GIVEN_has_mpl_AND_encryption_materials_has_required_EC_keys_WHEN_prep_m
492
495
# Given: encryption context has required_encryption_context_keys
493
496
self .mock_encryption_materials .required_encryption_context_keys = \
494
497
required_encryption_context_keys
495
-
498
+
496
499
for encryption_context in encryption_context_values :
497
500
self .mock_encryption_materials .encryption_context = encryption_context
498
501
@@ -514,6 +517,7 @@ def test_GIVEN_has_mpl_AND_encryption_materials_has_required_EC_keys_WHEN_prep_m
514
517
if k in required_encryption_context_keys :
515
518
# 1) Its EC is in the StreamEncryptor._required_encryption_context
516
519
assert k in test_encryptor ._required_encryption_context
520
+ assert test_encryptor ._required_encryption_context [k ] == encryption_context [k ]
517
521
# 2) Its EC is NOT in the StreamEncryptor._stored_encryption_context
518
522
assert k not in test_encryptor ._stored_encryption_context
519
523
# If a key is NOT in required_encryption_context_keys, then
@@ -522,16 +526,19 @@ def test_GIVEN_has_mpl_AND_encryption_materials_has_required_EC_keys_WHEN_prep_m
522
526
assert k not in test_encryptor ._required_encryption_context
523
527
# 2) Its EC is in the StreamEncryptor._stored_encryption_context
524
528
assert k in test_encryptor ._stored_encryption_context
525
-
529
+ assert test_encryptor ._stored_encryption_context [k ] == encryption_context [k ]
530
+
526
531
# Assert size(stored_EC) + size(required_EC) == size(EC)
527
532
# (i.e. every EC was sorted into one or the other)
528
533
assert len (test_encryptor ._required_encryption_context ) \
529
534
+ len (test_encryptor ._stored_encryption_context ) \
530
535
== len (encryption_context )
531
-
536
+
532
537
# Given: has MPL
533
538
@pytest .mark .skipif (not HAS_MPL , reason = "Test should only be executed with MPL in installation" )
534
- def test_GIVEN_has_mpl_AND_encryption_materials_does_not_have_required_EC_keys_WHEN_prep_message_THEN_stored_EC_is_EC (self ):
539
+ def test_GIVEN_has_mpl_AND_encryption_materials_does_not_have_required_EC_keys_WHEN_prep_message_THEN_stored_EC_is_EC ( # noqa pylint: disable=line-too-long
540
+ self
541
+ ):
535
542
536
543
self .mock_encryption_materials .algorithm = Algorithm .AES_128_GCM_IV12_TAG16
537
544
@@ -557,7 +564,7 @@ def test_GIVEN_has_mpl_AND_encryption_materials_does_not_have_required_EC_keys_W
557
564
assert test_encryptor ._stored_encryption_context == mock_encryption_context
558
565
# Then: _required_encryption_context is None
559
566
assert test_encryptor ._required_encryption_context is None
560
-
567
+
561
568
def test_prep_message_no_signer (self ):
562
569
self .mock_encryption_materials .algorithm = Algorithm .AES_128_GCM_IV12_TAG16
563
570
test_encryptor = StreamEncryptor (
0 commit comments