forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecutionPolicy.Tests.ps1
More file actions
24 lines (20 loc) · 1.04 KB
/
Copy pathExecutionPolicy.Tests.ps1
File metadata and controls
24 lines (20 loc) · 1.04 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
Describe "ExecutionPolicy" -Tags "CI" {
Context "Check Get-ExecutionPolicy behavior" {
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
}
}
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 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
}
}
}