Repository navigation
fix(tests): load SECRET_KEY from .env for internal API tests (#754) - #757
Merged
Merged
Conversation
conftest.py early-init block now reads SECRET_KEY and INTERNAL_API_SECRET from the project .env file via dotenv_values (handles duplicate keys, uses last value). Uses setdefault so explicitly-exported env vars win. Fixes 5 tests in test_internal.py that were skipping (or failing with 403 when env vars were set but wrong) because the X-Internal-Secret header couldn't be populated without manual env var export. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
3 tasks
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
conftest.pyearly-init block now loadsSECRET_KEYandINTERNAL_API_SECRETfrom the project.envviadotenv_values(which resolves duplicate keys by returning the last value)setdefaultso explicitly-exported env vars always take precedencetest_internal.pythat were skipping (or failing 403) because theX-Internal-Secretheader couldn't be populated without manually exporting the secret before running testsChanges
tests/conftest.py— 20-line addition in the early-init block, same pattern as the existing Redis env-var setupTest Plan
pytest tests/test_internal.py -v→ 7 passed, 0 failed (was 7 skipped / 5 failed)Fixes #754
🤖 Generated with Claude Code