Skip to content

Commit

Permalink
Fix an issue when gdpr is undefined (prebid#7817)
Browse files Browse the repository at this point in the history
Co-authored-by: mifanich <mihail.ivanchenko@nextmillennium.io>
  • Loading branch information
2 people authored and avj83 committed Jan 24, 2022
1 parent fd3a28d commit 830da96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
14 changes: 8 additions & 6 deletions modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions test/spec/modules/nextMillenniumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 () {
Expand Down

0 comments on commit 830da96

Please sign in to comment.