Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Remove test credentials from all test #659

Merged
merged 4 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions Tests/PSGetFindModule.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -582,59 +582,3 @@ Describe PowerShell.PSGet.FindModuleTests.P2 -Tags 'P2', 'OuterLoop' {
$i = $i + 1
}
}


Describe "Azure Artifacts Credential Provider Integration" -Tags 'BVT' {

BeforeAll {
$repoName = "OneGetTestPrivateFeed"
# This pkg source is an Azure DevOps private feed
$testLocation = "https://pkgs.dev.azure.com/onegettest/_packaging/onegettest/nuget/v2";
$username = "[email protected]"
$PAT = "qo2xvzdnfi2mlcq3eq2jkoxup576kt4gnngcicqhup6bbix6sila"
# see https://github.com/Microsoft/artifacts-credprovider#environment-variables for more info on env vars for the credential provider
# The line below is purely for local testing. Make sure to update env vars in AppVeyor and Travis CI as necessary.
$VSS_NUGET_EXTERNAL_FEED_ENDPOINTS = "{'endpointCredentials': [{'endpoint':'$testLocation', 'username':'$username', 'password':'$PAT'}]}"
[System.Environment]::SetEnvironmentVariable("VSS_NUGET_EXTERNAL_FEED_ENDPOINTS", $VSS_NUGET_EXTERNAL_FEED_ENDPOINTS, [System.EnvironmentVariableTarget]::Process)


# 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
$VSinstalledCredProvider = $false;
$programFiles = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFilesX86);
$vswhereExePath = $programFiles + "\\Microsoft Visual Studio\\Installer\\vswhere.exe";
$fullVSwhereExePath = [System.Environment]::ExpandEnvironmentVariables($vswhereExePath);
# If the env variable exists, check to see if the path itself exists
if (Test-Path ($fullVSwhereExePath)) {
$VSinstalledCredProvider = $true;
}
}

AfterAll {
UnRegister-PSRepository -Name $repoName -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
}

it "Register-PackageSource using Visual Studio installed credential provider" -Skip:(!$VSinstalledCredProvider) {
Register-PSRepository $repoName -SourceLocation $testLocation

(Get-PSRepository -Name $repoName).Name | should match $repoName
(Get-PSRepository -Name $repoName).SourceLocation | should match $testLocation

Unregister-PSRepository -Name $repoName -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
}

it "Register-PackageSource using credential provider" -Skip:(!$IsWindows) {
# Make sure the credential provider is installed (works for Windows, Linux, and Mac)
# If the credential provider is already installed, will receive the message: "The netcore Credential Provider is already in C:\Users\<alias>\.nuget\plugins"
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1'))

Register-PSRepository $repoName -SourceLocation $testLocation

(Get-PSRepository -Name $repoName).Name | should match $repoName
(Get-PSRepository -Name $repoName).SourceLocation | should match $testLocation
}

it "Find-Package using credential provider" -Skip:(!$IsWindows) {
$pkg = Find-Module * -Repository $repoName
$pkg.Count | should -BeGreaterThan 0
}
}
Loading