Skip to content

Commit e3f62d9

Browse files
committed
Acceptance Tests: use approved powershell verbs
1 parent db24724 commit e3f62d9

File tree

1 file changed

+41
-41
lines changed
  • acceptance_test/assets/bwats-release/jobs/check-system/templates

1 file changed

+41
-41
lines changed

acceptance_test/assets/bwats-release/jobs/check-system/templates/run.ps1

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ function Get-Config {
88
return $config
99
}
1010

11-
function Verify-LGPO {
12-
Write-Host "Running this function Verify-LGPO"
11+
function Test-LGPO {
12+
Write-Host "Running this function Test-LGPO"
1313
Write-Host "Verifying that expected policies have been applied"
1414

1515
lgpo /b $PSScriptRoot
@@ -76,7 +76,7 @@ function Verify-LGPO {
7676
Compare-LGPOPolicies "$OutputDir\audit.csv" "$TestDir\audit.csv" "\n"
7777
}
7878

79-
function Verify-Dependencies {
79+
function Test-Dependencies {
8080
$BOSH_BIN = "C:\\var\\vcap\\bosh\\bin"
8181
Write-Host "Checking $BOSH_BIN dependencies"
8282

@@ -98,7 +98,7 @@ function Verify-Dependencies {
9898
}
9999
}
100100

101-
function Verify-Acls {
101+
function Test-Acls {
102102
$expectedacls = New-Object System.Collections.ArrayList
103103
[void] $expectedacls.AddRange((
104104
"${env:COMPUTERNAME}\Administrator,Allow",
@@ -111,7 +111,7 @@ function Verify-Acls {
111111
"NT AUTHORITY\Authenticated Users,Allow"
112112
))
113113

114-
function Check-Acls {
114+
function Test-FolderAcls {
115115
param([string]$path)
116116

117117
$errCount = 0
@@ -132,17 +132,17 @@ function Verify-Acls {
132132
}
133133

134134
$errCount = 0
135-
$errCount += Check-Acls "C:\var"
136-
$errCount += Check-Acls "C:\bosh"
137-
$errCount += Check-Acls "C:\Windows\Panther\Unattend"
138-
$errCount += Check-Acls "C:\Program Files\OpenSSH"
135+
$errCount += Test-FolderAcls "C:\var"
136+
$errCount += Test-FolderAcls "C:\bosh"
137+
$errCount += Test-FolderAcls "C:\Windows\Panther\Unattend"
138+
$errCount += Test-FolderAcls "C:\Program Files\OpenSSH"
139139
if ($errCount -ne 0) {
140140
Write-Error "FAILED: $errCount"
141141
Exit 1
142142
}
143143
}
144144

145-
function Verify-Services {
145+
function Test-Services {
146146
If ((Get-Service WinRM).Status -ne "Stopped") {
147147
$msg = "WinRM is not Stopped. It is {0}" -f $( Get-Service WinRM ).Status
148148
Write-Error $msg
@@ -164,7 +164,7 @@ function Verify-Services {
164164
}
165165
}
166166

167-
function Verify-FirewallRules {
167+
function Test-FirewallRules {
168168
function Get-FirewallProfile {
169169
param([string] $ProfileName)
170170
$firewall = (Get-NetFirewallProfile -Name $ProfileName)
@@ -188,7 +188,7 @@ function Verify-FirewallRules {
188188
Test-FirewallProfile "domain"
189189
}
190190

191-
function Verify-MetadataFirewallRule {
191+
function Test-MetadataFirewallRule {
192192
$MetadataServerAllowRules = Get-NetFirewallRule -Enabled True -Direction Outbound | Get-NetFirewallAddressFilter | Where-Object -FilterScript { $_.RemoteAddress -Eq '169.254.169.254' }
193193

194194
If ($null -Ne $MetadataServerAllowRules) {
@@ -209,7 +209,7 @@ function Verify-MetadataFirewallRule {
209209
}
210210
}
211211

212-
function Verify-InstalledFeatures {
212+
function Test-InstalledFeatures {
213213
function Assert-IsInstalled {
214214
param (
215215
[Parameter(Mandatory)]
@@ -239,7 +239,7 @@ function Verify-InstalledFeatures {
239239
Assert-IsNotInstalled "Windows-Defender"
240240
}
241241

242-
function Verify-ProvisionerDeleted {
242+
function Test-ProvisionerDeleted {
243243
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
244244
$user = "Provisioner"
245245
$existing = $adsi.Children | Where-Object { $_.SchemaClassName -eq 'user' -and $_.Name -eq $user }
@@ -251,7 +251,7 @@ function Verify-ProvisionerDeleted {
251251
}
252252
}
253253

254-
function Verify-NetBIOSDisabled {
254+
function Test-NetBIOSDisabled {
255255
$DisabledNetBIOS = $false
256256
$nbtstat = nbtstat.exe -n
257257
"results for nbtstat: $nbtstat"
@@ -261,21 +261,21 @@ function Verify-NetBIOSDisabled {
261261
}
262262
}
263263

264-
function Verify-AgentBehavior {
264+
function Test-AgentBehavior {
265265
$agent = Get-Service | Where-Object { $_.Name -eq 'bosh-agent' }
266266
if ($null -eq $agent) {
267267
Write-Error "Missing service: bosh-agent"
268268
Exit 1
269269
}
270270
if ($agent.StartType -ne "Automatic") {
271-
Write-Error "verify-agent-start-type: bosh-agent start type is not 'Automatic' got: '$($agent.StartType.ToString() )'"
271+
Write-Error "test-agent-start-type: bosh-agent start type is not 'Automatic' got: '$($agent.StartType.ToString() )'"
272272
Exit 1
273273
}
274274

275275
$RegPath = "HKLM:\SYSTEM\CurrentControlSet\Services\bosh-agent"
276276

277277
if ((Get-ItemProperty $RegPath).DelayedAutostart -ne 1) {
278-
Write-Error "verify-agent-start-type: Expected DelayedAutostart to equal 1"
278+
Write-Error "test-agent-start-type: Expected DelayedAutostart to equal 1"
279279
Exit 1
280280
}
281281

@@ -296,7 +296,7 @@ function Verify-AgentBehavior {
296296
}
297297
}
298298

299-
function Verify-RandomPassword {
299+
function Test-RandomPassword {
300300
secedit /configure /db secedit.sdb /cfg c:\var\vcap\jobs\check-system\inf\security.inf
301301

302302
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
@@ -312,7 +312,7 @@ function Verify-RandomPassword {
312312
}
313313
}
314314

315-
function Verify-NTPSync {
315+
function Test-NTPSync {
316316
Write-Host "Verifying NTP sync works correctly"
317317
w32tm /query /configuration
318318

@@ -341,7 +341,7 @@ function Verify-NTPSync {
341341
}
342342
}
343343

344-
function Verify-NoDocker {
344+
function Test-NoDocker {
345345
try {
346346
docker ps
347347
} catch {
@@ -353,7 +353,7 @@ function Verify-NoDocker {
353353
Exit 1
354354
}
355355

356-
function Verify-PSVersion5 {
356+
function Test-PSVersion5 {
357357
$PSMajorVersion = $PSVersionTable.PSVersion.Major
358358

359359
if ($PSMajorVersion -lt 5) {
@@ -364,7 +364,7 @@ function Verify-PSVersion5 {
364364
Write-Host "PowerShell is up to date: Version is: $( $PSVersionTable.PSVersion )"
365365
}
366366

367-
function Verify-VersionFile {
367+
function Test-VersionFile {
368368
$VersionFileExists = Test-Path "C:\\var\\vcap\\bosh\\etc\\stemcell_version" -PathType Leaf
369369

370370
if (-Not $VersionFileExists) {
@@ -375,7 +375,7 @@ function Verify-VersionFile {
375375
Write-Host "Version file exists at path C:\\var\\vcap\\bosh\\etc\\stemcell_version"
376376
}
377377

378-
function Verify-HyperVIsEnabled {
378+
function Test-HyperVIsEnabled {
379379
$feature = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
380380

381381
if ($feature.State -ne "Enabled") {
@@ -387,30 +387,30 @@ function Verify-HyperVIsEnabled {
387387
Write-Host "Hyper-V is enabled"
388388
}
389389

390-
function Verify-TimeZone {
390+
function Test-TimeZone {
391391
$timezone = Get-TimeZone
392392
if ($timezone.Id -ne "UTC") {
393393
Write-Error "Timezone is $( $timezone.Id ), but should be: UTC"
394394
Exit 1
395395
}
396396
}
397397

398-
Verify-LGPO
399-
Verify-Dependencies
400-
Verify-Acls
401-
Verify-Services
402-
Verify-FirewallRules
403-
Verify-MetadataFirewallRule
404-
Verify-InstalledFeatures
405-
Verify-ProvisionerDeleted
406-
Verify-NetBIOSDisabled
407-
Verify-AgentBehavior
408-
Verify-RandomPassword
409-
Verify-NTPSync
410-
Verify-NoDocker
411-
Verify-PSVersion5
412-
Verify-VersionFile
413-
Verify-TimeZone
398+
Test-LGPO
399+
Test-Dependencies
400+
Test-Acls
401+
Test-Services
402+
Test-FirewallRules
403+
Test-MetadataFirewallRule
404+
Test-InstalledFeatures
405+
Test-ProvisionerDeleted
406+
Test-NetBIOSDisabled
407+
Test-AgentBehavior
408+
Test-RandomPassword
409+
Test-NTPSync
410+
Test-NoDocker
411+
Test-PSVersion5
412+
Test-VersionFile
413+
Test-TimeZone
414414

415415
Import-Module C:\var\vcap\packages\pester\Pester\Pester.psd1
416416
$pesterResults = Invoke-Pester $PSScriptRoot/AuditPolicies.Tests.ps1 -PassThru

0 commit comments

Comments
 (0)