@@ -2,6 +2,7 @@ package vpcgw_test
22
33import (
44 "fmt"
5+ "regexp"
56 "testing"
67
78 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -116,6 +117,7 @@ func TestAccVPCPublicGateway_Bastion(t *testing.T) {
116117 publicGatewayName ,
117118 ),
118119 resource .TestCheckResourceAttr ("scaleway_vpc_public_gateway.main" , "bastion_enabled" , "true" ),
120+ resource .TestCheckResourceAttr ("scaleway_vpc_public_gateway.main" , "bastion_port" , "61000" ),
119121 ),
120122 },
121123 {
@@ -132,6 +134,44 @@ func TestAccVPCPublicGateway_Bastion(t *testing.T) {
132134 resource .TestCheckResourceAttr ("scaleway_vpc_public_gateway.main" , "bastion_enabled" , "false" ),
133135 ),
134136 },
137+ {
138+ Config : fmt .Sprintf (`
139+ resource scaleway_vpc_public_gateway main {
140+ name = "%s"
141+ type = "VPC-GW-S"
142+ bastion_enabled = true
143+ bastion_port = 59999
144+ }
145+ ` , publicGatewayName ),
146+ Check : resource .ComposeTestCheckFunc (
147+ testAccCheckVPCPublicGatewayExists (tt , "scaleway_vpc_public_gateway.main" ),
148+ resource .TestCheckResourceAttr ("scaleway_vpc_public_gateway.main" , "name" , publicGatewayName ),
149+ resource .TestCheckResourceAttr ("scaleway_vpc_public_gateway.main" , "bastion_enabled" , "true" ),
150+ resource .TestCheckResourceAttr ("scaleway_vpc_public_gateway.main" , "bastion_port" , "59999" ),
151+ ),
152+ },
153+ },
154+ })
155+ }
156+
157+ func TestAccVPCPublicGateway_BastionInvalidPort (t * testing.T ) {
158+ tt := acctest .NewTestTools (t )
159+ defer tt .Cleanup ()
160+
161+ resource .ParallelTest (t , resource.TestCase {
162+ ProtoV6ProviderFactories : tt .ProviderFactories ,
163+ Steps : []resource.TestStep {
164+ {
165+ Config : `
166+ resource "scaleway_vpc_public_gateway" "main" {
167+ name = "public-gateway-bastion-invalid"
168+ type = "VPC-GW-S"
169+ bastion_enabled = true
170+ bastion_port = 61001
171+ }
172+ ` ,
173+ ExpectError : regexp .MustCompile (`expected bastion_port to be in the range \(1024 - 59999\) or default 61000, got 61001` ),
174+ },
135175 },
136176 })
137177}
0 commit comments