Skip to content

Commit

Permalink
Conversant adapter CCPA support (prebid#4569)
Browse files Browse the repository at this point in the history
  • Loading branch information
pycnvr authored and Isaac A. Dettman committed Dec 11, 2019
1 parent ca5cdcf commit 21dcd5a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
22 changes: 12 additions & 10 deletions modules/conversantBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,18 @@ export const spec = {

let userExt = {};

// Add GDPR flag and consent string
if (bidderRequest && bidderRequest.gdprConsent) {
userExt.consent = bidderRequest.gdprConsent.consentString;

if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') {
payload.regs = {
ext: {
gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0)
}
};
if (bidderRequest) {
// Add GDPR flag and consent string
if (bidderRequest.gdprConsent) {
userExt.consent = bidderRequest.gdprConsent.consentString;

if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') {
utils.deepSetValue(payload, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies ? 1 : 0);
}
}

if (bidderRequest.uspConsent) {
utils.deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}
}

Expand Down
40 changes: 36 additions & 4 deletions test/spec/modules/conversantBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,31 +404,63 @@ describe('Conversant adapter tests', function() {

it('Verify GDPR bid request', function() {
// add gdpr info
const bidRequest = {
const bidderRequest = {
gdprConsent: {
consentString: 'BOJObISOJObISAABAAENAA4AAAAAoAAA',
gdprApplies: true
}
};

const payload = spec.buildRequests(bidRequests, bidRequest).data;
const payload = spec.buildRequests(bidRequests, bidderRequest).data;
expect(payload).to.have.deep.nested.property('user.ext.consent', 'BOJObISOJObISAABAAENAA4AAAAAoAAA');
expect(payload).to.have.deep.nested.property('regs.ext.gdpr', 1);
});

it('Verify GDPR bid request without gdprApplies', function() {
// add gdpr info
const bidRequest = {
const bidderRequest = {
gdprConsent: {
consentString: ''
}
};

const payload = spec.buildRequests(bidRequests, bidRequest).data;
const payload = spec.buildRequests(bidRequests, bidderRequest).data;
expect(payload).to.have.deep.nested.property('user.ext.consent', '');
expect(payload).to.not.have.deep.nested.property('regs.ext.gdpr');
});

describe('CCPA', function() {
it('should have us_privacy', function() {
const bidderRequest = {
uspConsent: '1NYN'
};

const payload = spec.buildRequests(bidRequests, bidderRequest).data;
expect(payload).to.have.deep.nested.property('regs.ext.us_privacy', '1NYN');
expect(payload).to.not.have.deep.nested.property('regs.ext.gdpr');
});

it('should have no us_privacy', function() {
const payload = spec.buildRequests(bidRequests, {}).data;
expect(payload).to.not.have.deep.nested.property('regs.ext.us_privacy');
});

it('should have both gdpr and us_privacy', function() {
const bidderRequest = {
gdprConsent: {
consentString: 'BOJObISOJObISAABAAENAA4AAAAAoAAA',
gdprApplies: true
},
uspConsent: '1NYN'
};

const payload = spec.buildRequests(bidRequests, bidderRequest).data;
expect(payload).to.have.deep.nested.property('user.ext.consent', 'BOJObISOJObISAABAAENAA4AAAAAoAAA');
expect(payload).to.have.deep.nested.property('regs.ext.gdpr', 1);
expect(payload).to.have.deep.nested.property('regs.ext.us_privacy', '1NYN');
});
});

describe('Extended ID', function() {
it('Verify unifiedid and liveramp', function() {
// clone bidRequests
Expand Down

0 comments on commit 21dcd5a

Please sign in to comment.