1
- $Nsip = " 172.16.124.11"
2
- $Username = " nsroot"
3
- $Password = " nsroot"
4
-
5
1
Import-Module Pester
6
2
7
3
$here = Split-Path - Parent $MyInvocation.MyCommand.Path
8
- Import-Module - Force $here \..\Netscaler
4
+ Import-Module - Force $here \..\Netscaler\Netscaler.psd1
9
5
. $here \TestSupport.ps1
10
6
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
13
11
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
+ }
20
16
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
27
19
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
+ }
33
24
}
34
25
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" {
40
27
}
41
-
28
+ }
29
+
30
+ Describe " Netscaler Get-*" {
31
+ $Session = Connect-TestNetscaler
32
+
42
33
It " should get a certificate" {
43
34
$Cert = Get-NSSSLCertificate - Name " ns-server-certificate"
44
35
@@ -50,44 +41,29 @@ Describe "Netscaler Get-*" {
50
41
$Cert = Get-NSSSLCertificate
51
42
52
43
$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"
78
45
}
79
46
}
80
47
81
48
Describe " Netscaler" {
82
- $Session = Connect-Netscaler - Hostname $Nsip - Credential $Credential - PassThru
49
+ $Session = Connect-TestNetscaler
83
50
84
-
85
51
It " should add a LB server" {
86
52
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
89
68
}
90
-
91
- BeforeEach { $OldConf = Get-NSConfig }
92
- AfterEach { Clear-NSConfig - Force }
93
69
}
0 commit comments