diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js
index c6ecea48abf..1934fd53e60 100644
--- a/modules/pubmaticBidAdapter.js
+++ b/modules/pubmaticBidAdapter.js
@@ -48,7 +48,8 @@ const VIDEO_CUSTOM_PARAMS = {
'linearity': DATA_TYPES.NUMBER,
'placement': DATA_TYPES.NUMBER,
'minbitrate': DATA_TYPES.NUMBER,
- 'maxbitrate': DATA_TYPES.NUMBER
+ 'maxbitrate': DATA_TYPES.NUMBER,
+ 'skip': DATA_TYPES.NUMBER
}
const NATIVE_ASSETS = {
@@ -162,6 +163,12 @@ const BB_RENDERER = {
}
};
+const MEDIATYPE = [
+ BANNER,
+ VIDEO,
+ NATIVE
+]
+
let publisherId = 0;
let isInvalidNativeRequest = false;
let NATIVE_ASSET_ID_TO_KEY_MAP = {};
@@ -526,7 +533,7 @@ function _createBannerRequest(bid) {
}
function _createVideoRequest(bid) {
- var videoData = bid.params.video;
+ var videoData = utils.mergeDeep(utils.deepAccess(bid.mediaTypes, 'video'), bid.params.video);
var videoObj;
if (videoData !== UNDEFINED) {
@@ -544,11 +551,6 @@ 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')) {
- videoObj.ext = {
- 'video_skippable': bid.params.video.skippable ? 1 : 0
- };
- }
} else {
videoObj = UNDEFINED;
utils.logWarn(LOG_WARN_PREFIX + 'Error: Video config params missing for adunit: ' + bid.params.adUnit + ' with mediaType set as video. Ignoring video impression in the adunit.');
@@ -576,6 +578,28 @@ function _addPMPDealsInImpression(impObj, bid) {
}
}
+function _addDealCustomTargetings(imp, bid) {
+ 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()
+ } else {
+ utils.logWarn(LOG_WARN_PREFIX + 'Ignoring param : dctr with value : ' + dctr + ', expects string-value, found empty or non-string value');
+ }
+ }
+}
+
function _createImpressionObject(bid, conf) {
var impObj = {};
var bannerObj;
@@ -597,7 +621,7 @@ function _createImpressionObject(bid, conf) {
};
_addPMPDealsInImpression(impObj, bid);
-
+ _addDealCustomTargetings(impObj, bid);
if (bid.hasOwnProperty('mediaTypes')) {
for (mediaTypes in bid.mediaTypes) {
switch (mediaTypes) {
@@ -715,22 +739,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) {
+ 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) {
+ 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);
}
}
}
@@ -820,38 +850,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) {
@@ -886,22 +884,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)) {
+ 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')) {
+ 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;
}
}
@@ -1026,7 +1019,6 @@ export const spec = {
utils.deepSetValue(payload, 'regs.coppa', 1);
}
- _handleDealCustomTargetings(payload, dctrArr, validBidRequests);
_handleEids(payload, validBidRequests);
_blockedIabCategoriesValidation(payload, blockedIabCategories);
@@ -1100,7 +1092,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;
diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js
index 28e79a69e55..f7734bd8733 100644
--- a/test/spec/modules/pubmaticBidAdapter_spec.js
+++ b/test/spec/modules/pubmaticBidAdapter_spec.js
@@ -791,6 +791,151 @@ describe('PubMatic adapter', function () {
isValid = spec.isBidRequestValid(validBid);
expect(isValid).to.equal(true);
});
+
+ it('should check for context if video is present', function() {
+ let bid = {
+ 'bidder': 'pubmatic',
+ 'params': {
+ 'adSlot': 'SLOT_NHB1@728x90',
+ 'publisherId': '5890'
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [
+ [640, 480]
+ ],
+ 'protocols': [1, 2, 5],
+ 'context': 'instream',
+ 'mimes': ['video/flv'],
+ 'skippable': false,
+ 'skip': 1,
+ 'linearity': 2
+ }
+ },
+ 'adUnitCode': 'video1',
+ 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf',
+ 'sizes': [
+ [640, 480]
+ ],
+ 'bidId': '2c95df014cfe97',
+ 'bidderRequestId': '1fe59391566442',
+ 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142',
+ 'src': 'client',
+ 'bidRequestsCount': 1,
+ 'bidderRequestsCount': 1,
+ 'bidderWinsCount': 0
+ },
+ isValid = spec.isBidRequestValid(bid);
+ expect(isValid).to.equal(true);
+ })
+
+ it('should return false if context is not present in video', function() {
+ let bid = {
+ 'bidder': 'pubmatic',
+ 'params': {
+ 'adSlot': 'SLOT_NHB1@728x90',
+ 'publisherId': '5890'
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'w': 640,
+ 'h': 480,
+ 'protocols': [1, 2, 5],
+ 'mimes': ['video/flv'],
+ 'skippable': false,
+ 'skip': 1,
+ 'linearity': 2
+ }
+ },
+ 'adUnitCode': 'video1',
+ 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf',
+ 'sizes': [
+ [640, 480]
+ ],
+ 'bidId': '2c95df014cfe97',
+ 'bidderRequestId': '1fe59391566442',
+ 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142',
+ 'src': 'client',
+ 'bidRequestsCount': 1,
+ 'bidderRequestsCount': 1,
+ 'bidderWinsCount': 0
+ },
+ isValid = spec.isBidRequestValid(bid);
+ expect(isValid).to.equal(false);
+ })
+
+ it('should check for mimes if video is present', function() {
+ let bid = {
+ 'bidder': 'pubmatic',
+ 'params': {
+ 'adSlot': 'SLOT_NHB1@728x90',
+ 'publisherId': '5890'
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [
+ [640, 480]
+ ],
+ 'protocols': [1, 2, 5],
+ 'context': 'instream',
+ 'mimes': ['video/flv'],
+ 'skippable': false,
+ 'skip': 1,
+ 'linearity': 2
+ }
+ },
+ 'adUnitCode': 'video1',
+ 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf',
+ 'sizes': [
+ [640, 480]
+ ],
+ 'bidId': '2c95df014cfe97',
+ 'bidderRequestId': '1fe59391566442',
+ 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142',
+ 'src': 'client',
+ 'bidRequestsCount': 1,
+ 'bidderRequestsCount': 1,
+ 'bidderWinsCount': 0
+ },
+ isValid = spec.isBidRequestValid(bid);
+ expect(isValid).to.equal(true);
+ })
+
+ it('should return false if mimes is not present in video', function() {
+ let bid = {
+ 'bidder': 'pubmatic',
+ 'params': {
+ 'adSlot': 'SLOT_NHB1@728x90',
+ 'publisherId': '5890'
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [
+ [640, 480]
+ ],
+ 'protocols': [1, 2, 5],
+ 'context': 'instream',
+ 'skippable': false,
+ 'skip': 1,
+ 'linearity': 2
+ }
+ },
+ 'adUnitCode': 'video1',
+ 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf',
+ 'sizes': [
+ [640, 480]
+ ],
+ 'bidId': '2c95df014cfe97',
+ 'bidderRequestId': '1fe59391566442',
+ 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142',
+ 'src': 'client',
+ 'bidRequestsCount': 1,
+ 'bidderRequestsCount': 1,
+ 'bidderWinsCount': 0
+ },
+ isValid = spec.isBidRequestValid(bid);
+ expect(isValid).to.equal(false);
+ })
});
describe('Request formation', function () {
@@ -858,8 +1003,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
@@ -879,6 +1022,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);
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain);
});
@@ -967,7 +1111,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();
});
@@ -994,7 +1137,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();
@@ -1026,7 +1168,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();
@@ -1043,8 +1184,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
@@ -1063,6 +1202,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);
});
@@ -2105,7 +2245,6 @@ describe('PubMatic adapter', function () {
let data = JSON.parse(request.data);
expect(data.imp[0].video).to.exist;
expect(data.imp[0].tagid).to.equal('Div1');
- expect(data.imp[0].video.ext['video_skippable']).to.equal(videoBidRequests[0].params.video.skippable ? 1 : 0);
expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array');
expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]);
expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]);
@@ -2175,7 +2314,6 @@ describe('PubMatic adapter', function () {
// video imp object check
expect(data.imp[1].video).to.exist;
expect(data.imp[1].tagid).to.equal('Div1');
- expect(data.imp[1].video.ext['video_skippable']).to.equal(multipleMediaRequests[1].params.video.skippable ? 1 : 0);
expect(data.imp[1]['video']['mimes']).to.exist.and.to.be.an('array');
expect(data.imp[1]['video']['mimes'][0]).to.equal(multipleMediaRequests[1].params.video['mimes'][0]);
expect(data.imp[1]['video']['mimes'][1]).to.equal(multipleMediaRequests[1].params.video['mimes'][1]);
@@ -2494,6 +2632,93 @@ describe('PubMatic adapter', function () {
expect(data.video).to.exist;
expect(data.native).to.not.exist;
});
+
+ it('should build video impression if video params are present in adunit.mediaTypes instead of bid.params', function() {
+ let videoReq = [{
+ 'bidder': 'pubmatic',
+ 'params': {
+ 'adSlot': 'SLOT_NHB1@728x90',
+ 'publisherId': '5890',
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [
+ [640, 480]
+ ],
+ 'protocols': [1, 2, 5],
+ 'context': 'instream',
+ 'mimes': ['video/flv'],
+ 'skip': 1,
+ 'linearity': 2
+ }
+ },
+ 'adUnitCode': 'video1',
+ 'transactionId': 'adc36682-887c-41e9-9848-8b72c08332c0',
+ 'sizes': [
+ [640, 480]
+ ],
+ 'bidId': '21b59b1353ba82',
+ 'bidderRequestId': '1a08245305e6dd',
+ 'auctionId': 'bad3a743-7491-4d19-9a96-b0a69dd24a67',
+ 'src': 'client',
+ 'bidRequestsCount': 1,
+ 'bidderRequestsCount': 1,
+ 'bidderWinsCount': 0
+ }]
+ let request = spec.buildRequests(videoReq, {
+ auctionId: 'new-auction-id'
+ });
+ let data = JSON.parse(request.data);
+ data = data.imp[0];
+ expect(data.video).to.exist;
+ });
+
+ it('should build video impression with overwriting video params present in adunit.mediaTypes with bid.params', function() {
+ let videoReq = [{
+ 'bidder': 'pubmatic',
+ 'params': {
+ 'adSlot': 'SLOT_NHB1@728x90',
+ 'publisherId': '5890',
+ 'video': {
+ 'mimes': ['video/mp4'],
+ 'protocols': [1, 2, 5],
+ 'linearity': 1
+ }
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [
+ [640, 480]
+ ],
+ 'protocols': [1, 2, 5],
+ 'context': 'instream',
+ 'mimes': ['video/flv'],
+ 'skip': 1,
+ 'linearity': 2
+ }
+ },
+ 'adUnitCode': 'video1',
+ 'transactionId': 'adc36682-887c-41e9-9848-8b72c08332c0',
+ 'sizes': [
+ [640, 480]
+ ],
+ 'bidId': '21b59b1353ba82',
+ 'bidderRequestId': '1a08245305e6dd',
+ 'auctionId': 'bad3a743-7491-4d19-9a96-b0a69dd24a67',
+ 'src': 'client',
+ 'bidRequestsCount': 1,
+ 'bidderRequestsCount': 1,
+ 'bidderWinsCount': 0
+ }]
+ let request = spec.buildRequests(videoReq, {
+ auctionId: 'new-auction-id'
+ });
+ let data = JSON.parse(request.data);
+ data = data.imp[0];
+
+ expect(data.video).to.exist;
+ expect(data.video.linearity).to.equal(1);
+ });
});
it('Request params dctr check', function () {
@@ -2503,17 +2728,6 @@ describe('PubMatic adapter', function () {
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',
@@ -2559,11 +2773,11 @@ describe('PubMatic adapter', function () {
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);
+ expect(data.imp[0].ext).to.exist.and.to.be.an('object'); // dctr parameter
+ expect(data.imp[0].ext.key_val).to.exist.and.to.equal(multipleBidRequests[0].params.dctr);
/* case 2 -
- dctr not present in adunit[0]
+ dctr not present in adunit[0] but present in adunit[1]
*/
delete multipleBidRequests[0].params.dctr;
request = spec.buildRequests(multipleBidRequests, {
@@ -2571,7 +2785,9 @@ describe('PubMatic adapter', function () {
});
data = JSON.parse(request.data);
- expect(data.site.ext).to.not.exist;
+ expect(data.imp[0].ext).to.exist.and.to.deep.equal({});
+ expect(data.imp[1].ext).to.exist.and.to.be.an('object'); // dctr parameter
+ expect(data.imp[1].ext.key_val).to.exist.and.to.equal(multipleBidRequests[1].params.dctr);
/* case 3 -
dctr is present in adunit[0], but is not a string value
@@ -2582,7 +2798,7 @@ describe('PubMatic adapter', function () {
});
data = JSON.parse(request.data);
- expect(data.site.ext).to.not.exist;
+ expect(data.imp[0].ext).to.exist.and.to.deep.equal({});
});
it('Request params deals check', function () {
@@ -2966,6 +3182,155 @@ describe('PubMatic adapter', function () {
let response = spec.interpretResponse(bidResponses, request);
expect(response[0].renderer).to.not.exist;
});
+
+ it('should assign mediaType by reading bid.ext.mediaType', function() {
+ let newvideoRequests = [{
+ 'bidder': 'pubmatic',
+ 'params': {
+ 'adSlot': 'SLOT_NHB1@728x90',
+ 'publisherId': '5670',
+ 'video': {
+ 'mimes': ['video/mp4'],
+ 'skippable': true,
+ 'protocols': [1, 2, 5],
+ 'linearity': 1
+ }
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [
+ [640, 480]
+ ],
+ 'protocols': [1, 2, 5],
+ 'context': 'instream',
+ 'mimes': ['video/flv'],
+ 'skippable': false,
+ 'skip': 1,
+ 'linearity': 2
+ }
+ },
+ 'adUnitCode': 'video1',
+ 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf',
+ 'sizes': [
+ [640, 480]
+ ],
+ 'bidId': '2c95df014cfe97',
+ 'bidderRequestId': '1fe59391566442',
+ 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142',
+ 'src': 'client',
+ 'bidRequestsCount': 1,
+ 'bidderRequestsCount': 1,
+ 'bidderWinsCount': 0
+ }];
+ let newvideoBidResponses = {
+ 'body': {
+ 'id': '1621441141473',
+ 'cur': 'USD',
+ 'customdata': 'openrtb1',
+ 'ext': {
+ 'buyid': 'myBuyId'
+ },
+ 'seatbid': [{
+ 'bid': [{
+ 'id': '2c95df014cfe97',
+ 'impid': '2c95df014cfe97',
+ 'price': 4.2,
+ 'cid': 'test1',
+ 'crid': 'test2',
+ 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1",
+ 'w': 0,
+ 'h': 0,
+ 'dealId': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420',
+ 'ext': {
+ 'BidType': 1
+ }
+ }],
+ 'ext': {
+ 'buyid': 'myBuyId'
+ }
+ }]
+ },
+ 'headers': {}
+ }
+ let newrequest = spec.buildRequests(newvideoRequests, {
+ auctionId: 'new-auction-id'
+ });
+ let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest);
+ expect(newresponse[0].mediaType).to.equal('video')
+ })
+
+ it('should assign mediaType even if bid.ext.mediaType does not exists', function() {
+ let newvideoRequests = [{
+ 'bidder': 'pubmatic',
+ 'params': {
+ 'adSlot': 'SLOT_NHB1@728x90',
+ 'publisherId': '5670',
+ 'video': {
+ 'mimes': ['video/mp4'],
+ 'skippable': true,
+ 'protocols': [1, 2, 5],
+ 'linearity': 1
+ }
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [
+ [640, 480]
+ ],
+ 'protocols': [1, 2, 5],
+ 'context': 'instream',
+ 'mimes': ['video/flv'],
+ 'skippable': false,
+ 'skip': 1,
+ 'linearity': 2
+ }
+ },
+ 'adUnitCode': 'video1',
+ 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf',
+ 'sizes': [
+ [640, 480]
+ ],
+ 'bidId': '2c95df014cfe97',
+ 'bidderRequestId': '1fe59391566442',
+ 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142',
+ 'src': 'client',
+ 'bidRequestsCount': 1,
+ 'bidderRequestsCount': 1,
+ 'bidderWinsCount': 0
+ }];
+ let newvideoBidResponses = {
+ 'body': {
+ 'id': '1621441141473',
+ 'cur': 'USD',
+ 'customdata': 'openrtb1',
+ 'ext': {
+ 'buyid': 'myBuyId'
+ },
+ 'seatbid': [{
+ 'bid': [{
+ 'id': '2c95df014cfe97',
+ 'impid': '2c95df014cfe97',
+ 'price': 4.2,
+ 'cid': 'test1',
+ 'crid': 'test2',
+ 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1",
+ 'w': 0,
+ 'h': 0,
+ 'dealId': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420'
+ }],
+ 'ext': {
+ 'buyid': 'myBuyId'
+ }
+ }]
+ },
+ 'headers': {}
+ }
+ let newrequest = spec.buildRequests(newvideoRequests, {
+ auctionId: 'new-auction-id'
+ });
+ let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest);
+ expect(newresponse[0].mediaType).to.equal('video')
+ })
});
describe('getUserSyncs', function() {