-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2449 from limejuny/feature/email-routing-drop
add `drop` options to email_routing_rule
- Loading branch information
Showing
7 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:enhancement | ||
resource/cloudflare_email_routing_rule: add action type `drop` | ||
``` | ||
|
||
```release-note:enhancement | ||
resource/cloudflare_email_routing_rule: `action.value` is now optional to support `drop` rules not requiring it | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,27 @@ func testEmailRoutingRuleConfig(resourceID, zoneID string, enabled bool, priorit | |
`, resourceID, zoneID, enabled, priority) | ||
} | ||
|
||
func TestAccTestEmailRoutingRule(t *testing.T) { | ||
func testEmailRoutingRuleConfigDrop(resourceID, zoneID string, enabled bool, priority int) string { | ||
return fmt.Sprintf(` | ||
resource "cloudflare_email_routing_rule" "%[1]s" { | ||
zone_id = "%[2]s" | ||
enabled = "%[3]t" | ||
priority = "%[4]d" | ||
name = "%[1]s" | ||
matcher { | ||
field = "to" | ||
type = "literal" | ||
value = "[email protected]" | ||
} | ||
action { | ||
type = "drop" | ||
} | ||
} | ||
`, resourceID, zoneID, enabled, priority) | ||
} | ||
|
||
func TestAccCloudflareEmailRoutingRule_Basic(t *testing.T) { | ||
rnd := generateRandomResourceName() | ||
name := "cloudflare_email_routing_rule." + rnd | ||
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID") | ||
|
@@ -59,3 +79,31 @@ func TestAccTestEmailRoutingRule(t *testing.T) { | |
}, | ||
}) | ||
} | ||
|
||
func TestAccCloudflareEmailRoutingRule_Drop(t *testing.T) { | ||
rnd := generateRandomResourceName() | ||
name := "cloudflare_email_routing_rule." + rnd | ||
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID") | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: providerFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testEmailRoutingRuleConfigDrop(rnd, zoneID, true, 10), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(name, "enabled", "true"), | ||
resource.TestCheckResourceAttr(name, consts.ZoneIDSchemaKey, zoneID), | ||
resource.TestCheckResourceAttr(name, "priority", "10"), | ||
resource.TestCheckResourceAttr(name, "name", rnd), | ||
|
||
resource.TestCheckResourceAttr(name, "matcher.0.type", "literal"), | ||
resource.TestCheckResourceAttr(name, "matcher.0.field", "to"), | ||
resource.TestCheckResourceAttr(name, "matcher.0.value", "[email protected]"), | ||
|
||
resource.TestCheckResourceAttr(name, "action.0.type", "drop"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters