sipher/tests/discover.test.ts
Nixyan c587737f38 feat: enhance federation key rotation and server discovery functionality
- Added new environment variables for MinIO configuration in .env.local.example.
- Updated package.json and bun.lock to include new dependencies for key management and encryption.
- Refactored server and route handling to support Ed25519 and X25519 key pairs for improved security during key rotation.
- Implemented validation for public keys and enhanced error handling in the discovery routes.
- Introduced new challenges for key rotation, ensuring secure communication between federations.
- Updated README with additional instructions for the new key rotation process.
2026-03-12 18:42:52 -03:00

42 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";
test.beforeEach(async () => {
await clearServerRegistry()
})
test.afterEach(async () => {
await clearServerRegistry()
})
test("discover server", async ({ request, page }) => {
const response = await request.post(`http://192.168.3.26:3000/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(
"http://192.168.3.26:3000",
body.echo.publicKey as string,
body.echo.encryptionPublicKey as string,
);
const server = await getServerByUrl("http://192.168.3.26:3000");
expect(server).toBeDefined()
expect(server?.publicKey).toBe(body.echo.publicKey as string)
});