Files
openclaw/src/test-utils/auth-token-assertions.ts
2026-06-04 02:53:43 -04:00

16 lines
679 B
TypeScript

// Assertion helpers for auth token redaction and token shape tests.
import { expect } from "vitest";
import type { OpenClawConfig } from "../config/types.openclaw.js";
/** Asserts the generated Gateway auth token is both returned and persisted. */
export function expectGeneratedTokenPersistedToGatewayAuth(params: {
generatedToken?: string;
authToken?: string;
persistedConfig?: OpenClawConfig;
}) {
expect(params.generatedToken).toMatch(/^[0-9a-f]{48}$/);
expect(params.authToken).toBe(params.generatedToken);
expect(params.persistedConfig?.gateway?.auth?.mode).toBe("token");
expect(params.persistedConfig?.gateway?.auth?.token).toBe(params.generatedToken);
}