Commit 7da964b
committed
Fix ACL rule validation and port ordering issues
This commit addresses three code review comments:
1. Add validation for ruleset create path
- The ruleset create path was skipping verifyNetworkACLRuleParams
before calling createNetworkACLRules
- Added validation loop to verify each ruleset element before creation
- This prevents panics from unchecked type assertions in
createNetworkACLRule
2. Add validation for all rule creation paths
- createNetworkACLRule is called from Create and Update paths for
both 'rule' and 'ruleset' fields
- Added validation in Update path for both 'rule' and 'ruleset'
before calling updateNetworkACLRules
- Ensures all new rules are validated before creation, preventing
less actionable CloudStack API errors
3. Sort ports for deterministic rule numbering
- When expanding deprecated 'ports' field, iteration used
portsSet.List() which is unordered
- Rule numbers were derived as baseRuleNum + portIndex, causing
non-deterministic numbering across runs
- Added sort.Strings() to ensure stable, deterministic rule number
assignment
Additionally, consolidated duplicate validation loops into a helper
function validateRulesList() to improve code maintainability and
reduce duplication across Create and Update paths. The helper
correctly skips validation for out-of-band rule placeholders
(created by managed=true) as they are markers for deletion.
All changes tested with full ACL acceptance test suite (15 tests):
- TestAccCloudStackNetworkACLRule_basic
- TestAccCloudStackNetworkACLRule_update
- TestAccCloudStackNetworkACLRule_ruleset_basic
- TestAccCloudStackNetworkACLRule_ruleset_update
- TestAccCloudStackNetworkACLRule_ruleset_insert
- TestAccCloudStackNetworkACLRule_ruleset_insert_plan_check
- TestAccCloudStackNetworkACLRule_ruleset_managed
- TestAccCloudStackNetworkACLRule_ruleset_not_managed
- TestAccCloudStackNetworkACLRule_rule_managed
- TestAccCloudStackNetworkACLRule_rule_not_managed
- TestAccCloudStackNetworkACLRule_icmp_fields_no_spurious_diff
- TestAccCloudStackNetworkACLRule_icmp_fields_add_remove_rule
- TestAccCloudStackNetworkACLRule_deprecated_ports
- TestAccCloudStackNetworkACLRule_deprecated_ports_managed
- TestAccCloudStackNetworkACLRule_deprecated_ports_not_managed1 parent 4e43e06 commit 7da964b
1 file changed
+53
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
| 459 | + | |
| 460 | + | |
464 | 461 | | |
465 | 462 | | |
466 | 463 | | |
| |||
490 | 487 | | |
491 | 488 | | |
492 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
493 | 495 | | |
494 | 496 | | |
495 | 497 | | |
| |||
667 | 669 | | |
668 | 670 | | |
669 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
670 | 682 | | |
671 | | - | |
672 | | - | |
| 683 | + | |
673 | 684 | | |
674 | 685 | | |
675 | 686 | | |
| |||
1153 | 1164 | | |
1154 | 1165 | | |
1155 | 1166 | | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
1156 | 1172 | | |
1157 | 1173 | | |
1158 | 1174 | | |
| |||
1170 | 1186 | | |
1171 | 1187 | | |
1172 | 1188 | | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
1173 | 1194 | | |
1174 | 1195 | | |
1175 | 1196 | | |
| |||
1273 | 1294 | | |
1274 | 1295 | | |
1275 | 1296 | | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
1276 | 1322 | | |
1277 | 1323 | | |
1278 | 1324 | | |
| |||
0 commit comments