Skip to content

Commit

Permalink
updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rejain456 committed Jan 17, 2025
1 parent 0efb03f commit 3271d88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions cni/network/network_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,12 @@ func GetTestCNSResponseSecondaryWindows(macAddress string) map[string]network.In
},
},
NICType: cns.NodeNetworkInterfaceFrontendNIC,
EndpointPolicies: []policy.Policy{
{
Type: policy.EndpointPolicy,
Data: GetRawOutBoundNATPolicy(),
},
},
},
}
}
Expand Down Expand Up @@ -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: `.*`,
},
Expand Down Expand Up @@ -1338,6 +1350,8 @@ func TestPluginWindowsAdd(t *testing.T) {
epInfo1.EndpointPolicies[0] = policy.Policy{
Type: policy.ACLPolicy,
}
require.Equal(t, len(epInfo1.EndpointPolicies), 1)

Check failure on line 1353 in cni/network/network_windows_test.go

View workflow job for this annotation

GitHub Actions / Lint (1.22.x, windows-latest)

len: use require.Len (testifylint)

Check failure on line 1353 in cni/network/network_windows_test.go

View workflow job for this annotation

GitHub Actions / Lint (1.23.x, windows-latest)

len: use require.Len (testifylint)
require.Equal(t, len(epInfo2.EndpointPolicies), 1)

Check failure on line 1354 in cni/network/network_windows_test.go

View workflow job for this annotation

GitHub Actions / Lint (1.22.x, windows-latest)

len: use require.Len (testifylint)

Check failure on line 1354 in cni/network/network_windows_test.go

View workflow job for this annotation

GitHub Actions / Lint (1.23.x, windows-latest)

len: use require.Len (testifylint)
require.NotEqual(t, epInfo1.EndpointPolicies, epInfo2.EndpointPolicies)
}
// ensure the network policy slices are separate entities when in separate endpoint infos
Expand Down

0 comments on commit 3271d88

Please sign in to comment.