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

Un 38024 #37

Merged
merged 2 commits into from
May 29, 2023
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
10 changes: 9 additions & 1 deletion modules/undertoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export const spec = {
reqUrl += `&ccpa=${bidderRequest.uspConsent}`;
}

if (bidderRequest.gppConsent) {
const gppString = bidderRequest.gppConsent.gppString ?? '';
const ggpSid = bidderRequest.gppConsent.applicableSections ?? '';
reqUrl += `&gpp=${gppString}&gpp_sid=${ggpSid}`;
}

validBidRequests.map(bidReq => {
const bid = {
bidRequestId: bidReq.bidId,
Expand All @@ -146,7 +152,9 @@ export const spec = {
streamType: deepAccess(bidReq, 'mediaTypes.video.context') || null,
playbackMethod: deepAccess(bidReq, 'params.video.playbackMethod') || null,
maxDuration: deepAccess(bidReq, 'params.video.maxDuration') || null,
skippable: deepAccess(bidReq, 'params.video.skippable') || null
skippable: deepAccess(bidReq, 'params.video.skippable') || null,
placement: deepAccess(bidReq, 'mediaTypes.video.placement') || null,
plcmt: deepAccess(bidReq, 'mediaTypes.video.plcmt') || null
};
}
payload['x-ut-hb-params'].push(bid);
Expand Down
58 changes: 57 additions & 1 deletion test/spec/modules/undertoneBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ const videoBidReq = [{
},
mediaTypes: {video: {
context: 'outstream',
playerSize: [640, 480]
playerSize: [640, 480],
placement: 1,
plcmt: 1
}},
sizes: [[300, 250], [300, 600]],
bidId: '263be71e91dd9d',
Expand Down Expand Up @@ -184,6 +186,31 @@ const bidderReqCcpaAndGdpr = {
uspConsent: 'NY12'
};

const bidderReqGpp = {
refererInfo: {
topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html'
},
gppConsent: {
gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
applicableSections: [7]
}
};

const bidderReqFullGppCcpaGdpr = {
refererInfo: {
topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html'
},
gppConsent: {
gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
applicableSections: [7]
},
gdprConsent: {
gdprApplies: true,
consentString: 'gdprConsent'
},
uspConsent: '1YNN'
};

const validBidRes = {
ad: '<div>Hello</div>',
publisherId: 12345,
Expand Down Expand Up @@ -381,6 +408,31 @@ describe('Undertone Adapter', () => {
expect(request.url).to.equal(REQ_URL);
expect(request.method).to.equal('POST');
});
it(`should have gppConsent fields`, function () {
const request = spec.buildRequests(bidReq, bidderReqGpp);
const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//');
const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2);
const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd);
const gppStr = bidderReqGpp.gppConsent.gppString;
const gppSid = bidderReqGpp.gppConsent.applicableSections;
const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&gpp=${gppStr}&gpp_sid=${gppSid}`;
expect(request.url).to.equal(REQ_URL);
expect(request.method).to.equal('POST');
});
it(`should have gpp, ccpa and gdpr fields`, function () {
const request = spec.buildRequests(bidReq, bidderReqFullGppCcpaGdpr);
const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//');
const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2);
const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd);
const gppStr = bidderReqFullGppCcpaGdpr.gppConsent.gppString;
const gppSid = bidderReqFullGppCcpaGdpr.gppConsent.applicableSections;
const ccpa = bidderReqFullGppCcpaGdpr.uspConsent;
const gdpr = bidderReqFullGppCcpaGdpr.gdprConsent.gdprApplies ? 1 : 0;
const gdprStr = bidderReqFullGppCcpaGdpr.gdprConsent.consentString;
const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&gdpr=${gdpr}&gdprstr=${gdprStr}&ccpa=${ccpa}&gpp=${gppStr}&gpp_sid=${gppSid}`;
expect(request.url).to.equal(REQ_URL);
expect(request.method).to.equal('POST');
});
it('should have all relevant fields', function () {
const request = spec.buildRequests(bidReq, bidderReq);
const bid1 = JSON.parse(request.data)['x-ut-hb-params'][0];
Expand Down Expand Up @@ -409,10 +461,14 @@ describe('Undertone Adapter', () => {
expect(bidVideo.video.playbackMethod).to.equal(2);
expect(bidVideo.video.maxDuration).to.equal(30);
expect(bidVideo.video.skippable).to.equal(true);
expect(bidVideo.video.placement).to.equal(1);
expect(bidVideo.video.plcmt).to.equal(1);

expect(bidVideo2.video.skippable).to.equal(null);
expect(bidVideo2.video.maxDuration).to.equal(null);
expect(bidVideo2.video.playbackMethod).to.equal(null);
expect(bidVideo2.video.placement).to.equal(null);
expect(bidVideo2.video.plcmt).to.equal(null);
});
it('should send all userIds data to server', function () {
const request = spec.buildRequests(bidReqUserIds, bidderReq);
Expand Down