Skip to content

Commit

Permalink
Merge pull request #4259 from ranisha2/preview
Browse files Browse the repository at this point in the history
Adding new updated cmdlets for Auditing settings and deprecating the existing Auditing policy cmdlets
  • Loading branch information
cormacpayne authored Aug 2, 2017
2 parents 9208db9 + a966d83 commit 08a4815
Show file tree
Hide file tree
Showing 58 changed files with 224,944 additions and 38 deletions.
4 changes: 4 additions & 0 deletions src/ResourceManager/Sql/AzureRM.Sql.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,14 @@ CmdletsToExport = 'Get-AzureRmSqlDatabaseTransparentDataEncryption',
'Get-AzureRmSqlDatabaseRestorePoints',
'Get-AzureRmSqlDatabaseAuditingPolicy',
'Get-AzureRmSqlServerAuditingPolicy',
'Get-AzureRmSqlDatabaseAuditing',
'Get-AzureRmSqlServerAuditing',
'Remove-AzureRmSqlDatabaseAuditing',
'Remove-AzureRmSqlServerAuditing',
'Set-AzureRmSqlDatabaseAuditingPolicy',
'Set-AzureRmSqlServerAuditingPolicy',
'Set-AzureRmSqlDatabaseAuditing',
'Set-AzureRmSqlServerAuditing',
'Use-AzureRmSqlServerAuditingPolicy',
'Get-AzureRmSqlDatabaseRecommendedAction',
'Get-AzureRmSqlElasticPoolRecommendedAction',
Expand Down
13 changes: 13 additions & 0 deletions src/ResourceManager/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
- Additional information about change #1
-->
## Current Release
* Adding new updated cmdlets for Auditing settings
- Adding Get-AzureRmSqlDatabaseAuditing cmdlet which gets the auditing settings of an Azure SQL database.
- Adding Get-AzureRmSqlServerAuditing cmdlet which gets the auditing settings of an Azure SQL server.
- Adding Set-AzureRmSqlDatabaseAuditing cmdlet which changes the auditing settings for an Azure SQL database.
- Adding Set-AzureRmSqlServerAuditing cmdlet which changes the auditing settings of an Azure SQL server.
* Deprecating the existing Auditing policy cmdlets
- Deprecating Get-AzureRmSqlDatabaseAuditingPolicy
- Deprecating Get-AzureRmSqlServerAuditingPolicy
- Deprecating Set-AzureRmSqlDatabaseAuditingPolicy
- Deprecating Set-AzureRmSqlServerAuditingPolicy
- Deprecating Use-AzureRmSqlServerAuditingPolicy
- Deprecating Remove-AzureRmSqlDatabaseAuditing
- Deprecating Remove-AzureRmSqlServerAuditing
* Schema file parsing for Update-AzureRmSqlSyncGroup is now case insensitive.

## Version 3.2.1
Expand Down
71 changes: 71 additions & 0 deletions src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ScenarioTests\BlobAuditingTests.cs" />
<Compile Include="ScenarioTests\BlobAuditingClassicStorageTests.cs" />
<Compile Include="ScenarioTests\AuditingClassicStorageTests.cs" />
<Compile Include="ScenarioTests\ReadScaleCrudTests.cs" />
<Compile Include="ScenarioTests\DataSyncTests.cs" />
Expand All @@ -224,6 +226,12 @@
<Compile Include="ScenarioTests\DatabaseReplicationTests.cs" />
<Compile Include="ScenarioTests\DatabaseCrudTests.cs" />
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
<None Include="ScenarioTests\BlobAuditingTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\BlobAuditingClassicStorageTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\AuditingClassicStorageTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -517,6 +525,69 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests\TestServerAuditingTypeMigration.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingClassicStorageTests\TestAuditingUpdatePolicyWithClassicStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingDatabaseRetentionKeepProperties.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingDatabaseStorageKeyRotation.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingDatabaseUpdatePolicyKeepPreviousStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingDatabaseUpdatePolicyWithSameNameStorageOnDifferentRegion.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingDatabaseUpdatePolicyWithStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingDisableDatabaseAuditing.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingDisableServerAuditing.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingFailedDatabaseUpdatePolicyWithNoStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingFailedServerUpdatePolicyWithNoStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingFailWithBadDatabaseIndentity.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingFailWithBadServerIndentity.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingOnDatabase.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingOnServer.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingServerRetentionKeepProperties.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingServerStorageKeyRotation.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingServerUpdatePolicyKeepPreviousStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingServerUpdatePolicyWithStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestBlobAuditingWithAuditActionGroups.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestDeprecatedDatabaseAuditingCmdletToBlobAuditingNewCmdlet.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.BlobAuditingTests\TestDeprecatedServerAuditingCmdletToBlobAuditingNewCmdlet.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseActivationTests\TestDatabasePauseResume.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ----------------------------------------------------------------------------------
//
// 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.Azure.Commands.ScenarioTest.SqlTests;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
using Xunit.Abstractions;
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;

namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
{
public class BlobAuditingClassicStorageTests : SqlTestsBase
{
protected override void SetupManagementClients(RestTestFramework.MockContext context)
{
var sqlClient = GetSqlClient(context);
var sqlLegacyClient = GetLegacySqlClient();
var storageClient = GetStorageClient();
var storageV2Client = GetStorageV2Client();
var resourcesClient = GetResourcesClient();
var newResourcesClient = GetResourcesClient(context);
var authorizationClient = GetAuthorizationManagementClient();
helper.SetupSomeOfManagementClients(sqlClient, sqlLegacyClient, storageClient, storageV2Client, resourcesClient, newResourcesClient, authorizationClient);
}

public BlobAuditingClassicStorageTests(ITestOutputHelper output) : base(output)
{
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAuditingUpdatePolicyWithClassicStorage()
{
RunPowerShellTest("Test-BlobAuditingUpdatePolicyWithClassicStorage");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Tests setting and getting blob auditing policy with classic storage
#>
function Test-BlobAuditingUpdatePolicyWithClassicStorage
{
# Setup
$testSuffix = getAssetName
Create-BlobAuditingClassicTestEnvironment $testSuffix
$params = Get-SqlBlobAuditingTestEnvironmentParameters $testSuffix

try
{
# Test - Blob database Auditing
Set-AzureRmSqlDatabaseAuditing -State Enabled -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount
$policy = Get-AzureRmSqlDatabaseAuditing -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName

# Assert
Assert-AreEqual $policy.StorageAccountName $params.storageAccount
Assert-AreEqual $policy.AuditState "Enabled"

# Test - Blob server Auditing
Set-AzureRmSqlServerAuditing -State Enabled -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount
$policy = Get-AzureRmSqlServerAuditing -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.StorageAccountName $params.storageAccount
Assert-AreEqual $policy.AuditState "Enabled"
}
finally
{
# Cleanup
Remove-BlobAuditingTestEnvironment $testSuffix
}
}
Loading

0 comments on commit 08a4815

Please sign in to comment.