From 7ddbd841711a197b70a6894544aeeaca73021963 Mon Sep 17 00:00:00 2001 From: Harry Harpham Date: Fri, 3 Apr 2026 11:15:21 -0600 Subject: [PATCH] ipn/ipnlocal: ensure TestServeUnixSocket actually serves a Unix socket The test sets up an HTTP-over-Unix server and a reverse proxy pointed at this server, but prior to this change did not round-trip anything to the backing server. This change ensures that we test code paths which proxy Unix sockets for serve. Fixes #19232 Signed-off-by: Harry Harpham --- ipn/ipnlocal/serve_unix_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ipn/ipnlocal/serve_unix_test.go b/ipn/ipnlocal/serve_unix_test.go index 2d1f0a1e3..43ed41265 100644 --- a/ipn/ipnlocal/serve_unix_test.go +++ b/ipn/ipnlocal/serve_unix_test.go @@ -8,6 +8,7 @@ package ipnlocal import ( "errors" "fmt" + "io" "net" "net/http" "net/http/httptest" @@ -101,6 +102,23 @@ func TestServeUnixSocket(t *testing.T) { if rp.url.Host != "localhost" { t.Errorf("url.Host = %q, want %q", rp.url.Host, "localhost") } + + req := httptest.NewRequest("GET", "http://foo.test.ts.net/", nil) + rec := httptest.NewRecorder() + + rp.ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatal("unexpected response code:", rec.Code) + } + resp := rec.Result() + defer resp.Body.Close() + respB, err := io.ReadAll(resp.Body) + if err != nil { + t.Fatal("read error:", err) + } + if string(respB) != testResponse { + t.Fatalf("unexpected response: want: '%s'; got: '%s'", testResponse, string(respB)) + } } func TestServeUnixSocketErrors(t *testing.T) {