@@ -521,7 +521,30 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
521521 hostSubnetPrefix * net.IPNet
522522 options map [string ]interface {}
523523 }
524+ valueOut := []byte (`{
525+ "Type": "ACL",
526+ "Action": "Block",
527+ "Direction": "Out",
528+ "Priority": 10000
529+ }` )
524530
531+ valueIn := []byte (`{
532+ "Type": "ACL",
533+ "Action": "Block",
534+ "Direction": "In",
535+ "Priority": 10000
536+ }` )
537+
538+ expectedDefaultDenyACL := []cni.KVPair {
539+ {
540+ Name : "EndpointPolicy" ,
541+ Value : valueOut ,
542+ },
543+ {
544+ Name : "EndpointPolicy" ,
545+ Value : valueIn ,
546+ },
547+ }
525548 tests := []struct {
526549 name string
527550 fields fields
@@ -559,7 +582,8 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
559582 PrimaryIP : "10.0.0.1" ,
560583 Subnet : "10.0.0.0/24" ,
561584 },
562- NICType : cns .InfraNIC ,
585+ NICType : cns .InfraNIC ,
586+ DefaultDenyACL : expectedDefaultDenyACL ,
563587 },
564588 },
565589 Response : cns.Response {
@@ -628,6 +652,7 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
628652 PrimaryIP : "10.0.0.1" ,
629653 Subnet : "10.0.0.0/24" ,
630654 },
655+ DefaultDenyACL : expectedDefaultDenyACL ,
631656 },
632657 },
633658 Response : cns.Response {
@@ -696,7 +721,8 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
696721 PrimaryIP : "10.0.0.1" ,
697722 Subnet : "10.0.0.0/24" ,
698723 },
699- NICType : cns .InfraNIC ,
724+ NICType : cns .InfraNIC ,
725+ DefaultDenyACL : expectedDefaultDenyACL ,
700726 },
701727 {
702728 PodIPConfig : cns.IPSubnet {
@@ -795,8 +821,10 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
795821 ipamAddResult , err := invoker .Add (IPAMAddConfig {nwCfg : tt .args .nwCfg , args : tt .args .args , options : tt .args .options })
796822 if tt .wantErr {
797823 require .Error (err )
824+ require .Equalf ([]cni.KVPair (nil ), ipamAddResult .defaultDenyACL , "incorrect default deny ACL" )
798825 } else {
799826 require .NoError (err )
827+ require .Equalf (expectedDefaultDenyACL , ipamAddResult .defaultDenyACL , "incorrect default deny ACL" )
800828 }
801829
802830 for _ , ifInfo := range ipamAddResult .interfaceInfo {
0 commit comments