Files
outline/plugins/linear/server/api/linear.test.ts
T
Tom Moor 77cee2806c chore: getJWTToken -> getSessionToken (#12371)
* getJWTToken -> getSessionToken

Ensure expiry is included in payload

* Refactor test harness to avoid direct usage of getSessionToken
2026-05-17 16:58:52 -04:00

45 lines
1.4 KiB
TypeScript

import { buildUser } from "@server/test/factories";
import { getTestServer } from "@server/test/support";
const server = getTestServer();
describe("#linear.callback", () => {
it("should reject callback when state nonce does not match cookie", async () => {
const user = await buildUser();
const state = JSON.stringify({
teamId: user.teamId,
nonce: "attacker-nonce",
});
const res = await server.get(
`/api/linear.callback?state=${encodeURIComponent(
state
)}&code=123&token=${user.getSessionToken()}`,
{ redirect: "manual" }
);
const body = await res.json();
expect(res.status).toEqual(400);
expect(body.error).toEqual("state_mismatch");
});
it("should reject callback when nonce is missing from state", async () => {
const user = await buildUser();
const state = JSON.stringify({ teamId: user.teamId });
const res = await server.get(
`/api/linear.callback?state=${encodeURIComponent(
state
)}&code=123&token=${user.getSessionToken()}`,
{ redirect: "manual" }
);
expect(res.status).toEqual(400);
});
it("should fail when state is not valid JSON", async () => {
const user = await buildUser();
const res = await server.get(
`/api/linear.callback?state=bad&code=123&token=${user.getSessionToken()}`,
{ redirect: "manual" }
);
expect(res.status).toEqual(400);
});
});