Skip to content

Commit

Permalink
(chocolatey#3565) Add authenticated source for Pester tests
Browse files Browse the repository at this point in the history
Add the push source to configuration so that we are able to push to it
successfully. When anonymous access is disabled, Chocolatey will now
only use credentials it has configured by the exact source URL, and not
just one that matches the hostname. As such, this test started failing
and needs to be updated to ensure the credentials can be used.

See chocolatey#2026 for more details.
  • Loading branch information
corbob committed Nov 27, 2024
1 parent 4f5bd1d commit 7387944
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/pester-tests/commands/choco-push.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ Describe 'choco push nuget <_> repository' -Tag Chocolatey, PushCommand -Skip:($

if ($UseConfig) {
$null = Invoke-Choco apikey add --source $RepositoryToUse$RepositoryEndpoint --api-key $ApiKey
# Add the Nuget source so that the push doesn't prompt for credentials.
# See https://github.com/chocolatey/choco/issues/2026#issuecomment-2423828013
$null = Invoke-Choco source add --name temporary-nuget --source $RepositoryToUse$RepositoryEndpoint --user $env:NUGET_SOURCE_USERNAME --password $env:NUGET_SOURCE_PASSWORD
# Ensure the key is null (should always be, but scoping can be wonky)
$KeyParameter = $null
} else {
Expand Down

0 comments on commit 7387944

Please sign in to comment.