You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Fixed an issue in CheckForPreReqs function where on Server Core the installation of the
non existing Windows Feature 'RSAT-Feature-Tools-BitLocker-RemoteAdminTool' was
erroneously checked (issue #8).
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,6 +134,8 @@ Defaults to false.
134
134
* Fixed issue which caused Test to incorrectly succeed on fully decrypted volumes when correct Key Protectors were present ([issue #13](https://github.com/PowerShell/xBitlocker/issues/13))
135
135
* Fixed issue which caused xBLAutoBitlocker to incorrectly detect Fixed vs Removable volumes. ([issue #11](https://github.com/PowerShell/xBitlocker/issues/11))
136
136
* Fixed issue which made xBLAutoBitlocker unable to encrypt volumes with drive letters assigned. ([issue #10](https://github.com/PowerShell/xBitlocker/issues/10))
137
+
* Fixed an issue in CheckForPreReqs function where on Server Core the installation of the non existing Windows Feature 'RSAT-Feature-Tools-BitLocker-RemoteAdminTool' was erroneously checked. ([issue #8](https://github.com/PowerShell/xBitlocker/issues/8))
Context 'When OS Volume is not Encrypted and No Key Protectors Assigned' {
22
22
Mock `
23
23
-CommandName Get-BitlockerVolume`
24
24
-ModuleName 'xBitlockerCommon'`
25
25
-MockWith {
26
-
# Decrypted with no Key Protectors
27
-
return@{
28
-
VolumeType='OperatingSystem'
29
-
MountPoint=$MountPoint
30
-
CapacityGB=500
31
-
VolumeStatus='FullyDecrypted'
32
-
EncryptionPercentage=0
33
-
KeyProtector=@()
34
-
AutoUnlockEnabled=$null
35
-
ProtectionStatus='Off'
36
-
}
26
+
# Decrypted with no Key Protectors
27
+
return@{
28
+
VolumeType='OperatingSystem'
29
+
MountPoint=$MountPoint
30
+
CapacityGB=500
31
+
VolumeStatus='FullyDecrypted'
32
+
EncryptionPercentage=0
33
+
KeyProtector=@()
34
+
AutoUnlockEnabled=$null
35
+
ProtectionStatus='Off'
37
36
}
37
+
}
38
38
39
39
It 'Should Fail The Test (TPM and RecoveryPassword Protectors)' {
40
40
TestBitlocker -MountPoint 'C:'-PrimaryProtector 'TPMProtector'-RecoveryPasswordProtector $true| Should -Be $false
@@ -46,25 +46,25 @@ try
46
46
-CommandName Get-BitlockerVolume`
47
47
-ModuleName 'xBitlockerCommon'`
48
48
-MockWith {
49
-
# Encrypted with TPM and Recovery Password Key Protectors
50
-
return@{
51
-
VolumeType='OperatingSystem'
52
-
MountPoint=$MountPoint
53
-
CapacityGB=500
54
-
VolumeStatus='FullyEncrypted'
55
-
EncryptionPercentage=100
56
-
KeyProtector=@(
57
-
@{
58
-
KeyProtectorType='Tpm'
59
-
},
60
-
@{
61
-
KeyProtectorType='RecoveryPassword'
62
-
}
63
-
)
64
-
AutoUnlockEnabled=$null
65
-
ProtectionStatus='On'
66
-
}
49
+
# Encrypted with TPM and Recovery Password Key Protectors
50
+
return@{
51
+
VolumeType='OperatingSystem'
52
+
MountPoint=$MountPoint
53
+
CapacityGB=500
54
+
VolumeStatus='FullyEncrypted'
55
+
EncryptionPercentage=100
56
+
KeyProtector=@(
57
+
@{
58
+
KeyProtectorType='Tpm'
59
+
},
60
+
@{
61
+
KeyProtectorType='RecoveryPassword'
62
+
}
63
+
)
64
+
AutoUnlockEnabled=$null
65
+
ProtectionStatus='On'
67
66
}
67
+
}
68
68
69
69
It 'Should Pass The Test (TPM and RecoveryPassword Protectors)' {
70
70
TestBitlocker -MountPoint 'C:'-PrimaryProtector 'TPMProtector'-RecoveryPasswordProtector $true-verbose | Should -Be $true
@@ -76,31 +76,252 @@ try
76
76
-CommandName Get-BitlockerVolume`
77
77
-ModuleName 'xBitlockerCommon'`
78
78
-MockWith {
79
-
# Encrypted with TPM and Recovery Password Key Protectors
80
-
return@{
81
-
VolumeType='OperatingSystem'
82
-
MountPoint=$MountPoint
83
-
CapacityGB=500
84
-
VolumeStatus='FullyDecrypted'
85
-
EncryptionPercentage=0
86
-
KeyProtector=@(
87
-
@{
88
-
KeyProtectorType='Tpm'
89
-
},
90
-
@{
91
-
KeyProtectorType='RecoveryPassword'
92
-
}
93
-
)
94
-
AutoUnlockEnabled=$null
95
-
ProtectionStatus='Off'
96
-
}
79
+
# Encrypted with TPM and Recovery Password Key Protectors
80
+
return@{
81
+
VolumeType='OperatingSystem'
82
+
MountPoint=$MountPoint
83
+
CapacityGB=500
84
+
VolumeStatus='FullyDecrypted'
85
+
EncryptionPercentage=0
86
+
KeyProtector=@(
87
+
@{
88
+
KeyProtectorType='Tpm'
89
+
},
90
+
@{
91
+
KeyProtectorType='RecoveryPassword'
92
+
}
93
+
)
94
+
AutoUnlockEnabled=$null
95
+
ProtectionStatus='Off'
97
96
}
97
+
}
98
98
99
99
It 'Should Fail The Test (TPM and RecoveryPassword Protectors)' {
100
100
TestBitlocker -MountPoint 'C:'-PrimaryProtector 'TPMProtector'-RecoveryPasswordProtector $true| Should -Be $false
101
101
}
102
102
}
103
103
}
104
+
105
+
Describe 'xBitlockerCommon\CheckForPreReqs' {
106
+
functionGet-WindowsFeature
107
+
{
108
+
param
109
+
(
110
+
[string]
111
+
$FeatureName
112
+
)
113
+
}
114
+
115
+
functionGet-OSEdition
116
+
{
117
+
118
+
}
119
+
120
+
Context 'When OS is Server Core and all required features are installed' {
121
+
Mock -CommandName Get-OSEdition-MockWith {
122
+
'Server Core'
123
+
}
124
+
125
+
Mock -CommandName Get-WindowsFeature-MockWith {
126
+
if ($FeatureName-eq'RSAT-Feature-Tools-BitLocker-RemoteAdminTool')
127
+
{
128
+
return$null
129
+
}
130
+
else
131
+
{
132
+
return@{
133
+
DisplayName=$FeatureName
134
+
Name=$FeatureName
135
+
InstallState='Installed'
136
+
}
137
+
}
138
+
}
139
+
140
+
It 'Should not generate any error messages' {
141
+
Mock -CommandName Write-Error
142
+
CheckForPreReqs
143
+
Assert-MockCalled-Command Write-Error-Exactly -Times 0-Scope It
144
+
}
145
+
146
+
It 'Should run the CheckForPreReqs function without exceptions' {
147
+
{CheckForPreReqs} | Should -Not-Throw
148
+
}
149
+
}
150
+
151
+
Context 'When OS is Full Server and all required features are installed' {
152
+
Mock -CommandName Get-OSEdition-MockWith {
153
+
return'Server'
154
+
}
155
+
156
+
Mock -CommandName Get-WindowsFeature-MockWith {
157
+
param
158
+
(
159
+
[string]
160
+
$FeatureName
161
+
)
162
+
163
+
return@{
164
+
DisplayName=$FeatureName
165
+
Name=$FeatureName
166
+
InstallState='Installed'
167
+
}
168
+
}
169
+
170
+
It 'Should not generate any error messages' {
171
+
Mock -CommandName Write-Error
172
+
CheckForPreReqs
173
+
Assert-MockCalled-Command Write-Error-Exactly -Times 0-Scope It
174
+
}
175
+
176
+
It 'Should run the CheckForPreReqs function without exceptions' {
177
+
{CheckForPreReqs} | Should -Not-Throw
178
+
}
179
+
}
180
+
181
+
Context 'When OS is Full Server without the required features installed' {
182
+
Mock -CommandName Get-OSEdition-MockWith {
183
+
return'Server'
184
+
}
185
+
186
+
Mock -CommandName Get-WindowsFeature-MockWith {
187
+
return@{
188
+
DisplayName=$FeatureName
189
+
Name=$FeatureName
190
+
InstallState='Available'
191
+
}
192
+
}
193
+
194
+
Mock -CommandName Write-Error
195
+
196
+
It 'Should give an error that Bitlocker Windows Feature needs to be installed' {
197
+
{CheckForPreReqs} | Should -Throw
198
+
Assert-MockCalled-Command Write-Error-Exactly -Times 1-Scope It -ParameterFilter {
199
+
$Message-eq'The Bitlocker feature needs to be installed before the xBitlocker module can be used'
200
+
}
201
+
}
202
+
203
+
It 'Should give an error that RSAT-Feature-Tools-BitLocker Windows Feature needs to be installed' {
204
+
{CheckForPreReqs} | Should -Throw
205
+
Assert-MockCalled-Command Write-Error-Exactly -Times 1-Scope It -ParameterFilter {
206
+
$Message-eq'The RSAT-Feature-Tools-BitLocker feature needs to be installed before the xBitlocker module can be used'
207
+
}
208
+
}
209
+
210
+
It 'Should give an error that RSAT-Feature-Tools-BitLocker-RemoteAdminTool Windows Feature needs to be installed' {
211
+
{CheckForPreReqs} | Should -Throw
212
+
Assert-MockCalled-Command Write-Error-Exactly -Times 1-Scope It -ParameterFilter {
213
+
$Message-eq'The RSAT-Feature-Tools-BitLocker-RemoteAdminTool feature needs to be installed before the xBitlocker module can be used'
214
+
}
215
+
}
216
+
217
+
It 'The CheckForPreReqs function should throw an exceptions about missing required Windows Features' {
218
+
{CheckForPreReqs} | Should -Throw 'Required Bitlocker features need to be installed before xBitlocker can be used'
219
+
}
220
+
}
221
+
222
+
Context 'When OS is Server Core without the required features installed' {
223
+
Mock -CommandName Get-OSEdition-MockWith {
224
+
return'Server Core'
225
+
}
226
+
227
+
Mock -CommandName Get-WindowsFeature-MockWith {
228
+
param
229
+
(
230
+
[string]
231
+
$FeatureName
232
+
)
233
+
234
+
if ($FeatureName-eq'RSAT-Feature-Tools-BitLocker-RemoteAdminTool')
235
+
{
236
+
return$null
237
+
}
238
+
else
239
+
{
240
+
241
+
return@{
242
+
DisplayName=$FeatureName
243
+
Name=$FeatureName
244
+
InstallState='Available'
245
+
}
246
+
}
247
+
}
248
+
249
+
Mock -CommandName Write-Error
250
+
251
+
It 'Should give an error that Bitlocker Windows Feature needs to be installed' {
252
+
{CheckForPreReqs} | Should -Throw
253
+
Assert-MockCalled-Command Write-Error-Exactly -Times 1-Scope It -ParameterFilter {
254
+
$Message-eq'The Bitlocker feature needs to be installed before the xBitlocker module can be used'
255
+
}
256
+
}
257
+
258
+
It 'Should give an error that RSAT-Feature-Tools-BitLocker Windows Feature needs to be installed' {
259
+
{CheckForPreReqs} | Should -Throw
260
+
Assert-MockCalled-Command Write-Error-Exactly -Times 1-Scope It -ParameterFilter {
261
+
$Message-eq'The RSAT-Feature-Tools-BitLocker feature needs to be installed before the xBitlocker module can be used'
262
+
}
263
+
}
264
+
265
+
It 'Should not give an error that RSAT-Feature-Tools-BitLocker-RemoteAdminTool Windows Feature needs to be installed as this Windows Features is not available on Server Core.' {
266
+
{CheckForPreReqs} | Should -Throw
267
+
Assert-MockCalled-Command Write-Error-Exactly -Times 0-Scope It -ParameterFilter {
268
+
$Message-eq'The RSAT-Feature-Tools-BitLocker-RemoteAdminTool feature needs to be installed before the xBitlocker module can be used'
269
+
}
270
+
}
271
+
272
+
It 'The CheckForPreReqs function should throw an exceptions about missing required Windows Features' {
273
+
{CheckForPreReqs} | Should -Throw 'Required Bitlocker features need to be installed before xBitlocker can be used'
274
+
}
275
+
}
276
+
}
277
+
278
+
Describe 'xBitLockerCommon\Get-OSEdition' {
279
+
It 'Should return "Server Core" if the OS is Windows Server Core' {
0 commit comments