Skip to content

Commit f08a4f0

Browse files
committed
Revert "test: improved zone acceptance test coverage (#251)"
This reverts commit 19900b7.
1 parent 890d693 commit f08a4f0

File tree

7 files changed

+75
-170
lines changed

7 files changed

+75
-170
lines changed

internal/services/zone/resource_test.go

Lines changed: 52 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ import (
1010
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1111
)
1212

13+
const (
14+
planIDFree = "free"
15+
planIDLite = "lite"
16+
planIDPro = "pro"
17+
planIDProPlus = "pro_plus"
18+
planIDBusiness = "business"
19+
planIDEnterprise = "enterprise"
20+
21+
planIDPartnerFree = "partners_free"
22+
planIDPartnerPro = "partners_pro"
23+
planIDPartnerBusiness = "partners_business"
24+
planIDPartnerEnterprise = "partners_enterprise"
25+
)
26+
1327
func TestAccCloudflareZone_Basic(t *testing.T) {
1428
rnd := utils.GenerateRandomResourceName()
1529
name := "cloudflare_zone." + rnd
@@ -20,30 +34,19 @@ func TestAccCloudflareZone_Basic(t *testing.T) {
2034
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
2135
Steps: []resource.TestStep{
2236
{
23-
Config: testZoneConfig(rnd, fmt.Sprintf("%s.cfapi.net", rnd), accountID),
37+
Config: testZoneConfig(rnd, fmt.Sprintf("%s.cfapi.net", rnd), "true", "false", accountID),
2438
Check: resource.ComposeTestCheckFunc(
2539
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.cfapi.net", rnd)),
2640
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
2741
resource.TestCheckResourceAttr(name, "type", "full"),
28-
// Check development_mode
29-
resource.TestCheckResourceAttr(name, "development_mode", "0"),
30-
// Spot-check zone metadata
31-
resource.TestCheckResourceAttr(name, "meta.phishing_detected", "false"),
32-
// Check owner information
33-
resource.TestCheckResourceAttr(name, "owner.id", accountID), resource.TestCheckResourceAttrSet(name, "owner.name"),
34-
resource.TestCheckResourceAttr(name, "owner.type", "organization"),
3542
),
3643
},
37-
{
38-
ResourceName: name,
39-
ImportState: true,
40-
ImportStateVerify: true,
41-
},
4244
},
4345
})
4446
}
4547

46-
func TestAccCloudflareZone_PartialSetup(t *testing.T) {
48+
func TestAccCloudflareZone_WithPlan(t *testing.T) {
49+
t.Skip(`FIXME: {"success":false,"errors":[{"code":10000,"message":"Authentication error"}]}`)
4750
rnd := utils.GenerateRandomResourceName()
4851
name := "cloudflare_zone." + rnd
4952
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID")
@@ -53,23 +56,18 @@ func TestAccCloudflareZone_PartialSetup(t *testing.T) {
5356
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
5457
Steps: []resource.TestStep{
5558
{
56-
Config: testZoneConfigWithTypeSetup(rnd, accountID, fmt.Sprintf("%s.net", rnd), "partial"),
59+
Config: testZoneConfigWithPlan(rnd, fmt.Sprintf("%s.cfapi.net", rnd), "true", "false", "free", accountID),
5760
Check: resource.ComposeTestCheckFunc(
58-
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.net", rnd)),
59-
resource.TestCheckResourceAttr(name, "type", "partial"),
60-
resource.TestCheckResourceAttrSet(name, "verification_key"),
61-
resource.TestCheckResourceAttr(name, "name_servers.#", "0"),
61+
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.cfapi.net", rnd)),
62+
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
63+
resource.TestCheckResourceAttr(name, "type", "full"),
6264
),
6365
},
64-
{
65-
ResourceName: name,
66-
ImportState: true,
67-
ImportStateVerify: true,
68-
},
69-
}})
66+
},
67+
})
7068
}
7169

72-
func TestAccCloudflareZone_FullSetup(t *testing.T) {
70+
func TestAccCloudflareZone_PartialSetup(t *testing.T) {
7371
rnd := utils.GenerateRandomResourceName()
7472
name := "cloudflare_zone." + rnd
7573
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID")
@@ -79,23 +77,17 @@ func TestAccCloudflareZone_FullSetup(t *testing.T) {
7977
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
8078
Steps: []resource.TestStep{
8179
{
82-
Config: testZoneConfigWithTypeSetup(rnd, accountID, fmt.Sprintf("%s.cfapi.net", rnd), "full"),
80+
Config: testZoneConfigWithTypeSetup(rnd, "foo.net", "true", "false", "free", accountID, "partial"),
8381
Check: resource.ComposeTestCheckFunc(
84-
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.cfapi.net", rnd)),
85-
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
86-
resource.TestCheckResourceAttr(name, "type", "full"),
82+
resource.TestCheckResourceAttr(name, "name", "foo.net"),
83+
resource.TestCheckResourceAttr(name, "type", "partial"),
8784
),
8885
},
89-
{
90-
ResourceName: name,
91-
ImportState: true,
92-
ImportStateVerify: true,
93-
},
9486
},
9587
})
9688
}
9789

98-
func TestAccZoneWithUnicodeIsStoredAsUnicode(t *testing.T) {
90+
func TestAccCloudflareZone_FullSetup(t *testing.T) {
9991
rnd := utils.GenerateRandomResourceName()
10092
name := "cloudflare_zone." + rnd
10193
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID")
@@ -105,23 +97,18 @@ func TestAccZoneWithUnicodeIsStoredAsUnicode(t *testing.T) {
10597
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
10698
Steps: []resource.TestStep{
10799
{
108-
Config: testZoneConfig(rnd, "żółw.cfapi.net", accountID),
100+
Config: testZoneConfigWithTypeSetup(rnd, fmt.Sprintf("%s.cfapi.net", rnd), "true", "false", "free", accountID, "full"),
109101
Check: resource.ComposeTestCheckFunc(
110-
resource.TestCheckResourceAttr(name, "name", "żółw.cfapi.net"),
102+
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.cfapi.net", rnd)),
111103
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
112104
resource.TestCheckResourceAttr(name, "type", "full"),
113105
),
114106
},
115-
{
116-
ResourceName: name,
117-
ImportState: true,
118-
ImportStateVerify: true,
119-
},
120107
},
121108
})
122109
}
123110

124-
func TestAccZoneWithoutUnicodeIsStoredAsUnicode(t *testing.T) {
111+
func TestAccZoneWithUnicodeIsStoredAsUnicode(t *testing.T) {
125112
rnd := utils.GenerateRandomResourceName()
126113
name := "cloudflare_zone." + rnd
127114
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID")
@@ -131,23 +118,18 @@ func TestAccZoneWithoutUnicodeIsStoredAsUnicode(t *testing.T) {
131118
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
132119
Steps: []resource.TestStep{
133120
{
134-
Config: testZoneConfig(rnd, "xn--w-uga1v8h.cfapi.net", accountID),
121+
Config: testZoneConfig(rnd, "żółw.cfapi.net", "true", "false", accountID),
135122
Check: resource.ComposeTestCheckFunc(
136123
resource.TestCheckResourceAttr(name, "name", "żółw.cfapi.net"),
137124
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
138125
resource.TestCheckResourceAttr(name, "type", "full"),
139126
),
140127
},
141-
{
142-
ResourceName: name,
143-
ImportState: true,
144-
ImportStateVerify: true,
145-
},
146128
},
147129
})
148130
}
149131

150-
func TestAccZonePerformsUnicodeComparison(t *testing.T) {
132+
func TestAccCloudflareZone_WithEnterprisePlan(t *testing.T) {
151133
rnd := utils.GenerateRandomResourceName()
152134
name := "cloudflare_zone." + rnd
153135
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID")
@@ -157,33 +139,20 @@ func TestAccZonePerformsUnicodeComparison(t *testing.T) {
157139
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
158140
Steps: []resource.TestStep{
159141
{
160-
Config: testZoneConfig(rnd, "żółw.cfapi.net", accountID),
161-
Check: resource.ComposeTestCheckFunc(
162-
resource.TestCheckResourceAttr(name, "name", "żółw.cfapi.net"),
163-
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
164-
resource.TestCheckResourceAttr(name, "type", "full"),
165-
),
166-
},
167-
{
168-
Config: testZoneConfig(rnd, "xn--w-uga1v8h.cfapi.net", accountID),
169-
PlanOnly: true,
142+
Config: testZoneConfigWithTypeSetup(rnd, fmt.Sprintf("%s.cfapi.net", rnd), "false", "false", "enterprise", accountID, "full"),
170143
Check: resource.ComposeTestCheckFunc(
171-
resource.TestCheckResourceAttr(name, "name", "żółw.cfapi.net"),
144+
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.cfapi.net", rnd)),
145+
resource.TestCheckResourceAttr(name, "paused", "false"),
172146
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
173147
resource.TestCheckResourceAttr(name, "type", "full"),
174148
),
175149
},
176-
{
177-
ResourceName: name,
178-
ImportState: true,
179-
ImportStateVerify: true,
180-
},
181150
},
182151
})
183152
}
184153

185154
func TestAccCloudflareZone_WithEnterprisePlanVanityNameServers(t *testing.T) {
186-
acctest.TestAccSkipForDefaultAccount(t, "Need working zone_subscription to create enterprise plan before setting vanity name servers")
155+
acctest.TestAccSkipForDefaultAccount(t, "Pending investigation into vanity nameserver mismatches.")
187156

188157
rnd := utils.GenerateRandomResourceName()
189158
name := "cloudflare_zone." + rnd
@@ -195,7 +164,7 @@ func TestAccCloudflareZone_WithEnterprisePlanVanityNameServers(t *testing.T) {
195164
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
196165
Steps: []resource.TestStep{
197166
{
198-
Config: testZoneConfigWithTypeVanityNameServersSetup(rnd, accountID, fmt.Sprintf("%s.%s", rnd, zoneName), "full"),
167+
Config: testZoneConfigWithTypeVanityNameServersSetup(rnd, fmt.Sprintf("%s.%s", rnd, zoneName), "false", "false", "enterprise", accountID, "full"),
199168
Check: resource.ComposeTestCheckFunc(
200169
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.%s", rnd, zoneName)),
201170
resource.TestCheckResourceAttr(name, "paused", "false"),
@@ -204,11 +173,6 @@ func TestAccCloudflareZone_WithEnterprisePlanVanityNameServers(t *testing.T) {
204173
resource.TestCheckResourceAttr(name, "vanity_name_servers.#", "2"),
205174
),
206175
},
207-
{
208-
ResourceName: name,
209-
ImportState: true,
210-
ImportStateVerify: true,
211-
},
212176
},
213177
})
214178
}
@@ -224,24 +188,19 @@ func TestAccCloudflareZone_Secondary(t *testing.T) {
224188
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
225189
Steps: []resource.TestStep{
226190
{
227-
Config: testZoneConfigWithTypeSetup(rnd, accountID, fmt.Sprintf("%s.%s", rnd, zoneName), "secondary"),
191+
Config: testZoneConfigWithTypeSetup(rnd, fmt.Sprintf("%s.%s", rnd, zoneName), "true", "false", "enterprise", accountID, "secondary"),
228192
Check: resource.ComposeTestCheckFunc(
229193
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.%s", rnd, zoneName)),
230194
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
231195
resource.TestCheckResourceAttr(name, "type", "secondary"),
232196
),
233197
},
234-
{
235-
ResourceName: name,
236-
ImportState: true,
237-
ImportStateVerify: true,
238-
},
239198
},
240199
})
241200
}
242201

243202
func TestAccCloudflareZone_SecondaryWithVanityNameServers(t *testing.T) {
244-
acctest.TestAccSkipForDefaultAccount(t, "Need working zone_subscription to create enterprise plan before setting vanity name servers")
203+
acctest.TestAccSkipForDefaultAccount(t, "Pending investigation into vanity nameserver mismatches.")
245204

246205
rnd := utils.GenerateRandomResourceName()
247206
name := "cloudflare_zone." + rnd
@@ -253,66 +212,24 @@ func TestAccCloudflareZone_SecondaryWithVanityNameServers(t *testing.T) {
253212
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
254213
Steps: []resource.TestStep{
255214
{
256-
Config: testZoneConfigWithTypeVanityNameServersSetup(rnd, accountID, fmt.Sprintf("%s.%s", rnd, zoneName), "secondary"),
215+
Config: testZoneConfigWithTypeVanityNameServersSetup(rnd, fmt.Sprintf("%s.%s", rnd, zoneName), "true", "false", "enterprise", accountID, "secondary"),
257216
Check: resource.ComposeTestCheckFunc(
258217
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.%s", rnd, zoneName)),
259218
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
260219
resource.TestCheckResourceAttr(name, "type", "secondary"),
261220
resource.TestCheckResourceAttr(name, "vanity_name_servers.#", "2"),
262221
),
263222
},
264-
{
265-
ResourceName: name,
266-
ImportState: true,
267-
ImportStateVerify: true,
268-
},
269223
},
270224
})
271225
}
272226

273-
func TestAccCloudflareZone_TogglePaused(t *testing.T) {
274-
rnd := utils.GenerateRandomResourceName()
275-
name := "cloudflare_zone." + rnd
276-
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID")
227+
func testZoneConfig(resourceID, zoneName, paused, jumpStart, accountID string) string {
228+
return acctest.LoadTestCase("zoneconfig.tf", resourceID, zoneName, paused, jumpStart, accountID)
229+
}
277230

278-
resource.Test(t, resource.TestCase{
279-
PreCheck: func() { acctest.TestAccPreCheck(t) },
280-
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
281-
Steps: []resource.TestStep{
282-
{
283-
Config: testZoneConfigWithPaused(rnd, accountID, fmt.Sprintf("%s.cfapi.net", rnd), false),
284-
Check: resource.ComposeTestCheckFunc(
285-
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.cfapi.net", rnd)),
286-
resource.TestCheckResourceAttr(name, "paused", "false"),
287-
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
288-
resource.TestCheckResourceAttr(name, "type", "full"),
289-
),
290-
},
291-
{
292-
Config: testZoneConfigWithPaused(rnd, accountID, fmt.Sprintf("%s.cfapi.net", rnd), true),
293-
Check: resource.ComposeTestCheckFunc(
294-
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.cfapi.net", rnd)),
295-
resource.TestCheckResourceAttr(name, "paused", "true"),
296-
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
297-
resource.TestCheckResourceAttr(name, "type", "full"),
298-
),
299-
},
300-
{
301-
Config: testZoneConfigWithPaused(rnd, accountID, fmt.Sprintf("%s.cfapi.net", rnd), false),
302-
Check: resource.ComposeTestCheckFunc(
303-
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s.cfapi.net", rnd)),
304-
resource.TestCheckResourceAttr(name, "paused", "false"),
305-
resource.TestCheckResourceAttr(name, "name_servers.#", "2"),
306-
resource.TestCheckResourceAttr(name, "type", "full"),
307-
),
308-
},
309-
{
310-
ResourceName: name,
311-
ImportState: true,
312-
ImportStateVerify: true,
313-
},
314-
},
315-
})
231+
func testZoneConfigWithPlan(resourceID, zoneName, paused, jumpStart, plan, accountID string) string {
232+
return acctest.LoadTestCase("zoneconfigwithplan.tf", resourceID, zoneName, paused, jumpStart, plan, accountID)
316233
}
317234

318235
func TestAccCloudflareZone_SetType(t *testing.T) {
@@ -325,35 +242,22 @@ func TestAccCloudflareZone_SetType(t *testing.T) {
325242
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
326243
Steps: []resource.TestStep{
327244
{
328-
Config: testZoneConfigWithTypeSetup(rnd, accountID, fmt.Sprintf("%s.%s", rnd, zoneName), "full"),
245+
Config: testZoneConfigWithTypeSetup(rnd, fmt.Sprintf("%s.%s", rnd, zoneName), "true", "false", "enterprise", accountID, "full"),
329246
},
330247
{
331-
Config: testZoneConfigWithTypeSetup(rnd, accountID, fmt.Sprintf("%s.%s", rnd, zoneName), "partial"),
248+
Config: testZoneConfigWithTypeSetup(rnd, fmt.Sprintf("%s.%s", rnd, zoneName), "true", "false", "enterprise", accountID, "partial"),
332249
Check: resource.ComposeTestCheckFunc(
333250
resource.TestCheckResourceAttr(name, "type", "partial"),
334251
),
335252
},
336-
{
337-
ResourceName: name,
338-
ImportState: true,
339-
ImportStateVerify: true,
340-
},
341253
},
342254
})
343255
}
344256

345-
func testZoneConfig(resourceID, zoneName, accountID string) string {
346-
return acctest.LoadTestCase("zoneconfig.tf", resourceID, zoneName, accountID)
347-
}
348-
349-
func testZoneConfigWithTypeSetup(resourceID, accountID, zoneName, zoneType string) string {
350-
return acctest.LoadTestCase("zoneconfigwithtypesetup.tf", resourceID, accountID, zoneName, zoneType)
351-
}
352-
353-
func testZoneConfigWithTypeVanityNameServersSetup(resourceID, accountID, zoneName, zoneType string) string {
354-
return acctest.LoadTestCase("zoneconfigwithtypevanitynameserverssetup.tf", resourceID, accountID, zoneName, zoneType)
257+
func testZoneConfigWithTypeSetup(resourceID, zoneName, paused, jumpStart, plan, accountID, zoneType string) string {
258+
return acctest.LoadTestCase("zoneconfigwithtypesetup.tf", resourceID, zoneName, paused, jumpStart, plan, accountID, zoneType)
355259
}
356260

357-
func testZoneConfigWithPaused(resourceID, accountID, zoneName string, paused bool) string {
358-
return acctest.LoadTestCase("zoneconfigwithpaused.tf", resourceID, accountID, zoneName, paused)
261+
func testZoneConfigWithTypeVanityNameServersSetup(resourceID, zoneName, paused, jumpStart, plan, accountID, zoneType string) string {
262+
return acctest.LoadTestCase("zoneconfigwithtypevanitynameserverssetup.tf", resourceID, zoneName, paused, jumpStart, plan, accountID, zoneType)
359263
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
resource "cloudflare_zone" "%[1]s" {
33
account = {
4-
id = "%[3]s"
4+
id = "%[5]s"
55
}
66
name = "%[2]s"
77
}

internal/services/zone/testdata/zoneconfigwithpaused.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)