Skip to content

Commit

Permalink
azurerm_storage_account - empty allowed_headers and exposed_headers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alvintang authored May 13, 2021
1 parent 5099e03 commit 0af7724
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
8 changes: 4 additions & 4 deletions azurerm/internal/services/storage/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ func schemaStorageAccountCorsRule(patchEnabled bool) *schema.Schema {
Type: schema.TypeList,
Required: true,
MaxItems: 64,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
Type: schema.TypeString,
},
},
"allowed_headers": {
Type: schema.TypeList,
Required: true,
MaxItems: 64,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
Type: schema.TypeString,
},
},
"allowed_methods": {
Expand Down
51 changes: 51 additions & 0 deletions azurerm/internal/services/storage/storage_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,23 @@ func TestAccStorageAccount_blobProperties(t *testing.T) {
})
}

func TestAccStorageAccount_blobPropertiesEmptyAllowedExposedHeaders(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.blobPropertiesUpdatedEmptyAllowedExposedHeaders(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("blob_properties.0.cors_rule.#").HasValue("1"),
check.That(data.ResourceName).Key("blob_properties.0.cors_rule.0.allowed_headers.#").HasValue("1"),
check.That(data.ResourceName).Key("blob_properties.0.cors_rule.0.exposed_headers.#").HasValue("1"),
),
},
})
}

func TestAccStorageAccount_queueProperties(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}
Expand Down Expand Up @@ -1838,6 +1855,40 @@ resource "azurerm_storage_account" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r StorageAccountResource) blobPropertiesUpdatedEmptyAllowedExposedHeaders(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestAzureRMSA-%d"
location = "%s"
}
resource "azurerm_storage_account" "test" {
name = "unlikely23exst2acct%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
enable_https_traffic_only = true
allow_blob_public_access = true
blob_properties {
cors_rule {
allowed_headers = [""]
exposed_headers = [""]
allowed_origins = ["*"]
allowed_methods = ["GET"]
max_age_in_seconds = 3600
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r StorageAccountResource) queueProperties(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down

0 comments on commit 0af7724

Please sign in to comment.