@@ -547,12 +547,13 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
547547 },
548548 }
549549 tests := []struct {
550- name string
551- fields fields
552- args args
553- wantDefaultResult network.InterfaceInfo
554- wantMultitenantResult network.InterfaceInfo
555- wantErr bool
550+ name string
551+ fields fields
552+ args args
553+ wantDefaultDenyEndpoints bool
554+ wantDefaultResult network.InterfaceInfo
555+ wantMultitenantResult network.InterfaceInfo
556+ wantErr bool
556557 }{
557558 {
558559 name : "Test happy CNI add" ,
@@ -623,7 +624,8 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
623624 NICType : cns .InfraNIC ,
624625 HostSubnetPrefix : * parseCIDR ("10.0.0.0/24" ),
625626 },
626- wantErr : false ,
627+ wantDefaultDenyEndpoints : true ,
628+ wantErr : false ,
627629 },
628630 {
629631 name : "Test CNI add with pod ip info empty nictype" ,
@@ -654,7 +656,6 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
654656 PrimaryIP : "10.0.0.1" ,
655657 Subnet : "10.0.0.0/24" ,
656658 },
657- EndpointPolicies : expectedEndpointPolicies ,
658659 },
659660 },
660661 Response : cns.Response {
@@ -683,7 +684,6 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
683684 Gateway : net .ParseIP ("10.0.0.1" ),
684685 },
685686 },
686- EndpointPolicies : expectedEndpointPolicies ,
687687 Routes : []network.RouteInfo {
688688 {
689689 Dst : network .Ipv4DefaultRouteDstPrefix ,
@@ -693,7 +693,8 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
693693 NICType : cns .InfraNIC ,
694694 HostSubnetPrefix : * parseCIDR ("10.0.0.0/24" ),
695695 },
696- wantErr : false ,
696+ wantDefaultDenyEndpoints : false ,
697+ wantErr : false ,
697698 },
698699 {
699700 name : "Test happy CNI add for both ipv4 and ipv6" ,
@@ -793,7 +794,8 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
793794 NICType : cns .InfraNIC ,
794795 HostSubnetPrefix : * parseCIDR ("fd11:1234::/112" ),
795796 },
796- wantErr : false ,
797+ wantDefaultDenyEndpoints : true ,
798+ wantErr : false ,
797799 },
798800 {
799801 name : "fail to request IP addresses from cns" ,
@@ -820,7 +822,8 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
820822 },
821823 },
822824 },
823- wantErr : true ,
825+ wantDefaultDenyEndpoints : false ,
826+ wantErr : true ,
824827 },
825828 }
826829 for _ , tt := range tests {
@@ -852,7 +855,11 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
852855 }
853856 if ifInfo .NICType == cns .InfraNIC {
854857 require .Equalf (tt .wantDefaultResult , ifInfo , "incorrect default response" )
855- require .Equalf (expectedEndpointPolicies , ifInfo .EndpointPolicies , "Correct default deny ACL" )
858+ if tt .wantDefaultDenyEndpoints {
859+ require .Equalf (expectedEndpointPolicies , ifInfo .EndpointPolicies , "Correct default deny ACL" )
860+ } else {
861+ require .Equalf ([]policy.Policy (nil ), ifInfo .EndpointPolicies , "Correct default deny ACL" )
862+ }
856863 }
857864 }
858865 })
0 commit comments