mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-21 14:22:14 +03:00
* feat(devin-desktop): replace public Windsurf provider * fix(migrations): renumber Devin Desktop migration to 151 (avoid 147 collision) 147_windsurf_to_devin_desktop.sql collided with the released 147_api_keys_model_access_mode.sql — getMigrationFiles throws "Migration version collision detected" on every DB start. Base occupies slots up to 150, so renumber the new migration to 151 and point the windsurf→devin RENAMED_MIGRATION_COMPATIBILITY entries (and tests) at it. 147 is freed in KNOWN_GAPS since 147_api_keys now owns the slot. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
100 lines
3.3 KiB
TypeScript
100 lines
3.3 KiB
TypeScript
// Devin CLI and Devin Desktop use CLI-owned/import-only credentials. Neither provider
|
|
// should be treated as refresh-capable, so the health sweep must not force-expire
|
|
// connections that legitimately have no refresh token.
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
process.env.NODE_ENV = "test";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-hc-devin-cli-8407-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
const providersDb = await import("../../src/lib/db/providers.ts");
|
|
const tokenHealthCheck = await import("../../src/lib/tokenHealthCheck.ts");
|
|
const { supportsTokenRefresh } = await import("../../open-sse/services/tokenRefresh.ts");
|
|
|
|
async function resetStorage() {
|
|
core.resetDbInstance();
|
|
if (fs.existsSync(TEST_DATA_DIR)) {
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
}
|
|
fs.mkdirSync(TEST_DATA_DIR, { recursive: true });
|
|
}
|
|
|
|
function getCreatedConnectionId(connection: { id?: unknown }): string {
|
|
assert.equal(typeof connection.id, "string");
|
|
return connection.id as string;
|
|
}
|
|
|
|
test.after(async () => {
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
});
|
|
|
|
test("supportsTokenRefresh excludes import-only Devin providers", () => {
|
|
assert.equal(
|
|
supportsTokenRefresh("devin-cli"),
|
|
false,
|
|
"devin-cli is local import-token / CLI-owned — not refresh-capable"
|
|
);
|
|
assert.equal(
|
|
supportsTokenRefresh("devin-desktop"),
|
|
false,
|
|
"devin-desktop accepts an imported API key — not a refreshable OAuth token"
|
|
);
|
|
});
|
|
|
|
test("checkConnection leaves a devin-cli connection with no refresh token untouched (#8407)", async () => {
|
|
await resetStorage();
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider: "devin-cli",
|
|
authType: "oauth",
|
|
name: "Devin CLI Local Account",
|
|
accessToken: "local-cli-access-token",
|
|
refreshToken: null,
|
|
testStatus: "active",
|
|
isActive: true,
|
|
});
|
|
|
|
await tokenHealthCheck.checkConnection(connection);
|
|
|
|
const updated = await providersDb.getProviderConnectionById(getCreatedConnectionId(connection));
|
|
assert.equal(updated?.testStatus, "active", "devin-cli testStatus must remain active");
|
|
assert.notEqual(
|
|
updated?.errorCode,
|
|
"no_refresh_token",
|
|
"devin-cli must not be marked no_refresh_token"
|
|
);
|
|
});
|
|
|
|
test("checkConnection leaves an import-only devin-desktop connection active (#8228)", async () => {
|
|
await resetStorage();
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider: "devin-desktop",
|
|
authType: "oauth",
|
|
name: "Devin Desktop Imported Account",
|
|
accessToken: "imported-desktop-access-token",
|
|
refreshToken: null,
|
|
tokenExpiresAt: null,
|
|
apiKey: null,
|
|
testStatus: "active",
|
|
isActive: true,
|
|
});
|
|
|
|
await tokenHealthCheck.checkConnection(connection);
|
|
|
|
const updated = await providersDb.getProviderConnectionById(getCreatedConnectionId(connection));
|
|
assert.equal(updated?.testStatus, "active", "devin-desktop testStatus must remain active");
|
|
assert.notEqual(
|
|
updated?.errorCode,
|
|
"no_refresh_token",
|
|
"import-only devin-desktop must not be marked no_refresh_token"
|
|
);
|
|
});
|