From 0a120203be2667b53b190d8106fc68a6ab3c7784 Mon Sep 17 00:00:00 2001 From: siiky Date: Mon, 17 Mar 2025 16:57:30 +0000 Subject: [PATCH] feat: in stress testing use device ID sent in headers --- lib/middlewares/populateDeviceId.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/middlewares/populateDeviceId.js b/lib/middlewares/populateDeviceId.js index e406578d..e9de4d88 100644 --- a/lib/middlewares/populateDeviceId.js +++ b/lib/middlewares/populateDeviceId.js @@ -14,12 +14,13 @@ function sha256 (buf) { } const populateDeviceId = function (req, res, next) { - const deviceId = _.isFunction(req.connection.getPeerCertificate) + let deviceId = _.isFunction(req.connection.getPeerCertificate) ? sha256(req.connection.getPeerCertificate()?.raw) - : IS_STRESS_TESTING - ? 'placeholder' /* TODO: req... ? */ : null + if (!deviceId && IS_STRESS_TESTING) + deviceId = req.headers.device_id + if (!deviceId) return res.status(500).json({ error: 'Unable to find certificate' }) req.deviceId = deviceId req.deviceTime = req.get('date')