@@ -199,6 +199,101 @@ Describe "choco install" -Tag Chocolatey, InstallCommand {
199
199
It " Outputs a message indicating that missingpackage was not installed" {
200
200
$Output.Lines | Should - Contain " missingpackage not installed. The package was not found with the source(s) listed."
201
201
}
202
+
203
+ Context " packages.config containing all options" {
204
+ BeforeAll {
205
+ @"
206
+ <?xml version="1.0" encoding="utf-8"?>
207
+ <packages>
208
+ <package id="installpackage" prerelease="true" overrideArguments="true"
209
+ notSilent="true" allowDowngrade="true" forceDependencies="true"
210
+ skipAutomationScripts="true" user="string" password="string" cert="string"
211
+ certPassword="string" ignoreChecksums="true" allowEmptyChecksums="true"
212
+ allowEmptyChecksumsSecure="true" requireChecksums="true"
213
+ downloadChecksum="string" downloadChecksum64="string"
214
+ downloadChecksumType="sha512" downloadChecksumType64="sha512"
215
+ ignorePackageExitCodes="true" usePackageExitCodes="true"
216
+ stopOnFirstFailure="true" exitWhenRebootDetected="true"
217
+ ignoreDetectedReboot="true" disableRepositoryOptimizations="true"
218
+ acceptLicense="true" confirm="true" limitOutput="true" cacheLocation="Z:\"
219
+ failOnStderr="true" useSystemPowershell="true" noProgress="true"
220
+ force="true" executionTimeout="1000"
221
+ />
222
+ </packages>
223
+ "@ | Out-File $env: CHOCOLATEY_TEST_PACKAGES_PATH \alloptions.packages.config - Encoding utf8
224
+
225
+ $Output = Invoke-Choco install $env: CHOCOLATEY_TEST_PACKAGES_PATH \alloptions.packages.config -- confirm -- verbose -- debug
226
+
227
+ # This is based on two observations: The addition explicitly outputs that it's the Package Configuration.
228
+ # The configuration output is also about 80 lines.
229
+ $StartofPackageConfiguration = [array ]::IndexOf($Output.Lines , " Package Configuration: CommandName='install'|" )
230
+ $PackageConfigurationOutput = $Output.Lines [$StartofPackageConfiguration .. ($StartofPackageConfiguration + 80 )] -join [Environment ]::NewLine
231
+ }
232
+
233
+ # We are explicitly passing in a bad username and password here.
234
+ # Therefore it cannot find the package to install and fails the install.
235
+ # That doesn't matter because we just need to test that the configuration is set properly.
236
+ It " Should exit Failure (1)" {
237
+ $Output.ExitCode | Should - Be 1 - Because $Output.String
238
+ }
239
+
240
+ It " Should contain the expected configuration option (<Option>) set correctly (<ExpectedValue>)" - ForEach @ (
241
+ @ { Option = " Prerelease" ; ExpectedValue = " True" }
242
+ @ { Option = " OverrideArguments" ; ExpectedValue = " True" }
243
+ @ { Option = " NotSilent" ; ExpectedValue = " True" }
244
+ @ { Option = " AllowDowngrade" ; ExpectedValue = " True" }
245
+ @ { Option = " ForceDependencies" ; ExpectedValue = " True" }
246
+ # SkipAutomationScripts sets configuration option SkipPackageInstallProvider
247
+ @ { Option = " SkipPackageInstallProvider" ; ExpectedValue = " True" }
248
+ # User is expanded to Username
249
+ @ { Option = " Username" ; ExpectedValue = " string" }
250
+ # Password should *not* be output in the logging
251
+ # @{ Option = "Password" ; ExpectedValue = "string" }
252
+ # Cert is expanded to Certificate
253
+ @ { Option = " Certificate" ; ExpectedValue = " string" }
254
+ # CertPassword should *not* be output in the logging
255
+ # @{ Option = "CertPassword" ; ExpectedValue = "string" }
256
+ # IgnoreChecksums sets ChecksumFiles to False
257
+ @ { Option = " ChecksumFiles" ; ExpectedValue = " False" }
258
+ # RequireChecksums is evaluated after allowing empty. It sets both allow options to False
259
+ # @{ Option = "RequireChecksums" ; ExpectedValue = "True" }
260
+ @ { Option = " AllowEmptyChecksums" ; ExpectedValue = " False" }
261
+ @ { Option = " AllowEmptyChecksumsSecure" ; ExpectedValue = " False" }
262
+ @ { Option = " DownloadChecksum" ; ExpectedValue = " string" }
263
+ @ { Option = " DownloadChecksum64" ; ExpectedValue = " string" }
264
+ @ { Option = " DownloadChecksumType" ; ExpectedValue = " sha512" }
265
+ @ { Option = " DownloadChecksumType64" ; ExpectedValue = " sha512" }
266
+ # UsePackageExitCodes and IgnorePackageExitCodes set the same setting, but are opposite of each other.
267
+ # UsePackageExitCodes is evaluated last, so takes precidence.
268
+ # @{ Option = "IgnorePackageExitCodes" ; ExpectedValue = "True" }
269
+ @ { Option = " UsePackageExitCodes" ; ExpectedValue = " True" }
270
+ # StopOnFirstFailure is expanded to StopOnFirstPackageFailure
271
+ @ { Option = " StopOnFirstPackageFailure" ; ExpectedValue = " True" }
272
+ # ExitWhenRebootDetected and IgnoreDetectedReboot both set ExitOnRebootDetected.
273
+ # IgnoreDetectedReboot is evaluated last, so takes precidence.
274
+ # @{ Option = "ExitWhenRebootDetected" ; ExpectedValue = "True" }
275
+ # @{ Option = "IgnoreDetectedReboot" ; ExpectedValue = "True" }
276
+ @ { Option = " ExitOnRebootDetected" ; ExpectedValue = " False" }
277
+ # DisableRepositoryOptimizations sets UsePackageRepositoryOptimizations to false
278
+ @ { Option = " UsePackageRepositoryOptimizations" ; ExpectedValue = " False" }
279
+ @ { Option = " AcceptLicense" ; ExpectedValue = " True" }
280
+ # Confirm is negated into PromptForConfirmation
281
+ @ { Option = " PromptForConfirmation" ; ExpectedValue = " False" }
282
+ # LimitOutput is negated into Regular Output
283
+ @ { Option = " RegularOutput" ; ExpectedValue = " False" }
284
+ @ { Option = " CacheLocation" ; ExpectedValue = " Z:\\" }
285
+ @ { Option = " FailOnStandardError" ; ExpectedValue = " True" }
286
+ # UseSystemPowerShell sets UsePowerShellHost to False
287
+ @ { Option = " UsePowerShellHost" ; ExpectedValue = " False" }
288
+ # NoProgress sets ShowDownloadProgress to False
289
+ @ { Option = " ShowDownloadProgress" ; ExpectedValue = " False" }
290
+ @ { Option = " Force" ; ExpectedValue = " True" }
291
+ # ExecutionTimeout is expanded to CommandExecutionTimeoutSeconds
292
+ @ { Option = " CommandExecutionTimeoutSeconds" ; ExpectedValue = " 1000" }
293
+ ) {
294
+ $PackageConfigurationOutput | Should -Match " $Option ='$ExpectedValue '"
295
+ }
296
+ }
202
297
}
203
298
204
299
Context " Installing a Package that is already installed" {
0 commit comments