-
Notifications
You must be signed in to change notification settings - Fork 132
test(runner): add unit tests for token-exchange middleware integration (Priority 1) #2227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(runner): add unit tests for token-exchange middleware integration (Priority 1) #2227
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2227 +/- ##
==========================================
+ Coverage 53.32% 53.37% +0.05%
==========================================
Files 231 231
Lines 29536 29536
==========================================
+ Hits 15749 15766 +17
+ Misses 12654 12636 -18
- Partials 1133 1134 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these tests! They correctly verify the middleware ordering and types.
One suggestion: the tests currently only check the Type
field of each middleware config. Consider also verifying that the Parameters
field is properly populated and contains the expected configuration values. This would catch issues where the middleware has the correct type but is missing or has incorrect configuration data.
For the second test case where you provide a token-exchange config, you could:
- Use actual config values (TokenURL, ClientID, etc.) instead of an empty struct
- Assert that the Parameters field is not nil
- Unmarshal the Parameters and verify the config was passed through correctly
This would give more confidence that the middleware is fully configured, not just present in the chain.
ea92a77
to
835667e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds Priority 1 integration tests validating token-exchange middleware presence, ordering, and parameter propagation in the core middleware chain.
- Adds tests for absence when config is nil
- Adds tests for presence, ordering (auth → token-exchange → MCP parser), and parameter serialization
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Add Priority 1 (Core Integration) unit tests for token-exchange middleware in pkg/runner/config_builder.go. These tests: - Verify middleware is not added when tokenExchangeConfig is nil - Verify middleware is added and correctly ordered (auth → token-exchange → MCP parser) - Validate middleware chain integrity Fixes: stacklok#2149 Signed-off-by: Mohamed Fawas <[email protected]>
This commit adds Priority 1 (Core Integration) tests for the token-exchange middleware in pkg/runner/config_builder_test.go. Changes include: - Verified middleware is not added when `tokenExchangeConfig` is nil. - Verified middleware order (auth → token-exchange → mcp parser) when config is provided. - Confirmed that middleware parameters are populated and match the provided `tokenexchange.Config`. This improves coverage and ensures correct integration behavior between authentication and token-exchange components. Signed-off-by: Mohamed Fawas <[email protected]>
dad9fbc
to
86f9fe1
Compare
Hi @jhrozek 👋 Thank you for the review and detailed suggestions. I’ve updated the tests based on your feedback:
All tests pass locally. This update ensures the middleware is not only present in the chain but also fully configured as expected. This PR now fully covers Priority 1 (Core Integration) from issue #2149. Ready for re-review — thanks again for your guidance! |
Summary
This PR adds Priority 1 (Core Integration) tests for the token-exchange middleware integration as described in issue #2149.
Changes
pkg/runner/config_builder_test.go
tokenExchangeConfig
isnil
auth → token-exchange → MCP parser
)Scope
This PR focuses only on Priority 1 as defined in the issue description.
I plan to address Priority 2 and 3 in separate follow-up PRs.
Related Issue
Closes #2149