Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Security/ExecutionPolicy.Tests.ps1
T

24 lines
1.0 KiB
PowerShell
Raw Normal View History

2016-07-25 14:01:41 -07:00
Describe "ExecutionPolicy" -Tags "CI" {
2016-02-09 15:54:00 -08:00
Context "Check Get-ExecutionPolicy behavior" {
2016-07-14 14:31:31 -07:00
It "Should unrestricted when not on Windows" -Skip:$IsWindows {
Get-ExecutionPolicy | Should Be Unrestricted
}
2016-02-09 15:54:00 -08:00
2016-07-14 14:31:31 -07:00
It "Should return Microsoft.Powershell.ExecutionPolicy PSObject on Windows" -Skip:($IsLinux -Or $IsOSX) {
(Get-ExecutionPolicy).GetType() | Should Be Microsoft.Powershell.ExecutionPolicy
}
2016-02-09 15:54:00 -08:00
}
Context "Check Set-ExecutionPolicy behavior" {
2016-07-14 14:31:31 -07:00
It "Should throw PlatformNotSupported when not on Windows" -Skip:$IsWindows {
{ Set-ExecutionPolicy Unrestricted } | Should Throw "Operation is not supported on this platform."
}
2016-02-09 15:54:00 -08:00
2016-07-14 14:31:31 -07:00
It "Should succeed on Windows" -Skip:($IsLinux -Or $IsOSX) {
# We use the Process scope to avoid affecting the system
# Unrestricted is assumed "safe", otherwise these tests would not be running
{ Set-ExecutionPolicy -Force -Scope Process -ExecutionPolicy Unrestricted } | Should Not Throw
}
2016-02-09 15:54:00 -08:00
}
}