mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-24 10:23:26 +08:00
Fix PSVersion in PSSessionConfiguration tests (#5554)
* Fix PSVersion in PSSessionConfiguration tests by getting the expected value from PSVersionTable instead of hardcoded string.
This commit is contained in:
parent
cc0e74a7ae
commit
910c5a4780
@ -115,6 +115,8 @@ try
|
||||
}
|
||||
|
||||
$LocalConfigFilePath = CreateTestConfigFile
|
||||
|
||||
$expectedPSVersion = "$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)"
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +127,7 @@ try
|
||||
$Result = Get-PSSessionConfiguration
|
||||
|
||||
$Result.Name -contains $endpointName | Should Be $true
|
||||
$Result.PSVersion -ge 5.1 | Should be $true
|
||||
$Result.PSVersion | Should BeExactly $expectedPSVersion
|
||||
}
|
||||
|
||||
It "Get-PSSessionConfiguration with Name parameter" {
|
||||
@ -133,7 +135,7 @@ try
|
||||
$Result = Get-PSSessionConfiguration -Name $endpointName
|
||||
|
||||
$Result.Name | Should Be $endpointName
|
||||
$Result.PSVersion -ge 5.1 | Should be $true
|
||||
$Result.PSVersion | Should BeExactly $expectedPSVersion
|
||||
}
|
||||
|
||||
It "Get-PSSessionConfiguration -Name with wildcard character" {
|
||||
@ -143,7 +145,7 @@ try
|
||||
$Result = Get-PSSessionConfiguration -Name $endpointWildcard
|
||||
|
||||
$Result.Name -contains $endpointName | Should Be $true
|
||||
$Result.PSVersion -ge 5.1 | Should be $true
|
||||
$Result.PSVersion | Should BeExactly $expectedPSVersion
|
||||
}
|
||||
|
||||
It "Get-PSSessionConfiguration -Name with Non-Existent session configuration" {
|
||||
@ -324,6 +326,8 @@ try
|
||||
BeforeAll {
|
||||
if ($IsNotSkipped)
|
||||
{
|
||||
$expectedPSVersion = "$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)"
|
||||
|
||||
function ValidateRemoteEndpoint {
|
||||
param ($TestSessionConfigName, $ScriptToExecute, $ExpectedOutput)
|
||||
|
||||
@ -488,7 +492,7 @@ namespace PowershellTestConfigNamespace
|
||||
|
||||
$Result.Session.Name | Should be $TestSessionConfigName
|
||||
$Result.Session.SessionType | Should be "Default"
|
||||
$Result.Session.PSVersion | Should be 6.0
|
||||
$Result.Session.PSVersion | Should BeExactly $expectedPSVersion
|
||||
$Result.Session.Enabled | Should be $true
|
||||
$Result.Session.lang | Should be $Result.Culture
|
||||
$Result.Session.pssessionthreadoptions | Should be $pssessionthreadoptions
|
||||
@ -497,6 +501,15 @@ namespace PowershellTestConfigNamespace
|
||||
$Result.Session.UseSharedProcess | Should be $UseSharedProcess
|
||||
}
|
||||
|
||||
It "Validate Register-PSSessionConfiguration -PSVersion" {
|
||||
|
||||
Register-PSSessionConfiguration -Name $TestSessionConfigName -PSVersion 5.1
|
||||
$Session = Get-PSSessionConfiguration -Name $TestSessionConfigName
|
||||
|
||||
$Session.Name | Should be $TestSessionConfigName
|
||||
$Session.PSVersion | Should BeExactly 5.1
|
||||
}
|
||||
|
||||
It "Validate Register-PSSessionConfiguration -startupscript parameter" -Pending {
|
||||
|
||||
$null = Register-PSSessionConfiguration -Name $TestSessionConfigName -path $LocalConfigFilePath -StartupScript $LocalStartupScriptPath -Force
|
||||
@ -557,7 +570,7 @@ namespace PowershellTestConfigNamespace
|
||||
$Result = [PSObject]@{Session = (Get-PSSessionConfiguration -Name $TestSessionConfigName) ; Culture = (Get-Item WSMan:\localhost\Plugin\microsoft.powershell\lang -ea SilentlyContinue).value}
|
||||
|
||||
$Result.Session.Name | Should be $TestSessionConfigName
|
||||
$Result.Session.PSVersion | Should be 6.0
|
||||
$Result.Session.PSVersion | Should BeExactly $expectedPSVersion
|
||||
$Result.Session.Enabled | Should be $true
|
||||
$Result.Session.lang | Should be $result.Culture
|
||||
$Result.Session.pssessionthreadoptions | Should be $pssessionthreadoptions
|
||||
@ -566,6 +579,15 @@ namespace PowershellTestConfigNamespace
|
||||
$Result.Session.UseSharedProcess | Should be $UseSharedProcess
|
||||
}
|
||||
|
||||
It "Validate Set-PSSessionConfiguration -PSVersion" {
|
||||
|
||||
Set-PSSessionConfiguration -Name $TestSessionConfigName -PSVersion 5.1
|
||||
$Session = (Get-PSSessionConfiguration -Name $TestSessionConfigName)
|
||||
|
||||
$Session.Name | Should be $TestSessionConfigName
|
||||
$Session.PSVersion | Should BeExactly 5.1
|
||||
}
|
||||
|
||||
It "Validate Set-PSSessionConfiguration -startupscript parameter" -Pending {
|
||||
|
||||
$null = Set-PSSessionConfiguration -Name $TestSessionConfigName -StartupScript $LocalStartupScriptPath
|
||||
|
Loading…
Reference in New Issue
Block a user