aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/webfinger.spec.js
blob: d1b198e6bce9110a101775040b77fd318d56878d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
    })
})