2024-10-23 17:56:47 +02:00
|
|
|
import { afterAll, describe, expect, test } from "bun:test";
|
2024-11-01 20:57:16 +01:00
|
|
|
import { Application } from "@versia/kit/db";
|
2025-06-15 22:17:33 +02:00
|
|
|
import { fakeRequest } from "@versia-server/tests";
|
2025-03-30 22:10:33 +02:00
|
|
|
import { randomUUIDv7 } from "bun";
|
2024-10-07 12:52:22 +02:00
|
|
|
|
2024-10-23 17:56:47 +02:00
|
|
|
const application = await Application.insert({
|
2025-03-30 22:10:33 +02:00
|
|
|
id: randomUUIDv7(),
|
2024-10-23 17:56:47 +02:00
|
|
|
clientId: "test-client-id",
|
|
|
|
|
redirectUri: "https://example.com/callback",
|
|
|
|
|
scopes: "openid profile email",
|
|
|
|
|
secret: "test-secret",
|
|
|
|
|
name: "Test Application",
|
2024-10-07 12:52:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterAll(async () => {
|
2024-10-23 17:56:47 +02:00
|
|
|
await application.delete();
|
2024-10-07 12:52:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("/.well-known/jwks", () => {
|
|
|
|
|
test("should return JWK set with valid inputs", async () => {
|
|
|
|
|
const response = await fakeRequest("/.well-known/jwks", {
|
|
|
|
|
method: "GET",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
|
const body = await response.json();
|
|
|
|
|
expect(body.keys).toHaveLength(1);
|
|
|
|
|
expect(body.keys[0].kty).toBe("OKP");
|
|
|
|
|
expect(body.keys[0].use).toBe("sig");
|
|
|
|
|
expect(body.keys[0].alg).toBe("EdDSA");
|
|
|
|
|
expect(body.keys[0].kid).toBe("1");
|
|
|
|
|
expect(body.keys[0].crv).toBe("Ed25519");
|
|
|
|
|
expect(body.keys[0].x).toBeString();
|
|
|
|
|
});
|
|
|
|
|
});
|