@@ -2,14 +2,15 @@ package incapsula
22
33import (
44 "fmt"
5+ "math/rand"
56 "os"
7+ "regexp"
68 "strconv"
79 "testing"
810 "time"
911
1012 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1113 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
12- "math/rand"
1314)
1415
1516const siteV3ResourceName = "incapsula_site_v3.test-terraform-site-v3"
@@ -98,6 +99,27 @@ func TestIncapsulaSiteV3_isActive(t *testing.T) {
9899 })
99100}
100101
102+ func TestIncapsulaSiteV3_AccountIdUpdateFails (t * testing.T ) {
103+ resource .Test (t , resource.TestCase {
104+ Providers : testAccProviders ,
105+ CheckDestroy : testCheckIncapsulaSiteV3Destroy ,
106+ Steps : []resource.TestStep {
107+ {
108+ Config : testCheckIncapsulaSiteV3ConfigBasic (GenerateTestSiteName (nil ), "CLOUD_WAF" , "" ),
109+ Check : resource .ComposeTestCheckFunc (
110+ testCheckIncapsulaSiteExists (siteV3ResourceName ),
111+ resource .TestCheckResourceAttr (siteV3ResourceName , "name" , siteName ),
112+ resource .TestCheckResourceAttr (siteV3ResourceName , "type" , "CLOUD_WAF" ),
113+ ),
114+ },
115+ {
116+ Config : testCheckIncapsulaSiteV3ConfigWithAccountId (siteName , "CLOUD_WAF" , "999999" ),
117+ ExpectError : regexp .MustCompile ("account_id cannot be updated for an existing site" ),
118+ },
119+ },
120+ })
121+ }
122+
101123func testCheckIncapsulaSiteV3Destroy (state * terraform.State ) error {
102124 client := testAccProvider .Meta ().(* Client )
103125
@@ -141,6 +163,19 @@ func testCheckIncapsulaSiteV3ConfigBasic(name string, siteType string, extraAttr
141163 )
142164}
143165
166+ func testCheckIncapsulaSiteV3ConfigWithAccountId (name string , siteType string , accountId string ) string {
167+ return fmt .Sprintf (`
168+ resource "incapsula_site_v3" "test-terraform-site-v3" {
169+ name = "%s"
170+ type = "%s"
171+ account_id = "%s"
172+ }` ,
173+ name ,
174+ siteType ,
175+ accountId ,
176+ )
177+ }
178+
144179func testSiteV3Importer (s * terraform.State ) (string , error ) {
145180 for _ , rs := range s .RootModule ().Resources {
146181
0 commit comments