-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from PowerShell/dev
Release of version 2.6.0.0 of xWebAdministration
- Loading branch information
Showing
7 changed files
with
128 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -36,6 +36,9 @@ try | |
$certEKUReverse = @('Client authentication','Server Authentication') | ||
$certEKUNoMatch = $certEKU + @('Encrypting File System') | ||
$certSubject = 'CN=contoso, DC=com' | ||
$certSubjectLong = 'CN=contoso, [email protected], O=Fabrikam., OU=IT, L=Location, S=State, C=Country' | ||
$certSubjectNoSpace = 'CN=contoso,[email protected],O=Fabrikam.,OU=IT,L=Location,S=State,C=Country' | ||
$certSubjectLongReverse = '[email protected],O=Fabrikam.,L=Location,CN=contoso,OU=IT,S=State,C=Country' | ||
$certFriendlyName = 'Contoso Test Cert' | ||
$validCert = New-SelfSignedCertificateEx ` | ||
-Subject $certSubject ` | ||
|
@@ -51,6 +54,21 @@ try | |
$validCert = Get-Item -Path "cert:\CurrentUser\My\$validThumbprint" | ||
Remove-Item -Path $validCert.PSPath -Force | ||
|
||
# Generate the long subject certificate for testing but remove it from the store straight away | ||
$validCertSubjectLong = New-SelfSignedCertificateEx ` | ||
-Subject $certSubjectLong ` | ||
-KeyUsage $certKeyUsage ` | ||
-KeySpec 'Exchange' ` | ||
-EKU $certEKU ` | ||
-SubjectAlternativeName $certDNSNames ` | ||
-FriendlyName $certFriendlyName ` | ||
-StoreLocation 'CurrentUser' ` | ||
-Exportable | ||
# Pull the generated certificate from the store so we have the friendlyname | ||
$longThumbprint = $validCertSubjectLong.Thumbprint | ||
$validCertSubjectLong = Get-Item -Path "cert:\CurrentUser\My\$longThumbprint" | ||
Remove-Item -Path $validCertSubjectLong.PSPath -Force | ||
|
||
# Generate the Expired certificate for testing but remove it from the store straight away | ||
$expiredCert = New-SelfSignedCertificateEx ` | ||
-Subject $certSubject ` | ||
|
@@ -94,6 +112,11 @@ try | |
return @( $expiredCert ) | ||
} | ||
|
||
'cert:\LocalMachine\LongSubject' | ||
{ | ||
return @( $validCertSubjectLong ) | ||
} | ||
|
||
default | ||
{ | ||
throw 'mock called with unexpected value {0}' -f $Path | ||
|
@@ -201,6 +224,36 @@ try | |
} | ||
} | ||
|
||
Context 'Subject only is passed and certificate with a different subject order exists' { | ||
It 'should not throw exception' { | ||
{ $script:result = Find-Certificate -Subject $certSubjectLongReverse -Store 'LongSubject' } | Should Not Throw | ||
} | ||
|
||
It 'should return expected certificate' { | ||
$script:result.Thumbprint | Should Be $longThumbprint | ||
} | ||
|
||
It 'should call expected mocks' { | ||
Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 | ||
Assert-MockCalled -CommandName Get-ChildItem -Exactly -Times 1 | ||
} | ||
} | ||
|
||
Context 'Subject only is passed and certificate subject without spaces exists' { | ||
It 'should not throw exception' { | ||
{ $script:result = Find-Certificate -Subject $certSubjectNoSpace -Store 'LongSubject' } | Should Not Throw | ||
} | ||
|
||
It 'should return expected certificate' { | ||
$script:result.Thumbprint | Should Be $longThumbprint | ||
} | ||
|
||
It 'should call expected mocks' { | ||
Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 | ||
Assert-MockCalled -CommandName Get-ChildItem -Exactly -Times 1 | ||
} | ||
} | ||
|
||
Context 'Issuer only is passed and matching certificate exists' { | ||
It 'should not throw exception' { | ||
{ $script:result = Find-Certificate -Issuer $certSubject } | Should Not Throw | ||
|
This file contains 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