import type { LookupFn } from "openclaw/plugin-sdk/ssrf-runtime"; import { describe, expect, it, vi } from "vitest"; import { __testing } from "./searxng-client.js";
function createLookupFn(addresses: Array<{ address: string; family: number }>): LookupFn { return vi.fn(async (_hostname: string, options?: unknown) => { if (typeof options === "number" || !options || !(options as { all?: boolean }).all) { return addresses[0];
} return addresses;
}) as unknown as LookupFn;
}
describe("searxng client", () => {
it("preserves a configured base-path prefix when building the search URL", () => {
expect(
__testing.buildSearxngSearchUrl({
baseUrl: "https://search.example.com/searxng",
query: "openclaw",
categories: "general,news",
language: "en",
}),
).toBe( "https://search.example.com/searxng/search?q=openclaw&format=json&categories=general%2Cnews&language=en",pan>
);
});
it("rejects cleartext public hosts", async () => {
await expect(
__testing.validateSearxngBaseUrl( "http://search.example.com:8080",
createLookupFn([{ address: "93.184.216.34", family: 4 }]),
),
).rejects.toThrow( "SearXNG HTTP base URL must target a trusted private or loopback host. Use https:// for public hosts.",
);
});
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.