mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
test(oauth): cover slash-terminated authorize urls
This commit is contained in:
24
src/plugins/provider-openai-codex-oauth.test.ts
Normal file
24
src/plugins/provider-openai-codex-oauth.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { __testing } from "./provider-openai-codex-oauth.js";
|
||||
|
||||
describe("provider-openai-codex-oauth", () => {
|
||||
it("normalizes required scopes for slash-terminated authorize URLs", () => {
|
||||
const normalized = __testing.normalizeOpenAICodexAuthorizeUrl(
|
||||
"https://auth.openai.com/oauth/authorize/?scope=openid%20profile",
|
||||
);
|
||||
const url = new URL(normalized);
|
||||
const scopes = new Set((url.searchParams.get("scope") ?? "").split(/\s+/).filter(Boolean));
|
||||
|
||||
expect(url.pathname).toBe("/oauth/authorize/");
|
||||
expect(scopes).toEqual(
|
||||
new Set([
|
||||
"openid",
|
||||
"profile",
|
||||
"email",
|
||||
"offline_access",
|
||||
"model.request",
|
||||
"api.responses.write",
|
||||
]),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -49,6 +49,10 @@ function normalizeOpenAICodexAuthorizeUrl(rawUrl: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export const __testing = {
|
||||
normalizeOpenAICodexAuthorizeUrl,
|
||||
};
|
||||
|
||||
export async function loginOpenAICodexOAuth(params: {
|
||||
prompter: WizardPrompter;
|
||||
runtime: RuntimeEnv;
|
||||
|
||||
Reference in New Issue
Block a user