Skip to content

Conversation

@markekraus
Copy link
Contributor

@markekraus markekraus commented Dec 10, 2017

PR Summary

PR Checklist

Note: Please mark anything not applicable to this PR NA.

$result = ExecuteWebCommand -command $command

$result.Error.ErrorDetails.Message | Should Match "\-=\[ teapot \]"
$result.Error.ErrorDetails.Message | Should be $query.body
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo be -> Be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will Fix

Copy link
Contributor Author

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)
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe 'Should Be' too?

Copy link
Contributor Author

@markekraus markekraus Dec 11, 2017

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)

Copy link
Collaborator

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)?

Copy link
Contributor Author

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'
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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" 

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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?

Copy link
Contributor Author

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'
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Copy link
Contributor Author

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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"
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add

Copy link
Contributor Author

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same.

Copy link
Contributor Author

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){
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@iSazonov iSazonov self-assigned this Dec 11, 2017
@markekraus markekraus changed the title Replace Remaining HttpBin.org Tests with WebListener WIP: Replace Remaining HttpBin.org Tests with WebListener Dec 11, 2017
@markekraus markekraus changed the title WIP: Replace Remaining HttpBin.org Tests with WebListener Replace Remaining HttpBin.org Tests with WebListener Dec 11, 2017
ASP.NET Core 2.0 app for testing HTTP and HTTPS Requests.

# Run with `dotnet`
## Run with `dotnet`
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not.

$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-io
Copy link

codecov-io commented Dec 12, 2017

Codecov Report

Merging #5665 into master will increase coverage by 18.5%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
...on/engine/remoting/commands/PushRunspaceCommand.cs 15.17% <0%> (+0.15%) ⬆️
...ion/engine/remoting/fanin/WSManTransportManager.cs 64.11% <0%> (+0.23%) ⬆️
....Management.Automation/help/UpdatableHelpSystem.cs 61.87% <0%> (+0.26%) ⬆️
...Automation/engine/remoting/client/ThrottlingJob.cs 81.16% <0%> (+0.26%) ⬆️
...tion/engine/interpreter/ControlFlowInstructions.cs 82.93% <0%> (+0.29%) ⬆️
src/Microsoft.WSMan.Management/WsManHelper.cs 41.81% <0%> (+0.38%) ⬆️
src/System.Management.Automation/engine/Pipe.cs 78.26% <0%> (+0.39%) ⬆️
src/Microsoft.WSMan.Management/ConfigProvider.cs 73.36% <0%> (+0.41%) ⬆️
...on/engine/interpreter/CallInstruction.Generated.cs 32.38% <0%> (+0.47%) ⬆️
...nt.Automation/namespaces/NavigationProviderBase.cs 72.84% <0%> (+0.52%) ⬆️
... and 626 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2a9c1ca...466d019. Read the comment docs.

Copy link

@anmenaga anmenaga left a 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.

@iSazonov
Copy link
Collaborator

Reopen to restart AppVeyor CI

@iSazonov iSazonov closed this Dec 13, 2017
@iSazonov iSazonov reopened this Dec 13, 2017
@iSazonov iSazonov merged commit 19197e1 into PowerShell:master Dec 13, 2017
@TravisEz13 TravisEz13 added this to the 6.0.0-GA milestone Dec 16, 2017
TravisEz13 pushed a commit to TravisEz13/PowerShell that referenced this pull request Dec 19, 2017
•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
@TravisEz13 TravisEz13 mentioned this pull request Dec 19, 2017
TravisEz13 pushed a commit that referenced this pull request Dec 19, 2017
•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
@markekraus markekraus deleted the ReplaceHttpBin branch January 19, 2018 18:59
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

Successfully merging this pull request may close these issues.

Make Web Cmdlets Tests More Terse Friendly

5 participants