Skip to content

test_get_object_torrent: treat torrent body as bytes (not UTF-8) #725

@drey123

Description

@drey123

In s3tests/functional/test_s3.py, test_get_object_torrent() calls _get_body(response) which unconditionally does got.decode() when the body is bytes.

A .torrent file is a bencoded binary format. The pieces field contains raw SHA1 digests, so the response body is not guaranteed to be valid UTF-8. When a backend returns an actual torrent body, the test can fail with UnicodeDecodeError even though the server is correct.

Suggested fix: in test_get_object_torrent, read response["Body"].read() as bytes and compare against data.encode("utf-8") (do not decode).

PR prepared on fork: drey123/s3-tests (branch omni-fix-torrent-bytes).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions