Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,8 @@ class InheritedClassTest : System.Attribute

It "Should keep '~' in completiontext when it's used to refer to home in input" {
$res = TabExpansion2 -inputScript "~$separator"
$res.CompletionMatches[0].CompletionText | Should -BeLike "~$separator*"
$completedText = $res.CompletionMatches.CompletionText -join ","
$res.CompletionMatches[0].CompletionText | Should -BeLike "~$separator*" -Because "$completedText"
}

It "Should use '~' as relative filter text when not followed by separator" {
Expand All @@ -1240,7 +1241,7 @@ class InheritedClassTest : System.Attribute
$NewPath = Join-Path -Path $TestDrive -ChildPath $LiteralPath
$null = New-Item -Path $NewPath -Force
Push-Location $TestDrive

$InputText = "Get-ChildItem -Path {0}.${separator}BacktickTest"
$InputTextLiteral = "Get-ChildItem -LiteralPath {0}.${separator}BacktickTest"

Expand All @@ -1263,7 +1264,9 @@ class InheritedClassTest : System.Attribute
It 'Should keep custom drive names when completing file paths' {
$TempDriveName = "asdf"
$null = New-PSDrive -Name $TempDriveName -PSProvider FileSystem -Root $HOME
(TabExpansion2 -inputScript "${TempDriveName}:\").CompletionMatches[0].CompletionText | Should -BeLike "${TempDriveName}:*"
$completions = (TabExpansion2 -inputScript "${TempDriveName}:\").CompletionMatches
$completionText = $completions.CompletionText -join ","
$completions[0].CompletionText | Should -BeLike "${TempDriveName}:*" -Because "$completionText"
Remove-PSDrive -Name $TempDriveName
}

Expand Down Expand Up @@ -2296,6 +2299,7 @@ dir -Recurse `

Context "Tab completion help test" {
BeforeAll {
New-Item -ItemType File (Join-Path ${TESTDRIVE} "pwsh.xml")
if ($IsWindows) {
$userHelpRoot = Join-Path $HOME "Documents/PowerShell/Help/"
} else {
Expand Down Expand Up @@ -2469,10 +2473,10 @@ dir -Recurse `
}
@{
Intent = 'Complete help keyword EXTERNALHELP argument'
Expected = Join-Path $PSHOME "pwsh.xml"
Expected = Join-Path $TESTDRIVE "pwsh.xml"
TestString = @"
<#
.EXTERNALHELP $PSHOME\pwsh.^
.EXTERNALHELP $TESTDRIVE\pwsh.^
#>
"@
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,16 @@ Describe "Test-Connection" -tags "CI", "RequireSudoOnUnix" {
It "Force IPv4 with implicit PingOptions" {
$result = Test-Connection $testAddress -Count 1 -IPv4

$result[0].Address | Should -BeExactly $testAddress
$result[0].Reply.Options.Ttl | Should -BeLessOrEqual 128
if ($IsWindows) {
$result[0].Reply.Options.DontFragment | Should -BeFalse
$resultStatus = $result.Reply.Status
if ($resultStatus -eq "Success") {
$result[0].Address | Should -BeExactly $testAddress
$result[0].Reply.Options.Ttl | Should -BeLessOrEqual 128
if ($IsWindows) {
$result[0].Reply.Options.DontFragment | Should -BeFalse
}
}
else {
Set-ItResult -Skipped -Because "Ping reply not Success, was: '$resultStatus'"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

if(-not ("netDumbster.smtp.SimpleSmtpServer" -as [type]))
# the send-mailmessage cmdlet is obsolete and will be removed in a future release.
# We will address no issues in this cmdlet, so these tests are marked as skipped.
$script:SkipTest = $true

if(-not ("netDumbster.smtp.SimpleSmtpServer" -as [type]) -and ! $script:SkipTest)
{
Register-PackageSource -Name nuget.org -Location https://api.nuget.org/v3/index.json -ProviderName NuGet -ErrorAction SilentlyContinue

Expand All @@ -22,6 +26,9 @@ $DefaultInputObject = @{

Describe "Send-MailMessage DRT Unit Tests" -Tags CI, RequireSudoOnUnix {
BeforeAll {
if ($script:SkipTest) {
return
}
$server = [netDumbster.smtp.SimpleSmtpServer]::Start(25)

function Read-Mail
Expand All @@ -37,13 +44,21 @@ Describe "Send-MailMessage DRT Unit Tests" -Tags CI, RequireSudoOnUnix {
}

BeforeEach {
if ($script:SkipTest) {
return
}

if($server)
{
$server.ClearReceivedEmail()
}
}

AfterAll {
if ($script:SkipTest) {
return
}

if($server)
{
$server.Stop()
Expand Down Expand Up @@ -109,7 +124,7 @@ Describe "Send-MailMessage DRT Unit Tests" -Tags CI, RequireSudoOnUnix {
}
)

It "Shows obsolete message for cmdlet" {
It "Shows obsolete message for cmdlet" -skip:$script:SkipTest {
$server | Should -Not -Be $null

$powershell = [PowerShell]::Create()
Expand All @@ -124,7 +139,7 @@ Describe "Send-MailMessage DRT Unit Tests" -Tags CI, RequireSudoOnUnix {
$warnings[0].ToString() | Should -BeLike "The command 'Send-MailMessage' is obsolete. *"
}

It "Can send mail message using named parameters <Name>" -TestCases $testCases {
It "Can send mail message using named parameters <Name>" -TestCases $testCases -skip:$script:SkipTest {
param($InputObject)

$server | Should -Not -Be $null
Expand Down Expand Up @@ -156,7 +171,7 @@ Describe "Send-MailMessage DRT Unit Tests" -Tags CI, RequireSudoOnUnix {
$mail.MessageParts[0].BodyData | Should -BeExactly $InputObject.Body
}

It "Can send mail message using pipline named parameters <Name>" -TestCases $testCases -Pending {
It "Can send mail message using pipline named parameters <Name>" -TestCases $testCases -skip:$script:SkipTest {
param($InputObject)

Set-TestInconclusive "As of right now the Send-MailMessage cmdlet does not support piping named parameters (see issue 7591)"
Expand Down Expand Up @@ -193,6 +208,10 @@ Describe "Send-MailMessage DRT Unit Tests" -Tags CI, RequireSudoOnUnix {

Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {
BeforeAll {
if ($script:SkipTest) {
return
}

function Read-Mail
{
param()
Expand All @@ -206,6 +225,10 @@ Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {
}

BeforeEach {
if ($script:SkipTest) {
return
}

if($server)
{
$server.ClearReceivedEmail()
Expand All @@ -214,17 +237,25 @@ Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {

Context "Default Port 25" {
BeforeAll {
if ($script:SkipTest) {
return
}

$server = [netDumbster.smtp.SimpleSmtpServer]::Start(25)
}

AfterAll {
if ($script:SkipTest) {
return
}

if($server)
{
$server.Stop()
}
}

It "Can throw on wrong mail addresses" {
It "Can throw on wrong mail addresses" -skip:$script:SkipTest {
$server | Should -Not -Be $null

$obj = $DefaultInputObject.Clone()
Expand All @@ -233,7 +264,7 @@ Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {
{ Send-MailMessage @obj -ErrorAction Stop } | Should -Throw -ErrorId "FormatException,Microsoft.PowerShell.Commands.SendMailMessage"
}

It "Can send mail with free-form email address" {
It "Can send mail with free-form email address" -skip:$script:SkipTest {
$server | Should -Not -Be $null

$obj = $DefaultInputObject.Clone()
Expand All @@ -248,7 +279,7 @@ Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {
$mail.ToAddresses | Should -BeExactly "user02@example.com"
}

It "Can send mail with high priority" {
It "Can send mail with high priority" -skip:$script:SkipTest {
$server | Should -Not -Be $null

Send-MailMessage @DefaultInputObject -Priority High -ErrorAction SilentlyContinue
Expand All @@ -257,7 +288,7 @@ Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {
$mail.Priority | Should -BeExactly "urgent"
}

It "Can send mail with HTML content as body" {
It "Can send mail with HTML content as body" -skip:$script:SkipTest {
$server | Should -Not -Be $null

$obj = $DefaultInputObject.Clone()
Expand All @@ -271,7 +302,7 @@ Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {
$mail.MessageParts[0].BodyData | Should -Be $obj.Body
}

It "Can send mail with UTF8 encoding" {
It "Can send mail with UTF8 encoding" -skip:$script:SkipTest {
$server | Should -Not -Be $null

$obj = $DefaultInputObject.Clone()
Expand All @@ -286,7 +317,7 @@ Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {
$utf8Text | Should -Be $obj.Body
}

It "Can send mail with attachments" {
It "Can send mail with attachments" -skip:$script:SkipTest {
$attachment1 = "TestDrive:\attachment1.txt"
$attachment2 = "TestDrive:\attachment2.txt"

Expand All @@ -311,17 +342,25 @@ Describe "Send-MailMessage Feature Tests" -Tags Feature, RequireSudoOnUnix {

Context "Custom Port 2525" {
BeforeAll {
if ($script:SkipTest) {
return
}

$server = [netDumbster.smtp.SimpleSmtpServer]::Start(2525)
}

AfterAll {
if ($script:SkipTest) {
return
}

if($server)
{
$server.Stop()
}
}

It "Can send mail message using custom port 2525" {
It "Can send mail message using custom port 2525" -skip:$script:SkipTest {
$server | Should -Not -Be $null
$server.ReceivedEmailCount | Should -BeExactly 0

Expand Down
20 changes: 13 additions & 7 deletions test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {

Describe "JEA session Transcript script test" -Tag @("Feature", 'RequireAdminOnWindows') {
BeforeAll {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$originalDefaultParameterValues = $global:PSDefaultParameterValues.Clone()

if ( ! $IsWindows -or !(Test-CanWriteToPsHome))
{
$PSDefaultParameterValues["it:skip"] = $true
$global:PSDefaultParameterValues["it:skip"] = $true
}
else
{
Expand Down Expand Up @@ -101,11 +101,11 @@ Describe "JEA session Transcript script test" -Tag @("Feature", 'RequireAdminOnW

Describe "JEA session Get-Help test" -Tag @("CI", 'RequireAdminOnWindows') {
BeforeAll {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$originalDefaultParameterValues = $global:PSDefaultParameterValues.Clone()

if ( ! $IsWindows -or !(Test-CanWriteToPsHome))
{
$PSDefaultParameterValues["it:skip"] = $true
$global:PSDefaultParameterValues["it:skip"] = $true
}
else
{
Expand Down Expand Up @@ -141,16 +141,22 @@ Describe "JEA session Get-Help test" -Tag @("CI", 'RequireAdminOnWindows') {
Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') {
BeforeAll {

$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$originalDefaultParameterValues = $global:PSDefaultParameterValues.Clone()

if ( ! $IsWindows )
{
$PSDefaultParameterValues["it:skip"] = $true
$global:PSDefaultParameterValues["it:skip"] = $true
}
else
{
Enable-PSRemoting -SkipNetworkProfileCheck
$endPoint = (Get-PSSessionConfiguration -Name "PowerShell.$(${PSVersionTable}.GitCommitId)").Name
$configName = "PowerShell." + $PSVersionTable.GitCommitId
$configuration = Get-PSSessionConfiguration -Name $configName -ErrorAction Ignore
if ($null -eq $configuration) {
$global:PSDefaultParameterValues["it:skip"] = $true
return
}
$endPoint = $configuration.Name
$disconnectedSession = New-RemoteSession -ConfigurationName $endPoint -ComputerName localhost | Disconnect-PSSession
$closedSession = New-RemoteSession -ConfigurationName $endPoint -ComputerName localhost
$closedSession.Runspace.Close()
Expand Down
16 changes: 12 additions & 4 deletions test/powershell/engine/Security/FileSignature.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,22 @@ Describe "Windows file content signatures" -Tags @('Feature', 'RequireAdminOnWin
}

AfterAll {

if ($shouldSkip) {
return
}

Remove-Item -Path Cert:\LocalMachine\Root\$caRootThumbprint -Force
Remove-Item -Path Cert:\LocalMachine\TrustedPublisher\$signingThumbprint -Force
Remove-Item -Path Cert:\CurrentUser\My\$signingThumbprint -Force
$paths = @(
"Cert:\LocalMachine\Root\$caRootThumbprint"
"Cert:\LocalMachine\TrustedPublisher\$signingThumbprint"
"Cert:\CurrentUser\My\$signingThumbprint"
)

foreach($path in $paths) {
if (Test-Path $path) {
# failing to remove is not fatal
Remove-Item -Force -Path $path -ErrorAction Continue
}
}
}

It "Validates signature using path on even char count with Encoding <Encoding>" -TestCases @(
Expand Down