Fix coverage for auth

This commit is contained in:
Alex Holliday
2024-10-16 14:17:35 +08:00
parent c356843799
commit 4a05157eb3
6 changed files with 1708 additions and 1705 deletions

View File

@@ -103,7 +103,6 @@ const registerUser = async (req, res, next) => {
data: { user: newUser, token: token },
});
} catch (error) {
console.log("ERROR", error);
next(handleError(error, SERVICE_NAME, "registerController"));
}
};

View File

@@ -77,7 +77,7 @@ const getMonitorStatsById = async (req, res, next) => {
}
};
const getMonitorCertificate = async (req, res, next) => {
const getMonitorCertificate = async (req, res, next, fetchMonitorCertificate) => {
try {
await getCertificateParamValidation.validateAsync(req.params);
} catch (error) {

View File

@@ -1,25 +1,28 @@
import { Router } from "express";
import {
getAllMonitors,
getMonitorStatsById,
getMonitorCertificate,
getMonitorById,
getMonitorsAndSummaryByTeamId,
getMonitorsByTeamId,
createMonitor,
deleteMonitor,
deleteAllMonitors,
editMonitor,
pauseMonitor,
addDemoMonitors,
getAllMonitors,
getMonitorStatsById,
getMonitorCertificate,
getMonitorById,
getMonitorsAndSummaryByTeamId,
getMonitorsByTeamId,
createMonitor,
deleteMonitor,
deleteAllMonitors,
editMonitor,
pauseMonitor,
addDemoMonitors,
} from "../controllers/monitorController.js";
import { isAllowed } from "../middleware/isAllowed.js";
import { fetchMonitorCertificate } from "../controllers/controllerUtils.js";
const router = Router();
router.get("/", getAllMonitors);
router.get("/stats/:monitorId", getMonitorStatsById);
router.get("/certificate/:monitorId", getMonitorCertificate);
router.get("/certificate/:monitorId", (req, res, next) => {
getMonitorCertificate(req, res, next, fetchMonitorCertificate);
});
router.get("/:monitorId", getMonitorById);
router.get("/team/summary/:teamId", getMonitorsAndSummaryByTeamId);
router.get("/team/:teamId", getMonitorsByTeamId);
@@ -32,11 +35,7 @@ router.put("/:monitorId", isAllowed(["admin", "superadmin"]), editMonitor);
router.delete("/", isAllowed(["superadmin"]), deleteAllMonitors);
router.post(
"/pause/:monitorId",
isAllowed(["admin", "superadmin"]),
pauseMonitor
);
router.post("/pause/:monitorId", isAllowed(["admin", "superadmin"]), pauseMonitor);
router.post("/demo", isAllowed(["admin", "superadmin"]), addDemoMonitors);

File diff suppressed because it is too large Load Diff

View File

@@ -204,7 +204,7 @@ describe("controllerUtils - fetchMonitorCertificate", () => {
try {
await fetchMonitorCertificate(tls, monitor);
} catch (error) {
console.log(error);
expect(error.message).to.equal("Certificate error");
}
});
});

File diff suppressed because it is too large Load Diff