Commit graph

1372 commits

Author SHA1 Message Date
Ilya 84344cbb32 Update PowerShell to build with .NET Core SDK 2.1.300-rc1-008662 (#6718)
* Build Update
- Change `TargetFramework` to `netcoreapp2.1` and removed unnecessary `RuntimeFrameworkVersion` from `PowerShell.Common.props`
- Update dotnet SDK to 2.1.300-rc1-008662
- Update `TypeGen` target in `Build.psm1` to work with 2.1
- Rename macOS runtime to `osx-x64` as the old build logic expects 10.12 and breaks running on 10.13 system.
- Remove `PackageReference` to `System.Memory` as it's part of dotnetcore 2.1
- Update search for `crossgen` executable to find the matching version

* Test Update
- Update test tools `WebListener` to latest `asp.net core`
- Marked `AuthHeader Redirect` tests as `Pending` due to change in CoreFX
2018-05-02 16:58:39 -07:00
Dan Travison 385cc1b796 Disallow Basic Auth over HTTP on Unix (#6787)
Disallow Basic Auth over HTTP on Unix

Fix: #6779
2018-05-02 14:29:10 -07:00
Steve Lee 77d10e969e Fix Format-Table where rows were being trimmed unnecessarily if there's only one row of headers (#6772) 2018-05-02 17:59:48 +05:00
Aditya Patwardhan c51a6e38cf
Fix test and infrastructure blocking code coverage runs (#6790)
* Fix Remove-Item test to use a test directory instead of relying on pre-existing directory
* Increase timeout as we are regularly going over it.
2018-05-01 17:28:57 -07:00
Robert Holt 9ca059dcf8 Revert changes from PR #6600 which cause a regression in drive behavior (#6751)
This reverts the commit 35d8de927b, which caused a regression in drive behavior where drive paths were not restored. See issue #6749.
2018-04-30 15:25:11 -07:00
Klaudia Algiz bee98547e4 Fix Select-Object.Tests.ps1 which might fail for Unix OS. (#6747)
Fix Select-Object.Tests.ps1 which might fail for Unix OS.
In the test, the processes which name matches i* are selected and it checks if there is non zero number of these processes. The test assumes that there is always at least one process, probably `init` - idle, but on Unix idle process does not have the name and hence the test might fail
2018-04-30 13:09:16 -07:00
Robert Holt 0c3f429780 Add tests for PowerShell classes inheriting from abstract .NET classes (#6752) 2018-04-30 10:17:20 -07:00
Sergey Vasin 24069241bc Fix CimCmdlets tests. (#6755) 2018-04-28 09:48:13 +05:00
Aditya Patwardhan 2c3177a08d Add tests for PowerShell hosting API to verify MyGet packages (#6737) 2018-04-27 13:25:33 -07:00
Ilya ffa7e4bac0 Enhance and refactor Add-Type cmdlet (#6141)
- Can compile a source from strings (TypeDefinition and MemberDefinition).
- Can compile from files.
- Can compile only to a file (without loading the produced assembly).
- Do not recompile and don't reload if the sources have not changed.
- Implement `-IgnoreWarnings` to not treat warnings as errors. By default, the cmdlet considers warnings as errors.
- Add VisualBasic support.
- Add new `-CompilerOptions` parameter to allow setting Roslyn command line parameters including:
    - Parser options.
    - Compile options.
    - Emit options.

**ATTENTION:** The `CompilerOptions` can be specified along with other options like `-OutputAssembly`, `-Language` and `-IgnoreWarnings`. The explicit setting parameters will take precedence over the same settings specified in `-CompileOptions`.

See docs about the compiler options:
https://github.com/dotnet/roslyn/blob/master/docs/compilers/CSharp/CommandLine.md
https://github.com/dotnet/roslyn/blob/master/docs/compilers/Visual%20Basic/CommandLine.md

**ATTENTION:** `-OutputType` default is `Library`. If `-OutputType` is absent the `-OutputType` default overlaps a value in `CompileOptions`. In other words output type ("target" ot "t" in command line) is always ignored in `CompileOptions`. We have to use `-OutputType` to set an output type.
2018-04-25 22:40:26 -07:00
Robert Holt 63c0d8d783 Add error handling for interactive #requires (#6469) 2018-04-25 18:04:04 -07:00
Klaudia Algiz 4b149e4191 Use new Pester syntax for Pester tests in module PSDesiredStateConfiguration (#6622) 2018-04-25 17:29:40 -07:00
Matthew Bobke 35d8de927b Fix New-Item to work correctly when given path is drive root and $PWD is a sub folder of the drive root. (#6600) 2018-04-25 14:32:57 -07:00
Steve Lee a9d10dda42 Fix two tests that are failing on nightly run (#6723)
- For ConsoleHosts tests, the test is validating error condition, but did not redirect stderr to stdout so the output isn't captured and thus an empty string failing the assertion.
- For SSHConnectionInfo API tests, it's calling a constructor that got overwritten with a new parameter. Fix is to put back that public API and overload it with a new one.
2018-04-24 16:25:55 -07:00
Ilya 313a8596bb
Pretty print Export-FormatData XML output (#6691)
Pretty print Export-FormatData XML output by default.
Refactor Export-FormatData tests, remove test duplications.
2018-04-24 10:04:42 +05:00
Steve Lee 942c68e796 Add '-WorkingDirectory' parameter to pwsh (#6612)
Add `-WorkingDirectory` parameter to `pwsh` to allow starting in right working directory.
2018-04-23 14:27:47 -07:00
Ilya 2da7576736
Add tests for Format-Table -Wrap (#6670) 2018-04-23 12:45:14 +05:00
Ilya 5a326135ec
Add new reliable tests for Get-Date -UFormat (#6614) 2018-04-19 13:58:29 +05:00
Paul Higinbotham 80951777cf Port Windows PowerShell AppLocker and DeviceGuard UMCI application white listing support (#6133)
These changes port Windows PowerShell support for Applocker and DeviceGuard User Mode Code Integrity (UMCI) to PSCore6. Windows PowerShell uses public APIs to determine if a system is in locked down mode via AppLocker or DeviceGuard, and automatically runs in constrained language mode. For more information about PowerShell constrained language, see: https://blogs.msdn.microsoft.com/powershell/2017/11/02/powershell-constrained-language-mode/

This support for application whitelisting has mostly existed in PSCore6, but the primary APIs were stubbed out in CorePSStub.cs because they relied on Windows only DeviceGuard (wldp.dll) and AppLocker (Safer APIs) public APIs. These changes re-implement PowerShell lock down APIs on PSCore6 for Windows platforms only. The AppLocker and DeviceGuard public APIs are currently only implemented in Windows OSes and are not supported on Linux or MacOS platforms.

Tests have also been ported to PSCore6 and run only for Windows platforms.
2018-04-17 13:09:17 -07:00
Ilya 62bb0899ac
Reformat Format-Table tests (#6657)
* Convert identations to spaces
* Remove alias tests and extra lines
* Remane extra Describe
* Remove extra parentheses and add spaces
2018-04-17 10:06:39 +05:00
Joey Aiello feb38cff70 Remove extraneous SSH and install docs from the 'demos' folder (#6628) 2018-04-13 15:50:54 -07:00
Steve Lee c2accff785 Support importing module paths that end in trailing directory separator (#6602) 2018-04-13 08:07:50 +04:00
Sergey Vasin 25dbc68b8e Fix formatting in Add-Content.Tests.ps1 file. (#6591)
* Fix formatting.
* Capitalize TestDrive and add empty strings.
2018-04-11 07:23:30 +04:00
Klaudia Algiz 3cd2308af9 Create the default PSSession configuration, not tied to a specific PowerShell version. (#6519)
Create the default PSSession configuration, not tied to a specific PowerShell version.

When Enable-PSRemoting command is run, it creates 2 sessions configurations:

first, the same as it was before with the name containing the current version expressed as: 'PowerShell.$PSVersionTable.GitCommitId'
second with the default name 'PowerShell.6' so that administrators wouldn't have to guess which specific version is installed on the target.
PR addresses the issue: #6470
2018-04-10 12:21:44 -07:00
Mark Kraus 18e6a5c654 Add Missing Start-WebListener to Web Cmdlet Tests (#6604) 2018-04-10 10:12:45 +04:00
Ilya 6bd70bc2d0
Some fixes in Get-Date -UFormat (#6542)
* Use UTC datetime in Get-Date -UFormat %s
Fix %l output from 0..11 to 1..12
Fix %V using Gregorian calendar

* Use a workaround for ISO 8601 week of year (uformat %V)
2018-04-10 08:13:19 +04:00
Sergey Vasin 3ec98bbbe8 Fix typos and formatting in Clear-Content.Tests.ps1 (#6592)
* Fix typos and formatting.
* Capitalize function parameters.
2018-04-10 07:47:39 +04:00
Sergey Vasin a3e8929d6a Fix formatting Clear-EventLog.Tests.ps1 (#6594) 2018-04-10 07:17:52 +04:00
Sergey Vasin ca5aacca16 Fix formatting in Clear-Item.Tests.ps1. (#6593) 2018-04-09 16:24:01 +04:00
Sergey Vasin 9d3c2633e7 Fix formatting in Convert-Path.Tests.ps1. (#6595) 2018-04-09 16:22:45 +04:00
Sergey Vasin 1f7b3a65d3 Fix Copy.Item.Tests.ps1 (#6596)
Fix formatting, absent parameter names and use -Throw and -ErrorID parameters with Should function.
2018-04-09 16:21:47 +04:00
Florian Feldhaus 94c8ce007d Added check for existence of Location HTTP header before using it (#6560)
The HTTP RFC (https://tools.ietf.org/html/rfc7231#section-6.4) does not require a Location header to be present for redirects, thus it is required to check if the Location header is returned before using it.
2018-04-08 16:51:17 +04:00
Sergey Vasin 4554679a08 Use -Throw and -ErrorId native Pester parameters. (#6574) 2018-04-06 16:15:37 +04:00
Dongbo Wang e0b1f1f3af
Fix line ending in 'DefaultCommands.Tests.ps1' from CRLF to LF (#6553) 2018-04-03 13:32:16 -07:00
Ilya 24cf020442 Add ported Test-Connection cmdlet (#5328)
The Test-Connection cmdlet works on Windows and Unix.

Implemented:
Ping
Continues Ping
Traceroute
Detect MTU size (seems don't work on Unix because of .Net Core issue)
Connect to TCP port
Not jet implemented:
I'm putting this off for the future.

Detect blackhole routers
PingPath
Additional considerations
As you can see in the tests .Net Core has issues in API implementation. As a result, some tests are skipped on Unix. There is also one issue on Windows. Related comments added to tests.
I'm going to open an issue(s) in CoreFX repo.

I think we should break the feedback into two parts:

scripting functionality
interactive functionality (display output)
Now I have implemented the output to the screen as the progress bar and as text (without ETS) - we have to decide what is best to use.
2018-04-03 11:59:26 -07:00
Takuya Shibata cd1d2d2063 Fix error when 'Format-Wide -AutoSize | Out-String' is called. (#6491)
* Add checking if an output width is specified.

* change _failedToReadConsoleWidth variable to _noConsole bool value. 
This variable is to cache the default console width when failed to get 'Console.WindowWidth' value.
2018-04-03 11:17:05 -07:00
Klaudia Algiz f0b6ef2eb4 Terminate the loop in PsUtils.GetMainModule() which was infinite in case there was no main module. (#6358)
* Terminate the loop in GetMainModule if main module is null.

* Run tests with FileVersionInfo also on non-windows platforms. Add test for process which main module can be null.
2018-04-03 10:58:06 -07:00
Steve Lee 5d3456d11b Fix formatting of tables where headers span multiple rows (#6504)
* In cases where the header spans multiple rows, need to correctly calculate whitespace and trim appropriately

* Use System.Span<int> and C# 7.2 language in SMA

* Added new ref assemblies to Files.wxs
refactor tests to remove similar xml content
added single column test case
2018-04-03 07:24:23 +04:00
Dongbo Wang d1cf82ec20 Clean up workflow logic in the module loading component (#6523)
Clean up workflow logic in the module loading component.
Workflow module is not supported in PSCore.
Currently, Import-Module throws a terminating error when seeing .xaml modules. After the change, Import-Module throws a non-terminating error when seeing .xaml modules.
2018-04-02 16:18:56 -07:00
Aditya Patwardhan 610ae1a63f Update 'Update-Help' to save help content in user scope by default (#6352)
Add the parameter `-Scope` to `Update-Help`, which takes `AllUsers` or `CurrentUser`. The default value is `CurrentUser`.
2018-04-02 15:32:55 -07:00
Aditya Patwardhan 260c16ff4f
Mark Save-Help PackageManagement tests as pending (#6545) 2018-04-02 14:07:02 -07:00
Travis Plunk 77f36498e6
Simplify the paths the MSI uses (#6442)
- Implementation of PowerShell/PowerShell-RFC#115 (If anything changes in the RFC, we will treat it as a bug, and fix it later)
- Update registry and directory paths to use 6 for the version for stable and 6-preview for a preview release
- Add checkbox to set path
- default checkbox to off for preview builds and on for stable builds
2018-04-02 10:47:29 -07:00
Kevin Marquette 986a9eeecd Remove empty Should -Be statements (#6536) 2018-04-01 15:05:45 +04:00
Kevin Marquette e3ba6bd92c Fixed scenarios where NullOrEmpty string was used instead of -BeNullOrEmpty (#6535) 2018-04-01 15:05:08 +04:00
Kevin Marquette 404e876740 Use new Pester syntax: -Parameter for Pester tests in modules: PowerShellGet, PackageManagement, PSReadLine (#6488) 2018-03-30 09:22:26 +04:00
Dongbo Wang cd075ea4b4 Make LanguagePrimitive.GetEnumerable treat 'DataTable' as Enumerable (#6511)
* Make LanguagePrimitive.GetEnumerable treat 'DataTable' as Enumerable
2018-03-29 16:22:44 -07:00
Dan Travison ec0f1116db Add PowerShell logging tests for macOS and Linux (#6025)
This PR fixes the logging issue on Linux where logging is initialized before `-settingsFile` is parsed causing custom log settings to be ignored. (see ConsoleHost.cs and ManagedEntrance.cs)

The PR also includes basic logging tests for Linux and MacOS. PSSyslog.psm1 contains the functions to retrieve selected logged items (based on PowerShell's log id and a timestamp) and Logging.Tests.ps1 contains tests for Linux and MacOS.
2018-03-29 14:46:08 -07:00
Kevin Marquette 5da5a4bf62 Use new Pester syntax: -Parameter for Pester in SDK and Provider tests (#6490) 2018-03-29 08:08:22 +04:00
Steve Lee c18b9999d6 Enable [Environment]::OSVersion to return current OS rather than compatible version (#6457)
* add application manifest dictating compatibility so that osversion shows appropriate os version on Windows
2018-03-28 13:36:16 -07:00
James Truher [MSFT] a6479f8181 Make sure that the width of the header is at least the size of the label (or propertyname) (#6487) 2018-03-28 13:34:29 -07:00