fix(andreknie.de): harden personal data lifecycle

This commit is contained in:
2026-07-28 11:13:27 +02:00
parent 772a63c622
commit b31da6175a
11 changed files with 276 additions and 124 deletions
@@ -0,0 +1,36 @@
import { beforeAll, afterAll, describe, expect, it } from 'vitest'
let server
let baseUrl
beforeAll(async () => {
const { app } = await import('./index.js')
server = app.listen(0)
await new Promise(resolve => server.once('listening', resolve))
baseUrl = `http://127.0.0.1:${server.address().port}`
})
afterAll(() => server?.close())
describe('backend mail safety', () => {
it('reports degraded health without SMTP configuration', async () => {
const response = await fetch(`${baseUrl}/api/health`)
const body = await response.json()
expect(response.status).toBe(200)
expect(body.status).toBe('degraded')
expect(body.mailer).toEqual({ ready: false })
expect(JSON.stringify(body)).not.toContain('SMTP_PASS')
})
it('does not report success when contact mail cannot be sent', async () => {
const response = await fetch(`${baseUrl}/api/contact`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ name: 'Test', email: 'test@example.invalid', message: 'Synthetic test' }),
})
expect(response.status).toBe(503)
expect((await response.json()).error).toBeTruthy()
})
})