From a703b3d1f94eb673275a7e6c21a3e6698bfab79b Mon Sep 17 00:00:00 2001 From: Rajesh Date: Tue, 18 Dec 2018 14:43:40 +0530 Subject: [PATCH 1/3] Support Multi-Format Ads - Banner & Video --- modules/rhythmoneBidAdapter.js | 276 ++++++++------- modules/rhythmoneBidAdapter.md | 8 +- test/spec/modules/rhythmoneBidAdapter_spec.js | 314 ++++++++++++++---- 3 files changed, 413 insertions(+), 185 deletions(-) diff --git a/modules/rhythmoneBidAdapter.js b/modules/rhythmoneBidAdapter.js index f16e797af7d..ef1a891adac 100644 --- a/modules/rhythmoneBidAdapter.js +++ b/modules/rhythmoneBidAdapter.js @@ -1,5 +1,6 @@ 'use strict'; +import * as utils from 'src/utils'; import {registerBidder} from 'src/adapters/bidderFactory'; import { BANNER, VIDEO } from 'src/mediaTypes'; @@ -7,6 +8,17 @@ function RhythmOneBidAdapter() { this.code = 'rhythmone'; this.supportedMediaTypes = [VIDEO, BANNER]; + let SUPPORTED_VIDEO_PROTOCOLS = [2, 3, 5, 6]; + let SUPPORTED_VIDEO_MIMES = ['video/mp4']; + let SUPPORTED_VIDEO_PLAYBACK_METHODS = [1, 2, 3, 4]; + let SUPPORTED_VIDEO_DELIVERY = [1]; + let SUPPORTED_VIDEO_API = [1, 2, 5]; + let slotsToBids = {}; + let that = this; + let version = '1.0.2.0'; + let loadStart = Date.now(); + var win = typeof window !== 'undefined' ? window : {}; + this.isBidRequestValid = function (bid) { return true; }; @@ -70,151 +82,165 @@ function RhythmOneBidAdapter() { } }; - function getFirstParam(key, validBidRequests) { - for (let i = 0; i < validBidRequests.length; i++) { - if (validBidRequests[i].params && validBidRequests[i].params[key]) { - return validBidRequests[i].params[key]; + function frameImp(BRs) { + var imp = []; + for (var i = 0; i < BRs.length; i++) { + slotsToBids[BRs[i].adUnitCode || BRs[i].placementCode] = BRs[i]; + var impObj = {}; + impObj.id = BRs[i].adUnitCode; + impObj.bidfloor = parseFloat(utils.deepAccess(BRs[i], 'params.floor')) || 0; + impObj.secure = win.location.protocol === 'https:' ? 1 : 0; + if (utils.deepAccess(BRs[i], 'mediaTypes.banner') || utils.deepAccess(BRs[i], 'mediaType') === 'banner') { + impObj.banner = frameBanner(BRs[i]); } + if (utils.deepAccess(BRs[i], 'mediaTypes.video') || utils.deepAccess(BRs[i], 'mediaType') === 'video') { + impObj.video = frameVideo(BRs[i]); + } + impObj.ext = frameExt(BRs[i]); + imp.push(impObj); } + return imp; } - let slotsToBids = {}; - let that = this; - let version = '1.0.1.0'; - let loadStart = Date.now(); - - this.buildRequests = function (BRs, bidderRequest) { - let fallbackPlacementId = getFirstParam('placementId', BRs); - if (fallbackPlacementId === undefined || BRs.length < 1) { - return []; + function frameSite(bidderRequest) { + return { + domain: attempt(function() { + var d = win.document.location.ancestorOrigins; + if (d && d.length > 0) { + return d[d.length - 1]; + } + return win.top.document.location.hostname; // try/catch is in the attempt function + }, ''), + page: attempt(function() { + var l; + // try/catch is in the attempt function + try { + l = win.top.document.location.href.toString(); + } catch (ex) { + l = win.document.location.href.toString(); + } + return l; + }, ''), + ref: attempt(function() { + if (bidderRequest && bidderRequest.refererInfo) { + return bidderRequest.refererInfo.referer; + } + return ''; + }, '') } + } - loadStart = Date.now(); - slotsToBids = {}; - - let query = []; - let w = (typeof window !== 'undefined' ? window : {}); - - function p(k, v, d) { - if (v instanceof Array) { v = v.join((d || ',')); } - if (typeof v !== 'undefined') { query.push(encodeURIComponent(k) + '=' + encodeURIComponent(v)); } + function frameDevice() { + return { + ua: navigator.userAgent, + devicetype: /(ios|ipod|ipad|iphone|android)/i.test(win.navigator.userAgent) ? 1 : /(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i.test(win.navigator.userAgent) ? 3 : 2, + ip: '', // Empty Ip string is required, server gets the ip from HTTP header + dnt: utils.getDNT() ? 1 : 0, } + } - function attempt(valueFunction, defaultValue) { - try { - return valueFunction(); - } catch (ex) { } - return defaultValue; + function frameBanner(bid) { + var sizes = utils.parseSizesInput(bid.sizes).map(size => size.split('x')); + return { + w: parseInt(sizes[0][0]), + h: parseInt(sizes[0][1]) } + } - p('domain', attempt(function() { - var d = w.document.location.ancestorOrigins; - if (d && d.length > 0) { - return d[d.length - 1]; + function frameVideo(bid) { + var size = []; + if (utils.deepAccess(bid, 'mediaTypes.video.playerSize')) { + if (utils.isArray(bid.mediaTypes.video.playerSize[0])) { + size = bid.mediaTypes.video.playerSize[0]; + } else if (utils.isNumber(bid.mediaTypes.video.playerSize[0])) { + size = bid.mediaTypes.video.playerSize; } - return w.top.document.location.hostname; // try/catch is in the attempt function - }, '')); - p('url', attempt(function() { - var l; - // try/catch is in the attempt function - try { - l = w.top.document.location.href.toString(); - } catch (ex) { - l = w.document.location.href.toString(); + } + return { + mimes: utils.deepAccess(bid, 'mediaTypes.video.mimes') || SUPPORTED_VIDEO_MIMES, + protocols: utils.deepAccess(bid, 'mediaTypes.video.protocols') || SUPPORTED_VIDEO_PROTOCOLS, + w: size[0], + h: size[1], + startdelay: utils.deepAccess(bid, 'mediaTypes.video.startdelay') || 0, + skip: utils.deepAccess(bid, 'mediaTypes.video.skip') || 0, + playbackmethod: utils.deepAccess(bid, 'mediaTypes.video.playbackmethod') || SUPPORTED_VIDEO_PLAYBACK_METHODS, + delivery: utils.deepAccess(bid, 'mediaTypes.video.delivery') || SUPPORTED_VIDEO_DELIVERY, + api: utils.deepAccess(bid, 'mediaTypes.video.api') || SUPPORTED_VIDEO_API, + } + } + + function frameExt(bid) { + return { + bidder: { + placementId: (bid.params && bid.params['placementId']) ? bid.params['placementId'] : '', + zone: (bid.params && bid.params['zone']) ? bid.params['zone'] : '1r', + path: (bid.params && bid.params['path']) ? bid.params['path'] : 'mvo' } - return l; - }, '')); - - function getRMPUrl() { - let url = getFirstParam('endpoint', BRs) || '//tag.1rx.io/rmp/{placementId}/0/{path}?z={zone}'; - let defaultZone = getFirstParam('zone', BRs) || '1r'; - let defaultPath = getFirstParam('path', BRs) || 'mvo'; - - url = url.replace(/\{placementId\}/i, fallbackPlacementId); - url = url.replace(/\{zone\}/i, defaultZone); - url = url.replace(/\{path\}/i, defaultPath); - - p('title', attempt(function() { return w.top.document.title; }, '')); // try/catch is in the attempt function - p('dsh', (w.screen ? w.screen.height : '')); - p('dsw', (w.screen ? w.screen.width : '')); - p('tz', (new Date()).getTimezoneOffset()); - p('dtype', ((/(ios|ipod|ipad|iphone|android)/i).test(w.navigator.userAgent) ? 1 : ((/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(w.navigator.userAgent) ? 3 : 2))); - p('flash', attempt(function() { - let n = w.navigator; - let p = n.plugins; - let m = n.mimeTypes; - let t = 'application/x-shockwave-flash'; - let x = w.ActiveXObject; - - if (p && - p['Shockwave Flash'] && - m && - m[t] && - m[t].enabledPlugin) { - return 1; - } + } + } - if (x) { - try { - if ((new w.ActiveXObject('ShockwaveFlash.ShockwaveFlash'))) { - return 1; - } - } catch (e) { } + function frameBid(BRs, bidderRequest) { + return { + id: BRs[0].bidderRequestId, + imp: frameImp(BRs), + site: frameSite(bidderRequest), + device: frameDevice(), + user: { + ext: { + consent: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') ? bidderRequest.gdprConsent.consentString : '' } + }, + at: 1, + tmax: 1000, + regs: { + ext: { + gdpr: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') ? Boolean(bidderRequest.gdprConsent.gdprApplies & 1) : true + } + } + }; + } - return 0; - }, 0)); - - let heights = []; - let widths = []; - let floors = []; - let mediaTypes = []; - let i = 0; - let configuredPlacements = []; - let fat = /(^v|(\.0)+$)/gi; - - p('hbv', w.$$PREBID_GLOBAL$$.version.replace(fat, '') + ',' + version.replace(fat, '')); + function getFirstParam(key, validBidRequests) { + for (let i = 0; i < validBidRequests.length; i++) { + if (validBidRequests[i].params && validBidRequests[i].params[key]) { + return validBidRequests[i].params[key]; + } + } + } - for (; i < BRs.length; i++) { - let th = []; - let tw = []; - let params = BRs[i].params || {}; + function attempt(valueFunction, defaultValue) { + try { + return valueFunction(); + } catch (ex) { } + return defaultValue; + } - slotsToBids[BRs[i].adUnitCode || BRs[i].placementCode] = BRs[i]; + this.buildRequests = function (BRs, bidderRequest) { + let fallbackPlacementId = getFirstParam('placementId', BRs); + if (fallbackPlacementId === undefined || BRs.length < 1) { + return []; + } - if (BRs[i].sizes.length > 0 && typeof BRs[i].sizes[0] === 'number') { - BRs[i].sizes = [BRs[i].sizes]; - } + var rmpUrl = getFirstParam('endpoint', BRs) || '//tag.1rx.io/rmp/{placementId}/0/{path}?z={zone}'; + var defaultZone = getFirstParam('zone', BRs) || '1r'; + var defaultPath = getFirstParam('path', BRs) || 'mvo'; - for (let j = 0; j < BRs[i].sizes.length; j++) { - tw.push(BRs[i].sizes[j][0]); - th.push(BRs[i].sizes[j][1]); - } - configuredPlacements.push(BRs[i].adUnitCode || BRs[i].placementCode); - heights.push(th.join('|')); - widths.push(tw.join('|')); - mediaTypes.push((BRs[i].mediaTypes && BRs[i].mediaTypes.video ? 'v' : 'd')); - floors.push(params.floor || 0); - } + rmpUrl = rmpUrl.replace(/\{placementId\}/i, fallbackPlacementId); + rmpUrl = rmpUrl.replace(/\{zone\}/i, defaultZone); + rmpUrl = rmpUrl.replace(/\{path\}/i, defaultPath); - p('imp', configuredPlacements); - p('w', widths); - p('h', heights); - p('floor', floors); - p('t', mediaTypes); - if (bidderRequest && bidderRequest.gdprConsent) { - p('gdpr_consent', bidderRequest.gdprConsent.consentString); - p('gdpr', (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true); - } - url += '&' + query.join('&') + '&'; + var fat = /(^v|(\.0)+$)/gi; + var prebidVersion = '$prebid.version$'; + rmpUrl += '&hbv=' + prebidVersion.replace(fat, '') + ',' + version.replace(fat, ''); - return url; - } + var bidRequest = frameBid(BRs, bidderRequest); + loadStart = Date.now(); - return [{ - method: 'GET', - url: getRMPUrl() - }]; + return { + method: 'POST', + url: rmpUrl, + data: JSON.stringify(bidRequest) + }; }; this.interpretResponse = function (serverResponse) { @@ -244,13 +270,13 @@ function RhythmOneBidAdapter() { creativeId: bid.crid, currency: 'USD', netRevenue: true, - ttl: 1000 + ttl: 350 }; if (bidRequest.mediaTypes && bidRequest.mediaTypes.video) { bidResponse.vastUrl = bid.nurl; bidResponse.mediaType = 'video'; - bidResponse.ttl = 10000; + bidResponse.ttl = 600; } else { bidResponse.ad = bid.adm; } diff --git a/modules/rhythmoneBidAdapter.md b/modules/rhythmoneBidAdapter.md index d08baaecea8..86defbe320a 100644 --- a/modules/rhythmoneBidAdapter.md +++ b/modules/rhythmoneBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: RhythmOne Bidder Adapter Module Type: Bidder Adapter -Maintainer: astocker@rhythmone.com +Maintainer: support@rhythmone.com ``` # Description @@ -23,8 +23,10 @@ const adUnits = [{ bidder: 'rhythmone', params: { - placementId: '411806', - endpoint: "//tag.1rx.io/rmp/72721/0/mvo?z=1r" // only required for testing. this api guarantees no 204 responses + placementId: '411806', // REQUIRED + zone: '1r', // OPTIONAL + path: 'mvo', // OPTIONAL + endpoint: "//tag.1rx.io/rmp/72721/0/mvo?z=1r" // OPTIONAL, only required for testing. this api guarantees no 204 responses } } ] diff --git a/test/spec/modules/rhythmoneBidAdapter_spec.js b/test/spec/modules/rhythmoneBidAdapter_spec.js index 2f06e7f8288..98a7731c324 100644 --- a/test/spec/modules/rhythmoneBidAdapter_spec.js +++ b/test/spec/modules/rhythmoneBidAdapter_spec.js @@ -2,43 +2,74 @@ import {spec} from '../../../modules/rhythmoneBidAdapter'; var assert = require('assert'); describe('rhythmone adapter tests', function () { - describe('auditBeacon', function() { - var z = spec; - var beaconURL = z.getUserSyncs({pixelEnabled: true})[0]; - - it('should contain the correct path', function() { - var u = '//hbevents.1rx.io/audit?' - assert.equal(beaconURL.url.substring(0, u.length), u); - }); - }); - describe('rhythmoneResponse', function () { var z = spec; - var rmpRequest = z.buildRequests( + var rmpBannerRequest = z.buildRequests( [ { 'bidder': 'rhythmone', 'params': { - 'placementId': 'xyz', + 'placementId': 'abc', 'keywords': '', 'categories': [], 'trace': true, - 'method': 'get', - 'endpoint': 'http://fakedomain.com' + 'zone': '2345', + 'path': 'mvo', + 'method': 'POST' }, - 'mediaType': 'video', + 'mediaType': 'banner', 'adUnitCode': 'div-gpt-ad-1438287399331-0', 'sizes': [[300, 250]] } - ] + ], { 'refererInfo': { 'referer': 'Reference Page' } } ); - it('should have one request to RMP', function() { - assert.equal(rmpRequest.length, 1); + it('Verify POST Banner Bid Request', function () { + expect(rmpBannerRequest.url).to.have.string('//tag.1rx.io/rmp/abc/0/mvo?z=2345&hbv='); + expect(rmpBannerRequest.method).to.equal('POST'); + const bidRequest = JSON.parse(rmpBannerRequest.data); + expect(bidRequest.site).to.not.equal(null); + expect(bidRequest.site.ref).to.equal('Reference Page'); + expect(bidRequest.device).to.not.equal(null); + expect(bidRequest.device.ua).to.equal(navigator.userAgent); + expect(bidRequest.device).to.have.property('dnt'); + expect(bidRequest.imp[0].banner).to.not.equal(null); + expect(bidRequest.imp[0].banner.w).to.equal(300); + expect(bidRequest.imp[0].banner.h).to.equal(250); + expect(bidRequest.imp[0].ext.bidder.zone).to.equal('2345'); + expect(bidRequest.imp[0].ext.bidder.path).to.equal('mvo'); + }); + + var bannerBids = z.interpretResponse({ + body: [ + { + 'impid': 'div-gpt-ad-1438287399331-0', + 'w': 300, + 'h': 250, + 'adm': '
My ad4 with cpm of a4ab3485f434f74f
', + 'price': 1, + 'crid': 'cr-cfy24' + } + ] + }); + + it('should register one bid', function() { + assert.equal(bannerBids.length, 1); }); - var mangoRequest = z.buildRequests( + it('Verify parse banner response', function() { + const bid = bannerBids[0]; + expect(bid.width).to.equal(300); + expect(bid.height).to.equal(250); + expect(bid.creativeId).to.equal('cr-cfy24'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.cpm).to.equal(1.0); + expect(bid.ttl).to.equal(350); + }); + + var rmpVideoRequest = z.buildRequests( [ { 'bidder': 'rhythmone', @@ -47,18 +78,70 @@ describe('rhythmone adapter tests', function () { 'keywords': '', 'categories': [], 'trace': true, - 'method': 'get', - 'api': 'mango', - 'endpoint': 'http://fakedomain.com' + 'method': 'POST' }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'mediaTypes': { + 'video': { + 'playerSize': [[640, 480]], + 'context': 'instream' + } + }, + 'placementCode': 'div-gpt-ad-1438287399331-1', 'sizes': [[300, 250]] } - ] + ], { 'refererInfo': { 'referer': 'Reference Page' } } ); - it('should have one request to Mango', function() { - assert.equal(mangoRequest.length, 1); + it('Verify POST Video Bid Request', function () { + expect(rmpVideoRequest.url).to.have.string('//tag.1rx.io/rmp/xyz/0/mvo?z=1r&hbv='); + expect(rmpVideoRequest.method).to.equal('POST'); + const bidRequest = JSON.parse(rmpVideoRequest.data); + expect(bidRequest.site).to.not.equal(null); + expect(bidRequest.device).to.not.equal(null); + expect(bidRequest.device.ua).to.equal(navigator.userAgent); + expect(bidRequest.device).to.have.property('dnt'); + expect(bidRequest.imp[0].video).to.not.equal(null); + expect(bidRequest.imp[0].video.w).to.equal(640); + expect(bidRequest.imp[0].video.h).to.equal(480); + expect(bidRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); + expect(bidRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); + expect(bidRequest.imp[0].video.startdelay).to.equal(0); + expect(bidRequest.imp[0].video.skip).to.equal(0); + expect(bidRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); + expect(bidRequest.imp[0].video.delivery[0]).to.equal(1); + expect(bidRequest.imp[0].video.api).to.eql([1, 2, 5]); + }); + + var videoBids = z.interpretResponse({ + body: [ + { + 'impid': 'div-gpt-ad-1438287399331-1', + 'price': 1, + 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', + 'adomain': ['test.com'], + 'cid': '467415', + 'crid': 'cr-vid', + 'w': 800, + 'h': 600 + } + ] + }); + + it('should register one bid', function() { + assert.equal(videoBids.length, 1); + }); + + it('Verify parse video response', function() { + const bid = videoBids[0]; + expect(bid.width).to.equal(800); + expect(bid.height).to.equal(600); + expect(bid.vastUrl).to.equal('http://testdomain/rmp/placementid/0/path?reqId=1636037'); + expect(bid.mediaType).to.equal('video'); + expect(bid.creativeId).to.equal('cr-vid'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.cpm).to.equal(1.0); + expect(bid.ttl).to.equal(600); }); it('should send GDPR Consent data to RhythmOne tag', function () { @@ -72,48 +155,165 @@ describe('rhythmone adapter tests', function () { 'keywords': '', 'categories': [], 'trace': true, - 'method': 'get', - 'api': 'mango', - 'endpoint': 'http://fakedomain.com?' + 'method': 'POST' }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'adUnitCode': 'div-gpt-ad-1438287399331-3', 'sizes': [[300, 250]] } - ], {gdprConsent: {gdprApplies: 1, consentString: _consentString}} + ], {'gdprConsent': {'gdprApplies': true, 'consentString': _consentString}, 'refererInfo': { 'referer': 'Reference Page' }} ); - assert.equal(getURLParam(request[0].url, 'gdpr'), 'true'); - assert.equal(getURLParam(request[0].url, 'gdpr_consent'), 'testConsentString'); + const bidRequest = JSON.parse(request.data); + expect(bidRequest.user.ext.consent).to.equal(_consentString); + expect(bidRequest.regs.ext.gdpr).to.equal(true); }); - var bids = z.interpretResponse({ - body: [ + var rmpMultiFormatRequest = z.buildRequests( + [ { - 'impid': 'div-gpt-ad-1438287399331-0', - 'w': 300, - 'h': 250, - 'adm': '
My ad4 with cpm of a4ab3485f434f74f
', - 'price': 1, - 'crid': 'cr-cfy24' + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'xyz', + 'keywords': '', + 'categories': [], + 'trace': true, + 'zone': '2345', + 'path': 'mvo', + 'method': 'POST' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250] + ] + }, + 'video': { + 'playerSize': [[640, 480]], + 'context': 'instream' + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-5', + 'sizes': [[300, 250]] } - ] + ], { 'refererInfo': { 'referer': 'Reference Page' } } + ); + + it('Verify Multi-Format ads Bid Request', function () { + const bidRequest = JSON.parse(rmpMultiFormatRequest.data); + expect(bidRequest.site).to.not.equal(null); + expect(bidRequest.site.ref).to.equal('Reference Page'); + expect(bidRequest.device).to.not.equal(null); + expect(bidRequest.device.ua).to.equal(navigator.userAgent); + expect(bidRequest.device).to.have.property('dnt'); + expect(bidRequest.imp[0].video).to.not.equal(null); + expect(bidRequest.imp[0].video.w).to.equal(640); + expect(bidRequest.imp[0].video.h).to.equal(480); + expect(bidRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); + expect(bidRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); + expect(bidRequest.imp[0].video.startdelay).to.equal(0); + expect(bidRequest.imp[0].video.skip).to.equal(0); + expect(bidRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); + expect(bidRequest.imp[0].video.delivery[0]).to.equal(1); + expect(bidRequest.imp[0].video.api).to.eql([1, 2, 5]); + expect(bidRequest.imp[0].banner).to.not.equal(null); + expect(bidRequest.imp[0].banner.w).to.equal(300); + expect(bidRequest.imp[0].banner.h).to.equal(250); + expect(bidRequest.imp[0].ext.bidder.zone).to.equal('2345'); + expect(bidRequest.imp[0].ext.bidder.path).to.equal('mvo'); + }); + + var forRMPMultiFormatResponse = z.interpretResponse({ + body: { + 'id': '1e810245dd1779', + 'seatbid': [ { + 'bid': [ { + 'impid': 'div-gpt-ad-1438287399331-5', + 'price': 1, + 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', + 'adomain': ['test.com'], + 'cid': '467415', + 'crid': 'cr-vid', + 'w': 800, + 'h': 600 + } ] + } ] + } }); it('should register one bid', function() { - assert.equal(bids.length, 1); - }); - function getURLParam(url, key) { - let val = ''; - if (url.indexOf('?') > -1) { - let qs = url.substr(url.indexOf('?')); - let qsArr = qs.split('&'); - for (let i = 0; i < qsArr.length; i++) { - if (qsArr[i].indexOf(key.toLowerCase() + '=') > -1) { - val = qsArr[i].split('=')[1] - break; + assert.equal(forRMPMultiFormatResponse.length, 1); + }); + + it('Verify parse for multi format ad response', function() { + const bid = forRMPMultiFormatResponse[0]; + expect(bid.width).to.equal(800); + expect(bid.height).to.equal(600); + expect(bid.vastUrl).to.equal('http://testdomain/rmp/placementid/0/path?reqId=1636037'); + expect(bid.mediaType).to.equal('video'); + expect(bid.creativeId).to.equal('cr-vid'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.cpm).to.equal(1.0); + expect(bid.ttl).to.equal(600); + }); + + var noBidResponse = z.interpretResponse({ + body: '' + }); + + it('No bid response', function() { + assert.equal(noBidResponse.length, 0); + }); + describe('isRequiredParamPresent', function () { + var rmpBannerRequest = z.buildRequests( + [ + { + 'bidder': 'rhythmone', + 'params': { + 'keywords': '', + 'categories': [], + 'trace': true, + 'zone': '2345', + 'path': 'mvo', + 'method': 'POST' + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]] } - } - } - return val; - } + ], { 'refererInfo': { 'referer': 'Reference Page' } } + ); + + it('should return empty when required params not found', function () { + expect(rmpBannerRequest).to.be.empty; + }); + }); + }); + describe('auditBeacon', function() { + var z = spec; + var beaconURL = z.getUserSyncs({pixelEnabled: true})[0]; + + it('should contain the correct path', function() { + var u = '//hbevents.1rx.io/audit?'; + assert.equal(beaconURL.url.substring(0, u.length), u); + }); + + beaconURL = z.getUserSyncs({pixelEnabled: true}, null, {'gdprApplies': true, 'consentString': 'testConsentString'})[0]; + it('should send GDPR Consent data to Sync pixel', function () { + expect(beaconURL.url).to.have.string('&gdpr=true&gdpr_consent=testConsentString'); + }); + }); + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'rhythmone', + 'params': { + 'placementId': '469127' + }, + 'adUnitCode': 'bannerDiv', + 'sizes': [[300, 250]] + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); }); }); From c74b7daad3ce1eb3c55d1b4846804d8ad4645258 Mon Sep 17 00:00:00 2001 From: Rajesh Date: Fri, 18 Jan 2019 13:27:35 +0530 Subject: [PATCH 2/3] Updated gdpr default value to false, updated test placementId in rhythmoneBidAdapter.md file --- modules/rhythmoneBidAdapter.js | 4 ++-- modules/rhythmoneBidAdapter.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/rhythmoneBidAdapter.js b/modules/rhythmoneBidAdapter.js index 2541874d623..b0d225df8cd 100644 --- a/modules/rhythmoneBidAdapter.js +++ b/modules/rhythmoneBidAdapter.js @@ -65,7 +65,7 @@ function RhythmOneBidAdapter() { data.bidder_version = version; if (gdprConsent) { data.gdpr_consent = gdprConsent.consentString; - data.gdpr = (typeof gdprConsent.gdprApplies === 'boolean') ? gdprConsent.gdprApplies : true; + data.gdpr = (typeof gdprConsent.gdprApplies === 'boolean') ? gdprConsent.gdprApplies : false; } for (let k in data) { @@ -194,7 +194,7 @@ function RhythmOneBidAdapter() { tmax: 1000, regs: { ext: { - gdpr: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') ? Boolean(bidderRequest.gdprConsent.gdprApplies & 1) : true + gdpr: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') ? Boolean(bidderRequest.gdprConsent.gdprApplies & 1) : false } } }; diff --git a/modules/rhythmoneBidAdapter.md b/modules/rhythmoneBidAdapter.md index 86defbe320a..ec3ee4852e5 100644 --- a/modules/rhythmoneBidAdapter.md +++ b/modules/rhythmoneBidAdapter.md @@ -23,10 +23,10 @@ const adUnits = [{ bidder: 'rhythmone', params: { - placementId: '411806', // REQUIRED + placementId: '80184', // REQUIRED zone: '1r', // OPTIONAL path: 'mvo', // OPTIONAL - endpoint: "//tag.1rx.io/rmp/72721/0/mvo?z=1r" // OPTIONAL, only required for testing. this api guarantees no 204 responses + endpoint: "//tag.1rx.io/rmp/80184/0/mvo?z=1r" // OPTIONAL, only required for testing. this api guarantees no 204 responses } } ] From 5d2ee53429b0b0d62a84a0b6046e270fd0554d94 Mon Sep 17 00:00:00 2001 From: Rajesh Date: Fri, 18 Jan 2019 18:25:31 +0530 Subject: [PATCH 3/3] Version updated --- modules/rhythmoneBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rhythmoneBidAdapter.js b/modules/rhythmoneBidAdapter.js index b0d225df8cd..29572c228fe 100644 --- a/modules/rhythmoneBidAdapter.js +++ b/modules/rhythmoneBidAdapter.js @@ -15,7 +15,7 @@ function RhythmOneBidAdapter() { let SUPPORTED_VIDEO_API = [1, 2, 5]; let slotsToBids = {}; let that = this; - let version = '1.0.2.0'; + let version = '1.0.2.1'; let loadStart = Date.now(); var win = typeof window !== 'undefined' ? window : {};