Fix coverage for auth
This commit is contained in:
1 parent
c356843799
commit
4a05157eb3
6 files changed
+1708
-1705
No files matched your search
@@ -103,7 +103,6 @@ const registerUser = async (req, res, next) => {
|
|||||||
data: { user: newUser, token: token },
|
data: { user: newUser, token: token },
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("ERROR", error);
|
|
||||||
next(handleError(error, SERVICE_NAME, "registerController"));
|
next(handleError(error, SERVICE_NAME, "registerController"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const getMonitorStatsById = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMonitorCertificate = async (req, res, next) => {
|
const getMonitorCertificate = async (req, res, next, fetchMonitorCertificate) => {
|
||||||
try {
|
try {
|
||||||
await getCertificateParamValidation.validateAsync(req.params);
|
await getCertificateParamValidation.validateAsync(req.params);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import {
|
import {
|
||||||
getAllMonitors,
|
getAllMonitors,
|
||||||
getMonitorStatsById,
|
getMonitorStatsById,
|
||||||
getMonitorCertificate,
|
getMonitorCertificate,
|
||||||
getMonitorById,
|
getMonitorById,
|
||||||
getMonitorsAndSummaryByTeamId,
|
getMonitorsAndSummaryByTeamId,
|
||||||
getMonitorsByTeamId,
|
getMonitorsByTeamId,
|
||||||
createMonitor,
|
createMonitor,
|
||||||
deleteMonitor,
|
deleteMonitor,
|
||||||
deleteAllMonitors,
|
deleteAllMonitors,
|
||||||
editMonitor,
|
editMonitor,
|
||||||
pauseMonitor,
|
pauseMonitor,
|
||||||
addDemoMonitors,
|
addDemoMonitors,
|
||||||
} from "../controllers/monitorController.js";
|
} from "../controllers/monitorController.js";
|
||||||
import { isAllowed } from "../middleware/isAllowed.js";
|
import { isAllowed } from "../middleware/isAllowed.js";
|
||||||
|
import { fetchMonitorCertificate } from "../controllers/controllerUtils.js";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.get("/", getAllMonitors);
|
router.get("/", getAllMonitors);
|
||||||
router.get("/stats/:monitorId", getMonitorStatsById);
|
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("/:monitorId", getMonitorById);
|
||||||
router.get("/team/summary/:teamId", getMonitorsAndSummaryByTeamId);
|
router.get("/team/summary/:teamId", getMonitorsAndSummaryByTeamId);
|
||||||
router.get("/team/:teamId", getMonitorsByTeamId);
|
router.get("/team/:teamId", getMonitorsByTeamId);
|
||||||
@@ -32,11 +35,7 @@ router.put("/:monitorId", isAllowed(["admin", "superadmin"]), editMonitor);
|
|||||||
|
|
||||||
router.delete("/", isAllowed(["superadmin"]), deleteAllMonitors);
|
router.delete("/", isAllowed(["superadmin"]), deleteAllMonitors);
|
||||||
|
|
||||||
router.post(
|
router.post("/pause/:monitorId", isAllowed(["admin", "superadmin"]), pauseMonitor);
|
||||||
"/pause/:monitorId",
|
|
||||||
isAllowed(["admin", "superadmin"]),
|
|
||||||
pauseMonitor
|
|
||||||
);
|
|
||||||
|
|
||||||
router.post("/demo", isAllowed(["admin", "superadmin"]), addDemoMonitors);
|
router.post("/demo", isAllowed(["admin", "superadmin"]), addDemoMonitors);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -204,7 +204,7 @@ describe("controllerUtils - fetchMonitorCertificate", () => {
|
|||||||
try {
|
try {
|
||||||
await fetchMonitorCertificate(tls, monitor);
|
await fetchMonitorCertificate(tls, monitor);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
expect(error.message).to.equal("Certificate error");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user