Replace Remaining HttpBin.org Tests with WebListener#5665
Replace Remaining HttpBin.org Tests with WebListener#5665iSazonov merged 2 commits intoPowerShell:masterfrom
Conversation
7412274 to
70fab5c
Compare
| $result = ExecuteWebCommand -command $command | ||
|
|
||
| $result.Error.ErrorDetails.Message | Should Match "\-=\[ teapot \]" | ||
| $result.Error.ErrorDetails.Message | Should be $query.body |
| $testMethods = @("POST", "PATCH", "PUT", "DELETE") | ||
| $contentTypes = @("text/plain", "application/xml", "application/json") | ||
|
|
||
| foreach ($contentType in $contentTypes) |
There was a problem hiding this comment.
Minor comment - I'd prefer TestCases here.
There was a problem hiding this comment.
I have an open issue somewhere about refactoring the web cmdlet tests. There is much room for improvement.
| { | ||
| $jsonContent.data | Should Match $body | ||
| } | ||
| $jsonContent.data | Should Match $body |
There was a problem hiding this comment.
I can try changing it. I assumed there was specific logic to use match for some good reason. if you look at the if block above they have Should Be for application/xml but match for everything else. *shrugs (same for the other block liek this)
There was a problem hiding this comment.
My question was just about the "some good reason".
Right question is - should we expect that Invoke-WebRequest change the body (add/remove whitespaces)?
| It "Validate Invoke-WebRequest default ContentType for CustomMethod POST" { | ||
|
|
||
| $command = "Invoke-WebRequest -Uri 'http://httpbin.org/post' -CustomMethod POST -Body 'testparam=testvalue'" | ||
| $uri = Get-WebListenerUrl -Test 'Post' |
There was a problem hiding this comment.
The test header say "default ContentType" but why the test don't check a content type name?
There was a problem hiding this comment.
Default content type as in -ContentType is not specified. see the line below this.
There was a problem hiding this comment.
I think I misinterpreted the question. The headline says we're checking the default content type, but inside the test we're not doing it. I expect something like
$jsonContent.headers.'Content-Type' | Should Be "default-content-type-value"
There was a problem hiding this comment.
I will take another look at the surrounding code and try to determine what this test was really looking for.
There was a problem hiding this comment.
I'm not 100% sure what this is testing for, so i added the Headers test.
Fixed
|
|
||
| $result.Error.ErrorDetails.Message | Should Match "\-=\[ teapot \]" | ||
| $result.Error.ErrorDetails.Message | Should be $query.body | ||
| $result.Error.Exception | Should BeOfType Microsoft.PowerShell.Commands.HttpResponseException |
There was a problem hiding this comment.
Minor comment - could you please put the type in quotes?
| It "Validate Invoke-RestMethod default ContentType for CustomMethod POST" { | ||
|
|
||
| $command = "Invoke-RestMethod -Uri 'http://httpbin.org/post' -CustomMethod POST -Body 'testparam=testvalue'" | ||
| $uri = Get-WebListenerUrl -Test 'Post' |
There was a problem hiding this comment.
The same about default ContentType.
|
|
||
| $result.Error.ErrorDetails.Message | Should Match "\-=\[ teapot \]" | ||
| $result.Error.ErrorDetails.Message | Should Be $query.body | ||
| $result.Error.Exception | Should BeOfType Microsoft.PowerShell.Commands.HttpResponseException |
There was a problem hiding this comment.
The same minor comment about quotes.
| $result = Invoke-WebRequest -InFile $filePath -Uri $uri -Method Post | ||
| $content = $result.Content | ConvertFrom-Json | ||
| $content.form | Should Match "hello" | ||
| $content.form.hello[0] | Should Match "world" |
There was a problem hiding this comment.
I think we should check $content.form.hello.Count | Should Be 1 before the line.
| $result = Invoke-RestMethod -InFile $filePath -Uri http://httpbin.org/post -Method Post | ||
| $result.form | Should Match "hello" | ||
| $result = Invoke-RestMethod -InFile $filePath -Uri $uri -Method Post | ||
| $result.form.hello[0] | Should Match "world" |
| {"method" , Request.Method} | ||
| }; | ||
|
|
||
| if(Request.HasFormContentType){ |
There was a problem hiding this comment.
Typo - spaces skipped and the brace to next line.
63b3559 to
466d019
Compare
| ASP.NET Core 2.0 app for testing HTTP and HTTPS Requests. | ||
|
|
||
| # Run with `dotnet` | ||
| ## Run with `dotnet` |
There was a problem hiding this comment.
Is this file included in the markdown meta test?
There was a problem hiding this comment.
It is not.
PowerShell/test/common/markdown/markdown.tests.ps1
Lines 74 to 85 in 4dc5512
You you prefer that it be added?
Codecov Report
@@ Coverage Diff @@
## master #5665 +/- ##
==========================================
+ Coverage 42.39% 60.9% +18.5%
==========================================
Files 924 924
Lines 274195 274195
==========================================
+ Hits 116258 166994 +50736
+ Misses 157937 107201 -50736
Continue to review full report at Codecov.
|
anmenaga
left a comment
There was a problem hiding this comment.
AppVeyor test pass does not look complete as if something hang. @daxian-dbw can you please restart AppVeyor test run? Thank you.
|
Reopen to restart AppVeyor CI |
•Replaces all remaining test that rely on httpbin.org •Adds Put, Post, Patch, and Delete tests to WebListener by means of routes to Get test and modifications to the Get controller. •Adds responsephrase option to the Response test to accommodate error message tests •removed redundant GET tests from irm and iwr tests. •Fixed markdown linting errors in README.md for WebListener
•Replaces all remaining test that rely on httpbin.org •Adds Put, Post, Patch, and Delete tests to WebListener by means of routes to Get test and modifications to the Get controller. •Adds responsephrase option to the Response test to accommodate error message tests •removed redundant GET tests from irm and iwr tests. •Fixed markdown linting errors in README.md for WebListener
PR Summary
responsephraseoption to the Response test to accommodate error message testsGETtests from irm and iwr tests.PR Checklist
Note: Please mark anything not applicable to this PR
NA.[feature]if the change is significant or affectes feature testsWIP:to the beginning of the title and remove the prefix when the PR is ready.