Skip to content

Commit 7638ef9

Browse files
randomnote1johlju
authored andcommitted
Revert "Do not enforce reserved URLs when not supplied."
This reverts commit f2d7347.
1 parent ceb9a9b commit 7638ef9

File tree

3 files changed

+110
-115
lines changed

3 files changed

+110
-115
lines changed

source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1

Lines changed: 95 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ function Get-TargetResource
254254
Report Manager/Report Web App virtual directory name. Optional.
255255
256256
.PARAMETER ReportServerReservedUrl
257-
Report Server URL reservations. Optional.
257+
Report Server URL reservations. Optional. If not specified,
258+
'http://+:80' URL reservation will be used.
258259
259260
.PARAMETER ReportsReservedUrl
260-
Report Manager/Report Web App URL reservations.
261+
Report Manager/Report Web App URL reservations. Optional.
262+
If not specified, 'http://+:80' URL reservation will be used.
261263
262264
.PARAMETER HttpsCertificateThumbprint
263265
The thumbprint of the certificate used to secure SSL communication.
@@ -384,11 +386,11 @@ function Set-TargetResource
384386

385387
[Parameter()]
386388
[System.String[]]
387-
$ReportServerReservedUrl,
389+
$ReportServerReservedUrl = @('http://+:80'),
388390

389391
[Parameter()]
390392
[System.String[]]
391-
$ReportsReservedUrl,
393+
$ReportsReservedUrl = @('http://+:80'),
392394

393395
[Parameter()]
394396
[System.String]
@@ -848,103 +850,97 @@ function Set-TargetResource
848850
#endregion Virtual Directories
849851

850852
#region Reserved URLs
851-
if ( $PSBoundParameters.ContainsKey('EncryptionKeyBackupPath') )
852-
{
853-
$compareParameters = @{
854-
ReferenceObject = $currentConfig.ReportServerReservedUrl
855-
DifferenceObject = $ReportServerReservedUrl
856-
}
853+
$compareParameters = @{
854+
ReferenceObject = $currentConfig.ReportServerReservedUrl
855+
DifferenceObject = $ReportServerReservedUrl
856+
}
857857

858-
if ( ($null -ne $ReportServerReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) )
859-
{
860-
$restartReportingService = $true
858+
if ( ($null -ne $ReportServerReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) )
859+
{
860+
$restartReportingService = $true
861861

862-
$currentConfig.ReportServerReservedUrl | ForEach-Object -Process {
863-
$invokeRsCimMethodParameters = @{
864-
CimInstance = $reportingServicesData.Configuration
865-
MethodName = 'RemoveURL'
866-
Arguments = @{
867-
Application = 'ReportServerWebService'
868-
UrlString = $_
869-
Lcid = $language
870-
}
862+
$currentConfig.ReportServerReservedUrl | ForEach-Object -Process {
863+
$invokeRsCimMethodParameters = @{
864+
CimInstance = $reportingServicesData.Configuration
865+
MethodName = 'RemoveURL'
866+
Arguments = @{
867+
Application = 'ReportServerWebService'
868+
UrlString = $_
869+
Lcid = $language
871870
}
872-
873-
Invoke-RsCimMethod @invokeRsCimMethodParameters
874871
}
875872

876-
$ReportServerReservedUrl | ForEach-Object -Process {
877-
Write-Verbose -Message "Adding report server URL reservation on $DatabaseServerName\$DatabaseInstanceName`: $_."
878-
$invokeRsCimMethodParameters = @{
879-
CimInstance = $reportingServicesData.Configuration
880-
MethodName = 'ReserveUrl'
881-
Arguments = @{
882-
Application = 'ReportServerWebService'
883-
UrlString = $_
884-
Lcid = $language
885-
}
886-
}
873+
Invoke-RsCimMethod @invokeRsCimMethodParameters
874+
}
887875

888-
Invoke-RsCimMethod @invokeRsCimMethodParameters
876+
$ReportServerReservedUrl | ForEach-Object -Process {
877+
Write-Verbose -Message "Adding report server URL reservation on $DatabaseServerName\$DatabaseInstanceName`: $_."
878+
$invokeRsCimMethodParameters = @{
879+
CimInstance = $reportingServicesData.Configuration
880+
MethodName = 'ReserveUrl'
881+
Arguments = @{
882+
Application = 'ReportServerWebService'
883+
UrlString = $_
884+
Lcid = $language
885+
}
889886
}
890887

891-
# Get the current configuration
892-
$currentConfig = Get-TargetResource @getTargetResourceParameters
893-
Write-Verbose -Message ( $script:localizedData.ReportingServicesIsInitialized -f $DatabaseServerName, $DatabaseInstanceName, $currentConfig.IsInitialized ) -Verbose
888+
Invoke-RsCimMethod @invokeRsCimMethodParameters
894889
}
890+
891+
# Get the current configuration
892+
$currentConfig = Get-TargetResource @getTargetResourceParameters
893+
Write-Verbose -Message ( $script:localizedData.ReportingServicesIsInitialized -f $DatabaseServerName, $DatabaseInstanceName, $currentConfig.IsInitialized ) -Verbose
895894
}
896895

897-
if ( $PSBoundParameters.ContainsKey('ReportsReservedUrl') )
898-
{
899-
$compareParameters = @{
900-
ReferenceObject = $currentConfig.ReportsReservedUrl
901-
DifferenceObject = $ReportsReservedUrl
902-
}
896+
$compareParameters = @{
897+
ReferenceObject = $currentConfig.ReportsReservedUrl
898+
DifferenceObject = $ReportsReservedUrl
899+
}
903900

904-
if ( ($null -ne $ReportsReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) )
905-
{
906-
$restartReportingService = $true
901+
if ( ($null -ne $ReportsReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) )
902+
{
903+
$restartReportingService = $true
907904

908-
$currentConfig.ReportsReservedUrl | ForEach-Object -Process {
909-
$invokeRsCimMethodParameters = @{
910-
CimInstance = $reportingServicesData.Configuration
911-
MethodName = 'RemoveURL'
912-
Arguments = @{
913-
Application = $reportingServicesData.ReportsApplicationName
914-
UrlString = $_
915-
Lcid = $language
916-
}
905+
$currentConfig.ReportsReservedUrl | ForEach-Object -Process {
906+
$invokeRsCimMethodParameters = @{
907+
CimInstance = $reportingServicesData.Configuration
908+
MethodName = 'RemoveURL'
909+
Arguments = @{
910+
Application = $reportingServicesData.ReportsApplicationName
911+
UrlString = $_
912+
Lcid = $language
917913
}
918-
919-
Invoke-RsCimMethod @invokeRsCimMethodParameters
920914
}
921915

922-
$ReportsReservedUrl | ForEach-Object -Process {
923-
Write-Verbose -Message (
924-
$script:localizedData.AddReportsUrlReservation -f @(
925-
$DatabaseServerName
926-
$DatabaseInstanceName
927-
$_
928-
)
916+
Invoke-RsCimMethod @invokeRsCimMethodParameters
917+
}
918+
919+
$ReportsReservedUrl | ForEach-Object -Process {
920+
Write-Verbose -Message (
921+
$script:localizedData.AddReportsUrlReservation -f @(
922+
$DatabaseServerName
923+
$DatabaseInstanceName
924+
$_
929925
)
926+
)
930927

931-
$invokeRsCimMethodParameters = @{
932-
CimInstance = $reportingServicesData.Configuration
933-
MethodName = 'ReserveUrl'
934-
Arguments = @{
935-
Application = $reportingServicesData.ReportsApplicationName
936-
UrlString = $_
937-
Lcid = $language
938-
}
928+
$invokeRsCimMethodParameters = @{
929+
CimInstance = $reportingServicesData.Configuration
930+
MethodName = 'ReserveUrl'
931+
Arguments = @{
932+
Application = $reportingServicesData.ReportsApplicationName
933+
UrlString = $_
934+
Lcid = $language
939935
}
940-
941-
Invoke-RsCimMethod @invokeRsCimMethodParameters
942936
}
943937

944-
# Get the current configuration
945-
$currentConfig = Get-TargetResource @getTargetResourceParameters
946-
Write-Verbose -Message ( $script:localizedData.ReportingServicesIsInitialized -f $DatabaseServerName, $DatabaseInstanceName, $currentConfig.IsInitialized ) -Verbose
938+
Invoke-RsCimMethod @invokeRsCimMethodParameters
947939
}
940+
941+
# Get the current configuration
942+
$currentConfig = Get-TargetResource @getTargetResourceParameters
943+
Write-Verbose -Message ( $script:localizedData.ReportingServicesIsInitialized -f $DatabaseServerName, $DatabaseInstanceName, $currentConfig.IsInitialized ) -Verbose
948944
}
949945
#endregion Reserved URLs
950946

@@ -1254,10 +1250,12 @@ function Set-TargetResource
12541250
Report Manager/Report Web App virtual directory name. Optional.
12551251
12561252
.PARAMETER ReportServerReservedUrl
1257-
Report Server URL reservations. Optional.
1253+
Report Server URL reservations. Optional. If not specified,
1254+
'http://+:80' URL reservation will be used.
12581255
12591256
.PARAMETER ReportsReservedUrl
12601257
Report Manager/Report Web App URL reservations. Optional.
1258+
If not specified, 'http://+:80' URL reservation will be used.
12611259
12621260
.PARAMETER HttpsCertificateThumbprint
12631261
The thumbprint of the certificate used to secure SSL communication.
@@ -1348,11 +1346,11 @@ function Test-TargetResource
13481346

13491347
[Parameter()]
13501348
[System.String[]]
1351-
$ReportServerReservedUrl,
1349+
$ReportServerReservedUrl = @('http://+:80'),
13521350

13531351
[Parameter()]
13541352
[System.String[]]
1355-
$ReportsReservedUrl,
1353+
$ReportsReservedUrl = @('http://+:80'),
13561354

13571355
[Parameter()]
13581356
[System.String]
@@ -1528,30 +1526,27 @@ function Test-TargetResource
15281526
}
15291527
}
15301528

1531-
if ( $PSBoundParameters.ContainsKey('ReportsReservedUrl') )
1529+
if ( $null -eq $currentConfig.ReportsReservedUrl )
1530+
{
1531+
Write-Verbose -Message (
1532+
$script:localizedData.ReportsReservedUrlNotInDesiredState -f $DatabaseServerName, $DatabaseInstanceName, '', ( $ReportsReservedUrl -join ', ' )
1533+
) -Verbose
1534+
$result = $false
1535+
}
1536+
else
15321537
{
1533-
if ( $null -eq $currentConfig.ReportsReservedUrl )
1538+
$compareParameters = @{
1539+
ReferenceObject = $currentConfig.ReportsReservedUrl
1540+
DifferenceObject = $ReportsReservedUrl
1541+
}
1542+
1543+
if ( $null -ne ( Compare-Object @compareParameters ) )
15341544
{
15351545
Write-Verbose -Message (
1536-
$script:localizedData.ReportsReservedUrlNotInDesiredState -f $DatabaseServerName, $DatabaseInstanceName, '', ( $ReportsReservedUrl -join ', ' )
1546+
$script:localizedData.ReportsReservedUrlNotInDesiredState -f $DatabaseServerName, $DatabaseInstanceName, ( $currentConfig.ReportsReservedUrl -join ', ' ), ( $ReportsReservedUrl -join ', ' )
15371547
) -Verbose
15381548
$result = $false
15391549
}
1540-
else
1541-
{
1542-
$compareParameters = @{
1543-
ReferenceObject = $currentConfig.ReportsReservedUrl
1544-
DifferenceObject = $ReportsReservedUrl
1545-
}
1546-
1547-
if ( $null -ne ( Compare-Object @compareParameters ) )
1548-
{
1549-
Write-Verbose -Message (
1550-
$script:localizedData.ReportsReservedUrlNotInDesiredState -f $DatabaseServerName, $DatabaseInstanceName, ( $currentConfig.ReportsReservedUrl -join ', ' ), ( $ReportsReservedUrl -join ', ' )
1551-
) -Verbose
1552-
$result = $false
1553-
}
1554-
}
15551550
}
15561551

15571552
if ($PSBoundParameters.ContainsKey('UseSsl') -and $UseSsl -ne $currentConfig.UseSsl)

source/DSCResources/DSC_SqlRS/DSC_SqlRS.schema.mof

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class DSC_SqlRS : OMI_BaseResource
99
[Write, EmbeddedInstance("MSFT_Credential"), Description("The service account that should be used when running the _Windows_ service.")] String ServiceAccount;
1010
[Write, Description("_Report Server Web Service_ virtual directory. Optional.")] String ReportServerVirtualDirectory;
1111
[Write, Description("_Report Manager_ or _Report Web App_ virtual directory name. Optional.")] String ReportsVirtualDirectory;
12-
[Write, Description("_Report Server_ URL reservations. Optional.")] String ReportServerReservedUrl[];
13-
[Write, Description("_Report Manager_ or _Report Web App_ URL reservations. Optional.")] String ReportsReservedUrl[];
12+
[Write, Description("_Report Server_ URL reservations. Optional. If not specified, `'http://+:80'` URL reservation will be used.")] String ReportServerReservedUrl[];
13+
[Write, Description("_Report Manager_ or _Report Web App_ URL reservations. Optional. If not specified, `'http://+:80'` URL reservation will be used.")] String ReportsReservedUrl[];
1414
[Write, Description("The thumbprint of the certificate used to secure SSL communication.")] String HttpsCertificateThumbprint;
1515
[Write, Description("The IP address to bind the certificate specified in the _CertificateThumbprint_ parameter to. Default is `0.0.0.0` which binds to all IP addresses.")] String HttpsIPAddress;
1616
[Write, Description("The port used for SSL communication. Default is `443`.")] SInt32 HttpsPort;

tests/Unit/DSC_SqlRS.Tests.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -881,15 +881,15 @@ Describe 'SqlRS\Set-TargetResource' -Tag 'Set' {
881881

882882
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
883883
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportServerApplicationName
884-
} -Exactly -Times 0 -Scope It
884+
} -Exactly -Times 1 -Scope It
885885

886886
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
887887
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportsApplicationName
888-
} -Exactly -Times 0 -Scope It
888+
} -Exactly -Times 1 -Scope It
889889

890890
Should -Invoke -CommandName Get-CimInstance -ParameterFilter {
891891
$ClassName -eq 'Win32_OperatingSystem'
892-
} -Exactly -Times 8 -Scope It
892+
} -Exactly -Times 10 -Scope It
893893

894894
Should -Invoke -CommandName Invoke-SqlCmd -Exactly -Times 2 -Scope It
895895
Should -Invoke -CommandName Restart-ReportingServicesService -Exactly -Times 2 -Scope It
@@ -1211,7 +1211,7 @@ Describe 'SqlRS\Set-TargetResource' -Tag 'Set' {
12111211

12121212
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
12131213
$MethodName -eq 'RemoveURL' -and $Arguments.Application -eq $mockReportServerApplicationName
1214-
} -Exactly -Times 1 -Scope It
1214+
} -Exactly -Times 2 -Scope It
12151215

12161216
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
12171217
$MethodName -eq 'RemoveURL' -and $Arguments.Application -eq $mockReportsApplicationName
@@ -1252,7 +1252,7 @@ Describe 'SqlRS\Set-TargetResource' -Tag 'Set' {
12521252

12531253
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
12541254
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportServerApplicationName
1255-
} -Exactly -Times 0 -Scope It
1255+
} -Exactly -Times 1 -Scope It
12561256

12571257
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
12581258
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportsApplicationName
@@ -1349,13 +1349,13 @@ Describe 'SqlRS\Set-TargetResource' -Tag 'Set' {
13491349

13501350
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
13511351
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportServerApplicationName
1352-
} -Exactly -Times 0 -Scope It
1352+
} -Exactly -Times 1 -Scope It
13531353

13541354
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
13551355
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportsApplicationNameLegacy
1356-
} -Exactly -Times 0 -Scope It
1356+
} -Exactly -Times 1 -Scope It
13571357

1358-
Should -Invoke -CommandName Get-CimInstance -Exactly -Times 8 -Scope It
1358+
Should -Invoke -CommandName Get-CimInstance -Exactly -Times 10 -Scope It
13591359
Should -Invoke -CommandName Invoke-SqlCmd -Exactly -Times 2 -Scope It
13601360
Should -Invoke -CommandName Restart-ReportingServicesService -Exactly -Times 2 -Scope It
13611361

@@ -1433,13 +1433,13 @@ Describe 'SqlRS\Set-TargetResource' -Tag 'Set' {
14331433

14341434
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
14351435
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportServerApplicationName
1436-
} -Exactly -Times 0 -Scope It
1436+
} -Exactly -Times 1 -Scope It
14371437

14381438
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
14391439
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportsApplicationName
1440-
} -Exactly -Times 0 -Scope It
1440+
} -Exactly -Times 1 -Scope It
14411441

1442-
Should -Invoke -CommandName Get-CimInstance -Exactly -Times 8 -Scope It
1442+
Should -Invoke -CommandName Get-CimInstance -Exactly -Times 10 -Scope It
14431443
Should -Invoke -CommandName Invoke-Sqlcmd -Exactly -Times 2 -Scope It
14441444
Should -Invoke -CommandName Restart-ReportingServicesService -Exactly -Times 2 -Scope It
14451445
}
@@ -1503,7 +1503,7 @@ Describe 'SqlRS\Set-TargetResource' -Tag 'Set' {
15031503

15041504
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
15051505
$MethodName -eq 'RemoveURL' -and $Arguments.Application -eq $mockReportServerApplicationName
1506-
} -Exactly -Times 1 -Scope It
1506+
} -Exactly -Times 2 -Scope It
15071507

15081508
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
15091509
$MethodName -eq 'RemoveURL' -and $Arguments.Application -eq $mockReportsApplicationName
@@ -1535,7 +1535,7 @@ Describe 'SqlRS\Set-TargetResource' -Tag 'Set' {
15351535

15361536
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
15371537
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportServerApplicationName
1538-
} -Exactly -Times 0 -Scope It
1538+
} -Exactly -Times 1 -Scope It
15391539

15401540
Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
15411541
$MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportsApplicationName

0 commit comments

Comments
 (0)