Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_security_center_subscription_pricing - correctly type assert additional properties #27721

Merged
merged 3 commits into from
Oct 31, 2024
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 @@ -290,10 +290,16 @@ func expandSecurityCenterSubscriptionPricingExtensions(inputList []interface{},
isEnabled = pricings_v2023_01_01.IsEnabledTrue
}
output := pricings_v2023_01_01.Extension{
Name: extensionName,
IsEnabled: isEnabled,
AdditionalExtensionProperties: pointer.To(extensionProperties),
Name: extensionName,
IsEnabled: isEnabled,
}

if vAdditional, ok := extensionProperties[extensionName]; ok {
props, _ := vAdditional.(*interface{})
p := (*props).(map[string]interface{})
output.AdditionalExtensionProperties = pointer.To(p)
}

outputList = append(outputList, output)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ func TestAccSecurityCenterSubscriptionPricing_cloudPosture(t *testing.T) {
})
}

func TestAccSecurityCenterSubscriptionPricing_storage(t *testing.T) {
acceptance.RunTestsInSequence(t, map[string]map[string]func(t *testing.T){
"securityCenterSubscriptionPricing": {
"subplan": testAccSecurityCenterSubscriptionPricing_storageAccountSubplan,
"defender": testAccSecurityCenterSubscriptionPricing_storageAccountDefender,
},
})
}

func TestAccSecurityCenterSubscriptionPricing_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_security_center_subscription_pricing", "test")
r := SecurityCenterSubscriptionPricingResource{}
Expand Down Expand Up @@ -92,7 +101,7 @@ func TestAccSecurityCenterSubscriptionPricing_cosmosDbs(t *testing.T) {
})
}

func TestAccSecurityCenterSubscriptionPricing_storageAccountSubplan(t *testing.T) {
func testAccSecurityCenterSubscriptionPricing_storageAccountSubplan(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_security_center_subscription_pricing", "test")
r := SecurityCenterSubscriptionPricingResource{}

Expand All @@ -109,6 +118,21 @@ func TestAccSecurityCenterSubscriptionPricing_storageAccountSubplan(t *testing.T
})
}

func testAccSecurityCenterSubscriptionPricing_storageAccountDefender(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_security_center_subscription_pricing", "test")
r := SecurityCenterSubscriptionPricingResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
{
Config: r.storageAccountDefender(),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func testAccSecurityCenterSubscriptionPricing_cloudPostureExtension(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_security_center_subscription_pricing", "test")
r := SecurityCenterSubscriptionPricingResource{}
Expand Down Expand Up @@ -242,6 +266,31 @@ resource "azurerm_security_center_subscription_pricing" "test" {
`
}

func (SecurityCenterSubscriptionPricingResource) storageAccountDefender() string {
return `
provider "azurerm" {
features {}
}
resource "azurerm_security_center_subscription_pricing" "test" {
tier = "Standard"
resource_type = "StorageAccounts"
subplan = "DefenderForStorageV2"
extension {
additional_extension_properties = {
"CapGBPerMonthPerStorageAccount" = "5000"
}
name = "OnUploadMalwareScanning"
}
extension {
name = "SensitiveDataDiscovery"
}
}
`
}

func (SecurityCenterSubscriptionPricingResource) cloudPostureExtension() string {
return `
provider "azurerm" {
Expand Down
Loading