Skip to content

Commit daf9fe4

Browse files
The test suite keeps its credentials out of the real session store
Every test that unlocks or creates a vault stores a boot-bound credential, and the session directory defaults to the real ~/.compartment/session - so a full run left hundreds of dead .session files on the machine of whoever ran it, which is exactly what this suite promises not to do. One autouse fixture points the store at the test's own tmp directory; the tests that are about the store already choose their own and still win.
1 parent 99b8fd3 commit daf9fe4

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ def vault_path(tmp_path):
3131
return str(tmp_path / "test.vault")
3232

3333

34+
@pytest.fixture(autouse=True)
35+
def no_real_session_store(monkeypatch, tmp_path):
36+
"""No test writes a credential into the machine's real session store.
37+
38+
Any test that unlocks or creates a vault stores a boot-bound credential,
39+
and the session directory defaults to the real ~/.compartment/session -
40+
so a full run quietly left hundreds of dead .session files there, on the
41+
machine of whoever ran it. That is exactly what the fixture below says a
42+
suite run must never do. Tests that are about the store already pick
43+
their own directory, and a setenv inside a test wins over this one.
44+
"""
45+
monkeypatch.setenv("COMPARTMENT_SESSION_DIR", str(tmp_path / "session-store"))
46+
47+
3448
@pytest.fixture(autouse=True)
3549
def no_real_supervisors(monkeypatch, tmp_path, request):
3650
"""No test talks to the machine's own launchd, systemd or Task Scheduler,

0 commit comments

Comments
 (0)