Authentik: reads checked live; inspector says what a non-JSON answer is

Inspect on a real Authentik showed the version, outposts, certificates, tokens and events answer as the reader expects; /admin/workers/ answered with something that is not JSON, so the worker count stays unknown (no alert on a guess). The inspector now records the content type and what a non-JSON answer looks like (a web page, markup, metrics text, plain text; never its words) and shows it with the HTTP status on the page and in the copied report. Tests and docs updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-17 19:32:32 +01:00
1 parent 730d7fb36e
commit 76d6bfa85e
7 files changed
+44 -6

No files matched your search

+14
View File
@@ -72,6 +72,17 @@ describe("where it is empty", () => {
});
});
describe("what an answer that is not JSON looks like", () => {
test("a web page, markup, metrics text, plain text or nothing — from its first characters only", () => {
assert.equal(insp.looksLike("<!DOCTYPE html><html><body>Not found</body></html>"), "an HTML page");
assert.equal(insp.looksLike(" \n<html lang=en>"), "an HTML page");
assert.equal(insp.looksLike('<?xml version="1.0"?><a/>'), "XML or markup");
assert.equal(insp.looksLike("# HELP up whether it is up\nup 1"), "metrics text (Prometheus format)");
assert.equal(insp.looksLike("Not Found"), "plain text");
assert.equal(insp.looksLike(" "), undefined);
});
});
describe("the requests written down while a read runs", () => {
let http: Server;
let url = "";
@@ -100,6 +111,9 @@ describe("the requests written down while a read runs", () => {
assert.deepEqual(calls.map((c) => [c.method, c.path, c.status]), [["GET", "/json?token&page", 200], ["GET", "/html", 200], ["GET", "/missing", 404], ["GET", "/refused", 0]]);
assert.equal(calls[0].shape, "{ items: array(1) of { id: number, secret: string }, total: number }");
assert.equal(calls[1].shape, null, "not JSON");
assert.deepEqual([calls[0].contentType, calls[0].looks], ["application/json", undefined]);
assert.deepEqual([calls[1].contentType, calls[1].looks], ["application/json", "an HTML page"], "what the text looks like, not what it says");
assert.doesNotMatch(JSON.stringify(calls), /nope/);
assert.ok(calls[0].bytes > 10 && calls[0].ms >= 0);
assert.ok(calls[3].error);
assert.doesNotMatch(JSON.stringify(calls), /hidden-value|hidden/);