owasp zap config v9 #15

Merged
pm merged 2 commits from teste-bloqueio into main 2026-06-13 09:30:21 +00:00
Showing only changes of commit 7c7a2efd61 - Show all commits
+8 -3
View File
@@ -52,10 +52,16 @@ describe('Enterprise Application Flow & API Validation', () => {
const response = await request(app).post('/api/contact').send(invalidPayload); const response = await request(app).post('/api/contact').send(invalidPayload);
expect(response.status).toBe(400); expect(response.status).toBe(400);
expect(response.body).toHaveProperty('error', 'Email and message are required.');
// ==========================================
// CORREÇÃO DEVSECOPS: O servidor agora devolve HTML para a armadilha XSS!
// Lemos o response.text (HTML) em vez do response.body (JSON)
// ==========================================
expect(response.text).toContain('Erro de Validação');
expect(response.text).toContain('John'); // Garante que o input foi refletido na página (a vulnerabilidade XSS)
}); });
it('Should process request, return 200 OK, and invoke SMTP transporter with valid data', async () => { it('Should process request, return 200 OK, and invoke SMTP transporter with valid data', async () => {
const validPayload = { const validPayload = {
firstName: 'Jane', firstName: 'Jane',
lastName: 'Doe', lastName: 'Doe',
@@ -70,7 +76,6 @@ it('Should process request, return 200 OK, and invoke SMTP transporter with vali
expect(response.status).toBe(200); expect(response.status).toBe(200);
// Validate Business Logic: Verifica o objeto 'transporter' que veio do server.js // Validate Business Logic: Verifica o objeto 'transporter' que veio do server.js
// Como este objeto é o que injetámos no server, ele já é o mock!
expect(transporter.sendMail).toHaveBeenCalledTimes(1); expect(transporter.sendMail).toHaveBeenCalledTimes(1);
}); });
}); });