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

Change languages to String array type in UpdateServicesServer Get-TargetResource return value #77

Open
wants to merge 3 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Changed default timeout in Wait-Win32ProcessStart function for cab installation.
- Updated pester test to support pester v5
- Updated ReadMe.md to removed `RunRuleNow` parameter.
- Updated data type for `$languages` returned by `GetEnabledUpdateLanguages()` in
`Get-TargetResource` function in `MSFT_UpdateServicesServer.psm1`

### Added

Expand All @@ -34,6 +36,8 @@ multiple products dor the same `Title`.
- Fix issue [#63](https://github.com/dsccommunity/UpdateServicesDsc/issues/63),
Fixed verbose output of WSUS server in UpdateServicesApprovalRule
- Fixed the `azure-pipelines.yml` to trigger on main not master.
- Fix issue [#76](https://github.com/dsccommunity/UpdateServicesDsc/issues/76),
Incorrect Type for Language in return value for Get-TargetResource

## [1.2.0] - 2020-05-18

Expand Down
27 changes: 27 additions & 0 deletions Tests/Helpers/ImitateUpdateServicesModule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,30 @@ function Get-WsusClassification
}

function Get-WsusProduct {}

function Get-WsusServerWithAllUpdateLanguagesDisabled
{

$wsusServer = Get-WsusServerTemplate

$WsusServer | Add-Member -Force -MemberType ScriptMethod -Name GetConfiguration -Value {
$Configuration = @{
ProxyName = ''
ProxyServerPort = $null
ProxyServerBasicAuthentication = $false
UpstreamWsusServerName = ''
UpstreamWsusServerPortNumber = $null
UpStreamServerSSL = $false
MURollupOptin = $true
AllUpdateLanguagesEnabled = $false
}
$Configuration | Add-Member -MemberType ScriptMethod -Name GetEnabledUpdateLanguages -Value {
$language = @('en','fr')
return $language
}

return $Configuration
}

return $wsusServer
}
17 changes: 17 additions & 0 deletions Tests/Unit/MSFT_UpdateServicesServer.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ try
}
}
}

Context 'All update languages enabled' {
It 'should contain wildcard' {
$script:result.Languages | Should -Be *
}
}

Context 'All update languages not enabled' {
BeforeEach {
Mock Get-WsusServer -MockWith { return $(Get-WsusServerWithAllUpdateLanguagesDisabled) }
$script:result = Get-TargetResource -Ensure 'Present' -verbose
}

It 'should contain only selected languages' {
$script:result.Languages | Should -Be @('en','fr')
}
}
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ function Get-TargetResource
}
else
{
$Languages = ($WsusConfiguration.GetEnabledUpdateLanguages()) -join ','
$Languages = [String[]]$WsusConfiguration.GetEnabledUpdateLanguages()
}

Write-Verbose -Message ($script:localizedData.WsusLanguages -f $Languages)
Write-Verbose -Message ($script:localizedData.WsusLanguages -f ($Languages -join ','))
Write-Verbose -Message $script:localizedData.GettingWsusClassifications
if ($Classifications = @($WsusSubscription.GetUpdateClassifications().ID.Guid))
{
Expand Down