Skip to content

Commit d690630

Browse files
committed
Add integration test template
1 parent 2cbca67 commit d690630

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
param
22
(
33
[string]
4-
$DependencyPath = (Resolve-Path "$PSScriptRoot\requiredModules.psd1").Path
4+
$DependencyPath = (Resolve-Path "$PSScriptRoot\requiredModules.psd1").Path,
5+
6+
[switch]
7+
$BuildWorker
58
)
69

710
$psdependConfig = Import-PowerShellDataFile -Path $DependencyPath
811

9-
$null = Get-PackageProvider -Name NuGet -ForceBootstrap
12+
if ($BuildWorker.IsPresent)
13+
{
14+
$null = Get-PackageProvider -Name NuGet -ForceBootstrap
1015

11-
Save-Module -Name PackageManagement, PowerShellGet, PSDepend -Repository $psdependConfig.PSDependOptions.Parameters.Repository -Path $psdependConfig.PSDependOptions.Target -Force
16+
Install-Module -Force -Name PackageManagement, PowerShellGet -Repository $psdependConfig.PSDependOptions.Parameters.Repository -Scope CurrentUser
1217

13-
Remove-Module -Name PowerShellGet -ErrorAction SilentlyContinue -Force
14-
Remove-Module -Name PackageManagement -ErrorAction SilentlyContinue -Force
15-
Import-Module -Force -Name (Join-Path -Path $psdependConfig.PSDependOptions.Target -ChildPath PackageManagement\*\PackageManagement.psd1 -Resolve)
16-
Import-Module -Force -Name (Join-Path -Path $psdependConfig.PSDependOptions.Target -ChildPath PowerShellGet\*\PowerShellGet.psd1 -Resolve)
17-
Import-Module -Name (Join-Path -Path $psdependConfig.PSDependOptions.Target -ChildPath PSDepend\*\PSDepend.psd1 -Resolve)
18+
Remove-Module -Name PowerShellGet -ErrorAction SilentlyContinue -Force
19+
Remove-Module -Name PackageManagement -ErrorAction SilentlyContinue -Force
20+
Import-Module -Force -Name PowerShellGet
21+
Import-Module -Force -Name PackageManagement
1822

23+
$null = Install-WindowsFeature -Name GPMC
24+
}
25+
26+
Save-Module -Name PSDepend -Repository $psdependConfig.PSDependOptions.Parameters.Repository -Path $psdependConfig.PSDependOptions.Target -Force
27+
Import-Module -Name (Join-Path -Path $psdependConfig.PSDependOptions.Target -ChildPath PSDepend\*\PSDepend.psd1 -Resolve)
1928
Invoke-PSDepend -Path $DependencyPath -Force

templates/AppLockerProject/build/requiredModules.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
'Sampler.DscPipeline' = '0.2.0-preview0015' # Unfortunately still in preview
1515
Datum = '0.40.1'
1616
'Datum.InvokeCommand' = '0.3.0'
17-
AppLockerFoundry = '1.1.0'
17+
AppLockerFoundry = '1.1.5'
1818
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BeforeDiscovery {
2+
if (Get-DatumRsopCache)
3+
{
4+
Clear-DatumRsopCache
5+
}
6+
7+
$policies = foreach ($file in (Get-ChildItem -Path (Resolve-Path "$global:testroot\..\configurationdata\Policies").Path -Recurse -Filter *.y*ml -File))
8+
{
9+
@{
10+
Name = $file.BaseName
11+
Domain = $file.Directory.Name
12+
}
13+
}
14+
}
15+
16+
Describe "Policy exists" {
17+
It "<Name> Policy exists in <Domain>" -TestCases $policies {
18+
$gpo = Get-GPO -Name $Name -Domain $Domain
19+
$ctx = [System.DirectoryServices.ActiveDirectory.DirectoryContext]::new('Domain', $Domain)
20+
$domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetDomain($ctx)
21+
$domainDn = $domain.GetDirectoryEntry().DistinguishedName
22+
$appLockerGpo = try
23+
{
24+
Get-AppLockerPolicy -Domain -Ldap "LDAP://CN={$($gpo.Id)},CN=Policies,CN=System,$domainDn" -ErrorAction Stop
25+
}
26+
catch {} # Suppress exception from misbehaving cmdlet that does not like SilentlyContinue
27+
$appLockerGpo.RuleCollections | Should -Not -BeNullOrEmpty
28+
}
29+
}

0 commit comments

Comments
 (0)