Repository navigation
fix(tests): stop the test suite from overwriting the real ~/.devorch/permissions.yaml - #35
Merged
Merged
Conversation
tests/test_integration.py calls Permissions().set_tool_permission(...), which saves to the real ~/.devorch/permissions.yaml, so every pytest run replaced the developer's saved permissions with 'edit: allow' and 'filesystem: allow'. Point HOME and USERPROFILE at a throwaway directory before the application modules are imported, use the null keyring backend, and clear API key variables. Add tests that fail if the suite ever resolves to the real home.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (data-loss bug in the tests, from March)
tests/test_integration.pycreatesPermissions()and callsset_tool_permission("filesystem"|"edit", ALLOW). That method saves, and the target path is a module constant evaluated fromPath.home()at import time, so everypytestrun on a developer machine overwrote the real~/.devorch/permissions.yamlwith exactly:Consequences: any saved rules ("always allow" patterns, deny rules, per-tool levels) were silently replaced, and DevOrch then edited and wrote files without asking in ASK mode. A stray DevOrch session run by the maintainer did exactly that and modified
cli/main.py. The suite also wrote~/.devorch/sessions/registry.json.Found by running the suite with
HOMEpointed at an empty directory (onlytest_integration.pyproducedpermissions.yaml) and bisecting by file.Fix
New
tests/conftest.py, executed before any application module is imported:HOME/USERPROFILEpoint at a throwaway temp dir (removed at session end), so everyPath.home() / ".devorch"constant resolves therePYTHON_KEYRING_BACKEND= null backend: tests never touch the real keychaintests/test_isolation.pyfails if the suite ever resolves to the real home, if the application paths are outside the test home, if saving permissions escapes it, or if the real keyring is used.Verified
~/.devorchwas created, changed or removed (file list + mtimes identical before/after)Action for anyone who ran the tests before
Check
~/.devorch/permissions.yaml. If it contains onlyedit: allowandfilesystem: allow, rundevorch permissions reset(this also resets your saved rules, which were already overwritten).