Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.3 KB
Raw Blame
import { describe, expect, it, vi } from "vite-plus/test";

vi.mock("../../../apps/api/src/database", () => ({
  default: {
    query: {
      integrationTable: {
        findFirst: async () => ({
          id: "integration-1",
          projectId: "project-1",
          isActive: true,
          createdAt: new Date(),
          updatedAt: new Date(),
          config: JSON.stringify({
            baseUrl: "https://gitlab.com",
            accessToken: "glpat-abcdefghijklmnop",
            projectPath: "acme/web",
            webhookSecret: "webhook-secret",
          }),
        }),
      },
    },
  },
}));

const { default: getGitlabIntegration } =
  await import("../../../apps/api/src/gitlab-integration/controllers/get-gitlab-integration");

describe("getGitlabIntegration secrets", () => {
  it("returns no token hint or webhook secret to other members", async () => {
    const integration = await getGitlabIntegration("project-1");

    expect(integration?.maskedAccessToken).toBe("");
    expect(integration?.webhookSecret).toBe("");
  });

  it("returns the token hint and webhook secret to settings managers", async () => {
    const integration = await getGitlabIntegration("project-1", true);

    expect(integration?.maskedAccessToken).toBe("glpa••••••mnop");
    expect(integration?.webhookSecret).toBe("webhook-secret");
  });
});