🐛 Fix failing Go tests: IsAllowedOrigin and ValidateToken#4224
🐛 Fix failing Go tests: IsAllowedOrigin and ValidateToken#4224clubanderson merged 1 commit intomainfrom
Conversation
- TestServer_IsAllowedOrigin: Update test expectation to match implementation — wildcards match any subdomain depth (deep.sub.ibm.com is valid) - TestServer_ValidateToken: Add Upgrade header for WebSocket query token test — validateToken only accepts query params on WebSocket upgrades (#3895) - Add new test case for query token rejection on non-upgrade requests Fixes #4214 #4215 #4217 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole canceled.
|
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
There was a problem hiding this comment.
Pull request overview
Updates Go unit tests in pkg/agent/server_test.go to align expectations with existing agent-server behavior around CORS wildcard matching and authentication-token validation.
Changes:
- Update
TestServer_IsAllowedOriginto expect deep subdomains to matchhttps://*.ibm.com(implementation matches any subdomain depth). - Update
TestServer_ValidateTokento only accept?token=when the request is a WebSocket upgrade (Upgrade: websocket), and add a negative test asserting query tokens are rejected for non-upgrade HTTP requests.
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
Summary
https://deep.sub.ibm.comto be rejected by the wildcardhttps://*.ibm.com, but thematchOriginimplementation intentionally matches any subdomain depth. Updated the test expectation totrueto match the implementation behavior.validateToken()only accepts query parameter tokens on WebSocket upgrade requests (per Agent token passed via URL query parameter — token leaked in server logs #3895). Added theUpgrade: websocketheader to the test and added a new test case verifying query tokens are rejected on non-upgrade requests.These two test failures caused the Release workflow (#4214), Nightly unit-test (#4215), and Nightly Test Suite (#4217) to fail.
Test plan
go test ./pkg/agent/ -run "TestServer_IsAllowedOrigin|TestServer_ValidateToken"passes locallyFixes #4214 #4215 #4217