MCPcopy Index your code
hub / github.com/labstack/echo / TestTrustLinkLocal

Function TestTrustLinkLocal

ip_test.go:278–329  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

276}
277
278func TestTrustLinkLocal(t *testing.T) {
279 var testCases = []struct {
280 name string
281 whenIP string
282 expect bool
283 }{
284 {
285 name: "trust link local IPv4 address (lower bounds)",
286 whenIP: "169.254.0.0",
287 expect: true,
288 },
289 {
290 name: "trust link local IPv4 address (upper bounds)",
291 whenIP: "169.254.255.255",
292 expect: true,
293 },
294 {
295 name: "do not trust link local IPv4 address (outside of lower bounds)",
296 whenIP: "169.253.255.255",
297 expect: false,
298 },
299 {
300 name: "do not trust link local IPv4 address (outside of upper bounds)",
301 whenIP: "169.255.0.0",
302 expect: false,
303 },
304 {
305 name: "trust link local IPv6 address ",
306 whenIP: "fe80::1",
307 expect: true,
308 },
309 {
310 name: "do not trust link local IPv6 address ",
311 whenIP: "fec0::1",
312 expect: false,
313 },
314 }
315
316 for _, tc := range testCases {
317 t.Run(tc.name, func(t *testing.T) {
318 checker := newIPChecker([]TrustOption{
319 TrustLoopback(false), // disable to avoid interference
320 TrustPrivateNet(false), // disable to avoid interference
321
322 TrustLinkLocal(true),
323 })
324
325 result := checker.trust(net.ParseIP(tc.whenIP))
326 assert.Equal(t, tc.expect, result)
327 })
328 }
329}
330
331func TestTrustLoopback(t *testing.T) {
332 var testCases = []struct {

Callers

nothing calls this directly

Calls 5

newIPCheckerFunction · 0.85
TrustLoopbackFunction · 0.85
TrustPrivateNetFunction · 0.85
TrustLinkLocalFunction · 0.85
trustMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…