-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe270a1
commit a99b2b2
Showing
1 changed file
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
Import-Module "$psscriptroot\PSGetTestUtils.psm1" -Force | ||
|
||
Describe 'Test Azure Artifacts Credential Provider' -tags 'CI' { | ||
|
||
BeforeAll{ | ||
$TestModuleName = "PackageManagement" | ||
$ADORepoName = "ADORepository" | ||
$ADORepoUri = "https://pkgs.dev.azure.com/mscodehub/PowerShellCore/_packaging/PowerShellCore_PublicPackages/nuget/v2" | ||
$LocalRepoName = "LocalRepository" | ||
$LocalRepoUri = Join-Path -Path $TestDrive -ChildPath "testdir" | ||
$null = New-Item $LocalRepoUri -ItemType Directory -Force | ||
|
||
Get-NewPSResourceRepositoryFile | ||
Register-PSResourceRepository -Name $ADORepoName -Uri $ADORepoUri -Trusted | ||
} | ||
|
||
AfterAll { | ||
Uninstall-PSResource $TestModuleName -SkipDependencyCheck -ErrorAction SilentlyContinue | ||
|
||
Get-RevertPSResourceRepositoryFile | ||
} | ||
|
||
It "Find resource given specific Name and Repository" { | ||
$res = Find-PSResource -Name $TestModuleName -Repository $ADORepoName | ||
$res.Name | Should -Be $TestModuleName | ||
} | ||
|
||
It "Install resource given specific Name and Repository" { | ||
Install-PSResource -Name $TestModuleName -Repository $ADORepoName | ||
|
||
Get-InstalledPSResource -Name $TestModuleName | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
It "Register repository with local path (CredentialProvider should be set to 'None')" { | ||
Register-PSResourceRepository -Name $LocalRepoName -Uri $LocalRepoUri -Force | ||
$repo = Get-PSResourceRepository -Name $LocalRepoName | ||
$repo.CredentialProvider | Should -Be "None" | ||
} | ||
|
||
It "Set CredentialProvider for local path repository" { | ||
Register-PSResourceRepository -Name $LocalRepoName -Uri $LocalRepoUri -Trusted -Force | ||
$repo = Get-PSResourceRepository -Name $LocalRepoName | ||
$repo.CredentialProvider | Should -Be "None" | ||
|
||
Set-PSResourceRepository -Name $LocalRepoName -CredentialProvider AzArtifacts | ||
$repo2 = Get-PSResourceRepository -Name $LocalRepoName | ||
$repo2.CredentialProvider | Should -Be "AzArtifacts" | ||
} | ||
|
||
It "Register repository with ADO Uri (CredentialProvider should be set to 'AzArtifacts')" { | ||
Register-PSResourceRepository -Name $ADORepoName -Uri $ADORepoUri -Force | ||
$repo = Get-PSResourceRepository -Name $ADORepoName | ||
$repo.CredentialProvider | Should -Be "AzArtifacts" | ||
} | ||
|
||
It "Set CredentialProvider for ADO repository" { | ||
Register-PSResourceRepository -Name $ADORepoName -Uri $ADORepoUri -Trusted -Force | ||
$repo = Get-PSResourceRepository -Name $ADORepoName | ||
$repo.CredentialProvider | Should -Be "AzArtifacts" | ||
|
||
Set-PSResourceRepository -Name $ADORepoName -CredentialProvider None | ||
$repo2 = Get-PSResourceRepository -Name $ADORepoName | ||
$repo2.CredentialProvider | Should -Be "None" | ||
} | ||
|
||
It "Register repository with ADO Uri (CredentialProvider should be set to 'AzArtifacts')" { | ||
Register-PSResourceRepository -Name $ADORepoName -Uri $ADORepoUri -CredentialProvider None -Force | ||
$repo = Get-PSResourceRepository -Name $ADORepoName | ||
$repo.CredentialProvider | Should -Be "None" | ||
} | ||
} |