1
+ Import-Module Pester
2
+
3
+ $here = Split-Path - Parent $MyInvocation.MyCommand.Path
4
+ Import-Module - Force $here \..\Netscaler\Netscaler.psd1
5
+ . $here \TestSupport.ps1
6
+
7
+ Describe " Netscaler Connection" {
8
+ Context " not connected" {
9
+ It " should disconnect implicit session" {
10
+ $Session = Connect-TestNetscaler
11
+
12
+ Get-NSHostname
13
+ Disconnect-Netscaler
14
+ { Get-NSHostname } | Should Throw " Unauthorized"
15
+ }
16
+
17
+ It " should disconnect explicit session" {
18
+ $Session = Connect-TestNetscaler
19
+
20
+ Get-NSHostname - Session $Session
21
+ Disconnect-Netscaler - Session $Session
22
+ { Get-NSHostname - Session $Session } | Should Throw " Unauthorized"
23
+ }
24
+ }
25
+
26
+ Context " connection" {
27
+ }
28
+ }
29
+
30
+ Describe " Netscaler Get-*" {
31
+ $Session = Connect-TestNetscaler
32
+
33
+ It " should get a certificate" {
34
+ $Cert = Get-NSSSLCertificate - Name " ns-server-certificate"
35
+
36
+ $Cert | Should Not BeNullOrEmpty
37
+ $Cert.certkey | Should Be " ns-server-certificate"
38
+ }
39
+
40
+ It " should list certificates" {
41
+ $Cert = Get-NSSSLCertificate
42
+
43
+ $Cert | Should Not BeNullOrEmpty
44
+ $Cert.certkey | Should Match " ns-server-certificate|ns-sftrust-certificate"
45
+ }
46
+ }
47
+
48
+ Describe " Netscaler" {
49
+ $Session = Connect-TestNetscaler
50
+
51
+ It " should add a LB server" {
52
+ New-NSLBServer - Name ' srv-test' - IPAddress 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
68
+ }
69
+ }
0 commit comments