@@ -81,6 +81,25 @@ func TestAccCloudflareAccessOrganization(t *testing.T) {
81
81
ImportStateId : accountID ,
82
82
ImportStateCheck : accessOrgImportStateCheck ,
83
83
},
84
+ {
85
+ Config : testAccCloudflareAccessOrganizationConfigEmpty (rnd , accountID , testAuthDomain ()),
86
+ Check : resource .ComposeTestCheckFunc (
87
+ resource .TestCheckResourceAttr (name , consts .AccountIDSchemaKey , accountID ),
88
+ resource .TestCheckResourceAttr (name , "name" , testAuthDomain ()),
89
+ resource .TestCheckResourceAttr (name , "auth_domain" , rnd + "-" + testAuthDomain ()),
90
+ resource .TestCheckResourceAttr (name , "session_duration" , "12h" ),
91
+ // Verify that login_design is not present in the state
92
+ resource .TestCheckNoResourceAttr (name , "login_design.background_color" ),
93
+ resource .TestCheckNoResourceAttr (name , "login_design.text_color" ),
94
+ resource .TestCheckNoResourceAttr (name , "login_design.logo_path" ),
95
+ resource .TestCheckNoResourceAttr (name , "login_design.header_text" ),
96
+ resource .TestCheckNoResourceAttr (name , "login_design.footer_text" ),
97
+ ),
98
+ ResourceName : name ,
99
+ ImportState : true ,
100
+ ImportStateId : accountID ,
101
+ ImportStateCheck : accessOrgImportStateCheckEmpty ,
102
+ },
84
103
},
85
104
})
86
105
}
@@ -122,3 +141,56 @@ func accessOrgImportStateCheck(instanceStates []*terraform.InstanceState) error
122
141
func testAccCloudflareAccessOrganizationConfigBasic (rnd , accountID , headerText , authDomain string ) string {
123
142
return acctest .LoadTestCase ("accessorganizationconfigbasic.tf" , rnd , accountID , headerText , authDomain )
124
143
}
144
+
145
+ func testAccCloudflareAccessOrganizationConfigEmpty (rnd , accountID , authDomain string ) string {
146
+ return acctest .LoadTestCase ("accessorganizationconfigempty.tf" , rnd , accountID , authDomain )
147
+ }
148
+
149
+ func accessOrgImportStateCheckEmpty (instanceStates []* terraform.InstanceState ) error {
150
+ state := instanceStates [0 ]
151
+ attrs := state .Attributes
152
+ wantAuthDomain := testAuthDomain ()
153
+ accountID := os .Getenv ("CLOUDFLARE_ACCOUNT_ID" )
154
+
155
+ if stateName := attrs ["name" ]; ! strings .HasSuffix (stateName , wantAuthDomain ) {
156
+ return fmt .Errorf ("name has value %q and does not match expected suffix %q" , stateName , wantAuthDomain )
157
+ }
158
+
159
+ if stateAuthdomain := attrs ["auth_domain" ]; ! strings .HasSuffix (stateAuthdomain , wantAuthDomain ) {
160
+ return fmt .Errorf ("auth_domain has value %q and does not match expected suffix %q" , stateAuthdomain , wantAuthDomain )
161
+ }
162
+
163
+ stateChecks := []struct {
164
+ field string
165
+ stateValue string
166
+ expectedValue string
167
+ }{
168
+ {field : consts .AccountIDSchemaKey , stateValue : attrs [consts .AccountIDSchemaKey ], expectedValue : accountID },
169
+ {field : "is_ui_read_only" , stateValue : attrs ["is_ui_read_only" ], expectedValue : "false" },
170
+ {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" },
172
+ }
173
+
174
+ for _ , check := range stateChecks {
175
+ if check .stateValue != check .expectedValue {
176
+ return fmt .Errorf ("%s has value %q and does not match expected value %q" , check .field , check .stateValue , check .expectedValue )
177
+ }
178
+ }
179
+
180
+ loginDesignAttrs := []string {
181
+ "login_design.background_color" ,
182
+ "login_design.text_color" ,
183
+ "login_design.logo_path" ,
184
+ "login_design.header_text" ,
185
+ "login_design.footer_text" ,
186
+ }
187
+
188
+ // Verify login_design attributes are not present
189
+ for _ , attr := range loginDesignAttrs {
190
+ if _ , exists := attrs [attr ]; exists {
191
+ return fmt .Errorf ("%s exists in state but should not be present" , attr )
192
+ }
193
+ }
194
+
195
+ return nil
196
+ }
0 commit comments