Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Initial Check-in...

* Fix error message grammar...

* Fix the same error message again...

* Initial Check-in...
  • Loading branch information
WodansSon authored Sep 28, 2023
1 parent 09cadb0 commit dd4864c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
47 changes: 47 additions & 0 deletions internal/services/cdn/cdn_frontdoor_rule_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit dd4864c

Please sign in to comment.