-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add SkipCA and SkipCN check requirement to WinRM/OMI HTTPS connection #8279
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
Merged
adityapatwardhan
merged 12 commits into
PowerShell:master
from
PaulHigin:Unix_SkipCA_Fix
Nov 28, 2018
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c163520
Add SkipCA and SkipCN check requirement before allowing HTTPS connection
PaulHigin 8d17632
Merge remote-tracking branch 'upstream/master' into Unix_SkipCA_Fix
PaulHigin f3aa030
Updated error message per CR
PaulHigin a1e117d
Add required parameter tests
PaulHigin 557f385
Merge branch 'master' into Unix_SkipCA_Fix
PaulHigin 837c6f9
Add New-PSSessionOption to expected cmdlet list for CoreUnix
PaulHigin 76c6ed0
Merge branch 'Unix_SkipCA_Fix' of github.com:PaulHigin/PowerShell int…
PaulHigin 197b6eb
Update1
PaulHigin d52b894
Add conditional to Before work
PaulHigin 3cb1562
Changes to conform to test pattern requirement
PaulHigin f504f35
Update to use different error check pattern
PaulHigin 6c4f2e2
Updated error message per CR
PaulHigin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| # | ||
| # PSSession tests for non-Windows platforms | ||
| # | ||
|
|
||
| Describe "New-PSSessionOption parameters for non-Windows platforms" -Tag "CI" { | ||
|
|
||
| BeforeAll { | ||
| $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() | ||
|
|
||
| if ($IsWindows) { | ||
| $PSDefaultParameterValues['it:skip'] = $true | ||
| } | ||
| } | ||
|
|
||
| AfterAll { | ||
| $global:PSDefaultParameterValues = $originalDefaultParameterValues | ||
| } | ||
|
|
||
| It "Verifies New-PSSessionOption parameters" { | ||
|
|
||
| $cmdInfo = Get-Command New-PSSessionOption | ||
|
|
||
| $commonParameterCount = [System.Management.Automation.Internal.CommonParameters].GetProperties().Length | ||
| $cmdInfo.Parameters.Count | Should -Be ($commonParameterCount + 2) -Because "Only -SkipCACheck and -SkipCNCheck switch parameters are available" | ||
|
|
||
| { $null = $cmdInfo.ResolveParameter("SkipCACheck") } | Should -Not -Throw -Because "SkipCACheck parameter should be available" | ||
| { $null = $cmdInfo.ResolveParameter("SkipCNCheck") } | Should -Not -Throw -Because "SkipCNCheck parameter should be available" | ||
| } | ||
| } | ||
|
|
||
| Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSSession on non-Windows platforms" -Tag "CI" { | ||
|
|
||
| BeforeAll { | ||
| $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() | ||
|
|
||
| if ($IsWindows) { | ||
| $PSDefaultParameterValues['it:skip'] = $true | ||
| } | ||
| else { | ||
| $userName = "User_$(Get-Random -Maximum 99999)" | ||
| $userPassword = "Password_$(Get-Random -Maximum 99999)" | ||
| $cred = [pscredential]::new($userName, (ConvertTo-SecureString -String $userPassword -AsPlainText -Force)) | ||
| $soSkipCA = New-PSSessionOption -SkipCACheck | ||
| $soSkipCN = New-PSSessionOption -SkipCNCheck | ||
| } | ||
| } | ||
|
|
||
| AfterAll { | ||
| $global:PSDefaultParameterValues = $originalDefaultParameterValues | ||
| } | ||
|
|
||
| $testCases = @( | ||
| @{ | ||
| Name = 'Verifies expected error when session options is missing' | ||
| ScriptBlock = { New-PSSession -cn localhost -Credential $cred -Authentication Basic -UseSSL } | ||
| ExpectedErrorCode = 825 | ||
| }, | ||
| @{ | ||
| Name = 'Verifies expected error when SkipCACheck option is missing' | ||
| ScriptBlock = { New-PSSession -cn localhost -Credential $cred -Authentication Basic -UseSSl -SessionOption $soSkipCN } | ||
PaulHigin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ExpectedErrorCode = 825 | ||
| }, | ||
| @{ | ||
| Name = 'Verifies expected error when SkipCNCheck option is missing' | ||
| ScriptBlock = { New-PSSession -cn localhost -Credential $cred -Authentication Basic -UseSSl -SessionOption $soSkipCA } | ||
| ExpectedErrorCode = 825 | ||
| } | ||
| ) | ||
|
|
||
| It "<Name>" -TestCases $testCases { | ||
| param ($scriptBlock, $expectedErrorCode) | ||
|
|
||
| $er = { & $scriptBlock } | Should -Throw -ErrorId 'System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.NewPSSessionCommand' -PassThru | ||
| $er.Exception.ErrorCode | Should -Be $expectedErrorCode | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.