2024-04-14 02:46:33 +02:00
|
|
|
import { afterAll, describe, expect, test } from "bun:test";
|
2025-11-21 06:45:12 +01:00
|
|
|
import { generateClient, getTestUsers } from "@versia-server/tests";
|
2023-09-14 04:25:45 +02:00
|
|
|
|
2025-11-21 06:45:12 +01: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();
|
|
|
|
|
});
|
2024-05-06 10:19:42 +02:00
|
|
|
|
2025-06-15 22:17:33 +02:00
|
|
|
describe("Login flow", () => {
|
2025-08-21 01:21:32 +02:00
|
|
|
test("should create a client", async () => {
|
2025-06-15 22:17:33 +02:00
|
|
|
const client = await generateClient(users[0]);
|
2024-04-07 07:30:49 +02:00
|
|
|
|
2025-08-21 01:21:32 +02:00
|
|
|
const { ok, data } = await client.createApp("Test Client", {
|
2025-06-15 22:17:33 +02:00
|
|
|
redirect_uris: "https://example.com",
|
|
|
|
|
website: "https://example.com",
|
|
|
|
|
scopes: ["read", "write"],
|
2024-08-27 21:25:26 +02:00
|
|
|
});
|
2024-04-07 07:30:49 +02:00
|
|
|
|
2025-06-15 22:17:33 +02:00
|
|
|
expect(ok).toBe(true);
|
|
|
|
|
expect(data).toEqual({
|
2025-08-21 01:21:32 +02:00
|
|
|
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),
|
2025-02-13 02:34:44 +01:00
|
|
|
client_secret_expires_at: "0",
|
2024-04-07 07:30:49 +02:00
|
|
|
redirect_uri: "https://example.com",
|
2025-02-13 02:34:44 +01:00
|
|
|
redirect_uris: ["https://example.com"],
|
|
|
|
|
scopes: ["read", "write"],
|
2024-04-07 07:30:49 +02:00
|
|
|
});
|
|
|
|
|
});
|
2023-09-14 04:25:45 +02:00
|
|
|
|
2025-08-21 01:15:38 +02:00
|
|
|
// TODO: Test full flow including OpenID part
|
2023-09-14 04:25:45 +02:00
|
|
|
});
|