Skip to content

Commit 03777c8

Browse files
committed
Merge pull request #187 from huangpf/dev
Dev
2 parents 5b135ec + 9f8ce1a commit 03777c8

File tree

60 files changed

+36821
-15414
lines changed

Some content is hidden

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

60 files changed

+36821
-15414
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Azure SQL Database: new cmdlets for managing database threat detection policies:
2+
* Get-AzureRmSqlDatabaseThreatDetectionPolicy
3+
* Set-AzureRmSqlDatabaseThreatDetectionPolicy
4+
* Remove-AzureRmSqlDatabaseThreatDetectionPolicy
5+
16
## 2015.11.09 version 1.0.1
27
* Azure Compute
38
* Added cmdlets for managing VM DiskEncryption extension

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Scripts/PSHCommon/Common.ps1

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,6 @@ function Test-BinaryFile
250250
}
251251

252252

253-
<#
254-
.SYNOPSIS
255-
Removes all current subscriptions.
256-
#>
257-
function Remove-AllSubscriptions
258-
{
259-
Get-AzureRmSubscription | Remove-AzureRmSubscription -Force
260-
}
261-
262253
<#
263254
.SYNOPSIS
264255
Waits on the specified job with the given timeout.

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Scripts/VaultManagementTests.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function Test_DeleteUnknownVaultFails
9797
#------------------------------Set-AzureRmKeyVaultAccessPolicy--------------------------
9898
function Test_SetRemoveAccessPolicyByUPN
9999
{
100-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
100+
$user = (Get-AzureRmContext).Account.Id
101101
Reset-PreCreatedVault
102102
Test-SetRemoveAccessPolicyByUPN $global:precreatedVaultName $global:resourceGroupName $user
103103
}
@@ -125,23 +125,23 @@ function Test_SetRemoveAccessPolicyBySPN
125125

126126
function Test_SetRemoveAccessPolicyByObjectId
127127
{
128-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
128+
$user = (Get-AzureRmContext).Account.Id
129129
Reset-PreCreatedVault
130130
Test-SetRemoveAccessPolicyByObjectId $global:precreatedVaultName $global:resourceGroupName $user
131131
}
132132

133133

134134
function Test_SetRemoveAccessPolicyByCompoundId
135135
{
136-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
136+
$user = (Get-AzureRmContext).Account.Id
137137
$appId = [System.Guid]::NewGuid()
138138
Reset-PreCreatedVault
139139
Test-SetRemoveAccessPolicyByCompoundId $global:precreatedVaultName $global:resourceGroupName $user $appId
140140
}
141141

142142
function Test_RemoveAccessPolicyWithCompoundIdPolicies
143143
{
144-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
144+
$user = (Get-AzureRmContext).Account.Id
145145
$appId1 = [System.Guid]::NewGuid()
146146
$appId2 = [System.Guid]::NewGuid()
147147
Reset-PreCreatedVault
@@ -150,51 +150,51 @@ function Test_RemoveAccessPolicyWithCompoundIdPolicies
150150

151151
function Test_SetCompoundIdAccessPolicy
152152
{
153-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
153+
$user = (Get-AzureRmContext).Account.Id
154154
$appId = [System.Guid]::NewGuid()
155155
Reset-PreCreatedVault
156156
Test-SetCompoundIdAccessPolicy $global:precreatedVaultName $global:resourceGroupName $user $appId
157157
}
158158

159159
function Test_ModifyAccessPolicy
160160
{
161-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
161+
$user = (Get-AzureRmContext).Account.Id
162162
Reset-PreCreatedVault
163163
Test-ModifyAccessPolicy $global:precreatedVaultName $global:resourceGroupName $user
164164
}
165165

166166
function Test_ModifyAccessPolicyEnabledForDeployment
167167
{
168-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
168+
$user = (Get-AzureRmContext).Account.Id
169169
Reset-PreCreatedVault
170170
Test-ModifyAccessPolicyEnabledForDeployment $global:precreatedVaultName $global:resourceGroupName $user
171171
}
172172

173173
function Test_ModifyAccessPolicyEnabledForTemplateDeployment
174174
{
175-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
175+
$user = (Get-AzureRmContext).Account.Id
176176
Reset-PreCreatedVault
177177
Test-ModifyAccessPolicyEnabledForTemplateDeployment $global:precreatedVaultName $global:resourceGroupName $user
178178
}
179179

180180
function Test_ModifyAccessPolicyEnabledForDiskEncryption
181181
{
182-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
182+
$user = (Get-AzureRmContext).Account.Id
183183
Reset-PreCreatedVault
184184
Test-ModifyAccessPolicyEnabledForDiskEncryption $global:precreatedVaultName $global:resourceGroupName $user
185185
}
186186

187187
function Test_ModifyAccessPolicyNegativeCases
188188
{
189-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
189+
$user = (Get-AzureRmContext).Account.Id
190190
Reset-PreCreatedVault
191191
Test-ModifyAccessPolicyNegativeCases $global:precreatedVaultName $global:resourceGroupName $user
192192
}
193193

194194

195195
function Test_RemoveNonExistentAccessPolicyDoesNotThrow
196196
{
197-
$user = (Get-AzureRmSubscription -Current).DefaultAccount
197+
$user = (Get-AzureRmContext).Account.Id
198198
Reset-PreCreatedVault
199199
Test-RemoveNonExistentAccessPolicyDoesNotThrow $global:precreatedVaultName $global:resourceGroupName $user
200200
}
@@ -261,7 +261,7 @@ function Initialize-VaultTest
261261
}
262262
#create a vault using ARM
263263
$vaultName = Get-VaultName $suffix
264-
$tenantId = (Get-AzureRmSubscription -Current).TenantId
264+
$tenantId = (Get-AzureRmContext).Tenant.TenantId
265265
$tagName = "testtag"
266266
$tagValue = "testvalue"
267267
$vaultId = @{
@@ -305,7 +305,7 @@ function Reset-PreCreatedVault
305305
{
306306
$tagName = "testtag"
307307
$tagValue = "testvalue"
308-
$tenantId = (Get-AzureRmSubscription -Current).TenantId
308+
$tenantId = (Get-AzureRmContext).Tenant.TenantId
309309
$vaultProperties = @{
310310
"enabledForDeployment" = $false;
311311
"tenantId" = $tenantId;

src/ResourceManager/KeyVault/Commands.KeyVault/Properties/Resources.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/KeyVault/Commands.KeyVault/Properties/Resources.resx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="ADObjectNotFound" xml:space="preserve">
121-
<value>Cannot find the Active Directory object '{0}' in tenant '{1}'. Please make sure that the user or application service principal you are authorizing is registered in the current subscription's Azure Active directory. The TenantID displayed by the cmdlet 'get-AzureRmSubscription -current' is the current subscription's Azure Active directory.</value>
121+
<value>Cannot find the Active Directory object '{0}' in tenant '{1}'. Please make sure that the user or application service principal you are authorizing is registered in the current subscription's Azure Active directory. The TenantID displayed by the cmdlet 'Get-AzureRmContext' is the current subscription's Azure Active directory.</value>
122122
</data>
123123
<data name="BackupKeyFileAlreadyExists" xml:space="preserve">
124124
<value>The backup key file '{0}' already exists.</value>
@@ -139,7 +139,7 @@
139139
<value>Invalid AzureEnvironment.</value>
140140
</data>
141141
<data name="InvalidCurrentSubscription" xml:space="preserve">
142-
<value>No current subscription has been designated. Use Select-AzureRmSubscription -Current &lt;subscriptionName&gt; to set the current subscription.</value>
142+
<value>No current subscription has been designated. Use Set-AzureRmContext -SubscriptionName &lt;subscriptionName&gt; to set the current subscription.</value>
143143
</data>
144144
<data name="InvalidKeyAttributes" xml:space="preserve">
145145
<value>Invalid key attributes</value>
@@ -175,7 +175,7 @@
175175
<value>Invalid secret uri '{0}'.</value>
176176
</data>
177177
<data name="InvalidSelectedSubscription" xml:space="preserve">
178-
<value>No subscription is currently selected. Use Select-Subscription to activate a subscription.</value>
178+
<value>No subscription is currently selected. Use Set-AzureRmContext to activate a subscription.</value>
179179
</data>
180180
<data name="InvalidSubscriptionState" xml:space="preserve">
181181
<value>Your Azure credentials have not been set up or have expired, please run Add-AzureRmAccount to set up your Azure credentials.</value>

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<Private>True</Private>
7474
</Reference>
7575
<Reference Include="Microsoft.Azure.Management.Sql">
76-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.39.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
76+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.41.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
7777
</Reference>
7878
<Reference Include="Microsoft.Azure.Management.Storage">
7979
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
@@ -189,11 +189,15 @@
189189
<DesignTime>True</DesignTime>
190190
<DependentUpon>Resources.resx</DependentUpon>
191191
</Compile>
192+
<Compile Include="ScenarioTests\ThreatDetectionTests.cs" />
192193
<Compile Include="ScenarioTests\DatabaseActivationTests.cs" />
193194
<Compile Include="ScenarioTests\DatabaseBackupTests.cs" />
194195
<Compile Include="ScenarioTests\DatabaseReplicationTests.cs" />
195196
<Compile Include="ScenarioTests\DatabaseCrudTests.cs" />
196197
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
198+
<None Include="ScenarioTests\ThreatDetectionTests.ps1">
199+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
200+
</None>
197201
<None Include="ScenarioTests\DatabaseReplicationTests.ps1">
198202
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
199203
</None>
@@ -445,10 +449,7 @@
445449
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests\TestDatabaseDataMaskingNumberRuleLifecycle.json">
446450
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
447451
</None>
448-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests\TestDatabaseDataMaskingPolicyEnablementToggling.json">
449-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
450-
</None>
451-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests\TestDatabaseDataMaskingPrivilegedLoginsChanges.json">
452+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests\TestDatabaseDataMaskingPrivilegedUsersChanges.json">
452453
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
453454
</None>
454455
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests\TestDatabaseDataMaskingRuleCreationFailures.json">
@@ -514,6 +515,11 @@
514515
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerUpdate.json">
515516
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
516517
</None>
518+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\DisablingThreatDetection.json" />
519+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\InvalidArgumentsThreatDetection.json" />
520+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionDatabaseGetDefualtPolicy.json" />
521+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionDatabaseUpdatePolicy.json" />
522+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests\ThreatDetectionOnV2Server.json" />
517523
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.TransparentDataEncryptionCrudTests\TestDatabaseTransparentDataEncryptionGet.json">
518524
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
519525
</None>

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
2222
{
2323
public class AuditingTests : SqlTestsBase
2424
{
25-
protected Microsoft.Azure.Management.Storage.StorageManagementClient GetStorageV2Client()
26-
{
27-
var client = TestBase.GetServiceClient<Microsoft.Azure.Management.Storage.StorageManagementClient>(new CSMTestEnvironmentFactory());
28-
if (HttpMockServer.Mode == HttpRecorderMode.Playback)
29-
{
30-
client.LongRunningOperationInitialTimeout = 0;
31-
client.LongRunningOperationRetryTimeout = 0;
32-
}
33-
return client;
34-
}
35-
3625
protected override void SetupManagementClients()
3726
{
3827
var sqlCSMClient = GetSqlClient();

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

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ function Get-SqlAuditingTestEnvironmentParameters ($testSuffix)
2525
}
2626
}
2727

28+
<#
29+
.SYNOPSIS
30+
Gets the values of the parameters used at the threat detection tests
31+
#>
32+
function Get-SqlThreatDetectionTestEnvironmentParameters ($testSuffix)
33+
{
34+
return @{ rgname = "sql-td-cmdlet-test-rg" +$testSuffix;
35+
serverName = "sql-td-cmdlet-server" +$testSuffix;
36+
databaseName = "sql-td-cmdlet-db" + $testSuffix;
37+
storageAccount = "tdcmdlets" +$testSuffix
38+
}
39+
}
40+
2841
<#
2942
.SYNOPSIS
3043
Gets the values of the parameters used by the data masking tests
@@ -78,6 +91,28 @@ function Create-TestEnvironmentWithStorageV2 ($testSuffix)
7891
New-AzureRmStorageAccount -Name $params.storageAccount -Location "West US" -ResourceGroupName $params.rgname -Type "Standard_GRS"
7992
}
8093

94+
<#
95+
.SYNOPSIS
96+
Creates the test environment needed to perform the Sql threat detection tests, while using storage V2 as the used storage account
97+
#>
98+
function Create-ThreatDetectionTestEnvironmentWithStorageV2 ($testSuffix, $serverVersion = "12.0")
99+
{
100+
$params = Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
101+
New-AzureRmResourceGroup -Name $params.rgname -Location "Australia East" -Force
102+
103+
if ($serverVersion -eq "12.0")
104+
{
105+
New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-ddm-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "Australia East" -Force
106+
New-AzureRmStorageAccount -Name $params.storageAccount -Location "Australia East" -ResourceGroupName $params.rgname -Type "Standard_GRS"
107+
}
108+
109+
if ($serverVersion -eq "2.0")
110+
{
111+
New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-audit-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "Australia East" -Force
112+
New-AzureRmStorageAccount -Name $params.storageAccount -Location "West US" -ResourceGroupName $params.rgname -Type "Standard_GRS"
113+
}
114+
}
115+
81116
<#
82117
.SYNOPSIS
83118
Creates the test environment needed to perform the Sql data masking tests
@@ -214,8 +249,24 @@ function Remove-TestEnvironment ($testSuffix)
214249
{
215250
try
216251
{
217-
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
218-
Azure\Remove-AzureRmStorageAccount -StorageAccountName $params.storageAccount
252+
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
253+
Azure\Remove-AzureRmStorageAccount -StorageAccountName $params.storageAccount
254+
}
255+
catch
256+
{
257+
}
258+
}
259+
260+
<#
261+
.SYNOPSIS
262+
Removes the test environment that was needed to perform the Sql threat detection tests
263+
#>
264+
function Remove-ThreatDetectionTestEnvironment ($testSuffix)
265+
{
266+
try
267+
{
268+
$params = Get-SqlThreatDetectionTestEnvironmentParameters $testSuffix
269+
Azure\Remove-AzureRmStorageAccount -StorageAccountName $params.storageAccount
219270
}
220271
catch
221272
{

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,11 @@ namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
2020
{
2121
public class DataMaskingTests : SqlTestsBase
2222
{
23-
24-
[Fact]
25-
[Trait(Category.AcceptanceType, Category.BVT)]
26-
public void TestDatabaseDataMaskingPolicyEnablementToggling()
27-
{
28-
RunPowerShellTest("Test-DatabaseDataMaskingPolicyEnablementToggling");
29-
}
30-
3123
[Fact]
3224
[Trait(Category.AcceptanceType, Category.BVT)]
33-
public void TestDatabaseDataMaskingPrivilegedLoginsChanges()
25+
public void TestDatabaseDataMaskingPrivilegedUsersChanges()
3426
{
35-
RunPowerShellTest("Test-DatabaseDataMaskingPrivilegedLoginsChanges");
27+
RunPowerShellTest("Test-DatabaseDataMaskingPrivilegedUsersChanges");
3628
}
3729

3830
[Fact]

0 commit comments

Comments
 (0)