forked from dfinke/ImportExcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordProtection.tests.ps1
More file actions
31 lines (30 loc) · 1.41 KB
/
Copy pathPasswordProtection.tests.ps1
File metadata and controls
31 lines (30 loc) · 1.41 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
Describe "Password Support" {
if ($PSVersionTable.PSVersion.Major -GT 5) {
It "Password Supported" {
Set-ItResult -Pending -Because "Can't test passwords on V6 and later"
}
return
}
Context "Password protected sheet" {
BeforeAll {
$password = "YouMustRememberThis"
$path = "TestDrive:\Test.xlsx"
Remove-Item $path -ErrorAction SilentlyContinue
Get-Service | Select-Object -First 10 | Export-excel -password $password -Path $Path -DisplayPropertySet
}
it "Threw an error when the password was omitted " {
{Open-ExcelPackage -Path $path } | Should -Throw
}
it "Was able to append when the password was included " {
{Get-Service | Select-Object -First 10 |
Export-excel -password $password -Path $Path -Append } | Should -Not -Throw
}
it "Kept the password on the file when it was saved " {
{Import-Excel $Path } | Should -Throw
}
it "Could read the file when the password was included " {
(Import-excel $path -Password $password).count | Should -Be 20
}
}
}