|
| 1 | +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] |
| 2 | +param () |
| 3 | + |
| 4 | +BeforeDiscovery { |
| 5 | + try |
| 6 | + { |
| 7 | + if (-not (Get-Module -Name 'DscResource.Test')) |
| 8 | + { |
| 9 | + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. |
| 10 | + if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) |
| 11 | + { |
| 12 | + # Redirect all streams to $null, except the error stream (stream 2) |
| 13 | + & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null |
| 14 | + } |
| 15 | + |
| 16 | + # If the dependencies have not been resolved, this will throw an error. |
| 17 | + Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' |
| 18 | + } |
| 19 | + } |
| 20 | + catch [System.IO.FileNotFoundException] |
| 21 | + { |
| 22 | + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.' |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +BeforeAll { |
| 27 | + $script:moduleName = 'SqlServerDsc' |
| 28 | + |
| 29 | + # Do not use -Force. Doing so, or unloading the module in AfterAll, causes |
| 30 | + # PowerShell class types to get new identities, breaking type comparisons. |
| 31 | + Import-Module -Name $script:moduleName -ErrorAction 'Stop' |
| 32 | +} |
| 33 | + |
| 34 | +<# |
| 35 | + .NOTES |
| 36 | + This test is specifically for SQL Server 2017 where the encryption key |
| 37 | + operations have issues after removing encrypted information. |
| 38 | +
|
| 39 | + This test runs Set-SqlDscRSDatabaseConnection to re-establish the database |
| 40 | + connection after Post.EncryptedInformation.RS.Integration.Tests.ps1 has |
| 41 | + removed encrypted information. |
| 42 | +
|
| 43 | + This test runs after Post.EncryptedInformation.RS.Integration.Tests.ps1 and |
| 44 | + before Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1. |
| 45 | +#> |
| 46 | +Describe 'Post.DatabaseConnection.RS' { |
| 47 | + Context 'When re-establishing database connection for SQL Server Reporting Services on SQL Server 2017' -Tag @('Integration_SQL2017_RS') { |
| 48 | + BeforeAll { |
| 49 | + $script:configuration = Get-SqlDscRSConfiguration -InstanceName 'SSRS' -ErrorAction 'Stop' |
| 50 | + |
| 51 | + $script:computerName = Get-ComputerName |
| 52 | + } |
| 53 | + |
| 54 | + It 'Should set the database connection' { |
| 55 | + $script:configuration | Set-SqlDscRSDatabaseConnection -ServerName $script:computerName -InstanceName 'RSDB' -DatabaseName 'ReportServer' -Force -ErrorAction 'Stop' |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments