From 1f4b9cc1c1bb11b05a86b06b65b60d51ac0937d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Oct 2026 06:17:07 +0000 Subject: [PATCH] test: make the failed container write test hold when the suite runs as root The test relied on a chmod 0o500 drive denying writes, which root ignores. Make the container path a dangling symlink instead, so opening it for writing fails for every user and the same ordering guarantee is asserted. Closes #368 Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01GqtiAsmkmDmpynCN35XTzg Signed-off-by: Claude --- tests/test_offload.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/test_offload.py b/tests/test_offload.py index 0946a7a..3fee967 100644 --- a/tests/test_offload.py +++ b/tests/test_offload.py @@ -773,21 +773,22 @@ def test_a_failed_container_write_leaves_the_sealed_original_alone( """The ordering argument, exercised: prove the container, then destroy the copy. A drive that cannot be written to is the cheapest way to reach the failure - path. What matters is not the error but what survives it: the bytes are - still in the vault, no record claims otherwise, and a later export is a - complete one. + path (here, a container path that cannot be opened for writing). What + matters is not the error but what survives it: the bytes are still in the + vault, no record claims otherwise, and a later export is a complete one. """ vault, capture_id = _case(make_vault, make_jpeg) content_hash = vault.document.captures()[0].content_hash before = vault.read_original(capture_id, content_hash) - drive = tmp_path / "readonly-usb" - drive.mkdir() - drive.chmod(0o500) - try: - with pytest.raises(OSError): - offload_item(vault, capture_id, drive) - finally: - drive.chmod(0o700) + drive = tmp_path / "failing-usb" + drive.mkdir() + # The container's name is a dangling symlink into a directory that does not + # exist, so opening it for writing fails for every user. A read-only drive + # (chmod 0o500) would not do: root ignores directory permission bits, so the + # write would succeed and the test would fail in containers that run as root. + (drive / f"{capture_id}{OFFLOAD_CONTAINER_SUFFIX}").symlink_to(tmp_path / "gone" / "x.bin") + with pytest.raises(OSError): + offload_item(vault, capture_id, drive) assert vault.has_original(capture_id) assert not vault.is_offloaded(capture_id)