Skip to content

Commit 7041a0d

Browse files
Revert "fix: zt org test assertions and normalizations"
1 parent b8c0f2c commit 7041a0d

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

internal/services/zero_trust_organization/normalizations.go

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

47-
var empty ZeroTrustOrganizationLoginDesignModel
48-
if data.LoginDesign != nil || *data.LoginDesign == empty {
47+
if data.LoginDesign != nil && *data.LoginDesign == (ZeroTrustOrganizationLoginDesignModel{}) {
4948
data.LoginDesign = nil
5049
}
5150

internal/services/zero_trust_organization/resource_test.go

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ 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"
1413
"github.com/hashicorp/terraform-plugin-testing/terraform"
1514
)
1615

@@ -44,7 +43,7 @@ func TestAccCloudflareAccessOrganization(t *testing.T) {
4443
resource.TestCheckResourceAttr(name, "auth_domain", rnd+"-"+testAuthDomain()),
4544
resource.TestCheckResourceAttr(name, "is_ui_read_only", "false"),
4645
resource.TestCheckResourceAttr(name, "user_seat_expiration_inactive_time", "1460h"),
47-
resource.TestCheckResourceAttr(name, "auto_redirect_to_identity", "false"),
46+
resource.TestCheckNoResourceAttr(name, "auto_redirect_to_identity"),
4847
resource.TestCheckResourceAttr(name, "login_design.background_color", "#FFFFFF"),
4948
resource.TestCheckResourceAttr(name, "login_design.text_color", "#000000"),
5049
resource.TestCheckResourceAttr(name, "login_design.logo_path", "https://example.com/logo.png"),
@@ -54,33 +53,29 @@ func TestAccCloudflareAccessOrganization(t *testing.T) {
5453
resource.TestCheckResourceAttr(name, "warp_auth_session_duration", "36h"),
5554
resource.TestCheckResourceAttr(name, "allow_authenticate_via_warp", "false"),
5655
),
56+
ResourceName: name,
57+
ImportState: true,
58+
ImportStateId: accountID,
59+
ImportStateCheck: accessOrgImportStateCheck,
5760
},
5861
{
59-
Config: testAccCloudflareAccessOrganizationConfigBasic(rnd, accountID, headerText, testAuthDomain()),
62+
Config: testAccCloudflareAccessOrganizationConfigBasic(rnd, accountID, headerText+" updated", testAuthDomain()),
6063
Check: resource.ComposeTestCheckFunc(
6164
resource.TestCheckResourceAttr(name, consts.AccountIDSchemaKey, accountID),
6265
resource.TestCheckResourceAttr(name, "name", testAuthDomain()),
6366
resource.TestCheckResourceAttr(name, "auth_domain", rnd+"-"+testAuthDomain()),
6467
resource.TestCheckResourceAttr(name, "is_ui_read_only", "false"),
6568
resource.TestCheckResourceAttr(name, "user_seat_expiration_inactive_time", "1460h"),
66-
resource.TestCheckResourceAttr(name, "auto_redirect_to_identity", "false"),
69+
resource.TestCheckNoResourceAttr(name, "auto_redirect_to_identity"),
6770
resource.TestCheckResourceAttr(name, "login_design.background_color", "#FFFFFF"),
6871
resource.TestCheckResourceAttr(name, "login_design.text_color", "#000000"),
6972
resource.TestCheckResourceAttr(name, "login_design.logo_path", "https://example.com/logo.png"),
70-
resource.TestCheckResourceAttr(name, "login_design.header_text", headerText),
73+
resource.TestCheckResourceAttr(name, "login_design.header_text", headerText+" updated"),
7174
resource.TestCheckResourceAttr(name, "login_design.footer_text", "My footer text"),
7275
resource.TestCheckResourceAttr(name, "session_duration", "12h"),
7376
resource.TestCheckResourceAttr(name, "warp_auth_session_duration", "36h"),
7477
resource.TestCheckResourceAttr(name, "allow_authenticate_via_warp", "false"),
7578
),
76-
ConfigPlanChecks: resource.ConfigPlanChecks{
77-
PreApply: []plancheck.PlanCheck{
78-
plancheck.ExpectResourceAction(name, plancheck.ResourceActionNoop),
79-
plancheck.ExpectEmptyPlan(),
80-
},
81-
},
82-
},
83-
{
8479
ResourceName: name,
8580
ImportState: true,
8681
ImportStateId: accountID,
@@ -100,8 +95,6 @@ func TestAccCloudflareAccessOrganization(t *testing.T) {
10095
resource.TestCheckNoResourceAttr(name, "login_design.header_text"),
10196
resource.TestCheckNoResourceAttr(name, "login_design.footer_text"),
10297
),
103-
},
104-
{
10598
ResourceName: name,
10699
ImportState: true,
107100
ImportStateId: accountID,
@@ -175,7 +168,7 @@ func accessOrgImportStateCheckEmpty(instanceStates []*terraform.InstanceState) e
175168
{field: consts.AccountIDSchemaKey, stateValue: attrs[consts.AccountIDSchemaKey], expectedValue: accountID},
176169
{field: "is_ui_read_only", stateValue: attrs["is_ui_read_only"], expectedValue: "false"},
177170
{field: "auto_redirect_to_identity", stateValue: attrs["auto_redirect_to_identity"], expectedValue: "false"},
178-
{field: "user_seat_expiration_inactive_time", stateValue: attrs["user_seat_expiration_inactive_time"], expectedValue: ""},
171+
{field: "user_seat_expiration_inactive_time", stateValue: attrs["user_seat_expiration_inactive_time"], expectedValue: "1460h"},
179172
}
180173

181174
for _, check := range stateChecks {

0 commit comments

Comments
 (0)