mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
merge(master): sync master into dev
This commit is contained in:
@@ -8,6 +8,7 @@ import { describe, it, expect, beforeAll, afterAll, vi } from "vitest";
|
||||
const originalDataDir = process.env.DATA_DIR;
|
||||
let tempDir;
|
||||
let sqliteDb;
|
||||
let adminOwnerId;
|
||||
|
||||
beforeAll(async () => {
|
||||
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "9router-db-compare-"));
|
||||
@@ -15,6 +16,8 @@ beforeAll(async () => {
|
||||
vi.resetModules();
|
||||
sqliteDb = await import("@/lib/db/index.js");
|
||||
await sqliteDb.initDb();
|
||||
const admin = await sqliteDb.createUser({ username: "db-parity-admin", password: "password", role: "admin" });
|
||||
adminOwnerId = admin.id;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
@@ -76,9 +79,9 @@ describe("DB SQLite layer — public API parity", () => {
|
||||
});
|
||||
|
||||
it("providerConnections: CRUD + reorder by priority", async () => {
|
||||
const c1 = await sqliteDb.createProviderConnection({ provider: "test", authType: "apikey", name: "a", apiKey: "k1" });
|
||||
const c2 = await sqliteDb.createProviderConnection({ provider: "test", authType: "apikey", name: "b", apiKey: "k2" });
|
||||
const c3 = await sqliteDb.createProviderConnection({ provider: "test", authType: "apikey", name: "c", apiKey: "k3" });
|
||||
const c1 = await sqliteDb.createProviderConnection({ provider: "test", authType: "apikey", name: "a", apiKey: "k1", ownerId: adminOwnerId });
|
||||
const c2 = await sqliteDb.createProviderConnection({ provider: "test", authType: "apikey", name: "b", apiKey: "k2", ownerId: adminOwnerId });
|
||||
const c3 = await sqliteDb.createProviderConnection({ provider: "test", authType: "apikey", name: "c", apiKey: "k3", ownerId: adminOwnerId });
|
||||
|
||||
const list = await sqliteDb.getProviderConnections({ provider: "test" });
|
||||
expect(list).toHaveLength(3);
|
||||
@@ -103,6 +106,7 @@ describe("DB SQLite layer — public API parity", () => {
|
||||
provider: "p2", authType: "oauth", email: "x@y.com",
|
||||
accessToken: "tok", refreshToken: "rtok", expiresAt: 12345,
|
||||
providerSpecificData: { foo: "bar" },
|
||||
ownerId: adminOwnerId,
|
||||
});
|
||||
const back = await sqliteDb.getProviderConnectionById(c.id);
|
||||
expect(back.accessToken).toBe("tok");
|
||||
@@ -112,8 +116,8 @@ describe("DB SQLite layer — public API parity", () => {
|
||||
});
|
||||
|
||||
it("providerConnections: scopes retrieval and lookup to connection owner", async () => {
|
||||
const ownerOne = await sqliteDb.createUser({ username: "connection-owner-one", password: "password", role: "user" });
|
||||
const ownerTwo = await sqliteDb.createUser({ username: "connection-owner-two", password: "password", role: "user" });
|
||||
const ownerOne = await sqliteDb.createUser({ username: "connection-owner-one", password: "password", role: "admin" });
|
||||
const ownerTwo = await sqliteDb.createUser({ username: "connection-owner-two", password: "password", role: "admin" });
|
||||
const firstConnection = await sqliteDb.createProviderConnection({
|
||||
provider: "owner-test-one",
|
||||
authType: "apikey",
|
||||
@@ -200,6 +204,7 @@ describe("DB SQLite layer — public API parity", () => {
|
||||
authType: "oauth",
|
||||
accessToken: "tok",
|
||||
providerSpecificData: { githubLogin: "octocat" },
|
||||
ownerId: adminOwnerId,
|
||||
});
|
||||
|
||||
expect(c.name).toBe("octocat");
|
||||
|
||||
Reference in New Issue
Block a user