Skip to content

Commit

Permalink
Merge pull request #3602 from anordby/replace_insecure_js_zone_settin…
Browse files Browse the repository at this point in the history
…gs_toggle

chore: Add replace_insecure_js zone_settings_override toggle.
  • Loading branch information
jacobbednarz authored Sep 4, 2024
2 parents 438e904 + 5e57f8e commit 71b5afc
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/3602.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/cloudflare_zone_settings_override: Add optional setting `replace_insecure_js`
```
2 changes: 2 additions & 0 deletions docs/resources/zone_settings_override.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Optional:
- `privacy_pass` (String)
- `proxy_read_timeout` (String)
- `pseudo_ipv4` (String)
- `replace_insecure_js` (String)
- `response_buffering` (String)
- `rocket_loader` (String)
- `security_header` (Block List, Max: 1) (see [below for nested schema](#nestedblock--settings--security_header))
Expand Down Expand Up @@ -222,6 +223,7 @@ Read-Only:
- `privacy_pass` (String)
- `proxy_read_timeout` (String)
- `pseudo_ipv4` (String)
- `replace_insecure_js` (String)
- `response_buffering` (String)
- `rocket_loader` (String)
- `security_header` (List of Object) (see [below for nested schema](#nestedobjatt--initial_settings--security_header))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var fetchAsSingleSetting = []string{
"origin_max_http_version",
"fonts",
"nel",
"replace_insecure_js",
}

func resourceCloudflareZoneSettingsOverrideCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,36 @@ resource "cloudflare_zone_settings_override" "%[1]s" {
}`, rnd, zoneID)
}

func TestAccCloudflareZoneSettingsOverride_ReplaceInsecureJS(t *testing.T) {
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID")
rnd := generateRandomResourceName()
name := "cloudflare_zone_settings_override." + rnd

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testAccCheckCloudflareZoneSettingsOverrideReplaceInsecureJS(rnd, zoneID),
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudflareZoneSettings(name),
resource.TestCheckResourceAttr(name, "settings.0.replace_insecure_js", "on"),
),
},
},
})
}

func testAccCheckCloudflareZoneSettingsOverrideReplaceInsecureJS(rnd, zoneID string) string {
return fmt.Sprintf(`
resource "cloudflare_zone_settings_override" "%[1]s" {
zone_id = "%[2]s"
settings {
replace_insecure_js = "on"
}
}`, rnd, zoneID)
}

func TestCloudflareZoneSettingsOverrideStateUpgradeV0(t *testing.T) {
v0 := map[string]interface{}{
"settings": []interface{}{map[string]interface{}{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ var resourceCloudflareZoneSettingsSchema = map[string]*schema.Schema{
Computed: true,
},

"replace_insecure_js": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"on", "off"}, false),
Optional: true,
Computed: true,
},

"response_buffering": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"on", "off"}, false),
Expand Down

0 comments on commit 71b5afc

Please sign in to comment.