Skip to content

Commit

Permalink
Minor test cleanup changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan343 committed Nov 20, 2024
1 parent 253928d commit ff4f122
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ def get_checksum_cls(algorithm=DEFAULT_CHECKSUM_ALGORITHM.lower()):
This pass through is grabbing our internally supported list of checksums
to ensure we stay in sync, while not exposing them publicly.
Returns the default checksum algorithm class if none is specified.
Returns a checksum algorithm class. The default checksum class is used
if one isn't specified.
"""
return _CHECKSUM_CLS[algorithm]
2 changes: 1 addition & 1 deletion tests/unit/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ def test_request_validation_mode_member_when_required(
assert "ChecksumMode" not in params


def test_request_validation_mode_member_is_not_enabled(
def test_request_validation_mode_member_set_by_user(
checksum_operation_model,
):
params = {"ChecksumMode": "FAKE_VALUE"}
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/test_httpchecksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
resolve_request_checksum_algorithm,
resolve_response_checksum_algorithms,
)
from botocore.model import OperationModel, StringShape
from botocore.model import OperationModel, StringShape, StructureShape
from tests import get_checksum_cls, mock, requires_crt


Expand All @@ -57,6 +57,7 @@ def _make_operation_model(
if http_checksum and "requestAlgorithmMember" in http_checksum:
shape = mock.Mock(spec=StringShape)
shape.serialization = {"name": "x-amz-request-algorithm"}
operation.input_shape = mock.Mock(spec=StructureShape)
operation.input_shape.members = {
http_checksum["requestAlgorithmMember"]: shape
}
Expand Down Expand Up @@ -127,6 +128,9 @@ def test_request_checksum_algorithm_model_default(self):
}
actual_algorithm = request["context"]["checksum"]["request_algorithm"]
self.assertEqual(actual_algorithm, expected_algorithm)
self.assertEqual(
request["headers"]["x-amz-request-algorithm"], "CRC32"
)

# Param is present, sha256 checksum will be set
params = {"Algorithm": "sha256"}
Expand Down Expand Up @@ -164,6 +168,9 @@ def test_request_checksum_algorithm_model_default_streaming(self):
}
actual_algorithm = request["context"]["checksum"]["request_algorithm"]
self.assertEqual(actual_algorithm, expected_algorithm)
self.assertEqual(
request["headers"]["x-amz-request-algorithm"], "CRC32"
)

# Param is present, sha256 checksum will be set in the trailer
params = {"Algorithm": "sha256"}
Expand Down

0 comments on commit ff4f122

Please sign in to comment.