mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:00:44 +00:00
test: isolate Docker live profile-key auth
This commit is contained in:
@@ -20,7 +20,10 @@ import { isLiveProfileKeyModeEnabled, isLiveTestEnabled } from "./live-test-help
|
||||
import { getApiKeyForModel, requireApiKey } from "./model-auth.js";
|
||||
import { shouldSuppressBuiltInModel } from "./model-suppression.js";
|
||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
||||
import { isRateLimitErrorMessage } from "./pi-embedded-helpers/errors.js";
|
||||
import {
|
||||
isCloudflareOrHtmlErrorPage,
|
||||
isRateLimitErrorMessage,
|
||||
} from "./pi-embedded-helpers/errors.js";
|
||||
import { discoverAuthStorage, discoverModels } from "./pi-model-discovery.js";
|
||||
|
||||
const LIVE = isLiveTestEnabled();
|
||||
@@ -162,6 +165,24 @@ describe("isModelNotFoundErrorMessage", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isProviderUnavailableErrorMessage", () => {
|
||||
it("matches raw HTML provider error pages from transient upstreams", () => {
|
||||
expect(
|
||||
isProviderUnavailableErrorMessage(
|
||||
"Error: <html><head><title>Service Unavailable</title></head><body>try again</body></html>",
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("matches status-prefixed Cloudflare HTML pages", () => {
|
||||
expect(
|
||||
isProviderUnavailableErrorMessage(
|
||||
"521 <!DOCTYPE html><html><head><title>Web server is down</title></head><body>Cloudflare</body></html>",
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
function isChatGPTUsageLimitErrorMessage(raw: string): boolean {
|
||||
const msg = raw.toLowerCase();
|
||||
return msg.includes("hit your chatgpt usage limit") && msg.includes("try again in");
|
||||
@@ -190,6 +211,8 @@ function isModelTimeoutError(raw: string): boolean {
|
||||
function isProviderUnavailableErrorMessage(raw: string): boolean {
|
||||
const msg = raw.toLowerCase();
|
||||
return (
|
||||
isRawHtmlProviderErrorPage(raw) ||
|
||||
isCloudflareOrHtmlErrorPage(raw) ||
|
||||
msg.includes("no allowed providers are available") ||
|
||||
msg.includes("provider unavailable") ||
|
||||
msg.includes("upstream provider unavailable") ||
|
||||
@@ -201,6 +224,14 @@ function isProviderUnavailableErrorMessage(raw: string): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function isRawHtmlProviderErrorPage(raw: string): boolean {
|
||||
const normalized = raw
|
||||
.trim()
|
||||
.replace(/^error:\s*/i, "")
|
||||
.trim();
|
||||
return /^(?:<!doctype\s+html\b|<html\b)/i.test(normalized) && /<\/html>/i.test(normalized);
|
||||
}
|
||||
|
||||
function isOllamaUnavailableErrorMessage(raw: string): boolean {
|
||||
const msg = raw.toLowerCase();
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user