-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix PSVersion in PSSessionConfiguration tests #5554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,8 @@ try | |
| } | ||
|
|
||
| $LocalConfigFilePath = CreateTestConfigFile | ||
|
|
||
| $expectedPSVersion = "$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)" | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -125,15 +127,15 @@ 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" { | ||
|
|
||
| $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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| $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" { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is very similar to the test at L504. Can you use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine to keep it as is. This |
||
|
|
||
| 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still not convinced changing this from a string literal to the variable is the right move. Please provide answers to the question in the other PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests should work on all PowerShell Core versions without changes.
We don't pass-through the version constant, we evaluate it. So we should have a contract for this in the tests.