From 3271d88cd370cca076a0d472eb21255de13a279a Mon Sep 17 00:00:00 2001 From: rejain456 Date: Thu, 16 Jan 2025 16:44:30 -0800 Subject: [PATCH] updated unit tests --- cni/network/network.go | 2 +- cni/network/network_windows_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cni/network/network.go b/cni/network/network.go index 9ddb111a78..b25d3de5de 100644 --- a/cni/network/network.go +++ b/cni/network/network.go @@ -834,7 +834,7 @@ func (plugin *NetPlugin) createEpInfo(opt *createEpInfoOpt) (*network.EndpointIn // the value passed into NetworkPolicies should be unaffected since we reassign here opt.policies = append(opt.policies, endpointPolicies...) - // appends default deny endpoint policies if infra nic and default deny bool is enabled + // appends endpoint policies specific to this interface opt.policies = append(opt.policies, opt.ifInfo.EndpointPolicies...) endpointInfo.EndpointPolicies = opt.policies diff --git a/cni/network/network_windows_test.go b/cni/network/network_windows_test.go index 1837933769..d5fb3ec277 100644 --- a/cni/network/network_windows_test.go +++ b/cni/network/network_windows_test.go @@ -901,6 +901,12 @@ func GetTestCNSResponseSecondaryWindows(macAddress string) map[string]network.In }, }, NICType: cns.NodeNetworkInterfaceFrontendNIC, + EndpointPolicies: []policy.Policy{ + { + Type: policy.EndpointPolicy, + Data: GetRawOutBoundNATPolicy(), + }, + }, }, } } @@ -1281,6 +1287,12 @@ func TestPluginWindowsAdd(t *testing.T) { Gateway: net.ParseIP("10.241.0.1"), }, }, + EndpointPolicies: []policy.Policy{ + { + Type: policy.EndpointPolicy, + Data: GetRawOutBoundNATPolicy(), + }, + }, }, epIDRegex: `.*`, }, @@ -1338,6 +1350,8 @@ func TestPluginWindowsAdd(t *testing.T) { epInfo1.EndpointPolicies[0] = policy.Policy{ Type: policy.ACLPolicy, } + require.Equal(t, len(epInfo1.EndpointPolicies), 1) + require.Equal(t, len(epInfo2.EndpointPolicies), 1) require.NotEqual(t, epInfo1.EndpointPolicies, epInfo2.EndpointPolicies) } // ensure the network policy slices are separate entities when in separate endpoint infos