Skip to content

Commit 42bcfca

Browse files
authored
Merge pull request #596 from Azure/dev
huangpf PR: dev <- Azure:dev
2 parents a78f0bd + 83fa144 commit 42bcfca

File tree

136 files changed

+18520
-13355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+18520
-13355
lines changed

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
</Reference>
7272
<Reference Include="Microsoft.Azure.Management.Sql">
7373
<SpecificVersion>False</SpecificVersion>
74-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.48.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
74+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.50.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
7575
</Reference>
7676
<Reference Include="Microsoft.Azure.Management.Storage">
7777
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
@@ -609,15 +609,16 @@
609609
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\InvalidArgumentsThreatDetection.json">
610610
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
611611
</None>
612-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionDatabaseGetDefualtPolicy.json">
613-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
614-
</None>
615612
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionDatabaseUpdatePolicy.json">
616613
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
617614
</None>
615+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionGetDefualtPolicy.json" />
618616
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionOnV2Server.json">
619617
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
620618
</None>
619+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionServerUpdatePolicy.json">
620+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
621+
</None>
621622
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.TransparentDataEncryptionCrudTests\TestDatabaseTransparentDataEncryptionGet.json">
622623
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
623624
</None>
@@ -672,4 +673,4 @@
672673
</EmbeddedResource>
673674
</ItemGroup>
674675
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
675-
</Project>
676+
</Project>

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/AuditingTests.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@ protected override void SetupManagementClients(RestTestFramework.MockContext con
2929
var sqlCSMClient = GetSqlClient();
3030
var storageClient = GetStorageClient();
3131
var storageV2Client = GetStorageV2Client();
32-
//TODO, Remove the MockDeploymentFactory call when the test is re-recorded
33-
var resourcesClient =
34-
// MockDeploymentClientFactory.GetResourceClient(
35-
GetResourcesClient()
36-
// )
37-
;
32+
var resourcesClient = GetResourcesClient();
3833
var authorizationClient = GetAuthorizationManagementClient();
39-
var graphClient = GetGraphClient(context);
40-
helper.SetupSomeOfManagementClients(sqlCSMClient, storageClient, storageV2Client, resourcesClient, authorizationClient, graphClient);
34+
helper.SetupSomeOfManagementClients(sqlCSMClient, storageClient, storageV2Client, resourcesClient, authorizationClient);
4135
}
4236

4337
public AuditingTests(ITestOutputHelper output)

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/AuditingTests.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Tests that when setting the storage account property's value in a database's aud
1919
function Test-AuditingDatabaseUpdatePolicyWithStorageV2
2020
{
2121
# Setup
22-
$testSuffix = 103020
22+
$testSuffix = 103222
2323
Create-TestEnvironment $testSuffix
2424
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
2525

@@ -118,7 +118,7 @@ Tests that when setting the storage account property's value in a server's audit
118118
function Test-AuditingServerUpdatePolicyWithStorage
119119
{
120120
# Setup
121-
$testSuffix = 261607
121+
$testSuffix = 261883
122122
Create-TestEnvironment $testSuffix
123123
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
124124

@@ -147,7 +147,7 @@ storage account, you don't need to provide it.
147147
function Test-AuditingDatabaseUpdatePolicyKeepPreviousStorage
148148
{
149149
# Setup
150-
$testSuffix = 30251
150+
$testSuffix = 30567
151151
Create-TestEnvironment $testSuffix
152152
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
153153

@@ -180,7 +180,7 @@ storage account, you don't need to provide it.
180180
function Test-AuditingServerUpdatePolicyKeepPreviousStorage
181181
{
182182
# Setup
183-
$testSuffix = 425607
183+
$testSuffix = 425777
184184
Create-TestEnvironment $testSuffix
185185
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
186186

@@ -360,7 +360,7 @@ Tests the modification of a server's auditing policy event types with the 'All'
360360
function Test-AuditingServerUpdatePolicyWithEventTypeShortcuts
361361
{
362362
# Setup
363-
$testSuffix = 8015
363+
$testSuffix = 8077
364364
Create-TestEnvironment $testSuffix
365365
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
366366

@@ -540,7 +540,7 @@ Tests that after marking a database as using its server's policy, when fetching
540540
function Test-AuditingUseServerDefault
541541
{
542542
# Setup
543-
$testSuffix = 172497
543+
$testSuffix = 172777
544544
Create-TestEnvironment $testSuffix
545545
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
546546

@@ -770,7 +770,7 @@ Tests that when setting the retention values of server policy, that values is la
770770
function Test-AuditingServerUpdatePolicyWithRetention
771771
{
772772
# Setup
773-
$testSuffix = 2022
773+
$testSuffix = 2033
774774
Create-TestEnvironment $testSuffix
775775
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
776776

@@ -799,7 +799,7 @@ Tests that when setting the retention values of database policy, that values is
799799
function Test-AuditingDatabaseUpdatePolicyWithRetention
800800
{
801801
# Setup
802-
$testSuffix = 2035
802+
$testSuffix = 2645
803803
Create-TestEnvironment $testSuffix
804804
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
805805

@@ -828,7 +828,7 @@ Tests that after setting the retention values to a server auditing policy, this
828828
function Test-AuditingServerRetentionKeepProperties
829829
{
830830
# Setup
831-
$testSuffix = 2045
831+
$testSuffix = 2077
832832
Create-TestEnvironment $testSuffix
833833
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
834834

@@ -868,7 +868,7 @@ Tests that after setting the retention values to a database auditing policy, thi
868868
function Test-AuditingDatabaseRetentionKeepProperties
869869
{
870870
# Setup
871-
$testSuffix = 20551
871+
$testSuffix = 20555
872872
Create-TestEnvironment $testSuffix
873873
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
874874

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

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/Common.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ function Create-TestEnvironmentWithParams ($params, $location, $serverVersion)
7676
{
7777
New-AzureRmResourceGroup -Name $params.rgname -Location $location
7878

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

8888
# $res = New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile sql_audit_test_env_setup_classic_storage.json -serverName $params.serverName -databaseName $params.databaseName -storageName $params.storageAccount
8989
}
@@ -247,7 +247,7 @@ function Remove-ResourceGroupForTest ($rg)
247247
.SYNOPSIS
248248
Creates the test environment needed to perform the Sql server CRUD tests
249249
#>
250-
function Create-ServerForTest ($resourceGroup, $serverVersion = "12.0", $location = "Japan East", $server)
250+
function Create-ServerForTest ($resourceGroup, $serverVersion = "12.0", $location = "Japan East")
251251
{
252252
$serverName = Get-ServerName
253253
$serverLogin = "testusername"

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/ElasticPoolCrudTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function Test-RemoveElasticPool
185185
{
186186
# Setup
187187
$rg = Create-ResourceGroupForTest
188-
$server = Create-ServerForTest $rg "Japan East"
188+
$server = Create-ServerForTest $rg "12.0" "Japan East"
189189

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

205205
# Create a pool using piping
206206
$ep2 | Remove-AzureRmSqlElasticPool -Force

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ protected virtual void SetupManagementClients(RestTestFramework.MockContext cont
5454
//TODO, Remove the MockDeploymentFactory call when the test is re-recorded
5555
var resourcesClient = MockDeploymentClientFactory.GetResourceClient(GetResourcesClient());
5656
var authorizationClient = GetAuthorizationManagementClient();
57-
var graphClient = GetGraphClient(context);
58-
helper.SetupSomeOfManagementClients(sqlCSMClient, storageClient, resourcesClient, authorizationClient, graphClient);
57+
helper.SetupSomeOfManagementClients(sqlCSMClient, storageClient, resourcesClient, authorizationClient);
5958
}
6059

6160
protected void RunPowerShellTest(params string[] scripts)

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/ThreatDetectionTests.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public ThreatDetectionTests(ITestOutputHelper output)
4343

4444
[Fact]
4545
[Trait(Category.AcceptanceType, Category.Sql)]
46-
public void ThreatDetectionDatabaseGetDefualtPolicy()
46+
public void ThreatDetectionGetDefualtPolicy()
4747
{
48-
RunPowerShellTest("Test-ThreatDetectionDatabaseGetDefualtPolicy");
48+
RunPowerShellTest("Test-ThreatDetectionGetDefualtPolicy");
4949
}
5050

5151
[Fact]
@@ -55,6 +55,14 @@ public void ThreatDetectionDatabaseUpdatePolicy()
5555
RunPowerShellTest("Test-ThreatDetectionDatabaseUpdatePolicy");
5656
}
5757

58+
[Fact]
59+
[Trait(Category.AcceptanceType, Category.Sql)]
60+
public void ThreatDetectionServerUpdatePolicy()
61+
{
62+
RunPowerShellTest("Test-ThreatDetectionServerUpdatePolicy");
63+
}
64+
65+
5866
[Fact]
5967
[Trait(Category.AcceptanceType, Category.Sql)]
6068
public void DisablingThreatDetection()

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/ThreatDetectionTests.ps1

Lines changed: 93 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
.SYNOPSIS
1818
Tests the default values of database's threat detection policy
1919
#>
20-
function Test-ThreatDetectionDatabaseGetDefualtPolicy
20+
function Test-ThreatDetectionGetDefualtPolicy
2121
{
2222
# Setup
23-
$testSuffix = 4002
23+
$testSuffix = 4006
2424
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
2525
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
2626

@@ -33,7 +33,16 @@ function Test-ThreatDetectionDatabaseGetDefualtPolicy
3333
Assert-AreEqual $policy.ThreatDetectionState "New"
3434
Assert-AreEqual $policy.NotificationRecipientsEmails ""
3535
Assert-True {$policy.EmailAdmins}
36-
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 0
36+
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 1
37+
38+
# Test
39+
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
40+
41+
# Assert
42+
Assert-AreEqual $policy.ThreatDetectionState "New"
43+
Assert-AreEqual $policy.NotificationRecipientsEmails ""
44+
Assert-True {$policy.EmailAdmins}
45+
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 1
3746
}
3847
finally
3948
{
@@ -49,7 +58,7 @@ Tests that when modifying the properties of a databases's threat detection polic
4958
function Test-ThreatDetectionDatabaseUpdatePolicy
5059
{
5160
# Setup
52-
$testSuffix = 6002
61+
$testSuffix = 6004
5362
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
5463
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
5564

@@ -120,7 +129,7 @@ Tests that when turning off auditing or marking it as "use server default" , thr
120129
function Test-DisablingThreatDetection
121130
{
122131
# Setup
123-
$testSuffix = 7005
132+
$testSuffix = 7011
124133
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
125134
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
126135

@@ -163,7 +172,7 @@ Tests sending invalid arguments in database's threat detection
163172
function Test-InvalidArgumentsThreatDetection
164173
{
165174
# Setup5
166-
$testSuffix = 8009
175+
$testSuffix = 8025
167176
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
168177
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
169178

@@ -210,13 +219,89 @@ function Test-ThreatDetectionOnV2Server
210219
try
211220
{
212221
Set-AzureRmSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount
213-
Assert-Throws {Set-AzureRmSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -ThreatDetectionState "Enabled"}
214222
Assert-Throws {Set-AzureRmSqlDatabaseThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName}
215223
Assert-Throws {Get-AzureRmSqlDatabaseThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName}
224+
225+
Set-AzureRmSqlServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount
226+
Assert-Throws {Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName}
227+
Assert-Throws {Get-AzureRmSqlDatabaseThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName}
228+
216229
}
217230
finally
218231
{
219232
# Cleanup
220233
Remove-ThreatDetectionTestEnvironment $testSuffix
221234
}
222-
}
235+
}
236+
237+
<#
238+
.SYNOPSIS
239+
Tests that when modifying the properties of a server's threat detection policy , they are later fetched properly
240+
#>
241+
function Test-ThreatDetectionServerUpdatePolicy
242+
{
243+
# Setup
244+
$testSuffix = 6027
245+
Create-TestEnvironment $testSuffix "Japan East"#Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
246+
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix #Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
247+
248+
try
249+
{
250+
# Test
251+
Set-AzureRmSqlServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount
252+
Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -NotificationRecipientsEmails "[email protected];[email protected]" -EmailAdmins $false -ExcludedDetectionType Sql_Injection_Vulnerability
253+
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
254+
255+
# Assert
256+
Assert-AreEqual $policy.ThreatDetectionState "Enabled"
257+
Assert-AreEqual $policy.NotificationRecipientsEmails "[email protected];[email protected]"
258+
Assert-False {$policy.EmailAdmins}
259+
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 1
260+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection_Vulnerability)}
261+
262+
263+
# Test
264+
Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -ExcludedDetectionType Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Usage_Anomaly
265+
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
266+
267+
# Assert
268+
Assert-AreEqual $policy.ThreatDetectionState "Enabled"
269+
Assert-AreEqual $policy.NotificationRecipientsEmails "[email protected];[email protected]"
270+
Assert-False {$policy.EmailAdmins}
271+
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 4
272+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection)}
273+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection_Vulnerability)}
274+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Access_Anomaly)}
275+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Usage_Anomaly)}
276+
277+
# Test
278+
Remove-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
279+
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
280+
281+
# Assert
282+
Assert-AreEqual $policy.ThreatDetectionState "Disabled"
283+
Assert-AreEqual $policy.NotificationRecipientsEmails "[email protected];[email protected]"
284+
Assert-False {$policy.EmailAdmins}
285+
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 4
286+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection)}
287+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Sql_Injection_Vulnerability)}
288+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Access_Anomaly)}
289+
Assert-True {$policy.ExcludedDetectionTypes.Contains([Microsoft.Azure.Commands.Sql.ThreatDetection.Model.DetectionType]::Usage_Anomaly)}
290+
291+
# Test
292+
Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -ExcludedDetectionType None
293+
$policy = Get-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
294+
295+
# Assert
296+
Assert-AreEqual $policy.ThreatDetectionState "Enabled"
297+
Assert-AreEqual $policy.NotificationRecipientsEmails "[email protected];[email protected]"
298+
Assert-False {$policy.EmailAdmins}
299+
Assert-AreEqual $policy.ExcludedDetectionTypes.Length 0
300+
}
301+
finally
302+
{
303+
# Cleanup
304+
Remove-ThreatDetectionTestEnvironment $testSuffix
305+
}
306+
}
307+

0 commit comments

Comments
 (0)