Skip to content

Commit 74d1ec8

Browse files
committed
Simple PoC of a few integration tests
* Simple Get-* calls to the default configuration * New-* call with configuration diff assertion and configuration reset
1 parent b00bedd commit 74d1ec8

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

ITTests/Simple.ITTests.ps1

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
$Nsip = "172.16.124.10"
2+
$Username = "nsroot"
3+
$Password = "nsroot"
4+
5+
Import-Module Pester
6+
7+
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
8+
Import-Module -Force $here\..\Netscaler
9+
. $here\TestSupport.ps1
10+
11+
Describe "Netscaler Get-*" {
12+
$Session = Connect-Netscaler -Hostname $Nsip -Credential $Credential -PassThru
13+
14+
It "should list VPN policies" {
15+
$Policy = Get-NSVPNSessionPolicy
16+
17+
$Policy | Should Not BeNullOrEmpty
18+
$Policy.name | Should Be "SETVPNPARAMS_POL"
19+
}
20+
21+
It "should get VPN policy" {
22+
$Policy = Get-NSVPNSessionPolicy -Name "SETVPNPARAMS_POL"
23+
24+
$Policy | Should Not BeNullOrEmpty
25+
$Policy.name | Should Be "SETVPNPARAMS_POL"
26+
}
27+
28+
It "should list VPN profiles" {
29+
$Policy = Get-NSVPNSessionProfile
30+
31+
$Policy | Should Not BeNullOrEmpty
32+
$Policy.name | Should Be "SETVPNPARAMS_ACT"
33+
}
34+
35+
It "should get VPN profiles" {
36+
$Policy = Get-NSVPNSessionProfile -Name "SETVPNPARAMS_ACT"
37+
38+
$Policy | Should Not BeNullOrEmpty
39+
$Policy.name | Should Be "SETVPNPARAMS_ACT"
40+
}
41+
42+
It "should get a certificate" {
43+
$Cert = Get-NSSSLCertificate -Name "ns-server-certificate"
44+
45+
$Cert | Should Not BeNullOrEmpty
46+
$Cert.certkey | Should Be "ns-server-certificate"
47+
}
48+
49+
It "should list certificates" {
50+
$Cert = Get-NSSSLCertificate
51+
52+
$Cert | Should Not BeNullOrEmpty
53+
$Cert.certkey | Should Be "ns-server-certificate"
54+
}
55+
}
56+
57+
Describe "Netscaler" {
58+
$Session = Connect-Netscaler -Hostname $Nsip -Credential $Credential -PassThru
59+
60+
61+
It "should add a server" {
62+
New-NSLBServer -Name 'srv-test' -IPAddress 1.2.3.4
63+
64+
Compare-NSConfig $OldConf | Should Match "=> add server srv-test 1.2.3.4"
65+
}
66+
67+
BeforeEach { $OldConf = Get-NSConfig }
68+
AfterEach { Clear-NSConfig -Force }
69+
}

ITTests/TestSupport.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
2+
$Credential = New-Object System.Management.Automation.PSCredential ($Username, $SecurePassword)
3+
4+
5+
function Compare-NSConfig($Old, $New = $(Get-NSConfig)) {
6+
$Old = $Old | ? { Test-IsMutatingConfigLines $_ }
7+
$New = $New | ? { Test-IsMutatingConfigLines $_ }
8+
Compare-Object $Old $New | % {
9+
"{0} {1}" -f $_.SideIndicator, $_.InputObject
10+
}
11+
}
12+
13+
function Test-IsMutatingConfigLines($line) {
14+
!($_ -match "^set (ns encryptionParams|cluster rsskey|ns rpcNode)")
15+
}

0 commit comments

Comments
 (0)