From 1fd9a8acef4ac224abe3e312c95b49f1dfc7adca Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 27 Apr 2019 14:05:02 +0200 Subject: [PATCH] SqlServerEndpoint*: Added localization (#1337) - Changes to SqlServerEndpoint - Added en-US localization (issue #611). - Changes to SqlServerEndpointPermission - Added en-US localization (issue #612). - Changes to SqlServerEndpointState - Added en-US localization (issue #613). --- CHANGELOG.md | 15 ++-- .../MSFT_SqlServerEndpoint.psm1 | 77 ++++++++++++++----- .../en-US/MSFT_SqlServerEndpoint.strings.psd1 | 16 ++++ .../MSFT_SqlServerEndpointPermission.psm1 | 66 +++++++++++++--- ...T_SqlServerEndpointPermission.strings.psd1 | 11 +++ .../MSFT_SqlServerEndpointState.psm1 | 56 +++++++++++--- .../MSFT_SqlServerEndpointState.strings.psd1 | 12 +++ .../en-US/DscResource.Common.strings.psd1 | 6 -- .../sv-SE/DscResource.Common.strings.psd1 | 6 -- Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 | 10 +-- ...MSFT_SqlServerEndpointPermission.Tests.ps1 | 4 +- .../MSFT_SqlServerEndpointState.Tests.ps1 | 6 +- 12 files changed, 216 insertions(+), 69 deletions(-) create mode 100644 DSCResources/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 create mode 100644 DSCResources/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 create mode 100644 DSCResources/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a94afd89..c9776520c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,16 +42,21 @@ - Reporting Services are restarted after changing settings, unless `$SuppressRestart` parameter is set ([issue #1331](https://github.com/PowerShell/SqlServerDsc/issues/1331)). `$SuppressRestart` will also prevent Reporting Services restart after initialization. + - Fixed one of the error handling to use localization, and made the + error message more descriptive when the Set-TargetResource function + calls the Test-TargetResource function to verify the desired + state. *This was done prior to adding full en-US localization.* - Changes to SqlServerLogin - Added en-US localization ([issue #615](https://github.com/PowerShell/SqlServerDsc/issues/615)). - Added unit tests to improved code coverage. - Changes to SqlWindowsFirewall - Added en-US localization ([issue #614](https://github.com/PowerShell/SqlServerDsc/issues/614)). -- Changes to SqlRS - - Fixed one of the error handling to use localization, and made the - error message more descriptive when the Set-TargetResource function - calls the Test-TargetResource function to verify the desired - state. *This was done prior to adding full en-US localization.* +- Changes to SqlServerEndpoint + - Added en-US localization ([issue #611](https://github.com/PowerShell/SqlServerDsc/issues/611)). +- Changes to SqlServerEndpointPermission + - Added en-US localization ([issue #612](https://github.com/PowerShell/SqlServerDsc/issues/612)). +- Changes to SqlServerEndpointState + - Added en-US localization ([issue #613](https://github.com/PowerShell/SqlServerDsc/issues/613)). ## 12.4.0.0 diff --git a/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 b/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 index 927d250f2..4b7e3e698 100644 --- a/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 +++ b/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 @@ -7,6 +7,8 @@ Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath ' $script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common' Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1') +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlServerEndpoint' + <# .SYNOPSIS Returns the current state of the endpoint. @@ -39,6 +41,10 @@ function Get-TargetResource $InstanceName ) + Write-Verbose -Message ( + $script:localizedData.GetEndpoint -f $EndpointName, $InstanceName + ) + $getTargetResourceReturnValues = @{ ServerName = $ServerName InstanceName = $InstanceName @@ -52,16 +58,17 @@ function Get-TargetResource $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { - Write-Verbose -Message ('Connected to {0}\{1}' -f $ServerName, $InstanceName) + Write-Verbose -Message ( + $script:localizedData.ConnectedToInstance -f $ServerName, $InstanceName + ) $endpointObject = $sqlServerObject.Endpoints[$EndpointName] if ($endpointObject.Name -eq $EndpointName) { if ($sqlServerObject.Endpoints[$EndPointName].EndpointType -ne 'DatabaseMirroring') { - throw New-TerminatingError -ErrorType EndpointFoundButWrongType ` - -FormatArgs @($EndpointName) ` - -ErrorCategory InvalidOperation + $errorMessage = $script:localizedData.EndpointFoundButWrongType -f $EndpointName + New-InvalidOperationException -Message $errorMessage } $getTargetResourceReturnValues.Ensure = 'Present' @@ -81,9 +88,8 @@ function Get-TargetResource } else { - throw New-TerminatingError -ErrorType NotConnectedToInstance ` - -FormatArgs @($ServerName, $InstanceName) ` - -ErrorCategory InvalidOperation + $errorMessage = $script:localizedData.NotConnectedToInstance -f $ServerName, $InstanceName + New-InvalidOperationException -Message $errorMessage } return $getTargetResourceReturnValues @@ -156,7 +162,9 @@ function Set-TargetResource { if ($Ensure -eq 'Present' -and $getTargetResourceResult.Ensure -eq 'Absent') { - Write-Verbose -Message ('Creating endpoint {0}.' -f $EndpointName) + Write-Verbose -Message ( + $script:localizedData.CreateEndpoint -f $EndpointName, $InstanceName + ) $endpointObject = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Endpoint -ArgumentList $sqlServerObject, $EndpointName $endpointObject.EndpointType = [Microsoft.SqlServer.Management.Smo.EndpointType]::DatabaseMirroring @@ -177,56 +185,72 @@ function Set-TargetResource } elseif ($Ensure -eq 'Present' -and $getTargetResourceResult.Ensure -eq 'Present') { + Write-Verbose -Message ( + $script:localizedData.SetEndpoint -f $EndpointName, $InstanceName + ) + # The endpoint already exist, verifying supported endpoint properties so they are in desired state. $endpointObject = $sqlServerObject.Endpoints[$EndpointName] if ($endpointObject) { if ($endpointObject.Protocol.Tcp.ListenerIPAddress -ne $IpAddress) { - Write-Verbose -Message ('Updating endpoint {0} IP address to {1}.' -f $EndpointName, $IpAddress) + Write-Verbose -Message ( + $script:localizedData.UpdatingEndpointIPAddress -f $IpAddress + ) + $endpointObject.Protocol.Tcp.ListenerIPAddress = $IpAddress $endpointObject.Alter() } if ($endpointObject.Protocol.Tcp.ListenerPort -ne $Port) { - Write-Verbose -Message ('Updating endpoint {0} port to {1}.' -f $EndpointName, $Port) + Write-Verbose -Message ( + $script:localizedData.UpdatingEndpointPort -f $Port + ) + $endpointObject.Protocol.Tcp.ListenerPort = $Port $endpointObject.Alter() } if ($endpointObject.Owner -ne $Owner) { - Write-Verbose -Message ('Updating endpoint {0} Owner to {1}.' -f $EndpointName, $Owner) + Write-Verbose -Message ( + $script:localizedData.UpdatingEndpointOwner -f $Owner + ) + $endpointObject.Owner = $Owner $endpointObject.Alter() } } else { - throw New-TerminatingError -ErrorType EndpointNotFound -FormatArgs @($EndpointName) -ErrorCategory ObjectNotFound + $errorMessage = $script:localizedData.EndpointNotFound -f $EndpointName + New-ObjectNotFoundException -Message $errorMessage } } elseif ($Ensure -eq 'Absent' -and $getTargetResourceResult.Ensure -eq 'Present') { - Write-Verbose -Message ('Dropping endpoint {0}.' -f $EndpointName) - $endpointObject = $sqlServerObject.Endpoints[$EndpointName] if ($endpointObject) { + Write-Verbose -Message ( + $script:localizedData.DropEndpoint -f $EndpointName, $InstanceName + ) + $endpointObject.Drop() } else { - throw New-TerminatingError -ErrorType EndpointNotFound -FormatArgs @($EndpointName) -ErrorCategory ObjectNotFound + $errorMessage = $script:localizedData.EndpointNotFound -f $EndpointName + New-ObjectNotFoundException -Message $errorMessage } } } else { - throw New-TerminatingError -ErrorType NotConnectedToInstance ` - -FormatArgs @($ServerName, $InstanceName) ` - -ErrorCategory InvalidOperation + $errorMessage = $script:localizedData.NotConnectedToInstance -f $ServerName, $InstanceName + New-InvalidOperationException -Message $errorMessage } } @@ -291,6 +315,10 @@ function Test-TargetResource $Owner ) + Write-Verbose -Message ( + $script:localizedData.TestingConfiguration -f $EndpointName, $InstanceName + ) + $getTargetResourceResult = Get-TargetResource -EndpointName $EndpointName -ServerName $ServerName -InstanceName $InstanceName if ($getTargetResourceResult.Ensure -eq $Ensure) { @@ -317,6 +345,19 @@ function Test-TargetResource $result = $false } + if ($result) + { + Write-Verbose -Message ( + $script:localizedData.InDesiredState -f $EndpointName + ) + } + else + { + Write-Verbose -Message ( + $script:localizedData.NotInDesiredState -f $EndpointName + ) + } + return $result } diff --git a/DSCResources/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 b/DSCResources/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 new file mode 100644 index 000000000..fc20c5c6f --- /dev/null +++ b/DSCResources/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 @@ -0,0 +1,16 @@ +ConvertFrom-StringData @' + GetEndpoint = Getting the current values of the endpoint with the name '{0}' for the instance '{1}'. + EndpointFoundButWrongType = Endpoint '{0}' does exist, but it is not of type 'DatabaseMirroring'. + ConnectedToInstance = Connect to the instance '{0}\\{1}'. + NotConnectedToInstance = Was unable to connect to the instance '{0}\\{1}'. + SetEndpoint = Changing the values of the endpoint with the name '{0}' for the instance '{1}'. + CreateEndpoint = Creating the endpoint '{0}' on the instance '{1}'. + UpdatingEndpointIPAddress = Updating the endpoint IP address to '{0}'. + UpdatingEndpointPort = Updating the endpoint port to '{0}'. + UpdatingEndpointOwner = Updating the endpoint owner to '{0}'. + EndpointNotFound = The endpoint with the name '{0}' does not exist. + DropEndpoint = Removing the endpoint '{0}' on the instance '{1}'. + TestingConfiguration = Determines if the endpoint with the name '{0}' for the instance '{1}' is in desired state. + InDesiredState = The endpoint '{0}' is the desired state. + NotInDesiredState = The endpoint '{0}' is not in the desired state. +'@ diff --git a/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 b/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 index 5c8b5a060..1c7853c60 100644 --- a/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 +++ b/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 @@ -7,6 +7,8 @@ Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath ' $script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common' Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1') +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlServerEndpointPermission' + <# .SYNOPSIS Returns the current state of the permissions for the principal (login). @@ -46,6 +48,10 @@ function Get-TargetResource $Principal ) + Write-Verbose -Message ( + $script:localizedData.GetEndpointPermission -f $EndpointName, $InstanceName + ) + try { $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName @@ -53,11 +59,14 @@ function Get-TargetResource $endpointObject = $sqlServerObject.Endpoints[$Name] if ( $null -ne $endpointObject ) { - New-VerboseMessage -Message "Enumerating permissions for endpoint $Name" + $permissionSet = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.ObjectPermissionSet' -Property @{ + Connect = $true + } - $permissionSet = New-Object -Property @{ Connect = $true } -TypeName Microsoft.SqlServer.Management.Smo.ObjectPermissionSet + $endpointPermission = $endpointObject.EnumObjectPermissions($permissionSet) | Where-Object -FilterScript { + $_.PermissionState -eq 'Grant' -and $_.Grantee -eq $Principal + } - $endpointPermission = $endpointObject.EnumObjectPermissions( $permissionSet ) | Where-Object { $_.PermissionState -eq "Grant" -and $_.Grantee -eq $Principal } if ($endpointPermission.Count -ne 0) { $Ensure = 'Present' @@ -71,12 +80,14 @@ function Get-TargetResource } else { - throw New-TerminatingError -ErrorType EndpointNotFound -FormatArgs @($Name) -ErrorCategory ObjectNotFound + $errorMessage = $script:localizedData.EndpointNotFound -f $Name + New-ObjectNotFoundException -Message $errorMessage } } catch { - throw New-TerminatingError -ErrorType UnexpectedErrorFromGet -FormatArgs @($Name) -ErrorCategory ObjectNotFound -InnerException $_.Exception + $errorMessage = $script:localizedData.UnexpectedErrorFromGet -f $Name + New-ObjectNotFoundException -Message $errorMessage -ErrorRecord $_ } return @{ @@ -153,33 +164,47 @@ function Set-TargetResource $getTargetResourceResult = Get-TargetResource @parameters if ($getTargetResourceResult.Ensure -ne $Ensure) { + Write-Verbose -Message ( + $script:localizedData.SetEndpointPermission -f $EndpointName, $InstanceName + ) + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $endpointObject = $sqlServerObject.Endpoints[$Name] if ($null -ne $endpointObject) { - $permissionSet = New-Object -Property @{ Connect = $true } -TypeName Microsoft.SqlServer.Management.Smo.ObjectPermissionSet + $permissionSet = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.ObjectPermissionSet' -Property @{ + Connect = $true + } if ($Ensure -eq 'Present') { - New-VerboseMessage -Message "Grant permission to $Principal on endpoint $Name" + Write-Verbose -Message ( + $script:localizedData.GrantPermission -f $Principal + ) $endpointObject.Grant($permissionSet, $Principal) } else { - New-VerboseMessage -Message "Revoke permission to $Principal on endpoint $Name" + Write-Verbose -Message ( + $script:localizedData.RevokePermission -f $Principal + ) + $endpointObject.Revoke($permissionSet, $Principal) } } else { - throw New-TerminatingError -ErrorType EndpointNotFound -FormatArgs @($Name) -ErrorCategory ObjectNotFound + $errorMessage = $script:localizedData.EndpointNotFound -f $Name + New-ObjectNotFoundException -Message $errorMessage } } else { - New-VerboseMessage -Message "State is already $Ensure" + Write-Verbose -Message ( + $script:localizedData.InDesiredState -f $Name + ) } } @@ -245,11 +270,28 @@ function Test-TargetResource Principal = [System.String] $Principal } - New-VerboseMessage -Message "Testing state of endpoint permission for $Principal" + Write-Verbose -Message ( + $script:localizedData.TestingConfiguration -f $Name, $InstanceName + ) $getTargetResourceResult = Get-TargetResource @parameters - return $getTargetResourceResult.Ensure -eq $Ensure + $isInDesiredState = $getTargetResourceResult.Ensure -eq $Ensure + + if ($isInDesiredState) + { + Write-Verbose -Message ( + $script:localizedData.InDesiredState -f $Name + ) + } + else + { + Write-Verbose -Message ( + $script:localizedData.NotInDesiredState -f $Name + ) + } + + return $isInDesiredState } Export-ModuleMember -Function *-TargetResource diff --git a/DSCResources/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 b/DSCResources/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 new file mode 100644 index 000000000..917c57680 --- /dev/null +++ b/DSCResources/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 @@ -0,0 +1,11 @@ +ConvertFrom-StringData @' + GetEndpointPermission = Enumerating the current permissions for the endpoint with the name '{0}' for the instance '{1}'. + EndpointNotFound = The endpoint with the name '{0}' does not exist. + UnexpectedErrorFromGet = Got unexpected result from Get-TargetResource. No change is made. + SetEndpointPermission = Changing the permissions of the endpoint with the name '{0}' for the instance '{1}'. + GrantPermission = Grant permission to '{0}'. + RevokePermission = Revoke permission for '{0}'. + InDesiredState = The endpoint '{0}' is in the desired state. + NotInDesiredState = The endpoint '{0}' is not in the desired state. + TestingConfiguration = Determines the state of the endpoint with the name '{0}' for the instance '{1}'. +'@ diff --git a/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 b/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 index 35df74894..32a509e95 100644 --- a/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 +++ b/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 @@ -7,6 +7,8 @@ Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath ' $script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common' Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1') +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlServerEndpointState' + <# .SYNOPSIS Returns the current state of an endpoint. @@ -39,7 +41,9 @@ function Get-TargetResource $Name ) - New-VerboseMessage -Message "Getting state of endpoint $Name" + Write-Verbose -Message ( + $script:localizedData.GetEndpointState -f $Name, $InstanceName + ) try { @@ -49,15 +53,21 @@ function Get-TargetResource if ($null -ne $endpointObject) { $currentState = $endpointObject.EndpointState + + Write-Verbose -Message ( + $script:localizedData.CurrentState -f $currentState + ) } else { - throw New-TerminatingError -ErrorType EndpointNotFound -FormatArgs @($Name) -ErrorCategory ObjectNotFound + $errorMessage = $script:localizedData.EndpointNotFound -f $Name + New-ObjectNotFoundException -Message $errorMessage } } catch { - throw New-TerminatingError -ErrorType EndpointErrorVerifyExist -FormatArgs @($Name) -ErrorCategory ObjectNotFound -InnerException $_.Exception + $errorMessage = $script:localizedData.EndpointErrorVerifyExist -f $Name + New-ObjectNotFoundException -Message $errorMessage -ErrorRecord $_ } return @{ @@ -107,6 +117,10 @@ function Set-TargetResource $State = 'Started' ) + Write-Verbose -Message ( + $script:localizedData.SetEndpointState -f $Name, $InstanceName + ) + $parameters = @{ InstanceName = [System.String] $InstanceName ServerName = [System.String] $ServerName @@ -118,7 +132,9 @@ function Set-TargetResource { if ($getTargetResourceResult.State -ne $State) { - New-VerboseMessage -Message ('Changing state of endpoint ''{0}''' -f $Name) + Write-Verbose -Message ( + $script:localizedData.ChangeState -f $State + ) $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName @@ -129,16 +145,19 @@ function Set-TargetResource State = $State } - Set-SqlHADREndpoint @setEndpointParams -ErrorAction Stop | Out-Null + Set-SqlHADREndpoint @setEndpointParams -ErrorAction 'Stop' | Out-Null } else { - New-VerboseMessage -Message ('Endpoint ''{0}'' state is already correct.' -f $Name) + Write-Verbose -Message ( + $script:localizedData.InDesiredState -f $Name, $State + ) } } else { - throw New-TerminatingError -ErrorType UnexpectedErrorFromGet -ErrorCategory InvalidResult + $errorMessage = $script:localizedData.UnexpectedErrorFromGet + New-InvalidResultException -Message $errorMessage } } @@ -182,27 +201,40 @@ function Test-TargetResource $State = 'Started' ) + Write-Verbose -Message ( + $script:localizedData.TestingConfiguration -f $Name, $InstanceName + ) + $parameters = @{ InstanceName = $InstanceName ServerName = $ServerName Name = $Name } - New-VerboseMessage -Message "Testing state $State on endpoint '$Name'" - $getTargetResourceResult = Get-TargetResource @parameters if ($null -ne $getTargetResourceResult) { - $result = $false - if ($getTargetResourceResult.State -eq $State) { + Write-Verbose -Message ( + $script:localizedData.InDesiredState -f $Name, $getTargetResourceResult.State + ) + $result = $true } + else + { + Write-Verbose -Message ( + $script:localizedData.NotInDesiredState -f $Name, $getTargetResourceResult.State, $State + ) + + $result = $false + } } else { - throw New-TerminatingError -ErrorType UnexpectedErrorFromGet -ErrorCategory InvalidResult + $errorMessage = $script:localizedData.UnexpectedErrorFromGet + New-InvalidResultException -Message $errorMessage } return $result diff --git a/DSCResources/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 b/DSCResources/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 new file mode 100644 index 000000000..2962cc004 --- /dev/null +++ b/DSCResources/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 @@ -0,0 +1,12 @@ +ConvertFrom-StringData @' + GetEndpointState = Getting state of the endpoint with the name '{0}' for the instance '{1}'. + EndpointNotFound = The endpoint with the name '{0}' does not exist. + EndpointErrorVerifyExist = Unexpected result when trying to verify existence of the endpoint with the name '{0}'. + UnexpectedErrorFromGet = Got unexpected result from Get-TargetResource. No change is made. + CurrentState = The current state of the endpoint is '{0}'. + SetEndpointState = Changing the state of the endpoint with the name '{0}' for the instance '{1}'. + ChangeState = Changing the state of endpoint to '{0}'. + InDesiredState = The endpoint '{0}' is in the desired state, the state is '{1}'. + NotInDesiredState = The endpoint '{0}' has the state '{1}', but expected the state to be '{2}'. + TestingConfiguration = Determines the state of the endpoint with the name '{0}' for the instance '{1}'. +'@ diff --git a/Modules/DscResource.Common/en-US/DscResource.Common.strings.psd1 b/Modules/DscResource.Common/en-US/DscResource.Common.strings.psd1 index 38e1cfe5a..bf59ba6ec 100644 --- a/Modules/DscResource.Common/en-US/DscResource.Common.strings.psd1 +++ b/Modules/DscResource.Common/en-US/DscResource.Common.strings.psd1 @@ -68,7 +68,6 @@ ConvertFrom-StringData @' RemoteConnectionFailed = Remote PowerShell connection to Server '{0}' failed. TODO = ToDo. Work not implemented at this time. UnexpectedErrorFromGet = Got unexpected result from Get-TargetResource. No change is made. - NotConnectedToInstance = Was unable to connect to the instance '{0}\\{1}' AlterAvailabilityGroupFailed = Failed to alter the availability group '{0}'. HadrNotEnabled = HADR is not enabled. AvailabilityGroupNotFound = Unable to locate the availability group '{0}' on the instance '{1}'. @@ -93,11 +92,6 @@ ConvertFrom-StringData @' AvailabilityGroupListenerIPChangeError = IP-address configuration mismatch. Expecting '{0}' found '{1}'. Resource does not support changing IP-address. Listener needs to be removed and then created again. AvailabilityGroupListenerDHCPChangeError = IP-address configuration mismatch. Expecting '{0}' found '{1}'. Resource does not support changing between static IP and DHCP. Listener needs to be removed and then created again. - # Endpoint - EndpointNotFound = Endpoint '{0}' does not exist - EndpointErrorVerifyExist = Unexpected result when trying to verify existence of endpoint '{0}'. - EndpointFoundButWrongType = Endpoint '{0}' does exist, but it is not of type 'DatabaseMirroring'. - # AlwaysOnService AlterAlwaysOnServiceFailed = Failed to ensure Always On is {0} on the instance '{1}'. UnexpectedAlwaysOnStatus = The status of property Server.IsHadrEnabled was neither $true or $false. Status is '{0}'. diff --git a/Modules/DscResource.Common/sv-SE/DscResource.Common.strings.psd1 b/Modules/DscResource.Common/sv-SE/DscResource.Common.strings.psd1 index 3cb3e3ca9..11c18f93d 100644 --- a/Modules/DscResource.Common/sv-SE/DscResource.Common.strings.psd1 +++ b/Modules/DscResource.Common/sv-SE/DscResource.Common.strings.psd1 @@ -57,7 +57,6 @@ ConvertFrom-StringData @' RemoteConnectionFailed = Remote PowerShell connection to Server '{0}' failed. TODO = ToDo. Work not implemented at this time. UnexpectedErrorFromGet = Got unexpected result from Get-TargetResource. No change is made. - NotConnectedToInstance = Was unable to connect to the instance '{0}\\{1}' AlterAvailabilityGroupFailed = Failed to alter the availability group '{0}'. HadrNotEnabled = HADR is not enabled. AvailabilityGroupNotFound = Unable to locate the availability group '{0}' on the instance '{1}'. @@ -82,11 +81,6 @@ ConvertFrom-StringData @' AvailabilityGroupListenerIPChangeError = IP-address configuration mismatch. Expecting '{0}' found '{1}'. Resource does not support changing IP-address. Listener needs to be removed and then created again. AvailabilityGroupListenerDHCPChangeError = IP-address configuration mismatch. Expecting '{0}' found '{1}'. Resource does not support changing between static IP and DHCP. Listener needs to be removed and then created again. - # Endpoint - EndpointNotFound = Endpoint '{0}' does not exist - EndpointErrorVerifyExist = Unexpected result when trying to verify existence of endpoint '{0}'. - EndpointFoundButWrongType = Endpoint '{0}' does exist, but it is not of type 'DatabaseMirroring'. - # Configuration ConfigurationOptionNotFound = Specified option '{0}' could not be found. ConfigurationRestartRequired = Configuration option '{0}' has been updated, but a manual restart of SQL Server is required for it to take effect. diff --git a/Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 b/Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 index 86843d44b..3cbec6c3e 100644 --- a/Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 @@ -227,7 +227,7 @@ try Context 'When endpoint exist but with wrong endpoint type' { It 'Should throw the correct error' { - { Get-TargetResource @testParameters } | Should -Throw 'Endpoint ''DefaultEndpointMirror'' does exist, but it is not of type ''DatabaseMirroring''.' + { Get-TargetResource @testParameters } | Should -Throw ($script:localizedData.EndpointFoundButWrongType -f $testParameters.EndpointName) } } @@ -241,7 +241,7 @@ try return $null } - { Get-TargetResource @testParameters } | Should -Throw 'Was unable to connect to the instance ''localhost\INSTANCE1''' + { Get-TargetResource @testParameters } | Should -Throw ($script:localizedData.NotConnectedToInstance -f $testParameters.ServerName, $testParameters.InstanceName) } } @@ -583,7 +583,7 @@ try } } -Verifiable - { Set-TargetResource @testParameters } | Should -Throw 'Endpoint ''DefaultEndpointMirror'' does not exist' + { Set-TargetResource @testParameters } | Should -Throw ($script:localizedData.EndpointNotFound -f $testParameters.EndpointName) } } @@ -600,7 +600,7 @@ try $testParameters.Add('Ensure', 'Absent') - { Set-TargetResource @testParameters } | Should -Throw 'Endpoint ''DefaultEndpointMirror'' does not exist' + { Set-TargetResource @testParameters } | Should -Throw ($script:localizedData.EndpointNotFound -f $testParameters.EndpointName) } } @@ -611,7 +611,7 @@ try return $null } - { Set-TargetResource @testParameters } | Should -Throw 'Was unable to connect to the instance ''localhost\INSTANCE1''' + { Set-TargetResource @testParameters } | Should -Throw ($script:localizedData.NotConnectedToInstance -f $testParameters.ServerName, $testParameters.InstanceName) } } } diff --git a/Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 b/Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 index 3202edffb..e07e4ac21 100644 --- a/Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 @@ -147,7 +147,7 @@ try Context 'When endpoint is missing' { It 'Should throw the correct error message' { - { Get-TargetResource @testParameters } | Should -Throw 'Got unexpected result from Get-TargetResource. No change is made. InnerException: Endpoint ''DefaultEndpointMirror'' does not exist' + { Get-TargetResource @testParameters } | Should -Throw ($script:localizedData.UnexpectedErrorFromGet -f $testParameters.Name) Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It } @@ -296,7 +296,7 @@ try } } -Verifiable - { Set-TargetResource @testParameters } | Should -Throw 'Endpoint ''DefaultEndpointMirror'' does not exist' + { Set-TargetResource @testParameters } | Should -Throw ($script:localizedData.EndpointNotFound -f $testParameters.Name) Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It } diff --git a/Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 b/Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 index 7f90c553e..cb006d4e9 100644 --- a/Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 @@ -143,7 +143,7 @@ try Context 'When endpoint is missing' { It 'Should throw the correct error message' { - { Get-TargetResource @testParameters } | Should -Throw 'Unexpected result when trying to verify existence of endpoint ''DefaultEndpointMirror''. InnerException: Endpoint ''DefaultEndpointMirror'' does not exist' + { Get-TargetResource @testParameters } | Should -Throw ($script:localizedData.EndpointErrorVerifyExist -f $testParameters.Name) Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It } @@ -267,7 +267,7 @@ try return $null } -Verifiable - { Test-TargetResource @testParameters } | Should -Throw 'Got unexpected result from Get-TargetResource. No change is made.' + { Test-TargetResource @testParameters } | Should -Throw $script:localizedData.UnexpectedErrorFromGet Assert-MockCalled Connect-SQL -Exactly -Times 0 -Scope It } @@ -342,7 +342,7 @@ try return $null } -Verifiable - { Set-TargetResource @testParameters } | Should -Throw 'Got unexpected result from Get-TargetResource. No change is made.' + { Set-TargetResource @testParameters } | Should -Throw $script:localizedData.UnexpectedErrorFromGet Assert-MockCalled Connect-SQL -Exactly -Times 0 -Scope It }