Skip to content
This repository was archived by the owner on Mar 11, 2020. It is now read-only.

Commit e82494c

Browse files
authored
Merge pull request #23 from kilasuit/master
Major update
2 parents d861e70 + 3f552e9 commit e82494c

File tree

93 files changed

+3309
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3309
-314
lines changed

Artifacts/IIS/Discover.ps1

Lines changed: 0 additions & 87 deletions
This file was deleted.

Artifacts/IIS/Generate.ps1

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
function Completion_Artifact {
3+
4+
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
5+
6+
Function Get-Artifacts {
7+
$artifacts = Get-ChildItem -Path $modulepath\Functions\Private\Artifacts -Directory | Select-Object -ExpandProperty BaseName
8+
$artifacts
9+
}
10+
11+
### Create fresh completion results for Artifacts
12+
Get-Artifacts | Where-Object { $PSItem -match $wordToComplete } | ForEach-Object {
13+
$CompletionText = $PSItem;
14+
$ToolTip = $PSItem;
15+
$ListItemText = $PSItem;
16+
$CompletionResultType = [System.Management.Automation.CompletionResultType]::ParameterValue;
17+
18+
New-Object -TypeName System.Management.Automation.CompletionResult -ArgumentList @($CompletionText, $ListItemText, $CompletionResultType, $ToolTip);
19+
}
20+
21+
}
22+
23+
Microsoft.PowerShell.Core\Register-ArgumentCompleter -CommandName ConvertTo-DockerFile -ParameterName Artifact -ScriptBlock $Function:Completion_Artifact
24+

Artifacts/AddRemovePrograms/Discover.ps1 renamed to Functions/Private/Artifacts/AddRemovePrograms/Discover_AddRemovePrograms.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Discover_AddRemovePrograms {
12
<#
23
.SYNOPSIS
34
Scans for Add/Remove Programs entries
@@ -8,6 +9,7 @@ The path where the Windows image was mounted to.
89
.PARAMETER OutputPath
910
The filesystem path where the discovery manifest will be emitted.
1011
#>
12+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess",'')]
1113
[CmdletBinding()]
1214
param (
1315
[Parameter(Mandatory = $true)]
@@ -64,3 +66,6 @@ Write-Verbose -Message 'Finished unmounting the registry hive'
6466
### Write out the discovery results to the manifest file
6567
$SoftwareList | ConvertTo-Json | Set-Content -Path $ManifestPath
6668
Write-Verbose -Message ('Finished discovery for {0} artifact' -f (Split-Path -Path $PSScriptRoot -Leaf))
69+
70+
}
71+

Artifacts/AddRemovePrograms/Generate.ps1 renamed to Functions/Private/Artifacts/AddRemovePrograms/Generate_AddRemovePrograms.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Generate_AddRemovePrograms {
12
<#
23
.SYNOPSIS
34
Generate Dockerfile contents for Add/Remove Programs entries
@@ -24,3 +25,6 @@ foreach ($Item in $Artifact) {
2425
}
2526

2627
Write-Output -InputObject $Result
28+
29+
}
30+

Functions/Private/Artifacts/AddRemovePrograms/Tests/Discover_AddRemovePrograms.Functional.Tests.ps1

Whitespace-only changes.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Describe 'Discover_AddRemovePrograms Tests' {
2+
3+
Context 'Parameters for Discover_AddRemovePrograms'{
4+
5+
It 'Has a Parameter called MountPath' {
6+
$Function.Parameters.Keys.Contains('MountPath') | Should Be 'True'
7+
}
8+
It 'MountPath Parameter is Identified as Mandatory being True' {
9+
[String]$Function.Parameters.MountPath.Attributes.Mandatory | Should be 'True'
10+
}
11+
It 'MountPath Parameter is of String Type' {
12+
$Function.Parameters.MountPath.ParameterType.FullName | Should be 'System.String'
13+
}
14+
It 'MountPath Parameter is member of ParameterSets' {
15+
[String]$Function.Parameters.MountPath.ParameterSets.Keys | Should Be '__AllParameterSets'
16+
}
17+
It 'MountPath Parameter Position is defined correctly' {
18+
[String]$Function.Parameters.MountPath.Attributes.Position | Should be '0'
19+
}
20+
It 'Does MountPath Parameter Accept Pipeline Input?' {
21+
[String]$Function.Parameters.MountPath.Attributes.ValueFromPipeline | Should be 'False'
22+
}
23+
It 'Does MountPath Parameter Accept Pipeline Input by PropertyName?' {
24+
[String]$Function.Parameters.MountPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
25+
}
26+
It 'Does MountPath Parameter use advanced parameter Validation? ' {
27+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
28+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
29+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
30+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
31+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
32+
}
33+
It 'Has Parameter Help Text for MountPath '{
34+
$function.Definition.Contains('.PARAMETER MountPath') | Should Be 'True'
35+
}
36+
It 'Has a Parameter called OutputPath' {
37+
$Function.Parameters.Keys.Contains('OutputPath') | Should Be 'True'
38+
}
39+
It 'OutputPath Parameter is Identified as Mandatory being True' {
40+
[String]$Function.Parameters.OutputPath.Attributes.Mandatory | Should be 'True'
41+
}
42+
It 'OutputPath Parameter is of String Type' {
43+
$Function.Parameters.OutputPath.ParameterType.FullName | Should be 'System.String'
44+
}
45+
It 'OutputPath Parameter is member of ParameterSets' {
46+
[String]$Function.Parameters.OutputPath.ParameterSets.Keys | Should Be '__AllParameterSets'
47+
}
48+
It 'OutputPath Parameter Position is defined correctly' {
49+
[String]$Function.Parameters.OutputPath.Attributes.Position | Should be '1'
50+
}
51+
It 'Does OutputPath Parameter Accept Pipeline Input?' {
52+
[String]$Function.Parameters.OutputPath.Attributes.ValueFromPipeline | Should be 'False'
53+
}
54+
It 'Does OutputPath Parameter Accept Pipeline Input by PropertyName?' {
55+
[String]$Function.Parameters.OutputPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
56+
}
57+
It 'Does OutputPath Parameter use advanced parameter Validation? ' {
58+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
59+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
60+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
61+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
62+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
63+
}
64+
It 'Has Parameter Help Text for OutputPath '{
65+
$function.Definition.Contains('.PARAMETER OutputPath') | Should Be 'True'
66+
}
67+
}
68+
Context "Function $($function.Name) - Help Section" {
69+
70+
It "Function $($function.Name) Has show-help comment block" {
71+
72+
$function.Definition.Contains('<#') | should be 'True'
73+
$function.Definition.Contains('#>') | should be 'True'
74+
}
75+
76+
It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" {
77+
78+
$function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True'
79+
80+
}
81+
82+
It "Function $($function.Name) Is an advanced function" {
83+
84+
$function.CmdletBinding | should be 'True'
85+
$function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True'
86+
}
87+
88+
}
89+
90+
}
91+
92+

Functions/Private/Artifacts/AddRemovePrograms/Tests/Generate_AddRemovePrograms.Functional.Tests.ps1

Whitespace-only changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Describe 'Generate_AddRemovePrograms Tests' {
2+
3+
Context 'Parameters for Generate_AddRemovePrograms'{
4+
5+
It 'Has a Parameter called ManifestPath' {
6+
$Function.Parameters.Keys.Contains('ManifestPath') | Should Be 'True'
7+
}
8+
It 'ManifestPath Parameter is Identified as Mandatory being True' {
9+
[String]$Function.Parameters.ManifestPath.Attributes.Mandatory | Should be 'True'
10+
}
11+
It 'ManifestPath Parameter is of String Type' {
12+
$Function.Parameters.ManifestPath.ParameterType.FullName | Should be 'System.String'
13+
}
14+
It 'ManifestPath Parameter is member of ParameterSets' {
15+
[String]$Function.Parameters.ManifestPath.ParameterSets.Keys | Should Be '__AllParameterSets'
16+
}
17+
It 'ManifestPath Parameter Position is defined correctly' {
18+
[String]$Function.Parameters.ManifestPath.Attributes.Position | Should be '0'
19+
}
20+
It 'Does ManifestPath Parameter Accept Pipeline Input?' {
21+
[String]$Function.Parameters.ManifestPath.Attributes.ValueFromPipeline | Should be 'False'
22+
}
23+
It 'Does ManifestPath Parameter Accept Pipeline Input by PropertyName?' {
24+
[String]$Function.Parameters.ManifestPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
25+
}
26+
It 'Does ManifestPath Parameter use advanced parameter Validation? ' {
27+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
28+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
29+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
30+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
31+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
32+
}
33+
It 'Has Parameter Help Text for ManifestPath '{
34+
$function.Definition.Contains('.PARAMETER ManifestPath') | Should Be 'True'
35+
}
36+
}
37+
Context "Function $($function.Name) - Help Section" {
38+
39+
It "Function $($function.Name) Has show-help comment block" {
40+
41+
$function.Definition.Contains('<#') | should be 'True'
42+
$function.Definition.Contains('#>') | should be 'True'
43+
}
44+
45+
It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" {
46+
47+
$function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True'
48+
49+
}
50+
51+
It "Function $($function.Name) Is an advanced function" {
52+
53+
$function.CmdletBinding | should be 'True'
54+
$function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True'
55+
}
56+
57+
}
58+
59+
}
60+
61+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NetFx4ServerFeatures;NetFx4;MicrosoftWindowsPowerShellRoot;MicrosoftWindowsPowerShell;ServerCore-FullServer;WCF-Services45;WCF-TCP-PortSharing45;User-Interfaces-Infra;Server-Gui-Mgmt;RSAT;WindowsServerBackupSnapin;Printing-Client;Printing-Client-Gui;Server-Gui-Shell;Internet-Explorer-Optional-amd64;KeyDistributionService-PSH-Cmdlets;TlsSessionTicketKey-PSH-Cmdlets;MicrosoftWindowsPowerShellV2;Server-Psh-Cmdlets;ServerCore-WOW64;ServerCore-EA-IME-WOW64;NetFx3ServerFeatures;FileAndStorage-Services;Storage-Services;Printing-XPSServices-Features;ServerCore-EA-IME;ServerCore-Drivers-General;Server-Drivers-General;Server-Drivers-Printers;SmbDirect;SMB1Protocol;MicrosoftWindowsPowerShellV3;MicrosoftWindowsPowerShellISE;DSC-Service;WindowsRemoteManagement;WindowsRemoteManagement-ServerOnly

0 commit comments

Comments
 (0)