Add test coverage for -FollowRelLink authorization - #27863
Open
Chris Peterson (chris-peterson) wants to merge 2 commits into
Open
Add test coverage for -FollowRelLink authorization#27863Chris Peterson (chris-peterson) wants to merge 2 commits into
Chris Peterson (chris-peterson) wants to merge 2 commits into
Conversation
No test pins what -FollowRelLink does with the caller's Authorization header, so a change at the rel-link call site can alter it unnoticed. On the 7.4.19, 7.5.10 and 7.6.5 servicing releases each followed link goes through the redirect path, which strips the header, leaving -FollowRelLink unable to page an authenticated API. Against a server that permits anonymous reads the follows still return 200, so the caller gets a visibility-filtered result set and no error (PowerShell#27861). master reaches that call site through GetRequest(uri) and keeps the header, so this passes as written and fails if the strip arrives here.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Chris Peterson (chris-peterson)
marked this pull request as ready for review
August 18, 2026 19:26
Chris Peterson (chris-peterson)
requested a review
from a team
as a code owner
August 18, 2026 19:26
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a regression test to ensure Invoke-RestMethod -FollowRelLink preserves the Authorization header when following relation links within the same origin, preventing silent authentication loss during paging.
Changes:
- Added a new
Invoke-RestMethodtest covering header retention across rel-link pagination. - Validates no errors, expected page count, and consistent
Authorizationheader on all followed requests.
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Addresses review feedback on WebCmdlets.Tests.ps1:3049. The four other per-page assertions in the rel-link tests iterate with ForEach-Object; three indexed assertions were the only ones of their kind in the file.
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.
PR Summary
No test pins what
-FollowRelLinkdoes with the caller'sAuthorizationheader.-FollowRelLinkexists so the web cmdlets can page an API that advertises its next page in aLinkheader. GitHub's and GitLab's paginated endpoints are the canonical case, and those APIs want the caller's credentials on every page, not just the first. Nothing asserts that today, so a change at the rel-link call site can alter it with the suite still green.This adds one Pester case: a three-page same-origin walk checking the header reaches every page. Test-only, no product change.
PR Context
Per #27861, on the 7.4.19, 7.5.10 and 7.6.5 servicing releases each followed link goes through the redirect path, which strips the header, so
-FollowRelLinkcannot page an authenticated API. Against a server that permits anonymous reads the follows still return HTTP 200, and the caller gets a visibility-filtered result set with no error, no warning, and no non-zero status. It reached us as a GitLab group of 43 projects reporting 39.masterreaches that call site throughGetRequest(uri), which takes noisRedirectargument, so the header survives and this case passes as written.Verified in both directions on macOS arm64:
WebCmdlets.Tests.ps1masteras-ismasterwith the servicing strip applied locallyReview guide
WebCmdlets.Tests.ps1L3038 is the whole change: oneItblock beside the existing-FollowRelLinkcases, driving the WebListenerLinkendpoint the neighbouring cases already use. No test-tool support was added.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header