Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style fixes and Adding xIisModule Unit tests #349

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Suppressing this rule because Write-Verbose is called in Helper functions
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSDSCUseVerboseMessageInDSCResource', '')]
param ()

# Load the Helper Module
Import-Module -Name "$PSScriptRoot\..\Helper.psm1"

Expand All @@ -13,14 +17,14 @@ data LocalizedData
'@
}

<#
.SYNOPSIS
This will return a hashtable of results
#>
function Get-TargetResource
{
<#
.SYNOPSIS
This will return a hashtable of results
#>

[OutputType([Hashtable])]
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[Parameter(Mandatory)]
Expand All @@ -43,6 +47,10 @@ function Get-TargetResource
}
}

<#
.SYNOPSIS
This will set the desired state
#>
function Set-TargetResource
{
<#
Expand All @@ -66,21 +74,21 @@ function Set-TargetResource
Write-Verbose($($LocalizedData.ChangedMessage) -f $SectionName, $OverrideMode)

Set-WebConfiguration -Location '' `
-Filter "/system.webServer/$SectionName" `
-PSPath 'machine/webroot/apphost' `
-Metadata 'overrideMode' `
-Value $OverrideMode
-Filter "/system.webServer/$SectionName" `
-PSPath 'machine/webroot/apphost' `
-Metadata 'overrideMode' `
-Value $OverrideMode
}

function Test-TargetResource
{
<#
.SYNOPSIS
<#
.SYNOPSIS
This tests the desired state. If the state is not correct it will return $false.
If the state is correct it will return $true
#>

#>
function Test-TargetResource
{
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseVerboseMessageInDSCResource", "")]
[CmdletBinding()]
[OutputType([System.Boolean])]
param
(
Expand All @@ -105,15 +113,19 @@ function Test-TargetResource
}

#region Helper functions

<#
.SYNOPSIS
Checks for a single value.
.NOTES
If $oMode is anything but Allow or Deny, we have a problem with our
Get-WebConfiguration call or the ApplicationHost.config file is corrupted.
#>
function Get-OverrideMode
{
<#
.NOTES
Check for a single value.
If $oMode is anything but Allow or Deny, we have a problem with our
Get-WebConfiguration call or the ApplicationHost.config file is corrupted.
#>

[CmdletBinding()]
[OutputType([PSObject])]
param
(
[String] $Section
Expand Down
38 changes: 20 additions & 18 deletions DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.psm1
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Suppressing this rule because Write-Verbose is called in Helper functions
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSDSCUseVerboseMessageInDSCResource', '')]
param ()

# Load the Helper Module
Import-Module -Name "$PSScriptRoot\..\Helper.psm1"

Expand All @@ -13,13 +17,12 @@ data LocalizedData
'@
}

<#
.SYNOPSIS
This will return a hashtable of results
#>
function Get-TargetResource
{
<#
.SYNOPSIS
This will return a hashtable of results
#>

[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
Expand All @@ -40,13 +43,12 @@ function Get-TargetResource
}
}

<#
.SYNOPSIS
This will set the desired state
#>
function Set-TargetResource
{
<#
.SYNOPSIS
This will set the desired state
#>

[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseVerboseMessageInDSCResource", "")]
param
Expand All @@ -73,14 +75,13 @@ function Set-TargetResource
Set-Value -Path 'processModel' -Name 'identityType' -NewValue $IdentityType
}

function Test-TargetResource
{
<#
<#
.SYNOPSIS
This tests the desired state. If the state is not correct it will return $false.
If the state is correct it will return $true
#>

#>
function Test-TargetResource
{
[CmdletBinding()]
[OutputType([System.Boolean])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseVerboseMessageInDSCResource", "")]
Expand Down Expand Up @@ -143,7 +144,7 @@ function Confirm-Value
$NewValue
)

if (-not($NewValue))
if (-not $NewValue)
{
# if no new value was specified, we assume this value is okay.
return $true
Expand All @@ -157,7 +158,7 @@ function Confirm-Value
else
{
$relPath = $Path + '/' + $Name
Write-Verbose($LocalizedData.ValueOk -f $relPath,$NewValue);
Write-Verbose($LocalizedData.ValueOk -f $relPath, $NewValue);
return $true
}
}
Expand All @@ -182,7 +183,7 @@ function Set-Value
)

# if the variable doesn't exist, the user doesn't want to change this value
if (-not($NewValue))
if (-not $NewValue)
{
return
}
Expand All @@ -209,6 +210,7 @@ function Set-Value
function Get-Value
{
[CmdletBinding()]
[OutputType([PSObject])]
param
(
[Parameter(Mandatory = $true)]
Expand Down
4 changes: 4 additions & 0 deletions DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.psm1
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Suppressing this rule because Write-Verbose is called in Helper functions
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSDSCUseVerboseMessageInDSCResource', '')]
param ()

# Load the Helper Module
Import-Module -Name "$PSScriptRoot\..\Helper.psm1"

Expand Down
Loading