Skip to content

Commit a6fdb7e

Browse files
committed
Added integration tests to validate URI protocol fix
1 parent 4e885ba commit a6fdb7e

File tree

2 files changed

+49
-67
lines changed

2 files changed

+49
-67
lines changed

ITTests/Simple.ITTests.ps1

Lines changed: 38 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,35 @@
1-
$Nsip = "172.16.124.11"
2-
$Username = "nsroot"
3-
$Password = "nsroot"
4-
51
Import-Module Pester
62

73
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
8-
Import-Module -Force $here\..\Netscaler
4+
Import-Module -Force $here\..\Netscaler\Netscaler.psd1
95
. $here\TestSupport.ps1
106

11-
Describe "Netscaler Get-*" {
12-
$Session = Connect-Netscaler -Hostname $Nsip -Credential $Credential -PassThru
7+
Describe "Netscaler Connection" {
8+
Context "not connected" {
9+
It "should disconnect implicit session" {
10+
$Session = Connect-TestNetscaler
1311

14-
It "should list VPN policies" {
15-
$Policy = Get-NSVPNSessionPolicy
16-
17-
$Policy | Should Not BeNullOrEmpty
18-
$Policy.name | Should Be "SETVPNPARAMS_POL"
19-
}
12+
Get-NSHostname
13+
Disconnect-Netscaler
14+
{ Get-NSHostname } | Should Throw "401 (Unauthorized)"
15+
}
2016

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-
}
17+
It "should disconnect explicit session" {
18+
$Session = Connect-TestNetscaler
2719

28-
It "should list VPN profiles" {
29-
$Policy = Get-NSVPNSessionProfile
30-
31-
$Policy | Should Not BeNullOrEmpty
32-
$Policy.name | Should Be "SETVPNPARAMS_ACT"
20+
Get-NSHostname -Session $Session
21+
Disconnect-Netscaler -Session $Session
22+
{ Get-NSHostname -Session $Session } | Should Throw "401 (Unauthorized)"
23+
}
3324
}
3425

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"
26+
Context "connection" {
4027
}
41-
28+
}
29+
30+
Describe "Netscaler Get-*" {
31+
$Session = Connect-TestNetscaler
32+
4233
It "should get a certificate" {
4334
$Cert = Get-NSSSLCertificate -Name "ns-server-certificate"
4435

@@ -50,44 +41,29 @@ Describe "Netscaler Get-*" {
5041
$Cert = Get-NSSSLCertificate
5142

5243
$Cert | Should Not BeNullOrEmpty
53-
$Cert.certkey | Should Be "ns-server-certificate"
54-
}
55-
56-
It "should list builtin responder policies" {
57-
$Result = Get-NSResponderPolicy -ShowBuiltin
58-
59-
$Result | Should Not BeNullOrEmpty
60-
# TODO: this is fragile, it probably depends on the NS version
61-
$Result.Count | Should Be 6
62-
}
63-
64-
It "should list builtin rewrite actions" {
65-
$Result = Get-NSRewriteAction -ShowBuiltin
66-
67-
$Result | Should Not BeNullOrEmpty
68-
# TODO: this is fragile, it probably depends on the NS version
69-
$Result.Count | Should Be 45
70-
}
71-
72-
It "should list builtin rewrite policies" {
73-
$Result = Get-NSRewritePolicy -ShowBuiltin
74-
75-
$Result | Should Not BeNullOrEmpty
76-
# TODO: this is fragile, it probably depends on the NS version
77-
$Result.Count | Should Be 49
44+
$Cert.certkey | Should Match "ns-server-certificate|ns-sftrust-certificate"
7845
}
7946
}
8047

8148
Describe "Netscaler" {
82-
$Session = Connect-Netscaler -Hostname $Nsip -Credential $Credential -PassThru
49+
$Session = Connect-TestNetscaler
8350

84-
8551
It "should add a LB server" {
8652
New-NSLBServer -Name 'srv-test' -IPAddress 1.2.3.4
87-
88-
Compare-NSConfig $OldConf | Should Match "=> add server srv-test 1.2.3.4"
53+
54+
Compare-NSConfig $OldConf | Should Match "=> add server srv-test 1.2.3.4"
55+
}
56+
57+
It "should add features" {
58+
Enable-NSFeature -Force -Name "aaa", "lb", "rewrite", "ssl"
59+
60+
Compare-NSConfig $OldConf | Should Match "=> enable ns feature LB SSL AAA REWRITE"
61+
}
62+
63+
BeforeEach { $OldConf = Get-NSConfig }
64+
AfterEach {
65+
Clear-NSConfig -Force -Level Full
66+
# Web Logging and Surge Protection are not disabled by a config clear...
67+
"wl", "sp" | Disable-NSFeature -Force
8968
}
90-
91-
BeforeEach { $OldConf = Get-NSConfig }
92-
AfterEach { Clear-NSConfig -Force }
9369
}

ITTests/TestSupport.ps1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
2-
$Credential = New-Object System.Management.Automation.PSCredential ($Username, $SecurePassword)
1+
$TestNsip = $(if ($env:TEST_NSIP) { $env:TEST_NSIP } else { "172.16.124.10" })
2+
$TestUsername = "nsroot"
3+
$TestPassword = "nsroot"
34

5+
function Connect-TestNetscaler {
6+
$SecurePassword = ConvertTo-SecureString $TestPassword -AsPlainText -Force
7+
$Credential = New-Object System.Management.Automation.PSCredential ($TestUsername, $SecurePassword)
8+
Connect-Netscaler -Hostname $TestNsip -Credential $Credential -PassThru
9+
}
410

511
function Compare-NSConfig($Old, $New = $(Get-NSConfig)) {
6-
$Old = $Old | ? { Test-IsMutatingConfigLines $_ }
7-
$New = $New | ? { Test-IsMutatingConfigLines $_ }
8-
Compare-Object $Old $New | % {
12+
$Old = $Old | Where-Object { Test-IsMutatingConfigLines $_ }
13+
$New = $New | Where-Object { Test-IsMutatingConfigLines $_ }
14+
Compare-Object $Old $New | ForEach-Object {
915
"{0} {1}" -f $_.SideIndicator, $_.InputObject
1016
}
1117
}

0 commit comments

Comments
 (0)