Skip to content

Commit

Permalink
add scopes to extension test
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Feb 12, 2025
1 parent 2ff87c1 commit 693f43a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ Function Invoke-ExecExtensionTest {
$Results = [pscustomobject]@{'Results' = 'Successfully Connected to HIBP' }
}
'GitHub' {
$GitHubResponse = Invoke-GitHubApiRequest -Method 'GET' -Path 'user'
$GitHubResponse = Invoke-GitHubApiRequest -Method 'GET' -Path 'user' -ReturnHeaders
if ($GitHubResponse.login) {
$Results = [pscustomobject]@{ 'Results' = "Successfully connected to GitHub user: $($GitHubResponse.login)" }
if ($GitHubResponse.Headers.'x-oauth-scopes') {
$Results = [pscustomobject]@{ 'Results' = "Successfully connected to GitHub user: $($GitHubResponse.login) with scopes: $($GitHubResponse.Headers.'x-oauth-scopes')" }
} else {
$Results = [pscustomobject]@{ 'Results' = "Successfully connected to GitHub user: $($GitHubResponse.login) using a Fine Grained PAT" }
}
} else {
$Results = [pscustomobject]@{ 'Results' = 'Failed to connect to GitHub. Check your API credentials and try again.' }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ function Invoke-GitHubApiRequest {
try {
$Response = Invoke-RestMethod @RestMethod
if ($ReturnHeaders.IsPresent) {
$ResponseHeaders
$Response | Add-Member -MemberType NoteProperty -Name Headers -Value $ResponseHeaders
return $Response
} else {
$Response
return $Response
}
} catch {
throw $_.Exception.Message
Expand Down

0 comments on commit 693f43a

Please sign in to comment.