Skip to content

Commit

Permalink
SqlSetup: Remove value Windows from parameter SecurityMode (#2032)
Browse files Browse the repository at this point in the history
- SqlSetup
  - The parameter `SecurityMode` now only (correctly) allows the value
    `SQL` (issue #1185).
  • Loading branch information
johlju authored May 23, 2024
1 parent 47e02f2 commit c5e7fe7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `Connect-SqlDscDatabaseEngine`
- Update comment-based help with more examples.
- SqlSetup
- The parameter `SecurityMode` now only (correctly) allows the value
`SQL` ([issue #1185](https://github.com/dsccommunity/SqlServerDsc/issues/1185)).

### Fixed

Expand Down
14 changes: 5 additions & 9 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,7 @@ function Get-TargetResource
.PARAMETER SecurityMode
Security mode to apply to the
SQL Server instance. 'SQL' indicates mixed-mode authentication while
'Windows' indicates Windows authentication.
Default is Windows. { *Windows* | SQL }
SQL Server instance. 'SQL' indicates mixed-mode authentication.
.PARAMETER SAPwd
SA password, if SecurityMode is set to 'SQL'.
Expand Down Expand Up @@ -795,7 +793,7 @@ function Set-TargetResource
$SQLSysAdminAccounts,

[Parameter()]
[ValidateSet('SQL', 'Windows')]
[ValidateSet('SQL')]
[System.String]
$SecurityMode,

Expand Down Expand Up @@ -1804,9 +1802,7 @@ function Set-TargetResource
.PARAMETER SecurityMode
Security mode to apply to the
SQL Server instance. 'SQL' indicates mixed-mode authentication while
'Windows' indicates Windows authentication.
Default is Windows. { *Windows* | SQL }
SQL Server instance. 'SQL' indicates mixed-mode authentication.
.PARAMETER SAPwd
SA password, if SecurityMode is set to 'SQL'.
Expand Down Expand Up @@ -2054,7 +2050,7 @@ function Test-TargetResource
$SQLSysAdminAccounts,

[Parameter()]
[ValidateSet('SQL', 'Windows')]
[ValidateSet('SQL')]
[System.String]
$SecurityMode,

Expand Down Expand Up @@ -2690,7 +2686,7 @@ function Get-SqlEngineProperties
}
else
{
$securityMode = 'Windows'
$securityMode = $null
}

return @{
Expand Down
2 changes: 1 addition & 1 deletion source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DSC_SqlSetup : OMI_BaseResource
[Read, Description("Returns the username for the _SQL Agent_'s _Windows_ service.")] String AgtSvcAccountUsername;
[Write, Description("Collation for _SQL Server Database Engine_.")] String SQLCollation;
[Write, Description("An array of accounts to be made _SQL Server_ administrators.")] String SQLSysAdminAccounts[];
[Write, Description("Security mode to apply to the _SQL Server_ instance. The value `'SQL'` indicates mixed-mode authentication while the value `'Windows'` indicates _Windows Authentication_. Default value is `'Windows'`."), ValueMap{"SQL", "Windows"}, Values{"SQL", "Windows"}] String SecurityMode;
[Write, Description("Security mode to apply to the _SQL Server_ instance. The value `'SQL'` indicates mixed-mode authentication."), ValueMap{"SQL"}, Values{"SQL"}] String SecurityMode;
[Write, EmbeddedInstance("MSFT_Credential"), Description("Specifies the SA account's password. Only applicable if parameter **SecurityMode** is set to `'SQL'`.")] String SAPwd;
[Write, Description("Root path for _SQL Server_ database files.")] String InstallSQLDataDir;
[Write, Description("Path for _SQL Server_ database files.")] String SQLUserDBDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
$resourceCurrentState.RSSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.RSSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.SAPwd | Should -BeNullOrEmpty
$resourceCurrentState.SecurityMode | Should -Be 'Windows'
$resourceCurrentState.SecurityMode | Should -BeNullOrEmpty
$resourceCurrentState.SetupProcessTimeout | Should -BeNullOrEmpty
$resourceCurrentState.SourceCredential | Should -BeNullOrEmpty
$resourceCurrentState.SourcePath | Should -Be "$($ConfigurationData.AllNodes.DriveLetter):\"
Expand Down
22 changes: 11 additions & 11 deletions tests/Unit/DSC_SqlSetup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
SQLUserDBDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
SQLUserDBLogDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
SQLBackupDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\Backup"
SecurityMode = 'Windows'
SecurityMode = $null
}
}

Expand Down Expand Up @@ -547,7 +547,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
$result.AgtSvcAccountUsername | Should -Be 'COMPANY\AgentAccount'
$result.SqlCollation | Should -Be 'Finnish_Swedish_CI_AS'
$result.SQLSysAdminAccounts | Should -Be 'COMPANY\Stacy'
$result.SecurityMode | Should -Be 'Windows'
$result.SecurityMode | Should -BeNullOrEmpty
$result.InstallSQLDataDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL"
$result.SQLUserDBDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
$result.SQLUserDBLogDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
Expand Down Expand Up @@ -766,7 +766,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
SqlSvcStartupType = 'Auto'
AgtSvcStartupType = 'Auto'
SQLCollation = 'Finnish_Swedish_CI_AS'
SecurityMode = 'Windows'
SecurityMode = $null
}
}

Expand Down Expand Up @@ -884,7 +884,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
SQLUserDBDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
SQLUserDBLogDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
SQLBackupDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\Backup"
SecurityMode = 'Windows'
SecurityMode = $null
}
}

Expand Down Expand Up @@ -1008,7 +1008,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
$result.AgtSvcAccountUsername | Should -Be 'COMPANY\AgentAccount'
$result.SqlCollation | Should -Be 'Finnish_Swedish_CI_AS'
$result.SQLSysAdminAccounts | Should -Be 'COMPANY\Stacy'
$result.SecurityMode | Should -Be 'Windows'
$result.SecurityMode | Should -BeNullOrEmpty
$result.InstallSQLDataDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL"
$result.SQLUserDBDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
$result.SQLUserDBLogDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
Expand Down Expand Up @@ -1114,7 +1114,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
SQLUserDBDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
SQLUserDBLogDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
SQLBackupDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\Backup"
SecurityMode = 'Windows'
SecurityMode = $null
}
}

Expand Down Expand Up @@ -1241,7 +1241,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
$result.AgtSvcAccountUsername | Should -Be 'COMPANY\AgentAccount'
$result.SqlCollation | Should -Be 'Finnish_Swedish_CI_AS'
$result.SQLSysAdminAccounts | Should -Be 'COMPANY\Stacy'
$result.SecurityMode | Should -Be 'Windows'
$result.SecurityMode | Should -BeNullOrEmpty
$result.InstallSQLDataDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL"
$result.SQLUserDBDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
$result.SQLUserDBLogDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).MSSQLSERVER\MSSQL\DATA\"
Expand Down Expand Up @@ -1428,7 +1428,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
SQLUserDBDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).TEST\MSSQL\DATA\"
SQLUserDBLogDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).TEST\MSSQL\DATA\"
SQLBackupDir = "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).TEST\MSSQL\Backup"
SecurityMode = 'Windows'
SecurityMode = $null
}
}

Expand Down Expand Up @@ -1550,7 +1550,7 @@ Describe 'SqlSetup\Get-TargetResource' -Tag 'Get' {
$result.AgtSvcAccountUsername | Should -Be 'COMPANY\AgentAccount'
$result.SqlCollation | Should -Be 'Finnish_Swedish_CI_AS'
$result.SQLSysAdminAccounts | Should -Be 'COMPANY\Stacy'
$result.SecurityMode | Should -Be 'Windows'
$result.SecurityMode | Should -BeNullOrEmpty
$result.InstallSQLDataDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).TEST\MSSQL"
$result.SQLUserDBDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).TEST\MSSQL\DATA\"
$result.SQLUserDBLogDir | Should -Be "C:\Program Files\Microsoft SQL Server\MSSQL$($MockSqlMajorVersion).TEST\MSSQL\DATA\"
Expand Down Expand Up @@ -4628,7 +4628,7 @@ Describe 'Get-SqlEngineProperties' -Tag 'Helper' {
$result.SQLUserDBDir | Should -Be 'K:\MSSQL\Data'
$result.SQLUserDBLogDir | Should -Be 'L:\MSSQL\Logs'
$result.SQLBackupDir | Should -Be 'O:\MSSQL\Backup'
$result.SecurityMode | Should -Be 'Windows'
$result.SecurityMode | Should -BeNullOrEmpty
}
}

Expand All @@ -4643,7 +4643,7 @@ Describe 'Get-SqlEngineProperties' -Tag 'Helper' {

$result = Get-SqlEngineProperties -ServerName 'localhost' -InstanceName 'MSSQLSERVER'

$result.SecurityMode | Should -BeExactly 'Windows'
$result.SecurityMode | Should -BeNullOrEmpty
}
}
}
Expand Down

0 comments on commit c5e7fe7

Please sign in to comment.