Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingRuleCreationFailures.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingRuleCreationWithoutPolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.DataMaskingTests\TestDatabaseDataMaskingTextRuleLifecycle.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -286,6 +289,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseUpdatePolicyWithRetention.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseUpdatePolicyWithSameNameStorageOnDifferentRegion.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseUpdatePolicyWithStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,12 @@ public void TestDatabaseRetentionKeepProperties()
{
RunPowerShellTest("Test-DatabaseRetentionKeepProperties");
}

[Fact(Skip = "Skip for the version header upgrade on Storage library.")]
[Trait(Category.RunType, Category.LiveOnly)]
public void TestDatabaseUpdatePolicyWithSameNameStorageOnDifferentRegion()
{
RunPowerShellTest("Test-DatabaseUpdatePolicyWithSameNameStorageOnDifferentRegion");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,49 @@ function Test-DatabaseUpdatePolicyWithStorage
}
}

<#
.SYNOPSIS
Tests the flow in which re-setting the policy with storage account that has the same name as before, but it is now on a different region
#>
function Test-DatabaseUpdatePolicyWithSameNameStorageOnDifferentRegion
{
# Setup
$testSuffix = 173
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

try
{
# Test
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName

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

Azure\Remove-AzureStorageAccount -StorageAccountName $params.storageAccount
$newResourceGroupName = "test-rg-for-sql-cmdlets-" + $testSuffix
New-AzureResourceGroup -Name $newResourceGroupName -Location "japanwest"
New-AzureStorageAccount -StorageAccountName $params.storageAccount -ResourceGroupName $newResourceGroupName -Location "japanwest" -Type Standard_GRS

Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName

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


}
finally
{
# Cleanup
}
}

<#
.SYNOPSIS
Tests that when setting the storage account property's value in a server's auditing policy, that value is later fetched properly
Expand Down
Loading