-
Notifications
You must be signed in to change notification settings - Fork 227
Improve integration tests for RS Service Account #2404
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
Merged
johlju
merged 11 commits into
dsccommunity:main
from
johlju:f/improve-rs-service-account
Jan 10, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2e2473a
Improve integration tests for RS Service Account
johlju a1b92c1
Add integration test for database connection in Reporting Services
johlju 59b13a7
Add note for comprehensive Reporting Services log files information
johlju 11d12ef
Add SQL Server 2017 tag to Post.ServiceAccountChange.RS integration t…
johlju 5594da0
Add integration and unit tests for SQL Server Reporting Services DSC …
johlju 048038d
Remove redundant type checks for ReportServerUri in Get-SqlDscRSUrl i…
johlju 410a2a6
Fix parameter name in documentation for Get-SqlDscRSConfigFile and re…
johlju b7a2f81
Use -Raw parameter in Get-Content for improved performance in Get-Sql…
johlju 4fac04d
Add -Force parameter to Get-Content in Get-SqlDscRSConfigFile for imp…
johlju c8044c0
Add note for detailed trace log configuration in Troubleshooting Repo…
johlju 9d3410d
Update test description for Get-SqlDscRSConfigFile to clarify piped S…
johlju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Represents a Reporting Services URL returned by the GetReportServerUrls | ||
| CIM method. | ||
|
|
||
| .DESCRIPTION | ||
| This class represents a URL for a Reporting Services application, including | ||
| the instance name, application name (such as ReportServerWebService or | ||
| ReportServerWebApp), and the URL itself. | ||
|
|
||
| .PARAMETER InstanceName | ||
| The name of the Reporting Services instance. | ||
|
|
||
| .PARAMETER ApplicationName | ||
| The name of the Reporting Services application. Common values include: | ||
| - ReportServerWebService | ||
| - ReportServerWebApp | ||
| - ReportManager (for older versions) | ||
|
|
||
| .PARAMETER Uri | ||
| The URL for accessing the Reporting Services application. | ||
|
|
||
| .EXAMPLE | ||
| [ReportServerUri]::new() | ||
|
|
||
| Creates a new empty ReportServerUri instance. | ||
|
|
||
| .EXAMPLE | ||
| $uri = [ReportServerUri]::new() | ||
| $uri.InstanceName = 'SSRS' | ||
| $uri.ApplicationName = 'ReportServerWebService' | ||
| $uri.Uri = 'http://localhost:80/ReportServer' | ||
|
|
||
| Creates a new ReportServerUri instance with property values. | ||
| #> | ||
| class ReportServerUri | ||
| { | ||
| [System.String] | ||
| $InstanceName | ||
|
|
||
| [System.String] | ||
| $ApplicationName | ||
|
|
||
| [System.String] | ||
| $Uri | ||
|
|
||
| ReportServerUri() | ||
| { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,209 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Gets the RsReportServer.config configuration file as an XML object. | ||
|
|
||
| .DESCRIPTION | ||
| Gets the RsReportServer.config configuration file for SQL Server | ||
| Reporting Services (SSRS) or Power BI Report Server (PBIRS) as an | ||
| XML document object. This allows programmatic access to configuration | ||
| settings using standard XML navigation or XPath queries. | ||
|
|
||
| The configuration file path is automatically determined from the | ||
| instance's setup configuration in the registry when using the | ||
| `InstanceName` or `SetupConfiguration` parameter. Alternatively, a direct | ||
| file path can be specified using the `Path` parameter. | ||
|
|
||
| .PARAMETER InstanceName | ||
| Specifies the name of the Reporting Services instance. This is typically | ||
| 'SSRS' for SQL Server Reporting Services or 'PBIRS' for Power BI Report | ||
| Server. This parameter is mandatory when not passing a configuration object | ||
| or a direct path. | ||
|
|
||
| .PARAMETER SetupConfiguration | ||
| Specifies the configuration object from `Get-SqlDscRSSetupConfiguration`. | ||
| This can be piped from `Get-SqlDscRSSetupConfiguration`. The object must | ||
| have a `ConfigFilePath` property containing the path to the configuration | ||
| file. This parameter accepts pipeline input. | ||
|
|
||
| .PARAMETER Path | ||
| Specifies the direct path to the RsReportServer.config file. Use this | ||
| parameter to read configuration files from non-standard locations or | ||
| backup copies. | ||
|
|
||
| .EXAMPLE | ||
| Get-SqlDscRSConfigFile -InstanceName 'SSRS' | ||
|
|
||
| Returns the rsreportserver.config file content as an XML object for | ||
| the SSRS instance. | ||
|
|
||
| .EXAMPLE | ||
| Get-SqlDscRSConfigFile -InstanceName 'PBIRS' | ||
|
|
||
| Returns the rsreportserver.config file content as an XML object for | ||
| the Power BI Report Server instance. | ||
|
|
||
| .EXAMPLE | ||
| Get-SqlDscRSSetupConfiguration -InstanceName 'SSRS' | Get-SqlDscRSConfigFile | ||
|
|
||
| Gets the setup configuration for SSRS and pipes it to Get-SqlDscRSConfigFile | ||
| to retrieve the configuration file as XML. | ||
|
|
||
| .EXAMPLE | ||
| Get-SqlDscRSConfigFile -Path 'C:\Backup\rsreportserver.config' | ||
|
|
||
| Reads the configuration file from the specified path. | ||
|
|
||
| .EXAMPLE | ||
| $config = Get-SqlDscRSConfigFile -InstanceName 'SSRS' | ||
| $config.Configuration.Service.IsSchedulingService | ||
|
|
||
| Gets the config file and accesses the scheduling service setting directly | ||
| using dot notation. | ||
|
|
||
| .EXAMPLE | ||
| $config = Get-SqlDscRSConfigFile -InstanceName 'SSRS' | ||
| $config.SelectSingleNode('//Authentication/AuthenticationTypes') | ||
|
|
||
| Uses XPath to query the authentication types configuration section. | ||
|
|
||
| .EXAMPLE | ||
| $config = Get-SqlDscRSConfigFile -InstanceName 'SSRS' | ||
| $config.SelectNodes('//Extension[@Name]') | ForEach-Object { $_.Name } | ||
|
|
||
| Uses XPath to list all extension names defined in the configuration. | ||
|
|
||
| .EXAMPLE | ||
| $config = Get-SqlDscRSConfigFile -InstanceName 'SSRS' | ||
| $config.Configuration.URLReservations.Application | | ||
| Where-Object { $_.Name -eq 'ReportServerWebService' } | | ||
| Select-Object -ExpandProperty URLs | ||
|
|
||
| Gets the URL reservations for the Report Server Web Service application. | ||
|
|
||
| .EXAMPLE | ||
| $config = Get-SqlDscRSConfigFile -InstanceName 'SSRS' | ||
| $smtpServer = $config.SelectSingleNode('//RSEmailDPConfiguration/SMTPServer') | ||
| if ($smtpServer) { $smtpServer.InnerText } | ||
|
|
||
| Uses XPath to retrieve the SMTP server configuration for email delivery. | ||
|
|
||
| .INPUTS | ||
| `System.Object` | ||
|
|
||
| Accepts the setup configuration object from `Get-SqlDscRSSetupConfiguration` via | ||
| pipeline. | ||
|
|
||
| .OUTPUTS | ||
| `System.Xml.XmlDocument` | ||
|
|
||
| Returns the configuration file content as an XML document object. | ||
|
|
||
| .NOTES | ||
| For more information about the RsReportServer.config configuration file, | ||
| see the Microsoft documentation: | ||
| https://learn.microsoft.com/en-us/sql/reporting-services/report-server/rsreportserver-config-configuration-file | ||
| #> | ||
| function Get-SqlDscRSConfigFile | ||
| { | ||
| [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the examples use pipeline input and XPath the rule cannot validate.')] | ||
| [CmdletBinding(DefaultParameterSetName = 'ByInstanceName')] | ||
| [OutputType([System.Xml.XmlDocument])] | ||
| param | ||
| ( | ||
| [Parameter(Mandatory = $true, ParameterSetName = 'ByInstanceName')] | ||
| [System.String] | ||
| $InstanceName, | ||
|
|
||
| [Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'ByConfiguration')] | ||
| [System.Object] | ||
| $SetupConfiguration, | ||
|
|
||
| [Parameter(Mandatory = $true, ParameterSetName = 'ByPath')] | ||
| [System.String] | ||
| $Path | ||
| ) | ||
|
|
||
| process | ||
| { | ||
| $configFilePath = $null | ||
|
|
||
| switch ($PSCmdlet.ParameterSetName) | ||
| { | ||
| 'ByInstanceName' | ||
| { | ||
| Write-Verbose -Message ($script:localizedData.Get_SqlDscRSConfigFile_GettingConfigFile -f $InstanceName) | ||
|
|
||
| $setupConfiguration = Get-SqlDscRSSetupConfiguration -InstanceName $InstanceName | ||
|
|
||
| if (-not $setupConfiguration) | ||
| { | ||
| $errorMessage = $script:localizedData.Get_SqlDscRSConfigFile_InstanceNotFound -f $InstanceName | ||
|
|
||
| $errorRecord = New-ErrorRecord -Exception (New-InvalidOperationException -Message $errorMessage -PassThru) -ErrorId 'GSRSCF0001' -ErrorCategory 'ObjectNotFound' -TargetObject $InstanceName | ||
|
|
||
| $PSCmdlet.ThrowTerminatingError($errorRecord) | ||
| } | ||
|
|
||
| if ([System.String]::IsNullOrEmpty($setupConfiguration.ConfigFilePath)) | ||
| { | ||
| $errorMessage = $script:localizedData.Get_SqlDscRSConfigFile_ConfigFilePathNotFound -f $InstanceName | ||
|
|
||
| $errorRecord = New-ErrorRecord -Exception (New-InvalidOperationException -Message $errorMessage -PassThru) -ErrorId 'GSRSCF0002' -ErrorCategory 'ObjectNotFound' -TargetObject $InstanceName | ||
|
|
||
| $PSCmdlet.ThrowTerminatingError($errorRecord) | ||
| } | ||
|
|
||
| $configFilePath = $setupConfiguration.ConfigFilePath | ||
| } | ||
|
|
||
| 'ByConfiguration' | ||
| { | ||
| Write-Verbose -Message ($script:localizedData.Get_SqlDscRSConfigFile_GettingConfigFile -f $SetupConfiguration.InstanceName) | ||
|
|
||
| if ([System.String]::IsNullOrEmpty($SetupConfiguration.ConfigFilePath)) | ||
| { | ||
| $errorMessage = $script:localizedData.Get_SqlDscRSConfigFile_ConfigFilePathNotFound -f $SetupConfiguration.InstanceName | ||
|
|
||
| $errorRecord = New-ErrorRecord -Exception (New-InvalidOperationException -Message $errorMessage -PassThru) -ErrorId 'GSRSCF0002' -ErrorCategory 'ObjectNotFound' -TargetObject $SetupConfiguration.InstanceName | ||
|
|
||
| $PSCmdlet.ThrowTerminatingError($errorRecord) | ||
| } | ||
|
|
||
| $configFilePath = $SetupConfiguration.ConfigFilePath | ||
| } | ||
|
|
||
| 'ByPath' | ||
| { | ||
| Write-Verbose -Message ($script:localizedData.Get_SqlDscRSConfigFile_ReadingFromPath -f $Path) | ||
|
|
||
| if (-not (Test-Path -Path $Path -PathType 'Leaf')) | ||
| { | ||
| $errorMessage = $script:localizedData.Get_SqlDscRSConfigFile_FileNotFound -f $Path | ||
|
|
||
| $errorRecord = New-ErrorRecord -Exception (New-InvalidOperationException -Message $errorMessage -PassThru) -ErrorId 'GSRSCF0004' -ErrorCategory 'ObjectNotFound' -TargetObject $Path | ||
|
|
||
| $PSCmdlet.ThrowTerminatingError($errorRecord) | ||
| } | ||
|
|
||
| $configFilePath = $Path | ||
| } | ||
| } | ||
|
|
||
| Write-Verbose -Message ($script:localizedData.Get_SqlDscRSConfigFile_FoundConfigFile -f $configFilePath) | ||
|
|
||
| try | ||
| { | ||
| [xml] $configXml = Get-Content -Path $configFilePath -Raw -Force -ErrorAction 'Stop' | ||
| } | ||
| catch | ||
| { | ||
| $errorMessage = $script:localizedData.Get_SqlDscRSConfigFile_FailedToReadConfigFile -f $configFilePath, $_.Exception.Message | ||
|
|
||
| $errorRecord = New-ErrorRecord -Exception (New-InvalidOperationException -Message $errorMessage -ErrorRecord $_ -PassThru) -ErrorId 'GSRSCF0003' -ErrorCategory 'ReadError' -TargetObject $configFilePath | ||
|
|
||
| $PSCmdlet.ThrowTerminatingError($errorRecord) | ||
| } | ||
|
|
||
| return $configXml | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.