Skip to content

AzureSQL - Adding ConfirmAction usage, threat detection policy for servers, blob auditing policy properties #2824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6423f55
Merge remote-tracking branch 'refs/remotes/Azure/dev' into dev
yoavrubin Jul 19, 2016
ad90f42
Adding sql blob auditing
yoavrubin Jul 24, 2016
fd6690a
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
yoavrubin Jul 24, 2016
4e5da7a
Adding blob auditing cmdlets and tests
yoavrubin Jul 27, 2016
b373257
Merge remote-tracking branch 'refs/remotes/Azure/dev' into dev
yoavrubin Jul 27, 2016
e49da02
Merge remote-tracking branch 'refs/remotes/Azure/dev' into dev
yoavrubin Jul 28, 2016
1c58101
Adding threat detection tests recordings
yoavrubin Jul 28, 2016
d6db3c8
Updating test usage of resources clients
yoavrubin Jul 28, 2016
878a52c
Merge remote-tracking branch 'refs/remotes/Azure/dev' into dev
yoavrubin Jul 29, 2016
6b94f40
Merge remote-tracking branch 'refs/remotes/Azure/dev' into dev
yoavrubin Jul 29, 2016
9e42e6d
Merge remote-tracking branch 'refs/remotes/Azure/dev' into dev
yoavrubin Jul 30, 2016
41c3de2
Added information about Azure Sql blob auditing
yoavrubin Aug 3, 2016
3927493
Merge remote-tracking branch 'refs/remotes/Azure/dev' into dev
yoavrubin Aug 3, 2016
7062243
minor fix
yoavrubin Aug 17, 2016
2b74a99
merging
yoavrubin Aug 17, 2016
9594163
Server threat detection, blob audit properties
yoavrubin Aug 24, 2016
71ea637
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
yoavrubin Aug 24, 2016
26fb562
Adding the new cmdlets to the help file
yoavrubin Aug 24, 2016
b5e9898
Annotating all of AzureSQL cmdlets with SupportsShouldProcess
yoavrubin Aug 24, 2016
1b70df3
Removing force test
yoavrubin Aug 24, 2016
1ce8856
Fix to test
yoavrubin Aug 24, 2016
f7f1e8e
minor cleanup
yoavrubin Aug 24, 2016
7321402
removing confirmation
yoavrubin Aug 24, 2016
f5f16b0
fixing two tests
yoavrubin Aug 25, 2016
a2adf20
Removing the annotation "ConfirmImpat = High"
yoavrubin Aug 25, 2016
7290bdb
Cleanup
yoavrubin Aug 25, 2016
a153f71
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
yoavrubin Aug 25, 2016
27a7ec4
Fix delay call
yoavrubin Aug 25, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.48.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.50.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
Expand Down Expand Up @@ -609,15 +609,16 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\InvalidArgumentsThreatDetection.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionDatabaseGetDefualtPolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionDatabaseUpdatePolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionGetDefualtPolicy.json" />
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionOnV2Server.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionServerUpdatePolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.TransparentDataEncryptionCrudTests\TestDatabaseTransparentDataEncryptionGet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -672,4 +673,4 @@
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@ protected override void SetupManagementClients(RestTestFramework.MockContext con
var sqlCSMClient = GetSqlClient();
var storageClient = GetStorageClient();
var storageV2Client = GetStorageV2Client();
//TODO, Remove the MockDeploymentFactory call when the test is re-recorded
var resourcesClient =
// MockDeploymentClientFactory.GetResourceClient(
GetResourcesClient()
// )
;
var resourcesClient = GetResourcesClient();
var authorizationClient = GetAuthorizationManagementClient();
var graphClient = GetGraphClient(context);
helper.SetupSomeOfManagementClients(sqlCSMClient, storageClient, storageV2Client, resourcesClient, authorizationClient, graphClient);
helper.SetupSomeOfManagementClients(sqlCSMClient, storageClient, storageV2Client, resourcesClient, authorizationClient);
}

public AuditingTests(ITestOutputHelper output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Tests that when setting the storage account property's value in a database's aud
function Test-AuditingDatabaseUpdatePolicyWithStorageV2
{
# Setup
$testSuffix = 103020
$testSuffix = 103222
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -118,7 +118,7 @@ Tests that when setting the storage account property's value in a server's audit
function Test-AuditingServerUpdatePolicyWithStorage
{
# Setup
$testSuffix = 261607
$testSuffix = 261883
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -147,7 +147,7 @@ storage account, you don't need to provide it.
function Test-AuditingDatabaseUpdatePolicyKeepPreviousStorage
{
# Setup
$testSuffix = 30251
$testSuffix = 30567
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -180,7 +180,7 @@ storage account, you don't need to provide it.
function Test-AuditingServerUpdatePolicyKeepPreviousStorage
{
# Setup
$testSuffix = 425607
$testSuffix = 425777
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -360,7 +360,7 @@ Tests the modification of a server's auditing policy event types with the 'All'
function Test-AuditingServerUpdatePolicyWithEventTypeShortcuts
{
# Setup
$testSuffix = 8015
$testSuffix = 8077
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -540,7 +540,7 @@ Tests that after marking a database as using its server's policy, when fetching
function Test-AuditingUseServerDefault
{
# Setup
$testSuffix = 172497
$testSuffix = 172777
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -770,7 +770,7 @@ Tests that when setting the retention values of server policy, that values is la
function Test-AuditingServerUpdatePolicyWithRetention
{
# Setup
$testSuffix = 2022
$testSuffix = 2033
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -799,7 +799,7 @@ Tests that when setting the retention values of database policy, that values is
function Test-AuditingDatabaseUpdatePolicyWithRetention
{
# Setup
$testSuffix = 2035
$testSuffix = 2645
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -828,7 +828,7 @@ Tests that after setting the retention values to a server auditing policy, this
function Test-AuditingServerRetentionKeepProperties
{
# Setup
$testSuffix = 2045
$testSuffix = 2077
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -868,7 +868,7 @@ Tests that after setting the retention values to a database auditing policy, thi
function Test-AuditingDatabaseRetentionKeepProperties
{
# Setup
$testSuffix = 20551
$testSuffix = 20555
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -950,7 +950,7 @@ Tests that when modifying properties of a server's blob auditing policy, these p
function Test-BlobAuditingOnServer
{
# Setup
$testSuffix = 8822
$testSuffix = 881277
Create-TestEnvironment $testSuffix "Japan East"
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ function Create-TestEnvironmentWithParams ($params, $location, $serverVersion)
{
New-AzureRmResourceGroup -Name $params.rgname -Location $location

New-AzureRmStorageAccount -StorageAccountName $params.storageAccount -ResourceGroupName $params.rgname -Location $location -Type Standard_GRS

$serverName = $params.serverName
$serverLogin = "audittestusername"
$serverPassword = "t357ingP@s5w0rd!Audit"
$credentials = new-object System.Management.Automation.PSCredential($serverLogin, ($serverPassword | ConvertTo-SecureString -asPlainText -Force))
New-AzureRmSqlServer -ResourceGroupName $params.rgname -ServerName $params.serverName -Location $location -ServerVersion $serverVersion -SqlAdministratorCredentials $credentials
New-AzureRmSqlDatabase -DatabaseName $params.databaseName -ResourceGroupName $params.rgname -ServerName $params.serverName -Edition Basic
New-AzureRmStorageAccount -StorageAccountName $params.storageAccount -ResourceGroupName $params.rgname -Location $location -Type Standard_GRS


# $res = New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile sql_audit_test_env_setup_classic_storage.json -serverName $params.serverName -databaseName $params.databaseName -storageName $params.storageAccount
}
Expand Down Expand Up @@ -247,7 +247,7 @@ function Remove-ResourceGroupForTest ($rg)
.SYNOPSIS
Creates the test environment needed to perform the Sql server CRUD tests
#>
function Create-ServerForTest ($resourceGroup, $serverVersion = "12.0", $location = "Japan East", $server)
function Create-ServerForTest ($resourceGroup, $serverVersion = "12.0", $location = "Japan East")
{
$serverName = Get-ServerName
$serverLogin = "testusername"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function Test-RemoveElasticPool
{
# Setup
$rg = Create-ResourceGroupForTest
$server = Create-ServerForTest $rg "Japan East"
$server = Create-ServerForTest $rg "12.0" "Japan East"

$poolName = Get-ElasticPoolName
$ep1 = New-AzureRmSqlElasticPool -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName `
Expand All @@ -200,7 +200,7 @@ function Test-RemoveElasticPool
try
{
# Create a pool with all values
Remove-AzureRmSqlElasticPool -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName -ElasticPoolName $ep1.ElasticPoolName -Force
Remove-AzureRmSqlElasticPool -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName -ElasticPoolName $ep1.ElasticPoolName –Confirm:$false

# Create a pool using piping
$ep2 | Remove-AzureRmSqlElasticPool -Force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ protected virtual void SetupManagementClients(RestTestFramework.MockContext cont
//TODO, Remove the MockDeploymentFactory call when the test is re-recorded
var resourcesClient = MockDeploymentClientFactory.GetResourceClient(GetResourcesClient());
var authorizationClient = GetAuthorizationManagementClient();
var graphClient = GetGraphClient(context);
helper.SetupSomeOfManagementClients(sqlCSMClient, storageClient, resourcesClient, authorizationClient, graphClient);
helper.SetupSomeOfManagementClients(sqlCSMClient, storageClient, resourcesClient, authorizationClient);
}

protected void RunPowerShellTest(params string[] scripts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public ThreatDetectionTests(ITestOutputHelper output)

[Fact]
[Trait(Category.AcceptanceType, Category.Sql)]
public void ThreatDetectionDatabaseGetDefualtPolicy()
public void ThreatDetectionGetDefualtPolicy()
{
RunPowerShellTest("Test-ThreatDetectionDatabaseGetDefualtPolicy");
RunPowerShellTest("Test-ThreatDetectionGetDefualtPolicy");
}

[Fact]
Expand All @@ -55,6 +55,14 @@ public void ThreatDetectionDatabaseUpdatePolicy()
RunPowerShellTest("Test-ThreatDetectionDatabaseUpdatePolicy");
}

[Fact]
[Trait(Category.AcceptanceType, Category.Sql)]
public void ThreatDetectionServerUpdatePolicy()
{
RunPowerShellTest("Test-ThreatDetectionServerUpdatePolicy");
}


[Fact]
[Trait(Category.AcceptanceType, Category.Sql)]
public void DisablingThreatDetection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
.SYNOPSIS
Tests the default values of database's threat detection policy
#>
function Test-ThreatDetectionDatabaseGetDefualtPolicy
function Test-ThreatDetectionGetDefualtPolicy
{
# Setup
$testSuffix = 4002
$testSuffix = 4006
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix

Expand All @@ -33,7 +33,16 @@ function Test-ThreatDetectionDatabaseGetDefualtPolicy
Assert-AreEqual $policy.ThreatDetectionState "New"
Assert-AreEqual $policy.NotificationRecipientsEmails ""
Assert-True {$policy.EmailAdmins}
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 0
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 1

# Test
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.ThreatDetectionState "New"
Assert-AreEqual $policy.NotificationRecipientsEmails ""
Assert-True {$policy.EmailAdmins}
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 1
}
finally
{
Expand All @@ -49,7 +58,7 @@ Tests that when modifying the properties of a databases's threat detection polic
function Test-ThreatDetectionDatabaseUpdatePolicy
{
# Setup
$testSuffix = 6002
$testSuffix = 6004
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -120,7 +129,7 @@ Tests that when turning off auditing or marking it as "use server default" , thr
function Test-DisablingThreatDetection
{
# Setup
$testSuffix = 7005
$testSuffix = 7011
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -163,7 +172,7 @@ Tests sending invalid arguments in database's threat detection
function Test-InvalidArgumentsThreatDetection
{
# Setup5
$testSuffix = 8009
$testSuffix = 8025
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix

Expand Down Expand Up @@ -210,13 +219,89 @@ function Test-ThreatDetectionOnV2Server
try
{
Set-AzureRmSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount
Assert-Throws {Set-AzureRmSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -ThreatDetectionState "Enabled"}
Assert-Throws {Set-AzureRmSqlDatabaseThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName}
Assert-Throws {Get-AzureRmSqlDatabaseThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName}

Set-AzureRmSqlServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount
Assert-Throws {Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName}
Assert-Throws {Get-AzureRmSqlDatabaseThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName}

}
finally
{
# Cleanup
Remove-ThreatDetectionTestEnvironment $testSuffix
}
}
}

<#
.SYNOPSIS
Tests that when modifying the properties of a server's threat detection policy , they are later fetched properly
#>
function Test-ThreatDetectionServerUpdatePolicy
{
# Setup
$testSuffix = 6027
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix

try
{
# Test
Set-AzureRmSqlServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount
Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -NotificationRecipientsEmails "[email protected];[email protected]" -EmailAdmins $false -ExcludedDetectionType Sql_Injection_Vulnerability
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.ThreatDetectionState "Enabled"
Assert-AreEqual $policy.NotificationRecipientsEmails "[email protected];[email protected]"
Assert-False {$policy.EmailAdmins}
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 1
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection_Vulnerability)}


# Test
Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -ExcludedDetectionType Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Usage_Anomaly
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.ThreatDetectionState "Enabled"
Assert-AreEqual $policy.NotificationRecipientsEmails "[email protected];[email protected]"
Assert-False {$policy.EmailAdmins}
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 4
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection)}
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection_Vulnerability)}
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Access_Anomaly)}
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Usage_Anomaly)}

# Test
Remove-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.ThreatDetectionState "Disabled"
Assert-AreEqual $policy.NotificationRecipientsEmails "[email protected];[email protected]"
Assert-False {$policy.EmailAdmins}
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 4
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection)}
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection_Vulnerability)}
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Access_Anomaly)}
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Usage_Anomaly)}

# Test
Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -ExcludedDetectionType None
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.ThreatDetectionState "Enabled"
Assert-AreEqual $policy.NotificationRecipientsEmails "[email protected];[email protected]"
Assert-False {$policy.EmailAdmins}
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 0
}
finally
{
# Cleanup
Remove-ThreatDetectionTestEnvironment $testSuffix
}
}

Loading