Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (test) Add unit tests for ArgumentsUtility class
  (#2266) Update nuspec to what is being used
  • Loading branch information
gep13 committed Sep 9, 2021
2 parents cd93865 + c8ba893 commit ec864f8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nuget/chocolatey.lib/chocolatey.lib.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This is the Chocolatey Library (API / DLL) package which allows Chocolatey to be
<releaseNotes>See all - https://docs.chocolatey.org/en-us/choco/release-notes
</releaseNotes>
<dependencies>
<dependency id="log4net" version="2.0.3" />
<dependency id="log4net" version="2.0.12" />
</dependencies>
</metadata>
</package>
1 change: 1 addition & 0 deletions src/chocolatey.tests/chocolatey.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<Compile Include="infrastructure.app\services\NugetServiceSpecs.cs" />
<Compile Include="infrastructure.app\services\RegistryServiceSpecs.cs" />
<Compile Include="infrastructure.app\services\TemplateServiceSpecs.cs" />
<Compile Include="infrastructure.app\utility\ArgumentsUtilitySpecs.cs" />
<Compile Include="infrastructure\commands\ExternalCommandArgsBuilderSpecs.cs" />
<Compile Include="infrastructure\commandline\InteractivePromptSpecs.cs" />
<Compile Include="infrastructure\commands\CommandExecutorSpecs.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}

0 comments on commit ec864f8

Please sign in to comment.