mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Allow ExecutionPolicy tests to throw specific type of error
Split LocalMachine test case into two separate tests: - One without overriden policy (throws exception) - One with overriden policy
This commit is contained in:
@@ -1021,7 +1021,25 @@ ZoneId=$FileType
|
||||
}
|
||||
}
|
||||
|
||||
It "-Scope LocalMachine is Settable" {
|
||||
It '-Scope LocalMachine is Settable, but overridden' {
|
||||
# setup
|
||||
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Undefined
|
||||
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Restricted
|
||||
$errorId = $null
|
||||
try
|
||||
{
|
||||
Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy ByPass
|
||||
}
|
||||
catch [System.Security.SecurityException] {
|
||||
$errorId = $_.FullyQualifiedErrorId
|
||||
}
|
||||
|
||||
$errorId | Should Be 'ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand'
|
||||
Get-ExecutionPolicy -Scope LocalMachine | Should Be "ByPass"
|
||||
}
|
||||
|
||||
It '-Scope LocalMachine is Settable' {
|
||||
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Undefined
|
||||
Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy ByPass
|
||||
Get-ExecutionPolicy -Scope LocalMachine | Should Be "ByPass"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user