From ce3596808cb7be59c80859d733838c827c538736 Mon Sep 17 00:00:00 2001 From: eldarlandman Date: Thu, 11 Jan 2024 18:58:45 +0200 Subject: [PATCH] - Fix unit-tests to support req.get --- test/pxcors.test.js | 4 ++++ test/pxenforcer.test.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/test/pxcors.test.js b/test/pxcors.test.js index ba1c0e1..f3218d2 100644 --- a/test/pxcors.test.js +++ b/test/pxcors.test.js @@ -37,7 +37,11 @@ describe('PX Cors - pxCors.js', () => { req.protocol = 'http'; req.ip = '1.2.3.4'; req.hostname = 'example.com'; + req.host = 'example.com'; req.get = (key) => { + if (key === 'host') { + return req.host; + } return req.headers[key] || ''; }; diff --git a/test/pxenforcer.test.js b/test/pxenforcer.test.js index 50ac461..5c43868 100644 --- a/test/pxenforcer.test.js +++ b/test/pxenforcer.test.js @@ -40,6 +40,9 @@ describe('PX Enforcer - pxenforcer.js', () => { req.ip = '1.2.3.4'; req.hostname = 'example.com'; req.get = (key) => { + if (key === 'host') { + return req.host; + } return req.headers[key] || ''; };