2016-02-09 23:54:00 +00:00
|
|
|
Describe "ExecutionPolicy" {
|
|
|
|
|
|
|
|
Context "Check Get-ExecutionPolicy behavior" {
|
2016-03-04 22:52:27 +00:00
|
|
|
It "Should throw PlatformNotSupported when not on Windows" -Skip:$IsWindows {
|
|
|
|
{ Get-ExecutionPolicy } | Should Throw "Operation is not supported on this platform."
|
|
|
|
}
|
2016-02-09 23:54:00 +00:00
|
|
|
|
2016-03-04 22:52:27 +00: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 23:54:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Context "Check Set-ExecutionPolicy behavior" {
|
2016-03-04 22:52:27 +00: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 23:54:00 +00:00
|
|
|
|
2016-03-04 22:52:27 +00: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 23:54:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|