MegaBites-AI/Windows-powershell
0372
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3 4Describe "ConvertFrom-SddlString Tests" -Tags "CI", "RequireAdminOnWindows" {5 6 BeforeAll {7 if (-not $IsWindows) { return }8 $sddl = (Get-Item -Path WSMan:\localhost\Service\RootSDDL).Value9 $testCases = @(10 @{ Type = "_UNSPECIFIED_" }11 @{ Type = "FileSystemRights" }12 @{ Type = "RegistryRights" }13 @{ Type = "ActiveDirectoryRights" }14 @{ Type = "MutexRights" }15 @{ Type = "SemaphoreRights" }16 @{ Type = "EventWaitHandleRights" }17 )18 $expectedProperties = @('Owner', 'Group', 'DiscretionaryAcl', 'SystemAcl', 'RawDescriptor')19 }20 21 It "Validate ConvertFrom-SddlString with type <Type>" -Skip:(!$IsWindows) -TestCases $testCases {22 param($Type)23 24 $arguments = @{ Sddl = $sddl; }25 if ($Type -ne "_UNSPECIFIED_") {26 $arguments.Add("Type", $Type)27 }28 29 $result = ConvertFrom-SddlString @arguments30 foreach ($property in $expectedProperties)31 {32 $result.$property | Should -Not -Be $null33 }34 }35 36 It "Validate that ConvertFrom-SddlString with type <Type> via ValueFromPipeline" -Skip:(!$IsWindows) -TestCases $testCases {37 param($Type)38 39 $arguments = @{ }40 if ($Type -ne "_UNSPECIFIED_") {41 $arguments.Add("Type", $Type)42 }43 44 $result = $sddl | ConvertFrom-SddlString @arguments45 foreach ($property in $expectedProperties)46 {47 $result.$property | Should -Not -Be $null48 }49 }50}51 