mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat: add gitea/forgejo support
This commit is contained in:
parent
ace036c209
commit
aec0d1a257
43 changed files with 683 additions and 130 deletions
|
|
@ -7,8 +7,9 @@ import {
|
|||
adminCookie,
|
||||
clearAdminCookie,
|
||||
} from "../web/session";
|
||||
import { groupAcceptsProvider } from "../web/groups";
|
||||
import { loadRoutes, saveRoutes, loadConfig } from "../config";
|
||||
import type { Env, Route } from "../types";
|
||||
import type { Env, Route, Group } from "../types";
|
||||
|
||||
function createMockKV(): KVNamespace {
|
||||
const store = new Map<string, { value: string; expiration?: number }>();
|
||||
|
|
@ -111,6 +112,26 @@ describe("admin-session", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("groupAcceptsProvider", () => {
|
||||
const base: Group = { id: "g", name: "G", adminIds: [] };
|
||||
|
||||
it("accepts every provider when none are configured", () => {
|
||||
expect(groupAcceptsProvider(base, "github")).toBe(true);
|
||||
expect(groupAcceptsProvider(base, "gitea")).toBe(true);
|
||||
expect(groupAcceptsProvider(base, undefined)).toBe(true);
|
||||
});
|
||||
|
||||
it("restricts to the configured providers", () => {
|
||||
expect(groupAcceptsProvider({ ...base, providers: ["gitea"] }, "gitea")).toBe(true);
|
||||
expect(groupAcceptsProvider({ ...base, providers: ["gitea"] }, "github")).toBe(false);
|
||||
expect(groupAcceptsProvider({ ...base, providers: ["gitea"] }, undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("matches case-insensitively and trims whitespace", () => {
|
||||
expect(groupAcceptsProvider({ ...base, providers: [" Gitea "] }, "gitea")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("config routes persistence", () => {
|
||||
it("saves and loads routes from KV", async () => {
|
||||
const kv = createMockKV();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue