Commit graph

24 commits

Author SHA1 Message Date
Mark Kraus dd02aac3d7 [feature] Fix TestValue to avoid double // in Urls (#4920)
•Adds logic in  Get-WebListenerUrl  to only apply the  TestValue  part of the path if it was supplied.
2017-09-26 09:05:55 +04:00
Mark Kraus b30da378e7 Replace httpbin.org/delay Tests with WebListener (#4905) 2017-09-25 12:50:15 -07:00
Mark Kraus 65cf571b54 Replace httpbin.org/encoding Tests with WebListener (#4869) 2017-09-22 10:09:49 -07:00
Paul Higinbotham 7c8b7eff52 Port tests for constrained language mode (#4816)
* Port tests for constrained language mode
* Added 'RequireAdminOnWindows' for registry access
* Restored Wait-UntilTrue to current state
2017-09-19 14:53:29 -07:00
Mark Kraus a2dd0ca4b5 Replace httpbin.org/redirect Tests with WebListener (#4852) 2017-09-18 09:26:01 -07:00
Steve Lee 4ad313aafb Add tests for Get-Module over remoting (#4787)
Some additional tests that are remoting specific based on code coverage
2017-09-12 17:12:52 -07:00
Dongbo Wang c06ffc4a5c Add a generic file watcher function in HelpersCommon.psm1 (#4775)
Add a generic file watcher function in HelpersCommon.psm1 and update some tests to use the `Wait-FileToBePresent`.
2017-09-12 13:05:47 -07:00
Mark Kraus fd3a003765 Add Multipart Support to Web Cmdlets (#4782)
Partially implements  #2112
- Adds `System.Net.Http.MultipartFormDataContent` as a possible type for `-Body`
- Adds `/Multipart/` test to WebListener 

This allows for the user to create their own `Http.MultipartFormDataContent` object and submit it. Since `multipart/form-data` submissions are highly flexible, adding direct support for it to the CmdLets may over-complicate the command parameters and a limited implementation would not address the broad scope of use cases. This at least allows the user to submit multipart forms using the Web Cmdlets and not have to manage their own `HttpClient`. Once this is introduced, limited multipart implementations can be expanded to use the code in this PR.
2017-09-12 09:41:36 -07:00
Mark Kraus f41461825a Replace httpbin.org/get tests With WebListener (#4738)
* 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
2017-09-08 07:53:04 +04:00
Steve Lee 7c9b188c13 Rename $IsOSX to $IsMacOS (#4757) 2017-09-07 10:34:40 -07:00
James Truher [MSFT] e0b7c23384 Report the same number of tests when run by Travis via cron (#4731) 2017-08-31 15:03:20 -07:00
Mark Kraus 3b2d169c5e Add test WebListener module and tests for Web Cmdlet Certificate Authentication (#4622)
Introduce new test module 'WebListener.psm1'.
Now web HTTPS tests can use it to exclude using external sites.

PowerShell/PowerShell#4609

* [Feature] Add Tests for Web Cmdlet Certificate Authentication

PowerShell/PowerShell#4609

* [feature] Add new app to Publish-PSTestTools refactor tests

also add ASP.NET to .spelling

* [feature] spelling fix

* [feature] revert badssl changes

* [feature] Impliment suggestions

* [feature] Spelling, var rename, port 8443 to 8083

rebase fix conflict

* [feature] Rename to HttpsListener and Module-ize

.

* [feature] password protect ClientCert to fix macOS import issue

* [feature] Rename to WebListener 

* Rename HttpsListener to WebListener
* Switch Listener from Razor pages to MVC
* Address PR feedback
* Adjust tests

* [feature] Address PR feedback

* [feature] Replace missing smeicolons

* [feature] Address PR Feedback

* [feature] Cleanup and minor fix

* Enum was not used
* GetStatus() was not accessing the correct property chain
* Added -Test param to make URL generation smoother in test code and to fix double / issues

* [feature] More minor fixes

* Https when it matters.
* Expand property... not exclude..
* Remove superfluous and outdated ToString() override

* [Feature] Move ClientCeret.pfx to WebListener Module

* Move the cert
* Adjust Get-WebListenerClientCertificate 
* Remove cert from csproj
* ActionResult -> JsonResult (was mistakenly left as ActionResult during testing)..

* [Feature] Move ServerCert.pfx to Module

* Move cert
* Upate csproj
* Update module
* Add/Update README.md's

CI Retest.
2017-08-31 13:30:35 +04:00
Mark Kraus 297bba3fa1 Add support for Content Headers to BasicHtmlWebResponseObject and HtmlWebResponseObject (#4494) 2017-08-21 10:48:25 -07:00
bergmeister ffd39b2853 PSScriptAnalyzer fixes by category (#4261)
- Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'ForEach-Object' (alias is '%' or 'foreach')
- Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'Where-Object' (alias is '?' or 'where')
- Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'Select-Object' (alias is 'select')
- Fix PSScriptAnalyzer warnings of type PSPossibleIncorrectComparisonWithNull. Essentially, $null has to be on the left-hand side when using it for comparison.
- A Test in ParameterBinding.Tests.ps1 needed adapting as this test used to rely on the wrong null comparison
- Replace a subset of tests of kind '($object -eq $null) | Should Be $true' with '$object | Should Be $null'
2017-07-21 21:03:49 -07:00
Steve Lee b70460fb93 updated webcmdlets CI tests to not depend on external website (#4279)
* updated webcmdlets CI tests to not depend on external website

* When used in background runspace, validate listener is working before returning

* fix possible infinite loop waiting for listener to start
2017-07-18 12:33:40 -07:00
Dan Travison ea758a53af Add -SkipHeaderValidation switch to Invoke-WebRequest and Invoke-RestMethod to support adding headers without validating the header value. (#4085)
* Add -SkipHeaderValidation switch to Invoke-WebRequest and Invoke-RestMethod to support adding headers without validating the header value.

* Fix whitespace
2017-07-14 10:24:20 -07:00
Dan Travison 039ed6764d Strip authorization header on redirects with web cmdlets (#3885)
Invoke-WebRequest and Invoke-RestMethod cmdlets will now strip authorization header on redirect unless the new parameter `-PreserveAuthorizationOnRedirect` is specified.

The FullCLR implementation uses WebRequest to perform the request which silently strips the Authorization header when a redirect occurs.

The CoreCLR implementation uses HttpClient to perform the request which does not strip the authorization header. The change explicitly handles the initial redirect, removes the authorization header and submits the request to location in the response.

Fixes #2227
2017-06-15 15:52:08 -07:00
James Truher [MSFT] bc807322ed Alter test httplistener to use a new runspace rather than a job (#3966)
This improves the performance of the listener by not relying on a new
process starting up to run the listener. It improves the debugability
of tests by providing more direct access to the session executing
the listener. It also reverses the blocking nature of starting the
listener. By default, Start-HttpListener will no longer block, you need
to use -Foreground to have Start-HttpListener block. Lastly, create
a way to catch errors if the listener has a problem. If code in the
listener throws, it emits an error record.
2017-06-09 10:12:46 -07:00
Steve Lee 40446c80a7 Support Link Header pagination in WebCmdlets (#3828)
* Support Link Header pagination in WebCmdlets to make it easier for the end user implementing:
https://github.com/PowerShell/PowerShell-RFC/blob/master/2-Draft-Accepted/RFC0021-Link-header-based-pagination-for-WebCmdlets.md

When the response includes a Link Header (https://tools.ietf.org/html/rfc5988#page-6), for Invoke-WebRequest we
create a RelationLink property that is a Dictionary representing the URLs and rel attributes and ensure the
URLs are absolute to make it easier for the developer to use.  For Invoke-RestMethod, we expose a -FollowRelLink
switch to automatically follow 'next' rel links to the end until we hit the optional -MaxRelLink parameter value.

* removed unnecessary refs to namespaces

* addressed code review feedback
2017-05-24 15:54:02 -07:00
Steve Lee f0b03bc57d Test HttpListener so that PowerShell Core tests don't have to rely on an internet web service (#3778) 2017-05-18 15:02:19 -07:00
Ilya e00161a8af Add autoload for TestLanguage.psm1 TestHelpers.psm1 (#3456)
* Add autoload for TestHelpers.psm1

Test.Helpers.psm1 was renamed to TestHelpers.psm1

* Resolve conflit and rebase Add autoload for TestLanguage.psm1

* Remove unneeded comments from PSD1 files

* Rename test modules

Remove approved verbs (Get-Verb) from module names.

* Enhance ShouldBeErrorId to output exception into pipeline for later analysis

* Remove unneeded comments

* Resolve merge conflict
2017-05-17 11:09:27 -07:00
Dongbo Wang 7a55bf98b2 Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 11:52:38 -07:00
Ilya 27b27cc43a Autoload TestRemoting.psm1 (#3430) 2017-03-29 10:11:02 -07:00
Ilya a99fb531e6 Add autoload for test modules (#3342)
Related #3238

1. Add autoload for test modules
2. Move TestHostCS.psm1 to 'test\tools\Modules\' folder
3. Remove explicit load TestHostCS.psm1 from test files
2017-03-26 21:46:39 -07:00