/** * @jest-environment node */ import request from 'supertest' import { app } from '../app' describe('WebFinger middleware', () => { it('Existing user response should have a subject and links', async () => { const resource = 'acct:ugnich@example.lan' const response = await request(app) .get(`/.well-known/webfinger?resource=${resource}`) expect(response.status).toStrictEqual(200) expect(response.body.subject).toStrictEqual(resource) expect(response.body.links.length).toStrictEqual(1) expect(response.body.links[0].href).toStrictEqual('https://example.lan/u/ugnich') }) it('Unknown user should return 404', async () => { const resource = 'acct:durov@example.lan' const response = await request(app) .get(`/.well-known/webfinger?resource=${resource}`) expect(response.status).toStrictEqual(404) }) it('Invalid input should return 400', async () => { const resource = ';DROP TABLE users' const response = await request(app) .get(`/.well-known/webfinger?resource=${resource}`) expect(response.status).toStrictEqual(400) }) })