From a805b07d16c2b5552350836473c3744988fe84cf Mon Sep 17 00:00:00 2001 From: Sergio de Almeida Cipriano Junior Date: Sun, 2 Jul 2023 23:54:49 -0300 Subject: [PATCH] (fga-eps-mds/2023-1-CAPJu-Doc#122) - Testa caso de senha errada MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: OscarDeBrito Co-authored-by: YanWerlley Co-authored-by: Vinícius Vieira de Souza --- src/tests/__tests__/test_user_routes.js | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/tests/__tests__/test_user_routes.js b/src/tests/__tests__/test_user_routes.js index 87df0bdc..372b442d 100644 --- a/src/tests/__tests__/test_user_routes.js +++ b/src/tests/__tests__/test_user_routes.js @@ -774,6 +774,32 @@ describe("user endpoints", () => { expect(response.body.message).toBe("Usuário inexistente"); }); + it("should return error for wrong password", async () => { + const testUser = { + fullName: "Nomen Nomes", + cpf: "86891382424", + email: "aaa@bb.com", + password: "spw123456", + idUnit: 1, + idRole: 3, + }; + + await supertest(app).post("/newUser").send(testUser); + + await supertest(app).post(`/acceptRequest/${testUser.cpf}`); + + const response = await supertest(app) + .post("/login") + .send({ + cpf: testUser.cpf, + password: "senha_qualquer", + }) + .expect(401); + + expect(response.body.message).toBe("Senha ou usuário incorretos"); + expect(response.body.error).toBe("Impossível autenticar"); + }); + test("get all users", async () => { const testUser = { fullName: "Nomenni Nomesos",