Skip to content

Commit 788ab0d

Browse files
Revert "Revert "fix: zt org test assertions and normalizations""
1 parent 928844a commit 788ab0d

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

internal/services/zero_trust_organization/normalizations.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ func normalizeImportZeroTrustOrganizationAPIData(_ context.Context, data *ZeroTr
4444
data.AutoRedirectToIdentity = types.BoolValue(false)
4545
}
4646

47-
if data.LoginDesign != nil && *data.LoginDesign == (ZeroTrustOrganizationLoginDesignModel{}) {
47+
var empty ZeroTrustOrganizationLoginDesignModel
48+
if data.LoginDesign != nil || *data.LoginDesign == empty {
4849
data.LoginDesign = nil
4950
}
5051

internal/services/zero_trust_organization/resource_test.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/cloudflare/terraform-provider-cloudflare/internal/consts"
1111
"github.com/cloudflare/terraform-provider-cloudflare/internal/utils"
1212
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
13+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
1314
"github.com/hashicorp/terraform-plugin-testing/terraform"
1415
)
1516

@@ -43,7 +44,7 @@ func TestAccCloudflareAccessOrganization(t *testing.T) {
4344
resource.TestCheckResourceAttr(name, "auth_domain", rnd+"-"+testAuthDomain()),
4445
resource.TestCheckResourceAttr(name, "is_ui_read_only", "false"),
4546
resource.TestCheckResourceAttr(name, "user_seat_expiration_inactive_time", "1460h"),
46-
resource.TestCheckNoResourceAttr(name, "auto_redirect_to_identity"),
47+
resource.TestCheckResourceAttr(name, "auto_redirect_to_identity", "false"),
4748
resource.TestCheckResourceAttr(name, "login_design.background_color", "#FFFFFF"),
4849
resource.TestCheckResourceAttr(name, "login_design.text_color", "#000000"),
4950
resource.TestCheckResourceAttr(name, "login_design.logo_path", "https://example.com/logo.png"),
@@ -53,29 +54,33 @@ func TestAccCloudflareAccessOrganization(t *testing.T) {
5354
resource.TestCheckResourceAttr(name, "warp_auth_session_duration", "36h"),
5455
resource.TestCheckResourceAttr(name, "allow_authenticate_via_warp", "false"),
5556
),
56-
ResourceName: name,
57-
ImportState: true,
58-
ImportStateId: accountID,
59-
ImportStateCheck: accessOrgImportStateCheck,
6057
},
6158
{
62-
Config: testAccCloudflareAccessOrganizationConfigBasic(rnd, accountID, headerText+" updated", testAuthDomain()),
59+
Config: testAccCloudflareAccessOrganizationConfigBasic(rnd, accountID, headerText, testAuthDomain()),
6360
Check: resource.ComposeTestCheckFunc(
6461
resource.TestCheckResourceAttr(name, consts.AccountIDSchemaKey, accountID),
6562
resource.TestCheckResourceAttr(name, "name", testAuthDomain()),
6663
resource.TestCheckResourceAttr(name, "auth_domain", rnd+"-"+testAuthDomain()),
6764
resource.TestCheckResourceAttr(name, "is_ui_read_only", "false"),
6865
resource.TestCheckResourceAttr(name, "user_seat_expiration_inactive_time", "1460h"),
69-
resource.TestCheckNoResourceAttr(name, "auto_redirect_to_identity"),
66+
resource.TestCheckResourceAttr(name, "auto_redirect_to_identity", "false"),
7067
resource.TestCheckResourceAttr(name, "login_design.background_color", "#FFFFFF"),
7168
resource.TestCheckResourceAttr(name, "login_design.text_color", "#000000"),
7269
resource.TestCheckResourceAttr(name, "login_design.logo_path", "https://example.com/logo.png"),
73-
resource.TestCheckResourceAttr(name, "login_design.header_text", headerText+" updated"),
70+
resource.TestCheckResourceAttr(name, "login_design.header_text", headerText),
7471
resource.TestCheckResourceAttr(name, "login_design.footer_text", "My footer text"),
7572
resource.TestCheckResourceAttr(name, "session_duration", "12h"),
7673
resource.TestCheckResourceAttr(name, "warp_auth_session_duration", "36h"),
7774
resource.TestCheckResourceAttr(name, "allow_authenticate_via_warp", "false"),
7875
),
76+
ConfigPlanChecks: resource.ConfigPlanChecks{
77+
PreApply: []plancheck.PlanCheck{
78+
plancheck.ExpectResourceAction(name, plancheck.ResourceActionNoop),
79+
plancheck.ExpectEmptyPlan(),
80+
},
81+
},
82+
},
83+
{
7984
ResourceName: name,
8085
ImportState: true,
8186
ImportStateId: accountID,
@@ -95,6 +100,8 @@ func TestAccCloudflareAccessOrganization(t *testing.T) {
95100
resource.TestCheckNoResourceAttr(name, "login_design.header_text"),
96101
resource.TestCheckNoResourceAttr(name, "login_design.footer_text"),
97102
),
103+
},
104+
{
98105
ResourceName: name,
99106
ImportState: true,
100107
ImportStateId: accountID,
@@ -168,7 +175,7 @@ func accessOrgImportStateCheckEmpty(instanceStates []*terraform.InstanceState) e
168175
{field: consts.AccountIDSchemaKey, stateValue: attrs[consts.AccountIDSchemaKey], expectedValue: accountID},
169176
{field: "is_ui_read_only", stateValue: attrs["is_ui_read_only"], expectedValue: "false"},
170177
{field: "auto_redirect_to_identity", stateValue: attrs["auto_redirect_to_identity"], expectedValue: "false"},
171-
{field: "user_seat_expiration_inactive_time", stateValue: attrs["user_seat_expiration_inactive_time"], expectedValue: "1460h"},
178+
{field: "user_seat_expiration_inactive_time", stateValue: attrs["user_seat_expiration_inactive_time"], expectedValue: ""},
172179
}
173180

174181
for _, check := range stateChecks {

0 commit comments

Comments
 (0)