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] 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 e391f68ef1c9..bbd08c92ee99 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 6f0ec138a383..d7402c9031dd 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 }