From 509440a619bdfe4bcb467a98089d6365845d205a Mon Sep 17 00:00:00 2001 From: jonathan343 Date: Fri, 22 Nov 2024 12:04:58 -0500 Subject: [PATCH] fix testing issue; Assert actual checksum values in tests. --- botocore/httpchecksum.py | 9 +++++---- tests/functional/test_s3.py | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/botocore/httpchecksum.py b/botocore/httpchecksum.py index fa01286e39..0a0729b633 100644 --- a/botocore/httpchecksum.py +++ b/botocore/httpchecksum.py @@ -299,10 +299,11 @@ def resolve_request_checksum_algorithm( algorithm_member_header = _get_request_algorithm_member_header( operation_model, request, algorithm_member ) - checksum_context["request_algorithm_header"] = { - "name": algorithm_member_header, - "value": DEFAULT_CHECKSUM_ALGORITHM, - } + if algorithm_member_header is not None: + checksum_context["request_algorithm_header"] = { + "name": algorithm_member_header, + "value": DEFAULT_CHECKSUM_ALGORITHM, + } else: return diff --git a/tests/functional/test_s3.py b/tests/functional/test_s3.py index 5b5922a942..ab30d6c1fd 100644 --- a/tests/functional/test_s3.py +++ b/tests/functional/test_s3.py @@ -1534,7 +1534,7 @@ def test_trailing_checksum_set(self): b"STREAMING-UNSIGNED-PAYLOAD-TRAILER", ) body = self.http_stubber.requests[0].body.read() - self.assertIn(b"x-amz-checksum-crc32", body) + self.assertIn(b"x-amz-checksum-crc32:eCQEmA==", body) def test_trailing_checksum_set_empty_body(self): with self.http_stubber: @@ -1551,7 +1551,7 @@ def test_trailing_checksum_set_empty_body(self): b"STREAMING-UNSIGNED-PAYLOAD-TRAILER", ) body = self.http_stubber.requests[0].body.read() - self.assertIn(b"x-amz-checksum-crc32", body) + self.assertIn(b"x-amz-checksum-crc32:AAAAAA==", body) def test_trailing_checksum_set_empty_file(self): with self.http_stubber: @@ -1570,7 +1570,7 @@ def test_trailing_checksum_set_empty_file(self): sent_headers["x-amz-content-sha256"], b"STREAMING-UNSIGNED-PAYLOAD-TRAILER", ) - self.assertIn(b"x-amz-checksum-crc32", body) + self.assertIn(b"x-amz-checksum-crc32:AAAAAA==", body) def test_content_sha256_not_set_if_config_value_is_true(self): # By default, put_object() provides a trailing checksum and includes the