@@ -85,13 +85,13 @@ func TestAccDomainRegistration_SingleDomainWithUpdate(t *testing.T) {
8585 })
8686}
8787
88- func TestAccDomainRegistration_MultipleDomainsNoUpdate (t * testing.T ) {
88+ func TestAccDomainRegistration_MultipleDomainsUpdate (t * testing.T ) {
8989 tt := acctest .NewTestTools (t )
9090 defer tt .Cleanup ()
9191
92- domainName1 := "test-multiple-1 .com"
93- domainName2 := "test-multiple-2 .com"
94- domainName3 := "test-multiple-3 .com"
92+ domainName1 := "test-multiple-118 .com"
93+ domainName2 := "test-multiple-119 .com"
94+ domainName3 := "test-multiple-120 .com"
9595
9696 resource .ParallelTest (t , resource.TestCase {
9797 PreCheck : func () { acctest .PreCheck (t ) },
@@ -122,14 +122,77 @@ func TestAccDomainRegistration_MultipleDomainsNoUpdate(t *testing.T) {
122122 ` , domainName1 , domainName2 , domainName3 ),
123123 Check : resource .ComposeTestCheckFunc (
124124 resource .TestCheckResourceAttr ("scaleway_domain_domains_registration.multi" , "domain_names.0" , domainName1 ),
125- resource .TestCheckResourceAttr ("scaleway_domain_domains_registration.multi" , "domain_names.0" , domainName2 ),
126- resource .TestCheckResourceAttr ("scaleway_domain_domains_registration.multi" , "domain_names.0" , domainName3 ),
125+ resource .TestCheckResourceAttr ("scaleway_domain_domains_registration.multi" , "domain_names.1" , domainName2 ),
126+ resource .TestCheckResourceAttr ("scaleway_domain_domains_registration.multi" , "domain_names.2" , domainName3 ),
127+ ),
128+ },
129+ {
130+ Config : fmt .Sprintf (`
131+ resource "scaleway_domain_domains_registration" "multi" {
132+ domain_names = ["%s", "%s", "%s"]
133+ duration_in_years = 1
134+
135+ owner_contact {
136+ firstname = "John"
137+ lastname = "DOE"
138+ 139+ phone_number = "+1.23456789"
140+ address_line_1 = "123 Main Street"
141+ city = "Paris"
142+ zip = "75001"
143+ country = "FR"
144+ legal_form = "individual"
145+ vat_identification_code = "FR12345678901"
146+ company_identification_code = "123456789"
147+ }
148+
149+ auto_renew = true
150+ dnssec = true
151+ }
152+ ` , domainName1 , domainName2 , domainName3 ),
153+ Check : resource .ComposeTestCheckFunc (
154+ resource .TestCheckResourceAttr ("scaleway_domain_domains_registration.multi" , "auto_renew" , "true" ),
155+ resource .TestCheckResourceAttr ("scaleway_domain_domains_registration.multi" , "dnssec" , "true" ),
156+ testAccCheckDomainStatus (tt , domainSDK .DomainFeatureStatusEnabled .String (), domainSDK .DomainFeatureStatusEnabled .String ()),
127157 ),
128158 },
129159 },
130160 })
131161}
132162
163+ func testAccCheckDomainStatus (tt * acctest.TestTools , expectedAutoRenew , expectedDNSSEC string ) resource.TestCheckFunc {
164+ return func (state * terraform.State ) error {
165+ for _ , rs := range state .RootModule ().Resources {
166+ if rs .Type != "scaleway_domain_domains_registration" {
167+ continue
168+ }
169+
170+ registrarAPI := domain .NewRegistrarDomainAPI (tt .Meta )
171+ domainNames , err := domain .ExtractDomainsFromTaskID (nil , rs .Primary .ID , registrarAPI )
172+ if err != nil {
173+ return fmt .Errorf ("error extracting domains: %w" , err )
174+ }
175+
176+ for _ , domainName := range domainNames {
177+ domainResp , getErr := registrarAPI .GetDomain (& domainSDK.RegistrarAPIGetDomainRequest {
178+ Domain : domainName ,
179+ })
180+ if getErr != nil {
181+ return fmt .Errorf ("failed to get details for domain %s: %w" , domainName , getErr )
182+ }
183+
184+ if domainResp .AutoRenewStatus .String () != expectedAutoRenew {
185+ return fmt .Errorf ("domain %s has auto_renew status %s, expected %s" , domainName , domainResp .AutoRenewStatus , expectedAutoRenew )
186+ }
187+ if domainResp .Dnssec .Status .String () != expectedDNSSEC {
188+ return fmt .Errorf ("domain %s has dnssec status %s, expected %s" , domainName , domainResp .Dnssec .Status .String (), expectedDNSSEC )
189+ }
190+ }
191+ }
192+ return nil
193+ }
194+ }
195+
133196func testAccCheckDomainDestroy (tt * acctest.TestTools ) resource.TestCheckFunc {
134197 return func (state * terraform.State ) error {
135198 for _ , rs := range state .RootModule ().Resources {
0 commit comments