Skip to content

Commit 533708f

Browse files
committed
Threat detection tests to use dedicated template
1 parent e48733c commit 533708f

File tree

10 files changed

+8229
-7524
lines changed

10 files changed

+8229
-7524
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@
541541
<None Include="Templates\sql-audit-test-env-setup-classic-storage.json">
542542
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
543543
</None>
544+
<None Include="Templates\sql-td-test-env-setup.json">
545+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
546+
</None>
544547
<None Include="Templates\sql-ddm-test-env-setup.json">
545548
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
546549
</None>

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,7 @@ function Create-ThreatDetectionTestEnvironmentWithStorageV2 ($testSuffix, $serve
9797
{
9898
$params = Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
9999
New-AzureRmResourceGroup -Name $params.rgname -Location "Australia East" -Force
100-
101-
if ($serverVersion -eq "12.0")
102-
{
103-
New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-ddm-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "Australia East" -Force
104-
New-AzureRmStorageAccount -Name $params.storageAccount -Location "Australia East" -ResourceGroupName $params.rgname -Type "Standard_GRS"
105-
}
106-
107-
if ($serverVersion -eq "2.0")
108-
{
109-
New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-audit-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "Australia East" -Force
110-
New-AzureRmStorageAccount -Name $params.storageAccount -Location "West US" -ResourceGroupName $params.rgname -Type "Standard_GRS"
111-
}
100+
New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-td-test-env-setup.json" -serverName $params.serverName -version $serverVersion -databaseName $params.databaseName -storageName $params.storageAccount -Force
112101
}
113102

114103
<#

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Tests the default values of database's threat detection policy
2020
function Test-ThreatDetectionDatabaseGetDefualtPolicy
2121
{
2222
# Setup
23-
$testSuffix = 5000
23+
$testSuffix = 4000
2424
Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
2525
$params = Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
2626

@@ -49,7 +49,7 @@ Tests that when modifying the properties of a databases's threat detection polic
4949
function Test-ThreatDetectionDatabaseUpdatePolicy
5050
{
5151
# Setup
52-
$testSuffix = 5001
52+
$testSuffix = 6001
5353
Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
5454
$params = Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
5555

@@ -118,7 +118,7 @@ Tests that when turning off auditing or marking it as "use server default" , thr
118118
function Test-DisablingThreatDetection
119119
{
120120
# Setup
121-
$testSuffix = 5002
121+
$testSuffix = 7002
122122
Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
123123
$params = Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
124124

@@ -161,7 +161,7 @@ Tests sending invalid arguments in database's threat detection
161161
function Test-InvalidArgumentsThreatDetection
162162
{
163163
# Setup
164-
$testSuffix = 5003
164+
$testSuffix = 8003
165165
Create-ThreatDetectionTestEnvironmentWithStorageV2 $testSuffix
166166
$params = Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
167167

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests/DisablingThreatDetection.json

Lines changed: 1065 additions & 1410 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests/InvalidArgumentsThreatDetection.json

Lines changed: 1237 additions & 1774 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests/ThreatDetectionDatabaseGetDefualtPolicy.json

Lines changed: 845 additions & 2822 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests/ThreatDetectionDatabaseUpdatePolicy.json

Lines changed: 3966 additions & 1047 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests/ThreatDetectionOnV2Server.json

Lines changed: 1003 additions & 426 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/Templates/sql-audit-test-env-setup-storageV2.json

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,34 @@
3333
"type": "string"
3434
}
3535
},
36-
"resources": [
37-
{
38-
"apiVersion": "2014-04-01-preview",
39-
"location": "[resourceGroup().location]",
40-
"name": "[parameters('serverName')]",
41-
"properties": {
42-
"administratorLogin": "[parameters('administratorLogin')]",
43-
"administratorLoginPassword": "[parameters('administratorLoginPassword')]"
36+
"resources": [
37+
{
38+
"apiVersion": "2014-04-01-preview",
39+
"location": "[resourceGroup().location]",
40+
"name": "[parameters('serverName')]",
41+
"properties": {
42+
"administratorLogin": "[parameters('administratorLogin')]",
43+
"administratorLoginPassword": "[parameters('administratorLoginPassword')]"
44+
},
45+
"resources": [
46+
{
47+
"apiVersion": "2014-04-01-preview",
48+
"dependsOn": [
49+
"[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
50+
],
51+
"location": "[resourceGroup().location]",
52+
"name": "[parameters('databaseName')]",
53+
"properties": {
54+
"collation": "[parameters('collation')]",
55+
"edition": "[parameters('edition')]",
56+
"maxSizeBytes": "1073741824"
57+
},
58+
"type": "databases"
59+
}
60+
],
61+
"type": "Microsoft.Sql/servers"
4462
},
45-
"resources": [
46-
{
47-
"apiVersion": "2014-04-01-preview",
48-
"dependsOn": [
49-
"[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
50-
],
51-
"location": "[resourceGroup().location]",
52-
"name": "[parameters('databaseName')]",
53-
"properties": {
54-
"collation": "[parameters('collation')]",
55-
"edition": "[parameters('edition')]",
56-
"maxSizeBytes": "1073741824"
57-
},
58-
"type": "databases"
59-
}
60-
],
61-
"type": "Microsoft.Sql/servers"
62-
},
63-
{
63+
{
6464
"type": "Microsoft.Storage/storageAccounts",
6565
"name": "[parameters('storageName')]",
6666
"apiVersion": "2015-06-15",
@@ -69,6 +69,5 @@
6969
"accountType": "Standard_GRS"
7070
}
7171
}
72-
73-
]
72+
]
7473
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"$schema": "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview",
3+
"contentVersion": "1.0.0.0",
4+
5+
"parameters": {
6+
"administratorLogin": {
7+
"type": "string",
8+
"defaultValue": "testlogin"
9+
},
10+
"administratorLoginPassword": {
11+
"type": "securestring",
12+
"defaultValue": "testp@ssMakingIt1007Longer"
13+
},
14+
"collation": {
15+
"type": "string",
16+
"defaultValue": "SQL_Latin1_General_CP1_CI_AS"
17+
},
18+
"databaseName": {
19+
"type": "string"
20+
},
21+
"version": {
22+
"type": "string"
23+
},
24+
"edition": {
25+
"type": "string",
26+
"defaultValue": "Basic"
27+
},
28+
"configuredServiceLevelObjectiveId": {
29+
"type": "string",
30+
"defaultValue": "910b4fcb-8a29-4c3e-958f-f7ba794388b2"
31+
},
32+
"serverName": {
33+
"type": "string"
34+
},
35+
"storageName": {
36+
"type": "string"
37+
}
38+
},
39+
"resources": [
40+
{
41+
"apiVersion": "2014-04-01-preview",
42+
"location": "[resourceGroup().location]",
43+
"name": "[parameters('serverName')]",
44+
"properties": {
45+
"administratorLogin": "[parameters('administratorLogin')]",
46+
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
47+
"version": "[parameters('version')]"
48+
},
49+
"resources": [
50+
{
51+
"apiVersion": "2014-04-01-preview",
52+
"dependsOn": [
53+
"[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
54+
],
55+
"location": "[resourceGroup().location]",
56+
"name": "[parameters('databaseName')]",
57+
"properties": {
58+
"collation": "[parameters('collation')]",
59+
"edition": "[parameters('edition')]",
60+
"maxSizeBytes": "1073741824"
61+
},
62+
"type": "databases"
63+
}
64+
],
65+
"type": "Microsoft.Sql/servers"
66+
},
67+
{
68+
"type": "Microsoft.Storage/storageAccounts",
69+
"name": "[parameters('storageName')]",
70+
"apiVersion": "2015-06-15",
71+
"location": "[resourceGroup().location]",
72+
"properties": {
73+
"accountType": "Standard_GRS"
74+
}
75+
}
76+
]
77+
}

0 commit comments

Comments
 (0)