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

PubMatic Adapter : Support For Video Params from AdUnit MediaTypes #6773

Merged
merged 89 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
7e5986c
Merge pull request #1 from prebid/master
pm-shashank-jain Nov 27, 2018
d1146d7
Merge pull request #2 from prebid/master
pm-shashank-jain Nov 29, 2018
609ec16
changes to support native in pubmaticbid adapter
pm-shashank-jain Dec 5, 2018
792b854
Removed port from endpoint
pm-shashank-jain Dec 5, 2018
b6740d0
Removed protocol from endpoint
pm-shashank-jain Dec 5, 2018
0569f41
Formatting
pm-shashank-jain Dec 5, 2018
fd6bf03
Fix request payload
pm-shashank-jain Dec 6, 2018
bd14420
Updated test case
pm-shashank-jain Dec 6, 2018
65e2f1e
Changed request and response as per ortb spec
pm-shashank-jain Dec 7, 2018
13c87de
Change in request and response
pm-shashank-jain Dec 10, 2018
d9f3562
Removed comments and extra code
pm-shashank-jain Dec 10, 2018
adbc774
Code Review comments
pm-shashank-jain Dec 11, 2018
21fe846
Code Review Comments and Test cases for request and response
pm-shashank-jain Dec 13, 2018
9faff35
Removed data type as all data asset types are handled
pm-shashank-jain Dec 14, 2018
78cd16d
Code Review Changes
pm-shashank-jain Dec 14, 2018
4a40e1e
Code Review Comments
pm-shashank-jain Dec 17, 2018
a218d43
Supporting both banner and native and sending 0x0 in case of native
pm-shashank-jain Dec 18, 2018
f65b3fb
Bug Fixes
pm-shashank-jain Dec 21, 2018
a717fbc
Bug response not processed by prebid
pm-shashank-jain Dec 21, 2018
af2503d
Change warning message
pm-shashank-jain Dec 21, 2018
21277c1
Fixed typo
pm-shashank-jain Dec 21, 2018
53ac4fe
Merge pull request #4 from prebid/master
pm-shashank-jain Dec 21, 2018
ac1919f
Merge branch 'master' of github.com:pm-shashank-jain/Prebid.js into n…
pm-shashank-jain Dec 21, 2018
1de1623
Do not send request in case of invalid native bid
pm-shashank-jain Dec 24, 2018
6b059b7
Do not send request in case of invalid native requests
pm-shashank-jain Dec 24, 2018
9c80c46
objects converted to strings in log for debug purposes
pm-shashank-jain Dec 24, 2018
e0f8763
Fixed logic to check for required parmas
pm-shashank-jain Dec 24, 2018
c4ee495
Fixed typo for stringify
pm-shashank-jain Dec 24, 2018
d4abb65
Merge pull request #3 from pm-shashank-jain/nativesupport
pm-shashank-jain Dec 26, 2018
f143cee
documentation for native
pm-shashank-jain Dec 26, 2018
06a6e34
Merge pull request #5 from pm-shashank-jain/nativesupport
pm-shashank-jain Dec 26, 2018
84a9c02
Review comments from Prebid
pm-shashank-jain Jan 8, 2019
e3d068e
Typo
pm-shashank-jain Jan 8, 2019
468c3ab
Typo
pm-shashank-jain Jan 8, 2019
11fce22
Updated pub id for native
pm-shashank-jain Jan 10, 2019
b23e2dd
Code Review
pm-shashank-jain Jan 15, 2019
6b8c31b
Merge pull request #6 from pm-shashank-jain/nativesupport
pm-shashank-jain Jan 15, 2019
2f73d99
Merge branch 'master' of github.com:pm-shashank-jain/Prebid.js
pm-shashank-jain Aug 21, 2019
27e56d6
Latest Code
pm-shashank-jain Aug 21, 2019
9c0772b
Merge pull request #8 from prebid/master
pm-shashank-jain Aug 30, 2019
909f526
Support for pubid
pm-shashank-jain Aug 30, 2019
7fe0f35
Merge branch 'master' of github.com:pm-shashank-jain/Prebid.js
pm-shashank-jain Aug 30, 2019
53a7ddf
Test Cases for PubCommonId in PubMatic adapter
pm-shashank-jain Sep 3, 2019
f168aea
Delete yarn.lock
pm-shashank-jain Sep 3, 2019
e9db7f3
Rename adaptermanager.js to adapterManager.js
pm-shashank-jain Sep 3, 2019
e753a97
Rename yieldNexusBidAdapter.js to yieldnexusBidAdapter.js
pm-shashank-jain Sep 3, 2019
68b2e65
Rename yieldNexusBidAdapter.md to yieldnexusBidAdapter.md
pm-shashank-jain Sep 3, 2019
483cddf
Rename yieldNexusBidAdapter_spec.js to yieldnexusBidAdapter_spec.yiel…
pm-shashank-jain Sep 3, 2019
149875b
Rename yieldnexusBidAdapter_spec.yieldnexusBidAdaptera to yieldnexusB…
pm-shashank-jain Sep 3, 2019
8d89338
took latest
pm-shashank-jain Dec 27, 2019
e5b4722
Merge branch 'prebid-master'
pm-shashank-jain Dec 27, 2019
7a0cace
Merge remote-tracking branch 'upstream/master'
pm-shashank-jain Jun 12, 2020
a1d5256
bluebillywig outstream player support in pubmatic adapter
pm-shashank-jain Jun 23, 2020
6e4fa37
Merge https://github.com/prebid/Prebid.js
pm-shashank-jain Jul 2, 2020
fb6056c
Merge branch 'master' of github.com:pm-shashank-jain/Prebid.js into o…
pm-shashank-jain Jul 2, 2020
5d5e4eb
Merge https://github.com/prebid/Prebid.js into outstream_renderer
pm-shashank-jain Jul 15, 2020
825242c
Merge https://github.com/prebid/Prebid.js into outstream_renderer
pm-shashank-jain Jul 17, 2020
4681528
Merge https://github.com/prebid/Prebid.js into outstream_renderer
pm-shashank-jain Jul 21, 2020
1ee6583
removed pubcommon id test cases
pm-shashank-jain Jul 21, 2020
260f7f7
Merge https://github.com/prebid/Prebid.js
pm-shashank-jain Jul 21, 2020
cc7c65c
BBW Renderer
pm-shashank-jain Jul 21, 2020
8a2e508
Merge branch 'master' of github.com:pm-shashank-jain/Prebid.js into o…
pm-shashank-jain Jul 21, 2020
3362acd
Merge https://github.com/prebid/Prebid.js
pm-shashank-jain Jul 30, 2020
e72f47f
Merge pull request #11 from pm-shashank-jain/outstream_renderer
pm-shashank-jain Jul 30, 2020
251398e
Merge branch 'master' of https://github.com/prebid/Prebid.js
pm-shashank-jain Aug 12, 2020
efdf7a1
Took latest prebid
pm-shashank-jain Dec 16, 2020
936f0fe
Merge branch 'master' of https://github.com/prebid/Prebid.js
pm-shashank-jain Dec 28, 2020
af471f8
Pubmatic should work with provided renderer
pm-shashank-jain Dec 28, 2020
7048c86
Merge pull request #12 from pm-shashank-jain/outstream_bug_fix
pm-shashank-jain Dec 28, 2020
b75de91
Merge branch 'master' of https://github.com/prebid/Prebid.js
pm-shashank-jain Jan 27, 2021
92ee235
Review Comments
pm-shashank-jain Jan 27, 2021
6e24164
latest pull
pm-shashank-jain Apr 30, 2021
1b4abe3
Merge branch 'master' of github.com:prebid/Prebid.js
pm-shashank-jain May 5, 2021
393d8c9
changes for mediatype
pm-shashank-jain May 6, 2021
7c37018
Merge branch 'master' of github.com:prebid/Prebid.js
pm-shashank-jain May 6, 2021
563f594
Changes for video feature
pm-shashank-jain May 10, 2021
1eafbd9
DCTR at impression level
pm-shashank-jain May 11, 2021
f0428fc
Fixed test cases for DCTR
pm-shashank-jain May 11, 2021
dfd5d1b
Merge pull request #13 from pm-shashank-jain/dctr
pm-shashank-jain May 11, 2021
c2986b2
Merge pull request #14 from pm-shashank-jain/feature/video
pm-shashank-jain May 11, 2021
941555d
Merge branch 'mediatype_dctr_video' into mediatypedctrvideoparams
pm-shashank-jain May 11, 2021
d244a09
Merge pull request #15 from pm-shashank-jain/mediatypedctrvideoparams
pm-shashank-jain May 11, 2021
8c4f717
took latest md file
pm-shashank-jain May 12, 2021
35f0b04
Merge branch 'mediatype_dctr_video' of github.com:pm-shashank-jain/Pr…
pm-shashank-jain May 12, 2021
ca9a6dc
fixed issue with 0 as BidType
pm-shashank-jain May 12, 2021
a5d8c79
Fix for banner
pm-shashank-jain May 14, 2021
0af10d6
removed commented code
pm-shashank-jain May 17, 2021
4dc5c3c
Code Review comments, added unit test cases for dctr, video request a…
pm-shashank-jain May 20, 2021
70dda9d
review comments: Changed skip from bool to number,warning for non str…
pm-shashank-jain May 25, 2021
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
122 changes: 58 additions & 64 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ const BB_RENDERER = {
}
};

const MEDIATYPE = {
pm-shashank-jain marked this conversation as resolved.
Show resolved Hide resolved
0: BANNER,
1: VIDEO,
2: NATIVE
}

let publisherId = 0;
let isInvalidNativeRequest = false;
let NATIVE_ASSET_ID_TO_KEY_MAP = {};
Expand Down Expand Up @@ -526,7 +532,7 @@ function _createBannerRequest(bid) {
}

function _createVideoRequest(bid) {
var videoData = bid.params.video;
var videoData = utils.mergeDeep(utils.deepAccess(bid.mediaTypes, 'video'), bid.params.video);
patmmccann marked this conversation as resolved.
Show resolved Hide resolved
var videoObj;

if (videoData !== UNDEFINED) {
Expand All @@ -544,9 +550,9 @@ function _createVideoRequest(bid) {
videoObj.w = parseInt(bid.mediaTypes.video.playerSize[0], 10);
videoObj.h = parseInt(bid.mediaTypes.video.playerSize[1], 10);
}
if (bid.params.video.hasOwnProperty('skippable')) {
if (videoData.hasOwnProperty('skippable')) {
videoObj.ext = {
'video_skippable': bid.params.video.skippable ? 1 : 0
'video_skippable': videoData.skippable ? 1 : 0
pm-shashank-jain marked this conversation as resolved.
Show resolved Hide resolved
};
}
} else {
Expand Down Expand Up @@ -576,6 +582,26 @@ function _addPMPDealsInImpression(impObj, bid) {
}
}

function _addDealCustomTargetings(imp, bid) {
pm-shashank-jain marked this conversation as resolved.
Show resolved Hide resolved
var dctr = '';
var dctrLen;
if (bid.params.dctr) {
dctr = bid.params.dctr;
if (utils.isStr(dctr) && dctr.length > 0) {
var arr = dctr.split('|');
dctr = '';
arr.forEach(val => {
dctr += (val.length > 0) ? (val.trim() + '|') : '';
});
dctrLen = dctr.length;
if (dctr.substring(dctrLen, dctrLen - 1) === '|') {
dctr = dctr.substring(0, dctrLen - 1);
}
imp.ext['key_val'] = dctr.trim()
}
}
}

function _createImpressionObject(bid, conf) {
var impObj = {};
var bannerObj;
Expand All @@ -597,7 +623,7 @@ function _createImpressionObject(bid, conf) {
};

_addPMPDealsInImpression(impObj, bid);

_addDealCustomTargetings(impObj, bid);
if (bid.hasOwnProperty('mediaTypes')) {
for (mediaTypes in bid.mediaTypes) {
switch (mediaTypes) {
Expand Down Expand Up @@ -715,22 +741,28 @@ function _handleEids(payload, validBidRequests) {
}
}

function _checkMediaType(adm, newBid) {
function _checkMediaType(bid, newBid) {
// Create a regex here to check the strings
var admStr = '';
var videoRegex = new RegExp(/VAST\s+version/);
if (adm.indexOf('span class="PubAPIAd"') >= 0) {
newBid.mediaType = BANNER;
} else if (videoRegex.test(adm)) {
newBid.mediaType = VIDEO;
if (bid.ext && bid.ext['BidType'] != undefined && Object.keys(MEDIATYPE).indexOf(bid.ext.BidType.toString()) > -1) {
newBid.mediaType = MEDIATYPE[bid.ext.BidType];
} else {
try {
admStr = JSON.parse(adm.replace(/\\/g, ''));
if (admStr && admStr.native) {
newBid.mediaType = NATIVE;
utils.logInfo(LOG_WARN_PREFIX + 'bid.ext.BidType does not exist, checking alternatively for mediaType')
var adm = bid.adm;
var admStr = '';
var videoRegex = new RegExp(/VAST\s+version/);
if (adm.indexOf('span class="PubAPIAd"') >= 0) {
pm-shashank-jain marked this conversation as resolved.
Show resolved Hide resolved
newBid.mediaType = BANNER;
} else if (videoRegex.test(adm)) {
newBid.mediaType = VIDEO;
} else {
try {
admStr = JSON.parse(adm.replace(/\\/g, ''));
if (admStr && admStr.native) {
newBid.mediaType = NATIVE;
}
} catch (e) {
utils.logWarn(LOG_WARN_PREFIX + 'Error: Cannot parse native reponse for ad response: ' + adm);
}
} catch (e) {
utils.logWarn(LOG_WARN_PREFIX + 'Error: Cannot parse native reponse for ad response: ' + adm);
}
}
}
Expand Down Expand Up @@ -820,38 +852,6 @@ function _blockedIabCategoriesValidation(payload, blockedIabCategories) {
}
}

function _handleDealCustomTargetings(payload, dctrArr, validBidRequests) {
var dctr = '';
var dctrLen;
// set dctr value in site.ext, if present in validBidRequests[0], else ignore
if (dctrArr.length > 0) {
if (validBidRequests[0].params.hasOwnProperty('dctr')) {
dctr = validBidRequests[0].params.dctr;
if (utils.isStr(dctr) && dctr.length > 0) {
var arr = dctr.split('|');
dctr = '';
arr.forEach(val => {
dctr += (val.length > 0) ? (val.trim() + '|') : '';
});
dctrLen = dctr.length;
if (dctr.substring(dctrLen, dctrLen - 1) === '|') {
dctr = dctr.substring(0, dctrLen - 1);
}
payload.site.ext = {
key_val: dctr.trim()
}
} else {
utils.logWarn(LOG_WARN_PREFIX + 'Ignoring param : dctr with value : ' + dctr + ', expects string-value, found empty or non-string value');
}
if (dctrArr.length > 1) {
utils.logWarn(LOG_WARN_PREFIX + 'dctr value found in more than 1 adunits. Value from 1st adunit will be picked. Ignoring values from subsequent adunits');
}
} else {
utils.logWarn(LOG_WARN_PREFIX + 'dctr value not found in 1st adunit, ignoring values from subsequent adunits');
}
}
}

function _assignRenderer(newBid, request) {
let bidParams, context, adUnitCode;
if (request.bidderRequest && request.bidderRequest.bids) {
Expand Down Expand Up @@ -886,22 +886,17 @@ export const spec = {
return false;
}
// video ad validation
if (bid.params.hasOwnProperty('video')) {
if (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0) {
if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) {
pm-shashank-jain marked this conversation as resolved.
Show resolved Hide resolved
if (!bid.mediaTypes.video.mimes || (bid.params.video && (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0))) {
utils.logWarn(LOG_WARN_PREFIX + 'Error: For video ads, mimes is mandatory and must specify atlease 1 mime value. Call to OpenBid will not be sent for ad unit:' + JSON.stringify(bid));
return false;
}
if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) {
if (!bid.mediaTypes[VIDEO].hasOwnProperty('context')) {
utils.logError(`${LOG_WARN_PREFIX}: no context specified in bid. Rejecting bid: `, bid);
return false;
}
if (bid.mediaTypes[VIDEO].context === 'outstream' && !utils.isStr(bid.params.outstreamAU) && !bid.hasOwnProperty('renderer') && !bid.mediaTypes[VIDEO].hasOwnProperty('renderer')) {
utils.logError(`${LOG_WARN_PREFIX}: for "outstream" bids either outstreamAU parameter must be provided or ad unit supplied renderer is required. Rejecting bid: `, bid);
return false;
}
} else {
utils.logError(`${LOG_WARN_PREFIX}: mediaTypes or mediaTypes.video is not specified. Rejecting bid: `, bid);
if (!bid.mediaTypes[VIDEO].hasOwnProperty('context')) {
pm-shashank-jain marked this conversation as resolved.
Show resolved Hide resolved
utils.logError(`${LOG_WARN_PREFIX}: no context specified in bid. Rejecting bid: `, bid);
return false;
}
if (bid.mediaTypes[VIDEO].context === 'outstream' && !utils.isStr(bid.params.outstreamAU) && !bid.hasOwnProperty('renderer') && !bid.mediaTypes[VIDEO].hasOwnProperty('renderer')) {
utils.logError(`${LOG_WARN_PREFIX}: for "outstream" bids either outstreamAU parameter must be provided or ad unit supplied renderer is required. Rejecting bid: `, bid);
return false;
}
}
Expand Down Expand Up @@ -1026,7 +1021,6 @@ export const spec = {
utils.deepSetValue(payload, 'regs.coppa', 1);
}

_handleDealCustomTargetings(payload, dctrArr, validBidRequests);
_handleEids(payload, validBidRequests);
_blockedIabCategoriesValidation(payload, blockedIabCategories);

Expand Down Expand Up @@ -1100,7 +1094,7 @@ export const spec = {
if (parsedRequest.imp && parsedRequest.imp.length > 0) {
parsedRequest.imp.forEach(req => {
if (bid.impid === req.id) {
_checkMediaType(bid.adm, newBid);
_checkMediaType(bid, newBid);
switch (newBid.mediaType) {
case BANNER:
break;
Expand Down
98 changes: 2 additions & 96 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,6 @@ describe('PubMatic adapter', function () {
expect(data.site.domain).to.be.a('string'); // domain should be set
expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); // forced pageURL
expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id
expect(data.site.ext).to.exist.and.to.be.an('object'); // dctr parameter
expect(data.site.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
Expand All @@ -879,6 +877,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
pm-shashank-jain marked this conversation as resolved.
Show resolved Hide resolved
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain);
});
Expand Down Expand Up @@ -967,7 +966,6 @@ describe('PubMatic adapter', function () {
expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp');
expect(data.app.domain).to.equal('prebid.org');
expect(data.app.publisher.id).to.equal(bidRequests[0].params.publisherId);
expect(data.app.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.site).to.not.exist;
sandbox.restore();
});
Expand All @@ -994,7 +992,6 @@ describe('PubMatic adapter', function () {
expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp');
expect(data.app.domain).to.equal('prebid.org');
expect(data.app.publisher.id).to.equal(bidRequests[0].params.publisherId);
expect(data.app.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.app.content).to.deep.equal(content);
expect(data.site).to.not.exist;
sandbox.restore();
Expand Down Expand Up @@ -1026,7 +1023,6 @@ describe('PubMatic adapter', function () {
expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp');
expect(data.app.domain).to.equal('prebid.org');
expect(data.app.publisher.id).to.equal(bidRequests[0].params.publisherId);
expect(data.app.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.app.content).to.deep.equal(appContent);
expect(data.site).to.not.exist;
sandbox.restore();
Expand All @@ -1043,8 +1039,6 @@ describe('PubMatic adapter', function () {
expect(data.site.domain).to.be.a('string'); // domain should be set
expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); // forced pageURL
expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id
expect(data.site.ext).to.exist.and.to.be.an('object'); // dctr parameter
expect(data.site.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
Expand All @@ -1063,6 +1057,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].banner.w).to.equal(728); // width
expect(data.imp[0].banner.h).to.equal(90); // height
expect(data.imp[0].banner.format).to.deep.equal([{w: 160, h: 600}]);
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
});
Expand Down Expand Up @@ -2496,95 +2491,6 @@ describe('PubMatic adapter', function () {
});
});

it('Request params dctr check', function () {
let multipleBidRequests = [
{
bidder: 'pubmatic',
params: {
publisherId: '301',
adSlot: '/15671365/DMDemo@300x250:0',
kadfloor: '1.2',
pmzoneid: 'aabc, ddef',
kadpageurl: 'www.publisher.com',
yob: '1986',
gender: 'M',
lat: '12.3',
lon: '23.7',
wiid: '1234567890',
profId: '100',
verId: '200',
currency: 'AUD',
dctr: 'key1=val1|key2=val2,!val3'
},
placementCode: '/19968336/header-bid-tag-1',
sizes: [[300, 250], [300, 600]],
bidId: '23acc48ad47af5',
requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
bidderRequestId: '1c56ad30b9b8ca8',
transactionId: '92489f71-1bf2-49a0-adf9-000cea934729'
},
{
bidder: 'pubmatic',
params: {
publisherId: '301',
adSlot: '/15671365/DMDemo@300x250:0',
kadfloor: '1.2',
pmzoneid: 'aabc, ddef',
kadpageurl: 'www.publisher.com',
yob: '1986',
gender: 'M',
lat: '12.3',
lon: '23.7',
wiid: '1234567890',
profId: '100',
verId: '200',
currency: 'GBP',
dctr: 'key1=val3|key2=val1,!val3|key3=val123'
},
placementCode: '/19968336/header-bid-tag-1',
sizes: [[300, 250], [300, 600]],
bidId: '23acc48ad47af5',
requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
bidderRequestId: '1c56ad30b9b8ca8',
transactionId: '92489f71-1bf2-49a0-adf9-000cea934729'
}
];

let request = spec.buildRequests(multipleBidRequests, {
auctionId: 'new-auction-id'
});
let data = JSON.parse(request.data);

/* case 1 -
dctr is found in adunit[0]
*/

expect(data.site.ext).to.exist.and.to.be.an('object'); // dctr parameter
expect(data.site.ext.key_val).to.exist.and.to.equal(multipleBidRequests[0].params.dctr);

/* case 2 -
dctr not present in adunit[0]
*/
delete multipleBidRequests[0].params.dctr;
request = spec.buildRequests(multipleBidRequests, {
auctionId: 'new-auction-id'
});
data = JSON.parse(request.data);

expect(data.site.ext).to.not.exist;

/* case 3 -
dctr is present in adunit[0], but is not a string value
*/
multipleBidRequests[0].params.dctr = 123;
request = spec.buildRequests(multipleBidRequests, {
auctionId: 'new-auction-id'
});
data = JSON.parse(request.data);

expect(data.site.ext).to.not.exist;
});

it('Request params deals check', function () {
let multipleBidRequests = [
{
Expand Down