gateway: the extension socket's test takes a 401 from the LAN guard as refused

TestBrowserExtensionOnlyFromItsOrigin (0e9057227) wanted 403 for every
case. On Linux the other computer's try is answered by the LAN guard
first, 401 for no key, before the handler's 403; it is refused either
way, never switched to a WebSocket. Found by the full suite in
magpie-desktop after the push.

Run: go test ./internal/gateway -run Browser on mote (macOS) and in
magpie-desktop (Linux, -tags nogui), both ok. The rest of that Linux
full run at 0565c0bba: ., internal/cli ok with -tags nogui; reds that
fail the same at origin/main f9ca3dd44 or are filed: internal/agent's
install tests (#4033, #3548), TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), TestColdTurnsTaken, ok alone (#4510).
This commit is contained in:
yetone
2026-11-01 03:03:30 +08:00
parent f9ca3dd44c
commit f045ec1ea5
+3 -1
View File
@@ -214,7 +214,9 @@ func TestBrowserExtensionOnlyFromItsOrigin(t *testing.T) {
}
w := httptest.NewRecorder()
h.ServeHTTP(w, r)
if w.Code != http.StatusForbidden {
// refused, by the LAN guard (401 for a computer sending no key) or
// by the handler (403): never switched to a WebSocket
if w.Code != http.StatusForbidden && w.Code != http.StatusUnauthorized {
t.Fatalf("%+v: %d %s", c, w.Code, w.Body.String())
}
}