MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / TestIsLoopback

Function TestIsLoopback

internal/util/net_test.go:9–35  ·  view source on GitHub ↗

TestIsLoopback tests the IsLoopback helper function.

(t *testing.T)

Source from the content-addressed store, hash-verified

7
8// TestIsLoopback tests the IsLoopback helper function.
9func TestIsLoopback(t *testing.T) {
10 tests := []struct {
11 addr string
12 want bool
13 }{
14 {"localhost", true},
15 {"localhost:3000", true},
16 {"127.0.0.1", true},
17 {"127.0.0.1:3000", true},
18 {"[::1]", true},
19 {"[::1]:3000", true},
20 {"::1", true},
21 {"", false},
22 {"evil.com", false},
23 {"evil.com:80", false},
24 {"localhost.evil.com", false},
25 {"127.0.0.1.evil.com", false},
26 }
27
28 for _, tt := range tests {
29 t.Run(tt.addr, func(t *testing.T) {
30 if got := IsLoopback(tt.addr); got != tt.want {
31 t.Errorf("IsLoopback(%q) = %v, want %v", tt.addr, got, tt.want)
32 }
33 })
34 }
35}

Callers

nothing calls this directly

Calls 2

IsLoopbackFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…