Skip to content

Commit 2e2473a

Browse files
committed
Improve integration tests for RS Service Account
1 parent f9c6fd6 commit 2e2473a

5 files changed

Lines changed: 30 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
194194
for SQL Server Reporting Services or Power BI Report Server. Supports waiting
195195
for dependent services, configurable wait time, and accepts pipeline input
196196
from `Get-SqlDscRSConfiguration`.
197+
- Added public command `New-SqlDscRSEncryptionKey` to delete and regenerate the
198+
Reporting Services encryption key. Wraps the `DeleteEncryptionKey` CIM method.
199+
Warning: This operation cannot be undone and renders all encrypted content
200+
unreadable.
201+
- Added public command `Remove-SqlDscRSEncryptionKey` to remove all encrypted
202+
content from the report server database. Wraps the `DeleteEncryptionKey` CIM
203+
method with `DeleteEncryptedContent` mode.
204+
- Added public command `Remove-SqlDscRSEncryptedInformation` to remove all encrypted
205+
information from the report server database, including stored credentials and
206+
connection strings. Wraps the `DeleteEncryptedInformation` CIM method.
197207
- Added public commands `Get-SqlDscRSServiceAccount` and
198208
`Set-SqlDscRSServiceAccount` to get and set the Windows service account for
199209
SQL Server Reporting Services or Power BI Report Server. `Set-SqlDscRSServiceAccount`

azure-pipelines.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,20 @@ stages:
143143
$pesterConfig.Run.Path = '.\tests\QA'
144144
$pesterConfig.Run.Throw = $true
145145
$pesterConfig.Output.Verbosity = 'Detailed'
146+
$pesterConfig.TestResult.Enabled = $true
147+
$pesterConfig.TestResult.OutputFormat = 'NUnitXml'
148+
$pesterConfig.TestResult.OutputPath = ".\$(buildFolderName)\$(testResultFolderName)\NUnit_QA.xml"
146149
147150
Invoke-Pester -Configuration $pesterConfig
148151
name: qualityTest
149152
displayName: 'Run SqlServerDsc QA Test'
153+
- task: PublishTestResults@2
154+
displayName: 'Publish Test Results'
155+
condition: succeededOrFailed()
156+
inputs:
157+
testResultsFormat: 'NUnit'
158+
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit_QA.xml'
159+
testRunTitle: 'QA'
150160

151161
- job: Test_HQRM
152162
displayName: 'HQRM Test'
@@ -684,6 +694,7 @@ stages:
684694
# Group 8
685695
'tests/Integration/Commands/Repair-SqlDscPowerBIReportServer.Integration.Tests.ps1'
686696
'tests/Integration/Commands/Remove-SqlDscRSUrlReservation.Integration.Tests.ps1'
697+
'tests/Integration/Commands/Remove-SqlDscRSEncryptedInformation.Integration.Tests.ps1'
687698
# Group 9
688699
'tests/Integration/Commands/Uninstall-SqlDscPowerBIReportServer.Integration.Tests.ps1'
689700
)

source/en-US/SqlServerDsc.strings.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,15 @@ ConvertFrom-StringData @'
827827
Remove_SqlDscRSEncryptionKey_ShouldProcessConfirmation = Are you sure you want to remove the encryption key from Reporting Services instance '{0}'? This is a destructive operation.
828828
# This string shall not end with full stop (.) since it is used as a title of ShouldProcess messages.
829829
Remove_SqlDscRSEncryptionKey_ShouldProcessCaption = Remove encryption key from Reporting Services instance
830-
Remove_SqlDscRSEncryptionKey_FailedToRemove = Failed to remove encryption key from Reporting Services instance '{0}'. (RRSEK0001)
830+
Remove_SqlDscRSEncryptionKey_FailedToRemove = Failed to remove encryption key from Reporting Services instance '{0}'. (RSREK0001)
831831
832832
## Remove-SqlDscRSEncryptedInformation
833833
Remove_SqlDscRSEncryptedInformation_Removing = Removing encrypted information from Reporting Services instance '{0}'.
834834
Remove_SqlDscRSEncryptedInformation_ShouldProcessDescription = Removing encrypted information from Reporting Services instance '{0}'. This is a destructive operation.
835835
Remove_SqlDscRSEncryptedInformation_ShouldProcessConfirmation = Are you sure you want to remove all encrypted information from Reporting Services instance '{0}'? This is a destructive operation.
836836
# This string shall not end with full stop (.) since it is used as a title of ShouldProcess messages.
837837
Remove_SqlDscRSEncryptedInformation_ShouldProcessCaption = Remove encrypted information from Reporting Services instance
838-
Remove_SqlDscRSEncryptedInformation_FailedToRemove = Failed to remove encrypted information from Reporting Services instance '{0}'. (RRSREI0001)
838+
Remove_SqlDscRSEncryptedInformation_FailedToRemove = Failed to remove encrypted information from Reporting Services instance '{0}'. (RSRSEI0001)
839839
840840
## Get-SqlDscRSServiceAccount
841841
Get_SqlDscRSServiceAccount_Getting = Getting service account for Reporting Services instance '{0}'.

tests/Integration/Commands/Remove-SqlDscRSEncryptedInformation.Integration.Tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ BeforeAll {
3939
#>
4040

4141
Describe 'Remove-SqlDscRSEncryptedInformation' {
42-
Context 'When removing encrypted information for SQL Server Reporting Services' -Tag @('Integration_SQL2017_RS') -Skip:$true {
42+
Context 'When removing encrypted information for SQL Server 2017 Reporting Services' -Tag @('Integration_SQL2017_RS') -Skip:$true {
4343
BeforeAll {
4444
$script:configuration = Get-SqlDscRSConfiguration -InstanceName 'SSRS' -ErrorAction 'Stop'
4545
}
@@ -49,7 +49,7 @@ Describe 'Remove-SqlDscRSEncryptedInformation' {
4949
}
5050
}
5151

52-
Context 'When removing encrypted information for SQL Server Reporting Services' -Tag @('Integration_SQL2019_RS') {
52+
Context 'When removing encrypted information for SQL Server 2019 Reporting Services' -Tag @('Integration_SQL2019_RS') {
5353
BeforeAll {
5454
$script:configuration = Get-SqlDscRSConfiguration -InstanceName 'SSRS' -ErrorAction 'Stop'
5555
}
@@ -59,7 +59,7 @@ Describe 'Remove-SqlDscRSEncryptedInformation' {
5959
}
6060
}
6161

62-
Context 'When removing encrypted information for SQL Server Reporting Services' -Tag @('Integration_SQL2022_RS') {
62+
Context 'When removing encrypted information for SQL Server 2022 Reporting Services' -Tag @('Integration_SQL2022_RS') {
6363
BeforeAll {
6464
$script:configuration = Get-SqlDscRSConfiguration -InstanceName 'SSRS' -ErrorAction 'Stop'
6565
}

tests/Unit/Public/Request-SqlDscRSDatabaseRightsScript.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,31 +186,31 @@ Describe 'Request-SqlDscRSDatabaseRightsScript' {
186186
}
187187

188188
It 'Should throw terminating error for UserName without backslash with IsRemote' {
189-
$null = { $mockCimInstance | Request-SqlDscRSDatabaseRightsScript -DatabaseName 'ReportServer' -UserName 'SQLRSUser' -IsRemote } | Should -Throw -ErrorId 'UserName,New-ArgumentException'
189+
{ $mockCimInstance | Request-SqlDscRSDatabaseRightsScript -DatabaseName 'ReportServer' -UserName 'SQLRSUser' -IsRemote } | Should -Throw -ErrorId 'UserName,New-ArgumentException'
190190

191191
Should -Not -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
192192
$MethodName -eq 'GenerateDatabaseRightsScript'
193193
}
194194
}
195195

196196
It 'Should throw terminating error for UserName with multiple backslashes with IsRemote' {
197-
$null = { $mockCimInstance | Request-SqlDscRSDatabaseRightsScript -DatabaseName 'ReportServer' -UserName 'DOMAIN\SUB\SQLRSUser' -IsRemote } | Should -Throw -ErrorId 'UserName,New-ArgumentException'
197+
{ $mockCimInstance | Request-SqlDscRSDatabaseRightsScript -DatabaseName 'ReportServer' -UserName 'DOMAIN\SUB\SQLRSUser' -IsRemote } | Should -Throw -ErrorId 'UserName,New-ArgumentException'
198198

199199
Should -Not -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
200200
$MethodName -eq 'GenerateDatabaseRightsScript'
201201
}
202202
}
203203

204204
It 'Should throw terminating error for UserName with only domain with IsRemote' {
205-
$null = { $mockCimInstance | Request-SqlDscRSDatabaseRightsScript -DatabaseName 'ReportServer' -UserName 'DOMAIN\' -IsRemote } | Should -Throw -ErrorId 'UserName,New-ArgumentException'
205+
{ $mockCimInstance | Request-SqlDscRSDatabaseRightsScript -DatabaseName 'ReportServer' -UserName 'DOMAIN\' -IsRemote } | Should -Throw -ErrorId 'UserName,New-ArgumentException'
206206

207207
Should -Not -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
208208
$MethodName -eq 'GenerateDatabaseRightsScript'
209209
}
210210
}
211211

212212
It 'Should throw terminating error for UserName with only username with IsRemote' {
213-
$null = { $mockCimInstance | Request-SqlDscRSDatabaseRightsScript -DatabaseName 'ReportServer' -UserName '\SQLRSUser' -IsRemote } | Should -Throw -ErrorId 'UserName,New-ArgumentException'
213+
{ $mockCimInstance | Request-SqlDscRSDatabaseRightsScript -DatabaseName 'ReportServer' -UserName '\SQLRSUser' -IsRemote } | Should -Throw -ErrorId 'UserName,New-ArgumentException'
214214

215215
Should -Not -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
216216
$MethodName -eq 'GenerateDatabaseRightsScript'

0 commit comments

Comments
 (0)