Files
openclaw/extensions/minimax/oauth.test.ts
NianJiu d4e42d61c9 fix(minimax): normalize OAuth token expiry to absolute millisecond timestamp (#83480)
* fix(minimax): normalize OAuth token expiry to absolute millisecond timestamp

MiniMax returns expired_in from the token endpoint as a relative duration
in seconds (standard OAuth expires_in semantics), but the auth profile
store's hasUsableOAuthCredential() expects an absolute millisecond
timestamp.  Without conversion the token appears perpetually expired,
triggering a slow OAuth refresh network call to api.minimaxi.com on
every request — the root cause of the 30-50s auth-stage delay.

Fixes #83449.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(minimax): cover oauth expiry normalization

* fix: polish minimax oauth expiry normalization (#83480) (thanks @NianJiuZst)

* fix: update minimax raw fetch allowlist (#83480)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-05-24 05:21:22 +01:00

17 lines
616 B
TypeScript

import { describe, expect, it } from "vitest";
import { normalizeOAuthExpires } from "./oauth.js";
describe("normalizeOAuthExpires", () => {
it("converts relative expiry seconds into an absolute millisecond timestamp", () => {
expect(normalizeOAuthExpires(86_400, 1_700_000_000_000)).toBe(1_700_086_400_000);
});
it("converts Unix second timestamps into milliseconds", () => {
expect(normalizeOAuthExpires(1_700_000_000)).toBe(1_700_000_000_000);
});
it("preserves absolute millisecond timestamps", () => {
expect(normalizeOAuthExpires(1_700_000_000_000)).toBe(1_700_000_000_000);
});
});