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
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/26"
}

if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

$resource = Get-DscResource -Name $name
$resource | Should -Not -BeNullOrEmpty
$resource.Name | Should -Be $Name
Expand All @@ -148,6 +152,10 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/26"
}

if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
Expand Down Expand Up @@ -225,6 +233,10 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Set-ItResult -Pending -Because "Will only find script from PSDesiredStateConfiguration without modulename"
}

if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

if ($MissingLibmi) {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}
Expand Down Expand Up @@ -254,6 +266,10 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/12 and https://github.com/PowerShell/PowerShellGet/pull/529"
}

if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
Expand Down Expand Up @@ -315,6 +331,10 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}

if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
Expand All @@ -340,6 +360,10 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}

if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
Expand Down Expand Up @@ -402,6 +426,10 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}

if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

if (!$IsLinux) {
$result = Invoke-DscResource -Name PSModule -ModuleName $psGetModuleSpecification -Method set -Property @{
Name = 'PsDscResources'
Expand All @@ -427,6 +455,10 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}

if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

# using create scriptBlock because $using:<variable> doesn't work with existing Invoke-DscResource
# Verified in Windows PowerShell on 20190814
$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Set -Property @{TestScript = { Write-Output 'test'; return $false }; GetScript = { return @{ } }; SetScript = [scriptblock]::Create("`$global:DSCMachineStatus = $value;return") }
Expand All @@ -438,6 +470,9 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
if ($MissingLibmi) {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}
if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Test -Property @{TestScript = { Write-Output 'test'; return $false }; GetScript = { return @{ } }; SetScript = { return } }
$result | Should -Not -BeNullOrEmpty
Expand All @@ -448,6 +483,9 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
if ($MissingLibmi) {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}
if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Test -Property @{TestScript = { Write-Verbose 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } }
$result | Should -BeTrue -Because "Test method return true"
Expand All @@ -457,6 +495,9 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
if ($MissingLibmi) {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}
if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

$module = Get-Module PsDscResources -ListAvailable
$moduleSpecification = @{ModuleName = $module.Name; ModuleVersion = $module.Version.ToString() }
Expand Down Expand Up @@ -520,6 +561,9 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
if ($MissingLibmi) {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}
if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

{
Invoke-DscResource -Name santoheusnaasonteuhsantoheu -Method Test -Property @{TestScript = { Write-Host 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } -ErrorAction Stop
Expand All @@ -531,6 +575,9 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
if ($IsLinux) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/12 and https://github.com/PowerShell/PowerShellGet/pull/529"
}
if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

$result = Invoke-DscResource -Name PSModule -ModuleName $psGetModuleSpecification -Method Get -Property @{ Name = 'PsDscResources' }
$result | Should -Not -BeNullOrEmpty
Expand Down Expand Up @@ -577,6 +624,9 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
if ($MissingLibmi) {
Set-ItResult -Pending -Because "Libmi not available for this platform"
}
if ($IsMacOS) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

$testString = '890574209347509120348'
$result = Invoke-DscResource -Name XmlFileContentResource -ModuleName XmlContentDsc -Property @{Path = $resolvedXmlPath; XPath = '/configuration/appSetting/Test1'; Ensure = 'Present'; Attributes = @{ TestValue2 = $testString; Name = $testString } } -Method Set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Describe "DSC MOF Compilation" -tags "CI" {
if ($IsLinux) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShellGet/pull/529"
}
if ($IsMacOs) {
Set-ItResult -Pending -Because "macOS is incompatible with libmi"
}

Write-Verbose "DSC_HOME: ${env:DSC_HOME}" -Verbose
[Scriptblock]::Create(@"
Expand Down
12 changes: 9 additions & 3 deletions test/powershell/engine/Remoting/PSSession.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# PSSession tests for non-Windows platforms
#

function GetRandomString()
{
return [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
}

Describe "New-PSSessionOption parameters for non-Windows platforms" -Tag "CI" {

BeforeAll {
Expand Down Expand Up @@ -36,12 +41,13 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS
BeforeAll {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()

if ($IsWindows) {
# Skip this test for macOS because the latest OS release is incompatible with our shipped libmi for WinRM/OMI.
if ($IsWindows -or $IsMacOS) {
$PSDefaultParameterValues['it:skip'] = $true
}
else {
$userName = "User_$(Get-Random -Maximum 99999)"
$userPassword = "Password_$(Get-Random -Maximum 99999)"
$userPassword = GetRandomString
$cred = [pscredential]::new($userName, (ConvertTo-SecureString -String $userPassword -AsPlainText -Force))
$soSkipCA = New-PSSessionOption -SkipCACheck
$soSkipCN = New-PSSessionOption -SkipCNCheck
Expand All @@ -54,7 +60,7 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS

$testCases = @(
@{
Name = 'Verifies expected error when session options is missing'
Name = 'Verifies expected error when session option is missing'
ScriptBlock = { New-PSSession -cn localhost -Credential $cred -Authentication Basic -UseSSL }
ExpectedErrorCode = 825
},
Expand Down
27 changes: 18 additions & 9 deletions test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@

Import-Module HelpersCommon

function GetRandomString()
{
return [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
}

Describe "New-PSSession basic test" -Tag @("CI") {
It "New-PSSession should not crash powershell" {
$platformInfo = Get-PlatformInfo
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8')
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
return
}

{ New-PSSession -ComputerName nonexistcomputer -Authentication Basic } |
{ New-PSSession -ComputerName (GetRandomString) -Authentication Basic } |
Should -Throw -ErrorId "InvalidOperation,Microsoft.PowerShell.Commands.NewPSSessionCommand"
}
}
Expand All @@ -26,13 +32,14 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8')
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
return
}

$password = ConvertTo-SecureString -String "password" -AsPlainText -Force
$password = ConvertTo-SecureString -String (GetRandomString) -AsPlainText -Force
$credential = [PSCredential]::new('username', $password)

$err = ({New-PSSession -ComputerName 'localhost' -Credential $credential -Authentication Basic} | Should -Throw -PassThru -ErrorId 'System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.NewPSSessionCommand')
Expand All @@ -42,18 +49,20 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {
$err.Exception.ErrorCode | Should -Be 801
}

# Skip this test for macOS because the latest OS release is incompatible with our shipped libmi for WinRM/OMI.
It "New-PSSession should NOT throw a ConnectFailed exception when specifying Basic Auth over HTTPS on Unix" -Skip:($IsWindows) {
$platformInfo = Get-PlatformInfo
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8')
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
return
}

$password = ConvertTo-SecureString -String "password" -AsPlainText -Force
$password = ConvertTo-SecureString -String (GetRandomString) -AsPlainText -Force
$credential = [PSCredential]::new('username', $password)

# use a Uri that specifies HTTPS to test Basic Auth logic.
Expand Down