Description
The integration test PostInstallationConfiguration.Integration.Tests.ps1 contains code that duplicates functionality from private functions in the DSC_SqlSecureConnection DSC resource. These private functions should be refactored into public commands to reduce code duplication and improve maintainability.
Private Functions to Refactor
The following private functions from source/DSCResources/DSC_SqlSecureConnection/DSC_SqlSecureConnection.psm1 should be converted to public commands:
Certificate Permission Management
Get-CertificateAcl - Gets the ACL of the certificate private key
Set-CertificatePermission - Grants service account read permissions to certificate private key
Test-CertificatePermission - Tests if service account has read permissions to certificate private key
SQL Server Encryption Registry Configuration
Get-SqlEncryptionValue - Gets the SQL Server SuperSocketNetLib registry path
Get-EncryptedConnectionSetting - Gets certificate thumbprint and ForceEncryption settings from registry
Set-EncryptedConnectionSetting - Sets certificate thumbprint and ForceEncryption in registry
Benefits
- Reduce code duplication - Integration tests can use public commands instead of duplicating logic
- Improve testability - Public commands can be unit tested independently
- Better reusability - Other scripts and modules can leverage these commands
- Simplified maintenance - Single source of truth for certificate and encryption configuration logic
Implementation Notes
- Follow DSC Community naming conventions for public commands (e.g.,
Get-SqlDscCertificateAcl, Set-SqlDscCertificatePermission, etc.)
- Add appropriate comment-based help with examples
- Create unit tests for all new public commands
- Update integration tests to use the new public commands
- Update the DSC resource to use the new public commands
- Add localized strings for any user-facing messages
References
Description
The integration test
PostInstallationConfiguration.Integration.Tests.ps1contains code that duplicates functionality from private functions in theDSC_SqlSecureConnectionDSC resource. These private functions should be refactored into public commands to reduce code duplication and improve maintainability.Private Functions to Refactor
The following private functions from
source/DSCResources/DSC_SqlSecureConnection/DSC_SqlSecureConnection.psm1should be converted to public commands:Certificate Permission Management
Get-CertificateAcl- Gets the ACL of the certificate private keySet-CertificatePermission- Grants service account read permissions to certificate private keyTest-CertificatePermission- Tests if service account has read permissions to certificate private keySQL Server Encryption Registry Configuration
Get-SqlEncryptionValue- Gets the SQL Server SuperSocketNetLib registry pathGet-EncryptedConnectionSetting- Gets certificate thumbprint and ForceEncryption settings from registrySet-EncryptedConnectionSetting- Sets certificate thumbprint and ForceEncryption in registryBenefits
Implementation Notes
Get-SqlDscCertificateAcl,Set-SqlDscCertificatePermission, etc.)References