owasp zap config v10
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
This commit is contained in:
+8
-3
@@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user