server/packages/api/routes/oauth.test.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-04-14 02:46:33 +02:00
import { afterAll, describe, expect, test } from "bun:test";
import { generateClient, getTestUsers } from "@versia-server/tests";
2023-09-14 04:25:45 +02:00
const { users, deleteUsers } = await getTestUsers(1);
2023-09-14 04:25:45 +02:00
2024-04-14 02:46:33 +02:00
afterAll(async () => {
await deleteUsers();
});
describe("Login flow", () => {
test("should create a client", async () => {
const client = await generateClient(users[0]);
2024-04-07 07:30:49 +02:00
const { ok, data } = await client.createApp("Test Client", {
redirect_uris: "https://example.com",
website: "https://example.com",
scopes: ["read", "write"],
});
2024-04-07 07:30:49 +02:00
expect(ok).toBe(true);
expect(data).toEqual({
name: "Test Client",
2024-04-07 07:30:49 +02:00
website: "https://example.com",
client_id: expect.any(String),
client_secret: expect.any(String),
client_secret_expires_at: "0",
2024-04-07 07:30:49 +02:00
redirect_uri: "https://example.com",
redirect_uris: ["https://example.com"],
scopes: ["read", "write"],
2024-04-07 07:30:49 +02:00
});
});
2023-09-14 04:25:45 +02:00
// TODO: Test full flow including OpenID part
2023-09-14 04:25:45 +02:00
});