- Introduced single Redis connection for managing federation delivery jobs, improving reliability and performance. - Updated environment configuration to include Redis connection details and allowed hostnames for CORS. - Refactored existing code to streamline federation processes and improve error handling. - Enhanced database schema to track acknowledgment status for follow requests. This update aims to strengthen the federation's communication capabilities and ensure better handling of server interactions. #3 #4
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import createDebug from "debug";
|
|
import { clearServerRegistry, getServerByUrl, insertServerEcho, } from "./helpers/db";
|
|
|
|
const debug = createDebug("test:discover");
|
|
|
|
const url = "http://172.21.157.201:3001";
|
|
const serverUrl = process.env.BETTER_AUTH_URL!;
|
|
if (!serverUrl) {
|
|
throw new Error("BETTER_AUTH_URL is not set");
|
|
}
|
|
|
|
test.beforeEach(async () => {
|
|
await clearServerRegistry()
|
|
})
|
|
test.afterEach(async () => {
|
|
await clearServerRegistry()
|
|
})
|
|
|
|
test("discover server", async ({ request, page }) => {
|
|
const response = await request.post(`${serverUrl}/discover`, {
|
|
data: {
|
|
method: "REGISTER",
|
|
url: new URL(url).toString(),
|
|
publicKey: process.env.FEDERATION_PUBLIC_KEY!,
|
|
encryptionPublicKey: process.env.FEDERATION_ENCRYPTION_PUBLIC_KEY!,
|
|
}
|
|
})
|
|
const status = response.status()
|
|
const body = await response.json();
|
|
debug("response status: %o", status);
|
|
debug("response body: %o", body);
|
|
expect(status).toBe(200)
|
|
expect(body).toMatchObject({ message: "Server registered successfully" })
|
|
expect(body.echo).toBeInstanceOf(Object)
|
|
|
|
await insertServerEcho(
|
|
serverUrl,
|
|
body.echo.publicKey as string,
|
|
body.echo.encryptionPublicKey as string,
|
|
);
|
|
|
|
const server = await getServerByUrl(serverUrl);
|
|
expect(server).toBeDefined()
|
|
expect(server?.publicKey).toBe(body.echo.publicKey as string)
|
|
});
|