Repository navigation
Expand file tree
/
Copy pathStoreOnceModule.Tests.ps1
More file actions
206 lines (162 loc) · 5.33 KB
/
Copy pathStoreOnceModule.Tests.ps1
File metadata and controls
206 lines (162 loc) · 5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<#
.EXAMPLE
Invoke-Pester -Script @{ Path = '.\Tests\StoreOnceModule.Tests.ps1'; Parameters = @{ SOAppliance="192.168.130.129"; SOUser="Admin"; SOPass="admin"} }
#>
$SOAppliance = $Parameters.Get_Item("SOAppliance")
$SOUser = $Parameters.Get_Item("SOUser")
$SOPass = $Parameters.Get_Item("SOPass")
Describe "Module Tests" {
$error.Clear()
Remove-Module PS-StoreOnce -ErrorAction SilentlyContinue
It "Importing PS-StoreOnce Module" {
Import-Module ./PS-StoreOnce/PS-StoreOnce.psd1
Get-Module PS-StoreOnce | Should Be $true
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Connect-SOAppliance Tests" {
$error.Clear()
Clear-Variable SOConnections -Scope Global -ErrorAction SilentlyContinue
$connection = Connect-SOAppliance -Server $SOAppliance -Username $SOUser -Password $SOPass
It "Connection exists" {
($Global:SOConnections).count | Should Be 1
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Get-SOAppliance Tests" {
$error.Clear()
It "Variable is correct" {
(Get-SOAppliance).Server | Should Be $SOAppliance
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Get-SOSIDs Tests" {
$error.Clear()
It "System is correct" {
(Get-SOSIDs).System | Should Be $SOAppliance
}
It "SIDCount is correct" {
(Get-SOSIDs).SIDCount | Should BeGreaterThan 0
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Get-SONasShares Tests" {
$error.Clear()
It "System is correct" {
(Get-SONasShares).System | Should Be $SOAppliance
}
It "SIDCount is correct" {
(Get-SONasShares).SIDCount | Should BeGreaterThan 0
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Get-SOCatStores Tests" {
$error.Clear()
It "System is correct" {
(Get-SOCatStores).System | Should Be $SOAppliance
}
It "SIDCount is correct" {
(Get-SOCatStores).SIDCount | Should BeGreaterThan 0
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Get-SOCatClients Tests" {
$error.Clear()
It "System is correct" {
(Get-SOCatClients).System | Should Be $SOAppliance
}
It "SIDCount is correct" {
(Get-SOCatClients).SIDCount | Should BeGreaterThan 0
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Get-SOCatStoreAccess Tests" {
$error.Clear()
It "Client is correct" {
(Get-SOCatStoreAccess -Server $SOAppliance -CatStore myNewStore).Client | Should Be "myNewClient"
}
It "allowAccess is correct" {
(Get-SOCatStoreAccess -Server $SOAppliance -CatStore myNewStore).allowAccess | Should Be "true"
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "New-SOCatStore Tests" {
$error.Clear()
<#
It "Create duplicate Store" {
(New-SOCatStore -Server $SOAppliance -SSID 1 -SOCatStoreName MyNewStore ) | Should throw
}
#>
It "Create new Catalyst Store" {
(New-SOCatStore -Server $SOAppliance -SSID 1 -SOCatStoreName myPesterStore)
(Get-SOCatStores | where {$_.Name -eq "myPesterStore" -and $_.System -eq $SOAppliance}).Status | Should be "Online"
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "New-SOCatClient Tests" {
$error.Clear()
<#
It "Create duplicate Client" {
(New-SOCatClient -Server $SOAppliance -SOCatClientName myTestClient -SOCatClientPass myTestClientpass!! ) | Should throw
}
#>
It "Create new Client" {
(New-SOCatClient -Server $SOAppliance -SOCatClientName myPesterClient -SOCatClientPass myPesterClientPas!!)
(Get-SOCatClients | where {$_.Name -eq "myPesterClient" -and $_.System -eq $SOAppliance} ).Name | Should be "myPesterClient"
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Set-SOCatStoreAccess Tests" {
$error.Clear()
It "Set Access" {
(Set-SOCatStoreAccess -Server $SOAppliance -SOCatClientName myPesterClient -SOCatStoreName myPesterStore -allowAccess:$true)
(Get-SOCatStoreAccess -Server $SOAppliance -CatStore "myPesterStore").Client | Should be "myPesterClient"
}
It "Remove Access" {
(Set-SOCatStoreAccess -Server $SOAppliance -SOCatClientName myPesterClient -SOCatStoreName myPesterStore -allowAccess:$false)
(Get-SOCatStoreAccess -Server $SOAppliance -CatStore "myPesterStore").Client | Should not be "myPesterClient"
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Remove-SOCatStore Tests" {
$error.Clear()
It "Remove Catalyst Store" {
(Remove-SOCatStore -Server $SOAppliance -SSID 1 -SOCatStoreName myPesterStore)
(Get-SOCatStores | where {$_.Name -eq "myPesterStore" -and $_.System -eq $SOAppliance}) | Should not be "Online"
}
It "Check errors" {
$error.Count | should be 0
}
}
Describe "Remove-SOCatClient Tests" {
$error.Clear()
It "Remove Client" {
(Remove-SOCatClient -Server $SOAppliance -SOCatClientName myPesterClient)
(Get-SOCatClients | where {$_.Name -eq "myPesterClient" -and $_.System -eq $SOAppliance} ).Name | Should not be "myPesterClient"
}
It "Check errors" {
$error.Count | should be 0
}
}