Skip to content

Commit

Permalink
Merge pull request #26 from Azure/ignite
Browse files Browse the repository at this point in the history
Ignite
  • Loading branch information
huangpf committed Apr 26, 2015
2 parents d02434f + 1bc090a commit 0d23979
Show file tree
Hide file tree
Showing 22 changed files with 57,502 additions and 1,612 deletions.
12 changes: 12 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 @@ -241,6 +241,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseDisableEnableKeepProperties.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseRetentionKeepProperties.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseStorageKeyRotation.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -253,6 +256,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseUpdatePolicyWithEventTypeShortcuts.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseUpdatePolicyWithRetention.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestDatabaseUpdatePolicyWithStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -283,6 +289,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestServerDisableEnableKeepProperties.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestServerRetentionKeepProperties.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestServerStorageKeyRotation.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -295,6 +304,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestServerUpdatePolicyWithEventTypeShortcuts.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestServerUpdatePolicyWithRetention.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestServerUpdatePolicyWithStorage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void TestDatabaseUpdatePolicyWithStorage()
RunPowerShellTest("Test-DatabaseUpdatePolicyWithStorage");
}

[Fact(Skip = "Skip for the version header upgrade on Storage library.")]
[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestServerUpdatePolicyWithStorage()
Expand Down Expand Up @@ -183,5 +183,37 @@ public void TestServerStorageKeyRotation()
{
RunPowerShellTest("Test-ServerStorageKeyRotation");
}

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

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

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

[Fact]
[Trait(Category.RunType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseRetentionKeepProperties()
{
RunPowerShellTest("Test-DatabaseRetentionKeepProperties");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,11 @@ function Test-DatabaseUpdatePolicyWithEventTypes
Assert-AreEqual $policy.EventType.Length 15

# Test
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success","ParameterizedSQL_Success","ParameterizedSQL_Failure","DataAccess","DataChanges","RevokePermissions"
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success","ParameterizedSQL_Success","ParameterizedSQL_Failure"
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName

# Assert
Assert-AreEqual $policy.EventType.Length 6
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::DataAccess)}
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::DataChanges)}
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::RevokePermissions)}
Assert-AreEqual $policy.EventType.Length 3
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::PlainSQL_Success)}
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::ParameterizedSQL_Success)}
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::ParameterizedSQL_Failure)}
Expand Down Expand Up @@ -203,18 +200,16 @@ function Test-ServerUpdatePolicyWithEventTypes
Assert-AreEqual $policy.EventType.Length 15

# Test
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "DataAccess","DataChanges","RevokePermissions","PlainSQL_Success","ParameterizedSQL_Success","ParameterizedSQL_Failure"
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success","ParameterizedSQL_Success","ParameterizedSQL_Failure"
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.EventType.Length 6
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::DataAccess)}
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::DataChanges)}
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::RevokePermissions)}
Assert-AreEqual $policy.EventType.Length 3
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::PlainSQL_Success)}
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::ParameterizedSQL_Success)}
Assert-True {$policy.EventType.Contains([Microsoft.Azure.Commands.Sql.Security.Model.AuditEventType]::ParameterizedSQL_Failure)}


# Test
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "None"
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName
Expand Down Expand Up @@ -276,6 +271,10 @@ function Test-DatabaseUpdatePolicyWithEventTypeShortcuts
Assert-Throws {Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -EventType "None", "All"}
Assert-Throws {Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success", "All"}
Assert-Throws {Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success", "None"}

#Test - If the event types includes new events and deprecated events we throw error
Assert-Throws {Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success", "DataAccess"}

}
finally
{
Expand Down Expand Up @@ -331,6 +330,9 @@ function Test-ServerUpdatePolicyWithEventTypeShortcuts
Assert-Throws {Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "None", "All"}
Assert-Throws {Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success", "All"}
Assert-Throws {Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success", "None"}

#Test - If the event types includes new events and deprecated events we throw error
Assert-Throws {Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -EventType "PlainSQL_Success", "DataAccess"}
}
finally
{
Expand Down Expand Up @@ -731,4 +733,141 @@ function Test-DatabaseStorageKeyRotation
# Cleanup
Remove-TestEnvironment $testSuffix
}
}
}
<#
.SYNOPSIS
Tests that when setting the retention values of server policy, that values is later fetched properly.
#>
function Test-ServerUpdatePolicyWithRetention
{
# Setup
$testSuffix = 202
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

try
{
# Test
$retentionTableIdentifier = "retentionTableIdentifier" + $testSuffix;
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -RetentionInDays 10 -TableIdentifier $retentionTableIdentifier;
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.RetentionInDays 10
Assert-AreEqual $policy.TableIdentifier $retentionTableIdentifier
}
finally
{
# Cleanup
Remove-TestEnvironment $testSuffix
}
}

<#
.SYNOPSIS
Tests that when setting the retention values of database policy, that values is later fetched properly.
#>
function Test-DatabaseUpdatePolicyWithRetention
{
# Setup
$testSuffix = 203
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

try
{
# Test
$retentionTableIdentifier = "retentionTableIdentifier" + $testSuffix;
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -RetentionInDays 10 -TableIdentifier $retentionTableIdentifier;
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName

# Assert
Assert-AreEqual $policy.RetentionInDays 10
Assert-AreEqual $policy.TableIdentifier $retentionTableIdentifier
}
finally
{
# Cleanup
Remove-TestEnvironment $testSuffix
}
}

<#
.SYNOPSIS
Tests that after setting the retention values to a server auditing policy, this value is used on next policy set operations as default.
#>
function Test-ServerRetentionKeepProperties
{
# Setup
$testSuffix = 204
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

try
{
# Test
$retentionTableIdentifier = "retentionTableIdentifier" + $testSuffix;
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -RetentionInDays 10 -TableIdentifier $retentionTableIdentifier;

Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -RetentionInDays 11;
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.RetentionInDays 11
Assert-AreEqual $policy.TableIdentifier $retentionTableIdentifier

# Test
$retentionTableIdentifier = "retentionTableIdentifier1" + $testSuffix;
Set-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -StorageAccountName $params.storageAccount -TableIdentifier $retentionTableIdentifier;
$policy = Get-AzureSqlDatabaseServerAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName

# Assert
Assert-AreEqual $policy.RetentionInDays 11
Assert-AreEqual $policy.TableIdentifier $retentionTableIdentifier
}
finally
{
# Cleanup
Remove-TestEnvironment $testSuffix
}
}

<#
.SYNOPSIS
Tests that after setting the retention values to a database auditing policy, this value is used on next policy set operations as default.
#>
function Test-DatabaseRetentionKeepProperties
{
# Setup
$testSuffix = 205
Create-TestEnvironment $testSuffix
$params = Get-SqlAuditingTestEnvironmentParameters $testSuffix

try
{
# Test
$retentionTableIdentifier = "retentionTableIdentifier" + $testSuffix;
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -RetentionInDays 10 -TableIdentifier $retentionTableIdentifier;

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

# Assert
Assert-AreEqual $policy.RetentionInDays 11
Assert-AreEqual $policy.TableIdentifier $retentionTableIdentifier

# Test
$retentionTableIdentifier = "retentionTableIdentifier1" + $testSuffix;
Set-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageAccountName $params.storageAccount -TableIdentifier $retentionTableIdentifier;
$policy = Get-AzureSqlDatabaseAuditingPolicy -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName

# Assert
Assert-AreEqual $policy.RetentionInDays 11
Assert-AreEqual $policy.TableIdentifier $retentionTableIdentifier
}
finally
{
# Cleanup
Remove-TestEnvironment $testSuffix
}
}
Loading

0 comments on commit 0d23979

Please sign in to comment.