Skip to content

Commit

Permalink
Merge branch 'master' into Fix-Products
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasBn authored May 13, 2022
2 parents d48f934 + e92798d commit 69f61f8
Show file tree
Hide file tree
Showing 18 changed files with 1,387 additions and 430 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ output/
markdownissues.txt
node_modules
package-lock.json
*.local.*
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Updated inital offline package sync WSUS.cab.
- Changed azurepipeline, use latest version of ubuntu and change the management
of pipeline artifact
- Updated build.ps1 script and build.yaml.
- Changed default timeout in Wait-Win32ProcessStart function for cab installation.

### Added

- Added TestKitchen files for integration tests
- Added requiredmodules Sampler.GitHubTasks, powershell-yaml
- Added wildcard support in Products parameter of UpdatesServicesServer resource.
(issue #13)

### Fixed

- Fix deploy job in AzurePipeline, Added Sampler.GithubTasks in build.yaml
- Fix issue #61 and #67, with add a foreach loop when `Set-TargetRessource` found
multiple products dor the same `Title`.
- Fix issue #58 and #66, with removed `-ErrorRecord` parameter on `New-InvalidResultException`
because `$_` not contain an exception.

## [1.2.0] - 2020-05-18

Expand Down
4 changes: 3 additions & 1 deletion RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
}
}

'powershell-yaml' = 'latest'
InvokeBuild = 'latest'
PSScriptAnalyzer = 'latest'
Pester = 'latest'
Pester = '4.10.1'
Plaster = 'latest'
ModuleBuilder = '1.0.0'
ChangelogManagement = 'latest'
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
MarkdownLinkCheck = 'latest'
'DscResource.Test' = 'latest'
'DscResource.AnalyzerRules' = 'latest'
Expand Down
169 changes: 148 additions & 21 deletions Tests/Helpers/ImitateUpdateServicesModule.psm1
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
function Get-WsusServer {
function Get-WsusServerTemplate
{
$WsusServer = [pscustomobject] @{
Name = 'ServerName'
}

$ApprovalRule = [scriptblock]{
$ApprovalRule = [pscustomobject]@{
Name = 'ServerName'
Enabled = $true
Name = 'ServerName'
Enabled = $true
}

$ApprovalRule | Add-Member -MemberType ScriptMethod -Name GetUpdateClassifications -Value {
$UpdateClassification = [pscustomobject]@{
Name = 'Update Classification'
ID = [pscustomobject]@{
GUID = '00000000-0000-0000-0000-0000testguid'
}
Name = 'Update Classification'
ID = [pscustomobject]@{
GUID = '00000000-0000-0000-0000-0000testguid'
}
}

return $UpdateClassification
}

$ApprovalRule | Add-Member -MemberType ScriptMethod -Name GetCategories -Value {
$Products = [pscustomobject]@{
Title = 'Product'
}

$Products | Add-Member -MemberType ScriptMethod -Name Add -Value {}

return $Products
}

$ApprovalRule | Add-Member -MemberType ScriptMethod -Name GetComputerTargetGroups -Value {
$ComputerTargetGroups = [pscustomobject]@{
Name = 'Computer Target Group'
}

$ComputerTargetGroups | Add-Member -MemberType ScriptMethod -Name Add -Value {}

return $ComputerTargetGroups
}

Expand All @@ -51,33 +57,41 @@ function Get-WsusServer {
$WsusServer | Add-Member -MemberType ScriptMethod -Name CreateInstallApprovalRule -Value $ApprovalRule

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateClassification -Value {}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetComputerTargetGroups -Value {}

$WsusServer | Add-Member -MemberType ScriptMethod -Name DeleteInstallApprovalRule -Value {}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetSubscription -Value {
$Subscription = [pscustomobject]@{
SynchronizeAutomaticallyTimeOfDay = '04:00:00'
NumberOfSynchronizationsPerDay = 24
SynchronizeAutomatically = $true
}

$Subscription | Add-Member -MemberType ScriptMethod -Name StartSynchronization -Value {}
$Subscription | Add-Member -MemberType ScriptMethod -Name GetUpdateClassifications -Value {
$UpdateClassification = [pscustomobject]@{
Name = 'Update Classification'
ID = [pscustomobject]@{
GUID = '00000000-0000-0000-0000-0000testguid'
}
Name = 'Update Classification'
ID = [pscustomobject]@{
GUID = '00000000-0000-0000-0000-0000testguid'
}
}

return $UpdateClassification
}

$Subscription | Add-Member -MemberType ScriptMethod -Name GetUpdateCategories -Value {
$Categories = [pscustomobject]@{
Title = 'Category'
Title = 'Windows'
},
[pscustomobject]@{
Title = 'Office'
}

return $Categories
}

return $Subscription
}

Expand All @@ -93,37 +107,150 @@ function Get-WsusServer {
AllUpdateLanguagesEnabled = $true
}
$Configuration | Add-Member -MemberType ScriptMethod -Name GetEnabledUpdateLanguages -Value {}
return $Configuration

return $Configuration
}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateClassifications -Value {
$UpdateClassification = [pscustomobject]@{
Name = 'Update Classification'
ID = [pscustomobject]@{
GUID = '00000000-0000-0000-0000-0000testguid'
}
}

return $UpdateClassification
}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateCategories -Value {
$Categories = [pscustomobject]@{
Title = 'Windows'
},
[pscustomobject]@{
Title = 'Office'
},
[pscustomobject]@{
Title = 'Windows Server 2003'
},
[pscustomobject]@{
Title = 'Windows Server 2008'
},
[pscustomobject]@{
Title = 'Windows Server 2008R2'
},
[pscustomobject]@{
Title = 'Windows Server 2012'
},
[pscustomobject]@{
Title = 'Windows Server 2016'
},
[pscustomobject]@{
Title = 'Windows Server 2019'
}

return $Categories
}

return $WsusServer
}

function Get-WsusServer
{
return $(Get-WsusServerTemplate)
}

function Get-WsusServerMockWildCardPrdt
{
$wsusServer = Get-WsusServerTemplate

# Override GetSubscription method
$WsusServer | Add-Member -Force -MemberType ScriptMethod -Name GetSubscription -Value {
$Subscription = [pscustomobject]@{
SynchronizeAutomaticallyTimeOfDay = '04:00:00'
NumberOfSynchronizationsPerDay = 24
SynchronizeAutomatically = $true
}

$Subscription | Add-Member -MemberType ScriptMethod -Name StartSynchronization -Value {}
$Subscription | Add-Member -MemberType ScriptMethod -Name GetUpdateClassifications -Value {
$UpdateClassification = [pscustomobject]@{
Name = 'Update Classification'
ID = [pscustomobject]@{
GUID = '00000000-0000-0000-0000-0000testguid'
}
}

return $UpdateClassification
}
return $UpdateClassification

$Subscription | Add-Member -Force -MemberType ScriptMethod -Name GetUpdateCategories -Value {
$Categories = [pscustomobject]@{
Title = 'Windows Server 2003'
},
[pscustomobject]@{
Title = 'Windows Server 2008'
},
[pscustomobject]@{
Title = 'Windows Server 2008R2'
},
[pscustomobject]@{
Title = 'Windows Server 2012'
},
[pscustomobject]@{
Title = 'Windows Server 2016'
},
[pscustomobject]@{
Title = 'Windows Server 2019'
}

return $Categories
}

return $Subscription
}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateCategories -Value {
# Override GetUpdateCategories method
$WsusServer | Add-Member -Force -MemberType ScriptMethod -Name GetUpdateCategories -Value {
$Categories = [pscustomobject]@{
Title = 'Category'
Title = 'Windows'
},
[pscustomobject]@{
Title = 'Office'
},
[pscustomobject]@{
Title = 'Windows Server 2003'
},
[pscustomobject]@{
Title = 'Windows Server 2008'
},
[pscustomobject]@{
Title = 'Windows Server 2008R2'
},
[pscustomobject]@{
Title = 'Windows Server 2012'
},
[pscustomobject]@{
Title = 'Windows Server 2016'
},
[pscustomobject]@{
Title = 'Windows Server 2019'
}

return $Categories
}

return $WsusServer
}

function Get-WsusClassification {
function Get-WsusClassification
{
$WsusClassification = [pscustomobject]@{
Classification = [pscustomobject]@{
ID = [pscustomobject]@{
Guid = '00000000-0000-0000-0000-0000testguid'
}
}
}

return $WsusClassification
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Describe "Basic tests" {
Context "Windows Feature are correctly installed" {
$TestCases = @{
Feature = 'UpdateServices'
Installed = $True
},
@{
Feature = 'UpdateServices-RSAT'
Installed = $True
}

It "Should <feature> be installed" -TestCases $TestCases {
(Get-WindowsFeature -Name $Feature).Installed | Should -Be $Installed
}
}

Context "Wsus service is correctly configured" {
It "Should can the informations of update service" {
{$script:wuServer = Get-WsusServer}| Should -Not -Throw
}

It "Should product are correctly configured" {
$AllProductsServer = $script:wuServer.GetUpdateCategories().Title | Where-Object {$_ -like 'Windows Server*'}

($AllProductsServer | Measure-Object).Count | Should -Be ($script:wuServer.GetSubscription().GetUpdateCategories().Title | Measure-Object ).Count

foreach ($ProductServer in $AllProductsServer)
{
$script:wuServer.GetSubscription().GetUpdateCategories().Title | Should -Contain $ProductServer
}
}

$TestCases = @{Classification = "Critical Updates"},
@{Classification = "Definition Updates"},
@{Classification = "Security Updates"},
@{Classification = "Service Packs"},
@{Classification = "Update Rollups"}

It "Should have <Classification> in classifications value" -TestCases $TestCases{
$script:wuServer.GetSubscription().GetUpdateClassifications().Title | Should -Contain $Classification
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Describe "Tests installation with all products" {
Context "Windows Feature are correctly installed" {
$TestCases = @{
Feature = 'UpdateServices'
Installed = $True
},
@{
Feature = 'UpdateServices-RSAT'
Installed = $True
}

It "Should <feature> be installed" -TestCases $TestCases {
(Get-WindowsFeature -Name $Feature).Installed | Should -Be $Installed
}
}

Context "Wsus service is correctly configured" {
It "Should can the informations of update service" {
{$script:wuServer = Get-WsusServer}| Should -Not -Throw
}

It "Should product are correctly configured" {
$AllProducts = $script:wuServer.GetUpdateCategories().Title | Where-Object {$_ -in @('Windows','Office')}

($AllProducts | Measure-Object).Count | Should -Be ($script:wuServer.GetSubscription().GetUpdateCategories().Title | Measure-Object ).Count

foreach ($ProductServer in $AllProductsServer)
{
$script:wuServer.GetSubscription().GetUpdateCategories().Title | Should -Contain $ProductServer
}
}

$TestCases = @{Classification = "Critical Updates"},
@{Classification = "Definition Updates"},
@{Classification = "Security Updates"},
@{Classification = "Service Packs"},
@{Classification = "Update Rollups"}

It "Should have <Classification> in classifications value" -TestCases $TestCases{
$script:wuServer.GetSubscription().GetUpdateClassifications().Title | Should -Contain $Classification
}
}
}
Loading

0 comments on commit 69f61f8

Please sign in to comment.