Skip to content

Commit 3a82fbd

Browse files
committed
Merge pull request Azure#1426 from yaakoviyun/dev
Defect: Disable auditing cmdlets should send the resource group and subscription id
2 parents 3d52731 + 925f2b3 commit 3a82fbd

File tree

28 files changed

+11987
-27922
lines changed

28 files changed

+11987
-27922
lines changed

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/AuditingTests.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ function Test-AuditingDatabaseUpdatePolicyWithSameNameStorageOnDifferentRegion
105105
Assert-AreEqual $policy.StorageAccountName $params.storageAccount
106106
Assert-AreEqual $policy.AuditState "Enabled"
107107
Assert-AreEqual $policy.UseServerDefault "Disabled"
108-
109-
110108
}
111109
finally
112110
{
@@ -434,6 +432,7 @@ function Test-AuditingDisableDatabaseAuditing
434432

435433
# Assert
436434
Assert-AreEqual $policy.AuditState "Disabled"
435+
Assert-AreEqual $policy.StorageAccountName $params.storageAccount
437436
}
438437
finally
439438
{

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseDisableEnableKeepProperties.json

Lines changed: 441 additions & 861 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseRetentionKeepProperties.json

Lines changed: 435 additions & 1395 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseStorageKeyRotation.json

Lines changed: 460 additions & 1228 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseUpdatePolicyKeepPreviousStorage.json

Lines changed: 407 additions & 1367 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseUpdatePolicyWithEventTypeShortcuts.json

Lines changed: 526 additions & 2638 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseUpdatePolicyWithEventTypes.json

Lines changed: 449 additions & 929 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseUpdatePolicyWithRetention.json

Lines changed: 355 additions & 1027 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseUpdatePolicyWithStorage.json

Lines changed: 333 additions & 1485 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDatabaseUpdatePolicyWithStorageV2.json

Lines changed: 271 additions & 943 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDisableDatabaseAuditing.json

Lines changed: 761 additions & 461 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingDisableServerAuditing.json

Lines changed: 443 additions & 719 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingFailWithBadDatabaseIndentity.json

Lines changed: 283 additions & 283 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingFailWithBadServerIndentity.json

Lines changed: 627 additions & 243 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingFailedDatabaseUpdatePolicyWithNoStorage.json

Lines changed: 273 additions & 657 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingFailedServerUpdatePolicyWithNoStorage.json

Lines changed: 610 additions & 322 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingFailedUseServerDefault.json

Lines changed: 655 additions & 271 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingServerDisableEnableKeepProperties.json

Lines changed: 447 additions & 1347 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingServerRetentionKeepProperties.json

Lines changed: 376 additions & 1240 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingServerStorageKeyRotation.json

Lines changed: 405 additions & 1077 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingServerUpdatePolicyKeepPreviousStorage.json

Lines changed: 351 additions & 1311 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingServerUpdatePolicyWithEventTypeShortcuts.json

Lines changed: 783 additions & 495 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingServerUpdatePolicyWithEventTypes.json

Lines changed: 385 additions & 1633 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingServerUpdatePolicyWithRetention.json

Lines changed: 347 additions & 1115 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingServerUpdatePolicyWithStorage.json

Lines changed: 319 additions & 1183 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AuditingTests/TestAuditingUseServerDefault.json

Lines changed: 347 additions & 1259 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ThreatDetectionTests/InvalidArgumentsThreatDetection.json

Lines changed: 893 additions & 2411 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql/Auditing/Services/SqlAuditAdapter.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,7 @@ private bool IsEventTypeOn(AuditEventType lookedForType, AuditEventType[] userSe
423423
/// </summary>
424424
private string ExtractStorageAccountTableEndpoint(string storageName, string endpointSuffix)
425425
{
426-
if (IgnoreStorage)
427-
{
428-
return null;
429-
}
430-
if (storageName == FetchedStorageAccountName && FetchedStorageAccountTableEndpoint != null)
426+
if (IgnoreStorage || (storageName == FetchedStorageAccountName && FetchedStorageAccountTableEndpoint != null))
431427
{
432428
return FetchedStorageAccountTableEndpoint;
433429
}
@@ -439,11 +435,7 @@ private string ExtractStorageAccountTableEndpoint(string storageName, string end
439435
/// </summary>
440436
private string ExtractStorageAccountSubscriptionId(string storageName)
441437
{
442-
if (IgnoreStorage)
443-
{
444-
return null;
445-
}
446-
if (storageName == FetchedStorageAccountName && FetchedStorageAccountSubscription != null)
438+
if (IgnoreStorage || (storageName == FetchedStorageAccountName && FetchedStorageAccountSubscription != null))
447439
{
448440
return FetchedStorageAccountSubscription;
449441
}
@@ -455,11 +447,7 @@ private string ExtractStorageAccountSubscriptionId(string storageName)
455447
/// </summary>
456448
private string ExtractStorageAccountResourceGroup(string storageName)
457449
{
458-
if (IgnoreStorage)
459-
{
460-
return null;
461-
}
462-
if (storageName == FetchedStorageAccountName && FetchedStorageAccountResourceGroup != null)
450+
if (IgnoreStorage || (storageName == FetchedStorageAccountName && FetchedStorageAccountResourceGroup != null))
463451
{
464452
return FetchedStorageAccountResourceGroup;
465453
}
@@ -471,11 +459,7 @@ private string ExtractStorageAccountResourceGroup(string storageName)
471459
/// </summary>
472460
private string ExtractStorageAccountKey(string storageName, BaseAuditingPolicyModel model, string storageAccountResourceGroup, StorageKeyKind keyType)
473461
{
474-
if (IgnoreStorage)
475-
{
476-
return null;
477-
}
478-
if (model.StorageKeyType == keyType)
462+
if (IgnoreStorage || (model.StorageKeyType == keyType))
479463
{
480464
return AzureCommunicator.GetStorageKeys(storageAccountResourceGroup, storageName)[keyType];
481465
}

0 commit comments

Comments
 (0)