(t *testing.T)
| 167 | } |
| 168 | |
| 169 | func TestTrustPrivateNet(t *testing.T) { |
| 170 | var testCases = []struct { |
| 171 | name string |
| 172 | whenIP string |
| 173 | expect bool |
| 174 | }{ |
| 175 | { |
| 176 | name: "do not trust public IPv4 address", |
| 177 | whenIP: "8.8.8.8", |
| 178 | expect: false, |
| 179 | }, |
| 180 | { |
| 181 | name: "do not trust public IPv6 address", |
| 182 | whenIP: "2a00:1450:4026:805::200e", |
| 183 | expect: false, |
| 184 | }, |
| 185 | |
| 186 | { // Class A: 10.0.0.0 — 10.255.255.255 |
| 187 | name: "do not trust IPv4 just outside of class A (lower bounds)", |
| 188 | whenIP: "9.255.255.255", |
| 189 | expect: false, |
| 190 | }, |
| 191 | { |
| 192 | name: "do not trust IPv4 just outside of class A (upper bounds)", |
| 193 | whenIP: "11.0.0.0", |
| 194 | expect: false, |
| 195 | }, |
| 196 | { |
| 197 | name: "trust IPv4 of class A (lower bounds)", |
| 198 | whenIP: "10.0.0.0", |
| 199 | expect: true, |
| 200 | }, |
| 201 | { |
| 202 | name: "trust IPv4 of class A (upper bounds)", |
| 203 | whenIP: "10.255.255.255", |
| 204 | expect: true, |
| 205 | }, |
| 206 | |
| 207 | { // Class B: 172.16.0.0 — 172.31.255.255 |
| 208 | name: "do not trust IPv4 just outside of class B (lower bounds)", |
| 209 | whenIP: "172.15.255.255", |
| 210 | expect: false, |
| 211 | }, |
| 212 | { |
| 213 | name: "do not trust IPv4 just outside of class B (upper bounds)", |
| 214 | whenIP: "172.32.0.0", |
| 215 | expect: false, |
| 216 | }, |
| 217 | { |
| 218 | name: "trust IPv4 of class B (lower bounds)", |
| 219 | whenIP: "172.16.0.0", |
| 220 | expect: true, |
| 221 | }, |
| 222 | { |
| 223 | name: "trust IPv4 of class B (upper bounds)", |
| 224 | whenIP: "172.31.255.255", |
| 225 | expect: true, |
| 226 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…