Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (chocolateyGH-501) allow shutting off sign when no network
  (chocolateyGH-448) Add Output Directory for choco new
  (maint) assume xml file is utf8
  (maint) formatting
  (chocolateyGH-258) Switch for only using silent args provided
  (chocolateyGH-682) Add summary log file
  (chocolateyGH-644) Add info command
  (chocolateyGH-646) Add detail/detailed for search/list
  (maint) template share location should be appropriate
  (build) add a run.codesign switch
  • Loading branch information
ferventcoder committed Apr 9, 2016
2 parents 6b011ff + 3d67a72 commit 8a436eb
Show file tree
Hide file tree
Showing 22 changed files with 715 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .build.custom/codeSign.step
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<property name="code.cert.password" value="" />

<target name="go" depends="run_tasks" />
<target name="go" depends="run_tasks" if="${run.codesign}" />

<!-- run_normal_tasks is called from run_tasks unless replace extension exists-->
<target name="run_normal_tasks"
Expand Down Expand Up @@ -110,7 +110,7 @@ C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool.exe sign /t htt
$certPfx = "$env:CHOCOLATEY_OFFICIAL_CERT"
$certPassword = Get-Content "$env:CHOCOLATEY_OFFICIAL_CERT_PASSWORD"
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPfx, $certPassword)
Set-AuthenticodeSignature -Filepath @("C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1","C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1") -Cert $cert -TimeStampServer "http://timestamp.digicert.com" -IncludeChain All -HashAlgorithm SHA256
Set-AuthenticodeSignature -Filepath @("C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1","C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1") -Cert $cert -TimeStampServer "http://timestamp.digicert.com" -IncludeChain NotRoot -HashAlgorithm SHA256
-->

<target name="sign_powershell_files" description="Signs the final PowerShell files prior to packaging them up." if="${file::exists(app.powershell) and property::exists('path.code.cert')}">
Expand Down
2 changes: 1 addition & 1 deletion .build/default.build
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<nant buildfile="${dirs.current.file}${path.separator}gemsPrepare.step" inheritall="true" failonerror="false" if="${run.gems}" />
<nant buildfile="${dirs.current.file}${path.separator}gemsBuild.step" inheritall="true" failonerror="false" if="${run.gems}" />
<nant buildfile="${dirs.current.file}${path.separator}nugetPrepare.step" inheritall="true" failonerror="false" if="${run.nuget}" />
<nant buildfile="${dirs.build_scripts_custom}${path.separator}codeSign.step" failonerror="true" inheritall="true" />
<nant buildfile="${dirs.build_scripts_custom}${path.separator}codeSign.step" failonerror="true" inheritall="true" if="${run.codesign}" />
<nant buildfile="${dirs.current.file}${path.separator}nugetBuild.step" inheritall="true" failonerror="false" if="${run.nuget}" />
</target>

Expand Down
1 change: 1 addition & 0 deletions .uppercut
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<property name="run.fxcop" value="false" overwrite="false" />
<property name="run.obfuscator" value="false" overwrite="false" />
<property name="run.ilmerge" value="true" overwrite="false" />
<property name="run.codesign" value="true" overwrite="false" />

<!-- EXTERNAL TOOL OVERRIDES -->
<property name="path.separator" value="${string::trim(path::combine(' ', ' '))}" />
Expand Down
7 changes: 4 additions & 3 deletions src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ function script:chocoCmdOperations($commands, $command, $filter, $currentArgumen
where { $_ -like "$filter*" }
}

$script:someCommands = @('-?','search','list','install','outdated','upgrade','uninstall','new','pack','push','-h','--help','pin','source','config','feature','apikey')
$script:someCommands = @('-?','search','list','info','install','outdated','upgrade','uninstall','new','pack','push','-h','--help','pin','source','config','feature','apikey')

$allcommands = " --debug --verbose --force --noop --help --accept-license --confirm --limit-output --execution-timeout= --cache-location='' --fail-on-error-output --use-system-powershell"

$proInstallUpgradeOptions = " --skip-download-cache --use-download-cache --skip-virus-check --virus-check --virus-positives-minimum="

$commandOptions = @{
list = "--lo --pre --exact --by-id-only --id-starts-with --approved-only --not-broken --source='' --user= --password= --local-only --prerelease --include-programs --page= --page-size= --order-by-popularity --download-cache-only" + $allcommands
search = "--pre --exact --by-id-only --id-starts-with --approved-only --not-broken --source='' --user= --password= --local-only --prerelease --include-programs --page= --page-size= --order-by-popularity --download-cache-only" + $allcommands
list = "--lo --pre --exact --by-id-only --id-starts-with --detailed --approved-only --not-broken --source='' --user= --password= --local-only --prerelease --include-programs --page= --page-size= --order-by-popularity --download-cache-only" + $allcommands
search = "--pre --exact --by-id-only --id-starts-with --detailed --approved-only --not-broken --source='' --user= --password= --local-only --prerelease --include-programs --page= --page-size= --order-by-popularity --download-cache-only" + $allcommands
info = "--pre --lo --source='' --user= --password= --local-only --prerelease" + $allcommands
install = "-y -whatif -? --pre --version= --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --source='webpi' --user= --password= --prerelease --forcex86 --not-silent --package-parameters='' --allow-downgrade --force-dependencies --skip-automation-scripts --allow-multiple-versions --ignore-checksums" + $allcommands + $proInstallUpgradeOptions
pin = "--name= --version= -?" + $allcommands
outdated = "-? --source='' --user= --password=" + $allcommands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ param(
[alias("installerType")][string] $fileType = 'exe',
[string] $silentArgs = '',
[string] $file,
$validExitCodes = @(0)
$validExitCodes = @(0),
[switch] $onlyUsePackageSilentArgs
)
Write-Debug "Running 'Install-ChocolateyInstallPackage' for $packageName with file:`'$file`', args: `'$silentArgs`', fileType: `'$fileType`', validExitCodes: `'$validExitCodes`' ";
$installMessage = "Installing $packageName..."
Expand Down
2 changes: 2 additions & 0 deletions src/chocolatey.tests/chocolatey.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<Compile Include="infrastructure.app\commands\ChocolateyApiKeyCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyConfigCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyFeatureCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyInfoCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyInstallCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyListCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyNewCommandSpecs.cs" />
Expand All @@ -83,6 +84,7 @@
<Compile Include="infrastructure.app\services\FilesServiceSpecs.cs" />
<Compile Include="infrastructure.app\services\NugetServiceSpecs.cs" />
<Compile Include="infrastructure.app\services\RegistryServiceSpecs.cs" />
<Compile Include="infrastructure.app\services\TemplateServiceSpecs.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,215 @@
// Copyright © 2011 - Present RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace chocolatey.tests.infrastructure.app.commands
{
using System;
using System.Collections.Generic;
using System.Linq;
using chocolatey.infrastructure.app.attributes;
using chocolatey.infrastructure.app.commands;
using chocolatey.infrastructure.app.configuration;
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.commandline;
using Moq;
using Should;

public class ChocolateyInfoCommandSpecs
{
public abstract class ChocolateyInfoCommandSpecsBase : TinySpec
{
protected ChocolateyInfoCommand command;
protected Mock<IChocolateyPackageService> packageService = new Mock<IChocolateyPackageService>();
protected ChocolateyConfiguration configuration = new ChocolateyConfiguration();

public override void Context()
{
configuration.Sources = "bob";
command = new ChocolateyInfoCommand(packageService.Object);
}
}

public class when_implementing_command_for : ChocolateyInfoCommandSpecsBase
{
private List<string> results;

public override void Because()
{
results = command.GetType().GetCustomAttributes(typeof(CommandForAttribute), false).Cast<CommandForAttribute>().Select(a => a.CommandName).ToList();
}

[Fact]
public void should_implement_info()
{
results.ShouldContain("info");
}
}

public class when_configurating_the_argument_parser : ChocolateyInfoCommandSpecsBase
{
private OptionSet optionSet;

public override void Context()
{
base.Context();
optionSet = new OptionSet();
}

public override void Because()
{
command.configure_argument_parser(optionSet, configuration);
}

[Fact]
public void should_add_source_to_the_option_set()
{
optionSet.Contains("source").ShouldBeTrue();
}

[Fact]
public void should_add_short_version_of_source_to_the_option_set()
{
optionSet.Contains("s").ShouldBeTrue();
}

[Fact]
public void should_add_localonly_to_the_option_set()
{
optionSet.Contains("localonly").ShouldBeTrue();
}

[Fact]
public void should_add_short_version_of_localonly_to_the_option_set()
{
optionSet.Contains("l").ShouldBeTrue();
}

[Fact]
public void should_add_prerelease_to_the_option_set()
{
optionSet.Contains("prerelease").ShouldBeTrue();
}

[Fact]
public void should_add_short_version_of_prerelease_to_the_option_set()
{
optionSet.Contains("pre").ShouldBeTrue();
}

[Fact]
public void should_add_user_to_the_option_set()
{
optionSet.Contains("user").ShouldBeTrue();
}

[Fact]
public void should_add_short_version_of_user_to_the_option_set()
{
optionSet.Contains("u").ShouldBeTrue();
}

[Fact]
public void should_add_password_to_the_option_set()
{
optionSet.Contains("password").ShouldBeTrue();
}

[Fact]
public void should_add_short_version_of_password_to_the_option_set()
{
optionSet.Contains("p").ShouldBeTrue();
}
}

public class when_handling_additional_argument_parsing : ChocolateyInfoCommandSpecsBase
{
private readonly IList<string> unparsedArgs = new List<string>();
private string source = "https://somewhereoutthere";
private Action because;

public override void Context()
{
base.Context();
unparsedArgs.Add("pkg1");
unparsedArgs.Add("pkg2");
configuration.Sources = source;
}

public override void Because()
{
because = () => command.handle_additional_argument_parsing(unparsedArgs, configuration);
}

[Fact]
public void should_set_unparsed_arguments_to_configuration_input()
{
because();
configuration.Input.ShouldEqual("pkg1 pkg2");
}

[Fact]
public void should_leave_source_as_set()
{
configuration.ListCommand.LocalOnly = false;
because();
configuration.Sources.ShouldEqual(source);
}

[Fact]
public void should_set_exact_to_true()
{
configuration.ListCommand.Exact = false;
because();
configuration.ListCommand.Exact.ShouldBeTrue();
}

[Fact]
public void should_set_verbose_to_true()
{
configuration.Verbose = false;
because();
configuration.Verbose.ShouldBeTrue();
}
}

public class when_noop_is_called : ChocolateyInfoCommandSpecsBase
{
public override void Because()
{
command.noop(configuration);
}

[Fact]
public void should_call_service_list_noop()
{
packageService.Verify(c => c.list_noop(configuration), Times.Once);
}
}

public class when_run_is_called : ChocolateyInfoCommandSpecsBase
{
public override void Because()
{
command.run(configuration);
}

[Fact]
public void should_call_service_list_run()
{
packageService.Verify(c => c.list_run(configuration), Times.Once);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace chocolatey.tests.infrastructure.app.commands
using chocolatey.infrastructure.app.attributes;
using chocolatey.infrastructure.app.commands;
using chocolatey.infrastructure.app.configuration;
using chocolatey.infrastructure.app.domain;
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.app.templates;
using chocolatey.infrastructure.commandline;
Expand Down Expand Up @@ -102,6 +101,12 @@ public void should_add_maintainer_to_the_option_set()
{
optionSet.Contains("maintainer").ShouldBeTrue();
}

[Fact]
public void should_add_outputdirectory_to_the_option_set()
{
optionSet.Contains("outputdirectory").ShouldBeTrue();
}
}

public class when_handling_additional_argument_parsing : ChocolateyNewCommandSpecsBase
Expand Down Expand Up @@ -354,5 +359,59 @@ public void should_call_service_generate()
templateService.Verify(c => c.generate(configuration), Times.Once);
}
}

public class when_handling_arguments_parsing : ChocolateyNewCommandSpecsBase
{
private OptionSet optionSet;

public override void Context()
{
base.Context();
optionSet = new OptionSet();
command.configure_argument_parser(optionSet, configuration);
}

public override void Because()
{
optionSet.Parse(new[] { "--name", "Bob", "--automaticpackage", "--template-name", "custom", "--version", "0.42.0", "--maintainer" , "Loyd", "--outputdirectory", "c:\\packages" });
}

[Fact]
public void should_name_equal_to_Bob()
{
configuration.NewCommand.Name.ShouldEqual("Bob");
configuration.NewCommand.TemplateProperties[TemplateValues.NamePropertyName].ShouldEqual("Bob");
}

[Fact]
public void should_automaticpackage_equal_to_true()
{
configuration.NewCommand.AutomaticPackage.ShouldBeTrue();
}

[Fact]
public void should_templatename_equal_to_custom()
{
configuration.NewCommand.TemplateName.ShouldEqual("custom");
}

[Fact]
public void should_version_equal_to_42()
{
configuration.NewCommand.TemplateProperties[TemplateValues.VersionPropertyName].ShouldEqual("0.42.0");
}

[Fact]
public void should_maintainer_equal_to_Loyd()
{
configuration.NewCommand.TemplateProperties[TemplateValues.MaintainerPropertyName].ShouldEqual("Loyd");
}

[Fact]
public void should_outputdirectory_equal_packages()
{
configuration.OutputDirectory.ShouldEqual("c:\\packages");
}
}
}
}
Loading

0 comments on commit 8a436eb

Please sign in to comment.