fix(tests): override "test" sentinel in security conftest (closes #804) - #806
Closed
AndriiPasternak31 wants to merge 1 commit into
Closed
Conversation
`tests/conftest.py` setdefaults REDIS_PASSWORD/REDIS_BACKEND_PASSWORD to the literal "test" at global pytest import so backend modules can be imported without real Redis creds. `tests/security/conftest.py` was then using `os.environ.setdefault(...)` to overlay real `.env` values — a no-op because the sentinel was already set. Result: `redis-cli` ran with `-a test` against a healthy stack and the ACL acceptance tests failed for the wrong reason. Pop the sentinel before the `.env` overlay and use direct assignment. Add a regression test that asserts the live env value is not the sentinel and (when `.env` defines the keys) matches the `.env` value. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
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.
Summary
Fixes the fixture-precedence bug from #804 —
tests/security/test_redis_network_isolation.pyACL tests have failed against any live stack since #589 (2026-05-04) because the globaltests/conftest.py:30setdefaultsREDIS_BACKEND_PASSWORD="test"and the security conftest then tries to override from.envusingsetdefault(no-op when the key already exists). The bogus"test"value reachedredis-cli, Redis correctly rejected it, and the tests failed withNOAUTH.Two-line fix in
tests/security/conftest.py:del os.environ[key]forREDIS_PASSWORD/REDIS_BACKEND_PASSWORDwhen they equal the literal"test"sentinel, before loading.env.os.environ[key] = value) instead ofsetdefaultwhen applying values from.env.Plus a new file
tests/security/test_redis_conftest_regression.pywith 2 unit tests that lock in the precedence behavior — they'd fail under the old code and pass under the new code.Verification
Full integration suite against a fresh stack:
The three previously-failing tests now pass:
test_platform_container_can_authenticate✅test_backend_acl_blocks_flushall✅test_backend_acl_blocks_config_get✅Plus the 2 new regression tests:
test_security_conftest_overlays_test_sentinel✅test_dotenv_value_won_when_env_present✅Stacking
Based on top of #796 (
AndriiPasternak31/lint-baseline-orphan-test) — that PR baselines the pre-existing 3sys.modulesviolations intest_cleanup_unreachable_orphan.pyso the lint check passes. Without it, this PR's lint job fails on an unrelated pre-existing violation. #796 should land first; this PR auto-retargets todevonce #796 merges.Test plan
pytest tests/security/ -m integration -v→ 5 passed (the 3 ACL tests + 2 regression tests + the 2 already-passing existence tests)Closes #804
🤖 Generated with Claude Code