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 cc28e6f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/pester-tests/commands/choco-push.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module helpers/common-helpers
Import-Module helpers/common-helpers

# These are skipped in the Proxy Test environment because they push to a port outside of 8443 which is not allowed by our proxy.
Describe "choco push" -Tag Chocolatey, PushCommand, ProxySkip -Skip:($null -eq $env:API_KEY -or $null -eq $env:PUSH_REPO) {
Expand Down 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 cc28e6f

Please sign in to comment.