From dd4864c5726e9ad03d4123c25c233fa554d2f05a Mon Sep 17 00:00:00 2001 From: Wodans Son <20408400+WodansSon@users.noreply.github.com> Date: Wed, 27 Sep 2023 19:31:50 -0600 Subject: [PATCH 1/2] including #23384 fixes #23376 * Initial Check-in... * Fix error message grammar... * Fix the same error message again... * Initial Check-in... --- .../cdn/cdn_frontdoor_rule_resource_test.go | 47 +++++++++++++++++++ .../validate/front_door_validation_helpers.go | 4 -- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/internal/services/cdn/cdn_frontdoor_rule_resource_test.go b/internal/services/cdn/cdn_frontdoor_rule_resource_test.go index e391f68ef1c99..bbd08c92ee993 100644 --- a/internal/services/cdn/cdn_frontdoor_rule_resource_test.go +++ b/internal/services/cdn/cdn_frontdoor_rule_resource_test.go @@ -48,6 +48,21 @@ func TestAccCdnFrontDoorRule_cacheDuration(t *testing.T) { }) } +func TestAccCdnFrontDoorRule_cacheDurationZero(t *testing.T) { + // NOTE: Regression test case for issue #23376 + data := acceptance.BuildTestData(t, "azurerm_cdn_frontdoor_rule", "test") + r := CdnFrontDoorRuleResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.cacheDurationZero(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccCdnFrontDoorRule_urlRedirectAction(t *testing.T) { // NOTE: Regression test case for issue #18249 data := acceptance.BuildTestData(t, "azurerm_cdn_frontdoor_rule", "test") @@ -503,6 +518,38 @@ resource "azurerm_cdn_frontdoor_rule" "test" { `, template, data.RandomInteger) } +func (r CdnFrontDoorRuleResource) cacheDurationZero(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_cdn_frontdoor_rule" "test" { + depends_on = [azurerm_cdn_frontdoor_origin_group.test, azurerm_cdn_frontdoor_origin.test] + + name = "accTestRule%d" + cdn_frontdoor_rule_set_id = azurerm_cdn_frontdoor_rule_set.test.id + + order = 0 + + actions { + route_configuration_override_action { + cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.test.id + forwarding_protocol = "HttpsOnly" + query_string_caching_behavior = "IncludeSpecifiedQueryStrings" + query_string_parameters = ["foo", "clientIp={client_ip}"] + compression_enabled = true + cache_behavior = "OverrideIfOriginMissing" + cache_duration = "00:00:00" + } + } +} +`, template, data.RandomInteger) +} + func (r CdnFrontDoorRuleResource) urlRedirectAction(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` diff --git a/internal/services/cdn/validate/front_door_validation_helpers.go b/internal/services/cdn/validate/front_door_validation_helpers.go index 6f0ec138a3833..d7402c9031dd8 100644 --- a/internal/services/cdn/validate/front_door_validation_helpers.go +++ b/internal/services/cdn/validate/front_door_validation_helpers.go @@ -50,10 +50,6 @@ func CdnFrontDoorCacheDuration(i interface{}, k string) (_ []string, errors []er return nil, []error{fmt.Errorf(`%q must be in the d.HH:MM:SS or HH:MM:SS format and must be equal to or lower than %q, got %q`, k, "365.23:59:59", v)} } - if v == "00:00:00" { - return nil, []error{fmt.Errorf(`%q must be longer than zero seconds, got %q`, k, v)} - } - return nil, nil } From f93d250ade87120d0fd7369ea415c51676306a62 Mon Sep 17 00:00:00 2001 From: Wodans Son <20408400+WodansSon@users.noreply.github.com> Date: Wed, 27 Sep 2023 19:33:17 -0600 Subject: [PATCH 2/2] updating to include #23384 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e85d0662de424..d436300c63cc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ FEATURES: BUG FIXES: -* `azurerm_api_management_api` : fix importing `openapi` format content file issue [GH-23348] +* `azurerm_api_management_api` - fix importing `openapi` format content file issue [GH-23348] +* `azurerm_cdn_frontdoor_rule` - allow a `cache_duration` of `00:00:00` [GH-23384] * `azurerm_palo_alto_local_rulestack_prefix_list` - fix rulestack not being committed on delete [GH-23362] * `azurerm_palo_alto_local_rulestack_fqdn_list` - fix rulestack not being committed on delete [GH-23362] * `security_center_subscription_pricing_resource` - disabled extensions logic now works as expected [GH-22997]