-
Notifications
You must be signed in to change notification settings - Fork 22
100% Code Coverage for Invoke-GraphRequest #21
Copy link
Copy link
Open
Milestone
Description
Code coverage report:
Covered 0 % of 66 analyzed Commands in Invoke-GraphRequest
Missed commands:
| Line | Command |
|---|---|
| 134 | Write-Verbose "Performing token refresh" |
| 135 | $AccessToken |
| 135 | Update-GraphOauthAccessToken -ErrorAction Stop |
| 138 | $ErrorMessage = "Unable to refresh Access Token '{0}': {1}" -f $AccessToken.GUID, $_.Exception.Message |
| 139 | Write-Error $ErrorMessage |
| 142 | if (-not $pscmdlet.ShouldProcess("$Uri")) { ... |
| 145 | Write-Verbose "Set base parameters" |
| 146 | $Params = @{ ... |
| 147 | ContentType = $ContentType |
| 148 | Uri = $Uri |
| 149 | WebSession = $AccessToken.Session |
| 150 | Method = $Method |
| 151 | ErrorAction = 'Stop' |
| 153 | if ($Body) { ... |
| 154 | Write-Verbose "Setting Body Parameter" |
| 155 | $Params['Body'] = $Body |
| 157 | if ($TimeoutSec) { ... |
| 158 | Write-Verbose "Setting TimeoutSec Parameter" |
| 159 | $Params['TimeoutSec'] = $TimeoutSec |
| 161 | Write-Verbose "Setting Headers Parameter" |
| 162 | $Params['Headers'] = @{ } |
| 163 | if ($Headers) { ... |
| 164 | Write-Verbose "Setting user supplied headers" |
| 165 | $Params['Headers'] = $Headers |
| 167 | Write-Verbose "Setting Authorization header" |
| 168 | $Params['Headers']['Authorization'] = 'Bearer {0}' -f $AccessToken.GetAccessToken() |
| 169 | $RequestedDate = Get-Date |
| 171 | $Result = Invoke-WebRequest @Params |
| 172 | $ReceivedDate = Get-Date |
| 175 | $response = $_.Exception.Response |
| 176 | $Stream = $response.GetResponseStream() |
| 177 | $Stream.Position = 0 |
| 178 | $StreamReader = New-Object System.IO.StreamReader $Stream |
| 179 | $ResponseBody = $StreamReader.ReadToEnd() |
| 180 | $ErrorMessage = "Unable to query Uri '{0}': {1}: {2}" -f $Uri, $_.Exception.Message, $ResponseBody |
| 181 | Set-Variable -Scope global -Name _invokeGraphRequestException -Value $_ |
| 182 | Write-Error -message $ErrorMessage -Exception $_.Exception |
| 185 | Write-Verbose "Truncating Authorization header" |
| 187 | $Params['Headers']['Authorization'] = '{0}...{1}<truncated>' -f $Params.Headers.Authorization.Substring(0, 25), ... |
| 188 | $Params.Headers.Authorization.Length - 11 |
| 191 | Write-Verbose "No Authorization header to truncate" |
| 193 | $Result.Headers.'Content-Type' |
| 194 | $_ -match 'application/json' |
| 195 | Write-Verbose "Converting result from JSON to PSObject" |
| 196 | $ConentObject = $Result.Content ... |
| 196 | $ConentObject = $Result.Content ... |
| 199 | $_ -match 'application/xml' |
| 200 | Write-Verbose "Converting result from XML to PSObject" |
| 201 | [xml]$ConentObject = $Result.Content |
| 205 | Write-Verbose "Unhandled Content-Type. ContentObject will be raw." |
| 206 | $ConentObject = $Result.Content |
| 209 | Write-Verbose "Setting LastRequestDate on Access Token" |
| 210 | $AccessToken.LastRequestDate = $RequestedDate |
| 211 | [pscustomobject]@{ ... |
| 212 | PSTypeName = 'MSGraphAPI.RequestResult' |
| 213 | Result = $Result |
| 214 | Uri = $Uri |
| 215 | Headers = $Params.Headers |
| 216 | InvokeWebRequestParameters = $Params |
| 217 | ContentType = $ContentType |
| 218 | TimeoutSec = $TimeoutSec |
| 219 | Body = $Body |
| 220 | RequestedDate = $RequestedDate |
| 221 | RecievedDate = $ReceivedDate |
| 222 | AccessToken = $AccessToken |
| 223 | ContentObject = $ConentObject |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels