updated pester tests and uncluded new ones for CIS cmdlets
This commit is contained in:
37
Pester/Test Connect-CISServer Connection to VC.Tests.ps1
Normal file
37
Pester/Test Connect-CISServer Connection to VC.Tests.ps1
Normal file
@@ -0,0 +1,37 @@
|
||||
<#
|
||||
Script name: Test Connect-CISServer to VC.Tests.ps1
|
||||
Created on: 04/20/2017
|
||||
Author: Alan Renouf, @alanrenouf
|
||||
Description: The purpose of this pester test is to ensure the PowerCLI modules are imported and a connection can be made to a vCenter for the CIS Service
|
||||
Dependencies: Pester Module
|
||||
Example run:
|
||||
|
||||
Invoke-Pester -Script @{ Path = '.\Test Connect-CISServer to VC.Tests.ps1'; Parameters = @{ VCNAME="VC01.local"; VCUSER="Administrator@vsphere.local"; VCPASS="Admin!23"} }
|
||||
|
||||
#>
|
||||
|
||||
$VCUSER = $Parameters.Get_Item("VCUSER")
|
||||
$VCPASS = $Parameters.Get_Item("VCPASS")
|
||||
$VCNAME = $Parameters.Get_Item("VCNAME")
|
||||
|
||||
Describe "Checking PowerCLI Cmdlets available" {
|
||||
$cmdletname = "Connect-CISServer"
|
||||
It "Checking $cmdletname is available" {
|
||||
$command = Get-Command $cmdletname
|
||||
$command | Select Name, Version
|
||||
$command.Name| Should Be $cmdletname
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Connect-CISServer Tests" {
|
||||
|
||||
$connection = Connect-CISServer $VCName -User $VCUser -password $VCPass
|
||||
It "Connection is active" {
|
||||
$Global:DefaultCISServers[0].isconnected | Should Be $true
|
||||
}
|
||||
|
||||
It "Checking connected server name is $VCName" {
|
||||
$Global:DefaultCISServers[0] | Select *
|
||||
$Global:DefaultCISServers[0].name | Should Be $VCName
|
||||
}
|
||||
}
|
||||
36
Pester/Test Connect-VIServer Connection to VC.Tests.ps1
Normal file
36
Pester/Test Connect-VIServer Connection to VC.Tests.ps1
Normal file
@@ -0,0 +1,36 @@
|
||||
<#
|
||||
Script name: Test Connection to VC.ps1
|
||||
Created on: 07/15/2016
|
||||
Author: Alan Renouf, @alanrenouf
|
||||
Description: The purpose of this pester test is to ensure the PowerCLI modules are imported and a connection can be made to a vCenter
|
||||
Dependencies: Pester Module
|
||||
Example run:
|
||||
|
||||
Invoke-Pester -Script @{ Path = '.\Test Connection to VC.Tests.ps1'; Parameters = @{ VCNAME="VC01.local"; VCUSER="Administrator@vsphere.local"; VCPASS="Admin!23"} }
|
||||
|
||||
#>
|
||||
|
||||
$VCUSER = $Parameters.Get_Item("VCUSER")
|
||||
$VCPASS = $Parameters.Get_Item("VCPASS")
|
||||
$VCNAME = $Parameters.Get_Item("VCNAME")
|
||||
|
||||
Describe "Checking PowerCLI Cmdlets available" {
|
||||
$cmdletname = "Connect-VIServer"
|
||||
It "Checking $cmdletname is available" {
|
||||
$command = Get-Command $cmdletname
|
||||
$command | Select Name, Version
|
||||
$command.Name| Should Be $cmdletname
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Connect-VIServer Tests" {
|
||||
|
||||
$connection = Connect-VIServer $VCName -User $VCUser -password $VCPass
|
||||
It "Connection is active" {
|
||||
$Global:DefaultVIServer[0].isconnected | Should Be $true
|
||||
}
|
||||
|
||||
It "Checking connected server name is $VCName" {
|
||||
$Global:DefaultVIServer[0].name | Should Be $VCName
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<#
|
||||
Script name: Test Connection to VC.ps1
|
||||
Created on: 07/15/2016
|
||||
Author: Alan Renouf, @alanrenouf
|
||||
Description: The purpose of this pester test is to ensure the PowerCLI modules are imported and a connection and disconnection can be made to a vCenter
|
||||
Dependencies: Pester Module
|
||||
Example run:
|
||||
|
||||
Invoke-Pester -Script @{ Path = '.\Test Connection to VC.ps1'; Parameters = @{ VCNAME="VC01.local"; VCUSER="Administrator@vsphere.local"; VCPASS="Admin!23"} }
|
||||
|
||||
#>
|
||||
|
||||
$VCUSER = $Parameters.Get_Item("VCUSER")
|
||||
$VCPASS = $Parameters.Get_Item("VCPASS")
|
||||
$VCNAME = $Parameters.Get_Item("VCNAME")
|
||||
|
||||
Describe "PowerCLI Tests" {
|
||||
It "Importing PowerCLI Modules" {
|
||||
Get-Module VMware* | Foreach {
|
||||
Write-Host "Importing Module $($_.name) Version $($_.Version)"
|
||||
$_ | Import-Module
|
||||
Get-Module $_ | Should Be $true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Connect-VIServer Tests" {
|
||||
|
||||
$connection = Connect-VIServer $VCName -User $VCUser -password $VCPass
|
||||
It "Connection is active" {
|
||||
$Global:DefaultVIServer[0].isconnected | Should Be $true
|
||||
}
|
||||
|
||||
It "Checking connected server name is $VCName" {
|
||||
$Global:DefaultVIServer[0].name | Should Be $VCName
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Disconnect-VIServer Tests" {
|
||||
It "Disconnect from $VCName" {
|
||||
Disconnect-VIServer $VCName -confirm:$false
|
||||
$Global:DefaultVIServer | Should Be $null
|
||||
}
|
||||
}
|
||||
20
Pester/Test Disconnect-CISServer to VC.Tests.ps1
Normal file
20
Pester/Test Disconnect-CISServer to VC.Tests.ps1
Normal file
@@ -0,0 +1,20 @@
|
||||
<#
|
||||
Script name: Test Disconnect-CISServer to VC.Tests.ps1
|
||||
Created on: 04/20/2017
|
||||
Author: Alan Renouf, @alanrenouf
|
||||
Description: The purpose of this pester test is to ensure the Disconnect-CISServer cmdlet disconnects
|
||||
Dependencies: Pester Module
|
||||
Example run:
|
||||
|
||||
Invoke-Pester -Script @{ Path = '.\Test Disconnect-CISServer to VC.Tests.ps1'; Parameters = @{ VCNAME="VC01.local" } }
|
||||
|
||||
#>
|
||||
|
||||
$VCNAME = $Parameters.Get_Item("VCNAME")
|
||||
|
||||
Describe "Disconnect-CISServer Tests" {
|
||||
It "Disconnect from $VCName" {
|
||||
Disconnect-CISServer $VCName -confirm:$false
|
||||
$Global:DefaultCISServers | Should Be $null
|
||||
}
|
||||
}
|
||||
20
Pester/Test Disconnect-VIServer to VC.Tests.ps1
Normal file
20
Pester/Test Disconnect-VIServer to VC.Tests.ps1
Normal file
@@ -0,0 +1,20 @@
|
||||
<#
|
||||
Script name: Test Disconnect-VIServer to VC.ps1
|
||||
Created on: 04/20/2017
|
||||
Author: Alan Renouf, @alanrenouf
|
||||
Description: The purpose of this pester test is to ensure the Disconnect-VIServer cmdlet disconnects
|
||||
Dependencies: Pester Module
|
||||
Example run:
|
||||
|
||||
Invoke-Pester -Script @{ Path = '.\Test Disconnect-VISServer to VC.ps1'; Parameters = @{ VCNAME="VC01.local" } }
|
||||
|
||||
#>
|
||||
|
||||
$VCNAME = $Parameters.Get_Item("VCNAME")
|
||||
|
||||
Describe "Disconnect-VIServer Tests" {
|
||||
It "Disconnect from $VCName" {
|
||||
Disconnect-VIServer $VCName -confirm:$false
|
||||
$Global:DefaultVIServer | Should Be $null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user