Media build part 2 (unreleased): drive wiring in every app (R-1024/R-1037), old-install repair (R-1047), drive events notice + real restart now/later + stream check, file browser lets go of dead/removed drives and recreates on return (R-1038), safe removal keeps the drive (R-1044), Plex claim on the running server + probe accept (R-1028/R-1045)
gates / gates (push) Successful in 45s
gates / gates (push) Successful in 45s
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package stacks
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// R-1028/R-1045: Plex's „claimed" can be probed only with Accept: application/json (it answers XML otherwise —
|
||||
// measured 2026-10-15 on Tester 1). The probe with `accept:` reads the JSON field; without it the same server reads
|
||||
// „not JSON" and the gate stays closed. COMPANION RED-PROOF: ignore p.Accept in probeOnce → the first case fails.
|
||||
func TestSetupDoneProbe_AcceptJSON_Plex(t *testing.T) {
|
||||
claimed := false
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
c := "0"
|
||||
if claimed {
|
||||
c = "1"
|
||||
}
|
||||
if r.Header.Get("Accept") == "application/json" {
|
||||
v := "false"
|
||||
if claimed {
|
||||
v = "true"
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"MediaContainer":{"size":0,"claimed":` + v + `}}`))
|
||||
return
|
||||
}
|
||||
_, _ = w.Write([]byte(`<?xml version="1.0"?><MediaContainer size="0" claimed="` + c + `"></MediaContainer>`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
p := &SetupDoneProbe{URL: srv.URL + "/identity", Field: "MediaContainer.claimed", Done: "true", Accept: "application/json"}
|
||||
if done, got, err := probeOnce(p); err != nil || done {
|
||||
t.Fatalf("an unclaimed Plex must read NOT done: done=%v got=%q err=%v", done, got, err)
|
||||
}
|
||||
claimed = true
|
||||
if done, got, err := probeOnce(p); err != nil || !done {
|
||||
t.Fatalf("a claimed Plex must read done: done=%v got=%q err=%v", done, got, err)
|
||||
}
|
||||
p.Accept = ""
|
||||
if done, got, _ := probeOnce(p); done || got != "not JSON" {
|
||||
t.Fatalf("without the Accept header Plex answers XML: done=%v got=%q", done, got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user