diff --git a/assets/wix/files.wxs b/assets/wix/files.wxs index 17f0ca4da..e6dc09ea6 100644 --- a/assets/wix/files.wxs +++ b/assets/wix/files.wxs @@ -1638,45 +1638,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -3607,16 +3577,6 @@ - - - - - - - - - - diff --git a/build.psm1 b/build.psm1 index 690b8684f..73750e442 100644 --- a/build.psm1 +++ b/build.psm1 @@ -618,7 +618,8 @@ Fix steps: # Make sure ExperimentalFeatures from modules in PSHome are added # https://github.com/PowerShell/PowerShell/issues/10550 - @("PSDesiredStateConfiguration.InvokeDscResource") | ForEach-Object { + $ExperimentalFeaturesFromGalleryModulesInPSHome = @() + $ExperimentalFeaturesFromGalleryModulesInPSHome | ForEach-Object { if (!$expFeatures.Contains($_)) { $null = $expFeatures.Add($_) } diff --git a/src/Modules/PSGalleryModules.csproj b/src/Modules/PSGalleryModules.csproj index ae838f276..ca1c34df8 100644 --- a/src/Modules/PSGalleryModules.csproj +++ b/src/Modules/PSGalleryModules.csproj @@ -16,7 +16,6 @@ - diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/MOF-Compilation.Tests.ps1 b/test/powershell/Modules/PSDesiredStateConfiguration/MOF-Compilation.Tests.ps1 deleted file mode 100644 index 01620ee9e..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/MOF-Compilation.Tests.ps1 +++ /dev/null @@ -1,228 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -Describe "DSC MOF Compilation" -tags "CI" { - - AfterAll { - $env:PSModulePath = $_modulePath - } - - BeforeAll { - $platformInfo = Get-PlatformInfo - $SkipAdditionalPlatforms = - ($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') - - Import-Module PSDesiredStateConfiguration - $dscModule = Get-Module PSDesiredStateConfiguration - $baseSchemaPath = Join-Path $dscModule.ModuleBase 'Configuration' - $testResourceSchemaPath = Join-Path -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath dsc) schema - - # Copy test resources to PSDesiredStateConfiguration module - Copy-Item $testResourceSchemaPath $baseSchemaPath -Recurse -Force - - $_modulePath = $env:PSModulePath - $powershellexe = (Get-Process -pid $PID).MainModule.FileName - $env:PSModulePath = Join-Path ([io.path]::GetDirectoryName($powershellexe)) Modules - } - - It "Should be able to compile a MOF from a basic configuration" -Skip:($IsMacOS -or $IsWindows -or $SkipAdditionalPlatforms) { - [Scriptblock]::Create(@" - configuration DSCTestConfig - { - Import-DscResource -ModuleName PSDesiredStateConfiguration - Node "localhost" { - nxFile f1 - { - DestinationPath = "/tmp/file1"; - } - } - } - - DSCTestConfig -OutputPath TestDrive:\DscTestConfig1 -"@) | Should -Not -Throw - - "TestDrive:\DscTestConfig1\localhost.mof" | Should -Exist - } - - It "Should be able to compile a MOF from another basic configuration" -Skip:($IsMacOS -or $IsWindows -or $SkipAdditionalPlatforms) { - [Scriptblock]::Create(@" - configuration DSCTestConfig - { - Import-DscResource -ModuleName PSDesiredStateConfiguration - Node "localhost" { - nxScript f1 - { - GetScript = ""; - SetScript = ""; - TestScript = ""; - User = "root"; - } - } - } - - DSCTestConfig -OutputPath TestDrive:\DscTestConfig2 -"@) | Should -Not -Throw - - "TestDrive:\DscTestConfig2\localhost.mof" | Should -Exist - } - - It "Should be able to compile a MOF from a complex configuration" -Skip:($IsMacOS -or $IsWindows -or $SkipAdditionalPlatforms) { - [Scriptblock]::Create(@" - Configuration WordPressServer{ - - Import-DscResource -ModuleName PSDesiredStateConfiguration - - Node CentOS{ - - #Ensure Apache packages are installed - nxPackage httpd { - Ensure = "Present" - Name = "httpd" - PackageManager = "yum" - } - - #Include vhostdir - nxFile vHostDir{ - DestinationPath = "/etc/httpd/conf.d/vhosts.conf" - Ensure = "Present" - Contents = "IncludeOptional /etc/httpd/sites-enabled/*.conf`n" - Type = "File" - } - - nxFile vHostDirectory{ - DestinationPath = "/etc/httpd/sites-enabled" - Type = "Directory" - Ensure = "Present" - } - - #Ensure directory for Wordpress site - nxFile wpHttpDir{ - DestinationPath = "/var/www/wordpress" - Type = "Directory" - Ensure = "Present" - Mode = "755" - } - - #Ensure share directory - nxFile share{ - DestinationPath = "/mnt/share" - Type = "Directory" - Ensure = "Present" - Mode = "755" - } - - #Bind httpd to port 8080 - nxFile HttpdPort{ - DestinationPath = "/etc/httpd/conf.d/listen.conf" - Ensure = "Present" - Contents = "Listen 8080`n" - Type = "File" - } - - #nfs mounts - nxScript nfsMount{ - TestScript= "#!/bin/bash" - GetScript="#!/bin/bash" - SetScript="#!/bin/bash" - - } - - #Retrieve latest wordpress - nxFile WordPressTar{ - SourcePath = "/mnt/share/latest.zip" - DestinationPath = "/tmp/wordpress.zip" - Checksum = "md5" - Type = "file" - DependsOn = "[nxScript]nfsMount" - } - - #Extract wordpress if changed - nxArchive ExtractSite{ - SourcePath = "/tmp/wordpress.zip" - DestinationPath = "/var/www/wordpress" - Ensure = "Present" - DependsOn = "[nxFile]WordpressTar" - } - - #Set wp-config - - #Fixup SE Linux context - #nxScript SELinuxContext{ - #TestScript= "#!/bin/bash" - #GetScript = "#!/bin/bash" - #SetScript = "#!/bin/bash" - #} - - #Disable SELinux - nxFileLine SELinux { - Filepath = "/etc/selinux/config" - DoesNotContainPattern = "SELINUX=enforcing" - ContainsLine = "SELINUX=disabled" - } - - nxScript SELinuxHTTPNet{ - GetScript = "#!/bin/bash`ngetsebool httpd_can_network_connect" - setScript = "#!/bin/bash`nsetsebool -P httpd_can_network_connect=1" - TestScript = "#!/bin/bash`n exit 1" - } - - } - - } - WordPressServer -OutputPath TestDrive:\DscTestConfig3 -"@) | Should -Not -Throw - - "TestDrive:\DscTestConfig3\CentOS.mof" | Should -Exist - } - - It "Should be able to compile a MOF from a basic configuration on Windows" -Skip:($IsMacOS -or $IsLinux -or $SkipAdditionalPlatforms) { - [Scriptblock]::Create(@" - configuration DSCTestConfig - { - Import-DscResource -ModuleName PSDesiredStateConfiguration - Node "localhost" { - File f1 - { - DestinationPath = "$env:SystemDrive\\Test.txt"; - Ensure = "Present" - } - } - } - - DSCTestConfig -OutputPath TestDrive:\DscTestConfig4 -"@) | Should -Not -Throw - - "TestDrive:\DscTestConfig4\localhost.mof" | Should -Exist - } - - It "Should be able to compile a MOF from a configuration with multiple resources on Windows" -Skip:($IsMacOS -or $IsLinux -or $SkipAdditionalPlatforms) { - [Scriptblock]::Create(@" - configuration DSCTestConfig - { - Import-DscResource -ModuleName PSDesiredStateConfiguration - Node "localhost" { - File f1 - { - DestinationPath = "$env:SystemDrive\\Test.txt"; - Ensure = "Present" - } - Script s1 - { - GetScript = {return @{}} - SetScript = "Write-Verbose Hello" - TestScript = {return $false} - } - Log l1 - { - Message = "This is a log message" - } - } - } - - DSCTestConfig -OutputPath TestDrive:\DscTestConfig5 -"@) | Should -Not -Throw - - "TestDrive:\DscTestConfig5\localhost.mof" | Should -Exist - } -} diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/PSDesiredStateConfiguration.Tests.ps1 b/test/powershell/Modules/PSDesiredStateConfiguration/PSDesiredStateConfiguration.Tests.ps1 deleted file mode 100644 index 30a92d6a8..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/PSDesiredStateConfiguration.Tests.ps1 +++ /dev/null @@ -1,639 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -Function Install-ModuleIfMissing { - param( - [parameter(Mandatory)] - [String] - $Name, - [version] - $MinimumVersion, - [switch] - $SkipPublisherCheck, - [switch] - $Force - ) - - $module = Get-Module -Name $Name -ListAvailable -ErrorAction Ignore | Sort-Object -Property Version -Descending | Select-Object -First 1 - - if (!$module -or $module.Version -lt $MinimumVersion) { - Write-Verbose "Installing module '$Name' ..." -Verbose - Install-Module -Name $Name -Force -SkipPublisherCheck:$SkipPublisherCheck.IsPresent - } -} - -Function Test-IsInvokeDscResourceEnable { - return [ExperimentalFeature]::IsEnabled("PSDesiredStateConfiguration.InvokeDscResource") -} - -Describe "Test PSDesiredStateConfiguration" -tags CI { - BeforeAll { - $MissingLibmi = $false - $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') - ) { - $MissingLibmi = $true - } - } - - Context "Module loading" { - BeforeAll { - Function BeCommand { - [CmdletBinding()] - Param( - [object[]] $ActualValue, - [string] $CommandName, - [string] $ModuleName, - [switch]$Negate - ) - - $failure = if ($Negate) { - "Expected: Command $CommandName should not exist in module $ModuleName" - } - else { - "Expected: Command $CommandName should exist in module $ModuleName" - } - - $succeeded = if ($Negate) { - ($ActualValue | Where-Object { $_.Name -eq $CommandName }).count -eq 0 - } - else { - ($ActualValue | Where-Object { $_.Name -eq $CommandName }).count -gt 0 - } - - return [PSCustomObject]@{ - Succeeded = $succeeded - FailureMessage = $failure - } - } - - Add-AssertionOperator -Name 'HaveCommand' -Test $Function:BeCommand -SupportsArrayInput - - $commands = Get-Command -Module PSDesiredStateConfiguration - } - - It "The module should have the Configuration Command" { - $commands | Should -HaveCommand -CommandName 'Configuration' -ModuleName PSDesiredStateConfiguration - } - - It "The module should have the Configuration Command" { - $commands | Should -HaveCommand -CommandName 'New-DscChecksum' -ModuleName PSDesiredStateConfiguration - } - - It "The module should have the Get-DscResource Command" { - $commands | Should -HaveCommand -CommandName 'Get-DscResource' -ModuleName PSDesiredStateConfiguration - } - - It "The module should have the Invoke-DscResource Command" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - $commands | Should -HaveCommand -CommandName 'Invoke-DscResource' -ModuleName PSDesiredStateConfiguration - } - } - Context "Get-DscResource - Composite Resources" { - BeforeAll { - $origProgress = $global:ProgressPreference - $global:ProgressPreference = 'SilentlyContinue' - Install-ModuleIfMissing -Name PSDscResources - $testCases = @( - @{ - TestCaseName = 'case mismatch in resource name' - Name = 'groupset' - ModuleName = 'PSDscResources' - } - @{ - TestCaseName = 'Both names have matching case' - Name = 'GroupSet' - ModuleName = 'PSDscResources' - } - @{ - TestCaseName = 'case mismatch in module name' - Name = 'GroupSet' - ModuleName = 'psdscResources' - } - ) - } - - AfterAll { - $Global:ProgressPreference = $origProgress - } - - It "should be able to get - " -TestCases $testCases { - param($Name) - - if ($IsWindows) { - Set-ItResult -Pending -Because "Will only find script from PSDesiredStateConfiguration without modulename" - } - - if ($IsLinux) { - 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 - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - - } - - It "should be able to get from - " -TestCases $testCases { - param($Name, $ModuleName, $PendingBecause) - - if ($IsLinux) { - 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 - } - - $resource = Get-DscResource -Name $Name -Module $ModuleName - $resource | Should -Not -BeNullOrEmpty - $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - } - } - - Context "Get-DscResource - ScriptResources" { - BeforeAll { - $origProgress = $global:ProgressPreference - $global:ProgressPreference = 'SilentlyContinue' - - Install-ModuleIfMissing -Name PSDscResources -Force - - # Install PowerShellGet only if PowerShellGet 2.2.1 or newer does not exist - Install-ModuleIfMissing -Name PowerShellGet -MinimumVersion '2.2.1' - $module = Get-Module PowerShellGet -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 - - $psGetModuleSpecification = @{ModuleName = $module.Name; ModuleVersion = $module.Version.ToString() } - $psGetModuleCount = @(Get-Module PowerShellGet -ListAvailable).Count - $testCases = @( - @{ - TestCaseName = 'case mismatch in resource name' - Name = 'script' - ModuleName = 'PSDscResources' - } - @{ - TestCaseName = 'Both names have matching case' - Name = 'Script' - ModuleName = 'PSDscResources' - } - @{ - TestCaseName = 'case mismatch in module name' - Name = 'Script' - ModuleName = 'psdscResources' - } - <# - Add these back when PowerShellGet is fixed https://github.com/PowerShell/PowerShellGet/pull/529 - @{ - TestCaseName = 'case mismatch in resource name' - Name = 'PsModule' - ModuleName = 'PowerShellGet' - } - @{ - TestCaseName = 'Both names have matching case' - Name = 'PSModule' - ModuleName = 'PowerShellGet' - } - @{ - TestCaseName = 'case mismatch in module name' - Name = 'PSModule' - ModuleName = 'powershellget' - } - #> - ) - } - - AfterAll { - $Global:ProgressPreference = $origProgress - } - - It "should be able to get - " -TestCases $testCases { - param($Name) - - if ($IsWindows) { - 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" - } - - if ($PendingBecause) { - Set-ItResult -Pending -Because $PendingBecause - } - - $resources = @(Get-DscResource -Name $name) - $resources | Should -Not -BeNullOrEmpty - foreach ($resource in $resource) { - $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -Be 'ScriptBased' - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - - } - } - - It "should be able to get from - " -TestCases $testCases { - param($Name, $ModuleName, $PendingBecause) - - 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" - } - - if ($PendingBecause) { - Set-ItResult -Pending -Because $PendingBecause - } - - $resources = @(Get-DscResource -Name $name -Module $ModuleName) - $resources | Should -Not -BeNullOrEmpty - foreach ($resource in $resource) { - $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -Be 'ScriptBased' - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - } - } - - It "should throw when resource is not found" { - Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17" - { - Get-DscResource -Name antoehusatnoheusntahoesnuthao -Module tanshoeusnthaosnetuhasntoheusnathoseun - } | - Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound' - } - } - Context "Get-DscResource - Class base Resources" { - - BeforeAll { - $origProgress = $global:ProgressPreference - $global:ProgressPreference = 'SilentlyContinue' - Install-ModuleIfMissing -Name XmlContentDsc -Force - $classTestCases = @( - @{ - TestCaseName = 'Good case' - Name = 'XmlFileContentResource' - ModuleName = 'XmlContentDsc' - } - @{ - TestCaseName = 'Module Name case mismatch' - Name = 'XmlFileContentResource' - ModuleName = 'xmlcontentdsc' - } - @{ - TestCaseName = 'Resource name case mismatch' - Name = 'xmlfilecontentresource' - ModuleName = 'XmlContentDsc' - } - ) - } - - AfterAll { - $global:ProgressPreference = $origProgress - } - - It "should be able to get class resource - from - " -TestCases $classTestCases { - param($Name, $ModuleName, $PendingBecause) - - if ($MissingLibmi) { - 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 - } - - $resource = Get-DscResource -Name $Name -Module $ModuleName - $resource | Should -Not -BeNullOrEmpty - $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -Be 'ClassBased' - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - } - - It "should be able to get class resource - - " -TestCases $classTestCases { - param($Name, $ModuleName, $PendingBecause) - if ($IsWindows) { - Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/19" - } - - if ($MissingLibmi) { - 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 - } - - $resource = Get-DscResource -Name $Name - $resource | Should -Not -BeNullOrEmpty - $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -Be 'ClassBased' - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - } - } - Context "Invoke-DscResource" { - BeforeAll { - $origProgress = $global:ProgressPreference - $global:ProgressPreference = 'SilentlyContinue' - $module = Get-InstalledModule -Name PsDscResources -ErrorAction Ignore - if ($module) { - Write-Verbose "removing PSDscResources, tests will re-install..." -Verbose - Uninstall-Module -Name PsDscResources -AllVersions -Force - } - } - - AfterAll { - $Global:ProgressPreference = $origProgress - } - - Context "mof resources" { - BeforeAll { - $dscMachineStatusCases = @( - @{ - value = '1' - expectedResult = $true - } - @{ - value = '$true' - expectedResult = $true - } - @{ - value = '0' - expectedResult = $false - } - @{ - value = '$false' - expectedResult = $false - } - ) - - Install-ModuleIfMissing -Name PowerShellGet -Force -SkipPublisherCheck -MinimumVersion '2.2.1' - Install-ModuleIfMissing -Name xWebAdministration - $module = Get-Module PowerShellGet -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 - - $psGetModuleSpecification = @{ModuleName = $module.Name; ModuleVersion = $module.Version.ToString() } - } - It "Set method should work" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - if ($MissingLibmi) { - 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' - InstallationPolicy = 'Trusted' - } - } - else { - # workraound because of https://github.com/PowerShell/PowerShellGet/pull/529 - Install-ModuleIfMissing -Name PsDscResources -Force - } - - $result.RebootRequired | Should -BeFalse - $module = Get-Module PsDscResources -ListAvailable - $module | Should -Not -BeNullOrEmpty -Because "Resource should have installed module" - } - It 'Set method should return RebootRequired= when $global:DSCMachineStatus = ' -Skip:(!(Test-IsInvokeDscResourceEnable)) -TestCases $dscMachineStatusCases { - param( - $value, - $ExpectedResult - ) - - if ($MissingLibmi) { - 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: 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") } - $result | Should -Not -BeNullOrEmpty - $result.RebootRequired | Should -BeExactly $expectedResult - } - - It "Test method should return false" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - 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 - $result.InDesiredState | Should -BeFalse -Because "Test method return false" - } - - It "Test method should return true" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - 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" - } - - It "Test method should return true with moduleSpecification" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - 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() } - $result = Invoke-DscResource -Name Script -ModuleName $moduleSpecification -Method Test -Property @{TestScript = { Write-Verbose 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } - $result | Should -BeTrue -Because "Test method return true" - } - - It "Invalid moduleSpecification" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17" - $moduleSpecification = @{ModuleName = 'PsDscResources'; ModuleVersion = '99.99.99.993' } - { - Invoke-DscResource -Name Script -ModuleName $moduleSpecification -Method Test -Property @{TestScript = { Write-Host 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } -ErrorAction Stop - } | - Should -Throw -ErrorId 'InvalidResourceSpecification,Invoke-DscResource' -ExpectedMessage 'Invalid Resource Name ''Script'' or module specification.' - } - - It "Resource with embedded resource not supported and a warning should be produced" { - - Set-ItResult -Pending -Because "Test is unreliable in release automation." - - if (!(Test-IsInvokeDscResourceEnable)) { - Set-ItResult -Skipped -Because "Feature not enabled" - } - - if (!$IsMacOS) { - Set-ItResult -Skipped -Because "Not applicable on Windows and xWebAdministration resources don't load on linux" - } - - try { - Invoke-DscResource -Name xWebSite -ModuleName 'xWebAdministration' -Method Test -Property @{TestScript = 'foodbar' } -ErrorAction Stop -WarningVariable warnings - } - catch{ - #this will fail too, but that is nat what we are testing... - } - - $warnings.Count | Should -Be 1 -Because "There should be 1 warning on macOS and Linux" - $warnings[0] | Should -Match 'embedded resources.*not support' - } - - It "Using PsDscRunAsCredential should say not supported" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - { - Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Set -Property @{TestScript = { Write-Output 'test'; return $false }; GetScript = { return @{ } }; SetScript = {return}; PsDscRunAsCredential='natoheu'} -ErrorAction Stop - } | - Should -Throw -ErrorId 'PsDscRunAsCredentialNotSupport,Invoke-DscResource' - } - - # waiting on Get-DscResource to be fixed - It "Invalid module name" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17" - { - Invoke-DscResource -Name Script -ModuleName santoheusnaasonteuhsantoheu -Method Test -Property @{TestScript = { Write-Host 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } -ErrorAction Stop - } | - Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound' - } - - It "Invalid resource name" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - if ($IsWindows) { - Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17" - } - - 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 - } | - Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound' - } - - It "Get method should work" -Skip:(!(Test-IsInvokeDscResourceEnable)) { - 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 - $result.Author | Should -BeLike 'Microsoft*' - $result.InstallationPolicy | Should -BeOfType string - $result.Guid | Should -BeOfType Guid - $result.Ensure | Should -Be 'Present' - $result.Name | Should -Be 'PsDscResources' - $result.Description | Should -BeLike 'This*DSC*' - $result.InstalledVersion | Should -BeOfType Version - $result.ModuleBase | Should -BeLike '*PSDscResources*' - $result.Repository | Should -BeOfType string - $result.ModuleType | Should -Be 'Manifest' - } - } - - Context "Class Based Resources" { - BeforeAll { - Install-ModuleIfMissing -Name XmlContentDsc -Force - } - - AfterAll { - $Global:ProgressPreference = $origProgress - } - - BeforeEach { - $testXmlPath = 'TestDrive:\test.xml' - @' - - - - - -'@ | Out-File -FilePath $testXmlPath -Encoding utf8NoBOM - $resolvedXmlPath = (Resolve-Path -Path $testXmlPath).ProviderPath - } - - It 'Set method should work' -Skip:(!(Test-IsInvokeDscResourceEnable)) { - param( - $value, - $ExpectedResult - ) - - 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 - $result | Should -Not -BeNullOrEmpty - $result.RebootRequired | Should -BeFalse - $testXmlPath | Should -FileContentMatch $testString - } - } - } -} diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/BaseRegistration/BaseResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/BaseRegistration/BaseResource.schema.mof deleted file mode 100755 index d76821451..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/BaseRegistration/BaseResource.schema.mof +++ /dev/null @@ -1,207 +0,0 @@ - -[Abstract, ClassVersion("1.0.0")] -class OMI_BaseResource -{ - [required] string ResourceId; - [write] string SourceInfo; - [write] string DependsOn[]; - [required] string ModuleName; - [required] string ModuleVersion; - [write] string ConfigurationName; -}; - -[Abstract, ClassVersion("1.0.0")] -class MSFT_KeyValuePair -{ - [Key] - string Key; - - [write] - string Value; -}; - -[Abstract, ClassVersion("1.0.0")] -class MSFT_BaseConfigurationProviderRegistration -{ - [key] String ClassName; - String DSCEngineCompatVersion; - String DSCModuleVersion; -}; - -[ClassVersion("1.0.0")] -class MSFT_CimConfigurationProviderRegistration : MSFT_BaseConfigurationProviderRegistration -{ - String Namespace; -}; - -[ClassVersion("1.0.0")] -class MSFT_PSConfigurationProviderRegistration : MSFT_BaseConfigurationProviderRegistration -{ - String ModuleName; -}; - -[ClassVersion("1.0.0")] -class OMI_ConfigurationDocument -{ - String Version; - String Author; - String Copyright; - String HelpInfoUri; - String ContentType; - String GenerationDate; - String GenerationHost; - String Name; - String MinimumCompatibleVersion; - String CompatibleVersionAdditionalProperties[]; - String DocumentType; -}; - -[ClassVersion("1.0.0")] -class MSFT_Credential -{ - [MaxLen ( 256 )] - string UserName; - string Password; -}; - -// =============================================================== -// OMI_MetaConfigurationResource -// =============================================================== -[ClassVersion("1.0.0"), - Description ( - "Base schema for all Metaconfiguration resources." )] -class OMI_MetaConfigurationResource -{ - - [required] - string ResourceId; - - [write] - string SourceInfo; -}; - - -// =============================================================== -// Configuration Download Manager -// =============================================================== -[ClassVersion("1.0.0"), - Description("Class defining the configuration download manager" ) ] -class OMI_ConfigurationDownloadManager : OMI_MetaConfigurationResource -{ -}; - -[ClassVersion("1.0.0"), - Description("Web download manager class inheriting from OMI_ConfigurationDownloadManager" )] -class MSFT_WebDownloadManager : OMI_ConfigurationDownloadManager -{ - [Description ("String URL of the download manager location" ) , Key] - string ServerURL; - - - [Description ("The certificate ID used to locate the certificate." ) ] - string CertificateID; - - - [Description ("Boolean variable to allow unsecure connections" ) ] - boolean AllowUnsecureConnection; - - [Description ("Registration Key with which to register with the Pull Server" ) ] - string RegistrationKey; - - [Description ("The set of configuration names with which to register with the Pull Server.")] - string ConfigurationNames[]; -}; - - -// =============================================================== -// Report Managers -// =============================================================== - -[ClassVersion("1.0.0"), - Description("Class defining a report manager") ] -class OMI_ReportManager : OMI_MetaConfigurationResource -{ -}; - -[ClassVersion("1.0.0"), - Description("Web report manager class inheriting from OMI_ReportManager class") ] -class MSFT_WebReportManager : OMI_ReportManager -{ - [Description ("URL of the server used by report manager." ) , Key] - string ServerURL; - - [Description ("The certificate ID used to locate the certificate for secure connections." ) ] - string CertificateID; - - [Description("Specifies whether report manager can use unsecure connection over http.")] - boolean AllowUnsecureConnection; - - [Description ("Registration Key with which to register with the Reporting Server" ) ] - string RegistrationKey; -}; - - -// =============================================================== -// ResourceModule Managers -// =============================================================== - - -[ClassVersion("1.0.0"), Description("Class defining the structure of resource module managers") ] -class OMI_ResourceModuleManager : OMI_MetaConfigurationResource -{ -}; - - -[ClassVersion("1.0.0"), - Description("Web resource module manager class inheriting from OMI_ResourceModuleManager") ] -class MSFT_WebResourceManager : OMI_ResourceModuleManager -{ - [Description ("String URL of the resource module manager location" ) , Key] - string ServerURL; - - [Description ("The certificate ID used to locate the certificate." ) ] - string CertificateID; - - - [Description ("Boolean variable to allow unsecure connections" ) ] - boolean AllowUnsecureConnection; - - [Description ("Registration Key with which to register with the Resource Repository Web" ) ] - string RegistrationKey; - -}; - -[ClassVersion("1.0.0"), - Description("File resource module manager class inheriting from OMI_ResourceModuleManager class") ] -class MSFT_FileResourceManager : OMI_ResourceModuleManager -{ - [Description ("String UNC path of the File resource manager" ) , Key] - string SourcePath; - - [EmbeddedInstance("MSFT_Credential"), - Description ("Default credential to access resources." ) ] - string Credential; - -}; - - - -[Description( - "This represents a Partial Configuration class."), - ClassVersion("1.0.0")] -class MSFT_PartialConfiguration : OMI_MetaConfigurationResource -{ - [Description ("Description of the partial configuration" ) , Write] - String Description ; - - [Description ("Defines the resources that are exclusive to this particular partial configuration" ) , Write] - String ExclusiveResources[]; - - [Description ("The configuration repository source that this partial configuration will use" ) , Write] - String ConfigurationSource; - - [Description ("A dependency variable indicating which partial configuration must be applied prior to this" ) , Write] - String DependsOn[]; -}; - - diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/BaseRegistration/MSFT_DSCMetaConfiguration.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/BaseRegistration/MSFT_DSCMetaConfiguration.mof deleted file mode 100755 index f0c457075..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/BaseRegistration/MSFT_DSCMetaConfiguration.mof +++ /dev/null @@ -1,100 +0,0 @@ -// =============================================================== -// MetaConfiguration -// =============================================================== -[ClassVersion("1.0.0"),Description("Local Configuration Manager settings.")] -class MSFT_DSCMetaConfiguration -{ - [Description ("The time interval between consecutive runs for reapplying the configuration to get to the desired state." )] - uint32 ConfigurationModeFrequencyMins; - - [Description ("Reboot node if needed.")] - boolean RebootNodeIfNeeded; - - [Description ("The configuration apply mode for the server."), - ValueMap {"ApplyOnly","ApplyAndMonitor","ApplyAndAutoCorrect"}, - Values {"ApplyOnly","ApplyAndMonitor","ApplyAndAutoCorrect"}] - string ConfigurationMode; - - [EmbeddedInstance("MSFT_Credential"), - Description ("Default credential to access resources." )] - string Credential; - - [Description ("The refresh mode for the server. Valid values are Pull and Push." ), - ValueMap {"Push","Pull"}, - Values {"Push","Pull"}] - string RefreshMode; - - [Description ("The certificate ID used to locate the certificate." )] - string CertificateID; - - [Description ("The configuration ID used to get the configuration from the pull server." )] - string ConfigurationID; - - [Description ("Name of the configuration and module Download Manager." )] - string DownloadManagerName; - - [Description ("Custom data that is specific to Download Manager." ), - EmbeddedInstance("MSFT_KeyValuePair")] - string DownloadManagerCustomData[]; - - [Description ("The time interval between consecutive runs to get the action from the server." )] - uint32 RefreshFrequencyMins; - - [Description ("Overwrite modules when downloading from Pull Server." )] - boolean AllowModuleOverwrite; - - [Read, Description("Current state of local configuration manager."), - ValueMap{"Ready","Busy","PendingReboot"}, - Values{"Ready","Busy","PendingReboot"}] - string LocalConfigurationManagerState; - - [Description ("Array of configuration download manager objects that contain location information to download configurations" ) , - EmbeddedInstance("OMI_ConfigurationDownloadManager")] - string ConfigurationDownloadManagers[]; - - [Description ("Array of resource module managers pointing to a location to download missing DSCResources" ) , - EmbeddedInstance("OMI_ResourceModuleManager")] - string ResourceModuleManagers[]; - - [Description ("Array of report managers pointing to a location that would help generate reports for DSC" ) , - EmbeddedInstance("OMI_ReportManager")] - string ReportManagers[]; - - [EmbeddedInstance("MSFT_PartialConfiguration")] string PartialConfigurations[]; - - - [Description ("The action after reboot the server."), - ValueMap {"ContinueConfiguration","StopConfiguration"}, - Values {"ContinueConfiguration","StopConfiguration"}] - string ActionAfterReboot; - - [Description ("The enumeration for DebugMode."), - ValueMap {"None","ForceModuleImport", "All", "ResourceScriptBreakAll"}, - Values {"None","ForceModuleImport", "All", "ResourceScriptBreakAll"}] - string DebugMode[]; - - [Read, Description("Current version of local configuration manager.")] - string LCMVersion; - - [Read, Description("Compatible versions of current local configuration manager.")] - string LCMCompatibleVersions[]; - - [Read, Description("Current state of local configuration manager."), - ValueMap{"Idle","Busy","PendingReboot","PendingConfiguration"}, - Values{"Idle","Busy","PendingReboot","PendingConfiguration"}] - string LCMState; - - [Read, Description("State detail of local configuration manager.")] - string LCMStateDetail; - - [Description ("Number of days to retain configuration status history.")] - uint32 StatusRetentionTimeInDays; - - [Read, Description("AgentId of the current Dsc Agent.")] - string AgentId; - - - boolean EnableSignatureValidation; - boolean DisableModuleSignatureValidation; - -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_LogResource/MSFT_LogResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_LogResource/MSFT_LogResource.schema.mof deleted file mode 100755 index 9216888fe..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_LogResource/MSFT_LogResource.schema.mof +++ /dev/null @@ -1,7 +0,0 @@ -#pragma namespace("\\\\.\\root\\microsoft\\windows\\DesiredstateConfiguration") - -[ClassVersion("1.0.0"),FriendlyName("Log")] -class MSFT_LogResource : OMI_BaseResource -{ - [required] string Message; -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxArchiveResource/MSFT_nxArchiveResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxArchiveResource/MSFT_nxArchiveResource.schema.mof deleted file mode 100755 index 53dcdbac1..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxArchiveResource/MSFT_nxArchiveResource.schema.mof +++ /dev/null @@ -1,10 +0,0 @@ -[ClassVersion("1.0.0"), FriendlyName("nxArchive")] -class MSFT_nxArchiveResource : OMI_BaseResource -{ - [Key] string SourcePath; - [Key] string DestinationPath; - [write,ValueMap{"ctime", "mtime", "md5"},Values{"ctime", "mtime","md5"}] string Checksum; - [write] boolean Force; - [Write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; -}; - diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxEnvironmentResource/MSFT_nxEnvironmentResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxEnvironmentResource/MSFT_nxEnvironmentResource.schema.mof deleted file mode 100755 index bdfa934a1..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxEnvironmentResource/MSFT_nxEnvironmentResource.schema.mof +++ /dev/null @@ -1,8 +0,0 @@ -[ClassVersion("1.0.0"), Description("The configuration provider for environment variable control."), FriendlyName("nxEnvironment")] -class MSFT_nxEnvironmentResource:OMI_BaseResource -{ - [Key] string Name; - [write] string Value; - [Write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; - [Write] boolean Path; -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxFileLineResource/MSFT_nxFileLineResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxFileLineResource/MSFT_nxFileLineResource.schema.mof deleted file mode 100755 index 85cc45dc6..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxFileLineResource/MSFT_nxFileLineResource.schema.mof +++ /dev/null @@ -1,8 +0,0 @@ -[ClassVersion("1.0.0"), FriendlyName("nxFileLine")] -class MSFT_nxFileLineResource : OMI_BaseResource -{ -[key,required] string FilePath; -[write] string DoesNotContainPattern; -[key,write] string ContainsLine; -}; - diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxFileResource/MSFT_nxFileResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxFileResource/MSFT_nxFileResource.schema.mof deleted file mode 100755 index 003e4e2d5..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxFileResource/MSFT_nxFileResource.schema.mof +++ /dev/null @@ -1,17 +0,0 @@ -[ClassVersion("1.0.0"), Description("The configuration provider for files and directories."), FriendlyName("nxFile")] -class MSFT_nxFileResource:OMI_BaseResource -{ - [Key] string DestinationPath; - [Write] string SourcePath; - [Write,ValueMap{"present", "absent"},Values{"present", "absent"}] string Ensure; - [Write,ValueMap{"file", "directory", "link"},Values{"file", "directory","link"}] string Type; - [Write] boolean Force; - [Write] string Contents; - [Write, ValueMap{"md5", "mtime", "ctime"}] string Checksum; - [Write] boolean Recurse; - [Write, ValueMap{"follow", "manage", "ignore" }] string Links; - [Write] string Group; - [Write] string Mode; - [Write] string Owner; - [Read] datetime ModifiedDate; -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxGroupResource/MSFT_nxGroupResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxGroupResource/MSFT_nxGroupResource.schema.mof deleted file mode 100755 index 76680de5c..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxGroupResource/MSFT_nxGroupResource.schema.mof +++ /dev/null @@ -1,12 +0,0 @@ -[ClassVersion("1.0.0"), FriendlyName("nxGroup")] -class MSFT_nxGroupResource:OMI_BaseResource -{ - [Key] string GroupName; - [write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; - [write] string Members[]; - [write] string MembersToInclude[]; - [write] string MembersToExclude[]; - [write] string PreferredGroupID; - [read] string GroupID; - -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxPackageResource/MSFT_nxPackageResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxPackageResource/MSFT_nxPackageResource.schema.mof deleted file mode 100755 index d51aedf91..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxPackageResource/MSFT_nxPackageResource.schema.mof +++ /dev/null @@ -1,19 +0,0 @@ -[ClassVersion("1.0.0"), FriendlyName("nxPackage")] -class MSFT_nxPackageResource : OMI_BaseResource -{ - [write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; - [write,ValueMap{"Yum", "Apt", "Zypper", "*"},Values{"Yum", "Apt", "Zypper", "*"}] string PackageManager; - [Key] string Name; - [write] string FilePath; - [write] Boolean PackageGroup; - [write] string Arguments; - [write] uint32 ReturnCode; - [read] string PackageDescription; - [read] string Publisher; - [read] string InstalledOn; - [read] uint32 Size; - [read] string Version; - [read] boolean Installed; - [read] string Architecture; - -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxScriptResource/MSFT_nxScriptResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxScriptResource/MSFT_nxScriptResource.schema.mof deleted file mode 100755 index 509747abb..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxScriptResource/MSFT_nxScriptResource.schema.mof +++ /dev/null @@ -1,10 +0,0 @@ -[ClassVersion("1.0.0"),FriendlyName("nxScript")] -class MSFT_nxScriptResource : OMI_BaseResource -{ - [Key] string GetScript; - [Key] string SetScript; - [Key] string TestScript; - [write] string User; - [write] string Group; - [Read] string Result; -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxServiceResource/MSFT_nxServiceResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxServiceResource/MSFT_nxServiceResource.schema.mof deleted file mode 100755 index 2995aba53..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxServiceResource/MSFT_nxServiceResource.schema.mof +++ /dev/null @@ -1,12 +0,0 @@ -/* I am really new */ -[ClassVersion("1.0.0"), FriendlyName("nxService")] -class MSFT_nxServiceResource : OMI_BaseResource -{ - [key] string Name; - [write,required,ValueMap{"init", "upstart", "systemd", "*"},Values{"init","upstart","systemd", "*"}] string Controller; - [write] boolean Enabled; - [write,ValueMap{"Running", "Stopped"},Values{"Running", "Stopped"}] string State; - [read] string Path; - [read] string Description; - [read] string Runlevels; -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxSshAuthorizedKeysResource/MSFT_nxSshAuthorizedKeysResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxSshAuthorizedKeysResource/MSFT_nxSshAuthorizedKeysResource.schema.mof deleted file mode 100755 index 71bb190b9..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxSshAuthorizedKeysResource/MSFT_nxSshAuthorizedKeysResource.schema.mof +++ /dev/null @@ -1,8 +0,0 @@ -[ClassVersion("1.0.0"), Description("The configuration provider for ssh authorized key control."), FriendlyName("nxSshAuthorizedKeys")] -class MSFT_nxSshAuthorizedKeysResource:OMI_BaseResource -{ - [Key] string KeyComment; - [write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; - [write] string UserName; - [write] string Key; -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxUserResource/MSFT_nxUserResource.schema.mof b/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxUserResource/MSFT_nxUserResource.schema.mof deleted file mode 100755 index 9360ab203..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/assets/dsc/schema/MSFT_nxUserResource/MSFT_nxUserResource.schema.mof +++ /dev/null @@ -1,15 +0,0 @@ -[ClassVersion("1.0.0"), FriendlyName("nxUser")] -class MSFT_nxUserResource : OMI_BaseResource -{ - [Key] string UserName; - [write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; - [write] string FullName; - [write] string Description; - [write] string Password; - [write] boolean Disabled; - [write] boolean PasswordChangeRequired; - [write] string HomeDirectory; - [write] string GroupID; - [read] string UserID; - -}; diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/configuration.Tests.ps1 b/test/powershell/Modules/PSDesiredStateConfiguration/configuration.Tests.ps1 deleted file mode 100644 index 953b28ace..000000000 --- a/test/powershell/Modules/PSDesiredStateConfiguration/configuration.Tests.ps1 +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -Describe "DSC MOF Compilation" -tags "CI" { - BeforeAll { - $module = Get-Module PowerShellGet -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 - - $psGetModuleVersion = $module.Version.ToString() - if (!$env:DSC_HOME) - { - Import-Module PSDesiredStateConfiguration - } - } - - It "Should be able to compile a MOF using PSModule resource" { - 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(@" - configuration DSCTestConfig - { - Import-DscResource -ModuleName PowerShellGet -ModuleVersion $psGetModuleVersion - Node "localhost" { - PSModule f1 - { - Name = 'PsDscResources' - InstallationPolicy = 'Trusted' - } - } - } - - DSCTestConfig -OutputPath TestDrive:\DscTestConfig2 -"@) | Should -Not -Throw - - "TestDrive:\DscTestConfig2\localhost.mof" | Should -Exist - } -} diff --git a/test/powershell/engine/ExperimentalFeature/Get-ExperimentalFeature.Tests.ps1 b/test/powershell/engine/ExperimentalFeature/Get-ExperimentalFeature.Tests.ps1 index c11002fbe..af18672cf 100644 --- a/test/powershell/engine/ExperimentalFeature/Get-ExperimentalFeature.Tests.ps1 +++ b/test/powershell/engine/ExperimentalFeature/Get-ExperimentalFeature.Tests.ps1 @@ -165,23 +165,34 @@ Describe "Default enablement of Experimental Features" -Tags CI { } It "On stable builds, Experimental Features are not enabled" -Skip:($isPreview) { - foreach ($expFeature in Get-ExperimentalFeature) { - $expFeature.Enabled | Should -Not -BeEnabled -Name $expFeature.Name + foreach ($expFeature in Get-ExperimentalFeature) + { + # In CI, pwsh that is running tests (with $PSHOME like D:\a\1\s\src\powershell-win-core\bin\release\net6.0\win7-x64\publish) + # is launched from another pwsh (with $PSHOME like C:\program files\powershell\7) + # resulting in combined PSModulePath which is used by Get-ExperimentalFeature to enum module-scoped exp.features from both pwsh locations. + # So we need to exclude parent's modules' exp.features from verification using filtering on $PSHOME. + if (($expFeature.Source -eq 'PSEngine') -or ($expFeature.Source.StartsWith($PSHOME, "InvariantCultureIgnoreCase"))) + { + "Checking $($expFeature.Name) experimental feature" | Write-Verbose -Verbose + $expFeature.Enabled | Should -Not -BeEnabled -Name $expFeature.Name + } } } It "On preview builds, Experimental Features are enabled" -Skip:(!$isPreview) { (Join-Path -Path $PSHOME -ChildPath 'powershell.config.json') | Should -Exist - foreach ($expFeature in Get-ExperimentalFeature) { - if ($expFeature.Name -ne "PS7DscSupport") + foreach ($expFeature in Get-ExperimentalFeature) + { + # In CI, pwsh that is running tests (with $PSHOME like D:\a\1\s\src\powershell-win-core\bin\release\net6.0\win7-x64\publish) + # is launched from another pwsh (with $PSHOME like C:\program files\powershell\7) + # resulting in combined PSModulePath which is used by Get-ExperimentalFeature to enum module-scoped exp.features from both pwsh locations. + # So we need to exclude parent's modules' exp.features from verification using filtering on $PSHOME. + if (($expFeature.Source -eq 'PSEngine') -or ($expFeature.Source.StartsWith($PSHOME, "InvariantCultureIgnoreCase"))) { + "Checking $($expFeature.Name) experimental feature" | Write-Verbose -Verbose $expFeature.Enabled | Should -BeEnabled -Name $expFeature.Name } - else - { - $expFeature.Enabled | Should -Not -BeEnabled -Name $expFeature.Name - } } } }