forked from JeffHarkavy/SafeguardCmdletTesting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdlet-tests-diagnostic.ps1
More file actions
68 lines (53 loc) · 3.44 KB
/
cmdlet-tests-diagnostic.ps1
File metadata and controls
68 lines (53 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
try {
Get-Command "writeCallHeader" -ErrorAction Stop > $null
} catch {
write-host -ForegroundColor Red "Not meant to be run as a standalone script"
exit
}
$TestBlockName = "Running Diagnostic Package Tests"
$blockInfo = testBlockHeader $TestBlockName
# ===== Covered Commands =====
# Clear-SafeguardDiagnosticPackage
# Get-SafeguardDiagnosticPackage
# Get-SafeguardDiagnosticPackageLog
# Get-SafeguardDiagnosticPackageStatus
# Invoke-SafeguardDiagnosticPackage
# Set-SafeguardDiagnosticPackage
try {
$localDiagnosticPackageFilename = "cmdlet-test-sgdiagnosticpackage_$testBranch_$("{0:yyyy}{0:MM}{0:dd}_{0:HH}{0:mm}{0:ss}" -f (Get-Date)).sgb"
$localDiagnosticPackageFilePath = "$($DATA.outputPaths.logs)\$localDiagnosticPackageFilename"
$diagon = Clear-SafeguardDiagnosticPackage
goodResult "Clear-SafeguardDiagnosticPackage" "Successfull Clear SafeguardDiagnosticPackage $($diagon)"
$diagon = Get-SafeguardDiagnosticPackage
goodResult "Get-SafeguardDiagnosticPackage" "Successfull retrieved DiagnosticPackage $($diagon)"
$diagon = Get-SafeguardDiagnosticPackageLog -OutFile "$localDiagnosticPackageFilePath"
goodResult "Get-SafeguardDiagnosticPackageLog" "Successfull retrieved Get-SafeguardDiagnosticPackageLog $($diagon)"
$diagon = Get-SafeguardDiagnosticPackage
goodResult "Get-SafeguardDiagnosticPackageStatus" "Successfull retrieved Get-SafeguardDiagnosticPackageStatus $($diagon)"
#This only tests Prod... A test one can be found here https://sg-archive.sg.lab/pangaea/qa/secdiags/test/mbx_3000/AutomationSuccess.sgd to used by hand if wanted
$DiagnosticPackageFileName = "\AutomationSuccess.sgd"
if ($isVm) {
$DiagnosticPackageFileName = "\VmAutomationSuccess.sgd"
}
$DiagnosticPackageFilePath = "$($SCRIPT_PATH)" + "$($DiagnosticPackageFileName)"
$diagon = Set-SafeguardDiagnosticPackage -PackagePath "$($DiagnosticPackageFilePath)"
goodResult "Set-SafeguardDiagnosticPackage" "Successfull set Set-SafeguardDiagnosticPackage $($diagon)"
$diagon = Invoke-SafeguardDiagnosticPackage
goodResult "Invoke-SafeguardDiagnosticPackage" "Successfull Invoke SafeguardDiagnosticPackage $($diagon)"
$diagon = Get-SafeguardDiagnosticPackage
goodResult "Get-SafeguardDiagnosticPackage" "Successfull retrieved DiagnosticPackage $($diagon)"
$diagon = Get-SafeguardDiagnosticPackageLog -OutFile "$localDiagnosticPackageFilePath"
goodResult "Get-SafeguardDiagnosticPackageLog" "Successfull retrieved Get-SafeguardDiagnosticPackageLog $($diagon)"
$diagon = Get-SafeguardDiagnosticPackage
#@{PackageType=Diagnostic; Name=Test Hello World; Description=Diagnostic package used for automation. Should run for 5 seconds and output to the log file the text "Hello World"; MinimumSafeguardVersion=2.9.0; ApplianceId=; Expiration=2050-01-01T00:00:00Z}
if ($diagon.Name -match "Test Hello World") {
goodResult "Get-SafeguardDiagnosticPackageStatus" "Successfull retrieved Get-SafeguardDiagnosticPackageStatus $($diagon)"
}
$diagon = Clear-SafeguardDiagnosticPackage
goodResult "Clear-SafeguardDiagnosticPackage" "Successfull Clear SafeguardDiagnosticPackage $($diagon)"
} catch {
badResult "Diagnostic Package general" "Unexpected error in Diagnostic Package test" $_
} finally {
#try { if ($directoryAdded -eq 1) { Remove-SafeguardDirectory -DirectoryToDelete $domainname > $null } } catch {}
}
testBlockHeader $TestBlockName $blockInfo