feat: in stress testing use device ID sent in headers

This commit is contained in:
siiky 2025-03-17 16:57:30 +00:00
parent 6fb2b29bcb
commit 0a120203be

View file

@ -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')