Skip to content

Adding data masking cmdlets and refactoring to create a framework for AzureSql cmdlets #205

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 15 commits into from
Mar 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/.nuget/NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
</configuration>
29 changes: 27 additions & 2 deletions src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Hyak.Common">
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\net45\Hyak.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common">
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.2\lib\net45\Microsoft.Azure.Common.dll</HintPath>
Expand All @@ -59,7 +59,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.0-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.16.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.17.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.12.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
Expand Down Expand Up @@ -143,6 +143,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
<Compile Include="ScenarioTests\SecurityTests.cs" />
<Compile Include="ScenarioTests\SqlTestsBase.cs" />
</ItemGroup>
Expand Down Expand Up @@ -184,12 +185,36 @@
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="ScenarioTests\DataMaskingTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\SecurityTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\Common.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingBasicRuleLifecycle.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingLevelChanges.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingNumberRuleLifecycle.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingPolicyEnablementToggling.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingPrivilegedLoginsChanges.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingRuleCreationFailures.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingTextRuleLifecycle.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseDirectAccess.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
29 changes: 29 additions & 0 deletions src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ function Get-SqlAuditingTestEnvironmentParameters ($testSuffix)
}
}

<#
.SYNOPSIS
Gets the values of the parameters used at the data masking tests
#>
function Get-SqlDataMaskingTestEnvironmentParameters ($testSuffix)
{
return @{ rgname = "sql-dm-cmdlet-test-rg" +$testSuffix;
serverName = "sql-dm-cmdlet-server" +$testSuffix;
databaseName = "sql-dm-cmdlet-db" + $testSuffix
}
}

<#
.SYNOPSIS
Creates the test environment needed to perform the Sql auditing tests
Expand All @@ -36,12 +48,29 @@ function Create-TestEnvironment ($testSuffix)
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
}

<#
.SYNOPSIS
Creates the test environment needed to perform the Sql data masking tests
#>
function Create-DataMaskingTestEnvironment ($testSuffix)
{
$params = Get-SqlDataMaskingTestEnvironmentParameters $testSuffix
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
return $params
}

<#
.SYNOPSIS
Removes the test environment that was needed to perform the Sql auditing tests
#>
function Remove-TestEnvironment ($testSuffix)
{
try
{
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix
Remove-AzureStorageAccount -StorageAccountName $params.storageAccount
}
catch
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.ScenarioTest.SqlTests
{
public class DataMaskingTests : SqlTestsBase
{

[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseDataMaskingPolicyEnablementToggling()
{
RunPowerShellTest("Test-DatabaseDataMaskingPolicyEnablementToggling");
}

[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseDataMaskingLevelChanges()
{
RunPowerShellTest("Test-DatabaseDataMaskingLevelChanges");
}

[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseDataMaskingPrivilegedLoginsChanges()
{
RunPowerShellTest("Test-DatabaseDataMaskingPrivilegedLoginsChanges");
}

[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseDataMaskingBasicRuleLifecycle()
{
RunPowerShellTest("Test-DatabaseDataMaskingBasicRuleLifecycle");
}

[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseDataMaskingNumberRuleLifecycle()
{
RunPowerShellTest("Test-DatabaseDataMaskingNumberRuleLifecycle");
}

[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseDataMaskingTextRuleLifecycle()
{
RunPowerShellTest("Test-DatabaseDataMaskingTextRuleLifecycle");
}

[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseDataMaskingRuleCreationFailures()
{
RunPowerShellTest("Test-DatabaseDataMaskingRuleCreationFailures");
}
}
}
Loading