Files
OmniRoute/tests/unit/oauth-device-code-endpoints.test.ts
backryun 65e0aeda79 [Part 1/3]refactor(qwen): replace legacy Qwen Code and remove OAuth provider (#7866)
* refactor(cli): remove legacy Qwen Code integration

* refactor(qwen): remove deprecated Qwen OAuth provider

* feat(cli): rebuild Qwen Code integration for upstream V4

* fix(qwen): clear stale CLI auth on reset

* test(qwen): align retired provider coverage

* fix(db): renumber qwen-cleanup migration 129 -> 130

release/v3.8.49 tip took slot 129 via #7843 (usage_history_codex_strong_identity,
itself renumbered from 128 during the #7838/#7840 base-red cleanup) after this
branch forked; renumber remove_unregistered_qwen_data to 130.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com>
2026-07-20 17:53:04 -03:00

26 lines
1.2 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";
// Regression guard for the device-code provider that returned "ошибка сервера OmniRoute":
//
// codebuddy-cn— the Tencent state endpoint reads `platform` from the QUERY string, not the JSON
// body; body-only returned 400 "platform is empty" (verified live). The fix passes
// it as a query param. Guard: requestDeviceCode builds the URL with ?platform=.
//
// Source-level: the real validation is the live upstream 200 (can't be hit from CI); these pin
// the exact change so a revert to the broken host / body-only platform fails here.
const here = dirname(fileURLToPath(import.meta.url));
const read = (p: string) => readFileSync(resolve(here, "../..", p), "utf8");
test("codebuddy-cn device-code sends platform as a query param (not body-only)", () => {
const cb = read("src/lib/oauth/providers/codebuddy-cn.ts");
assert.match(
cb,
/\?platform=\$\{encodeURIComponent\(config\.platform\)\}/,
"platform query param"
);
});