snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
Some checks failed
Lint and Test / Lint/Test (push) Has been cancelled
Generate Sponsors README / deploy (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-23 17:39:41 +05:00
commit 906fb231cc
1544 changed files with 164131 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
import type { Context } from "@yaakapp/api";
import { describe, expect, test } from "vite-plus/test";
import { plugin } from "../src";
const ctx = {} as Context;
describe("auth-bearer", () => {
test("No values", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: {},
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "" }] });
});
test("Only token", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { token: "my-token" },
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "my-token" }] });
});
test("Only prefix", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: "Hello" },
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello" }] });
});
test("Prefix and token", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: "Hello", token: "my-token" },
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello my-token" }] });
});
test("Extra spaces", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: "\t Hello ", token: " \nmy-token " },
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello my-token" }] });
});
});