INNER CODE UNIT · Go

TestIsLoopbackHost

chaitin/SafeLine · mcp_server/main_test.go:126

func TestIsLoopbackHost(t *testing.T) {
	for _, host := range []string{"127.0.0.1", "::1", "[::1]", "localhost", "LocalHost"} {
		if !isLoopbackHost(host) {
			t.Errorf("isLoopbackHost(%q) = false, want true", host)
		}
	}
	for _, host := range []string{"", "0.0.0.0", "::", "10.0.0.10", "example.com"} {
		if isLoopbackHost(host) {
			t.Errorf("isLoopbackHost(%q) = true, want false", host)
		}
	}
}

func TestNonLoopbackListenerRequiresTLS(t *testing.T) {
	dir := t.TempDir()
	stateDir := filepath.Join(dir, "state")
	if err := os.Mkdir(stateDir, 0o700); err != nil {
		t.Fatal(err)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…