| 1 | // Copyright 2023 CNI authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package mainscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/ |
| 16 | |
| 17 | import ( |
| 18 | "fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/" |
| 19 | "stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/" |
| 20 | |
| 21 | . "github.com/onsi/ginkgo/v2scip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/" |
| 22 | . "github.com/onsi/gomegascip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/" |
| 23 | "sigs.k8s.io/knftablesscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/" |
| 24 | |
| 25 | "github.com/containernetworking/cni/pkg/typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/" |
| 26 | ) |
| 27 | |
| 28 | var _ = Describescip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/Describe().("portmapping configuration (nftables)", func() { |
| 29 | containerID := "icee6giejonei6so" |
| 30 | configTmpl := `{ |
| 31 | "name": "test", |
| 32 | "type": "portmap", |
| 33 | "cniVersion": "%s", |
| 34 | "backend": "nftables", |
| 35 | "runtimeConfig": { |
| 36 | "portMappings": [ |
| 37 | { "hostPort": 8080, "containerPort": 80, "protocol": "tcp"}, |
| 38 | { "hostPort": 8081, "containerPort": 80, "protocol": "tcp"}, |
| 39 | { "hostPort": 8080, "containerPort": 81, "protocol": "udp"}, |
| 40 | { "hostPort": 8082, "containerPort": 82, "protocol": "udp"}, |
| 41 | { "hostPort": 8083, "containerPort": 83, "protocol": "tcp", "hostIP": "192.168.0.2"}, |
| 42 | { "hostPort": 8084, "containerPort": 84, "protocol": "tcp", "hostIP": "0.0.0.0"}, |
| 43 | { "hostPort": 8085, "containerPort": 85, "protocol": "tcp", "hostIP": "2001:db8:a::1"}, |
| 44 | { "hostPort": 8086, "containerPort": 86, "protocol": "tcp", "hostIP": "::"} |
| 45 | ] |
| 46 | }, |
| 47 | "snat": true, |
| 48 | "conditionsV4": ["a", "b"], |
| 49 | "conditionsV6": ["c", "d"] |
| 50 | }` |
| 51 | containerNet4, err := typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.ParseCIDRscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/ParseCIDR().("10.0.0.2/24") |
| 52 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 53 | containerNet6, err := typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.ParseCIDRscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/ParseCIDR().("2001:db8::2/64") |
| 54 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 55 | |
| 56 | for _, ver := range []string{"0.3.0", "0.3.1", "0.4.0", "1.0.0"} { |
| 57 | // Redefine ver inside for scope so real value is picked up by each dynamically defined It() |
| 58 | // See Gingkgo's "Patterns for dynamically generating tests" documentation. |
| 59 | ver := ver |
| 60 | |
| 61 | Describescip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/Describe().("nftables rules", func() { |
| 62 | var pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT. *portMapperNFTablesscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables# |
| 63 | var ipv4Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv4Fake., ipv6Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv6Fake. *knftablesscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/.Fakescip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/Fake# |
| 64 | BeforeEachscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/BeforeEach().(func() { |
| 65 | ipv4Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv4Fake. = knftablesscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/.NewFakescip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/NewFake().(knftablesscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/.IPv4Familyscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/IPv4Family., tableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/tableName.) |
| 66 | ipv6Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv6Fake. = knftablesscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/.NewFakescip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/NewFake().(knftablesscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/.IPv6Familyscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/IPv6Family., tableNamescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/tableName.) |
| 67 | pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT. = &portMapperNFTablesscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#{ |
| 68 | ipv4scip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#ipv4.: ipv4Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv4Fake., |
| 69 | ipv6scip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#ipv6.: ipv6Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv6Fake., |
| 70 | } |
| 71 | }) |
| 72 | |
| 73 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().(fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("[%s] generates correct rules", ver), func() { |
| 74 | configBytes := []byte(fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().(configTmpl, ver)) |
| 75 | |
| 76 | conf, _, err := parseConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/parseConfig().(configBytes, "foo") |
| 77 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 78 | conf.ContainerIDscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/PortMapConf#ContainerID. = containerID |
| 79 | |
| 80 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..forwardPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#forwardPorts().(conf, *containerNet4) |
| 81 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 82 | |
| 83 | expectedRules := stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.2 strings/TrimSpace().(` |
| 84 | add table ip cni_hostport { comment "CNI portmap plugin" ; } |
| 85 | add chain ip cni_hostport hostip_hostports |
| 86 | add chain ip cni_hostport hostports |
| 87 | add chain ip cni_hostport hostports_all |
| 88 | add chain ip cni_hostport masquerading { type nat hook postrouting priority 100 ; } |
| 89 | add chain ip cni_hostport output { type nat hook output priority -100 ; } |
| 90 | add chain ip cni_hostport prerouting { type nat hook prerouting priority -100 ; } |
| 91 | add rule ip cni_hostport hostports tcp dport 8080 dnat to 10.0.0.2:80 comment "icee6giejonei6so" |
| 92 | add rule ip cni_hostport hostports tcp dport 8081 dnat to 10.0.0.2:80 comment "icee6giejonei6so" |
| 93 | add rule ip cni_hostport hostports udp dport 8080 dnat to 10.0.0.2:81 comment "icee6giejonei6so" |
| 94 | add rule ip cni_hostport hostports udp dport 8082 dnat to 10.0.0.2:82 comment "icee6giejonei6so" |
| 95 | add rule ip cni_hostport hostports ip daddr 192.168.0.2 tcp dport 8083 dnat to 10.0.0.2:83 comment "icee6giejonei6so" |
| 96 | add rule ip cni_hostport hostports tcp dport 8084 dnat to 10.0.0.2:84 comment "icee6giejonei6so" |
| 97 | add rule ip cni_hostport hostports_all jump hostip_hostports |
| 98 | add rule ip cni_hostport hostports_all jump hostports |
| 99 | add rule ip cni_hostport masquerading ip saddr 10.0.0.2 ip daddr 10.0.0.2 masquerade comment "icee6giejonei6so" |
| 100 | add rule ip cni_hostport masquerading ip saddr 127.0.0.1 ip daddr 10.0.0.2 masquerade comment "icee6giejonei6so" |
| 101 | add rule ip cni_hostport output a b fib daddr type local jump hostports_all |
| 102 | add rule ip cni_hostport prerouting a b fib daddr type local jump hostports_all |
| 103 | `) |
| 104 | actualRules := stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.2 strings/TrimSpace().(ipv4Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv4Fake..Dumpscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/Fake#Dump().()) |
| 105 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(actualRules).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(expectedRules)) |
| 106 | |
| 107 | // Disable snat, generate IPv6 rules |
| 108 | *conf.SNATscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/PortMapConf#SNAT. = false |
| 109 | |
| 110 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..forwardPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#forwardPorts().(conf, *containerNet6) |
| 111 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 112 | |
| 113 | expectedRules = stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.2 strings/TrimSpace().(` |
| 114 | add table ip6 cni_hostport { comment "CNI portmap plugin" ; } |
| 115 | add chain ip6 cni_hostport hostip_hostports |
| 116 | add chain ip6 cni_hostport hostports |
| 117 | add chain ip6 cni_hostport hostports_all |
| 118 | add chain ip6 cni_hostport output { type nat hook output priority -100 ; } |
| 119 | add chain ip6 cni_hostport prerouting { type nat hook prerouting priority -100 ; } |
| 120 | add rule ip6 cni_hostport hostports tcp dport 8080 dnat to [2001:db8::2]:80 comment "icee6giejonei6so" |
| 121 | add rule ip6 cni_hostport hostports tcp dport 8081 dnat to [2001:db8::2]:80 comment "icee6giejonei6so" |
| 122 | add rule ip6 cni_hostport hostports udp dport 8080 dnat to [2001:db8::2]:81 comment "icee6giejonei6so" |
| 123 | add rule ip6 cni_hostport hostports udp dport 8082 dnat to [2001:db8::2]:82 comment "icee6giejonei6so" |
| 124 | add rule ip6 cni_hostport hostports ip6 daddr 2001:db8:a::1 tcp dport 8085 dnat to [2001:db8::2]:85 comment "icee6giejonei6so" |
| 125 | add rule ip6 cni_hostport hostports tcp dport 8086 dnat to [2001:db8::2]:86 comment "icee6giejonei6so" |
| 126 | add rule ip6 cni_hostport hostports_all jump hostip_hostports |
| 127 | add rule ip6 cni_hostport hostports_all jump hostports |
| 128 | add rule ip6 cni_hostport output c d fib daddr type local jump hostports_all |
| 129 | add rule ip6 cni_hostport prerouting c d fib daddr type local jump hostports_all |
| 130 | `) |
| 131 | actualRules = stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.2 strings/TrimSpace().(ipv6Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv6Fake..Dumpscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/Fake#Dump().()) |
| 132 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(actualRules).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(expectedRules)) |
| 133 | |
| 134 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..unforwardPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#unforwardPorts().(conf) |
| 135 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 136 | |
| 137 | expectedRules = stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.2 strings/TrimSpace().(` |
| 138 | add table ip cni_hostport { comment "CNI portmap plugin" ; } |
| 139 | add chain ip cni_hostport hostip_hostports |
| 140 | add chain ip cni_hostport hostports |
| 141 | add chain ip cni_hostport hostports_all |
| 142 | add chain ip cni_hostport masquerading { type nat hook postrouting priority 100 ; } |
| 143 | add chain ip cni_hostport output { type nat hook output priority -100 ; } |
| 144 | add chain ip cni_hostport prerouting { type nat hook prerouting priority -100 ; } |
| 145 | add rule ip cni_hostport hostports_all jump hostip_hostports |
| 146 | add rule ip cni_hostport hostports_all jump hostports |
| 147 | add rule ip cni_hostport output a b fib daddr type local jump hostports_all |
| 148 | add rule ip cni_hostport prerouting a b fib daddr type local jump hostports_all |
| 149 | `) |
| 150 | actualRules = stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.2 strings/TrimSpace().(ipv4Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv4Fake..Dumpscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/Fake#Dump().()) |
| 151 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(actualRules).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(expectedRules)) |
| 152 | |
| 153 | expectedRules = stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.2 strings/TrimSpace().(` |
| 154 | add table ip6 cni_hostport { comment "CNI portmap plugin" ; } |
| 155 | add chain ip6 cni_hostport hostip_hostports |
| 156 | add chain ip6 cni_hostport hostports |
| 157 | add chain ip6 cni_hostport hostports_all |
| 158 | add chain ip6 cni_hostport output { type nat hook output priority -100 ; } |
| 159 | add chain ip6 cni_hostport prerouting { type nat hook prerouting priority -100 ; } |
| 160 | add rule ip6 cni_hostport hostports_all jump hostip_hostports |
| 161 | add rule ip6 cni_hostport hostports_all jump hostports |
| 162 | add rule ip6 cni_hostport output c d fib daddr type local jump hostports_all |
| 163 | add rule ip6 cni_hostport prerouting c d fib daddr type local jump hostports_all |
| 164 | `) |
| 165 | actualRules = stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.2 strings/TrimSpace().(ipv6Fakescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:ipv6Fake..Dumpscip-go gomod sigs.k8s.io/knftables v0.0.18 `sigs.k8s.io/knftables`/Fake#Dump().()) |
| 166 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(actualRules).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(expectedRules)) |
| 167 | }) |
| 168 | |
| 169 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().(fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("[%s] has working CHECK", ver), func() { |
| 170 | configBytes := []byte(fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().(configTmpl, ver)) |
| 171 | |
| 172 | conf, _, err := parseConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/parseConfig().(configBytes, "foo") |
| 173 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 174 | conf.ContainerIDscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/PortMapConf#ContainerID. = containerID |
| 175 | |
| 176 | // CHECK KO: Missing all rules |
| 177 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet4) |
| 178 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 179 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet6) |
| 180 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 181 | |
| 182 | *conf.SNATscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/PortMapConf#SNAT. = false |
| 183 | |
| 184 | // ADD with SNAT=false |
| 185 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..forwardPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#forwardPorts().(conf, *containerNet4) |
| 186 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 187 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..forwardPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#forwardPorts().(conf, *containerNet6) |
| 188 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 189 | |
| 190 | // CHECK OK: no SNAT rules |
| 191 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet4) |
| 192 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 193 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet6) |
| 194 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 195 | |
| 196 | *conf.SNATscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/PortMapConf#SNAT. = true |
| 197 | |
| 198 | // CHECK KO: missing SNAT rules |
| 199 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet4) |
| 200 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 201 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet6) |
| 202 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 203 | |
| 204 | // ADD with SNAT=true |
| 205 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..forwardPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#forwardPorts().(conf, *containerNet4) |
| 206 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 207 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..forwardPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#forwardPorts().(conf, *containerNet6) |
| 208 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 209 | |
| 210 | // CHECK OK: All rules present |
| 211 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet4) |
| 212 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 213 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet6) |
| 214 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 215 | |
| 216 | // DELETE |
| 217 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..unforwardPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#unforwardPorts().(conf) |
| 218 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 219 | |
| 220 | // CHECK KO: Missing all rules |
| 221 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet4) |
| 222 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 223 | err = pmNFTscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/_:pmNFT..checkPortsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/meta/portmap`/portMapperNFTables#checkPorts().(conf, *containerNet6) |
| 224 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 225 | }) |
| 226 | }) |
| 227 | } |
| 228 | }) |