@@ -42,40 +42,37 @@ func TestAccCloudStackNetworkACLRule_basic(t *testing.T) {
4242 testAccCheckCloudStackNetworkACLRulesExist ("cloudstack_network_acl.foo" ),
4343 resource .TestCheckResourceAttr (
4444 "cloudstack_network_acl_rule.foo" , "rule.#" , "3" ),
45- resource .TestCheckResourceAttr (
46- "cloudstack_network_acl_rule.foo" , "rule.0.action" , "allow" ),
47- resource .TestCheckResourceAttr (
48- "cloudstack_network_acl_rule.foo" , "rule.0.cidr_list.0" , "172.16.100.0/24" ),
49- resource .TestCheckResourceAttr (
50- "cloudstack_network_acl_rule.foo" , "rule.0.protocol" , "tcp" ),
51- resource .TestCheckResourceAttr (
52- "cloudstack_network_acl_rule.foo" , "rule.0.port" , "443" ),
53- resource .TestCheckResourceAttr (
54- "cloudstack_network_acl_rule.foo" , "rule.0.port" , "80" ),
55- resource .TestCheckResourceAttr (
56- "cloudstack_network_acl_rule.foo" , "rule.0.traffic_type" , "ingress" ),
57- resource .TestCheckResourceAttr (
58- "cloudstack_network_acl_rule.foo" , "rule.0.description" , "Allow HTTP and HTTPS" ),
59- resource .TestCheckResourceAttr (
60- "cloudstack_network_acl_rule.foo" , "rule.1.rule_number" , "20" ),
61- resource .TestCheckResourceAttr (
62- "cloudstack_network_acl_rule.foo" , "rule.1.action" , "allow" ),
63- resource .TestCheckResourceAttr (
64- "cloudstack_network_acl_rule.foo" , "rule.1.cidr_list.#" , "1" ),
65- resource .TestCheckResourceAttr (
66- "cloudstack_network_acl_rule.foo" , "rule.1.cidr_list.0" , "172.18.100.0/24" ),
67- resource .TestCheckResourceAttr (
68- "cloudstack_network_acl_rule.foo" , "rule.1.icmp_code" , "-1" ),
69- resource .TestCheckResourceAttr (
70- "cloudstack_network_acl_rule.foo" , "rule.1.icmp_type" , "-1" ),
71- resource .TestCheckResourceAttr (
72- "cloudstack_network_acl_rule.foo" , "rule.1.traffic_type" , "ingress" ),
73- resource .TestCheckResourceAttr (
74- "cloudstack_network_acl_rule.foo" , "rule.1.description" , "Allow ICMP traffic" ),
75- resource .TestCheckResourceAttr (
76- "cloudstack_network_acl_rule.foo" , "rule.2.rule_number" , "10" ),
77- resource .TestCheckResourceAttr (
78- "cloudstack_network_acl_rule.foo" , "rule.2.description" , "Allow all traffic" ),
45+ resource .TestCheckTypeSetElemNestedAttrs (
46+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
47+ "action" : "allow" ,
48+ "cidr_list.0" : "172.16.100.0/24" ,
49+ "protocol" : "tcp" ,
50+ "port" : "80" ,
51+ "traffic_type" : "ingress" ,
52+ "description" : "Allow HTTP and HTTPS" ,
53+ },
54+ ),
55+ resource .TestCheckTypeSetElemNestedAttrs (
56+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
57+ "rule_number" : "20" ,
58+ "action" : "allow" ,
59+ "cidr_list.0" : "172.18.100.0/24" ,
60+ "icmp_code" : "-1" ,
61+ "icmp_type" : "-1" ,
62+ "traffic_type" : "ingress" ,
63+ "description" : "Allow ICMP traffic" ,
64+ },
65+ ),
66+ resource .TestCheckTypeSetElemNestedAttrs (
67+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
68+ "rule_number" : "10" ,
69+ "action" : "allow" ,
70+ "cidr_list.0" : "172.18.100.0/24" ,
71+ "protocol" : "all" ,
72+ "traffic_type" : "ingress" ,
73+ "description" : "Allow all traffic" ,
74+ },
75+ ),
7976 ),
8077 },
8178 },
@@ -91,35 +88,41 @@ func TestAccCloudStackNetworkACLRule_update(t *testing.T) {
9188 {
9289 Config : testAccCloudStackNetworkACLRule_basic ,
9390 Check : resource .ComposeTestCheckFunc (
91+
9492 testAccCheckCloudStackNetworkACLRulesExist ("cloudstack_network_acl.foo" ),
9593 resource .TestCheckResourceAttr (
9694 "cloudstack_network_acl_rule.foo" , "rule.#" , "3" ),
97- resource .TestCheckResourceAttr (
98- "cloudstack_network_acl_rule.foo" , "rule.0.action" , "allow" ),
99- resource .TestCheckResourceAttr (
100- "cloudstack_network_acl_rule.foo" , "rule.0.cidr_list.0" , "172.18.100.0/24" ),
101- resource .TestCheckResourceAttr (
102- "cloudstack_network_acl_rule.foo" , "rule.0.protocol" , "tcp" ),
103- resource .TestCheckResourceAttr (
104- "cloudstack_network_acl_rule.foo" , "rule.0.port" , "443" ),
105- resource .TestCheckResourceAttr (
106- "cloudstack_network_acl_rule.foo" , "rule.0.port" , "80" ),
107- resource .TestCheckResourceAttr (
108- "cloudstack_network_acl_rule.foo" , "rule.0.traffic_type" , "ingress" ),
109- resource .TestCheckResourceAttr (
110- "cloudstack_network_acl_rule.foo" , "rule.1.rule_number" , "20" ),
111- resource .TestCheckResourceAttr (
112- "cloudstack_network_acl_rule.foo" , "rule.1.action" , "allow" ),
113- resource .TestCheckResourceAttr (
114- "cloudstack_network_acl_rule.foo" , "rule.1.cidr_list.#" , "1" ),
115- resource .TestCheckResourceAttr (
116- "cloudstack_network_acl_rule.foo" , "rule.1.cidr_list.0" , "172.16.100.0/24" ),
117- resource .TestCheckResourceAttr (
118- "cloudstack_network_acl_rule.foo" , "rule.1.icmp_code" , "-1" ),
119- resource .TestCheckResourceAttr (
120- "cloudstack_network_acl_rule.foo" , "rule.1.icmp_type" , "-1" ),
121- resource .TestCheckResourceAttr (
122- "cloudstack_network_acl_rule.foo" , "rule.1.traffic_type" , "ingress" ),
95+ resource .TestCheckTypeSetElemNestedAttrs (
96+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
97+ "action" : "allow" ,
98+ "cidr_list.0" : "172.16.100.0/24" ,
99+ "protocol" : "tcp" ,
100+ "port" : "80" ,
101+ "traffic_type" : "ingress" ,
102+ "description" : "Allow HTTP and HTTPS" ,
103+ },
104+ ),
105+ resource .TestCheckTypeSetElemNestedAttrs (
106+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
107+ "rule_number" : "20" ,
108+ "action" : "allow" ,
109+ "cidr_list.0" : "172.18.100.0/24" ,
110+ "icmp_code" : "-1" ,
111+ "icmp_type" : "-1" ,
112+ "traffic_type" : "ingress" ,
113+ "description" : "Allow ICMP traffic" ,
114+ },
115+ ),
116+ resource .TestCheckTypeSetElemNestedAttrs (
117+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
118+ "rule_number" : "10" ,
119+ "action" : "allow" ,
120+ "cidr_list.0" : "172.18.100.0/24" ,
121+ "protocol" : "all" ,
122+ "traffic_type" : "ingress" ,
123+ "description" : "Allow all traffic" ,
124+ },
125+ ),
123126 ),
124127 },
125128
@@ -129,44 +132,45 @@ func TestAccCloudStackNetworkACLRule_update(t *testing.T) {
129132 testAccCheckCloudStackNetworkACLRulesExist ("cloudstack_network_acl.foo" ),
130133 resource .TestCheckResourceAttr (
131134 "cloudstack_network_acl_rule.foo" , "rule.#" , "4" ),
132- resource .TestCheckResourceAttr (
133- "cloudstack_network_acl_rule.foo" , "rule.1.action" , "deny" ),
134- resource .TestCheckResourceAttr (
135- "cloudstack_network_acl_rule.foo" , "rule.1.cidr_list.0" , "10.0.0.0/24" ),
136- resource .TestCheckResourceAttr (
137- "cloudstack_network_acl_rule.foo" , "rule.1.protocol" , "tcp" ),
138- resource .TestCheckResourceAttr (
139- "cloudstack_network_acl_rule.foo" , "rule.1.port" , "1000-2000" ),
140- resource .TestCheckResourceAttr (
141- "cloudstack_network_acl_rule.foo" , "rule.1.port" , "80" ),
142- resource .TestCheckResourceAttr (
143- "cloudstack_network_acl_rule.foo" , "rule.1.traffic_type" , "egress" ),
144- resource .TestCheckResourceAttr (
145- "cloudstack_network_acl_rule.foo" , "rule.2.action" , "deny" ),
146- resource .TestCheckResourceAttr (
147- "cloudstack_network_acl_rule.foo" , "rule.2.cidr_list.#" , "2" ),
148- resource .TestCheckResourceAttr (
149- "cloudstack_network_acl_rule.foo" , "rule.2.cidr_list.1" , "172.18.101.0/24" ),
150- resource .TestCheckResourceAttr (
151- "cloudstack_network_acl_rule.foo" , "rule.2.cidr_list.0" , "172.18.100.0/24" ),
152- resource .TestCheckResourceAttr (
153- "cloudstack_network_acl_rule.foo" , "rule.2.icmp_code" , "-1" ),
154- resource .TestCheckResourceAttr (
155- "cloudstack_network_acl_rule.foo" , "rule.2.icmp_type" , "-1" ),
156- resource .TestCheckResourceAttr (
157- "cloudstack_network_acl_rule.foo" , "rule.2.traffic_type" , "ingress" ),
158- resource .TestCheckResourceAttr (
159- "cloudstack_network_acl_rule.foo" , "rule.0.action" , "allow" ),
160- resource .TestCheckResourceAttr (
161- "cloudstack_network_acl_rule.foo" , "rule.0.cidr_list.0" , "172.18.100.0/24" ),
162- resource .TestCheckResourceAttr (
163- "cloudstack_network_acl_rule.foo" , "rule.0.protocol" , "tcp" ),
164- resource .TestCheckResourceAttr (
165- "cloudstack_network_acl_rule.foo" , "rule.0.port" , "443" ),
166- resource .TestCheckResourceAttr (
167- "cloudstack_network_acl_rule.foo" , "rule.0.port" , "80" ),
168- resource .TestCheckResourceAttr (
169- "cloudstack_network_acl_rule.foo" , "rule.0.traffic_type" , "ingress" ),
135+ resource .TestCheckTypeSetElemNestedAttrs (
136+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
137+ "action" : "deny" ,
138+ "cidr_list.0" : "10.0.0.0/24" ,
139+ "protocol" : "tcp" ,
140+ "port" : "1000-2000" ,
141+ "traffic_type" : "egress" ,
142+ "description" : "Deny specific TCP ports" ,
143+ },
144+ ),
145+ resource .TestCheckTypeSetElemNestedAttrs (
146+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
147+ "action" : "allow" ,
148+ "cidr_list.0" : "172.18.100.0/24" ,
149+ "protocol" : "tcp" ,
150+ "port" : "80" ,
151+ "traffic_type" : "ingress" ,
152+ },
153+ ),
154+ resource .TestCheckTypeSetElemNestedAttrs (
155+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
156+ "action" : "deny" ,
157+ "cidr_list.0" : "172.18.100.0/24" ,
158+ "cidr_list.1" : "172.18.101.0/24" ,
159+ "protocol" : "icmp" ,
160+ "icmp_code" : "-1" ,
161+ "icmp_type" : "-1" ,
162+ "traffic_type" : "ingress" ,
163+ "description" : "Deny ICMP traffic" ,
164+ },
165+ ),
166+ resource .TestCheckTypeSetElemNestedAttrs (
167+ "cloudstack_network_acl_rule.foo" , "rule.*" , map [string ]string {
168+ "action" : "deny" ,
169+ "cidr_list.0" : "172.18.100.0/24" ,
170+ "protocol" : "all" ,
171+ "traffic_type" : "ingress" ,
172+ },
173+ ),
170174 ),
171175 },
172176 },
0 commit comments