Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#3565) Update tests to be able to push when anonymous access is disabled. #3576

Merged
merged 2 commits into from
Nov 29, 2024
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
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
9 changes: 8 additions & 1 deletion tests/pester-tests/features/UserAgent.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ Describe "Chocolatey User Agent" -Tag Chocolatey, UserAgent {

$userAgent = $matches['UserAgent']

$userAgent -match 'Chocolatey Command Line/(?<Version>[a-z0-9.-]+) ([a-z ]+/(<?LicensedVersion>[a-z0-9.-]+) )?\((?<RootProcess>[^,)]+)(?:, (?<ParentProcess>[^)]+))?\) via NuGet Client' |
$userAgent -match 'Chocolatey Command Line/(?<Version>[a-z0-9.-]+) ([a-z ]+/(?<LicensedVersion>[a-z0-9.-]+) )?\((?<RootProcess>[^,)]+)(?:, (?<ParentProcess>[^)]+))?\) via NuGet Client' |
Should -BeTrue -Because "the user agent string should contain the choco.exe version, the licensed extension version if any, and any parent processes. $logLine"

$matches['Version'] | Should -Be $ChocolateyVersion -Because "the user agent string should contain the currently running Chocolatey version. $logLine"

if (Test-PackageIsEqualOrHigher -PackageName 'chocolatey.extension' -Version '6.3.0-alpha') {
# We are not asserting the Licensed Extension version here as the Chocolatey package version often
# mismatches the assembly version.
$matches['LicensedVersion'] | Should -Not -BeNullOrEmpty -Because "Chocolatey Licensed Extension is installed and should be in the user agent. $logLine"
}

$filteredProcesses = @($Processes | Where-Object { $_ -notin $ExcludedProcesses })

if ($filteredProcesses.Count -gt 1) {
Expand Down