Skip to content

Commit 86311a7

Browse files
committed
updated unit test
1 parent 4aa3a54 commit 86311a7

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

cni/network/invoker_cns_test.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
612612
Gateway: net.ParseIP("10.0.0.1"),
613613
},
614614
},
615+
DefaultDenyACL: expectedDefaultDenyACL,
615616
Routes: []network.RouteInfo{
616617
{
617618
Dst: network.Ipv4DefaultRouteDstPrefix,
@@ -681,6 +682,7 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
681682
Gateway: net.ParseIP("10.0.0.1"),
682683
},
683684
},
685+
DefaultDenyACL: expectedDefaultDenyACL,
684686
Routes: []network.RouteInfo{
685687
{
686688
Dst: network.Ipv4DefaultRouteDstPrefix,
@@ -742,7 +744,8 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
742744
PrimaryIP: "fe80::1234:5678:9abc",
743745
Subnet: "fd11:1234::/112",
744746
},
745-
NICType: cns.InfraNIC,
747+
NICType: cns.InfraNIC,
748+
DefaultDenyACL: expectedDefaultDenyACL,
746749
},
747750
},
748751
Response: cns.Response{
@@ -775,6 +778,7 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
775778
Gateway: net.ParseIP("fe80::1234:5678:9abc"),
776779
},
777780
},
781+
DefaultDenyACL: expectedDefaultDenyACL,
778782
Routes: []network.RouteInfo{
779783
{
780784
Dst: network.Ipv4DefaultRouteDstPrefix,
@@ -799,8 +803,19 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
799803
require: require,
800804
requestIPs: requestIPsHandler{
801805
ipconfigArgument: getTestIPConfigsRequest(),
802-
result: nil,
803-
err: errors.New("failed error from CNS"), //nolint "error for ut"
806+
result: &cns.IPConfigsResponse{
807+
PodIPInfo: []cns.PodIpInfo{
808+
{
809+
DefaultDenyACL: expectedDefaultDenyACL,
810+
},
811+
},
812+
Response: cns.Response{
813+
ReturnCode: 0,
814+
Message: "",
815+
},
816+
},
817+
err: errors.New("failed error from CNS"), //nolint "error for ut"
818+
804819
},
805820
},
806821
},
@@ -820,6 +835,7 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
820835
}
821836
ipamAddResult, err := invoker.Add(IPAMAddConfig{nwCfg: tt.args.nwCfg, args: tt.args.args, options: tt.args.options})
822837
if tt.wantErr {
838+
require.Equalf([]cni.KVPair(nil), ipamAddResult.interfaceInfo[string(cns.InfraNIC)].DefaultDenyACL, "Correct default deny ACL")
823839
require.Error(err)
824840
} else {
825841
require.NoError(err)

0 commit comments

Comments
 (0)