diff --git a/checks/Databasev5.Tests.ps1 b/checks/Databasev5.Tests.ps1 index 5808f4c0..6ad3e95e 100644 --- a/checks/Databasev5.Tests.ps1 +++ b/checks/Databasev5.Tests.ps1 @@ -61,3 +61,22 @@ Describe "Suspect Page" -Tags SuspectPage, High , Database -ForEach $InstancesTo } } } + +Describe "Valid Database Owner" -Tags ValidDatabaseOwner, Medium, Database -ForEach $InstancesToTest { + BeforeAll { + [string[]]$targetowner = Get-DbcConfigValue policy.validdbowner.name + $ExcludedDatabases += Get-DbcConfigValue policy.validdbowner.excludedb + } + Context "Testing Database Owners on <_.Name>" { + #TODO fix the it text - needs commas --> should be in this list ( sqladmin sa ) ) + #It "Database <_.Name> - owner should be in this list ( $( [String]::Join(", ", $targetowner) ) ) on <_.Parent.Name>" -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database }else { $ExcludedDatabases -notcontains $PsItem.Name } } { + It "Database <_.Name> - owner '<_.Owner>' should be in this list ( ) ) on <_.Parent.Name>" -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database }else { $ExcludedDatabases -notcontains $PsItem.Name } } { + [string[]]$targetowner = Get-DbcConfigValue policy.validdbowner.name + $psitem.Owner | Should -BeIn $targetowner -Because "The account that is the database owner is not what was expected" + } + } +} + +# how to we get config data to use in its? like $TargetOwner + +