ceph / ceph/s3-tests

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

Open
#725 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
372
Forks
328
PR merge metrics
No merged PRs in 30d

Description

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).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.