mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 22:51:30 -07:00
experimental api docs
This commit is contained in:
@@ -46,3 +46,22 @@ it('rejects an unauthenticated coach message', async () => {
|
||||
expect(res.status).toBe(401)
|
||||
expect(await res.json()).toEqual({ error: 'not signed in' })
|
||||
})
|
||||
|
||||
it('serves the aggregated docs page with a source per documented service', async () => {
|
||||
const res = await SELF.fetch('https://example.com/docs')
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.headers.get('content-type')).toContain('text/html')
|
||||
const html = await res.text()
|
||||
// Mounts the self-hosted Scalar bundle (not a CDN) and lists every service's spec.
|
||||
expect(html).toContain('/docs/scalar.standalone.js')
|
||||
for (const slug of ['auth', 'accounts', 'match', 'econ']) {
|
||||
expect(html).toContain(`/docs/openapi/${slug}.json`)
|
||||
}
|
||||
})
|
||||
|
||||
it('404s a spec proxy for an unknown service (not an open proxy)', async () => {
|
||||
// An un-allowlisted service is rejected before any upstream fetch, so this can't be
|
||||
// turned into a proxy to `https://<anything>.<DOMAIN>`.
|
||||
const res = await SELF.fetch('https://example.com/docs/openapi/evil.json')
|
||||
expect(res.status).toBe(404)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user