Skip to content

Commit 69f61f8

Browse files
authored
Merge branch 'master' into Fix-Products
2 parents d48f934 + e92798d commit 69f61f8

18 files changed

+1387
-430
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ output/
1414
markdownissues.txt
1515
node_modules
1616
package-lock.json
17+
*.local.*

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
### Changed
1717

1818
- Updated inital offline package sync WSUS.cab.
19+
- Changed azurepipeline, use latest version of ubuntu and change the management
20+
of pipeline artifact
21+
- Updated build.ps1 script and build.yaml.
22+
- Changed default timeout in Wait-Win32ProcessStart function for cab installation.
23+
24+
### Added
25+
26+
- Added TestKitchen files for integration tests
27+
- Added requiredmodules Sampler.GitHubTasks, powershell-yaml
28+
- Added wildcard support in Products parameter of UpdatesServicesServer resource.
29+
(issue #13)
30+
31+
### Fixed
32+
33+
- Fix deploy job in AzurePipeline, Added Sampler.GithubTasks in build.yaml
34+
- Fix issue #61 and #67, with add a foreach loop when `Set-TargetRessource` found
35+
multiple products dor the same `Title`.
36+
- Fix issue #58 and #66, with removed `-ErrorRecord` parameter on `New-InvalidResultException`
37+
because `$_` not contain an exception.
1938

2039
## [1.2.0] - 2020-05-18
2140

RequiredModules.psd1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
}
99
}
1010

11+
'powershell-yaml' = 'latest'
1112
InvokeBuild = 'latest'
1213
PSScriptAnalyzer = 'latest'
13-
Pester = 'latest'
14+
Pester = '4.10.1'
1415
Plaster = 'latest'
1516
ModuleBuilder = '1.0.0'
1617
ChangelogManagement = 'latest'
1718
Sampler = 'latest'
19+
'Sampler.GitHubTasks' = 'latest'
1820
MarkdownLinkCheck = 'latest'
1921
'DscResource.Test' = 'latest'
2022
'DscResource.AnalyzerRules' = 'latest'

Tests/Helpers/ImitateUpdateServicesModule.psm1

Lines changed: 148 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
function Get-WsusServer {
1+
function Get-WsusServerTemplate
2+
{
23
$WsusServer = [pscustomobject] @{
34
Name = 'ServerName'
45
}
56

67
$ApprovalRule = [scriptblock]{
78
$ApprovalRule = [pscustomobject]@{
8-
Name = 'ServerName'
9-
Enabled = $true
9+
Name = 'ServerName'
10+
Enabled = $true
1011
}
11-
12+
1213
$ApprovalRule | Add-Member -MemberType ScriptMethod -Name GetUpdateClassifications -Value {
1314
$UpdateClassification = [pscustomobject]@{
14-
Name = 'Update Classification'
15-
ID = [pscustomobject]@{
16-
GUID = '00000000-0000-0000-0000-0000testguid'
17-
}
15+
Name = 'Update Classification'
16+
ID = [pscustomobject]@{
17+
GUID = '00000000-0000-0000-0000-0000testguid'
18+
}
1819
}
20+
1921
return $UpdateClassification
2022
}
2123

2224
$ApprovalRule | Add-Member -MemberType ScriptMethod -Name GetCategories -Value {
2325
$Products = [pscustomobject]@{
2426
Title = 'Product'
2527
}
28+
2629
$Products | Add-Member -MemberType ScriptMethod -Name Add -Value {}
30+
2731
return $Products
2832
}
2933

3034
$ApprovalRule | Add-Member -MemberType ScriptMethod -Name GetComputerTargetGroups -Value {
3135
$ComputerTargetGroups = [pscustomobject]@{
3236
Name = 'Computer Target Group'
3337
}
38+
3439
$ComputerTargetGroups | Add-Member -MemberType ScriptMethod -Name Add -Value {}
40+
3541
return $ComputerTargetGroups
3642
}
3743

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

5359
$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateClassification -Value {}
54-
60+
5561
$WsusServer | Add-Member -MemberType ScriptMethod -Name GetComputerTargetGroups -Value {}
5662

5763
$WsusServer | Add-Member -MemberType ScriptMethod -Name DeleteInstallApprovalRule -Value {}
58-
64+
5965
$WsusServer | Add-Member -MemberType ScriptMethod -Name GetSubscription -Value {
6066
$Subscription = [pscustomobject]@{
6167
SynchronizeAutomaticallyTimeOfDay = '04:00:00'
6268
NumberOfSynchronizationsPerDay = 24
6369
SynchronizeAutomatically = $true
6470
}
71+
6572
$Subscription | Add-Member -MemberType ScriptMethod -Name StartSynchronization -Value {}
6673
$Subscription | Add-Member -MemberType ScriptMethod -Name GetUpdateClassifications -Value {
6774
$UpdateClassification = [pscustomobject]@{
68-
Name = 'Update Classification'
69-
ID = [pscustomobject]@{
70-
GUID = '00000000-0000-0000-0000-0000testguid'
71-
}
75+
Name = 'Update Classification'
76+
ID = [pscustomobject]@{
77+
GUID = '00000000-0000-0000-0000-0000testguid'
78+
}
7279
}
80+
7381
return $UpdateClassification
7482
}
83+
7584
$Subscription | Add-Member -MemberType ScriptMethod -Name GetUpdateCategories -Value {
7685
$Categories = [pscustomobject]@{
77-
Title = 'Category'
86+
Title = 'Windows'
87+
},
88+
[pscustomobject]@{
89+
Title = 'Office'
7890
}
91+
7992
return $Categories
8093
}
94+
8195
return $Subscription
8296
}
8397

@@ -93,37 +107,150 @@ function Get-WsusServer {
93107
AllUpdateLanguagesEnabled = $true
94108
}
95109
$Configuration | Add-Member -MemberType ScriptMethod -Name GetEnabledUpdateLanguages -Value {}
96-
return $Configuration
110+
111+
return $Configuration
97112
}
98113

99114
$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateClassifications -Value {
100115
$UpdateClassification = [pscustomobject]@{
116+
Name = 'Update Classification'
117+
ID = [pscustomobject]@{
118+
GUID = '00000000-0000-0000-0000-0000testguid'
119+
}
120+
}
121+
122+
return $UpdateClassification
123+
}
124+
125+
$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateCategories -Value {
126+
$Categories = [pscustomobject]@{
127+
Title = 'Windows'
128+
},
129+
[pscustomobject]@{
130+
Title = 'Office'
131+
},
132+
[pscustomobject]@{
133+
Title = 'Windows Server 2003'
134+
},
135+
[pscustomobject]@{
136+
Title = 'Windows Server 2008'
137+
},
138+
[pscustomobject]@{
139+
Title = 'Windows Server 2008R2'
140+
},
141+
[pscustomobject]@{
142+
Title = 'Windows Server 2012'
143+
},
144+
[pscustomobject]@{
145+
Title = 'Windows Server 2016'
146+
},
147+
[pscustomobject]@{
148+
Title = 'Windows Server 2019'
149+
}
150+
151+
return $Categories
152+
}
153+
154+
return $WsusServer
155+
}
156+
157+
function Get-WsusServer
158+
{
159+
return $(Get-WsusServerTemplate)
160+
}
161+
162+
function Get-WsusServerMockWildCardPrdt
163+
{
164+
$wsusServer = Get-WsusServerTemplate
165+
166+
# Override GetSubscription method
167+
$WsusServer | Add-Member -Force -MemberType ScriptMethod -Name GetSubscription -Value {
168+
$Subscription = [pscustomobject]@{
169+
SynchronizeAutomaticallyTimeOfDay = '04:00:00'
170+
NumberOfSynchronizationsPerDay = 24
171+
SynchronizeAutomatically = $true
172+
}
173+
174+
$Subscription | Add-Member -MemberType ScriptMethod -Name StartSynchronization -Value {}
175+
$Subscription | Add-Member -MemberType ScriptMethod -Name GetUpdateClassifications -Value {
176+
$UpdateClassification = [pscustomobject]@{
101177
Name = 'Update Classification'
102178
ID = [pscustomobject]@{
103179
GUID = '00000000-0000-0000-0000-0000testguid'
104180
}
181+
}
182+
183+
return $UpdateClassification
105184
}
106-
return $UpdateClassification
185+
186+
$Subscription | Add-Member -Force -MemberType ScriptMethod -Name GetUpdateCategories -Value {
187+
$Categories = [pscustomobject]@{
188+
Title = 'Windows Server 2003'
189+
},
190+
[pscustomobject]@{
191+
Title = 'Windows Server 2008'
192+
},
193+
[pscustomobject]@{
194+
Title = 'Windows Server 2008R2'
195+
},
196+
[pscustomobject]@{
197+
Title = 'Windows Server 2012'
198+
},
199+
[pscustomobject]@{
200+
Title = 'Windows Server 2016'
201+
},
202+
[pscustomobject]@{
203+
Title = 'Windows Server 2019'
204+
}
205+
206+
return $Categories
207+
}
208+
209+
return $Subscription
107210
}
108211

109-
$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateCategories -Value {
212+
# Override GetUpdateCategories method
213+
$WsusServer | Add-Member -Force -MemberType ScriptMethod -Name GetUpdateCategories -Value {
110214
$Categories = [pscustomobject]@{
111-
Title = 'Category'
215+
Title = 'Windows'
216+
},
217+
[pscustomobject]@{
218+
Title = 'Office'
219+
},
220+
[pscustomobject]@{
221+
Title = 'Windows Server 2003'
222+
},
223+
[pscustomobject]@{
224+
Title = 'Windows Server 2008'
225+
},
226+
[pscustomobject]@{
227+
Title = 'Windows Server 2008R2'
228+
},
229+
[pscustomobject]@{
230+
Title = 'Windows Server 2012'
231+
},
232+
[pscustomobject]@{
233+
Title = 'Windows Server 2016'
234+
},
235+
[pscustomobject]@{
236+
Title = 'Windows Server 2019'
112237
}
238+
113239
return $Categories
114240
}
115241

116242
return $WsusServer
117243
}
118-
119-
function Get-WsusClassification {
244+
function Get-WsusClassification
245+
{
120246
$WsusClassification = [pscustomobject]@{
121247
Classification = [pscustomobject]@{
122248
ID = [pscustomobject]@{
123249
Guid = '00000000-0000-0000-0000-0000testguid'
124250
}
125251
}
126252
}
253+
127254
return $WsusClassification
128255
}
129256

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Describe "Basic tests" {
2+
Context "Windows Feature are correctly installed" {
3+
$TestCases = @{
4+
Feature = 'UpdateServices'
5+
Installed = $True
6+
},
7+
@{
8+
Feature = 'UpdateServices-RSAT'
9+
Installed = $True
10+
}
11+
12+
It "Should <feature> be installed" -TestCases $TestCases {
13+
(Get-WindowsFeature -Name $Feature).Installed | Should -Be $Installed
14+
}
15+
}
16+
17+
Context "Wsus service is correctly configured" {
18+
It "Should can the informations of update service" {
19+
{$script:wuServer = Get-WsusServer}| Should -Not -Throw
20+
}
21+
22+
It "Should product are correctly configured" {
23+
$AllProductsServer = $script:wuServer.GetUpdateCategories().Title | Where-Object {$_ -like 'Windows Server*'}
24+
25+
($AllProductsServer | Measure-Object).Count | Should -Be ($script:wuServer.GetSubscription().GetUpdateCategories().Title | Measure-Object ).Count
26+
27+
foreach ($ProductServer in $AllProductsServer)
28+
{
29+
$script:wuServer.GetSubscription().GetUpdateCategories().Title | Should -Contain $ProductServer
30+
}
31+
}
32+
33+
$TestCases = @{Classification = "Critical Updates"},
34+
@{Classification = "Definition Updates"},
35+
@{Classification = "Security Updates"},
36+
@{Classification = "Service Packs"},
37+
@{Classification = "Update Rollups"}
38+
39+
It "Should have <Classification> in classifications value" -TestCases $TestCases{
40+
$script:wuServer.GetSubscription().GetUpdateClassifications().Title | Should -Contain $Classification
41+
}
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Describe "Tests installation with all products" {
2+
Context "Windows Feature are correctly installed" {
3+
$TestCases = @{
4+
Feature = 'UpdateServices'
5+
Installed = $True
6+
},
7+
@{
8+
Feature = 'UpdateServices-RSAT'
9+
Installed = $True
10+
}
11+
12+
It "Should <feature> be installed" -TestCases $TestCases {
13+
(Get-WindowsFeature -Name $Feature).Installed | Should -Be $Installed
14+
}
15+
}
16+
17+
Context "Wsus service is correctly configured" {
18+
It "Should can the informations of update service" {
19+
{$script:wuServer = Get-WsusServer}| Should -Not -Throw
20+
}
21+
22+
It "Should product are correctly configured" {
23+
$AllProducts = $script:wuServer.GetUpdateCategories().Title | Where-Object {$_ -in @('Windows','Office')}
24+
25+
($AllProducts | Measure-Object).Count | Should -Be ($script:wuServer.GetSubscription().GetUpdateCategories().Title | Measure-Object ).Count
26+
27+
foreach ($ProductServer in $AllProductsServer)
28+
{
29+
$script:wuServer.GetSubscription().GetUpdateCategories().Title | Should -Contain $ProductServer
30+
}
31+
}
32+
33+
$TestCases = @{Classification = "Critical Updates"},
34+
@{Classification = "Definition Updates"},
35+
@{Classification = "Security Updates"},
36+
@{Classification = "Service Packs"},
37+
@{Classification = "Update Rollups"}
38+
39+
It "Should have <Classification> in classifications value" -TestCases $TestCases{
40+
$script:wuServer.GetSubscription().GetUpdateClassifications().Title | Should -Contain $Classification
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)