Skip to content

Commit

Permalink
Index Exchange: CCPA support (#4662)
Browse files Browse the repository at this point in the history
  • Loading branch information
ix-prebid-support authored and mkendall07 committed Dec 30, 2019
1 parent c549b65 commit 5ba6ea9
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 28 deletions.
4 changes: 4 additions & 0 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
}
}

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

if (bidderRequest.refererInfo) {
r.site.page = bidderRequest.refererInfo.referer;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/ixBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Description
===========

This module connects publishers to Index Exchange's (IX) network of demand
sources through Prebid.js. This module is GDPR compliant.
sources through Prebid.js. This module is GDPR and CCPA compliant.

It is compatible with both the older ad unit format where the `sizes` and
`mediaType` properties are placed at the top-level of the ad unit, and the newer
Expand Down
88 changes: 61 additions & 27 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,15 +896,50 @@ describe('IndexexchangeAdapter', function () {
expect(result[0]).to.deep.equal(expectedParse[0]);
});

it('bidrequest should have consent info if gdprApplies and consentString exist', function () {
it('bidrequest should not have page if options is undefined', function () {
const options = {};
const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);

expect(requestWithoutreferInfo.site.page).to.be.undefined;
expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
});

it('bidrequest should not have page if options.refererInfo is an empty object', function () {
const options = {
refererInfo: {}
};
const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);

expect(requestWithoutreferInfo.site.page).to.be.undefined;
expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
});

it('bidrequest should sent to secure endpoint if page url is secure', function () {
const options = {
refererInfo: {
referer: 'https://www.prebid.org'
}
};
const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);

expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.referer);
expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
});
});

describe('bidrequest consent', function() {
it('should have consent info if gdprApplies and consentString exist', function () {
const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION);
const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);

expect(requestWithConsent.regs.ext.gdpr).to.equal(1);
expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae');
});

it('bidrequest should not have consent field if consentString is undefined', function () {
it('should not have consent field if consentString is undefined', function () {
const options = {
gdprConsent: {
gdprApplies: true,
Expand All @@ -918,7 +953,7 @@ describe('IndexexchangeAdapter', function () {
expect(requestWithConsent.user).to.be.undefined;
});

it('bidrequest should not have gdpr field if gdprApplies is undefined', function () {
it('should not have gdpr field if gdprApplies is undefined', function () {
const options = {
gdprConsent: {
consentString: '3huaa11=qu3198ae',
Expand All @@ -932,7 +967,7 @@ describe('IndexexchangeAdapter', function () {
expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae');
});

it('bidrequest should not have consent info if options.gdprConsent is undefined', function () {
it('should not have consent info if options.gdprConsent is undefined', function () {
const options = {};
const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
Expand All @@ -941,37 +976,36 @@ describe('IndexexchangeAdapter', function () {
expect(requestWithConsent.user).to.be.undefined;
});

it('bidrequest should not have page if options is undefined', function () {
const options = {};
const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);
it('should have us_privacy if uspConsent is defined', function() {
const options = {
uspConsent: '1YYN'
};
const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r);

expect(requestWithoutreferInfo.site.page).to.be.undefined;
expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
expect(requestWithUspConsent.regs.ext.us_privacy).to.equal('1YYN');
});

it('bidrequest should not have page if options.refererInfo is an empty object', function () {
const options = {
refererInfo: {}
};
const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);
it('should not have us_privacy if uspConsent undefined', function() {
const options = {};
const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r);

expect(requestWithoutreferInfo.site.page).to.be.undefined;
expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
expect(requestWithUspConsent.regs).to.be.undefined;
});

it('bidrequest should sent to secure endpoint if page url is secure', function () {
it('should have both gdpr and us_privacy if both are defined', function() {
const options = {
refererInfo: {
referer: 'https://www.prebid.org'
}
gdprConsent: {
gdprApplies: true,
vendorData: {}
},
uspConsent: '1YYN'
};
const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);

expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.referer);
expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
expect(requestWithConsent.regs.ext.gdpr).to.equal(1);
expect(requestWithConsent.regs.ext.us_privacy).to.equal('1YYN');
});
});
});

0 comments on commit 5ba6ea9

Please sign in to comment.