@@ -116,7 +116,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
116
116
# Expected Result: Should fail
117
117
#
118
118
It " FindModuleNonExistentModule" {
119
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module NonExistentModule} `
119
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module NonExistentModule } `
120
120
- expectedFullyQualifiedErrorId " NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage"
121
121
}
122
122
@@ -127,7 +127,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
127
127
# Expected Result: Should fail
128
128
#
129
129
It " FindScriptNotModule" {
130
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module Fabrikam- ServerScript} `
130
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module Fabrikam- ServerScript } `
131
131
- expectedFullyQualifiedErrorId ' MatchInvalidType,Find-Module'
132
132
}
133
133
@@ -149,7 +149,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
149
149
# Expected Result: Should fail with error id
150
150
#
151
151
It " FindModuleWithVersionParams" {
152
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module ContosoServer - MinimumVersion 1.0 - RequiredVersion 5.0 } `
152
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module ContosoServer - MinimumVersion 1.0 - RequiredVersion 5.0 } `
153
153
- expectedFullyQualifiedErrorId " VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Find-Module"
154
154
}
155
155
@@ -171,7 +171,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
171
171
# Expected Result: Should not find the ContosoServer module
172
172
#
173
173
It " FindModuleWithMinVersionNotAvailable" {
174
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module ContosoServer - MinimumVersion 10.0 } `
174
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module ContosoServer - MinimumVersion 10.0 } `
175
175
- expectedFullyQualifiedErrorId " NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage"
176
176
}
177
177
@@ -182,7 +182,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
182
182
# Expected Result: Should not find the ContosoServer module
183
183
#
184
184
It " FindModuleWithReqVersionNotAvailable" {
185
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module ContosoServer - RequiredVersion 10.0 } `
185
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module ContosoServer - RequiredVersion 10.0 } `
186
186
- expectedFullyQualifiedErrorId " NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage"
187
187
}
188
188
@@ -204,7 +204,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
204
204
# Expected Result: Should fail with error id
205
205
#
206
206
It " FindModuleWithMultipleModuleNamesAndReqVersion" {
207
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module ContosoServer, ContosoClient - RequiredVersion 1.0 } `
207
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module ContosoServer, ContosoClient - RequiredVersion 1.0 } `
208
208
- expectedFullyQualifiedErrorId " VersionParametersAreAllowedOnlyWithSingleName,Find-Module"
209
209
}
210
210
@@ -215,7 +215,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
215
215
# Expected Result: Should fail with error id
216
216
#
217
217
It " FindModuleWithMultipleModuleNamesAndMinVersion" {
218
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module ContosoServer, ContosoClient - MinimumVersion 1.0 } `
218
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module ContosoServer, ContosoClient - MinimumVersion 1.0 } `
219
219
- expectedFullyQualifiedErrorId " VersionParametersAreAllowedOnlyWithSingleName,Find-Module"
220
220
}
221
221
@@ -226,7 +226,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
226
226
# Expected Result: Should fail with error id
227
227
#
228
228
It " FindModuleWithWildcardNameAndReqVersion" {
229
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module Contoso* er - RequiredVersion 1.0 } `
229
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module Contoso* er - RequiredVersion 1.0 } `
230
230
- expectedFullyQualifiedErrorId " VersionParametersAreAllowedOnlyWithSingleName,Find-Module"
231
231
}
232
232
@@ -237,7 +237,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
237
237
# Expected Result: Should fail with error id
238
238
#
239
239
It " FindModuleWithWildcardNameAndMinVersion" {
240
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module Contoso* er - MinimumVersion 1.0 } `
240
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module Contoso* er - MinimumVersion 1.0 } `
241
241
- expectedFullyQualifiedErrorId " VersionParametersAreAllowedOnlyWithSingleName,Find-Module"
242
242
}
243
243
@@ -281,7 +281,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
281
281
# Expected Result: Find-Module should work and it should have valid metadata
282
282
#
283
283
It FindModuleUsingIncludesRoleCapability {
284
- $psgetModuleInfo = Find-Module - Includes RoleCapability | Where-Object {$_.Name -eq " DscTestModule" }
284
+ $psgetModuleInfo = Find-Module - Includes RoleCapability | Where-Object { $_.Name -eq " DscTestModule" }
285
285
AssertNotNull $psgetModuleInfo.Includes " Includes is missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes ) "
286
286
Assert $psgetModuleInfo.Includes.RoleCapability.Count " RoleCapability are missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes.RoleCapability ) "
287
287
Assert $psgetModuleInfo.Includes.DscResource.Count " DscResource are missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes.DscResource ) "
@@ -297,7 +297,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
297
297
# Expected Result: Find-Module should work and it should have valid metadata
298
298
#
299
299
It FindModuleUsingIncludesDscResource {
300
- $psgetModuleInfo = Find-Module - Includes DscResource | Where-Object {$_.Name -eq " DscTestModule" }
300
+ $psgetModuleInfo = Find-Module - Includes DscResource | Where-Object { $_.Name -eq " DscTestModule" }
301
301
AssertNotNull $psgetModuleInfo.Includes " Includes is missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes ) "
302
302
Assert $psgetModuleInfo.Includes.DscResource.Count " DscResource are missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes.DscResource ) "
303
303
Assert $psgetModuleInfo.Includes.Command.Count " Commands are missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes.Command ) "
@@ -312,7 +312,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
312
312
# Expected Result: Find-Module should work and it should have valid metadata
313
313
#
314
314
It FindModuleUsingIncludesCmdlet {
315
- $psgetModuleInfo = Find-Module - Includes Cmdlet | Where-Object {$_.Name -eq " DscTestModule" }
315
+ $psgetModuleInfo = Find-Module - Includes Cmdlet | Where-Object { $_.Name -eq " DscTestModule" }
316
316
AssertNotNull $psgetModuleInfo.Includes " Includes is missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes ) "
317
317
Assert $psgetModuleInfo.Includes.DscResource.Count " DscResource are missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes.DscResource ) "
318
318
Assert $psgetModuleInfo.Includes.Command.Count " Commands are missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes.Command ) "
@@ -327,7 +327,7 @@ Describe PowerShell.PSGet.FindModuleTests -Tags 'BVT', 'InnerLoop' {
327
327
# Expected Result: Find-Module should work and it should have valid metadata
328
328
#
329
329
It FindModuleUsingIncludesFunction {
330
- $psgetModuleInfo = Find-Module - Includes Function - Tag CommandsAndResource | Where-Object {$_.Name -eq " DscTestModule" }
330
+ $psgetModuleInfo = Find-Module - Includes Function - Tag CommandsAndResource | Where-Object { $_.Name -eq " DscTestModule" }
331
331
AssertNotNull $psgetModuleInfo.Includes " Includes is missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes ) "
332
332
Assert $psgetModuleInfo.Includes.DscResource.Count " DscResource are missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes.DscResource ) "
333
333
Assert $psgetModuleInfo.Includes.Command.Count " Commands are missing on PSGetModuleInfo, $ ( $psgetModuleInfo.Includes.Command ) "
@@ -476,7 +476,7 @@ Describe PowerShell.PSGet.FindModuleTests.P1 -Tags 'P1', 'OuterLoop' {
476
476
# Expected Result: should fail with an error id
477
477
#
478
478
It FindModuleWithAllVersionsAndMinimumVersion {
479
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module ContosoClient - MinimumVersion 2.0 - Repository PSGallery - AllVersions} `
479
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module ContosoClient - MinimumVersion 2.0 - Repository PSGallery - AllVersions } `
480
480
- expectedFullyQualifiedErrorId ' AllVersionsCannotBeUsedWithOtherVersionParameters,Find-Module'
481
481
}
482
482
@@ -487,7 +487,7 @@ Describe PowerShell.PSGet.FindModuleTests.P1 -Tags 'P1', 'OuterLoop' {
487
487
# Expected Result: should fail with an error id
488
488
#
489
489
It FindModuleWithAllVersionsAndRequiredVersion {
490
- AssertFullyQualifiedErrorIdEquals - scriptblock {Find-Module ContosoClient - RequiredVersion 2.0 - Repository PSGallery - AllVersions} `
490
+ AssertFullyQualifiedErrorIdEquals - scriptblock { Find-Module ContosoClient - RequiredVersion 2.0 - Repository PSGallery - AllVersions } `
491
491
- expectedFullyQualifiedErrorId ' AllVersionsCannotBeUsedWithOtherVersionParameters,Find-Module'
492
492
}
493
493
@@ -519,7 +519,7 @@ Describe PowerShell.PSGet.FindModuleTests.P1 -Tags 'P1', 'OuterLoop' {
519
519
$res2 = Find-Module - Name $ModuleName - IncludeDependencies - MaximumVersion " 1.0" - MinimumVersion " 0.1"
520
520
Assert ($res2.Count -ge ($DepencyModuleNames.Count + 1 )) " Find-Module with -IncludeDependencies returned wrong results, $res2 "
521
521
522
- $DepencyModuleNames | ForEach-Object { Assert ($res2.Name -Contains $_ ) " Find-Module with -IncludeDependencies didn't return the $_ module, $ ( $res2.Name ) " }
522
+ $DepencyModuleNames | ForEach-Object { Assert ($res2.Name -Contains $_ ) " Find-Module with -IncludeDependencies didn't return the $_ module, $ ( $res2.Name ) " }
523
523
}
524
524
}
525
525
@@ -582,3 +582,59 @@ Describe PowerShell.PSGet.FindModuleTests.P2 -Tags 'P2', 'OuterLoop' {
582
582
$i = $i + 1
583
583
}
584
584
}
585
+
586
+
587
+ Describe " Azure Artifacts Credential Provider Integration" - Tags ' BVT' {
588
+
589
+ BeforeAll {
590
+ $repoName = " OneGetTestPrivateFeed"
591
+ # This pkg source is an Azure DevOps private feed
592
+ $testLocation = " https://pkgs.dev.azure.com/onegettest/_packaging/onegettest/nuget/v2" ;
593
+ $username = " onegettest@hotmail.com"
594
+ $PAT = " qo2xvzdnfi2mlcq3eq2jkoxup576kt4gnngcicqhup6bbix6sila"
595
+ # see https://github.com/Microsoft/artifacts-credprovider#environment-variables for more info on env vars for the credential provider
596
+ # The line below is purely for local testing. Make sure to update env vars in AppVeyor and Travis CI as necessary.
597
+ $VSS_NUGET_EXTERNAL_FEED_ENDPOINTS = " {'endpointCredentials': [{'endpoint':'$testLocation ', 'username':'$username ', 'password':'$PAT '}]}"
598
+ [System.Environment ]::SetEnvironmentVariable(" VSS_NUGET_EXTERNAL_FEED_ENDPOINTS" , $VSS_NUGET_EXTERNAL_FEED_ENDPOINTS , [System.EnvironmentVariableTarget ]::Process )
599
+
600
+
601
+ # Figure out if Visual Studio is installed, and if it is, we'll use the credential provider that's installed there for the first test
602
+ $VSinstalledCredProvider = $false ;
603
+ $programFiles = [System.Environment ]::GetFolderPath([System.Environment + SpecialFolder ]::ProgramFilesX86);
604
+ $vswhereExePath = $programFiles + " \\Microsoft Visual Studio\\Installer\\vswhere.exe" ;
605
+ $fullVSwhereExePath = [System.Environment ]::ExpandEnvironmentVariables($vswhereExePath );
606
+ # If the env variable exists, check to see if the path itself exists
607
+ if (Test-Path ($fullVSwhereExePath )) {
608
+ $VSinstalledCredProvider = $true ;
609
+ }
610
+ }
611
+
612
+ AfterAll {
613
+ UnRegister-PSRepository - Name $repoName - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
614
+ }
615
+
616
+ it " Register-PackageSource using Visual Studio installed credential provider" - Skip:(! $VSinstalledCredProvider ) {
617
+ Register-PSRepository $repoName - SourceLocation $testLocation
618
+
619
+ (Get-PSRepository - Name $repoName ).Name | should match $repoName
620
+ (Get-PSRepository - Name $repoName ).SourceLocation | should match $testLocation
621
+
622
+ Unregister-PSRepository - Name $repoName - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
623
+ }
624
+
625
+ it " Register-PackageSource using credential provider" - Skip:(! $IsWindows ) {
626
+ # Make sure the credential provider is installed (works for Windows, Linux, and Mac)
627
+ # If the credential provider is already installed, will receive the message: "The netcore Credential Provider is already in C:\Users\<alias>\.nuget\plugins"
628
+ iex ((new-object net.webclient).DownloadString(' https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1' ))
629
+
630
+ Register-PSRepository $repoName - SourceLocation $testLocation
631
+
632
+ (Get-PSRepository - Name $repoName ).Name | should match $repoName
633
+ (Get-PSRepository - Name $repoName ).SourceLocation | should match $testLocation
634
+ }
635
+
636
+ it " Find-Package using credential provider" - Skip:(! $IsWindows ) {
637
+ $pkg = Find-Module * - Repository $repoName
638
+ $pkg.Count | should - BeGreaterThan 0
639
+ }
640
+ }
0 commit comments