diff --git a/gatewayservice/gateway-service.test.js b/gatewayservice/gateway-service.test.js index d2cd2996..ed880b61 100644 --- a/gatewayservice/gateway-service.test.js +++ b/gatewayservice/gateway-service.test.js @@ -8,6 +8,8 @@ afterAll(async () => { jest.mock("axios"); +const TEST_PASSWORD = "testpassword"; + describe("Gateway Service", () => { // Mock responses from external services axios.post.mockImplementation((url, data) => { @@ -122,7 +124,7 @@ describe("Gateway Service", () => { it("should forward login request to auth service", async () => { const response = await request(app) .post("/login") - .send({ username: "testuser", password: "testpassword" }); + .send({ username: "testuser", password: TEST_PASSWORD }); expect(response.statusCode).toBe(200); expect(response.body.token).toBe("mockedToken"); @@ -132,7 +134,7 @@ describe("Gateway Service", () => { it("should forward add user request to user service", async () => { const response = await request(app) .post("/adduser") - .send({ username: "newuser", password: "newpassword" }); + .send({ username: "newuser", password: TEST_PASSWORD }); expect(response.statusCode).toBe(200); expect(response.body.userId).toBe("mockedUserId"); diff --git a/webapp/.env b/webapp/.env index 607f024f..e4102042 100644 --- a/webapp/.env +++ b/webapp/.env @@ -3,4 +3,5 @@ REACT_APP_API_ENDPOINT=http://localhost:8000 AUTH_SERVICE_URL=http://localhost:8002 USER_SERVICE_URL=http://localhost:8001 QUESTION_SERVICE_URL=http://localhost:8003 -STATS_SERVICE_URL=http://localhost:8004 \ No newline at end of file +STATS_SERVICE_URL=http://localhost:8004 +REGISTER_PASSWORD="testPassword" \ No newline at end of file diff --git a/webapp/src/components/Register/Register.test.js b/webapp/src/components/Register/Register.test.js index 0279cc18..a8d5cb2b 100644 --- a/webapp/src/components/Register/Register.test.js +++ b/webapp/src/components/Register/Register.test.js @@ -7,6 +7,8 @@ import { BrowserRouter as Router } from "react-router-dom"; jest.mock("axios"); +const password = process.env.REGISTER_PASSWORD || "testpassword"; + describe("Register Component", () => { const mockSuccessResponse = { data: "Usuario registrado exitosamente" }; const mockErrorResponse = { response: { data: { error: "Error al registrar usuario" } } }; @@ -58,7 +60,7 @@ describe("Register Component", () => { expect(screen.getByText("Usuario registrado exitosamente")).toBeInTheDocument(); expect(axios.post).toHaveBeenCalledWith("http://localhost:8000/adduser", { username: "testUser", - password: "testPassword", + password: password }); }); @@ -77,7 +79,7 @@ describe("Register Component", () => { expect(screen.getByText("Error: Error al registrar usuario")).toBeInTheDocument(); expect(axios.post).toHaveBeenCalledWith("http://localhost:8000/adduser", { username: "testUser", - password: "testPassword", + password: password, }); }); });