Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index Exchange: CCPA Support (Legacy) #4662

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice usage of deepSetValue

}

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');
});
});
});