From 388b3f6875b903618c264605c36455cb70d269e2 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Thu, 16 Feb 2023 14:39:15 -0800 Subject: [PATCH] (tests) Enhance Invoke-Choco to force proxy use We're adding some Test Kitchen instances that set custom environment variables so that we can test the proxy parameters. This enhances the `Invoke-Choco` function to look for these variables and add the proxy parameters to the command. (cherry picked from commit 06825feff8fe9ecd99d7ea56730b6c50627841bd) # Conflicts: # tests/helpers/common/Chocolatey/Invoke-Choco.ps1 --- tests/helpers/common/Chocolatey/Invoke-Choco.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/helpers/common/Chocolatey/Invoke-Choco.ps1 b/tests/helpers/common/Chocolatey/Invoke-Choco.ps1 index 79e136aef1..9491030351 100644 --- a/tests/helpers/common/Chocolatey/Invoke-Choco.ps1 +++ b/tests/helpers/common/Chocolatey/Invoke-Choco.ps1 @@ -19,7 +19,21 @@ begin { $chocoPath = Get-ChocoPath $firstArgument, [string[]]$remainingArguments = $Arguments - $arguments = @($firstArgument; '--allow-unofficial'; $remainingArguments) + $arguments = @( + $firstArgument + '--allow-unofficial' + + if ($env:CHOCO_TEST_PROXY) { + "--proxy='$($env:CHOCO_TEST_PROXY)'" + if ($env:CHOCO_TEST_PROXY_USER) { + "--proxy-user='$($env:CHOCO_TEST_PROXY_USER)'" + "--proxy-password='$($env:CHOCO_TEST_PROXY_PASSWORD)'" + } + } + + $remainingArguments + ) + } end { $output = if ($PipelineInput) {