From d8080a65fee3b110cf1eb0df85267fe8f4e211d9 Mon Sep 17 00:00:00 2001 From: mifanich Date: Tue, 7 Dec 2021 13:51:00 +0300 Subject: [PATCH] Fix an issue when gdpr is undefined --- modules/nextMillenniumBidAdapter.js | 14 ++++++++------ test/spec/modules/nextMillenniumBidAdapter_spec.js | 11 +++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/nextMillenniumBidAdapter.js b/modules/nextMillenniumBidAdapter.js index 803aff5c8b6..a800500faf0 100644 --- a/modules/nextMillenniumBidAdapter.js +++ b/modules/nextMillenniumBidAdapter.js @@ -44,12 +44,14 @@ export const spec = { if (uspConsent) { postBody.regs.ext.us_privacy = uspConsent; } - if (typeof gdprConsent.gdprApplies !== 'undefined') { - postBody.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0; - } - if (typeof gdprConsent.consentString !== 'undefined') { - postBody.user = { - ext: { consent: gdprConsent.consentString } + if (gdprConsent) { + if (typeof gdprConsent.gdprApplies !== 'undefined') { + postBody.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0; + } + if (typeof gdprConsent.consentString !== 'undefined') { + postBody.user = { + ext: { consent: gdprConsent.consentString } + } } } } diff --git a/test/spec/modules/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js index 1bd47cf1aac..d95ca1bf173 100644 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -18,13 +18,20 @@ describe('nextMillenniumBidAdapterTests', function() { } ]; - it('Request params check with GDPR Consent', function () { + it('Request params check with GDPR and USP Consent', function () { const request = spec.buildRequests(bidRequestData, bidRequestData[0]); expect(JSON.parse(request[0].data).user.ext.consent).to.equal('kjfdniwjnifwenrif3'); expect(JSON.parse(request[0].data).regs.ext.us_privacy).to.equal('1---'); expect(JSON.parse(request[0].data).regs.ext.gdpr).to.equal(1); }); + it('Request params check without GDPR Consent', function () { + delete bidRequestData[0].gdprConsent + const request = spec.buildRequests(bidRequestData, bidRequestData[0]); + expect(JSON.parse(request[0].data).regs.ext.gdpr).to.be.undefined; + expect(JSON.parse(request[0].data).regs.ext.us_privacy).to.equal('1---'); + }); + it('validate_generated_params', function() { const request = spec.buildRequests(bidRequestData); expect(request[0].bidId).to.equal('bid1234'); @@ -33,7 +40,7 @@ describe('nextMillenniumBidAdapterTests', function() { it('Check if refresh_count param is incremented', function() { const request = spec.buildRequests(bidRequestData); - expect(JSON.parse(request[0].data).refresh_count).to.equal(2); + expect(JSON.parse(request[0].data).refresh_count).to.equal(3); }); it('Test getUserSyncs function', function () {