fix: generate strong per-run JWT secret in plugin integration harness - #5797
Open
madhu-mohan-jaishankar wants to merge 1 commit into
Open
fix: generate strong per-run JWT secret in plugin integration harness#5797madhu-mohan-jaishankar wants to merge 1 commit into
madhu-mohan-jaishankar wants to merge 1 commit into
Conversation
The plugin E2E harness defaulted JWT_SECRET_KEY to 'my-test-key-but-now-longer-than-32-bytes', which is now on the known-weak blocklist rejected by Settings validation in every environment — both the test gateway and the pytest legs failed at startup/import. - run_plugin_tests.sh: generate a strong random secret per run via 'openssl rand -base64 48' when none is supplied; gateway and pytest share the same value so tokens stay consistent within a run. - Makefile.plugin-integration: drop the weak default so the runner fallback applies; explicit JWT_SECRET_KEY overrides still work. - Stale-gateway cleanup now also kills uvicorn-launched gateways (uvicorn mcpgateway.main:app), which previously kept the port and fooled wait_for_health into a false 'gateway is up' while the real test gateway was crashing. Signed-off-by: Madhu Mohan Jaishankar <madhu.mohan.jaishankar@ibm.com>
madhu-mohan-jaishankar
requested review from
Lang-Akshay,
brian-hussey,
crivetimihai,
ja8zyjits and
msureshkumar88
as code owners
July 23, 2026 14:31
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.
Pull Request
🔗 Related Issue
Closes #
📝 Summary
The plugin E2E harness defaulted
JWT_SECRET_KEYtomy-test-key-but-now-longer-than-32-bytes, which is now on the known-weak blocklist (mcpgateway/_security_constants.py) rejected bySettingsvalidation in every environment. As a result, every localmake test-plugin-*run failed on both legs:SecurityConfigurationError, andtests/conftest.py→mcpgateway.db→Settings()).The failure was also masked: a stale uvicorn-launched dev gateway holding port 4444 answered the harness health check, producing a false
[info] gateway is upwhile the real test gateway was crash-looping — so the summary showed pytest failures instead of the actual gateway boot failure.Changes (local test harness only — CI does not use these files, see Notes):
tests/live_gateway/plugins/run_plugin_tests.sh: generate a strong random secret per run viaopenssl rand -base64 48when none is supplied; the gateway and pytest legs share the same value, so tokens stay consistent within a run.tests/live_gateway/plugins/Makefile.plugin-integration: drop the weak default so the runner fallback applies; explicitJWT_SECRET_KEY=...overrides still work.uvicorn mcpgateway.main:app), which previously kept the port and fooledwait_for_healthinto a false "gateway is up".📏 Reviewability
triage🏷️ Type of Change
🧪 Verification
Reproduced the failure, applied the fix, and re-ran the affected target end-to-end:
make test-plugin-pii-filterSecurityConfigurationError: jwt_secret_key: known-weak/default value rejectedmake test-plugin-pii-filterJWT_SECRET_KEY="$(openssl rand -base64 48 | tr -d '\n')" python -c "from mcpgateway.config import Settings; Settings()"make lintmake testmake coverageMasked-failure repro: start a dev server (
python -m uvicorn mcpgateway.main:app --port 4444), run anymake test-plugin-*target on main — the harness reportsgateway is upeven though its own gateway never started (visible in/tmp/gateway-plugin-tests.log).✅ Checklist
make black isort pre-commit) — N/A for shell/Make changes📓 Notes (optional)