diff --git a/tests/phase_b_acceptance.lua b/tests/phase_b_acceptance.lua index 85c1452..bb569ad 100644 --- a/tests/phase_b_acceptance.lua +++ b/tests/phase_b_acceptance.lua @@ -116,6 +116,51 @@ else ok3b and tostring(zul3b) or "warf") end +-- 3c. VERANKERUNG: M.SUPPORTED gegen den LAUFENDEN Server. +-- +-- Ohne diese Pruefung misst der Test die Liste nur an sich selbst -- und ein +-- Modul, das eine Fassung beansprucht, die der Server nicht spricht, besteht +-- ihn glatt. Genau das ist am 2026-08-08 passiert: {"2025-06-18","2025-11-25"} +-- ergab 14/14, obwohl lmcp nur 2025-06-18 meldet. +-- +-- Gefragt wird per `initialize`; die Antwort nennt genau EINE protocolVersion, +-- naemlich die, die dieser Server spricht. M.SUPPORTED muss exakt daraus +-- bestehen. +-- +-- Kein Uebersprung, wenn der Server fehlt: eine Abnahme, die ihre zentrale +-- Eigenschaft nicht pruefen kann, ist keine Abnahme. +local probe_url = os.getenv("LMCP_PROBE_URL") +local probe_token = os.getenv("LMCP_PROBE_TOKEN") +pruefe("LMCP_PROBE_URL ist gesetzt (ohne Server keine Verankerung)", + probe_url ~= nil and probe_url ~= "", tostring(probe_url)) + +if probe_url and probe_url ~= "" then + local rumpf = '{"jsonrpc":"2.0","id":1,"method":"initialize","params":' .. + '{"protocolVersion":"2025-06-18","capabilities":{},' .. + '"clientInfo":{"name":"phase-b-acceptance","version":"1"}}}' + local befehl = "curl -s -m 15 -X POST" + .. " -H 'Content-Type: application/json'" + .. " -H 'Accept: application/json, text/event-stream'" + if probe_token and probe_token ~= "" then + befehl = befehl .. " -H 'Authorization: Bearer " .. probe_token .. "'" + end + befehl = befehl .. " -d '" .. rumpf .. "' '" .. probe_url .. "' 2>/dev/null" + + local p = io.popen(befehl) + local antwort = p and p:read("*a") or "" + if p then p:close() end + + local gemessen = antwort:match('"protocolVersion"%s*:%s*"([^"]+)"') + pruefe("Server nennt eine protocolVersion", gemessen ~= nil, + (#antwort > 0) and antwort:sub(1, 70) or "keine Antwort") + + if gemessen then + local passt = (#M.SUPPORTED == 1) and (M.SUPPORTED[1] == gemessen) + pruefe("M.SUPPORTED entspricht GENAU dem, was der Server spricht (" + .. gemessen .. ")", passt, table.concat(M.SUPPORTED, ",")) + end +end + -- 4. wirft nie local fremde = { 42, true, false, {}, print, 0/0 } local alle_still, welcher = true, nil