Skip to content

Commit

Permalink
SqlRs: Adding checks for ReportServerReservedUrl and ReportsReservedU…
Browse files Browse the repository at this point in the history
…rl (#1870)

- SqlRS
  - Fixed issue of configuring reporting services (issue #1868).
  • Loading branch information
shurick81 authored Mar 19, 2023
1 parent 13400a6 commit 5efa82d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
installation where the database engine is not installed.
- `SqlRS`
- Test renamed to `When Reports virtual directory is different` so it is more correct and not a duplicate
- Fixed issue of configuring reporting services ([issue #1868](https://github.com/dsccommunity/SqlServerDsc/issues/1868)).

## [16.1.0] - 2023-02-28

Expand Down
52 changes: 37 additions & 15 deletions source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -953,26 +953,48 @@ function Test-TargetResource
$result = $false
}

$compareParameters = @{
ReferenceObject = $currentConfig.ReportServerReservedUrl
DifferenceObject = $ReportServerReservedUrl
}

if (($null -ne $ReportServerReservedUrl) -and ($null -ne (Compare-Object @compareParameters)))
if ($PSBoundParameters.ContainsKey('ReportServerReservedUrl'))
{
Write-Verbose -Message "Report server reserved URLs on $DatabaseServerName\$DatabaseInstanceName are $($currentConfig.ReportServerReservedUrl -join ', '), should be $($ReportServerReservedUrl -join ', ')."
$result = $false
}
if ($null -eq $currentConfig.ReportServerReservedUrl)
{
Write-Verbose -Message "Report server reserved URLs on $DatabaseServerName\$DatabaseInstanceName are missing, should be $($ReportServerReservedUrl -join ', ')."
$result = $false
}
else
{
$compareParameters = @{
ReferenceObject = $currentConfig.ReportServerReservedUrl
DifferenceObject = $ReportServerReservedUrl
}

$compareParameters = @{
ReferenceObject = $currentConfig.ReportsReservedUrl
DifferenceObject = $ReportsReservedUrl
if ($null -ne (Compare-Object @compareParameters))
{
Write-Verbose -Message "Report server reserved URLs on $DatabaseServerName\$DatabaseInstanceName are $($currentConfig.ReportServerReservedUrl -join ', '), should be $($ReportServerReservedUrl -join ', ')."
$result = $false
}
}
}

if (($null -ne $ReportsReservedUrl) -and ($null -ne (Compare-Object @compareParameters)))
if ($PSBoundParameters.ContainsKey('ReportsReservedUrl'))
{
Write-Verbose -Message "Reports reserved URLs on $DatabaseServerName\$DatabaseInstanceName are $($currentConfig.ReportsReservedUrl -join ', ')), should be $($ReportsReservedUrl -join ', ')."
$result = $false
if ($null -eq $currentConfig.ReportsReservedUrl)
{
Write-Verbose -Message "Reports reserved URLs on $DatabaseServerName\$DatabaseInstanceName are missing, should be $($ReportsReservedUrl -join ', ')."
$result = $false
}
else
{
$compareParameters = @{
ReferenceObject = $currentConfig.ReportsReservedUrl
DifferenceObject = $ReportsReservedUrl
}

if ($null -ne (Compare-Object @compareParameters))
{
Write-Verbose -Message "Reports reserved URLs on $DatabaseServerName\$DatabaseInstanceName are $($currentConfig.ReportsReservedUrl -join ', ')), should be $($ReportsReservedUrl -join ', ')."
$result = $false
}
}
}

if ($PSBoundParameters.ContainsKey('UseSsl') -and $UseSsl -ne $currentConfig.UseSsl)
Expand Down
56 changes: 56 additions & 0 deletions tests/Unit/DSC_SqlRS.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,62 @@ Describe 'SqlRS\Test-TargetResource' -Tag 'Test' {
}
}

Context 'When current Report Server reserved URL is $null' {
BeforeAll {
Mock -CommandName Get-TargetResource -MockWith {
return @{
IsInitialized = $false
ReportServerReservedUrl = $null
}
}
}

It 'Should return state as not in desired state' {
InModuleScope -ScriptBlock {
Set-StrictMode -Version 1.0

$testParameters = @{
InstanceName = 'INSTANCE'
DatabaseServerName = 'DBSERVER'
DatabaseInstanceName = 'DBINSTANCE'
ReportServerReservedUrl = 'ReportServer_SQL2016'
}

$resultTestTargetResource = Test-TargetResource @testParameters

$resultTestTargetResource | Should -BeFalse
}
}
}

Context 'When current Reports reserved URL is $null' {
BeforeAll {
Mock -CommandName Get-TargetResource -MockWith {
return @{
IsInitialized = $false
ReportsReservedUrl = $null
}
}
}

It 'Should return state as not in desired state' {
InModuleScope -ScriptBlock {
Set-StrictMode -Version 1.0

$testParameters = @{
InstanceName = 'INSTANCE'
DatabaseServerName = 'DBSERVER'
DatabaseInstanceName = 'DBINSTANCE'
ReportsReservedUrl = 'Reports_SQL2016'
}

$resultTestTargetResource = Test-TargetResource @testParameters

$resultTestTargetResource | Should -BeFalse
}
}
}

Context 'When Report Server virtual directory is different' {
BeforeAll {
Mock -CommandName Get-TargetResource -MockWith {
Expand Down

0 comments on commit 5efa82d

Please sign in to comment.