From 58a63da718f719c9cd179f8efcf0433597393648 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 9 Sep 2021 09:13:36 +0100 Subject: [PATCH 1/2] (#2266) Update nuspec to what is being used All Chocolatey products are now using log4net 2.0.12, however, the nuspec file for the chocolatey.lib package still has a reference to the older 2.0.3 version. The decision has been taken that this doesn't warrant a new release of this package. --- nuget/chocolatey.lib/chocolatey.lib.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuget/chocolatey.lib/chocolatey.lib.nuspec b/nuget/chocolatey.lib/chocolatey.lib.nuspec index cb067d69d7..d4f0aea314 100644 --- a/nuget/chocolatey.lib/chocolatey.lib.nuspec +++ b/nuget/chocolatey.lib/chocolatey.lib.nuspec @@ -34,7 +34,7 @@ This is the Chocolatey Library (API / DLL) package which allows Chocolatey to be See all - https://docs.chocolatey.org/en-us/choco/release-notes - + From f10f52e55ecd81eac8e70ab1a45955f52296add8 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 9 Sep 2021 09:47:38 +0100 Subject: [PATCH 2/2] (test) Add unit tests for ArgumentsUtility class This is starting to be used in other places, so we should have some tests around the execution of the logic contained within this class to ensure that there are no regressions if/when editing this class. For now, all the current expectations are covered within the different TestFixtures, but this should be extended if any changes are made to the class. --- src/chocolatey.tests/chocolatey.tests.csproj | 1 + .../utility/ArgumentsUtilitySpecs.cs | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/chocolatey.tests/infrastructure.app/utility/ArgumentsUtilitySpecs.cs diff --git a/src/chocolatey.tests/chocolatey.tests.csproj b/src/chocolatey.tests/chocolatey.tests.csproj index 8aebac445e..45ad943082 100644 --- a/src/chocolatey.tests/chocolatey.tests.csproj +++ b/src/chocolatey.tests/chocolatey.tests.csproj @@ -112,6 +112,7 @@ + diff --git a/src/chocolatey.tests/infrastructure.app/utility/ArgumentsUtilitySpecs.cs b/src/chocolatey.tests/infrastructure.app/utility/ArgumentsUtilitySpecs.cs new file mode 100644 index 0000000000..21c9ac2281 --- /dev/null +++ b/src/chocolatey.tests/infrastructure.app/utility/ArgumentsUtilitySpecs.cs @@ -0,0 +1,62 @@ +namespace chocolatey.tests.infrastructure.app.utility +{ + using chocolatey.infrastructure.app.utility; + using NUnit.Framework; + using Should; + + public class ArgumentsUtilitySpecs + { + public abstract class ArgumentsUtilitySpecsBase : TinySpec + { + public override void Context() + { + } + } + + [TestFixture("choco install bob --package-parameters-sensitive=\"/test=bill\"", true)] + [TestFixture("choco install bob -package-parameters-sensitive=\"/test=bill\"", true)] + [TestFixture("choco install bob --install-arguments-sensitive=\"/test=bill\"", true)] + [TestFixture("choco install bob -install-arguments-sensitive=\"/test=bill\"", true)] + [TestFixture("choco apikey -k secretKey -s secretSource", true)] + [TestFixture("choco config set --name=proxyPassword --value=secretPassword", true)] + [TestFixture("choco push package.nupkg -k=secretKey", true)] + [TestFixture("choco source add -n=test -u=bob -p bill", true)] + [TestFixture("choco source add -n=test -u=bob -p=bill", true)] + [TestFixture("choco source add -n=test -u=bob -password=bill", true)] + [TestFixture("choco source add -n=test -cert=text.pfx -cp secretPassword", true)] + [TestFixture("choco source add -n=test -cert=text.pfx -cp=secretPassword", true)] + [TestFixture("choco source add -n=test -cert=text.pfx -certpassword=secretPassword", true)] + [TestFixture("choco push package.nupkg -k secretKey", true)] + [TestFixture("choco push package.nupkg -k=secretKey", true)] + [TestFixture("choco push package.nupkg -key secretKey", true)] + [TestFixture("choco push package.nupkg -key=secretKey", true)] + [TestFixture("choco install bob -apikey=secretKey", true)] + [TestFixture("choco install bob -apikey secretKey", true)] + [TestFixture("choco install bob -api-key=secretKey", true)] + [TestFixture("choco install bob -api-key secretKey", true)] + [TestFixture("choco install bob", false)] + public class when_ArgumentsUtility_is_testing_for_sensitive_parameters : ArgumentsUtilitySpecsBase + { + private bool _result; + private bool _expectedResult; + private string _commandArguments; + + public when_ArgumentsUtility_is_testing_for_sensitive_parameters(string commandArguments, bool expectedResult) + { + _commandArguments = commandArguments; + _expectedResult = expectedResult; + } + + public override void Because() + { + _result = ArgumentsUtility.arguments_contain_sensitive_information(_commandArguments); + } + + [Fact] + public void should_return_expected_result() + { + _result.ShouldEqual(_expectedResult); + } + } + } +}