@@ -47,23 +47,34 @@ BeforeAll {
4747 and sets the binding after Remove-SqlDscRSSslCertificateBinding has removed it.
4848#>
4949Describe ' Set-SqlDscRSSslCertificateBinding' {
50+ BeforeAll {
51+ # Get the test certificate that was created by Add-SqlDscRSSslCertificateBinding tests
52+ $script :testCertificate = Get-ChildItem - Path ' Cert:\LocalMachine\My' |
53+ Where-Object - FilterScript { $_.FriendlyName -eq $script :testCertificateFriendlyName } |
54+ Select-Object - First 1
55+
56+ if (-not $script :testCertificate )
57+ {
58+ throw ' Test certificate not found. Ensure Add-SqlDscRSSslCertificateBinding integration tests have run first to create the certificate.'
59+ }
60+
61+ $script :testCertificateHash = $script :testCertificate.Thumbprint
62+ $script :testIPAddress = ' 0.0.0.0'
63+ $script :testPort = 443
64+
65+ Write-Verbose - Message (' Using self-signed certificate '' {0}'' with thumbprint '' {1}'' .' -f $script :testCertificate.Subject , $script :testCertificateHash ) - Verbose
66+ }
67+
5068 Context ' When setting SSL certificate binding for SQL Server Reporting Services' - Tag @ (' Integration_SQL2017_RS' ) {
5169 BeforeAll {
5270 $script :configuration = Get-SqlDscRSConfiguration - InstanceName ' SSRS' - ErrorAction ' Stop'
53-
54- # Get the test certificate that was created by Add-SqlDscRSSslCertificateBinding tests
55- $script :testCertificate = Get-ChildItem - Path ' Cert:\LocalMachine\My' |
56- Where-Object - FilterScript { $_.FriendlyName -eq $script :testCertificateFriendlyName } |
57- Select-Object - First 1
58-
59- $script :testCertificateHash = $script :testCertificate.Thumbprint
6071 }
6172
62- It ' Should set SSL certificate binding' - Skip:( -not $ script :testCertificateHash ) {
73+ It ' Should set SSL certificate binding' {
6374 { $script :configuration | Set-SqlDscRSSslCertificateBinding - Application ' ReportServerWebService' - CertificateHash $script :testCertificateHash - IPAddress $script :testIPAddress - Port $script :testPort - Force - ErrorAction ' Stop' } | Should -Not - Throw
6475 }
6576
66- It ' Should return configuration when using PassThru' - Skip:( -not $ script :testCertificateHash ) {
77+ It ' Should return configuration when using PassThru' {
6778 $config = Get-SqlDscRSConfiguration - InstanceName ' SSRS' - ErrorAction ' Stop'
6879 $result = $config | Set-SqlDscRSSslCertificateBinding - Application ' ReportServerWebService' - CertificateHash $script :testCertificateHash - IPAddress $script :testIPAddress - Port $script :testPort - Force - PassThru - ErrorAction ' Stop'
6980
@@ -75,19 +86,13 @@ Describe 'Set-SqlDscRSSslCertificateBinding' {
7586 Context ' When setting SSL certificate binding for SQL Server Reporting Services' - Tag @ (' Integration_SQL2019_RS' ) {
7687 BeforeAll {
7788 $script :configuration = Get-SqlDscRSConfiguration - InstanceName ' SSRS' - ErrorAction ' Stop'
78-
79- $script :testCertificate = Get-ChildItem - Path ' Cert:\LocalMachine\My' |
80- Where-Object - FilterScript { $_.FriendlyName -eq $script :testCertificateFriendlyName } |
81- Select-Object - First 1
82-
83- $script :testCertificateHash = $script :testCertificate.Thumbprint
8489 }
8590
86- It ' Should set SSL certificate binding' - Skip:( -not $ script :testCertificateHash ) {
91+ It ' Should set SSL certificate binding' {
8792 { $script :configuration | Set-SqlDscRSSslCertificateBinding - Application ' ReportServerWebService' - CertificateHash $script :testCertificateHash - IPAddress $script :testIPAddress - Port $script :testPort - Force - ErrorAction ' Stop' } | Should -Not - Throw
8893 }
8994
90- It ' Should return configuration when using PassThru' - Skip:( -not $ script :testCertificateHash ) {
95+ It ' Should return configuration when using PassThru' {
9196 $config = Get-SqlDscRSConfiguration - InstanceName ' SSRS' - ErrorAction ' Stop'
9297 $result = $config | Set-SqlDscRSSslCertificateBinding - Application ' ReportServerWebService' - CertificateHash $script :testCertificateHash - IPAddress $script :testIPAddress - Port $script :testPort - Force - PassThru - ErrorAction ' Stop'
9398
@@ -99,19 +104,13 @@ Describe 'Set-SqlDscRSSslCertificateBinding' {
99104 Context ' When setting SSL certificate binding for SQL Server Reporting Services' - Tag @ (' Integration_SQL2022_RS' ) {
100105 BeforeAll {
101106 $script :configuration = Get-SqlDscRSConfiguration - InstanceName ' SSRS' - ErrorAction ' Stop'
102-
103- $script :testCertificate = Get-ChildItem - Path ' Cert:\LocalMachine\My' |
104- Where-Object - FilterScript { $_.FriendlyName -eq $script :testCertificateFriendlyName } |
105- Select-Object - First 1
106-
107- $script :testCertificateHash = $script :testCertificate.Thumbprint
108107 }
109108
110- It ' Should set SSL certificate binding' - Skip:( -not $ script :testCertificateHash ) {
109+ It ' Should set SSL certificate binding' {
111110 { $script :configuration | Set-SqlDscRSSslCertificateBinding - Application ' ReportServerWebService' - CertificateHash $script :testCertificateHash - IPAddress $script :testIPAddress - Port $script :testPort - Force - ErrorAction ' Stop' } | Should -Not - Throw
112111 }
113112
114- It ' Should return configuration when using PassThru' - Skip:( -not $ script :testCertificateHash ) {
113+ It ' Should return configuration when using PassThru' {
115114 $config = Get-SqlDscRSConfiguration - InstanceName ' SSRS' - ErrorAction ' Stop'
116115 $result = $config | Set-SqlDscRSSslCertificateBinding - Application ' ReportServerWebService' - CertificateHash $script :testCertificateHash - IPAddress $script :testIPAddress - Port $script :testPort - Force - PassThru - ErrorAction ' Stop'
117116
@@ -123,19 +122,13 @@ Describe 'Set-SqlDscRSSslCertificateBinding' {
123122 Context ' When setting SSL certificate binding for Power BI Report Server' - Tag @ (' Integration_PowerBI' ) {
124123 BeforeAll {
125124 $script :configuration = Get-SqlDscRSConfiguration - InstanceName ' PBIRS' - ErrorAction ' Stop'
126-
127- $script :testCertificate = Get-ChildItem - Path ' Cert:\LocalMachine\My' |
128- Where-Object - FilterScript { $_.FriendlyName -eq $script :testCertificateFriendlyName } |
129- Select-Object - First 1
130-
131- $script :testCertificateHash = $script :testCertificate.Thumbprint
132125 }
133126
134- It ' Should set SSL certificate binding' - Skip:( -not $ script :testCertificateHash ) {
127+ It ' Should set SSL certificate binding' {
135128 { $script :configuration | Set-SqlDscRSSslCertificateBinding - Application ' ReportServerWebService' - CertificateHash $script :testCertificateHash - IPAddress $script :testIPAddress - Port $script :testPort - Force - ErrorAction ' Stop' } | Should -Not - Throw
136129 }
137130
138- It ' Should return configuration when using PassThru' - Skip:( -not $ script :testCertificateHash ) {
131+ It ' Should return configuration when using PassThru' {
139132 $config = Get-SqlDscRSConfiguration - InstanceName ' PBIRS' - ErrorAction ' Stop'
140133 $result = $config | Set-SqlDscRSSslCertificateBinding - Application ' ReportServerWebService' - CertificateHash $script :testCertificateHash - IPAddress $script :testIPAddress - Port $script :testPort - Force - PassThru - ErrorAction ' Stop'
141134
0 commit comments