Skip to content

Commit c8a6b0b

Browse files
chore(zero_trust_access_group): e2e test case (#294)
1 parent dc0177c commit c8a6b0b

3 files changed

Lines changed: 103 additions & 0 deletions

File tree

e2e-v5/testdata/zero_trust_access_group/zero_trust_access_group.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,41 @@ resource "cloudflare_zero_trust_access_group" "child" {
470470
}
471471

472472

473+
# Pattern 23: Already-renamed v4 resource (exercises UpgradeState path, not MoveState)
474+
resource "cloudflare_zero_trust_access_group" "cftftest_upgrade_state_boolean" {
475+
account_id = var.cloudflare_account_id
476+
name = "${local.name_prefix} UpgradeState Boolean Group"
477+
478+
include = [
479+
{
480+
any_valid_service_token = {}
481+
},
482+
]
483+
}
484+
485+
# Pattern 24: Already-renamed v4 resource with multiple selectors (UpgradeState path)
486+
resource "cloudflare_zero_trust_access_group" "cftftest_upgrade_state_mixed" {
487+
account_id = var.cloudflare_account_id
488+
name = "${local.name_prefix} UpgradeState Mixed Group"
489+
490+
491+
include = [
492+
{
493+
email = {
494+
email = "admin@example.com"
495+
}
496+
},
497+
{
498+
everyone = {}
499+
},
500+
]
501+
exclude = [
502+
{
503+
certificate = {}
504+
},
505+
]
506+
}
507+
473508
variable "from_version" {
474509
description = "Provider version under test, used to namespace resource names"
475510
type = string

integration/v4_to_v5/testdata/zero_trust_access_group/expected/zero_trust_access_group.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,45 @@ locals {
3838

3939

4040

41+
42+
# Pattern 23: Already-renamed v4 resource (exercises UpgradeState path, not MoveState)
43+
# When the v4 config already uses cloudflare_zero_trust_access_group (the newer v4 name),
44+
# tf-migrate does NOT generate a moved {} block. During v5 apply, Terraform triggers
45+
# UpgradeState (not MoveState) to migrate the v4 state. This is the exact scenario
46+
# that fails in APIX-741 when any_valid_service_token is a boolean in state.
47+
resource "cloudflare_zero_trust_access_group" "cftftest_upgrade_state_boolean" {
48+
account_id = var.cloudflare_account_id
49+
name = "${local.name_prefix} UpgradeState Boolean Group"
50+
51+
include = [
52+
{
53+
any_valid_service_token = {}
54+
},
55+
]
56+
}
57+
58+
# Pattern 24: Already-renamed v4 resource with multiple selectors (UpgradeState path)
59+
resource "cloudflare_zero_trust_access_group" "cftftest_upgrade_state_mixed" {
60+
account_id = var.cloudflare_account_id
61+
name = "${local.name_prefix} UpgradeState Mixed Group"
62+
63+
64+
include = [
65+
{
66+
email = {
67+
email = "admin@example.com"
68+
}
69+
},
70+
{
71+
everyone = {}
72+
},
73+
]
74+
exclude = [
75+
{
76+
certificate = {}
77+
},
78+
]
79+
}
4180

4281
# Pattern 1: Simple email selector
4382
resource "cloudflare_zero_trust_access_group" "simple_email" {

integration/v4_to_v5/testdata/zero_trust_access_group/input/zero_trust_access_group.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,32 @@ resource "cloudflare_access_group" "auth_context" {
296296
}
297297
}
298298
}
299+
300+
# Pattern 23: Already-renamed v4 resource (exercises UpgradeState path, not MoveState)
301+
# When the v4 config already uses cloudflare_zero_trust_access_group (the newer v4 name),
302+
# tf-migrate does NOT generate a moved {} block. During v5 apply, Terraform triggers
303+
# UpgradeState (not MoveState) to migrate the v4 state. This is the exact scenario
304+
# that fails in APIX-741 when any_valid_service_token is a boolean in state.
305+
resource "cloudflare_zero_trust_access_group" "cftftest_upgrade_state_boolean" {
306+
account_id = var.cloudflare_account_id
307+
name = "${local.name_prefix} UpgradeState Boolean Group"
308+
309+
include {
310+
any_valid_service_token = true
311+
}
312+
}
313+
314+
# Pattern 24: Already-renamed v4 resource with multiple selectors (UpgradeState path)
315+
resource "cloudflare_zero_trust_access_group" "cftftest_upgrade_state_mixed" {
316+
account_id = var.cloudflare_account_id
317+
name = "${local.name_prefix} UpgradeState Mixed Group"
318+
319+
include {
320+
email = ["admin@example.com"]
321+
everyone = true
322+
}
323+
324+
exclude {
325+
certificate = true
326+
}
327+
}

0 commit comments

Comments
 (0)