From 00abeecb40aecd12f85f01bfe45aef9e8d4f7f77 Mon Sep 17 00:00:00 2001 From: Jimmy Tu Date: Thu, 7 Nov 2019 11:50:03 -0800 Subject: [PATCH] OpenX Adapter: Prebid 3.0 Compatibility Update (#4413) * Removed usage of deprecated functions * Removed beacons * Banner sizes now reads from bidRequest.mediaTypes.banner.sizes instead of bidRequest.sizes * Updated tests to reflect changes. --- modules/openxBidAdapter.js | 73 +------ modules/openxoutstreamBidAdapter.js | 7 +- test/spec/modules/openxBidAdapter_spec.js | 191 +++++------------- .../modules/openxoutstreamBidAdapter_spec.js | 14 +- 4 files changed, 61 insertions(+), 224 deletions(-) diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js index a5c5b432a55..1e69dc01471 100644 --- a/modules/openxBidAdapter.js +++ b/modules/openxBidAdapter.js @@ -1,14 +1,13 @@ import {config} from '../src/config'; import {registerBidder} from '../src/adapters/bidderFactory'; import * as utils from '../src/utils'; -import {userSync} from '../src/userSync'; import {BANNER, VIDEO} from '../src/mediaTypes'; import {parse} from '../src/url'; const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; const BIDDER_CODE = 'openx'; const BIDDER_CONFIG = 'hb_pb'; -const BIDDER_VERSION = '2.1.9'; +const BIDDER_VERSION = '3.0.0'; const USER_ID_CODE_TO_QUERY_ARG = { idl_env: 'lre', // liveramp @@ -16,12 +15,6 @@ const USER_ID_CODE_TO_QUERY_ARG = { tdid: 'ttduuid' // the trade desk }; -let shouldSendBoPixel = true; - -export function resetBoPixel() { - shouldSendBoPixel = true; -} - export const spec = { code: BIDDER_CODE, supportedMediaTypes: SUPPORTED_AD_TYPES, @@ -132,24 +125,10 @@ function createBannerBidResponses(oxResponseObj, {bids, startTime}) { } bidResponses.push(bidResponse); - - registerBeacon(BANNER, adUnit, startTime); } return bidResponses; } -function buildQueryStringFromParams(params) { - for (let key in params) { - if (params.hasOwnProperty(key)) { - if (!params[key]) { - delete params[key]; - } - } - } - return utils._map(Object.keys(params), key => `${key}=${params[key]}`) - .join('&'); -} - function getViewportDimensions(isIfr) { let width; let height; @@ -210,8 +189,7 @@ function buildCommonQueryParamsFromBids(bids, bidderRequest) { let defaultParams; defaultParams = { - ju: config.getConfig('pageUrl') || utils.getTopWindowUrl(), - jr: utils.getTopWindowReferrer(), + ju: config.getConfig('pageUrl') || bidderRequest.refererInfo.referer, ch: document.charSet || document.characterSet, res: `${screen.width}x${screen.height}x${screen.colorDepth}`, ifr: isInIframe, @@ -285,7 +263,8 @@ function buildOXBannerRequest(bids, bidderRequest) { let hasCustomParam = false; let queryParams = buildCommonQueryParamsFromBids(bids, bidderRequest); let auids = utils._map(bids, bid => bid.params.unit); - queryParams.aus = utils._map(bids, bid => utils.parseSizesInput(bid.sizes).join(',')).join('|'); + + queryParams.aus = utils._map(bids, bid => utils.parseSizesInput(bid.mediaTypes.banner.sizes).join(',')).join('|'); queryParams.divIds = utils._map(bids, bid => encodeURIComponent(bid.adUnitCode)).join(','); if (auids.some(auid => auid)) { @@ -425,53 +404,9 @@ function createVideoBidResponses(response, {bid, startTime}) { response.ts = vastQueryParams.ts; bidResponses.push(bidResponse); - - registerBeacon(VIDEO, response, startTime) } return bidResponses; } -function registerBeacon(mediaType, adUnit, startTime) { - // only register beacon once - if (!shouldSendBoPixel) { - return; - } - shouldSendBoPixel = false; - - let bt = config.getConfig('bidderTimeout'); - let beaconUrl; - if (window.PREBID_TIMEOUT) { - bt = Math.min(window.PREBID_TIMEOUT, bt); - } - - let beaconParams = { - bd: +(new Date()) - startTime, - bp: adUnit.pub_rev, - br: '0', // may be 0, t, or p - bs: utils.getTopWindowLocation().hostname, - bt: bt, - ts: adUnit.ts - }; - - beaconParams.br = beaconParams.bt < beaconParams.bd ? 't' : 'p'; - - if (mediaType === VIDEO) { - let url = parse(adUnit.colo); - beaconParams.ph = adUnit.ph; - beaconUrl = `https://${url.hostname}/w/1.0/bo?${buildQueryStringFromParams(beaconParams)}` - } else { - let recordPixel = utils.deepAccess(adUnit, 'creative.0.tracking.impression'); - let boBase = recordPixel.match(/([^?]+\/)ri\?/); - - if (boBase && boBase.length > 1) { - beaconUrl = `${boBase[1]}bo?${buildQueryStringFromParams(beaconParams)}`; - } - } - - if (beaconUrl) { - userSync.registerSync('image', BIDDER_CODE, beaconUrl); - } -} - registerBidder(spec); diff --git a/modules/openxoutstreamBidAdapter.js b/modules/openxoutstreamBidAdapter.js index 9011a949e7b..b9760c0c3bb 100644 --- a/modules/openxoutstreamBidAdapter.js +++ b/modules/openxoutstreamBidAdapter.js @@ -6,7 +6,7 @@ import { BANNER } from '../src/mediaTypes'; const SUPPORTED_AD_TYPES = [BANNER]; const BIDDER_CODE = 'openxoutstream'; const BIDDER_CONFIG = 'hb_pb_ym'; -const BIDDER_VERSION = '1.0.0'; +const BIDDER_VERSION = '1.0.1'; const CURRENCY = 'USD'; const NET_REVENUE = true; const TIME_TO_LIVE = 300; @@ -70,8 +70,7 @@ function buildCommonQueryParamsFromBids(bid, bidderRequest) { const width = '414'; const aus = '304x184%7C412x184%7C375x184%7C414x184'; defaultParams = { - ju: config.getConfig('pageUrl') || utils.getTopWindowUrl(), - jr: utils.getTopWindowReferrer(), + ju: config.getConfig('pageUrl') || bidderRequest.refererInfo.referer, ch: document.charSet || document.characterSet, res: `${screen.width}x${screen.height}x${screen.colorDepth}`, ifr: isInIframe, @@ -118,7 +117,7 @@ function buildOXBannerRequest(bid, bidderRequest) { queryParams.tfcd = 1; } - let url = `https://${bid.params.delDomain}/v/1.0/avjp` + let url = `https://${bid.params.delDomain}/v/1.0/avjp`; return { method: 'GET', url: url, diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index 0002d25c37d..353c3342627 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -234,12 +234,6 @@ describe('OpenxAdapter', function () { videoBidWithMediaTypes.params = {}; expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false); }); - it('should send bid request to openx url via GET, with mediaType specified as video', function () { - const request = spec.buildRequests([videoBidWithMediaTypes]); - expect(request[0].url).to.equal(`https://${videoBidWithMediaTypes.params.delDomain}${URLBASEVIDEO}`); - expect(request[0].data.ph).to.be.undefined; - expect(request[0].method).to.equal('GET'); - }); }); describe('and request config uses both delDomain and platform', () => { const videoBidWithDelDomainAndPlatform = { @@ -269,12 +263,6 @@ describe('OpenxAdapter', function () { videoBidWithMediaTypes.params = {}; expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false); }); - it('should send bid request to openx url via GET, with mediaType specified as video', function () { - const request = spec.buildRequests([videoBidWithDelDomainAndPlatform]); - expect(request[0].url).to.equal(`https://u.openx.net${URLBASEVIDEO}`); - expect(request[0].data.ph).to.equal(videoBidWithDelDomainAndPlatform.params.platform); - expect(request[0].method).to.equal('GET'); - }); }); describe('and request config uses mediaType', () => { const videoBidWithMediaType = { @@ -301,30 +289,11 @@ describe('OpenxAdapter', function () { videoBidWithMediaType.params = {}; expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(false); }); - it('should send bid request to openx url via GET, with mediaType specified as video', function () { - const request = spec.buildRequests([videoBidWithMediaType]); - expect(request[0].url).to.equal(`https://${videoBidWithMediaType.params.delDomain}${URLBASEVIDEO}`); - expect(request[0].data.ph).to.be.undefined; - expect(request[0].method).to.equal('GET'); - }); }); }); }); describe('buildRequests for banner ads', function () { - const bidRequestsWithMediaType = [{ - 'bidder': 'openx', - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'mediaType': 'banner', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; const bidRequestsWithMediaTypes = [{ 'bidder': 'openx', 'params': { @@ -356,6 +325,7 @@ describe('OpenxAdapter', function () { 'bidderRequestId': 'test-bid-request-2', 'auctionId': 'test-auction-2' }]; + const bidRequestsWithPlatform = [{ 'bidder': 'openx', 'params': { @@ -388,22 +358,17 @@ describe('OpenxAdapter', function () { 'auctionId': 'test-auction-1' }]; - it('should send bid request to openx url via GET, with mediaType specified as banner', function () { - const request = spec.buildRequests(bidRequestsWithMediaType); - expect(request[0].url).to.equal('https://' + bidRequestsWithMediaType[0].params.delDomain + URLBASE); - expect(request[0].data.ph).to.be.undefined; - expect(request[0].method).to.equal('GET'); - }); + const mockBidderRequest = {refererInfo: {}}; it('should send bid request to openx url via GET, with mediaTypes specified with banner type', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); expect(request[0].url).to.equal('https://' + bidRequestsWithMediaTypes[0].params.delDomain + URLBASE); expect(request[0].data.ph).to.be.undefined; expect(request[0].method).to.equal('GET'); }); it('should send bid request to openx platform url via GET, if platform is present', function () { - const request = spec.buildRequests(bidRequestsWithPlatform); + const request = spec.buildRequests(bidRequestsWithPlatform, mockBidderRequest); expect(request[0].url).to.equal(`https://u.openx.net${URLBASE}`); expect(request[0].data.ph).to.equal(bidRequestsWithPlatform[0].params.platform); expect(request[0].method).to.equal('GET'); @@ -444,14 +409,14 @@ describe('OpenxAdapter', function () { 'auctionId': 'test-auction-1' }]; - const request = spec.buildRequests(bidRequestsWithPlatformAndDelDomain); + const request = spec.buildRequests(bidRequestsWithPlatformAndDelDomain, mockBidderRequest); expect(request[0].url).to.equal(`https://u.openx.net${URLBASE}`); expect(request[0].data.ph).to.equal(bidRequestsWithPlatform[0].params.platform); expect(request[0].method).to.equal('GET'); }); it('should send the adunit codes', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); expect(request[0].data.divIds).to.equal(`${encodeURIComponent(bidRequestsWithMediaTypes[0].adUnitCode)},${encodeURIComponent(bidRequestsWithMediaTypes[1].adUnitCode)}`); }); @@ -486,7 +451,7 @@ describe('OpenxAdapter', function () { 'bidderRequestId': 'test-bid-request-2', 'auctionId': 'test-auction-2' }]; - const request = spec.buildRequests(bidRequestsWithUnitIds); + const request = spec.buildRequests(bidRequestsWithUnitIds, mockBidderRequest); expect(request[0].data.auid).to.equal(`,${bidRequestsWithUnitIds[1].params.unit}`); }); @@ -520,39 +485,10 @@ describe('OpenxAdapter', function () { 'bidderRequestId': 'test-bid-request-2', 'auctionId': 'test-auction-2' }]; - const request = spec.buildRequests(bidRequestsWithoutUnitIds); + const request = spec.buildRequests(bidRequestsWithoutUnitIds, mockBidderRequest); expect(request[0].data).to.not.have.any.keys('auid'); }); - describe('when there is a legacy request with no media type', function () { - const deprecatedBidRequestsFormatWithNoMediaType = [{ - 'bidder': 'openx', - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - let requestData; - - beforeEach(function () { - requestData = spec.buildRequests(deprecatedBidRequestsFormatWithNoMediaType)[0].data; - }); - - it('should have an ad unit id', function () { - expect(requestData.auid).to.equal('12345678'); - }); - - it('should have ad sizes', function () { - expect(requestData.aus).to.equal('300x250,300x600'); - }); - }); - it('should send out custom params on bids that have customParams specified', function () { const bidRequest = Object.assign({}, bidRequestsWithMediaTypes[0], @@ -565,7 +501,7 @@ describe('OpenxAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], mockBidderRequest); const dataParams = request[0].data; expect(dataParams.tps).to.exist; @@ -584,7 +520,7 @@ describe('OpenxAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], mockBidderRequest); const dataParams = request[0].data; expect(dataParams.aumfs).to.exist; @@ -603,7 +539,7 @@ describe('OpenxAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], mockBidderRequest); const dataParams = request[0].data; expect(dataParams.bc).to.exist; @@ -611,7 +547,7 @@ describe('OpenxAdapter', function () { }); it('should not send any consent management properties', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); expect(request[0].data.gdpr).to.equal(undefined); expect(request[0].data.gdpr_consent).to.equal(undefined); expect(request[0].data.x_gdpr_f).to.equal(undefined); @@ -669,7 +605,8 @@ describe('OpenxAdapter', function () { gdprConsent: { consentString: 'test-gdpr-consent-string', gdprApplies: true - } + }, + refererInfo: {} }; mockConfig = { @@ -710,7 +647,8 @@ describe('OpenxAdapter', function () { gdprConsent: { consentString: 'test-gdpr-consent-string', gdprApplies: false - } + }, + refererInfo: {} }; mockConfig = { @@ -751,7 +689,8 @@ describe('OpenxAdapter', function () { gdprConsent: { consentString: 'test-gdpr-consent-string', gdprApplies: true - } + }, + refererInfo: {} }; mockConfig = { @@ -823,7 +762,7 @@ describe('OpenxAdapter', function () { bidderRequestId: 'test-bid-request-2', auctionId: 'test-auction-2' }]; - const request = spec.buildRequests(bidRequestsWithoutCoppa); + const request = spec.buildRequests(bidRequestsWithoutCoppa, mockBidderRequest); expect(request[0].data).to.not.have.any.keys('tfcd'); }); @@ -861,7 +800,7 @@ describe('OpenxAdapter', function () { bidderRequestId: 'test-bid-request-2', auctionId: 'test-auction-2' }]; - const request = spec.buildRequests(bidRequestsWithCoppa); + const request = spec.buildRequests(bidRequestsWithCoppa, mockBidderRequest); expect(request[0].data.tfcd).to.equal(1); }); @@ -898,7 +837,7 @@ describe('OpenxAdapter', function () { bidderRequestId: 'test-bid-request-2', auctionId: 'test-auction-2' }]; - const request = spec.buildRequests(bidRequestsWithoutDnt); + const request = spec.buildRequests(bidRequestsWithoutDnt, mockBidderRequest); expect(request[0].data).to.not.have.any.keys('ns'); }); @@ -936,7 +875,7 @@ describe('OpenxAdapter', function () { bidderRequestId: 'test-bid-request-2', auctionId: 'test-auction-2' }]; - const request = spec.buildRequests(bidRequestsWithDnt); + const request = spec.buildRequests(bidRequestsWithDnt, mockBidderRequest); expect(request[0].data.ns).to.equal(1); }); @@ -998,7 +937,7 @@ describe('OpenxAdapter', function () { }); it('should send a schain parameter with the proper delimiter symbols', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, mockBidderRequest); const dataParams = request[0].data; const numNodes = schainConfig.nodes.length; @@ -1011,7 +950,7 @@ describe('OpenxAdapter', function () { }); it('should send a schain with the right version', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, mockBidderRequest); const dataParams = request[0].data; let serializedSupplyChain = dataParams.schain.split('!'); let version = serializedSupplyChain.shift().split(',')[0]; @@ -1020,7 +959,7 @@ describe('OpenxAdapter', function () { }); it('should send a schain with the right complete value', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, mockBidderRequest); const dataParams = request[0].data; let serializedSupplyChain = dataParams.schain.split('!'); let isComplete = serializedSupplyChain.shift().split(',')[1]; @@ -1029,7 +968,7 @@ describe('OpenxAdapter', function () { }); it('should send all available params in the right order', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, mockBidderRequest); const dataParams = request[0].data; let serializedSupplyChain = dataParams.schain.split('!'); serializedSupplyChain.shift(); @@ -1051,7 +990,7 @@ describe('OpenxAdapter', function () { describe('when there are userid providers', function () { describe('with publisher common id', function () { it('should not send a pubcid query param when there is no crumbs.pubcid and no userId.pubcid defined in the bid requests', function () { - const request = spec.buildRequests(bidRequestsWithMediaType); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); expect(request[0].data).to.not.have.any.keys('pubcid'); }); @@ -1075,7 +1014,7 @@ describe('OpenxAdapter', function () { bidderRequestId: 'test-bid-request-1', auctionId: 'test-auction-1' }]; - const request = spec.buildRequests(bidRequestsWithPubcid); + const request = spec.buildRequests(bidRequestsWithPubcid, mockBidderRequest); expect(request[0].data.pubcid).to.equal('c4a4c843-2368-4b5e-b3b1-6ee4702b9ad6'); }); @@ -1099,14 +1038,14 @@ describe('OpenxAdapter', function () { bidderRequestId: 'test-bid-request-1', auctionId: 'test-auction-1' }]; - const request = spec.buildRequests(bidRequestsWithPubcid); + const request = spec.buildRequests(bidRequestsWithPubcid, mockBidderRequest); expect(request[0].data.pubcid).to.equal('c1a4c843-2368-4b5e-b3b1-6ee4702b9ad6'); }); }); describe('with the trade desk unified id', function () { it('should not send a tdid query param when there is no userId.tdid defined in the bid requests', function () { - const request = spec.buildRequests(bidRequestsWithMediaType); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); expect(request[0].data).to.not.have.any.keys('ttduuid'); }); @@ -1130,14 +1069,14 @@ describe('OpenxAdapter', function () { bidderRequestId: 'test-bid-request-1', auctionId: 'test-auction-1' }]; - const request = spec.buildRequests(bidRequestsWithTdid); + const request = spec.buildRequests(bidRequestsWithTdid, mockBidderRequest); expect(request[0].data.ttduuid).to.equal('00000000-aaaa-1111-bbbb-222222222222'); }); }); describe('with the liveRamp identity link envelope', function () { it('should not send a tdid query param when there is no userId.lre defined in the bid requests', function () { - const request = spec.buildRequests(bidRequestsWithMediaType); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); expect(request[0].data).to.not.have.any.keys('lre'); }); @@ -1161,7 +1100,7 @@ describe('OpenxAdapter', function () { bidderRequestId: 'test-bid-request-1', auctionId: 'test-auction-1' }]; - const request = spec.buildRequests(bidRequestsWithLiveRampEnvelope); + const request = spec.buildRequests(bidRequestsWithLiveRampEnvelope, mockBidderRequest); expect(request[0].data.lre).to.equal('00000000-aaaa-1111-bbbb-222222222222'); }); }); @@ -1187,36 +1126,15 @@ describe('OpenxAdapter', function () { 'auctionId': '1d1a030790a475', 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' }]; - - const bidRequestsWithMediaType = [{ - 'bidder': 'openx', - 'mediaType': 'video', - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [640, 480], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' - }]; - - it('should send bid request to openx url via GET, with mediaType as video', function () { - const request = spec.buildRequests(bidRequestsWithMediaType); - expect(request[0].url).to.equal('https://' + bidRequestsWithMediaType[0].params.delDomain + URLBASEVIDEO); - expect(request[0].method).to.equal('GET'); - }); + const mockBidderRequest = {refererInfo: {}}; it('should send bid request to openx url via GET, with mediaTypes having video parameter', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); expect(request[0].url).to.equal('https://' + bidRequestsWithMediaTypes[0].params.delDomain + URLBASEVIDEO); expect(request[0].method).to.equal('GET'); }); - it('should have the correct parameters', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); const dataParams = request[0].data; expect(dataParams.auid).to.equal('12345678'); @@ -1225,7 +1143,7 @@ describe('OpenxAdapter', function () { }); it('should send a bc parameter', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes); + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); const dataParams = request[0].data; expect(dataParams.bc).to.have.string('hb_pb'); @@ -1233,6 +1151,7 @@ describe('OpenxAdapter', function () { describe('when using the video param', function () { let videoBidRequest; + let mockBidderRequest = {refererInfo: {}}; beforeEach(function () { videoBidRequest = { @@ -1253,13 +1172,14 @@ describe('OpenxAdapter', function () { 'auctionId': '1d1a030790a475', 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' } + mockBidderRequest = {refererInfo: {}}; }); it('should not allow you to set a url', function () { videoBidRequest.params.video = { url: 'test-url' }; - const request = spec.buildRequests([videoBidRequest]); + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); expect(request[0].data.url).to.be.undefined; }); @@ -1269,7 +1189,7 @@ describe('OpenxAdapter', function () { videoBidRequest.params.video = { ju: myUrl }; - const request = spec.buildRequests([videoBidRequest]); + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); expect(request[0].data.ju).to.not.equal(myUrl); }); @@ -1280,7 +1200,7 @@ describe('OpenxAdapter', function () { videoBidRequest.params.video = { openrtb: myOpenRTBObject }; - const request = spec.buildRequests([videoBidRequest]); + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); expect(request[0].data.openrtb).to.equal(JSON.stringify(myOpenRTBObject)); }); @@ -1292,7 +1212,7 @@ describe('OpenxAdapter', function () { videoBidRequest.params.video = { openrtb: myOpenRTBObject }; - const request = spec.buildRequests([videoBidRequest]); + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); const openRtbRequestParams = JSON.parse(request[0].data.openrtb); expect(openRtbRequestParams.w).to.not.equal(width); @@ -1308,7 +1228,7 @@ describe('OpenxAdapter', function () { }; videoBidRequest.mediaTypes.video.playerSize = undefined; - const request = spec.buildRequests([videoBidRequest]); + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); const openRtbRequestParams = JSON.parse(request[0].data.openrtb); expect(openRtbRequestParams.w).to.equal(width); @@ -1339,10 +1259,13 @@ describe('OpenxAdapter', function () { auctionId: '1d1a030790a475', transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e' }; + let mockBidderRequest = {refererInfo: {}}; + + it('should default to a banner request', function () { + const request = spec.buildRequests([multiformatBid], mockBidderRequest); + const dataParams = request[0].data; - it('should send bid request to openx url via GET, with mediaType specified as banner', function () { - const request = spec.buildRequests([multiformatBid]); - expect(request[0].url).to.equal(`https://${multiformatBid.params.delDomain}${URLBASE}`); + expect(dataParams.divIds).to.have.string(multiformatBid.adUnitCode); }); }); @@ -1450,12 +1373,6 @@ describe('OpenxAdapter', function () { it('should return a brand ID', function () { expect(bid.meta.dspid).to.equal(DEFAULT_TEST_ARJ_AD_UNIT.adv_id); }); - - it('should register a beacon', function () { - resetBoPixel(); - spec.interpretResponse({body: bidResponse}, bidRequest); - sinon.assert.calledWith(userSync.registerSync, 'image', 'openx', sinon.match(new RegExp(`https:\/\/openx-d\.openx\.net.*\/bo\?.*ts=${adUnitOverride.ts}`))); - }); }); describe('when there is a deal', function () { @@ -1745,14 +1662,6 @@ describe('OpenxAdapter', function () { const result = spec.interpretResponse({body: bidResponse}, bidRequestsWithMediaType); expect(result.length).to.equal(0); }); - - it('should register a beacon', function () { - resetBoPixel(); - spec.interpretResponse({body: bidResponse}, bidRequestsWithMediaTypes); - sinon.assert.calledWith(userSync.registerSync, 'image', 'openx', sinon.match(/^https:\/\/test-colo\.com/)); - sinon.assert.calledWith(userSync.registerSync, 'image', 'openx', sinon.match(/ph=test-ph/)); - sinon.assert.calledWith(userSync.registerSync, 'image', 'openx', sinon.match(/ts=test-ts/)); - }); }); describe('user sync', function () { diff --git a/test/spec/modules/openxoutstreamBidAdapter_spec.js b/test/spec/modules/openxoutstreamBidAdapter_spec.js index 634df1c8c6a..9d2b7082a22 100644 --- a/test/spec/modules/openxoutstreamBidAdapter_spec.js +++ b/test/spec/modules/openxoutstreamBidAdapter_spec.js @@ -13,12 +13,6 @@ describe('OpenXOutstreamAdapter', function () { const CR_ID = '2052941939925262540'; const AD_ID = '1991358644725162800'; - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - describe('isBidRequestValid', function () { describe('when request is for a banner ad', function () { let bannerBid; @@ -80,8 +74,10 @@ describe('OpenXOutstreamAdapter', function () { 'auctionId': '1d1a030790a475' }]; + const mockBidderRequest = {refererInfo: {}}; + it('should send bid request to openx url via GET, with mediaType specified as banner', function () { - const request = spec.buildRequests(bidRequestsWithMediaType); + const request = spec.buildRequests(bidRequestsWithMediaType, mockBidderRequest); const params = bidRequestsWithMediaType[0].params; expect(request[0].url).to.equal(`https://` + params.delDomain + URLBASE); expect(request[0].method).to.equal('GET'); @@ -97,7 +93,6 @@ describe('OpenXOutstreamAdapter', function () { 'delDomain': 'test-del-domain' }, 'adUnitCode': 'adunit-code', - sizes: [300, 250], mediaTypes: { banner: { sizes: [[728, 90]] @@ -112,7 +107,6 @@ describe('OpenXOutstreamAdapter', function () { 'delDomain': 'test-del-domain' }, 'adUnitCode': 'adunit-code', - 'sizes': [300, 250], mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] @@ -122,7 +116,7 @@ describe('OpenXOutstreamAdapter', function () { 'bidderRequestId': 'test-bid-request-1', 'auctionId': 'test-auction-1' }]; - const request = spec.buildRequests(bidRequestsWithUnitIds); + const request = spec.buildRequests(bidRequestsWithUnitIds, mockBidderRequest); expect(request[0].data.auid).to.equal(`${bidRequestsWithUnitIds[0].params.unit}`); expect(request[0].data.vht).to.not.equal(`${bidRequestsWithUnitIds[0].params.height}`); expect(request[0].data.vwd).to.not.equal(`${bidRequestsWithUnitIds[0].params.width}`);