-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Added check for existence of Location HTTP header before using it #6560
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
Changes from 1 commit
3f2bfb5
6ecc705
d04be33
f44f0db
bcd2588
85c6c2c
b61860b
33dba99
7e54d41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…er to respond correctly
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -828,11 +828,10 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" { | |
# for a redirect response which does not contain a Location header | ||
# the correct redirect status code should be included in the exception message | ||
$StatusCode = [System.Net.HttpStatusCode]$redirectType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use this: [int]$StatusCode = [System.Net.HttpStatusCode]$redirectType Then you no longer need to do |
||
$uri = Get-WebListenerUrl -Test Response -Query @{statuscode = $StatusCode} | ||
$uri = Get-WebListenerUrl -Test Response -Query @{statuscode = $StatusCode.value__} | ||
$command = "Invoke-WebRequest -Uri '$uri' -Headers @{Authorization = 'foo'}" | ||
$response = ExecuteWebCommand -command $command | ||
|
||
$response.Error | Should -Not -BeNullOrEmpty | ||
$response.Error.Exception | Should -BeOfType 'Microsoft.PowerShell.Commands.HttpResponseException' | ||
$response.Error.Exception.Message | Should -Be "Response status code does not indicate success: $(StatusCode.value__) ($StatusCode)." | ||
$response.Error.Exception.Response.StatusCode | Should -Be $StatusCode | ||
|
@@ -2160,11 +2159,10 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" { | |
# for a redirect response which does not contain a Location header | ||
# the correct redirect status code should be included in the exception message | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
$StatusCode = [System.Net.HttpStatusCode]$redirectType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same. |
||
$uri = Get-WebListenerUrl -Test Response -Query @{statuscode = $StatusCode} | ||
$uri = Get-WebListenerUrl -Test Response -Query @{statuscode = $StatusCode.value__} | ||
$command = "Invoke-RestMethod -Uri '$uri' -Headers @{Authorization = 'foo'}" | ||
$response = ExecuteWebCommand -command $command | ||
|
||
$response.Error | Should -Not -BeNullOrEmpty | ||
$response.Error.Exception | Should -BeOfType 'Microsoft.PowerShell.Commands.HttpResponseException' | ||
$response.Error.Exception.Message | Should -Be "Response status code does not indicate success: $(StatusCode.value__) ($StatusCode)." | ||
$response.Error.Exception.Response.StatusCode | Should -Be $StatusCode | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should include a note about this requiring a Authorization header. Something like
It's a mouth full, but at least people will understand why we are doing what seems like a superfluous set of tests.