mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
* fix(usage): harden account identity reconciliation * fix(db): renumber codex strong-identity migration 128 -> 129 release/v3.8.49 tip took slot 128 via #7839 (auto_candidate_overrides) after this branch forked; renumber the new migration and its test references. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const { resolveUsageAccountIdentity } = await import("../../src/lib/usage/accountIdentity.ts");
|
|
|
|
test("Codex chatgptUserId identity is stable across UUID and label changes", () => {
|
|
const first = resolveUsageAccountIdentity({
|
|
id: "old-uuid",
|
|
provider: "codex",
|
|
authType: "oauth",
|
|
email: "member@example.com",
|
|
displayName: "Production Codex",
|
|
providerSpecificData: { chatgptUserId: "user-production" },
|
|
});
|
|
const recreated = resolveUsageAccountIdentity({
|
|
id: "new-uuid",
|
|
provider: "codex",
|
|
authType: "oauth",
|
|
email: "member@example.com",
|
|
name: "member@example.com",
|
|
providerSpecificData: { chatgptUserId: "user-production" },
|
|
});
|
|
|
|
const emailChanged = resolveUsageAccountIdentity({
|
|
id: "third-uuid",
|
|
provider: "codex",
|
|
authType: "oauth",
|
|
email: "renamed@example.com",
|
|
providerSpecificData: { chatgptUserId: "user-production" },
|
|
});
|
|
|
|
assert.equal(first.accountKey, recreated.accountKey);
|
|
assert.equal(first.accountKey, emailChanged.accountKey);
|
|
assert.equal(first.accountLabel, "Production Codex");
|
|
assert.equal(recreated.accountLabel, "member@example.com");
|
|
});
|