Skip to content

Commit ee7f125

Browse files
committed
Merge pull request #205 from yoavrubin/dev
Adding data masking cmdlets and refactoring
2 parents b287d55 + aaf33c5 commit ee7f125

File tree

102 files changed

+25411
-36961
lines changed

Some content is hidden

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

102 files changed

+25411
-36961
lines changed

src/.nuget/NuGet.Config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<solution>
44
<add key="disableSourceControlIntegration" value="true" />
55
</solution>
6-
</configuration>
6+
</configuration>

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</PropertyGroup>
4444
<ItemGroup>
4545
<Reference Include="Hyak.Common">
46-
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
46+
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\net45\Hyak.Common.dll</HintPath>
4747
</Reference>
4848
<Reference Include="Microsoft.Azure.Common">
4949
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.2\lib\net45\Microsoft.Azure.Common.dll</HintPath>
@@ -59,7 +59,7 @@
5959
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.0-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Management.Sql">
62-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.16.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
62+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.17.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
6363
</Reference>
6464
<Reference Include="Microsoft.Azure.ResourceManager">
6565
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.12.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -143,6 +143,7 @@
143143
<DesignTime>True</DesignTime>
144144
<DependentUpon>Resources.resx</DependentUpon>
145145
</Compile>
146+
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
146147
<Compile Include="ScenarioTests\SecurityTests.cs" />
147148
<Compile Include="ScenarioTests\SqlTestsBase.cs" />
148149
</ItemGroup>
@@ -184,12 +185,36 @@
184185
<None Include="packages.config">
185186
<SubType>Designer</SubType>
186187
</None>
188+
<None Include="ScenarioTests\DataMaskingTests.ps1">
189+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
190+
</None>
187191
<None Include="ScenarioTests\SecurityTests.ps1">
188192
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
189193
</None>
190194
<None Include="ScenarioTests\Common.ps1">
191195
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
192196
</None>
197+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingBasicRuleLifecycle.json">
198+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
199+
</None>
200+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingLevelChanges.json">
201+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
202+
</None>
203+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingNumberRuleLifecycle.json">
204+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
205+
</None>
206+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingPolicyEnablementToggling.json">
207+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
208+
</None>
209+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingPrivilegedLoginsChanges.json">
210+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
211+
</None>
212+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingRuleCreationFailures.json">
213+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
214+
</None>
215+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingTextRuleLifecycle.json">
216+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
217+
</None>
193218
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseDirectAccess.json">
194219
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
195220
</None>

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

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

28+
<#
29+
.SYNOPSIS
30+
Gets the values of the parameters used at the data masking tests
31+
#>
32+
function Get-SqlDataMaskingTestEnvironmentParameters ($testSuffix)
33+
{
34+
return @{ rgname = "sql-dm-cmdlet-test-rg" +$testSuffix;
35+
serverName = "sql-dm-cmdlet-server" +$testSuffix;
36+
databaseName = "sql-dm-cmdlet-db" + $testSuffix
37+
}
38+
}
39+
2840
<#
2941
.SYNOPSIS
3042
Creates the test environment needed to perform the Sql auditing tests
@@ -36,12 +48,29 @@ function Create-TestEnvironment ($testSuffix)
3648
New-AzureResourceGroup -Name $params.rgname -Location "West US" -TemplateFile ".\Templates\sql-audit-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "West US" -Force
3749
}
3850

51+
<#
52+
.SYNOPSIS
53+
Creates the test environment needed to perform the Sql data masking tests
54+
#>
55+
function Create-DataMaskingTestEnvironment ($testSuffix)
56+
{
57+
$params = Get-SqlDataMaskingTestEnvironmentParameters $testSuffix
58+
New-AzureResourceGroup -Name $params.rgname -Location "West US" -TemplateFile ".\Templates\sql-audit-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "West US" -Force
59+
return $params
60+
}
61+
3962
<#
4063
.SYNOPSIS
4164
Removes the test environment that was needed to perform the Sql auditing tests
4265
#>
4366
function Remove-TestEnvironment ($testSuffix)
4467
{
68+
try
69+
{
4570
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
4671
Remove-AzureStorageAccount -StorageAccountName $params.storageAccount
72+
}
73+
catch
74+
{
75+
}
4776
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.ScenarioTest.SqlTests
19+
{
20+
public class DataMaskingTests : SqlTestsBase
21+
{
22+
23+
[Fact]
24+
[Trait(Category.RunType, Category.LiveOnly)]
25+
[Trait(Category.AcceptanceType, Category.CheckIn)]
26+
public void TestDatabaseDataMaskingPolicyEnablementToggling()
27+
{
28+
RunPowerShellTest("Test-DatabaseDataMaskingPolicyEnablementToggling");
29+
}
30+
31+
[Fact]
32+
[Trait(Category.RunType, Category.LiveOnly)]
33+
[Trait(Category.AcceptanceType, Category.CheckIn)]
34+
public void TestDatabaseDataMaskingLevelChanges()
35+
{
36+
RunPowerShellTest("Test-DatabaseDataMaskingLevelChanges");
37+
}
38+
39+
[Fact]
40+
[Trait(Category.RunType, Category.LiveOnly)]
41+
[Trait(Category.AcceptanceType, Category.CheckIn)]
42+
public void TestDatabaseDataMaskingPrivilegedLoginsChanges()
43+
{
44+
RunPowerShellTest("Test-DatabaseDataMaskingPrivilegedLoginsChanges");
45+
}
46+
47+
[Fact]
48+
[Trait(Category.RunType, Category.LiveOnly)]
49+
[Trait(Category.AcceptanceType, Category.CheckIn)]
50+
public void TestDatabaseDataMaskingBasicRuleLifecycle()
51+
{
52+
RunPowerShellTest("Test-DatabaseDataMaskingBasicRuleLifecycle");
53+
}
54+
55+
[Fact]
56+
[Trait(Category.RunType, Category.LiveOnly)]
57+
[Trait(Category.AcceptanceType, Category.CheckIn)]
58+
public void TestDatabaseDataMaskingNumberRuleLifecycle()
59+
{
60+
RunPowerShellTest("Test-DatabaseDataMaskingNumberRuleLifecycle");
61+
}
62+
63+
[Fact]
64+
[Trait(Category.RunType, Category.LiveOnly)]
65+
[Trait(Category.AcceptanceType, Category.CheckIn)]
66+
public void TestDatabaseDataMaskingTextRuleLifecycle()
67+
{
68+
RunPowerShellTest("Test-DatabaseDataMaskingTextRuleLifecycle");
69+
}
70+
71+
[Fact]
72+
[Trait(Category.RunType, Category.LiveOnly)]
73+
[Trait(Category.AcceptanceType, Category.CheckIn)]
74+
public void TestDatabaseDataMaskingRuleCreationFailures()
75+
{
76+
RunPowerShellTest("Test-DatabaseDataMaskingRuleCreationFailures");
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)