From 723f784c72faf4559eb1a754e5a16a83eaaa8c7e Mon Sep 17 00:00:00 2001 From: mattsb42-aws Date: Thu, 23 May 2019 12:29:20 -0700 Subject: [PATCH 1/4] bump version to 1.4.0 and update changelog --- CHANGELOG.rst | 11 ++++++++++- src/aws_encryption_sdk/identifiers.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8115435f6..6b2a8b70a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,7 +2,7 @@ Changelog ********* -1.x.x -- 201x-xx-xx +1.4.0 -- 2019-05-23 =================== Minor @@ -11,6 +11,15 @@ Minor * Remove dependence on all ``source_stream`` APIs except for ``read()``. `#103 `_ +Potentially Breaking +^^^^^^^^^^^^^^^^^^^^ + +* Encryption streams no longer close the ``source_stream`` when they themselves close. + If you are using context managers for all of your stream handling, + this change will not affect you. + However, if you have been relying on this to close your ``source_stream`` for you, + you will now need to close those streams yourself. + Maintenance ----------- diff --git a/src/aws_encryption_sdk/identifiers.py b/src/aws_encryption_sdk/identifiers.py index 35a29d74d..1bd9bb1f1 100644 --- a/src/aws_encryption_sdk/identifiers.py +++ b/src/aws_encryption_sdk/identifiers.py @@ -27,7 +27,7 @@ # We only actually need these imports when running the mypy checks pass -__version__ = "1.3.8" +__version__ = "1.4.0" USER_AGENT_SUFFIX = "AwsEncryptionSdkPython/{}".format(__version__) From 9729559d5cc4b1b0870a3c80c16ce50107bfe67d Mon Sep 17 00:00:00 2001 From: mattsb42-aws Date: Thu, 23 May 2019 13:25:07 -0700 Subject: [PATCH 2/4] rework attribute deprecation/removal tests to check both pre and post removal --- .../test_f_aws_encryption_sdk_client.py | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/test/functional/test_f_aws_encryption_sdk_client.py b/test/functional/test_f_aws_encryption_sdk_client.py index 3686ccead..f7ffa6dd6 100644 --- a/test/functional/test_f_aws_encryption_sdk_client.py +++ b/test/functional/test_f_aws_encryption_sdk_client.py @@ -810,6 +810,17 @@ def test_decrypt_minimal_source_stream_api(frame_length, wrapping_class): assert plaintext == decrypted +def _assert_deprecated_but_not_yet_removed(logcap, instance, attribute_name, error_message, no_later_than): + assert hasattr(instance, attribute_name) + assert error_message in logcap.text + assert aws_encryption_sdk.__version__ < no_later_than + + +def _assert_decrypted_and_removed(instance, attribute_name, removed_in): + assert not hasattr(instance, attribute_name) + assert aws_encryption_sdk.__version__ >= removed_in + + @pytest.mark.parametrize("attribute, no_later_than", (("body_start", "1.4.0"), ("body_end", "1.4.0"))) def test_decryptor_deprecated_attributes(caplog, attribute, no_later_than): caplog.set_level(logging.WARNING) @@ -820,9 +831,19 @@ def test_decryptor_deprecated_attributes(caplog, attribute, no_later_than): decrypted = decryptor.read() assert decrypted == plaintext - assert hasattr(decryptor, attribute) - watch_string = "StreamDecryptor.{name} is deprecated and will be removed in {version}".format( - name=attribute, version=no_later_than - ) - assert watch_string in caplog.text - assert aws_encryption_sdk.__version__ < no_later_than + if aws_encryption_sdk.__version__ < no_later_than: + _assert_deprecated_but_not_yet_removed( + logcap=caplog, + instance=decryptor, + attribute_name=attribute, + error_message="StreamDecryptor.{name} is deprecated and will be removed in {version}".format( + name=attribute, version=no_later_than + ), + no_later_than=no_later_than + ) + else: + _assert_decrypted_and_removed( + instance=decryptor, + attribute_name=attribute, + removed_in=no_later_than + ) From aaa5337e804b39bee3e10aed1ddaaa21117c83f5 Mon Sep 17 00:00:00 2001 From: mattsb42-aws Date: Thu, 23 May 2019 13:27:09 -0700 Subject: [PATCH 3/4] remove deprecated StreamDecryptor.body_start and StreamDecryptor.body_end for 1.4.0 release --- CHANGELOG.rst | 7 +++++-- src/aws_encryption_sdk/streaming_client.py | 12 ------------ test/unit/test_streaming_client_stream_decryptor.py | 4 ++-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6b2a8b70a..8a388b11c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,14 +11,17 @@ Minor * Remove dependence on all ``source_stream`` APIs except for ``read()``. `#103 `_ -Potentially Breaking -^^^^^^^^^^^^^^^^^^^^ +Potentially Backwards Incompatible +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Encryption streams no longer close the ``source_stream`` when they themselves close. If you are using context managers for all of your stream handling, this change will not affect you. However, if you have been relying on this to close your ``source_stream`` for you, you will now need to close those streams yourself. +* ``StreamDecryptor.body_start`` and ``StreamDecryptor.body_end``, + deprecated in a prior release, + have now been removed. Maintenance ----------- diff --git a/src/aws_encryption_sdk/streaming_client.py b/src/aws_encryption_sdk/streaming_client.py index 2132ea177..90dc9d25c 100644 --- a/src/aws_encryption_sdk/streaming_client.py +++ b/src/aws_encryption_sdk/streaming_client.py @@ -781,18 +781,6 @@ def _read_header(self): validate_header(header=header, header_auth=header_auth, raw_header=raw_header, data_key=self._derived_data_key) return header, header_auth - @property - def body_start(self): - """Log deprecation warning when body_start is accessed.""" - _LOGGER.warning("StreamDecryptor.body_start is deprecated and will be removed in 1.4.0") - return self._body_start - - @property - def body_end(self): - """Log deprecation warning when body_end is accessed.""" - _LOGGER.warning("StreamDecryptor.body_end is deprecated and will be removed in 1.4.0") - return self._body_end - def _prep_non_framed(self): """Prepare the opening data for a non-framed message.""" self._unframed_body_iv, self.body_length = deserialize_non_framed_values( diff --git a/test/unit/test_streaming_client_stream_decryptor.py b/test/unit/test_streaming_client_stream_decryptor.py index 362c97f66..6a3ccb56d 100644 --- a/test/unit/test_streaming_client_stream_decryptor.py +++ b/test/unit/test_streaming_client_stream_decryptor.py @@ -238,8 +238,8 @@ def test_prep_non_framed(self): stream=test_decryptor.source_stream, header=self.mock_header, verifier=sentinel.verifier ) assert test_decryptor.body_length == len(VALUES["data_128"]) - assert test_decryptor.body_start == self.mock_header.algorithm.iv_len + 8 - assert test_decryptor.body_end == self.mock_header.algorithm.iv_len + 8 + len(VALUES["data_128"]) + assert test_decryptor._body_start == self.mock_header.algorithm.iv_len + 8 + assert test_decryptor._body_end == self.mock_header.algorithm.iv_len + 8 + len(VALUES["data_128"]) def test_read_bytes_from_non_framed(self): ct_stream = io.BytesIO(VALUES["data_128"]) From 639e08a3635eb06aa4368d424023e0df72882bc6 Mon Sep 17 00:00:00 2001 From: mattsb42-aws Date: Thu, 23 May 2019 13:30:36 -0700 Subject: [PATCH 4/4] clarify changelog entry --- CHANGELOG.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8a388b11c..80b7fc304 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,7 +17,8 @@ Potentially Backwards Incompatible * Encryption streams no longer close the ``source_stream`` when they themselves close. If you are using context managers for all of your stream handling, this change will not affect you. - However, if you have been relying on this to close your ``source_stream`` for you, + However, if you have been relying on the ``StreamDecryptor`` + or ``StreamEncryptor`` to close your ``source_stream`` for you, you will now need to close those streams yourself. * ``StreamDecryptor.body_start`` and ``StreamDecryptor.body_end``, deprecated in a prior release,