Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.2 KB
Raw Blame
import { readFileSync } from "node:fs";
import { expect, it } from "vitest";

type ScopedPermission = { identifier: string; allow?: { path: string }[]; deny?: { path: string }[] };
const capability = JSON.parse(readFileSync(new URL("../../src-tauri/capabilities/default.json", import.meta.url), "utf8")) as {
  permissions: (string | ScopedPermission)[];
};

it("grants only exists and readTextFile command scopes for the exact UI tuning and Vim config files", () => {
  const scopes = capability.permissions.filter((permission): permission is ScopedPermission => typeof permission !== "string" && permission.identifier.startsWith("fs:"));
  expect(scopes).toEqual([
    { identifier: "fs:allow-exists", allow: [{ path: "$HOME/.dbx/ui-tuning.json" }, { path: "$HOME/.dbx/vimrc" }] },
    { identifier: "fs:allow-read-text-file", allow: [{ path: "$HOME/.dbx/ui-tuning.json" }, { path: "$HOME/.dbx/vimrc" }] },
  ]);
  expect(capability.permissions).not.toContain("fs:scope");
  expect(capability.permissions.filter((permission) => typeof permission === "string" && permission.startsWith("fs:"))).toEqual(["fs:default", "fs:allow-write-file", "fs:allow-write-text-file", "fs:allow-stat", "fs:allow-read-file", "fs:allow-open", "fs:allow-read"]);
});