Skip to content

Refactor DSC_SqlSecureConnection private functions to public commands #2304

@coderabbitai

Description

@coderabbitai

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

  1. Reduce code duplication - Integration tests can use public commands instead of duplicating logic
  2. Improve testability - Public commands can be unit tested independently
  3. Better reusability - Other scripts and modules can leverage these commands
  4. 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

Metadata

Metadata

Assignees

Labels

enhancementThe issue is an enhancement request.help wantedThe issue is up for grabs for anyone in the community.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions