Remove Platform.HasExecutionPolicy query

Also change Get-ExecutionPolicy to not throw, but to return
Unrestricted (which is the effect of the actual policy).
This commit is contained in:
Andrew Schwartzmeyer committed 2016-07-14 17:34:12 -07:00
1 parent 73a1a51f69
commit e6c037c666
3 files changed
+22 -30

No files matched your search

@@ -1,24 +1,24 @@
Describe "ExecutionPolicy" {
Context "Check Get-ExecutionPolicy behavior" {
It "Should throw PlatformNotSupported when not on Windows" -Skip:$IsWindows {
{ Get-ExecutionPolicy } | Should Throw "Operation is not supported on this platform."
}
It "Should unrestricted when not on Windows" -Skip:$IsWindows {
Get-ExecutionPolicy | Should Be Unrestricted
}
It "Should return Microsoft.Powershell.ExecutionPolicy PSObject on Windows" -Skip:($IsLinux -Or $IsOSX) {
(Get-ExecutionPolicy).GetType() | Should Be Microsoft.Powershell.ExecutionPolicy
}
It "Should return Microsoft.Powershell.ExecutionPolicy PSObject on Windows" -Skip:($IsLinux -Or $IsOSX) {
(Get-ExecutionPolicy).GetType() | Should Be Microsoft.Powershell.ExecutionPolicy
}
}
Context "Check Set-ExecutionPolicy behavior" {
It "Should throw PlatformNotSupported when not on Windows" -Skip:$IsWindows {
{ Set-ExecutionPolicy Unrestricted } | Should Throw "Operation is not supported on this platform."
}
It "Should throw PlatformNotSupported when not on Windows" -Skip:$IsWindows {
{ Set-ExecutionPolicy Unrestricted } | Should Throw "Operation is not supported on this platform."
}
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
}
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
}
}
}