Add Token parameter to Search-AzResourceGraph command#8
Merged
SimonWahlin merged 1 commit intomainfrom Jul 3, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds a -Token parameter to Search-AzResourceGraph that lets users supply a raw access token, bypassing the regular sign-in flow. It updates the function logic and headers, adds Pester tests for both token and non-token scenarios, and documents the change in the changelog.
- Introduce
Tokenparameter and conditionally callAssert-AzureConnection - Update request header to use the provided or generated token
- Add Pester tests for token vs. no-token invocation and bump changelog
- Clean up extra blank lines in existing tests
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Unit/Public/Search-AzResourceGraph.tests.ps1 | Added tests to verify Assert-AzureConnection is called only when no token is supplied |
| tests/Unit/Private/Assert-AzureConnection.tests.ps1 | Removed trailing blank lines for cleaner formatting |
| CHANGELOG.md | Documented the new Token parameter under “Added” |
| AzResourceGraph/Public/Search-AzResourceGraph.ps1 | Added Token parameter, updated connection logic, and modified the Authorization header |
Comments suppressed due to low confidence (3)
tests/Unit/Public/Search-AzResourceGraph.tests.ps1:58
- Mock the
Assert-AzureConnectionfunction at the start of the Describe block soShould -Invokecan correctly track invocations instead of running the real implementation.
It 'Calls Assert-AzureConnection when not given a token' {
AzResourceGraph/Public/Search-AzResourceGraph.ps1:45
- [nitpick] Clarify in the parameter description that
-Tokenexpects a raw access token (without the "Bearer " prefix) to avoid confusion.
.PARAMETER Token
AzResourceGraph/Public/Search-AzResourceGraph.ps1:96
- [nitpick] Remove the extra blank line after the comma so the new
[Parameter]attributes and$Tokendeclaration align consistently with existing formatting.
[int]$PageSize = 1000,
PalmEmanuel
approved these changes
Jul 3, 2025
Contributor
Contributor
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.
No description provided.