provider/openstack: Add test for ICMP SecGroup rules with type zero

This is to just catch possible breakage in the future. The actual
support was done in Gophercloud.

Previously, values of 0 were not allowed since there's no such port
as 0. However, there are ICMP codes of 0.
This commit is contained in:
Joe Topjian 2016-03-01 03:18:27 +00:00
parent 1448b84b37
commit 9332a1ddac
1 changed files with 30 additions and 0 deletions

View File

@ -106,6 +106,24 @@ func TestAccComputeV2SecGroup_self(t *testing.T) {
})
}
func TestAccComputeV2SecGroup_icmpZero(t *testing.T) {
var secgroup secgroups.SecurityGroup
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeV2SecGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeV2SecGroup_icmpZero,
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_1", &secgroup),
),
},
},
})
}
func testAccCheckComputeV2SecGroupDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)
computeClient, err := config.computeV2Client(OS_REGION_NAME)
@ -304,3 +322,15 @@ var testAccComputeV2SecGroup_self = fmt.Sprintf(`
self = true
}
}`)
var testAccComputeV2SecGroup_icmpZero = fmt.Sprintf(`
resource "openstack_compute_secgroup_v2" "test_group_1" {
name = "test_group_1"
description = "first test security group"
rule {
from_port = 0
to_port = 0
ip_protocol = "icmp"
cidr = "0.0.0.0/0"
}
}`)