-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4259 from ranisha2/preview
Adding new updated cmdlets for Auditing settings and deprecating the existing Auditing policy cmdlets
- Loading branch information
Showing
58 changed files
with
224,944 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/BlobAuditingClassicStorageTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/BlobAuditingClassicStorageTests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.