Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100% Code Coverage for Invoke-GraphRequest #21

Open
markekraus opened this issue Apr 22, 2017 · 0 comments
Open

100% Code Coverage for Invoke-GraphRequest #21

markekraus opened this issue Apr 22, 2017 · 0 comments

Comments

@markekraus
Copy link
Owner

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
@markekraus markekraus added this to the 100% Code Coverage milestone Apr 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant