Repository navigation
test: add secrets detection hook regressions - #3931
Conversation
gandhipratik203
left a comment
There was a problem hiding this comment.
Nit (non-blocking): The three blocking tests (test_prompt_pre_fetch_blocks_without_redaction, test_tool_post_invoke_blocks_without_redaction, test_resource_post_fetch_blocks_without_redaction) assert result.modified_payload == payload. This works via Pydantic value equality, but the modified_payload here is backfilled by the executor (manager.py:361-363), not set by the plugin itself. A brief inline comment would help future readers understand this isn't testing plugin output directly.
gandhipratik203
left a comment
There was a problem hiding this comment.
LGTM — good regression coverage for the secrets detection hooks across all three dispatch paths.
|
@gandhipratik203 added the comment |
gandhipratik203
left a comment
There was a problem hiding this comment.
LGTM — good regression coverage for the secrets detection hooks across all three dispatch paths.
Signed-off-by: lucarlig <[email protected]>
Signed-off-by: lucarlig <[email protected]>
Signed-off-by: lucarlig <[email protected]>
Signed-off-by: lucarlig <[email protected]>
- Regenerate .secrets.baseline to reflect shifted line numbers after test additions (466 → 636) - Fix isort import section ordering in test_secrets_detection.py Signed-off-by: Mihai Criveti <[email protected]>
d84a03c to
7350122
Compare
crivetimihai
left a comment
There was a problem hiding this comment.
Looks good — well-structured regression tests for the three secrets detection hook dispatch paths (prompt_pre_fetch, tool_post_invoke, resource_post_fetch).
What was reviewed:
- All 6 new tests correctly exercise the real
PluginManager.invoke_hookdispatch, not just direct plugin method calls - Redact paths verify
continue_processing=True, modified payload contents, and metadata - Block paths verify
continue_processing=False, violation code, and payload backfill behavior - Test isolation is solid:
PluginManager.reset()autouse fixture +try/finallyshutdown - Consistent with existing test patterns in the codebase
Changes made during rebase:
- Rebased onto main, removed merge commit
- Regenerated
.secrets.baseline(line number shift 466 → 665) - Fixed isort import section ordering
* test: add secrets detection hook regressions Signed-off-by: lucarlig <[email protected]> * test: exercise secrets detection through manager dispatch Signed-off-by: lucarlig <[email protected]> * test: load secrets hook cases through plugin config Signed-off-by: lucarlig <[email protected]> * test: clarify manager-backed blocked payload assertions Signed-off-by: lucarlig <[email protected]> * fix: update secrets baseline line numbers and fix import ordering - Regenerate .secrets.baseline to reflect shifted line numbers after test additions (466 → 636) - Fix isort import section ordering in test_secrets_detection.py Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: lucarlig <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
* test: add secrets detection hook regressions Signed-off-by: lucarlig <[email protected]> * test: exercise secrets detection through manager dispatch Signed-off-by: lucarlig <[email protected]> * test: load secrets hook cases through plugin config Signed-off-by: lucarlig <[email protected]> * test: clarify manager-backed blocked payload assertions Signed-off-by: lucarlig <[email protected]> * fix: update secrets baseline line numbers and fix import ordering - Regenerate .secrets.baseline to reflect shifted line numbers after test additions (466 → 636) - Fix isort import section ordering in test_secrets_detection.py Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: lucarlig <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
🔗 Related Issue
Related internal mirror issue: contextforge-org/mcp-context-forge#5
📝 Summary
This PR adds regression coverage for the secrets detection plugin hook paths reported in the issue:
prompt_pre_fetch,tool_post_invoke, andresource_post_fetch.Only test changes were needed because targeted local verification showed the current plugin implementation already handled the reported redact-only and block-only behaviors correctly. The gap was missing automated coverage for those scenarios through the framework dispatch path, so this PR codifies those cases to prevent regressions.
🏷️ Type of Change
🧪 Verification
make lintsource .venv/bin/activate && python -m pytest tests/unit/plugins/test_secrets_detection.py -qmake coverage✅ Checklist
make black isort pre-commit)📓 Notes (optional)
The regression cases are loaded through a minimal plugin config so the tests exercise
PluginManager.initialize()and hook dispatch, rather than only calling plugin methods directly.