mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Merge pull request #897 from PowerShell/andschwa/add-encodedcommand-tests-#712
Add -EncodedCommand tests
This commit is contained in:
commit
3e53aefebb
2 files changed
+10
-1
No files matched your search
@@ -146,7 +146,7 @@ OPTIONS
|
||||
break;
|
||||
case Options.EncodedCommand:
|
||||
byte[] data = Convert.FromBase64String(nextArg);
|
||||
initialScript = Encoding.UTF8.GetString(data);
|
||||
initialScript = Encoding.Unicode.GetString(data);
|
||||
++i;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -8,5 +8,14 @@ Describe "CoreConsoleHost unit tests" {
|
||||
& $powershell -noprofile $x | ?{ $_ -match "usage: powershell" } | Should Not BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
It "Should accept a Base64 encoded command" {
|
||||
$commandString = "Get-Location"
|
||||
$encodedCommand = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($commandString))
|
||||
# We don't compare to `Get-Location` directly because object and formatted output comparisons are difficult
|
||||
$expected = & $powershell -noprofile -command $commandString
|
||||
$actual = & $powershell -noprofile -EncodedCommand $encodedCommand
|
||||
$actual | Should Be $expected
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user