Remove PSDesiredStateConfiguration v2.0.5 module (#15536)

* No longer include module with PS releases

* Updated assets/wix/files.wxs

* Moving tests out of the ps repo

* Debug 1

* Debug 2
This commit is contained in:
Andrew 2021-06-09 12:15:46 -07:00 committed by GitHub
parent 659dff09e4
commit 6e73c2d4f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 21 additions and 1391 deletions

View file

@ -1638,45 +1638,15 @@
</Component>
</Directory>
<Directory Id="dirAB5880051B03D55D6C333CF1F67C7F76" Name="PSDesiredStateConfiguration">
<Component Id="cmp9723892C7119DFDFD3A6FAE8027B053F">
<File Id="fil52D468AAC368F8F9427B5AB0D5DF94F3" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1" />
</Component>
<Directory Name="Configuration" Id="dir709A20AD6F5242A1805E8C5D775F584C">
<Directory Name="BaseRegistration" Id="dir46B77C0AFD5642C9A8A00107796F3AF0">
<Directory Name="en-US" Id="dirDC3198AB09D84802BC00C697A113698B">
<Component Id="cmp2CA89A2376A848BE849FBD5ECFD6738B">
<File Id="filB354FF41265E43498774FB1E8F86A3EE" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\Configuration\BaseRegistration\en-US\MSFT_MetaConfigurationExtensionClasses.Schema.mfl" />
</Component>
<Component Id="cmp0E915393766B4DC6A9A83EBA0C218BF4">
<File Id="fil426E09F768D94A1DA8B4B91B68926493" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\Configuration\BaseRegistration\en-US\MSFT_DSCMetaConfiguration.mfl" />
</Component>
<Component Id="cmp5DF3BF3BEEE34C329E690E094A3CAFA2">
<File Id="filCEE0C3D2C1134C59921EE338A9F10BCA" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\Configuration\BaseRegistration\en-US\BaseResource.Schema.mfl" />
</Component>
</Directory>
<Component Id="cmp19F1175335B14CA5AC6F7ABA06E4DD34">
<File Id="fil0BF7A56B763E4CAA8195E7E886484FCD" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\Configuration\BaseRegistration\MSFT_DSCMetaConfiguration.mof" />
</Component>
<Component Id="cmpF8DA47047FBD4A7B8F876059F4EDB73D">
<File Id="fil86FCEEBF9FE145D9BAA7D19769959F70" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\Configuration\BaseRegistration\BaseResource.schema.mof" />
</Component>
<Component Id="cmp44977EB99C0647F4941AA2711A81651F">
<File Id="fil5909011A884C453C92EBDB5550791B6C" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\Configuration\BaseRegistration\MSFT_MetaConfigurationExtensionClasses.schema.mof" />
</Component>
</Directory>
</Directory>
<Component Id="cmp3AF5C6350FE04033B037554EA5060135">
<File Id="fil58E456DF33A141DFA4B165479510EA95" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psd1" />
</Component>
<Directory Name="helpers" Id="dir4774426A44B041E1A377AE889D3FFB19">
<Component Id="cmp0125D538DA2E4396BC1D595250B69263">
<File Id="fil98D6A2CAE08A408BB0215CD1DD6C7A0F" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\helpers\DscResourceInfo.psm1" />
</Component>
</Directory>
<Directory Name="en-US" Id="dir28499A54B1694A25BB7EFA06CAE3272E">
<Component Id="cmpAC685A1C6E354E228EB6A1DD95FF03D5">
<File Id="filD2DD9066D1A148EBB7AD542DAC529862" KeyPath="yes" Source="$(var.ProductSourcePath)\Modules\PSDesiredStateConfiguration\en-US\about_PSDesiredStateConfiguration.md" />
</Component>
</Directory>
</Directory>
<Directory Id="dirECE37E3EC3637A365744D075BD8132E9" Name="Microsoft.PowerShell.Management">
@ -3607,16 +3577,6 @@
<ComponentRef Id="cmpDC2EF4541FA5A2E63F36A8CD6C5FA51B" />
<ComponentRef Id="cmpA620CA71E6FF4F50B6D7BB0761D17036" />
<ComponentRef Id="cmp2DF9FE0BD560EB7DC8489A259330C2C6" />
<ComponentRef Id="cmp9723892C7119DFDFD3A6FAE8027B053F" />
<ComponentRef Id="cmp2CA89A2376A848BE849FBD5ECFD6738B" />
<ComponentRef Id="cmp0E915393766B4DC6A9A83EBA0C218BF4" />
<ComponentRef Id="cmp5DF3BF3BEEE34C329E690E094A3CAFA2" />
<ComponentRef Id="cmp19F1175335B14CA5AC6F7ABA06E4DD34" />
<ComponentRef Id="cmpF8DA47047FBD4A7B8F876059F4EDB73D" />
<ComponentRef Id="cmp44977EB99C0647F4941AA2711A81651F" />
<ComponentRef Id="cmp3AF5C6350FE04033B037554EA5060135" />
<ComponentRef Id="cmp0125D538DA2E4396BC1D595250B69263" />
<ComponentRef Id="cmpAC685A1C6E354E228EB6A1DD95FF03D5" />
<ComponentRef Id="cmp6DAFD01CAA3A4C67185922F445EDE495" />
<ComponentRef Id="cmp4AF592F1EDC8794BF4A3CCC2DCB717DB" />
<ComponentRef Id="cmpA65CEF99B64C1E95632B68EDFBF3739E" />

View file

@ -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($_)
}

View file

@ -16,7 +16,6 @@
<PackageReference Include="Microsoft.PowerShell.Archive" Version="1.2.5" />
<PackageReference Include="PSReadLine" Version="2.1.0" />
<PackageReference Include="ThreadJob" Version="2.0.3" />
<PackageReference Include="PSDesiredStateConfiguration" Version="2.0.5" />
</ItemGroup>
</Project>

View file

@ -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
}
}

View file

@ -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 <Name> - <TestCaseName>" -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 <Name> from <ModuleName> - <TestCaseName>" -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 <Name> - <TestCaseName>" -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 <Name> from <ModuleName> - <TestCaseName>" -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 - <Name> from <ModuleName> - <TestCaseName>" -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 - <Name> - <TestCaseName>" -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=<expectedResult> when $global:DSCMachineStatus = <value>' -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:<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") }
$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'
@'
<configuration>
<appSetting>
<Test1/>
</appSetting>
</configuration>
'@ | 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
}
}
}
}

View file

@ -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[];
};

View file

@ -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;
};

View file

@ -1,7 +0,0 @@
#pragma namespace("\\\\.\\root\\microsoft\\windows\\DesiredstateConfiguration")
[ClassVersion("1.0.0"),FriendlyName("Log")]
class MSFT_LogResource : OMI_BaseResource
{
[required] string Message;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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
}
}

View file

@ -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
}
}
}
}