Skip to content

Keep the secrets_sync Tests Meaningful Under a Root Test Runner #4262

Closed

Description

@ptr727

Problem

tests/test_secrets_sync.py fails almost case by case when the test runner is root. scripts/secrets_sync.py refuses to run as root, and nearly every case drives the tool through a real main() path that reaches that refusal before the fake op is called. A run under a root CI container or a root shell therefore reports a wall of failures that say nothing about the code.

The one case added for the dry-run account refusal patches os.geteuid, so it passes as root. The rest of the module has no such guard.

How to Reproduce

Run uv run --no-project --python 3.13 --with-requirements tests/requirements.txt python -m unittest discover -s tests -p 'test_secrets_sync.py' as root inside a disposable container that holds a copy of the tree. The cases that reach the root refusal fail.

Fix Direction

Follow the shape tests/test_bootstrap.py and tests/test_restore_secrets.py took in #4258. Either patch os.geteuid to a non-root id for the cases that test non-root behavior, or skip them under real root, and keep the root-refusal case running as root.

Raised as a pre-existing finding on #4258.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions