From f94b39787804455ca4f5377fb5f7fc2cb846a808 Mon Sep 17 00:00:00 2001 From: MegaportPhilipBrowne Date: Thu, 23 Jul 2026 05:06:45 -0700 Subject: [PATCH] ESD-1689: Test BGP JSON validation errors at a non-zero connection index Add coverage proving parseBGPConnections reports the correct connection index when the bad-type field is on a non-first entry in a multi-connection bgpConnections array, not just index 0. --- internal/commands/vxc/vxc_inputs_test.go | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/internal/commands/vxc/vxc_inputs_test.go b/internal/commands/vxc/vxc_inputs_test.go index b9aa16a7..d5ca2bb3 100644 --- a/internal/commands/vxc/vxc_inputs_test.go +++ b/internal/commands/vxc/vxc_inputs_test.go @@ -1026,6 +1026,49 @@ func TestParseVRouterConfigBGP(t *testing.T) { }, expectedError: "importWhitelist must be a number", }, + { + name: "second of two BGP connections wrong type reports index 1, not index 0", + config: map[string]interface{}{ + "connectType": "VROUTER", + "interfaces": []interface{}{ + map[string]interface{}{ + "bgpConnections": []interface{}{ + map[string]interface{}{ + "peerAsn": 65000.0, + "localIpAddress": "192.168.1.1", + "peerIpAddress": "192.168.1.2", + }, + map[string]interface{}{"shutdown": "yes"}, + }, + }, + }, + }, + expectedError: "shutdown must be a boolean in BGP connection 1 of interface 0", + }, + { + name: "third of three BGP connections wrong type reports index 2", + config: map[string]interface{}{ + "connectType": "VROUTER", + "interfaces": []interface{}{ + map[string]interface{}{ + "bgpConnections": []interface{}{ + map[string]interface{}{ + "peerAsn": 65000.0, + "localIpAddress": "192.168.1.1", + "peerIpAddress": "192.168.1.2", + }, + map[string]interface{}{ + "peerAsn": 65001.0, + "localIpAddress": "192.168.1.3", + "peerIpAddress": "192.168.1.4", + }, + map[string]interface{}{"medIn": "lots"}, + }, + }, + }, + }, + expectedError: "medIn must be a number in BGP connection 2 of interface 0", + }, } for _, tt := range tests {