From ec667a1646e9dfcf956206c86cce1751691aaaed Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Fri, 29 May 2026 00:22:18 +0200 Subject: [PATCH] test: use tempfile.gettempdir() for all bg-sync debug screenshots The remaining SonarCloud S5443 (publicly-writable directory) findings were the hard-coded /tmp screenshot paths in revoke_background_sync_access, which became "new code" once the surrounding function was edited. Replace every /tmp literal in the file with tempfile.gettempdir() (which S5443 accepts), eliminating the findings consistently rather than per-line. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../test_astrolabe_multi_user_background_sync.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/integration/test_astrolabe_multi_user_background_sync.py b/tests/integration/test_astrolabe_multi_user_background_sync.py index 1fafcfdf..eeb32c23 100644 --- a/tests/integration/test_astrolabe_multi_user_background_sync.py +++ b/tests/integration/test_astrolabe_multi_user_background_sync.py @@ -524,7 +524,9 @@ async def revoke_background_sync_access(page: Page, username: str) -> bool: await revoke_button.wait_for(timeout=5000, state="visible") logger.info("Found 'Disable background indexing' button") except Exception: - screenshot_path = f"/tmp/astrolabe_no_revoke_button_{username}.png" + screenshot_path = ( + f"{tempfile.gettempdir()}/astrolabe_no_revoke_button_{username}.png" + ) await page.screenshot(path=screenshot_path) raise ValueError( f"Could not find revoke button for {username}. Screenshot: {screenshot_path}" @@ -561,7 +563,9 @@ async def revoke_background_sync_access(page: Page, username: str) -> bool: else: logger.warning("No response found for credentials/revoke endpoint!") # Take screenshot for debugging - screenshot_path = f"/tmp/astrolabe_revoke_no_response_{username}.png" + screenshot_path = ( + f"{tempfile.gettempdir()}/astrolabe_revoke_no_response_{username}.png" + ) await page.screenshot(path=screenshot_path) return False @@ -586,7 +590,9 @@ async def revoke_background_sync_access(page: Page, username: str) -> bool: try: if await page.locator("#mcp-revoke-background-button").is_visible(timeout=2000): logger.error("Revoke button still visible for %s after revoke!", username) - screenshot_path = f"/tmp/astrolabe_revoke_still_enabled_{username}.png" + screenshot_path = ( + f"{tempfile.gettempdir()}/astrolabe_revoke_still_enabled_{username}.png" + ) await page.screenshot(path=screenshot_path) return False except Exception: