Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

16 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { oauthCallback } from "./oauth-callback.ts";
4
5test("successful and denied OAuth callbacks carry the exact configured issuer and state", () => {
6 for (const issuer of ["https://api.g1t.sh", "https://api.example/custom"]) {
7 for (const outcome of [{ code: "one-use-code" }, { error: "access_denied" }]) {
8 const url = new URL(oauthCallback("http://localhost:8765/callback?keep=1&iss=wrong&code=old&error=old", { ...outcome, state: "state & value" } as Record<string, string>, issuer));
9 assert.deepEqual(url.searchParams.getAll("iss"), [issuer]);
10 assert.equal(url.searchParams.get("state"), "state & value");
11 assert.equal(url.searchParams.get("keep"), "1");
12 assert.equal(url.searchParams.get("code"), outcome.code ?? null);
13 assert.equal(url.searchParams.get("error"), outcome.error ?? null);
14 }
15 }
16});