Open markekraus opened 7 years ago
Code coverage report: Covered 0 % of 66 analyzed Commands in Invoke-GraphRequest Missed commands:
Invoke-GraphRequest
Write-Verbose "Performing token refresh"
$AccessToken
Update-GraphOauthAccessToken -ErrorAction Stop
$ErrorMessage = "Unable to refresh Access Token '{0}': {1}" -f $AccessToken.GUID, $_.Exception.Message
Write-Error $ErrorMessage
if (-not $pscmdlet.ShouldProcess("$Uri")) { ...
Write-Verbose "Set base parameters"
$Params = @{ ...
ContentType = $ContentType
Uri = $Uri
WebSession = $AccessToken.Session
Method = $Method
ErrorAction = 'Stop'
if ($Body) { ...
Write-Verbose "Setting Body Parameter"
$Params['Body'] = $Body
if ($TimeoutSec) { ...
Write-Verbose "Setting TimeoutSec Parameter"
$Params['TimeoutSec'] = $TimeoutSec
Write-Verbose "Setting Headers Parameter"
$Params['Headers'] = @{ }
if ($Headers) { ...
Write-Verbose "Setting user supplied headers"
$Params['Headers'] = $Headers
Write-Verbose "Setting Authorization header"
$Params['Headers']['Authorization'] = 'Bearer {0}' -f $AccessToken.GetAccessToken()
$RequestedDate = Get-Date
$Result = Invoke-WebRequest @Params
$ReceivedDate = Get-Date
$response = $_.Exception.Response
$Stream = $response.GetResponseStream()
$Stream.Position = 0
$StreamReader = New-Object System.IO.StreamReader $Stream
$ResponseBody = $StreamReader.ReadToEnd()
$ErrorMessage = "Unable to query Uri '{0}': {1}: {2}" -f $Uri, $_.Exception.Message, $ResponseBody
Set-Variable -Scope global -Name _invokeGraphRequestException -Value $_
Write-Error -message $ErrorMessage -Exception $_.Exception
Write-Verbose "Truncating Authorization header"
$Params['Headers']['Authorization'] = '{0}...{1}<truncated>' -f $Params.Headers.Authorization.Substring(0, 25), ...
$Params.Headers.Authorization.Length - 11
Write-Verbose "No Authorization header to truncate"
$Result.Headers.'Content-Type'
$_ -match 'application/json'
Write-Verbose "Converting result from JSON to PSObject"
$ConentObject = $Result.Content ...
$_ -match 'application/xml'
Write-Verbose "Converting result from XML to PSObject"
[xml]$ConentObject = $Result.Content
Write-Verbose "Unhandled Content-Type. ContentObject will be raw."
$ConentObject = $Result.Content
Write-Verbose "Setting LastRequestDate on Access Token"
$AccessToken.LastRequestDate = $RequestedDate
[pscustomobject]@{ ...
PSTypeName = 'MSGraphAPI.RequestResult'
Result = $Result
Headers = $Params.Headers
InvokeWebRequestParameters = $Params
TimeoutSec = $TimeoutSec
Body = $Body
RequestedDate = $RequestedDate
RecievedDate = $ReceivedDate
AccessToken = $AccessToken
ContentObject = $ConentObject
Code coverage report: Covered 0 % of 66 analyzed Commands in
Invoke-GraphRequest
Missed commands:Write-Verbose "Performing token refresh"
$AccessToken
Update-GraphOauthAccessToken -ErrorAction Stop
$ErrorMessage = "Unable to refresh Access Token '{0}': {1}" -f $AccessToken.GUID, $_.Exception.Message
Write-Error $ErrorMessage
if (-not $pscmdlet.ShouldProcess("$Uri")) { ...
Write-Verbose "Set base parameters"
$Params = @{ ...
ContentType = $ContentType
Uri = $Uri
WebSession = $AccessToken.Session
Method = $Method
ErrorAction = 'Stop'
if ($Body) { ...
Write-Verbose "Setting Body Parameter"
$Params['Body'] = $Body
if ($TimeoutSec) { ...
Write-Verbose "Setting TimeoutSec Parameter"
$Params['TimeoutSec'] = $TimeoutSec
Write-Verbose "Setting Headers Parameter"
$Params['Headers'] = @{ }
if ($Headers) { ...
Write-Verbose "Setting user supplied headers"
$Params['Headers'] = $Headers
Write-Verbose "Setting Authorization header"
$Params['Headers']['Authorization'] = 'Bearer {0}' -f $AccessToken.GetAccessToken()
$RequestedDate = Get-Date
$Result = Invoke-WebRequest @Params
$ReceivedDate = Get-Date
$response = $_.Exception.Response
$Stream = $response.GetResponseStream()
$Stream.Position = 0
$StreamReader = New-Object System.IO.StreamReader $Stream
$ResponseBody = $StreamReader.ReadToEnd()
$ErrorMessage = "Unable to query Uri '{0}': {1}: {2}" -f $Uri, $_.Exception.Message, $ResponseBody
Set-Variable -Scope global -Name _invokeGraphRequestException -Value $_
Write-Error -message $ErrorMessage -Exception $_.Exception
Write-Verbose "Truncating Authorization header"
$Params['Headers']['Authorization'] = '{0}...{1}<truncated>' -f $Params.Headers.Authorization.Substring(0, 25), ...
$Params.Headers.Authorization.Length - 11
Write-Verbose "No Authorization header to truncate"
$Result.Headers.'Content-Type'
$_ -match 'application/json'
Write-Verbose "Converting result from JSON to PSObject"
$ConentObject = $Result.Content ...
$ConentObject = $Result.Content ...
$_ -match 'application/xml'
Write-Verbose "Converting result from XML to PSObject"
[xml]$ConentObject = $Result.Content
Write-Verbose "Unhandled Content-Type. ContentObject will be raw."
$ConentObject = $Result.Content
Write-Verbose "Setting LastRequestDate on Access Token"
$AccessToken.LastRequestDate = $RequestedDate
[pscustomobject]@{ ...
PSTypeName = 'MSGraphAPI.RequestResult'
Result = $Result
Uri = $Uri
Headers = $Params.Headers
InvokeWebRequestParameters = $Params
ContentType = $ContentType
TimeoutSec = $TimeoutSec
Body = $Body
RequestedDate = $RequestedDate
RecievedDate = $ReceivedDate
AccessToken = $AccessToken
ContentObject = $ConentObject