Skip to content

Commit

Permalink
Dailymotion bid adapter: add publisher constraints in consent enforce…
Browse files Browse the repository at this point in the history
…ment

The previous version of the consent enforcement was only looking at the consent given by the user.

This change now also looks at the publisher constraints to disable cookie sending when the user gave consent but the publisher disallows some consents or legitimate interests.
  • Loading branch information
sebmil-daily committed Jul 29, 2024
1 parent 0cf6481 commit 8f71631
Show file tree
Hide file tree
Showing 2 changed files with 354 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modules/dailymotionBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,17 @@ export const spec = {
// Vendor consent
deepAccess(bidderRequest, 'gdprConsent.vendorData.vendor.consents.573') === true &&
// Purposes
[1, 3, 4].every(v => deepAccess(bidderRequest, `gdprConsent.vendorData.purpose.consents.${v}`) === true) &&
[1, 3, 4].every(v =>
deepAccess(bidderRequest, `gdprConsent.vendorData.publisher.consents.${v}`) !== false &&
deepAccess(bidderRequest, `gdprConsent.vendorData.purpose.consents.${v}`) === true ) &&
// Flexible purposes
[2, 7, 9, 10].every(v =>
deepAccess(bidderRequest, `gdprConsent.vendorData.purpose.consents.${v}`) === true ||
deepAccess(bidderRequest, `gdprConsent.vendorData.purpose.legitimateInterests.${v}`) === true
[2, 7, 9, 10].every(v => (
deepAccess(bidderRequest, `gdprConsent.vendorData.publisher.consents.${v}`) !== false ||
deepAccess(bidderRequest, `gdprConsent.vendorData.publisher.legitimateInterests.${v}`) !== false
) && (
deepAccess(bidderRequest, `gdprConsent.vendorData.purpose.consents.${v}`) === true ||
deepAccess(bidderRequest, `gdprConsent.vendorData.purpose.legitimateInterests.${v}`) === true
)
)
);

Expand Down
344 changes: 344 additions & 0 deletions test/spec/modules/dailymotionBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,350 @@ describe('dailymotionBidAdapterTests', () => {
expect(request.options.withCredentials).to.eql(true);
});

it('validates buildRequests with detailed consent but publisher restriction, no legitimate interest', () => {
const bidRequestData = [{
auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
bidId: 123456,
adUnitCode: 'preroll',
mediaTypes: {
video: {
api: [2, 7],
mimes: ['video/mp4'],
minduration: 5,
maxduration: 30,
playbackmethod: [3],
plcmt: 1,
protocols: [1, 2, 3, 4, 5, 6, 7, 8],
skip: 1,
skipafter: 5,
skipmin: 10,
startdelay: 0,
w: 1280,
h: 720,
},
},
sizes: [[1920, 1080]],
params: {
apiKey: 'test_api_key',
video: {
description: 'this is a test video',
duration: 556,
iabcat1: ['IAB-1'],
iabcat2: ['6', '17'],
id: '54321',
lang: 'FR',
private: false,
tags: 'tag_1,tag_2,tag_3',
title: 'test video',
url: 'https://test.com/test',
topics: 'topic_1, topic_2',
xid: 'x123456',
livestream: 1,
isCreatedForKids: true,
videoViewsInSession: 2,
autoplay: true,
playerVolume: 8,
},
},
}];

const bidderRequestData = {
refererInfo: {
page: 'https://publisher.com',
},
uspConsent: '1YN-',
gdprConsent: {
apiVersion: 2,
consentString: 'xxx',
gdprApplies: true,
vendorData: {
hasGlobalConsent: false,
publisher: {
consents: {
1: false,
},
},
purpose: {
consents: {
1: true,
2: true,
3: true,
4: true,
7: true,
9: true,
10: true,
},
},
vendor: {
consents: {
573: true
}
},
},
},
gppConsent: {
gppString: 'xxx',
applicableSections: [5],
},
ortb2: {
regs: {
coppa: 1,
},
site: {
content: {
data: [
{
name: 'dataprovider.com',
ext: { segtax: 5 },
segment: [{ id: '200' }],
},
],
},
},
},
};

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestData, bidderRequestData),
);

expect(request.options.withCredentials).to.eql(false);
});

it('validates buildRequests with detailed consent but publisher restriction, with legitimate interest', () => {
const bidRequestData = [{
auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
bidId: 123456,
adUnitCode: 'preroll',
mediaTypes: {
video: {
api: [2, 7],
mimes: ['video/mp4'],
minduration: 5,
maxduration: 30,
playbackmethod: [3],
plcmt: 1,
protocols: [1, 2, 3, 4, 5, 6, 7, 8],
skip: 1,
skipafter: 5,
skipmin: 10,
startdelay: 0,
w: 1280,
h: 720,
},
},
sizes: [[1920, 1080]],
params: {
apiKey: 'test_api_key',
video: {
description: 'this is a test video',
duration: 556,
iabcat1: ['IAB-1'],
iabcat2: ['6', '17'],
id: '54321',
lang: 'FR',
private: false,
tags: 'tag_1,tag_2,tag_3',
title: 'test video',
url: 'https://test.com/test',
topics: 'topic_1, topic_2',
xid: 'x123456',
livestream: 1,
isCreatedForKids: true,
videoViewsInSession: 2,
autoplay: true,
playerVolume: 8,
},
},
}];

const bidderRequestData = {
refererInfo: {
page: 'https://publisher.com',
},
uspConsent: '1YN-',
gdprConsent: {
apiVersion: 2,
consentString: 'xxx',
gdprApplies: true,
vendorData: {
hasGlobalConsent: false,
publisher: {
consents: {
2: false,
},
legitimateInterests: {
2: false,
},
},
purpose: {
consents: {
1: true,
3: true,
4: true,
},
legitimateInterests: {
2: true,
7: true,
9: true,
10: true,
},
},
vendor: {
consents: {
573: true
}
},
},
},
gppConsent: {
gppString: 'xxx',
applicableSections: [5],
},
ortb2: {
regs: {
coppa: 1,
},
site: {
content: {
data: [
{
name: 'dataprovider.com',
ext: { segtax: 5 },
segment: [{ id: '200' }],
},
],
},
},
},
};

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestData, bidderRequestData),
);

expect(request.options.withCredentials).to.eql(false);
});


it('validates buildRequests with detailed consent and publisher restriction, with legitimate interest valid in both', () => {
const bidRequestData = [{
auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
bidId: 123456,
adUnitCode: 'preroll',
mediaTypes: {
video: {
api: [2, 7],
mimes: ['video/mp4'],
minduration: 5,
maxduration: 30,
playbackmethod: [3],
plcmt: 1,
protocols: [1, 2, 3, 4, 5, 6, 7, 8],
skip: 1,
skipafter: 5,
skipmin: 10,
startdelay: 0,
w: 1280,
h: 720,
},
},
sizes: [[1920, 1080]],
params: {
apiKey: 'test_api_key',
video: {
description: 'this is a test video',
duration: 556,
iabcat1: ['IAB-1'],
iabcat2: ['6', '17'],
id: '54321',
lang: 'FR',
private: false,
tags: 'tag_1,tag_2,tag_3',
title: 'test video',
url: 'https://test.com/test',
topics: 'topic_1, topic_2',
xid: 'x123456',
livestream: 1,
isCreatedForKids: true,
videoViewsInSession: 2,
autoplay: true,
playerVolume: 8,
},
},
}];

const bidderRequestData = {
refererInfo: {
page: 'https://publisher.com',
},
uspConsent: '1YN-',
gdprConsent: {
apiVersion: 2,
consentString: 'xxx',
gdprApplies: true,
vendorData: {
hasGlobalConsent: false,
publisher: {
consents: {
2: false,
},
legitimateInterests: {
2: true,
},
},
purpose: {
consents: {
1: true,
3: true,
4: true,
},
legitimateInterests: {
2: true,
7: true,
9: true,
10: true,
},
},
vendor: {
consents: {
573: true
}
},
},
},
gppConsent: {
gppString: 'xxx',
applicableSections: [5],
},
ortb2: {
regs: {
coppa: 1,
},
site: {
content: {
data: [
{
name: 'dataprovider.com',
ext: { segtax: 5 },
segment: [{ id: '200' }],
},
],
},
},
},
};

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestData, bidderRequestData),
);

expect(request.options.withCredentials).to.eql(true);
});

it('validates buildRequests with insufficient consent', () => {
const bidRequestData = [{
auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
Expand Down

0 comments on commit 8f71631

Please sign in to comment.