-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Replace Remaining HttpBin.org Tests with WebListener #5665
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
Conversation
7412274 to
70fab5c
Compare
| $result = ExecuteWebCommand -command $command | ||
|
|
||
| $result.Error.ErrorDetails.Message | Should Match "\-=\[ teapot \]" | ||
| $result.Error.ErrorDetails.Message | Should be $query.body |
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.
Typo be -> Be.
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.
Will Fix
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.
fixed
| $testMethods = @("POST", "PATCH", "PUT", "DELETE") | ||
| $contentTypes = @("text/plain", "application/xml", "application/json") | ||
|
|
||
| foreach ($contentType in $contentTypes) |
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.
Minor comment - I'd prefer TestCases here.
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.
I have an open issue somewhere about refactoring the web cmdlet tests. There is much room for improvement.
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.
| { | ||
| $jsonContent.data | Should Match $body | ||
| } | ||
| $jsonContent.data | Should Match $body |
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.
Maybe 'Should Be' too?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question was just about the "some good reason".
Right question is - should we expect that Invoke-WebRequest change the body (add/remove whitespaces)?
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.
fixed
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test header say "default ContentType" but why the test don't check a content type name?
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.
Default content type as in -ContentType is not specified. see the line below this.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment - could you please put the type in quotes?
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.
fixed
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same about default ContentType.
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.
same as above.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same minor comment about quotes.
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.
fixed
| $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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should check $content.form.hello.Count | Should Be 1 before the line.
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.
will add
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.
fixed
| $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" |
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.
The same.
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.
fixed
| {"method" , Request.Method} | ||
| }; | ||
|
|
||
| if(Request.HasFormContentType){ |
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.
Typo - spaces skipped and the brace to next line.
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.
will fix
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.
fixed
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file included in the markdown meta test?
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.
It is not.
PowerShell/test/common/markdown/markdown.tests.ps1
Lines 74 to 85 in 4dc5512
| $docsToTest = @( | |
| './*.md' | |
| './docs/*.md' | |
| './docs/building/*.md' | |
| './docs/cmdlet-example/*.md' | |
| './docs/installation/*.md' | |
| './docs/maintainers/README.md' | |
| './demos/SSHRemoting/*.md' | |
| './docker/*.md' | |
| './tools/*.md' | |
| './.github/CONTRIBUTING.md' | |
| ) |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.