mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
test(openai): align auth contract with provider default (#103760)
This commit is contained in:
committed by
GitHub
parent
5635d74ecc
commit
9b4c7c0991
@@ -1,6 +1,7 @@
|
||||
// Openai tests cover provider auth.contract plugin behavior.
|
||||
import { describeOpenAICodexProviderAuthContract } from "openclaw/plugin-sdk/provider-test-contracts";
|
||||
import { vi } from "vitest";
|
||||
import { OPENAI_CODEX_DEFAULT_MODEL } from "./default-models.js";
|
||||
|
||||
const loginOpenAICodexOAuthMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
@@ -9,5 +10,6 @@ vi.mock("./openai-chatgpt-oauth.runtime.js", () => ({
|
||||
}));
|
||||
|
||||
describeOpenAICodexProviderAuthContract(() => import("./index.js"), {
|
||||
expectedCodexDefaultModel: OPENAI_CODEX_DEFAULT_MODEL,
|
||||
loginOpenAICodexOAuthMock,
|
||||
});
|
||||
|
||||
@@ -29,6 +29,7 @@ export type ProviderAuthContractPluginLoader = () => Promise<{
|
||||
}>;
|
||||
|
||||
export type OpenAICodexProviderAuthContractOptions = {
|
||||
expectedCodexDefaultModel: string;
|
||||
loginOpenAICodexOAuthMock: ReturnType<typeof vi.fn<LoginOpenAICodexOAuth>>;
|
||||
};
|
||||
|
||||
@@ -80,6 +81,7 @@ function buildOpenAICodexOAuthResult(params: {
|
||||
refresh: string;
|
||||
expires: number;
|
||||
email?: string;
|
||||
defaultModel: string;
|
||||
}) {
|
||||
return {
|
||||
profiles: [
|
||||
@@ -99,12 +101,12 @@ function buildOpenAICodexOAuthResult(params: {
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
"openai/gpt-5.5": {},
|
||||
[params.defaultModel]: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
defaultModel: "openai/gpt-5.5",
|
||||
defaultModel: params.defaultModel,
|
||||
notes: undefined,
|
||||
};
|
||||
}
|
||||
@@ -146,7 +148,7 @@ export function describeOpenAICodexProviderAuthContract(
|
||||
const state = {
|
||||
authStore: { version: 1, profiles: {} } as AuthProfileStore,
|
||||
};
|
||||
const { loginOpenAICodexOAuthMock } = options;
|
||||
const { expectedCodexDefaultModel, loginOpenAICodexOAuthMock } = options;
|
||||
|
||||
describe("openai provider ChatGPT auth contract", () => {
|
||||
installSharedAuthProfileStoreHooks(state);
|
||||
@@ -166,6 +168,7 @@ export function describeOpenAICodexProviderAuthContract(
|
||||
access: params.access,
|
||||
refresh: "refresh-token",
|
||||
expires: 1_700_000_000_000,
|
||||
defaultModel: expectedCodexDefaultModel,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -193,6 +196,7 @@ export function describeOpenAICodexProviderAuthContract(
|
||||
refresh: "refresh-token",
|
||||
expires: 1_700_000_000_000,
|
||||
email: "user@example.com",
|
||||
defaultModel: expectedCodexDefaultModel,
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -219,6 +223,7 @@ export function describeOpenAICodexProviderAuthContract(
|
||||
refresh: "refresh-token",
|
||||
expires: 1_700_000_000_000,
|
||||
email: "jwt-user@example.com",
|
||||
defaultModel: expectedCodexDefaultModel,
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -277,6 +282,7 @@ export function describeOpenAICodexProviderAuthContract(
|
||||
access: "not-a-jwt-token",
|
||||
refresh: "refresh-token",
|
||||
expires: 1_700_000_000_000,
|
||||
defaultModel: expectedCodexDefaultModel,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user