GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing github.com — Replace httpbin.org/get tests With WebListener by markekraus · Pull Request #4738 · PowerShell/PowerShell Conversation
Contributor
Some tests which use a loop still call httpbin.org. those will be moved when the other functions they rely on have been added. Also, A few of the tests has disabled reference #2504
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Collaborator
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. Please remove parentheses. It seems the time has come to add
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
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. Unless I'm mistaken, the Parens are required when assign a default value with a statement in a Param block. At your suggestion I tried removing them but I get all kinds of errors. As for moving this to the BeforeAll block, I don't think that makes sense in this context since this is part of the For the more general concern, we could create a variable, but, as we move the other tests over you will see that it will get less possible to do so in the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
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. Ah, sorry - My thoughts was about many
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
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. Please remove parentheses.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Typo '$uri' -> $uri
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of unencapsulated strings in evaluated commands. the command would become
Invoke-WebRequest -Uri http://localhost:8083/Get -CustomMethod GET -Body @{'testparam'='testvalue'}
Which is improper IMO. Does this have to be done? I feel like this change was actually an improvement and I made it everywhere purposefully.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Binding is not preprocessor, we don't parse the variable value, so we shouldn't quote variables. Uri get right string.
My thoughts was that we should use the file pattern.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In this instance the $Command string is later evaluated by Invoke-Expression. $uri is expanded before that evaluation. In instances where the url may contain a $, it would be expanded first during the $command assignment and then when the Invoke-Expression is run on $command the $ in the url would attempt to be expanded again.
# $Field1 is a literal field name, not a variable $uri = 'http://localhost:8083/Get?$Field1=Value1' $Command = "Write-Output $uri" Invoke-Expression $Command
Result:
http://localhost:8083/Get?=Value1
vs:
$uri = 'http://localhost:8083/Get?$Field1=Value1' $Command = "Write-Output '$uri'" Invoke-Expression $Command
Result:
http://localhost:8083/Get?$Field1=Value1
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry again - I lost the context.
Closed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Typo '$uri' -> $uri
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
See this comment
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Closed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We use " ," twice - it is good to use a const.
Do we really have space?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I will create a constant, as for the space, it should be the other way around ", " and yes, the space is there when multiple values are supplied for a given header.
X-Fake-Header: Value1
X-Fake-Header: Value2
and
X-Fake-Header: Value1, Value2
Are equivalent.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
5bd6b82 to
c89de63
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It seems we skip a description for '/' in Readme.md.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The default page will return a list of available tests.
I could make it an explicit section. but honestly, I only include it in the ValidateSet to accommodate scenarios where looping may always provide the -Test param but may not need any more than the default index. / is less of a test and more of a convenience during development of tests.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please clarify. Previously we used Get-WebListenerUrl -Https in tests - do we use by default '/'?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
we do return the / by default.
This is the scenario I included it for:
$Testcases = @( @{ Name = 'Get Test' Test = 'Get' ExpectedResult = 'Foo' Https = $False } @{ Name = 'Cert test' Test = 'Cert' ExpectedResult = 'Bar' Https = $True } @{ Name = 'Default Test' Test = '/' ExpectedResult = 'Baz' Https = $False } ) It "<Name>" -TestCases $TestCases { Param($Name, $Test, $ExpectedResult, $Https) $Url = Get-WebListenerUrl -Test $Test -Https:$Https Invoke-RestMethod | Should Match $ExpectedResult }
-Test is always passed, but a named test might not always be needed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think we need the explicit section for -Test '/', -Test "", -Test $null. Maybe block last two by validate attribute?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The ValidetSet already blocks them:
Get-WebListenerUrl -Test ""
Get-WebListenerUrl : Cannot validate argument on parameter 'Test'. The argument "" does not
belong to the set "Cert,Get,Home,/" specified by the ValidateSet attribute. Supply an argument
that is in the set and then try the command again.
At line:1 char:26
+ Get-WebListenerUrl -Test ""
+ ~~
+ CategoryInfo : InvalidData: (:) [Get-WebListenerUrl], ParameterBindingValidationEx
ception
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-WebListenerUrl
Get-WebListenerUrl -Test $Null
Get-WebListenerUrl : Cannot validate argument on parameter 'Test'. The argument "" does not
belong to the set "Cert,Get,Home,/" specified by the ValidateSet attribute. Supply an argument
that is in the set and then try the command again.
At line:1 char:26
+ Get-WebListenerUrl -Test $Null
+ ~~~~~
+ CategoryInfo : InvalidData: (:) [Get-WebListenerUrl], ParameterBindingValidationEx
ception
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-WebListenerUrl
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think we could add that the page can be used as default for some test as we do in HTTPS tests already.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
heh. I had a blurb about that but removed it thinking it was too wordy (I have a tendency to be overly verbose). I'll add it back.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark Kraus (@markekraus) Sorry for my inconsiderateness today. Thanks for the great work! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) No problem! I was making a lot of tiny changes in a huge context. I got lost a few times making these changes. I suspected it might make for a tough review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It seems WebListener.psm1 is stable now and follow PRs will be small. 😄 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) It actually will change again. I plan on adding a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the be localhost... not just match?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is in a few locations
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
it actually returns localhost:<portnumber> but, I didn't want to couple the port number, which may change, with the individual tests. If 8083 and 8084 will be the permanent ports, then this can be changed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I guess it could be
$result.Output.headers.Host | Should Be $uri.Authority
Sorry, something went wrong.
There was an error while loading. Please reload this page.
348a5ca to
09efb78
Compare
There was an error while loading. Please reload this page.
|
AppVeyor fail is unrelated (#4762) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark Kraus (@markekraus) The test is now pending - so please rebase to pass CI. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
09efb78 to
a35adde
Compare
|
Ilya (@iSazonov) rebased and passing. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark Kraus (@markekraus) Thanks for very useful work! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* Adds the /Get/ functionality to Weblistener * Replaces the tests that rely on httpbin.org/get with WebListener * [Feature] Move HttpBin/Get Tests to WebListener * [Feature] update .spelling * [Feature] Address PR Feedback * [Feature] Add and document Home & / * Readme Update * [Feature] Should Match -> Should Be Rerun CI * [Feature] Rebase and Rerun CI
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.