From 9332a1ddac6591231def6e4ad8465ce7298c6918 Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Tue, 1 Mar 2016 03:18:27 +0000 Subject: [PATCH] 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. --- ...urce_openstack_compute_secgroup_v2_test.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/builtin/providers/openstack/resource_openstack_compute_secgroup_v2_test.go b/builtin/providers/openstack/resource_openstack_compute_secgroup_v2_test.go index 28223fa1b..34d1c8489 100644 --- a/builtin/providers/openstack/resource_openstack_compute_secgroup_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_compute_secgroup_v2_test.go @@ -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" + } + }`)