mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:50:43 +00:00
test(auth): isolate provider alias registry mock
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { resolveAuthProfileOrder } from "./order.js";
|
||||
import { markAuthProfileGood } from "./profiles.js";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { saveAuthProfileStore } from "./store.js";
|
||||
import type { AuthProfileStore } from "./types.js";
|
||||
|
||||
@@ -28,12 +26,30 @@ vi.mock("./external-auth.js", () => ({
|
||||
shouldPersistExternalAuthProfile: () => true,
|
||||
}));
|
||||
|
||||
async function importAuthProfileModulesWithAliasRegistry() {
|
||||
vi.resetModules();
|
||||
vi.doMock("../../plugins/manifest-registry.js", () => ({
|
||||
loadPluginManifestRegistry,
|
||||
}));
|
||||
const [{ resolveAuthProfileOrder }, { markAuthProfileGood }] = await Promise.all([
|
||||
import("./order.js"),
|
||||
import("./profiles.js"),
|
||||
]);
|
||||
return { markAuthProfileGood, resolveAuthProfileOrder };
|
||||
}
|
||||
|
||||
describe("resolveAuthProfileOrder", () => {
|
||||
beforeEach(() => {
|
||||
loadPluginManifestRegistry.mockClear();
|
||||
});
|
||||
|
||||
it("accepts aliased provider credentials from manifest metadata", () => {
|
||||
afterEach(() => {
|
||||
vi.doUnmock("../../plugins/manifest-registry.js");
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it("accepts aliased provider credentials from manifest metadata", async () => {
|
||||
const { resolveAuthProfileOrder } = await importAuthProfileModulesWithAliasRegistry();
|
||||
const store: AuthProfileStore = {
|
||||
version: 1,
|
||||
profiles: {
|
||||
@@ -54,6 +70,7 @@ describe("resolveAuthProfileOrder", () => {
|
||||
});
|
||||
|
||||
it("marks aliased provider profiles good under the canonical auth provider", async () => {
|
||||
const { markAuthProfileGood } = await importAuthProfileModulesWithAliasRegistry();
|
||||
const agentDir = await mkdtemp(path.join(os.tmpdir(), "openclaw-auth-profile-alias-"));
|
||||
try {
|
||||
const store: AuthProfileStore = {
|
||||
|
||||
Reference in New Issue
Block a user