From 45791aa030c0366afba4ebdc2a66e54ace47ceac Mon Sep 17 00:00:00 2001 From: PowerShell Team Date: Tue, 5 Jul 2016 15:38:37 -0700 Subject: [PATCH] Add tests for TimeZone cmdlets and FileCatalog cmdlets [SD:717473] --- .../Clear-EventLog.Tests.ps1 | 4 +- .../Get-EventLog.Tests.ps1 | 2 +- .../Get-TimeZone.Tests.ps1 | 118 ++++++ .../New-EventLog.Tests.ps1 | 4 +- .../Remove-EventLog.Tests.ps1 | 4 +- .../Set-TimeZone.Tests.ps1 | 133 ++++++ .../FileCatalog.Tests.ps1 | 377 ++++++++++++++++++ .../CatalogTestData/CatalogTestFile1.mof | Bin 0 -> 2558 bytes .../CatalogTestData/CatalogTestFile2.xml | 49 +++ .../CatalogTestData/TestFileCatalog.txt | 1 + .../TestData/CatalogTestData/TestImage.gif | Bin 0 -> 4796 bytes .../UserConfigProviderModVersion1.psm1 | 61 +++ .../UserConfigProviderModVersion1.schema.mof | 8 + .../UserConfigProviderModVersion2.psm1 | 62 +++ .../UserConfigProviderModVersion2.schema.mof | 8 + .../UserConfigProviderModVersion3.psm1 | 62 +++ .../UserConfigProviderModVersion3.schema.mof | 8 + .../DSCResources/scriptdsc/scriptdsc.psd1 | Bin 0 -> 5224 bytes .../scriptdsc/scriptdsc.schema.psm1 | 15 + .../UserConfigProv/UserConfigProv.psd1 | 12 + .../Compare-Object.Tests.ps1 | 12 +- 21 files changed, 927 insertions(+), 13 deletions(-) create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Management/Get-TimeZone.Tests.ps1 create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Management/Set-TimeZone.Tests.ps1 create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1 create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/CatalogTestFile1.mof create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/CatalogTestFile2.xml create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/TestFileCatalog.txt create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/TestImage.gif create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/UserConfigProviderModVersion1/UserConfigProviderModVersion1.psm1 create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/UserConfigProviderModVersion1/UserConfigProviderModVersion1.schema.mof create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/UserConfigProviderModVersion2/UserConfigProviderModVersion2.psm1 create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/UserConfigProviderModVersion2/UserConfigProviderModVersion2.schema.mof create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/UserConfigProviderModVersion3/UserConfigProviderModVersion3.psm1 create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/UserConfigProviderModVersion3/UserConfigProviderModVersion3.schema.mof create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/scriptdsc/scriptdsc.psd1 create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/scriptdsc/scriptdsc.schema.psm1 create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/UserConfigProv.psd1 diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Clear-EventLog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Clear-EventLog.Tests.ps1 index 014b3126a7..9fff93ab30 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Clear-EventLog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Clear-EventLog.Tests.ps1 @@ -1,4 +1,4 @@ -if ($IsWindows) { +if ($IsWindows -and !$IsCore) { #check to see whether we're running as admin in Windows... $windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() $windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity @@ -28,4 +28,4 @@ if ($IsWindows) { } catch {$_.FullyQualifiedErrorId | Should Be "Microsoft.PowerShell.Commands.ClearEventLogCommand"} } } -} \ No newline at end of file +} diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-EventLog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-EventLog.Tests.ps1 index d10fcc5943..ebeb00f480 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-EventLog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-EventLog.Tests.ps1 @@ -1,4 +1,4 @@ -if ($IsWindows) { +if ($IsWindows -and !$IsCore) { #check to see whether we're running as admin in Windows... $windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() $windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-TimeZone.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-TimeZone.Tests.ps1 new file mode 100644 index 0000000000..b369a9d7c9 --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-TimeZone.Tests.ps1 @@ -0,0 +1,118 @@ +# This is a Pester test suite to validate the cmdlets in the TimeZone module +# +# Copyright (c) Microsoft Corporation, 2016 + +<# + -------------------------------------- + Script Notes: opportunities for improving this test script + -------------------------------------- + Localization + Many of the tests below looking-up timezones by Name do not support localization. + That is, the current tests use us english versions of StandardName and DaylighName for tests. + + ref: https://msdn.microsoft.com/en-us/library/windows/desktop/ms725481.aspx + [snippet] Both StandardName and DaylightName are localized according to the current user default UI language. +#> + +function Assert-ListsSame +{ + param([object[]] $expected, [object[]] $observed ) + $compResult = Compare-Object $observed $expected | Select-Object -ExpandProperty InputObject + if ($compResult) + { + $observedList = ([string]::Join("|",$observed)) + $expectedList = ([string]::Join("|",$expected)) + $observedList | Should Be $expectedList + } +} + +Describe "Get-Timezone test case no switches" -tags 'BVT' { + It "Call without ListAvailable switch returns current TimeZoneInfo" { + $observed = (Get-TimeZone).Id + $expected = ([System.TimeZoneInfo]::Local).Id + $observed -eq $expected | Should Be $true + } +} + +Describe "Get-Timezone test cases" -tags 'Innerloop','RI' { + + It "Call without ListAvailable switch returns an object of type TimeZoneInfo" { + $result = (Get-TimeZone).GetType().Name + $result | Should Be "TimeZoneInfo" + } + + It "Call WITH ListAvailable switch returns ArrayList of TimeZoneInfo objects where the list is greater than 0 item" { + $list = Get-TimeZone -ListAvailable + $list.Count -gt 0 | Should Be $true + + $list.GetType().Name | Should Be "Object[]" + $list[0].GetType().Name | Should Be "TimeZoneInfo" + } + + It "Call with ListAvailable switch returns a list containing TimeZoneInfo.Local" { + $observedIdList = Get-TimeZone -ListAvailable | select -ExpandProperty Id + $oneExpectedId = ([System.TimeZoneInfo]::Local).Id + $observedIdList -contains $oneExpectedId | Should Be $true + } + + It "Call with ListAvailable switch returns a list containing one returned by Get-TimeZone" { + $observedIdList = Get-TimeZone -ListAvailable | select -ExpandProperty Id + $oneExpectedId = (Get-TimeZone).Id + $observedIdList -contains $oneExpectedId | Should Be $true + } + + It "Call Get-TimeZone using ID param and single item" { + (Get-TimeZone -Id "Cape Verde Standard Time").Id -eq "Cape Verde Standard Time" | Should Be $true + } + + It "Call Get-TimeZone using ID param and multiple items" { + $idList = @("Cape Verde Standard Time","Morocco Standard Time","Azores Standard Time") + $result = (Get-TimeZone -Id $idList).Id + Assert-ListsSame $result $idList + } + + It "Call Get-TimeZone using ID param and multiple items, where first and third are invalid ids - expect error" { + $null = Get-TimeZone -Id @("Cape Verde Standard","Morocco Standard Time","Azores Standard") ` + -ErrorVariable errVar -ErrorAction SilentlyContinue + $errVar.Count -eq 2 | Should Be $true + $errVar[0].FullyQualifiedErrorID | Should Be "TimeZoneNotFound,Microsoft.PowerShell.Commands.GetTimeZoneCommand" + } + + It "Call Get-TimeZone using ID param and multiple items, one is wild card but error action ignore works as expected" { + $result = Get-TimeZone -Id @("Cape Verde Standard Time","Morocco Standard Time","*","Azores Standard Time") ` + -ErrorAction SilentlyContinue | % Id + $expectedIdList = @("Cape Verde Standard Time","Morocco Standard Time","Azores Standard Time") + Assert-ListsSame $expectedIdList $result + } + + It "Call Get-TimeZone using Name param and singe item" { + $timezoneList = Get-TimeZone -ListAvailable + $timezoneName = $timezoneList[0].StandardName + $observed = Get-TimeZone -Name $timezoneName + $observed.StandardName -eq $timezoneName | Should Be $true + } + + It "Call Get-TimeZone using Name param with wild card" { + $result = (Get-TimeZone -Name "Pacific*").Id + $expectedIdList = @("Pacific Standard Time (Mexico)","Pacific Standard Time","Pacific SA Standard Time") + Assert-ListsSame $expectedIdList $result + } + + It "Verify that alias 'gtz' exists" { + (Get-Alias -Name "gtz").Name | Should Be "gtz" + } + + It "Call Get-TimeZone Name parameter from pipeline by value " { + $result = ("Pacific*" | Get-TimeZone).Id + $expectedIdList = @("Pacific Standard Time (Mexico)","Pacific Standard Time","Pacific SA Standard Time") + Assert-ListsSame $expectedIdList $result + } + + It "Call Get-TimeZone Id parameter from pipeline by ByPropertyName" { + $timezoneList = Get-TimeZone -ListAvailable + $timezone = $timezoneList[0] + $observed = $timezone | Get-TimeZone + $observed.StandardName -eq $timezone.StandardName | Should Be $true + } +} + diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/New-EventLog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/New-EventLog.Tests.ps1 index 8ef155616e..30955ffd06 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/New-EventLog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/New-EventLog.Tests.ps1 @@ -1,4 +1,4 @@ -if ($IsWindows) { +if ($IsWindows -and !$IsCore) { #check to see whether we're running as admin in Windows... $windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() $windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity @@ -44,4 +44,4 @@ $result.EventID | Should be 4 } } -} \ No newline at end of file +} diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Remove-EventLog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Remove-EventLog.Tests.ps1 index 78a6a9ae9f..26787c206d 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Remove-EventLog.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Remove-EventLog.Tests.ps1 @@ -1,4 +1,4 @@ -if ($IsWindows) { +if ($IsWindows -and !$IsCore) { #check to see whether we're running as admin in Windows... $windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() $windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity @@ -28,4 +28,4 @@ } catch {$_.FullyQualifiedErrorId | Should Be "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"} } } -} \ No newline at end of file +} diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-TimeZone.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-TimeZone.Tests.ps1 new file mode 100644 index 0000000000..ed76e0b1ae --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-TimeZone.Tests.ps1 @@ -0,0 +1,133 @@ +# This is a Pester test suite to validate the cmdlets in the TimeZone module +# +# Copyright (c) Microsoft Corporation, 2016 + +<# + -------------------------------------- + Script Notes: opportunities for improving this test script + -------------------------------------- + Localization + Many of the tests below looking-up timezones by Name do not support localization. + That is, the current tests use us english versions of StandardName and DaylighName for tests. + + ref: https://msdn.microsoft.com/en-us/library/windows/desktop/ms725481.aspx + [snippet] Both StandardName and DaylightName are localized according to the current user default UI language. +#> + +function Assert-ListsSame +{ + param([object[]] $expected, [object[]] $observed ) + $compResult = Compare-Object $observed $expected | Select-Object -ExpandProperty InputObject + if ($compResult) + { + $observedList = ([string]::Join("|",$observed)) + $expectedList = ([string]::Join("|",$expected)) + $observedList | Should Be $expectedList + } +} + +Describe "Set-Timezone test case: call by single Id" -tags 'BVT' { + $originalTimeZoneId + BeforeAll { + $originalTimeZoneId = (Get-TimeZone).Id + } + AfterAll { + Set-TimeZone -ID $originalTimeZoneId + } + + It "Call Set-TimeZone by Id" { + $origTimeZoneID = (Get-TimeZone).Id + $timezoneList = Get-TimeZone -ListAvailable + $testTimezone = $null + foreach($timezone in $timezoneList) + { + if ($timezone.Id -ne $origTimeZoneID) + { + $testTimezone = $timezone + break + } + } + Set-TimeZone -Id $testTimezone.Id + $observed = Get-TimeZone + $testTimezone.Id -eq $observed.Id | Should Be $true + } +} + +Describe "Set-Timezone test cases" -tags 'Innerloop','RI' { + $originalTimeZoneId + BeforeAll { + $originalTimeZoneId = (Get-TimeZone).Id + } + AfterAll { + Set-TimeZone -ID $originalTimeZoneId + } + + It "Call Set-TimeZone with invalid Id" { + $exception = $null + try { Set-TimeZone -Id "zzInvalidID" } catch { $exception = $_ } + $exception.FullyQualifiedErrorID | Should Be "TimeZoneNotFound,Microsoft.PowerShell.Commands.SetTimeZoneCommand" + } + + It "Call Set-TimeZone by Name" { + $origTimeZoneName = (Get-TimeZone).StandardName + $timezoneList = Get-TimeZone -ListAvailable + $testTimezone = $null + foreach($timezone in $timezoneList) + { + if ($timezone.StandardName -ne $origTimeZoneName) + { + $testTimezone = $timezone + break + } + } + Set-TimeZone -Name $testTimezone.StandardName + $observed = Get-TimeZone + $testTimezone.StandardName -eq $observed.StandardName | Should Be $true + } + + It "Call Set-TimeZone with invalid Name" { + $exception = $null + try { Set-TimeZone -Name "zzINVALID_Name" } catch { $exception = $_ } + $exception.FullyQualifiedErrorID | Should Be "TimeZoneNotFound,Microsoft.PowerShell.Commands.SetTimeZoneCommand" + } + + It "Verify that alias 'stz' exists" { + (Get-Alias -Name "stz").Name | Should Be "stz" + } + + It "Call Set-TimeZone from pipeline input object of type TimeZoneInfo" { + $origTimeZoneID = (Get-TimeZone).Id + $timezoneList = Get-TimeZone -ListAvailable + $testTimezone = $null + foreach($timezone in $timezoneList) + { + if ($timezone.Id -ne $origTimeZoneID) + { + $testTimezone = $timezone + break + } + } + + $testTimezone | Set-TimeZone + $observed = Get-TimeZone + $observed.ID -eq $testTimezone.Id | Should Be $true + } + + It "Call Set-TimeZone from pipeline input object of type TimeZoneInfo, verify supports whatif" { + $origTimeZoneID = (Get-TimeZone).Id + $timezoneList = Get-TimeZone -ListAvailable + $testTimezone = $null + foreach($timezone in $timezoneList) + { + if ($timezone.Id -ne $origTimeZoneID) + { + $testTimezone = $timezone + break + } + } + + Set-TimeZone -Id $testTimezone.Id -WhatIf > $null + $observed = Get-TimeZone + $observed.Id -eq $origTimeZoneID | Should Be $true + } +} diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1 new file mode 100644 index 0000000000..99a36df0f5 --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1 @@ -0,0 +1,377 @@ +# This is a Pester test suite to validate the New-FileCatalog & Test-FileCatalog cmdlets on PowerShell Core. +# +# Copyright (c) Microsoft Corporation, 2016 +# + +$script:catalogPath = "" + +Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "Innerloop","BVT" { + + #compare two hashtables + function CompareHashTables + { + param + ( + $hashTable1, + $hashTable2 + ) + + foreach ($key in $hashTable1.keys) + { + $keyValue1 = $hashTable1["$key"] + if($hashTable2.ContainsKey($key)) + { + $keyValue2 = $hashTable2["$key"] + $keyValue1 | Should Be $keyValue2 + } + else + { + throw "Failed to find the file $keyValue1 for $key in Hashtable" + } + } + } + + BeforeAll { + $testDataPath = "$PSScriptRoot\TestData\CatalogTestData" + } + + Context "NewAndTestCatalogTests PositiveTestCases when validation Succeeds" { + + It "NewFileCatalogFolder" { + + $sourcePath = Join-Path $testDataPath 'UserConfigProv\DSCResources\scriptdsc' + $catalogPath = "$testDataPath\NewFileCatalogFolder.cat" + + try + { + $null = New-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath -CatalogVersion 1.0 + $result = Test-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath -Detailed + } + finally + { + Remove-Item $catalogPath -Force -ErrorAction SilentlyContinue + } + + # Validate result properties + $result.Status | Should Be "Valid" + $result.Signature.Status | Should Be "NotSigned" + $result.HashAlgorithm | Should Be "SHA1" + } + + It "NewFileCatalogFolderWithSubFolders" { + + $sourcePath = Join-Path $testDataPath 'UserConfigProv' + # use non existant Path for the directory when .cat file name is specified + $catalogPath = "$testDataPath\OutPutCatalog\NewFileCatalogFolderWithSubFolders.cat" + + try + { + $null = New-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath + $result = Test-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath -Detailed + } + finally + { + Remove-Item "$sourcePath\OutPutCatalog" -Force -ErrorAction SilentlyContinue -Recurse + } + + # Validate result properties + $result.Status | Should Be "Valid" + $result.Signature.Status | Should Be "NotSigned" + $result.HashAlgorithm | Should Be "SHA1" + } + + It "NewFileCatalogWithSingleFile" { + + $sourcePath = Join-Path $testDataPath '\CatalogTestFile1.mof' + # use existant Path for the directory when .cat file name is not specified + $catalogPath = $testDataPath + try + { + $null = New-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath + $result = Test-FileCatalog -Path $sourcePath -CatalogFilePath ($catalogPath + "\catalog.cat") + } + finally + { + Remove-Item "$catalogPath\catalog.cat" -Force -ErrorAction SilentlyContinue + } + + # Validate result properties + $result | Should Be "Valid" + } + + It "NewFileCatalogForFilesThatDoNotSupportEmbeddedSignatures" { + + $expectedPathsAndHashes = @{ "TestImage.gif" = "B0E4B9F0BB21284AA0AF0D525C913420AD73DA6A" ; + "TestFileCatalog.txt" = "925834D22A8AEB8E0A5EAFABC739F8AFAAD3E490" } + + # use non existant Path for the directory when .cat file name is not specified + $catalogPath = "$testDataPath\OutPutCatalog" + + try + { + $null = New-FileCatalog -Path "$testDataPath\TestImage.gif","$testDataPath\TestFileCatalog.txt" -CatalogFilePath $catalogPath -CatalogVersion 1.0 + $result = Test-FileCatalog -Path "$testDataPath\TestImage.gif","$testDataPath\TestFileCatalog.txt" -CatalogFilePath ($catalogPath + "\catalog.cat") -Detailed + } + finally + { + Remove-Item "$catalogPath" -Force -ErrorAction SilentlyContinue -Recurse + } + + $result.Status | Should Be "Valid" + $result.CatalogItems.Count | Should Be 2 + $result.PathItems.Count | Should Be 2 + CompareHashTables $result.CatalogItems $result.PathItems + CompareHashTables $result.CatalogItems $expectedPathsAndHashes + } + + It "NewFileCatalogWithMutipleFoldersAndFiles" { + + $expectedPathsAndHashes = @{ + "UserConfigProv.psd1" = "748E5486814051DA3DFB79FE8964152727213248" ; + "DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.schema.mof" ="F7CAB050E32CF0C9B2AC2807C4F24D31EFCC8B61"; + "dscresources\UserConfigProviderModVersion3\UserConfigProviderModVersion3.psm1" = "F9DD6B02C7BD0FB98A25BE0D41210B2A2333E139"; + "DSCResources\scriptdsc\scriptDSC.schema.psm1"= "CDBAF85FEDE2E0CD09B1AEA0532010CEFCECBC12"; + "DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1" = "7599777B85B60377B1F3E492C817190090A754A7" + "DSCResources\scriptdsc\scriptdsc.psd1"= "CDDC68AF9B863760A14031772DC9ADDAFD209D80"; + "DSCResources\UserConfigProviderModVersion3\UserConfigProviderModVersion3.schema.mof" ="AFEB46104F506FC64CAB4B0B2A9C6C50622B487A"; + "DSCResources\UserConfigProviderModVersion2\UserConfigProviderModVersion2.psm1"= "60CB9C8AEDA7A64127D34361ED4F30DEAFE37022"; + "DSCResources\UserConfigProviderModVersion2\UserConfigProviderModVersion2.schema.mof" = "E33FBFEA28E9A8FBA793FBC3D8015BCC9A10944B"; + "CatalogTestFile1.mof" = "083B0953D0D70FFF62710F0356FEB86BCE327FE7"; + "CatalogTestFile2.xml" = "E73BB7A0DD9FAC6A8182F67B750D9CA3094490F1" } + + $catalogPath = "$env:TEMP\NewFileCatalogWithMutipleFoldersAndFiles.cat" + $catalogDataPath = @("$testDataPath\UserConfigProv\","$testDataPath\CatalogTestFile1.mof","$testDataPath\CatalogTestFile2.xml") + + try + { + $null =New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 1.0 + $result = Test-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -Detailed + } + finally + { + Remove-Item "$catalogPath" -Force -ErrorAction SilentlyContinue + } + + $result.Status | Should Be "Valid" + $result.Signature.Status | Should Be "NotSigned" + $result.HashAlgorithm | Should Be "SHA1" + $result.CatalogItems.Count | Should Be 11 + $result.PathItems.Count | Should Be 11 + + CompareHashTables $result.CatalogItems $result.PathItems + CompareHashTables $result.CatalogItems $expectedPathsAndHashes + } + + It "NewFileCatalogVersion2WithMutipleFoldersAndFiles" { + + $expectedPathsAndHashes = @{ + "UserConfigProv.psd1" = "9FFE4CA2873CD91CDC9D71362526446ECACDA64D26DEA768E6CE489B84D888E4" ; + "DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.schema.mof" ="517F625CB6C465928586F5C613F768B33C20F477DAF843C179071B8C74B992AA"; + "DSCResources\UserConfigProviderModVersion3\UserConfigProviderModVersion3.psm1" = "0774A539E73B1A480E38CFFE2CF0B8AC46120A0B2E0377E0DE2630031BE83347"; + "DSCResources\scriptdsc\scriptdsc.schema.psm1"= "7DE80DED0F96FA7D34CF34089A1B088E91CD7B1D80251949FC7C78A6308D51C3"; + "DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1" = "EB0310C630EDFDFBDD1D993A636EC9B75BB1F04DF7E7FFE39CF6357679C852C7" + "DSCResources\scriptdsc\scriptdsc.psd1"= "AB8E8D0840D4854CDCDE25058872413AF417FC016BD77FD5EC677BBB7393532B"; + "DSCResources\UserConfigProviderModVersion3\UserConfigProviderModVersion3.schema.mof" ="7163E607F067A3C4F91D3AFF3C466ECA47C0CF84B5F0DDA22B2C0E99929B5E21"; + "DSCResources\UserConfigProviderModVersion2\UserConfigProviderModVersion2.psm1"= "6591FE02528D7FB66F00E09D7F1A025D5D5BAF30A49C5FF1EC562FAE39B38F43"; + "DSCResources\UserConfigProviderModVersion2\UserConfigProviderModVersion2.schema.mof" = "679318201B012CC5936B29C095956B2131FAF828C0CCA4342A5914F721480FB9"; + "CatalogTestFile1.mof" = "7C1885AE5F76F58DAA232A5E962875F90308C3CB8580400EE12F999B4E10F940"; + "CatalogTestFile2.xml" = "00B7DA28CD285F796660D36B77B2EC6054F21A44D5B329EB6BC4EC7687D70B13"; + "TestImage.gif" = "2D938D255D0D6D547747BD21447CF7295318D34D9B4105D04C1C27487D2FF402" } + + + $catalogPath = "$env:TEMP\NewFileCatalogVersion2WithMutipleFoldersAndFiles.cat" + $catalogDataPath = @("$testDataPath\UserConfigProv\","$testDataPath\CatalogTestFile1.mof","$testDataPath\CatalogTestFile2.xml", "$testDataPath\TestImage.gif") + + try + { + $null = New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 2.0 + $result = Test-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -Detailed + } + finally + { + Remove-Item "$catalogPath" -Force -ErrorAction SilentlyContinue + } + + $result.Status | Should Be "Valid" + $result.Signature.Status | Should Be "NotSigned" + $result.HashAlgorithm | Should Be "SHA256" + $result.CatalogItems.Count | Should Be 12 + $result.PathItems.Count | Should Be 12 + CompareHashTables $result.CatalogItems $result.PathItems + CompareHashTables $result.CatalogItems $expectedPathsAndHashes + } + + It "NewFileCatalogFolderWhenCatlogFileIsCreatedInsideSameFolder" { + + $catalogPath = "$env:TEMP\UserConfigProv\NewFileCatalogFolderWhenCatlogFileIsCreatedInsideSameFolder.cat" + try + { + copy-item $testDataPath\UserConfigProv $env:temp -Recurse -ErrorAction SilentlyContinue + $null = New-FileCatalog -Path $env:temp\UserConfigProv\ -CatalogFilePath $catalogPath -CatalogVersion 1.0 + $result = Test-FileCatalog -Path $env:temp\UserConfigProv\ -CatalogFilePath $catalogPath + } + finally + { + Remove-Item "$catalogPath" -Force -ErrorAction SilentlyContinue + Remove-Item "$env:temp\UserConfigProv\" -Force -ErrorAction SilentlyContinue -Recurse + } + + $result | Should Be "Valid" + } + + It "NewFileCatalogWithUnicodeCharactersInFileNames" { + + $expectedPathsAndHashes = @{ + "UserConfigProv.psd1" = "9FFE4CA2873CD91CDC9D71362526446ECACDA64D26DEA768E6CE489B84D888E4" ; + "DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.schema.mof" ="517F625CB6C465928586F5C613F768B33C20F477DAF843C179071B8C74B992AA"; + "DSCResources\UserConfigProviderModVersion3\UserConfigProviderModVersion3.psm1" = "0774A539E73B1A480E38CFFE2CF0B8AC46120A0B2E0377E0DE2630031BE83347"; + "DSCResources\scriptdsc\scriptdsc.schema.psm1"= "7DE80DED0F96FA7D34CF34089A1B088E91CD7B1D80251949FC7C78A6308D51C3"; + "DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1" = "EB0310C630EDFDFBDD1D993A636EC9B75BB1F04DF7E7FFE39CF6357679C852C7" + "DSCResources\scriptdsc\scriptdsc.psd1"= "AB8E8D0840D4854CDCDE25058872413AF417FC016BD77FD5EC677BBB7393532B"; + "DSCResources\UserConfigProviderModVersion3\UserConfigProviderModVersion3.schema.mof" ="7163E607F067A3C4F91D3AFF3C466ECA47C0CF84B5F0DDA22B2C0E99929B5E21"; + "DSCResources\UserConfigProviderModVersion2\UserConfigProviderModVersion2.psm1"= "6591FE02528D7FB66F00E09D7F1A025D5D5BAF30A49C5FF1EC562FAE39B38F43"; + "DSCResources\UserConfigProviderModVersion2\UserConfigProviderModVersion2.schema.mof" = "679318201B012CC5936B29C095956B2131FAF828C0CCA4342A5914F721480FB9"; + "ٿ ڀ ځ ڂ ڃ ڄ څ چ ڇ ڈ ډ ڊ ڋ ڌ ڍ ڎ ڏ ڐ ڑ.txt" = "EFD0AE8FF12C7387D51FFC03259B60E06DA012BF7D3B7B9D3480FAB2864846CE"; + "ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ.txt" = "9FB57660EDD8DA898A9F1E7F5A36B8B760B4A21625F9968D87A32A55B3546BF9"} + + # Create Test Files with unicode characters in names and content + $unicodeTempDir = Join-Path -Path $testDataPath -ChildPath "UnicodeTestDir" + $null = New-Item -ItemType Directory -Path $unicodeTempDir -Force + + $null = New-Item -ItemType File -Path "$unicodeTempDir\ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ.txt" -Force -ErrorAction SilentlyContinue + $null = Add-Content -Path "$unicodeTempDir\ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ.txt" -Value "Testing unicode" + $null = Out-File -FilePath "$unicodeTempDir\ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ.txt" -Encoding unicode -InputObject "ɗ ɘ ə ɚ ɛ ɜ ɝ ɞ ɟ ɠ ɡ ɢ ɣ ɤ ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ ɭ ɮ ɯ ɰ ɱ ɲ ɳ ɴ ɵ ɶ ɷ ɸ ɹ ɺ ɻ ɼ ɽ ɾ ɿ ʀ ʁ ʂ ʃ ʄ ʅ" -Append + $null = New-Item -ItemType File -Path "$unicodeTempDir\ٿ ڀ ځ ڂ ڃ ڄ څ چ ڇ ڈ ډ ڊ ڋ ڌ ڍ ڎ ڏ ڐ ڑ.txt" -Force -ErrorAction SilentlyContinue + $null = Out-File -FilePath "$unicodeTempDir\ٿ ڀ ځ ڂ ڃ ڄ څ چ ڇ ڈ ډ ڊ ڋ ڌ ڍ ڎ ڏ ڐ ڑ.txt" -Encoding unicode -InputObject "ਅ ਆ ਇ ਈ ਉ ਊ ਏ ਐ ਓ ਔ ਕ ਖ ਗ ਘ ਙ ਚ ਛ ਜ ਝ ਞ ਟ ਠ ਡ ਢ ਣ ਤ ਥ ਦ ਧ ਨ ਪ ਫ ਬ ਭ ਮ ਯ ਰ ਲ ਲ਼ ਵ " -Append + $null = Out-File -FilePath "$unicodeTempDir\ٿ ڀ ځ ڂ ڃ ڄ څ چ ڇ ڈ ډ ڊ ڋ ڌ ڍ ڎ ڏ ڐ ڑ.txt" -Encoding unicode -InputObject "அ ஆ இ ஈ உ ஊ எ ஏ ஐ ஒ ஓ ஔ க ங ச ஜ ஞ ட ண த ந ன ப ம ய ர ற ல ள ழ வ ஷ ஸ ஹ " -Append + + $catalogPath = "$env:TEMP\క ఖ గ ఘ ఙ చ ఛ జ ఝ ఞ.cat" + $catalogDataPath = @("$testDataPath\UserConfigProv\", "$unicodeTempDir\ٿ ڀ ځ ڂ ڃ ڄ څ چ ڇ ڈ ډ ڊ ڋ ڌ ڍ ڎ ڏ ڐ ڑ.txt" ,"$unicodeTempDir\ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ.txt") + + try + { + $null = New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 2.0 + $result = Test-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -Detailed + } + finally + { + Remove-Item $unicodeTempDir -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item "$catalogPath" -Force -ErrorAction SilentlyContinue + } + + $result.Status | Should Be "Valid" + $result.Signature.Status | Should Be "NotSigned" + $result.HashAlgorithm | Should Be "SHA256" + $result.CatalogItems.Count | Should Be 11 + $result.PathItems.Count | Should Be 11 + CompareHashTables $result.CatalogItems $result.PathItems + CompareHashTables $result.CatalogItems $expectedPathsAndHashes + } + } + + Context "NewAndTestCatalogTests NegativeTestCases when creation or validation Fails"{ + + AfterEach { + Remove-Item "$script:catalogPath" -Force -ErrorAction SilentlyContinue + Remove-Item "$env:temp\UserConfigProv" -Force -Recurse -ErrorAction SilentlyContinue + } + + It "TestCatalogWhenNewFileAddedtoFolderBeforeValidation" { + + $script:catalogPath = "$env:TEMP\TestCatalogWhenNewFileAddedtoFolderBeforeValidation.cat" + $null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2.0 + $null = copy-item $testDataPath\UserConfigProv $env:temp -Recurse -ErrorAction SilentlyContinue + $null = New-Item $env:temp\UserConfigProv\DSCResources\NewFile.txt -ItemType File + Add-Content $env:temp\UserConfigProv\DSCResources\NewFile.txt -Value "More Data" -force + $result = Test-FileCatalog -Path $env:temp\UserConfigProv -CatalogFilePath $script:catalogPath -Detailed + + $result.Status | Should Be "ValidationFailed" + $result.CatalogItems.Count | Should Be 9 + $result.PathItems.Count | Should Be 10 + $result.CatalogItems.ContainsKey("DSCResources\NewFile.txt") | Should Be $false + $result.PathItems.ContainsKey("DSCResources\NewFile.txt") | Should Be $true + + # By Skipping the new added file validation will pass + $result = Test-FileCatalog -Path $env:temp\UserConfigProv -CatalogFilePath $script:catalogPath -Detailed -FilesToSkip "NewFile.txt" + $result.Status | Should Be "Valid" + } + + It "TestCatalogWhenNewFileDeletedFromFolderBeforeValidation" { + + $script:catalogPath = "$env:TEMP\TestCatalogWhenNewFileDeletedFromFolderBeforeValidation.cat" + $null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1.0 + $null = copy-item $testDataPath\UserConfigProv $env:temp -Recurse -ErrorAction SilentlyContinue + del $env:temp\UserConfigProv\DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1 -force -ErrorAction SilentlyContinue + $result = Test-FileCatalog -Path $env:temp\UserConfigProv -CatalogFilePath $script:catalogPath -Detailed + + $result.Status | Should Be "ValidationFailed" + $result.CatalogItems.Count | Should Be 9 + $result.PathItems.Count | Should Be 8 + $result.CatalogItems.ContainsKey("DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1") | Should Be $true + $result.PathItems.ContainsKey("DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1") | Should Be $false + + # By Skipping the deleted file validation will pass + $result = Test-FileCatalog -Path $env:temp\UserConfigProv -CatalogFilePath $script:catalogPath -Detailed -FilesToSkip "UserConfigProviderModVersion1.psm1" + $result.Status | Should Be "Valid" + } + + It "TestCatalogWhenFileContentModifiedBeforeValidation" { + + $script:catalogPath = "$env:TEMP\TestCatalogWhenFileContentModifiedBeforeValidation.cat" + $null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1.0 + $null = copy-item $testDataPath\UserConfigProv $env:temp -Recurse -ErrorAction SilentlyContinue + Add-Content $env:temp\UserConfigProv\DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1 -Value "More Data" -Force + $result = Test-FileCatalog -Path $env:temp\UserConfigProv -CatalogFilePath $script:catalogPath -Detailed + + $result.Status | Should Be "ValidationFailed" + $result.CatalogItems.Count | Should Be 9 + $result.PathItems.Count | Should Be 9 + $catalogHashValue = $result.CatalogItems["DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1"] + $pathHashValue = $result.PathItems["DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1"] + ($catalogHashValue -eq $pathHashValue) | Should Be $false + + # By Skipping the file with modifed contents validation will pass + $result = Test-FileCatalog -Path $env:temp\UserConfigProv -CatalogFilePath $script:catalogPath -Detailed -FilesToSkip "UserConfigProviderModVersion1.psm1" + $result.Status | Should Be "Valid" + } + } + + Context "TestCatalog Skip Validation Tests"{ + + AfterEach { + Remove-Item "$script:catalogPath" -Force -ErrorAction SilentlyContinue + } + + It "TestCatalogSkipSingleFileDuringValidation" { + + $script:catalogPath = "$env:TEMP\TestCatalogSkipSingleFileDuringValidation.cat" + $null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2.0 + $result = Test-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -FilesToSkip "scriptdsc.schema" + $result | Should Be "Valid" + } + + It "TestCatalogSkipCertainFileTypeDuringValidation" { + + $script:catalogPath = "$env:TEMP\TestCatalogSkipCertainFileTypeDuringValidation.cat" + $null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2.0 + $result = Test-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -FilesToSkip "*.mof" + $result | Should Be "Valid" + } + + It "TestCatalogSkipWildCardPatternDuringValidation" { + + $script:catalogPath = "$env:TEMP\TestCatalogSkipWildCardPatternDuringValidation.cat" + $null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1.0 + $result = Test-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -FilesToSkip "UserConfigProvider*.psm1" + $result | Should Be "Valid" + } + + It "TestCatalogSkipMuitplePattensDuringValidation" { + + $script:catalogPath = "$env:TEMP\TestCatalogSkipMuitplePattensDuringValidation.cat" + $null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1.0 + $result = Test-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -FilesToSkip "*.psd1","UserConfigProviderModVersion2.psm1","*ModVersion1.schema.mof" + $result | Should Be "Valid" + } + } +} diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/CatalogTestFile1.mof b/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/CatalogTestFile1.mof new file mode 100644 index 0000000000000000000000000000000000000000..5ec9506131663e12fbeea236a3cfb1bde16ffde1 GIT binary patch literal 2558 zcmcJRYik-o6o${|LjJ=dg+L&QhS-ZmsL@`88YQObhqe@>HnDgKt|67szuxwFXIyvH zYBWt)W_M=ioHOTr&t><|?|s{`Eqh|G?bI4Jv2#It2bHb$pp*U0I8=AV)s?DUcHT6s&`OWU^tF5S~;Wi4>`9P6y*?9g7U zu=IZ7mrj0TXSR!O8ofitE*1{$nbY3EzOZU^@IY7^Je&9$VB%!=R5r%!_!8 zt@n`_Oiw71F<-cfoO|j#8R5-0nA6*mi>_wzo>m`_uQ-V!wq&tGBy@)I)aPs+G(+ZB zya}D`2@-vx6xv6Ia=zkns^zo>tjBhPhIp=F_r}SDtlDH%H^IFa+rx55_U5=$4|+a# z_vLxH$XU$NV(u!3Hp$#54=ecI0;?+F7;MVnD57!x)WACcgLoK$d_E5{iOjA!hAtCU zeAFTyJ-^9bq9_%xel@K{AGfGKMKSFmp}BgJYO0CXzLvGF+PVE;r^(J9<0m6#EQ#~X z;Rq+OkI-h&N>4OYg8?yImM`;6J#4mkuakXXSr4d^m1Qbmxu+#CG>Na`s%|5zTaz9X zfbs6j_qTxltLR6p + + + + + No + Linux + CentOS + Fre + 00000000-0000-0000-0000-000000000000 + No + Yes + + $ipAddress + + Yes + + 2001:4898:28:3:215:5dff:feb8:b9b3 + + Linux1 + Workgroup + None + X64 + en-US + Windows 8 Server + X64 + Server DataCenter + None + Unknown + C:\ + No + + + + Basic + + + + + + + Basic + + + + + + + \ No newline at end of file diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/TestFileCatalog.txt b/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/TestFileCatalog.txt new file mode 100644 index 0000000000..5c341af14e --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/TestFileCatalog.txt @@ -0,0 +1 @@ +Text File to test catalog \ No newline at end of file diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/TestImage.gif b/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/TestImage.gif new file mode 100644 index 0000000000000000000000000000000000000000..cac0342888368096f7ecb254061f4b3a829ede16 GIT binary patch literal 4796 zcmXYwc|25I{KpUV2r2tILbh<_iR(d)l&2^{>$LGy#I>X%Et8?HEL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uO3J}LOaxX^)t#rOWp|S0a}w3UHhJ=->E$h!l(}N4&#$+VBSPh z--@F=R#MJW7E<0^~$@RyOeLGt8uWB z*BE7Dn#wKvr7X^^8_<`39&cqzHMP50N_cB|l_l74?*i~RS&d>;H; z{keBlep1M7b=$a$81})w9!r}ss%$4&l+%igY0 z8|+&@3*F03Mw^}!vx2Hq#Ir6%c}$&$Dv~-z;dXhu_Tehusk4-)s;g7<#IszIR|qy~ z3F(uJj_2U-*1FqMD0lE-)z<4E$m#6L{T0r$re z(35LJ9Z-CZm8Gb)+luuZ+u0Q|kFfkC^9)&s z*zSUirEgXhz9=+!iq_s9(^b~2?~Z%RIO)9D1B`SxMhhJUi*Gr|me@*~LEV0w0fk-C>qzD||bVmLvY;$+?vNRl>gx QcCsDu%S5uqKUe+OzZBwHCIA2c literal 0 HcmV?d00001 diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/scriptdsc/scriptdsc.schema.psm1 b/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/scriptdsc/scriptdsc.schema.psm1 new file mode 100644 index 0000000000..2c58ee1768 --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/DSCResources/scriptdsc/scriptdsc.schema.psm1 @@ -0,0 +1,15 @@ + + +configuration scriptdsc +{ + param ($one, $two, $three) + + Import-DscResource -ModuleName UserConfigProv + Log scriptDscLogResource + { + Message = "This is the message from the embedded log resource: one=$one two=$two three=$three" + } + + } + +Export-ModuleMember -Function scriptdsc diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/UserConfigProv.psd1 b/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/UserConfigProv.psd1 new file mode 100644 index 0000000000..2bbd83efc5 --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/TestData/CatalogTestData/UserConfigProv/UserConfigProv.psd1 @@ -0,0 +1,12 @@ +@{ + ModuleVersion = '3.0.0.1' + Author = 'fayzas' + CompanyName = 'Microsoft Corporation' + Copyright = '(c) 2013 Microsoft Corporation. All rights reserved.' + Description = 'Hello World!' + PowerShellVersion = '3.0' + CLRVersion = '4.0' + RequiredModules = @() + # NestedModules = @("UserConfigProviderModVersion.psm1") + # FunctionsToExport = @("Get-TargetResource", "Set-TargetResource", "Test-TargetResource") + } \ No newline at end of file diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Compare-Object.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Compare-Object.Tests.ps1 index 6bde8fdd93..73ff7a5c79 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Compare-Object.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Compare-Object.Tests.ps1 @@ -1,6 +1,6 @@ Describe "Compare-Object" { BeforeAll { - $nl = [Environment]::NewLine + $nl = [Environment]::NewLine $content1 = "line 1" + $nl + "line 2" $content2 = "line 1" + $nl + "line 2.1" @@ -12,10 +12,10 @@ Describe "Compare-Object" { $file3 = Join-Path -Path $TestDrive -ChildPath "test3.txt" $file4 = Join-Path -Path $TestDrive -ChildPath "test4.txt" - New-Item $file1 -ItemType file -Value $content1 -Force - New-Item $file2 -ItemType file -Value $content2 -Force - New-Item $file3 -ItemType file -Value $content3 -Force - New-Item $file4 -ItemType file -Value $content4 -Force + $null = New-Item $file1 -ItemType file -Value $content1 -Force + $null = New-Item $file2 -ItemType file -Value $content2 -Force + $null = New-Item $file3 -ItemType file -Value $content3 -Force + $null = New-Item $file4 -ItemType file -Value $content4 -Force } It "Should be able to compare the same object using the referenceObject and differenceObject switches" { @@ -454,4 +454,4 @@ Describe "Compare-Object DRT basic functionality" -Tags DRT{ $result.InputObject | Should Be "refObject" $result.SideIndicator | Should Be "<=" } -} \ No newline at end of file +}