From 95faa225a0c4f634c3a5bc648b4173fb082de8e6 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Tue, 10 Sep 2019 19:38:51 +0300 Subject: [PATCH 01/14] Adding Konduit module --- modules/konduitWrapper.js | 96 +++++++++++++++++ modules/konduitWrapper.md | 39 +++++++ test/spec/modules/konduitWrapper_spec.js | 126 +++++++++++++++++++++++ 3 files changed, 261 insertions(+) create mode 100644 modules/konduitWrapper.js create mode 100644 modules/konduitWrapper.md create mode 100644 test/spec/modules/konduitWrapper_spec.js diff --git a/modules/konduitWrapper.js b/modules/konduitWrapper.js new file mode 100644 index 00000000000..f3dccd66a43 --- /dev/null +++ b/modules/konduitWrapper.js @@ -0,0 +1,96 @@ +import { registerVideoSupport } from '../src/adServerManager'; +import { targeting } from '../src/targeting'; +import { format as buildUrl } from '../src/url'; +import * as utils from '../src/utils'; +import { config } from '../src/config'; +import { getHook } from '../src/hook'; + +const MODULE_NAME = 'Konduit'; + +function addLogLabel(args) { + args = [].slice.call(args); + args.unshift(`${MODULE_NAME}: `); + return args; +} + +export function logInfo() { + utils.logInfo(...addLogLabel(arguments)); +} + +export function logError() { + utils.logError(...addLogLabel(arguments)); +} + +export function buildVastUrl(options) { + if (!options.params || !options.params.konduit_id) { + logError(`'konduit_id' parameter is required for $$PREBID_GLOBAL$$.adServers.konduit.buildVastUrl function`); + + return null; + } + + const bid = options.bid || targeting.getWinningBids()[0]; + + if (!bid) { + logError('Bid is not provided or not found'); + + return null; + } + + logInfo('The following bid will be wrapped: ', bid); + + const queryParams = {}; + + const vastUrl = obtainVastUrl(bid, options, 'params'); + + if (vastUrl) { + queryParams.konduit_id = options.params.konduit_id; + queryParams.konduit_header_bidding = 1; + queryParams.konduit_url = vastUrl; + } else { + logError('No VAST url found in the bid'); + } + + let resultingUrl = null; + + if (queryParams.konduit_url) { + resultingUrl = buildUrl({ + protocol: 'https', + host: 'p.konduit.me', + pathname: '/api/vastProxy', + search: queryParams + }); + + logInfo(`Konduit wrapped VAST url: ${resultingUrl}`); + } + + return resultingUrl; +} + +export function notifyTranslationModule(fn) { + fn.call(this, 'konduit'); +} + +getHook('registerAdserver').before(notifyTranslationModule); + +function obtainVastUrl(bid) { + const cacheUrl = config.getConfig('cache.url'); + if (cacheUrl) { + const composedCacheUrl = `${cacheUrl}?uuid=${bid.videoCacheKey}`; + + logInfo(`VAST url is taken from cache.url: ${composedCacheUrl}`); + + return encodeURIComponent(composedCacheUrl); + } + + const vastUrl = bid && bid.vastUrl; + + if (vastUrl) { + logInfo(`VAST url found in the bid - ${vastUrl}`); + + return encodeURIComponent(vastUrl); + } +} + +registerVideoSupport('konduit', { + buildVastUrl: buildVastUrl, +}); diff --git a/modules/konduitWrapper.md b/modules/konduitWrapper.md new file mode 100644 index 00000000000..c9b949d7998 --- /dev/null +++ b/modules/konduitWrapper.md @@ -0,0 +1,39 @@ +## Konduit video tags wrapper + +Konduit Wrapper is a prebid module to generate Konduit wrapped VAST tag URLs for a provided bid or a winning bid. + + +### Setup + +``` +pbjs.que.push(function(){ + pbjs.addAdUnits(videoAdUnit); + pbjs.requestBids({ + timeout : 700, + bidsBackHandler : function(bids) { + var videoUrl = pbjs.adServers.konduit.buildVastUrl({ + bid: winnerBid, + params: { + konduit_id: 'your_konduit_id' + } + }); + + invokeVideoPlayer(vastTagUrl); + } + }); +}); +``` + +Function parameters: +* `bid` - prebid object with VAST url that should be wrapped (if not passed first winning bid from `auctionManager.getWinningBids()` is used) +* `konduit_id` - your personal unique Konduit identifier (required) + +The function returns a Konduit wrapped VAST url if valid parameters are passed in. If some of the parameters are not passed or are invalid the function returns 'null' along with related error logs providing more details. + + +### Building Prebid with the Konduit wrapper function + +Your Prebid build must include the **konduitWrapper** module. Follow the build instructions for Prebid as explained in the top level README.md file of the Prebid source tree. + +ex: $ gulp build --modules=konduitWrapper + diff --git a/test/spec/modules/konduitWrapper_spec.js b/test/spec/modules/konduitWrapper_spec.js new file mode 100644 index 00000000000..aa39a5bff89 --- /dev/null +++ b/test/spec/modules/konduitWrapper_spec.js @@ -0,0 +1,126 @@ +// eslint-disable-file +import { expect } from 'chai'; + +import parse from 'url-parse'; +import { buildVastUrl } from 'modules/konduitWrapper'; +import { parseQS } from 'src/url'; +import { config } from 'src/config'; + +describe('The Konduit vast wrapper module', function () { + it('should make a wrapped request url when `bid` passed', function () { + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + + const url = parse(buildVastUrl({ + bid, + params: { 'konduit_id': 'testId' }, + })); + + expect(url.protocol).to.equal('https:'); + expect(url.host).to.equal('p.konduit.me'); + + const queryParams = parseQS(url.query); + expect(queryParams).to.have.property('konduit_url', encodeURIComponent('http://some-vast-url.com')); + expect(queryParams).to.have.property('konduit_header_bidding', '1'); + expect(queryParams).to.have.property('konduit_id', 'testId'); + }); + + it('should return null when no `konduit_id` (required param) passed', function () { + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + + const url = buildVastUrl({ bid }); + + expect(url).to.equal(null); + }); + + it('should return null when either bid or adUnit is not passed', function () { + const url = buildVastUrl({ params: { 'konduit_id': 'testId' } }); + + expect(url).to.equal(null); + }); + + it('should return null when bid does not contain vastUrl', function () { + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + + delete bid.vastUrl; + + const url = buildVastUrl({ + bid, + params: { 'konduit_id': 'testId' }, + }); + + expect(url).to.equal(null); + }); + + it('should return wrapped vastUrl based on cached url in params', function () { + config.setConfig({ cache: { url: 'https://cached.url.com' } }); + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + + const expectedUrl = encodeURIComponent(`https://cached.url.com?uuid=${bid.videoCacheKey}`); + + const url = parse(buildVastUrl({ + bid, + params: { 'konduit_id': 'testId' }, + })); + const queryParams = parseQS(url.query); + + expect(queryParams).to.have.property('konduit_url', expectedUrl); + + config.resetConfig(); + }); +}); + +function createBid(cpm, adUnitCode, durationBucket, priceIndustryDuration, uuid, label) { + return { + 'bidderCode': 'appnexus', + 'width': 640, + 'height': 360, + 'statusMessage': 'Bid available', + 'adId': '28f24ced14586c', + 'mediaType': 'video', + 'source': 'client', + 'requestId': '28f24ced14586c', + 'cpm': cpm, + 'creativeId': 97517771, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 3600, + 'adUnitCode': adUnitCode, + 'video': { + 'context': 'adpod', + 'durationBucket': durationBucket + }, + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'vastUrl': 'http://some-vast-url.com', + 'vastImpUrl': 'http://some-vast-imp-url.com', + 'auctionId': 'ec266b31-d652-49c5-8295-e83fafe5532b', + 'responseTimestamp': 1548442460888, + 'requestTimestamp': 1548442460827, + 'bidder': 'appnexus', + 'timeToRespond': 61, + 'pbLg': '5.00', + 'pbMg': '5.00', + 'pbHg': '5.00', + 'pbAg': '5.00', + 'pbDg': '5.00', + 'pbCg': '', + 'size': '640x360', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '28f24ced14586c', + 'hb_pb': '5.00', + 'hb_size': '640x360', + 'hb_source': 'client', + 'hb_format': 'video', + 'hb_pb_cat_dur': priceIndustryDuration, + 'hb_cache_id': uuid + }, + 'customCacheKey': `${priceIndustryDuration}_${uuid}`, + 'meta': { + 'iabSubCatId': 'iab-1', + 'adServerCatId': label + }, + 'videoCacheKey': '4cf395af-8fee-4960-af0e-88d44e399f14' + } +} From 6adc687ca17371f280ba72e85c47292a6ba04fb8 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Wed, 11 Sep 2019 16:44:54 +0300 Subject: [PATCH 02/14] Removed superfluous arguments passed to obtainVastUrl function --- modules/konduitWrapper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/konduitWrapper.js b/modules/konduitWrapper.js index f3dccd66a43..2c7aba1f530 100644 --- a/modules/konduitWrapper.js +++ b/modules/konduitWrapper.js @@ -40,7 +40,7 @@ export function buildVastUrl(options) { const queryParams = {}; - const vastUrl = obtainVastUrl(bid, options, 'params'); + const vastUrl = obtainVastUrl(bid); if (vastUrl) { queryParams.konduit_id = options.params.konduit_id; From bc6d752fbd5090349c48e65d4a5ee3c04d87cdf7 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Wed, 11 Sep 2019 16:44:54 +0300 Subject: [PATCH 03/14] Removed superfluous arguments passed to obtainVastUrl function. --- modules/konduitWrapper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/konduitWrapper.js b/modules/konduitWrapper.js index f3dccd66a43..2c7aba1f530 100644 --- a/modules/konduitWrapper.js +++ b/modules/konduitWrapper.js @@ -40,7 +40,7 @@ export function buildVastUrl(options) { const queryParams = {}; - const vastUrl = obtainVastUrl(bid, options, 'params'); + const vastUrl = obtainVastUrl(bid); if (vastUrl) { queryParams.konduit_id = options.params.konduit_id; From 67e79575ec3c5160e49de7409901741e6e48a205 Mon Sep 17 00:00:00 2001 From: Alexander Kislitsyn Date: Fri, 13 Sep 2019 12:03:42 +0300 Subject: [PATCH 04/14] Build trigger (empty commit) From f0d6e343aee0e251314c2b6fbe90aa847b725669 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Tue, 17 Sep 2019 15:30:47 +0300 Subject: [PATCH 05/14] Module documentation updated according to the comments --- modules/konduitWrapper.md | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/modules/konduitWrapper.md b/modules/konduitWrapper.md index c9b949d7998..adbb50487da 100644 --- a/modules/konduitWrapper.md +++ b/modules/konduitWrapper.md @@ -6,13 +6,34 @@ Konduit Wrapper is a prebid module to generate Konduit wrapped VAST tag URLs for ### Setup ``` +var videoAdUnit = [{ + code: 'videoAd', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13232361, + video: { + skippable: true, + playback_method: ['auto_play_sound_off'] + } + } + }] +}]; + pbjs.que.push(function(){ pbjs.addAdUnits(videoAdUnit); pbjs.requestBids({ timeout : 700, bidsBackHandler : function(bids) { - var videoUrl = pbjs.adServers.konduit.buildVastUrl({ - bid: winnerBid, + var winnerBid = pbjs.getHighestCpmBids('videoAd')[0]; + var vastTagUrl = pbjs.adServers.konduit.buildVastUrl({ + bid: winnerBid, // just in case if you want to pass your bid params: { konduit_id: 'your_konduit_id' } @@ -22,6 +43,19 @@ pbjs.que.push(function(){ } }); }); + +function invokeVideoPlayer(vastTagUrl) { + videojs("video_player_id").ready(function() { + this.vastClient({ + adTagUrl: vastTagUrl, + playAdAlways: true, + verbosity: 4, + autoplay: true + }); + + this.play(); + }); + } ``` Function parameters: From 105513ba31a6bcf85cf2801c19029d8cf4d63dbf Mon Sep 17 00:00:00 2001 From: Alexander Kislitsyn Date: Thu, 26 Sep 2019 15:05:26 +0300 Subject: [PATCH 06/14] Logic in obtainVastUrl function updated according to the review comment. --- modules/konduitWrapper.js | 16 ++++++++-------- test/spec/modules/konduitWrapper_spec.js | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/konduitWrapper.js b/modules/konduitWrapper.js index 2c7aba1f530..c9411d86b2a 100644 --- a/modules/konduitWrapper.js +++ b/modules/konduitWrapper.js @@ -73,6 +73,14 @@ export function notifyTranslationModule(fn) { getHook('registerAdserver').before(notifyTranslationModule); function obtainVastUrl(bid) { + const vastUrl = bid && bid.vastUrl; + + if (vastUrl) { + logInfo(`VAST url found in the bid - ${vastUrl}`); + + return encodeURIComponent(vastUrl); + } + const cacheUrl = config.getConfig('cache.url'); if (cacheUrl) { const composedCacheUrl = `${cacheUrl}?uuid=${bid.videoCacheKey}`; @@ -81,14 +89,6 @@ function obtainVastUrl(bid) { return encodeURIComponent(composedCacheUrl); } - - const vastUrl = bid && bid.vastUrl; - - if (vastUrl) { - logInfo(`VAST url found in the bid - ${vastUrl}`); - - return encodeURIComponent(vastUrl); - } } registerVideoSupport('konduit', { diff --git a/test/spec/modules/konduitWrapper_spec.js b/test/spec/modules/konduitWrapper_spec.js index aa39a5bff89..6832a745291 100644 --- a/test/spec/modules/konduitWrapper_spec.js +++ b/test/spec/modules/konduitWrapper_spec.js @@ -55,6 +55,8 @@ describe('The Konduit vast wrapper module', function () { config.setConfig({ cache: { url: 'https://cached.url.com' } }); const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + delete bid.vastUrl; + const expectedUrl = encodeURIComponent(`https://cached.url.com?uuid=${bid.videoCacheKey}`); const url = parse(buildVastUrl({ From 191a4983044e8b810d0d43a1ed8648781fc609c8 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Tue, 1 Oct 2019 14:30:47 +0300 Subject: [PATCH 07/14] Removed hook, enabled eslint --- modules/konduitWrapper.js | 7 ------- test/spec/modules/konduitWrapper_spec.js | 1 - 2 files changed, 8 deletions(-) diff --git a/modules/konduitWrapper.js b/modules/konduitWrapper.js index c9411d86b2a..c155720c606 100644 --- a/modules/konduitWrapper.js +++ b/modules/konduitWrapper.js @@ -3,7 +3,6 @@ import { targeting } from '../src/targeting'; import { format as buildUrl } from '../src/url'; import * as utils from '../src/utils'; import { config } from '../src/config'; -import { getHook } from '../src/hook'; const MODULE_NAME = 'Konduit'; @@ -66,12 +65,6 @@ export function buildVastUrl(options) { return resultingUrl; } -export function notifyTranslationModule(fn) { - fn.call(this, 'konduit'); -} - -getHook('registerAdserver').before(notifyTranslationModule); - function obtainVastUrl(bid) { const vastUrl = bid && bid.vastUrl; diff --git a/test/spec/modules/konduitWrapper_spec.js b/test/spec/modules/konduitWrapper_spec.js index 6832a745291..bcc65ddd683 100644 --- a/test/spec/modules/konduitWrapper_spec.js +++ b/test/spec/modules/konduitWrapper_spec.js @@ -1,4 +1,3 @@ -// eslint-disable-file import { expect } from 'chai'; import parse from 'url-parse'; From 6eabb0d57f1420f4882eb5743e2bd77a8155b010 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Thu, 16 Apr 2020 14:30:23 +0300 Subject: [PATCH 08/14] Merged recent prebid changes --- .circleci/config.yml | 128 +- .eslintrc.js | 7 +- .gitignore | 3 + CONTRIBUTING.md | 4 +- PR_REVIEW.md | 4 +- README.md | 4 +- allowedModules.js | 19 +- browsers.json | 26 +- gulpHelpers.js | 1 + gulpfile.js | 68 +- .../gpt/audigentSegments_example.html | 262 + .../gpt/cmp_files/purposes.json | 25 + integrationExamples/gpt/digitrust_Full.html | 2 +- integrationExamples/gpt/digitrust_Simple.html | 3 +- .../gpt/digitrust_cmp_test.html | 192 + integrationExamples/gpt/hello_world.html | 122 +- .../gpt/prebidServer_example.html | 6 +- .../gpt/proxistore_example.html | 118 + .../gpt/responsiveAds_sizeMappingV2.html | 121 + .../gpt/revcontent_example.html | 109 + integrationExamples/gpt/userId_example.html | 21 +- .../longform/basic_w_bidderSettings.html | 145 + .../basic_w_custom_adserver_translation.html | 4 +- .../longform/basic_w_priceGran.html | 153 + .../basic_w_requireExactDuration.html | 4 +- .../basic_wo_brandCategoryExclusion.html | 4 +- .../basic_wo_requireExactDuration.html | 4 +- karma.conf.maker.js | 34 +- modules/.submodules.json | 12 +- modules/1ad4goodBidAdapter.js | 399 + modules/1ad4goodBidAdapter.md | 87 + modules/33acrossBidAdapter.js | 21 +- modules/7xbidBidAdapter.js | 159 + modules/7xbidBidAdapter.md | 59 + modules/a4gBidAdapter.js | 89 - modules/aardvarkBidAdapter.js | 115 +- modules/ablidaBidAdapter.js | 93 + modules/ablidaBidAdapter.md | 32 + modules/adagioAnalyticsAdapter.js | 58 +- modules/adagioAnalyticsAdapter.md | 2 +- modules/adagioBidAdapter.js | 446 +- modules/adagioBidAdapter.md | 66 +- modules/adbutlerBidAdapter.js | 54 +- ...amaBidAdapter.js => adfinityBidAdapter.js} | 72 +- modules/adfinityBidAdapter.md | 67 + modules/adformBidAdapter.js | 28 +- modules/adformOpenRTBBidAdapter.js | 10 +- modules/adgenerationBidAdapter.js | 10 +- modules/adgenerationBidAdapter.md | 86 +- modules/adglareBidAdapter.js | 90 + modules/adglareBidAdapter.md | 36 + modules/adheseBidAdapter.js | 44 +- modules/adkernelAdnAnalyticsAdapter.js | 58 +- modules/adkernelAdnBidAdapter.js | 28 +- modules/adkernelBidAdapter.js | 188 +- modules/adkernelBidAdapter.md | 98 +- modules/adliveBidAdapter.js | 6 +- modules/admanBidAdapter.js | 144 +- modules/admanBidAdapter.md | 88 +- modules/admaticBidAdapter.js | 8 +- modules/admediaBidAdapter.js | 6 +- modules/admixerBidAdapter.js | 21 +- modules/adnuntiusBidAdapter.js | 68 + modules/adnuntiusBidAdapter.md | 36 + modules/adoceanBidAdapter.js | 12 +- modules/adomikAnalyticsAdapter.js | 10 +- modules/adotBidAdapter.js | 607 ++ modules/adotBidAdapter.md | 218 + modules/adpod.js | 101 +- modules/adponeBidAdapter.js | 37 +- modules/adspendBidAdapter.js | 31 +- modules/adspiritBidAdapter.js | 72 - modules/adtelligentBidAdapter.js | 66 +- modules/aduptechBidAdapter.js | 158 +- modules/aduptechBidAdapter.md | 25 +- modules/advangelistsBidAdapter.js | 21 +- modules/advenueBidAdapter.js | 8 +- modules/advertlyBidAdapter.js | 127 + modules/advertlyBidAdapter.md | 50 + modules/adxcgAnalyticsAdapter.js | 25 +- modules/adxcgAnalyticsAdapter.md | 2 +- modules/adxcgBidAdapter.js | 64 +- modules/adxcgBidAdapter.md | 96 +- modules/adxpremiumAnalyticsAdapter.js | 160 + modules/adxpremiumAnalyticsAdapter.md | 41 + modules/adyoulikeBidAdapter.js | 41 +- modules/ajaBidAdapter.js | 10 +- modules/andbeyondBidAdapter.js | 168 - modules/aniviewBidAdapter.js | 51 +- modules/aniviewBidAdapter.md | 26 +- modules/aolBidAdapter.js | 56 +- modules/appierAnalyticsAdapter.js | 11 +- modules/appierBidAdapter.js | 6 +- modules/appnexusAnalyticsAdapter.js | 4 +- modules/appnexusBidAdapter.js | 148 +- modules/arteebeeBidAdapter.js | 190 - modules/astraoneBidAdapter.js | 140 + modules/astraoneBidAdapter.md | 198 + modules/atomxBidAdapter.js | 6 +- modules/atsAnalyticsAdapter.js | 153 + modules/atsAnalyticsAdapter.md | 23 + modules/audienceNetworkBidAdapter.js | 25 +- modules/audiencerunBidAdapter.js | 142 + modules/audiencerunBidAdapter.md | 48 + modules/audigentRtdProvider.js | 141 + modules/audigentRtdProvider.md | 52 + modules/automatadBidAdapter.js | 123 + modules/automatadBidAdapter.md | 34 + modules/beachfrontBidAdapter.js | 54 +- modules/beachfrontBidAdapter.md | 1 + modules/betweenBidAdapter.js | 29 +- modules/betweenBidAdapter.md | 23 +- modules/bidfluenceBidAdapter.js | 11 +- modules/bidglassBidAdapter.js | 228 +- modules/bidlabBidAdapter.js | 112 + modules/bidlabBidAdapter.md | 53 + modules/bidphysicsBidAdapter.js | 8 +- modules/bizzclickBidAdapter.js | 105 - modules/brainyBidAdapter.js | 154 - modules/bridgewellBidAdapter.js | 101 +- modules/bridgewellBidAdapter.md | 35 +- modules/brightcomBidAdapter.js | 18 +- modules/brightcomBidAdapter.md | 16 +- modules/britepoolIdSystem.js | 132 + modules/britepoolIdSystem.md | 42 + modules/browsiRtdProvider.js | 318 + modules/bucksenseBidAdapter.js | 8 +- modules/buzzoolaBidAdapter.js | 10 +- modules/byplayBidAdapter.js | 67 + modules/byplayBidAdapter.md | 37 + modules/c1xBidAdapter.js | 11 +- modules/categoryTranslation.js | 18 +- modules/ccxBidAdapter.js | 33 +- modules/cedatoBidAdapter.js | 233 +- modules/cleanmedianetBidAdapter.js | 51 +- modules/clickforceBidAdapter.js | 12 +- modules/clicktripzBidAdapter.js | 67 + modules/clicktripzBidAdapter.md | 35 + modules/coinzillaBidAdapter.js | 8 +- modules/collectcentBidAdapter.js | 10 +- modules/colombiaBidAdapter.js | 72 - modules/colossussspBidAdapter.js | 36 +- modules/colossussspBidAdapter.md | 6 +- modules/connectadBidAdapter.js | 299 + modules/connectadBidAdapter.md | 46 + modules/consentManagement.js | 246 +- modules/consentManagementUsp.js | 311 + modules/consumableBidAdapter.js | 18 +- modules/contentigniteBidAdapter.js | 115 - modules/convergeBidAdapter.js | 313 + modules/convergeBidAdapter.md | 57 + modules/conversantBidAdapter.js | 129 +- modules/conversantBidAdapter.md | 6 +- modules/cosmosBidAdapter.js | 10 +- modules/cpmstarBidAdapter.js | 12 +- modules/criteoBidAdapter.js | 163 +- modules/criteoIdSystem.js | 141 + modules/criteortusIdSystem.js | 105 - modules/currency.js | 17 +- modules/dailyhuntBidAdapter.js | 192 + modules/dailyhuntBidAdapter.md | 69 + modules/danmarketBidAdapter.js | 161 - modules/datablocksAnalyticsAdapter.js | 4 +- modules/datablocksBidAdapter.js | 63 +- modules/datablocksBidAdapter.md | 21 +- modules/decenteradsBidAdapter.js | 90 - modules/deepintentBidAdapter.js | 176 + modules/deepintentBidAdapter.md | 54 + modules/dfpAdServerVideo.js | 19 +- modules/dgadsBidAdapter.js | 103 - modules/digiTrustIdSystem.js | 108 +- modules/districtmDMXBidAdapter.js | 196 +- modules/districtmDmxBidAdapter.md | 31 +- modules/djaxBidAdapter.js | 129 + modules/djaxBidAdapter.md | 50 + modules/dspxBidAdapter.js | 26 +- modules/dspxBidAdapter.md | 3 +- modules/e_volutionBidAdapter.js | 111 + modules/e_volutionBidAdapter.md | 53 + modules/ebdrBidAdapter.js | 8 +- modules/emoteevBidAdapter.js | 32 +- modules/emx_digitalBidAdapter.js | 66 +- modules/envivoBidAdapter.js | 129 + modules/envivoBidAdapter.md | 50 + modules/eplanningAnalyticsAdapter.js | 8 +- modules/eplanningBidAdapter.js | 319 +- modules/etargetBidAdapter.js | 6 +- modules/express.js | 4 +- modules/eywamediaBidAdapter.js | 181 - modules/fairtradeBidAdapter.js | 150 - modules/feedadBidAdapter.js | 8 +- modules/fidelityBidAdapter.js | 60 +- modules/fidelityBidAdapter.md | 18 +- modules/fintezaAnalyticsAdapter.js | 77 +- modules/fluctBidAdapter.js | 121 + modules/fluctBidAdapter.md | 36 + modules/freeWheelAdserverVideo.js | 4 +- modules/freewheel-sspBidAdapter.js | 167 +- modules/freewheel-sspBidAdapter.md | 12 +- modules/fyberBidAdapter.js | 378 - modules/gammaBidAdapter.js | 13 +- modules/gamoshiBidAdapter.js | 186 +- modules/gdprEnforcement.js | 218 + modules/getintentBidAdapter.js | 6 +- modules/giantsBidAdapter.js | 343 - modules/gjirafaBidAdapter.js | 95 - modules/googleAnalyticsAdapter.js | 18 +- modules/googleAnalyticsAdapter.md | 37 + modules/gridBidAdapter.js | 52 +- modules/gridNMBidAdapter.js | 234 + modules/gridNMBidAdapter.md | 39 + modules/gumgumBidAdapter.js | 127 +- modules/gxoneBidAdapter.js | 141 - modules/hpmdnetworkBidAdapter.js | 6 +- modules/huddledmassesBidAdapter.js | 132 - modules/hybridBidAdapter.js | 198 + modules/hybridBidAdapter.md | 54 + modules/iasBidAdapter.js | 6 +- modules/id5IdSystem.js | 34 +- modules/identityLinkIdSystem.js | 29 +- modules/imonomyBidAdapter.js | 8 +- modules/improvedigitalBidAdapter.js | 43 +- modules/innityBidAdapter.js | 16 +- modules/innityBidAdapter.md | 8 +- modules/inskinBidAdapter.js | 7 +- modules/interactiveOffersBidAdapter.js | 99 - modules/invibesBidAdapter.js | 133 +- modules/invisiblyAnalyticsAdapter.js | 224 + modules/invisiblyAnalyticsAdapter.md | 24 + modules/iqmBidAdapter.js | 137 - modules/ixBidAdapter.js | 395 +- modules/ixBidAdapter.md | 168 +- modules/jcmBidAdapter.js | 10 +- modules/justpremiumBidAdapter.js | 83 +- modules/justpremiumBidAdapter.md | 12 +- modules/kargoAnalyticsAdapter.js | 4 +- modules/kargoBidAdapter.js | 34 +- modules/komoonaBidAdapter.js | 8 +- modules/konduitWrapper.js | 11 +- modules/lemmaBidAdapter.js | 401 + modules/lemmaBidAdapter.md | 66 + modules/lifestreetBidAdapter.js | 124 +- modules/lifestreetBidAdapter.md | 43 +- modules/liveIntentIdSystem.js | 162 + modules/livewrappedAnalyticsAdapter.js | 53 +- modules/livewrappedBidAdapter.js | 139 +- modules/liveyieldAnalyticsAdapter.js | 6 +- modules/lkqdBidAdapter.js | 115 +- modules/lkqdBidAdapter.md | 10 +- modules/lockerdomeBidAdapter.js | 43 +- modules/lockerdomeBidAdapter.md | 3 +- modules/logicadBidAdapter.js | 4 +- modules/loopmeBidAdapter.js | 8 +- modules/madvertiseBidAdapter.js | 6 +- modules/mantisBidAdapter.js | 15 +- modules/marsmediaAnalyticsAdapter.js | 8 +- modules/marsmediaBidAdapter.js | 360 +- modules/marsmediaBidAdapter.md | 47 +- modules/meazyBidAdapter.js | 10 +- modules/mediaforceBidAdapter.js | 151 + modules/mediaforceBidAdapter.md | 35 + modules/medianetAnalyticsAdapter.js | 633 ++ modules/medianetAnalyticsAdapter.md | 23 + modules/medianetBidAdapter.js | 76 +- modules/medianetBidAdapter.md | 6 +- modules/mgidBidAdapter.js | 26 +- modules/microadBidAdapter.js | 6 +- modules/mobfoxBidAdapter.js | 2 +- modules/mobsmartBidAdapter.js | 94 + modules/mobsmartBidAdapter.md | 50 + modules/my6senseBidAdapter.js | 6 +- modules/mytargetBidAdapter.js | 19 +- modules/nafdigitalBidAdapter.js | 11 +- modules/nanointeractiveBidAdapter.js | 42 +- modules/nasmediaAdmixerBidAdapter.js | 69 +- modules/nasmediaAdmixerBidAdapter.md | 12 +- modules/netIdSystem.js | 40 + modules/newborntownWebBidAdapter.js | 159 + modules/newborntownWebBidAdapter.md | 35 + modules/nextMillenniumBidAdapter.js | 6 +- modules/nextrollBidAdapter.js | 214 + modules/nextrollBidAdapter.md | 50 + modules/nobidBidAdapter.js | 136 +- modules/nobidBidAdapter.md | 1 + modules/oneVideoBidAdapter.js | 143 +- modules/oneVideoBidAdapter.md | 67 +- modules/oneplanetonlyBidAdapter.js | 76 - modules/onetagBidAdapter.js | 240 +- modules/onetagBidAdapter.md | 34 +- modules/open8BidAdapter.js | 12 +- modules/openxAnalyticsAdapter.js | 12 +- modules/openxAnalyticsAdapter.md | 129 + modules/openxBidAdapter.js | 181 +- modules/openxBidAdapter.md | 8 +- modules/openxoutstreamBidAdapter.js | 213 - modules/openxoutstreamBidAdapter.md | 43 - modules/optimaticBidAdapter.js | 106 - modules/optimeraBidAdapter.js | 4 +- modules/orbidderBidAdapter.js | 26 +- modules/orbitsoftBidAdapter.js | 147 - modules/otmBidAdapter.js | 4 +- modules/outconAdapter.md | 26 + modules/outconBidAdapter.js | 69 + modules/ozoneBidAdapter.js | 626 +- modules/padsquadBidAdapter.js | 8 +- modules/papyrusBidAdapter.js | 6 +- modules/parrableIdSystem.js | 96 + modules/peak226BidAdapter.js | 97 - modules/piximediaBidAdapter.js | 6 +- modules/platformioBidAdapter.js | 61 +- modules/platformioBidAdapter.md | 7 +- modules/playgroundxyzBidAdapter.md | 30 - modules/polluxBidAdapter.js | 120 - modules/polymorphBidAdapter.js | 131 - modules/prebidServerBidAdapter/config.js | 8 +- modules/prebidServerBidAdapter/index.js | 349 +- modules/prebidmanagerAnalyticsAdapter.js | 42 +- modules/priceFloors.js | 644 ++ modules/priceFloors.md | 62 + modules/projectLimeLightBidAdapter.js | 10 +- modules/proxistoreBidAdapter.js | 123 + modules/proxistoreBidAdapter.md | 73 + modules/pubCommonId.js | 123 +- modules/pubCommonIdSystem.js | 96 + modules/pubmaticAnalyticsAdapter.js | 443 ++ modules/pubmaticBidAdapter.js | 165 +- modules/pubmaticBidAdapter.md | 8 +- modules/pubnxBidAdapter.js | 86 - modules/pubwiseAnalyticsAdapter.js | 15 +- modules/pulsepointAnalyticsAdapter.js | 4 +- modules/pulsepointBidAdapter.js | 125 +- ...oundxyzBidAdapter.js => pxyzBidAdapter.js} | 49 +- modules/pxyzBidAdapter.md | 37 + modules/quantcastBidAdapter.js | 130 +- modules/quantcastBidAdapter.md | 10 +- modules/quantumBidAdapter.js | 14 +- modules/radsBidAdapter.js | 151 + modules/radsBidAdapter.md | 37 + modules/rdnBidAdapter.js | 81 - modules/readpeakBidAdapter.js | 202 +- modules/realvuAnalyticsAdapter.js | 21 +- modules/reklamstoreBidAdapter.js | 8 +- modules/relaidoBidAdapter.js | 303 + modules/relaidoBidAdapter.md | 48 + modules/reloadBidAdapter.js | 22 +- modules/resultsmediaBidAdapter.js | 269 + modules/resultsmediaBidAdapter.md | 47 + modules/revcontentBidAdapter.js | 293 + modules/revcontentBidAdapter.md | 68 + modules/rexrtbBidAdapter.js | 138 - modules/rhythmoneBidAdapter.js | 18 +- modules/richaudienceBidAdapter.js | 121 +- modules/rivrAnalyticsAdapter.js | 8 +- modules/rockyouBidAdapter.js | 370 - modules/roxotAnalyticsAdapter.js | 29 +- modules/rtbdemandBidAdapter.js | 8 +- modules/rtbdemandadkBidAdapter.js | 187 - modules/rtbhouseBidAdapter.js | 15 +- modules/rtbhouseBidAdapter.md | 6 +- modules/rtbsolutionsBidAdapter.js | 100 + modules/rtbsolutionsBidAdapter.md | 128 + modules/rtdModule/index.js | 220 + modules/rtdModule/provider.md | 27 + modules/rtdModule/realTimeData.md | 32 + modules/rubiconAnalyticsAdapter.js | 126 +- modules/rubiconBidAdapter.js | 325 +- modules/rubiconBidAdapter.md | 16 +- modules/s2sTesting.js | 4 +- modules/saraBidAdapter.js | 141 - modules/scaleableAnalyticsAdapter.js | 156 +- modules/schain.js | 206 +- modules/schain.md | 4 +- modules/seedingAllianceBidAdapter.js | 219 + modules/seedingAllianceBidAdapter.md | 45 + modules/seedtagBidAdapter.js | 6 +- modules/segmentoBidAdapter.js | 85 + modules/segmentoBidAdapter.md | 33 + modules/sekindoUMBidAdapter.js | 6 +- modules/serverbidBidAdapter.js | 234 - modules/serverbidServerBidAdapter.js | 233 - modules/shBidAdapter.js | 184 - modules/shBidAdapter.md | 69 - modules/sharethroughAnalyticsAdapter.js | 8 +- modules/sharethroughBidAdapter.js | 44 +- modules/showheroes-bsBidAdapter.js | 287 + modules/showheroes-bsBidAdapter.md | 127 + modules/sigmoidAnalyticsAdapter.js | 31 +- modules/sizeMappingV2.js | 546 ++ modules/slimcutBidAdapter.js | 10 +- modules/smartadserverBidAdapter.js | 113 +- modules/smartadserverBidAdapter.md | 109 +- modules/smartrtbBidAdapter.js | 60 +- modules/smartrtbBidAdapter.md | 19 +- modules/smartyadsBidAdapter.js | 43 +- modules/smartyadsBidAdapter.md | 63 +- modules/smilewantedBidAdapter.js | 10 +- modules/smmsBidAdapter.js | 156 + modules/smmsBidAdapter.md | 60 + modules/somoBidAdapter.js | 73 +- modules/somoBidAdapter.md | 14 +- modules/sonobiAnalyticsAdapter.js | 8 +- modules/sonobiBidAdapter.js | 90 +- modules/sortableAnalyticsAdapter.js | 12 +- modules/sortableBidAdapter.js | 262 +- modules/sortableBidAdapter.md | 59 +- modules/sovrnAnalyticsAdapter.js | 71 +- modules/sovrnBidAdapter.js | 159 +- modules/sovrnBidAdapter.md | 4 +- modules/spotxBidAdapter.js | 68 +- modules/spotxBidAdapter.md | 4 +- modules/staqAnalyticsAdapter.js | 121 +- modules/stvBidAdapter.js | 10 +- modules/sublimeBidAdapter.js | 5 +- modules/synacormediaBidAdapter.js | 20 +- modules/synacormediaBidAdapter.md | 8 +- modules/taphypeBidAdapter.js | 2 +- modules/teadsBidAdapter.js | 56 +- modules/telariaBidAdapter.js | 140 +- modules/theAdxBidAdapter.js | 13 +- modules/timBidAdapter.js | 8 +- modules/topRTBBidAdapter.js | 6 +- modules/tpmnBidAdapter.js | 119 + modules/tpmnBidAdapter.md | 37 + modules/trafficrootsBidAdapter.js | 129 - modules/tribeosBidAdapter.js | 165 + modules/tribeosBidAdapter.md | 31 + modules/trionBidAdapter.js | 89 +- modules/tripleliftBidAdapter.js | 117 +- modules/tripleliftBidAdapter.md | 2 +- modules/trustxBidAdapter.js | 41 +- modules/trustxBidAdapter.md | 6 +- ...BidAdapter.js => turktelekomBidAdapter.js} | 137 +- modules/turktelekomBidAdapter.md | 49 + modules/ucfunnelAnalyticsAdapter.js | 199 + modules/ucfunnelAnalyticsAdapter.md | 23 + modules/ucfunnelBidAdapter.js | 85 +- modules/underdogmediaBidAdapter.js | 61 +- modules/underdogmediaBidAdapter.md | 6 +- modules/undertoneBidAdapter.js | 72 +- modules/unicornBidAdapter.js | 147 + modules/unicornBidAdapter.md | 31 + modules/{userId => }/unifiedIdSystem.js | 22 +- modules/unrulyBidAdapter.js | 8 +- modules/uolBidAdapter.js | 192 - modules/userId/eids.js | 131 + modules/userId/eids.md | 90 + modules/userId/index.js | 269 +- modules/userId/pubCommonIdSystem.js | 42 - modules/userId/userId.md | 45 +- modules/userIdTargeting.js | 8 +- modules/valueimpressionBidAdapter.js | 152 + modules/valueimpressionBidAdapter.md | 56 + modules/vdoaiBidAdapter.js | 119 + modules/vdoaiBidAdapter.md | 34 + modules/vertozBidAdapter.js | 86 - modules/viBidAdapter.js | 11 +- modules/vidazooBidAdapter.js | 108 +- modules/vidazooBidAdapter.md | 2 +- modules/videoNowBidAdapter.js | 187 + modules/videoNowBidAdapter.md | 35 + modules/videoreachBidAdapter.js | 54 +- modules/videoreachBidAdapter.md | 15 +- ...aBidAdapter.js => viewdeosDXBidAdapter.js} | 109 +- modules/viewdeosDXBidAdapter.md | 64 + modules/visxBidAdapter.js | 119 +- modules/vmgBidAdapter.js | 2 +- modules/vrtcalBidAdapter.js | 88 + modules/vrtcalBidAdapter.md | 30 + modules/vubleAnalyticsAdapter.js | 258 - modules/vubleBidAdapter.js | 31 +- modules/widespaceBidAdapter.js | 58 +- ...aBidAdapter.js => windtalkerBidAdapter.js} | 57 +- modules/windtalkerBidAdapter.md | 86 + modules/wipesBidAdapter.js | 69 + modules/wipesBidAdapter.md | 33 + modules/xendizBidAdapter.js | 102 - modules/xhbBidAdapter.js | 16 +- modules/yieldbotBidAdapter.js | 604 -- modules/yieldlabBidAdapter.js | 35 +- modules/yieldliftBidAdapter.js | 144 + modules/yieldliftBidAdapter.md | 31 + modules/yieldmoBidAdapter.js | 142 +- modules/yieldmoBidAdapter.md | 7 +- modules/yieldnexusBidAdapter.js | 232 - modules/yieldoneAnalyticsAdapter.js | 177 + modules/yieldoneAnalyticsAdapter.md | 21 + modules/yieldoneBidAdapter.js | 68 +- modules/yuktamediaAnalyticsAdapter.js | 24 +- modules/zedoBidAdapter.js | 316 - package-lock.json | 6941 +++++++++++------ package.json | 26 +- plugins/eslint/validateImports.js | 8 + src/AnalyticsAdapter.js | 8 +- src/Renderer.js | 13 +- src/adServerManager.js | 4 +- src/adUnits.js | 74 +- src/adapterManager.js | 118 +- src/adapters/analytics/example.js | 2 +- src/adapters/analytics/example2.js | 5 +- src/adapters/analytics/libraries/example.js | 1 + src/adapters/analytics/libraries/example2.js | 1 + src/adapters/bidderFactory.js | 87 +- src/adloader.js | 126 +- src/adserver.js | 4 +- src/ajax.js | 9 +- src/auction.js | 247 +- src/auctionManager.js | 9 +- src/config.js | 168 +- src/constants.json | 7 +- src/cpmBucketManager.js | 22 +- src/debugging.js | 116 +- src/events.js | 8 +- src/hook.js | 2 +- src/native.js | 4 +- src/prebid.js | 210 +- src/prebidGlobal.js | 4 + src/refererDetection.js | 2 +- src/secureCreatives.js | 38 +- src/sizeMapping.js | 24 +- src/storageManager.js | 311 + src/targeting.js | 104 +- src/url.js | 55 - src/userSync.js | 60 +- src/utils.js | 414 +- src/video.js | 11 +- src/videoCache.js | 14 +- test/.eslintrc.js | 2 +- test/fixtures/fixtures.js | 452 +- .../request-response-pairs/banner/index.js | 96 + .../request-response-pairs/currency/index.js | 175 + .../request-response-pairs/gdpr/index.js | 94 + .../request-response-pairs/instream/index.js | 94 + .../ad_server_translation_request_1.js | 577 ++ .../ad_server_translation_request_2.js | 289 + .../basic_w_requireExactDuration_request_1.js | 606 ++ .../basic_w_requireExactDuration_request_2.js | 288 + ...sic_wo_brandCategoryExclusion_request_1.js | 852 ++ ...sic_wo_brandCategoryExclusion_request_2.js | 312 + ...basic_wo_requireExactDuration_request_1.js | 620 ++ ...basic_wo_requireExactDuration_request_2.js | 312 + .../longform/bidder_settings_request_1.js | 418 + .../longform/bidder_settings_request_2.js | 284 + .../longform/price_gran_request_1.js | 620 ++ .../longform/price_gran_request_2.js | 283 + .../multiple-bidders/index-1.js | 110 + .../multiple-bidders/index-2.js | 175 + .../request-response-pairs/native/index.js | 191 + .../request-response-pairs/outstream/index.js | 162 + test/mock-server/index.js | 37 + .../request-middlewares/prebid-request.js | 75 + test/mocks/adloaderStub.js | 32 +- test/mocks/videoCacheStub.js | 2 +- test/mocks/xhr.js | 9 + test/pages/banner.html | 42 +- test/pages/bidderSettings.html | 125 + test/pages/consent_mgt_gdpr.html | 206 + test/pages/currency.html | 129 + test/pages/{video.html => instream.html} | 10 +- test/pages/multiple_bidders.html | 174 + test/pages/native.html | 2 +- test/pages/outstream.html | 2 +- test/pages/priceGranularity.html | 131 + test/pages/sizeConfig.html | 142 + test/pages/userSync.html | 121 + test/spec/AnalyticsAdapter_spec.js | 37 +- test/spec/adapters/adbutler_spec.js | 0 test/spec/adloader_spec.js | 15 +- test/spec/aliasBidder_spec.js | 2 +- test/spec/api_spec.js | 4 + test/spec/auctionmanager_spec.js | 207 +- test/spec/config_spec.js | 43 +- test/spec/cpmBucketManager_spec.js | 18 +- test/spec/debugging_spec.js | 63 +- test/spec/e2e/banner/basic_banner_ad.spec.js | 41 +- .../instream/basic_instream_video_ad.spec.js | 52 + .../longform/basic_w_bidderSettings.spec.js | 68 + .../e2e/longform/basic_w_priceGran.spec.js | 68 + .../e2e/modules/e2e_bidderSettings.spec.js | 59 + .../e2e/modules/e2e_consent_mgt_gdpr.spec.js | 59 + test/spec/e2e/modules/e2e_currency.spec.js | 59 + .../e2e/modules/e2e_priceGranularity.spec.js | 59 + test/spec/e2e/modules/e2e_sizeConfig.spec.js | 59 + test/spec/e2e/modules/e2e_userSync.spec.js | 59 + .../multi-format/e2e_multiple_bidders.spec.js | 68 + test/spec/e2e/native/basic_native_ad.spec.js | 2 +- test/spec/integration/faker/fixtures.js | 2 +- test/spec/integration/faker/googletag.js | 2 +- test/spec/modules/1ad4goodBidAdapter_spec.js | 548 ++ test/spec/modules/33acrossBidAdapter_spec.js | 77 +- test/spec/modules/7xbidBidAdapter_spec.js | 160 + test/spec/modules/a4gBidAdapter_spec.js | 149 - test/spec/modules/aardvarkBidAdapter_spec.js | 175 +- test/spec/modules/ablidaBidAdapter_spec.js | 102 + .../modules/adagioAnalyticsAdapter_spec.js | 183 + test/spec/modules/adagioBidAdapter_spec.js | 601 +- test/spec/modules/adbutlerBidAdapter_spec.js | 72 +- ...ter_spec.js => adfinityBidAdapter_spec.js} | 62 +- test/spec/modules/adformBidAdapter_spec.js | 21 +- .../modules/adformOpenRTBBidAdapter_spec.js | 9 +- .../modules/adgenerationBidAdapter_spec.js | 20 +- test/spec/modules/adglareBidAdapter_spec.js | 138 + test/spec/modules/adheseBidAdapter_spec.js | 35 +- ...r_spec.js => adkernelAdnAnalytics_spec.js} | 4 +- .../modules/adkernelAdnBidAdapter_spec.js | 19 +- test/spec/modules/adkernelBidAdapter_spec.js | 185 +- test/spec/modules/adliveBidAdapter_spec.js | 2 +- test/spec/modules/admanBidAdapter_spec.js | 404 +- test/spec/modules/admediaBidAdapter_spec.js | 6 +- test/spec/modules/admixerBidAdapter_spec.js | 19 +- test/spec/modules/adnuntiusBidAdapter_spec.js | 119 + test/spec/modules/adoceanBidAdapter_spec.js | 6 +- .../modules/adomikAnalyticsAdapter_spec.js | 11 +- test/spec/modules/adotBidAdapter_spec.js | 3118 ++++++++ test/spec/modules/adpod_spec.js | 118 +- test/spec/modules/adponeBidAdapter_spec.js | 137 +- test/spec/modules/adspiritBidAdapter_spec.js | 142 - .../modules/adtelligentBidAdapter_spec.js | 49 +- test/spec/modules/aduptechBidAdapter_spec.js | 641 +- .../modules/advangelistsBidAdapter_spec.js | 4 +- test/spec/modules/advenueBidAdapter_spec.js | 4 +- test/spec/modules/advertlyBidAdapter_spec.js | 159 + .../modules/adxcgAnalyticsAdapter_spec.js | 18 +- test/spec/modules/adxcgBidAdapter_spec.js | 830 +- test/spec/modules/adyoulikeBidAdapter_spec.js | 114 +- test/spec/modules/ajaBidAdapter_spec.js | 14 +- test/spec/modules/andbeyondBidAdapter_spec.js | 208 - test/spec/modules/aniviewBidAdapter_spec.js | 4 +- test/spec/modules/aolBidAdapter_spec.js | 184 +- .../modules/appierAnalyticsAdapter_spec.js | 6 +- test/spec/modules/appierBidAdapter_spec.js | 6 +- test/spec/modules/appnexusBidAdapter_spec.js | 260 +- test/spec/modules/arteebeeBidAdapter_spec.js | 156 - test/spec/modules/astraoneBidAdapter_spec.js | 210 + test/spec/modules/atomxBidAdapter_spec.js | 6 +- test/spec/modules/atsAnalyticsAdapter_spec.js | 150 + .../modules/audienceNetworkBidAdapter_spec.js | 86 +- .../modules/audiencerunBidAdapter_spec.js | 204 + test/spec/modules/automatadBidAdapter_spec.js | 144 + .../spec/modules/beachfrontBidAdapter_spec.js | 79 +- test/spec/modules/betweenBidAdapter_spec.js | 157 +- .../spec/modules/bidfluenceBidAdapter_spec.js | 228 +- test/spec/modules/bidglassAdapter_spec.js | 4 +- test/spec/modules/bidlabBidAdapter_spec.js | 235 + .../spec/modules/bidphysicsBidAdapter_spec.js | 6 +- test/spec/modules/bizzclickBidAdapter_spec.js | 117 - test/spec/modules/brainyBidAdapter_spec.js | 128 - .../spec/modules/bridgewellBidAdapter_spec.js | 1873 ++--- test/spec/modules/brightcomBidAdapter_spec.js | 30 +- test/spec/modules/britepoolIdSystem_spec.js | 67 + test/spec/modules/bucksenseBidAdapter_spec.js | 10 +- test/spec/modules/buzzoolaBidAdapter_spec.js | 8 +- test/spec/modules/byplayBidAdapter_spec.js | 93 + test/spec/modules/c1xBidAdapter_spec.js | 8 +- test/spec/modules/categoryTranslation_spec.js | 8 +- test/spec/modules/ccxBidAdapter_spec.js | 29 +- test/spec/modules/cedatoBidAdapter_spec.js | 62 +- .../modules/cleanmedianetBidAdapter_spec.js | 50 +- .../spec/modules/clickforceBidAdapter_spec.js | 8 +- .../spec/modules/clicktripzBidAdapter_spec.js | 152 + test/spec/modules/coinzillaBidAdapter_spec.js | 8 +- .../modules/collectcentBidAdapter_spec.js | 6 +- test/spec/modules/colombiaBidAdapter_spec.js | 152 - .../modules/colossussspBidAdapter_spec.js | 53 +- test/spec/modules/connectadBidAdapter_spec.js | 453 ++ .../spec/modules/consentManagementUsp_spec.js | 361 + test/spec/modules/consentManagement_spec.js | 918 +-- .../spec/modules/consumableBidAdapter_spec.js | 218 +- .../modules/contentigniteBidAdapter_spec.js | 186 - test/spec/modules/convergeBidAdapter_spec.js | 899 +++ .../spec/modules/conversantBidAdapter_spec.js | 233 +- test/spec/modules/cosmosBidAdapter_spec.js | 8 +- test/spec/modules/cpmstarBidAdapter_spec.js | 10 +- test/spec/modules/criteoBidAdapter_spec.js | 342 +- test/spec/modules/criteoIdSystem_spec.js | 156 + test/spec/modules/criteortusIdSystem_spec.js | 88 - test/spec/modules/currency_spec.js | 44 +- test/spec/modules/dailyhuntBidAdapter_spec.js | 289 + test/spec/modules/danmarketBidAdapter_spec.js | 309 - .../spec/modules/datablocksBidAdapter_spec.js | 69 +- .../modules/decenteradsBidAdapter_spec.js | 207 - .../spec/modules/deepintentBidAdapter_spec.js | 193 + test/spec/modules/dfpAdServerVideo_spec.js | 73 +- test/spec/modules/dgadsBidAdapter_spec.js | 299 - test/spec/modules/digitrustIdSystem_spec.js | 85 +- .../modules/districtmDmxBidAdapter_spec.js | 132 +- test/spec/modules/djaxBidAdapter_spec.js | 159 + test/spec/modules/dspxBidAdapter_spec.js | 33 +- .../spec/modules/e_volutionBidAdapter_spec.js | 235 + test/spec/modules/ebdrBidAdapter_spec.js | 16 +- test/spec/modules/eids_spec.js | 181 + test/spec/modules/emoteevBidAdapter_spec.js | 100 +- .../modules/emx_digitalBidAdapter_spec.js | 69 +- test/spec/modules/envivoBidAdapter_spec.js | 159 + .../modules/eplanningAnalyticsAdapter_spec.js | 18 +- test/spec/modules/eplanningBidAdapter_spec.js | 496 +- test/spec/modules/etargetBidAdapter_spec.js | 7 +- test/spec/modules/eywamediaBidAdapter_spec.js | 253 - test/spec/modules/fairtradeBidAdapter_spec.js | 289 - test/spec/modules/feedadBidAdapter_spec.js | 27 +- test/spec/modules/fidelityBidAdapter_spec.js | 49 +- .../modules/fintezaAnalyticsAdapter_spec.js | 63 +- test/spec/modules/fluctBidAdapter_spec.js | 201 + .../modules/freeWheelAdserverVideo_spec.js | 106 +- .../modules/freewheel-sspBidAdapter_spec.js | 737 +- test/spec/modules/fyberBidAdapter_spec.js | 154 - test/spec/modules/gammaBidAdapter_spec.js | 25 +- test/spec/modules/gamoshiBidAdapter_spec.js | 552 +- test/spec/modules/gdprEnforcement_spec.js | 418 + test/spec/modules/getintentBidAdapter_spec.js | 10 +- test/spec/modules/giantsBidAdapter_spec.js | 301 - test/spec/modules/gjirafaBidAdapter_spec.js | 172 - .../modules/googleAnalyticsAdapter_spec.js | 20 +- test/spec/modules/gridBidAdapter_spec.js | 111 +- test/spec/modules/gridNMBidAdapter_spec.js | 461 ++ test/spec/modules/gumgumBidAdapter_spec.js | 134 +- test/spec/modules/gxoneBidAdapter_spec.js | 293 - .../modules/hpmdnetworkBidAdapter_spec.js | 12 +- test/spec/modules/hybridBidAdapter_spec.js | 275 + test/spec/modules/iasBidAdapter_spec.js | 4 +- test/spec/modules/imonomyBidAdapter_spec.js | 8 +- .../modules/improvedigitalBidAdapter_spec.js | 192 +- test/spec/modules/innityBidAdapter_spec.js | 34 +- test/spec/modules/inskinBidAdapter_spec.js | 35 +- .../interactiveOffersBidAdapter_spec.js | 177 - test/spec/modules/invibesBidAdapter_spec.js | 59 +- .../modules/invisiblyAnalyticsAdapter_spec.js | 491 ++ test/spec/modules/iqmBidAdapter_spec.js | 219 - test/spec/modules/ixBidAdapter_spec.js | 542 +- test/spec/modules/jcmBidAdapter_spec.js | 10 +- .../modules/justpremiumBidAdapter_spec.js | 48 +- test/spec/modules/kargoBidAdapter_spec.js | 33 +- test/spec/modules/komoonaBidAdapter_spec.js | 8 +- test/spec/modules/konduitWrapper_spec.js | 6 +- test/spec/modules/lemmaBidAdapter_spec.js | 335 + .../spec/modules/lifestreetBidAdapter_spec.js | 426 +- test/spec/modules/liveIntentIdSystem_spec.js | 221 + .../livewrappedAnalyticsAdapter_spec.js | 77 +- .../modules/livewrappedBidAdapter_spec.js | 446 +- .../modules/liveyieldAnalyticsAdapter_spec.js | 2 +- test/spec/modules/lkqdBidAdapter_spec.js | 134 +- .../spec/modules/lockerdomeBidAdapter_spec.js | 106 +- test/spec/modules/logicadBidAdapter_spec.js | 6 +- test/spec/modules/loopmeBidAdapter_spec.js | 4 +- .../spec/modules/madvertiseBidAdapter_spec.js | 10 +- test/spec/modules/mantisBidAdapter_spec.js | 8 +- test/spec/modules/marsmediaBidAdapter_spec.js | 703 +- test/spec/modules/meazyBidAdapter_spec.js | 14 +- .../spec/modules/mediaforceBidAdapter_spec.js | 240 + .../modules/medianetAnalyticsAdapter_spec.js | 185 + test/spec/modules/medianetBidAdapter_spec.js | 608 +- test/spec/modules/mgidBidAdapter_spec.js | 47 +- test/spec/modules/microadBidAdapter_spec.js | 21 +- test/spec/modules/mobfoxBidAdapter_spec.js | 4 +- test/spec/modules/mobsmartBidAdapter_spec.js | 214 + test/spec/modules/my6senseBidAdapter_spec.js | 2 +- test/spec/modules/mytargetBidAdapter_spec.js | 34 +- .../spec/modules/nafdigitalBidAdapter_spec.js | 6 +- .../modules/nanointeractiveBidAdapter_spec.js | 8 +- .../modules/nasmediaAdmixerBidAdapter_spec.js | 23 +- .../modules/newborntownWebBidAdapter_spec.js | 152 + .../modules/nextMillenniumBidAdapter_spec.js | 2 +- test/spec/modules/nextrollBidAdapter_spec.js | 183 + test/spec/modules/nobidBidAdapter_spec.js | 197 +- test/spec/modules/oneVideoBidAdapter_spec.js | 266 +- .../modules/oneplanetonlyBidAdapter_spec.js | 100 - test/spec/modules/onetagBidAdapter_spec.js | 282 +- test/spec/modules/open8BidAdapter_spec.js | 26 +- .../modules/openxAnalyticsAdapter_spec.js | 49 +- test/spec/modules/openxBidAdapter_spec.js | 645 +- .../modules/openxoutstreamBidAdapter_spec.js | 243 - test/spec/modules/optimaticBidAdapter_spec.js | 178 - test/spec/modules/optimeraBidAdapter_spec.js | 4 +- test/spec/modules/orbidderBidAdapter_spec.js | 30 +- test/spec/modules/orbitsoftBidAdapter_spec.js | 248 - test/spec/modules/otmBidAdapter_spec.js | 2 +- test/spec/modules/outconBidAdapter_spec.js | 100 + test/spec/modules/ozoneBidAdapter_spec.js | 625 +- test/spec/modules/padsquadBidAdapter_spec.js | 6 +- test/spec/modules/papyrusBidAdapter_spec.js | 4 +- test/spec/modules/parrableIdSystem_spec.js | 80 + test/spec/modules/peak226BidAdapter_spec.js | 114 - test/spec/modules/piximediaBidAdapter_spec.js | 2 +- .../spec/modules/platformioBidAdapter_spec.js | 53 +- test/spec/modules/polluxBidAdapter_spec.js | 207 - test/spec/modules/polymorphBidAdapter_spec.js | 219 - .../modules/prebidServerBidAdapter_spec.js | 844 +- .../prebidmanagerAnalyticsAdapter_spec.js | 59 +- test/spec/modules/priceFloorsSchema.json | 86 + test/spec/modules/priceFloors_spec.js | 972 +++ .../projectLimeLightBidAdapter_spec.js | 4 +- .../spec/modules/proxistoreBidAdapter_spec.js | 109 + test/spec/modules/pubCommonId_spec.js | 48 +- .../modules/pubmaticAnalyticsAdapter_spec.js | 556 ++ test/spec/modules/pubmaticBidAdapter_spec.js | 702 +- test/spec/modules/pubnxBidAdapter_spec.js | 112 - .../modules/pubwiseAnalyticsAdapter_spec.js | 9 +- .../spec/modules/pulsepointBidAdapter_spec.js | 259 +- ...Adapter_spec.js => pxyzBidAdapter_spec.js} | 138 +- test/spec/modules/quantcastBidAdapter_spec.js | 457 +- test/spec/modules/quantumBidAdapter_spec.js | 36 +- test/spec/modules/radsBidAdapter_spec.js | 206 + test/spec/modules/rdnBidAdapter_spec.js | 156 - test/spec/modules/readpeakBidAdapter_spec.js | 242 +- test/spec/modules/realTimeModule_spec.js | 245 + .../modules/realvuAnalyticsAdapter_spec.js | 13 +- .../modules/reklamstoreBidAdapter_spec.js | 12 +- test/spec/modules/relaidoBidAdapter_spec.js | 323 + test/spec/modules/reloadBidAdapter_spec.js | 2 +- .../modules/resultsmediaBidAdapter_spec.js | 574 ++ .../spec/modules/revcontentBidAdapter_spec.js | 330 + test/spec/modules/rexrtbBidAdapter_spec.js | 107 - test/spec/modules/rhythmoneBidAdapter_spec.js | 56 +- .../modules/richaudienceBidAdapter_spec.js | 359 +- .../spec/modules/rivrAnalyticsAdapter_spec.js | 10 +- test/spec/modules/rockyouBidAdapter_spec.js | 494 -- .../modules/roxotAnalyticsAdapter_spec.js | 53 +- test/spec/modules/rtbdemandBidAdapter_spec.js | 8 +- .../modules/rtbdemandadkBidAdapter_spec.js | 268 - test/spec/modules/rtbhouseBidAdapter_spec.js | 39 +- .../modules/rtbsolutionsBidAdapter_spec.js | 62 + .../modules/rubiconAnalyticsAdapter_spec.js | 265 +- test/spec/modules/rubiconAnalyticsSchema.json | 3 +- test/spec/modules/rubiconBidAdapter_spec.js | 784 +- test/spec/modules/s2sTesting_spec.js | 4 +- test/spec/modules/saraBidAdapter_spec.js | 293 - .../modules/scaleableAnalyticsAdapter_spec.js | 133 +- test/spec/modules/schain_spec.js | 280 +- .../modules/seedingAllianceAdapter_spec.js | 186 + test/spec/modules/seedtagBidAdapter_spec.js | 2 +- test/spec/modules/segmentoBidAdapter_spec.js | 187 + test/spec/modules/sekindoUMBidAdapter_spec.js | 8 +- test/spec/modules/serverbidBidAdapter_spec.js | 253 - .../modules/serverbidServerBidAdapter_spec.js | 303 - test/spec/modules/shBidAdapter_spec.js | 187 - test/spec/modules/shareUserIds_spec.js | 12 +- .../modules/sharethroughBidAdapter_spec.js | 104 +- .../modules/showheroes-bsBidAdapter_spec.js | 448 ++ .../modules/sigmoidAnalyticsAdapter_spec.js | 7 +- test/spec/modules/sizeMappingV2_spec.js | 1669 ++++ test/spec/modules/slimcutBidAdapter_spec.js | 14 +- .../modules/smartadserverBidAdapter_spec.js | 357 +- test/spec/modules/smartrtbBidAdapter_spec.js | 116 +- test/spec/modules/smartyadsBidAdapter_spec.js | 37 +- .../modules/smilewantedBidAdapter_spec.js | 14 +- test/spec/modules/smmsBidAdapter_spec.js | 161 + test/spec/modules/somoBidAdapter_spec.js | 128 +- .../modules/sonobiAnalyticsAdapter_spec.js | 13 +- test/spec/modules/sonobiBidAdapter_spec.js | 425 +- .../modules/sortableAnalyticsAdapter_spec.js | 36 +- test/spec/modules/sortableBidAdapter_spec.js | 293 +- .../modules/sovrnAnalyticsAdapter_spec.js | 23 +- test/spec/modules/sovrnBidAdapter_spec.js | 400 +- test/spec/modules/spotxBidAdapter_spec.js | 107 +- .../spec/modules/staqAnalyticsAdapter_spec.js | 79 +- test/spec/modules/stvBidAdapter_spec.js | 4 +- test/spec/modules/sublimeBidAdapter_spec.js | 4 +- test/spec/modules/supply2BidAdapter_spec.js | 332 - .../modules/synacormediaBidAdapter_spec.js | 137 +- test/spec/modules/taphypeBidAdapter_spec.js | 2 +- test/spec/modules/teadsBidAdapter_spec.js | 164 +- test/spec/modules/telariaBidAdapter_spec.js | 119 +- test/spec/modules/theAdxBidAdapter_spec.js | 18 +- test/spec/modules/timBidAdapter_spec.js | 6 +- test/spec/modules/topRTBBidAdapter_spec.js | 4 +- test/spec/modules/tpmnBidAdapter_spec.js | 144 + .../modules/trafficrootsBidAdapter_spec.js | 149 - test/spec/modules/tribeosBidAdapter_spec.js | 86 + test/spec/modules/trionBidAdapter_spec.js | 192 +- .../spec/modules/tripleliftBidAdapter_spec.js | 302 +- test/spec/modules/trustxBidAdapter_spec.js | 67 +- .../modules/turktelekomBidAdapter_spec.js | 749 ++ .../modules/ucfunnelAnalyticsAdapter_spec.js | 487 ++ test/spec/modules/ucfunnelBidAdapter_spec.js | 88 +- .../modules/underdogmediaBidAdapter_spec.js | 140 +- test/spec/modules/undertoneBidAdapter_spec.js | 178 +- test/spec/modules/unicornBidAdapter_spec.js | 463 ++ test/spec/modules/unrulyBidAdapter_spec.js | 14 +- test/spec/modules/uolBidAdapter_spec.js | 308 - test/spec/modules/userId_spec.js | 909 ++- .../modules/valueimpressionBidAdapter_spec.js | 602 ++ test/spec/modules/vdoaiBidAdapter_spec.js | 105 + .../spec/modules/vertamediaBidAdapter_spec.js | 218 - test/spec/modules/vertozBidAdapter_spec.js | 112 - test/spec/modules/viBidAdapter_spec.js | 21 +- test/spec/modules/vidazooBidAdapter_spec.js | 86 +- test/spec/modules/videoNowBidAdapter_spec.js | 599 ++ .../spec/modules/videoreachBidAdapter_spec.js | 8 +- .../spec/modules/viewdeosDXBidAdapter_spec.js | 336 + test/spec/modules/visxBidAdapter_spec.js | 104 +- test/spec/modules/vmgBidAdapter_spec.js | 4 +- test/spec/modules/vrtcalBidAdapter_spec.js | 135 + .../modules/vubleAnalyticsAdapter_spec.js | 122 - test/spec/modules/vubleBidAdapter_spec.js | 171 +- test/spec/modules/weboramaBidAdapter_spec.js | 118 - test/spec/modules/widespaceBidAdapter_spec.js | 40 +- ...r_spec.js => windtalkerBidAdapter_spec.js} | 67 +- test/spec/modules/wipesBidAdapter_spec.js | 148 + test/spec/modules/xendizBidAdapter_spec.js | 119 - test/spec/modules/xhbBidAdapter_spec.js | 22 +- test/spec/modules/yieldbotBidAdapter_spec.js | 1383 ---- test/spec/modules/yieldlabBidAdapter_spec.js | 28 +- test/spec/modules/yieldliftBidAdapter_spec.js | 257 + test/spec/modules/yieldmoBidAdapter_spec.js | 213 +- .../spec/modules/yieldnexusBidAdapter_spec.js | 418 - .../modules/yieldoneAnalyticsAdapter_spec.js | 288 + test/spec/modules/yieldoneBidAdapter_spec.js | 17 +- .../yuktamediaAnalyticsAdaptor_spec.js | 847 +- test/spec/modules/zedoBidAdapter_spec.js | 354 - test/spec/native_spec.js | 2 +- test/spec/refererDetection_spec.js | 2 +- test/spec/renderer_spec.js | 22 +- test/spec/sizeMapping_spec.js | 4 +- test/spec/unit/adServerManager_spec.js | 4 +- test/spec/unit/adUnits_spec.js | 50 +- test/spec/unit/core/adapterManager_spec.js | 303 +- test/spec/unit/core/bidderFactory_spec.js | 129 +- test/spec/unit/core/storageManager_spec.js | 46 + test/spec/unit/core/targeting_spec.js | 243 +- test/spec/unit/pbjs_api_spec.js | 471 +- test/spec/unit/secureCreatives_spec.js | 4 +- test/spec/url_spec.js | 94 - test/spec/userSync_spec.js | 167 +- test/spec/utils_spec.js | 350 +- test/spec/videoCache_spec.js | 93 +- test/spec/video_spec.js | 2 +- test/test_index.js | 1 + wdio.conf.js | 8 +- 927 files changed, 89790 insertions(+), 35376 deletions(-) create mode 100644 integrationExamples/gpt/audigentSegments_example.html create mode 100644 integrationExamples/gpt/cmp_files/purposes.json create mode 100644 integrationExamples/gpt/digitrust_cmp_test.html mode change 100644 => 100755 integrationExamples/gpt/hello_world.html create mode 100644 integrationExamples/gpt/proxistore_example.html create mode 100644 integrationExamples/gpt/responsiveAds_sizeMappingV2.html create mode 100644 integrationExamples/gpt/revcontent_example.html create mode 100644 integrationExamples/longform/basic_w_bidderSettings.html create mode 100644 integrationExamples/longform/basic_w_priceGran.html create mode 100644 modules/1ad4goodBidAdapter.js create mode 100644 modules/1ad4goodBidAdapter.md create mode 100644 modules/7xbidBidAdapter.js create mode 100644 modules/7xbidBidAdapter.md delete mode 100644 modules/a4gBidAdapter.js create mode 100644 modules/ablidaBidAdapter.js create mode 100644 modules/ablidaBidAdapter.md rename modules/{weboramaBidAdapter.js => adfinityBidAdapter.js} (57%) create mode 100644 modules/adfinityBidAdapter.md create mode 100644 modules/adglareBidAdapter.js create mode 100644 modules/adglareBidAdapter.md create mode 100644 modules/adnuntiusBidAdapter.js create mode 100644 modules/adnuntiusBidAdapter.md create mode 100644 modules/adotBidAdapter.js create mode 100644 modules/adotBidAdapter.md delete mode 100644 modules/adspiritBidAdapter.js create mode 100755 modules/advertlyBidAdapter.js create mode 100755 modules/advertlyBidAdapter.md create mode 100644 modules/adxpremiumAnalyticsAdapter.js create mode 100644 modules/adxpremiumAnalyticsAdapter.md delete mode 100644 modules/andbeyondBidAdapter.js delete mode 100644 modules/arteebeeBidAdapter.js create mode 100644 modules/astraoneBidAdapter.js create mode 100644 modules/astraoneBidAdapter.md create mode 100644 modules/atsAnalyticsAdapter.js create mode 100644 modules/atsAnalyticsAdapter.md create mode 100644 modules/audiencerunBidAdapter.js create mode 100644 modules/audiencerunBidAdapter.md create mode 100644 modules/audigentRtdProvider.js create mode 100644 modules/audigentRtdProvider.md create mode 100644 modules/automatadBidAdapter.js create mode 100644 modules/automatadBidAdapter.md create mode 100644 modules/bidlabBidAdapter.js create mode 100644 modules/bidlabBidAdapter.md delete mode 100644 modules/bizzclickBidAdapter.js delete mode 100644 modules/brainyBidAdapter.js create mode 100644 modules/britepoolIdSystem.js create mode 100644 modules/britepoolIdSystem.md create mode 100644 modules/browsiRtdProvider.js create mode 100644 modules/byplayBidAdapter.js create mode 100644 modules/byplayBidAdapter.md create mode 100644 modules/clicktripzBidAdapter.js create mode 100644 modules/clicktripzBidAdapter.md delete mode 100644 modules/colombiaBidAdapter.js create mode 100644 modules/connectadBidAdapter.js create mode 100644 modules/connectadBidAdapter.md create mode 100644 modules/consentManagementUsp.js delete mode 100644 modules/contentigniteBidAdapter.js create mode 100644 modules/convergeBidAdapter.js create mode 100644 modules/convergeBidAdapter.md create mode 100644 modules/criteoIdSystem.js delete mode 100644 modules/criteortusIdSystem.js create mode 100644 modules/dailyhuntBidAdapter.js create mode 100644 modules/dailyhuntBidAdapter.md delete mode 100644 modules/danmarketBidAdapter.js delete mode 100644 modules/decenteradsBidAdapter.js create mode 100644 modules/deepintentBidAdapter.js create mode 100644 modules/deepintentBidAdapter.md delete mode 100644 modules/dgadsBidAdapter.js create mode 100644 modules/djaxBidAdapter.js create mode 100644 modules/djaxBidAdapter.md create mode 100644 modules/e_volutionBidAdapter.js create mode 100644 modules/e_volutionBidAdapter.md create mode 100644 modules/envivoBidAdapter.js create mode 100644 modules/envivoBidAdapter.md delete mode 100644 modules/eywamediaBidAdapter.js delete mode 100644 modules/fairtradeBidAdapter.js create mode 100644 modules/fluctBidAdapter.js create mode 100644 modules/fluctBidAdapter.md delete mode 100644 modules/fyberBidAdapter.js create mode 100644 modules/gdprEnforcement.js delete mode 100644 modules/giantsBidAdapter.js delete mode 100644 modules/gjirafaBidAdapter.js create mode 100644 modules/googleAnalyticsAdapter.md create mode 100644 modules/gridNMBidAdapter.js create mode 100644 modules/gridNMBidAdapter.md delete mode 100644 modules/gxoneBidAdapter.js delete mode 100644 modules/huddledmassesBidAdapter.js create mode 100644 modules/hybridBidAdapter.js create mode 100644 modules/hybridBidAdapter.md delete mode 100644 modules/interactiveOffersBidAdapter.js create mode 100644 modules/invisiblyAnalyticsAdapter.js create mode 100644 modules/invisiblyAnalyticsAdapter.md delete mode 100644 modules/iqmBidAdapter.js create mode 100644 modules/lemmaBidAdapter.js create mode 100644 modules/lemmaBidAdapter.md create mode 100644 modules/liveIntentIdSystem.js create mode 100644 modules/mediaforceBidAdapter.js create mode 100644 modules/mediaforceBidAdapter.md create mode 100644 modules/medianetAnalyticsAdapter.js create mode 100644 modules/medianetAnalyticsAdapter.md create mode 100644 modules/mobsmartBidAdapter.js create mode 100644 modules/mobsmartBidAdapter.md create mode 100644 modules/netIdSystem.js create mode 100644 modules/newborntownWebBidAdapter.js create mode 100644 modules/newborntownWebBidAdapter.md create mode 100644 modules/nextrollBidAdapter.js create mode 100644 modules/nextrollBidAdapter.md delete mode 100644 modules/oneplanetonlyBidAdapter.js create mode 100644 modules/openxAnalyticsAdapter.md delete mode 100644 modules/openxoutstreamBidAdapter.js delete mode 100644 modules/openxoutstreamBidAdapter.md delete mode 100644 modules/optimaticBidAdapter.js delete mode 100644 modules/orbitsoftBidAdapter.js create mode 100644 modules/outconAdapter.md create mode 100644 modules/outconBidAdapter.js create mode 100644 modules/parrableIdSystem.js delete mode 100644 modules/peak226BidAdapter.js delete mode 100644 modules/playgroundxyzBidAdapter.md delete mode 100644 modules/polluxBidAdapter.js delete mode 100644 modules/polymorphBidAdapter.js create mode 100644 modules/priceFloors.js create mode 100644 modules/priceFloors.md create mode 100644 modules/proxistoreBidAdapter.js create mode 100644 modules/proxistoreBidAdapter.md create mode 100644 modules/pubCommonIdSystem.js create mode 100755 modules/pubmaticAnalyticsAdapter.js delete mode 100644 modules/pubnxBidAdapter.js rename modules/{playgroundxyzBidAdapter.js => pxyzBidAdapter.js} (75%) create mode 100644 modules/pxyzBidAdapter.md create mode 100644 modules/radsBidAdapter.js create mode 100644 modules/radsBidAdapter.md delete mode 100644 modules/rdnBidAdapter.js create mode 100644 modules/relaidoBidAdapter.js create mode 100644 modules/relaidoBidAdapter.md create mode 100644 modules/resultsmediaBidAdapter.js create mode 100644 modules/resultsmediaBidAdapter.md create mode 100644 modules/revcontentBidAdapter.js create mode 100644 modules/revcontentBidAdapter.md delete mode 100644 modules/rexrtbBidAdapter.js mode change 100644 => 100755 modules/richaudienceBidAdapter.js delete mode 100644 modules/rockyouBidAdapter.js delete mode 100644 modules/rtbdemandadkBidAdapter.js create mode 100644 modules/rtbsolutionsBidAdapter.js create mode 100644 modules/rtbsolutionsBidAdapter.md create mode 100644 modules/rtdModule/index.js create mode 100644 modules/rtdModule/provider.md create mode 100644 modules/rtdModule/realTimeData.md delete mode 100644 modules/saraBidAdapter.js create mode 100755 modules/seedingAllianceBidAdapter.js create mode 100755 modules/seedingAllianceBidAdapter.md create mode 100644 modules/segmentoBidAdapter.js create mode 100644 modules/segmentoBidAdapter.md delete mode 100644 modules/serverbidBidAdapter.js delete mode 100644 modules/serverbidServerBidAdapter.js delete mode 100644 modules/shBidAdapter.js delete mode 100644 modules/shBidAdapter.md create mode 100644 modules/showheroes-bsBidAdapter.js create mode 100644 modules/showheroes-bsBidAdapter.md create mode 100644 modules/sizeMappingV2.js create mode 100644 modules/smmsBidAdapter.js create mode 100644 modules/smmsBidAdapter.md create mode 100644 modules/tpmnBidAdapter.js create mode 100644 modules/tpmnBidAdapter.md delete mode 100644 modules/trafficrootsBidAdapter.js create mode 100644 modules/tribeosBidAdapter.js create mode 100644 modules/tribeosBidAdapter.md rename modules/{supply2BidAdapter.js => turktelekomBidAdapter.js} (54%) create mode 100644 modules/turktelekomBidAdapter.md create mode 100644 modules/ucfunnelAnalyticsAdapter.js create mode 100644 modules/ucfunnelAnalyticsAdapter.md create mode 100644 modules/unicornBidAdapter.js create mode 100644 modules/unicornBidAdapter.md rename modules/{userId => }/unifiedIdSystem.js (72%) delete mode 100644 modules/uolBidAdapter.js create mode 100644 modules/userId/eids.js create mode 100644 modules/userId/eids.md delete mode 100644 modules/userId/pubCommonIdSystem.js create mode 100644 modules/valueimpressionBidAdapter.js create mode 100644 modules/valueimpressionBidAdapter.md create mode 100644 modules/vdoaiBidAdapter.js create mode 100644 modules/vdoaiBidAdapter.md delete mode 100644 modules/vertozBidAdapter.js create mode 100644 modules/videoNowBidAdapter.js create mode 100644 modules/videoNowBidAdapter.md rename modules/{vertamediaBidAdapter.js => viewdeosDXBidAdapter.js} (53%) create mode 100644 modules/viewdeosDXBidAdapter.md create mode 100644 modules/vrtcalBidAdapter.js create mode 100644 modules/vrtcalBidAdapter.md delete mode 100644 modules/vubleAnalyticsAdapter.js rename modules/{kummaBidAdapter.js => windtalkerBidAdapter.js} (89%) create mode 100644 modules/windtalkerBidAdapter.md create mode 100644 modules/wipesBidAdapter.js create mode 100644 modules/wipesBidAdapter.md delete mode 100644 modules/xendizBidAdapter.js delete mode 100644 modules/yieldbotBidAdapter.js create mode 100644 modules/yieldliftBidAdapter.js create mode 100644 modules/yieldliftBidAdapter.md delete mode 100644 modules/yieldnexusBidAdapter.js create mode 100644 modules/yieldoneAnalyticsAdapter.js create mode 100644 modules/yieldoneAnalyticsAdapter.md delete mode 100644 modules/zedoBidAdapter.js create mode 100644 src/storageManager.js delete mode 100644 src/url.js create mode 100644 test/mock-server/expectations/request-response-pairs/banner/index.js create mode 100644 test/mock-server/expectations/request-response-pairs/currency/index.js create mode 100644 test/mock-server/expectations/request-response-pairs/gdpr/index.js create mode 100644 test/mock-server/expectations/request-response-pairs/instream/index.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_1.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_2.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_1.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_2.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_1.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_2.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_1.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_2.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_1.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_2.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/price_gran_request_1.js create mode 100644 test/mock-server/expectations/request-response-pairs/longform/price_gran_request_2.js create mode 100644 test/mock-server/expectations/request-response-pairs/multiple-bidders/index-1.js create mode 100644 test/mock-server/expectations/request-response-pairs/multiple-bidders/index-2.js create mode 100644 test/mock-server/expectations/request-response-pairs/native/index.js create mode 100644 test/mock-server/expectations/request-response-pairs/outstream/index.js create mode 100644 test/mock-server/index.js create mode 100644 test/mock-server/request-middlewares/prebid-request.js create mode 100644 test/mocks/xhr.js create mode 100644 test/pages/bidderSettings.html create mode 100644 test/pages/consent_mgt_gdpr.html create mode 100644 test/pages/currency.html rename test/pages/{video.html => instream.html} (91%) create mode 100644 test/pages/multiple_bidders.html create mode 100644 test/pages/priceGranularity.html create mode 100644 test/pages/sizeConfig.html create mode 100644 test/pages/userSync.html create mode 100644 test/spec/adapters/adbutler_spec.js create mode 100644 test/spec/e2e/instream/basic_instream_video_ad.spec.js create mode 100644 test/spec/e2e/longform/basic_w_bidderSettings.spec.js create mode 100644 test/spec/e2e/longform/basic_w_priceGran.spec.js create mode 100644 test/spec/e2e/modules/e2e_bidderSettings.spec.js create mode 100644 test/spec/e2e/modules/e2e_consent_mgt_gdpr.spec.js create mode 100644 test/spec/e2e/modules/e2e_currency.spec.js create mode 100644 test/spec/e2e/modules/e2e_priceGranularity.spec.js create mode 100644 test/spec/e2e/modules/e2e_sizeConfig.spec.js create mode 100644 test/spec/e2e/modules/e2e_userSync.spec.js create mode 100644 test/spec/e2e/multi-format/e2e_multiple_bidders.spec.js create mode 100644 test/spec/modules/1ad4goodBidAdapter_spec.js create mode 100644 test/spec/modules/7xbidBidAdapter_spec.js delete mode 100644 test/spec/modules/a4gBidAdapter_spec.js create mode 100644 test/spec/modules/ablidaBidAdapter_spec.js create mode 100644 test/spec/modules/adagioAnalyticsAdapter_spec.js rename test/spec/modules/{huddledmassesBidAdapter_spec.js => adfinityBidAdapter_spec.js} (74%) create mode 100644 test/spec/modules/adglareBidAdapter_spec.js rename test/spec/modules/{adkernelAdnAnalyticsAdapter_spec.js => adkernelAdnAnalytics_spec.js} (98%) create mode 100644 test/spec/modules/adnuntiusBidAdapter_spec.js create mode 100644 test/spec/modules/adotBidAdapter_spec.js delete mode 100644 test/spec/modules/adspiritBidAdapter_spec.js create mode 100755 test/spec/modules/advertlyBidAdapter_spec.js delete mode 100644 test/spec/modules/andbeyondBidAdapter_spec.js delete mode 100644 test/spec/modules/arteebeeBidAdapter_spec.js create mode 100644 test/spec/modules/astraoneBidAdapter_spec.js create mode 100644 test/spec/modules/atsAnalyticsAdapter_spec.js create mode 100644 test/spec/modules/audiencerunBidAdapter_spec.js create mode 100644 test/spec/modules/automatadBidAdapter_spec.js create mode 100644 test/spec/modules/bidlabBidAdapter_spec.js delete mode 100644 test/spec/modules/bizzclickBidAdapter_spec.js delete mode 100644 test/spec/modules/brainyBidAdapter_spec.js create mode 100644 test/spec/modules/britepoolIdSystem_spec.js create mode 100644 test/spec/modules/byplayBidAdapter_spec.js create mode 100644 test/spec/modules/clicktripzBidAdapter_spec.js delete mode 100644 test/spec/modules/colombiaBidAdapter_spec.js create mode 100644 test/spec/modules/connectadBidAdapter_spec.js create mode 100644 test/spec/modules/consentManagementUsp_spec.js delete mode 100644 test/spec/modules/contentigniteBidAdapter_spec.js create mode 100644 test/spec/modules/convergeBidAdapter_spec.js create mode 100644 test/spec/modules/criteoIdSystem_spec.js delete mode 100644 test/spec/modules/criteortusIdSystem_spec.js create mode 100644 test/spec/modules/dailyhuntBidAdapter_spec.js delete mode 100644 test/spec/modules/danmarketBidAdapter_spec.js delete mode 100644 test/spec/modules/decenteradsBidAdapter_spec.js create mode 100644 test/spec/modules/deepintentBidAdapter_spec.js delete mode 100644 test/spec/modules/dgadsBidAdapter_spec.js create mode 100644 test/spec/modules/djaxBidAdapter_spec.js create mode 100644 test/spec/modules/e_volutionBidAdapter_spec.js create mode 100644 test/spec/modules/eids_spec.js create mode 100644 test/spec/modules/envivoBidAdapter_spec.js delete mode 100644 test/spec/modules/eywamediaBidAdapter_spec.js delete mode 100644 test/spec/modules/fairtradeBidAdapter_spec.js create mode 100644 test/spec/modules/fluctBidAdapter_spec.js delete mode 100644 test/spec/modules/fyberBidAdapter_spec.js create mode 100644 test/spec/modules/gdprEnforcement_spec.js delete mode 100644 test/spec/modules/giantsBidAdapter_spec.js delete mode 100644 test/spec/modules/gjirafaBidAdapter_spec.js create mode 100644 test/spec/modules/gridNMBidAdapter_spec.js delete mode 100644 test/spec/modules/gxoneBidAdapter_spec.js create mode 100644 test/spec/modules/hybridBidAdapter_spec.js delete mode 100644 test/spec/modules/interactiveOffersBidAdapter_spec.js create mode 100644 test/spec/modules/invisiblyAnalyticsAdapter_spec.js delete mode 100644 test/spec/modules/iqmBidAdapter_spec.js create mode 100644 test/spec/modules/lemmaBidAdapter_spec.js create mode 100644 test/spec/modules/liveIntentIdSystem_spec.js create mode 100644 test/spec/modules/mediaforceBidAdapter_spec.js create mode 100644 test/spec/modules/medianetAnalyticsAdapter_spec.js create mode 100644 test/spec/modules/mobsmartBidAdapter_spec.js create mode 100644 test/spec/modules/newborntownWebBidAdapter_spec.js create mode 100644 test/spec/modules/nextrollBidAdapter_spec.js delete mode 100644 test/spec/modules/oneplanetonlyBidAdapter_spec.js delete mode 100644 test/spec/modules/openxoutstreamBidAdapter_spec.js delete mode 100644 test/spec/modules/optimaticBidAdapter_spec.js delete mode 100644 test/spec/modules/orbitsoftBidAdapter_spec.js create mode 100644 test/spec/modules/outconBidAdapter_spec.js create mode 100644 test/spec/modules/parrableIdSystem_spec.js delete mode 100644 test/spec/modules/peak226BidAdapter_spec.js delete mode 100644 test/spec/modules/polluxBidAdapter_spec.js delete mode 100644 test/spec/modules/polymorphBidAdapter_spec.js create mode 100644 test/spec/modules/priceFloorsSchema.json create mode 100644 test/spec/modules/priceFloors_spec.js create mode 100644 test/spec/modules/proxistoreBidAdapter_spec.js create mode 100755 test/spec/modules/pubmaticAnalyticsAdapter_spec.js delete mode 100644 test/spec/modules/pubnxBidAdapter_spec.js rename test/spec/modules/{playgroundxyzBidAdapter_spec.js => pxyzBidAdapter_spec.js} (60%) create mode 100644 test/spec/modules/radsBidAdapter_spec.js delete mode 100644 test/spec/modules/rdnBidAdapter_spec.js create mode 100644 test/spec/modules/realTimeModule_spec.js create mode 100644 test/spec/modules/relaidoBidAdapter_spec.js create mode 100644 test/spec/modules/resultsmediaBidAdapter_spec.js create mode 100644 test/spec/modules/revcontentBidAdapter_spec.js delete mode 100644 test/spec/modules/rexrtbBidAdapter_spec.js delete mode 100644 test/spec/modules/rockyouBidAdapter_spec.js delete mode 100644 test/spec/modules/rtbdemandadkBidAdapter_spec.js create mode 100644 test/spec/modules/rtbsolutionsBidAdapter_spec.js delete mode 100644 test/spec/modules/saraBidAdapter_spec.js create mode 100755 test/spec/modules/seedingAllianceAdapter_spec.js create mode 100644 test/spec/modules/segmentoBidAdapter_spec.js delete mode 100644 test/spec/modules/serverbidBidAdapter_spec.js delete mode 100644 test/spec/modules/shBidAdapter_spec.js create mode 100644 test/spec/modules/showheroes-bsBidAdapter_spec.js create mode 100644 test/spec/modules/sizeMappingV2_spec.js create mode 100644 test/spec/modules/smmsBidAdapter_spec.js delete mode 100644 test/spec/modules/supply2BidAdapter_spec.js create mode 100644 test/spec/modules/tpmnBidAdapter_spec.js delete mode 100644 test/spec/modules/trafficrootsBidAdapter_spec.js create mode 100644 test/spec/modules/tribeosBidAdapter_spec.js create mode 100644 test/spec/modules/turktelekomBidAdapter_spec.js create mode 100644 test/spec/modules/ucfunnelAnalyticsAdapter_spec.js create mode 100644 test/spec/modules/unicornBidAdapter_spec.js delete mode 100644 test/spec/modules/uolBidAdapter_spec.js create mode 100644 test/spec/modules/valueimpressionBidAdapter_spec.js create mode 100644 test/spec/modules/vdoaiBidAdapter_spec.js delete mode 100644 test/spec/modules/vertamediaBidAdapter_spec.js delete mode 100644 test/spec/modules/vertozBidAdapter_spec.js create mode 100644 test/spec/modules/videoNowBidAdapter_spec.js create mode 100644 test/spec/modules/viewdeosDXBidAdapter_spec.js create mode 100644 test/spec/modules/vrtcalBidAdapter_spec.js delete mode 100644 test/spec/modules/weboramaBidAdapter_spec.js rename test/spec/modules/{kummaBidAdapter_spec.js => windtalkerBidAdapter_spec.js} (87%) create mode 100644 test/spec/modules/wipesBidAdapter_spec.js delete mode 100644 test/spec/modules/xendizBidAdapter_spec.js delete mode 100644 test/spec/modules/yieldbotBidAdapter_spec.js create mode 100644 test/spec/modules/yieldliftBidAdapter_spec.js delete mode 100644 test/spec/modules/yieldnexusBidAdapter_spec.js create mode 100644 test/spec/modules/yieldoneAnalyticsAdapter_spec.js delete mode 100644 test/spec/modules/zedoBidAdapter_spec.js create mode 100644 test/spec/unit/core/storageManager_spec.js delete mode 100644 test/spec/url_spec.js mode change 100755 => 100644 test/spec/utils_spec.js diff --git a/.circleci/config.yml b/.circleci/config.yml index ca6713bb587..0d48ec13fa1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,49 +2,93 @@ # # Check https://circleci.com/docs/2.0/language-javascript/ for more details # + +aliases: + - &environment + docker: + # specify the version you desire here + - image: circleci/node:8.9.0 + + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/mongo:3.4.4 + working_directory: ~/Prebid.js + + - &restore_dep_cache + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - &save_dep_cache + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + + - &install + name: Install gulp cli + command: sudo npm install -g gulp-cli + + - &run_unit_test + name: BrowserStack testing + command: gulp test --browserstack --nolintfix + + - &run_endtoend_test + name: BrowserStack End to end testing + command: echo "127.0.0.1 test.localhost" | sudo tee -a /etc/hosts && gulp e2e-test --host=test.localhost + + # Download and run BrowserStack local + - &setup_browserstack + name : Download BrowserStack Local binary and start it. + command : | + # Download the browserstack binary file + wget "https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip" + # Unzip it + unzip BrowserStackLocal-linux-x64.zip + # Run the file with user's access key + ./BrowserStackLocal ${BROWSERSTACK_ACCESS_KEY} & + + - &unit_test_steps + - checkout + - restore_cache: *restore_dep_cache + - run: npm install + - save_cache: *save_dep_cache + - run: *install + - run: *setup_browserstack + - run: *run_unit_test + + - &endtoend_test_steps + - checkout + - restore_cache: *restore_dep_cache + - run: npm install + - save_cache: *save_dep_cache + - run: *install + - run: *setup_browserstack + - run: *run_endtoend_test + version: 2 jobs: build: - docker: - # specify the version you desire here - - image: circleci/node:8.9.0 + <<: *environment + steps: *unit_test_steps - # Specify service dependencies here if necessary - # CircleCI maintains a library of pre-built images - # documented at https://circleci.com/docs/2.0/circleci-images/ - # - image: circleci/mongo:3.4.4 - - working_directory: ~/Prebid.js - - steps: - - checkout - - # Download and cache dependencies - - restore_cache: - keys: - - v1-dependencies-{{ checksum "package.json" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- - - - run: npm install - - - save_cache: - paths: - - node_modules - key: v1-dependencies-{{ checksum "package.json" }} - - - run: sudo npm install -g gulp-cli - # Download and run BrowserStack local - - run: - name : Download BrowserStack Local binary and start it. - command : | - # Download the browserstack binary file - wget "https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip" - # Unzip it - unzip BrowserStackLocal-linux-x64.zip - # Run the file with user's access key - ./BrowserStackLocal ${BROWSERSTACK_ACCESS_KEY} & - # run tests! - - run: - name: BrowserStack testing - command: gulp test --browserstack --nolintfix + e2etest: + <<: *environment + steps: *endtoend_test_steps + +workflows: + version: 2 + commit: + jobs: + - build + nightly: + triggers: + - schedule: + cron: "0 0 * * *" + filters: + branches: + only: + - master + jobs: + - e2etest diff --git a/.eslintrc.js b/.eslintrc.js index 56e4808f985..c64ab379c52 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,8 @@ module.exports = { }, "extends": "standard", "plugins": [ - "prebid" + "prebid", + "import" ], "globals": { "$$PREBID_GLOBAL$$": false @@ -27,6 +28,7 @@ module.exports = { "comma-dangle": "off", "semi": "off", "space-before-function-paren": "off", + "import/extensions": ["error", "ignorePackages"], // Exceptions below this line are temporary, so that eslint can be added into the CI process. // Violations of these styles should be fixed, and the exceptions removed over time. @@ -35,8 +37,9 @@ module.exports = { "eqeqeq": "off", "no-return-assign": "off", "no-throw-literal": "off", - "no-undef": "off", + "no-undef": 2, "no-useless-escape": "off", + "no-console": "error" }, "overrides": Object.keys(allowedModules).map((key) => ({ "files": key + "/**/*.js", diff --git a/.gitignore b/.gitignore index 88e849a35ad..c0452b7b3d0 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,9 @@ build/coverage/ .idea/ # if you remove the above rule, at least ignore the following: +# VS Code +.vscode/ + # User-specific stuff: # .idea/workspace.xml # .idea/tasks.xml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c00a2bf51a..016f4055216 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,8 +48,10 @@ When you are adding code to Prebid.js, or modifying code that isn't covered by a - _Assert_: check that the expected results have occurred - e.g., use Chai assertions to check that the expected output is equal to the actual output - Test the public interface, not the internal implementation -- If you need to check `adloader.loadScript` in a test, use a `stub` rather than a `spy`. `spy`s trigger a network call which can result in a `script error` and cause unrelated unit tests to fail. `stub`s will let you gather information about the `adloader.loadScript` call without affecting external resources +- If you need to check `adloader.loadExternalScript` in a test, use a `stub` rather than a `spy`. `spy`s trigger a network call which can result in a `script error` and cause unrelated unit tests to fail. `stub`s will let you gather information about the `adloader.loadExternalScript` call without affecting external resources +- If your test makes ajax requests, use the global xhr stub in `test/mocks/xhr`. Do not use your own `sinon.useFakeXMLHttpRequest()` or `sinon.createFakeServer()`. - When writing tests you may use ES2015 syntax if desired +- If your test relies on `Window` or `global` object, do not mutate that object directly. Instead, create a separate copy of that object and perform operations on that new copy. ### Test Examples Prebid.js already has many tests. Read them to see how Prebid.js is tested, and for inspiration: diff --git a/PR_REVIEW.md b/PR_REVIEW.md index 4ad8b8ec372..64635b7fc03 100644 --- a/PR_REVIEW.md +++ b/PR_REVIEW.md @@ -16,9 +16,11 @@ For modules and core platform updates, the initial reviewer should request an ad - If the change results in needing updates to docs (such as public API change, module interface etc), add a label for "needs docs" and inform the submitter they must submit a docs PR to update the appropriate area of Prebid.org **before the PR can merge**. Help them with finding where the docs are located on prebid.org if needed. - Below are some examples of bidder specific updates that should require docs update (in their dev-docs/bidders/bidder.md file): - Add support for GDPR consentManagement module > add `gdpr_supported: true` + - Add support for US Privacy consentManagement module > add `usp_supported: true` - Add support for userId module > add `userId: pubCommon, digitrust, newProviderHere` - Add support for video and/or native mediaTypes > add `media_types: video, native` - Add support for COPPA > add `coppa_supported: true` + - Add support for SChain > add `schain_supported: true` - If all above is good, add a `LGTM` comment and request 1 additional core member to review. - Once there is 2 `LGTM` on the PR, merge to master - Ask the submitter to add a PR for documentation if applicable. @@ -29,7 +31,7 @@ For modules and core platform updates, the initial reviewer should request an ad - Follow steps above for general review process. In addition, please verify the following: - Verify that bidder has submitted valid bid params and that bids are being received. - Verify that bidder is not manipulating the prebid.js auction in any way or doing things that go against the principles of the project. If unsure check with the Tech Lead. -- Verify that the bidder is being as efficient as possible, ideally not loading an external library, however if they do load a library it should be cached. +- Verify that the bidder is being as efficient as possible, ideally not loading an external library, however if they do load a library it should be cached. - Verify that code re-use is being done properly and that changes introduced by a bidder don't impact other bidders. - If the adapter being submitted is an alias type, check with the bidder contact that is being aliased to make sure it's allowed. - If the adapter is triggering any user syncs make sure they are using the user sync module in the Prebid.js core. diff --git a/README.md b/README.md index 4b52e7d3f09..0e07521ac3b 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ module.exports = { // override the regular exclusion from above (for being inside node_modules). { test: /.js$/, - include: new RegExp(`\\${path.sep}prebid\.js`), + include: new RegExp(`\\${path.sep}prebid\\.js`), use: { loader: 'babel-loader', // presets and plugins for Prebid.js must be manually specified separate from your other babel rule. @@ -114,7 +114,7 @@ prebid.requestBids({ *Note:* You need to have `NodeJS` 8.9.x or greater installed. -*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To compily with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in it's setup. +*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To comply with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in its setup. If you have a previous version of `gulp` installed globally, you'll need to remove it before installing `gulp-cli`. You can check if this is installed by running `gulp -v` and seeing the version that's listed in the `CLI` field of the output. If you have the `gulp` package installed globally, it's likely the same version that you'll see in the `Local` field. If you already have `gulp-cli` installed, it should be a lower major version (it's at version `2.0.1` at the time of the transition). diff --git a/allowedModules.js b/allowedModules.js index e66b8e24098..4f8b8039d97 100644 --- a/allowedModules.js +++ b/allowedModules.js @@ -1,24 +1,27 @@ const sharedWhiteList = [ - "core-js/library/fn/array/find", // no ie11 - "core-js/library/fn/array/includes", // no ie11 - "core-js/library/fn/set", // ie11 supports Set but not Set#values - "core-js/library/fn/string/includes", // no ie11 - "core-js/library/fn/number/is-integer", // no ie11, - "core-js/library/fn/array/from" // no ie11 + 'core-js/library/fn/array/find', // no ie11 + 'core-js/library/fn/array/includes', // no ie11 + 'core-js/library/fn/set', // ie11 supports Set but not Set#values + 'core-js/library/fn/string/includes', // no ie11 + 'core-js/library/fn/number/is-integer', // no ie11, + 'core-js/library/fn/array/from' // no ie11 ]; module.exports = { 'modules': [ ...sharedWhiteList, + 'criteo-direct-rsa-validate', 'jsencrypt', - 'crypto-js' + 'crypto-js', + 'live-connect' // Maintained by LiveIntent : https://github.com/liveintent-berlin/live-connect/ ], 'src': [ ...sharedWhiteList, 'fun-hooks/no-eval', 'just-clone', 'dlv', - 'dset' + 'dset', + 'deep-equal' ] }; diff --git a/browsers.json b/browsers.json index 9042d7d0627..91e0548d78a 100644 --- a/browsers.json +++ b/browsers.json @@ -7,11 +7,11 @@ "device": null, "os": "Windows" }, - "bs_edge_16_windows_10": { + "bs_edge_18_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "edge", - "browser_version": "16.0", + "browser_version": "18.0", "device": null, "os": "Windows" }, @@ -23,43 +23,43 @@ "device": null, "os": "Windows" }, - "bs_chrome_74_windows_10": { + "bs_chrome_80_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "chrome", - "browser_version": "74.0", + "browser_version": "80.0", "device": null, "os": "Windows" }, - "bs_chrome_75_windows_10": { + "bs_chrome_79_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "chrome", - "browser_version": "75.0", + "browser_version": "79.0", "device": null, "os": "Windows" }, - "bs_firefox_66_windows_10": { + "bs_firefox_73_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "firefox", - "browser_version": "66.0", + "browser_version": "73.0", "device": null, "os": "Windows" }, - "bs_firefox_67_windows_10": { + "bs_firefox_72_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "firefox", - "browser_version": "67.0", + "browser_version": "72.0", "device": null, "os": "Windows" }, - "bs_safari_11_mac_high_sierra": { + "bs_safari_11_mac_catalina": { "base": "BrowserStack", - "os_version": "High Sierra", + "os_version": "Catalina", "browser": "safari", - "browser_version": "11.1", + "browser_version": "13.0", "device": null, "os": "OS X" }, diff --git a/gulpHelpers.js b/gulpHelpers.js index 84f01b4e966..aabd28ced02 100644 --- a/gulpHelpers.js +++ b/gulpHelpers.js @@ -59,6 +59,7 @@ module.exports = { }); } + // we need to forcefuly include the parentModule if the subModule is present in modules list and parentModule is not present in modules list Object.keys(submodules).forEach(parentModule => { if ( !modules.includes(parentModule) && diff --git a/gulpfile.js b/gulpfile.js index 24c628ef228..1b5cd85abd6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,6 +32,9 @@ var prebid = require('./package.json'); var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10); var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + ' */\n'; var port = 9999; +const mockServerPort = 4444; +const host = argv.host ? argv.host : 'localhost'; +const { spawn } = require('child_process'); // these modules must be explicitly listed in --modules to be included in the build, won't be part of "all" modules var explicitModules = [ @@ -64,11 +67,11 @@ function lint(done) { if (argv.nolint) { return done(); } - const isFixed = function(file) { + const isFixed = function (file) { return file.eslint != null && file.eslint.fixed; } - return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], {base: './'}) - .pipe(gulpif(argv.nolintfix, eslint(), eslint({fix: true}))) + return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], { base: './' }) + .pipe(gulpif(argv.nolintfix, eslint(), eslint({ fix: true }))) .pipe(eslint.format('stylish')) .pipe(eslint.failAfterError()) .pipe(gulpif(isFixed, gulp.dest('./'))); @@ -81,7 +84,7 @@ function viewCoverage(done) { connect.server({ port: coveragePort, - root: 'build/coverage/karma_html', + root: 'build/coverage/lcov-report', livereload: false }); opens('http://' + mylocalhost + ':' + coveragePort); @@ -157,7 +160,7 @@ function nodeBundle(modules) { .on('error', (err) => { reject(err); }) - .pipe(through.obj(function(file, enc, done) { + .pipe(through.obj(function (file, enc, done) { resolve(file.contents.toString(enc)); done(); })); @@ -196,7 +199,7 @@ function bundle(dev, moduleArr) { return gulp.src( entries ) - .pipe(gulpif(dev, sourcemaps.init({loadMaps: true}))) + .pipe(gulpif(dev, sourcemaps.init({ loadMaps: true }))) .pipe(concat(outputFileName)) .pipe(gulpif(!argv.manualEnable, footer('\n<%= global %>.processQueue();', { global: prebid.globalVarName @@ -214,16 +217,49 @@ function bundle(dev, moduleArr) { // If --browserstack is given, it will run the full suite of currently supported browsers. // If --browsers is given, browsers can be chosen explicitly. e.g. --browsers=chrome,firefox,ie9 // If --notest is given, it will immediately skip the test task (useful for developing changes with `gulp serve --notest`) + function test(done) { if (argv.notest) { done(); } else if (argv.e2e) { let wdioCmd = path.join(__dirname, 'node_modules/.bin/wdio'); let wdioConf = path.join(__dirname, 'wdio.conf.js'); - let wdioOpts = [ - wdioConf - ]; - return execa(wdioCmd, wdioOpts, { stdio: 'inherit' }); + let wdioOpts; + + if (argv.file) { + wdioOpts = [ + wdioConf, + `--spec`, + `${argv.file}` + ] + } else { + wdioOpts = [ + wdioConf + ]; + } + + //run mock-server + const mockServer = spawn('node', ['./test/mock-server/index.js', '--port=' + mockServerPort]); + mockServer.stdout.on('data', (data) => { + console.log(`stdout: ${data}`); + }); + mockServer.stderr.on('data', (data) => { + console.log(`stderr: ${data}`); + }); + + execa(wdioCmd, wdioOpts, { stdio: 'inherit' }) + .then(stdout => { + // kill mock server + mockServer.kill('SIGINT'); + done(); + process.exit(0); + }) + .catch(err => { + // kill mock server + mockServer.kill('SIGINT'); + done(new Error(`Tests failed with error: ${err}`)); + process.exit(1); + }); } else { var karmaConf = karmaConfMaker(false, argv.browserstack, argv.watch, argv.file); @@ -237,7 +273,7 @@ function test(done) { } function newKarmaCallback(done) { - return function(exitCode) { + return function (exitCode) { if (exitCode) { done(new Error('Karma tests failed with exit code ' + exitCode)); if (argv.browserstack) { @@ -260,7 +296,7 @@ function testCoverage(done) { function coveralls() { // 2nd arg is a dependency: 'test' must be finished // first send results of istanbul's test coverage to coveralls.io. return gulp.src('gulpfile.js', { read: false }) // You have to give it a file, but you don't - // have to read it. + // have to read it. .pipe(shell('cat build/coverage/lcov.info | node_modules/coveralls/bin/coveralls.js')); } @@ -290,6 +326,12 @@ function setupE2e(done) { done(); } +gulp.task('updatepath', function () { + return gulp.src(['build/dist/*.js']) + .pipe(replace('https://ib.adnxs.com/ut/v3/prebid', 'http://' + host + ':' + mockServerPort + '/')) + .pipe(gulp.dest('build/dist')); +}); + // support tasks gulp.task(lint); gulp.task(watch); @@ -315,7 +357,7 @@ gulp.task('build-postbid', gulp.series(escapePostbidConfig, buildPostbid)); gulp.task('serve', gulp.series(clean, lint, gulp.parallel('build-bundle-dev', watch, test))); gulp.task('default', gulp.series(clean, makeWebpackPkg)); -gulp.task('e2e-test', gulp.series(clean, setupE2e, gulp.parallel('build-bundle-dev', watch), test)) +gulp.task('e2e-test', gulp.series(clean, setupE2e, gulp.parallel('build-bundle-prod', watch), 'updatepath', test)); // other tasks gulp.task(bundleToStdout); gulp.task('bundle', gulpBundle.bind(null, false)); // used for just concatenating pre-built files with no build step diff --git a/integrationExamples/gpt/audigentSegments_example.html b/integrationExamples/gpt/audigentSegments_example.html new file mode 100644 index 00000000000..9b72da76d23 --- /dev/null +++ b/integrationExamples/gpt/audigentSegments_example.html @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + +

Audigent Segments Prebid

+ +
+ +
+TDID: +
+
+ +Audigent Segments: +
+
+ + diff --git a/integrationExamples/gpt/cmp_files/purposes.json b/integrationExamples/gpt/cmp_files/purposes.json new file mode 100644 index 00000000000..04219e92ce4 --- /dev/null +++ b/integrationExamples/gpt/cmp_files/purposes.json @@ -0,0 +1,25 @@ +{ + "version": 1, + "purposes": [ + { + "id": 25, + "name": "Custom Purpose 1", + "description": "Here's a description of the first purpose" + }, + { + "id": 26, + "name": "Custom Purpose 2", + "description": "Here's a description of the second purpose" + }, + { + "id": 27, + "name": "Custom Purpose 3", + "description": "Here's a description of the third purpose" + }, + { + "id": 28, + "name": "Custom Purpose 4", + "description": "Here's a description of the fourth purpose" + } + ] +} diff --git a/integrationExamples/gpt/digitrust_Full.html b/integrationExamples/gpt/digitrust_Full.html index 7ec268a619a..fc7704776f4 100644 --- a/integrationExamples/gpt/digitrust_Full.html +++ b/integrationExamples/gpt/digitrust_Full.html @@ -70,7 +70,7 @@ }()); var t = document.createElement('script'); t.async = false; - t.src = 'http://acdn.adnxs.com/cmp/cmp.bundle.js'; + t.src = 'https://acdn.adnxs.com/cmp/cmp.bundle.js'; var tag = document.getElementsByTagName('head')[0]; tag.appendChild(t); } diff --git a/integrationExamples/gpt/digitrust_Simple.html b/integrationExamples/gpt/digitrust_Simple.html index c9a8c1d2ad6..03634dfc701 100644 --- a/integrationExamples/gpt/digitrust_Simple.html +++ b/integrationExamples/gpt/digitrust_Simple.html @@ -71,7 +71,7 @@ }()); var t = document.createElement('script'); t.async = false; - t.src = 'http://acdn.adnxs.com/cmp/cmp.bundle.js'; + t.src = 'https://acdn.adnxs.com/cmp/cmp.bundle.js'; var tag = document.getElementsByTagName('head')[0]; tag.appendChild(t); } @@ -86,6 +86,7 @@ { code: 'test-div', sizes: [[300, 250], [300, 600], [728, 90]], + mediaTypes: { banner: { sizes: [400, 600], name: 'testAdUnit'}}, bids: [ { bidder: 'rubicon', diff --git a/integrationExamples/gpt/digitrust_cmp_test.html b/integrationExamples/gpt/digitrust_cmp_test.html new file mode 100644 index 00000000000..6f0a70188f3 --- /dev/null +++ b/integrationExamples/gpt/digitrust_cmp_test.html @@ -0,0 +1,192 @@ + + + CMP Simple DigiTrust Prebid - No Framework + + + + + + + + + + + + + +

DigiTrust Prebid Sample - No Framework

+ +

+ This sample tests cmp behavior with simple integration path for using DigiTrust ID with Prebid. + You can use DigiTrust ID without integrating the entire DigiTrust suite. +

+
+ +
+ +
+ + + diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html old mode 100644 new mode 100755 index 337c762adc5..47ba5b8f18a --- a/integrationExamples/gpt/hello_world.html +++ b/integrationExamples/gpt/hello_world.html @@ -8,84 +8,84 @@ --> - - - - + + - - + + - - + + - - - -

Prebid.js Test

-
Div-1
-
- + + + +

Prebid.js Test

+
Div-1
+
+ -
- - + +
+ + \ No newline at end of file diff --git a/integrationExamples/gpt/prebidServer_example.html b/integrationExamples/gpt/prebidServer_example.html index db61a6a46d6..7761178efa8 100644 --- a/integrationExamples/gpt/prebidServer_example.html +++ b/integrationExamples/gpt/prebidServer_example.html @@ -36,7 +36,11 @@ pbjs.que.push(function() { var adUnits = [{ code: 'div-gpt-ad-1460505748561-0', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bids: [ { bidder: 'appnexus', diff --git a/integrationExamples/gpt/proxistore_example.html b/integrationExamples/gpt/proxistore_example.html new file mode 100644 index 00000000000..acd95baef2a --- /dev/null +++ b/integrationExamples/gpt/proxistore_example.html @@ -0,0 +1,118 @@ + + + + + + + + + + + + + +

Prebid.js Test

+ +
Div-1
+ +
+ +
+ + + \ No newline at end of file diff --git a/integrationExamples/gpt/responsiveAds_sizeMappingV2.html b/integrationExamples/gpt/responsiveAds_sizeMappingV2.html new file mode 100644 index 00000000000..d262af5199a --- /dev/null +++ b/integrationExamples/gpt/responsiveAds_sizeMappingV2.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + + diff --git a/integrationExamples/gpt/revcontent_example.html b/integrationExamples/gpt/revcontent_example.html new file mode 100644 index 00000000000..ad0933885f3 --- /dev/null +++ b/integrationExamples/gpt/revcontent_example.html @@ -0,0 +1,109 @@ + + + + + + + + + + + +

Basic Prebid.js Example

+
Div-1
+
+ +
+ + + \ No newline at end of file diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index 5878d05aecd..6d2c2ce677a 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -143,14 +143,26 @@ }, { name: "id5Id", params: { - partner: 173 // @TODO: Set your real ID5 partner ID here for production, please ask for one contact@id5.io + partner: 173 //Set your real ID5 partner ID here for production, please ask for one at http://id5.io/prebid }, storage: { type: "cookie", name: "id5id", - expires: 90 + expires: 90, + refreshInSeconds: 8*3600 // Refresh frequency of cookies, defaulting to 'expires' }, + }, { + name: "parrableId", + params: { + // change to Parrable Partner Client ID(s) you received from the Parrable Partners you are using + partner: '30182847-e426-4ff9-b2b5-9ca1324ea09b' + }, + storage: { + type: "cookie", + name: "_parrable_eid", // create a cookie with this name + expires: 365 // cookie can last for a year + } }, { name: "pubCommonId", storage: { @@ -170,10 +182,11 @@ storage: { type: 'cookie', name: 'idl_env', - expires: 60 + expires: 30 } }], - syncDelay: 5000 + syncDelay: 5000, + auctionDelay: 1000 } }); pbjs.addAdUnits(adUnits); diff --git a/integrationExamples/longform/basic_w_bidderSettings.html b/integrationExamples/longform/basic_w_bidderSettings.html new file mode 100644 index 00000000000..f9389686b1f --- /dev/null +++ b/integrationExamples/longform/basic_w_bidderSettings.html @@ -0,0 +1,145 @@ + + + + + Prebid Freewheel Integration Demo + + + + + + + + + + + + + + + + + + +

Prebid Freewheel Test Page

+

requireExactDuration = false

+
+
+ +
+
+
+
+

+ +

+
+
+
+ // bids +
+
+
+
+
+

+ +

+
+
+
+ // bids +
+
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/integrationExamples/longform/basic_w_custom_adserver_translation.html b/integrationExamples/longform/basic_w_custom_adserver_translation.html index 995ea822da4..8f4d46c3079 100644 --- a/integrationExamples/longform/basic_w_custom_adserver_translation.html +++ b/integrationExamples/longform/basic_w_custom_adserver_translation.html @@ -5,7 +5,7 @@ Prebid Freewheel Integration Demo - + + + + + + + + + + + + + + + + +

Prebid Freewheel Test Page

+

requireExactDuration = false

+
+
+ +
+
+
+
+

+ +

+
+
+
+ // bids +
+
+
+
+
+

+ +

+
+
+
+ // bids +
+
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/integrationExamples/longform/basic_w_requireExactDuration.html b/integrationExamples/longform/basic_w_requireExactDuration.html index 016b51d09c4..5a902cf913e 100644 --- a/integrationExamples/longform/basic_w_requireExactDuration.html +++ b/integrationExamples/longform/basic_w_requireExactDuration.html @@ -5,7 +5,7 @@ Prebid Freewheel Integration Demo - + + + + + + +
+ + + `; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid(bid) { + return ( + getMediaTypeFromBid(bid) === BANNER && + !!bid.params.placeId && + !!bid.params.imageUrl && + !!bid.params.placement && + (bid.params.placement === 'inImage') + ); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests(validBidRequests, bidderRequest) { + const payload = { + url: bidderRequest.refererInfo.referer, + cmp: !!bidderRequest.gdprConsent, + bidRequests: buildBidRequests(validBidRequests) + }; + + if (payload.cmp) { + const gdprApplies = bidderRequest.gdprConsent.gdprApplies; + if (gdprApplies !== undefined) payload['ga'] = gdprApplies; + payload['cs'] = bidderRequest.gdprConsent.consentString; + } + + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: SSP_ENDPOINT, + data: payloadString, + options: { + contentType: 'application/json' + } + } + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse) { + const serverBody = serverResponse.body; + if (serverBody && utils.isArray(serverBody)) { + return utils._map(serverBody, function(bid) { + return buildBid(bid); + }); + } else { + return []; + } + } + +} +registerBidder(spec); diff --git a/modules/astraoneBidAdapter.md b/modules/astraoneBidAdapter.md new file mode 100644 index 00000000000..a7eaeeef5a4 --- /dev/null +++ b/modules/astraoneBidAdapter.md @@ -0,0 +1,198 @@ +# Overview + + +**Module Name**: AstraOne Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: prebid@astraone.io + +# Description + +You can use this adapter to get a bid from AstraOne. +Please reach out to your AstraOne account team before using this plugin to get placeId. +The code below returns a demo ad. + +About us: https://astraone.io + +# Test Parameters +```js +var adUnits = [{ + code: 'test-div', + mediaTypes: { + banner: { + sizes: [1, 1] + } + }, + bids: [{ + bidder: "astraone", + params: { + placement: "inImage", + placeId: "5af45ad34d506ee7acad0c26", + imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg" + } + }] +}]; +``` + +# Example page + +```html + + + + + Prebid.js Banner Example + + + + + + +

Prebid.js InImage Banner Test

+ +
+ + +
+ + + +``` +# Example page with GPT + +```html + + + + + Prebid.js Banner Example + + + + + + +

Prebid.js Banner Ad Unit Test

+ +
+ + + +
+ + +``` diff --git a/modules/atomxBidAdapter.js b/modules/atomxBidAdapter.js index f36419902a1..e9f15218c4c 100644 --- a/modules/atomxBidAdapter.js +++ b/modules/atomxBidAdapter.js @@ -1,5 +1,5 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'atomx'; @@ -60,7 +60,7 @@ export const spec = { return validBidRequests.map(bidRequest => { return { method: 'GET', - url: location.protocol + '//p.ato.mx/placement', + url: 'https://p.ato.mx/placement', data: { v: 12, id: bidRequest.params.id, diff --git a/modules/atsAnalyticsAdapter.js b/modules/atsAnalyticsAdapter.js new file mode 100644 index 00000000000..f15e5aa2b1f --- /dev/null +++ b/modules/atsAnalyticsAdapter.js @@ -0,0 +1,153 @@ +import adapter from '../src/AnalyticsAdapter.js'; +import CONSTANTS from '../src/constants.json'; +import adaptermanager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; +import {ajax} from '../src/ajax.js'; + +const analyticsType = 'endpoint'; + +let handlerRequest = []; +let handlerResponse = []; +let host = ''; + +function bidRequestedHandler(args) { + let requests; + requests = args.bids.map(function(bid) { + return { + has_envelope: bid.userId ? !!bid.userId.idl_env : false, + bidder: bid.bidder, + bid_id: bid.bidId, + auction_id: args.auctionId, + user_browser: (browserIsFirefox() || browserIsEdge() || browserIsChrome() || browserIsSafari()), + user_platform: navigator.platform, + auction_start: new Date(args.auctionStart).toJSON(), + domain: args.refererInfo.referer, + pid: atsAnalyticsAdapter.context.pid, + }; + }); + return requests; +} + +function bidResponseHandler(args) { + return { + bid_id: args.requestId, + response_time_stamp: new Date(args.responseTimestamp).toJSON(), + currency: args.currency, + cpm: args.cpm, + net_revenue: args.netRevenue + }; +} + +export function browserIsFirefox() { + if (typeof InstallTrigger !== 'undefined') { + return 'Firefox'; + } else { + return false; + } +} + +export function browserIsIE() { + return !!document.documentMode; +} + +export function browserIsEdge() { + if (!browserIsIE() && !!window.StyleMedia) { + return 'Edge'; + } else { + return false; + } +} + +export function browserIsChrome() { + if ((!!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime)) || (/Android/i.test(navigator.userAgent) && !!window.chrome)) { + return 'Chrome'; + } else { + return false; + } +} + +export function browserIsSafari() { + if (navigator.vendor.indexOf('Apple')) { + return 'Safari' + } else { + return false; + } +} + +function callHandler(evtype, args) { + if (evtype === CONSTANTS.EVENTS.BID_REQUESTED) { + handlerRequest = handlerRequest.concat(bidRequestedHandler(args)); + } else if (evtype === CONSTANTS.EVENTS.BID_RESPONSE) { + handlerResponse.push(bidResponseHandler(args)); + } + if (evtype === CONSTANTS.EVENTS.AUCTION_END) { + if (handlerRequest.length) { + let events = []; + if (handlerResponse.length) { + events = handlerRequest.filter(request => handlerResponse.filter(function(response) { + if (request.bid_id === response.bid_id) { + Object.assign(request, response); + } + })); + } else { + events = handlerRequest; + } + atsAnalyticsAdapter.context.events = events; + } + } +} + +let atsAnalyticsAdapter = Object.assign(adapter( + { + host, + analyticsType + }), +{ + track({eventType, args}) { + if (typeof args !== 'undefined') { + callHandler(eventType, args); + } + if (eventType === CONSTANTS.EVENTS.AUCTION_END) { + // send data to ats analytic endpoint + try { + let dataToSend = {'Data': atsAnalyticsAdapter.context.events}; + let strJSON = JSON.stringify(dataToSend); + ajax(atsAnalyticsAdapter.context.host, function () { + }, strJSON, {method: 'POST', contentType: 'application/json'}); + } catch (err) { + } + } + } +}); + +// save the base class function +atsAnalyticsAdapter.originEnableAnalytics = atsAnalyticsAdapter.enableAnalytics; + +// override enableAnalytics so we can get access to the config passed in from the page +atsAnalyticsAdapter.enableAnalytics = function (config) { + if (!config.options.pid) { + utils.logError('Publisher ID (pid) option is not defined. Analytics won\'t work'); + return; + } + + if (!config.options.host) { + utils.logError('Host option is not defined. Analytics won\'t work'); + return; + } + + host = config.options.host; + atsAnalyticsAdapter.context = { + events: [], + host: config.options.host, + pid: config.options.pid + }; + let initOptions = config.options; + atsAnalyticsAdapter.originEnableAnalytics(initOptions); // call the base class function +}; + +adaptermanager.registerAnalyticsAdapter({ + adapter: atsAnalyticsAdapter, + code: 'atsAnalytics' +}); + +export default atsAnalyticsAdapter; diff --git a/modules/atsAnalyticsAdapter.md b/modules/atsAnalyticsAdapter.md new file mode 100644 index 00000000000..560ad237aa0 --- /dev/null +++ b/modules/atsAnalyticsAdapter.md @@ -0,0 +1,23 @@ +# Overview + +``` +Module Name: Ats Analytics Adapter +Module Type: Analytics Adapter +Maintainer: marko.matic@liveramp.com +``` + +# Description + +Analytics adapter for Authenticated Traffic Solution(ATS), provided by LiveRamp. + +# Test Parameters + +``` +{ + provider: 'atsAnalytics', + options: { + pid: '999', // publisher ID + host: 'https://example.com' // host is provided to publisher + } +} +``` diff --git a/modules/audienceNetworkBidAdapter.js b/modules/audienceNetworkBidAdapter.js index b4cf93363f6..2d7b7eae0dc 100644 --- a/modules/audienceNetworkBidAdapter.js +++ b/modules/audienceNetworkBidAdapter.js @@ -1,11 +1,10 @@ /** * @file AudienceNetwork adapter. */ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { formatQS } from '../src/url'; -import { generateUUID, getTopWindowUrl, convertTypes } from '../src/utils'; -import findIndex from 'core-js/library/fn/array/find-index'; -import includes from 'core-js/library/fn/array/includes'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { generateUUID, deepAccess, convertTypes, formatQS } from '../src/utils.js'; +import findIndex from 'core-js/library/fn/array/find-index.js'; +import includes from 'core-js/library/fn/array/includes.js'; const code = 'audienceNetwork'; const currency = 'USD'; @@ -168,12 +167,6 @@ const createAdHtml = (placementId, format, bidId) => { `; }; -/** - * Get the current window location URL correctly encoded for use in a URL query string. - * @returns {String} URI-encoded URL - */ -const getTopWindowUrlEncoded = () => encodeURIComponent(getTopWindowUrl()); - /** * Convert each bid request to a single URL to fetch those bids. * @param {Array} bids - list of bids @@ -186,7 +179,7 @@ const getTopWindowUrlEncoded = () => encodeURIComponent(getTopWindowUrl()); * @param {Array} bids[].sizes[] - Size arrays [h,w]: should include one of [300, 250], [320, 50] * @returns {Array} List of URLs to fetch, plus formats and sizes for later use with interpretResponse */ -const buildRequests = bids => { +const buildRequests = (bids, bidderRequest) => { // Build lists of placementids, adformats, sizes and SDK versions const placementids = []; const adformats = []; @@ -210,10 +203,9 @@ const buildRequests = bids => { requestIds.push(bid.bidId); }) ); - // Build URL const testmode = isTestmode(); - const pageurl = getTopWindowUrlEncoded(); + const pageurl = encodeURIComponent(deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || deepAccess(bidderRequest, 'refererInfo.referer')); const platform = findPlatform(platforms); const cb = generateUUID(); const search = { @@ -233,7 +225,7 @@ const buildRequests = bids => { } const data = formatQS(search); - return [{ adformats, data, method, requestIds, sizes, url }]; + return [{ adformats, data, method, requestIds, sizes, url, pageurl }]; }; /** @@ -245,7 +237,7 @@ const buildRequests = bids => { * @param {Array} bidRequest.sizes - list of sizes fot the original bid requests * @returns {Array} A list of bid response objects */ -const interpretResponse = ({ body }, { adformats, requestIds, sizes }) => { +const interpretResponse = ({ body }, { adformats, requestIds, sizes, pageurl }) => { const { bids = {} } = body; return Object.keys(bids) // extract Array of bid responses @@ -284,7 +276,6 @@ const interpretResponse = ({ body }, { adformats, requestIds, sizes }) => { }; // Video attributes if (isVideo(format)) { - const pageurl = getTopWindowUrlEncoded(); bidResponse.mediaType = 'video'; bidResponse.vastUrl = `https://an.facebook.com/v1/instream/vast.xml?placementid=${creativeId}&pageurl=${pageurl}&playerwidth=${width}&playerheight=${height}&bidid=${fbBidid}`; bidResponse.ttl = videoTtl; diff --git a/modules/audiencerunBidAdapter.js b/modules/audiencerunBidAdapter.js new file mode 100644 index 00000000000..b90471ee21a --- /dev/null +++ b/modules/audiencerunBidAdapter.js @@ -0,0 +1,142 @@ +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'audiencerun'; +const ENDPOINT_URL = 'https://d.audiencerun.com/prebid'; + +export const spec = { + version: '1.0.0', + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + let isValid = true; + if (!utils.deepAccess(bid, 'params.zoneId')) { + utils.logError('AudienceRun zoneId parameter is required. Bid aborted.'); + isValid = false; + } + return isValid; + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. + * @param {*} bidderRequest + * @return {ServerRequest} Info describing the request to the server. + */ + buildRequests: function(bidRequests, bidderRequest) { + const bids = bidRequests.map(bid => { + const sizes = utils.deepAccess(bid, 'mediaTypes.banner.sizes', []); + return { + zoneId: utils.getValue(bid.params, 'zoneId'), + sizes: sizes.map(size => ({ + w: size[0], + h: size[1] + })), + bidfloor: bid.params.bidfloor || 0.0, + bidId: bid.bidId, + bidderRequestId: utils.getBidIdParameter('bidderRequestId', bid), + adUnitCode: utils.getBidIdParameter('adUnitCode', bid), + auctionId: utils.getBidIdParameter('auctionId', bid), + transactionId: utils.getBidIdParameter('transactionId', bid) + }; + }); + + const payload = { + libVersion: this.version, + referer: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null, + currencyCode: config.getConfig('currency.adServerCurrency'), + timeout: config.getConfig('bidderTimeout'), + bids + }; + + if (bidderRequest && bidderRequest.gdprConsent) { + payload.gdpr = { + consent: bidderRequest.gdprConsent.consentString, + applies: bidderRequest.gdprConsent.gdprApplies + }; + } else { + payload.gdpr = { + consent: '' + } + } + + return { + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(payload), + options: { + withCredentials: true + } + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, bidRequest) { + const bids = []; + utils._each(serverResponse.body.bid, function (bidObject) { + if (!bidObject.cpm || bidObject.cpm === null || !bidObject.adm) { + return; + } + + const bid = {}; + + bid.ad = bidObject.adm; + bid.mediaType = BANNER; + + // Common properties + bid.requestId = bidObject.bidId; + bid.adId = bidObject.zoneId; + bid.cpm = parseFloat(bidObject.cpm); + bid.creativeId = bidObject.crid; + bid.currency = bidObject.currency ? bidObject.currency.toUpperCase() : 'USD'; + + bid.height = bidObject.h; + bid.width = bidObject.w; + bid.netRevenue = bidObject.isNet ? bidObject.isNet : false; + bid.ttl = 300; + + bids.push(bid); + }); + return bids; + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs: function(syncOptions, serverResponses) { + if (!serverResponses || !serverResponses.length) return []; + + const syncs = []; + serverResponses.forEach(response => { + response.body.bid.forEach(bidObject => { + syncs.push({ + type: 'iframe', + url: bidObject.syncUrl + }); + }); + }); + + return syncs; + } +}; + +registerBidder(spec); diff --git a/modules/audiencerunBidAdapter.md b/modules/audiencerunBidAdapter.md new file mode 100644 index 00000000000..3704922fdd5 --- /dev/null +++ b/modules/audiencerunBidAdapter.md @@ -0,0 +1,48 @@ +# Overview + +**Module Name**: AudienceRun Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: prebid@audiencerun.com + +# Description + +Module that connects to AudienceRun demand sources + +Use `audiencerun` as bidder. + +`zoneId` is required and must be 10 alphanumeric characters. + +## AdUnits configuration example +``` + var adUnits = [{ + code: 'ad-slot-300x600', + mediaTypes: { + banner: { + sizes: [ + [300, 600] + ], + } + }, + bids: [{ + bidder: 'audiencerun', + params: { + zoneId: 'xtov2mgij0' + } + }] + },{ + code: 'ad-slot-728x90', + mediaTypes: { + banner: { + sizes: [ + [728, 90] + ], + } + }, + bids: [{ + bidder: 'audiencerun', + params: { + zoneId: 'u4q6z6u97b' + } + }] + }]; +``` diff --git a/modules/audigentRtdProvider.js b/modules/audigentRtdProvider.js new file mode 100644 index 00000000000..0f32c84962f --- /dev/null +++ b/modules/audigentRtdProvider.js @@ -0,0 +1,141 @@ +/** + * This module adds audigent provider to the real time data module + * The {@link module:modules/realTimeData} module is required + * The module will fetch segments from audigent server + * @module modules/audigentRtdProvider + * @requires module:modules/realTimeData + */ + +/** + * @typedef {Object} ModuleParams + * @property {string} siteKey + * @property {string} pubKey + * @property {string} url + * @property {?string} keyName + * @property {number} auctionDelay + */ + +import {config} from '../src/config.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import * as utils from '../src/utils.js'; +import {submodule} from '../src/hook.js'; +import {ajax} from '../src/ajax.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); + +/** @type {string} */ +const MODULE_NAME = 'realTimeData'; + +/** @type {ModuleParams} */ +let _moduleParams = {}; + +/** + * XMLHttpRequest to get data form audigent server + * @param {string} url server url with query params + */ + +export function setData(data) { + storage.setDataInLocalStorage('__adgntseg', JSON.stringify(data)); +} + +function getSegments(adUnits, onDone) { + try { + let jsonData = storage.getDataFromLocalStorage('__adgntseg'); + if (jsonData) { + let data = JSON.parse(jsonData); + if (data.audigent_segments) { + let dataToReturn = adUnits.reduce((rp, cau) => { + const adUnitCode = cau && cau.code; + if (!adUnitCode) { return rp } + rp[adUnitCode] = data; + return rp; + }, {}); + + onDone(dataToReturn); + return; + } + } + getSegmentsAsync(adUnits, onDone); + } catch (e) { + getSegmentsAsync(adUnits, onDone); + } +} + +function getSegmentsAsync(adUnits, onDone) { + const userIds = (getGlobal()).getUserIds(); + let tdid = null; + + if (userIds && userIds['tdid']) { + tdid = userIds['tdid']; + } else { + onDone({}); + } + + const url = `https://seg.ad.gt/api/v1/rtb_segments?tdid=${tdid}`; + + ajax(url, { + success: function (response, req) { + if (req.status === 200) { + try { + const data = JSON.parse(response); + if (data && data.audigent_segments) { + setData(data); + let dataToReturn = adUnits.reduce((rp, cau) => { + const adUnitCode = cau && cau.code; + if (!adUnitCode) { return rp } + rp[adUnitCode] = data; + return rp; + }, {}); + + onDone(dataToReturn); + } else { + onDone({}); + } + } catch (err) { + utils.logError('unable to parse audigent segment data'); + onDone({}) + } + } else if (req.status === 204) { + // unrecognized site key + onDone({}); + } + }, + error: function () { + onDone({}); + utils.logError('unable to get audigent segment data'); + } + } + ); +} + +/** @type {RtdSubmodule} */ +export const audigentSubmodule = { + /** + * used to link submodule with realTimeData + * @type {string} + */ + name: 'audigent', + /** + * get data and send back to realTimeData module + * @function + * @param {adUnit[]} adUnits + * @param {function} onDone + */ + getData: getSegments +}; + +export function init(config) { + const confListener = config.getConfig(MODULE_NAME, ({realTimeData}) => { + try { + _moduleParams = realTimeData.dataProviders && realTimeData.dataProviders.filter(pr => pr.name && pr.name.toLowerCase() === 'audigent')[0].params; + _moduleParams.auctionDelay = realTimeData.auctionDelay; + } catch (e) { + _moduleParams = {}; + } + confListener(); + }); +} + +submodule('realTimeData', audigentSubmodule); +init(config); diff --git a/modules/audigentRtdProvider.md b/modules/audigentRtdProvider.md new file mode 100644 index 00000000000..47bcbbbf951 --- /dev/null +++ b/modules/audigentRtdProvider.md @@ -0,0 +1,52 @@ +Audigent is a next-generation data management platform and a first-of-a-kind +"data agency" containing some of the most exclusive content-consuming audiences +across desktop, mobile and social platforms. + +This real-time data module provides first-party Audigent segments that can be +attached to bid request objects destined for different SSPs in order to optimize +targeting. Audigent maintains a large database of first-party Tradedesk Unified +ID to third party segment mappings that can now be queried at bid-time. + +Usage: + +Compile the audigent RTD module into your Prebid build: + +`gulp build --modules=userId,unifiedIdSystem,rtdModule,audigentRtdProvider,rubiconBidAdapter` + +Audigent segments will then be attached to each bid request objects in +`bid.realTimeData.audigent_segments` + +The format of the segments is a per-SSP mapping: + +``` +{ + 'appnexus': ['anseg1', 'anseg2'], + 'google': ['gseg1', 'gseg2'] +} +``` + +If a given SSP's API backend supports segment fields, they can then be +attached prior to the bid request being sent: + +``` +pbjs.requestBids({bidsBackHandler: addAudigentSegments}); + +function addAudigentSegments() { + for (i = 0; i < adUnits.length; i++) { + let adUnit = adUnits[i]; + for (j = 0; j < adUnit.bids.length; j++) { + adUnit.bids[j].userId.lipb.segments = adUnit.bids[j].realTimeData.audigent_segments['rubicon']; + } + } +} +``` + +To view an example of the segments returned by Audigent's backends: + +`gulp serve --modules=userId,unifiedIdSystem,rtdModule,audigentRtdProvider,rubiconBidAdapter` + +and then point your browser at: + +`http://localhost:9999/integrationExamples/gpt/audigentSegments_example.html` + + diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js new file mode 100644 index 00000000000..4a9e6b6a1e4 --- /dev/null +++ b/modules/automatadBidAdapter.js @@ -0,0 +1,123 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js' +import * as utils from '../src/utils.js' +import {BANNER} from '../src/mediaTypes.js' +import {ajax} from '../src/ajax.js' + +const BIDDER = 'automatad' + +const ENDPOINT_URL = 'https://rtb2.automatad.com/ortb2' + +const DEFAULT_BID_TTL = 30 +const DEFAULT_CURRENCY = 'USD' +const DEFAULT_NET_REVENUE = true + +export const spec = { + code: BIDDER, + aliases: ['atd'], + supportedMediaTypes: [BANNER], + + isBidRequestValid: function (bid) { + // will receive request bid. check if have necessary params for bidding + return (bid && bid.hasOwnProperty('params') && bid.params.hasOwnProperty('siteId') && bid.params.hasOwnProperty('placementId') && bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty('banner')) + }, + + buildRequests: function (validBidRequests, bidderRequest) { + if (!validBidRequests || !bidderRequest) { + return + } + + const siteId = validBidRequests[0].params.siteId + const placementId = validBidRequests[0].params.placementId + + const impressions = validBidRequests.map(bidRequest => ({ + id: bidRequest.bidId, + banner: { + format: bidRequest.sizes.map(sizeArr => ({ + w: sizeArr[0], + h: sizeArr[1], + })) + }, + })) + + // params from bid request + const openrtbRequest = { + id: validBidRequests[0].auctionId, + imp: impressions, + site: { + id: siteId, + placement: placementId, + domain: window.location.hostname, + page: window.location.href, + ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null, + }, + } + + const payloadString = JSON.stringify(openrtbRequest) + return { + method: 'POST', + url: ENDPOINT_URL + '/resp', + data: payloadString, + options: { + contentType: 'application/json', + withCredentials: false, + crossOrigin: true, + }, + } + }, + + interpretResponse: function (serverResponse, request) { + const bidResponses = [] + const response = (serverResponse || {}).body + + if (response && response.seatbid && response.seatbid.length === 1 && response.seatbid[0].bid && response.seatbid[0].bid.length) { + response.seatbid[0].bid.forEach(bid => { + bidResponses.push({ + requestId: bid.impid, + cpm: bid.price, + ad: bid.adm, + adDomain: bid.adomain[0], + currency: DEFAULT_CURRENCY, + ttl: DEFAULT_BID_TTL, + creativeId: bid.crid, + width: bid.w, + height: bid.h, + netRevenue: DEFAULT_NET_REVENUE, + nurl: bid.nurl, + }) + }) + } else { + utils.logInfo('automatad :: no valid responses to interpret') + } + + return bidResponses + }, + getUserSyncs: function(syncOptions, serverResponse) { + return [{ + type: 'iframe', + url: 'https://rtb2.automatad.com/ortb2/async_usersync' + }] + }, + onBidWon: function(bid) { + if (!bid.nurl) { return } + const winUrl = bid.nurl.replace( + /\$\{AUCTION_PRICE\}/, + bid.cpm + ).replace( + /\$\{AUCTION_IMP_ID\}/, + bid.requestId + ).replace( + /\$\{AUCTION_CURRENCY\}/, + bid.currency + ).replace( + /\$\{AUCTION_ID\}/, + bid.auctionId + ) + spec.ajaxCall(winUrl, null) + return true + }, + ajaxCall: function(endpoint, data) { + ajax(endpoint, data) + }, + +} +registerBidder(spec) diff --git a/modules/automatadBidAdapter.md b/modules/automatadBidAdapter.md new file mode 100644 index 00000000000..56a4b53c067 --- /dev/null +++ b/modules/automatadBidAdapter.md @@ -0,0 +1,34 @@ +# Overview + +``` +Module Name: Automatad Bid Adapter +Module Type: Bidder Adapter +Maintainer: tech@automatad.com +``` + +# Description + +Connects to automatad exchange for bids. + +automatad bid adapter supports Banner ads. + +# Test Parameters +``` +var adUnits = [ + { + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'automatad', + params: { + siteId: 'someValue', + placementId: 'someValue' + } + }] + } +]; +``` diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 0143f01835d..9b6c431fdd7 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -1,19 +1,18 @@ -import * as utils from '../src/utils'; -import { parse as parseUrl } from '../src/url'; -import { config } from '../src/config'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { Renderer } from '../src/Renderer'; -import { VIDEO, BANNER } from '../src/mediaTypes'; -import find from 'core-js/library/fn/array/find'; -import includes from 'core-js/library/fn/array/includes'; - -const ADAPTER_VERSION = '1.7'; +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { Renderer } from '../src/Renderer.js'; +import { VIDEO, BANNER } from '../src/mediaTypes.js'; +import find from 'core-js/library/fn/array/find.js'; +import includes from 'core-js/library/fn/array/includes.js'; + +const ADAPTER_VERSION = '1.9'; const ADAPTER_NAME = 'BFIO_PREBID'; const OUTSTREAM = 'outstream'; export const VIDEO_ENDPOINT = 'https://reachms.bfmio.com/bid.json?exchange_id='; export const BANNER_ENDPOINT = 'https://display.bfmio.com/prebid_display'; -export const OUTSTREAM_SRC = '//player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js'; +export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js'; export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement']; export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; @@ -68,10 +67,11 @@ export const spec = { requestId: bidRequest.bidId, bidderCode: spec.code, vastUrl: response.url, + vastXml: response.vast, cpm: response.bidPrice, width: firstSize.w, height: firstSize.h, - creativeId: response.cmpId, + creativeId: response.crid || response.cmpId, renderer: context === OUTSTREAM ? createRenderer(bidRequest) : null, mediaType: VIDEO, currency: 'USD', @@ -104,9 +104,9 @@ export const spec = { } }, - getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}) { + getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '') { let syncs = []; - let { gdprApplies, consentString } = gdprConsent; + let { gdprApplies, consentString = '' } = gdprConsent; let bannerResponse = find(serverResponses, (res) => utils.isArray(res.body)); if (bannerResponse) { @@ -123,12 +123,12 @@ export const spec = { } else if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: `https://sync.bfmio.com/sync_iframe?ifg=1&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString || ''}&gce=1` + url: `https://sync.bfmio.com/sync_iframe?ifg=1&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString}&gce=1&us_privacy=${uspConsent}` }); } else if (syncOptions.pixelEnabled) { syncs.push({ type: 'image', - url: `https://sync.bfmio.com/syncb?pid=144&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString || ''}&gce=1` + url: `https://sync.bfmio.com/syncb?pid=144&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString}&gce=1&us_privacy=${uspConsent}` }); } @@ -151,7 +151,8 @@ function createRenderer(bidRequest) { height: bid.height, expandInView: getPlayerBidParam(bidRequest, 'expandInView', false), collapseOnComplete: getPlayerBidParam(bidRequest, 'collapseOnComplete', true), - progressColor: getPlayerBidParam(bidRequest, 'progressColor') + progressColor: getPlayerBidParam(bidRequest, 'progressColor'), + adPosterColor: getPlayerBidParam(bidRequest, 'adPosterColor') }); }); }); @@ -245,7 +246,7 @@ function isBannerBidValid(bid) { function getTopWindowLocation(bidderRequest) { let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); + return utils.parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); } function getTopWindowReferrer() { @@ -284,7 +285,9 @@ function createVideoRequestData(bid, bidderRequest) { mimes: DEFAULT_MIMES }, video), bidfloor: bidfloor, - secure: topLocation.protocol === 'https:' ? 1 : 0 + secure: topLocation.protocol === 'https:' ? 1 : 0, + displaymanager: ADAPTER_NAME, + displaymanagerver: ADAPTER_VERSION }], site: { page: topLocation.href, @@ -307,6 +310,10 @@ function createVideoRequestData(bid, bidderRequest) { cur: ['USD'] }; + if (bidderRequest && bidderRequest.uspConsent) { + payload.regs.ext.us_privacy = bidderRequest.uspConsent; + } + if (bidderRequest && bidderRequest.gdprConsent) { let { gdprApplies, consentString } = bidderRequest.gdprConsent; payload.regs.ext.gdpr = gdprApplies ? 1 : 0; @@ -325,6 +332,11 @@ function createVideoRequestData(bid, bidderRequest) { }]; } + let connection = navigator.connection || navigator.webkitConnection; + if (connection && connection.effectiveType) { + payload.device.connectiontype = connection.effectiveType; + } + return payload; } @@ -354,6 +366,10 @@ function createBannerRequestData(bids, bidderRequest) { adapterName: ADAPTER_NAME }; + if (bidderRequest && bidderRequest.uspConsent) { + payload.usPrivacy = bidderRequest.uspConsent; + } + if (bidderRequest && bidderRequest.gdprConsent) { let { gdprApplies, consentString } = bidderRequest.gdprConsent; payload.gdpr = gdprApplies ? 1 : 0; diff --git a/modules/beachfrontBidAdapter.md b/modules/beachfrontBidAdapter.md index 3f827fe9241..0a6b8b73da4 100644 --- a/modules/beachfrontBidAdapter.md +++ b/modules/beachfrontBidAdapter.md @@ -109,6 +109,7 @@ Module that connects to Beachfront's demand sources }, player: { progressColor: '#50A8FA', + adPosterColor: '#FFF', expandInView: false, collapseOnComplete: true } diff --git a/modules/betweenBidAdapter.js b/modules/betweenBidAdapter.js index 9da6b4dbe29..521c6cb6f98 100644 --- a/modules/betweenBidAdapter.js +++ b/modules/betweenBidAdapter.js @@ -1,5 +1,5 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; - +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { getAdUnitSizes, parseSizesInput } from '../src/utils.js'; const BIDDER_CODE = 'between'; export const spec = { @@ -13,7 +13,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function(bid) { - return !!(bid.params.w && bid.params.h && bid.params.s); + return Boolean(bid.params.s); }, /** * Make a server request from the list of BidRequests. @@ -21,17 +21,18 @@ export const spec = { * @param {validBidRequests[]} - an array of bids * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(validBidRequests) { + buildRequests: function(validBidRequests, bidderRequest) { let requests = []; + const gdprConsent = bidderRequest && bidderRequest.gdprConsent; + validBidRequests.forEach(i => { let params = { + sizes: parseSizesInput(getAdUnitSizes(i)), jst: 'hb', ord: Math.random() * 10000000000000000, tz: getTz(), fl: getFl(), rr: getRr(), - w: i.params.w, - h: i.params.h, s: i.params.s, bidid: i.bidId, transactionid: i.transactionId, @@ -54,6 +55,16 @@ export const spec = { params['pubside_macro[' + key + ']'] = encodeURIComponent(i.params.pubdata[key]); } } + + if (gdprConsent) { + if (typeof gdprConsent.gdprApplies !== 'undefined') { + params.gdprApplies = !!gdprConsent.gdprApplies; + } + if (typeof gdprConsent.consentString !== 'undefined') { + params.consentString = gdprConsent.consentString; + } + } + requests.push({method: 'GET', url: 'https://ads.betweendigital.com/adjson', data: params}) }) return requests; @@ -96,7 +107,7 @@ export const spec = { if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: '//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' + url: 'https://acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' }); } if (syncOptions.pixelEnabled && serverResponses.length > 0) { @@ -108,11 +119,11 @@ export const spec = { // syncs.push({ // type: 'iframe', - // url: '//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' + // url: 'https://acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' // }); syncs.push({ type: 'iframe', - url: '//ads.betweendigital.com/sspmatch-iframe' + url: 'https://ads.betweendigital.com/sspmatch-iframe' }); return syncs; } diff --git a/modules/betweenBidAdapter.md b/modules/betweenBidAdapter.md index 426d0aa2ed7..4aadd31d3a3 100644 --- a/modules/betweenBidAdapter.md +++ b/modules/betweenBidAdapter.md @@ -15,14 +15,17 @@ About us : http://betweendigital.com ```javascript var adUnits = [ { - code: 'test-div', + code: 'ad_slot', + mediaTypes: { + banner: { + sizes: [[970, 250], [240, 400], [728, 90]] + } + }, bids: [ { bidder: "between", params: { - w: 200, - h: 400, - s: 111 + s: 122938 } } ] @@ -45,14 +48,16 @@ Where: var PREBID_TIMEOUT = 700; var adUnits = [{ - code: 'example', - sizes: [[300, 250], [200,400]], + code: 'example', + mediaTypes: { + banner: { + sizes: [[970, 250], [240, 400], [728, 90]] + } + }, bids: [{ bidder: 'between', params: { - w: 240, - h: 400, - s: 8 + s: 809832 } }] diff --git a/modules/bidfluenceBidAdapter.js b/modules/bidfluenceBidAdapter.js index 4a9c4433ee0..f8a1f9ac92f 100644 --- a/modules/bidfluenceBidAdapter.js +++ b/modules/bidfluenceBidAdapter.js @@ -1,5 +1,8 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); const BIDDER_CODE = 'bidfluence'; function stdTimezoneOffset(t) { @@ -46,7 +49,7 @@ export const spec = { var payload = { v: '2.0', azr: true, - ck: utils.cookiesAreEnabled(), + ck: storage.cookiesAreEnabled(), re: refInfo ? refInfo.referer : '', st: refInfo ? refInfo.stack : [], tz: getBdfTz(new Date()), @@ -81,7 +84,7 @@ export const spec = { const payloadString = JSON.stringify(payload); return { method: 'POST', - url: `//bdf${payload.bids[0].pid}.bidfluence.com/Prebid`, + url: `https://bdf${payload.bids[0].pid}.bidfluence.com/Prebid`, data: payloadString, options: { contentType: 'text/plain' } }; diff --git a/modules/bidglassBidAdapter.js b/modules/bidglassBidAdapter.js index f5991f7f3a5..6db35f184ca 100644 --- a/modules/bidglassBidAdapter.js +++ b/modules/bidglassBidAdapter.js @@ -1,134 +1,134 @@ -import * as utils from '../src/utils'; -// import {config} from 'src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'bidglass'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['bg'], // short code - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!(bid.params.adUnitId && !isNaN(parseFloat(bid.params.adUnitId)) && isFinite(bid.params.adUnitId)); - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids - * @return ServerRequest Info describing the request to the server. - */ +import * as utils from '../src/utils.js'; +// import {config} from 'src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'bidglass'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['bg'], // short code + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid.params.adUnitId && !isNaN(parseFloat(bid.params.adUnitId)) && isFinite(bid.params.adUnitId)); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ buildRequests: function(validBidRequests, bidderRequest) { - /* - Sample array entry for validBidRequests[]: - [{ - "bidder": "bidglass", - "bidId": "51ef8751f9aead", - "params": { - "adUnitId": 11, - ... - }, - "adUnitCode": "div-gpt-ad-1460505748561-0", - "transactionId": "d7b773de-ceaa-484d-89ca-d9f51b8d61ec", - "sizes": [[320,50],[300,250],[300,600]], - "bidderRequestId": "418b37f85e772c", - "auctionId": "18fd8b8b0bd757", - "bidRequestsCount": 1 - }] - */ - - let imps = []; + /* + Sample array entry for validBidRequests[]: + [{ + "bidder": "bidglass", + "bidId": "51ef8751f9aead", + "params": { + "adUnitId": 11, + ... + }, + "adUnitCode": "div-gpt-ad-1460505748561-0", + "transactionId": "d7b773de-ceaa-484d-89ca-d9f51b8d61ec", + "sizes": [[320,50],[300,250],[300,600]], + "bidderRequestId": "418b37f85e772c", + "auctionId": "18fd8b8b0bd757", + "bidRequestsCount": 1 + }] + */ + + let imps = []; let getReferer = function() { return window === window.top ? window.location.href : window.parent === window.top ? document.referrer : null; - }; + }; let getOrigins = function() { - var ori = [window.location.protocol + '//' + window.location.hostname]; - + var ori = ['https://' + window.location.hostname]; + if (window.location.ancestorOrigins) { for (var i = 0; i < window.location.ancestorOrigins.length; i++) { ori.push(window.location.ancestorOrigins[i]); } } else if (window !== window.top) { - // Derive the parent origin - var parts = document.referrer.split('/'); - - ori.push(parts[0] + '//' + parts[2]); - + // Derive the parent origin + var parts = document.referrer.split('/'); + + ori.push('https://' + parts[2]); + if (window.parent !== window.top) { - // Additional unknown origins exist + // Additional unknown origins exist ori.push('null'); } - } - + } + return ori; - }; - + }; + utils._each(validBidRequests, function(bid) { - bid.sizes = ((utils.isArray(bid.sizes) && utils.isArray(bid.sizes[0])) ? bid.sizes : [bid.sizes]); - bid.sizes = bid.sizes.filter(size => utils.isArray(size)); - - // Stuff to send: [bid id, sizes, adUnitId] - imps.push({ - bidId: bid.bidId, - sizes: bid.sizes, - adUnitId: utils.getBidIdParameter('adUnitId', bid.params) + bid.sizes = ((utils.isArray(bid.sizes) && utils.isArray(bid.sizes[0])) ? bid.sizes : [bid.sizes]); + bid.sizes = bid.sizes.filter(size => utils.isArray(size)); + + // Stuff to send: [bid id, sizes, adUnitId] + imps.push({ + bidId: bid.bidId, + sizes: bid.sizes, + adUnitId: utils.getBidIdParameter('adUnitId', bid.params) }); - }); - - // Stuff to send: page URL - const bidReq = { - reqId: utils.getUniqueIdentifierStr(), - imps: imps, - ref: getReferer(), - ori: getOrigins() - }; - - let url = 'https://bid.glass/ad/hb.php?' + - `src=$$REPO_AND_VERSION$$`; - - return { - method: 'POST', - url: url, - data: JSON.stringify(bidReq), - options: { - contentType: 'text/plain', - withCredentials: false - } + }); + + // Stuff to send: page URL + const bidReq = { + reqId: utils.getUniqueIdentifierStr(), + imps: imps, + ref: getReferer(), + ori: getOrigins() + }; + + let url = 'https://bid.glass/ad/hb.php?' + + `src=$$REPO_AND_VERSION$$`; + + return { + method: 'POST', + url: url, + data: JSON.stringify(bidReq), + options: { + contentType: 'text/plain', + withCredentials: false + } } - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ interpretResponse: function(serverResponse) { - const bidResponses = []; - + const bidResponses = []; + utils._each(serverResponse.body.bidResponses, function(bid) { - bidResponses.push({ - requestId: bid.requestId, - cpm: parseFloat(bid.cpm), - width: parseInt(bid.width, 10), - height: parseInt(bid.height, 10), - creativeId: bid.creativeId, - dealId: bid.dealId || null, - currency: bid.currency || 'USD', - mediaType: bid.mediaType || 'banner', - netRevenue: true, - ttl: bid.ttl || 10, - ad: bid.ad + bidResponses.push({ + requestId: bid.requestId, + cpm: parseFloat(bid.cpm), + width: parseInt(bid.width, 10), + height: parseInt(bid.height, 10), + creativeId: bid.creativeId, + dealId: bid.dealId || null, + currency: bid.currency || 'USD', + mediaType: bid.mediaType || 'banner', + netRevenue: true, + ttl: bid.ttl || 10, + ad: bid.ad }); - }); - + }); + return bidResponses; - } - -} - -registerBidder(spec); + } + +} + +registerBidder(spec); diff --git a/modules/bidlabBidAdapter.js b/modules/bidlabBidAdapter.js new file mode 100644 index 00000000000..8f501505a6d --- /dev/null +++ b/modules/bidlabBidAdapter.js @@ -0,0 +1,112 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; + +const BIDDER_CODE = 'bidlab'; +const AD_URL = 'https://service.bidlab.ai/?c=o&m=multi'; +const URL_SYNC = 'https://service.bidlab.ai/?c=o&m=sync'; +const NO_SYNC = true; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || + !bid.ttl || !bid.currency) { + return false; + } + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl); + case NATIVE: + return Boolean(bid.native && bid.native.title && bid.native.image && bid.native.impressionTrackers); + default: + return false; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + noSync: NO_SYNC, + + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); + }, + + buildRequests: (validBidRequests = [], bidderRequest) => { + let winTop = window; + let location; + try { + location = new URL(bidderRequest.refererInfo.referer) + winTop = window.top; + } catch (e) { + location = winTop.location; + utils.logMessage(e); + }; + let placements = []; + let request = { + 'deviceWidth': winTop.screen.width, + 'deviceHeight': winTop.screen.height, + 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', + 'secure': 1, + 'host': location.host, + 'page': location.pathname, + 'placements': placements + }; + request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0]) + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent) { + request.gdpr = bidderRequest.gdprConsent + } + } + const len = validBidRequests.length; + + for (let i = 0; i < len; i++) { + let bid = validBidRequests[i]; + let traff = bid.params.traffic || BANNER + + placements.push({ + placementId: bid.params.placementId, + bidId: bid.bidId, + sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], + traffic: traff + }); + if (bid.schain) { + placements.schain = bid.schain; + } + } + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses) => { + if (NO_SYNC) { + return false + } else { + return [{ + type: 'image', + url: URL_SYNC + }]; + } + } + +}; + +registerBidder(spec); diff --git a/modules/bidlabBidAdapter.md b/modules/bidlabBidAdapter.md new file mode 100644 index 00000000000..3e5fe3128ed --- /dev/null +++ b/modules/bidlabBidAdapter.md @@ -0,0 +1,53 @@ +# Overview + +``` +Module Name: bidlab Bidder Adapter +Module Type: bidlab Bidder Adapter +``` + +# Description + +Module that connects to bidlab demand sources + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'placementId_0', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'bidlab', + params: { + placementId: 0, + traffic: 'banner' + } + } + ] + }, + // Will return test vast xml. All video params are stored under placement in publishers UI + { + code: 'placementId_0', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [ + { + bidder: 'bidlab', + params: { + placementId: 0, + traffic: 'video' + } + } + ] + } + ]; +``` diff --git a/modules/bidphysicsBidAdapter.js b/modules/bidphysicsBidAdapter.js index cbd76c8bc10..b6b5690ede5 100644 --- a/modules/bidphysicsBidAdapter.js +++ b/modules/bidphysicsBidAdapter.js @@ -1,8 +1,8 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; -import {BANNER} from '../src/mediaTypes'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import {BANNER} from '../src/mediaTypes.js'; -const ENDPOINT_URL = '//exchange.bidphysics.com/auction'; +const ENDPOINT_URL = 'https://exchange.bidphysics.com/auction'; const DEFAULT_BID_TTL = 30; const DEFAULT_CURRENCY = 'USD'; diff --git a/modules/bizzclickBidAdapter.js b/modules/bizzclickBidAdapter.js deleted file mode 100644 index a9b202b4c97..00000000000 --- a/modules/bizzclickBidAdapter.js +++ /dev/null @@ -1,105 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; - -const BIDDER_CODE = 'bizzclick'; -const URL = '//supply.bizzclick.com/?c=o&m=multi'; -const URL_SYNC = '//supply.bizzclick.com/?c=o&m=cookie'; - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native); - } - return false; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - /** - * Determines whether or not the given bid request is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(bid.params.placementId) && bid.params.type); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: (validBidRequests) => { - let winTop = window; - try { - window.top.location.toString(); - winTop = window.top; - } catch (e) { - utils.logMessage(e); - }; - const location = utils.getTopWindowLocation(); - const placements = []; - const len = validBidRequests.length; - for (let i = 0; i < len; i++) { - const bid = validBidRequests[i]; - const placement = { - placementId: bid.params.placementId, - bidId: bid.bidId, - sizes: bid.sizes, - type: bid.params.type - }; - placements.push(placement); - } - return { - method: 'POST', - url: URL, - data: { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'secure': (location.protocol === 'https:') ? 1 : 0, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - } - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: (bidResponses) => { - const res = []; - bidResponses = bidResponses.body; - const len = bidResponses.length; - for (let i = 0; i < len; i++) { - const bid = bidResponses[i]; - if (isBidResponseValid(bid)) { - res.push(bid); - } - } - return res; - }, - - getUserSyncs: () => { - return [{ - type: 'image', - url: URL_SYNC - }]; - } -}; - -registerBidder(spec); diff --git a/modules/brainyBidAdapter.js b/modules/brainyBidAdapter.js deleted file mode 100644 index a5d076d8fd0..00000000000 --- a/modules/brainyBidAdapter.js +++ /dev/null @@ -1,154 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; - -const BIDDER_CODE = 'brainy'; -const BASE_URL = '//proparm.jp/ssp/p/pbjs'; - -/** - * Check if the browser supports flash - * 0 is return if it dosen't support flash - * @return {int} Flash version - */ -/** - * 接続元のブラウザがフラッシュに対応しているか判定 - * 対応していなければ0を返す - * @return {int} フラッシュのバージョン - */ -function _getFlash() { - try { - var _mac = (navigator.userAgent.indexOf('Mac') != -1); - if (document.all) { - if (_mac) { - if (window['sample']) { - return ((window['sample'].FlashVersion() & 0xffff0000) >> 16); - } - } else { - var _axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); - return Math.floor(_axo.FlashVersion() / 0x10000); - } - } else { - if (navigator.plugins && navigator.plugins['Shockwave Flash']) { - var info = navigator.plugins['Shockwave Flash'].description.split(' '); - var _v = parseInt(info[2]); - if (!isNaN(_v)) { - return _v; - } - } - } - } catch (e) {} - return 0; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - /** - * Check if the bid account ID and slotID is valid - * @param {object} bid the brainy bid to validate - * @return {boolean} - */ - /** - * adUnits.bidに値が入っているかを判断する - * @param {object} bid 検証する入札リクエスト - * @return {boolean} - */ - isBidRequestValid: function(bid) { - return !!(bid && bid.params && bid.params.accountID && bid.params.slotID); - }, - - /** - * Format the bid request object for our endpoint - * @param {BidRequest[]} bidRequests Array of brainy bidders - * @return object of parameters for Prebid AJAX request - */ - /** - * 入札リクエストをbrainyに対応するように整形する - * @param {BidRequest[]} bidRequests 入札のための配列 - * @return Prebid AJAX用に整形したオブジェクト - */ - buildRequests: function(validBidRequests) { - var bidRequests = []; - for (var i = 0, len = validBidRequests.length; i < len; i++) { - var bid = validBidRequests[i]; - var accountID = utils.getBidIdParameter('accountID', bid.params); - var slotID = utils.getBidIdParameter('slotID', bid.params); - var url = utils.getTopWindowUrl(); - var flash = _getFlash(); - var nocache = new Date().getTime() + Math.floor(Math.random() * 100000000); - var requestURL; - - requestURL = '_aid=' + accountID + '&'; - requestURL += '_slot=' + slotID + '&'; - requestURL += '_url=' + url + '&'; - requestURL += '_flash=' + flash + '&'; - requestURL += '_nocache=' + nocache; - - bidRequests.push({ - method: 'GET', - url: BASE_URL, - data: requestURL, - bidRequest: bid - }) - } - return bidRequests; - }, - - /** - * Format brainy responses as Prebid bid responses - * @param {String} brainyResponseObj A successful response from brainy. - * @param {object} request Object received from web page - * @return {object} An array of formatted bids. - */ - /** - * brainySSPからのレスポンスを解釈するメソッド - * @param {String} brainyResponseObj SSPから受け取った文字列 - * @param {object} request メディアから受け取ったオブジェクト - * @return {object} 分解、再格納したbidResponses - */ - interpretResponse: function (brainyResponseObj, request) { - var bidResponses = []; - var bidRequest = request.bidRequest; - var responseBody = brainyResponseObj ? brainyResponseObj.body : {}; - - bidResponses.push({ - requestId: bidRequest.bidId, - cpm: responseBody.cpm || 0, - width: responseBody.width, - height: responseBody.height, - creativeId: responseBody.adID, - currency: 'USD', - netRevenue: true, - ttl: 1000, - mediaType: BANNER, - ad: responseBody.src - }); - - return bidResponses; - }, - - /** - * SyncURLがある場合にレスポンスを解析してURLを返す - * @param {object} syncOptions Syncの設定 - * @param {object} serverResponses SSPからのレスポンス - * @return {object} 表示タイプとURLが入ったオブジェクト - */ - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - if (syncOptions.pixelEnabled) { - const brainyResponseObj = serverResponses[0].body; - if (!brainyResponseObj) { - return []; - } - if (brainyResponseObj.syncUrl && brainyResponseObj.syncUrl != 'null' && brainyResponseObj.syncUrl.length > 0) { - syncs.push({ - type: 'image', - url: brainyResponseObj.syncUrl - }); - } - } - return syncs; - } -}; -registerBidder(spec); diff --git a/modules/bridgewellBidAdapter.js b/modules/bridgewellBidAdapter.js index cac827e5a5d..a95a19f0402 100644 --- a/modules/bridgewellBidAdapter.js +++ b/modules/bridgewellBidAdapter.js @@ -1,10 +1,10 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, NATIVE} from '../src/mediaTypes'; -import find from 'core-js/library/fn/array/find'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE } from '../src/mediaTypes.js'; +import find from 'core-js/library/fn/array/find.js'; const BIDDER_CODE = 'bridgewell'; -const REQUEST_ENDPOINT = '//rec.scupio.com/recweb/prebid.aspx?cb=' + Math.random(); +const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb=' + Math.random(); const BIDDER_VERSION = '0.0.2'; export const spec = { @@ -17,23 +17,11 @@ export const spec = { * @param {BidRequest} bid The bid params to validate. * @return boolean True if this is a valid bid, and false otherwise. */ - isBidRequestValid: function(bid) { + isBidRequestValid: function (bid) { let valid = false; - let typeOfCpmWeight; - - if (bid && bid.params) { - if (bid.params.ChannelID) { - // cpmWeight is optinal parameter and should above than zero - typeOfCpmWeight = typeof bid.params.cpmWeight; - if (typeOfCpmWeight === 'undefined') { - bid.params.cpmWeight = 1; - valid = true; - } else if (typeOfCpmWeight === 'number' && bid.params.cpmWeight > 0) { - valid = true; - } else { - valid = false; - } - } + + if (bid && bid.params && bid.params.ChannelID) { + valid = true; } return valid; @@ -45,11 +33,12 @@ export const spec = { * @param {BidRequest[]} validBidRequests - an array of bids * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(validBidRequests) { + buildRequests: function (validBidRequests, bidderRequest) { const adUnits = []; - utils._each(validBidRequests, function(bid) { + utils._each(validBidRequests, function (bid) { adUnits.push({ ChannelID: bid.params.ChannelID, + adUnitCode: bid.adUnitCode, mediaTypes: bid.mediaTypes || { banner: { sizes: bid.sizes @@ -58,6 +47,11 @@ export const spec = { }); }); + let topUrl = ''; + if (bidderRequest && bidderRequest.refererInfo) { + topUrl = bidderRequest.refererInfo.referer; + } + return { method: 'POST', url: REQUEST_ENDPOINT, @@ -67,8 +61,8 @@ export const spec = { bridgewell: BIDDER_VERSION }, inIframe: utils.inIframe(), - url: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), + url: topUrl, + referrer: getTopWindowReferrer(), adUnits: adUnits }, validBidRequests: validBidRequests @@ -82,40 +76,41 @@ export const spec = { * @param {*} bidRequest * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function(serverResponse, bidRequest) { + interpretResponse: function (serverResponse, bidRequest) { const bidResponses = []; // map responses to requests - utils._each(bidRequest.validBidRequests, function(req) { + utils._each(bidRequest.validBidRequests, function (req) { const bidResponse = {}; if (!serverResponse.body) { return; } - let matchedResponse = find(serverResponse.body, function(res) { + let matchedResponse = find(serverResponse.body, function (res) { let valid = false; - if (!!res && !res.consumed) { // response exists and not consumed - if (res.width && res.height) { - let mediaTypes = req.mediaTypes; - // for prebid 1.0 and later usage, mediaTypes.banner.sizes - let sizes = mediaTypes && mediaTypes.banner && mediaTypes.banner.sizes ? mediaTypes.banner.sizes : req.sizes; - if (sizes) { - let sizeValid; - let width = res.width; - let height = res.height; - // check response size validation - if (typeof sizes[0] === 'number') { // for foramt Array[Number] check - sizeValid = width === sizes[0] && height === sizes[1]; - } else { // for format Array[Array[Number]] check - sizeValid = find(sizes, function(size) { - return (width === size[0] && height === size[1]); - }); - } - - if (sizeValid || (mediaTypes && mediaTypes.native)) { // dont care native sizes - valid = true; + if (res && !res.consumed) { + let mediaTypes = req.mediaTypes; + let adUnitCode = req.adUnitCode; + if (res.adUnitCode) { + return res.adUnitCode === adUnitCode; + } else if (res.width && res.height && mediaTypes) { + if (mediaTypes.native) { // dont care native sizes + valid = true; + } else if (mediaTypes.banner) { + if (mediaTypes.banner.sizes) { + let width = res.width; + let height = res.height; + let sizes = mediaTypes.banner.sizes; + // check response size validation + if (typeof sizes[0] === 'number') { // for foramt Array[Number] check + valid = width === sizes[0] && height === sizes[1]; + } else { // for format Array[Array[Number]] check + valid = !!find(sizes, function (size) { + return (width === size[0] && height === size[1]); + }); + } } } } @@ -139,7 +134,7 @@ export const spec = { } bidResponse.requestId = req.bidId; - bidResponse.cpm = matchedResponse.cpm * req.params.cpmWeight; + bidResponse.cpm = matchedResponse.cpm; bidResponse.width = matchedResponse.width; bidResponse.height = matchedResponse.height; bidResponse.ttl = matchedResponse.ttl; @@ -266,4 +261,12 @@ export const spec = { } }; +function getTopWindowReferrer() { + try { + return window.top.document.referrer; + } catch (e) { + return ''; + } +} + registerBidder(spec); diff --git a/modules/bridgewellBidAdapter.md b/modules/bridgewellBidAdapter.md index 014be62ccef..6bcab4b8820 100644 --- a/modules/bridgewellBidAdapter.md +++ b/modules/bridgewellBidAdapter.md @@ -1,8 +1,8 @@ # Overview -Module Name: Bridgewell Bidder Adapter -Module Type: Bidder Adapter -Maintainer: kuchunchou@bridgewell.com +Module Name: Bridgewell Bidder Adapter +Module Type: Bidder Adapter +Maintainer: scupio@bridgewell.com # Description @@ -12,34 +12,15 @@ Module that connects to Bridgewell demand source to fetch bids. ``` var adUnits = [{ code: 'test-div', - sizes: [ - [300, 250] - ], - bids: [{ - bidder: 'bridgewell', - params: { - ChannelID: 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ' - } - }] - }, { - code: 'test-div', - sizes: [ - [728, 90] - ], - bids: [{ - bidder: 'bridgewell', - params: { - ChannelID: 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - cpmWeight: 1.5 + mediaTypes: { + banner: { + sizes: [300, 250] } - }] - }, { - code: 'test-div', - sizes: [728, 90], + }, bids: [{ bidder: 'bridgewell', params: { - ChannelID: 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ' + ChannelID: 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ' } }] }, { diff --git a/modules/brightcomBidAdapter.js b/modules/brightcomBidAdapter.js index 626aa99f5de..a4b013a2fe2 100644 --- a/modules/brightcomBidAdapter.js +++ b/modules/brightcomBidAdapter.js @@ -1,8 +1,7 @@ -import * as utils from '../src/utils'; -import * as url from '../src/url'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; -import { config } from '../src/config'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'brightcom'; const URL = 'https://brightcombid.marphezis.com/hb'; @@ -25,9 +24,10 @@ function buildRequests(bidReqs, bidderRequest) { const brightcomImps = []; const publisherId = utils.getBidIdParameter('publisherId', bidReqs[0].params); utils._each(bidReqs, function (bid) { - bid.sizes = ((utils.isArray(bid.sizes) && utils.isArray(bid.sizes[0])) ? bid.sizes : [bid.sizes]); - bid.sizes = bid.sizes.filter(size => utils.isArray(size)); - const processedSizes = bid.sizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)})); + let bidSizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes; + bidSizes = ((utils.isArray(bidSizes) && utils.isArray(bidSizes[0])) ? bidSizes : [bidSizes]); + bidSizes = bidSizes.filter(size => utils.isArray(size)); + const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)})); const element = document.getElementById(bid.adUnitCode); const minSize = _getMinSize(processedSizes); @@ -56,7 +56,7 @@ function buildRequests(bidReqs, bidderRequest) { id: utils.getUniqueIdentifierStr(), imp: brightcomImps, site: { - domain: url.parse(referrer).host, + domain: utils.parseUrl(referrer).host, page: referrer, publisher: { id: publisherId diff --git a/modules/brightcomBidAdapter.md b/modules/brightcomBidAdapter.md index badc6ea94a4..9f9aa0e5dd7 100644 --- a/modules/brightcomBidAdapter.md +++ b/modules/brightcomBidAdapter.md @@ -16,17 +16,25 @@ Brightcom's adapter integration to the Prebid library. var adUnits = [ { code: 'test-leaderboard', - sizes: [[728, 90]], + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, bids: [{ bidder: 'brightcom', params: { - publisherId: 2141020, - bidFloor: 0.01 + publisherId: 2141020, + bidFloor: 0.01 } }] }, { code: 'test-banner', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bids: [{ bidder: 'brightcom', params: { diff --git a/modules/britepoolIdSystem.js b/modules/britepoolIdSystem.js new file mode 100644 index 00000000000..17a39e96aad --- /dev/null +++ b/modules/britepoolIdSystem.js @@ -0,0 +1,132 @@ +/** + * This module adds BritePoolId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/britepoolIdSystem + * @requires module:modules/userId + */ + +import * as utils from '../src/utils.js' +import {ajax} from '../src/ajax.js'; +import {submodule} from '../src/hook.js'; + +/** @type {Submodule} */ +export const britepoolIdSubmodule = { + /** + * Used to link submodule with config + * @type {string} + */ + name: 'britepoolId', + /** + * Decode the stored id value for passing to bid requests + * @function + * @param {string} value + * @returns {{britepoolid:string}} + */ + decode(value) { + return (value && typeof value['primaryBPID'] === 'string') ? { 'britepoolid': value['primaryBPID'] } : null; + }, + /** + * Performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleParams} [configParams] + * @returns {function(callback:function)} + */ + getId(submoduleConfigParams, consentData) { + const { params, headers, url, getter, errors } = britepoolIdSubmodule.createParams(submoduleConfigParams, consentData); + let getterResponse = null; + if (typeof getter === 'function') { + getterResponse = getter(params); + // First let's rule out that the response is not a function + if (typeof getterResponse !== 'function') { + // Optimization to return value from getter + return { + id: britepoolIdSubmodule.normalizeValue(getterResponse) + }; + } + } + // Return for async operation + return { + callback: function(callback) { + if (errors.length > 0) { + errors.forEach(error => utils.logError(error)); + callback(); + return; + } + if (getterResponse) { + // Resolve the getter function response + try { + getterResponse(function(response) { + callback(britepoolIdSubmodule.normalizeValue(response)); + }); + } catch (error) { + if (error !== '') utils.logError(error); + callback(); + } + } else { + ajax(url, { + success: response => { + const responseObj = britepoolIdSubmodule.normalizeValue(response); + callback(responseObj ? { primaryBPID: responseObj.primaryBPID } : null); + }, + error: error => { + if (error !== '') utils.logError(error); + callback(); + } + }, JSON.stringify(params), { customHeaders: headers, contentType: 'application/json', method: 'POST', withCredentials: true }); + } + } + } + }, + /** + * Helper method to create params for our API call + * @param {SubmoduleParams} [configParams] + * @returns {object} Object with parsed out params + */ + createParams(submoduleConfigParams, consentData) { + let errors = []; + const headers = {}; + let params = Object.assign({}, submoduleConfigParams); + if (params.getter) { + // Custom getter will not require other params + if (typeof params.getter !== 'function') { + errors.push(`userIdTargeting - britepoolId submodule requires getter to be a function`); + return { errors }; + } + } else { + if (params.api_key) { + // Add x-api-key into the header + headers['x-api-key'] = params.api_key; + } + } + const url = params.url || 'https://api.britepool.com/v1/britepool/id'; + const getter = params.getter; + delete params.api_key; + delete params.url; + delete params.getter; + return { + params, + headers, + url, + getter, + errors + }; + }, + /** + * Helper method to normalize a JSON value + */ + normalizeValue(value) { + let valueObj = null; + if (typeof value === 'object') { + valueObj = value; + } else if (typeof value === 'string') { + try { + valueObj = JSON.parse(value); + } catch (error) { + utils.logError(error); + } + } + return valueObj; + } +}; + +submodule('userId', britepoolIdSubmodule); diff --git a/modules/britepoolIdSystem.md b/modules/britepoolIdSystem.md new file mode 100644 index 00000000000..89287aed7ca --- /dev/null +++ b/modules/britepoolIdSystem.md @@ -0,0 +1,42 @@ +## BritePool User ID Submodule + +BritePool User ID Module. For assistance setting up your module please contact us at [prebid@britepool.com](prebid@britepool.com). + +### Prebid Params + +Individual params may be set for the BritePool User ID Submodule. At least one identifier must be set in the params. +``` +pbjs.setConfig({ + usersync: { + userIds: [{ + name: 'britepoolId', + storage: { + name: 'britepoolid', + type: 'cookie', + expires: 30 + }, + params: { + url: 'https://sandbox-api.britepool.com/v1/britepool/id', // optional + api_key: '3fdbe297-3690-4f5c-9e11-ee9186a6d77c', // provided by britepool + hash: '31c5543c1734d25c7206f5fd591525d0295bec6fe84ff82f946a34fe970a1e66', // example hash identifier (sha256) + ssid: '221aa074-57fc-453b-81f0-6c74f628cd5c' // example identifier + } + }] + } +}); +``` +## Parameter Descriptions for the `usersync` Configuration Section +The below parameters apply only to the BritePool User ID Module integration. + +| Param under usersync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | ID value for the BritePool module - `"britepoolId"` | `"britepoolId"` | +| params | Required | Object | Details for BritePool initialization. | | +| params.api_key | Required | String |BritePool API Key provided by BritePool | "3fdbe297-3690-4f5c-9e11-ee9186a6d77c" | +| params.url | Optional | String |BritePool API url | "https://sandbox-api.britepool.com/v1/britepool/id" | +| params.identifier | Required | String | Where identifier in the params object is the key name. At least one identifier is required. Available Identifiers `aaid` `dtid` `idfa` `ilid` `luid` `mmid` `msid` `mwid` `rida` `ssid` `hash` | `params.ssid` `params.aaid` | +| storage | Required | Object | The publisher must specify the local storage in which to store the results of the call to get the user ID. This can be either cookie or HTML5 storage. | | +| storage.type | Required | String | This is where the results of the user ID will be stored. The recommended method is `localStorage` by specifying `html5`. | `"html5"` | +| storage.name | Required | String | The name of the cookie or html5 local storage where the user ID will be stored. | `"britepoolid"` | +| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. | `365` | +| value | Optional | Object | Used only if the page has a separate mechanism for storing the BritePool ID. The value is an object containing the values to be sent to the adapters. In this scenario, no URL is called and nothing is added to local storage | `{"primaryBPID": "eb33b0cb-8d35-4722-b9c0-1a31d4064888"}` | diff --git a/modules/browsiRtdProvider.js b/modules/browsiRtdProvider.js new file mode 100644 index 00000000000..3765b6603af --- /dev/null +++ b/modules/browsiRtdProvider.js @@ -0,0 +1,318 @@ +/** + * This module adds browsi provider to the eal time data module + * The {@link module:modules/realTimeData} module is required + * The module will fetch predictions from browsi server + * The module will place browsi bootstrap script on page + * @module modules/browsiProvider + * @requires module:modules/realTimeData + */ + +/** + * @typedef {Object} ModuleParams + * @property {string} siteKey + * @property {string} pubKey + * @property {string} url + * @property {?string} keyName + * @property {?number} auctionDelay + * @property {?number} timeout + */ + +import {config} from '../src/config.js'; +import * as utils from '../src/utils.js'; +import {submodule} from '../src/hook.js'; +import {ajaxBuilder} from '../src/ajax.js'; +import {loadExternalScript} from '../src/adloader.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); + +/** @type {string} */ +const MODULE_NAME = 'realTimeData'; +/** @type {number} */ +const DEF_TIMEOUT = 1000; +/** @type {ModuleParams} */ +let _moduleParams = {}; +/** @type {null|Object} */ +let _data = null; +/** @type {null | function} */ +let _dataReadyCallback = null; + +/** + * add browsi script to page + * @param {Object} data + */ +export function addBrowsiTag(data) { + let script = loadExternalScript(data.u, 'browsi'); + script.async = true; + script.setAttribute('data-sitekey', _moduleParams.siteKey); + script.setAttribute('data-pubkey', _moduleParams.pubKey); + script.setAttribute('prebidbpt', 'true'); + script.setAttribute('id', 'browsi-tag'); + script.setAttribute('src', data.u); + script.prebidData = utils.deepClone(data); + if (_moduleParams.keyName) { + script.prebidData.kn = _moduleParams.keyName; + } + return script; +} + +/** + * collect required data from page + * send data to browsi server to get predictions + */ +function collectData() { + const win = window.top; + const doc = win.document; + let browsiData = null; + try { + browsiData = storage.getDataFromLocalStorage('__brtd'); + } catch (e) { + utils.logError('unable to parse __brtd'); + } + + let predictorData = { + ...{ + sk: _moduleParams.siteKey, + sw: (win.screen && win.screen.width) || -1, + sh: (win.screen && win.screen.height) || -1, + url: encodeURIComponent(`${doc.location.protocol}//${doc.location.host}${doc.location.pathname}`), + }, + ...(browsiData ? {us: browsiData} : {us: '{}'}), + ...(document.referrer ? {r: document.referrer} : {}), + ...(document.title ? {at: document.title} : {}) + }; + getPredictionsFromServer(`//${_moduleParams.url}/prebid?${toUrlParams(predictorData)}`); +} + +export function setData(data) { + _data = data; + + if (typeof _dataReadyCallback === 'function') { + _dataReadyCallback(_data); + _dataReadyCallback = null; + } +} + +/** + * wait for data from server + * call callback when data is ready + * @param {function} callback + */ +function waitForData(callback) { + if (_data) { + _dataReadyCallback = null; + callback(_data); + } else { + _dataReadyCallback = callback; + } +} + +/** + * filter server data according to adUnits received + * call callback (onDone) when data is ready + * @param {adUnit[]} adUnits + * @param {function} onDone callback function + */ +function sendDataToModule(adUnits, onDone) { + try { + waitForData(_predictionsData => { + const _predictions = _predictionsData.p; + if (!_predictions || !Object.keys(_predictions).length) { + return onDone({}); + } + const slots = getAllSlots(); + if (!slots || !slots.length) { + return onDone({}); + } + let dataToReturn = adUnits.reduce((rp, cau) => { + const adUnitCode = cau && cau.code; + if (!adUnitCode) { return rp } + const adSlot = getSlotById(adUnitCode); + if (!adSlot) { return rp } + const macroId = getMacroId(_predictionsData.pmd, adUnitCode, adSlot); + const predictionData = _predictions[macroId]; + if (!predictionData) { return rp } + + if (predictionData.p) { + if (!isIdMatchingAdUnit(adUnitCode, adSlot, predictionData.w)) { + return rp; + } + rp[adUnitCode] = getKVObject(predictionData.p, _predictionsData.kn); + } + return rp; + }, {}); + return onDone(dataToReturn); + }); + } catch (e) { + onDone({}); + } +} + +/** + * get all slots on page + * @return {Object[]} slot GoogleTag slots + */ +function getAllSlots() { + return utils.isGptPubadsDefined && window.googletag.pubads().getSlots(); +} +/** + * get prediction and return valid object for key value set + * @param {number} p + * @param {string?} keyName + * @return {Object} key:value + */ +function getKVObject(p, keyName) { + const prValue = p < 0 ? 'NA' : (Math.floor(p * 10) / 10).toFixed(2); + let prObject = {}; + prObject[((_moduleParams['keyName'] || keyName).toString())] = prValue.toString(); + return prObject; +} +/** + * check if placement id matches one of given ad units + * @param {number} id placement id + * @param {Object} slot google slot + * @param {string[]} whitelist ad units + * @return {boolean} + */ +export function isIdMatchingAdUnit(id, slot, whitelist) { + if (!whitelist || !whitelist.length) { + return true; + } + const slotAdUnits = slot.getAdUnitPath(); + return whitelist.indexOf(slotAdUnits) !== -1; +} + +/** + * get GPT slot by placement id + * @param {string} id placement id + * @return {?Object} + */ +function getSlotById(id) { + const slots = getAllSlots(); + if (!slots || !slots.length) { + return null; + } + return slots.filter(s => s.getSlotElementId() === id)[0] || null; +} + +/** + * generate id according to macro script + * @param {string} macro replacement macro + * @param {string} id placement id + * @param {Object} slot google slot + * @return {?Object} + */ +function getMacroId(macro, id, slot) { + if (macro) { + try { + const macroResult = evaluate(macro, slot.getSlotElementId(), slot.getAdUnitPath(), (match, p1) => { + return (p1 && slot.getTargeting(p1).join('_')) || 'NA'; + }); + return macroResult; + } catch (e) { + utils.logError(`failed to evaluate: ${macro}`); + } + } + return id; +} + +function evaluate(macro, divId, adUnit, replacer) { + let macroResult = macro.p + .replace(/['"]+/g, '') + .replace(//g, divId); + + if (adUnit) { + macroResult = macroResult.replace(//g, adUnit); + } + if (replacer) { + macroResult = macroResult.replace(//g, replacer); + } + if (macro.s) { + macroResult = macroResult.substring(macro.s.s, macro.s.e); + } + return macroResult; +} +/** + * XMLHttpRequest to get data form browsi server + * @param {string} url server url with query params + */ +function getPredictionsFromServer(url) { + let ajax = ajaxBuilder(_moduleParams.auctionDelay || _moduleParams.timeout || DEF_TIMEOUT); + + ajax(url, + { + success: function (response, req) { + if (req.status === 200) { + try { + const data = JSON.parse(response); + if (data && data.p && data.kn) { + setData({p: data.p, kn: data.kn, pmd: data.pmd}); + } else { + setData({}); + } + addBrowsiTag(data); + } catch (err) { + utils.logError('unable to parse data'); + setData({}) + } + } else if (req.status === 204) { + // unrecognized site key + setData({}); + } + }, + error: function () { + setData({}); + utils.logError('unable to get prediction data'); + } + } + ); +} + +/** + * serialize object and return query params string + * @param {Object} data + * @return {string} + */ +function toUrlParams(data) { + return Object.keys(data) + .map(key => key + '=' + encodeURIComponent(data[key])) + .join('&'); +} + +/** @type {RtdSubmodule} */ +export const browsiSubmodule = { + /** + * used to link submodule with realTimeData + * @type {string} + */ + name: 'browsi', + /** + * get data and send back to realTimeData module + * @function + * @param {adUnit[]} adUnits + * @param {function} onDone + */ + getData: sendDataToModule +}; + +export function init(config) { + const confListener = config.getConfig(MODULE_NAME, ({realTimeData}) => { + try { + _moduleParams = realTimeData.dataProviders && realTimeData.dataProviders.filter( + pr => pr.name && pr.name.toLowerCase() === 'browsi')[0].params; + _moduleParams.auctionDelay = realTimeData.auctionDelay; + _moduleParams.timeout = realTimeData.timeout; + } catch (e) { + _moduleParams = {}; + } + if (_moduleParams.siteKey && _moduleParams.pubKey && _moduleParams.url) { + confListener(); + collectData(); + } else { + utils.logError('missing params for Browsi provider'); + } + }); +} + +submodule('realTimeData', browsiSubmodule); +init(config); diff --git a/modules/bucksenseBidAdapter.js b/modules/bucksenseBidAdapter.js index 12a9e287f38..3f327e62121 100644 --- a/modules/bucksenseBidAdapter.js +++ b/modules/bucksenseBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const WHO = 'BKSHBID-005'; const BIDDER_CODE = 'bucksense'; -const URL = 'https://prebid.bksn.se:445/prebidjs/'; +const URL = 'https://prebid.bksn.se/prebidjs/'; export const spec = { code: BIDDER_CODE, diff --git a/modules/buzzoolaBidAdapter.js b/modules/buzzoolaBidAdapter.js index da2a3b30c2e..f87607657c3 100644 --- a/modules/buzzoolaBidAdapter.js +++ b/modules/buzzoolaBidAdapter.js @@ -1,8 +1,8 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, VIDEO} from '../src/mediaTypes'; -import {Renderer} from '../src/Renderer'; -import {OUTSTREAM} from '../src/video'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {Renderer} from '../src/Renderer.js'; +import {OUTSTREAM} from '../src/video.js'; const BIDDER_CODE = 'buzzoola'; const ENDPOINT = 'https://exchange.buzzoola.com/ssp/prebidjs'; diff --git a/modules/byplayBidAdapter.js b/modules/byplayBidAdapter.js new file mode 100644 index 00000000000..6133cdfa647 --- /dev/null +++ b/modules/byplayBidAdapter.js @@ -0,0 +1,67 @@ +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { Renderer } from '../src/Renderer.js'; +import { VIDEO } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'byplay'; +const ENDPOINT_URL = 'https://prebid.byplay.net/bidder'; +const VIDEO_PLAYER_URL = 'https://cdn.byplay.net/prebid-byplay-v2.js'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [VIDEO], + isBidRequestValid: (bid) => { + return !!bid.params.sectionId; + }, + buildRequests: function(validBidRequests) { + return validBidRequests.map(req => { + const payload = { + requestId: req.bidId, + sectionId: req.params.sectionId, + ...(req.params.env ? { env: req.params.env } : {}) + }; + + return { + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(payload), + options: { + withCredentials: false + } + }; + }); + }, + interpretResponse: (serverResponse, bidderRequest) => { + const response = serverResponse.body; + const data = JSON.parse(bidderRequest.data); + const bidResponse = { + requestId: data.requestId, + cpm: response.cpm, + width: response.width, + height: response.height, + creativeId: response.creativeId || '0', + ttl: config.getConfig('_bidderTimeout'), + currency: 'JPY', + netRevenue: response.netRevenue, + mediaType: VIDEO, + vastXml: response.vastXml, + renderer: createRenderer() + }; + + return [bidResponse]; + } +}; + +function createRenderer() { + const renderer = Renderer.install({ url: VIDEO_PLAYER_URL }); + + renderer.setRender(bid => { + bid.renderer.push(() => { + window.adtagRender(bid); + }); + }); + + return renderer; +} + +registerBidder(spec); diff --git a/modules/byplayBidAdapter.md b/modules/byplayBidAdapter.md new file mode 100644 index 00000000000..67fb9c40d35 --- /dev/null +++ b/modules/byplayBidAdapter.md @@ -0,0 +1,37 @@ +# Overview + +``` +Module Name: ByPlay Bidder Adapter +Module Type: Bidder Adapter +Maintainer: byplayers@tsumikiinc.com +``` + +# Description + +Connects to ByPlay exchange for bids. + +ByPlay bid adapter supports Video. + +# Test Parameters +``` + const adUnits = [ + { + code: 'byplay-ad', + mediaTypes: { + video: { + playerSize: [400, 225], + context: 'outstream' + } + }, + bids: [ + { + bidder: 'byplay', + params: { + sectionId: '7986', + env: 'dev' + } + } + ] + } + ]; +``` diff --git a/modules/c1xBidAdapter.js b/modules/c1xBidAdapter.js index 1e8d3cf2e0a..8e1f1487ba7 100644 --- a/modules/c1xBidAdapter.js +++ b/modules/c1xBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; -import { userSync } from '../src/userSync'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import { userSync } from '../src/userSync.js'; const BIDDER_CODE = 'c1x'; const URL = 'https://ht.c1exchange.com/ht'; -const PIXEL_ENDPOINT = '//px.c1exchange.com/pubpixel/'; +const PIXEL_ENDPOINT = 'https://px.c1exchange.com/pubpixel/'; const LOG_MSG = { invalidBid: 'C1X: [ERROR] bidder returns an invalid bid', noSite: 'C1X: [ERROR] no site id supplied', @@ -41,7 +41,6 @@ export const c1xAdapter = { // flattened tags in a tag object tagObj = c1xTags.reduce((current, next) => Object.assign(current, next)); const pixelId = tagObj.pixelId; - const useSSL = document.location.protocol; payload = { adunits: adunits.toString(), @@ -58,7 +57,7 @@ export const c1xAdapter = { } if (pixelId) { - pixelUrl = (useSSL ? 'https:' : 'http:') + PIXEL_ENDPOINT + pixelId; + pixelUrl = PIXEL_ENDPOINT + pixelId; if (payload.consent_required) { pixelUrl += '&gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? 1 : 0); pixelUrl += '&consent=' + encodeURIComponent(bidderRequest.gdprConsent.consentString || ''); diff --git a/modules/categoryTranslation.js b/modules/categoryTranslation.js index 091b16c8211..5342220d13a 100644 --- a/modules/categoryTranslation.js +++ b/modules/categoryTranslation.js @@ -11,12 +11,14 @@ * If publisher has not defined translation file than prebid will use default prebid translation file provided here //cdn.jsdelivr.net/gh/prebid/category-mapping-file@1/freewheel-mapping.json */ -import { config } from '../src/config'; -import { setupBeforeHookFnOnce, hook } from '../src/hook'; -import { ajax } from '../src/ajax'; -import { timestamp, logError, setDataInLocalStorage, getDataFromLocalStorage } from '../src/utils'; -import { addBidResponse } from '../src/auction'; +import { config } from '../src/config.js'; +import { setupBeforeHookFnOnce, hook } from '../src/hook.js'; +import { ajax } from '../src/ajax.js'; +import { timestamp, logError } from '../src/utils.js'; +import { addBidResponse } from '../src/auction.js'; +import { getCoreStorageManager } from '../src/storageManager.js'; +export const storage = getCoreStorageManager('categoryTranslation'); const DEFAULT_TRANSLATION_FILE_URL = 'https://cdn.jsdelivr.net/gh/prebid/category-mapping-file@1/freewheel-mapping.json'; const DEFAULT_IAB_TO_FW_MAPPING_KEY = 'iabToFwMappingkey'; const DEFAULT_IAB_TO_FW_MAPPING_KEY_PUB = 'iabToFwMappingkeyPub'; @@ -43,7 +45,7 @@ export function getAdserverCategoryHook(fn, adUnitCode, bid) { let localStorageKey = (config.getConfig('brandCategoryTranslation.translationFile')) ? DEFAULT_IAB_TO_FW_MAPPING_KEY_PUB : DEFAULT_IAB_TO_FW_MAPPING_KEY; if (bid.meta && !bid.meta.adServerCatId) { - let mapping = getDataFromLocalStorage(localStorageKey); + let mapping = storage.getDataFromLocalStorage(localStorageKey); if (mapping) { try { mapping = JSON.parse(mapping); @@ -65,7 +67,7 @@ export function getAdserverCategoryHook(fn, adUnitCode, bid) { export function initTranslation(url, localStorageKey) { setupBeforeHookFnOnce(addBidResponse, getAdserverCategoryHook, 50); - let mappingData = getDataFromLocalStorage(localStorageKey); + let mappingData = storage.getDataFromLocalStorage(localStorageKey); if (!mappingData || timestamp() < mappingData.lastUpdated + refreshInDays * 24 * 60 * 60 * 1000) { ajax(url, { @@ -73,7 +75,7 @@ export function initTranslation(url, localStorageKey) { try { response = JSON.parse(response); response['lastUpdated'] = timestamp(); - setDataInLocalStorage(localStorageKey, JSON.stringify(response)); + storage.setDataInLocalStorage(localStorageKey, JSON.stringify(response)); } catch (error) { logError('Failed to parse translation mapping file'); } diff --git a/modules/ccxBidAdapter.js b/modules/ccxBidAdapter.js index 226ed44f6da..ee15d6bb3ec 100644 --- a/modules/ccxBidAdapter.js +++ b/modules/ccxBidAdapter.js @@ -1,6 +1,9 @@ -import * as utils from '../src/utils' -import { registerBidder } from '../src/adapters/bidderFactory' -import { config } from '../src/config' +import * as utils from '../src/utils.js' +import { registerBidder } from '../src/adapters/bidderFactory.js' +import { config } from '../src/config.js' +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); const BIDDER_CODE = 'ccx' const BID_URL = 'https://delivery.clickonometrics.pl/ortb/prebid/bid' const SUPPORTED_VIDEO_PROTOCOLS = [2, 3, 5, 6] @@ -15,9 +18,9 @@ function _getDeviceObj () { return device } -function _getSiteObj () { +function _getSiteObj (bidderRequest) { let site = {} - let url = config.getConfig('pageUrl') || utils.getTopWindowUrl() + let url = config.getConfig('pageUrl') || utils.deepAccess(window, 'location.href'); if (url.length > 0) { url = url.split('?')[0] } @@ -167,10 +170,26 @@ export const spec = { if (validBidRequests.length > 0) { let requestBody = {} requestBody.imp = [] - requestBody.site = _getSiteObj() + requestBody.site = _getSiteObj(bidderRequest) requestBody.device = _getDeviceObj() requestBody.id = bidderRequest.bids[0].auctionId - requestBody.ext = {'ce': (utils.cookiesAreEnabled() ? 1 : 0)} + requestBody.ext = {'ce': (storage.cookiesAreEnabled() ? 1 : 0)} + + // Attaching GDPR Consent Params + if (bidderRequest && bidderRequest.gdprConsent) { + requestBody.user = { + ext: { + consent: bidderRequest.gdprConsent.consentString + } + }; + + requestBody.regs = { + ext: { + gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0) + } + }; + } + utils._each(validBidRequests, function (bid) { requestBody.imp.push(_buildBid(bid)) }) diff --git a/modules/cedatoBidAdapter.js b/modules/cedatoBidAdapter.js index 155e6eda107..ab381698f01 100644 --- a/modules/cedatoBidAdapter.js +++ b/modules/cedatoBidAdapter.js @@ -1,20 +1,20 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); const BIDDER_CODE = 'cedato'; -const BID_URL = '//h.cedatoplayer.com/hb'; -const SYNC_URL = '//h.cedatoplayer.com/hb_usync?uid={UUID}'; -const COOKIE_NAME = 'hb-cedato-id'; -const UUID_LEN = 36; +const BID_URL = 'https://h.cedatoplayer.com/hb'; +const SYNC_URL = 'https://h.cedatoplayer.com/hb_usync'; const TTL = 10000; const CURRENCY = 'USD'; -const FIRST_PRICE = 1; const NET_REVENUE = true; export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function(bid) { return !!( @@ -22,104 +22,193 @@ export const spec = { bid.params && bid.params.player_id && utils.checkCookieSupport() && - utils.cookiesAreEnabled() + storage.cookiesAreEnabled() ); }, buildRequests: function(bidRequests, bidderRequest) { - const req = bidRequests[Math.floor(Math.random() * bidRequests.length)]; - const params = req.params; - const at = FIRST_PRICE; - const site = { id: params.player_id, domain: document.domain }; - const device = { ua: navigator.userAgent, ip: '' }; - const user = { id: getUserID() } + const site = { domain: document.domain }; + const device = { ua: navigator.userAgent, w: screen.width, h: screen.height }; const currency = CURRENCY; const tmax = bidderRequest.timeout; + const auctionId = bidderRequest.auctionId; + const auctionStart = bidderRequest.auctionStart; + const bidderRequestId = bidderRequest.bidderRequestId; const imp = bidRequests.map(req => { - const banner = { 'format': getFormats(utils.deepAccess(req, 'mediaTypes.banner.sizes')) }; - const bidfloor = params.bidfloor; + const banner = getMediaType(req, 'banner'); + const video = getMediaType(req, 'video'); + const params = req.params; const bidId = req.bidId; + const adUnitCode = req.adUnitCode; + const bidRequestsCount = req.bidRequestsCount; + const bidderWinsCount = req.bidderWinsCount; + const transactionId = req.transactionId; return { bidId, banner, - bidfloor, + video, + adUnitCode, + bidRequestsCount, + bidderWinsCount, + transactionId, + params }; }); const payload = { version: '$prebid.version$', - at, site, device, - user, imp, currency, tmax, + auctionId, + auctionStart, + bidderRequestId }; - if (bidderRequest && bidderRequest.gdprConsent) { - payload.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; + if (bidderRequest) { + payload.referer_info = bidderRequest.refererInfo; + payload.us_privacy = bidderRequest.uspConsent; + + if (bidderRequest.gdprConsent) { + payload.gdpr_consent = { + consent_string: bidderRequest.gdprConsent.consentString, + consent_required: bidderRequest.gdprConsent.gdprApplies + }; + } } - return { - method: 'POST', - url: BID_URL, - data: JSON.stringify(payload), - }; + return formatRequest(payload, bidderRequest); }, - interpretResponse: function(resp) { - if (resp.body === '') return []; - - const bids = resp.body.seatbid[0].bid.map(bid => { - const cpm = bid.price; - const requestId = bid.uuid; - const width = bid.w; - const height = bid.h; - const creativeId = bid.crid; - const dealId = bid.dealid; - const currency = resp.body.cur; - const netRevenue = NET_REVENUE; - const ttl = TTL; - const ad = bid.adm; + interpretResponse: function(resp, {bidderRequest}) { + resp = resp.body; + const bids = []; - return { - cpm, - requestId, - width, - height, - creativeId, - dealId, - currency, - netRevenue, - ttl, - ad, - }; + if (!resp) { + return bids; + } + + resp.seatbid[0].bid.map(serverBid => { + const bid = newBid(serverBid, bidderRequest); + bid.currency = resp.cur; + bids.push(bid); }); return bids; }, - getUserSyncs: function(syncOptions, resps, gdprConsent) { + getUserSyncs: function(syncOptions, resps, gdprConsent, uspConsent) { const syncs = []; if (syncOptions.iframeEnabled) { - syncs.push(getSync('iframe', gdprConsent)); + syncs.push(getSync('iframe', gdprConsent, uspConsent)); } else if (syncOptions.pixelEnabled) { - syncs.push(getSync('image', gdprConsent)); + syncs.push(getSync('image', gdprConsent, uspConsent)); } return syncs; } } -const getSync = (type, gdprConsent) => { - const uuid = getUserID(); +function getMediaType(req, type) { + const { mediaTypes } = req; + + if (!mediaTypes) { + return; + } + + switch (type) { + case 'banner': + if (mediaTypes.banner) { + const { sizes } = mediaTypes.banner; + return { + format: getFormats(sizes) + }; + } + break; + + case 'video': + if (mediaTypes.video) { + const { playerSize, context } = mediaTypes.video; + return { + context: context, + format: getFormats(playerSize) + }; + } + } +} + +function newBid(serverBid, bidderRequest) { + const bidRequest = utils.getBidRequest(serverBid.uuid, [bidderRequest]); + + const cpm = serverBid.price; + const requestId = serverBid.uuid; + const width = serverBid.w; + const height = serverBid.h; + const creativeId = serverBid.crid; + const dealId = serverBid.dealid; + const mediaType = serverBid.media_type; + const netRevenue = NET_REVENUE; + const ttl = TTL; + + const bid = { + cpm, + requestId, + width, + height, + mediaType, + creativeId, + dealId, + netRevenue, + ttl, + }; + + if (mediaType == 'video') { + const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); + + if (videoContext == 'instream') { + bid.vastUrl = serverBid.vast_url; + bid.vastImpUrl = serverBid.notify_url; + } + } else { + bid.ad = serverBid.adm; + } + + return bid; +} + +function formatRequest(payload, bidderRequest) { + const payloadByUrl = {}; + const requests = []; + + payload.imp.forEach(imp => { + const url = imp.params.bid_url || BID_URL; + if (!payloadByUrl[url]) { + payloadByUrl[url] = { + ...payload, + imp: [] + }; + } + payloadByUrl[url].imp.push(imp); + }); + + for (const url in payloadByUrl) { + requests.push({ + url, + method: 'POST', + data: JSON.stringify(payloadByUrl[url]), + bidderRequest + }); + } + + return requests; +} + +const getSync = (type, gdprConsent, uspConsent = '') => { const syncUrl = SYNC_URL; - let params = '&type=' + type; + let params = '?type=' + type + '&us_privacy=' + uspConsent; if (gdprConsent && typeof gdprConsent.consentString === 'string') { if (typeof gdprConsent.gdprApplies === 'boolean') { params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; @@ -129,26 +218,10 @@ const getSync = (type, gdprConsent) => { } return { type: type, - url: syncUrl.replace('{UUID}', uuid) + params, + url: syncUrl + params, }; } -const getUserID = () => { - const cookieName = COOKIE_NAME; - const uuidLen = UUID_LEN; - - const i = document.cookie.indexOf(cookieName); - - if (i === -1) { - const uuid = utils.generateUUID(); - document.cookie = `${cookieName}=${uuid}; path=/`; - return uuid; - } - - const j = i + cookieName.length + 1; - return document.cookie.substring(j, j + uuidLen); -}; - const getFormats = arr => arr.map((s) => { return { w: s[0], h: s[1] }; }); diff --git a/modules/cleanmedianetBidAdapter.js b/modules/cleanmedianetBidAdapter.js index 15871e1a6ae..a8f37450d68 100644 --- a/modules/cleanmedianetBidAdapter.js +++ b/modules/cleanmedianetBidAdapter.js @@ -1,11 +1,14 @@ -import * as utils from '../src/utils'; -import {parse} from '../src/url'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {config} from '../src/config'; -import {Renderer} from '../src/Renderer'; -import {BANNER, VIDEO} from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {Renderer} from '../src/Renderer.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; export const helper = { + getTopWindowDomain: function (url) { + const domainStart = url.indexOf('://') + '://'.length; + return url.substring(domainStart, url.indexOf('/', domainStart) < 0 ? url.length : url.indexOf('/', domainStart)); + }, startsWith: function (str, search) { return str.substr(0, search.length) === search; }, @@ -66,15 +69,22 @@ export const spec = { const rtbBidRequest = { id: auctionId, site: { - domain: parse(url).hostname, + domain: helper.getTopWindowDomain(url), page: url, ref: bidderRequest.refererInfo.referer }, device: { - ua: navigator.userAgent + ua: navigator.userAgent, + dnt: utils.getDNT() ? 1 : 0, + h: screen.height, + w: screen.width, + language: navigator.language }, imp: [], - ext: {} + ext: {}, + user: { + ext: {} + } }; if ( @@ -86,6 +96,16 @@ export const spec = { consent_string: bidderRequest.gdprConsent.consentString, consent_required: bidderRequest.gdprConsent.gdprApplies }; + rtbBidRequest.regs = { + ext: { + gdpr: bidderRequest.gdprConsent.gdprApplies === true ? 1 : 0 + } + }; + rtbBidRequest.user = { + ext: { + consent: bidderRequest.gdprConsent.consentString + } + } } const imp = { @@ -94,12 +114,7 @@ export const spec = { tagid: adUnitCode, bidfloor: params.bidfloor || 0, bidfloorcur: 'USD', - secure: helper.startsWith( - utils.getTopWindowUrl().toLowerCase(), - 'http://' - ) - ? 0 - : 1 + secure: 1 }; const hasFavoredMediaType = @@ -113,7 +128,7 @@ export const spec = { w: sizes.length ? sizes[0][0] : 300, h: sizes.length ? sizes[0][1] : 250, pos: params.pos || 0, - topframe: bidderRequest.refererInfo.reachedTop + topframe: utils.inIframe() ? 0 : 1 } }); rtbBidRequest.imp.push(bannerImp); @@ -179,7 +194,7 @@ export const spec = { cpm: bid.price, width: bid.w, height: bid.h, - ttl: 60 * 10, + ttl: 360, creativeId: bid.crid || bid.adid, netRevenue: true, currency: bid.cur || response.cur, @@ -264,7 +279,7 @@ function newRenderer(bidRequest, bid, rendererOptions = {}) { url: (bidRequest.params && bidRequest.params.rendererUrl) || (bid.ext && bid.ext.renderer_url) || - '//s.wlplayer.com/video/latest/renderer.js', + 'https://s.wlplayer.com/video/latest/renderer.js', config: rendererOptions, loaded: false }); diff --git a/modules/clickforceBidAdapter.js b/modules/clickforceBidAdapter.js index 16ecdf713d9..20408fe9177 100644 --- a/modules/clickforceBidAdapter.js +++ b/modules/clickforceBidAdapter.js @@ -1,8 +1,8 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, NATIVE} from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE} from '../src/mediaTypes.js'; const BIDDER_CODE = 'clickforce'; -const ENDPOINT_URL = '//ad.doublemax.net/adserver/prebid.json?cb=' + new Date().getTime() + '&hb=1&ver=1.21'; +const ENDPOINT_URL = 'https://ad.holmesmind.com/adserver/prebid.json?cb=' + new Date().getTime() + '&hb=1&ver=1.21'; export const spec = { code: BIDDER_CODE, @@ -112,12 +112,12 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: 'https://cdn.doublemax.net/js/capmapping.htm' + url: 'https://cdn.holmesmind.com/js/capmapping.htm' }] } else if (syncOptions.pixelEnabled) { return [{ type: 'image', - url: 'https://c.doublemax.net/cm' + url: 'https://c.holmesmind.com/cm' }] } } diff --git a/modules/clicktripzBidAdapter.js b/modules/clicktripzBidAdapter.js new file mode 100644 index 00000000000..2149cbe4527 --- /dev/null +++ b/modules/clicktripzBidAdapter.js @@ -0,0 +1,67 @@ +import {logError, _each} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'clicktripz'; +const ENDPOINT_URL = 'https://www.clicktripz.com/x/prebid/v1'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['ctz'], // short code + + isBidRequestValid: function (bid) { + if (bid && bid.params && bid.params.placementId && bid.params.siteId) { + return true; + } + + return false; + }, + + buildRequests: function (validBidRequests) { + let bidRequests = []; + + _each(validBidRequests, function (bid) { + bidRequests.push({ + bidId: bid.bidId, + placementId: bid.params.placementId, + siteId: bid.params.siteId, + sizes: bid.sizes.map(function (size) { + return size.join('x') + }) + }); + }); + return { + method: 'POST', + url: ENDPOINT_URL, + data: bidRequests + }; + }, + + interpretResponse: function (serverResponse) { + let bidResponses = []; + + if (serverResponse && serverResponse.body) { + _each(serverResponse.body, function (bid) { + if (bid.errors) { + logError(bid.errors); + return; + } + + const size = bid.size.split('x'); + bidResponses.push({ + requestId: bid.bidId, + cpm: bid.cpm, + width: size[0], + height: size[1], + creativeId: bid.creativeId, + currency: bid.currency, + netRevenue: bid.netRevenue, + ttl: bid.ttl, + adUrl: bid.adUrl + }); + }); + } + return bidResponses; + } +}; + +registerBidder(spec); diff --git a/modules/clicktripzBidAdapter.md b/modules/clicktripzBidAdapter.md new file mode 100644 index 00000000000..1de1e26f37a --- /dev/null +++ b/modules/clicktripzBidAdapter.md @@ -0,0 +1,35 @@ +# Overview + +``` +Module Name: Clicktripz Bidder Adapter +Module Type: Bidder Adapter +Maintainer: integration-support@clicktripz.com +``` + +# Description +Our module makes it easy to integrate Clicktripz demand sources into your website. + +Supported Ad Fortmats: +* Banner + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]], + } + }, + bids: [ + { + bidder: "clicktripz", + params: { + placementId: '4312c63f', + siteId: 'prebid', + } + } + ] + } + ]; diff --git a/modules/coinzillaBidAdapter.js b/modules/coinzillaBidAdapter.js index 6918d47eb10..240a3f1fcde 100644 --- a/modules/coinzillaBidAdapter.js +++ b/modules/coinzillaBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'coinzilla'; const ENDPOINT_URL = 'https://request.czilladx.com/serve/request.php'; @@ -31,7 +31,7 @@ export const spec = { return []; } return validBidRequests.map(bidRequest => { - const sizes = utils.parseSizesInput(bidRequest.sizes)[0]; + const sizes = utils.parseSizesInput(bidRequest.params.size || bidRequest.sizes)[0]; const width = sizes.split('x')[0]; const height = sizes.split('x')[1]; const payload = { diff --git a/modules/collectcentBidAdapter.js b/modules/collectcentBidAdapter.js index 50ac377788e..add3e06430d 100644 --- a/modules/collectcentBidAdapter.js +++ b/modules/collectcentBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = 'collectcent'; -const URL_MULTI = '//publishers.motionspots.com/?c=o&m=multi'; -const URL_SYNC = '//publishers.motionspots.com/?c=o&m=cookie'; +const URL_MULTI = 'https://publishers.motionspots.com/?c=o&m=multi'; +const URL_SYNC = 'https://publishers.motionspots.com/?c=o&m=cookie'; export const spec = { code: BIDDER_CODE, diff --git a/modules/colombiaBidAdapter.js b/modules/colombiaBidAdapter.js deleted file mode 100644 index e5ebc41ebfd..00000000000 --- a/modules/colombiaBidAdapter.js +++ /dev/null @@ -1,72 +0,0 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; -const BIDDER_CODE = 'colombia'; -const ENDPOINT_URL = 'https://ade.clmbtech.com/cde/prebid.htm'; -const HOST_NAME = document.location.protocol + '//' + window.location.host; - -export const spec = { - code: BIDDER_CODE, - aliases: ['clmb'], - isBidRequestValid: function(bid) { - return !!(bid.params.placementId); - }, - buildRequests: function(validBidRequests) { - return validBidRequests.map(bidRequest => { - const params = bidRequest.params; - const sizes = utils.parseSizesInput(bidRequest.sizes)[0]; - const width = sizes.split('x')[0]; - const height = sizes.split('x')[1]; - const placementId = params.placementId; - const cb = Math.floor(Math.random() * 99999999999); - const referrer = encodeURIComponent(utils.getTopWindowUrl()); - const bidId = bidRequest.bidId; - const payload = { - v: 'hb1', - p: placementId, - w: width, - h: height, - cb: cb, - r: referrer, - uid: bidId, - t: 'i', - d: HOST_NAME, - }; - return { - method: 'POST', - url: ENDPOINT_URL, - data: payload, - } - }); - }, - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - const response = serverResponse.body; - const crid = response.creativeId || 0; - const width = response.width || 0; - const height = response.height || 0; - const cpm = response.cpm || 0; - if (width !== 0 && height !== 0 && cpm !== 0 && crid !== 0) { - const dealId = response.dealid || ''; - const currency = response.currency || 'USD'; - const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue; - const referrer = utils.getTopWindowUrl(); - const bidResponse = { - requestId: bidRequest.data.uid, - cpm: cpm, - width: response.width, - height: response.height, - creativeId: crid, - dealId: dealId, - currency: currency, - netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), - referrer: referrer, - ad: response.ad - }; - bidResponses.push(bidResponse); - } - return bidResponses; - } -} -registerBidder(spec); diff --git a/modules/colossussspBidAdapter.js b/modules/colossussspBidAdapter.js index 2ad320ede38..cf4d306e686 100644 --- a/modules/colossussspBidAdapter.js +++ b/modules/colossussspBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = 'colossusssp'; -const URL = '//colossusssp.com/?c=o&m=multi'; -const URL_SYNC = '//colossusssp.com/?c=o&m=cookie'; +const G_URL = 'https://colossusssp.com/?c=o&m=multi'; +const G_URL_SYNC = 'https://colossusssp.com/?c=o&m=cookie'; function isBidResponseValid(bid) { if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { @@ -42,15 +42,16 @@ export const spec = { * @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server. * @return ServerRequest Info describing the request to the server. */ - buildRequests: (validBidRequests) => { + buildRequests: (validBidRequests, bidderRequest) => { let winTop = window; + let location; try { - window.top.location.toString(); + location = new URL(bidderRequest.refererInfo.referer) winTop = window.top; } catch (e) { + location = winTop.location; utils.logMessage(e); }; - let location = utils.getTopWindowLocation(); let placements = []; let request = { 'deviceWidth': winTop.screen.width, @@ -61,19 +62,30 @@ export const spec = { 'page': location.pathname, 'placements': placements }; + + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + } + for (let i = 0; i < validBidRequests.length; i++) { let bid = validBidRequests[i]; + let traff = bid.params.traffic || BANNER let placement = { placementId: bid.params.placement_id, bidId: bid.bidId, - sizes: bid.sizes, - traffic: bid.params.traffic || BANNER + sizes: bid.mediaTypes[traff].sizes, + traffic: traff }; + if (bid.schain) { + placement.schain = bid.schain; + } placements.push(placement); } return { method: 'POST', - url: URL, + url: G_URL, data: request }; }, @@ -103,7 +115,7 @@ export const spec = { getUserSyncs: () => { return [{ type: 'image', - url: URL_SYNC + url: G_URL_SYNC }]; } }; diff --git a/modules/colossussspBidAdapter.md b/modules/colossussspBidAdapter.md index 4760002f0db..d95080546c2 100644 --- a/modules/colossussspBidAdapter.md +++ b/modules/colossussspBidAdapter.md @@ -14,7 +14,11 @@ Module that connects to Colossus SSP demand sources ``` var adUnits = [{ code: 'placementid_0', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, bids: [{ bidder: 'colossusssp', params: { diff --git a/modules/connectadBidAdapter.js b/modules/connectadBidAdapter.js new file mode 100644 index 00000000000..3dcb8da9838 --- /dev/null +++ b/modules/connectadBidAdapter.js @@ -0,0 +1,299 @@ +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js' +import {config} from '../src/config.js'; + +const BIDDER_CODE = 'connectad'; +const BIDDER_CODE_ALIAS = 'connectadrealtime'; +const ENDPOINT_URL = 'https://i.connectad.io/api/v2'; +const SUPPORTED_MEDIA_TYPES = [BANNER]; + +export const spec = { + code: BIDDER_CODE, + aliases: [ BIDDER_CODE_ALIAS ], + supportedMediaTypes: SUPPORTED_MEDIA_TYPES, + + isBidRequestValid: function(bid) { + return !!(bid.params.networkId && bid.params.siteId); + }, + + buildRequests: function(validBidRequests, bidderRequest) { + let digitrust; + + let ret = { + method: 'POST', + url: '', + data: '', + bidRequest: [] + }; + + if (validBidRequests.length < 1) { + return ret; + } + + const data = Object.assign({ + placements: [], + time: Date.now(), + user: {}, + url: (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : window.location.href, + referrer: window.document.referrer, + referrer_info: bidderRequest.refererInfo, + screensize: getScreenSize(), + dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, + language: navigator.language, + ua: navigator.userAgent + }); + + // coppa compliance + if (config.getConfig('coppa') === true) { + utils.deepSetValue(data, 'user.coppa', 1); + } + + // adding schain object + if (validBidRequests[0].schain) { + utils.deepSetValue(data, 'source.ext.schain', validBidRequests[0].schain); + } + + // Attaching GDPR Consent Params + if (bidderRequest.gdprConsent) { + let gdprApplies; + if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { + gdprApplies = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + } + utils.deepSetValue(data, 'user.ext.gdpr', gdprApplies); + utils.deepSetValue(data, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + } + + // CCPA + if (bidderRequest.uspConsent) { + utils.deepSetValue(data, 'user.ext.us_privacy', bidderRequest.uspConsent); + } + + // Digitrust Support + const bidRequestDigitrust = utils.deepAccess(validBidRequests[0], 'userId.digitrustid.data'); + if (bidRequestDigitrust && (!bidRequestDigitrust.privacy || !bidRequestDigitrust.privacy.optout)) { + digitrust = { + id: bidRequestDigitrust.id, + keyv: bidRequestDigitrust.keyv + } + } + + if (digitrust) { + utils.deepSetValue(data, 'user.ext.digitrust', { + id: digitrust.id, + keyv: digitrust.keyv + }) + } + + if (validBidRequests[0].userId && typeof validBidRequests[0].userId === 'object' && (validBidRequests[0].userId.tdid || validBidRequests[0].userId.pubcid || validBidRequests[0].userId.lipb || validBidRequests[0].userId.id5id || validBidRequests[0].userId.parrableid)) { + utils.deepSetValue(data, 'user.ext.eids', []); + + if (validBidRequests[0].userId.tdid) { + data.user.ext.eids.push({ + source: 'adserver.org', + uids: [{ + id: validBidRequests[0].userId.tdid, + ext: { + rtiPartner: 'TDID' + } + }] + }); + } + + if (validBidRequests[0].userId.pubcid) { + data.user.ext.eids.push({ + source: 'pubcommon', + uids: [{ + id: validBidRequests[0].userId.pubcid, + }] + }); + } + + if (validBidRequests[0].userId.id5id) { + data.user.ext.eids.push({ + source: 'id5-sync.com', + uids: [{ + id: validBidRequests[0].userId.id5id, + }] + }); + } + + if (validBidRequests[0].userId.parrableid) { + data.user.ext.eids.push({ + source: 'parrable.com', + uids: [{ + id: validBidRequests[0].userId.parrableid, + }] + }); + } + + if (validBidRequests[0].userId.lipb && validBidRequests[0].userId.lipb.lipbid) { + data.user.ext.eids.push({ + source: 'liveintent.com', + uids: [{ + id: validBidRequests[0].userId.lipb.lipbid + }] + }); + } + } + + validBidRequests.map(bid => { + const placement = Object.assign({ + id: bid.transactionId, + divName: bid.bidId, + sizes: bid.mediaTypes.banner.sizes, + adTypes: getSize(bid.mediaTypes.banner.sizes || bid.sizes) + }, bid.params); + + if (placement.networkId && placement.siteId) { + data.placements.push(placement); + } + }); + + ret.data = JSON.stringify(data); + ret.bidRequest = validBidRequests; + ret.url = ENDPOINT_URL; + + return ret; + }, + + interpretResponse: function(serverResponse, bidRequest, bidderRequest) { + let bid; + let bids; + let bidId; + let bidObj; + let bidResponses = []; + + bids = bidRequest.bidRequest; + + serverResponse = (serverResponse || {}).body; + for (let i = 0; i < bids.length; i++) { + bid = {}; + bidObj = bids[i]; + bidId = bidObj.bidId; + + if (serverResponse) { + const decision = serverResponse.decisions && serverResponse.decisions[bidId]; + const price = decision && decision.pricing && decision.pricing.clearPrice; + + if (decision && price) { + bid.requestId = bidId; + bid.cpm = price; + bid.width = decision.width; + bid.height = decision.height; + bid.dealid = decision.dealid || null; + bid.ad = retrieveAd(decision); + bid.currency = 'USD'; + bid.creativeId = decision.adId; + bid.ttl = 360; + bid.netRevenue = true; + bidResponses.push(bid); + } + } + } + + return bidResponses; + }, + + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + let syncEndpoint = 'https://cdn.connectad.io/connectmyusers.php?'; + + if (gdprConsent) { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'gdpr', (gdprConsent.gdprApplies ? 1 : 0)); + } + + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'gdpr_consent', gdprConsent.consentString); + } + + if (uspConsent) { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'us_privacy', uspConsent); + } + + if (config.getConfig('coppa') === true) { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'coppa', 1); + } + + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: syncEndpoint + }]; + } else { + utils.logWarn('Bidder ConnectAd: Please activate iFrame Sync'); + } + } +}; + +const sizeMap = [ + null, + '120x90', + '200x200', + '468x60', + '728x90', + '300x250', + '160x600', + '120x600', + '300x100', + '180x150', + '336x280', + '240x400', + '234x60', + '88x31', + '120x60', + '120x240', + '125x125', + '220x250', + '250x250', + '250x90', + '0x0', + '200x90', + '300x50', + '320x50', + '320x480', + '185x185', + '620x45', + '300x125', + '800x250', + '980x120', + '980x150', + '320x150', + '300x300', + '200x600', + '320x500', + '320x320' +]; + +sizeMap[77] = '970x90'; +sizeMap[123] = '970x250'; +sizeMap[43] = '300x600'; +sizeMap[286] = '970x66'; +sizeMap[3230] = '970x280'; +sizeMap[429] = '486x60'; +sizeMap[374] = '700x500'; +sizeMap[934] = '300x1050'; +sizeMap[1578] = '320x100'; +sizeMap[331] = '320x250'; +sizeMap[3301] = '320x267'; +sizeMap[2730] = '728x250'; + +function getSize(sizes) { + const result = []; + sizes.forEach(function(size) { + const index = sizeMap.indexOf(size[0] + 'x' + size[1]); + if (index >= 0) { + result.push(index); + } + }); + return result; +} + +function retrieveAd(decision) { + return decision.contents && decision.contents[0] && decision.contents[0].body; +} + +function getScreenSize() { + return [window.screen.width, window.screen.height].join('x'); +} + +registerBidder(spec); diff --git a/modules/connectadBidAdapter.md b/modules/connectadBidAdapter.md new file mode 100644 index 00000000000..e63494e1add --- /dev/null +++ b/modules/connectadBidAdapter.md @@ -0,0 +1,46 @@ +# Overview + +``` +Module Name: ConnectAd PreBid Adapter +Module Type: Bidder Adapter +Maintainer: support@connectad.io +``` + +# Description + +ConnectAd bid adapter supports only Banner at present. Video and Mobile will follow Q2/2020 + +# Sample Ad Unit: For Publishers +``` +var adUnits = [ +{ + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'connectad', + params: { + siteId: 123456, + networkId: 123456, + bidfloor: 0.20 // Optional: Requested Bidfloor + } + }] +} + +# ## Configuration +ConnectAd recommends the UserSync configuration below otherwise we will not be able to performe user syncs. + +```javascript +pbjs.setConfig({ + userSync: { + filterSettings: { + iframe: { + bidders: ['connectad'], + filter: 'include' + } + } + } +}); \ No newline at end of file diff --git a/modules/consentManagement.js b/modules/consentManagement.js index 1e2a6648145..4a1fa9ba8d0 100644 --- a/modules/consentManagement.js +++ b/modules/consentManagement.js @@ -4,11 +4,11 @@ * and make it available for any GDPR supported adapters to read/pass this information to * their system. */ -import * as utils from '../src/utils'; -import { config } from '../src/config'; -import { gdprDataHandler } from '../src/adapterManager'; -import includes from 'core-js/library/fn/array/includes'; -import strIncludes from 'core-js/library/fn/string/includes'; +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { gdprDataHandler } from '../src/adapterManager.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import strIncludes from 'core-js/library/fn/string/includes.js'; const DEFAULT_CMP = 'iab'; const DEFAULT_CONSENT_TIMEOUT = 10000; @@ -17,8 +17,10 @@ const DEFAULT_ALLOW_AUCTION_WO_CONSENT = true; export let userCMP; export let consentTimeout; export let allowAuction; +export let gdprScope; export let staticConsentData; +let cmpVersion = 0; let consentData; let addedConsentHook = false; @@ -47,11 +49,70 @@ function lookupStaticConsentData(cmpSuccess, cmpError, hookConfig) { * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) */ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { - function handleCmpResponseCallbacks() { + function findCMP() { + let f = window; + let cmpFrame; + let cmpFunction; + while (!cmpFrame) { + try { + if (typeof f.__tcfapi === 'function' || typeof f.__cmp === 'function') { + if (typeof f.__tcfapi === 'function') { + cmpVersion = 2; + cmpFunction = f.__tcfapi; + } else { + cmpVersion = 1; + cmpFunction = f.__cmp; + } + cmpFrame = f; + break; + } + } catch (e) { } + + // need separate try/catch blocks due to the exception errors thrown when trying to check for a frame that doesn't exist in 3rd party env + try { + if (f.frames['__tcfapiLocator']) { + cmpVersion = 2; + cmpFrame = f; + break; + } + } catch (e) { } + + try { + if (f.frames['__cmpLocator']) { + cmpVersion = 1; + cmpFrame = f; + break; + } + } catch (e) { } + + if (f === window.top) break; + f = f.parent; + } + return { + cmpFrame, + cmpFunction + }; + } + + function v2CmpResponseCallback(tcfData, success) { + utils.logInfo('Received a response from CMP', tcfData); + if (success) { + if (tcfData.eventStatus === 'tcloaded' || tcfData.eventStatus === 'useractioncomplete') { + cmpSuccess(tcfData, hookConfig); + } else if (tcfData.eventStatus === 'cmpuishown' && tcfData.tcString && tcfData.purposeOneTreatment === true) { + cmpSuccess(tcfData, hookConfig); + } + } else { + cmpError('CMP unable to register callback function. Please check CMP setup.', hookConfig); + } + } + + function handleV1CmpResponseCallbacks() { const cmpResponse = {}; function afterEach() { if (cmpResponse.getConsentData && cmpResponse.getVendorConsents) { + utils.logInfo('Received all requested responses from CMP', cmpResponse); cmpSuccess(cmpResponse, hookConfig); } } @@ -68,10 +129,13 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { } } - let callbackHandler = handleCmpResponseCallbacks(); + let v1CallbackHandler = handleV1CmpResponseCallbacks(); let cmpCallbacks = {}; - let cmpFunction; + let { cmpFrame, cmpFunction } = findCMP(); + if (!cmpFrame) { + return cmpError('CMP not found.', hookConfig); + } // to collect the consent information from the user, we perform two calls to the CMP in parallel: // first to collect the user's consent choices represented in an encoded string (via getConsentData) // second to collect the user's full unparsed consent information (via getVendorConsents) @@ -81,34 +145,28 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { // check to see if prebid is in a safeframe (with CMP support) // else assume prebid may be inside an iframe and use the IAB CMP locator code to see if CMP's located in a higher parent window. this works in cross domain iframes // if the CMP is not found, the iframe function will call the cmpError exit callback to abort the rest of the CMP workflow - try { - cmpFunction = window.__cmp || utils.getWindowTop().__cmp; - } catch (e) { } if (utils.isFn(cmpFunction)) { - cmpFunction('getConsentData', null, callbackHandler.consentDataCallback); - cmpFunction('getVendorConsents', null, callbackHandler.vendorConsentsCallback); - } else if (inASafeFrame() && typeof window.$sf.ext.cmp === 'function') { - callCmpWhileInSafeFrame('getConsentData', callbackHandler.consentDataCallback); - callCmpWhileInSafeFrame('getVendorConsents', callbackHandler.vendorConsentsCallback); - } else { - // find the CMP frame - let f = window; - let cmpFrame; - while (!cmpFrame) { - try { - if (f.frames['__cmpLocator']) cmpFrame = f; - } catch (e) { } - if (f === window.top) break; - f = f.parent; + utils.logInfo('Detected CMP API is directly accessible, calling it now...'); + if (cmpVersion === 1) { + cmpFunction('getConsentData', null, v1CallbackHandler.consentDataCallback); + cmpFunction('getVendorConsents', null, v1CallbackHandler.vendorConsentsCallback); + } else if (cmpVersion === 2) { + cmpFunction('addEventListener', cmpVersion, v2CmpResponseCallback); } - - if (!cmpFrame) { - return cmpError('CMP not found.', hookConfig); + } else if (cmpVersion === 1 && inASafeFrame() && typeof window.$sf.ext.cmp === 'function') { + // this safeframe workflow is only supported with TCF v1 spec; the v2 recommends to use the iframe postMessage route instead (even if you are in a safeframe). + utils.logInfo('Detected Prebid.js is encased in a SafeFrame and CMP is registered, calling it now...'); + callCmpWhileInSafeFrame('getConsentData', v1CallbackHandler.consentDataCallback); + callCmpWhileInSafeFrame('getVendorConsents', v1CallbackHandler.vendorConsentsCallback); + } else { + utils.logInfo('Detected CMP is outside the current iframe where Prebid.js is located, calling it now...'); + if (cmpVersion === 1) { + callCmpWhileInIframe('getConsentData', cmpFrame, v1CallbackHandler.consentDataCallback); + callCmpWhileInIframe('getVendorConsents', cmpFrame, v1CallbackHandler.vendorConsentsCallback); + } else if (cmpVersion === 2) { + callCmpWhileInIframe('addEventListener', cmpFrame, v2CmpResponseCallback); } - - callCmpWhileInIframe('getConsentData', cmpFrame, callbackHandler.consentDataCallback); - callCmpWhileInIframe('getVendorConsents', cmpFrame, callbackHandler.vendorConsentsCallback); } function inASafeFrame() { @@ -138,17 +196,22 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { } function callCmpWhileInIframe(commandName, cmpFrame, moduleCallback) { + let apiName = (cmpVersion === 2) ? '__tcfapi' : '__cmp'; + /* Setup up a __cmp function to do the postMessage and stash the callback. This function behaves (from the caller's perspective identicially to the in-frame __cmp call */ - window.__cmp = function (cmd, arg, callback) { + window[apiName] = function (cmd, arg, callback) { let callId = Math.random() + ''; + let callName = `${apiName}Call`; let msg = { - __cmpCall: { + [callName]: { command: cmd, parameter: arg, callId: callId } }; + if (cmpVersion !== 1) msg[callName].version = cmpVersion; + cmpCallbacks[callId] = callback; cmpFrame.postMessage(msg, '*'); } @@ -157,28 +220,19 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { window.addEventListener('message', readPostMessageResponse, false); // call CMP - window.__cmp(commandName, null, cmpIframeCallback); + window[apiName](commandName, null, moduleCallback); function readPostMessageResponse(event) { - let json = (typeof event.data === 'string' && strIncludes(event.data, 'cmpReturn')) ? JSON.parse(event.data) : event.data; - if (json.__cmpReturn && json.__cmpReturn.callId) { - let i = json.__cmpReturn; + let cmpDataPkgName = `${apiName}Return`; + let json = (typeof event.data === 'string' && strIncludes(event.data, cmpDataPkgName)) ? JSON.parse(event.data) : event.data; + if (json[cmpDataPkgName] && json[cmpDataPkgName].callId) { + let payload = json[cmpDataPkgName]; // TODO - clean up this logic (move listeners?); we have duplicate messages responses because 2 eventlisteners are active from the 2 cmp requests running in parallel - if (typeof cmpCallbacks[i.callId] !== 'undefined') { - cmpCallbacks[i.callId](i.returnValue, i.success); - delete cmpCallbacks[i.callId]; + if (typeof cmpCallbacks[payload.callId] !== 'undefined') { + cmpCallbacks[payload.callId](payload.returnValue, payload.success); } } } - - function removePostMessageListener() { - window.removeEventListener('message', readPostMessageResponse, false); - } - - function cmpIframeCallback(consentObject) { - removePostMessageListener(); - moduleCallback(consentObject); - } } } @@ -204,6 +258,7 @@ export function requestBidsHook(fn, reqBidsConfigObj) { // in case we already have consent (eg during bid refresh) if (consentData) { + utils.logInfo('User consent information already known. Pulling internally stored information...'); return exitModule(null, hookConfig); } @@ -232,22 +287,50 @@ export function requestBidsHook(fn, reqBidsConfigObj) { * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) */ function processCmpData(consentObject, hookConfig) { - let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies; - if ( - (typeof gdprApplies !== 'boolean') || - (gdprApplies === true && - !(utils.isStr(consentObject.getConsentData.consentData) && - utils.isPlainObject(consentObject.getVendorConsents) && - Object.keys(consentObject.getVendorConsents).length > 1 + function checkV1Data(consentObject) { + let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies; + return !!( + (typeof gdprApplies !== 'boolean') || + (gdprApplies === true && + !(utils.isStr(consentObject.getConsentData.consentData) && + utils.isPlainObject(consentObject.getVendorConsents) && + Object.keys(consentObject.getVendorConsents).length > 1 + ) ) - ) - ) { - cmpFailed(`CMP returned unexpected value during lookup process.`, hookConfig, consentObject); - } else { - clearTimeout(hookConfig.timer); - storeConsentData(consentObject); + ); + } - exitModule(null, hookConfig); + function checkV2Data() { + let gdprApplies = consentObject && consentObject.gdprApplies; + let tcString = consentObject && consentObject.tcString; + return !!( + (typeof gdprApplies !== 'boolean') || + (gdprApplies === true && !utils.isStr(tcString)) + ); + } + + // do extra things for static config + if (userCMP === 'static') { + cmpVersion = (consentObject.getConsentData) ? 1 : (consentObject.getTCData) ? 2 : 0; + // remove extra layer in static v2 data object so it matches normal v2 CMP object for processing step + if (cmpVersion === 2) { + consentObject = consentObject.getTCData; + } + } + + // determine which set of checks to run based on cmpVersion + let checkFn = (cmpVersion === 1) ? checkV1Data : (cmpVersion === 2) ? checkV2Data : null; + + if (utils.isFn(checkFn)) { + if (checkFn(consentObject)) { + cmpFailed(`CMP returned unexpected value during lookup process.`, hookConfig, consentObject); + } else { + clearTimeout(hookConfig.timer); + storeConsentData(consentObject); + exitModule(null, hookConfig); + } + } else { + cmpFailed('Unable to derive CMP version to process data. Consent object does not conform to TCF v1 or v2 specs.', hookConfig, consentObject); } } @@ -279,17 +362,26 @@ function cmpFailed(errMsg, hookConfig, extraArgs) { * @param {object} cmpConsentObject required; an object representing user's consent choices (can be undefined in certain use-cases for this function only) */ function storeConsentData(cmpConsentObject) { - consentData = { - consentString: (cmpConsentObject) ? cmpConsentObject.getConsentData.consentData : undefined, - vendorData: (cmpConsentObject) ? cmpConsentObject.getVendorConsents : undefined, - gdprApplies: (cmpConsentObject) ? cmpConsentObject.getConsentData.gdprApplies : undefined - }; + if (cmpVersion === 1) { + consentData = { + consentString: (cmpConsentObject) ? cmpConsentObject.getConsentData.consentData : undefined, + vendorData: (cmpConsentObject) ? cmpConsentObject.getVendorConsents : undefined, + gdprApplies: (cmpConsentObject) ? cmpConsentObject.getConsentData.gdprApplies : gdprScope + }; + } else { + consentData = { + consentString: (cmpConsentObject) ? cmpConsentObject.tcString : undefined, + vendorData: (cmpConsentObject) || undefined, + gdprApplies: (cmpConsentObject) ? cmpConsentObject.gdprApplies : gdprScope + }; + } + consentData.apiVersion = cmpVersion; gdprDataHandler.setConsentData(consentData); } /** * This function handles the exit logic for the module. - * There are several paths in the module's logic to call this function and we only allow 1 of the 3 potential exits to happen before suppressing others. + * While there are several paths in the module's logic to call this function, we only allow 1 of the 3 potential exits to happen before suppressing others. * * We prevent multiple exits to avoid conflicting messages in the console depending on certain scenarios. * One scenario could be auction was canceled due to timeout with CMP being reached. @@ -335,14 +427,23 @@ function exitModule(errMsg, hookConfig, extraArgs) { */ export function resetConsentData() { consentData = undefined; + userCMP = undefined; + cmpVersion = 0; gdprDataHandler.setConsentData(null); } /** * A configuration function that initializes some module variables, as well as add a hook into the requestBids function - * @param {object} config required; consentManagement module config settings; cmp (string), timeout (int), allowAuctionWithoutConsent (boolean) + * @param {{cmp:string, timeout:number, allowAuctionWithoutConsent:boolean, defaultGdprScope:boolean}} config required; consentManagement module config settings; cmp (string), timeout (int), allowAuctionWithoutConsent (boolean) */ export function setConsentConfig(config) { + // if `config.gdpr` or `config.usp` exist, assume new config format. + // else for backward compatability, just use `config` + config = config.gdpr || config.usp ? config.gdpr : config; + if (!config || typeof config !== 'object') { + utils.logWarn('consentManagement config not defined, exiting consent manager'); + return; + } if (utils.isStr(config.cmpApi)) { userCMP = config.cmpApi; } else { @@ -364,6 +465,9 @@ export function setConsentConfig(config) { utils.logInfo(`consentManagement config did not specify allowAuctionWithoutConsent. Using system default setting (${DEFAULT_ALLOW_AUCTION_WO_CONSENT}).`); } + // if true, then gdprApplies should be set to true + gdprScope = config.defaultGdprScope === true; + utils.logInfo('consentManagement module has been activated...'); if (userCMP === 'static') { diff --git a/modules/consentManagementUsp.js b/modules/consentManagementUsp.js new file mode 100644 index 00000000000..1a5879a40ff --- /dev/null +++ b/modules/consentManagementUsp.js @@ -0,0 +1,311 @@ +/** + * This module adds USPAPI (CCPA) consentManagement support to prebid.js. It + * interacts with supported USP Consent APIs to grab the user's consent + * information and make it available for any USP (CCPA) supported adapters to + * read/pass this information to their system. + */ +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { uspDataHandler } from '../src/adapterManager.js'; + +const DEFAULT_CONSENT_API = 'iab'; +const DEFAULT_CONSENT_TIMEOUT = 50; +const USPAPI_VERSION = 1; + +export let consentAPI; +export let consentTimeout; +export let staticConsentData; + +let consentData; +let addedConsentHook = false; + +// consent APIs +const uspCallMap = { + 'iab': lookupUspConsent, + 'static': lookupStaticConsentData +}; + +/** + * This function reads the consent string from the config to obtain the consent information of the user. + * @param {function(string)} cmpSuccess acts as a success callback when the value is read from config; pass along consentObject (string) from CMP + * @param {function(string)} cmpError acts as an error callback while interacting with the config string; pass along an error message (string) + * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) + */ +function lookupStaticConsentData(cmpSuccess, cmpError, hookConfig) { + cmpSuccess(staticConsentData, hookConfig); +} + +/** + * This function handles interacting with an USP compliant consent manager to obtain the consent information of the user. + * Given the async nature of the USP's API, we pass in acting success/error callback functions to exit this function + * based on the appropriate result. + * @param {function(string)} uspSuccess acts as a success callback when USPAPI returns a value; pass along consentObject (string) from USPAPI + * @param {function(string)} uspError acts as an error callback while interacting with USPAPI; pass along an error message (string) + * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) + */ +function lookupUspConsent(uspSuccess, uspError, hookConfig) { + function handleUspApiResponseCallbacks() { + const uspResponse = {}; + + function afterEach() { + if (uspResponse.usPrivacy) { + uspSuccess(uspResponse, hookConfig); + } else { + uspError('Unable to get USP consent string.', hookConfig); + } + } + + return { + consentDataCallback: (consentResponse, success) => { + if (success && consentResponse.uspString) { + uspResponse.usPrivacy = consentResponse.uspString; + } + afterEach(); + } + }; + } + + let callbackHandler = handleUspApiResponseCallbacks(); + let uspapiCallbacks = {}; + + // to collect the consent information from the user, we perform a call to USPAPI + // to collect the user's consent choices represented as a string (via getUSPData) + + // the following code also determines where the USPAPI is located and uses the proper workflow to communicate with it: + // - use the USPAPI locator code to see if USP's located in the current window or an ancestor window. This works in friendly or cross domain iframes + // - if USPAPI is not found, the iframe function will call the uspError exit callback to abort the rest of the USPAPI workflow + // - try to call the __uspapi() function directly, otherwise use the postMessage() api + // find the CMP frame/window + + try { + // try to call __uspapi directly + window.__uspapi('getUSPData', USPAPI_VERSION, callbackHandler.consentDataCallback); + } catch (e) { + // must not have been accessible, try using postMessage() api + let f = window; + let uspapiFrame; + while (!uspapiFrame) { + try { + if (f.frames['__uspapiLocator']) uspapiFrame = f; + } catch (e) { } + if (f === window.top) break; + f = f.parent; + } + + if (!uspapiFrame) { + return uspError('USP CMP not found.', hookConfig); + } + callUspApiWhileInIframe('getUSPData', uspapiFrame, callbackHandler.consentDataCallback); + } + + function callUspApiWhileInIframe(commandName, uspapiFrame, moduleCallback) { + /* Setup up a __uspapi function to do the postMessage and stash the callback. + This function behaves, from the caller's perspective, identicially to the in-frame __uspapi call (although it is not synchronous) */ + window.__uspapi = function (cmd, ver, callback) { + let callId = Math.random() + ''; + let msg = { + __uspapiCall: { + command: cmd, + version: ver, + callId: callId + } + }; + + uspapiCallbacks[callId] = callback; + uspapiFrame.postMessage(msg, '*'); + } + + /** when we get the return message, call the stashed callback */ + window.addEventListener('message', readPostMessageResponse, false); + + // call uspapi + window.__uspapi(commandName, USPAPI_VERSION, uspapiCallback); + + function readPostMessageResponse(event) { + const res = event && event.data && event.data.__uspapiReturn; + if (res && res.callId) { + if (typeof uspapiCallbacks[res.callId] !== 'undefined') { + uspapiCallbacks[res.callId](res.returnValue, res.success); + delete uspapiCallbacks[res.callId]; + } + } + } + + function uspapiCallback(consentObject, success) { + window.removeEventListener('message', readPostMessageResponse, false); + moduleCallback(consentObject, success); + } + } +} + +/** + * If consentManagementUSP module is enabled (ie included in setConfig), this hook function will attempt to fetch the + * user's encoded consent string from the supported USPAPI. Once obtained, the module will store this + * data as part of a uspConsent object which gets transferred to adapterManager's uspDataHandler object. + * This information is later added into the bidRequest object for any supported adapters to read/pass along to their system. + * @param {object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids. + * @param {function} fn required; The next function in the chain, used by hook.js + */ +export function requestBidsHook(fn, reqBidsConfigObj) { + // preserves all module related variables for the current auction instance (used primiarily for concurrent auctions) + const hookConfig = { + context: this, + args: [reqBidsConfigObj], + nextFn: fn, + adUnits: reqBidsConfigObj.adUnits || $$PREBID_GLOBAL$$.adUnits, + bidsBackHandler: reqBidsConfigObj.bidsBackHandler, + haveExited: false, + timer: null + }; + + // in case we already have consent (eg during bid refresh) + if (consentData) { + return exitModule(null, hookConfig); + } + + if (!uspCallMap[consentAPI]) { + utils.logWarn(`USP framework (${consentAPI}) is not a supported framework. Aborting consentManagement module and resuming auction.`); + return hookConfig.nextFn.apply(hookConfig.context, hookConfig.args); + } + + uspCallMap[consentAPI].call(this, processUspData, uspapiFailed, hookConfig); + + // only let this code run if module is still active (ie if the callbacks used by USPs haven't already finished) + if (!hookConfig.haveExited) { + if (consentTimeout === 0) { + processUspData(undefined, hookConfig); + } else { + hookConfig.timer = setTimeout(uspapiTimeout.bind(null, hookConfig), consentTimeout); + } + } +} + +/** + * This function checks the consent data provided by USPAPI to ensure it's in an expected state. + * If it's bad, we exit the module depending on config settings. + * If it's good, then we store the value and exits the module. + * @param {object} consentObject required; object returned by USPAPI that contains user's consent choices + * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) + */ +function processUspData(consentObject, hookConfig) { + const valid = !!(consentObject && consentObject.usPrivacy); + if (!valid) { + uspapiFailed(`USPAPI returned unexpected value during lookup process.`, hookConfig, consentObject); + return; + } + + clearTimeout(hookConfig.timer); + storeUspConsentData(consentObject); + exitModule(null, hookConfig); +} + +/** + * General timeout callback when interacting with USPAPI takes too long. + */ +function uspapiTimeout(hookConfig) { + uspapiFailed('USPAPI workflow exceeded timeout threshold.', hookConfig); +} + +/** + * This function contains the controlled steps to perform when there's a problem with USPAPI. + * @param {string} errMsg required; should be a short descriptive message for why the failure/issue happened. + * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) + * @param {object} extraArgs contains additional data that's passed along in the error/warning messages for easier debugging +*/ +function uspapiFailed(errMsg, hookConfig, extraArgs) { + clearTimeout(hookConfig.timer); + + exitModule(errMsg, hookConfig, extraArgs); +} + +/** + * Stores USP data locally in module and then invokes uspDataHandler.setConsentData() to make information available in adaptermanger.js for later in the auction + * @param {object} cmpConsentObject required; an object representing user's consent choices (can be undefined in certain use-cases for this function only) + */ +function storeUspConsentData(consentObject) { + if (consentObject && consentObject.usPrivacy) { + consentData = consentObject.usPrivacy; + uspDataHandler.setConsentData(consentData); + } +} + +/** + * This function handles the exit logic for the module. + * There are a couple paths in the module's logic to call this function and we only allow 1 of the 2 potential exits to happen before suppressing others. + * + * We prevent multiple exits to avoid conflicting messages in the console depending on certain scenarios. + * One scenario could be auction was canceled due to timeout with USPAPI being reached. + * While the timeout is the accepted exit and runs first, the USP's callback still tries to process the user's data (which normally leads to a good exit). + * In this case, the good exit will be suppressed since we already decided to cancel the auction. + * + * Three exit paths are: + * 1. good exit where auction runs (USPAPI data is processed normally). + * 2. bad exit but auction still continues (warning message is logged, USPAPI data is undefined and still passed along). + * @param {string} errMsg optional; only to be used when there was a 'bad' exit. String is a descriptive message for the failure/issue encountered. + * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) + * @param {object} extraArgs contains additional data that's passed along in the error/warning messages for easier debugging + */ +function exitModule(errMsg, hookConfig, extraArgs) { + if (hookConfig.haveExited === false) { + hookConfig.haveExited = true; + + let context = hookConfig.context; + let args = hookConfig.args; + let nextFn = hookConfig.nextFn; + + if (errMsg) { + utils.logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.', extraArgs); + } + nextFn.apply(context, args); + } +} + +/** + * Simply resets the module's consentData variable back to undefined, mainly for testing purposes + */ +export function resetConsentData() { + consentData = undefined; + consentAPI = undefined; + uspDataHandler.setConsentData(null); +} + +/** + * A configuration function that initializes some module variables, as well as add a hook into the requestBids function + * @param {object} config required; consentManagementUSP module config settings; usp (string), timeout (int), allowAuctionWithoutConsent (boolean) + */ +export function setConsentConfig(config) { + config = config.usp; + if (!config || typeof config !== 'object') { + utils.logWarn('consentManagement.usp config not defined, exiting usp consent manager'); + return; + } + if (utils.isStr(config.cmpApi)) { + consentAPI = config.cmpApi; + } else { + consentAPI = DEFAULT_CONSENT_API; + utils.logInfo(`consentManagement.usp config did not specify cmpApi. Using system default setting (${DEFAULT_CONSENT_API}).`); + } + + if (utils.isNumber(config.timeout)) { + consentTimeout = config.timeout; + } else { + consentTimeout = DEFAULT_CONSENT_TIMEOUT; + utils.logInfo(`consentManagement.usp config did not specify timeout. Using system default setting (${DEFAULT_CONSENT_TIMEOUT}).`); + } + + utils.logInfo('USPAPI consentManagement module has been activated...'); + + if (consentAPI === 'static') { + if (utils.isPlainObject(config.consentData) && utils.isPlainObject(config.consentData.getUSPData)) { + if (config.consentData.getUSPData.uspString) staticConsentData = { usPrivacy: config.consentData.getUSPData.uspString }; + consentTimeout = 0; + } else { + utils.logError(`consentManagement config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.`); + } + } + if (!addedConsentHook) { + $$PREBID_GLOBAL$$.requestBids.before(requestBidsHook, 50); + } + addedConsentHook = true; +} +config.getConfig('consentManagement', config => setConsentConfig(config.consentManagement)); diff --git a/modules/consumableBidAdapter.js b/modules/consumableBidAdapter.js index d462acaee59..8eb56f7d0c2 100644 --- a/modules/consumableBidAdapter.js +++ b/modules/consumableBidAdapter.js @@ -1,5 +1,5 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'consumable'; @@ -47,7 +47,7 @@ export const spec = { const data = Object.assign({ placements: [], time: Date.now(), - url: utils.getTopWindowUrl(), + url: bidderRequest.refererInfo.referer, referrer: document.referrer, source: [{ 'name': 'prebidjs', @@ -62,10 +62,15 @@ export const spec = { }; } + if (bidderRequest && bidderRequest.uspConsent) { + data.ccpa = bidderRequest.uspConsent; + } + validBidRequests.map(bid => { + const sizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes || []; const placement = Object.assign({ divName: bid.bidId, - adTypes: bid.adTypes || getSize(bid.sizes) + adTypes: bid.adTypes || getSize(sizes) }, bid.params); if (placement.networkId && placement.siteId && placement.unitId && placement.unitName) { @@ -75,6 +80,7 @@ export const spec = { ret.data = JSON.stringify(data); ret.bidRequest = validBidRequests; + ret.bidderRequest = bidderRequest; ret.url = BASE_URI; return ret; @@ -117,7 +123,7 @@ export const spec = { bid.creativeId = decision.adId; bid.ttl = 30; bid.netRevenue = true; - bid.referrer = utils.getTopWindowUrl(); + bid.referrer = bidRequest.bidderRequest.refererInfo.referer; bidResponses.push(bid); } @@ -131,7 +137,7 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: '//sync.serverbid.com/ss/' + siteId + '.html' + url: 'https://sync.serverbid.com/ss/' + siteId + '.html' }]; } diff --git a/modules/contentigniteBidAdapter.js b/modules/contentigniteBidAdapter.js deleted file mode 100644 index 2e3092114f6..00000000000 --- a/modules/contentigniteBidAdapter.js +++ /dev/null @@ -1,115 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { config } from '../src/config'; -import * as utils from '../src/utils'; - -const BIDDER_CODE = 'contentignite'; - -export const spec = { - code: BIDDER_CODE, - pageID: Math.floor(Math.random() * 10e6), - - isBidRequestValid: (bid) => { - return !!(bid.params.accountID && bid.params.zoneID); - }, - - buildRequests: (validBidRequests) => { - let i; - let zoneID; - let bidRequest; - let accountID; - let keyword; - let requestURI; - const serverRequests = []; - const zoneCounters = {}; - - for (i = 0; i < validBidRequests.length; i++) { - bidRequest = validBidRequests[i]; - zoneID = utils.getBidIdParameter('zoneID', bidRequest.params); - accountID = utils.getBidIdParameter('accountID', bidRequest.params); - keyword = utils.getBidIdParameter('keyword', bidRequest.params); - - if (!(zoneID in zoneCounters)) { - zoneCounters[zoneID] = 0; - } - - requestURI = - location.protocol + '//serve.connectignite.com/adserve/;type=hbr;'; - requestURI += `ID=${encodeURIComponent(accountID)};`; - requestURI += `setID=${encodeURIComponent(zoneID)};`; - requestURI += `pid=${spec.pageID};`; - requestURI += `place=${encodeURIComponent(zoneCounters[zoneID])};`; - - // append the keyword for targeting if one was passed in - if (keyword !== '') { - requestURI += `kw=${encodeURIComponent(keyword)};`; - } - - zoneCounters[zoneID]++; - serverRequests.push({ - method: 'GET', - url: requestURI, - data: {}, - bidRequest: bidRequest - }); - } - return serverRequests; - }, - - // tslint:disable-next-line:cyclomatic-complexity - interpretResponse: (serverResponse, bidRequest) => { - const bidObj = bidRequest.bidRequest; - const bidResponses = []; - const bidResponse = {}; - let isCorrectSize = false; - let isCorrectCPM = true; - let cpm; - let minCPM; - let maxCPM; - let width; - let height; - - serverResponse = serverResponse.body; - if (serverResponse && serverResponse.status === 'SUCCESS' && bidObj) { - cpm = serverResponse.cpm; - minCPM = utils.getBidIdParameter('minCPM', bidObj.params); - maxCPM = utils.getBidIdParameter('maxCPM', bidObj.params); - width = parseInt(serverResponse.width); - height = parseInt(serverResponse.height); - - // Ensure response CPM is within the given bounds - if (minCPM !== '' && cpm < parseFloat(minCPM)) { - isCorrectCPM = false; - utils.logWarn('ContentIgnite: CPM did not meet minCPM requirements.'); - } else if (maxCPM !== '' && cpm > parseFloat(maxCPM)) { - isCorrectCPM = false; - utils.logWarn('ContentIgnite: CPM did not meet maxCPM requirements.'); - } - - // Ensure that response ad matches one of the placement sizes. - utils._each(bidObj.sizes, (size) => { - if (width === size[0] && height === size[1]) { - isCorrectSize = true; - } else { - utils.logWarn( - 'ContentIgnite: Returned ad is of a different size to that requested.' - ); - } - }); - if (isCorrectCPM && isCorrectSize) { - bidResponse.requestId = bidObj.bidId; - bidResponse.creativeId = serverResponse.placement_id; - bidResponse.cpm = cpm; - bidResponse.width = width; - bidResponse.height = height; - bidResponse.ad = serverResponse.ad_code; - bidResponse.currency = 'USD'; - bidResponse.netRevenue = true; - bidResponse.ttl = config.getConfig('_bidderTimeout'); - bidResponse.referrer = utils.getTopWindowUrl(); - bidResponses.push(bidResponse); - } - } - return bidResponses; - } -}; -registerBidder(spec); diff --git a/modules/convergeBidAdapter.js b/modules/convergeBidAdapter.js new file mode 100644 index 00000000000..bea3b6cb1ab --- /dev/null +++ b/modules/convergeBidAdapter.js @@ -0,0 +1,313 @@ +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { Renderer } from '../src/Renderer.js'; +import { VIDEO, BANNER } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'converge'; +const ENDPOINT_URL = 'https://tech.convergd.com/hb'; +const TIME_TO_LIVE = 360; +const SYNC_URL = 'https://tech.convergd.com/push_sync'; +const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; + +let hasSynced = false; + +const LOG_ERROR_MESS = { + noAuid: 'Bid from response has no auid parameter - ', + noAdm: 'Bid from response has no adm parameter - ', + noBid: 'Array of bid objects is empty', + noPlacementCode: "Can't find in requested bids the bid with auid - ", + emptyUids: 'Uids should be not empty', + emptySeatbid: 'Seatbid array from response has empty item', + emptyResponse: 'Response is empty', + hasEmptySeatbidArray: 'Response has empty seatbid array', + hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' +}; +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [ BANNER, VIDEO ], + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!bid.params.uid; + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} validBidRequests - an array of bids + * @param {bidderRequest} bidderRequest - bidder request object + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + const auids = []; + const bidsMap = {}; + const slotsMapByUid = {}; + const sizeMap = {}; + const bids = validBidRequests || []; + let priceType = 'net'; + let pageKeywords; + let reqId; + + bids.forEach(bid => { + if (bid.params.priceType === 'gross') { + priceType = 'gross'; + } + reqId = bid.bidderRequestId; + const {params: {uid}, adUnitCode} = bid; + auids.push(uid); + const sizesId = utils.parseSizesInput(bid.sizes); + + if (!pageKeywords && !utils.isEmpty(bid.params.keywords)) { + const keywords = utils.transformBidderParamKeywords(bid.params.keywords); + + if (keywords.length > 0) { + keywords.forEach(deleteValues); + } + pageKeywords = keywords; + } + + if (!slotsMapByUid[uid]) { + slotsMapByUid[uid] = {}; + } + const slotsMap = slotsMapByUid[uid]; + if (!slotsMap[adUnitCode]) { + slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []}; + } else { + slotsMap[adUnitCode].bids.push(bid); + } + const slot = slotsMap[adUnitCode]; + + sizesId.forEach((sizeId) => { + sizeMap[sizeId] = true; + if (!bidsMap[uid]) { + bidsMap[uid] = {}; + } + + if (!bidsMap[uid][sizeId]) { + bidsMap[uid][sizeId] = [slot]; + } else { + bidsMap[uid][sizeId].push(slot); + } + slot.parents.push({parent: bidsMap[uid], key: sizeId, uid}); + }); + }); + + const payload = { + pt: priceType, + auids: auids.join(','), + sizes: utils.getKeys(sizeMap).join(','), + r: reqId, + wrapperType: 'Prebid_js', + wrapperVersion: '$prebid.version$' + }; + + if (pageKeywords) { + payload.keywords = JSON.stringify(pageKeywords); + } + + if (bidderRequest) { + if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + payload.u = bidderRequest.refererInfo.referer; + } + if (bidderRequest.timeout) { + payload.wtimeout = bidderRequest.timeout; + } + if (bidderRequest.gdprConsent) { + if (bidderRequest.gdprConsent.consentString) { + payload.gdpr_consent = bidderRequest.gdprConsent.consentString; + } + payload.gdpr_applies = + (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') + ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; + } + if (bidderRequest.uspConsent) { + payload.us_privacy = bidderRequest.uspConsent; + } + } + + return { + method: 'GET', + url: ENDPOINT_URL, + data: utils.parseQueryStringParameters(payload).replace(/\&$/, ''), + bidsMap: bidsMap, + }; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @param {*} bidRequest + * @param {Renderer} RendererConst + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest, RendererConst = Renderer) { + serverResponse = serverResponse && serverResponse.body; + const bidResponses = []; + const bidsMap = bidRequest.bidsMap; + const priceType = bidRequest.data.pt; + + let errorMessage; + + if (!serverResponse) errorMessage = LOG_ERROR_MESS.emptyResponse; + else if (serverResponse.seatbid && !serverResponse.seatbid.length) { + errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray; + } + + if (!errorMessage && serverResponse.seatbid) { + serverResponse.seatbid.forEach(respItem => { + _addBidResponse(_getBidFromResponse(respItem), bidsMap, priceType, bidResponses, RendererConst); + }); + } + if (errorMessage) utils.logError(errorMessage); + return bidResponses; + }, + getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { + if (!hasSynced && syncOptions.pixelEnabled) { + let params = ''; + + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + params += `&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent) { + params += `&us_privacy=${uspConsent}`; + } + + hasSynced = true; + return { + type: 'image', + url: SYNC_URL + params + }; + } + } +}; + +function isPopulatedArray(arr) { + return !!(utils.isArray(arr) && arr.length > 0); +} + +function deleteValues(keyPairObj) { + if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { + delete keyPairObj.value; + } +} + +function _getBidFromResponse(respItem) { + if (!respItem) { + utils.logError(LOG_ERROR_MESS.emptySeatbid); + } else if (!respItem.bid) { + utils.logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); + } else if (!respItem.bid[0]) { + utils.logError(LOG_ERROR_MESS.noBid); + } + return respItem && respItem.bid && respItem.bid[0]; +} + +function _addBidResponse(serverBid, bidsMap, priceType, bidResponses, RendererConst) { + if (!serverBid) return; + let errorMessage; + if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); + if (!serverBid.adm) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); + else { + const awaitingBids = bidsMap[serverBid.auid]; + if (awaitingBids) { + const sizeId = `${serverBid.w}x${serverBid.h}`; + if (awaitingBids[sizeId]) { + const slot = awaitingBids[sizeId][0]; + + const bid = slot.bids.shift(); + const bidResponse = { + requestId: bid.bidId, // bid.bidderRequestId, + bidderCode: spec.code, + cpm: serverBid.price, + width: serverBid.w, + height: serverBid.h, + creativeId: serverBid.auid, // bid.bidId, + currency: 'EUR', + netRevenue: priceType !== 'gross', + ttl: TIME_TO_LIVE, + dealId: serverBid.dealid + }; + if (serverBid.content_type === 'video' || (!serverBid.content_type && bid.mediaTypes && bid.mediaTypes.video)) { + bidResponse.vastXml = serverBid.adm; + bidResponse.mediaType = VIDEO; + bidResponse.adResponse = { + content: bidResponse.vastXml + }; + if (!bid.renderer && (!bid.mediaTypes || !bid.mediaTypes.video || bid.mediaTypes.video.context === 'outstream')) { + bidResponse.renderer = createRenderer(bidResponse, { + id: bid.bidId, + url: RENDERER_URL + }, RendererConst); + } + } else { + bidResponse.ad = serverBid.adm; + bidResponse.mediaType = BANNER; + } + + bidResponses.push(bidResponse); + + if (!slot.bids.length) { + slot.parents.forEach(({parent, key, uid}) => { + const index = parent[key].indexOf(slot); + if (index > -1) { + parent[key].splice(index, 1); + } + if (!parent[key].length) { + delete parent[key]; + if (!utils.getKeys(parent).length) { + delete bidsMap[uid]; + } + } + }); + } + } + } else { + errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; + } + } + if (errorMessage) { + utils.logError(errorMessage); + } +} + +function outstreamRender (bid) { + bid.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + targetId: bid.adUnitCode, + adResponse: bid.adResponse + }); + }); +} + +function createRenderer (bid, rendererParams, RendererConst) { + const rendererInst = RendererConst.install({ + id: rendererParams.id, + url: rendererParams.url, + loaded: false + }); + + try { + rendererInst.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + + return rendererInst; +} + +export function resetUserSync() { + hasSynced = false; +} + +export function getSyncUrl() { + return SYNC_URL; +} + +registerBidder(spec); diff --git a/modules/convergeBidAdapter.md b/modules/convergeBidAdapter.md new file mode 100644 index 00000000000..ab916a8b3b6 --- /dev/null +++ b/modules/convergeBidAdapter.md @@ -0,0 +1,57 @@ +# Overview + +Module Name: Converge Bidder Adapter +Module Type: Bidder Adapter +Maintainer: support@converge-digital.com + +# Description + +Module that connects to Converge demand source to fetch bids. +Converge Bid Adapter supports Banner and Video (instream and outstream). + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + sizes: [[300, 250]], + bids: [ + { + bidder: "converge", + params: { + uid: '59', + priceType: 'gross' // by default is 'net' + } + } + ] + },{ + code: 'test-div', + sizes: [[728, 90]], + bids: [ + { + bidder: "converge", + params: { + uid: 1, + priceType: 'gross', + keywords: { + brandsafety: ['disaster'], + topic: ['stress', 'fear'] + } + } + } + ] + },{ + code: 'test-div', + sizes: [[640, 360]], + mediaTypes: { video: {} }, + bids: [ + { + bidder: "converge", + params: { + uid: 60 + } + } + ] + } + ]; +``` diff --git a/modules/conversantBidAdapter.js b/modules/conversantBidAdapter.js index 90865493d8d..25eed9c0e99 100644 --- a/modules/conversantBidAdapter.js +++ b/modules/conversantBidAdapter.js @@ -1,13 +1,17 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const GVLID = 24; +export const storage = getStorageManager(GVLID); const BIDDER_CODE = 'conversant'; -const URL = '//web.hb.ad.cpe.dotomi.com/s2s/header/24'; -const VERSION = '2.2.4'; +const URL = 'https://web.hb.ad.cpe.dotomi.com/s2s/header/24'; export const spec = { code: BIDDER_CODE, + gvlid: GVLID, aliases: ['cnvr'], // short code supportedMediaTypes: [BANNER, VIDEO], @@ -24,7 +28,7 @@ export const spec = { } if (!utils.isStr(bid.params.site_id)) { - utils.logWarn(BIDDER_CODE + ': site_id must be specified as a string') + utils.logWarn(BIDDER_CODE + ': site_id must be specified as a string'); return false; } @@ -45,29 +49,30 @@ export const spec = { * Make a server request from the list of BidRequests. * * @param {BidRequest[]} validBidRequests - an array of bids + * @param bidderRequest * @return {ServerRequest} Info describing the request to the server. */ buildRequests: function(validBidRequests, bidderRequest) { - const loc = utils.getTopWindowLocation(); - const page = loc.href; - const isPageSecure = (loc.protocol === 'https:') ? 1 : 0; + const page = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : ''; let siteId = ''; let requestId = ''; let pubcid = null; + let pubcidName = '_pubcid'; const conversantImps = validBidRequests.map(function(bid) { const bidfloor = utils.getBidIdParameter('bidfloor', bid.params); - const secure = isPageSecure || (utils.getBidIdParameter('secure', bid.params) ? 1 : 0); - siteId = utils.getBidIdParameter('site_id', bid.params); + siteId = utils.getBidIdParameter('site_id', bid.params) || siteId; + pubcidName = utils.getBidIdParameter('pubcid_name', bid.params) || pubcidName; + requestId = bid.auctionId; const imp = { id: bid.bidId, - secure: secure, + secure: 1, bidfloor: bidfloor || 0, displaymanager: 'Prebid.js', - displaymanagerver: VERSION + displaymanagerver: '$prebid.version$' }; copyOptProperty(bid.params.tag_id, imp, 'tagid'); @@ -122,17 +127,23 @@ export const spec = { let userExt = {}; - // Add GDPR flag and consent string - if (bidderRequest && bidderRequest.gdprConsent) { - userExt.consent = bidderRequest.gdprConsent.consentString; + if (bidderRequest) { + // Add GDPR flag and consent string + if (bidderRequest.gdprConsent) { + userExt.consent = bidderRequest.gdprConsent.consentString; - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - payload.regs = { - ext: { - gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0) - } - }; + if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { + utils.deepSetValue(payload, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies ? 1 : 0); + } } + + if (bidderRequest.uspConsent) { + utils.deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + } + + if (!pubcid) { + pubcid = readStoredValue(pubcidName); } // Add common id if available @@ -140,6 +151,12 @@ export const spec = { userExt.fpc = pubcid; } + // Add Eids if available + const eids = collectEids(validBidRequests); + if (eids.length > 0) { + userExt.eids = eids; + } + // Only add the user object if it's not empty if (!utils.isEmpty(userExt)) { payload.user = {ext: userExt}; @@ -155,6 +172,7 @@ export const spec = { * Unpack the response from the server into a list of bids. * * @param {*} serverResponse A successful response from the server. + * @param bidRequest * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: function(serverResponse, bidRequest) { @@ -185,7 +203,12 @@ export const spec = { }; if (request.video) { - bid.vastUrl = responseAd; + if (responseAd.charAt(0) === '<') { + bid.vastXml = responseAd; + } else { + bid.vastUrl = responseAd; + } + bid.mediaType = 'video'; bid.width = request.video.w; bid.height = request.video.h; @@ -250,7 +273,7 @@ function getDevice() { * * [[300, 250], [300, 600]] => [{w: 300, h: 250}, {w: 300, h: 600}] * - * @param {number[2][]|number[2]} bidSizes - arrays of widths and heights + * @param {Array.>} bidSizes - arrays of widths and heights * @returns {object[]} Array of objects with w and h */ function convertSizes(bidSizes) { @@ -289,4 +312,62 @@ function copyOptProperty(src, dst, dstName) { } } +/** + * Collect IDs from validBidRequests and store them as an extended id array + * @param bidRequests valid bid requests + */ +function collectEids(bidRequests) { + const request = bidRequests[0]; // bidRequests have the same userId object + const eids = []; + if (utils.isArray(request.userIdAsEids) && request.userIdAsEids.length > 0) { + // later following white-list can be converted to block-list if needed + const requiredSourceValues = { + 'adserver.org': 1, + 'liveramp.com': 1, + 'criteo.com': 1, + 'id5-sync.com': 1, + 'parrable.com': 1, + 'digitru.st': 1, + 'liveintent.com': 1 + }; + request.userIdAsEids.forEach(function(eid) { + if (requiredSourceValues.hasOwnProperty(eid.source)) { + eids.push(eid); + } + }); + } + return eids; +} + +/** + * Look for a stored value from both cookie and local storage and return the first value found. + * @param key Key for the search + * @return {string} Stored value + */ +function readStoredValue(key) { + let storedValue; + try { + // check cookies first + storedValue = storage.getCookie(key); + + if (!storedValue) { + // check expiration time before reading local storage + const storedValueExp = storage.getDataFromLocalStorage(`${key}_exp`); + if (storedValueExp === '' || (storedValueExp && (new Date(storedValueExp)).getTime() - Date.now() > 0)) { + storedValue = storage.getDataFromLocalStorage(key); + storedValue = storedValue ? decodeURIComponent(storedValue) : storedValue; + } + } + + // deserialize JSON if needed + if (utils.isStr(storedValue) && storedValue.charAt(0) === '{') { + storedValue = JSON.parse(storedValue); + } + } catch (e) { + utils.logError(e); + } + + return storedValue; +} + registerBidder(spec); diff --git a/modules/conversantBidAdapter.md b/modules/conversantBidAdapter.md index 3ce83d8c893..5aba5653043 100644 --- a/modules/conversantBidAdapter.md +++ b/modules/conversantBidAdapter.md @@ -13,7 +13,11 @@ Module that connects to Conversant's demand sources. Supports banners and video var adUnits = [ { code: 'banner-test-div', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250],[300,600]] + } + }, bids: [{ bidder: "conversant", params: { diff --git a/modules/cosmosBidAdapter.js b/modules/cosmosBidAdapter.js index 84131bfa131..73ee5c223b3 100644 --- a/modules/cosmosBidAdapter.js +++ b/modules/cosmosBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = 'cosmos'; -const BID_ENDPOINT = '//bid.cosmoshq.com/openrtb2/bids'; -const USER_SYNC_ENDPOINT = '//sync.cosmoshq.com/js/v1/usersync.html'; +const BID_ENDPOINT = 'https://bid.cosmoshq.com/openrtb2/bids'; +const USER_SYNC_ENDPOINT = 'https://sync.cosmoshq.com/js/v1/usersync.html'; const HTTP_POST = 'POST'; const LOG_PREFIX = 'COSMOS: '; const DEFAULT_CURRENCY = 'USD'; diff --git a/modules/cpmstarBidAdapter.js b/modules/cpmstarBidAdapter.js index 84b76cbbc35..6146e704448 100644 --- a/modules/cpmstarBidAdapter.js +++ b/modules/cpmstarBidAdapter.js @@ -1,13 +1,13 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import {VIDEO, BANNER} from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import {VIDEO, BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'cpmstar'; -const ENDPOINT_DEV = '//dev.server.cpmstar.com/view.aspx'; -const ENDPOINT_STAGING = '//staging.server.cpmstar.com/view.aspx'; -const ENDPOINT_PRODUCTION = '//server.cpmstar.com/view.aspx'; +const ENDPOINT_DEV = 'https://dev.server.cpmstar.com/view.aspx'; +const ENDPOINT_STAGING = 'https://staging.server.cpmstar.com/view.aspx'; +const ENDPOINT_PRODUCTION = 'https://server.cpmstar.com/view.aspx'; const DEFAULT_TTL = 300; const DEFAULT_CURRENCY = 'USD'; diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js index 559c02cd4a9..6eca0c95dde 100644 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -1,34 +1,32 @@ -import { loadExternalScript } from '../src/adloader'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { config } from '../src/config'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import { parse } from '../src/url'; -import * as utils from '../src/utils'; -import find from 'core-js/library/fn/array/find'; -import JSEncrypt from 'jsencrypt/bin/jsencrypt'; -import sha256 from 'crypto-js/sha256'; - -export const ADAPTER_VERSION = 20; +import { loadExternalScript } from '../src/adloader.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; +import find from 'core-js/library/fn/array/find.js'; +import { verify } from 'criteo-direct-rsa-validate/build/verify.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const GVLID = 91; +export const ADAPTER_VERSION = 27; const BIDDER_CODE = 'criteo'; -const CDB_ENDPOINT = '//bidder.criteo.com/cdb'; +const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb'; const CRITEO_VENDOR_ID = 91; const PROFILE_ID_INLINE = 207; export const PROFILE_ID_PUBLISHERTAG = 185; +const storage = getStorageManager(GVLID); // Unminified source code can be found in: https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js -const PUBLISHER_TAG_URL = '//static.criteo.net/js/ld/publishertag.prebid.js'; +const PUBLISHER_TAG_URL = 'https://static.criteo.net/js/ld/publishertag.prebid.js'; -export const FAST_BID_PUBKEY = `-----BEGIN PUBLIC KEY----- -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDO1BjAITkFTtP0IMzmF7qsqhpu -y1dGaTPHnjMU9mRZsrnfR3C0sEN5pYEzEcFRPnkJjJuhH8Rnh5+CE+LcKg0Z8ZZ7 -OmOSj0/qnYTAYCu0cR5LiyWG79KlIgUyMbp92ulGg24gAyGrVn4+v/4c53WlOEUp -4YWvb82G0CD5NcDNpQIDAQAB ------END PUBLIC KEY-----`; +const FAST_BID_PUBKEY_E = 65537; +const FAST_BID_PUBKEY_N = 'ztQYwCE5BU7T9CDM5he6rKoabstXRmkzx54zFPZkWbK530dwtLBDeaWBMxHBUT55CYyboR/EZ4efghPi3CoNGfGWezpjko9P6p2EwGArtHEeS4slhu/SpSIFMjG6fdrpRoNuIAMhq1Z+Pr/+HOd1pThFKeGFr2/NhtAg+TXAzaU='; /** @type {BidderSpec} */ export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [ BANNER, VIDEO ], + gvlid: GVLID, + supportedMediaTypes: [ BANNER, VIDEO, NATIVE ], /** * @param {object} bid @@ -59,7 +57,11 @@ export const spec = { let url; let data; - Object.assign(bidderRequest, { ceh: config.getConfig('criteo.ceh') }); + Object.assign(bidderRequest, { + publisherExt: config.getConfig('fpd.context'), + userExt: config.getConfig('fpd.user'), + ceh: config.getConfig('criteo.ceh') + }); // If publisher tag not already loaded try to get it from fast bid if (!publisherTagAvailable()) { @@ -75,11 +77,16 @@ export const spec = { } if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = new Criteo.PubTag.Adapters.Prebid(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$'); + const enableSendAllBids = config.getConfig('enableSendAllBids'); + if (adapter.setEnableSendAllBids && typeof adapter.setEnableSendAllBids === 'function' && typeof enableSendAllBids === 'boolean') { + adapter.setEnableSendAllBids(enableSendAllBids); + } url = adapter.buildCdbUrl(); data = adapter.buildCdbRequest(); } else { - const context = buildContext(bidRequests); + const context = buildContext(bidRequests, bidderRequest); url = buildCdbUrl(context); data = buildCdbRequest(context, bidRequests, bidderRequest); } @@ -98,6 +105,7 @@ export const spec = { const body = response.body || response; if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(request); if (adapter) { return adapter.interpretResponse(body, request); @@ -121,9 +129,16 @@ export const spec = { width: slot.width, height: slot.height, dealId: slot.dealCode, - } + }; if (slot.native) { - bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback); + if (bidRequest.params.nativeCallback) { + bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback); + } else if (config.getConfig('enableSendAllBids') === true) { + return; + } else { + bid.native = createPrebidNativeAd(slot.native); + bid.mediaType = NATIVE; + } } else if (slot.video) { bid.vastUrl = slot.displayurl; bid.mediaType = VIDEO; @@ -142,6 +157,7 @@ export const spec = { */ onTimeout: (timeoutData) => { if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(timeoutData.auctionId); adapter.handleBidTimeout(); } @@ -152,6 +168,7 @@ export const spec = { */ onBidWon: (bid) => { if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(bid.auctionId); adapter.handleBidWon(bid); } @@ -162,6 +179,7 @@ export const spec = { */ onSetTargeting: (bid) => { if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(bid.auctionId); adapter.handleSetTargeting(bid); } @@ -172,19 +190,23 @@ export const spec = { * @return {boolean} */ function publisherTagAvailable() { + // eslint-disable-next-line no-undef return typeof Criteo !== 'undefined' && Criteo.PubTag && Criteo.PubTag.Adapters && Criteo.PubTag.Adapters.Prebid; } /** * @param {BidRequest[]} bidRequests - * @return {CriteoContext} + * @param bidderRequest */ -function buildContext(bidRequests) { - const url = utils.getTopWindowUrl(); - const queryString = parse(url).search; +function buildContext(bidRequests, bidderRequest) { + let referrer = ''; + if (bidderRequest && bidderRequest.refererInfo) { + referrer = bidderRequest.refererInfo.referer; + } + const queryString = utils.parseUrl(referrer).search; const context = { - url: url, + url: referrer, debug: queryString['pbt_debug'] === '1', noLog: queryString['pbt_nolog'] === '1', amp: false, @@ -194,7 +216,7 @@ function buildContext(bidRequests) { if (bidRequest.params.integrationMode === 'amp') { context.amp = true; } - }) + }); return context; } @@ -233,6 +255,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { const request = { publisher: { url: context.url, + ext: bidderRequest.publisherExt }, slots: bidRequests.map(bidRequest => { networkId = bidRequest.params.networkId || networkId; @@ -245,10 +268,16 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (bidRequest.params.zoneId) { slot.zoneid = bidRequest.params.zoneId; } + if (bidRequest.fpd && bidRequest.fpd.context) { + slot.ext = bidRequest.fpd.context; + } + if (bidRequest.params.ext) { + slot.ext = Object.assign({}, slot.ext, bidRequest.params.ext); + } if (bidRequest.params.publisherSubId) { slot.publishersubid = bidRequest.params.publisherSubId; } - if (bidRequest.params.nativeCallback) { + if (bidRequest.params.nativeCallback || utils.deepAccess(bidRequest, `mediaTypes.${NATIVE}`)) { slot.native = true; } if (hasVideoMediaType(bidRequest)) { @@ -274,7 +303,9 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (networkId) { request.publisher.networkid = networkId; } - request.user = {}; + request.user = { + ext: bidderRequest.userExt + }; if (bidderRequest && bidderRequest.ceh) { request.user.ceh = bidderRequest.ceh; } @@ -291,6 +322,9 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { request.gdprConsent.consentData = bidderRequest.gdprConsent.consentString; } } + if (bidderRequest && bidderRequest.uspConsent) { + request.user.uspIab = bidderRequest.uspConsent; + } return request; } @@ -354,6 +388,27 @@ function hasValidVideoMediaType(bidRequest) { return false; } +/** + * Create prebid compatible native ad with native payload + * @param {*} payload + * @returns prebid native ad assets + */ +function createPrebidNativeAd(payload) { + return { + title: payload.products[0].title, + body: payload.products[0].description, + sponsoredBy: payload.advertiser.description, + icon: payload.advertiser.logo, + image: payload.products[0].image, + clickUrl: payload.products[0].click_url, + privacyLink: payload.privacy.optout_click_url, + privacyIcon: payload.privacy.optout_image_url, + cta: payload.products[0].call_to_action, + price: payload.products[0].price, + impressionTrackers: payload.impression_pixels.map(pix => pix.url) + }; +} + /** * @param {string} id * @param {*} payload @@ -362,32 +417,29 @@ function hasValidVideoMediaType(bidRequest) { */ function createNativeAd(id, payload, callback) { // Store the callback and payload in a global object to be later accessed from the creative - window.criteo_prebid_native_slots = window.criteo_prebid_native_slots || {}; - window.criteo_prebid_native_slots[id] = { callback, payload }; + var slotsName = 'criteo_prebid_native_slots'; + window[slotsName] = window[slotsName] || {}; + window[slotsName][id] = { callback, payload }; // The creative is in an iframe so we have to get the callback and payload // from the parent window (doesn't work with safeframes) - return ``; + return ` +`; } -/** - * @return {boolean} - */ export function tryGetCriteoFastBid() { try { const fastBidStorageKey = 'criteo_fast_bid'; const hashPrefix = '// Hash: '; - const fastBidFromStorage = localStorage.getItem(fastBidStorageKey); + const fastBidFromStorage = storage.getDataFromLocalStorage(fastBidStorageKey); if (fastBidFromStorage !== null) { // The value stored must contain the file's encrypted hash as first line @@ -396,20 +448,21 @@ export function tryGetCriteoFastBid() { if (firstLine.substr(0, hashPrefix.length) !== hashPrefix) { utils.logWarn('No hash found in FastBid'); - localStorage.removeItem(fastBidStorageKey); + storage.removeDataFromLocalStorage(fastBidStorageKey); } else { // Remove the hash part from the locally stored value const publisherTagHash = firstLine.substr(hashPrefix.length); const publisherTag = fastBidFromStorage.substr(firstLineEndPosition + 1); - var jsEncrypt = new JSEncrypt(); - jsEncrypt.setPublicKey(FAST_BID_PUBKEY); - if (jsEncrypt.verify(publisherTag, publisherTagHash, sha256)) { + if (verify(publisherTag, publisherTagHash, FAST_BID_PUBKEY_N, FAST_BID_PUBKEY_E)) { utils.logInfo('Using Criteo FastBid'); - eval(publisherTag); // eslint-disable-line no-eval + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.text = publisherTag; + utils.insertElement(script); } else { utils.logWarn('Invalid Criteo FastBid found'); - localStorage.removeItem(fastBidStorageKey); + storage.removeDataFromLocalStorage(fastBidStorageKey); } } } diff --git a/modules/criteoIdSystem.js b/modules/criteoIdSystem.js new file mode 100644 index 00000000000..c44f0c843ae --- /dev/null +++ b/modules/criteoIdSystem.js @@ -0,0 +1,141 @@ +/** + * This module adds Criteo Real Time User Sync to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/criteoIdSystem + * @requires module:modules/userId + */ + +import * as utils from '../src/utils.js' +import * as ajax from '../src/ajax.js' +import { getRefererInfo } from '../src/refererDetection.js' +import { submodule } from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; + +export const storage = getStorageManager(); + +const bididStorageKey = 'cto_bidid'; +const bundleStorageKey = 'cto_bundle'; +const cookieWriteableKey = 'cto_test_cookie'; +const cookiesMaxAge = 13 * 30 * 24 * 60 * 60 * 1000; + +const pastDateString = new Date(0).toString(); +const expirationString = new Date(utils.timestamp() + cookiesMaxAge).toString(); + +function areCookiesWriteable() { + storage.setCookie(cookieWriteableKey, '1'); + const canWrite = storage.getCookie(cookieWriteableKey) === '1'; + storage.setCookie(cookieWriteableKey, '', pastDateString); + return canWrite; +} + +function extractProtocolHost (url, returnOnlyHost = false) { + const parsedUrl = utils.parseUrl(url) + return returnOnlyHost + ? `${parsedUrl.hostname}` + : `${parsedUrl.protocol}://${parsedUrl.hostname}${parsedUrl.port ? ':' + parsedUrl.port : ''}/`; +} + +function getFromAllStorages(key) { + return storage.getCookie(key) || storage.getDataFromLocalStorage(key); +} + +function saveOnAllStorages(key, value) { + if (key && value) { + storage.setCookie(key, value, expirationString); + storage.setDataInLocalStorage(key, value); + } +} + +function deleteFromAllStorages(key) { + storage.setCookie(key, '', pastDateString); + storage.removeDataFromLocalStorage(key); +} + +function getCriteoDataFromAllStorages() { + return { + bundle: getFromAllStorages(bundleStorageKey), + bidId: getFromAllStorages(bididStorageKey), + } +} + +function buildCriteoUsersyncUrl(topUrl, domain, bundle, areCookiesWriteable, isPublishertagPresent, gdprString) { + const url = 'https://gum.criteo.com/sid/json?origin=prebid' + + `${topUrl ? '&topUrl=' + encodeURIComponent(topUrl) : ''}` + + `${domain ? '&domain=' + encodeURIComponent(domain) : ''}` + + `${bundle ? '&bundle=' + encodeURIComponent(bundle) : ''}` + + `${gdprString ? '&gdprString=' + encodeURIComponent(gdprString) : ''}` + + `${areCookiesWriteable ? '&cw=1' : ''}` + + `${isPublishertagPresent ? '&pbt=1' : ''}` + + return url; +} + +function callCriteoUserSync(parsedCriteoData, gdprString) { + const cw = areCookiesWriteable(); + const topUrl = extractProtocolHost(getRefererInfo().referer); + const domain = extractProtocolHost(document.location.href, true); + const isPublishertagPresent = typeof criteo_pubtag !== 'undefined'; // eslint-disable-line camelcase + + const url = buildCriteoUsersyncUrl( + topUrl, + domain, + parsedCriteoData.bundle, + cw, + isPublishertagPresent, + gdprString + ); + + ajax.ajaxBuilder()( + url, + response => { + const jsonResponse = JSON.parse(response); + if (jsonResponse.bidId) { + saveOnAllStorages(bididStorageKey, jsonResponse.bidId); + } else { + deleteFromAllStorages(bididStorageKey); + } + + if (jsonResponse.acwsUrl) { + const urlsToCall = typeof jsonResponse.acwsUrl === 'string' ? [jsonResponse.acwsUrl] : jsonResponse.acwsUrl; + urlsToCall.forEach(url => utils.triggerPixel(url)); + } else if (jsonResponse.bundle) { + saveOnAllStorages(bundleStorageKey, jsonResponse.bundle); + } + } + ); +} + +/** @type {Submodule} */ +export const criteoIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'criteo', + /** + * decode the stored id value for passing to bid requests + * @function + * @returns {{criteoId: string} | undefined} + */ + decode(bidId) { + return bidId; + }, + /** + * get the Criteo Id from local storages and initiate a new user sync + * @function + * @param {SubmoduleParams} [configParams] + * @param {ConsentData} [consentData] + * @returns {{id: {criteoId: string} | undefined}}} + */ + getId(configParams, consentData) { + const hasGdprData = consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies; + const gdprConsentString = hasGdprData ? consentData.consentString : undefined; + + let localData = getCriteoDataFromAllStorages(); + callCriteoUserSync(localData, gdprConsentString); + + return { id: localData.bidId ? { criteoId: localData.bidId } : undefined } + } +}; + +submodule('userId', criteoIdSubmodule); diff --git a/modules/criteortusIdSystem.js b/modules/criteortusIdSystem.js deleted file mode 100644 index 02edf0ef06e..00000000000 --- a/modules/criteortusIdSystem.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * This module adds Criteo Real Time User Sync to the User ID module - * The {@link module:modules/userId} module is required - * @module modules/criteortusIdSystem - * @requires module:modules/userId - */ - -import * as utils from '../src/utils' -import { ajax } from '../src/ajax'; -import { submodule } from '../src/hook'; - -const key = '__pbjs_criteo_rtus'; - -/** @type {Submodule} */ -export const criteortusIdSubmodule = { - /** - * used to link submodule with config - * @type {string} - */ - name: 'criteortus', - /** - * decode the stored id value for passing to bid requests - * @function - * @returns {{criteortus:Object}} - */ - decode() { - let uid = utils.getCookie(key); - try { - uid = JSON.parse(uid); - return { 'criteortus': uid }; - } catch (error) { - utils.logError('Error in parsing criteo rtus data', error); - } - }, - /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleParams} [configParams] - * @returns {function(callback:function)} - */ - getId(configParams) { - if (!configParams || !utils.isPlainObject(configParams.clientIdentifier)) { - utils.logError('User ID - Criteo rtus requires client identifier to be defined'); - return; - } - - let uid = utils.getCookie(key); - if (uid) { - return uid; - } else { - let userIds = {}; - return function(callback) { - let bidders = Object.keys(configParams.clientIdentifier); - - function afterAllResponses() { - // criteo rtus user id expires in 1 hour - const expiresStr = (new Date(Date.now() + (60 * 60 * 1000))).toUTCString(); - utils.setCookie(key, JSON.stringify(userIds), expiresStr); - callback(userIds); - } - - const onResponse = utils.delayExecution(afterAllResponses, bidders.length); - - bidders.forEach((bidder) => { - let url = `https://gum.criteo.com/sync?c=${configParams.clientIdentifier[bidder]}&r=3`; - const getSuccessHandler = (bidder) => { - return function onSuccess(response) { - if (response) { - try { - response = JSON.parse(response); - userIds[bidder] = response; - onResponse(); - } catch (error) { - utils.logError(error); - } - } - } - } - - const getFailureHandler = (bidder) => { - return function onFailure(error) { - utils.logError(`Criteo RTUS server call failed for ${bidder}`, error); - onResponse(); - } - } - - ajax( - url, - { - success: getSuccessHandler(bidder), - error: getFailureHandler(bidder) - }, - undefined, - Object.assign({ - method: 'GET', - withCredentials: true - }) - ); - }) - } - } - } -}; - -submodule('userId', criteortusIdSubmodule); diff --git a/modules/currency.js b/modules/currency.js index ae2f9ac1f1b..0464d9b5cdb 100644 --- a/modules/currency.js +++ b/modules/currency.js @@ -1,8 +1,9 @@ -import { createBid } from '../src/bidfactory'; -import { STATUS } from '../src/constants'; -import { ajax } from '../src/ajax'; -import * as utils from '../src/utils'; -import { config } from '../src/config'; +import { getGlobal } from '../src/prebidGlobal.js'; +import { createBid } from '../src/bidfactory.js'; +import { STATUS } from '../src/constants.json'; +import { ajax } from '../src/ajax.js'; +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; import { getHook } from '../src/hook.js'; const DEFAULT_CURRENCY_RATE_URL = 'https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=$$TODAY$$'; @@ -122,6 +123,8 @@ function initCurrency(url) { utils.logInfo('Installing addBidResponse decorator for currency module', arguments); + // Adding conversion function to prebid global for external module and on page use + getGlobal().convertCurrency = (cpm, fromCurrency, toCurrency) => parseFloat(cpm) * getCurrencyConversion(fromCurrency, toCurrency); getHook('addBidResponse').before(addBidResponseHook, 100); // call for the file if we haven't already @@ -149,6 +152,7 @@ function resetCurrency() { utils.logInfo('Uninstalling addBidResponse decorator for currency module', arguments); getHook('addBidResponse').getHooks({hook: addBidResponseHook}).remove(); + delete getGlobal().convertCurrency; adServerCurrency = 'USD'; conversionCache = {}; @@ -185,9 +189,6 @@ export function addBidResponseHook(fn, adUnitCode, bid) { return (parseFloat(this.cpm) * getCurrencyConversion(this.currency, toCurrency)).toFixed(3); }; - bid.originalCpm = bid.cpm; - bid.originalCurrency = bid.currency; - // execute immediately if the bid is already in the desired currency if (bid.currency === adServerCurrency) { return fn.call(this, adUnitCode, bid); diff --git a/modules/dailyhuntBidAdapter.js b/modules/dailyhuntBidAdapter.js new file mode 100644 index 00000000000..5b28f086938 --- /dev/null +++ b/modules/dailyhuntBidAdapter.js @@ -0,0 +1,192 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import * as mediaTypes from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; + +const BIDDER_CODE = 'dailyhunt'; +const BIDDER_ALIAS = 'dh'; +const SUPPORTED_MEDIA_TYPES = [mediaTypes.BANNER, mediaTypes.NATIVE]; + +const PROD_PREBID_ENDPOINT_URL = 'https://money.dailyhunt.in/openrtb2/auction'; + +const PROD_ENDPOINT_URL = 'https://money.dailyhunt.in/openx/ads/index.php'; + +function buildParams(bid) { + let params = { ...bid.params }; + params.pagetype = 'sources'; + params.placementId = 12345; + params.env = 'prod'; + if (params.testmode && params.testmode === true) { + params.customEvent = 'pb-testmode'; + } + let hasWeb5Size = false; + let hasWeb3Size = false; + bid && bid.sizes && bid.sizes.forEach((size, i) => { + if (!hasWeb3Size && size[0] == 300 && size[1] == 250) { + hasWeb3Size = true; + } + if (!hasWeb5Size && (size[0] == 300 || size[0] == 320) && size[1] == 50) { + hasWeb5Size = true; + } + }) + params.zone = 'web'; + if (!hasWeb3Size && hasWeb5Size) { + params.subSlots = 'web-5'; + } else { + params.subSlots = 'web-3'; + } + if (bid.nativeParams) { + params.subSlots = 'web-3'; + params.ad_type = '2,3'; + } + if (!params.partnerId) { + params.partnerId = 'unknown-pb-partner'; + } + params.pbRequestId = bid.bidId; + params.format = 'json'; + return params; +} + +const _encodeURIComponent = function (a) { + let b = window.encodeURIComponent(a); + b = b.replace(/'/g, '%27'); + return b; +} + +export const spec = { + code: BIDDER_CODE, + + aliases: [BIDDER_ALIAS], + + supportedMediaTypes: SUPPORTED_MEDIA_TYPES, + + isBidRequestValid: bid => !!bid.params.partnerId, + + buildRequests: function (validBidRequests, bidderRequest) { + let serverRequests = []; + const userAgent = navigator.userAgent; + const page = bidderRequest.refererInfo.referer; + + validBidRequests.forEach((bid, i) => { + let params = buildParams(bid); + let request = ''; + if (bid.nativeParams) { + request = { + method: 'GET', + url: PROD_ENDPOINT_URL, + data: utils.parseQueryStringParameters(params) + }; + } else { + let ortbReq = { + id: bidderRequest.auctionId, + imp: [{ + id: i.toString(), + banner: { + id: 'banner-' + bidderRequest.auctionId, + format: [ + { + 'h': 250, + 'w': 300 + }, + { + 'h': 50, + 'w': 320 + } + ] + }, + bidfloor: 0, + ext: { + dailyhunt: { + ...params + } + } + }], + site: { id: i.toString(), page }, + device: { userAgent }, + user: { + id: params.clientId || '', + } + }; + request = { + method: 'POST', + url: PROD_PREBID_ENDPOINT_URL, + data: JSON.stringify(ortbReq), + options: { + contentType: 'application/json', + withCredentials: true + }, + bids: validBidRequests + }; + } + serverRequests.push(request); + }); + return serverRequests; + }, + + interpretResponse: function (serverResponse, request) { + let bidResponses = []; + if (!request.bids) { + let bid = serverResponse.body[0][0].ad; + if (bid.typeId != 2 && bid.typeId != 3) { + return bidResponses; + } + let impTrackers = []; + impTrackers.push(bid.beaconUrl); + impTrackers = (bid.beaconUrlAdditional && bid.beaconUrlAdditional.length !== 0) ? impTrackers.concat(bid.beaconUrlAdditional) : impTrackers; + let bidResponse = { + requestId: bid.pbRequestId, + cpm: bid.price, + creativeId: bid.bannerid, + currency: 'USD', + ttl: 360, + netRevenue: true, + }; + bidResponse.mediaType = 'native' + bidResponse.native = { + title: bid.content.itemTitle.data, + body: bid.content.itemSubtitle1.data, + body2: bid.content.itemSubtitle1.data, + cta: bid.content.itemSubtitle2.data, + clickUrl: _encodeURIComponent(bid.action), + impressionTrackers: impTrackers, + clickTrackers: bid.landingUrlAdditional && bid.landingUrlAdditional.length !== 0 ? bid.landingUrlAdditional : [], + image: { + url: bid.content.iconLink, + height: bid.height, + width: bid.width + }, + icon: { + url: bid.content.iconLink, + height: bid.height, + width: bid.width + } + } + bidResponses.push(bidResponse); + return bidResponses; + } else { + if (!serverResponse.body) { + return; + } + const { seatbid } = serverResponse.body; + let bids = request.bids; + return bids.reduce((accumulator, bid, index) => { + const _cbid = seatbid && seatbid[index] && seatbid[index].bid; + const bidResponse = _cbid && _cbid[0]; + if (bidResponse) { + accumulator.push({ + requestId: bid.bidId, + cpm: bidResponse.price, + creativeId: bidResponse.crid, + width: bidResponse.w, + height: bidResponse.h, + ttl: 360, + netRevenue: bid.netRevenue === 'net', + currency: 'USD', + ad: bidResponse.adm + }); + } + return accumulator; + }, []); + } + }, +} +registerBidder(spec); diff --git a/modules/dailyhuntBidAdapter.md b/modules/dailyhuntBidAdapter.md new file mode 100644 index 00000000000..d860d0817c2 --- /dev/null +++ b/modules/dailyhuntBidAdapter.md @@ -0,0 +1,69 @@ +# Overview + +``` +Module Name: Dailyhunt Bid Adapter +Module Type: Bidder Adapter +Maintainer: Dailyhunt +``` + +# Description + +Connects to dailyhunt for bids. + +Dailyhunt bid adapter supports Banner and Native. + +# Test Parameters +``` + var adUnits = [ + { + code: '/83414793/prebid_test_display', + sizes: [[300, 250], [320, 50]], + mediaTypes: { + banner : { + sizes: [[300, 250], [320, 50]], + } + }, + bids: [ + { + bidder: 'dailyhunt', + params: { + partnerId: 'pb-partnerId' + } + } + ] + }, + { + code: '/83414793/prebid_test_native', + sizes: [[300, 250]], + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + image: { + required: true + }, + cta: { + required: true + } + } + }, + bids: [ + { + bidder: 'dailyhunt', + params: { + partnerId: 'pb-partnerId' + } + } + ] + } + ]; +``` + +# CheckList +``` +https://drive.google.com/open?id=1t4rmcyHl5OmRF3sYiqBi-VKEjzX6iN-A +``` diff --git a/modules/danmarketBidAdapter.js b/modules/danmarketBidAdapter.js deleted file mode 100644 index 77f90f43319..00000000000 --- a/modules/danmarketBidAdapter.js +++ /dev/null @@ -1,161 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -const BIDDER_CODE = 'danmarket'; -const ENDPOINT_URL = '//ads.danmarketplace.com/hb'; -const TIME_TO_LIVE = 360; -const ADAPTER_SYNC_URL = '//ads.danmarketplace.com/push_sync'; -const LOG_ERROR_MESS = { - noAuid: 'Bid from response has no auid parameter - ', - noAdm: 'Bid from response has no adm parameter - ', - noBid: 'Array of bid objects is empty', - noPlacementCode: 'Can\'t find in requested bids the bid with auid - ', - emptyUids: 'Uids should be not empty', - emptySeatbid: 'Seatbid array from response has empty item', - emptyResponse: 'Response is empty', - hasEmptySeatbidArray: 'Response has empty seatbid array', - hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' -}; - -/** - * Dentsu Aegis Network Marketplace Bid Adapter. - * Contact: niels@baarsma.net - * - */ -export const spec = { - code: BIDDER_CODE, - - aliases: ['DANMarketplace', 'DAN_Marketplace', 'danmarketplace'], - - isBidRequestValid: function(bid) { - return !!bid.params.uid; - }, - - buildRequests: function(validBidRequests, bidderRequest) { - const auids = []; - const bidsMap = {}; - const bids = validBidRequests || []; - let priceType = 'net'; - let reqId; - - bids.forEach(bid => { - if (bid.params.priceType === 'gross') { - priceType = 'gross'; - } - if (!bidsMap[bid.params.uid]) { - bidsMap[bid.params.uid] = [bid]; - auids.push(bid.params.uid); - } else { - bidsMap[bid.params.uid].push(bid); - } - reqId = bid.bidderRequestId; - }); - - const payload = { - u: utils.getTopWindowUrl(), - pt: priceType, - auids: auids.join(','), - r: reqId, - }; - - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.consentString) { - payload.gdpr_consent = bidderRequest.gdprConsent.consentString; - } - payload.gdpr_applies = - (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') - ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; - } - - return { - method: 'GET', - url: ENDPOINT_URL, - data: payload, - bidsMap: bidsMap, - }; - }, - - interpretResponse: function(serverResponse, bidRequest) { - serverResponse = serverResponse && serverResponse.body - const bidResponses = []; - const bidsMap = bidRequest.bidsMap; - const priceType = bidRequest.data.pt; - - let errorMessage; - - if (!serverResponse) errorMessage = LOG_ERROR_MESS.emptyResponse; - else if (serverResponse.seatbid && !serverResponse.seatbid.length) { - errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray; - } - - if (!errorMessage && serverResponse.seatbid) { - serverResponse.seatbid.forEach(respItem => { - _addBidResponse(_getBidFromResponse(respItem), bidsMap, priceType, bidResponses); - }); - } - if (errorMessage) utils.logError(errorMessage); - return bidResponses; - }, - - getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { - if (syncOptions.pixelEnabled) { - var query = []; - if (gdprConsent) { - if (gdprConsent.consentString) { - query.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString)); - } - query.push('gdpr_applies=' + encodeURIComponent( - (typeof gdprConsent.gdprApplies === 'boolean') - ? Number(gdprConsent.gdprApplies) : 1)); - } - return [{ - type: 'image', - url: ADAPTER_SYNC_URL + (query.length ? '?' + query.join('&') : '') - }]; - } - } -} - -function _getBidFromResponse(respItem) { - if (!respItem) { - utils.logError(LOG_ERROR_MESS.emptySeatbid); - } else if (!respItem.bid) { - utils.logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); - } else if (!respItem.bid[0]) { - utils.logError(LOG_ERROR_MESS.noBid); - } - return respItem && respItem.bid && respItem.bid[0]; -} - -function _addBidResponse(serverBid, bidsMap, priceType, bidResponses) { - if (!serverBid) return; - let errorMessage; - if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); - if (!serverBid.adm) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); - else { - const awaitingBids = bidsMap[serverBid.auid]; - if (awaitingBids) { - awaitingBids.forEach(bid => { - const bidResponse = { - requestId: bid.bidId, // bid.bidderRequestId, - cpm: serverBid.price, - width: serverBid.w, - height: serverBid.h, - creativeId: serverBid.auid, // bid.bidId, - currency: 'USD', - netRevenue: priceType !== 'gross', - ttl: TIME_TO_LIVE, - ad: serverBid.adm, - dealId: serverBid.dealid - }; - bidResponses.push(bidResponse); - }); - } else { - errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; - } - } - if (errorMessage) { - utils.logError(errorMessage); - } -} - -registerBidder(spec); diff --git a/modules/datablocksAnalyticsAdapter.js b/modules/datablocksAnalyticsAdapter.js index 76dd490180b..5e977155284 100644 --- a/modules/datablocksAnalyticsAdapter.js +++ b/modules/datablocksAnalyticsAdapter.js @@ -2,8 +2,8 @@ * Analytics Adapter for Datablocks */ -import adapter from '../src/AnalyticsAdapter'; -import adapterManager from '../src/adapterManager'; +import adapter from '../src/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; var datablocksAdapter = adapter({ global: 'datablocksAnalytics', diff --git a/modules/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js index aa427c6eae1..b00a3eae659 100644 --- a/modules/datablocksBidAdapter.js +++ b/modules/datablocksBidAdapter.js @@ -1,7 +1,6 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE } from '../src/mediaTypes'; -import { parse as parseUrl } from '../src/url'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; const NATIVE_MAP = { 'body': 2, 'body2': 10, @@ -43,12 +42,17 @@ const NATIVE_IMAGE = [{ } }]; +const VIDEO_PARAMS = ['mimes', 'minduration', 'maxduration', 'protocols', 'w', 'h', 'startdelay', + 'placement', 'linearity', 'skip', 'skipmin', 'skipafter', 'sequence', 'battr', 'maxextended', + 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', + 'pos', 'companionad', 'api', 'companiontype', 'ext']; + export const spec = { - supportedMediaTypes: [BANNER, NATIVE], + supportedMediaTypes: [BANNER, NATIVE, VIDEO], code: 'datablocks', isBidRequestValid: function(bid) { return !!(bid.params.host && bid.params.sourceId && - bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native)); + bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native || bid.mediaTypes.video)); }, buildRequests: function(validBidRequests, bidderRequest) { if (!validBidRequests.length) { return []; } @@ -56,7 +60,7 @@ export const spec = { let imps = {}; let site = {}; let device = {}; - let refurl = parseUrl(bidderRequest.referrer); + let refurl = utils.parseUrl(bidderRequest.referrer); let requests = []; validBidRequests.forEach(bidRequest => { @@ -142,6 +146,43 @@ export const spec = { request: JSON.stringify({native: {assets: nativeAssets}}) }; } + } else if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { + let video = bidRequest.mediaTypes.video; + let sizes = video.playerSize || bidRequest.sizes || []; + if (sizes.length && Array.isArray(sizes[0])) { + imp.video = { + w: sizes[0][0], + h: sizes[0][1] + }; + } else if (sizes.length == 2 && !Array.isArray(sizes[0])) { + imp.video = { + w: sizes[0], + h: sizes[1] + }; + } else { + return; + } + + if (video.durationRangeSec) { + if (Array.isArray(video.durationRangeSec)) { + if (video.durationRangeSec.length == 1) { + imp.video.maxduration = video.durationRangeSec[0]; + } else if (video.durationRangeSec.length == 2) { + imp.video.minduration = video.durationRangeSec[0]; + imp.video.maxduration = video.durationRangeSec[1]; + } + } else { + imp.video.maxduration = video.durationRangeSec; + } + } + + if (bidRequest.params.video) { + Object.keys(bidRequest.params.video).forEach(k => { + if (VIDEO_PARAMS.indexOf(k) > -1) { + imp.video[k] = bidRequest.params.video[k]; + } + }) + } } let host = bidRequest.params.host; let sourceId = bidRequest.params.sourceId; @@ -181,7 +222,6 @@ export const spec = { } }) }); - return requests; function RtbRequest(device, site, imps) { @@ -191,7 +231,7 @@ export const spec = { Object.keys(sourceIds).forEach(sourceId => { let impObj = sourceIds[sourceId]; collection.push({ - url: `${impObj.protocol}${host}/${impObj.path}/?${impObj.idParam}=${sourceId}`, + url: `https://${host}/${impObj.path}/?${impObj.idParam}=${sourceId}`, body: { id: bidderRequest.auctionId, imp: impObj.imps, @@ -276,6 +316,11 @@ export const spec = { } }) br.native = result; + } else if (imp.video) { + br.mediaType = VIDEO; + br.width = rtbBid.w; + br.height = rtbBid.h; + if (rtbBid.adm) { br.vastXml = rtbBid.adm; } else if (rtbBid.nurl) { br.vastUrl = rtbBid.nurl; } } return br; }); diff --git a/modules/datablocksBidAdapter.md b/modules/datablocksBidAdapter.md index 7562eee5704..e30cd361974 100644 --- a/modules/datablocksBidAdapter.md +++ b/modules/datablocksBidAdapter.md @@ -9,7 +9,7 @@ Maintainer: support@datablocks.net # Description Connects to Datablocks Version 5 Platform -Banner Native and +Banner Native and Video # Test Parameters @@ -47,6 +47,25 @@ Banner Native and sourceId: 12345, host: 'prebid.datablocks.net' } + }, { + code: 'video-div', + mediaTypes : { + video: { + playerSize:[500,400], + durationRangeSec:[15,30], + context: "linear" + } + }, + bids: [ + { + bidder: 'datablocks', + params: { + sourceId: 12345, + host: 'prebid.datablocks.net', + video: { + mimes:["video/flv"] + } + } } ] } diff --git a/modules/decenteradsBidAdapter.js b/modules/decenteradsBidAdapter.js deleted file mode 100644 index 65d3032d3f8..00000000000 --- a/modules/decenteradsBidAdapter.js +++ /dev/null @@ -1,90 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory' -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes' -import * as utils from '../src/utils' - -const BIDDER_CODE = 'decenterads' -const URL = '//supply.decenterads.com/?c=o&m=multi' -const URL_SYNC = '//supply.decenterads.com/?c=o&m=cookie' - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: function (opts) { - return Boolean(opts.bidId && opts.params && !isNaN(opts.params.placementId)) - }, - - buildRequests: function (validBidRequests) { - validBidRequests = validBidRequests || [] - let winTop = window - try { - window.top.location.toString() - winTop = window.top - } catch (e) { utils.logMessage(e) } - - const location = utils.getTopWindowLocation() - const placements = [] - - for (let i = 0; i < validBidRequests.length; i++) { - const p = validBidRequests[i] - - placements.push({ - placementId: p.params.placementId, - bidId: p.bidId, - traffic: p.params.traffic || BANNER - }) - } - - return { - method: 'POST', - url: URL, - data: { - deviceWidth: winTop.screen.width, - deviceHeight: winTop.screen.height, - language: (navigator && navigator.language) ? navigator.language : '', - secure: +(location.protocol === 'https:'), - host: location.host, - page: location.pathname, - placements: placements - } - } - }, - - interpretResponse: function (opts) { - const body = opts.body - const response = [] - - for (let i = 0; i < body.length; i++) { - const item = body[i] - if (isBidResponseValid(item)) { - delete item.mediaType - response.push(item) - } - } - - return response - }, - - getUserSyncs: function (syncOptions, serverResponses) { - return [{ type: 'image', url: URL_SYNC }] - } -} - -registerBidder(spec) - -function isBidResponseValid (bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false - } - switch (bid['mediaType']) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad) - case VIDEO: - return Boolean(bid.vastUrl) - case NATIVE: - return Boolean(bid.title && bid.image && bid.impressionTrackers) - default: - return false - } -} diff --git a/modules/deepintentBidAdapter.js b/modules/deepintentBidAdapter.js new file mode 100644 index 00000000000..d72477a582a --- /dev/null +++ b/modules/deepintentBidAdapter.js @@ -0,0 +1,176 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; +const BIDDER_CODE = 'deepintent'; +const BIDDER_ENDPOINT = 'https://prebid.deepintent.com/prebid'; +const USER_SYNC_URL = 'https://cdn.deepintent.com/syncpixel.html'; +const DI_M_V = '1.0.0'; +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + aliases: [], + + // tagId is mandatory param + isBidRequestValid: bid => { + let valid = false; + if (bid && bid.params && bid.params.tagId) { + if (typeof bid.params.tagId === 'string' || bid.params.tagId instanceof String) { + valid = true; + } + } + return valid; + }, + interpretResponse: function(bidResponse, request) { + let responses = []; + if (bidResponse && bidResponse.body) { + let bids = bidResponse.body.seatbid && bidResponse.body.seatbid[0] ? bidResponse.body.seatbid[0].bid : []; + responses = bids.map(bid => formatResponse(bid)) + } + return responses; + }, + buildRequests: function (validBidRequests, bidderRequest) { + var user = validBidRequests.map(bid => buildUser(bid)); + clean(user); + const openRtbBidRequest = { + id: utils.generateUUID(), + at: 1, + imp: validBidRequests.map(bid => buildImpression(bid)), + site: buildSite(bidderRequest), + device: buildDevice(), + user: user && user.length === 1 ? user[0] : {} + }; + + if (bidderRequest && bidderRequest.uspConsent) { + utils.deepSetValue(openRtbBidRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + + return { + method: 'POST', + url: BIDDER_ENDPOINT, + data: JSON.stringify(openRtbBidRequest), + options: { + contentType: 'application/json' + } + }; + }, + /** + * Register User Sync. + */ + getUserSyncs: syncOptions => { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: USER_SYNC_URL + }]; + } + } + +}; +function clean(obj) { + for (let propName in obj) { + if (obj[propName] === null || obj[propName] === undefined) { + delete obj[propName]; + } + } +} + +function formatResponse(bid) { + return { + requestId: bid && bid.impid ? bid.impid : undefined, + cpm: bid && bid.price ? bid.price : 0.0, + width: bid && bid.w ? bid.w : 0, + height: bid && bid.h ? bid.h : 0, + ad: bid && bid.adm ? bid.adm : '', + creativeId: bid && bid.crid ? bid.crid : undefined, + netRevenue: false, + currency: bid && bid.cur ? bid.cur : 'USD', + ttl: 300, + dealId: bid && bid.dealId ? bid.dealId : undefined + } +} + +function buildImpression(bid) { + return { + id: bid.bidId, + tagid: bid.params.tagId || '', + secure: window.location.protocol === 'https' ? 1 : 0, + banner: buildBanner(bid), + displaymanager: 'di_prebid', + displaymanagerver: DI_M_V, + ext: buildCustomParams(bid) + }; +} +function buildCustomParams(bid) { + if (bid.params && bid.params.custom) { + return { + deepintent: bid.params.custom + + } + } else { + return {} + } +} +function buildUser(bid) { + if (bid && bid.params && bid.params.user) { + return { + id: bid.params.user.id && typeof bid.params.user.id == 'string' ? bid.params.user.id : undefined, + buyeruid: bid.params.user.buyeruid && typeof bid.params.user.buyeruid == 'string' ? bid.params.user.buyeruid : undefined, + yob: bid.params.user.yob && typeof bid.params.user.yob == 'number' ? bid.params.user.yob : null, + gender: bid.params.user.gender && typeof bid.params.user.gender == 'string' ? bid.params.user.gender : undefined, + keywords: bid.params.user.keywords && typeof bid.params.user.keywords == 'string' ? bid.params.user.keywords : undefined, + customdata: bid.params.user.customdata && typeof bid.params.user.customdata == 'string' ? bid.params.user.customdata : undefined + } + } +} + +function buildBanner(bid) { + if (utils.deepAccess(bid, 'mediaTypes.banner')) { + // Get Sizes from MediaTypes Object, Will always take first size, will be overrided by params for exact w,h + if (utils.deepAccess(bid, 'mediaTypes.banner.sizes') && !bid.params.height && !bid.params.width) { + let sizes = utils.deepAccess(bid, 'mediaTypes.banner.sizes'); + if (utils.isArray(sizes) && sizes.length > 0) { + return { + h: sizes[0][1], + w: sizes[0][0], + pos: bid && bid.params && bid.params.pos ? bid.params.pos : 0 + } + } + } else { + return { + h: bid.params.height, + w: bid.params.width, + pos: bid && bid.params && bid.params.pos ? bid.params.pos : 0 + } + } + } +} + +function buildSite(bidderRequest) { + let site = {}; + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + site.page = bidderRequest.refererInfo.referer; + site.domain = getDomain(bidderRequest.refererInfo.referer); + } + return site; +} + +function getDomain(referer) { + if (referer) { + let domainA = document.createElement('a'); + domainA.href = referer; + return domainA.hostname; + } +} + +function buildDevice() { + return { + ua: navigator.userAgent, + js: 1, + dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack === '1') ? 1 : 0, + h: screen.height, + w: screen.width, + language: navigator.language + } +} + +registerBidder(spec); diff --git a/modules/deepintentBidAdapter.md b/modules/deepintentBidAdapter.md new file mode 100644 index 00000000000..79a6a1679e2 --- /dev/null +++ b/modules/deepintentBidAdapter.md @@ -0,0 +1,54 @@ +# Overview + +``` +Module Name: Deepintent Bidder Adapter +Module Type: Bidder Adapter +Maintainer: prebid@deepintent.com +``` + +# Description + +Deepintent currently supports the BANNER type ads through prebid js + +Module that connects to Deepintent's demand sources. + +# Banner Test Request +``` + var adUnits = [ + { + code: 'di_adUnit1', + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size, only first one will be picked up since multiple ad sizes are not supported yet + } + } + bids: [ + { + bidder: 'deepintent', + params: { + tagId: '1300', // Required parameter + w: 300, // Width and Height here will override sizes in mediatype + h: 250, + pos: 1, + custom: { // Custom parameters in form of key value pairs + user_min_age: 18 + } + } + } + ] + } + ]; +``` + +###Recommended User Sync Configuration + +```javascript +pbjs.setConfig({ + userSync: { + iframeEnabled: true, + enabledBidders: ['deepintent'], + syncDelay: 3000 + }}); + + +``` diff --git a/modules/dfpAdServerVideo.js b/modules/dfpAdServerVideo.js index 6f3c23f1f3d..71a8471d554 100644 --- a/modules/dfpAdServerVideo.js +++ b/modules/dfpAdServerVideo.js @@ -2,13 +2,12 @@ * This module adds [DFP support]{@link https://www.doubleclickbygoogle.com/} for Video to Prebid. */ -import { registerVideoSupport } from '../src/adServerManager'; -import { targeting } from '../src/targeting'; -import { formatQS, format as buildUrl, parse } from '../src/url'; -import { deepAccess, isEmpty, logError, parseSizesInput } from '../src/utils'; -import { config } from '../src/config'; -import { getHook, submodule } from '../src/hook'; -import { auctionManager } from '../src/auctionManager'; +import { registerVideoSupport } from '../src/adServerManager.js'; +import { targeting } from '../src/targeting.js'; +import { deepAccess, isEmpty, logError, parseSizesInput, formatQS, parseUrl, buildUrl } from '../src/utils.js'; +import { config } from '../src/config.js'; +import { getHook, submodule } from '../src/hook.js'; +import { auctionManager } from '../src/auctionManager.js'; /** * @typedef {Object} DfpVideoParams @@ -74,7 +73,7 @@ export function buildDfpVideoUrl(options) { if (options.url) { // when both `url` and `params` are given, parsed url will be overwriten // with any matching param components - urlComponents = parse(options.url, {noDecodeWholeURL: true}); + urlComponents = parseUrl(options.url, {noDecodeWholeURL: true}); if (isEmpty(options.params)) { return buildUrlFromAdserverUrlComponents(urlComponents, bid, options); @@ -101,7 +100,7 @@ export function buildDfpVideoUrl(options) { return buildUrl({ protocol: 'https', - host: 'pubads.g.doubleclick.net', + host: 'securepubads.g.doubleclick.net', pathname: '/gampad/ads', search: queryParams }); @@ -184,7 +183,7 @@ export function buildAdpodVideoUrl({code, params, callback} = {}) { const masterTag = buildUrl({ protocol: 'https', - host: 'pubads.g.doubleclick.net', + host: 'securepubads.g.doubleclick.net', pathname: '/gampad/ads', search: queryParams }); diff --git a/modules/dgadsBidAdapter.js b/modules/dgadsBidAdapter.js deleted file mode 100644 index c8a97d86990..00000000000 --- a/modules/dgadsBidAdapter.js +++ /dev/null @@ -1,103 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; -import { BANNER, NATIVE } from '../src/mediaTypes'; - -const BIDDER_CODE = 'dgads'; -const UID_NAME = 'dgads_uid'; -const ENDPOINT = 'https://ads-tr.bigmining.com/ad/p/bid'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [ BANNER, NATIVE ], - isBidRequestValid: function(bid) { - const params = bid.params; - if (!/^\d+$/.test(params.location_id)) { - return false; - } - if (!/^\d+$/.test(params.site_id)) { - return false; - } - return true; - }, - buildRequests: function(bidRequests) { - if (bidRequests.length === 0) { - return {}; - } - - return bidRequests.map(bidRequest => { - const params = bidRequest.params; - const data = {}; - - data['_loc'] = params.location_id; - data['_medium'] = params.site_id; - data['transaction_id'] = bidRequest.transactionId; - data['bid_id'] = bidRequest.bidId; - data['referer'] = utils.getTopWindowUrl(); - data['_uid'] = getCookieUid(UID_NAME); - - return { - method: 'GET', - url: ENDPOINT, - data, - }; - }); - }, - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - const responseObj = serverResponse.body; - const ads = responseObj.bids; - let bidResponse = {}; - if (utils.isEmpty(ads)) { - return []; - } - utils._each(ads, function(ad) { - bidResponse.requestId = ad.bidId; - bidResponse.bidderCode = BIDDER_CODE; - bidResponse.cpm = ad.cpm; - bidResponse.creativeId = ad.creativeId; - bidResponse.currency = 'JPY'; - bidResponse.netRevenue = true; - bidResponse.ttl = ad.ttl; - bidResponse.referrer = utils.getTopWindowUrl(); - if (ad.isNative == 1) { - bidResponse.mediaType = NATIVE; - bidResponse.native = setNativeResponse(ad); - } else { - bidResponse.width = parseInt(ad.w); - bidResponse.height = parseInt(ad.h); - bidResponse.ad = ad.ad; - } - bidResponses.push(bidResponse); - }); - return bidResponses; - } -}; -function setNativeResponse(ad) { - let nativeResponce = {}; - nativeResponce.image = { - url: ad.image, - width: parseInt(ad.w), - height: parseInt(ad.h) - } - nativeResponce.title = ad.title; - nativeResponce.body = ad.desc; - nativeResponce.sponsoredBy = ad.sponsoredBy; - nativeResponce.clickUrl = ad.clickUrl; - nativeResponce.clickTrackers = ad.clickTrackers || []; - nativeResponce.impressionTrackers = ad.impressionTrackers || []; - return nativeResponce; -} -export function getCookieUid(uidName) { - if (utils.cookiesAreEnabled()) { - let cookies = document.cookie.split(';'); - for (let i = 0; i < cookies.length; i++) { - let value = cookies[i].split('='); - if (value[0].indexOf(uidName) > -1) { - return value[1]; - } - } - } - return ''; -} - -registerBidder(spec); diff --git a/modules/digiTrustIdSystem.js b/modules/digiTrustIdSystem.js index 17f6fd9f737..0b964c43d57 100644 --- a/modules/digiTrustIdSystem.js +++ b/modules/digiTrustIdSystem.js @@ -9,9 +9,13 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils' -import { ajax } from '../src/ajax'; -import { submodule } from '../src/hook'; +import * as utils from '../src/utils.js' +import { ajax } from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const DT_VENDOR_ID = 64; // cmp gvlVendorId +const storage = getStorageManager(DT_VENDOR_ID); var fallbackTimeout = 1550; // timeout value that allows userId system to execute first var fallbackTimer = 0; // timer Id for fallback init so we don't double call @@ -24,6 +28,7 @@ function isInitialized() { if (window.DigiTrust == null) { return false; } + // eslint-disable-next-line no-undef return DigiTrust.isClient; // this is set to true after init } @@ -44,7 +49,14 @@ var isFunc = function (fn) { return typeof (fn) === 'function'; } +var _savedId = null; // closure variable for storing Id to avoid additional requests + function callApi(options) { + var ajaxOptions = { + method: 'GET', + withCredentials: true + }; + ajax( DT_ID_SVC, { @@ -52,9 +64,7 @@ function callApi(options) { error: options.fail }, null, - { - method: 'GET' - } + ajaxOptions ); } @@ -67,7 +77,7 @@ function encId(id) { if (typeof (id) !== 'string') { id = JSON.stringify(id); } - return encodeURIComponent(btoa(id)); + return btoa(id); } catch (ex) { return id; } @@ -81,8 +91,7 @@ function writeDigiId(id) { var key = 'DigiTrust.v1.identity'; var date = new Date(); date.setTime(date.getTime() + 604800000); - var exp = 'expires=' + date.toUTCString(); - document.cookie = key + '=' + encId(id) + '; ' + exp + '; path=/;SameSite=none;'; + storage.setCookie(key, encId(id), date.toUTCString(), 'none'); } /** @@ -90,8 +99,6 @@ function writeDigiId(id) { * */ function initDigitrustFacade(config) { - var _savedId = null; // closure variable for storing Id to avoid additional requests - clearTimeout(fallbackTimer); fallbackTimer = 0; @@ -110,17 +117,17 @@ function initDigitrustFacade(config) { inter.callCount++; // wrap the initializer callback, if present - var checkCallInitializeCb = function (idResponse) { + var checkAndCallInitializeCb = function (idResponse) { if (inter.callCount <= 1 && isFunc(inter.initCallback)) { try { inter.initCallback(idResponse); } catch (ex) { - utils.logError('Exception in passed DigiTrust init callback'); + utils.logError('Exception in passed DigiTrust init callback', ex); } } } - if (!isMemberIdValid) { + if (!isMemberIdValid(obj.member)) { if (!isAsync) { return errResp } else { @@ -130,9 +137,9 @@ function initDigitrustFacade(config) { } if (_savedId != null) { - checkCallInitializeCb(_savedId); if (isAsync) { - cb(_savedId); + checkAndCallInitializeCb(_savedId); + // cb(_savedId); return; } else { return _savedId; @@ -145,21 +152,26 @@ function initDigitrustFacade(config) { success: true } try { - writeDigiId(respText); idResult.identity = JSON.parse(respText); - _savedId = idResult; + _savedId = idResult; // Save result to the cache variable + writeDigiId(respText); } catch (ex) { idResult.success = false; + delete idResult.identity; } - checkCallInitializeCb(idResult); - cb(idResult); + checkAndCallInitializeCb(idResult); }, fail: function (statusErr, result) { utils.logError('DigiTrustId API error: ' + statusErr); } } - callApi(opts); + // check gdpr vendor here. Full DigiTrust library has vendor check built in + gdprConsent.hasConsent(null, function (hasConsent) { + if (hasConsent) { + callApi(opts); + } + }) if (!isAsync) { return errResp; // even if it will be successful later, without a callback we report a "failure in this moment" @@ -189,6 +201,46 @@ var isMemberIdValid = function (memberId) { } }; +/** + * DigiTrust consent handler for GDPR and __cmp. + * */ +var gdprConsent = { + hasConsent: function (options, consentCb) { + options = options || { consentTimeout: 1500 }; + var stopTimer; + var processed = false; + var consentAnswer = false; + if (typeof (window.__cmp) !== 'undefined') { + stopTimer = setTimeout(function () { + consentAnswer = false; + processed = true; + consentCb(consentAnswer); + }, options.consentTimeout); + + window.__cmp('ping', null, function(pingAnswer) { + if (pingAnswer.gdprAppliesGlobally) { + window.__cmp('getVendorConsents', [DT_VENDOR_ID], function (result) { + if (processed) { return; } // timeout before cmp answer, cancel + clearTimeout(stopTimer); + var myconsent = result.vendorConsents[DT_VENDOR_ID]; + consentCb(myconsent); + }); + } else { + if (processed) { return; } // timeout before cmp answer, cancel + clearTimeout(stopTimer); + consentAnswer = true; + consentCb(consentAnswer); + } + }); + } else { + // __cmp library is not preset. + // ignore this check and rely on id system GDPR consent management + consentAnswer = true; + consentCb(consentAnswer); + } + } +} + /** * Encapsulation of needed info for the callback return. * @@ -207,6 +259,10 @@ var ResultWrapper = function (opts) { */ this.userIdCallback = function (callback) { idSystemFn = callback; + if (me.idObj == null) { + me.idObj = _savedId; + } + if (me.idObj != null && isFunc(callback)) { callback(wrapIdResult()); } @@ -216,6 +272,10 @@ var ResultWrapper = function (opts) { * Return a wrapped result formatted for userId system */ function wrapIdResult() { + if (me.idObj == null) { + me.idObj = _savedId; + } + if (me.idObj == null) { return null; } @@ -240,6 +300,7 @@ var ResultWrapper = function (opts) { this.retryId = 0; this.executeIdRequest = function (configParams) { + // eslint-disable-next-line no-undef DigiTrust.getUser({ member: 'prebid' }, function (idResult) { me.idObj = idResult; var cb = function () { @@ -321,6 +382,7 @@ export function surfaceTestHook() { } testHook.initDigitrustFacade = initDigitrustFacade; // expose for unit tests +testHook.gdpr = gdprConsent; /** @type {Submodule} */ export const digiTrustIdSubmodule = { @@ -342,7 +404,9 @@ export const digiTrustIdSubmodule = { utils.logError('DigiTrust ID submodule decode error'); } }, - getId: getDigiTrustId, + getId: function (configParams) { + return {callback: getDigiTrustId(configParams)}; + }, _testInit: surfaceTestHook }; diff --git a/modules/districtmDMXBidAdapter.js b/modules/districtmDMXBidAdapter.js index 12b7ac16c0c..0dbaf2b2336 100644 --- a/modules/districtmDMXBidAdapter.js +++ b/modules/districtmDMXBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import {config} from '../src/config'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; const BIDDER_CODE = 'districtmDMX'; @@ -22,17 +22,19 @@ export const spec = { if (oBid.price < nBid.price) { const bid = matchRequest(nBid.impid, bidRequest); const {width, height} = defaultSize(bid); - nBid.cpm = nBid.price; + nBid.cpm = parseFloat(nBid.price).toFixed(2); nBid.bidId = nBid.impid; nBid.requestId = nBid.impid; nBid.width = nBid.w || width; nBid.height = nBid.h || height; + if (nBid.dealid) { + nBid.dealId = nBid.dealid; + } nBid.ad = nBid.adm; nBid.netRevenue = true; nBid.creativeId = nBid.crid; nBid.currency = 'USD'; nBid.ttl = 60; - return nBid; } else { oBid.cpm = oBid.price; @@ -60,6 +62,7 @@ export const spec = { }, buildRequests(bidRequest, bidderRequest) { let timeout = config.getConfig('bidderTimeout'); + let schain = null; let dmxRequest = { id: utils.generateUUID(), cur: ['USD'], @@ -69,6 +72,23 @@ export const spec = { publisher: { id: String(bidRequest[0].params.memberid) || null } } } + + try { + let params = config.getConfig('dmx'); + dmxRequest.user = params.user || {}; + let site = params.site || {}; + dmxRequest.site = {...dmxRequest.site, ...site} + } catch (e) { + + } + + let eids = []; + if (bidRequest && bidRequest.userId) { + bindUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'liveramp.com', 1); + dmxRequest.user = dmxRequest.user || {}; + dmxRequest.user.ext = dmxRequest.user.ext || {}; + dmxRequest.user.ext.eids = eids; + } if (!dmxRequest.test) { delete dmxRequest.test; } @@ -80,46 +100,166 @@ export const spec = { dmxRequest.user.ext = {}; dmxRequest.user.ext.consent = bidderRequest.gdprConsent.consentString; } + dmxRequest.regs = dmxRequest.regs || {}; + dmxRequest.regs.coppa = config.getConfig('coppa') === true ? 1 : 0; + if (bidderRequest && bidderRequest.uspConsent) { + dmxRequest.regs = dmxRequest.regs || {}; + dmxRequest.regs.ext = dmxRequest.regs.ext || {}; + dmxRequest.regs.ext.us_privacy = bidderRequest.uspConsent; + } + try { + schain = bidRequest[0].schain; + dmxRequest.source = {}; + dmxRequest.source.ext = {}; + dmxRequest.source.ext.schain = schain || {} + } catch (e) {} let tosendtags = bidRequest.map(dmx => { var obj = {}; obj.id = dmx.bidId; obj.tagid = String(dmx.params.dmxid); - obj.secure = window.location.protocol === 'https:' ? 1 : 0; + obj.secure = 1; obj.banner = { topframe: 1, - w: dmx.sizes[0][0] || 0, - h: dmx.sizes[0][1] || 0, - format: dmx.sizes.map(s => { + w: cleanSizes(dmx.sizes, 'w'), + h: cleanSizes(dmx.sizes, 'h'), + format: cleanSizes(dmx.sizes).map(s => { return {w: s[0], h: s[1]}; }).filter(obj => typeof obj.w === 'number' && typeof obj.h === 'number') }; return obj; }); - dmxRequest.imp = tosendtags; - return { - method: 'POST', - url: DMXURI, - data: JSON.stringify(dmxRequest), - options: { - contentType: 'application/json', - withCredentials: true - }, - bidderRequest + + if (tosendtags.length <= 5) { + dmxRequest.imp = tosendtags; + return { + method: 'POST', + url: DMXURI, + data: JSON.stringify(dmxRequest), + bidderRequest + } + } else { + return upto5(tosendtags, dmxRequest, bidderRequest, DMXURI); } }, test() { return window.location.href.indexOf('dmTest=true') !== -1 ? 1 : 0; }, - getUserSyncs(optionsType) { + getUserSyncs(optionsType, serverResponses, gdprConsent, uspConsent) { + let query = []; + let url = 'https://cdn.districtm.io/ids/index.html' + if (gdprConsent && gdprConsent.gdprApplies && typeof gdprConsent.consentString === 'string') { + query.push(['gdpr', gdprConsent.consentString]) + } + if (uspConsent) { + query.push(['ccpa', uspConsent]) + } + if (query.length > 0) { + url += '?' + query.map(q => q.join('=')).join('&') + } if (optionsType.iframeEnabled) { return [{ type: 'iframe', - url: 'https://cdn.districtm.io/ids/index.html' + url: url }]; } } } +export function cleanSizes(sizes, value) { + const supportedSize = [ + { + size: [300, 250], + s: 100 + }, + { + size: [728, 90], + s: 95 + }, + { + size: [320, 50], + s: 90 + }, + { + size: [160, 600], + s: 88 + }, + { + size: [300, 600], + s: 85 + }, + { + size: [300, 50], + s: 80 + }, + { + size: [970, 250], + s: 75 + }, + { + size: [970, 90], + s: 60 + }, + ]; + let newArray = shuffle(sizes, supportedSize); + switch (value) { + case 'w': + return newArray[0][0] || 0; + case 'h': + return newArray[0][1] || 0; + case 'size': + return newArray; + default: + return newArray; + } +} + +export function shuffle(sizes, list) { + let removeSizes = sizes.filter(size => { + return list.map(l => `${l.size[0]}x${l.size[1]}`).indexOf(`${size[0]}x${size[1]}`) === -1 + }) + let reOrder = sizes.reduce((results, current) => { + if (results.length === 0) { + results.push(current); + return results; + } + results.push(current); + results = list.filter(l => results.map(r => `${r[0]}x${r[1]}`).indexOf(`${l.size[0]}x${l.size[1]}`) !== -1); + results = results.sort(function(a, b) { + return b.s - a.s; + }) + return results.map(r => r.size); + }, []) + return removeDuplicate([...reOrder, ...removeSizes]); +} + +export function removeDuplicate(arrayValue) { + return arrayValue.filter((elem, index) => { + return arrayValue.map(e => `${e[0]}x${e[1]}`).indexOf(`${elem[0]}x${elem[1]}`) === index + }) +} + +export function upto5(allimps, dmxRequest, bidderRequest, DMXURI) { + let start = 0; + let step = 5; + let req = []; + while (allimps.length !== 0) { + if (allimps.length >= 5) { + req.push(allimps.splice(start, step)) + } else { + req.push(allimps.splice(start, allimps.length)) + } + } + return req.map(r => { + dmxRequest.imp = r; + return { + method: 'POST', + url: DMXURI, + data: JSON.stringify(dmxRequest), + bidderRequest + } + }) +} + /** * Function matchRequest(id: string, BidRequest: object) * @param id @@ -152,4 +292,18 @@ export function defaultSize(thebidObj) { returnObject.height = checkDeepArray(sizes)[1]; return returnObject; } + +export function bindUserId(eids, value, source, atype) { + if (utils.isStr(value) && Array.isArray(eids)) { + eids.push({ + source, + uids: [ + { + id: value, + atype + } + ] + }) + } +} registerBidder(spec); diff --git a/modules/districtmDmxBidAdapter.md b/modules/districtmDmxBidAdapter.md index 2859bcfa19d..792cf2e7305 100644 --- a/modules/districtmDmxBidAdapter.md +++ b/modules/districtmDmxBidAdapter.md @@ -13,6 +13,8 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman * Single Request * Multi-Size Support * GDPR Compliant +* CCPA Compliant +* COPPA Compliant * Bids returned in **NET** ## Media Types @@ -23,8 +25,8 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman | Key | Scope | Type | Description | --- | --- | --- | --- -| dmxid | Mandatory | Integer | Unique identifier of the placement, dmxid can be obtained in the district m Boost platform. -| memberid | Mandatory | Integer | Unique identifier for your account, memberid can be obtained in the district m Boost platform. +| `dmxid` | Mandatory | Integer | Unique identifier of the placement, dmxid can be obtained in the district m Boost platform. +| `memberid` | Mandatory | Integer | Unique identifier for your account, memberid can be obtained in the district m Boost platform. # Ad Unit Configuration Example @@ -47,6 +49,9 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman ``` +# Ad Unit Configuration when COPPA is needed + + # Quick Start Guide ###### 1. Including the `districtmDmxAdapter` in your build process. @@ -115,3 +120,25 @@ Our demand and adapter supports multiple sizes per placement, as such a single d ###### 4. Implementation Checking Once the bidder is live in your Prebid configuration you may confirm it is making requests to our end point by looking for requests to `https://dmx.districtm.io/b/v1`. + + +###### 5. Setting first party data + +```code +pbjs.setConfig({ + dmx: { + user: { + 'gender': 'M', + 'yob': 1992, + // keywords example + 'keywords': 'automotive,dodge,engine,car' + + }, + site: { + cat: ['IAB-12'], + pagecat: ['IAB-14'], + sectioncat: ['IAB-24'] + } + } +}); +``` diff --git a/modules/djaxBidAdapter.js b/modules/djaxBidAdapter.js new file mode 100644 index 00000000000..ffaf61a3f15 --- /dev/null +++ b/modules/djaxBidAdapter.js @@ -0,0 +1,129 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import * as utils from '../src/utils.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import { ajax } from '../src/ajax.js'; +import {Renderer} from '../src/Renderer.js'; + +const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; +const BIDDER_CODE = 'djax'; +const DOMAIN = 'https://demo.reviveadservermod.com/headerbidding_adminshare/'; +const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; + +function isBidRequestValid(bid) { + return (typeof bid.params !== 'undefined' && parseInt(utils.getValue(bid.params, 'publisherId')) > 0); +} + +function buildRequests(validBidRequests) { + return { + method: 'POST', + url: DOMAIN + 'www/admin/plugins/Prebid/getAd.php', + options: { + withCredentials: false, + crossOrigin: true + }, + data: validBidRequests, + }; +} + +function interpretResponse(serverResponse, request) { + const response = serverResponse.body; + const bidResponses = []; + var bidRequestResponses = []; + + utils._each(response, function(bidAd) { + bidAd.adResponse = { + content: bidAd.vastXml, + height: bidAd.height, + width: bidAd.width + }; + bidAd.ttl = config.getConfig('_bidderTimeout') + bidAd.renderer = bidAd.context === 'outstream' ? createRenderer(bidAd, { + id: bidAd.adUnitCode, + url: RENDERER_URL + }, bidAd.adUnitCode) : undefined; + bidResponses.push(bidAd); + }); + + bidRequestResponses.push({ + function: 'saveResponses', + request: request, + response: bidResponses + }); + sendResponseToServer(bidRequestResponses); + return bidResponses; +} + +function outstreamRender(bidAd) { + bidAd.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + sizes: [bidAd.width, bidAd.height], + width: bidAd.width, + height: bidAd.height, + targetId: bidAd.adUnitCode, + adResponse: bidAd.adResponse, + rendererOptions: { + showVolume: false, + allowFullscreen: false + } + }); + }); +} + +function createRenderer(bidAd, rendererParams, adUnitCode) { + const renderer = Renderer.install({ + id: rendererParams.id, + url: rendererParams.url, + loaded: false, + config: {'player_height': bidAd.height, 'player_width': bidAd.width}, + adUnitCode + }); + try { + renderer.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + return renderer; +} + +function onBidWon(bid) { + let wonBids = []; + wonBids.push(bid); + wonBids[0].function = 'onBidWon'; + sendResponseToServer(wonBids); +} + +function onTimeout(details) { + details.unshift({ 'function': 'onTimeout' }); + sendResponseToServer(details); +} + +function sendResponseToServer(data) { + ajax(DOMAIN + 'www/admin/plugins/Prebid/tracking/track.php', null, JSON.stringify(data), { + withCredentials: false, + method: 'POST', + crossOrigin: true + }); +} + +function getUserSyncs(syncOptions) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: DOMAIN + 'www/admin/plugins/Prebid/userSync.php' + }]; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: SUPPORTED_AD_TYPES, + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs, + onBidWon, + onTimeout +}; + +registerBidder(spec); diff --git a/modules/djaxBidAdapter.md b/modules/djaxBidAdapter.md new file mode 100644 index 00000000000..d597eb59b58 --- /dev/null +++ b/modules/djaxBidAdapter.md @@ -0,0 +1,50 @@ +# Overview + +``` +Module Name: djax Bid Adapter +Module Type: Bidder Adapter +Maintainer : support@djaxtech.com +``` + +# Description + +Connects to Djax Ad Server for bids. + +djax bid adapter supports Banner and Video. + +# Test Parameters +``` + var adUnits = [ + //bannner object + { + code: 'banner-ad-slot', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]], + } + }, + bids: [{ + bidder: 'djax', + params: { + publisherId: 2 + } + }] + + }, + //video object + { + code: 'video-ad-slot', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + }, + }, + bids: [{ + bidder: "djax", + params: { + publisherId: 2 + } + }] + }]; +``` \ No newline at end of file diff --git a/modules/dspxBidAdapter.js b/modules/dspxBidAdapter.js index 8b763202b7c..16764e76ede 100644 --- a/modules/dspxBidAdapter.js +++ b/modules/dspxBidAdapter.js @@ -1,9 +1,10 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'dspx'; const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; +const ENDPOINT_URL_DEV = 'https://dcbuyer.dspx.tv/request/'; export const spec = { code: BIDDER_CODE, @@ -14,14 +15,17 @@ export const spec = { buildRequests: function(validBidRequests, bidderRequest) { return validBidRequests.map(bidRequest => { const params = bidRequest.params; - const sizes = utils.parseSizesInput(bidRequest.sizes)[0]; - const width = sizes.split('x')[0]; - const height = sizes.split('x')[1]; const placementId = params.placement; - const rnd = Math.floor(Math.random() * 99999999999); const referrer = encodeURIComponent(bidderRequest.refererInfo.referer); const bidId = bidRequest.bidId; + const isDev = params.devMode || false; + + let bannerSizes = utils.parseSizesInput(utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes') || bidRequest.sizes); + let [width, height] = bannerSizes[0].split('x'); + + let endpoint = isDev ? ENDPOINT_URL_DEV : ENDPOINT_URL; + const payload = { _f: 'html', alternative: 'prebid_js', @@ -42,9 +46,12 @@ export const spec = { if (params.dvt !== undefined) { payload.dvt = params.dvt; } + if (isDev) { + payload.prebidDevMode = 1; + } return { method: 'GET', - url: ENDPOINT_URL, + url: endpoint, data: objectToQueryString(payload), } }); @@ -58,7 +65,6 @@ export const spec = { const dealId = response.dealid || ''; const currency = response.currency || 'EUR'; const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue; - const referrer = utils.getTopWindowUrl(); const bidResponse = { requestId: response.bid_id, cpm: cpm, @@ -68,8 +74,8 @@ export const spec = { dealId: dealId, currency: currency, netRevenue: netRevenue, + type: response.type, ttl: config.getConfig('_bidderTimeout'), - referrer: referrer, ad: response.adTag }; bidResponses.push(bidResponse); diff --git a/modules/dspxBidAdapter.md b/modules/dspxBidAdapter.md index 362f4fbcb69..9945dc5e6dd 100644 --- a/modules/dspxBidAdapter.md +++ b/modules/dspxBidAdapter.md @@ -8,7 +8,7 @@ Maintainer: prebid@dspx.tv # Description -Dspx adapter for Prebid.js 1.0 +Dspx adapter for Prebid.js 3.0 # Test Parameters ``` @@ -28,6 +28,7 @@ Dspx adapter for Prebid.js 1.0 bidder: "dspx", params: { placement: '101', + devMode: true, // if true: library uses dev server for tests pfilter: { floorprice: 1000000, // EUR * 1,000,000 private_auction: 1, // Is private auction? 0 - no, 1 - yes diff --git a/modules/e_volutionBidAdapter.js b/modules/e_volutionBidAdapter.js new file mode 100644 index 00000000000..9fc7035db32 --- /dev/null +++ b/modules/e_volutionBidAdapter.js @@ -0,0 +1,111 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; + +const BIDDER_CODE = 'e_volution'; +const AD_URL = 'https://service.e-volution.ai/?c=o&m=multi'; +const URL_SYNC = 'https://service.e-volution.ai/?c=o&m=sync'; +const NO_SYNC = true; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || + !bid.ttl || !bid.currency) { + return false; + } + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl); + case NATIVE: + return Boolean(bid.native && bid.native.title && bid.native.image && bid.native.impressionTrackers); + default: + return false; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + noSync: NO_SYNC, + + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); + }, + + buildRequests: (validBidRequests = [], bidderRequest) => { + let winTop = window; + let location; + try { + location = new URL(bidderRequest.refererInfo.referer) + winTop = window.top; + } catch (e) { + location = winTop.location; + utils.logMessage(e); + }; + let placements = []; + let request = { + 'deviceWidth': winTop.screen.width, + 'deviceHeight': winTop.screen.height, + 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', + 'secure': 1, + 'host': location.host, + 'page': location.pathname, + 'placements': placements + }; + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent) { + request.gdpr = bidderRequest.gdprConsent + } + } + const len = validBidRequests.length; + + for (let i = 0; i < len; i++) { + let bid = validBidRequests[i]; + let traff = bid.params.traffic || BANNER + + placements.push({ + placementId: bid.params.placementId, + bidId: bid.bidId, + sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], + traffic: traff + }); + if (bid.schain) { + placements.schain = bid.schain; + } + } + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses) => { + if (NO_SYNC) { + return false + } else { + return [{ + type: 'image', + url: URL_SYNC + }]; + } + } + +}; + +registerBidder(spec); diff --git a/modules/e_volutionBidAdapter.md b/modules/e_volutionBidAdapter.md new file mode 100644 index 00000000000..ff5b2860e05 --- /dev/null +++ b/modules/e_volutionBidAdapter.md @@ -0,0 +1,53 @@ +# Overview + +``` +Module Name: e_volution Bidder Adapter +Module Type: Bidder Adapter +``` + +# Description + +Module that connects to e-volution-tech demand sources + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'placementId_0', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'e_volution', + params: { + placementId: 0, + traffic: 'banner' + } + } + ] + }, + // Will return test vast xml. All video params are stored under placement in publishers UI + { + code: 'placementId_0', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [ + { + bidder: 'e_volution', + params: { + placementId: 0, + traffic: 'video' + } + } + ] + } + ]; +``` diff --git a/modules/ebdrBidAdapter.js b/modules/ebdrBidAdapter.js index 79bf4bb1004..c30c10d8a90 100644 --- a/modules/ebdrBidAdapter.js +++ b/modules/ebdrBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import { VIDEO, BANNER } from '../src/mediaTypes'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { VIDEO, BANNER } from '../src/mediaTypes.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'ebdr'; export const spec = { code: BIDDER_CODE, @@ -57,7 +57,7 @@ export const spec = { }; return { method: 'GET', - url: '//' + rtbServerDomain + '/hb?' + '&zoneid=' + zoneid + '&br=' + encodeURIComponent(JSON.stringify(ebdrBidReq)), + url: 'https://' + rtbServerDomain + '/hb?' + '&zoneid=' + zoneid + '&br=' + encodeURIComponent(JSON.stringify(ebdrBidReq)), bids: ebdrReq }; }, diff --git a/modules/emoteevBidAdapter.js b/modules/emoteevBidAdapter.js index db84b6ea36d..e0f88725d8a 100644 --- a/modules/emoteevBidAdapter.js +++ b/modules/emoteevBidAdapter.js @@ -14,8 +14,8 @@ * @author Emoteev Engineering . */ -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER} from '../src/mediaTypes'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; import { triggerPixel, getUniqueIdentifierStr, @@ -24,10 +24,12 @@ import { isArray, isInteger, getParameterByName, - getCookie -} from '../src/utils'; -import {config} from '../src/config'; -import * as url from '../src/url'; + buildUrl +} from '../src/utils.js'; +import {config} from '../src/config.js'; +import { getStorageManager } from '../src/storageManager.js'; + +export const storage = getStorageManager(); export const BIDDER_CODE = 'emoteev'; @@ -36,8 +38,8 @@ export const BIDDER_CODE = 'emoteev'; */ export const ADAPTER_VERSION = '1.35.0'; -export const DOMAIN = 'prebid.emoteev.io'; -export const DOMAIN_STAGING = 'prebid-staging.emoteev.io'; +export const DOMAIN = 'prebid.emoteev.xyz'; +export const DOMAIN_STAGING = 'prebid-staging.emoteev.xyz'; export const DOMAIN_DEVELOPMENT = 'localhost:3000'; /** @@ -232,7 +234,7 @@ export const domain = (env) => { * @param {string} env Emoteev environment parameter * @returns {string} The full URL which events is sent to. */ -export const eventsUrl = env => url.format({ +export const eventsUrl = env => buildUrl({ protocol: (env === DEVELOPMENT) ? 'http' : 'https', hostname: domain(env), pathname: EVENTS_PATH @@ -244,7 +246,7 @@ export const eventsUrl = env => url.format({ * @param {string} env Emoteev environment parameter * @returns {string} The full URL which bidderRequest is sent to. */ -export const bidderUrl = env => url.format({ +export const bidderUrl = env => buildUrl({ protocol: (env === DEVELOPMENT) ? 'http' : 'https', hostname: domain(env), pathname: BIDDER_PATH @@ -256,7 +258,7 @@ export const bidderUrl = env => url.format({ * @param {string} env Emoteev environment parameter * @returns {string} The full URL called for iframe-based user sync */ -export const userSyncIframeUrl = env => url.format({ +export const userSyncIframeUrl = env => buildUrl({ protocol: (env === DEVELOPMENT) ? 'http' : 'https', hostname: domain(env), pathname: USER_SYNC_IFRAME_PATH @@ -268,7 +270,7 @@ export const userSyncIframeUrl = env => url.format({ * @param {string} env Emoteev environment parameter * @returns {string} The full URL called for image-based user sync */ -export const userSyncImageUrl = env => url.format({ +export const userSyncImageUrl = env => buildUrl({ protocol: (env === DEVELOPMENT) ? 'http' : 'https', hostname: domain(env), pathname: USER_SYNC_IMAGE_PATH @@ -506,12 +508,12 @@ export const spec = { bidderRequest), interpretResponse: interpretResponse, onBidWon: (bidObject) => - triggerPixel(url.format(onBidWon( + triggerPixel(buildUrl(onBidWon( resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), - getCookie('_pubcid'), + storage.getCookie('_pubcid'), bidObject))), onTimeout: (bidRequest) => - triggerPixel(url.format(onTimeout( + triggerPixel(buildUrl(onTimeout( resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), bidRequest))), getUserSyncs: (syncOptions) => diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index 2ca595151f9..83689aa76f1 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -1,13 +1,13 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import { Renderer } from '../src/Renderer'; -import includes from 'core-js/library/fn/array/includes'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { Renderer } from '../src/Renderer.js'; +import includes from 'core-js/library/fn/array/includes.js'; const BIDDER_CODE = 'emx_digital'; const ENDPOINT = 'hb.emxdgt.com'; -const RENDERER_URL = '//js.brealtime.com/outstream/1.30.0/bundle.js'; -const ADAPTER_VERSION = '1.40.2'; +const RENDERER_URL = 'https://js.brealtime.com/outstream/1.30.0/bundle.js'; +const ADAPTER_VERSION = '1.5.0'; const DEFAULT_CUR = 'USD'; export const emxAdapter = { @@ -39,11 +39,11 @@ export const emxAdapter = { h: sizes[0][1] }; }, - formatVideoResponse: (bidResponse, emxBid) => { + formatVideoResponse: (bidResponse, emxBid, bidRequest) => { bidResponse.vastXml = emxBid.adm; - if (!emxBid.renderer && (!emxBid.mediaTypes || !emxBid.mediaTypes.video || !emxBid.mediaTypes.video.context || emxBid.mediaTypes.video.context === 'outstream')) { + if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') { bidResponse.renderer = emxAdapter.createRenderer(bidResponse, { - id: emxBid.bidId, + id: emxBid.id, url: RENDERER_URL }); } @@ -103,12 +103,20 @@ export const emxAdapter = { return renderer; }, buildVideo: (bid) => { - let videoObj = Object.assign(bid.mediaTypes.video, bid.params.video) + let videoObj = Object.assign(bid.mediaTypes.video, bid.params.video); + + if (utils.isArray(bid.mediaTypes.video.playerSize[0])) { + videoObj['w'] = bid.mediaTypes.video.playerSize[0][0]; + videoObj['h'] = bid.mediaTypes.video.playerSize[0][1]; + } else { + videoObj['w'] = bid.mediaTypes.video.playerSize[0]; + videoObj['h'] = bid.mediaTypes.video.playerSize[1]; + } return emxAdapter.cleanProtocols(videoObj); }, parseResponse: (bidResponseAdm) => { try { - return decodeURIComponent(bidResponseAdm); + return decodeURIComponent(bidResponseAdm.replace(/%(?![0-9][0-9a-fA-F]+)/g, '%25')); } catch (err) { utils.logError('emx_digitalBidAdapter', 'error', err); } @@ -120,6 +128,14 @@ export const emxAdapter = { return document.referrer; } }, + getSite: (refInfo) => { + let url = utils.parseUrl(refInfo.referer); + return { + domain: url.hostname, + page: refInfo.referer, + ref: emxAdapter.getReferrer() + } + }, getGdpr: (bidRequests, emxData) => { if (bidRequests.gdprConsent) { emxData.regs = { @@ -184,12 +200,10 @@ export const spec = { const emxImps = []; const timeout = bidderRequest.timeout || ''; const timestamp = Date.now(); - const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); + const url = 'https://' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; - const domain = utils.getTopWindowLocation().hostname; - const page = bidderRequest.refererInfo.referer; const device = emxAdapter.getDevice(); - const ref = emxAdapter.getReferrer(); + const site = emxAdapter.getSite(bidderRequest.refererInfo); utils._each(validBidRequests, function (bid) { let tagid = utils.getBidIdParameter('tagid', bid.params); @@ -212,26 +226,26 @@ export const spec = { id: bidderRequest.auctionId, imp: emxImps, device, - site: { - domain, - page, - ref - }, + site, cur: DEFAULT_CUR, version: ADAPTER_VERSION }; emxData = emxAdapter.getGdpr(bidderRequest, Object.assign({}, emxData)); + if (bidderRequest && bidderRequest.uspConsent) { + emxData.us_privacy = bidderRequest.uspConsent + } return { method: 'POST', - url: url, + url, data: JSON.stringify(emxData), options: { withCredentials: true - } + }, + bidderRequest }; }, - interpretResponse: function (serverResponse) { + interpretResponse: function (serverResponse, bidRequest) { let emxBidResponses = []; let response = serverResponse.body || {}; if (response.seatbid && response.seatbid.length > 0 && response.seatbid[0].bid) { @@ -253,7 +267,7 @@ export const spec = { }; if (emxBid.adm && emxBid.adm.indexOf(' -1) { isVideo = true; - bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid)); + bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest); } bidResponse.mediaType = (isVideo ? VIDEO : BANNER); emxBidResponses.push(bidResponse); @@ -266,7 +280,7 @@ export const spec = { if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: '//biddr.brealtime.com/check.html' + url: 'https://biddr.brealtime.com/check.html' }); } return syncs; diff --git a/modules/envivoBidAdapter.js b/modules/envivoBidAdapter.js new file mode 100644 index 00000000000..b9c80ffd468 --- /dev/null +++ b/modules/envivoBidAdapter.js @@ -0,0 +1,129 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import * as utils from '../src/utils.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import { ajax } from '../src/ajax.js'; +import {Renderer} from '../src/Renderer.js'; + +const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; +const BIDDER_CODE = 'envivo'; +const DOMAIN = 'https://ad.nvivo.tv/'; +const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; + +function isBidRequestValid(bid) { + return (typeof bid.params !== 'undefined' && parseInt(utils.getValue(bid.params, 'publisherId')) > 0); +} + +function buildRequests(validBidRequests) { + return { + method: 'POST', + url: DOMAIN + 'ads/www/admin/plugins/Prebid/getAd.php', + options: { + withCredentials: false, + crossOrigin: true + }, + data: validBidRequests, + }; +} + +function interpretResponse(serverResponse, request) { + const response = serverResponse.body; + const bidResponses = []; + var bidRequestResponses = []; + + utils._each(response, function(bidAd) { + bidAd.adResponse = { + content: bidAd.vastXml, + height: bidAd.height, + width: bidAd.width + }; + bidAd.ttl = config.getConfig('_bidderTimeout') + bidAd.renderer = bidAd.context === 'outstream' ? createRenderer(bidAd, { + id: bidAd.adUnitCode, + url: RENDERER_URL + }, bidAd.adUnitCode) : undefined; + bidResponses.push(bidAd); + }); + + bidRequestResponses.push({ + function: 'saveResponses', + request: request, + response: bidResponses + }); + sendResponseToServer(bidRequestResponses); + return bidResponses; +} + +function outstreamRender(bidAd) { + bidAd.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + sizes: [bidAd.width, bidAd.height], + width: bidAd.width, + height: bidAd.height, + targetId: bidAd.adUnitCode, + adResponse: bidAd.adResponse, + rendererOptions: { + showVolume: false, + allowFullscreen: false + } + }); + }); +} + +function createRenderer(bidAd, rendererParams, adUnitCode) { + const renderer = Renderer.install({ + id: rendererParams.id, + url: rendererParams.url, + loaded: false, + config: {'player_height': bidAd.height, 'player_width': bidAd.width}, + adUnitCode + }); + try { + renderer.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + return renderer; +} + +function onBidWon(bid) { + let wonBids = []; + wonBids.push(bid); + wonBids[0].function = 'onBidWon'; + sendResponseToServer(wonBids); +} + +function onTimeout(details) { + details.unshift({ 'function': 'onTimeout' }); + sendResponseToServer(details); +} + +function sendResponseToServer(data) { + ajax(DOMAIN + 'ads/www/admin/plugins/Prebid/tracking/track.php', null, JSON.stringify(data), { + withCredentials: false, + method: 'POST', + crossOrigin: true + }); +} + +function getUserSyncs(syncOptions) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: DOMAIN + 'ads/www/admin/plugins/Prebid/userSync.php' + }]; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: SUPPORTED_AD_TYPES, + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs, + onBidWon, + onTimeout +}; + +registerBidder(spec); diff --git a/modules/envivoBidAdapter.md b/modules/envivoBidAdapter.md new file mode 100644 index 00000000000..3ecc8a251f3 --- /dev/null +++ b/modules/envivoBidAdapter.md @@ -0,0 +1,50 @@ +# Overview + +``` +Module Name: envivo Bid Adapter +Module Type: Bidder Adapter +Maintainer : adtech@nvivo.tv +``` + +# Description + +Connects to Envivo Ad Server for bids. + +envivo bid adapter supports Banner and Video. + +# Test Parameters +``` + var adUnits = [ + //bannner object + { + code: 'banner-ad-slot', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [{ + bidder: 'envivo', + params: { + publisherId: 14 + } + }] + + }, + //video object + { + code: 'video-ad-slot', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + }, + }, + bids: [{ + bidder: "envivo", + params: { + publisherId: 14 + } + }] + }]; +``` diff --git a/modules/eplanningAnalyticsAdapter.js b/modules/eplanningAnalyticsAdapter.js index 21ecddfbc3a..08db2f2ca9d 100644 --- a/modules/eplanningAnalyticsAdapter.js +++ b/modules/eplanningAnalyticsAdapter.js @@ -1,7 +1,7 @@ -import {ajax} from '../src/ajax'; -import adapter from '../src/AnalyticsAdapter'; -import adapterManager from '../src/adapterManager'; -import * as utils from '../src/utils'; +import {ajax} from '../src/ajax.js'; +import adapter from '../src/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; const CONSTANTS = require('../src/constants.json'); diff --git a/modules/eplanningBidAdapter.js b/modules/eplanningBidAdapter.js index 01a956d1bd8..a4b4f2d6728 100644 --- a/modules/eplanningBidAdapter.js +++ b/modules/eplanningBidAdapter.js @@ -1,24 +1,30 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { getStorageManager } from '../src/storageManager.js'; + +export const storage = getStorageManager(); const BIDDER_CODE = 'eplanning'; const rnd = Math.random(); const DEFAULT_SV = 'ads.us.e-planning.net'; const DEFAULT_ISV = 'i.e-planning.net'; -const PARAMS = ['ci', 'sv', 't']; +const PARAMS = ['ci', 'sv', 't', 'ml']; const DOLLARS = 'USD'; const NET_REVENUE = true; const TTL = 120; const NULL_SIZE = '1x1'; const FILE = 'file'; +const STORAGE_RENDER_PREFIX = 'pbsr_'; +const STORAGE_VIEW_PREFIX = 'pbvi_'; export const spec = { code: BIDDER_CODE, + isBidRequestValid: function(bid) { return Boolean(bid.params.ci) || Boolean(bid.params.t); }, - buildRequests: function(bidRequests) { + buildRequests: function(bidRequests, bidderRequest) { const method = 'GET'; const dfpClientId = '1'; const sec = 'ROS'; @@ -26,23 +32,33 @@ export const spec = { let params; const urlConfig = getUrlConfig(bidRequests); const pcrs = getCharset(); - + const spaces = getSpaces(bidRequests, urlConfig.ml); + const pageUrl = bidderRequest.refererInfo.referer; + const getDomain = (url) => { + let anchor = document.createElement('a'); + anchor.href = url; + return anchor.hostname; + } if (urlConfig.t) { - url = urlConfig.isv + '/layers/t_pbjs_2.json'; + url = 'https://' + urlConfig.isv + '/layers/t_pbjs_2.json'; params = {}; } else { - url = '//' + (urlConfig.sv || DEFAULT_SV) + '/hb/1/' + urlConfig.ci + '/' + dfpClientId + '/' + (utils.getTopWindowLocation().hostname || FILE) + '/' + sec; - const referrerUrl = utils.getTopWindowReferrer(); - const spacesString = getSpacesString(bidRequests); + url = 'https://' + (urlConfig.sv || DEFAULT_SV) + '/hb/1/' + urlConfig.ci + '/' + dfpClientId + '/' + getDomain(pageUrl) + '/' + sec; + const referrerUrl = bidderRequest.refererInfo.referer.reachedTop ? encodeURIComponent(window.top.document.referrer) : encodeURIComponent(bidderRequest.refererInfo.referer); + + if (storage.hasLocalStorage()) { + registerViewabilityAllBids(bidRequests); + } + params = { rnd: rnd, - e: spacesString, - ur: utils.getTopWindowUrl() || FILE, + e: spaces.str, + ur: encodeURIComponent(pageUrl || FILE), r: 'pbjs', pbv: '$prebid.version$', - ncb: '1' + ncb: '1', + vs: spaces.vs }; - if (pcrs) { params.crs = pcrs; } @@ -50,13 +66,26 @@ export const spec = { if (referrerUrl) { params.fr = referrerUrl; } + + if (bidderRequest && bidderRequest.gdprConsent) { + if (typeof bidderRequest.gdprConsent.gdprApplies !== 'undefined') { + params.gdpr = bidderRequest.gdprConsent.gdprApplies ? '1' : '0'; + if (typeof bidderRequest.gdprConsent.consentString !== 'undefined') { + params.gdprcs = bidderRequest.gdprConsent.consentString; + } + } + } + + if (bidderRequest && bidderRequest.uspConsent) { + params.ccpa = bidderRequest.uspConsent; + } } return { method: method, url: url, data: params, - adUnitToBidId: getBidIdMap(bidRequests), + adUnitToBidId: spaces.map, }; }, interpretResponse: function(serverResponse, request) { @@ -111,9 +140,6 @@ export const spec = { }, } -function cleanName(name) { - return name.replace(/_|\.|-|\//g, '').replace(/\)\(|\(|\)|:/g, '_').replace(/^_+|_+$/g, ''); -} function getUrlConfig(bidRequests) { if (isTestRequest(bidRequests)) { return getTestConfig(bidRequests.filter(br => br.params.t)); @@ -128,31 +154,76 @@ function getUrlConfig(bidRequests) { }); }); - if (config.sv) { - config.sv = '//' + config.sv; - } - return config; } function isTestRequest(bidRequests) { - let isTest = false; - bidRequests.forEach(bid => isTest = bid.params.t); - return isTest; + for (let i = 0; i < bidRequests.length; i++) { + if (bidRequests[i].params.t) { + return true; + } + } + return false; } function getTestConfig(bidRequests) { let isv; bidRequests.forEach(br => isv = isv || br.params.isv); return { t: true, - isv: '//' + (isv || DEFAULT_ISV) + isv: (isv || DEFAULT_ISV) }; } -function getSpacesString(bids) { - const spacesString = bids.map(bid => - cleanName(bid.adUnitCode) + ':' + (bid.sizes && bid.sizes.length ? utils.parseSizesInput(bid.sizes).join(',') : NULL_SIZE) - ).join('+'); - return spacesString; +function getSize(bid, first) { + return bid.sizes && bid.sizes.length ? utils.parseSizesInput(first ? bid.sizes[0] : bid.sizes).join(',') : NULL_SIZE; +} + +function getSpacesStruct(bids) { + let e = {}; + bids.forEach(bid => { + let size = getSize(bid, true); + e[size] = e[size] ? e[size] : []; + e[size].push(bid); + }); + + return e; +} + +function cleanName(name) { + return name.replace(/_|\.|-|\//g, '').replace(/\)\(|\(|\)|:/g, '_').replace(/^_+|_+$/g, ''); +} + +function getSpaces(bidRequests, ml) { + let spacesStruct = getSpacesStruct(bidRequests); + let es = {str: '', vs: '', map: {}}; + es.str = Object.keys(spacesStruct).map(size => spacesStruct[size].map((bid, i) => { + es.vs += getVs(bid); + let name = ml ? cleanName(bid.adUnitCode) : getSize(bid, true) + '_' + i; + es.map[name] = bid.bidId; + return name + ':' + getSize(bid); + }).join('+')).join('+'); + return es; +} + +function getVs(bid) { + let s; + let vs = ''; + if (storage.hasLocalStorage()) { + s = getViewabilityData(bid); + vs += s.render >= 4 ? s.ratio.toString(16) : 'F'; + } else { + vs += 'F'; + } + return vs; +} + +function getViewabilityData(bid) { + let r = storage.getDataFromLocalStorage(STORAGE_RENDER_PREFIX + bid.adUnitCode) || 0; + let v = storage.getDataFromLocalStorage(STORAGE_VIEW_PREFIX + bid.adUnitCode) || 0; + let ratio = r > 0 ? (v / r) : 0; + return { + render: r, + ratio: window.parseInt(ratio * 10, 10) + }; } function getCharset() { @@ -163,10 +234,190 @@ function getCharset() { } } -function getBidIdMap(bidRequests) { - let map = {}; - bidRequests.forEach(bid => map[cleanName(bid.adUnitCode)] = bid.bidId); - return map; +function waitForElementsPresent(elements) { + const observer = new MutationObserver(function (mutationList, observer) { + if (mutationList && Array.isArray(mutationList)) { + mutationList.forEach(mr => { + if (mr && mr.addedNodes && Array.isArray(mr.addedNodes)) { + mr.addedNodes.forEach(ad => { + let index = elements.indexOf(ad.id); + if (index >= 0) { + registerViewability(ad); + elements.splice(index, 1); + if (!elements.length) { + observer.disconnect(); + } + } + }); + } + }); + } + }); + document.addEventListener('DOMContentLoaded', function (event) { + var config = { + childList: true, + subtree: true, + characterData: true + }; + observer.observe(document.body, config); + }); +} + +function registerViewability(div) { + visibilityHandler({ + name: div.id, + div: div + }); +} + +function registerViewabilityAllBids(bids) { + let elementsNotPresent = []; + bids.forEach(bid => { + let div = document.getElementById(bid.adUnitCode); + if (div) { + registerViewability(div); + } else { + elementsNotPresent.push(bid.adUnitCode); + } + }); + if (elementsNotPresent.length) { + waitForElementsPresent(elementsNotPresent); + } +} + +function getViewabilityTracker() { + let TIME_PARTITIONS = 5; + let VIEWABILITY_TIME = 1000; + let VIEWABILITY_MIN_RATIO = 0.5; + let publicApi; + let context; + + function segmentIsOutsideTheVisibleRange(visibleRangeEnd, p1, p2) { + return p1 > visibleRangeEnd || p2 < 0; + } + + function segmentBeginsBeforeTheVisibleRange(p1) { + return p1 < 0; + } + + function segmentEndsAfterTheVisibleRange(visibleRangeEnd, p2) { + return p2 < visibleRangeEnd; + } + + function axialVisibilityRatio(visibleRangeEnd, p1, p2) { + let visibilityRatio = 0; + if (!segmentIsOutsideTheVisibleRange(visibleRangeEnd, p1, p2)) { + if (segmentBeginsBeforeTheVisibleRange(p1)) { + visibilityRatio = p2 / (p2 - p1); + } else { + visibilityRatio = segmentEndsAfterTheVisibleRange(visibleRangeEnd, p2) ? 1 : (visibleRangeEnd - p1) / (p2 - p1); + } + } + return visibilityRatio; + } + + function isNotHiddenByNonFriendlyIframe() { + return (window === window.top) || window.frameElement; + } + + function defineContext(e) { + context = e && window.document.body.contains(e) ? window : (window.top.document.body.contains(e) ? top : undefined); + return context; + } + + function getContext(e) { + return context; + } + + function verticalVisibilityRatio(position) { + return axialVisibilityRatio(getContext().innerHeight, position.top, position.bottom); + } + + function horizontalVisibilityRatio(position) { + return axialVisibilityRatio(getContext().innerWidth, position.left, position.right); + } + + function itIsNotHiddenByBannerAreaPosition(e) { + let position = e.getBoundingClientRect(); + return (verticalVisibilityRatio(position) * horizontalVisibilityRatio(position)) > VIEWABILITY_MIN_RATIO; + } + + function itIsNotHiddenByDisplayStyleCascade(e) { + return e.offsetHeight > 0 && e.offsetWidth > 0; + } + + function itIsNotHiddenByOpacityStyleCascade(e) { + let s = e.style; + let p = e.parentNode; + return !(s && parseFloat(s.opacity) === 0) && (!p || itIsNotHiddenByOpacityStyleCascade(p)); + } + + function itIsNotHiddenByVisibilityStyleCascade(e) { + return getContext().getComputedStyle(e).visibility !== 'hidden'; + } + + function itIsNotHiddenByTabFocus() { + return getContext().top.document.hasFocus(); + } + + function isDefined(e) { + return (e !== null) && (typeof e !== 'undefined'); + } + + function itIsNotHiddenByOrphanBranch() { + return isDefined(getContext()); + } + + function isContextInAnIframe() { + return isDefined(getContext().frameElement); + } + + function processIntervalVisibilityStatus(elapsedVisibleIntervals, element, callback) { + let visibleIntervals = isVisible(element) ? (elapsedVisibleIntervals + 1) : 0; + if (visibleIntervals === TIME_PARTITIONS) { + callback(); + } else { + setTimeout(processIntervalVisibilityStatus.bind(this, visibleIntervals, element, callback), VIEWABILITY_TIME / TIME_PARTITIONS); + } + } + + function isVisible(element) { + defineContext(element); + return isNotHiddenByNonFriendlyIframe() && + itIsNotHiddenByOrphanBranch() && + itIsNotHiddenByTabFocus() && + itIsNotHiddenByDisplayStyleCascade(element) && + itIsNotHiddenByVisibilityStyleCascade(element) && + itIsNotHiddenByOpacityStyleCascade(element) && + itIsNotHiddenByBannerAreaPosition(element) && + (!isContextInAnIframe() || isVisible(getContext().frameElement)); + } + + publicApi = { + isVisible: isVisible, + onView: processIntervalVisibilityStatus.bind(this, 0) + }; + + return publicApi; +}; + +function visibilityHandler(obj) { + if (obj.div) { + registerAuction(STORAGE_RENDER_PREFIX + obj.name); + getViewabilityTracker().onView(obj.div, registerAuction.bind(undefined, STORAGE_VIEW_PREFIX + obj.name)); + } } +function registerAuction(storageID) { + let value; + try { + value = storage.getDataFromLocalStorage(storageID); + value = value ? window.parseInt(value, 10) + 1 : 1; + storage.setDataInLocalStorage(storageID, value); + } catch (exc) { + return false; + } + + return true; +} registerBidder(spec); diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index bdf07742497..5e07561044a 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -1,7 +1,7 @@ 'use strict'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; const BIDDER_CODE = 'etarget'; const countryMap = { @@ -39,7 +39,7 @@ export const spec = { request.push(formRequestUrl(reqParams)); } - request.unshift('//' + lastCountry + '.search.etargetnet.com/hb/?hbget=1'); + request.unshift('https://' + lastCountry + '.search.etargetnet.com/hb/?hbget=1'); netRevenue = 'net'; if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { diff --git a/modules/express.js b/modules/express.js index 1249822f587..f4a76daefdf 100644 --- a/modules/express.js +++ b/modules/express.js @@ -1,5 +1,5 @@ -import * as utils from '../src/utils'; +import * as utils from '../src/utils.js'; const MODULE_NAME = 'express'; @@ -61,6 +61,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) { function defaultSlots(slots) { return Array.isArray(slots) ? slots.slice() + // eslint-disable-next-line no-undef : googletag.pubads().getSlots().slice(); } @@ -116,6 +117,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) { // if not SRA mode, get only the gpt slot corresponding to sEementId var aGptSlots; if (!bEnabledSRA) { + // eslint-disable-next-line no-undef aGptSlots = googletag.pubads().getSlots().filter(function (oGptSlot) { return oGptSlot.getSlotElementId() === sElementId; }); diff --git a/modules/eywamediaBidAdapter.js b/modules/eywamediaBidAdapter.js deleted file mode 100644 index 543775dc3aa..00000000000 --- a/modules/eywamediaBidAdapter.js +++ /dev/null @@ -1,181 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'eywamedia'; -const CURRENCY = 'USD'; -const VERSION = '1.0.0'; -const TIME_TO_LIVE = 360; -const NET_REVENUE = true; -const COOKIE_NAME = 'emaduuid'; -const UUID_LEN = 36; -const SERVER_ENDPOINT = 'https://adtarbostg.eywamedia.com/auctions/prebidjs/3000'; -const localWindow = getTopWindow(); - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['banner'], - /** - * Determines whether or not the given bid request is valid. - * @param {object} bid, bid to validate - * @return boolean, true if valid, otherwise false - */ - isBidRequestValid: function(bid) { - return !!(bid.params.publisherId); - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return requestPayload Info describing the request to the server. - */ - buildRequests: function(bidRequests, bidRequest) { - const device = getDeviceInfo(); - const site = getSiteInfo(); - const user = getUserInfo(); - - let requestPayload = { - id: utils.generateUUID(), - publisherId: bidRequests[0].params.publisherId, - device: device, - site: site, - user: user, - bidPayload: bidRequests, - cacheBust: new Date().getTime().toString(), - adapterVersion: VERSION, - tmax: bidRequest.timeout - }; - - return { - method: 'POST', - url: SERVER_ENDPOINT, - options: { - contentType: 'application/json' - }, - data: requestPayload - } - }, - - /** - * Makes Eywamedia Ad Server response compatible to Prebid specs - * @param serverResponse successful response from Ad Server - * @param bidderRequest original bidRequest - * @return {Bid[]} an array of bids - */ - interpretResponse: function (serverResponse, bidRequest) { - var bidObject, response; - var bidRespones = []; - var responses = serverResponse.body; - for (var i = 0; i < responses.length; i++) { - response = responses[i]; - bidObject = { - requestId: response.bidId, - cpm: response.cpm, - width: parseInt(response.width), - height: parseInt(response.height), - creativeId: response.bidId, - currency: CURRENCY, - netRevenue: NET_REVENUE, - ttl: TIME_TO_LIVE, - ad: response.ad, - bidderCode: BIDDER_CODE, - transactionId: response.transactionId, - mediaType: response.respType, - }; - bidRespones.push(bidObject); - } - return bidRespones; - } -} -registerBidder(spec); - -/*************************************** - * Helper Functions - ***************************************/ - -/** - * get device type - */ -function getDeviceType() { - let ua = navigator.userAgent; - // Tablets must be checked before phones. - if ((/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i).test(ua)) { - return 5; // "Tablet" - } - if ((/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/).test(ua)) { - return 4; // "Phone" - } - return 2; // Personal Computers -}; - -/** - * get device info - */ -function getDeviceInfo() { - const language = navigator.language; - return { - ua: navigator.userAgent, - language: navigator[language], - devicetype: getDeviceType(), - dnt: utils.getDNT(), - geo: {}, - js: 1 - }; -}; - -/** - * get site info - */ -function getSiteInfo() { - const topLocation = utils.getTopWindowLocation(); - return { - domain: topLocation.hostname, - page: topLocation.href, - referrer: utils.getTopWindowReferrer(), - desc: getPageDescription(), - title: localWindow.document.title, - }; -}; - -/** - * get user info - */ -function getUserInfo() { - return { - id: getUserID(), - }; -}; - -/** - * get user Id - */ -const getUserID = () => { - const i = document.cookie.indexOf(COOKIE_NAME); - - if (i === -1) { - const uuid = utils.generateUUID(); - document.cookie = `${COOKIE_NAME}=${uuid}; path=/`; - return uuid; - } - - const j = i + COOKIE_NAME.length + 1; - return document.cookie.substring(j, j + UUID_LEN); -}; - -/** - * get page description - */ -function getPageDescription() { - if (document.querySelector('meta[name="description"]')) { - return document.querySelector('meta[name="description"]').getAttribute('content'); // Value of the description metadata from the publisher's page. - } else { - return ''; - } -}; - -function getTopWindow() { - try { - return window.top; - } catch (e) { - return window; - } -}; diff --git a/modules/fairtradeBidAdapter.js b/modules/fairtradeBidAdapter.js deleted file mode 100644 index 55f24ab8906..00000000000 --- a/modules/fairtradeBidAdapter.js +++ /dev/null @@ -1,150 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -const BIDDER_CODE = 'fairtrade'; -const ENDPOINT_URL = '//pool.fair-trademedia.com/hb'; -const TIME_TO_LIVE = 360; -const ADAPTER_SYNC_URL = '//pool.fair-trademedia.com/push_sync'; -const LOG_ERROR_MESS = { - noAuid: 'Bid from response has no auid parameter - ', - noAdm: 'Bid from response has no adm parameter - ', - noBid: 'Array of bid objects is empty', - noPlacementCode: 'Can\'t find in requested bids the bid with auid - ', - emptyUids: 'Uids should be not empty', - emptySeatbid: 'Seatbid array from response has empty item', - emptyResponse: 'Response is empty', - hasEmptySeatbidArray: 'Response has empty seatbid array', - hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' -}; -export const spec = { - code: BIDDER_CODE, - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!bid.params.uid; - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests - an array of bids - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(validBidRequests) { - const auids = []; - const bidsMap = {}; - const bids = validBidRequests || []; - let priceType = 'net'; - let reqId; - - bids.forEach(bid => { - if (bid.params.priceType === 'gross') { - priceType = 'gross'; - } - reqId = bid.bidderRequestId; - if (!bidsMap[bid.params.uid]) { - bidsMap[bid.params.uid] = [bid]; - auids.push(bid.params.uid); - } else { - bidsMap[bid.params.uid].push(bid); - } - }); - - const payload = { - u: utils.getTopWindowUrl(), - pt: priceType, - auids: auids.join(','), - r: reqId - }; - - return { - method: 'GET', - url: ENDPOINT_URL, - data: payload, - bidsMap: bidsMap, - }; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @param {*} bidRequest - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest) { - serverResponse = serverResponse && serverResponse.body - const bidResponses = []; - const bidsMap = bidRequest.bidsMap; - const priceType = bidRequest.data.pt; - - let errorMessage; - - if (!serverResponse) errorMessage = LOG_ERROR_MESS.emptyResponse; - else if (serverResponse.seatbid && !serverResponse.seatbid.length) { - errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray; - } - - if (!errorMessage && serverResponse.seatbid) { - serverResponse.seatbid.forEach(respItem => { - _addBidResponse(_getBidFromResponse(respItem), bidsMap, priceType, bidResponses); - }); - } - if (errorMessage) utils.logError(errorMessage); - return bidResponses; - }, - getUserSyncs: function(syncOptions) { - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: ADAPTER_SYNC_URL - }]; - } - } -} - -function _getBidFromResponse(respItem) { - if (!respItem) { - utils.logError(LOG_ERROR_MESS.emptySeatbid); - } else if (!respItem.bid) { - utils.logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); - } else if (!respItem.bid[0]) { - utils.logError(LOG_ERROR_MESS.noBid); - } - return respItem && respItem.bid && respItem.bid[0]; -} - -function _addBidResponse(serverBid, bidsMap, priceType, bidResponses) { - if (!serverBid) return; - let errorMessage; - if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); - if (!serverBid.adm) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); - else { - const awaitingBids = bidsMap[serverBid.auid]; - if (awaitingBids) { - awaitingBids.forEach(bid => { - const bidResponse = { - requestId: bid.bidId, // bid.bidderRequestId, - cpm: serverBid.price, - width: serverBid.w, - height: serverBid.h, - creativeId: serverBid.auid, // bid.bidId, - currency: 'USD', - netRevenue: priceType !== 'gross', - ttl: TIME_TO_LIVE, - ad: serverBid.adm, - dealId: serverBid.dealid - }; - bidResponses.push(bidResponse); - }); - } else { - errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; - } - } - if (errorMessage) { - utils.logError(errorMessage); - } -} - -registerBidder(spec); diff --git a/modules/feedadBidAdapter.js b/modules/feedadBidAdapter.js index 1e995ee8914..3992f2db5e0 100644 --- a/modules/feedadBidAdapter.js +++ b/modules/feedadBidAdapter.js @@ -1,7 +1,7 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, VIDEO} from '../src/mediaTypes'; -import {ajax} from '../src/ajax'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {ajax} from '../src/ajax.js'; /** * Version of the FeedAd bid adapter diff --git a/modules/fidelityBidAdapter.js b/modules/fidelityBidAdapter.js index 078e9d2fcce..f16a8ea96be 100644 --- a/modules/fidelityBidAdapter.js +++ b/modules/fidelityBidAdapter.js @@ -1,15 +1,16 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'fidelity'; const BIDDER_SERVER = 'x.fidelity-media.com'; const FIDELITY_VENDOR_ID = 408; export const spec = { code: BIDDER_CODE, - isBidRequestValid: function(bid) { + gvlid: 408, + isBidRequestValid: function isBidRequestValid(bid) { return !!(bid && bid.params && bid.params.zoneid); }, - buildRequests: function(validBidRequests, bidderRequest) { + buildRequests: function buildRequests(validBidRequests, bidderRequest) { return validBidRequests.map(bidRequest => { var server = bidRequest.params.server || BIDDER_SERVER; @@ -24,19 +25,20 @@ export const spec = { subid: 'hb', flashver: getFlashVersion(), tmax: bidderRequest.timeout, - defloc: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), + defloc: bidderRequest.refererInfo.referer, + referrer: getTopWindowReferrer(), + schain: getSupplyChain(bidRequest.schain), }; - setConsentParams(bidderRequest.gdprConsent, payload); + setConsentParams(bidderRequest.gdprConsent, bidderRequest.uspConsent, payload); return { method: 'GET', - url: '//' + server + '/delivery/hb.php', + url: 'https://' + server + '/delivery/hb.php', data: payload }; }); }, - interpretResponse: function(serverResponse) { + interpretResponse: function interpretResponse(serverResponse) { serverResponse = serverResponse.body; const bidResponses = []; if (serverResponse && serverResponse.seatbid) { @@ -58,13 +60,13 @@ export const spec = { } return bidResponses; }, - getUserSyncs: function getUserSyncs(syncOptions, serverResponses, gdprConsent) { + getUserSyncs: function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { if (syncOptions.iframeEnabled) { - var url = '//' + BIDDER_SERVER + '/delivery/matches.php'; + var url = 'https://' + BIDDER_SERVER + '/delivery/matches.php'; var payload = { type: 'iframe' }; - setConsentParams(gdprConsent, payload); + setConsentParams(gdprConsent, uspConsent, payload); return [{ type: 'iframe', @@ -89,7 +91,15 @@ function getFlashVersion() { return result || ''; } -function setConsentParams(gdprConsent, payload) { +function getTopWindowReferrer() { + try { + return window.top.document.referrer; + } catch (e) { + return ''; + } +} + +function setConsentParams(gdprConsent, uspConsent, payload) { if (gdprConsent) { payload.gdpr = 0; payload.consent_str = ''; @@ -104,6 +114,30 @@ function setConsentParams(gdprConsent, payload) { payload.consent_given = gdprConsent.vendorData.vendorConsents[FIDELITY_VENDOR_ID.toString(10)] ? 1 : 0; } } + if (typeof uspConsent !== 'undefined') { + payload.us_privacy = uspConsent; + } } +function getSupplyChain(schain) { + var supplyChain = ''; + if (schain != null && schain.nodes) { + supplyChain = schain.ver + ',' + schain.complete; + for (let i = 0; i < schain.nodes.length; i++) { + supplyChain += '!'; + supplyChain += (schain.nodes[i].asi) ? encodeURIComponent(schain.nodes[i].asi) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].sid) ? encodeURIComponent(schain.nodes[i].sid) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].hp) ? encodeURIComponent(schain.nodes[i].hp) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].rid) ? encodeURIComponent(schain.nodes[i].rid) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].name) ? encodeURIComponent(schain.nodes[i].name) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].domain) ? encodeURIComponent(schain.nodes[i].domain) : ''; + } + } + return supplyChain; +} registerBidder(spec); diff --git a/modules/fidelityBidAdapter.md b/modules/fidelityBidAdapter.md index a4f1e91cd3d..0af75689bd6 100644 --- a/modules/fidelityBidAdapter.md +++ b/modules/fidelityBidAdapter.md @@ -1,18 +1,22 @@ # Overview - +​ **Module Name**: Fidelity Media fmxSSP Bidder Adapter **Module Type**: Bidder Adapter **Maintainer**: on@fidelity-media.com - +​ # Description - +​ Connects to Fidelity Media fmxSSP demand source to fetch bids. - +​ # Test Parameters -``` +``` var adUnits = [{ code: 'banner-ad-div', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, bids: [{ bidder: 'fidelity', params: { @@ -23,4 +27,4 @@ Connects to Fidelity Media fmxSSP demand source to fetch bids. }] }]; -``` +``` \ No newline at end of file diff --git a/modules/fintezaAnalyticsAdapter.js b/modules/fintezaAnalyticsAdapter.js index 097d56e05f3..8729035491f 100644 --- a/modules/fintezaAnalyticsAdapter.js +++ b/modules/fintezaAnalyticsAdapter.js @@ -1,9 +1,10 @@ -import { ajax } from '../src/ajax'; -import adapter from '../src/AnalyticsAdapter'; -import adapterManager from '../src/adapterManager'; -import * as utils from '../src/utils'; -import { parse as parseURL } from '../src/url'; +import { ajax } from '../src/ajax.js'; +import adapter from '../src/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; +import { getStorageManager } from '../src/storageManager.js'; +const storage = getStorageManager(); const CONSTANTS = require('../src/constants.json'); const ANALYTICS_TYPE = 'endpoint'; @@ -19,6 +20,7 @@ const SESSION_ID = '_fz_ssn'; const SESSION_DURATION = 30 * 60 * 1000; const SESSION_RAND_PART = 9; const TRACK_TIME_KEY = '_fz_tr'; +const UNIQ_ID_KEY = '_fz_uniq'; function getPageInfo() { const pageInfo = { @@ -26,12 +28,48 @@ function getPageInfo() { } if (document.referrer) { - pageInfo.referrerDomain = parseURL(document.referrer).hostname; + pageInfo.referrerDomain = utils.parseUrl(document.referrer).hostname; } return pageInfo; } +function getUniqId() { + let cookies; + + try { + cookies = parseCookies(document.cookie); + } catch (a) { + cookies = {}; + } + + let isUniqFromLS; + let uniq = cookies[ UNIQ_ID_KEY ]; + if (!uniq) { + try { + if (storage.hasLocalStorage()) { + uniq = storage.getDataFromLocalStorage(UNIQ_ID_KEY) || ''; + isUniqFromLS = true; + } + } catch (b) {} + } + + if (uniq && isNaN(uniq)) { + uniq = null; + } + + if (uniq && isUniqFromLS) { + let expires = new Date(); + expires.setFullYear(expires.getFullYear() + 10); + + try { + storage.setCookie(UNIQ_ID_KEY, uniq, expires.toUTCString()); + } catch (e) {} + } + + return uniq; +} + function initFirstVisit() { let now; let visitDate; @@ -53,7 +91,7 @@ function initFirstVisit() { now.setFullYear(now.getFullYear() + 20); try { - document.cookie = FIRST_VISIT_DATE + '=' + visitDate + '; path=/; expires=' + now.toUTCString(); + storage.setCookie(FIRST_VISIT_DATE, visitDate, now.toUTCString()); } catch (e) {} } @@ -73,7 +111,7 @@ function parseCookies(cookie) { let param, value; let i, j; - if (!cookie) { + if (!cookie || !storage.cookiesAreEnabled()) { return {}; } @@ -166,7 +204,7 @@ function initSession() { } try { - document.cookie = SESSION_ID + '=' + sessionId + '; path=/; expires=' + expires.toUTCString(); + storage.setCookie(SESSION_ID, sessionId, expires.toUTCString()); } catch (e) {} return { @@ -212,10 +250,10 @@ function saveTrackRequestTime() { const expires = new Date(now + SESSION_DURATION); try { - if (window.localStorage) { - window.localStorage.setItem(TRACK_TIME_KEY, now.toString()); + if (storage.hasLocalStorage()) { + storage.setDataInLocalStorage(TRACK_TIME_KEY, now.toString()); } else { - document.cookie = TRACK_TIME_KEY + '=' + now + '; path=/; expires=' + expires.toUTCString(); + storage.setCookie(TRACK_TIME_KEY, now.toString(), expires.toUTCString()); } } catch (a) {} } @@ -224,9 +262,9 @@ function getTrackRequestLastTime() { let cookie; try { - if (window.localStorage) { + if (storage.hasLocalStorage()) { return parseInt( - window.localStorage.getItem(TRACK_TIME_KEY) || 0, + storage.getDataFromLocalStorage(TRACK_TIME_KEY) || 0, 10, ); } @@ -330,6 +368,10 @@ function prepareTrackData(evtype, args) { ac: getAntiCacheParam(), }) + if (fntzAnalyticsAdapter.context.uniqId) { + trackData.fz_uniq = fntzAnalyticsAdapter.context.uniqId; + } + if (session.id) { trackData.ssn = session.id; } @@ -347,12 +389,12 @@ function sendTrackRequest(trackData) { try { ajax( fntzAnalyticsAdapter.context.host, - null, // Callback + null, trackData, { method: 'GET', - contentType: 'application/x-www-form-urlencoded', - // preflight: true, + withCredentials: true, + contentType: 'application/x-www-form-urlencoded' }, ); saveTrackRequestTime(); @@ -396,6 +438,7 @@ fntzAnalyticsAdapter.enableAnalytics = function (config) { bidWonTrack: config.options.bidWonTrack || BID_WON_TRACK, firstVisit: initFirstVisit(), screenResolution: `${window.screen.width}x${window.screen.height}`, + uniqId: getUniqId(), pageInfo: getPageInfo(), }; diff --git a/modules/fluctBidAdapter.js b/modules/fluctBidAdapter.js new file mode 100644 index 00000000000..420fe04ddcb --- /dev/null +++ b/modules/fluctBidAdapter.js @@ -0,0 +1,121 @@ +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'fluct'; +const END_POINT = 'https://hb.adingo.jp/prebid'; +const VERSION = '1.2'; +const NET_REVENUE = true; +const TTL = 300; + +export const spec = { + code: BIDDER_CODE, + aliases: ['adingo'], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: (bid) => { + return !!(bid.params.groupId && bid.params.tagId); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: (validBidRequests, bidderRequest) => { + const serverRequests = []; + const referer = bidderRequest.refererInfo.referer; + + utils._each(validBidRequests, (request) => { + const data = Object(); + + data.referer = referer; + data.adUnitCode = request.adUnitCode; + data.bidId = request.bidId; + data.transactionId = request.transactionId; + + data.sizes = []; + utils._each(request.sizes, (size) => { + data.sizes.push({ + w: size[0], + h: size[1] + }); + }); + + data.params = request.params; + + serverRequests.push({ + method: 'POST', + url: END_POINT, + options: { + contentType: 'application/json', + withCredentials: true, + customHeaders: { + 'x-fluct-app': 'prebid/fluctBidAdapter', + 'x-fluct-version': VERSION, + 'x-openrtb-version': 2.5 + } + }, + data: data + }); + }); + + return serverRequests; + }, + + /* + * Unpack the respnse from the server into a list of bids. + * + * @param {serverResponse} serverResponse A successful response from the server. + * @return {bid[]} An array of bids which weer nested inside the server. + */ + interpretResponse: (serverResponse, serverRequest) => { + const bidResponses = []; + + const res = serverResponse.body; + if (!utils.isEmpty(res) && !utils.isEmpty(res.seatbid) && !utils.isEmpty(res.seatbid[0].bid)) { + const bid = res.seatbid[0].bid[0]; + const dealId = bid.dealid; + const beaconUrl = bid.burl; + const callImpBeacon = ``; + let data = { + bidderCode: BIDDER_CODE, + requestId: res.id, + currency: res.cur, + cpm: parseFloat(bid.price) || 0, + netRevenue: NET_REVENUE, + width: bid.w, + height: bid.h, + creativeId: bid.crid, + ttl: TTL, + ad: bid.adm + callImpBeacon, + }; + if (!utils.isEmpty(dealId)) { + data.dealId = dealId; + } + bidResponses.push(data); + } + return bidResponses; + }, + + /* + * Register the user sync pixels which should be dropped after the auction. + * + * @params {syncOptions} syncOptions which user syncs are allowed? + * @params {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + * + */ + getUserSyncs: (syncOptions, serverResponses) => { + return []; + }, +}; + +registerBidder(spec); diff --git a/modules/fluctBidAdapter.md b/modules/fluctBidAdapter.md new file mode 100644 index 00000000000..a1dc4d6f225 --- /dev/null +++ b/modules/fluctBidAdapter.md @@ -0,0 +1,36 @@ +# Overview + +``` +Module Name: fluct Bid Adapter +Module Type: Bidder Adapter +Maintainer: developer@fluct.jp +``` + +# Description + +Connects to fluct exchange for bids. + +# Test parameters + +``` +var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'fluct', + params: { + tagId: '25405:1000192893', + groupId: '1000105712', + dfpUnitCode: '/62532913/s_fluct.test_hb_prebid_11940', // Optional + } + } + ] + } +] +``` diff --git a/modules/freeWheelAdserverVideo.js b/modules/freeWheelAdserverVideo.js index 03217b1165d..cb4bd938373 100644 --- a/modules/freeWheelAdserverVideo.js +++ b/modules/freeWheelAdserverVideo.js @@ -2,8 +2,8 @@ * This module adds Freewheel support for Video to Prebid. */ -import { registerVideoSupport } from '../src/adServerManager'; -import { getHook, submodule } from '../src/hook'; +import { registerVideoSupport } from '../src/adServerManager.js'; +import { getHook, submodule } from '../src/hook.js'; export const adpodUtils = {}; export function notifyTranslationModule(fn) { diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js index 3e52ba2cbe9..34724658631 100644 --- a/modules/freewheel-sspBidAdapter.js +++ b/modules/freewheel-sspBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -// import { config } from '../src/config'; +import * as utils from '../src/utils.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'freewheel-ssp'; @@ -11,11 +11,7 @@ const PRIMETIME_URL = PROTOCOL + '://cdn.stickyadstv.com/prime-time/'; const USER_SYNC_URL = PROTOCOL + '://ads.stickyadstv.com/auto-user-sync'; function getProtocol() { - if (location.protocol && location.protocol.indexOf('https') === 0) { - return 'https'; - } else { - return 'http'; - } + return 'https'; } function isValidUrl(str) { @@ -38,6 +34,20 @@ function getBiggerSize(array) { return result; } +function getBiggerSizeWithLimit(array, minSizeLimit, maxSizeLimit) { + var minSize = minSizeLimit || [0, 0]; + var maxSize = maxSizeLimit || [Number.MAX_VALUE, Number.MAX_VALUE]; + var candidates = []; + + for (var i = 0; i < array.length; i++) { + if (array[i][0] * array[i][1] >= minSize[0] * minSize[1] && array[i][0] * array[i][1] <= maxSize[0] * maxSize[1]) { + candidates.push(array[i]); + } + } + + return getBiggerSize(candidates); +} + /* * read the pricing extension with this format: 1.0000 * @return {object} pricing data in format: {currency: "EUR", price:"1.000"} @@ -204,7 +214,7 @@ var getOutstreamScript = function(bid) { export const spec = { code: BIDDER_CODE, - supportedMediaTypes: ['banner', 'video'], + supportedMediaTypes: [BANNER, VIDEO], aliases: ['stickyadstv'], // former name for freewheel-ssp /** * Determines whether or not the given bid request is valid. @@ -225,62 +235,82 @@ export const spec = { buildRequests: function(bidRequests, bidderRequest) { // var currency = config.getConfig(currency); - var currentBidRequest = bidRequests[0]; - if (bidRequests.length > 1) { - utils.logMessage('Prebid.JS - freewheel bid adapter: only one ad unit is required.'); - } + let buildRequest = (currentBidRequest, bidderRequest) => { + var zone = currentBidRequest.params.zoneId; + var timeInMillis = new Date().getTime(); + var keyCode = hashcode(zone + '' + timeInMillis); + var requestParams = { + reqType: 'AdsSetup', + protocolVersion: '2.0', + zoneId: zone, + componentId: getComponentId(currentBidRequest.params.format), + timestamp: timeInMillis, + pKey: keyCode + }; - var zone = currentBidRequest.params.zoneId; - var timeInMillis = new Date().getTime(); - var keyCode = hashcode(zone + '' + timeInMillis); - - var requestParams = { - reqType: 'AdsSetup', - protocolVersion: '2.0', - zoneId: zone, - componentId: getComponentId(currentBidRequest.params.format), - timestamp: timeInMillis, - pKey: keyCode - }; + // Add GDPR flag and consent string + if (bidderRequest && bidderRequest.gdprConsent) { + requestParams._fw_gdpr_consent = bidderRequest.gdprConsent.consentString; - // Add GDPR flag and consent string - if (bidderRequest.gdprConsent) { - requestParams._fw_gdpr_consent = bidderRequest.gdprConsent.consentString; + if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { + requestParams._fw_gdpr = bidderRequest.gdprConsent.gdprApplies; + } + } - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - requestParams._fw_gdpr = bidderRequest.gdprConsent.gdprApplies; + if (currentBidRequest.params.gdpr_consented_providers) { + requestParams._fw_gdpr_consented_providers = currentBidRequest.params.gdpr_consented_providers; } - } - if (currentBidRequest.params.gdpr_consented_providers) { - requestParams._fw_gdpr_consented_providers = currentBidRequest.params.gdpr_consented_providers; - } + // Add CCPA consent string + if (bidderRequest && bidderRequest.uspConsent) { + requestParams._fw_us_privacy = bidderRequest.uspConsent; + } - var vastParams = currentBidRequest.params.vastUrlParams; - if (typeof vastParams === 'object') { - for (var key in vastParams) { - if (vastParams.hasOwnProperty(key)) { - requestParams[key] = vastParams[key]; + var vastParams = currentBidRequest.params.vastUrlParams; + if (typeof vastParams === 'object') { + for (var key in vastParams) { + if (vastParams.hasOwnProperty(key)) { + requestParams[key] = vastParams[key]; + } } } - } - var location = utils.getTopWindowUrl(); - if (isValidUrl(location)) { - requestParams.loc = location; - } + var location = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : getTopMostWindow().location.href; + if (isValidUrl(location)) { + requestParams.loc = location; + } - var playerSize = getBiggerSize(currentBidRequest.sizes); - if (playerSize[0] > 0 || playerSize[1] > 0) { - requestParams.playerSize = playerSize[0] + 'x' + playerSize[1]; - } + var playerSize = []; + if (currentBidRequest.mediaTypes.video && currentBidRequest.mediaTypes.video.playerSize) { + // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3 + if (utils.isArray(currentBidRequest.mediaTypes.video.playerSize[0])) { + playerSize = currentBidRequest.mediaTypes.video.playerSize[0]; + } else { + playerSize = currentBidRequest.mediaTypes.video.playerSize; + } + } else if (currentBidRequest.mediaTypes.banner.sizes) { + // If mediaTypes is banner, get size from mediaTypes.banner.sizes per http://prebid.org/blog/pbjs-3 + playerSize = getBiggerSizeWithLimit(currentBidRequest.mediaTypes.banner.sizes, currentBidRequest.mediaTypes.banner.minSizeLimit, currentBidRequest.mediaTypes.banner.maxSizeLimit); + } else { + // Backward compatible code, in case size still pass by sizes in bid request + playerSize = getBiggerSize(currentBidRequest.sizes); + } + + if (playerSize[0] > 0 || playerSize[1] > 0) { + requestParams.playerSize = playerSize[0] + 'x' + playerSize[1]; + } - return { - method: 'GET', - url: FREEWHEEL_ADSSETUP, - data: requestParams, - bidRequest: currentBidRequest + return { + method: 'GET', + url: FREEWHEEL_ADSSETUP, + data: requestParams, + bidRequest: currentBidRequest + }; }; + + return bidRequests.map(function(currentBidRequest) { + return buildRequest(currentBidRequest, bidderRequest); + }); }, /** @@ -292,7 +322,21 @@ export const spec = { */ interpretResponse: function(serverResponse, request) { var bidrequest = request.bidRequest; - var playerSize = getBiggerSize(bidrequest.sizes); + var playerSize = []; + if (bidrequest.mediaTypes.video && bidrequest.mediaTypes.video.playerSize) { + // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3 + if (utils.isArray(bidrequest.mediaTypes.video.playerSize[0])) { + playerSize = bidrequest.mediaTypes.video.playerSize[0]; + } else { + playerSize = bidrequest.mediaTypes.video.playerSize; + } + } else if (bidrequest.mediaTypes.banner.sizes) { + // If mediaTypes is banner, get size from mediaTypes.banner.sizes per http://prebid.org/blog/pbjs-3 + playerSize = getBiggerSizeWithLimit(bidrequest.mediaTypes.banner.sizes, bidrequest.mediaTypes.banner.minSizeLimit, bidrequest.mediaTypes.banner.maxSizeLimit); + } else { + // Backward compatible code, in case size still pass by sizes in bid request + playerSize = getBiggerSize(bidrequest.sizes); + } if (typeof serverResponse == 'object' && typeof serverResponse.body == 'string') { serverResponse = serverResponse.body; @@ -330,17 +374,12 @@ export const spec = { ttl: 360 }; - var mediaTypes = bidrequest.mediaTypes || {}; - if (mediaTypes.video) { - // bidResponse.vastXml = serverResponse; + if (bidrequest.mediaTypes.video) { + bidResponse.vastXml = serverResponse; bidResponse.mediaType = 'video'; - - var blob = new Blob([serverResponse], {type: 'application/xml'}); - bidResponse.vastUrl = window.URL.createObjectURL(blob); - } else { - bidResponse.ad = formatAdHTML(bidrequest, playerSize); } + bidResponse.ad = formatAdHTML(bidrequest, playerSize); bidResponses.push(bidResponse); } @@ -348,11 +387,13 @@ export const spec = { }, getUserSyncs: function(syncOptions) { - if (syncOptions.pixelEnabled) { + if (syncOptions && syncOptions.pixelEnabled) { return [{ type: 'image', url: USER_SYNC_URL }]; + } else { + return []; } }, diff --git a/modules/freewheel-sspBidAdapter.md b/modules/freewheel-sspBidAdapter.md index 70ab2415279..0086aac6567 100644 --- a/modules/freewheel-sspBidAdapter.md +++ b/modules/freewheel-sspBidAdapter.md @@ -13,15 +13,21 @@ Module that connects to Freewheel ssp's demand sources var adUnits = [ { code: 'test-div', - sizes: [[300, 250]], // a display size + + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size + } + }, + bids: [ { bidder: "freewheel-ssp", params: { - zoneId : '41852' + zoneId : '277225' } } ] } ]; -``` \ No newline at end of file +``` diff --git a/modules/fyberBidAdapter.js b/modules/fyberBidAdapter.js deleted file mode 100644 index 3586d0775ac..00000000000 --- a/modules/fyberBidAdapter.js +++ /dev/null @@ -1,378 +0,0 @@ -import {logError, getTopWindowUrl, getTopWindowReferrer, getTopWindowLocation, createTrackPixelHtml} from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { formatQS } from '../src/url'; -import { config } from '../src/config'; - -/** - * @type {{CODE: string, V: string, RECTANGLE_SIZE: {W: number, H: number}, SPOT_TYPES: {INTERSTITIAL: string, RECTANGLE: string, FLOATING: string, BANNER: string}, DISPLAY_AD: number, ENDPOINT_URL: string, EVENTS_ENDPOINT_URL: string, RESPONSE_HEADERS_NAME: {PRICING_VALUE: string, AD_H: string, AD_W: string}}} - */ -const CONSTANTS = { - CODE: 'fyber', - V: 'FY-JS-HB-PBJS-1.0', - RECTANGLE_SIZE: {W: 300, H: 250}, - - SPOT_TYPES: { - INTERSTITIAL: 'interstitial', - RECTANGLE: 'rectangle', - FLOATING: 'floating', - BANNER: 'banner' - }, - - DISPLAY_AD: 20, - ENDPOINT_URL: '//ad-tag.inner-active.mobi/simpleM2M/requestJsonAd', - EVENTS_ENDPOINT_URL: '//vast-events.inner-active.mobi/Event', - RESPONSE_HEADERS_NAME: { - PRICING_VALUE: 'X-IA-Pricing-Value', - AD_H: 'X-IA-Ad-Height', - AD_W: 'X-IA-Ad-Width', - CREATIVE_ID: 'X-IA-Creative-ID', - CURRENCY: 'X-IA-Pricing-Currency', - TIMEOUT: 'X-IA-SESSION-TIMEOUT' - } -}; - -/** - * gloable util functions - * @type {{defaultsQsParams: {v: (string|string), page: string, mw: boolean, hb: string}, stringToCamel: (function(*)), objectToCamel: (function(*=))}} - */ -const Helpers = { - defaultsQsParams: {v: CONSTANTS.V, page: encodeURIComponent(getTopWindowUrl()), mw: true, hb: 'prebidjs'}, - /** - * Returns the ad HTML template - * @param adHtml: string {ad server creative} - * @param tracking: object {impressions, clicks} - * @param bidParams: object - * @returns {string}: create template - */ - getAd(adHtml, tracking, bidParams) { - let impressionsHtml = ''; - if (tracking && Array.isArray(tracking.impressions)) { - let impressions = tracking.impressions; - impressions.push(Reporter.getEventUrl('HBPreBidImpression', bidParams, false)); - impressions.forEach(impression => impression && (impressionsHtml += createTrackPixelHtml(impression))); - } - adHtml = impressionsHtml + adHtml.replace(/ - - - - -
${adHtml}
- - - `; - return adTemplate; - }, - - /** - * Change string format from underscore to camelcase (e.g., APP_ID to appId) - * @param {string} str - * @return string - */ - stringToCamel(str) { - if (str.indexOf('_') === -1) { - const first = str.charAt(0); - if (first !== first.toLowerCase()) { - str = str.toLowerCase(); - } - return str; - } - - str = str.toLowerCase(); - return str.replace(/(\_[a-z])/g, $1 => $1.toUpperCase().replace('_', '')); - }, - - /** - * Change all object keys string format from underscore to camelcase (e.g., {'APP_ID' : ...} to {'appId' : ...}) - * @param params: object - * @returns object - */ - objectToCamel(params) { - Object.keys(params).forEach(key => { - const keyCamelCase = this.stringToCamel(key); - if (keyCamelCase !== key) { - params[keyCamelCase] = params[key]; - delete params[key]; - } - }); - return params; - }, - - /** - * @param {Object} params - * @return {string} url - */ - getEndpointUrl(params) { - return (params && params.qa && params.qa.url) || (Reporter.getPageProtocol() + CONSTANTS.ENDPOINT_URL); - }, - - /** - * Adjust bid params to fyber-ad-server params - * @param {Object} bid - * @return {Object} bid - */ - toBidParams(bid) { - const bidParamsWithCustomParams = Object.assign({}, bid.params, bid.params.customParams); - delete bidParamsWithCustomParams.customParams; - bid.params = this.objectToCamel(bidParamsWithCustomParams); - return bid; - }, - - /** - * Validate if response is valid - * @param responseAsJson : object - * @param headersData: {} - * @returns {boolean} - * @private - */ - isValidBidResponse(responseAsJson, headersData) { - return (responseAsJson && responseAsJson.ad && responseAsJson.ad.html && headersData && headersData[CONSTANTS.RESPONSE_HEADERS_NAME.PRICING_VALUE] > 0); - } -}; - -/** - * Url generator - generates a request URL - * @type {{defaultsParams: *, serverParamNameBySettingParamName: {referrer: string, keywords: string, appId: string, portal: string, age: string, gender: string, isSecured: (boolean|null)}, toServerParams: (function(*)), unwantedValues: *[], getUrlParams: (function(*=))}} - */ -const Url = { - defaultsParams: Object.assign({}, Helpers.defaultsQsParams, {f: CONSTANTS.DISPLAY_AD, fs: false, ref: getTopWindowReferrer()}), - serverParamNameBySettingParamName: { - referrer: 'ref', - keywords: 'k', - appId: 'aid', - portal: 'po', - age: 'a', - gender: 'g', - gdprPrivacyConsent: 'gdpr_privacy_consent', - consentString: 'consent_string', - gdprConsentData: 'gdpr_consent_data' - }, - unwantedValues: ['', null, undefined], - - /** - * Maps publisher params to server params - * @param params: object {k:v} - * @returns object {k:v} - */ - toServerParams(params) { - const serverParams = {}; - for (const paramName in params) { - if (params.hasOwnProperty(paramName) && this.serverParamNameBySettingParamName.hasOwnProperty(paramName)) { - serverParams[this.serverParamNameBySettingParamName[paramName]] = params[paramName]; - } else { - serverParams[paramName] = params[paramName]; - } - } - - serverParams.isSecured = Reporter.getPageProtocol() === 'https:' || null; - return serverParams; - }, - - handleGDPR(params) { - if (params.hasOwnProperty('gdprPrivacyConsent')) { - if (['true', true, '1', 1].indexOf(params.gdprPrivacyConsent) !== -1) { - params.gdprPrivacyConsent = 1; - } else { - params.gdprPrivacyConsent = 0; - } - } - }, - - /** - * Prepare querty string to ad server - * @param params: object {k:v} - * @returns : object {k:v} - */ - getUrlParams(params) { - this.handleGDPR(params); - const serverParams = this.toServerParams(params); - const toQueryString = Object.assign({}, this.defaultsParams, serverParams); - for (const paramName in toQueryString) { - if (toQueryString.hasOwnProperty(paramName) && this.unwantedValues.indexOf(toQueryString[paramName]) !== -1) { - delete toQueryString[paramName]; - } - } - toQueryString.fs = params.spotType === CONSTANTS.SPOT_TYPES.INTERSTITIAL; - - if (params.spotType === CONSTANTS.SPOT_TYPES.RECTANGLE) { - toQueryString.rw = CONSTANTS.RECTANGLE_SIZE.W; - toQueryString.rh = CONSTANTS.RECTANGLE_SIZE.H; - } - toQueryString.bco = config.getConfig('cbTimeout') || config.getConfig('bidderTimeout'); - toQueryString.timestamp = Date.now(); - delete toQueryString.qa; - return toQueryString; - } -}; - -/** - * Analytics - * @type {{errorEventName: string, pageProtocol: string, getPageProtocol: (function(): string), getEventUrl: (function(*, *=)), defaults: {v: (string|string), page: string, mw: boolean, hb: string}, eventQueryStringParams: (function(Object): string)}} - */ -const Reporter = { - /** - * @private - */ - errorEventName: 'HBPreBidError', - pageProtocol: '', - defaults: Helpers.defaultsQsParams, - - /** - * Gets the page protocol based on the document.location.protocol - * The returned string is either http:// or https:// - * @return {string} - */ - getPageProtocol() { - if (!this.pageProtocol) { - this.pageProtocol = (getTopWindowLocation().protocol === 'http:' ? 'http:' : 'https:'); - } - return this.pageProtocol; - }, - - getEventUrl(evtName, extraDetails) { - let eventsEndpoint = CONSTANTS.EVENTS_ENDPOINT_URL + '?table=' + ((evtName === this.errorEventName) ? 'mbwError' : 'mbwEvent'); - let queryStringParams = this.eventQueryStringParams(extraDetails); - const appId = extraDetails && extraDetails.appId; - let queryStringParamsWithAID = `${queryStringParams}&aid=${appId}_${evtName}_other&evtName=${evtName}`; - return eventsEndpoint + '&' + queryStringParamsWithAID; - }, - - /** - * Fyber Event Reporting Query String Parameters, not including App Id. - * @param {object} extraDetails - e.g., a JS exception JSON object. - * @return {string} Fyber event contcatenated queryString parameters. - */ - eventQueryStringParams(extraDetails) { - const toQS = Object.assign({}, this.defaults, {realAppId: extraDetails && extraDetails.appId, timestamp: Date.now()}); - Url.handleGDPR(toQS); - return formatQS(toQS); - } -}; -const {PRICING_VALUE, AD_W, AD_H, CREATIVE_ID, CURRENCY, TIMEOUT} = CONSTANTS.RESPONSE_HEADERS_NAME; -/** - * Http helper to extract metadata - * @type {{headers: *[], getBidHeaders: (function(*))}} - */ -const Http = { - headerNames: [PRICING_VALUE, AD_W, AD_H, CREATIVE_ID, CURRENCY, TIMEOUT], - - /** - * Extract headers data - * @param responseHeaders: XMLHttpRequest - * @return {} - */ - getBidHeaders(responseHeaders) { - const headersData = {}; - this.headerNames.forEach(headerName => headersData[headerName] = responseHeaders.get(headerName)); - return headersData; - } -}; - -const bidByBidId = {}; -class FyberBid { - constructor(headersData, response, bid) { - this.handleGDPR(response.config.tracking, bid.params); - const [w, h] = bid.sizes[0]; - this.cpm = ((bid.params.qa && bid.params.qa.cpm) || headersData[PRICING_VALUE]) * 1000; - this.requestId = bid.bidId; - this.width = parseFloat(headersData[AD_W]) || w; - this.ad = Helpers.getAd(response.ad.html, response.config.tracking, bid.params); - this.height = parseFloat(headersData[AD_H]) || h; - this.creativeId = headersData[CREATIVE_ID]; - this.currency = headersData[CURRENCY] || 'USD'; - this.netRevenue = true; - this.ttl = 60 * (headersData[TIMEOUT] || 20); - this.dealId = null; - } - - handleGDPR(tracking, params) { - if (params.hasOwnProperty('gdprPrivacyConsent')) { - if (['true', true, '1', 1].indexOf(params.gdprPrivacyConsent) !== -1) { - params.gdprPrivacyConsent = 1; - } else { - params.gdprPrivacyConsent = 0; - } - Object.keys(tracking).forEach((trackName) => { - if (Array.isArray(tracking[trackName])) { - tracking[trackName].forEach((url, index) => { - if (url) { - if (url.indexOf('?') === -1) { - url += '?'; - } - url += '&gdpr_privacy_consent=' + params.gdprPrivacyConsent; - tracking[trackName][index] = url; - } - }); - } - }); - } - } -} - -export const spec = { - code: CONSTANTS.CODE, - - /** - * Determines whether or not the given bid request is valid. - * Valid bid request must have appId and spotType - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid(bid) { - const {appId, spotType} = Helpers.objectToCamel(bid.params); - const isValid = !!(appId && spotType); - if (!isValid) { - logError(`bid requires appId = ${appId} , spotType = ${spotType}`); - } - return isValid; - }, - - buildRequests(bidRequests) { - let requests = []; - bidRequests.forEach((bid) => { - bid = Helpers.toBidParams(bid); - bidByBidId[bid.bidId] = bid; - requests.push({ - method: 'GET', - url: Helpers.getEndpointUrl(bid.params), - data: Url.getUrlParams(bid.params), - bidId: bid.bidId - }); - }); - return requests; - }, - - interpretResponse(response, request) { - const isValid = response.body && response.body.ad; - const headersData = (isValid && Http.getBidHeaders(response.headers)) || {}; - const bid = bidByBidId[request.bidId]; - const bidResponse = []; - if (!isValid || !Helpers.isValidBidResponse(response.body, headersData)) { - logError(`response failed for ${CONSTANTS.CODE} adapter`); - return bidResponse; - } - bidResponse.push(new FyberBid(headersData, response.body, bid)); - return bidResponse; - } -}; -registerBidder(spec); diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 926dae14790..5fd3c56b2c6 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -1,7 +1,7 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; -const ENDPOINT = 'hb.gammaplatform.com'; +const ENDPOINT = 'https://hb.gammaplatform.com'; +const ENDPOINT_USERSYNC = 'https://cm-supply-web.gammaplatform.com'; const BIDDER_CODE = 'gamma'; export const spec = { @@ -25,13 +25,14 @@ export const spec = { * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(bidRequests) { + buildRequests: function(bidRequests, bidderRequest) { const serverRequests = []; + const bidderRequestReferer = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || ''; for (var i = 0, len = bidRequests.length; i < len; i++) { const gaxObjParams = bidRequests[i]; serverRequests.push({ method: 'GET', - url: '//' + ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(utils.getTopWindowUrl()) + url: ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(bidderRequestReferer) }); } return serverRequests; @@ -60,7 +61,7 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: '//' + ENDPOINT + '/adx/usersync' + url: ENDPOINT_USERSYNC + '/adx/usersync' }]; } } diff --git a/modules/gamoshiBidAdapter.js b/modules/gamoshiBidAdapter.js index 6d243f155bf..1316d74e430 100644 --- a/modules/gamoshiBidAdapter.js +++ b/modules/gamoshiBidAdapter.js @@ -1,8 +1,8 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {config} from '../src/config'; -import {Renderer} from '../src/Renderer'; -import {BANNER, VIDEO} from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {Renderer} from '../src/Renderer.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; const ENDPOINTS = { 'gamoshi': 'https://rtb.gamoshi.io' @@ -42,17 +42,16 @@ export const helper = { export const spec = { code: 'gamoshi', - aliases: ['gambid', 'cleanmedia', 'viewdeos', 'adastaMedia', '9MediaOnline'], + aliases: ['gambid', 'cleanmedia', '9MediaOnline'], supportedMediaTypes: ['banner', 'video'], isBidRequestValid: function (bid) { - return !!bid.params.supplyPartnerId && - typeof bid.params.supplyPartnerId === 'string' && - (typeof bid.params['rtbEndpoint'] === 'undefined' || typeof bid.params['rtbEndpoint'] === 'string') && - (typeof bid.params.bidfloor === 'undefined' || typeof bid.params.bidfloor === 'number') && - (typeof bid.params['adpos'] === 'undefined' || typeof bid.params['adpos'] === 'number') && - (typeof bid.params['protocols'] === 'undefined' || Array.isArray(bid.params['protocols'])) && - (typeof bid.params.instl === 'undefined' || bid.params.instl === 0 || bid.params.instl === 1); + return !!bid.params.supplyPartnerId && utils.isStr(bid.params.supplyPartnerId) && + (!bid.params['rtbEndpoint'] || utils.isStr(bid.params['rtbEndpoint'])) && + (!bid.params.bidfloor || utils.isNumber(bid.params.bidfloor)) && + (!bid.params['adpos'] || utils.isNumber(bid.params['adpos'])) && + (!bid.params['protocols'] || Array.isArray(bid.params['protocols'])) && + (!bid.params.instl || bid.params.instl === 0 || bid.params.instl === 1); }, buildRequests: function (validBidRequests, bidderRequest) { @@ -63,48 +62,65 @@ export const spec = { let url = config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; const rtbBidRequest = { - 'id': auctionId, - 'site': { - 'domain': helper.getTopWindowDomain(url), - 'page': url, - 'ref': bidderRequest.refererInfo.referer + id: auctionId, + site: { + domain: helper.getTopWindowDomain(url), + page: url, + ref: bidderRequest.refererInfo.referer }, - 'device': { - 'ua': navigator.userAgent + device: { + ua: navigator.userAgent, + dnt: utils.getDNT() ? 1 : 0, + h: screen.height, + w: screen.width, + language: navigator.language }, - 'imp': [], - 'ext': {} + imp: [], + ext: {}, + user: {ext: {}}, + source: {ext: {}}, + regs: {ext: {}} }; + const gdprConsent = bidderRequest.gdprConsent; - if (bidderRequest.gdprConsent && - bidderRequest.gdprConsent.consentString && - bidderRequest.gdprConsent.gdprApplies) { + if (gdprConsent && gdprConsent.consentString && gdprConsent.gdprApplies) { rtbBidRequest.ext.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies + consent_string: gdprConsent.consentString, + consent_required: gdprConsent.gdprApplies }; + + utils.deepSetValue(rtbBidRequest, 'regs.ext.gdpr', gdprConsent.gdprApplies === true ? 1 : 0); + utils.deepSetValue(rtbBidRequest, 'user.ext.consent', gdprConsent.consentString); + } + + if (validBidRequests[0].schain) { + utils.deepSetValue(rtbBidRequest, 'source.ext.schain', validBidRequests[0].schain); + } + + if (bidderRequest && bidderRequest.uspConsent) { + utils.deepSetValue(rtbBidRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); } const imp = { - 'id': transactionId, - 'instl': params.instl === 1 ? 1 : 0, - 'tagid': adUnitCode, - 'bidfloor': params.bidfloor || 0, - 'bidfloorcur': 'USD', - 'secure': helper.startsWith(utils.getTopWindowUrl().toLowerCase(), 'http://') ? 0 : 1 + id: transactionId, + instl: params.instl === 1 ? 1 : 0, + tagid: adUnitCode, + bidfloor: params.bidfloor || 0, + bidfloorcur: 'USD', + secure: 1 }; const hasFavoredMediaType = params.favoredMediaType && this.supportedMediaTypes.includes(params.favoredMediaType); - if ((!mediaTypes || mediaTypes.banner)) { + if (!mediaTypes || mediaTypes.banner) { if (!hasFavoredMediaType || params.favoredMediaType === BANNER) { const bannerImp = Object.assign({}, imp, { banner: { w: sizes.length ? sizes[0][0] : 300, h: sizes.length ? sizes[0][1] : 250, pos: params.pos || 0, - topframe: helper.getTopFrame() + topframe: utils.inIframe() ? 0 : 1 } }); rtbBidRequest.imp.push(bannerImp); @@ -116,8 +132,6 @@ export const spec = { const playerSize = mediaTypes.video.playerSize || sizes; const videoImp = Object.assign({}, imp, { video: { - w: playerSize ? playerSize[0][0] : 300, - h: playerSize ? playerSize[0][1] : 250, protocols: params.protocols || [1, 2, 3, 4, 5, 6], pos: params.pos || 0, ext: { @@ -125,15 +139,41 @@ export const spec = { } } }); + + if (utils.isArray(playerSize[0])) { + videoImp.video.w = playerSize[0][0]; + videoImp.video.h = playerSize[0][1]; + } else if (utils.isNumber(playerSize[0])) { + videoImp.video.w = playerSize[0]; + videoImp.video.h = playerSize[1]; + } else { + videoImp.video.w = 300; + videoImp.video.h = 250; + } + rtbBidRequest.imp.push(videoImp); } } + let eids = []; + if (bidRequest && bidRequest.userId) { + addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 'ID5ID'); + addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.tdid`), 'adserver.org', 'TDID'); + } + if (eids.length > 0) { + rtbBidRequest.user.ext.eids = eids; + } + if (rtbBidRequest.imp.length === 0) { return; } - return {method: 'POST', url: rtbEndpoint, data: rtbBidRequest, bidRequest}; + return { + method: 'POST', + url: rtbEndpoint, + data: rtbBidRequest, + bidRequest + }; }); }, @@ -176,28 +216,52 @@ export const spec = { return outBids; }, - getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { + getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - const gdprApplies = gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean') ? gdprConsent.gdprApplies : false; - const suffix = gdprApplies ? 'gc=' + encodeURIComponent(gdprConsent.consentString) : 'gc=missing'; + let gdprApplies = false; + let consentString = ''; + let uspConsentString = ''; + + if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { + gdprApplies = gdprConsent.gdprApplies; + } + let gdpr = gdprApplies ? 1 : 0; + + if (gdprApplies && gdprConsent.consentString) { + consentString = encodeURIComponent(gdprConsent.consentString) + } + + if (uspConsent) { + uspConsentString = encodeURIComponent(uspConsent); + } + + const macroValues = { + gdpr: gdpr, + consent: consentString, + uspConsent: uspConsentString + }; + serverResponses.forEach(resp => { if (resp.body) { const bidResponse = resp.body; if (bidResponse.ext && Array.isArray(bidResponse.ext['utrk'])) { - bidResponse.ext['utrk'].forEach(pixel => { - const url = pixel.url + (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix); - return syncs.push({type: pixel.type, url}); - }); + bidResponse.ext['utrk'] + .forEach(pixel => { + const url = replaceMacros(pixel.url, macroValues); + syncs.push({type: pixel.type, url}); + }); } + if (Array.isArray(bidResponse.seatbid)) { bidResponse.seatbid.forEach(seatBid => { if (Array.isArray(seatBid.bid)) { seatBid.bid.forEach(bid => { if (bid.ext && Array.isArray(bid.ext['utrk'])) { - bid.ext['utrk'].forEach(pixel => { - const url = pixel.url + (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix); - return syncs.push({type: pixel.type, url}); - }); + bid.ext['utrk'] + .forEach(pixel => { + const url = replaceMacros(pixel.url, macroValues); + syncs.push({type: pixel.type, url}); + }); } }); } @@ -205,13 +269,14 @@ export const spec = { } } }); + return syncs; } }; function newRenderer(bidRequest, bid, rendererOptions = {}) { const renderer = Renderer.install({ - url: (bidRequest.params && bidRequest.params.rendererUrl) || (bid.ext && bid.ext.renderer_url) || '//s.wlplayer.com/video/latest/renderer.js', + url: (bidRequest.params && bidRequest.params.rendererUrl) || (bid.ext && bid.ext.renderer_url) || 'https://s.gamoshi.io/video/latest/renderer.js', config: rendererOptions, loaded: false, }); @@ -243,4 +308,25 @@ function renderOutstream(bid) { }); } +function addExternalUserId(eids, value, source, rtiPartner) { + if (utils.isStr(value)) { + eids.push({ + source, + uids: [{ + id: value, + ext: { + rtiPartner + } + }] + }); + } +} + +function replaceMacros(url, macros) { + return url + .replace('[GDPR]', macros.gdpr) + .replace('[CONSENT]', macros.consent) + .replace('[US_PRIVACY]', macros.uspConsent); +} + registerBidder(spec); diff --git a/modules/gdprEnforcement.js b/modules/gdprEnforcement.js new file mode 100644 index 00000000000..363d0e396f8 --- /dev/null +++ b/modules/gdprEnforcement.js @@ -0,0 +1,218 @@ +/** + * This module gives publishers extra set of features to enforce individual purposes of TCF v2 + */ + +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { hasDeviceAccess } from '../src/utils.js'; +import adapterManager, { gdprDataHandler } from '../src/adapterManager.js'; +import find from 'core-js/library/fn/array/find.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import { registerSyncInner } from '../src/adapters/bidderFactory.js'; +import { getHook } from '../src/hook.js'; +import { validateStorageEnforcement } from '../src/storageManager.js'; + +const purpose1 = 'storage'; + +let addedDeviceAccessHook = false; +let enforcementRules; + +function getGvlid() { + let gvlid; + const bidderCode = config.getCurrentBidder(); + if (bidderCode) { + const bidder = adapterManager.getBidAdapter(bidderCode); + gvlid = bidder.getSpec().gvlid; + } else { + utils.logWarn('Current module not found'); + } + return gvlid; +} + +/** + * This function takes in rules and consentData as input and validates against the consentData provided. If it returns true Prebid will allow the next call else it will log a warning + * @param {Object} rules enforcement rules set in config + * @param {Object} consentData gdpr consent data + * @returns {boolean} + */ +function validateRules(rule, consentData, currentModule, gvlid) { + let isAllowed = false; + if (!rule.vendorExceptions) rule.vendorExceptions = []; + if (rule.enforcePurpose && rule.enforceVendor) { + if ( + includes(rule.vendorExceptions, currentModule) || + ( + utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true && + utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true + ) + ) { + isAllowed = true; + } + } else if (rule.enforcePurpose === false && rule.enforceVendor === true) { + if ( + includes(rule.vendorExceptions, currentModule) || + ( + utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true + ) + ) { + isAllowed = true; + } + } else if (rule.enforcePurpose === false && rule.enforceVendor === false) { + if ( + !includes(rule.vendorExceptions, currentModule) || + ( + (utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true) && + (utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true) + ) + ) { + isAllowed = true; + } + } else if (rule.enforcePurpose === true && rule.enforceVendor === false) { + if ( + (utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true) && + ( + !includes(rule.vendorExceptions, currentModule) || + (utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true) + ) + ) { + isAllowed = true; + } + } + return isAllowed; +} + +/** + * This hook checks whether module has permission to access device or not. Device access include cookie and local storage + * @param {Function} fn reference to original function (used by hook logic) + * @param {Number=} gvlid gvlid of the module + * @param {string=} moduleName name of the module + */ +export function deviceAccessHook(fn, gvlid, moduleName, result) { + result = Object.assign({}, { + hasEnforcementHook: true + }); + if (!hasDeviceAccess()) { + utils.logWarn('Device access is disabled by Publisher'); + result.valid = false; + fn.call(this, gvlid, moduleName, result); + } else { + const consentData = gdprDataHandler.getConsentData(); + if (consentData && consentData.gdprApplies) { + if (consentData.apiVersion === 2) { + if (!gvlid) { + gvlid = getGvlid(); + } + const curModule = moduleName || config.getCurrentBidder(); + const purpose1Rule = find(enforcementRules, hasPurpose1); + let isAllowed = validateRules(purpose1Rule, consentData, curModule, gvlid); + if (isAllowed) { + result.valid = true; + fn.call(this, gvlid, moduleName, result); + } else { + utils.logWarn(`User denied Permission for Device access for ${curModule}`); + result.valid = false; + fn.call(this, gvlid, moduleName, result); + } + } else { + utils.logInfo('Enforcing TCF2 only'); + result.valid = true; + fn.call(this, gvlid, moduleName, result); + } + } else { + result.valid = true; + fn.call(this, gvlid, moduleName, result); + } + } +} + +/** + * This hook checks if a bidder has consent for user sync or not + * @param {Function} fn reference to original function (used by hook logic) + * @param {...any} args args + */ +export function userSyncHook(fn, ...args) { + const consentData = gdprDataHandler.getConsentData(); + if (consentData && consentData.gdprApplies) { + if (consentData.apiVersion === 2) { + const gvlid = getGvlid(); + const curBidder = config.getCurrentBidder(); + if (gvlid) { + const purpose1Rule = find(enforcementRules, hasPurpose1); + let isAllowed = validateRules(purpose1Rule, consentData, curBidder, gvlid); + if (isAllowed) { + fn.call(this, ...args); + } else { + utils.logWarn(`User sync not allowed for ${curBidder}`); + } + } else { + utils.logWarn(`User sync not allowed for ${curBidder}`); + } + } else { + utils.logInfo('Enforcing TCF2 only'); + fn.call(this, ...args); + } + } else { + fn.call(this, ...args); + } +} + +/** + * This hook checks if user id module is given consent or not + * @param {Function} fn reference to original function (used by hook logic) + * @param {Submodule[]} submodules Array of user id submodules + * @param {Object} consentData GDPR consent data + */ +export function userIdHook(fn, submodules, consentData) { + if (consentData && consentData.gdprApplies) { + if (consentData.apiVersion === 2) { + let userIdModules = submodules.map((submodule) => { + const gvlid = submodule.submodule.gvlid; + const moduleName = submodule.submodule.name; + if (gvlid) { + const purpose1Rule = find(enforcementRules, hasPurpose1); + let isAllowed = validateRules(purpose1Rule, consentData, moduleName, gvlid); + if (isAllowed) { + return submodule; + } else { + utils.logWarn(`User denied permission to fetch user id for ${moduleName} User id module`); + } + } else { + utils.logWarn(`User denied permission to fetch user id for ${moduleName} User id module`); + } + return undefined; + }).filter(module => module) + fn.call(this, userIdModules, consentData); + } else { + utils.logInfo('Enforcing TCF2 only'); + fn.call(this, submodules, consentData); + } + } else { + fn.call(this, submodules, consentData); + } +} + +const hasPurpose1 = (rule) => { return rule.purpose === purpose1 } + +/** + * A configuration function that initializes some module variables, as well as add hooks + * @param {Object} config GDPR enforcement config object + */ +export function setEnforcementConfig(config) { + const rules = utils.deepAccess(config, 'gdpr.rules'); + if (!rules) { + utils.logWarn('GDPR enforcement rules not defined, exiting enforcement module'); + return; + } + + enforcementRules = rules; + const hasDefinedPurpose1 = find(enforcementRules, hasPurpose1); + if (hasDefinedPurpose1 && !addedDeviceAccessHook) { + addedDeviceAccessHook = true; + validateStorageEnforcement.before(deviceAccessHook, 49); + registerSyncInner.before(userSyncHook, 48); + // Using getHook as user id and gdprEnforcement are both optional modules. Using import will auto include the file in build + getHook('validateGdprEnforcement').before(userIdHook, 47); + } +} + +config.getConfig('consentManagement', config => setEnforcementConfig(config.consentManagement)); diff --git a/modules/getintentBidAdapter.js b/modules/getintentBidAdapter.js index bc2ed093665..134dd0b4fc9 100644 --- a/modules/getintentBidAdapter.js +++ b/modules/getintentBidAdapter.js @@ -1,5 +1,5 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { isInteger } from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { isInteger } from '../src/utils.js'; const BIDDER_CODE = 'getintent'; const IS_NET_REVENUE = true; @@ -83,7 +83,7 @@ export const spec = { } function buildUrl(bid) { - return '//' + BID_HOST + (bid.is_video ? BID_VIDEO_PATH : BID_BANNER_PATH); + return 'https://' + BID_HOST + (bid.is_video ? BID_VIDEO_PATH : BID_BANNER_PATH); } /** diff --git a/modules/giantsBidAdapter.js b/modules/giantsBidAdapter.js deleted file mode 100644 index e2693392578..00000000000 --- a/modules/giantsBidAdapter.js +++ /dev/null @@ -1,343 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import includes from 'core-js/library/fn/array/includes'; - -const BIDDER_CODE = 'giants'; -const URL = '//d.admp.io/hb'; -const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', - 'startdelay', 'skippable', 'playback_method', 'frameworks']; -const NATIVE_MAPPING = { - body: 'description', - cta: 'ctatext', - image: { - serverName: 'main_image', - requiredParams: { required: true }, - minimumParams: { sizes: [{}] }, - }, - icon: { - serverName: 'icon', - requiredParams: { required: true }, - minimumParams: { sizes: [{}] }, - }, - sponsoredBy: 'sponsored_by', -}; -const SOURCE = 'pbjs'; - -export const spec = { - code: BIDDER_CODE, - aliases: [], - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!(bid.params.zoneId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(bidRequests, bidderRequest) { - const tags = bidRequests.map(bidToTag); - // const zoneIds = bidRequests.map(bidToZoneId); - // var firstBid = bidRequests[0]; - var ref = utils.getTopWindowUrl(); - const url = URL + '/multi?url=' + ref; - // + '&callback=window.$$PREBID_GLOBAL$$.giantsResponse&callback_uid=' + bid.bidId; - - const payload = { - tags: [...tags], - // user: userObj, - sdk: { - source: SOURCE, - version: '$prebid.version$' - } - }; - // if (member > 0) { - // payload.member_id = member; - // } - - if (bidderRequest && bidderRequest.gdprConsent) { - // note - objects for impbus use underscore instead of camelCase - payload.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - } - - const payloadString = JSON.stringify(payload); - - return { - method: 'POST', - // url: URL, - url: url, - data: payloadString, - bidderRequest - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, {bidderRequest}) { - serverResponse = serverResponse.body; - const bids = []; - if (!serverResponse || serverResponse.error) { - let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`; - if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; } - utils.logError(errorMessage); - return bids; - } - if (serverResponse.tags) { - serverResponse.tags.forEach(serverBid => { - if (serverBid.cpm && serverBid.cpm !== 0) { - const bid = newBid(serverBid, bidderRequest); - bid.mediaType = BANNER; - bids.push(bid); - } - }); - } - return bids; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: '//d.admp.io/ping' - }]; - } - } -} - -/* Turn keywords parameter into ut-compatible format */ -function getKeywords(keywords) { - let arrs = []; - - utils._each(keywords, (v, k) => { - if (utils.isArray(v)) { - let values = []; - utils._each(v, (val) => { - val = utils.getValueString('keywords.' + k, val); - if (val) { values.push(val); } - }); - v = values; - } else { - v = utils.getValueString('keywords.' + k, v); - if (utils.isStr(v)) { - v = [v]; - } else { - return; - } // unsuported types - don't send a key - } - arrs.push({key: k, value: v}); - }); - - return arrs; -} - -/** - * Unpack the Server's Bid into a Prebid-compatible one. - * @param serverBid - * @param rtbBid - * @param bidderRequest - * @return Bid - */ -function newBid(serverBid, bidderRequest) { - const bid = { - requestId: serverBid.uuid, - cpm: serverBid.cpm, - creativeId: serverBid.creative_id, - // dealId: rtbBid.deal_id, - currency: 'USD', - netRevenue: true, - ttl: 300 - }; - - Object.assign(bid, { - width: serverBid.width, - height: serverBid.height, - // ad: serverBid.ad - ad: _renderCreative(serverBid.adUrl, serverBid.width, serverBid.height) - }); - // try { - // const url = rtbBid.rtb.trackers[0].impression_urls[0]; - // const tracker = utils.createTrackPixelHtml(url); - // bid.ad += tracker; - // } catch (error) { - // utils.logError('Error appending tracking pixel', error); - // } - - return bid; -} - -function bidToTag(bid) { - const tag = {}; - tag.sizes = transformSizes(bid.sizes); - tag.primary_size = tag.sizes[0]; - tag.ad_types = []; - tag.uuid = bid.bidId; - if (bid.params.zoneId) { - tag.id = bid.params.zoneId; - } else { - tag.code = bid.params.invCode; - } - tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; - tag.use_pmt_rule = bid.params.usePaymentRule || false - tag.prebid = true; - tag.disable_psa = true; - if (bid.params.reserve) { - tag.reserve = bid.params.reserve; - } - if (bid.params.position) { - tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0; - } - if (bid.params.trafficSourceCode) { - tag.traffic_source_code = bid.params.trafficSourceCode; - } - if (bid.params.privateSizes) { - tag.private_sizes = transformSizes(bid.params.privateSizes); - } - if (bid.params.supplyType) { - tag.supply_type = bid.params.supplyType; - } - if (bid.params.pubClick) { - tag.pubclick = bid.params.pubClick; - } - if (bid.params.extInvCode) { - tag.ext_inv_code = bid.params.extInvCode; - } - if (bid.params.externalImpId) { - tag.external_imp_id = bid.params.externalImpId; - } - if (!utils.isEmpty(bid.params.keywords)) { - tag.keywords = getKeywords(bid.params.keywords); - } - - if (bid.mediaType === NATIVE || utils.deepAccess(bid, `mediaTypes.${NATIVE}`)) { - tag.ad_types.push(NATIVE); - - if (bid.nativeParams) { - const nativeRequest = buildNativeRequest(bid.nativeParams); - tag[NATIVE] = {layouts: [nativeRequest]}; - } - } - - const videoMediaType = utils.deepAccess(bid, `mediaTypes.${VIDEO}`); - const context = utils.deepAccess(bid, 'mediaTypes.video.context'); - - if (bid.mediaType === VIDEO || videoMediaType) { - tag.ad_types.push(VIDEO); - } - - // instream gets vastUrl, outstream gets vastXml - if (bid.mediaType === VIDEO || (videoMediaType && context !== 'outstream')) { - tag.require_asset_url = true; - } - - if (bid.params.video) { - tag.video = {}; - // place any valid video params on the tag - Object.keys(bid.params.video) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => tag.video[param] = bid.params.video[param]); - } - - if ( - (utils.isEmpty(bid.mediaType) && utils.isEmpty(bid.mediaTypes)) || - (bid.mediaType === BANNER || (bid.mediaTypes && bid.mediaTypes[BANNER])) - ) { - tag.ad_types.push(BANNER); - } - - return tag; -} - -// function bidToZoneId(bid) { -// return bid.params.zoneId; -// } - -/* Turn bid request sizes into ut-compatible format */ -function transformSizes(requestSizes) { - let sizes = []; - let sizeObj = {}; - - if (utils.isArray(requestSizes) && requestSizes.length === 2 && - !utils.isArray(requestSizes[0])) { - sizeObj.width = parseInt(requestSizes[0], 10); - sizeObj.height = parseInt(requestSizes[1], 10); - sizes.push(sizeObj); - } else if (typeof requestSizes === 'object') { - for (let i = 0; i < requestSizes.length; i++) { - let size = requestSizes[i]; - sizeObj = {}; - sizeObj.width = parseInt(size[0], 10); - sizeObj.height = parseInt(size[1], 10); - sizes.push(sizeObj); - } - } - - return sizes; -} - -function buildNativeRequest(params) { - const request = {}; - - // map standard prebid native asset identifier to /ut parameters - // e.g., tag specifies `body` but /ut only knows `description`. - // mapping may be in form {tag: ''} or - // {tag: {serverName: '', requiredParams: {...}}} - Object.keys(params).forEach(key => { - // check if one of the forms is used, otherwise - // a mapping wasn't specified so pass the key straight through - const requestKey = - (NATIVE_MAPPING[key] && NATIVE_MAPPING[key].serverName) || - NATIVE_MAPPING[key] || - key; - - // required params are always passed on request - const requiredParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].requiredParams; - request[requestKey] = Object.assign({}, requiredParams, params[key]); - - // minimum params are passed if no non-required params given on adunit - const minimumParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].minimumParams; - - if (requiredParams && minimumParams) { - // subtract required keys from adunit keys - const adunitKeys = Object.keys(params[key]); - const requiredKeys = Object.keys(requiredParams); - const remaining = adunitKeys.filter(key => !includes(requiredKeys, key)); - - // if none are left over, the minimum params needs to be sent - if (remaining.length === 0) { - request[requestKey] = Object.assign({}, request[requestKey], minimumParams); - } - } - }); - - return request; -} - -function _renderCreative(adUrl, width, height) { - return ` - - - - `; } -/** - * Returns iframe document in a browser agnostic way - * @param {Object} iframe reference - * @return {Object} iframe `document` reference - */ -export function getIframeDocument(iframe) { - if (!iframe) { - return; - } - - let doc; - try { - if (iframe.contentWindow) { - doc = iframe.contentWindow.document; - } else if (iframe.contentDocument.document) { - doc = iframe.contentDocument.document; - } else { - doc = iframe.contentDocument; - } - } catch (e) { - internal.logError('Cannot get iframe document', e); - } - - return doc; -} - export function getValueString(param, val, defaultValue) { if (val === undefined || val === null) { return defaultValue; @@ -865,16 +689,6 @@ export function adUnitsFilter(filter, bid) { return includes(filter, bid && bid.adUnitCode); } -/** - * Check if parent iframe of passed document supports content rendering via 'srcdoc' property - * @param {HTMLDocument} doc document to check support of 'srcdoc' - */ -export function isSrcdocSupported(doc) { - // Firefox is excluded due to https://bugzilla.mozilla.org/show_bug.cgi?id=1265961 - return doc.defaultView && doc.defaultView.frameElement && - 'srcdoc' in doc.defaultView.frameElement && !/firefox/i.test(navigator.userAgent); -} - export function deepClone(obj) { return clone(obj); } @@ -888,7 +702,7 @@ export function inIframe() { } export function isSafariBrowser() { - return /^((?!chrome|android).)*safari/i.test(navigator.userAgent); + return /^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent); } export function replaceAuctionPrice(str, cpm) { @@ -900,37 +714,20 @@ export function timestamp() { return new Date().getTime(); } -export function checkCookieSupport() { - if (window.navigator.cookieEnabled || !!document.cookie.length) { - return true; - } -} -export function cookiesAreEnabled() { - if (internal.checkCookieSupport()) { - return true; - } - window.document.cookie = 'prebid.cookieTest'; - return window.document.cookie.indexOf('prebid.cookieTest') != -1; -} - -export function getCookie(name) { - let m = window.document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]*)\\s*(;|$)'); - return m ? decodeURIComponent(m[2]) : null; -} - -export function setCookie(key, value, expires) { - document.cookie = `${key}=${encodeURIComponent(value)}${(expires !== '') ? `; expires=${expires}` : ''}; path=/`; +/** + * When the deviceAccess flag config option is false, no cookies should be read or set + * @returns {boolean} + */ +export function hasDeviceAccess() { + return config.getConfig('deviceAccess') !== false; } /** - * @returns {boolean} + * @returns {(boolean|undefined)} */ -export function localStorageIsEnabled () { - try { - localStorage.setItem('prebid.cookieTest', '1'); - return localStorage.getItem('prebid.cookieTest') === '1'; - } catch (error) { - return false; +export function checkCookieSupport() { + if (window.navigator.cookieEnabled || !!document.cookie.length) { + return true; } } @@ -954,7 +751,7 @@ export function delayExecution(func, numRequiredCalls) { return function () { numCalls++; if (numCalls === numRequiredCalls) { - func.apply(null, arguments); + func.apply(this, arguments); } } } @@ -973,19 +770,6 @@ export function groupBy(xs, key) { }, {}); } -/** - * Returns content for a friendly iframe to execute a URL in script tag - * @param {string} url URL to be executed in a script tag in a friendly iframe - * and are macros left to be replaced if required - */ -export function createContentToExecuteExtScriptInFriendlyFrame(url) { - if (!url) { - return ''; - } - - return ``; -} - /** * Build an object consisting of only defined parameters to avoid creating an * object with defined keys and undefined values. @@ -1088,6 +872,24 @@ export function isSlotMatchingAdUnitCode(adUnitCode) { return (slot) => compareCodeAndSlot(slot, adUnitCode); } +/** + * @summary Uses the adUnit's code in order to find a matching gptSlot on the page + */ +export function getGptSlotInfoForAdUnitCode(adUnitCode) { + let matchingSlot; + if (isGptPubadsDefined()) { + // find the first matching gpt slot on the page + matchingSlot = find(window.googletag.pubads().getSlots(), isSlotMatchingAdUnitCode(adUnitCode)); + } + if (matchingSlot) { + return { + gptSlot: matchingSlot.getAdUnitPath(), + divId: matchingSlot.getSlotElementId() + } + } + return {}; +}; + /** * Constructs warning message for when unsupported bidders are dropped from an adunit * @param {Object} adUnit ad unit from which the bidder is being dropped @@ -1104,18 +906,6 @@ export function unsupportedBidderMessage(adUnit, bidder) { `; } -/** - * Delete property from object - * @param {Object} object - * @param {string} prop - * @return {Object} object - */ -export function deletePropertyFromObject(object, prop) { - let result = Object.assign({}, object); - delete result[prop]; - return result; -} - /** * Checks input is integer or not * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger @@ -1252,26 +1042,6 @@ export function convertTypes(types, params) { return params; } -export function setDataInLocalStorage(key, value) { - if (hasLocalStorage()) { - window.localStorage.setItem(key, value); - } -} - -export function getDataFromLocalStorage(key) { - if (hasLocalStorage()) { - return window.localStorage.getItem(key); - } -} - -export function hasLocalStorage() { - try { - return !!window.localStorage; - } catch (e) { - logError('Local storage api disabled'); - } -} - export function isArrayOfNums(val, size) { return (isArray(val)) && ((size) ? val.length === size : true) && (val.every(v => isInteger(v))); } @@ -1334,3 +1104,93 @@ export function compareOn(property) { return 0; } } + +export function parseQS(query) { + return !query ? {} : query + .replace(/^\?/, '') + .split('&') + .reduce((acc, criteria) => { + let [k, v] = criteria.split('='); + if (/\[\]$/.test(k)) { + k = k.replace('[]', ''); + acc[k] = acc[k] || []; + acc[k].push(v); + } else { + acc[k] = v || ''; + } + return acc; + }, {}); +} + +export function formatQS(query) { + return Object + .keys(query) + .map(k => Array.isArray(query[k]) + ? query[k].map(v => `${k}[]=${v}`).join('&') + : `${k}=${query[k]}`) + .join('&'); +} + +export function parseUrl(url, options) { + let parsed = document.createElement('a'); + if (options && 'noDecodeWholeURL' in options && options.noDecodeWholeURL) { + parsed.href = url; + } else { + parsed.href = decodeURIComponent(url); + } + // in window.location 'search' is string, not object + let qsAsString = (options && 'decodeSearchAsString' in options && options.decodeSearchAsString); + return { + href: parsed.href, + protocol: (parsed.protocol || '').replace(/:$/, ''), + hostname: parsed.hostname, + port: +parsed.port, + pathname: parsed.pathname.replace(/^(?!\/)/, '/'), + search: (qsAsString) ? parsed.search : internal.parseQS(parsed.search || ''), + hash: (parsed.hash || '').replace(/^#/, ''), + host: parsed.host || window.location.host + }; +} + +export function buildUrl(obj) { + return (obj.protocol || 'http') + '://' + + (obj.host || + obj.hostname + (obj.port ? `:${obj.port}` : '')) + + (obj.pathname || '') + + (obj.search ? `?${internal.formatQS(obj.search || '')}` : '') + + (obj.hash ? `#${obj.hash}` : ''); +} + +/** + * This function compares two objects for checking their equivalence. + * @param {Object} obj1 + * @param {Object} obj2 + * @returns {boolean} + */ +export function deepEqual(obj1, obj2) { + return deepequal(obj1, obj2); +} + +export function mergeDeep(target, ...sources) { + if (!sources.length) return target; + const source = sources.shift(); + + if (isPlainObject(target) && isPlainObject(source)) { + for (const key in source) { + if (isPlainObject(source[key])) { + if (!target[key]) Object.assign(target, { [key]: {} }); + mergeDeep(target[key], source[key]); + } else if (isArray(source[key])) { + if (!target[key]) { + Object.assign(target, { [key]: source[key] }); + } else if (isArray(target[key])) { + target[key] = target[key].concat(source[key]); + } + } else { + Object.assign(target, { [key]: source[key] }); + } + } + } + + return mergeDeep(target, ...sources); +} diff --git a/src/video.js b/src/video.js index f59ff78a32a..c3deb73ad4d 100644 --- a/src/video.js +++ b/src/video.js @@ -1,11 +1,12 @@ -import adapterManager from './adapterManager'; -import { getBidRequest, deepAccess, logError } from './utils'; -import { config } from '../src/config'; -import includes from 'core-js/library/fn/array/includes'; -import { hook } from './hook'; +import adapterManager from './adapterManager.js'; +import { getBidRequest, deepAccess, logError } from './utils.js'; +import { config } from '../src/config.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import { hook } from './hook.js'; const VIDEO_MEDIA_TYPE = 'video'; export const OUTSTREAM = 'outstream'; +export const INSTREAM = 'instream'; /** * Helper functions for working with video-enabled adUnits diff --git a/src/videoCache.js b/src/videoCache.js index 06847012a6e..46bf74ee553 100644 --- a/src/videoCache.js +++ b/src/videoCache.js @@ -9,8 +9,8 @@ * This trickery helps integrate with ad servers, which set character limits on request params. */ -import { ajax } from './ajax'; -import { config } from '../src/config'; +import { ajax } from './ajax.js'; +import { config } from '../src/config.js'; /** * @typedef {object} CacheableUrlBid @@ -60,12 +60,18 @@ function wrapURI(uri, impUrl) { */ function toStorageRequest(bid) { const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl); + let payload = { type: 'xml', value: vastValue, ttlseconds: Number(bid.ttl) }; + if (config.getConfig('cache.vasttrack')) { + payload.bidder = bid.bidder; + payload.bidid = bid.requestId; + } + if (typeof bid.customCacheKey === 'string' && bid.customCacheKey !== '') { payload.key = bid.customCacheKey; } @@ -94,7 +100,7 @@ function toStorageRequest(bid) { */ function shimStorageCallback(done) { return { - success: function(responseBody) { + success: function (responseBody) { let ids; try { ids = JSON.parse(responseBody).responses @@ -109,7 +115,7 @@ function shimStorageCallback(done) { done(new Error("The cache server didn't respond with a responses property."), []); } }, - error: function(statusText, responseBody) { + error: function (statusText, responseBody) { done(new Error(`Error storing video ad in the cache: ${statusText}: ${JSON.stringify(responseBody)}`), []); } } diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 4cd5a854ac4..842bccd99b1 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -35,6 +35,6 @@ module.exports = { "no-unused-vars": "off", "no-use-before-define": "off", "no-useless-escape": "off", - "one-var": "off", + "one-var": "off" } }; diff --git a/test/fixtures/fixtures.js b/test/fixtures/fixtures.js index 050ff90bc7a..2a0a7638fc4 100644 --- a/test/fixtures/fixtures.js +++ b/test/fixtures/fixtures.js @@ -53,11 +53,14 @@ export function getBidRequests() { 90 ] ], + 'mediaTypes': { + 'banner': { + 'sizes': [[728, 90], [970, 90]] + } + }, 'bidId': '392b5a6b05d648', 'bidderRequestId': '2946b569352ef2', 'auctionId': '1863e370099523', - 'startTime': 1462918897462, - 'status': 1, 'transactionId': 'fsafsa' }, { @@ -76,11 +79,14 @@ export function getBidRequests() { 600 ] ], + 'mediaTypes': { + 'banner': { + 'sizes': [[728, 90], [970, 90]] + } + }, 'bidId': '4dccdc37746135', 'bidderRequestId': '2946b569352ef2', 'auctionId': '1863e370099523', - 'startTime': 1462918897463, - 'status': 1, 'transactionId': 'fsafsa' } ], @@ -108,6 +114,11 @@ export function getBidRequests() { 600 ] ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '6d11aa2d5b3659', 'bidderRequestId': '5e1525bae3eb11', 'auctionId': '1863e370099523', @@ -157,6 +168,11 @@ export function getBidRequests() { 600 ] ], + 'mediaType': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '96aff279720d39', 'bidderRequestId': '8778750ee15a77', 'auctionId': '1863e370099523', @@ -186,10 +202,14 @@ export function getBidRequests() { 600 ] ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '1144e2f0de84363', 'bidderRequestId': '107f5e6e98dcf09', 'auctionId': '1863e370099523', - 'startTime': 1462918897477, 'transactionId': 'fsafsa' } ], @@ -216,10 +236,14 @@ export function getBidRequests() { 600 ] ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '135e89c039705da', 'bidderRequestId': '12eeded736650b4', 'auctionId': '1863e370099523', - 'status': 1, 'transactionId': 'fsafsa' } ], @@ -246,11 +270,14 @@ export function getBidRequests() { 600 ] ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '17dd1d869bed44e', 'bidderRequestId': '167c4d79b615948', 'auctionId': '1863e370099523', - 'startTime': 1462918897480, - 'status': 1, 'transactionId': 'fsafsa' } ], @@ -277,11 +304,14 @@ export function getBidRequests() { 600 ] ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '192c8c1df0f5d1d', 'bidderRequestId': '18bed198c172a69', 'auctionId': '1863e370099523', - 'startTime': 1462918897481, - 'status': 1, 'transactionId': 'fsafsa' } ], @@ -308,6 +338,11 @@ export function getBidRequests() { 600 ] ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '21ae8131ec04f6e', 'bidderRequestId': '20d0d30333715a7', 'auctionId': '1863e370099523', @@ -323,6 +358,7 @@ export function getBidResponses() { return [ { 'bidderCode': 'triplelift', + 'mediaType': 'banner', 'width': 0, 'height': 0, 'statusMessage': 'Bid available', @@ -354,6 +390,7 @@ export function getBidResponses() { }, { 'bidderCode': 'appnexus', + 'mediaType': 'banner', 'width': 300, 'height': 250, 'statusMessage': 'Bid available', @@ -387,6 +424,7 @@ export function getBidResponses() { }, { 'bidderCode': 'appnexus', + 'mediaType': 'banner', 'width': 728, 'height': 90, 'statusMessage': 'Bid available', @@ -420,6 +458,7 @@ export function getBidResponses() { }, { 'bidderCode': 'pagescience', + 'mediaType': 'banner', 'width': 300, 'height': 250, 'statusMessage': 'Bid available', @@ -452,6 +491,7 @@ export function getBidResponses() { }, { 'bidderCode': 'brightcom', + 'mediaType': 'banner', 'width': 300, 'height': 250, 'statusMessage': 'Bid available', @@ -483,6 +523,7 @@ export function getBidResponses() { }, { 'bidderCode': 'brealtime', + 'mediaType': 'banner', 'width': 300, 'height': 250, 'statusMessage': 'Bid available', @@ -515,6 +556,7 @@ export function getBidResponses() { }, { 'bidderCode': 'pubmatic', + 'mediaType': 'banner', 'width': '300', 'height': '250', 'statusMessage': 'Bid available', @@ -548,6 +590,7 @@ export function getBidResponses() { }, { 'bidderCode': 'rubicon', + 'mediaType': 'banner', 'width': 300, 'height': 600, 'statusMessage': 'Bid available', @@ -616,138 +659,54 @@ export function getAdUnits() { return [ { 'code': '/19968336/header-bid-tag1', - 'sizes': [ - [ - 728, - 90 - ], - [ - 970, - 90 - ] - ], + 'mediaTypes': { + 'banner': { + 'sizes': [[728, 90], [970, 90]] + }, + }, 'bids': [ { 'bidder': 'adequant', 'params': { 'publisher_id': '1234567', 'bidfloor': 0.01 - }, - 'adUnitCode': '/19968336/header-bid-tag1', - 'sizes': [ - [ - 728, - 90 - ], - [ - 970, - 90 - ] - ], - 'bidId': '3692954f816efc', - 'bidderRequestId': '2b1a75d5e826c4', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'appnexus', 'params': { 'placementId': '543221', 'test': 'me' - }, - 'adUnitCode': '/19968336/header-bid-tag1', - 'sizes': [ - [ - 728, - 90 - ], - [ - 970, - 90 - ] - ], - 'bidId': '68136e1c47023d', - 'bidderRequestId': '55e24a66bed717', - 'auctionId': '1ff753bd4ae5cb', - 'startTime': 1463510220995, - 'status': 1 + } } ] }, { 'code': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bids': [ { 'bidder': 'appnexus', 'params': { 'placementId': '5324321' - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '7e5d6af25ed188', - 'bidderRequestId': '55e24a66bed717', - 'auctionId': '1ff753bd4ae5cb', - 'startTime': 1463510220996 + } }, { 'bidder': 'adequant', 'params': { 'publisher_id': '12353433', 'bidfloor': 0.01 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '4448d80ac1374e', - 'bidderRequestId': '2b1a75d5e826c4', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'triplelift', 'params': { 'inventoryCode': 'inv_code_here' - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '9514d586c52abf', - 'bidderRequestId': '8c4f03b838d7ee', - 'auctionId': '1ff753bd4ae5cb', - 'startTime': 1463510220997 + } }, { 'bidder': 'springserve', @@ -755,21 +714,7 @@ export function getAdUnits() { 'impId': 1234, 'supplyPartnerId': 1, 'test': true - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '113079fed03f58c', - 'bidderRequestId': '1048e0df882e965', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'rubicon', @@ -795,105 +740,33 @@ export function getAdUnits() { 15, 10 ] - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '13c2c2a79d155ea', - 'bidderRequestId': '129e383ac549e5d', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'openx', 'params': { 'jstag_url': 'http://servedbyopenx.com/w/1.0/jstag?nc=account_key', 'unit': 2345677 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '154f9cbf82df565', - 'bidderRequestId': '1448569c2453b84', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'pubmatic', 'params': { 'publisherId': 1234567, 'adSlot': '1234567@300x250' - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '17f8c3a8fb13308', - 'bidderRequestId': '16095445eeb05e4', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'pagescience', 'params': { 'placementId': '1234567' - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '2074d5757675542', - 'bidderRequestId': '19883380ef5453a', - 'auctionId': '1ff753bd4ae5cb', - 'startTime': 1463510221014 + } }, { 'bidder': 'brealtime', 'params': { 'placementId': '1234567' - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '222b6ad5a9b835d', - 'bidderRequestId': '2163409fdf6f333', - 'auctionId': '1ff753bd4ae5cb', - 'startTime': 1463510221015 + } }, { 'bidder': 'indexExchange', @@ -901,21 +774,7 @@ export function getAdUnits() { 'id': '1', 'siteID': 123456, 'timeout': 10000 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '2499961ab3f937a', - 'bidderRequestId': '23b57a2de4ae50b', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'adform', @@ -923,82 +782,26 @@ export function getAdUnits() { 'adxDomain': 'adx.adform.net', 'mid': 123456, 'test': 1 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '26605265bf5e9c5', - 'bidderRequestId': '25a0902299c17d3', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'amazon', 'params': { 'aId': 3080 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '2935d8f6764fe45', - 'bidderRequestId': '28afa21ca9246c1', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'aol', 'params': { 'network': '112345.45', 'placement': 12345 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '31d1489681dc539', - 'bidderRequestId': '30bf32da9080fdd', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'sovrn', 'params': { 'tagid': '123556' - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '33c1a8028d91563', - 'bidderRequestId': '324bcb47cfcf034', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'pulsepoint', @@ -1006,41 +809,13 @@ export function getAdUnits() { 'cf': '300X250', 'cp': 1233456, 'ct': 12357 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '379219f0506a26f', - 'bidderRequestId': '360ec66bbb0719c', - 'auctionId': '1ff753bd4ae5cb' + } }, { 'bidder': 'brightcom', 'params': { 'tagId': 75423 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '395cfcf496e7d6d', - 'bidderRequestId': '38a776c7f001ea', - 'auctionId': '1ff753bd4ae5cb' + } } ] } @@ -1055,6 +830,7 @@ export function getBidResponsesFromAPI() { 'bidderCode': 'brightcom', 'width': 300, 'height': 250, + 'mediaType': 'banner', 'statusMessage': 'Bid available', 'adId': '26e0795ab963896', 'cpm': 0.17, @@ -1086,6 +862,7 @@ export function getBidResponsesFromAPI() { 'bidderCode': 'brealtime', 'width': 300, 'height': 250, + 'mediaType': 'banner', 'statusMessage': 'Bid available', 'adId': '275bd666f5a5a5d', 'creative_id': 29681110, @@ -1118,6 +895,7 @@ export function getBidResponsesFromAPI() { 'bidderCode': 'pubmatic', 'width': '300', 'height': '250', + 'mediaType': 'banner', 'statusMessage': 'Bid available', 'adId': '28f4039c636b6a7', 'adSlot': '39620189@300x250', @@ -1151,6 +929,7 @@ export function getBidResponsesFromAPI() { 'bidderCode': 'rubicon', 'width': 300, 'height': 600, + 'mediaType': 'banner', 'statusMessage': 'Bid available', 'adId': '29019e2ab586a5a', 'cpm': 2.74, @@ -1484,3 +1263,64 @@ export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, ad } return bid; } + +export function getServerTestingsAds() { + return [ + { + code: 'test_div_1', + sizes: [[728, 90]], + bids: [ + { + 'bidSource': { 'client': 0, 'server': 100 }, + 'bidder': 'rubicon' + }, + { + 'bidSource': { 'client': 100, 'server': 0 }, + 'bidder': 'appnexus' + } + ] + }, + { + code: 'test_div_2', + sizes: [[300, 250]], + bids: [ + { + 'bidSource': { 'client': 100, 'server': 0 }, + 'bidder': 'rubicon' + }, + { + 'bidSource': { 'client': 100, 'server': 0 }, + 'bidder': 'appnexus' + } + ] + }, + { + code: 'test_div_3', + sizes: [[300, 250]], + bids: [{ bidder: 'adequant' }] + }, + { + code: 'test_div_4', + sizes: [[300, 250]], + bids: [{ bidder: 'openx' }] + } + ]; +}; + +export const getServerTestingConfig = (config, override = {}) => + Object.assign({}, config, { + enabled: true, + testing: true, + testServerOnly: true, + bidders: ['appnexus', 'rubicon', 'openx'], + bidderControl: { + rubicon: { + bidSource: { server: 100, client: 0 }, + includeSourceKvp: true + }, + appnexus: { + bidSource: { server: 0, client: 100 }, + includeSourceKvp: true + } + } + }, override); diff --git a/test/mock-server/expectations/request-response-pairs/banner/index.js b/test/mock-server/expectations/request-response-pairs/banner/index.js new file mode 100644 index 00000000000..17538c8b33d --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/banner/index.js @@ -0,0 +1,96 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + * The expecation created here is replicating trafficSourceCode example in Prebid. + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 300, + 'height': 250 + }, { + 'width': 300, + 'height': 600 + }], + 'primary_size': { + 'width': 300, + 'height': 250 + }, + 'ad_types': ['banner'], + 'id': 13144370, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2c8c83a1deaf1a', + 'tag_id': 13144370, + 'auction_id': '8147841645883553832', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Fgpt%2Fhello_world.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKzCKAzBAAAAwDWAAUBCJKPpe4FEKjwl-js2byJcRiq5MnUovf28WEqNgkAAAkCABEJBywAABkAAACA61HgPyEREgApEQkAMREb8GkwsqKiBjjtSEDtSEgAUABYnPFbYABotc95eACAAQGKAQCSAQNVU0SYAawCoAH6AagBAbABALgBAcABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3MzQ3MjE0Nik7AR0scicsIDk2ODQ2MDM1Nh4A8PWSAqUCIXp6ZmhVQWl1c0s0S0VOT0JseTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFzcUtpQmxnQVlJSUNhQUJ3Q0hncWdBRWtpQUVxa0FFQW1BRUFvQUVCcUFFRHNBRUF1UUVwaTRpREFBRGdQOEVCS1l1SWd3QUE0RF9KQVozRkl5WjA1Tm9fMlFFQUFBQUFBQUR3UC1BQkFQVUJBQUFBQUpnQ0FLQUNBTFVDQUFBQUFMMENBQUFBQU9BQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEcnJDdUNyb0RDVk5KVGpNNk5EY3pOZUFEcUJXSUJBQ1FCQUNZQkFIQkIFRQkBCHlRUQkJAQEUTmdFQVBFEY0BkEg0QkFDSUJmOGuaAokBIUl3OTBCOikBJG5QRmJJQVFvQUQROFhEZ1B6b0pVMGxPTXpvME56TTFRS2dWUxFoDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwQGVBQS7CAi9odHRwOi8vcHJlYmlkLm9yZy9kZXYtZG9jcy9nZXR0aW5nLXN0YXJ0ZWQuaHRtbNgCAOACrZhI6gJTDTrYdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2dwdC9oZWxsb193b3JsZAVO8EA_cGJqc19kZWJ1Zz10cnVlgAMAiAMBkAMAmAMXoAMBqgMAwAOsAsgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92Mw248F6YBACiBAsxMC43NS43NC42OagEkECyBBIIBBAEGKwCIPoBKAEoAjAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggA4AQB8ATTgZcuiAUBmAUAoAX______wEDFAHABQDJBWmAFPA_0gUJCQkMcAAA2AUB4AUB8AUB-gUECAAQAJAGAJgGALgGAMEGCSM08L_IBgDQBvUv2gYWChAJFBkBUBAAGADgBgHyBgIIAIAHAYgHAKAHAQ..&s=68cfb6ed042ea47f5d3fc2c32cc068500e542066', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'banner', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 96846035, + 'media_type_id': 1, + 'media_subtype_id': 1, + 'cpm': 0.500000, + 'cpm_publisher_currency': 0.500000, + 'is_bin_price_applied': false, + 'publisher_currency_code': '$', + 'brand_category_id': 0, + 'client_initiated_ad_counting': true, + 'rtb': { + 'banner': { + 'content': "
", + 'width': 300, + 'height': 250 + }, + 'trackers': [{ + 'impression_urls': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Fgpt%2Fhello_world.html%3Fpbjs_debug%3Dtrue&e=wqT_3QK7CKA7BAAAAwDWAAUBCJKPpe4FEKjwl-js2byJcRiq5MnUovf28WEqNgkAAAECCOA_EQEHNAAA4D8ZAAAAgOtR4D8hERIAKREJADERG6gwsqKiBjjtSEDtSEgCUNOBly5YnPFbYABotc95eJK4BYABAYoBA1VTRJIBAQbwUpgBrAKgAfoBqAEBsAEAuAEBwAEEyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTczNDcyMTQ2KTt1ZigncicsIDk2ODQ2MDM1Nh4A8PWSAqUCIXp6ZmhVQWl1c0s0S0VOT0JseTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFzcUtpQmxnQVlJSUNhQUJ3Q0hncWdBRWtpQUVxa0FFQW1BRUFvQUVCcUFFRHNBRUF1UUVwaTRpREFBRGdQOEVCS1l1SWd3QUE0RF9KQVozRkl5WjA1Tm9fMlFFQUFBQUFBQUR3UC1BQkFQVUJBQUFBQUpnQ0FLQUNBTFVDQUFBQUFMMENBQUFBQU9BQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEcnJDdUNyb0RDVk5KVGpNNk5EY3pOZUFEcUJXSUJBQ1FCQUNZQkFIQkIFRQkBCHlRUQkJAQEUTmdFQVBFEY0BkEg0QkFDSUJmOGuaAokBIUl3OTBCOikBJG5QRmJJQVFvQUQROFhEZ1B6b0pVMGxPTXpvME56TTFRS2dWUxFoDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwQGVBQS7CAi9odHRwOi8vcHJlYmlkLm9yZy9kZXYtZG9jcy9nZXR0aW5nLXN0YXJ0ZWQuaHRtbNgCAOACrZhI6gJTDTrYdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2dwdC9oZWxsb193b3JsZAVO8EA_cGJqc19kZWJ1Zz10cnVlgAMAiAMBkAMAmAMXoAMBqgMAwAOsAsgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92Mw248F6YBACiBAsxMC43NS43NC42OagEkECyBBIIBBAEGKwCIPoBKAEoAjAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggB4AQB8ATTgZcuiAUBmAUAoAX______wEDFAHABQDJBWmIFPA_0gUJCQkMcAAA2AUB4AUB8AUB-gUECAAQAJAGAJgGALgGAMEGCSM08D_IBgDQBvUv2gYWChAJFBkBUBAAGADgBgHyBgIIAIAHAYgHAKAHAQ..&s=951a029669a69e3f0c527c937c2d852be92802e1'], + 'video_events': {} + }] + } + }] + }] + }, + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/currency/index.js b/test/mock-server/expectations/request-response-pairs/currency/index.js new file mode 100644 index 00000000000..1f809476afa --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/currency/index.js @@ -0,0 +1,175 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 300, + 'height': 250 + }, { + 'width': 300, + 'height': 600 + }], + 'primary_size': { + 'width': 300, + 'height': 250 + }, + 'ad_types': ['banner'], + 'id': 13144370, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true + }, { + 'sizes': [{ + 'width': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232354, + 'allow_smaller_sizes': true, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'description': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + }, + 'icon': { + 'required': false + } + }] + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '232f6ceccb3749', + 'tag_id': 13144370, + 'auction_id': '4842409943576641356', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmodules%2Fcurrency.html%3Fpbjs_debug%3Dtrue&e=wqT_3QK7CKA7BAAAAwDWAAUBCNvV-_AFEMz-0f3_xeyZQxjCs_b6q5D9_0oqNgkAAAkCABEJBywAABkAAACA61HgPyEREgApEQkAMREb8GkwsqKiBjjtSEDtSEgAUABYnPFbYABotc95eACAAQGKAQCSAQNVU0SYAawCoAHYBKgBAbABALgBAcABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3OTA4NDUwNyk7AR0scicsIDk4NDkzNTgxNh4A8NCSArUCIVpqeldtZ2l1c0s0S0VJM0oteTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFzcUtpQmxnQVlNSUdhQUJ3RG5qd0U0QUJUSWdCOEJPUUFRQ1lBUUNnQVFHb0FRT3dBUUM1QVNtTGlJTUFBT0Ffd1FFcGk0aURBQURnUDhrQmxiMDhGYV9INERfWkFRQUFBQUFBQVBBXzRBRUE5UUVBQUFBQW1BSUFvQUlBdFFJQUFBQUF2UUlBQUFBQTRBSUE2QUlBLUFJQWdBTUJtQU1CcUFPdQHEiHVnTUpVMGxPTXpvME56TTE0QU80R1lnRUFKQUVBSmdFQWNFCV0FAQhESkIFCAkBGDJBUUE4UVEJDQEBLFBnRUFJZ0ZfeVNwQhEXNFBBX5oCiQEhblE4cUxBNjkBJG5QRmJJQVFvQUQRZBBEZ1B6bzKRABBRTGdaUx1NAFURDAxBQUFXHQwAWR0MAGEdDABjHQzwQGVBQS7CAi9odHRwOi8vcHJlYmlkLm9yZy9kZXYtZG9jcy9nZXR0aW5nLXN0YXJ0ZWQuaHRtbNgCAOACrZhI6gJLDTpIdGVzdC5sb2NhbGhvc3Q6OTk5OQUUWC9wYWdlcy9tb2R1bGVzL2N1cnJlbmN5BUbwQD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDbDwXpgEAKIECzEwLjc1Ljc0LjY5qATikAGyBBIIBBAEGKwCIPoBKAEoAjAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggA4AQB8ASNyfsuiAUBmAUAoAX_____BQMYAcAFAMkFAAUBFPA_0gUJCQULfAAAANgFAeAFAfAFmfQh-gUECAAQAJAGAJgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGAfIGAggAgAcBiAcAoAcB&s=16a5ea7c8d5eb050a368495961803753dd6086c2', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'banner', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 98493581, + 'media_type_id': 1, + 'media_subtype_id': 1, + 'cpm': 0.500000, + 'cpm_publisher_currency': 0.500000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'rtb': { + 'banner': { + 'content': "
", + 'width': 300, + 'height': 600 + }, + 'trackers': [{ + 'impression_urls': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmodules%2Fcurrency.html%3Fpbjs_debug%3Dtrue&e=wqT_3QLDCKBDBAAAAwDWAAUBCNvV-_AFEMz-0f3_xeyZQxjCs_b6q5D9_0oqNgkAAAECCOA_EQEHNAAA4D8ZAAAAgOtR4D8hERIAKREJADERG6gwsqKiBjjtSEDtSEgCUI3J-y5YnPFbYABotc95eJ64BYABAYoBA1VTRJIBAQbwUpgBrAKgAdgEqAEBsAEAuAEBwAEEyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5MDg0NTA3KTt1ZigncicsIDk4NDkzNTgxNh4A8NCSArUCIVpqeldtZ2l1c0s0S0VJM0oteTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFzcUtpQmxnQVlNSUdhQUJ3RG5qd0U0QUJUSWdCOEJPUUFRQ1lBUUNnQVFHb0FRT3dBUUM1QVNtTGlJTUFBT0Ffd1FFcGk0aURBQURnUDhrQmxiMDhGYV9INERfWkFRQUFBQUFBQVBBXzRBRUE5UUVBQUFBQW1BSUFvQUlBdFFJQUFBQUF2UUlBQUFBQTRBSUE2QUlBLUFJQWdBTUJtQU1CcUFPdQHEiHVnTUpVMGxPTXpvME56TTE0QU80R1lnRUFKQUVBSmdFQWNFCV0FAQhESkIFCAkBGDJBUUE4UVEJDQEBLFBnRUFJZ0ZfeVNwQhEXNFBBX5oCiQEhblE4cUxBNjkBJG5QRmJJQVFvQUQRZBBEZ1B6bzKRABBRTGdaUx1NAFURDAxBQUFXHQwAWR0MAGEdDABjHQzwQGVBQS7CAi9odHRwOi8vcHJlYmlkLm9yZy9kZXYtZG9jcy9nZXR0aW5nLXN0YXJ0ZWQuaHRtbNgCAOACrZhI6gJLDTpIdGVzdC5sb2NhbGhvc3Q6OTk5OQUUWC9wYWdlcy9tb2R1bGVzL2N1cnJlbmN5BUbwQD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDbDwXpgEAKIECzEwLjc1Ljc0LjY5qATikAGyBBIIBBAEGKwCIPoBKAEoAjAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggB4AQB8ASNyfsuiAUBmAUAoAX_____BQMYAcAFAMkFAAUBFPA_0gUJCQULfAAAANgFAeAFAfAFmfQh-gUECAAQAJAGAJgGALgGAMEGASEwAADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGAfIGAggAgAcBiAcAoAcB&s=9c378bb4ca21a7509f69955fb4e6fe72035190c6'], + 'video_events': {} + }] + } + }] + }, { + 'uuid': '3867e6fdb23eb6', + 'tag_id': 13232354, + 'auction_id': '8100967561168057198', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmodules%2Fcurrency.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKECKAEBAAAAwDWAAUBCNvV-_AFEO7mieO34pq2cBjCs_b6q5D9_0oqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMOLRpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5MDg0NTA3KTsBHSxyJywgOTc0OTQyMDQ2HgDwmpICtQIhMVR6c3lRajgtTHdLRUx6SnZpNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUTR0R25CbGdBWU1JR2FBQndBSGdBZ0FGTWlBSHdFNUFCQUpnQkFLQUJBYWdCQTdBQkFMa0I4NjFxcEFBQUpFREJBZk90YXFRQUFDUkF5UUc5QzZTMEtFampQOWtCQUFBQUFBQUE4RF9nQVFEMUFRAQ8sQ1lBZ0NnQWdDMUFnBRAAOQkI8EBEZ0FnRG9BZ0Q0QWdDQUF3R1lBd0dvQV96NHZBcTZBd2xUU1U0ek9qUTNNelhnQTdnWmlBUUFrQVFBbUFRQndRUQFNCQEITWtFCQkBARhEWUJBRHhCAQsNASwtQVFBaUFYX0pLa0YNEzxBOEQ4LpoCiQEhZUE4dE1BNjkBJG5QRmJJQVFvQUQVWFhrUURvSlUwbE9Nem8wTnpNMVFMZ1pTUQ1PDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQygZUFBLtgCAOACrZhI6gJLaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkFFPDXL3BhZ2VzL21vZHVsZXMvY3VycmVuY3kuaHRtbD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagE4pABsgQOCAAQARgAIAAoADAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggA4AQB8AS8yb4uiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAaVZ0ANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=428486554947609aac96ed5569d9bb2dd2be5502', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97494204, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'desc': 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + 'sponsored': 'Prebid.org', + 'icon': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/1a/3e/e9/5b/1a3ee95b-06cd-4260-98c7-0258627c9197.png', + 'width': 127, + 'height': 83, + 'prevent_crop': false + }, + 'main_img': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'width': 989, + 'height': 742, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-native-ads.html', + 'click_trackers': ['http://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQG5zYnwTa2xwwpldv4L0_0rb6h5eAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoAYBc26wAAAAA./bcr=AAAAAAAA8D8=/cnd=%21eA8tMAj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0NzM1QLgZSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ3MzU=/bn=89118/'] + }, + 'impression_trackers': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmodules%2Fcurrency.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKMCKAMBAAAAwDWAAUBCNvV-_AFEO7mieO34pq2cBjCs_b6q5D9_0oqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXieuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzkwODQ1MDcpO3VmKCdyJywgOTc0OTQyMDQsIC4eAPCakgK1AiExVHpzeVFqOC1Md0tFTHpKdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZTUlHYUFCd0FIZ0FnQUZNaUFId0U1QUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRRzlDNlMwS0VqalA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BX3o0dkFxNkF3bFRTVTR6T2pRM016WGdBN2daaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhfSktrRg0TPEE4RDgumgKJASFlQTh0TUE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBOek0xUUxnWlNRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDKBlQUEu2AIA4AKtmEjqAktodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OQUU8NcvcGFnZXMvbW9kdWxlcy9jdXJyZW5jeS5odG1sP3BianNfZGVidWc9dHJ1ZYADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qATikAGyBA4IABABGAAgACgAMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM12gQCCAHgBAHwBLzJvi6IBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQBpXnQA2AUB4AUB8AWZ9CH6BQQIABAAkAYBmAYAuAYAwQYJJCjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGDPIGAggAgAcBiAcAoAdB&s=d6c58ebc137658c5dd258579c2575ad499e7a7b4'], + 'id': 97494204 + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/gdpr/index.js b/test/mock-server/expectations/request-response-pairs/gdpr/index.js new file mode 100644 index 00000000000..646559f2a7f --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/gdpr/index.js @@ -0,0 +1,94 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 300, + 'height': 250 + }, { + 'width': 300, + 'height': 600 + }], + 'primary_size': { + 'width': 300, + 'height': 250 + }, + 'ad_types': ['banner'], + 'id': 13144370, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '27c4cea6dfcad4', + 'tag_id': 13144370, + 'auction_id': '6784868202366971885', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Fgpt%2Fgdpr_hello_world.html%3Fpbjs_debug%3Dtrue&e=wqT_3QL0CWz0BAAAAwDWAAUBCKKt0fAFEO3ftM_qtayUXhj_EQEQASo2CQANAQARDQgoABkAAACA61HgPyEREgApEQkAMREb8GkwsqKiBjjtSEDtSEgAUABYnPFbYABotc95eACAAQGKAQCSAQNVU0SYAawCoAH6AagBAbABALgBAcABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3ODM5MTIwMik7AR0scicsIDk2ODQ2MDM1Nh4A9A4BkgLJAiF0ajlmS2dpdXNLNEtFTk9CbHk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRc3FLaUJsZ0FZUF9fX184UGFBQndBWGdCZ0FFQmlBRUJrQUVCbUFFQm9BRUJxQUVEc0FFQXVRRXBpNGlEQUFEZ1A4RUJLWXVJZ3dBQTREX0pBZWxBS28zZEV1OF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBTUFDQWNnQ0FkQUNBZGdDQWVBQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEcnJDdUNyb0RDVk5KVGpNNk5EY3pPZUFEX0JpSUJBQ1FCQUNZQkFIQkJBQUFBQQmDCHlRUQkJAQEYTmdFQVBFRQELCQEwRDRCQUNJQllNbHFRVQkTREFEd1B3Li6aAokBIWZnOFhHUTZNASRuUEZiSUFRb0FEEUhYRGdQem9KVTBsT016bzBOek01UVB3WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EBlQUEuwgIvaHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3MvZ2V0dGluZy1zdGFydGVkLmh0bWzYAgDgAq2YSOoCWA068IF0ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2dkcHJfaGVsbG9fd29ybGQuaHRtbD9wYmpzX2RlYnVnPXRydWWAAwGIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDb3wW5gEAKIECzEwLjc1Ljc0LjY5qAS_NrIEEggEEAQYrAIg-gEoASgCMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM52gQCCADgBAHwBNOBly6IBQGYBQCgBf__bcwUAcAFAMkFaakU8D_SBQkJCQyIAADYBQHgBQHwBQH6BQQIABAAkAYAmAYAsgaWAUJPc3kwUXkBBixYaUFBQUJBRU5DMi0hswh0RjdhJQxfX185AQXwcV9fOXV6X092X3ZfZl9fMzNlOF9fOXZfbF83Xy1fX191Xy0zM2Q0dV8xdmY5OXlmbTEtN2V0cjN0cF84N3VlczJfWHVyX183OV9fM3ozXzlweFA3OGs4OXI3MzM3RXdfdi1fdi1iN0pDT05fQbgGAcEGAAW-KPC_0Ab1L9oGFgoQBRAdAVAQABgA4AYB8gYCCACABwGIBwCgBwE.&s=896d8d25ed5c73ed4b49adebaa58ba23ed6afa43', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'banner', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 96846035, + 'media_type_id': 1, + 'media_subtype_id': 1, + 'cpm': 0.500000, + 'cpm_publisher_currency': 0.500000, + 'publisher_currency_code': '$', + 'brand_category_id': 0, + 'client_initiated_ad_counting': true, + 'rtb': { + 'banner': { + 'content': "
", + 'width': 300, + 'height': 250 + }, + 'trackers': [{ + 'impression_urls': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Fgpt%2Fgdpr_hello_world.html%3Fpbjs_debug%3Dtrue&e=wqT_3QL8CWz8BAAAAwDWAAUBCKKt0fAFEO3ftM_qtayUXhj_EQEQASo2CQAFAQjgPxEFCDAA4D8ZAAAAgOtR4D8hERIAKREJADERG6gwsqKiBjjtSEDtSEgCUNOBly5YnPFbYABotc95eMu4BYABAYoBA1VTRJIBAQbwUpgBrAKgAfoBqAEBsAEAuAEBwAEEyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc4MzkxMjAyKTt1ZigncicsIDk2ODQ2MDM1Nh4A9A4BkgLJAiF0ajlmS2dpdXNLNEtFTk9CbHk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRc3FLaUJsZ0FZUF9fX184UGFBQndBWGdCZ0FFQmlBRUJrQUVCbUFFQm9BRUJxQUVEc0FFQXVRRXBpNGlEQUFEZ1A4RUJLWXVJZ3dBQTREX0pBZWxBS28zZEV1OF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBTUFDQWNnQ0FkQUNBZGdDQWVBQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEcnJDdUNyb0RDVk5KVGpNNk5EY3pPZUFEX0JpSUJBQ1FCQUNZQkFIQkJBQUFBQQmDCHlRUQkJAQEYTmdFQVBFRQELCQEwRDRCQUNJQllNbHFRVQkTREFEd1B3Li6aAokBIWZnOFhHUTZNASRuUEZiSUFRb0FEEUhYRGdQem9KVTBsT016bzBOek01UVB3WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EBlQUEuwgIvaHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3MvZ2V0dGluZy1zdGFydGVkLmh0bWzYAgDgAq2YSOoCWA068IF0ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2dkcHJfaGVsbG9fd29ybGQuaHRtbD9wYmpzX2RlYnVnPXRydWWAAwGIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDb3wW5gEAKIECzEwLjc1Ljc0LjY5qAS_NrIEEggEEAQYrAIg-gEoASgCMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM52gQCCAHgBAHwBNOBly6IBQGYBQCgBf__bdQUAcAFAMkFabEU8D_SBQkJCQyIAADYBQHgBQHwBQH6BQQIABAAkAYAmAYAsgaWAUJPc3kwUXkBBixYaUFBQUJBRU5DMi0hswh0RjdhJQxfX185AQXwcV9fOXV6X092X3ZfZl9fMzNlOF9fOXZfbF83Xy1fX191Xy0zM2Q0dV8xdmY5OXlmbTEtN2V0cjN0cF84N3VlczJfWHVyX183OV9fM3ozXzlweFA3OGs4OXI3MzM3RXdfdi1fdi1iN0pDT05fQbgGAcEGAAW-KPA_0Ab1L9oGFgoQBRAdAVAQABgA4AYB8gYCCACABwGIBwCgBwE.&s=1ad011df80b035fdd957f6ae84e46bdeebae9f83'], + 'video_events': {} + }] + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/instream/index.js b/test/mock-server/expectations/request-response-pairs/instream/index.js new file mode 100644 index 00000000000..5164e56e093 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/instream/index.js @@ -0,0 +1,94 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 13232361, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': {} + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '206465a8c326a5', + 'tag_id': 13232361, + 'auction_id': '1398509384102899505', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Finstream.html&e=wqT_3QKxCKAxBAAAAwDWAAUBCKXQzPAFELHeg_SAnKC0ExjCs_b6q5D9_0oqNgkAAAkCABEJBywAABkAAADgehQUQCEREgApEQkAMREb8Hkw6dGnBjjtSEDtSEgAUABYnPFbYABozbp1eACAAQGKAQCSAQNVU0SYAQGgAQGoAQGwAQC4AQPAAQDIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzgzMTM3NjUpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPD1kgK1AiF5andtb2dpMi1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNmRHbkJsZ0FZTUlHYUFCd0tIZ0dnQUU4aUFFR2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFVUU1FQjg2MXFwQUFBRkVESkFmZjUwcVFyNGVvXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHR2aThDcm9EQ1ZOSlRqTTZORGN6T09BRC1SaUlCQUNRQkFDWUJBSEJCBUUJAQh5UVEJCQEBFE5nRUFQRRGNAZAsNEJBQ0lCWUlscVFVAREBFDx3UHcuLpoCiQEhTGc5WkRRNjkBJG5QRmJJQVFvQUQVSFRVUURvSlUwbE9Nem8wTnpNNFFQa1lTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBSZUFBLsICP2h0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctdmlkZW8td2l0aC1hLWRmcC12aWRlby10YWcuaHRtbNgCAOACrZhI6gIzaHQFSkh0ZXN0LmxvY2FsaG9zdDo5OTk5BRQ4L3BhZ2VzL2luc3RyZWFtBT7IgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvCanwXpgEAKIECzEwLjc1Ljc0LjY5qAS0LLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM42gQCCADgBADwBMuBwC6IBQGYBQCgBf______AQMUAcAFAMkFaX8U8D_SBQkJCQx4AADYBQHgBQHwBcOVC_oFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=6805157848bdfdf973d0dbafff4bb9b4c4ce7e60', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQklKBNeAAAAABEx74AO4IBoExklKBNeAAAAACDLgcAuKAAw7Ug47UhA0-hISLuv1AFQ6dGnBljDlQtiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcuBwC6wAQE.&s=07e6e5f2f03cc92e899c3ddbf4e2988e966caaa2&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97517771, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 5.000000, + 'cpm_publisher_currency': 5.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 36, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Finstream.html&e=wqT_3QKNCaCNBAAAAwDWAAUBCKXQzPAFELHeg_SAnKC0ExjCs_b6q5D9_0oqNgkAAAECCBRAEQEHNAAAFEAZAAAA4HoUFEAhERIAKREJADERG6gw6dGnBjjtSEDtSEgCUMuBwC5YnPFbYABozbp1eJG4BYABAYoBA1VTRJIBAQbwUpgBAaABAagBAbABALgBA8ABBMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3ODMxMzc2NSk7dWYoJ3InLCA5NzUxNzc3MSwgLh4A8PWSArUCIXlqd21vZ2kyLUx3S0VNdUJ3QzRZQUNDYzhWc3dBRGdBUUFSSTdVaFE2ZEduQmxnQVlNSUdhQUJ3S0hnR2dBRThpQUVHa0FFQW1BRUFvQUVCcUFFRHNBRUF1UUh6cldxa0FBQVVRTUVCODYxcXBBQUFGRURKQWZmNTBxUXI0ZW9fMlFFQUFBQUFBQUR3UC1BQkFQVUJBQUFBQUpnQ0FLQUNBTFVDQUFBQUFMMENBQUFBQU9BQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEdHZpOENyb0RDVk5KVGpNNk5EY3pPT0FELVJpSUJBQ1FCQUNZQkFIQkIFRQkBCHlRUQkJAQEUTmdFQVBFEY0BkCw0QkFDSUJZSWxxUVUBEQEUPHdQdy4umgKJASFMZzlaRFE2OQEkblBGYklBUW9BRBVIVFVRRG9KVTBsT016bzBOek00UVBrWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8FJlQUEuwgI_aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy12aWRlby13aXRoLWEtZGZwLXZpZGVvLXRhZy5odG1s2AIA4AKtmEjqAjNodAVKSHRlc3QubG9jYWxob3N0Ojk5OTkFFDgvcGFnZXMvaW5zdHJlYW0FPmjyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-4ElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92Mw398F6YBACiBAsxMC43NS43NC42OagEtCyyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczONoEAggB4AQA8ATLgcAuiAUBmAUAoAX______wEDFAHABQDJBWnbFPA_0gUJCQkMeAAA2AUB4AUB8AXDlQv6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=68b9d39d60a72307a201e479000a8c7be5508188' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_1.js new file mode 100644 index 00000000000..d92e64c6075 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_1.js @@ -0,0 +1,577 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '7360998998672342781', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCN73l_AFEP39-97ssuGTZhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIVNqMmZTQWlua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaQmtTcHl1c2Q4XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFOZzhKRnc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfC2Lmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAZXZw2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYFIiwA8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=c92cbcde5c8bf8e053f86493dd4c4698da0392de', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQne-wVeAAAAABH9_t7LloUnZhne-wVeAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=8e35c1264cd1b4f1d89f929c3a4a334cf6a68eca&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-COh-BAAAAwDWAAUBCN73l_AFEP39-97ssuGTZhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV40rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFTajJmU0FpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnV1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWkJrU3B5dXNkOF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhTmc4SkZ3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBJLGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBNLsn0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=ca640dffaea7bfcf2b0f2e11d8877821189b74bb' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '1919339751435064934', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCN73l_AFEOasy7zbqrfRGhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIU1EMUZJQWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFRclZ0ZGpIUGVBXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASE1QTdmLVE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfC2Lmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAZXZw2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYFIiwA8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=c3130de64bc0b8df258e603dfb96f78550ab0c3c', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQne-wVeAAAAABFm1pK3Vd2iGhne-wVeAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=2c3cee10303d9b93531bed443c0781d905270598&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-COh-BAAAAwDWAAUBCN73l_AFEOasy7zbqrfRGhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV40rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFNRDFGSUFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnV1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUXJWdGRqSFBlQV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhNUE3Zi1RNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBJLGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBIvhn0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx4AADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=996a3937245f03e5eefb0cb69917d2d8d7f60424' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '3257875652791896280', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '5756905673624319729', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '4205438746002589111', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '204849530930208960', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '3482944224379652843', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '2123689132466331410', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '6150444453316813936', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '2810956382376737966', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '7164199537578897638', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKhCKAhBAAAAwDWAAUBCN73l_AFEObhocvZsJa2Yxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIXNENXVfQWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYSEZfdmZOei1NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFDd19DQnc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfC2Lmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAZXZs2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgUhLADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=2b9ed1e2e7f27fea52cbdc64cb700195bbd14d75', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQne-wVeAAAAABHmcGiZhVlsYxne-wVeAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=8ba7f141449cb45f8b6e12361a62d8d68aa9c812&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL9COh9BAAAAwDWAAUBCN73l_AFEObhocvZsJa2Yxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV40rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFzRDV1X0FpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnV1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWEhGX3ZmTnotTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhQ3dfQ0J3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBJLGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBK_ln0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx0AADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSQo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=527640949733fba32740156d743d421eb1fe2863' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '8404712946290777461', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCN73l_AFEPW6p5bQvOLRdBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIWp6MkdiZ2lta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaQ0RhTlBDYk9NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFOUS0yRjo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56TXpRSzRZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwZWVBQS7YAgDgAq2YSOoCYGh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19jdXN0b21fYWRzZXJ2ZXJfdHJhbnNsYQE18LYuaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qASSxgSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggA4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABldnDYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgUiLADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=ed84428f432d6e743bcad6f7862aed957bece82b', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQne-wVeAAAAABF13ckC5YmjdBne-wVeAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=7024b063fcacac27e184ed097ad5878c4dd4dc1d&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-COh-BAAAAwDWAAUBCN73l_AFEPW6p5bQvOLRdBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV40rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiFqejJHYmdpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnV1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWkNEYU5QQ2JPTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNAQUR3UHcuLpoCiQEhTlEtMkY6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNXwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wn0lGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAeAEAPAE39-fR4gFAZgFAKAF______8BBRQBwAUAyQVpwxTwP9IFCQkJDHgAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=aefe9625d8e866e048a156abdf26d7c626e6a398' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '4063389973481762703', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCN73l_AFEI_fjorv9IOyOBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIV96eHRIQWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFSVExWM2x4c2VJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFEZy1VQ1E2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfC2Lmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAExd2fR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAZXZw2AUB4AUB8AXC8hf6BQQIABAAkAYBmAYAuAYAwQYFIiwA8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=2fb33b5204f9b75c58d89487725a9d55139f9ff4', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQne-wVeAAAAABGPr0Pxpg9kOBne-wVeAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=f9ec8d0b81c1cf4eefc58a7990f4a0a78440725f&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-CKB-BAAAAwDWAAUBCN73l_AFEI_fjorv9IOyOBiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjSuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc0NTA0NjIpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIV96eHRIQWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFSVExWM2x4c2VJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFEZy1VQ1E2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNXwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wn0lGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAeAEAPAExd2fR4gFAZgFAKAF______8BBRQBwAUAyQVpwxTwP9IFCQkJDHgAANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=6b79542e3cee0319d8cb83d1daf127c3aeea9b28' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '5097385192927446024', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '2612757136292876686', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_2.js new file mode 100644 index 00000000000..ea77d211826 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_2.js @@ -0,0 +1,289 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '2837696487158070058', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCNSDmPAFEKr2uMu5veGwJxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIV9EemhKUWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFTbnRDdFVIdU9BXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0RBRHdQdy4umgKJASFOdzh1Rnc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek0xUUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfDtLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEq8YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzXaBAIIAOAEAPAE39-fR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPC_0Ab1L9oGFgoQAAAAAAU3DQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=3414eb9e83df14945d2dbfb00e17fb3f2bad2e33', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnUAQZeAAAAABEqO26Z64VhJxnUAQZeAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=e5a720a9884e1df845be9c33658ab69f4c56981e&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-COh-BAAAAwDWAAUBCNSDmPAFEKr2uMu5veGwJxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiFfRHpoSlFpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjd1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBU250Q3RVSHVPQV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek5lQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjhrcVFVCRNEQUR3UHcuLpoCiQEhTnc4dUZ3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNMVFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKvGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM12gQCCAHgBADwBN_fn0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx4AADYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=99418325b8f5ec79e22c1a9aedd73f03de616c2d' + } + } + }] + }, { + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '8688113570839045503', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKhCKAhBAAAAwDWAAUBCNSDmPAFEP_K8rCtqJjJeBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIUN6d3Rud2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFWUzRZeVVvR09JXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0RBRHdQdy4umgKJASFKQTlsRUE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek0xUUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfDXLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEq8YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzXaBAIIAOAEAPAExOefR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGBSEsAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=2e7c9d18300402e2e183667711728f7743b70a2b', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnUAQZeAAAAABF_pRzWQmGSeBnUAQZeAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=febf12010c66ac7247f571f03c33175ca9036b32&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL9COh9BAAAAwDWAAUBCNSDmPAFEP_K8rCtqJjJeBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFDend0bndpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjd1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVlM0WXlVb0dPSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek5lQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjhrcVFVCRNEQUR3UHcuLpoCiQEhSkE5bEVBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNMVFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKvGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM12gQCCAHgBADwBMTnn0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx0AADYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGCSQo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=92aa9e9c89384c435ab9c7fa62b963d8fc087ef7' + } + } + }] + }, { + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '4162295099171231907', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKhCKAhBAAAAwDWAAUBCNSDmPAFEKOxzaPwqtzhORiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIWREMGtXZ2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhSFRjUzNjWS1VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0RBRHdQdy4umgKJASFEUTg2Q0E2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek0xUUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfDXLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEq8YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzXaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGBSEsAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=95047e919846faea401c778106fb33dae0c95b02', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnUAQZeAAAAABGjWHMEV3HDORnUAQZeAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=50350aadc603f4bb6c59888515d60e9182da0eb8&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL9COh9BAAAAwDWAAUBCNSDmPAFEKOxzaPwqtzhORiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFkRDBrV2dpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjd1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYUhUY1MzY1ktVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek5lQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjhrcVFVCRNEQUR3UHcuLpoCiQEhRFE4NkNBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNMVFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKvGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM12gQCCAHgBADwBK_ln0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx0AADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSQo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=82c42e6aa09e7c842254552ae524791fa3693bbb' + } + } + }] + }, { + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '1076114531988487576', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCNSDmPAFEJj7vIbyjsj3Dhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIVRqMWVUZ2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFZOUNHX2M3MHRvXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0BBRHdQdy4umgKJASFFQThNQzo9ASRuUEZiSUFRb0FEFUhUa1FEb0pVMGxPTXpvME56TTFRSzRZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwZWVBQS7YAgDgAq2YSOoCYGh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19jdXN0b21fYWRzZXJ2ZXJfdHJhbnNsYQE18O0uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qASrxgSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggA4AQA8ATF3Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAAAABTcNAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=c49afba7ca4b5193f7da37b17e1fbfbee2328f61', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnUAQZeAAAAABGYPc8gdyDvDhnUAQZeAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=47618eb9096567900e84fd1c6aff09d753b2fe91&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-CKB-BAAAAwDWAAUBCNSDmPAFEJj7vIbyjsj3Dhiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjWuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc0NTE5ODgpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIVRqMWVUZ2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFZOUNHX2M3MHRvXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0BBRHdQdy4umgKJASFFQThNQzo9ASRuUEZiSUFRb0FEFUhUa1FEb0pVMGxPTXpvME56TTFRSzRZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwZWVBQS7YAgDgAq2YSOoCYGh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19jdXN0b21fYWRzZXJ2ZXJfdHJhbnNsYQE1fC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvCfSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qASrxgSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggB4AQA8ATF3Z9HiAUBmAUAoAX______wEFFAHABQDJBWnDFPA_0gUJCQkMeAAA2AUB4AUB8AXC8hf6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=72d1ec3db5baaa29c1b0e5f07c012db606675fe5' + } + } + }] + }, { + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '7495588537924508785', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_1.js new file mode 100644 index 00000000000..0c58bd6fb3e --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_1.js @@ -0,0 +1,606 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '4424969993715088689', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFELH6mcm82Km0PRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIWhUNEwzZ2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFjek5XT196NC1VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFTZy1SR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBNLsn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=3d8c006f4f85ecffd49c500554c3852b9079ff2b', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABExfSbJw6ZoPRlNxwleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=e2c6cedf67a96613ea8851673ebcfdd25a19435c&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCM2Op_AFELH6mcm82Km0PRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFoVDRMM2dpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBY3pOV09fejQtVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhU2ctUkd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wkElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8ARhjSCIBQGYBQCgBf8RARQBwAUAyQVpvhTwP9IFCQkJDHgAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=de23f822f483b6e85615d4297d872262310c240d' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '2013100091803497646', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '2659371493620557151', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFEN_KtpiJif_zJBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIWR6eUJxQWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFWSHZpWGF0Q09zXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASEtQTVuX2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBIvhn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx4AADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=eafba287adec58427d1679f43a84ebb19223c4e7', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABFfpQ2TSPznJBlNxwleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=b335b2c79378c1699d54cf9ffe097958bd989a0b&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCM2Op_AFEN_KtpiJif_zJBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFkenlCcUFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVkh2aVhhdENPc18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhLUE1bl9nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wkElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8ARhjSCIBQGYBQCgBf8RARQBwAUAyQVpvhTwP9IFCQkJDHgAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=66b9e769da1e1d68b202605fc178fc172046e9c5' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '5424637592449788792', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '3470330348822422583', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '4415549097692431196', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '1628359298176905427', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '1949183409076770477', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '4707958683377993236', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '2499032734231846767', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '1295788165766409083', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKcCKAcBAAAAwDWAAUBCM2Op_AFEPvWpeWKj-T9ERiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCITR6eVM5d2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFlS0tONGIwQS00XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFOZzkxRkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBMTnn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx0AADYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=3cb170cdf53cd6a6bfec0676659daeb6170895e3', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQlNxwleAAAAABF7a6mseJD7ERlNxwleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=45f5cce314725120ec769afaacbb7aa92d32e674&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL4COh4BAAAAwDWAAUBCM2Op_AFEPvWpeWKj-T9ERiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiE0enlTOXdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZUtLTjRiMEEtNF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhTmc5MUZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7w7UlGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwP9AG9S_aBhYKEACJABUBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=5c9f03b9c5c6cc2bf070d8cdc6c9af4b06595879' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '702761892273189154', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKcCKAcBAAAAwDWAAUBCM2Op_AFEKLi_7T7xq3gCRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4NDg2Nh8A8P2SArkCITdUeVNDd2lva184UEVQYmpuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFHSTh5N21BQUFzUU1FQmlQTXU1Z0FBTEVESkFYQTM4QzJIcnVFXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHFKUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFaQThESlE2PQEkblBGYklBUW9BRBVIVHNRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBPbjn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx0AADYBQHgBQHwBf0F-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=f459a78a1b20c9643b90d7491f22593d79cff253', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQlNxwleAAAAABEi8Z-2N7bACRlNxwleAAAAACD2459HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1j9BWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgB9uOfR7ABAQ..&s=83289d261bced5258930a1ce2464260a96565241&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418486, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 14.000010, + 'cpm_publisher_currency': 14.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL4COh4BAAAAwDWAAUBCM2Op_AFEKLi_7T7xq3gCRiq5MnUovf28WEqNgmOWItPAQAsQBGOWItPAQAsQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ9uOfR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODQ4NiwgMTUZH_D9kgK5AiE3VHlTQ3dpb2tfOFBFUGJqbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRR0k4eTdtQUFBc1FNRUJpUE11NWdBQUxFREpBWEEzOEMySHJ1RV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RxSlBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhWkE4REpRNj0BJG5QRmJJQVFvQUQVSFRzUURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7w7UlGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8AT2459HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF_QX6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwP9AG9S_aBhYKEACJABUBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=16a432c0a05db78fa40fefc7967796ff2a2e8444' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '8192047453391406704', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFEPCMp9SW-P_XcRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIXhUdGdYZ2lHa184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFSR0FWSjZORXVNXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFKUThlRDo9ASRuUEZiSUFRb0FEFUhUcVFEb0pVMGxPTXpvME56TXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwXmVBQS7YAgDgAq2YSOoCWWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19yZXF1aXJlRXhhY3REdXJhAS7wny5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEwuYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAE39-fR4gFAZgFAKAF______8BBRQBwAUAyQVpYhTwP9IFCQkJDHgAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGCSUo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=8bf90e0756a9265ab6ac029e883e14803447a7fb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABFwxolqwf-vcRlNxwleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=cf9ea0df7655a5c6150a527399cb2852c61ec14a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCM2Op_AFEPCMp9SW-P_XcRiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiF4VHRnWGdpR2tfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBUkdBVko2TkV1TV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNAQUR3UHcuLpoCiQEhSlE4ZUQ6PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGNIIgFAZgFAKAF_xEBFAHABQDJBWm-FPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=cefb5f476892ed335cd8b0fc20fabf7650b1d2e3' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '9041697983972949142', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFEJb5yqiVjaS9fRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIURUMkpEd2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFYeHdUOEhkUmVzXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFJZzhjRGc2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBMXdn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx4AADYBQHgBQHwBcLyF_oFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=308ea3c3363b379ef62dbb6c7a91d1d91d9ee47a', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABGWvBJVaZB6fRlNxwleAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=70a33aa1a57d812d9da5c321e898197836ed16f8&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5CKB5BAAAAwDWAAUBCM2Op_AFEJb5yqiVjaS9fRiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXiVuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc2OTkxNDkpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIURUMkpEd2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFYeHdUOEhkUmVzXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFJZzhjRGc2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvDeSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBMXdn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXC8hf6BQQIABAAkAYBmAYAuAYAwQYAAGHxKPA_0Ab1L9oGFgoQAQ8uAQBQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=ee15793b41a9d22ffad9bd46878a47821d6044fa' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '356000177781223639', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_2.js new file mode 100644 index 00000000000..38331688a9b --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_2.js @@ -0,0 +1,288 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '198494455120718841', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKcCKAcBAAAAwDWAAUBCM2Op_AFEPnX6_r7tMzgAhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIXpUMDRwQWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhejg2NVNoMGVJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0RBRHdQdy4umgKJASFKQTkzRFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCADgBADwBK_ln0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx0AADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=645b6e0a37eb3a315bc3208365bd4fc03e1ecd18', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQlNxwleAAAAABH561q_pzHBAhlNxwleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=35a21bf0bef1ca2c138e37a2e025ad523b5a1db2&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL4COh4BAAAAwDWAAUBCM2Op_AFEPnX6_r7tMzgAhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4xbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiF6VDA0cEFpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYXo4NjVTaDBlSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME4tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWXNscVFVCRNEQUR3UHcuLpoCiQEhSkE5M0RRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wkElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0N9oEAggB4AQA8ARhjSCIBQGYBQCgBf8RARQBwAUAyQVpvhTwP9IFCQkJDHQAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYJJCjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=cf3130989b2b4fe5271240d65055b85d1192b78a' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '998265386177420565', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFEJW6sbXGoqPtDRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIVdqM1Jid2lHa184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFmcXpCNjduMU9rXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0BBRHdQdy4umgKJASFLZzlMRDo9ASRuUEZiSUFRb0FEFUhUcVFEb0pVMGxPTXpvME56UTNRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwXmVBQS7YAgDgAq2YSOoCWWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19yZXF1aXJlRXhhY3REdXJhAS7wny5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEwuYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDfaBAIIAOAEAPAE39-fR4gFAZgFAKAF______8BBRQBwAUAyQVpYhTwP9IFCQkJDHgAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGCSUo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=33f01ddfb15bc84d7bf134a168aeb9d9de76fa57', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABEVXaxmFI3aDRlNxwleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=023640de7c18a0d0e80b2456144b89a351455cda&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCM2Op_AFEJW6sbXGoqPtDRiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4xbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiFXajNSYndpR2tfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBZnF6QjY3bjFPa18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjME4tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWXNscVFVCRNAQUR3UHcuLpoCiQEhS2c5TEQ6PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCAHgBADwBGGNIIgFAZgFAKAF_xEBFAHABQDJBWm-FPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=515ab42a7fdcad8fcf34e4fb98b1e076a75006a9' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '8884527464400177295', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKcCKAcBAAAAwDWAAUBCM2Op_AFEI-RmcaB1Yumexiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCITVqcmtHUWlta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYb0paejlaR09NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0BBRHdQdy4umgKJASFPdy1pRjo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UTNRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwXmVBQS7YAgDgAq2YSOoCWWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19yZXF1aXJlRXhhY3REdXJhAS7wny5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEwuYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDfaBAIIAOAEAPAExOefR4gFAZgFAKAF______8BBRQBwAUAyQVpYhTwP9IFCQkJDHQAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYJJCjwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=dc7d874e52ac39980ec1070a7769632be56a2f00', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQlNxwleAAAAABGPSMYYqC5MexlNxwleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=9fd739e9f0a6054296f9bb5168c49a89a425795c&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL4COh4BAAAAwDWAAUBCM2Op_AFEI-RmcaB1Yumexiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4xbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiE1anJrR1FpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWG9KWno5WkdPTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME4tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWXNscVFVCRNAQUR3UHcuLpoCiQEhT3ctaUY6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkAFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=1f8ea8f07f781fe149beb0d65dd25ad725a12f3b' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '1279521442385130931', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFELPr8f6Pv_HgERiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIW9EeDJEQWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFkb01fcFZkVGVVXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0RBRHdQdy4umgKJASFKdzlKRHc2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCADgBADwBMXdn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx4AADYBQHgBQHwBcLyF_oFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=4b14660ae659b3d301ec6c40f0f096bb88db145b', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABGzddz_-MXBERlNxwleAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=5f277bcab624f05c9d3a3a9c111961f3f33ccca2&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5CKB5BAAAAwDWAAUBCM2Op_AFELPr8f6Pv_HgERiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjFuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc2OTkxNDkpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIW9EeDJEQWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFkb01fcFZkVGVVXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0RBRHdQdy4umgKJASFKdzlKRHc2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvDeSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCAHgBADwBMXdn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXC8hf6BQQIABAAkAYBmAYAuAYAwQYAAGHxKPA_0Ab1L9oGFgoQAQ8uAQBQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=7bb7b75e4769a1260eaed2c79752ee542b4d28ce' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '7664937561033023835', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_1.js new file mode 100644 index 00000000000..ee1a19d21b2 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_1.js @@ -0,0 +1,852 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '6316075342634007031', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEPfztqL2oc3TVxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIV96eWNLZ2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFZYkYwSW1fZGU0XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASE5dzR0Xzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBIvhn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=bb81a081c756fd493253bf765c06ff46888f009a', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABH3uU1kDzWnVxk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=a3da30186f69a5ce2edcfc14fa3a31b92ee70060&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEPfztqL2oc3TVxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFfenljS2dpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWWJGMEltX2RlNF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhOXc0dF86PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx4AADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=62b9db151b3739399e0970c74fafc4bb61486510' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '8259815099516488747', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFEKuY2qihwrDQchiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIW1UeUFCd2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYNml4eGFGdE8wXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFOUTg3RkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAAGmpDQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=8a55db8e788616ef057647b49c0560296fdacb65', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABErjBYVEsKgchk3yQleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=75d46be63f76fd4062f354a56c692855da366148&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFEKuY2qihwrDQchiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFtVHlBQndpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWDZpeHhhRnRPMF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhTlE4N0ZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkDFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=59e0ab1f626c2e4dc5c4f6e6837b77559cf502b4' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '7960926407704980889', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEJnboLK5jLm9bhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIUZEeFl4QWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhSUpVQVhXMC1JXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFTQThFR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=8d00bc7576c3cc19fe8b3fb4aa42966583741dfa', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABGZLUiWY-R6bhk3yQleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=c813392cbb81d43466d5d949b9bebc2305e6fe7d&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEJnboLK5jLm9bhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiFGRHhZeEFpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYUlKVUFYVzAtSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhU0E4RUd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=284760a6e2d4f226b639d29237e9c1aa25ca49a9' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '7561862402601574638', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEO7By9umucj4aBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCITREcWpId2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFTSVA1dzg5RGVRXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASFTUTlYRzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBNLsn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=917e8af2ed1c82091f487b6abd78de47b99e9e46', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABHu4HJryiHxaBk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=ff73768bfb14e9ae603064fc91e95b60c8d872e2&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEO7By9umucj4aBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiE0RHFqSHdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBU0lQNXc4OURlUV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhU1E5WEc6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=84c66b632a2930d28092e00985ee154ba2e97288' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '6577796711489765634', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEIKC0sii6MGkWxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIVBUem53UWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFlaE5hMWl1Y3V3XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASE5dzR0X2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=ea4a54786a8f3cf5177b3372ce97682da060c358', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABECgRQpQgdJWxk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=778fbf3014328ec0b01d6ebd7b306be32cf79950&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEIKC0sii6MGkWxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFQVHpud1FpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZWhOYTFpdWN1d18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhOXc0dF9nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=28a3b583912b95528519f63a75c0fe2d06064e7b' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '2418275491761094586', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFELr_z7v0l9zHIRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIUF6MUJSZ2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFVNUE2dXpUVy1ZXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFTUTlYR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=c563626304ebb31fd6f1644cc2d4098133dec096', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABG6_3NHv3CPIRk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=88c9fbb2b9dc273865a5f9238543a29224908b26&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFELr_z7v0l9zHIRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFBejFCUmdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVTVBNnV6VFctWV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhU1E5WEd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=e76aeb8daad477f4428631fc89d277d4a4646ded' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '5990197965284733361', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFELHjwfj9qd2QUxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIURUeDF3d2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFmWXBYSEoxUGVNXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASFTUTlYRzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBNLsn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=e443347514ff5f6a52a2811f591f9a346061a756', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABGxcRDfT3UhUxk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=50348eb78116f7d35ca5ac6f6fa4c5548a6ceffc&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFELHjwfj9qd2QUxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFEVHgxd3dpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZllwWEhKMVBlTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhU1E5WEc6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=a24f331ff55f96c5afe5134762f8d8e230b6287c' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '4399290132982250349', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEO32psKU4tqGPRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCITN6dDlwd2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFRWlZqbkpncmV3XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASFTUTlYRzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBNLsn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=0d9b0a06992ff427d281fae8d8b18d4e6838b944', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABFtu0lIEWsNPRk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=52a446d84f5e9a2baa068760c4406f4a567a911a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEO32psKU4tqGPRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiEzenQ5cHdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUVpWam5KZ3Jld18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhU1E5WEc6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=e6ae592b5fc3de0053b5acd46294b83549aa00c8' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '8677372908685012092', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEPzYku74lY62eBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIVVEeGp5d2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFVN29abmh2c09RXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASE5dzR0X2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=522b764f2276ce75053a55a0198b79fb8d1d39d5', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABF8rMSNrzhseBk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=02b75d0ecc71c7897b9590be5e50b094158c8097&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEPzYku74lY62eBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFVRHhqeXdpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVTdvWm5odnNPUV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhOXc0dF9nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=0ae5558a7b0cc87eaa0c6811522629963b41bac5' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '617065604518434488', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFELitu4PevJDICBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIUFqMVNSZ2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaUzdZYTg5Ny13XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFTUTlYR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9HYBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAAAAAAAAAAAAAAAAAAAAEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f59bdb7b0f7020f75c6019f23686915b72d61779', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABG41m7g5UGQCBk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=912a721db8e85d4d64a8869d7cf9b56cd0c24907&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFELitu4PevJDICBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFBajFTUmdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWlM3WWE4OTctd18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhU1E5WEd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBGAHABQDJBQAFARTwP9IFCQkFC3wAAADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgEhMAAA8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=9b4372ae0674305d9cd7152959910d1fa7d4daec' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '8957511111704921777', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFELGNpebanN6nfBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIXVqdHppQWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFUM1dNOVpkQU9JXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASFIZzhRRDo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBK_ln0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPC_0Ab1L9oGFgoQAAAAaakNAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=a8817d9dc3326ba1b59fe308f126ddaca5710a9c', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABGxRsms5XhPfBk3yQleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=a0ac94e902cbc609881fa9f39537bbc67ba046e7&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFELGNpebanN6nfBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiF1anR6aUFpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVDNXTTlaZEFPSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhSGc4UUQ6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx0AADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSQo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=75b3ad3e867323196da165cd655b3ae51c8b44d0' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '2680240375770812721', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFELGi6rO9jYiZJRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIWd6eTMtZ2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYcFdVTk9rai1jXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFOUTg3RkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAAGmpDQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f8458c6a48fed591c269169a9744aba11cb90285', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABExkXrWayAyJRk3yQleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=e2dbd082b353a37db9f632efc2532913a0c48166&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFELGi6rO9jYiZJRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFnenkzLWdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWHBXVU5Pa2otY18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhTlE4N0ZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkDFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=5475ac640321ae51a06b5c05ac62519e97e90114' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '8439286287321689724', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFEPzciY2kxZePdRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIU1UeWZ6d2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFWalR1QThjek9FXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFOUTg3RkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAAGmpDQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=73e760427d2aec3d47824994cf35c35f1eeddcf8', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABF8bqJBKl4edRk3yQleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=dac1e836a6f2c4dc036c50d0b3128dfefb34915d&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFEPzciY2kxZePdRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFNVHlmendpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVmpUdUE4Y3pPRV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhTlE4N0ZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkDFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=6c1fb35564d2ffd08fb4c5b290aadd6e1e3d83ec' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '5519278898732145414', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEIa29Pmn3ZrMTBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCITFEc0hwUWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFkQUZ3YVliRWVNXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFTQThFR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=d01f411e7cc9126e912daca85136b2ca6f99a347', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABEGGz1_6mqYTBk3yQleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=81115280cee86ae0bc259627410fa5dbbc178646&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEIa29Pmn3ZrMTBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiExRHNIcFFpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZEFGd2FZYkVlTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhU0E4RUd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=90f21feeb2c798cd77b3cadbc961240238825f0d' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '6754624236211478320', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFELC-hPXI3s_eXRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIVJqc0hVUWlta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaRjJPd05MVnVvXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFOUTg3RkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAAGmpDQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=34811f7e5c917550619274f5b75a0cd214119812', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABEwH6GO9D69XRk3yQleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=d811faa48963b18d33c0a1f9d1e64ff97640a415&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFELC-hPXI3s_eXRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFSanNIVVFpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWkYyT3dOTFZ1b18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhTlE4N0ZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkDFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=c0a0a2d65dd091bd2ed81f95da1a9f7ff16ad70e' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_2.js new file mode 100644 index 00000000000..ce8bad3e9d7 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_2.js @@ -0,0 +1,312 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '4631210661889362034', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEPKQq-_0sdeiQBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIXF6eU1HUWlua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFVQk5fYTFxbHU0XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASFTd19PR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0M9oEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=0dae5294ed5bb48b7d3a156e5e587a26da27c7e1', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABFyyOpNj11FQBk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=9085e4dbb4849b0e6d3714d84a2754bbab578e16&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEPKQq-_0sdeiQBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFxenlNR1FpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVUJOX2ExcWx1NF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhU3dfT0d3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=aa5533d04e16ee398f8028ab3af03a48d7d8cc17' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '714778825826946473', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEKmbi7Ph8dn1CRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIU56dmJOZ2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFRbjlXUzRmY09jXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0BBRHdQdy4umgKJASEtUTZrXzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCADgBADwBIvhn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=8917b1722eed5b6d85c6d5a01eea7862089bee32', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABGpzWIWjmfrCRk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=9ec7e7de16b948b60d74b47f1917faf5d3b6dbf0&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEKmbi7Ph8dn1CRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFOenZiTmdpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUW45V1M0ZmNPY18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNAQUR3UHcuLpoCiQEhLVE2a186PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8N5JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAeAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgAAYfQo8D_QBvUv2gYWChABDy4BAFAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=8198652a5ee16abf4595ab1bfc6b051f81f0579d' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '231404788116786844', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEJydmpjcrYebAxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIUVqMFlVZ2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhLXFPTExmZ2VrXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASFTd19PR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0M9oEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=775dfc49086467337dee9a5e8d78b361931c6aaa', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABGcjgbDbR02Axk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=914256a92514df787ccb1eae7dea7578d23c8fba&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEJydmpjcrYebAxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFFajBZVWdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYS1xT0xMZmdla18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhU3dfT0d3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f624619431372f9a248d0fa0dd8d09c4977bb544' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '7557072342526904599', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFEJeS-7GaqIfwaBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIUFqdmVKQWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFSY2lLblVqeU9VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0BBRHdQdy4umgKJASFJQS1IRDo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0dQFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCADgBADwBK_ln0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPC_0Ab1L9oGFgoQAAAAAAAAAAAAAAAAAAAAABAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=552663ed1246fd2a3cc5824164f57d32f18078ee', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABEXyT6mQR3gaBk3yQleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=e1c80e622aa60bf7683413f4371b0055d0d16f47&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFEJeS-7GaqIfwaBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFBanZlSkFpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUmNpS25VanlPVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNAQUR3UHcuLpoCiQEhSUEtSEQ6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEYAcAFAMkFAAUBFPA_0gUJCQULeAAAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYBIDAAAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=ccf266d1b02551a2ad0af0871d4af43e4aee4bba' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '5093465143102876632', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFENjX7JP78efXRhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIUJUeXRwUWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYamVBMVdNcXUwXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASEtUTZrX2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0M9oEAggA4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=6651c1436b699842aabb3ae53d96d07caf5b4938', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABHYK3uyj5-vRhk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=f62098bf5037b22ca4e5583289a1527fdfa87e43&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFENjX7JP78efXRhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFCVHl0cFFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWGplQTFXTXF1MF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhLVE2a19nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDeSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBIvhn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYAAGH0KPA_0Ab1L9oGFgoQAQ8uAQBQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=4b43aaab766ee7d2e4c900ec32cb3c8b7ccef1d0' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_1.js new file mode 100644 index 00000000000..fc2ad82fe5f --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_1.js @@ -0,0 +1,620 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '8905202273088829598', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCLWXp_AFEJ7x1-ORyejKexiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIWlEeE84Z2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhV09TRWpDY09NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0BBRHdQdy4umgKJASFQZzlaRjo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56YzNRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAZWQU8D_SBQkJBQt4AAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgEgMAAA8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=21195aa3e27f8eb88ba43d5da32e6b78c2aa03f8', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQm1ywleAAAAABGe-HUcSaKVexm1ywleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=3c05b8509dd5c7c4459886f4c69fdd9cd07caa66&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCLWXp_AFEJ7x1-ORyejKexiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFpRHhPOGdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYVdPU0VqQ2NPTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNAQUR3UHcuLpoCiQEhUGc5WkY6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTQUWPExFQUZfTkFNRRIA8gIeChoyMwDwwkxBU1RfTU9ESUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBNXmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0Nzc32gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAGXObNgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYFISwA8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=203ae79160a460b18f20165e5de53bb1f45e4933' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '2428831247136753876', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFENSR0sfppLzaIRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIXRUeV9FQWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFTek5nNXJvQi0wXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFVUThpSFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAE39-fR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=af2d5096aa4f934e84b59ad16cd18dfe5b9bbc77', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABHUiPSYJvG0IRm1ywleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=440a389c7f556dac70c650bb1e593a10cbcdf2af&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFENSR0sfppLzaIRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiF0VHlfRUFpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBU3pOZzVyb0ItMF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNEQUR3UHcuLpoCiQEhVVE4aUhRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpjM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggB4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=9b00ed17c420f328d63b72519d2d578c5921d0d7' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '1625697369389546128', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEJD1gLbO5OjHFhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIXVqeHMtUWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhcDVwSkxuSXVVXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFBQTlhQUE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=0e70f535a95c82238d685147f41e0bd2f86631c0', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABGQOsDmJKOPFhm1ywleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=144214d77cc4ced0893c9fe64132ad01c429c43c&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEJD1gLbO5OjHFhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiF1anhzLVFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYXA1cEpMbkl1VV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNEQUR3UHcuLpoCiQEhQUE5YUFBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpjM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggB4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f6bc475b66c167036dcb9f10c7c5f176124829a6' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '5434800203981031918', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCLWXp_AFEO6TivzZv5K2Sxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIW5Ud3I5QWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFXVVcwV1Y1LU9JXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFKdzh1RGc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULeAAAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=c3ba85f0eb0293896e02066385f82b4450af2cfb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQm1ywleAAAAABHuiYKf_UlsSxm1ywleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=9eb2d880fa9b524a6a0807eef0c65b7b1393f48a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCLWXp_AFEO6TivzZv5K2Sxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFuVHdyOUFpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBV1VXMFdWNS1PSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNEQUR3UHcuLpoCiQEhSnc4dURnNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpjM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggB4AQA8ASv5Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlzmzYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGBSEsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=17038c2671b58d2fd6ea98dd3f3e1166ee664dd0' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '8071104954749355970', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEMKP7OWZ5pSBcBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIXBUeEJEQWlsa184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFRbWtta1pXNGVZXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFSZ19sR1E2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=005579c0ff91586a887354409f637a63a1d69031', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABHCB7ucMVMCcBm1ywleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=edbfae73be0f41d672298d5c3ec9dd28a5307233&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6CKB6BAAAAwDWAAUBCLWXp_AFEMKP7OWZ5pSBcBiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDS7J9HWJzxW2AAaM26dXjWuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc3MDAyNzcpO3VmKCdyJywgMTQ5NDE5NjAyLCAxNRkf8P2SArkCIXBUeEJEQWlsa184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFRbWtta1pXNGVZXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFSZ19sR1E2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTQUWPExFQUZfTkFNRRIA8gIeChoyMwDwwkxBU1RfTU9ESUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBNXmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0Nzc32gQCCAHgBADwBNLsn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAGXOcNgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGBSIsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=0ac18b64a6c0d58a114085d8b565b4c98de56448' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '6893555531330982923', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEIuopuO2h7XVXxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE0MTg4Nh8A8P2SArkCIVFqd1R0Z2lHa184UEVLekNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFZS1J6NEZQV2V3XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASEzUTZnOHc2PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAErMKfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF8owB-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f9ddb1066825dfc556d108168ffc0d16cf567ae8', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABELlGlsO9SqXxm1ywleAAAAACCswp9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jyjAFiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAazCn0ewAQE.&s=db3a0d52f97edd94aa7e4213c437d8e4a5bd16ce&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149414188, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 32, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 29000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEIuopuO2h7XVXxiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQrMKfR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxNDE4OCwgMTUZH_D9kgK5AiFRandUdGdpR2tfOFBFS3pDbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBWUtSejRGUFdld18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNEQUR3UHcuLpoCiQEhM1E2Zzh3Nj0BJG5QRmJJQVFvQUQVSFRxUURvSlUwbE9Nem8wTnpjM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggB4AQA8ASswp9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBfKMAfoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=917c8192c7dc7e382c0bb7296ab0df261e69f572' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '5615186251901272031', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '6647218197537074925', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '4707051182303115567', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '4831890668873532085', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '7151522995196673389', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '4077353832159380438', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFENaHwKvS9urKOBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIWJqeHo1UWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFZd1VQNVZMNi1VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFLZzhBRUE2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAExd2fR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=e96d121a0a7d49e05c1d2b4fab2da60d0b544287', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABHWA3AltauVOBm1ywleAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=8d90e3ce42fe47da19cb85f8fb2d78822c590464&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6CKB6BAAAAwDWAAUBCLWXp_AFENaHwKvS9urKOBiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjWuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc3MDAyNzcpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIWJqeHo1UWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFZd1VQNVZMNi1VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFLZzhBRUE2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTQUWPExFQUZfTkFNRRIA8gIeChoyMwDwwkxBU1RfTU9ESUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBNXmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0Nzc32gQCCAHgBADwBMXdn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAGXOcNgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGBSIsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=db30796cc71c3bee3aa8fc2890c75ad7186f9d73' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '2099457773367093540', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '7214207858308840891', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '4564285281969145467', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_2.js new file mode 100644 index 00000000000..751abfa14e4 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_2.js @@ -0,0 +1,312 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '2704229116537156015', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEK_j3NPcwdbDJRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIXpUczJvQWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFURVBwVy1oVE9ZXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0BBRHdQdy4umgKJASFVQV9qSDo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UTVRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggA4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAZWQU8D_SBQkJBQt8AAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYBITAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=64565aadf65d370e9730e9ce82c93c9bd2fcfc14', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABGvMXfKDVqHJRm1ywleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=3b1f10f67b3253e38770fff694edbe6052795602&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEK_j3NPcwdbDJRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiF6VHMyb0FpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVEVQcFctaFRPWV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNAQUR3UHcuLpoCiQEhVUFfakg6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTQUWPExFQUZfTkFNRRIA8gIeChoyMwDwwkxBU1RfTU9ESUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBNXmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ52gQCCAHgBADwBN_fn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAGXOcNgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGBSIsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=5316c3262f36e4d89735b1ba252c64651a84f479' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '7987581685263122854', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEKaDmaSQ5-Xsbhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIU16MXpZd2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYLVkxZU5tY3VRXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0RBRHdQdy4umgKJASFVUTgySFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDnaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=17f2a3f5e78c188cc6ca23e677ced305198a8a05', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABGmQYYEOZfZbhm1ywleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=28e8f96efdfb9bc1e33e4d087ff5ed992e4692b1&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEKaDmaSQ5-Xsbhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFNejF6WXdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWC1ZMWVObWN1UV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNEQUR3UHcuLpoCiQEhVVE4MkhRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRNVFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggB4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=89d4586d9597cd2f9a4a918d1e6985aee45ade01' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '653115326806257319', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCLWXp_AFEKfdmd3enZWICRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCITlEd0hNZ2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFjTnlESmJxeS13XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0RBRHdQdy4umgKJASFKZ192RFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDnaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULeAAAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=1928a9daadbd431792adace7620880dda961eefb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQm1ywleAAAAABGnbqbr7VQQCRm1ywleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=7617d08e0c16fe1dea8ec80cd6bf73ec0a736b41&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCLWXp_AFEKfdmd3enZWICRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiE5RHdITWdpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBY055REpicXktd18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNEQUR3UHcuLpoCiQEhSmdfdkRRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRNVFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggB4AQA8ASv5Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlzmzYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGBSEsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=0d1d3f42fa225995a2f57ab84877dce3d24e9901' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '866435845408148233', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEImW35H52YyDDBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIXJEenNfZ2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFjMmZTZ1BpMi1BXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0RBRHdQdy4umgKJASFfdzRiQUE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDnaBAIIAOAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=83f65f38b4fd56344b3aceb70df7bac1b9b5f229', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABEJyzeSzzIGDBm1ywleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=9130c13cca7a1d3eb05c2b96585ccfdc2faa6844&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEImW35H52YyDDBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFyRHpzX2dpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYzJmU2dQaTItQV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNEQUR3UHcuLpoCiQEhX3c0YkFBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRNVFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggB4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=1f88d8b0a467d528291f90a54fd810b8fdac4488' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '1540903203561034860', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCLWXp_AFEOyokYzL6ZixFRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIXdUekVId2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaeE00NUxjRXVNXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0RBRHdQdy4umgKJASFQUThhRmc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDnaBAIIAOAEAPAExOefR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULeAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=a4de0e4084ce04a5cb2d347c07fde867aa9ff5c1', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQm1ywleAAAAABFsVISxTGNiFRm1ywleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=cf600d825cec85f83c06119e5e383f8548b469a2&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCLWXp_AFEOyokYzL6ZixFRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiF3VHpFSHdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWnhNNDVMY0V1TV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNEQUR3UHcuLpoCiQEhUFE4YUZnNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRNVFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggB4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlzmzYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGBSEsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=17c466ea45d5d4beff02aa2b0eb87bc6c4d5aff3' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_1.js new file mode 100644 index 00000000000..4f11a203724 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_1.js @@ -0,0 +1,418 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {}, + 'brand_category_uniqueness': true + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '2678252910506723691', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '3548675574061430850', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '8693167356543642173', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '7686428711280367086', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '3784359541475413084', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '7233136875958651734', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '159775901183771330', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '6558726890185052779', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '6624810255570939818', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '528384387675374412', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '2535665225687089273', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '2166694611986638079', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '9137369006412413609', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '3524702228053475248', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '57990683038266307', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_2.js new file mode 100644 index 00000000000..b69612d86b9 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_2.js @@ -0,0 +1,284 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {}, + 'brand_category_uniqueness': true + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '3810681093956255668', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QKVCKAVBAAAAwDWAAUBCKD4kfAFELT_vOy9yJDxNBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIUxEMWZkUWlua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOE13Q2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFZVS10N09mcU9BXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTS1BRG9SaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJaRWxxUVUJE0RBRHdQdy4umgKJASFLdy1SRkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV6UUtFWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9AUBZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagErLkEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTPaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAGVbFPA_0gUJCQULfAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=66ba37441db5e28c87ee52e729333fd9324333f9', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQkgfAReAAAAABG0P4_dQ0LiNBkgfAReAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=6931bf3569012d0e1f02cb5a2e88dfcafe00dba9&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QLxCOhxBAAAAwDWAAUBCKD4kfAFELT_vOy9yJDxNBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4vLgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFMRDFmZFFpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjhNd0NrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWVUtdDdPZnFPQV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU0tQURvUmlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWkVscVFVCRNEQUR3UHcuLpoCiQEhS3ctUkZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVelFLRVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkMyHQDwlUFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKy5BLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUz2gQCCAHgBADwBGGFIIgFAZgFAKAF_xEBFAHABQDJBWm2FPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=ea46ec90cf31744c7be2af5d5f239ab4eed29098' + } + } + }] + }, { + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '7325897349627488405', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QKUCKAUBAAAAwDWAAUBCKD4kfAFEJXRloy0mrTVZRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIXJUeTNJd2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOE13Q2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFVSzAtQ2hwcWRrXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTS1BRG9SaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJaRWxxUVUJE0RBRHdQdy4umgKJASFBQTlLQlE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV6UUtFWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9AUBZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagErLkEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTPaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAGVbFPA_0gUJCQULeAAAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=271fd8a0ccdfc36e320f707164588ed1b33e9861', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQkgfAReAAAAABGVqIVB09CqZRkgfAReAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=115ac2b842cf3efeb5acaeda94ddf05632c345ca&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QLwCOhwBAAAAwDWAAUBCKD4kfAFEJXRloy0mrTVZRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4vLgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFyVHkzSXdpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjhNd0NrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVUswLUNocHFka18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU0tQURvUmlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWkVscVFVCRNEQUR3UHcuLpoCiQEhQUE5S0JRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVelFLRVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkMyHQDwlUFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKy5BLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUz2gQCCAHgBADwBGGFIIgFAZgFAKAF_xEBFAHABQDJBWm2FPA_0gUJCQkMdAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgkkKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=f73e060b15a6bbcca65f918a296f155b78c74eca' + } + } + }] + }, { + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '968802322305726102', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QKVCKAVBAAAAwDWAAUBCKD4kfAFEJbt7LTEkvi4DRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTsBHTByJywgMTQ5NDE0MTg4Nh8A8P2SArkCIUtUejN5d2lHa184UEVLekNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOE13Q2tBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFTT3dTTWVaYnVJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGMxTS1BRG9SaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJaRWxxUVUJE0RBRHdQdy4umgKJASF0ZzY4Nmc2PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOelV6UUtFWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9AUBZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagErLkEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTPaBAIIAOAEAPAErMKfR4gFAZgFAKAF____________AcAFAMkFAGVbFPA_0gUJCQULfAAAANgFAeAFAfAF8owB-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=e35825a106304da78477df1575f981395be21d5f', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQkgfAReAAAAABGWNptGlOBxDRkgfAReAAAAACCswp9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jyjAFiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAazCn0ewAQE.&s=677bedd5b2d21fdc3f940cbae279261c8f84c2e7&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149414188, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 32, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 29000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QLxCOhxBAAAAwDWAAUBCKD4kfAFEJbt7LTEkvi4DRiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQrMKfR1ic8VtgAGjNunV4vLgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTt1ZigncicsIDE0OTQxNDE4OCwgMTUZH_D9kgK5AiFLVHozeXdpR2tfOFBFS3pDbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjhNd0NrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBU093U01lWmJ1SV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjMU0tQURvUmlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWkVscVFVCRNEQUR3UHcuLpoCiQEhdGc2ODZnNj0BJG5QRmJJQVFvQUQVSFRxUURvSlUwbE9Nem8wTnpVelFLRVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkMyHQDwlUFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKy5BLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUz2gQCCAHgBADwBGGFIIgFAZgFAKAF_xEBFAHABQDJBWm2FPA_0gUJCQkMeAAA2AUB4AUB8AXyjAH6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=0707b1385afa81517cd338f1516aeccc46fe33e1' + } + } + }] + }, { + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '1273216786519070425', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '1769115862397582681', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QKUCKAUBAAAAwDWAAUBCKD4kfAFENn63YWPsMrGGBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIXp6djFzd2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOE13Q2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFZbW5MamdJaXVRXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTS1BRG9SaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJaRWxxUVUJE0RBRHdQdy4umgKJASFGdzkxRFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV6UUtFWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9AUBZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagErLkEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTPaBAIIAOAEAPAExOefR4gFAZgFAKAF____________AcAFAMkFAGVbFPA_0gUJCQULeAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=fb3a15e7ff747fccd750671b763e312d97083c72', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQkgfAReAAAAABFZfbfwgCmNGBkgfAReAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=7f4b8dd7c7dd9faecebac2e9ec6d7ef8da08da16&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QLwCOhwBAAAAwDWAAUBCKD4kfAFENn63YWPsMrGGBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4vLgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiF6enYxc3dpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjhNd0NrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWW1uTGpnSWl1UV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU0tQURvUmlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWkVscVFVCRNEQUR3UHcuLpoCiQEhRnc5MURRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVelFLRVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkMyHQDwsEFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKy5BLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUz2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBWm2FPA_0gUJCQkMdAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgkkKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=3a27c12c33ebaaae43dbce1cafb0bae43b753fa0' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_1.js new file mode 100644 index 00000000000..ffb03cc0563 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_1.js @@ -0,0 +1,620 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '1249897353793397796', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEKTIuZTW4KGsERiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCITFqdjBlZ2lta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFXU1JOVU1OTk9jXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFTUTgtR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAE39-fR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=e9887c670ae9fcb7eb2a0253037c64c3587f4bcb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABEkZI5iBYdYERnJwgleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=68a5c49da3a6ecf3dfc0835cb3da72b3b2c7b080&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEKTIuZTW4KGsERiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiExanYwZWdpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBV1NSTlVNTk5PY18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhU1E4LUd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=9514ae5f8aae1ee9dddd24dce3e812ae76e0e783' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '4278372095219023172', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEMT65MOLmPWvOxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIUxEeUhqUWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaQWJScDluWS1FXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASEtQTVuX2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=987d4bb0c7611d41b5974ec412469da2241084cd', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABFEPXm4wNRfOxnJwgleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=75aaa9ec84807690ceff60e39fbba6625240f9f3&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEMT65MOLmPWvOxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFMRHlIalFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWkFiUnA5blktRV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhLUE1bl9nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=9872a378866ce61fc366ca8c34bdd9302fa41a9b' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '8860024420878272196', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKRCKARBAAAAwDWAAUBCMmFp_AFEMSN8Z3LqMj6ehiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIU9EMjhLZ2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFkZExBS3hfN09nXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFIdzlLREE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkcADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSMo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=1289862cbe265fd9af13d2aab9635e3232421ec1', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnKwgleAAAAABHERryzRCH1ehnJwgleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=0b094204d5c18803149e081bd2bc0077d25ebb14&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLtCOhtBAAAAwDWAAUBCMmFp_AFEMSN8Z3LqMj6ehiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFPRDI4S2dpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZGRMQUt4XzdPZ18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhSHc5S0RBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMdAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgkkKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=f35771975371bb250fd6701914534b4f595fcf68' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '5236733650551797458', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKRCKARBAAAAwDWAAUBCMmFp_AFENLt5YOosKfWSBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIThUMjJsZ2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFkczByb2Ytbk9VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFOZzkxRkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAExOefR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkcADYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGCSMo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=e997907677e4e2f9b641d51b522a901b85944899', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnKwgleAAAAABHSdnmAgp2sSBnJwgleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=d70eef0df40cece50465a13d05a2dc11b65eadeb&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLtCOhtBAAAAwDWAAUBCMmFp_AFENLt5YOosKfWSBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiE4VDIybGdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZHMwcm9mLW5PVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhTmc5MUZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_DtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAGn1FQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=e8b6716ad3d2fcbdb79976f72d60f8e90ce8f5a6' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '4987762881548953446', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '201567478388503336', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEKjm-NzbkYfmAhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIXV6NlFDd2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFkejE5MUdLNk8wXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFTZy1SRzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56TXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qASv5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAaWR0ANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=4a887316a3197dfae07c1443a4debc62a2f17fef', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABEoM567jRzMAhnJwgleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=eef6278d136f8df4879846840f97933e9d67388a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEKjm-NzbkYfmAhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiF1ejZRQ3dpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZHoxOTFHSzZPMF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNAQUR3UHcuLpoCiQEhU2ctUkc6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8JplQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkNVU1RPTREdCEFTVAEL8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAeAEAPAEYYIgiAUBmAUAoAX_EQEUAcAFAMkFabMU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=e68b089e4fc94aa7566784ccbff299e50c8bc090' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '3876520534914199302', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '4833995299234629234', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '8352235304492782614', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEJaok6aeuMb0cxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE0MTg4Nh8A8P2SArkCIUpUMS1FZ2lHa184UEVLekNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFmQ1lIN1I1bmVzXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASExUTY4OFE2PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAErMKfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBfKMAfoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=7081f4ad4ae9837aaff4b4f59abc4ce7f8b02cb6', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABEW1MTkwRnpcxnJwgleAAAAACCswp9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jyjAFiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAazCn0ewAQE.&s=71f281c81d1ae269bde275b84aa955c833ab1dea&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149414188, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 32, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 29000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEJaok6aeuMb0cxiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQrMKfR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxNDE4OCwgMTUZH_D9kgK5AiFKVDEtRWdpR2tfOFBFS3pDbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBZkNZSDdSNW5lc18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhMVE2ODhRNj0BJG5QRmJJQVFvQUQVSFRxUURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AXyjAH6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=05fc37623521011853ff69d194aa6d692b6c0504' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '2318891724556922037', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '5654583906891472332', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEMy7oJeqw8e8Thiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIXZ6Ml9mZ2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFhYzY5MFRlZi1rXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFJZzhjRDo9ASRuUEZiSUFRb0FEFUhUa1FEb0pVMGxPTXpvME56TXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qASv5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggA4AQA8ATF3Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAaWR0ANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=f929565158c7caa5b85e88fa456cdd04d0e4b6d8', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABHMHeiiGh55ThnJwgleAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=a93773067b8588465b9c007e19970bd9e08c1b6c&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCKBuBAAAAwDWAAUBCMmFp_AFEMy7oJeqw8e8Thiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjDuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc2OTc5OTMpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIXZ6Ml9mZ2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFhYzY5MFRlZi1rXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFJZzhjRDo9ASRuUEZiSUFRb0FEFUhUa1FEb0pVMGxPTXpvME56TXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwmmVBQS7YAgDgAq2YSOoCTmh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19wcmljZUdyYW4uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTV9NT0RFTF9MRUFGX05BTUUSAPICHgoaQ1VTVE9NER0IQVNUAQvwkElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qASv5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8ARhgiCIBQGYBQCgBf8RARQBwAUAyQVpsxTwP9IFCQkJDHgAANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=a3a24cbf148bb959f539e883af3d118f64e81bc9' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '2268711976967571175', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '8379392370800588084', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '6225030428438795793', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '1592368529919250324', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_2.js new file mode 100644 index 00000000000..5a716c6e8e9 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_2.js @@ -0,0 +1,283 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '6123799897847039642', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKRCKARBAAAAwDWAAUBCMmFp_AFEJqN_JX98Yb-VBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIUN6dzV3Z2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYQm5aNWdRbi1NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASFJQS1IREE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkcADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSMo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=a7e4ff14c60153db90971365f90e514f45875324', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnJwgleAAAAABGaBr_Sjxv8VBnJwgleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=842283d9de78fba7e92fac09f95bb63902a0b54a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLtCOhtBAAAAwDWAAUBCMmFp_AFEJqN_JX98Yb-VBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4zrgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFDenc1d2dpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWEJuWjVnUW4tTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhSUEtSERBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMdAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgkkKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=0fb74d544be103e1440c3ee8f7abc14d2c322d15' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '889501690217653627', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEPvKoYSxoomsDBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIWt6eTlHUWlua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFRSzgzNzR1VnVVXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASFTd19PR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=78ac70aeeae1da43c90efd248fb30a4ee630ffd5', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnJwgleAAAAABF7ZYgQEyVYDBnJwgleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=f21e2a522ddcaf0a67bc7d52f70288fdf7e6f3dd&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEPvKoYSxoomsDBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4zrgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFrenk5R1FpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUUs4Mzc0dVZ1VV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhU3dfT0d3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=69611db1024ddb77e0754087ddbeae68a00633a1' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '2793012314322059080', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEMj-1IPuvLHhJhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE0MTg4Nh8A8P2SArkCIXhqb2ZBZ2lHa184UEVLekNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFRQWhlSGt0VHVRXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASExZzc1OFE2PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAOAEAPAErMKfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBfKMAfoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=243f58d85b09468de2fe485662c950a86b5d90fb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnJwgleAAAAABFIP3Xg5sXCJhnJwgleAAAAACCswp9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jyjAFiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAazCn0ewAQE.&s=99dd40ab6ae736c6aa7c96b5319e1723ea581e0d&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149414188, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 32, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 29000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEMj-1IPuvLHhJhiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQrMKfR1ic8VtgAGjNunV4zrgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxNDE4OCwgMTUZH_D9kgK5AiF4am9mQWdpR2tfOFBFS3pDbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBUUFoZUhrdFR1UV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhMWc3NThRNj0BJG5QRmJJQVFvQUQVSFRxUURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AXyjAH6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=d9a3c817696f263b6e6d81f7251827fa54a47c37' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '45194178065897765', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '3805126675549039795', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFELPZ2uvQ0aHnNBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIWNUM1hkZ2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFjbUQzMExTME9VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0BBRHdQdy4umgKJASEtUTZrXzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qASv5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0M9oEAggA4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAaWR0ANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=bbeaa584bea9afedf6dcab51b1616988441dfa22', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnJwgleAAAAABGzrHYNjYbONBnJwgleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=b7e937b5acc3d8b910f6b08c3a40e04aa10818cd&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFELPZ2uvQ0aHnNBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4zrgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFjVDNYZGdpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBY21EMzBMUzBPVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNAQUR3UHcuLpoCiQEhLVE2a186PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8JplQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkNVU1RPTREdCEFTVAEL8N5JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAeAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgAAYeYo8D_QBvUv2gYWChABDy4BAFAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=279827127eba3204bc3a152b8abaf701260eb494' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-1.js b/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-1.js new file mode 100644 index 00000000000..9c4128fc004 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-1.js @@ -0,0 +1,110 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232392, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + } + }] + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '256e5e4b136d05', + 'tag_id': 13232392, + 'auction_id': '6287559286677633407', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKICKAIBAAAAwDWAAUBCM3FpfEFEP_yg9W7u_mgVxi7_-bKzp3kuD8qNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMIjSpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5NzcwNTczKTsBHSxyJywgOTc1MjA0MzQ2HgDw0JICtQIhQWp4NUh3aUgtYndLRUxLV3dDNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUWlOS25CbGdBWUtzR2FBQndBbmlLQVlBQkhvZ0JpZ0dRQVFDWUFRQ2dBUUdvQVFPd0FRQzVBZk90YXFRQUFDUkF3UUh6cldxa0FBQWtRTWtCb2FZc1BwVDM0VF9aQVFBQUFBQUFBUEFfNEFFQTlRRUFBQUFBbUFJQW9BSUF0UUlBQUFBQXZRSUFBQUFBNEFJQTZBSUEtQUlBZ0FNQm1BTUJxQU9IAcSIdWdNSlUwbE9Nem8wT0RRMDRBUDRHWWdFQUpBRUFKZ0VBY0UJXQUBCERKQgUICQEYMkFRQThRUQkNAQEsUGdFQUlnRjdDV3BCERc0UEFfmgKJASFDZy1TX2c2OQEkblBGYklBUW9BRBVkDGtRRG8ykQAQUVBnWlMdTQBVEQwMQUFBVx0MAFkdDABhHQwAYx0MoGVBQS7YAgDgAq2YSOoCS2h0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5BRTw3i9wYWdlcy9tdWx0aXBsZV9iaWRkZXJzLmh0bWw_cGJqc19kZWJ1Zz10cnVlgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQOMTAzLjc5LjEwMC4xODCoBOZCsgQQCAQQARgAIAAoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0ODQ02gQCCADgBAHwBLKWwC6IBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAABDnDYBQHgBQHwBZn0IfoFBAgAEACQBgGYBgC4BgDBBgEhMAAA8L_QBvUv2gYWChAJERkBUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=8b14b952b73092945ef66436be991786b53f7a68', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97520434, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'sponsored': 'Prebid.org', + 'main_img': { + 'url': 'https://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'width': 989, + 'height': 742, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-multi-format-ads.html', + 'click_trackers': ['https://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQH_5oLrb5UFXu79Z6eyQcT_NYileAAAAAAjpyQBtJAAAbSQAAAIAAAAyC9AFnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoAnRbC8wAAAAA./bcr=AAAAAAAA8D8=/cnd=%21Cg-S_giH-bwKELKWwC4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0ODQ0QPgZSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ4NDQ=/bn=89112/'] + }, + 'impression_trackers': ['https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKQCKAQBAAAAwDWAAUBCM3FpfEFEP_yg9W7u_mgVxi7_-bKzp3kuD8qNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIjSpwY47UhA7UhIAlCylsAuWJzxW2AAaM26dXiYuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1Nzk3NzA1NzMpO3VmKCdyJywgOTc1MjA0MzQsIC4eAPDQkgK1AiFBang1SHdpSC1id0tFTEtXd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRaU5LbkJsZ0FZS3NHYUFCd0FuaUtBWUFCSG9nQmlnR1FBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0JvYVlzUHBUMzRUX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBT0gBxIh1Z01KVTBsT016bzBPRFEwNEFQNEdZZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BASxQZ0VBSWdGN0NXcEIRFzRQQV-aAokBIUNnLVNfZzY5ASRuUEZiSUFRb0FEFWQMa1FEbzKRABBRUGdaUx1NAFURDAxBQUFXHQwAWR0MAGEdDABjHQygZUFBLtgCAOACrZhI6gJLaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkFFPDeL3BhZ2VzL211bHRpcGxlX2JpZGRlcnMuaHRtbD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA4xMDMuNzkuMTAwLjE4MKgE5kKyBBAIBBABGAAgACgBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ4NDTaBAIIAeAEAfAEspbALogFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAEOcNgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGASEwAADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGDPIGAggAgAcBiAcAoAdB&s=2061bd85ce022a41bc16ebb20c193aabbbc07809'], + 'id': 97520434 + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-2.js b/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-2.js new file mode 100644 index 00000000000..d3c8e8ea376 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-2.js @@ -0,0 +1,175 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 300, + 'height': 250 + }, { + 'width': 300, + 'height': 600 + }], + 'primary_size': { + 'width': 300, + 'height': 250 + }, + 'ad_types': ['banner'], + 'id': 13232392, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true + }, { + 'sizes': [{ + 'width': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232354, + 'allow_smaller_sizes': true, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'description': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + }, + 'icon': { + 'required': false + } + }] + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '28ae233df319a1', + 'tag_id': 13232392, + 'auction_id': '6917498423334366136', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QLBCKBBBAAAAwDWAAUBCNGcpvEFELjXrYmmhfn_Xxi7_-bKzp3kuD8qNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQn0gQEkQDCI0qcGOO1IQO1ISABQAFic8VtgAGjNunV4AIABAYoBAJIBA1VTRJgBrAKgAfoBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5NzgxNzEzKTt1ZigncicsIDk2ODQ2MDM1LCAxNTc5NzgxNzEzKTuSArUCITZEb2NyZ2lILWJ3S0VOT0JseTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFpTktuQmxnQVlLc0dhQUJ3R25oaWdBR1lBWWdCWXBBQkFKZ0JBS0FCQWFnQkE3QUJBTGtCODYxcXBBQUFKRURCQWZPdGFxUUFBQ1JBeVFHQ1VBT2x6Q0xkUDlrQkFBQUFBQUFBOERfZ0FRRDFBUUFBQUFDWUFnQ2dBZ0MxQWdBQUFBQzlBZ0FBQUFEZ0FnRG9BZ0Q0QWdDQUF3R1lBd0dvQTRmNXZBcTZBd2xUU1U0ek9qUTNNem5nQV9nWmlBUUFrQVFBbUFRQndRUQFNCQEITWtFCQkBARhEWUJBRHhCAQsNASwtQVFBaUFXREpha0YNE0BBOEQ4LpoCiQEhOEE1YjlRaTI5ASRuUEZiSUFRb0FEFVhYa1FEb0pVMGxPTXpvME56TTVRUGdaU1ENTwxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EZlQUEuwgI1aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy1tdWx0aS1mb3JtYXQtYWRzLmh0bWzYAgDgAq2YSOoCSw1ASHRlc3QubG9jYWxob3N0Ojk5OTkFFBgvcGFnZXMvBUYocGxlX2JpZGRlcnMFRvBAP3BianNfZGVidWc9dHJ1ZYADAIgDAZADAJgDF6ADAaoDAMADrALIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMNtvBhmAQAogQOMTAzLjc5LjEwMC4xODCoBJ9EsgQSCAQQARisAiD6ASgBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MznaBAIIAOAEAfAE04GXLogFAZgFAKAF______8BAxQBwAUAyQVpiBTwP9IFCQkJDHAAANgFAeAFAfAFAfoFBAgAEACQBgCYBgC4BgDBBgkjKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYB8gYCCACABwGIBwCgBwE.&s=8d42ac30ca2d2a8a63215f5aba2a43bd23af0023', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'banner', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 96846035, + 'media_type_id': 1, + 'media_subtype_id': 1, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 0, + 'client_initiated_ad_counting': true, + 'rtb': { + 'banner': { + 'content': "
", + 'width': 300, + 'height': 250 + }, + 'trackers': [{ + 'impression_urls': ['https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QLJCKBJBAAAAwDWAAUBCNGcpvEFELjXrYmmhfn_Xxi7_-bKzp3kuD8qNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIjSpwY47UhA7UhIAlDTgZcuWJzxW2AAaM26dXicuAWAAQGKAQNVU0SSAQEG8FKYAawCoAH6AagBAbABALgBAcABBMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3OTc4MTcxMyk7dWYoJ3InLCA5Njg0NjAzNTYeAPCakgK1AiE2RG9jcmdpSC1id0tFTk9CbHk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRaU5LbkJsZ0FZS3NHYUFCd0duaGlnQUdZQVlnQllwQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRR0NVQU9sekNMZFA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BNGY1dkFxNkF3bFRTVTR6T2pRM016bmdBX2daaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVdESmFrRg0TPEE4RDgumgKJASE4QTViOVE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBOek01UVBnWlNRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBGZUFBLsICNWh0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctbXVsdGktZm9ybWF0LWFkcy5odG1s2AIA4AKtmEjqAksNQEh0ZXN0LmxvY2FsaG9zdDo5OTk5BRQYL3BhZ2VzLwVGKHBsZV9iaWRkZXJzBUbwQD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDbbwYZgEAKIEDjEwMy43OS4xMDAuMTgwqASfRLIEEggEEAEYrAIg-gEoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM52gQCCAHgBAHwBNOBly6IBQGYBQCgBf______AQMUAcAFAMkFaZAU8D_SBQkJCQxwAADYBQHgBQHwBQH6BQQIABAAkAYAmAYAuAYAwQYJIyjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGAfIGAggAgAcBiAcAoAcB&s=6c6fb8a005b60bc5535b528c16ed74cd66c08dd0'], + 'video_events': {} + }] + } + }] + }, { + 'uuid': '375d249fda4d84', + 'tag_id': 13232354, + 'auction_id': '2793298983265666969', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKGCKAGBAAAAwDWAAUBCNGcpvEFEJmPioiD1PLhJhi7_-bKzp3kuD8qNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMOLRpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5NzgxNzEzKTsBHSxyJywgOTc0OTQyMDQ2HgDw0JICtQIhZ2oxVmFnajgtTHdLRUx6SnZpNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUTR0R25CbGdBWUtzR2FBQndCbmlhQklBQm1BR0lBV0tRQVFDWUFRQ2dBUUdvQVFPd0FRQzVBZk90YXFRQUFDUkF3UUh6cldxa0FBQWtRTWtCQXNyenVXOVg0RF9aQVFBQUFBQUFBUEFfNEFFQTlRRUFBQUFBbUFJQW9BSUF0UUlBQUFBQXZRSUFBQUFBNEFJQTZBSUEtQUlBZ0FNQm1BTUJxQVA4AcSIdWdNSlUwbE9Nem8wTnpNNTRBUDRHWWdFQUpBRUFKZ0VBY0UJXQUBCERKQgUICQEYMkFRQThRUQkNAQEsUGdFQUlnRmd5V3BCERc0UEFfmgKJASF2QS1kUHc2OQEkblBGYklBUW9BRBVkDGtRRG8ykQAQUVBnWlMdTQBVEQwMQUFBVx0MAFkdDABhHQwAYx0MoGVBQS7YAgDgAq2YSOoCS2h0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5BRT0DgEvcGFnZXMvbXVsdGlwbGVfYmlkZGVycy5odG1sP3BianNfZGVidWc9dHJ1ZYADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDjEwMy43OS4xMDAuMTgwqASfRLIEDggAEAEYACAAKAAwADgCuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MznaBAIIAOAEAfAEvMm-LogFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBZn0IfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYM8gYCCACABwGIBwCgB0E.&s=acd26154fe24e1ce797e3016322901140c18ce65', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97494204, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'desc': 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + 'sponsored': 'Prebid.org', + 'icon': { + 'url': 'https://vcdn.adnxs.com/p/creative-image/1a/3e/e9/5b/1a3ee95b-06cd-4260-98c7-0258627c9197.png', + 'width': 127, + 'height': 83, + 'prevent_crop': false + }, + 'main_img': { + 'url': 'https://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'width': 989, + 'height': 742, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-native-ads.html', + 'click_trackers': ['https://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQJmHAjGgysMmu79Z6eyQcT9RjileAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoAxBbHxgAAAAA./bcr=AAAAAAAA8D8=/cnd=%21vA-dPwj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0NzM5QPgZSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ3Mzk=/bn=89116/'] + }, + 'impression_trackers': ['https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKOCKAOBAAAAwDWAAUBCNGcpvEFEJmPioiD1PLhJhi7_-bKzp3kuD8qNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXicuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1Nzk3ODE3MTMpO3VmKCdyJywgOTc0OTQyMDQsIC4eAPDQkgK1AiFnajFWYWdqOC1Md0tFTHpKdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZS3NHYUFCd0JuaWFCSUFCbUFHSUFXS1FBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0JBc3J6dVc5WDREX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBUDgBxIh1Z01KVTBsT016bzBOek01NEFQNEdZZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BASxQZ0VBSWdGZ3lXcEIRFzRQQV-aAokBIXZBLWRQdzY5ASRuUEZiSUFRb0FEFWQMa1FEbzKRABBRUGdaUx1NAFURDAxBQUFXHQwAWR0MAGEdDABjHQygZUFBLtgCAOACrZhI6gJLaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkFFPQOAS9wYWdlcy9tdWx0aXBsZV9iaWRkZXJzLmh0bWw_cGJqc19kZWJ1Zz10cnVlgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQOMTAzLjc5LjEwMC4xODCoBJ9EsgQOCAAQARgAIAAoADAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczOdoEAggB4AQB8AS8yb4uiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8D_QBvUv2gYWChAJERkBUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=2d3f9336af4da684d7733e29f53bbb80bf69a18c'], + 'id': 97494204 + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/native/index.js b/test/mock-server/expectations/request-response-pairs/native/index.js new file mode 100644 index 00000000000..f9a8b9e3585 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/native/index.js @@ -0,0 +1,191 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232354, + 'allow_smaller_sizes': true, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + } + }] + } + }, { + 'sizes': [{ + 'width': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232354, + 'allow_smaller_sizes': true, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'description': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + }, + 'icon': { + 'required': false + } + }] + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2b7ae9fa0e76be', + 'tag_id': 13232354, + 'auction_id': '2566965852006062421', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fnative.html&e=wqT_3QLhB6DhAwAAAwDWAAUBCNDZme8FENWyhPv4uuzPIxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMOLRpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc1MzgyMjI0KTsBHThyJywgOTc0OTQ0MDMsIDEdHvDQkgKpAiFCenhPTlFqOC1Md0tFSVBMdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZSUlDYUFCd0FIZ0FnQUdtQVlnQl9GLVFBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0JRTDdBTHVfbzFqX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBUDgBxIh1Z01KVTBsT016bzBOelF5NEFQbUZvZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BAVBQZ0VBSWdGaGlVLpoCiQEhYWdfb0o6LQEkblBGYklBUW9BRBVYDGtRRG8yhQAQUU9ZV1MRWAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0MoGVBQS7YAgDgAq2YSOoCMWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5BRTwvC9wYWdlcy9uYXRpdmUuaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qATruAKyBA4IABABGAAgACgAMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQy2gQCCADgBAHwBIPLvi6IBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQkMeAAA2AUB4AUB8AWZ9CH6BQQIABAAkAYBmAYAuAYAwQYJJTTwv8gGANAG9S_aBhYKEAkUGQFQEAAYAOAGDPIGAggAgAcBiAcAoAdB&s=54514bb848c51d509dfe3e21af09b77edfe9738e', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97494403, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'sponsored': 'Prebid.org', + 'main_img': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/94/22/cd/0f/9422cd0f-f400-45d3-80f5-2b92629d9257.jpg', + 'width': 3000, + 'height': 2250, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-native-ads.html', + 'click_trackers': ['http://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQFUZYY_XsZ8jKnKSKrrb42HQbOZdAAAAAOLoyQBtJAAAbSQAAAIAAACDpc8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoA8BZszgAAAAA./bcr=AAAAAAAA8D8=/cnd=%21ag_oJQj8-LwKEIPLvi4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0NzQyQOYWSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ3NDI=/bn=89169/'] + }, + 'impression_trackers': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fnative.html&e=wqT_3QLpB6DpAwAAAwDWAAUBCNDZme8FENWyhPv4uuzPIxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlCDy74uWJzxW2AAaM26dXjRuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzUzODIyMjQpO3VmKCdyJywgOTc0OTQ0MDMsIC4eAPDQkgKpAiFCenhPTlFqOC1Md0tFSVBMdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZSUlDYUFCd0FIZ0FnQUdtQVlnQl9GLVFBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0JRTDdBTHVfbzFqX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBUDgBxIh1Z01KVTBsT016bzBOelF5NEFQbUZvZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BAVBQZ0VBSWdGaGlVLpoCiQEhYWdfb0o6LQEkblBGYklBUW9BRBVYDGtRRG8yhQAQUU9ZV1MRWAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0MoGVBQS7YAgDgAq2YSOoCMWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5BRTwlS9wYWdlcy9uYXRpdmUuaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qATruAKyBA4IABABGAAgACgAMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQy2gQCCAHgBAHwBEH6IIgFAZgFAKAF_xEBGAHABQDJBQAFARTwP9IFCQkFC3wAAADYBQHgBQHwBZn0IfoFBAgAEACQBgGYBgC4BgDBBgEhQAAA8D_IBgDQBvUv2gYWChAAOgEAUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=6b203c7aee654cffa9c0b3771f6945f6d1e8d06c'], + 'id': 97494403 + } + } + }] + }, { + 'uuid': '35598a5ad26f59', + 'tag_id': 13232354, + 'auction_id': '6083251961435599864', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fnative.html&e=wqT_3QLhB6DhAwAAAwDWAAUBCNDZme8FEPjnxITbrYO2VBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMOLRpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc1MzgyMjI0KTsBHSxyJywgOTc0OTQyMDQ2HgDw0JICqQIhYlR3OWZBajgtTHdLRUx6SnZpNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUTR0R25CbGdBWUlJQ2FBQndBSGdBZ0FHbUFZZ0JfRi1RQVFDWUFRQ2dBUUdvQVFPd0FRQzVBZk90YXFRQUFDUkF3UUh6cldxa0FBQWtRTWtCeVdmYjBYeWIxVF9aQVFBQUFBQUFBUEFfNEFFQTlRRUFBQUFBbUFJQW9BSUF0UUlBQUFBQXZRSUFBQUFBNEFJQTZBSUEtQUlBZ0FNQm1BTUJxQVA4AcSIdWdNSlUwbE9Nem8wTnpReTRBUG1Gb2dFQUpBRUFKZ0VBY0UJXQUBCERKQgUICQEYMkFRQThRUQkNAQFUUGdFQUlnRmhpVS6aAokBIW9ROTNPUTYtASRuUEZiSUFRb0FEFVgMa1FEbzKFABBRT1lXUxFYDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQygZUFBLtgCAOACrZhI6gIxaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkFFPC8L3BhZ2VzL25hdGl2ZS5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBOu4ArIEDggAEAEYACAAKAAwADgCuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDLaBAIIAOAEAfAEvMm-LogFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJCQx4AADYBQHgBQHwBZn0IfoFBAgAEACQBgGYBgC4BgDBBgklNPC_yAYA0Ab1L9oGFgoQCRQZAVAQABgA4AYM8gYCCACABwGIBwCgB0E.&s=99a73b39ab82dd9384eee306ff03276ab688cfe5', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97494204, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'desc': 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + 'sponsored': 'Prebid.org', + 'icon': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/1a/3e/e9/5b/1a3ee95b-06cd-4260-98c7-0258627c9197.png', + 'width': 127, + 'height': 83, + 'prevent_crop': false + }, + 'main_img': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'width': 989, + 'height': 742, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-native-ads.html', + 'click_trackers': ['http://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQPgzkbBtDWxUKnKSKrrb42HQbOZdAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoAJhcX3AAAAAA./bcr=AAAAAAAA8D8=/cnd=%21oQ93OQj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0NzQyQOYWSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ3NDI=/bn=89169/'] + }, + 'impression_trackers': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fnative.html&e=wqT_3QLpB6DpAwAAAwDWAAUBCNDZme8FEPjnxITbrYO2VBiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXjRuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzUzODIyMjQpO3VmKCdyJywgOTc0OTQyMDQsIC4eAPDQkgKpAiFiVHc5ZkFqOC1Md0tFTHpKdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZSUlDYUFCd0FIZ0FnQUdtQVlnQl9GLVFBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0J5V2ZiMFh5YjFUX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBUDgBxIh1Z01KVTBsT016bzBOelF5NEFQbUZvZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BAVRQZ0VBSWdGaGlVLpoCiQEhb1E5M09RNi0BJG5QRmJJQVFvQUQVWAxrUURvMoUAEFFPWVdTEVgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDKBlQUEu2AIA4AKtmEjqAjFodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OQUU8LwvcGFnZXMvbmF0aXZlLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagE67gCsgQOCAAQARgAIAAoADAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDc0MtoEAggB4AQB8AS8yb4uiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkJDHgAANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSU48D_IBgDQBvUv2gYWChAAOgEAUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=5c316c116b6e2bdb19f3950c4c769821e735688e'], + 'id': 97494204 + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/outstream/index.js b/test/mock-server/expectations/request-response-pairs/outstream/index.js new file mode 100644 index 00000000000..be5f4654b9f --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/outstream/index.js @@ -0,0 +1,162 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 13232385, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'video': { + 'skippable': true, + 'playback_method': ['auto_play_sound_off'] + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 13232385, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'video': { + 'skippable': true, + 'playback_method': ['auto_play_sound_off'] + } + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '223e8549781f2e', + 'tag_id': 13232385, + 'auction_id': '527250675737245396', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Foutstream.html&e=wqT_3QKwCKAwBAAAAwDWAAUBCOiWpO8FENTtnJej9sqoBxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMIHSpwY47UhA7UhIAFAAWJzxW2AAaOWljwF4AIABAYoBAJIBA1VTRJgBAaABAagBAbABALgBA8ABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3NTU1Mzg5NikFHTRyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFUenpuS1FqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSG5NQW5aODYzalA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TOEE4RDgumgKJASFXdzkxSDo5ASRuUEZiSUFRb0FEFVhYa1FEb0pVMGxPTXpvME9ETTBRUGtXU1ENTwxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EllQUEuwgI4aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy1vdXRzdHJlYW0tdmlkZW8tYWRzLmh0bWzYAgDgAq2YSOoCNA1DSHRlc3QubG9jYWxob3N0Ojk5OTkFFBgvcGFnZXMvFUkALgE_yIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzLwmj8F6YBACiBAsxMC43NS43NC42OagEmM8CsgQSCAQQBBiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ4MzTaBAIIAOAEAPAEy4HALogFAZgFAKAF_____wUDFAHABQDJBWlyFPA_0gUJCQkMeAAA2AUB4AUB8AXDlQv6BQQIABAAkAYBmAYAuAYAwQYJJTTwv8gGANAG9S_aBhYKEAkUGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=9953ce4d94992db04897ab580bf81b3e274b2601', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQloC-ldAAAAABHUNucysitRBxloC-ldAAAAACDLgcAuKAAw7Ug47UhA0-hISLuv1AFQgdKnBljDlQtiAi0taAFwAXgAgAECiAEEkAGABZgB4AOgAQCoAcuBwC6wAQE.&s=979aee1106a0bea5609a3c23fdc46153ad6d9eec&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97517771, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 36, + 'renderer_url': 'http://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + 'renderer_id': 2, + 'renderer_config': '{"skippable":{"videoThreshold":null,"skipLocation":"top-right"}}', + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': 'tv=vh2-121&d=1x1&s=3479483&st=0&vctx=4&ts=1575553896&vc=iab;vid_ccr=1&vjs=http%3A%2F%2Fcdn.adnxs.com%2Fv%2Fvideo%2F182%2Ftrk.js&cb=http%3A%2F%2Fsin3-ib.adnxs.com%2Fvevent%3Fan_audit%3D0%26referrer%3Dhttp%253A%252F%252Ftest.localhost%253A9999%252Ftest%252Fpages%252Foutstream.html%26e%3DwqT_3QK4CKA4BAAAAwDWAAUBCOiWpO8FENTtnJej9sqoBxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIHSpwY47UhA7UhIAlDLgcAuWJzxW2AAaOWljwF4urgFgAEBigEDVVNEkgUG8FKYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzU1NTM4OTYpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFUenpuS1FqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSG5NQW5aODYzalA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TOEE4RDgumgKJASFXdzkxSDo5ASRuUEZiSUFRb0FEFVhYa1FEb0pVMGxPTXpvME9ETTBRUGtXU1ENTwxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EllQUEuwgI4aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy1vdXRzdHJlYW0tdmlkZW8tYWRzLmh0bWzYAgDgAq2YSOoCNA1DSHRlc3QubG9jYWxob3N0Ojk5OTkFFBgvcGFnZXMvFUkALgE_yIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzLwmj8F6YBACiBAsxMC43NS43NC42OagEmM8CsgQSCAQQBBiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ4MzTaBAIIAeAEAPAEy4HALogFAZgFAKAF_____wUDFAHABQDJBWl6FPA_0gUJCQkMeAAA2AUB4AUB8AXDlQv6BQQIABAAkAYBmAYAuAYAwQYJJTTwP8gGANAG9S_aBhYKEAkUGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA%26s%3D5adef946cd5f0d8db86d67860914e02ef6f91d6b&cet=0&cecb=&rdcb=http%3A%2F%2Fsin3-ib.adnxs.com%2Frd_log%3Fan_audit%3D0%26referrer%3Dhttp%253A%252F%252Ftest.localhost%253A9999%252Ftest%252Fpages%252Foutstream.html%26e%3DwqT_3QKMCaCMBAAAAwDWAAUBCOiWpO8FENTtnJej9sqoBxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIHSpwY47UhA7UhIAlDLgcAuWJzxW2AAaOWljwF4urgFgAEBigEDVVNEkgUG8FKYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzU1NTM4OTYpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFUenpuS1FqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSG5NQW5aODYzalA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TOEE4RDgumgKJASFXdzkxSDo5ASRuUEZiSUFRb0FEFVhYa1FEb0pVMGxPTXpvME9ETTBRUGtXU1ENTwxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EllQUEuwgI4aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy1vdXRzdHJlYW0tdmlkZW8tYWRzLmh0bWzYAgDgAq2YSOoCNA1DSHRlc3QubG9jYWxob3N0Ojk5OTkFFBgvcGFnZXMvFUkALgE_aPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7gSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDffwXpgEAKIECzEwLjc1Ljc0LjY5qASYzwKyBBIIBBAEGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDgzNNoEAggB4AQA8ATLgcAuiAUBmAUAoAX_____BQMUAcAFAMkFac4U8D_SBQkJCQx4AADYBQHgBQHwBcOVC_oFBAgAEACQBgGYBgC4BgDBBgklNPA_yAYA0Ab1L9oGFgoQCRQZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.%26s%3Df2a73057b50fb0c9e98a6093141472a4ed2e401e&bridge=1.11.0&rblog=auc=527250675737245396;bm=9325;sm=9325;cr=97517771;pl=13232385&vid_context=anoutstream;anbannerstream;anoverlayplayer' + }, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_off'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'content': 'adnxs00:00:30.000' + } + } + }] + }, { + 'uuid': '3acfd472dd4bdf', + 'tag_id': 13232385, + 'auction_id': '3449642271543746980', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Foutstream.html&e=wqT_3QKwCKAwBAAAAwDWAAUBCOiWpO8FEKTDpazn6-XvLxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMIHSpwY47UhA7UhIAFAAWJzxW2AAaOWljwF4AIABAYoBAJIBA1VTRJgBAaABAagBAbABALgBA8ABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3NTU1Mzg5NikFHTRyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFvendNV2dqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSHIwdDF2TTdMaVA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TPEE4RDgumgKJASFXdzkxSFE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBPRE0wUVBrV1NRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBJZUFBLsICOGh0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctb3V0c3RyZWFtLXZpZGVvLWFkcy5odG1s2AIA4AKtmEjqAjQNQ0h0ZXN0LmxvY2FsaG9zdDo5OTk5BRQYL3BhZ2VzLxVJAC4BP8iAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My8Jo_BemAQAogQLMTAuNzUuNzQuNjmoBJjPArIEEggEEAQYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0ODM02gQCCADgBADwBMuBwC6IBQGYBQCgBf____8FAxQBwAUAyQVpchTwP9IFCQkJDHgAANgFAeAFAfAFw5UL-gUECAAQAJAGAZgGALgGAMEGCSU08L_IBgDQBvUv2gYWChAJFBkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=e43b45a2391036da6d93eda546d8808de0169bb1', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQloC-ldAAAAABGkYYl1XpffLxloC-ldAAAAACDLgcAuKAAw7Ug47UhA0-hISLuv1AFQgdKnBljDlQtiAi0taAFwAXgAgAECiAEEkAGABZgB4AOgAQCoAcuBwC6wAQE.&s=414834fdc6e268f284292aedf8b01ee525c3e999&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97517771, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 36, + 'renderer_url': 'http://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + 'renderer_id': 2, + 'renderer_config': '{"skippable":{"videoThreshold":null,"skipLocation":"top-right"}}', + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': 'tv=vh2-121&d=1x1&s=3479483&st=0&vctx=4&ts=1575553896&vc=iab;vid_ccr=1&vjs=http%3A%2F%2Fcdn.adnxs.com%2Fv%2Fvideo%2F182%2Ftrk.js&cb=http%3A%2F%2Fsin3-ib.adnxs.com%2Fvevent%3Fan_audit%3D0%26referrer%3Dhttp%253A%252F%252Ftest.localhost%253A9999%252Ftest%252Fpages%252Foutstream.html%26e%3DwqT_3QK4CKA4BAAAAwDWAAUBCOiWpO8FEKTDpazn6-XvLxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIHSpwY47UhA7UhIAlDLgcAuWJzxW2AAaOWljwF4urgFgAEBigEDVVNEkgUG8FKYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzU1NTM4OTYpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFvendNV2dqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSHIwdDF2TTdMaVA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TPEE4RDgumgKJASFXdzkxSFE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBPRE0wUVBrV1NRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBJZUFBLsICOGh0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctb3V0c3RyZWFtLXZpZGVvLWFkcy5odG1s2AIA4AKtmEjqAjQNQ0h0ZXN0LmxvY2FsaG9zdDo5OTk5BRQYL3BhZ2VzLxVJAC4BP8iAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My8Jo_BemAQAogQLMTAuNzUuNzQuNjmoBJjPArIEEggEEAQYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0ODM02gQCCAHgBADwBMuBwC6IBQGYBQCgBf____8FAxQBwAUAyQVpehTwP9IFCQkJDHgAANgFAeAFAfAFw5UL-gUECAAQAJAGAZgGALgGAMEGCSU08D_IBgDQBvUv2gYWChAJFBkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..%26s%3Dc2a8dac8959d9366981afc868ec5b54853090944&cet=0&cecb=&rdcb=http%3A%2F%2Fsin3-ib.adnxs.com%2Frd_log%3Fan_audit%3D0%26referrer%3Dhttp%253A%252F%252Ftest.localhost%253A9999%252Ftest%252Fpages%252Foutstream.html%26e%3DwqT_3QKMCaCMBAAAAwDWAAUBCOiWpO8FEKTDpazn6-XvLxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIHSpwY47UhA7UhIAlDLgcAuWJzxW2AAaOWljwF4urgFgAEBigEDVVNEkgUG8FKYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzU1NTM4OTYpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFvendNV2dqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSHIwdDF2TTdMaVA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TPEE4RDgumgKJASFXdzkxSFE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBPRE0wUVBrV1NRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBJZUFBLsICOGh0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctb3V0c3RyZWFtLXZpZGVvLWFkcy5odG1s2AIA4AKtmEjqAjQNQ0h0ZXN0LmxvY2FsaG9zdDo5OTk5BRQYL3BhZ2VzLxVJAC4BP2jyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-4ElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92Mw338F6YBACiBAsxMC43NS43NC42OagEmM8CsgQSCAQQBBiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ4MzTaBAIIAeAEAPAEy4HALogFAZgFAKAF_____wUDFAHABQDJBWnOFPA_0gUJCQkMeAAA2AUB4AUB8AXDlQv6BQQIABAAkAYBmAYAuAYAwQYJJTTwP8gGANAG9S_aBhYKEAkUGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA%26s%3D4e9e218d8f075cb19c4a4e8da2a7e716fa15d3c5&bridge=1.11.0&rblog=auc=3449642271543746980;bm=9325;sm=9325;cr=97517771;pl=13232385&vid_context=anoutstream;anbannerstream;anoverlayplayer' + }, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_off'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'content': 'adnxs00:00:30.000' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/index.js b/test/mock-server/index.js new file mode 100644 index 00000000000..9a97ca5e0a0 --- /dev/null +++ b/test/mock-server/index.js @@ -0,0 +1,37 @@ +/* eslint-disable no-console */ +const express = require('express'); +const argv = require('yargs').argv; +const app = module.exports = express(); +const port = (argv.port) ? argv.port : 3000; +const bodyParser = require('body-parser'); +const renderCreative = require('./request-middlewares/prebid-request.js'); + +app.use(express.static(__dirname + '/content')); +app.use(bodyParser.text({type: 'text/plain'})); + +app.locals = { + 'port': port, + 'host': 'localhost' +}; + +// get type will be used to test prebid jsonp requests +app.get('/', renderCreative, (request, response) => { + response.send(); +}); + +// prebid make POST type request to ut endpoint so here we will match ut endpoint request. +app.post('/', renderCreative, (request, response) => { + response.send(); +}); + +app.listen(port, (err) => { + if (err) { + return console.log('something bad happened', err); + } + + console.log(`server is listening on ${port}`); +}); + +process.on('SIGTERM', function() { console.log('halt mock-server'); process.exit(0) }); + +process.on('SIGINT', function() { console.log('shutdown mock-server'); process.exit(0) }); diff --git a/test/mock-server/request-middlewares/prebid-request.js b/test/mock-server/request-middlewares/prebid-request.js new file mode 100644 index 00000000000..b14c3119247 --- /dev/null +++ b/test/mock-server/request-middlewares/prebid-request.js @@ -0,0 +1,75 @@ +/** + * This middleware will be used to find matching request hitting the ut endpoint by prebid. + * As of now it only uses the request payload to compare with httpRequest.body defined in expectations dir. + * Matching headers or cookies can also be the use case. + */ + +const glob = require('glob'); +const path = require('path'); +const deepEqual = require('deep-equal'); + +module.exports = function (req, res, next) { + let reqBody; + try { + if (req.method === 'GET') { + reqBody = JSON.parse(req.query.q); + } else { + reqBody = JSON.parse(req.body); + } + } catch (e) { + // error + } + + // prebid uses uuid to match request response pairs. + // On each request new uuid is generated, so here i am grabbing the uuid from incoming request and adding it to matched response. + let uuidObj = {}; + if (reqBody && reqBody.uuid) { + uuidObj.response = reqBody.uuid; + delete reqBody.uuid; + } + + if (reqBody && reqBody.tags) { + uuidObj.tags = reqBody.tags.map((tag) => { + let uuid = tag.uuid; + delete tag.uuid; + return uuid; + }); + } + + // values within these request props are dynamically generated and aren't + // vital to check in these tests, so they are deleted rather than updating + // the request-response pairs continuously + ['sdk', 'referrer_detection', 'brand_category_uniqueness', 'gdpr_consent'].forEach(prop => { + if (reqBody && reqBody[prop]) { + delete reqBody[prop]; + } + }); + + // Parse all the expectation to find response for this request + glob.sync('./test/mock-server/expectations/**/*.js').some((file) => { + file = require(path.resolve(file)); + let expectedReqBody = JSON.parse(JSON.stringify(file.getRequest().httpRequest.body)); + // respond to all requests + // TODO send a 404 if resource not found + res.set({ + 'Access-Control-Allow-Credentials': 'true', + 'Access-Control-Allow-Origin': req.headers.origin + }); + + // As of now only body is compared. We can also add other request properties like headers, cookies if required + if (deepEqual(reqBody, expectedReqBody)) { + let response = file.getResponse().httpResponse.body; + if (Object.keys(uuidObj).length > 0) { + response.tags.forEach((tag, index) => { + tag.uuid = uuidObj.tags[index]; + }); + } + res.type('json'); + response = JSON.stringify(response); + res.write(response); + return true; + } + }); + + next(); +}; diff --git a/test/mocks/adloaderStub.js b/test/mocks/adloaderStub.js index 9b9e62a4c3b..b52ca5e9280 100644 --- a/test/mocks/adloaderStub.js +++ b/test/mocks/adloaderStub.js @@ -1,23 +1,23 @@ -import * as adloader from 'src/adloader'; +import * as adloader from 'src/adloader.js'; -let sandbox; +// this export is for adloader's tests against actual implementation +export let loadExternalScript = adloader.loadExternalScript; -export let loadScript; -export let loadExternalScript; -export let loadScriptStub; -export let loadExternalScriptStub; +let stub = createStub(); -beforeEach(function() { - sandbox = sinon.sandbox.create(); - loadScript = adloader.loadScript; - loadExternalScript = adloader.loadExternalScript; - loadScriptStub = sandbox.stub(adloader, 'loadScript').callsFake((...args) => { - args[1](); +function createStub() { + return sinon.stub(adloader, 'loadExternalScript').callsFake((...args) => { + if (typeof args[2] === 'function') { + args[2](); + } else if (typeof args[3] === 'function') { + args[3](); + } + return document.createElement('script'); }); - loadExternalScriptStub = sandbox.stub(adloader, 'loadExternalScript'); -}); +} -afterEach(function() { - sandbox.restore(); +beforeEach(function() { + stub.restore(); + stub = createStub(); }); diff --git a/test/mocks/videoCacheStub.js b/test/mocks/videoCacheStub.js index 39f5d67b6a9..7ce899cae35 100644 --- a/test/mocks/videoCacheStub.js +++ b/test/mocks/videoCacheStub.js @@ -1,4 +1,4 @@ -import * as videoCache from 'src/videoCache'; +import * as videoCache from 'src/videoCache.js'; /** * Function which can be called from unit tests to stub out the video cache. diff --git a/test/mocks/xhr.js b/test/mocks/xhr.js new file mode 100644 index 00000000000..9fb8fe87fa0 --- /dev/null +++ b/test/mocks/xhr.js @@ -0,0 +1,9 @@ + +export let server = sinon.createFakeServer(); +export let xhr = global.XMLHttpRequest; + +beforeEach(function() { + server.restore(); + server = sinon.createFakeServer(); + xhr = global.XMLHttpRequest; +}); diff --git a/test/pages/banner.html b/test/pages/banner.html index 03f3b9b9e54..e1859abdd85 100644 --- a/test/pages/banner.html +++ b/test/pages/banner.html @@ -7,7 +7,7 @@ Prebid.js Banner Example - + @@ -30,20 +30,24 @@ placementId: 13144370 } }] - }, { - code: 'div-gpt-ad-1460505748561-1', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - } - }, - bids: [{ - bidder: 'appnexus', - params: { - placementId: 13144370 - } - }] - }]; + } + //, { + // code: 'div-gpt-ad-1460505748561-1', + // mediaTypes: { + // banner: { + // sizes: [[300, 250], [300, 600]], + // } + // }, + // bids: [{ + // bidder: "appnexus", + // params: { + // accountId: 14062, + // siteId: 70608, + // zoneId: 498816 + // } + // }] + // } + ]; +
diff --git a/test/pages/bidderSettings.html b/test/pages/bidderSettings.html new file mode 100644 index 00000000000..a4a718d6497 --- /dev/null +++ b/test/pages/bidderSettings.html @@ -0,0 +1,125 @@ + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/consent_mgt_gdpr.html b/test/pages/consent_mgt_gdpr.html new file mode 100644 index 00000000000..a7da17ca2f7 --- /dev/null +++ b/test/pages/consent_mgt_gdpr.html @@ -0,0 +1,206 @@ + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/currency.html b/test/pages/currency.html new file mode 100644 index 00000000000..5214982f67c --- /dev/null +++ b/test/pages/currency.html @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/video.html b/test/pages/instream.html similarity index 91% rename from test/pages/video.html rename to test/pages/instream.html index e040b65fe23..be7aceb40db 100644 --- a/test/pages/video.html +++ b/test/pages/instream.html @@ -16,7 +16,7 @@ - + + + + + + + + + + + +

Multi-Format Ad Units

+

div-banner

+
+ +
+ +

div-native

+
+

No response

+ +
+ + + + \ No newline at end of file diff --git a/test/pages/native.html b/test/pages/native.html index 0823f486848..f382ab8aad7 100644 --- a/test/pages/native.html +++ b/test/pages/native.html @@ -7,7 +7,7 @@ Prebid.js Native Example - + diff --git a/test/pages/outstream.html b/test/pages/outstream.html index 56e443a519b..2a0543095cd 100644 --- a/test/pages/outstream.html +++ b/test/pages/outstream.html @@ -7,7 +7,7 @@ Prebid.js Video Outstream Example - + diff --git a/test/pages/priceGranularity.html b/test/pages/priceGranularity.html new file mode 100644 index 00000000000..588b11044fb --- /dev/null +++ b/test/pages/priceGranularity.html @@ -0,0 +1,131 @@ + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/sizeConfig.html b/test/pages/sizeConfig.html new file mode 100644 index 00000000000..b62b4a741ab --- /dev/null +++ b/test/pages/sizeConfig.html @@ -0,0 +1,142 @@ + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/userSync.html b/test/pages/userSync.html new file mode 100644 index 00000000000..43aeafd46e9 --- /dev/null +++ b/test/pages/userSync.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/spec/AnalyticsAdapter_spec.js b/test/spec/AnalyticsAdapter_spec.js index 59138b03e61..4afa430f81e 100644 --- a/test/spec/AnalyticsAdapter_spec.js +++ b/test/spec/AnalyticsAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; -import events from 'src/events'; +import events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; +import { server } from 'test/mocks/xhr.js'; const REQUEST_BIDS = CONSTANTS.EVENTS.REQUEST_BIDS; const BID_REQUESTED = CONSTANTS.EVENTS.BID_REQUESTED; @@ -12,7 +13,7 @@ const ADD_AD_UNITS = CONSTANTS.EVENTS.ADD_AD_UNITS; const AnalyticsAdapter = require('src/AnalyticsAdapter').default; const config = { - url: 'http://localhost:9999/endpoint', + url: 'https://localhost:9999/endpoint', analyticsType: 'endpoint' }; @@ -20,19 +21,13 @@ describe(` FEATURE: Analytics Adapters API SCENARIO: A publisher enables analytics AND an \`example\` instance of \`AnalyticsAdapter\`\n`, () => { - let xhr; - let requests; let adapter; beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (request) => requests.push(request); adapter = new AnalyticsAdapter(config); }); afterEach(function () { - xhr.restore(); adapter.disableAnalytics(); }); @@ -42,7 +37,7 @@ FEATURE: Analytics Adapters API adapter.track({ eventType, args }); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {some: 'data'}, eventType: 'bidRequested'}); }); @@ -53,7 +48,7 @@ FEATURE: Analytics Adapters API events.emit(eventType, args); adapter.enableAnalytics(); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {wat: 'wot'}, eventType: 'bidResponse'}); }); @@ -73,7 +68,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {more: 'info'}, eventType: 'bidWon'}); }); @@ -84,7 +79,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'adRenderFailed'}, eventType: 'adRenderFailed'}); }); @@ -95,7 +90,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'addAdUnits'}, eventType: 'addAdUnits'}); }); @@ -106,7 +101,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'request'}, eventType: 'requestBids'}); }); @@ -117,7 +112,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'request'}, eventType: 'bidRequested'}); }); @@ -128,7 +123,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'response'}, eventType: 'bidResponse'}); }); @@ -139,7 +134,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'timeout'}, eventType: 'bidTimeout'}); }); @@ -151,7 +146,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); }); describe(`AND sampling is enabled\n`, function () { @@ -174,8 +169,8 @@ FEATURE: Analytics Adapters API }); events.emit(eventType, args); - expect(requests.length).to.equal(1); - let result = JSON.parse(requests[0].requestBody); + expect(server.requests.length).to.equal(1); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {more: 'info'}, eventType: 'bidWon'}); }); @@ -187,7 +182,7 @@ FEATURE: Analytics Adapters API }); events.emit(eventType, args); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); }); }); diff --git a/test/spec/adapters/adbutler_spec.js b/test/spec/adapters/adbutler_spec.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/spec/adloader_spec.js b/test/spec/adloader_spec.js index 27f574c9c42..0c46cd2f171 100644 --- a/test/spec/adloader_spec.js +++ b/test/spec/adloader_spec.js @@ -1,5 +1,5 @@ -import * as utils from 'src/utils'; -import * as adLoader from 'test/mocks/adloaderStub'; +import * as utils from 'src/utils.js'; +import * as adLoader from 'test/mocks/adloaderStub.js'; describe('adLoader', function () { let utilsinsertElementStub; @@ -27,5 +27,16 @@ describe('adLoader', function () { expect(utilsLogErrorStub.called).to.be.false; expect(utilsinsertElementStub.called).to.be.true; }); + + it('should not load cached script again', function() { + adLoader.loadExternalScript('someURL', 'criteo'); + expect(utilsinsertElementStub.called).to.be.false; + }); + + it('callback function can be passed to the function', function() { + let callback = function() {}; + adLoader.loadExternalScript('someURL1', 'criteo', callback); + expect(utilsinsertElementStub.called).to.be.true; + }); }); }); diff --git a/test/spec/aliasBidder_spec.js b/test/spec/aliasBidder_spec.js index 61a654dcb90..771d7fcdd46 100644 --- a/test/spec/aliasBidder_spec.js +++ b/test/spec/aliasBidder_spec.js @@ -1,4 +1,4 @@ -import { pbjsTestOnly } from 'test/helpers/pbjs-test-only'; +import { pbjsTestOnly } from 'test/helpers/pbjs-test-only.js'; describe('Publisher API _ Alias Bidder', function () { var assert = require('chai').assert; diff --git a/test/spec/api_spec.js b/test/spec/api_spec.js index a8987d3ed07..6f21eba7aaf 100755 --- a/test/spec/api_spec.js +++ b/test/spec/api_spec.js @@ -24,6 +24,10 @@ describe('Publisher API', function () { it('should have $$PREBID_GLOBAL$$.que.push function', function () { assert.isFunction($$PREBID_GLOBAL$$.que.push); }); + + it('should have global pointer for PBJS global', function () { + assert.isArray(window._pbjsGlobals); + }); }); describe('has function', function () { diff --git a/test/spec/auctionmanager_spec.js b/test/spec/auctionmanager_spec.js index 577b1bec333..3ec3d67e448 100644 --- a/test/spec/auctionmanager_spec.js +++ b/test/spec/auctionmanager_spec.js @@ -1,13 +1,14 @@ -import { getKeyValueTargetingPairs, auctionCallbacks, AUCTION_COMPLETED } from 'src/auction'; +import { getKeyValueTargetingPairs, auctionCallbacks, AUCTION_COMPLETED } from 'src/auction.js'; import CONSTANTS from 'src/constants.json'; -import { adjustBids } from 'src/auction'; -import * as auctionModule from 'src/auction'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import { createBid } from 'src/bidfactory'; -import { config } from 'src/config'; -import * as store from 'src/videoCache'; -import * as ajaxLib from 'src/ajax'; -import find from 'core-js/library/fn/array/find'; +import { adjustBids, getMediaTypeGranularity } from 'src/auction.js'; +import * as auctionModule from 'src/auction.js'; +import { registerBidder } from 'src/adapters/bidderFactory.js'; +import { createBid } from 'src/bidfactory.js'; +import { config } from 'src/config.js'; +import * as store from 'src/videoCache.js'; +import * as ajaxLib from 'src/ajax.js'; +import find from 'core-js/library/fn/array/find.js'; +import { server } from 'test/mocks/xhr.js'; var assert = require('assert'); @@ -25,6 +26,10 @@ const BIDDER_CODE1 = 'sampleBidder1'; const ADUNIT_CODE = 'adUnit-code'; const ADUNIT_CODE1 = 'adUnit-code-1'; +/** + * @param {Object} [opts] + * @returns {Bid} + */ function mockBid(opts) { let bidderCode = opts && opts.bidderCode; @@ -43,6 +48,11 @@ function mockBid(opts) { }; } +/** + * @param {Bid} bid + * @param {Object} [opts] + * @returns {BidRequest} + */ function mockBidRequest(bid, opts) { if (!bid) { throw new Error('bid required'); @@ -757,7 +767,6 @@ describe('auctionmanager.js', function () { describe('when auction timeout is 20', function () { let eventsEmitSpy; - let server; before(function () { bids = [mockBid(), mockBid({ bidderCode: BIDDER_CODE1 })]; @@ -767,8 +776,6 @@ describe('auctionmanager.js', function () { }); beforeEach(function () { - server = sinon.createFakeServer(); - adUnits = [{ code: ADUNIT_CODE, bids: [ @@ -780,7 +787,6 @@ describe('auctionmanager.js', function () { eventsEmitSpy = sinon.spy(events, 'emit'); }); afterEach(function () { - server.restore(); events.emit.restore(); }); @@ -976,11 +982,176 @@ describe('auctionmanager.js', function () { }); }); + describe('addBidRequests', function () { + let createAuctionStub; + let adUnits; + let adUnitCodes; + let spec; + let spec1; + let auction; + let ajaxStub; + let logMessageStub; + let logInfoStub; + let logWarnStub; + let logErrorStub; + + let bids = TEST_BIDS; + let bids1 = [mockBid({ bidderCode: BIDDER_CODE1 })]; + + before(function () { + logMessageStub = sinon.stub(utils, 'logMessage'); + logInfoStub = sinon.stub(utils, 'logInfo'); + logWarnStub = sinon.stub(utils, 'logWarn'); + logErrorStub = sinon.stub(utils, 'logError'); + let bidRequests = [ + mockBidRequest(bids[0]), + mockBidRequest(bids1[0], { adUnitCode: ADUNIT_CODE1 }) + ]; + let makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests'); + makeRequestsStub.returns(bidRequests); + + ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockAjaxBuilder); + }); + + after(function () { + logMessageStub.restore(); + logInfoStub.restore(); + logWarnStub.restore(); + logErrorStub.restore(); + ajaxStub.restore(); + adapterManager.makeBidRequests.restore(); + }); + + beforeEach(function () { + config.setConfig({ + debugging: { + enabled: true, + bidRequests: [{ + bidderCode: BIDDER_CODE, + adUnitCode: ADUNIT_CODE, + storedAuctionResponse: '11111' + }] + } + }); + + adUnits = [{ + code: ADUNIT_CODE, + bids: [ + {bidder: BIDDER_CODE, params: {placementId: 'id'}}, + ] + }, { + code: ADUNIT_CODE1, + bids: [ + {bidder: BIDDER_CODE1, params: {placementId: 'id'}}, + ] + }]; + adUnitCodes = adUnits.map(({ code }) => code); + auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: 3000}); + createAuctionStub = sinon.stub(auctionModule, 'newAuction'); + createAuctionStub.returns(auction); + + spec = mockBidder(BIDDER_CODE, bids); + spec1 = mockBidder(BIDDER_CODE1, bids1); + + registerBidder(spec); + registerBidder(spec1); + }); + + afterEach(function () { + logMessageStub.resetHistory(); + logInfoStub.resetHistory(); + logWarnStub.resetHistory(); + logErrorStub.resetHistory(); + auctionModule.newAuction.restore(); + config.resetConfig(); + }); + + it('should override bidRequest properties when config debugging has a matching bidRequest defined', function () { + auction.callBids(); + const auctionBidRequests = auction.getBidRequests(); + assert.equal(auctionBidRequests.length > 0, true); + assert.equal(Array.isArray(auctionBidRequests[0].bids), true); + + const bid = find(auctionBidRequests[0].bids, bid => bid.adUnitCode === ADUNIT_CODE); + assert.equal(typeof bid !== 'undefined', true); + assert.equal(bid.hasOwnProperty('storedAuctionResponse'), true); + assert.equal(bid.storedAuctionResponse, '11111'); + }); + }); + + describe('getMediaTypeGranularity', function () { + it('video', function () { + let bidReq = { + 'mediaTypes': { video: {id: '1'} } + }; + + // mediaType is video and video.context is undefined + expect(getMediaTypeGranularity('video', bidReq, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + expect(getMediaTypeGranularity('video', {}, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + `` + expect(getMediaTypeGranularity('video', undefined, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + // also when mediaTypes.video is undefined + bidReq = { + 'mediaTypes': { banner: {} } + }; + expect(getMediaTypeGranularity('video', bidReq, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + // also when mediaTypes is undefined + expect(getMediaTypeGranularity('video', {}, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + }); + + it('video-outstream', function () { + let bidReq = { 'mediaTypes': { video: { context: 'outstream' } } }; + + expect(getMediaTypeGranularity('video', bidReq, { + 'banner': 'low', 'video': 'medium', 'video-outstream': 'high' + })).to.equal('high'); + }); + + it('video-instream', function () { + let bidReq = { 'mediaTypes': { video: { context: 'instream' } } }; + + expect(getMediaTypeGranularity('video', bidReq, { + banner: 'low', video: 'medium', 'video-instream': 'high' + })).to.equal('high'); + + // fall back to video if video-instream not found + expect(getMediaTypeGranularity('video', bidReq, { + banner: 'low', video: 'medium' + })).to.equal('medium'); + + expect(getMediaTypeGranularity('video', {mediaTypes: {banner: {}}}, { + banner: 'low', video: 'medium' + })).to.equal('medium'); + }); + + it('native', function () { + expect(getMediaTypeGranularity('native', {mediaTypes: {native: {}}}, { + banner: 'low', video: 'medium', native: 'high' + })).to.equal('high'); + }); + }); + describe('auctionCallbacks', function() { let bids = TEST_BIDS; let bidRequests; - let xhr; - let requests; let doneSpy; let auction = { getBidRequests: () => bidRequests, @@ -991,9 +1162,6 @@ describe('auctionmanager.js', function () { beforeEach(() => { doneSpy = sinon.spy(); - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (request) => requests.push(request); config.setConfig({ cache: { url: 'https://prebid.adnxs.com/pbc/v1/cache' @@ -1003,7 +1171,6 @@ describe('auctionmanager.js', function () { afterEach(() => { doneSpy.resetHistory(); - xhr.restore(); config.resetConfig(); }); @@ -1053,7 +1220,7 @@ describe('auctionmanager.js', function () { assert.equal(doneSpy.callCount, 0); const uuid = 'c488b101-af3e-4a99-b538-00423e5a3371'; const responseBody = `{"responses":[{"uuid":"${uuid}"}]}`; - requests[0].respond(200, { 'Content-Type': 'application/json' }, responseBody); + server.requests[0].respond(200, { 'Content-Type': 'application/json' }, responseBody); assert.equal(doneSpy.callCount, 1); }) }); diff --git a/test/spec/config_spec.js b/test/spec/config_spec.js index 196e167420a..be5b4bbb78b 100644 --- a/test/spec/config_spec.js +++ b/test/spec/config_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { assert } from 'chai'; -import { newConfig } from 'src/config'; +import { newConfig } from 'src/config.js'; const utils = require('src/utils'); @@ -33,7 +33,7 @@ describe('config API', function () { expect(getConfig()).to.be.a('object'); }); - it('sets and gets arbitrary configuarion properties', function () { + it('sets and gets arbitrary configuration properties', function () { setConfig({ baz: 'qux' }); expect(getConfig('baz')).to.equal('qux'); }); @@ -77,7 +77,8 @@ describe('config API', function () { syncEnabled: true, pixelEnabled: true, syncsPerBidder: 5, - syncDelay: 3000 + syncDelay: 3000, + auctionDelay: 0 }; setDefaults({'userSync': DEFAULT_USERSYNC}); expect(getConfig('userSync')).to.eql(DEFAULT_USERSYNC); @@ -136,32 +137,37 @@ describe('config API', function () { }); it('set mediaTypePriceGranularity', function () { - const customPriceGranularity = { + const customPriceGranularityVideo = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, 'cap': true }] }; + const customPriceGranularityInstream = utils.deepClone(customPriceGranularityVideo); + const customPriceGranularityOutstream = utils.deepClone(customPriceGranularityVideo); + setConfig({ 'mediaTypePriceGranularity': { 'banner': 'medium', - 'video': customPriceGranularity, - 'native': 'medium' + 'video': customPriceGranularityVideo, + 'video-instream': customPriceGranularityInstream, + 'video-outstream': customPriceGranularityOutstream, + 'native': 'high' } }); const configResult = getConfig('mediaTypePriceGranularity'); expect(configResult.banner).to.be.equal('medium'); - expect(configResult.video).to.be.equal(customPriceGranularity); - expect(configResult.native).to.be.equal('medium'); + expect(configResult.video).to.be.equal(customPriceGranularityVideo); + expect(configResult['video-instream']).to.be.equal(customPriceGranularityInstream); + expect(configResult['video-outstream']).to.be.equal(customPriceGranularityOutstream); + expect(configResult.native).to.be.equal('high'); }); it('sets priceGranularity and customPriceBucket', function () { const goodConfig = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, 'cap': true @@ -172,6 +178,23 @@ describe('config API', function () { expect(getConfig('customPriceBucket')).to.equal(goodConfig); }); + it('sets deviceAccess', function () { + // When the deviceAccess flag config option is not set, cookies may be read and set + expect(getConfig('deviceAccess')).to.be.equal(true); + + // When the deviceAccess flag config option is set to false, no cookies are read or set + setConfig({ + 'deviceAccess': false + }); + expect(getConfig('deviceAccess')).to.be.equal(false); + + // When the deviceAccess flag config option is set to true, cookies may be read and set + setConfig({ + 'deviceAccess': true + }); + expect(getConfig('deviceAccess')).to.be.equal(true); + }); + it('should log error for invalid priceGranularity', function () { setConfig({ priceGranularity: '' }); const error = 'Prebid Error: no value passed to `setPriceGranularity()`'; diff --git a/test/spec/cpmBucketManager_spec.js b/test/spec/cpmBucketManager_spec.js index 88e04be9ad6..0b8635a4e3b 100644 --- a/test/spec/cpmBucketManager_spec.js +++ b/test/spec/cpmBucketManager_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import {getPriceBucketString, isValidPriceConfig} from 'src/cpmBucketManager'; +import {getPriceBucketString, isValidPriceConfig} from 'src/cpmBucketManager.js'; let cpmFixtures = require('test/fixtures/cpmInputsOutputs.json'); describe('cpmBucketManager', function () { @@ -17,13 +17,11 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [{ 'precision': 4, - 'min': 0, 'max': 3, 'increment': 0.01, }, { 'precision': 4, - 'min': 3, 'max': 18, 'increment': 0.05, 'cap': true @@ -40,13 +38,11 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [{ 'precision': 4, - 'min': 0, 'max': 4, 'increment': 0.01, }, { 'precision': 4, - 'min': 4, 'max': 18, 'increment': 0.3, 'cap': true @@ -63,13 +59,11 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [{ 'precision': 4, - 'min': 0, 'max': 3, 'increment': 0.01, }, { 'precision': 4, - 'min': 3, 'max': 18, 'increment': 0.05, 'cap': true @@ -85,7 +79,6 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [{ 'precision': 4, - 'min': 0, 'max': 4, 'increment': 0.10, }] @@ -103,7 +96,6 @@ describe('cpmBucketManager', function () { customConfig = { 'buckets': [{ 'precision': 3, - 'min': 0, 'max': 6, 'increment': 0.08, }] @@ -116,7 +108,6 @@ describe('cpmBucketManager', function () { customConfig = { 'buckets': [{ 'precision': 3, - 'min': 0, 'max': 6, 'increment': 0.05, }] @@ -134,7 +125,6 @@ describe('cpmBucketManager', function () { customConfig = { 'buckets': [{ 'precision': 2, - 'min': 0, 'max': 6, 'increment': 0.01, }] @@ -161,7 +151,6 @@ describe('cpmBucketManager', function () { 'buckets': [ { 'precision': 0, - 'min': 3, 'max': 18, 'increment': 0.05, } @@ -177,7 +166,6 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [ { - 'min': 3, 'max': 18, 'increment': 0.05, } @@ -191,14 +179,12 @@ describe('cpmBucketManager', function () { it('checks whether custom config is valid', function () { let badConfig = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, }, { - // missing min prop 'max': 18, - 'increment': 0.05, + // missing increment prop 'cap': true } ] diff --git a/test/spec/debugging_spec.js b/test/spec/debugging_spec.js index ba9702b0324..bf49a579cbd 100644 --- a/test/spec/debugging_spec.js +++ b/test/spec/debugging_spec.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { sessionLoader, addBidResponseHook, getConfig, disableOverrides, boundHook } from 'src/debugging'; -import { addBidResponse } from 'src/auction'; -import { config } from 'src/config'; +import { sessionLoader, addBidResponseHook, addBidderRequestsHook, getConfig, disableOverrides, addBidResponseBound, addBidderRequestsBound } from 'src/debugging.js'; +import { addBidResponse, addBidderRequests } from 'src/auction.js'; +import { config } from 'src/config.js'; describe('bid overrides', function () { let sandbox; @@ -31,14 +31,16 @@ describe('bid overrides', function () { enabled: true }); - expect(addBidResponse.getHooks().some(hook => hook.hook === boundHook)).to.equal(true); + expect(addBidResponse.getHooks().some(hook => hook.hook === addBidResponseBound)).to.equal(true); + expect(addBidderRequests.getHooks().some(hook => hook.hook === addBidderRequestsBound)).to.equal(true); }); it('should happen when configuration found in sessionStorage', function () { sessionLoader({ getItem: () => ('{"enabled": true}') }); - expect(addBidResponse.getHooks().some(hook => hook.hook === boundHook)).to.equal(true); + expect(addBidResponse.getHooks().some(hook => hook.hook === addBidResponseBound)).to.equal(true); + expect(addBidderRequests.getHooks().some(hook => hook.hook === addBidderRequestsBound)).to.equal(true); }); it('should not throw if sessionStorage is inaccessible', function () { @@ -52,7 +54,7 @@ describe('bid overrides', function () { }); }); - describe('hook', function () { + describe('bidResponse hook', function () { let mockBids; let bids; @@ -84,7 +86,7 @@ describe('bid overrides', function () { let next = (adUnitCode, bid) => { bids.push(bid); }; - addBidResponseHook.bind(overrides)(next, bid.adUnitCode, bid) + addBidResponseHook.bind(overrides)(next, bid.adUnitCode, bid); }); } @@ -141,4 +143,51 @@ describe('bid overrides', function () { expect(bids[1].cpm).to.equal(2); }); }); + + describe('bidRequests hook', function () { + let mockBidRequests; + let bidderRequests; + + beforeEach(function () { + let baseBidderRequest = { + 'bidderCode': 'rubicon', + 'bids': [{ + 'width': 970, + 'height': 250, + 'statusMessage': 'Bid available', + 'mediaType': 'banner', + 'source': 'client', + 'currency': 'USD', + 'cpm': 0.5, + 'ttl': 300, + 'netRevenue': false, + 'adUnitCode': '/19968336/header-bid-tag-0' + }] + }; + mockBidRequests = []; + mockBidRequests.push(baseBidderRequest); + mockBidRequests.push(Object.assign({}, baseBidderRequest, { + bidderCode: 'appnexus' + })); + + bidderRequests = []; + }); + + function run(overrides) { + let next = (b) => { + bidderRequests = b; + }; + addBidderRequestsHook.bind(overrides)(next, mockBidRequests); + } + + it('should allow us to exclude bidders', function () { + run({ + enabled: true, + bidders: ['appnexus'] + }); + + expect(bidderRequests.length).to.equal(1); + expect(bidderRequests[0].bidderCode).to.equal('appnexus'); + }); + }); }); diff --git a/test/spec/e2e/banner/basic_banner_ad.spec.js b/test/spec/e2e/banner/basic_banner_ad.spec.js index ee01ce627db..fa2d5af142f 100644 --- a/test/spec/e2e/banner/basic_banner_ad.spec.js +++ b/test/spec/e2e/banner/basic_banner_ad.spec.js @@ -1,19 +1,19 @@ const expect = require('chai').expect; const { host, protocol } = require('../../../helpers/testing-utils'); -const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/banner.html`; +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/banner.html?pbjs_debug=true`; const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; const EXPECTED_TARGETING_KEYS = { - hb_format: 'banner', - hb_source: 'client', - hb_pb: '0.50', - hb_bidder: 'appnexus', - hb_format_appnexus: 'banner', - hb_source_appnexus: 'client', - hb_pb_appnexus: '0.50', - hb_bidder_appnexus: 'appnexus' -} + 'hb_format': 'banner', + 'hb_source': 'client', + 'hb_pb': '0.60', + 'hb_bidder': 'rubicon', + 'hb_format_rubicon': 'banner', + 'hb_source_rubicon': 'client', + 'hb_pb_rubicon': '0.60', + 'hb_bidder_rubicon': 'rubicon' +}; describe('Prebid.js Banner Ad Unit Test', function () { before(function loadTestPage() { @@ -29,18 +29,19 @@ describe('Prebid.js Banner Ad Unit Test', function () { } }); - it('should load the targeting keys with correct values', function () { - const result = browser.execute(function () { - return window.top.pbjs.getAdserverTargeting('div-gpt-ad-1460505748561-1'); - }); + // TODO: Add below test again. Removed the test since we are testing only for appnexus endpoint now and appnexus adapter does not set AdserverTargetting. - const targetingKeys = result.value['div-gpt-ad-1460505748561-1']; + // it('should load the targeting keys with correct values', function () { + // const result = browser.execute(function () { + // return window.top.pbjs.getAdserverTargeting('div-gpt-ad-1460505748561-1'); + // }); + // const targetingKeys = result.value['div-gpt-ad-1460505748561-1']; - expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); - expect(targetingKeys.hb_adid).to.be.a('string'); - expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); - expect(targetingKeys.hb_size).to.satisfy((size) => size === '300x250' || '300x600'); - }); + // expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + // expect(targetingKeys.hb_adid).to.be.a('string'); + // expect(targetingKeys.hb_adid_rubicon).to.be.a('string'); + // expect(targetingKeys.hb_size).to.satisfy((size) => size === '300x250' || '300x600'); + // }); it('should render the Banner Ad on the page', function () { expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; diff --git a/test/spec/e2e/instream/basic_instream_video_ad.spec.js b/test/spec/e2e/instream/basic_instream_video_ad.spec.js new file mode 100644 index 00000000000..034363685d2 --- /dev/null +++ b/test/spec/e2e/instream/basic_instream_video_ad.spec.js @@ -0,0 +1,52 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/instream.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'div[class="VPAID-container"] > div > iframe'; + +const EXPECTED_TARGETING_KEYS = { + hb_cache_id: '', + hb_uuid: '', + hb_format: 'video', + hb_source: 'client', + hb_size: '640x480', + hb_pb: '10.00', + hb_bidder: 'appnexus', + hb_format_appnexus: 'video', + hb_source_appnexus: 'client', + hb_size_appnexus: '640x480', + hb_pb_appnexus: '10.00', + hb_bidder_appnexus: 'appnexus' +}; + +describe('Prebid.js Instream Video Ad Test', function () { + before(function loadTestPage() { + browser + .url(TEST_PAGE_URL) + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 5000); + // const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + // browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + // it('should load the targeting keys with correct values', function () { + // const result = browser.execute(function () { + // console.log('pbjs::', window.top.pbjs); + // return window.top.pbjs.getAdserverTargeting('video1'); + // }); + // console.log('result:::', result); + // const targetingKeys = result.value['vid1']; + // expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + // expect(targetingKeys.hb_adid).to.be.a('string'); + // expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + // }); + + it('should render the instream ad on the page', function() { + expect(browser.isVisible(CREATIVE_IFRAME_CSS_SELECTOR)); + }); +}); diff --git a/test/spec/e2e/longform/basic_w_bidderSettings.spec.js b/test/spec/e2e/longform/basic_w_bidderSettings.spec.js new file mode 100644 index 00000000000..06413fb809a --- /dev/null +++ b/test/spec/e2e/longform/basic_w_bidderSettings.spec.js @@ -0,0 +1,68 @@ +const includes = require('core-js/library/fn/array/includes'); +const expect = require('chai').expect; +const testServer = require('../../../helpers/testing-utils'); + +const host = testServer.host; +const protocol = testServer.protocol; + +const validDurations = ['15s', '30s']; +const validCats = ['Food', 'Retail Stores/Chains', 'Pet Food/Supplies', 'Travel/Hotels/Airlines', 'Automotive', 'Health Care Services']; +const validCpms = ['14.00', '13.00', '12.00', '9.00']; +const customKeyRegex = /\d{2}\.\d{2}_\d{1,3}_\d{2}s/; +const uuidRegex = /(\d|\w){8}-((\d|\w){4}-){3}(\d|\w){12}/; + +describe('longform ads not using requireExactDuration field', function() { + this.retries(3); + it('process the bids successfully', function() { + browser + .url(protocol + '://' + host + ':9999/integrationExamples/longform/basic_w_bidderSettings.html?pbjs_debug=true') + .pause(10000); + + const loadPrebidBtnXpath = '//*[@id="loadPrebidRequestBtn"]'; + browser.waitForExist(loadPrebidBtnXpath); + $(loadPrebidBtnXpath).click(); + browser.pause(3000); + + const listOfCpmsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[2]'; + const listOfCategoriesXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[3]'; + const listOfDurationsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[4]'; + + browser.waitForExist(listOfCpmsXpath); + + let listOfCpms = $$(listOfCpmsXpath); + let listOfCats = $$(listOfCategoriesXpath); + let listOfDuras = $$(listOfDurationsXpath); + + expect(listOfCpms.length).to.equal(listOfCats.length).and.to.equal(listOfDuras.length); + for (let i = 0; i < listOfCpms.length; i++) { + let cpm = listOfCpms[i].getText(); + let cat = listOfCats[i].getText(); + let dura = listOfDuras[i].getText(); + expect(includes(validCpms, cpm), `Could not find CPM ${cpm} in accepted list`).to.equal(true); + expect(includes(validCats, cat), `Could not find Category ${cat} in accepted list`).to.equal(true); + expect(includes(validDurations, dura), `Could not find Duration ${dura} in accepted list`).to.equal(true); + } + }); + + it('formats the targeting keys properly', function () { + const listOfKeyElementsXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[1]'; + const listOfKeyValuesXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[2]'; + browser.waitForExist(listOfKeyElementsXpath); + browser.waitForExist(listOfKeyValuesXpath); + + let listOfKeyElements = $$(listOfKeyElementsXpath); + let listOfKeyValues = $$(listOfKeyValuesXpath); + + let firstKey = listOfKeyElements[0].getText(); + expect(firstKey).to.equal('hb_pb_cat_dur'); + + let firstKeyValue = listOfKeyValues[0].getText(); + expect(firstKeyValue).match(customKeyRegex); + + let lastKey = listOfKeyElements[listOfKeyElements.length - 1].getText(); + expect(lastKey).to.equal('hb_cache_id'); + + let lastKeyValue = listOfKeyValues[listOfKeyValues.length - 1].getText(); + expect(lastKeyValue).to.match(uuidRegex); + }); +}) diff --git a/test/spec/e2e/longform/basic_w_priceGran.spec.js b/test/spec/e2e/longform/basic_w_priceGran.spec.js new file mode 100644 index 00000000000..696b7fa3359 --- /dev/null +++ b/test/spec/e2e/longform/basic_w_priceGran.spec.js @@ -0,0 +1,68 @@ +const includes = require('core-js/library/fn/array/includes'); +const expect = require('chai').expect; +const testServer = require('../../../helpers/testing-utils'); + +const host = testServer.host; +const protocol = testServer.protocol; + +const validDurations = ['15s', '30s']; +const validCats = ['Food', 'Retail Stores/Chains', 'Pet Food/Supplies', 'Travel/Hotels/Airlines', 'Automotive', 'Health Care Services']; +const validCpms = ['15.00', '14.00', '13.00', '10.00']; +const customKeyRegex = /\d{2}\.\d{2}_\d{1,3}_\d{2}s/; +const uuidRegex = /(\d|\w){8}-((\d|\w){4}-){3}(\d|\w){12}/; + +describe('longform ads not using requireExactDuration field', function() { + this.retries(3); + it('process the bids successfully', function() { + browser + .url(protocol + '://' + host + ':9999/integrationExamples/longform/basic_w_priceGran.html?pbjs_debug=true') + .pause(10000); + + const loadPrebidBtnXpath = '//*[@id="loadPrebidRequestBtn"]'; + browser.waitForExist(loadPrebidBtnXpath); + $(loadPrebidBtnXpath).click(); + browser.pause(3000); + + const listOfCpmsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[2]'; + const listOfCategoriesXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[3]'; + const listOfDurationsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[4]'; + + browser.waitForExist(listOfCpmsXpath); + + let listOfCpms = $$(listOfCpmsXpath); + let listOfCats = $$(listOfCategoriesXpath); + let listOfDuras = $$(listOfDurationsXpath); + + expect(listOfCpms.length).to.equal(listOfCats.length).and.to.equal(listOfDuras.length); + for (let i = 0; i < listOfCpms.length; i++) { + let cpm = listOfCpms[i].getText(); + let cat = listOfCats[i].getText(); + let dura = listOfDuras[i].getText(); + expect(includes(validCpms, cpm), `Could not find CPM ${cpm} in accepted list`).to.equal(true); + expect(includes(validCats, cat), `Could not find Category ${cat} in accepted list`).to.equal(true); + expect(includes(validDurations, dura), `Could not find Duration ${dura} in accepted list`).to.equal(true); + } + }); + + it('formats the targeting keys properly', function () { + const listOfKeyElementsXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[1]'; + const listOfKeyValuesXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[2]'; + browser.waitForExist(listOfKeyElementsXpath); + browser.waitForExist(listOfKeyValuesXpath); + + let listOfKeyElements = $$(listOfKeyElementsXpath); + let listOfKeyValues = $$(listOfKeyValuesXpath); + + let firstKey = listOfKeyElements[0].getText(); + expect(firstKey).to.equal('hb_pb_cat_dur'); + + let firstKeyValue = listOfKeyValues[0].getText(); + expect(firstKeyValue).match(customKeyRegex); + + let lastKey = listOfKeyElements[listOfKeyElements.length - 1].getText(); + expect(lastKey).to.equal('hb_cache_id'); + + let lastKeyValue = listOfKeyValues[listOfKeyValues.length - 1].getText(); + expect(lastKeyValue).to.match(uuidRegex); + }); +}) diff --git a/test/spec/e2e/modules/e2e_bidderSettings.spec.js b/test/spec/e2e/modules/e2e_bidderSettings.spec.js new file mode 100644 index 00000000000..d9f1d18725d --- /dev/null +++ b/test/spec/e2e/modules/e2e_bidderSettings.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/bidderSettings.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Bidder Settings Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_consent_mgt_gdpr.spec.js b/test/spec/e2e/modules/e2e_consent_mgt_gdpr.spec.js new file mode 100644 index 00000000000..1c11a5432ff --- /dev/null +++ b/test/spec/e2e/modules/e2e_consent_mgt_gdpr.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/consent_mgt_gdpr.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +}; + +describe('Prebid.js GDPR Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_currency.spec.js b/test/spec/e2e/modules/e2e_currency.spec.js new file mode 100644 index 00000000000..8692b4991bd --- /dev/null +++ b/test/spec/e2e/modules/e2e_currency.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/currency.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '7.50', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '7.50', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Currency Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_priceGranularity.spec.js b/test/spec/e2e/modules/e2e_priceGranularity.spec.js new file mode 100644 index 00000000000..1042ab491fb --- /dev/null +++ b/test/spec/e2e/modules/e2e_priceGranularity.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/priceGranularity.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Price Granularity Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_sizeConfig.spec.js b/test/spec/e2e/modules/e2e_sizeConfig.spec.js new file mode 100644 index 00000000000..1eb3fad8dea --- /dev/null +++ b/test/spec/e2e/modules/e2e_sizeConfig.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/sizeConfig.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Size Config Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_userSync.spec.js b/test/spec/e2e/modules/e2e_userSync.spec.js new file mode 100644 index 00000000000..3957f3cdfef --- /dev/null +++ b/test/spec/e2e/modules/e2e_userSync.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/userSync.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js User Sync Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/multi-format/e2e_multiple_bidders.spec.js b/test/spec/e2e/multi-format/e2e_multiple_bidders.spec.js new file mode 100644 index 00000000000..4ce750bdd96 --- /dev/null +++ b/test/spec/e2e/multi-format/e2e_multiple_bidders.spec.js @@ -0,0 +1,68 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/multiple_bidders.html?pbjs_debug=true`; +const CREATIVE_BANNER_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/prebid_multiformat_test_0"]'; +const CREATIVE_NATIVE_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/prebid_multiformat_test_1"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +}; + +describe('Prebid.js Multiple Bidder Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_BANNER_CSS_SELECTOR, 3000); + const creativeIframe = $(CREATIVE_BANNER_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); + + it('should render the native ad on the page', function () { + browser.frameParent(); + browser.waitForExist(CREATIVE_NATIVE_CSS_SELECTOR, 3000); + const creativeIframe = $(CREATIVE_NATIVE_CSS_SELECTOR).value; + browser.frame(creativeIframe); + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > div[class="card"]')).to.be.true; + }); +}); diff --git a/test/spec/e2e/native/basic_native_ad.spec.js b/test/spec/e2e/native/basic_native_ad.spec.js index ed09228b532..8eb9a5940a0 100644 --- a/test/spec/e2e/native/basic_native_ad.spec.js +++ b/test/spec/e2e/native/basic_native_ad.spec.js @@ -37,7 +37,7 @@ describe('Prebid.js Native Ad Unit Test', function () { it('should load the targeting keys with correct values', function () { const result = browser.execute(function () { - return window.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); }); const targetingKeys = result.value['/19968336/prebid_native_example_2']; diff --git a/test/spec/integration/faker/fixtures.js b/test/spec/integration/faker/fixtures.js index 643b531ad42..a11bd126d61 100644 --- a/test/spec/integration/faker/fixtures.js +++ b/test/spec/integration/faker/fixtures.js @@ -1,5 +1,5 @@ import faker from 'faker'; -import { makeSlot } from './googletag'; +import { makeSlot } from './googletag.js'; export function makeAdSlot(overrides = {}) { return Object.assign(makeSlot( diff --git a/test/spec/integration/faker/googletag.js b/test/spec/integration/faker/googletag.js index b043b5321cb..a0ce04402f7 100644 --- a/test/spec/integration/faker/googletag.js +++ b/test/spec/integration/faker/googletag.js @@ -1,5 +1,5 @@ import faker from 'faker'; -import { randomFive } from './fixtures'; +import { randomFive } from './fixtures.js'; var Slot = function Slot({ code, divId }) { code = code || `ad-slot-code-${randomFive()}`; diff --git a/test/spec/modules/1ad4goodBidAdapter_spec.js b/test/spec/modules/1ad4goodBidAdapter_spec.js new file mode 100644 index 00000000000..b9cd86a4cf7 --- /dev/null +++ b/test/spec/modules/1ad4goodBidAdapter_spec.js @@ -0,0 +1,548 @@ +import { expect } from 'chai'; +import { spec } from 'modules/1ad4goodBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as bidderFactory from 'src/adapters/bidderFactory.js'; +import { deepClone } from 'src/utils.js'; +import { config } from 'src/config.js'; + +const ENDPOINT = 'https://hb.1ad4good.org/prebid'; + +describe('AdforgoodAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': '1ad4good', + 'params': { + 'placementId': '10433394' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'placementId': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let bidRequests = [ + { + 'bidder': '1ad4good', + 'params': { + 'placementId': '10433394' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should parse out private sizes', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placementId: '10433394', + privateSizes: [300, 250] + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].private_sizes).to.exist; + expect(payload.tags[0].private_sizes).to.deep.equal([{width: 300, height: 250}]); + }); + + it('should add source and verison to the tag', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.sdk).to.exist; + expect(payload.sdk).to.deep.equal({ + source: 'pbjs', + version: '$prebid.version$' + }); + }); + + it('should populate the ad_types array on all requests', function () { + ['banner', 'video'].forEach(type => { + const bidRequest = Object.assign({}, bidRequests[0]); + bidRequest.mediaTypes = {}; + bidRequest.mediaTypes[type] = {}; + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].ad_types).to.deep.equal([type]); + }); + }); + + it('should populate the ad_types array on outstream requests', function () { + const bidRequest = Object.assign({}, bidRequests[0]); + bidRequest.mediaTypes = {}; + bidRequest.mediaTypes.video = {context: 'outstream'}; + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].ad_types).to.deep.equal(['video']); + }); + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests); + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('should attach valid video params to the tag', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placementId: '10433394', + video: { + id: 123, + minduration: 100, + foobar: 'invalid' + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tags[0].video).to.deep.equal({ + id: 123, + minduration: 100 + }); + }); + + it('should add video property when adUnit includes a renderer', function () { + const videoData = { + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mp4'] + } + }, + params: { + placementId: '10433394', + video: { + skippable: true, + playback_method: ['auto_play_sound_off'] + } + } + }; + + let bidRequest1 = deepClone(bidRequests[0]); + bidRequest1 = Object.assign({}, bidRequest1, videoData, { + renderer: { + url: 'http://test.renderer.url', + render: function () {} + } + }); + + let bidRequest2 = deepClone(bidRequests[0]); + bidRequest2.adUnitCode = 'adUnit_code_2'; + bidRequest2 = Object.assign({}, bidRequest2, videoData); + + const request = spec.buildRequests([bidRequest1, bidRequest2]); + const payload = JSON.parse(request.data); + expect(payload.tags[0].video).to.deep.equal({ + skippable: true, + playback_method: ['auto_play_sound_off'], + custom_renderer_present: true + }); + expect(payload.tags[1].video).to.deep.equal({ + skippable: true, + playback_method: ['auto_play_sound_off'] + }); + }); + + it('should attach valid user params to the tag', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placementId: '10433394', + user: { + externalUid: '123', + foobar: 'invalid' + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.user).to.exist; + expect(payload.user).to.deep.equal({ + externalUid: '123', + }); + }); + + // it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () { + // let bidRequest = Object.assign({}, + // bidRequests[0], + // { + // mediaType: 'native', + // nativeParams: { + // image: { required: true } + // } + // } + // ); + // bidRequest.sizes = [[150, 100], [300, 250]]; + + // let request = spec.buildRequests([bidRequest]); + // let payload = JSON.parse(request.data); + // expect(payload.tags[0].sizes).to.deep.equal([{width: 150, height: 100}, {width: 300, height: 250}]); + + // delete bidRequest.sizes; + + // request = spec.buildRequests([bidRequest]); + // payload = JSON.parse(request.data); + + // expect(payload.tags[0].sizes).to.deep.equal([{width: 1, height: 1}]); + // }); + + it('should convert keyword params to proper form and attaches to request', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placementId: '10433394', + keywords: { + single: 'val', + singleArr: ['val'], + singleArrNum: [5], + multiValMixed: ['value1', 2, 'value3'], + singleValNum: 123, + emptyStr: '', + emptyArr: [''], + badValue: {'foo': 'bar'} // should be dropped + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].keywords).to.deep.equal([{ + 'key': 'single', + 'value': ['val'] + }, { + 'key': 'singleArr', + 'value': ['val'] + }, { + 'key': 'singleArrNum', + 'value': ['5'] + }, { + 'key': 'multiValMixed', + 'value': ['value1', '2', 'value3'] + }, { + 'key': 'singleValNum', + 'value': ['123'] + }, { + 'key': 'emptyStr' + }, { + 'key': 'emptyArr' + }]); + }); + + it('should add payment rules to the request', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placementId: '10433394', + usePaymentRule: true + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].use_pmt_rule).to.equal(true); + }); + + it('should add gdpr consent information to the request', function () { + let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let bidderRequest = { + 'bidderCode': '1ad4good', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true + } + }; + bidderRequest.bids = bidRequests; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.gdpr_consent).to.exist; + expect(payload.gdpr_consent.consent_string).to.exist.and.to.equal(consentString); + expect(payload.gdpr_consent.consent_required).to.exist.and.to.be.true; + }); + + it('supports sending hybrid mobile app parameters', function () { + let appRequest = Object.assign({}, + bidRequests[0], + { + params: { + placementId: '10433394', + app: { + id: 'B1O2W3M4AN.com.prebid.webview', + geo: { + lat: 40.0964439, + lng: -75.3009142 + }, + device_id: { + idfa: '4D12078D-3246-4DA4-AD5E-7610481E7AE', // Apple advertising identifier + aaid: '38400000-8cf0-11bd-b23e-10b96e40000d', // Android advertising identifier + md5udid: '5756ae9022b2ea1e47d84fead75220c8', // MD5 hash of the ANDROID_ID + sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF', // SHA1 hash of the ANDROID_ID + windowsadid: '750c6be243f1c4b5c9912b95a5742fc5' // Windows advertising identifier + } + } + } + } + ); + const request = spec.buildRequests([appRequest]); + const payload = JSON.parse(request.data); + expect(payload.app).to.exist; + expect(payload.app).to.deep.equal({ + appid: 'B1O2W3M4AN.com.prebid.webview' + }); + expect(payload.device.device_id).to.exist; + expect(payload.device.device_id).to.deep.equal({ + aaid: '38400000-8cf0-11bd-b23e-10b96e40000d', + idfa: '4D12078D-3246-4DA4-AD5E-7610481E7AE', + md5udid: '5756ae9022b2ea1e47d84fead75220c8', + sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF', + windowsadid: '750c6be243f1c4b5c9912b95a5742fc5' + }); + expect(payload.device.geo).to.exist; + expect(payload.device.geo).to.deep.equal({ + lat: 40.0964439, + lng: -75.3009142 + }); + }); + + it('should add referer info to payload', function () { + const bidRequest = Object.assign({}, bidRequests[0]) + const bidderRequest = { + refererInfo: { + referer: 'http://example.com/page.html', + reachedTop: true, + numIframes: 2, + stack: [ + 'http://example.com/page.html', + 'http://example.com/iframe1.html', + 'http://example.com/iframe2.html' + ] + } + } + const request = spec.buildRequests([bidRequest], bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.referrer_detection).to.exist; + expect(payload.referrer_detection).to.deep.equal({ + rd_ref: 'http%3A%2F%2Fexample.com%2Fpage.html', + rd_top: true, + rd_ifs: 2, + rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') + }); + }); + }) + + describe('interpretResponse', function () { + let bfStub; + before(function() { + bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); + }); + + after(function() { + bfStub.restore(); + }); + + let response = { + 'version': '3.0.0', + 'tags': [ + { + 'uuid': '3db3773286ee59', + 'tag_id': 10433394, + 'auction_id': '4534722592064951574', + 'nobid': false, + 'no_ad_url': 'http://lax1-ib.adnxs.com/no-ad', + 'timeout_ms': 10000, + 'ad_profile_id': 27079, + 'ads': [ + { + 'content_source': 'rtb', + 'ad_type': 'banner', + 'buyer_member_id': 958, + 'creative_id': 29681110, + 'media_type_id': 1, + 'media_subtype_id': 1, + 'cpm': 0.5, + 'cpm_publisher_currency': 0.5, + 'publisher_currency_code': '$', + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'banner': { + 'content': '', + 'width': 300, + 'height': 250 + }, + 'trackers': [ + { + 'impression_urls': [ + 'http://lax1-ib.adnxs.com/impression' + ], + 'video_events': {} + } + ] + } + } + ] + } + ] + }; + + it('should get correct bid response', function () { + let expectedResponse = [ + { + 'requestId': '3db3773286ee59', + 'cpm': 0.5, + 'creativeId': 29681110, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '', + 'mediaType': 'banner', + 'currency': 'USD', + 'ttl': 300, + 'netRevenue': true, + 'adUnitCode': 'code', + 'ads4good': { + 'buyerMemberId': 958 + } + } + ]; + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code' + }] + } + let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + + it('handles nobid responses', function () { + let response = { + 'version': '0.0.1', + 'tags': [{ + 'uuid': '84ab500420319d', + 'tag_id': 5976557, + 'auction_id': '297492697822162468', + 'nobid': true + }] + }; + let bidderRequest; + + let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result.length).to.equal(0); + }); + + it('handles non-banner media responses', function () { + let response = { + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'cpm': 0.500000, + 'notify_url': 'imptracker.com', + 'rtb': { + 'video': { + 'content': '' + } + }, + 'javascriptTrackers': '' + }] + }] + }; + let bidderRequest = { + bids: [{ + bidId: '84ab500420319d', + adUnitCode: 'code' + }] + } + + let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result[0]).to.have.property('vastUrl'); + expect(result[0]).to.have.property('vastImpUrl'); + expect(result[0]).to.have.property('mediaType', 'video'); + }); + + it('should add deal_priority and deal_code', function() { + let responseWithDeal = deepClone(response); + responseWithDeal.tags[0].ads[0].deal_priority = 'high'; + responseWithDeal.tags[0].ads[0].deal_code = '123'; + + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code' + }] + } + let result = spec.interpretResponse({ body: responseWithDeal }, {bidderRequest}); + expect(Object.keys(result[0].ads4good)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']); + }); + + it('should add advertiser id', function() { + let responseAdvertiserId = deepClone(response); + responseAdvertiserId.tags[0].ads[0].advertiser_id = '123'; + + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code' + }] + } + let result = spec.interpretResponse({ body: responseAdvertiserId }, {bidderRequest}); + expect(Object.keys(result[0].meta)).to.include.members(['advertiserId']); + }) + }); +}); diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 08ea0a863ee..d27cc99b5bc 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; -import { spec } from 'modules/33acrossBidAdapter'; +import { spec } from 'modules/33acrossBidAdapter.js'; describe('33acrossBidAdapter:', function () { const BIDDER_CODE = '33across'; @@ -61,6 +61,7 @@ describe('33acrossBidAdapter:', function () { }, ext: { ttx: { + prebidStartedAt: 1, caller: [{ 'name': 'prebidjs', 'version': '$prebid.version$' @@ -74,7 +75,7 @@ describe('33acrossBidAdapter:', function () { return this; }; - this.withViewabiliuty = viewability => { + this.withViewability = viewability => { Object.assign(ttxRequest.imp[0].banner, { ext: { ttx: { viewability } @@ -102,6 +103,14 @@ describe('33acrossBidAdapter:', function () { return this; }; + this.withPageUrl = pageUrl => { + Object.assign(ttxRequest.site, { + page: pageUrl + }); + + return this; + }; + this.build = () => ttxRequest; } @@ -183,6 +192,7 @@ describe('33acrossBidAdapter:', function () { ]; sandbox = sinon.sandbox.create(); + sandbox.stub(Date, 'now').returns(1); sandbox.stub(document, 'getElementById').withArgs('div-id').returns(element); sandbox.stub(utils, 'getWindowTop').returns(win); sandbox.stub(utils, 'getWindowSelf').returns(win); @@ -265,7 +275,7 @@ describe('33acrossBidAdapter:', function () { context('when element is fully in view', function() { it('returns 100', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: 100}) + .withViewability({amount: 100}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -280,7 +290,7 @@ describe('33acrossBidAdapter:', function () { context('when element is out of view', function() { it('returns 0', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: 0}) + .withViewability({amount: 0}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -295,7 +305,7 @@ describe('33acrossBidAdapter:', function () { context('when element is partially in view', function() { it('returns percentage', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: 75}) + .withViewability({amount: 75}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -311,7 +321,7 @@ describe('33acrossBidAdapter:', function () { it('try to use alternative values', function() { const ttxRequest = new TtxRequestBuilder() .withSizes([{ w: 800, h: 2400, ext: {} }]) - .withViewabiliuty({amount: 25}) + .withViewability({amount: 25}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -327,7 +337,7 @@ describe('33acrossBidAdapter:', function () { context('when nested iframes', function() { it('returns \'nm\'', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: spec.NON_MEASURABLE}) + .withViewability({amount: spec.NON_MEASURABLE}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -347,7 +357,7 @@ describe('33acrossBidAdapter:', function () { context('when tab is inactive', function() { it('returns 0', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: 0}) + .withViewability({amount: 0}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -443,6 +453,45 @@ describe('33acrossBidAdapter:', function () { expect(builtServerRequests).to.deep.equal([serverRequest]); }); }); + + context('when referer value is available', function() { + it('returns corresponding server requests with site.page set', function() { + const bidderRequest = { + refererInfo: { + referer: 'http://foo.com/bar' + } + }; + + const ttxRequest = new TtxRequestBuilder() + .withPageUrl('http://foo.com/bar') + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + const builtServerRequests = spec.buildRequests(bidRequests, bidderRequest); + + expect(builtServerRequests).to.deep.equal([serverRequest]); + }); + }); + + context('when referer value is not available', function() { + it('returns corresponding server requests without site.page set', function() { + const bidderRequest = { + refererInfo: {} + }; + + const ttxRequest = new TtxRequestBuilder() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + const builtServerRequests = spec.buildRequests(bidRequests, bidderRequest); + + expect(builtServerRequests).to.deep.equal([serverRequest]); + }); + }); }); describe('interpretResponse', function() { @@ -452,11 +501,11 @@ describe('33acrossBidAdapter:', function () { ttxRequest = new TtxRequestBuilder() .withSite({ id: SITE_ID, - page: 'http://test-url.com' + page: 'https://test-url.com' }) .build(); serverRequest = new ServerRequestBuilder() - .withUrl('//staging-ssc.33across.com/api/v1/hb') + .withUrl('https://staging-ssc.33across.com/api/v1/hb') .withData(ttxRequest) .withOptions({ contentType: 'text/plain', @@ -577,11 +626,11 @@ describe('33acrossBidAdapter:', function () { syncs = [ { type: 'iframe', - url: 'https://de.tynt.com/deb/v2?m=xch&rt=html&id=id1' + url: 'https://ssc-cms.33across.com/ps/?m=xch&rt=html&ru=deb&id=id1' }, { type: 'iframe', - url: 'https://de.tynt.com/deb/v2?m=xch&rt=html&id=id2' + url: 'https://ssc-cms.33across.com/ps/?m=xch&rt=html&ru=deb&id=id2' }, ]; bidRequests = [ diff --git a/test/spec/modules/7xbidBidAdapter_spec.js b/test/spec/modules/7xbidBidAdapter_spec.js new file mode 100644 index 00000000000..bed2c604349 --- /dev/null +++ b/test/spec/modules/7xbidBidAdapter_spec.js @@ -0,0 +1,160 @@ +import {expect} from 'chai'; +import {spec, _getUrlVars} from 'modules/7xbidBidAdapter.js'; +import * as utils from 'src/utils.js'; + +const BASE_URI = '//bidder.7xbid.com/api/v1/prebid/banner' +const NATIVE_BASE_URI = '//bidder.7xbid.com/api/v1/prebid/native' + +describe('7xbid adapter', function() { + let bidRequests; + let nativeBidRequests; + + beforeEach(function() { + bidRequests = [ + { + bidder: '7xbid', + params: { + placementId: 1425292, + currency: 'USD' + } + } + ] + + nativeBidRequests = [ + { + bidder: '7xbid', + params: { + placementId: 1429695, + currency: 'USD' + }, + nativeParams: { + title: { + required: true, + len: 80 + }, + image: { + required: true, + sizes: [150, 50] + }, + sponsoredBy: { + required: true + } + } + } + ] + }) + describe('isBidRequestValid', function () { + it('valid bid case', function () { + let validBid = { + bidder: '7xbid', + params: { + placementId: 1425292, + currency: 'USD' + } + } + let isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); + + it('invalid bid case: placementId is not passed', function() { + let validBid = { + bidder: '7xbid', + params: { + } + } + let isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }) + + it('invalid bid case: currency is not support', function() { + let validBid = { + bidder: '7xbid', + params: { + placementId: 1108295, + currency: 'AUD' + } + } + let isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }) + }) + + describe('buildRequests', function () { + it('sends bid request to ENDPOINT via GET', function () { + const request = spec.buildRequests(bidRequests)[0]; + expect(request.url).to.equal(BASE_URI); + expect(request.method).to.equal('GET'); + }); + + it('sends native bid request to ENDPOINT via GET', function () { + const request = spec.buildRequests(nativeBidRequests)[0]; + expect(request.url).to.equal(NATIVE_BASE_URI); + expect(request.method).to.equal('GET'); + }); + + it('buildRequests function should not modify original bidRequests object', function () { + let originalBidRequests = utils.deepClone(bidRequests); + let request = spec.buildRequests(bidRequests); + expect(bidRequests).to.deep.equal(originalBidRequests); + }); + + it('buildRequests function should not modify original nativeBidRequests object', function () { + let originalBidRequests = utils.deepClone(nativeBidRequests); + let request = spec.buildRequests(nativeBidRequests); + expect(nativeBidRequests).to.deep.equal(originalBidRequests); + }); + + it('Request params check', function() { + let request = spec.buildRequests(bidRequests)[0]; + const data = _getUrlVars(request.data) + expect(parseInt(data.placementid)).to.exist.and.to.equal(bidRequests[0].params.placementId); + expect(data.cur).to.exist.and.to.equal(bidRequests[0].params.currency); + }) + + it('Native request params check', function() { + let request = spec.buildRequests(nativeBidRequests)[0]; + const data = _getUrlVars(request.data) + expect(parseInt(data.placementid)).to.exist.and.to.equal(nativeBidRequests[0].params.placementId); + expect(data.cur).to.exist.and.to.equal(nativeBidRequests[0].params.currency); + }) + }) + + describe('interpretResponse', function () { + let response = { + 1425292: + { + 'creativeId': '', + 'cur': 'USD', + 'price': 0.0920, + 'width': 300, + 'height': 250, + 'requestid': '2e42361a6172bf', + 'adm': '' + } + } + + it('should get correct bid response', function () { + let expectedResponse = [ + { + 'requestId': '2e42361a6172bf', + 'cpm': 0.0920, + 'width': 300, + 'height': 250, + 'netRevenue': true, + 'currency': 'USD', + 'creativeId': '', + 'ttl': 700, + 'ad': '' + } + ]; + let request = spec.buildRequests(bidRequests)[0]; + let result = spec.interpretResponse({body: response}, request); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + expect(result[0].cpm).to.not.equal(null); + expect(result[0].creativeId).to.not.equal(null); + expect(result[0].ad).to.not.equal(null); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + }); + }) +}) diff --git a/test/spec/modules/a4gBidAdapter_spec.js b/test/spec/modules/a4gBidAdapter_spec.js deleted file mode 100644 index f5aa1014702..00000000000 --- a/test/spec/modules/a4gBidAdapter_spec.js +++ /dev/null @@ -1,149 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/a4gBidAdapter'; - -describe('a4gAdapterTests', function () { - describe('bidRequestValidity', function () { - it('bidRequest with zoneId and deliveryUrl params', function () { - expect(spec.isBidRequestValid({ - bidder: 'a4g', - params: { - zoneId: 59304, - deliveryUrl: 'http://dev01.ad4game.com/v1/bid' - } - })).to.equal(true); - }); - - it('bidRequest with only zoneId', function () { - expect(spec.isBidRequestValid({ - bidder: 'a4g', - params: { - zoneId: 59304 - } - })).to.equal(true); - }); - - it('bidRequest with only deliveryUrl', function () { - expect(spec.isBidRequestValid({ - bidder: 'a4g', - params: { - deliveryUrl: 'http://dev01.ad4game.com/v1/bid' - } - })).to.equal(false); - }); - }); - - describe('bidRequest', function () { - const bidRequests = [{ - 'bidder': 'a4g', - 'bidId': '51ef8751f9aead', - 'params': { - 'zoneId': 59304, - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[320, 50], [300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }, { - 'bidder': 'a4g', - 'bidId': '51ef8751f9aead', - 'params': { - 'zoneId': 59354, - 'deliveryUrl': '//dev01.ad4game.com/v1/bid' - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[320, 50], [300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - it('bidRequest method', function () { - const request = spec.buildRequests(bidRequests); - expect(request.method).to.equal('GET'); - }); - - it('bidRequest url', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.match(new RegExp(`${bidRequests[1].params.deliveryUrl}`)); - }); - - it('bidRequest data', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data).to.exist; - }); - - it('bidRequest zoneIds', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data.zoneId).to.equal('59304;59354'); - }); - - it('bidRequest gdpr consent', function () { - const consentString = 'consentString'; - const bidderRequest = { - bidderCode: 'a4g', - auctionId: '18fd8b8b0bd757', - bidderRequestId: '418b37f85e772c', - timeout: 3000, - gdprConsent: { - consentString: consentString, - gdprApplies: true - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - - expect(request.data.gdpr).to.exist; - expect(request.data.gdpr.applies).to.exist.and.to.be.true; - expect(request.data.gdpr.consent).to.exist.and.to.equal(consentString); - }); - }); - - describe('interpretResponse', function () { - const bidRequest = [{ - 'bidder': 'a4g', - 'bidId': '51ef8751f9aead', - 'params': { - 'zoneId': 59304, - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[320, 50], [300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - const bidResponse = { - body: [{ - 'id': 'div-gpt-ad-1460505748561-0', - 'ad': 'test ad', - 'width': 320, - 'height': 250, - 'cpm': 5.2 - }], - headers: {} - }; - - it('required keys', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - - let requiredKeys = [ - 'requestId', - 'creativeId', - 'adId', - 'cpm', - 'width', - 'height', - 'currency', - 'netRevenue', - 'ttl', - 'ad' - ]; - - let resultKeys = Object.keys(result[0]); - resultKeys.forEach(function(key) { - expect(requiredKeys.indexOf(key) !== -1).to.equal(true); - }); - }) - }); -}); diff --git a/test/spec/modules/aardvarkBidAdapter_spec.js b/test/spec/modules/aardvarkBidAdapter_spec.js index b532fa4264a..9671f961407 100644 --- a/test/spec/modules/aardvarkBidAdapter_spec.js +++ b/test/spec/modules/aardvarkBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as utils from 'src/utils'; -import { spec, resetUserSync } from 'modules/aardvarkBidAdapter'; +import * as utils from 'src/utils.js'; +import { spec, resetUserSync } from 'modules/aardvarkBidAdapter.js'; describe('aardvarkAdapterTest', function () { describe('forming valid bidRequests', function () { @@ -58,7 +58,7 @@ describe('aardvarkAdapterTest', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -72,7 +72,7 @@ describe('aardvarkAdapterTest', function () { it('should call the correct bidRequest url', function () { const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests.length).to.equal(1); - expect(requests[0].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/TdAx_RAZd/aardvark\?')); + expect(requests[0].url).to.match(new RegExp('^https:\/\/adzone.pub.com/xiby/TdAx_RAZd/aardvark\?')); }); it('should have correct data', function () { @@ -125,7 +125,7 @@ describe('aardvarkAdapterTest', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -138,9 +138,9 @@ describe('aardvarkAdapterTest', function () { it('should call the correct bidRequest urls for each auction', function () { const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].url).to.match(new RegExp('^\/\/bidder.rtk.io/Toby/TdAx/aardvark\?')); + expect(requests[0].url).to.match(new RegExp('^https:\/\/bidder.rtk.io/Toby/TdAx/aardvark\?')); expect(requests[0].data.categories.length).to.equal(2); - expect(requests[1].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/RAZd/aardvark\?')); + expect(requests[1].url).to.match(new RegExp('^https:\/\/adzone.pub.com/xiby/RAZd/aardvark\?')); }); it('should have correct data', function () { @@ -187,7 +187,7 @@ describe('aardvarkAdapterTest', function () { gdprApplies: true }, refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -217,7 +217,7 @@ describe('aardvarkAdapterTest', function () { const bidderRequest = { gdprConsent: undefined, refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -229,13 +229,61 @@ describe('aardvarkAdapterTest', function () { }); }); + describe('CCPA conformity', function () { + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + }, + adUnitCode: 'aaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337' + }]; + + it('should transmit us_privacy data', function () { + const usp = '1NY-'; + const bidderRequest = { + gdprConsent: { + consentString: 'awefasdfwefasdfasd', + gdprApplies: true + }, + refererInfo: { + referer: 'http://example.com' + }, + uspConsent: usp + }; + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests.length).to.equal(1); + expect(requests[0].data.gdpr).to.equal(true); + expect(requests[0].data.consent).to.equal('awefasdfwefasdfasd'); + expect(requests[0].data.us_privacy).to.equal(usp); + }); + + it('should not send us_privacy', function () { + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests.length).to.equal(1); + expect(requests[0].data.gdpr).to.be.undefined; + expect(requests[0].data.consent).to.be.undefined; + expect(requests[0].data.us_privacy).to.be.undefined; + }); + }); + describe('interpretResponse', function () { it('should handle bid responses', function () { const serverResponse = { body: [ { media: 'banner', - nurl: 'http://www.nurl.com/0', + nurl: 'https://www.nurl.com/0', cpm: 0.09, width: 300, height: 250, @@ -246,7 +294,7 @@ describe('aardvarkAdapterTest', function () { }, { media: 'banner', - nurl: 'http://www.nurl.com/1', + nurl: 'https://www.nurl.com/1', cpm: 0.19, width: 300, height: 250, @@ -307,7 +355,7 @@ describe('aardvarkAdapterTest', function () { const syncs = spec.getUserSyncs(syncOptions); expect(syncs.length).to.equal(1); expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('//sync.rtk.io/cs'); + expect(syncs[0].url).to.equal('https://sync.rtk.io/cs'); }); it('should return empty, as we sync only once', function () { @@ -341,7 +389,16 @@ describe('aardvarkAdapterTest', function () { const syncs = spec.getUserSyncs(syncOptions, null, gdprConsent); expect(syncs.length).to.equal(1); expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('//sync.rtk.io/cs?g=1&c=BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'); + expect(syncs[0].url).to.equal('https://sync.rtk.io/cs?g=1&c=BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'); + }); + + it('should produce sync url with ccpa params', function () { + resetUserSync(); + + const syncs = spec.getUserSyncs(syncOptions, null, {}, '1YYN'); + expect(syncs.length).to.equal(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.equal('https://sync.rtk.io/cs?us_privacy=1YYN'); }); }); @@ -366,7 +423,7 @@ describe('aardvarkAdapterTest', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -419,4 +476,94 @@ describe('aardvarkAdapterTest', function () { }); }); }); + + describe('schain support', function() { + const nodePropsOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; + let schainConfig = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'rtk.io', + sid: '1234', + hp: 1, + rid: 'bid-request-1', + name: 'first pub', + domain: 'first.com' + }, + { + asi: 'rtk.io', + sid: '5678', + hp: 1, + rid: 'bid-request-2', + name: 'second pub', + domain: 'second.com' + } + ] + }; + + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + }, + adUnitCode: 'aaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337', + schain: schainConfig, + }]; + + const bidderRequest = { + gdprConsent: undefined, + refererInfo: { + referer: 'https://example.com' + } + }; + + it('should properly serialize schain object with correct delimiters', () => { + const results = spec.buildRequests(bidRequests, bidderRequest); + const numNodes = schainConfig.nodes.length; + + const schain = results[0].data.schain; + + // each node serialization should start with an ! + expect(schain.match(/!/g).length).to.equal(numNodes); + + // 5 commas per node plus 1 for version + expect(schain.match(/,/g).length).to.equal(numNodes * 5 + 1); + }); + + it('should send the proper version for the schain', () => { + const results = spec.buildRequests(bidRequests, bidderRequest); + const schain = decodeURIComponent(results[0].data.schain).split('!'); + const version = schain.shift().split(',')[0]; + expect(version).to.equal(bidRequests[0].schain.ver); + }); + + it('should send the correct value for complete in schain', () => { + const results = spec.buildRequests(bidRequests, bidderRequest); + const schain = decodeURIComponent(results[0].data.schain).split('!'); + const complete = schain.shift().split(',')[1]; + expect(complete).to.equal(String(bidRequests[0].schain.complete)); + }); + + it('should send available params in the right order', () => { + const results = spec.buildRequests(bidRequests, bidderRequest); + const schain = decodeURIComponent(results[0].data.schain).split('!'); + schain.shift(); + + schain.forEach((serializeNode, nodeIndex) => { + const nodeProps = serializeNode.split(','); + nodeProps.forEach((nodeProp, propIndex) => { + const node = schainConfig.nodes[nodeIndex]; + const key = nodePropsOrder[propIndex]; + expect(nodeProp).to.equal(node[key] ? String(node[key]) : ''); + }); + }); + }); + }); }); diff --git a/test/spec/modules/ablidaBidAdapter_spec.js b/test/spec/modules/ablidaBidAdapter_spec.js new file mode 100644 index 00000000000..ca4fd4ab0be --- /dev/null +++ b/test/spec/modules/ablidaBidAdapter_spec.js @@ -0,0 +1,102 @@ +import {assert, expect} from 'chai'; +import {spec} from 'modules/ablidaBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; + +const ENDPOINT_URL = 'https://bidder.ablida.net/prebid'; + +describe('ablidaBidAdapter', function () { + const adapter = newBidder(spec); + describe('isBidRequestValid', function () { + let bid = { + bidder: 'ablida', + params: { + placementId: 123 + }, + adUnitCode: 'adunit-code', + sizes: [ + [300, 250] + ], + bidId: '1234asdf1234', + bidderRequestId: '1234asdf1234asdf', + auctionId: '69e8fef8-5105-4a99-b011-d5669f3bc7f0' + }; + it('should return true where required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + }); + describe('buildRequests', function () { + let bidRequests = [ + { + bidder: 'ablida', + params: { + placementId: 123 + }, + sizes: [ + [300, 250] + ], + adUnitCode: 'adunit-code', + bidId: '23beaa6af6cdde', + bidderRequestId: '14d2939272a26a', + auctionId: '69e8fef8-5105-4a99-b011-d5669f3bc7f0', + } + ]; + + let bidderRequests = { + refererInfo: { + numIframes: 0, + reachedTop: true, + referer: 'http://example.com', + stack: ['http://example.com'] + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequests); + it('sends bid request via POST', function () { + expect(request[0].method).to.equal('POST'); + }); + }); + + describe('interpretResponse', function () { + let bidRequest = { + method: 'POST', + url: ENDPOINT_URL, + data: { + placementId: 'testPlacementId', + width: 300, + height: 200, + bidId: '2b8c4de0116e54', + jaySupported: true, + device: 'desktop', + referer: 'www.example.com' + } + }; + let serverResponse = { + body: [{ + requestId: '2b8c4de0116e54', + cpm: 1.00, + width: 300, + height: 250, + creativeId: '2b8c4de0116e54', + currency: 'EUR', + netRevenue: true, + ttl: 3000, + ad: '' + }] + }; + it('should get the correct bid response', function () { + let expectedResponse = [{ + requestId: '2b8c4de0116e54', + cpm: 1.00, + width: 300, + height: 250, + creativeId: '2b8c4de0116e54', + currency: 'EUR', + netRevenue: true, + ttl: 3000, + ad: '' + }]; + let result = spec.interpretResponse(serverResponse, bidRequest[0]); + expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); + }); + }); +}); diff --git a/test/spec/modules/adagioAnalyticsAdapter_spec.js b/test/spec/modules/adagioAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..aee85412104 --- /dev/null +++ b/test/spec/modules/adagioAnalyticsAdapter_spec.js @@ -0,0 +1,183 @@ +import adagioAnalyticsAdapter from 'modules/adagioAnalyticsAdapter.js'; +import { expect } from 'chai'; +import * as utils from 'src/utils.js'; + +let adapterManager = require('src/adapterManager').default; +let events = require('src/events'); +let constants = require('src/constants.json'); + +describe('adagio analytics adapter', () => { + let sandbox; + let adagioQueuePushSpy; + + beforeEach(() => { + sandbox = sinon.createSandbox(); + + sandbox.stub(events, 'getEvents').returns([]); + + const w = utils.getWindowTop(); + + adapterManager.registerAnalyticsAdapter({ + code: 'adagio', + adapter: adagioAnalyticsAdapter + }); + + w.ADAGIO = w.ADAGIO || {}; + w.ADAGIO.queue = w.ADAGIO.queue || []; + + adagioQueuePushSpy = sandbox.spy(w.ADAGIO.queue, 'push'); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('track', () => { + beforeEach(() => { + adapterManager.enableAnalytics({ + provider: 'adagio' + }); + }); + + afterEach(() => { + adagioAnalyticsAdapter.disableAnalytics(); + }); + + it('builds and sends auction data', () => { + const w = utils.getWindowTop(); + + let bidRequest = { + bids: [{ + adUnitCode: 'div-1', + params: { + features: { + siteId: '2', + placement: 'pave_top', + pagetype: 'article', + category: 'IAB12,IAB12-2', + device: '2', + } + } + }, { + adUnitCode: 'div-2', + params: { + features: { + siteId: '2', + placement: 'ban_top', + pagetype: 'article', + category: 'IAB12,IAB12-2', + device: '2', + } + }, + }], + }; + let bidResponse = { + bidderCode: 'adagio', + width: 300, + height: 250, + statusMessage: 'Bid available', + cpm: 6.2189757658226075, + currency: '', + netRevenue: false, + adUnitCode: 'div-1', + timeToRespond: 132, + }; + + // Step 1: Send bid requested event + events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); + + // Step 2: Send bid response event + events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); + + // Step 3: Send auction end event + events.emit(constants.EVENTS.AUCTION_END, {}); + + sandbox.assert.callCount(adagioQueuePushSpy, 3); + + const call0 = adagioQueuePushSpy.getCall(0); + expect(call0.args[0].action).to.equal('pb-analytics-event'); + expect(call0.args[0].ts).to.not.be.undefined; + expect(call0.args[0].data).to.not.be.undefined; + expect(call0.args[0].data).to.deep.equal({eventName: constants.EVENTS.BID_REQUESTED, args: bidRequest}); + + const call1 = adagioQueuePushSpy.getCall(1); + expect(call1.args[0].action).to.equal('pb-analytics-event'); + expect(call1.args[0].ts).to.not.be.undefined; + expect(call1.args[0].data).to.not.be.undefined; + expect(call1.args[0].data).to.deep.equal({eventName: constants.EVENTS.BID_RESPONSE, args: bidResponse}); + + const call2 = adagioQueuePushSpy.getCall(2); + expect(call2.args[0].action).to.equal('pb-analytics-event'); + expect(call2.args[0].ts).to.not.be.undefined; + expect(call2.args[0].data).to.not.be.undefined; + expect(call2.args[0].data).to.deep.equal({eventName: constants.EVENTS.AUCTION_END, args: {}}); + }); + }); + + describe('no track', () => { + beforeEach(() => { + sandbox.stub(utils, 'getWindowTop').throws(); + + adapterManager.enableAnalytics({ + provider: 'adagio' + }); + }); + + afterEach(() => { + adagioAnalyticsAdapter.disableAnalytics(); + sandbox.restore(); + }); + + it('builds and sends auction data', () => { + let bidRequest = { + bids: [{ + adUnitCode: 'div-1', + params: { + features: { + siteId: '2', + placement: 'pave_top', + pagetype: 'article', + category: 'IAB12,IAB12-2', + device: '2', + } + } + }, { + adUnitCode: 'div-2', + params: { + features: { + siteId: '2', + placement: 'ban_top', + pagetype: 'article', + category: 'IAB12,IAB12-2', + device: '2', + } + }, + }], + }; + let bidResponse = { + bidderCode: 'adagio', + width: 300, + height: 250, + statusMessage: 'Bid available', + cpm: 6.2189757658226075, + currency: '', + netRevenue: false, + adUnitCode: 'div-1', + timeToRespond: 132, + }; + + // Step 1: Send bid requested event + events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); + + // Step 2: Send bid response event + events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); + + // Step 3: Send auction end event + events.emit(constants.EVENTS.AUCTION_END, {}); + + utils.getWindowTop.restore(); + + sandbox.assert.callCount(adagioQueuePushSpy, 0); + }); + }); +}); diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js index 7437b45b6c1..f387b7a021c 100644 --- a/test/spec/modules/adagioBidAdapter_spec.js +++ b/test/spec/modules/adagioBidAdapter_spec.js @@ -1,10 +1,22 @@ import { expect } from 'chai'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { spec } from 'modules/adagioBidAdapter'; +import { getAdagioScript, spec } from 'modules/adagioBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; describe('adagioAdapter', () => { + let utilsMock; const adapter = newBidder(spec); const ENDPOINT = 'https://mp.4dex.io/prebid'; + const VERSION = '2.2.0'; + + beforeEach(function() { + localStorage.removeItem('adagioScript'); + utilsMock = sinon.mock(utils); + }); + + afterEach(function() { + utilsMock.restore(); + }); describe('inherited functions', () => { it('exists and is a function', () => { @@ -13,12 +25,40 @@ describe('adagioAdapter', () => { }); describe('isBidRequestValid', () => { + let sandbox; + beforeEach(function () { + sandbox = sinon.sandbox.create(); + let element = { + x: 0, + y: 0, + width: 200, + height: 300, + getBoundingClientRect: () => { + return { + width: element.width, + height: element.height, + left: element.x, + top: element.y, + right: element.x + element.width, + bottom: element.y + element.height + }; + } + }; + sandbox.stub(document, 'getElementById').withArgs('banner-atf').returns(element); + }); + + afterEach(function () { + sandbox.restore(); + }); + let bid = { 'bidder': 'adagio', 'params': { - siteId: '123', - placementId: 4, - categories: ['IAB12', 'IAB12-2'] + organizationId: '0', + placement: 'PAVE_ATF', + site: 'SITE-NAME', + pagetype: 'ARTICLE', + adUnitElementId: 'banner-atf' }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -27,33 +67,168 @@ describe('adagioAdapter', () => { 'auctionId': 'lel4fhp239i9km', }; + let bidWithMediaTypes = { + 'bidder': 'adagio', + 'params': { + organizationId: '0', + placement: 'PAVE_ATF', + site: 'SITE-NAME', + pagetype: 'ARTICLE', + adUnitElementId: 'banner-atf' + }, + 'adUnitCode': 'adunit-code-2', + 'mediaTypes': { + banner: { + sizes: [[300, 250]], + } + }, + sizes: [[300, 600]], + 'bidId': 'c180kg4267tyqz', + 'bidderRequestId': '8vfscuixrovn8i', + 'auctionId': 'lel4fhp239i9km', + } + it('should return true when required params found', () => { expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(window.top.ADAGIO.adUnits['adunit-code'].printNumber).to.equal(1); + }) + + it('should compute a printNumber for the new bid request on same adUnitCode and same pageviewId', () => { + spec.isBidRequestValid(bid); + expect(window.top.ADAGIO.adUnits).ok; + expect(window.top.ADAGIO.adUnits['adunit-code']).ok; + expect(window.top.ADAGIO.adUnits['adunit-code'].printNumber).to.equal(2); + + spec.isBidRequestValid(bid); + expect(window.top.ADAGIO.adUnits['adunit-code'].printNumber).to.equal(3); + + window.top.ADAGIO.pageviewId = 123; + spec.isBidRequestValid(bid); + expect(window.top.ADAGIO.adUnits['adunit-code'].printNumber).to.equal(1); + }); + + it('should return false when organization params is not passed', () => { + let bidTest = Object.assign({}, bid); + delete bidTest.params.organizationId; + expect(spec.isBidRequestValid(bidTest)).to.equal(false); }); it('should return false when site params is not passed', () => { let bidTest = Object.assign({}, bid); - delete bidTest.params.siteId; + delete bidTest.params.site; expect(spec.isBidRequestValid(bidTest)).to.equal(false); }); it('should return false when placement params is not passed', () => { let bidTest = Object.assign({}, bid); - delete bidTest.params.placementId; + delete bidTest.params.placement; + expect(spec.isBidRequestValid(bidTest)).to.equal(false); + }); + + it('should return false when adUnit element id params is not passed', () => { + let bidTest = Object.assign({}, bid); + delete bidTest.params.adUnitElementId; expect(spec.isBidRequestValid(bidTest)).to.equal(false); }); + + it('should return false if not in the window.top', () => { + sandbox.stub(utils, 'getWindowTop').throws(); + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should expose ADAGIO.pbjsAdUnits in window', () => { + spec.isBidRequestValid(bidWithMediaTypes); + spec.isBidRequestValid(bid); + expect(window.top.ADAGIO.pbjsAdUnits).ok; + expect(window.top.ADAGIO.pbjsAdUnits).to.have.lengthOf(2); + const adUnitWithMediaTypeSizes = window.top.ADAGIO.pbjsAdUnits.filter((aU) => aU.code === 'adunit-code-2')[0]; + const adUnitWithSizes = window.top.ADAGIO.pbjsAdUnits.filter((aU) => aU.code === 'adunit-code')[0]; + expect(adUnitWithMediaTypeSizes.sizes).to.eql([[300, 250]]); + expect(adUnitWithSizes.sizes).to.eql([[300, 250], [300, 600]]); + }); }); describe('buildRequests', () => { + const sandbox = sinon.createSandbox(); + + const banner300x250 = { + x: 0, + y: 0, + width: 300, + height: 250, + getBoundingClientRect: () => { + return { + width: banner300x250.width, + height: banner300x250.height, + left: banner300x250.x, + top: banner300x250.y, + right: banner300x250.x + banner300x250.width, + bottom: banner300x250.y + banner300x250.height + }; + }, + }; + + const banner300x600 = { + x: 0, + y: 0, + width: 300, + height: 600, + getBoundingClientRect: () => { + return { + width: banner300x600.width, + height: banner300x600.height, + left: banner300x600.x, + top: banner300x600.y, + right: banner300x600.x + banner300x600.width, + bottom: banner300x600.y + banner300x600.height + }; + }, + }; + + const computedStyleBlock = { + display: 'block' + }; + + const computedStyleNone = { + display: 'none' + }; + + const stubs = { + topGetElementById: undefined, + topGetComputedStyle: undefined + } + + top.ADAGIO = top.ADAGIO || {}; + top.ADAGIO.adUnits = top.ADAGIO.adUnits || {}; + top.ADAGIO.pbjsAdUnits = top.ADAGIO.pbjsAdUnits || []; + + beforeEach(function () { + stubs.topGetElementById = sandbox.stub(top.document, 'getElementById'); + stubs.topGetComputedStyle = sandbox.stub(top, 'getComputedStyle'); + + stubs.topGetElementById.withArgs('banner-atf-123').returns(banner300x250); + stubs.topGetElementById.withArgs('banner-atf-456').returns(banner300x600); + stubs.topGetElementById.withArgs('does-not-exist').returns(null); + stubs.topGetComputedStyle.returns(computedStyleBlock); + }); + + afterEach(function () { + sandbox.restore(); + }); + + after(function() { + sandbox.reset(); + }) + let bidRequests = [ - // siteId 123 { 'bidder': 'adagio', 'params': { - siteId: '123', - placementId: 4, - pagetypeId: '232', - categories: ['IAB12'] + organizationId: '123', + site: 'ADAGIO-123', + placement: 'PAVE_ATF-123', + pagetype: 'ARTICLE', + adUnitElementId: 'banner-atf-123' }, 'adUnitCode': 'adunit-code1', 'sizes': [[300, 250], [300, 600]], @@ -64,10 +239,11 @@ describe('adagioAdapter', () => { { 'bidder': 'adagio', 'params': { - siteId: '123', - placementId: 3, - pagetypeId: '232', - categories: ['IAB12'] + organizationId: '123', + site: 'ADAGIO-123', + placement: 'PAVE_ATF-123', + pagetype: 'ARTICLE', + adUnitElementId: 'banner-atf-123' }, 'adUnitCode': 'adunit-code2', 'sizes': [[300, 250], [300, 600]], @@ -75,14 +251,38 @@ describe('adagioAdapter', () => { 'bidderRequestId': '8vfscuixrovn8i', 'auctionId': 'lel4fhp239i9km', }, - // siteId 456 { 'bidder': 'adagio', 'params': { - siteId: '456', - placementId: 4, - pagetypeId: '232', - categories: ['IAB12'] + organizationId: '456', + site: 'ADAGIO-456', + placement: 'PAVE_ATF-456', + pagetype: 'ARTICLE', + adUnitElementId: 'banner-atf-456' + }, + 'adUnitCode': 'adunit-code3', + 'mediaTypes': { + banner: { + sizes: [[300, 250]] + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'c180kg4267tyqz', + 'bidderRequestId': '8vfscuixrovn8i', + 'auctionId': 'lel4fhp239i9km', + } + ]; + + const bidRequestsWithPostBid = [ + { + 'bidder': 'adagio', + 'params': { + organizationId: '456', + site: 'ADAGIO-456', + placement: 'PAVE_ATF-456', + pagetype: 'ARTICLE', + adUnitElementId: 'banner-atf-456', + postBid: true }, 'adUnitCode': 'adunit-code3', 'sizes': [[300, 250], [300, 600]], @@ -101,35 +301,151 @@ describe('adagioAdapter', () => { 'gdprConsent': { consentString: consentString, gdprApplies: true, - allowAuctionWithoutConsent: true + allowAuctionWithoutConsent: true, + apiVersion: 1, + }, + 'refererInfo': { + 'numIframes': 0, + 'reachedTop': true, + 'referer': 'http://test.io/index.html?pbjs_debug=true' + } + }; + + let bidderRequestTCF2 = { + 'bidderCode': 'adagio', + 'auctionId': '12jejebn', + 'bidderRequestId': 'hehehehbeheh', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + vendorData: { + tcString: consentString, + gdprApplies: true + }, + gdprApplies: true, + apiVersion: 2 + }, + 'refererInfo': { + 'numIframes': 0, + 'reachedTop': true, + 'referer': 'http://test.io/index.html?pbjs_debug=true' } }; it('groups requests by siteId', () => { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests).to.have.lengthOf(2); - expect(requests[0].data.siteId).to.equal('123'); + expect(requests[0].data.organizationId).to.equal('123'); expect(requests[0].data.adUnits).to.have.lengthOf(2); - expect(requests[1].data.siteId).to.equal('456'); + expect(requests[1].data.organizationId).to.equal('456'); expect(requests[1].data.adUnits).to.have.lengthOf(1); }); it('sends bid request to ENDPOINT_PB via POST', () => { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests).to.have.lengthOf(2); const request = requests[0]; expect(request.method).to.equal('POST'); expect(request.url).to.equal(ENDPOINT); + expect(request.data.prebidVersion).to.equal('$prebid.version$'); + }); + + it('features params "adunit_position" must be empty if adUnitElement is not found in the DOM', () => { + const requests = spec.buildRequests([Object.assign({}, bidRequests[0], {params: {adUnitElementId: 'does-not-exist'}})], bidderRequest); + const request = requests[0]; + expect(request.data.adUnits[0].features).to.exist; + expect(request.data.adUnits[0].features.adunit_position).to.deep.equal(''); + }); + + it('features params "adunit_position" should be computed even if DOM element is display:none', () => { + stubs.topGetComputedStyle.returns(computedStyleNone); + const requests = spec.buildRequests([Object.assign({}, bidRequests[0])], bidderRequest); + let request = requests[0]; + expect(request.data.adUnits[0].features).to.exist; + expect(request.data.adUnits[0].features.adunit_position).to.equal('0x0'); + }); + + it('features params "viewport" should be computed even if window.innerWidth is not supported', () => { + sandbox.stub(top, 'innerWidth').value(undefined); + const requests = spec.buildRequests([Object.assign({}, bidRequests[0])], bidderRequest); + let request = requests[0]; + expect(request.data.adUnits[0].features).to.exist; + expect(request.data.adUnits[0].features.viewport_dimensions).to.match(/^[\d]+x[\d]+$/); + }); + + it('AdUnit requested should have the correct sizes array depending on the config', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests[1].data.adUnits[0]).to.have.property('mediaTypes'); + }); + + it('features params must be an object if featurejs is loaded', () => { + let requests = spec.buildRequests(bidRequests, bidderRequest); + let request = requests[0]; + expect(request.data.adUnits[0].features).to.exist; + }); + + it('outerAdUnitElementId must be added when PostBid param has been set', () => { + top.ADAGIO = top.ADAGIO || {}; + top.ADAGIO.pbjsAdUnits = []; + + top.ADAGIO.pbjsAdUnits.push({ + code: bidRequestsWithPostBid[0].adUnitCode, + sizes: bidRequestsWithPostBid[0].sizes, + bids: [{ + bidder: bidRequestsWithPostBid[0].bidder, + params: bidRequestsWithPostBid[0].params + }] + }); + let requests = spec.buildRequests(bidRequestsWithPostBid, bidderRequest); + let request = requests[0]; + expect(request.data.adUnits[0].features).to.exist; + expect(request.data.adUnits[0].params.outerAdUnitElementId).to.exist; + top.ADAGIO.pbjsAdUnits = undefined; }); - it('features params must be an empty object if featurejs is not loaded', () => { - const requests = spec.buildRequests(bidRequests); + it('generates a pageviewId if missing', () => { + window.top.ADAGIO = window.top.ADAGIO || {}; + delete window.top.ADAGIO.pageviewId; + + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests).to.have.lengthOf(2); + + expect(requests[0].data.pageviewId).to.exist.and.to.not.equal('_').and.to.not.equal(''); + expect(requests[0].data.pageviewId).to.equal(requests[1].data.pageviewId); + }); + + it('uses an existing pageviewId if present', () => { + window.top.ADAGIO = window.top.ADAGIO || {}; + window.top.ADAGIO.pageviewId = 'abc'; + + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests).to.have.lengthOf(2); + + expect(requests[0].data.pageviewId).to.equal('abc'); + expect(requests[1].data.pageviewId).to.equal('abc'); + }); + + it('should send the printNumber in features object', () => { + window.top.ADAGIO = window.top.ADAGIO || {}; + window.top.ADAGIO.pageviewId = 'abc'; + window.top.ADAGIO.adUnits['adunit-code1'] = { + pageviewId: 'abc', + printNumber: 2 + }; + const requests = spec.buildRequests([bidRequests[0]], bidderRequest); const request = requests[0]; - const expected = {}; - expect(request.data.adUnits[0].params.features).to.deep.equal(expected); + expect(request.data.adUnits[0].features.print_number).to.equal('2'); + }); + + it('organizationId param key must be a string', () => { + const requests = spec.buildRequests([Object.assign({}, bidRequests[0], {params: {organizationId: 1010}})], bidderRequest); + const request = requests[0]; + expect(request.data.adUnits[0].params).to.exist; + expect(request.data.adUnits[0].params.organizationId).to.deep.equal('1010'); + expect(request.data.organizationId).to.exist; + expect(request.data.organizationId).to.deep.equal('1010'); }); it('GDPR consent is applied', () => { @@ -139,6 +455,17 @@ describe('adagioAdapter', () => { expect(request.data.gdpr).to.exist; expect(request.data.gdpr.consentString).to.exist.and.to.equal(consentString); expect(request.data.gdpr.consentRequired).to.exist.and.to.equal(1); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(1); + }); + + it('GDPR consent is applied w/ TCF2', () => { + const requests = spec.buildRequests(bidRequests, bidderRequestTCF2); + expect(requests).to.have.lengthOf(2); + const request = requests[0]; + expect(request.data.gdpr).to.exist; + expect(request.data.gdpr.consentString).to.exist.and.to.equal(consentString); + expect(request.data.gdpr.consentRequired).to.exist.and.to.equal(1); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(2); }); it('GDPR consent is not applied', () => { @@ -149,6 +476,18 @@ describe('adagioAdapter', () => { expect(request.data.gdpr).to.exist; expect(request.data.gdpr.consentString).to.exist.and.to.equal(consentString); expect(request.data.gdpr.consentRequired).to.exist.and.to.equal(0); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(1); + }); + + it('GDPR consent is not applied w/ TCF2', () => { + bidderRequestTCF2.gdprConsent.gdprApplies = false; + const requests = spec.buildRequests(bidRequests, bidderRequestTCF2); + expect(requests).to.have.lengthOf(2); + const request = requests[0]; + expect(request.data.gdpr).to.exist; + expect(request.data.gdpr.consentString).to.exist.and.to.equal(consentString); + expect(request.data.gdpr.consentRequired).to.exist.and.to.equal(0); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(2); }); it('GDPR consent is undefined', () => { @@ -162,6 +501,20 @@ describe('adagioAdapter', () => { expect(request.data.gdpr).to.not.have.property('consentString'); expect(request.data.gdpr).to.not.have.property('gdprApplies'); expect(request.data.gdpr).to.not.have.property('allowAuctionWithoutConsent'); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(1); + }); + + it('GDPR consent is undefined w/ TCF2', () => { + delete bidderRequestTCF2.gdprConsent.consentString; + delete bidderRequestTCF2.gdprConsent.gdprApplies; + delete bidderRequestTCF2.gdprConsent.vendorData; + const requests = spec.buildRequests(bidRequests, bidderRequestTCF2); + expect(requests).to.have.lengthOf(2); + const request = requests[0]; + expect(request.data.gdpr).to.exist; + expect(request.data.gdpr).to.not.have.property('consentString'); + expect(request.data.gdpr).to.not.have.property('gdprApplies'); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(2); }); it('GDPR consent bidderRequest does not have gdprConsent', () => { @@ -172,11 +525,64 @@ describe('adagioAdapter', () => { expect(request.data.gdpr).to.exist; expect(request.data.gdpr).to.be.empty; }); + + it('should expose version in window', () => { + expect(window.top.ADAGIO).ok; + expect(window.top.ADAGIO.versions).ok; + expect(window.top.ADAGIO.versions.adagioBidderAdapter).to.eq(VERSION); + }); + + it('should returns an empty array if the bidder cannot access to window top (based on refererInfo.reachedTop)', () => { + const requests = spec.buildRequests(bidRequests, { + ...bidderRequest, + refererInfo: { reachedTop: false } + }); + expect(requests).to.be.empty; + }); + + it('Should add the schain if available at bidder level', () => { + const bidRequest = Object.assign({}, bidRequests[0], { + schain: { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'ssp.test', + sid: '00001', + hp: 1 + }] + } + }); + + const requests = spec.buildRequests([bidRequest], bidderRequest); + const request = requests[0]; + + expect(request.data.schain).to.exist; + expect(request.data.schain).to.deep.equal({ + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'ssp.test', + sid: '00001', + hp: 1 + }] + }); + }); + + it('Schain should not be added to the request', () => { + const requests = spec.buildRequests([bidRequests[0]], bidderRequest); + const request = requests[0]; + expect(request.data.schain).to.not.exist; + }); }); describe('interpretResponse', () => { + const sandbox = sinon.createSandbox(); + let serverResponse = { body: { + data: { + pred: 1 + }, bids: [ { ad: '
', @@ -193,27 +599,66 @@ describe('adagioAdapter', () => { } }; + let emptyBodyServerResponse = { + body: null + }; + + let withoutBidsArrayServerResponse = { + body: { + bids: [] + } + }; + + let serverResponseWhichThrowsException = { + body: { + data: { + pred: 1 + }, + bids: { + foo: 'bar' + } + } + }; + let bidRequest = { 'data': { 'adUnits': [ { 'bidder': 'adagio', 'params': { - siteId: '666', - placementId: 4, - pagetypeId: '232', - categories: ['IAB12'] + organizationId: '456', + site: 'ADAGIO-456', + placement: 'PAVE_ATF-456', + adUnitElementId: 'banner-atf-456', + pagetype: 'ARTICLE', + category: 'NEWS', + subcategory: 'SPORT', + environment: 'SITE-MOBILE' }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], 'bidId': 'c180kg4267tyqz', 'bidderRequestId': '8vfscuixrovn8i', 'auctionId': 'lel4fhp239i9km', + 'pageviewId': 'd8c4fl2k39i0wn', } ] } }; + afterEach(function() { + sandbox.restore(); + }); + + it('Should returns empty response if body is empty', () => { + expect(spec.interpretResponse(emptyBodyServerResponse, bidRequest)).to.be.an('array').length(0); + expect(spec.interpretResponse({body: {}}, bidRequest)).to.be.an('array').length(0); + }); + + it('Should returns empty response if bids array is empty', () => { + expect(spec.interpretResponse({withoutBidsArrayServerResponse}, bidRequest)).to.be.an('array').length(0); + }); + it('should get correct bid response', () => { let expectedResponse = [{ ad: '
', @@ -225,13 +670,35 @@ describe('adagioAdapter', () => { requestId: 'c180kg4267tyqz', ttl: 360, width: 300, - categories: [], - pagetypeId: '232', - placementId: 4, + placement: 'PAVE_ATF-456', + site: 'ADAGIO-456', + pagetype: 'ARTICLE', + category: 'NEWS', + subcategory: 'SPORT', + environment: 'SITE-MOBILE' }]; expect(spec.interpretResponse(serverResponse, bidRequest)).to.be.an('array'); expect(spec.interpretResponse(serverResponse, bidRequest)).to.deep.equal(expectedResponse); }); + + it('Should populate ADAGIO queue with ssp-data', () => { + spec.interpretResponse(serverResponse, bidRequest); + expect(window.top.ADAGIO).ok; + expect(window.top.ADAGIO.queue).to.be.an('array'); + }); + + it('Should not populate ADAGIO queue with ssp-data if not in top window', () => { + utils.getWindowTop().ADAGIO.queue = []; + sandbox.stub(utils, 'getWindowTop').throws(); + spec.interpretResponse(serverResponse, bidRequest); + expect(window.top.ADAGIO).ok; + expect(window.top.ADAGIO.queue).to.be.an('array'); + expect(window.top.ADAGIO.queue).empty; + }); + + it('should return an empty response even if an exception is ', () => { + expect(spec.interpretResponse(serverResponseWhichThrowsException, bidRequest)).to.be.an('array').length(0); + }); }); describe('getUserSyncs', () => { @@ -270,4 +737,64 @@ describe('adagioAdapter', () => { expect(emptyResult).to.equal(false); }); }); + + describe('getAdagioScript', () => { + const VALID_HASH = 'Lddcw3AADdQDrPtbRJkKxvA+o1CtScGDIMNRpHB3NnlC/FYmy/9RKXelKrYj/sjuWusl5YcOpo+lbGSkk655i8EKuDiOvK6ae/imxSrmdziIp+S/TA6hTFJXcB8k1Q9OIp4CMCT52jjXgHwX6G0rp+uYoCR25B1jHaHnpH26A6I='; + const INVALID_HASH = 'invalid'; + const VALID_SCRIPT_CONTENT = 'var _ADAGIO=function(){};(_ADAGIO)();\n'; + const INVALID_SCRIPT_CONTENT = 'var _ADAGIO=function(){//corrupted};(_ADAGIO)();\n'; + const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript'; + + it('should verify valid hash with valid script', function () { + localStorage.setItem(ADAGIO_LOCALSTORAGE_KEY, '// hash: ' + VALID_HASH + '\n' + VALID_SCRIPT_CONTENT); + + utilsMock.expects('logInfo').withExactArgs('Start Adagio script').once(); + utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never(); + utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').never(); + + getAdagioScript(); + + expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.equals('// hash: ' + VALID_HASH + '\n' + VALID_SCRIPT_CONTENT); + utilsMock.verify(); + }); + + it('should verify valid hash with invalid script', function () { + localStorage.setItem(ADAGIO_LOCALSTORAGE_KEY, '// hash: ' + VALID_HASH + '\n' + INVALID_SCRIPT_CONTENT); + + utilsMock.expects('logInfo').withExactArgs('Start Adagio script').never(); + utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never(); + utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').once(); + + getAdagioScript(); + + expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null; + utilsMock.verify(); + }); + + it('should verify invalid hash with valid script', function () { + localStorage.setItem(ADAGIO_LOCALSTORAGE_KEY, '// hash: ' + INVALID_HASH + '\n' + VALID_SCRIPT_CONTENT); + + utilsMock.expects('logInfo').withExactArgs('Start Adagio script').never(); + utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never(); + utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').once(); + + getAdagioScript(); + + expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null; + utilsMock.verify(); + }); + + it('should verify missing hash', function () { + localStorage.setItem(ADAGIO_LOCALSTORAGE_KEY, VALID_SCRIPT_CONTENT); + + utilsMock.expects('logInfo').withExactArgs('Start Adagio script').never(); + utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').once(); + utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').never(); + + getAdagioScript(); + + expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null; + utilsMock.verify(); + }); + }); }); diff --git a/test/spec/modules/adbutlerBidAdapter_spec.js b/test/spec/modules/adbutlerBidAdapter_spec.js index cf6b52f70e5..a9b56ade79e 100644 --- a/test/spec/modules/adbutlerBidAdapter_spec.js +++ b/test/spec/modules/adbutlerBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/adbutlerBidAdapter'; +import {spec} from 'modules/adbutlerBidAdapter.js'; describe('AdButler adapter', function () { let bidRequests; @@ -16,7 +16,11 @@ describe('AdButler adapter', function () { maxCPM: '5.00' }, placementCode: '/19968336/header-bid-tag-1', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, bidId: '23acc48ad47af5', auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', bidderRequestId: '1c56ad30b9b8ca8', @@ -79,7 +83,7 @@ describe('AdButler adapter', function () { let [domain] = request.url.split('/adserve/'); - expect(domain).to.equal('http://servedbyadbutler.com'); + expect(domain).to.equal('https://servedbyadbutler.com'); }); it('should set the keyword parameter', function () { @@ -97,7 +101,6 @@ describe('AdButler adapter', function () { params: { accountID: '107878', zoneID: '86133', - domain: 'servedbyadbutler.com.dan.test' } }, { sizes: [[300, 250]], @@ -105,7 +108,6 @@ describe('AdButler adapter', function () { params: { accountID: '107878', zoneID: '86133', - domain: 'servedbyadbutler.com.dan.test' } }, ], @@ -151,11 +153,13 @@ describe('AdButler adapter', function () { it('should return empty bid response', function () { let serverResponse = { - status: 'NO_ELIGIBLE_ADS', - zone_id: 210083, - width: 300, - height: 250, - place: 0 + body: { + status: 'NO_ELIGIBLE_ADS', + zone_id: 210083, + width: 300, + height: 250, + place: 0 + } }, bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); @@ -164,13 +168,15 @@ describe('AdButler adapter', function () { it('should return empty bid response on incorrect size', function () { let serverResponse = { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210083, - cpm: 1.5, - width: 728, - height: 90, - place: 0 + body: { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210083, + cpm: 1.5, + width: 728, + height: 90, + place: 0 + } }, bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); @@ -179,13 +185,15 @@ describe('AdButler adapter', function () { it('should return empty bid response with CPM too low', function () { let serverResponse = { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210093, - cpm: 0.75, - width: 300, - height: 250, - place: 0 + body: { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 0.75, + width: 300, + height: 250, + place: 0 + } }, bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); @@ -194,13 +202,15 @@ describe('AdButler adapter', function () { it('should return empty bid response with CPM too high', function () { let serverResponse = { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210093, - cpm: 7.00, - width: 300, - height: 250, - place: 0 + body: { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 7, + width: 300, + height: 250, + place: 0 + } }, bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); diff --git a/test/spec/modules/huddledmassesBidAdapter_spec.js b/test/spec/modules/adfinityBidAdapter_spec.js similarity index 74% rename from test/spec/modules/huddledmassesBidAdapter_spec.js rename to test/spec/modules/adfinityBidAdapter_spec.js index 7823ae53c12..479a2303dd5 100644 --- a/test/spec/modules/huddledmassesBidAdapter_spec.js +++ b/test/spec/modules/adfinityBidAdapter_spec.js @@ -1,36 +1,63 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/huddledmassesBidAdapter'; +import {spec} from '../../../modules/adfinityBidAdapter.js'; -describe('HuddledmassesAdapter', function () { +describe('AdfinityAdapter', function () { let bid = { bidId: '2dd581a2b6281d', - bidder: 'huddledmasses', + bidder: 'adfinity', bidderRequestId: '145e1d6a7837c9', params: { placement_id: 0 }, placementCode: 'placementid_0', auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'example.com', + sid: '0', + hp: 1, + rid: 'bidrequestid', + domain: 'example.com' + } + ] + } }; + let bidderRequest = { + bidderCode: 'adfinity', + auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff', + bidderRequestId: 'ffffffffffffff', + start: 1472239426002, + auctionStart: 1472239426000, + timeout: 5000, + uspConsent: '1YN-', + refererInfo: { + referer: 'http://www.example.com', + reachedTop: true, + }, + bids: [bid] + } describe('isBidRequestValid', function () { - it('Should return true when placement_id can be cast to a number, and when at least one of the sizes passed is allowed', function () { + it('Should return true when placement_id can be cast to a number', function () { expect(spec.isBidRequestValid(bid)).to.be.true; }); it('Should return false when placement_id is not a number', function () { bid.params.placement_id = 'aaa'; expect(spec.isBidRequestValid(bid)).to.be.false; }); - it('Should return false when the sizes are not allowed', function () { - bid.sizes = [[1, 1]]; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); + let serverRequest = spec.buildRequests([bid], bidderRequest); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -41,8 +68,9 @@ describe('HuddledmassesAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//huddledmassessupply.com/?c=o&m=multi'); + expect(serverRequest.url).to.equal('https://stat.adfinity.pro/?c=o&m=multi'); }); + it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; expect(data).to.be.an('object'); @@ -56,9 +84,11 @@ describe('HuddledmassesAdapter', function () { let placements = data['placements']; for (let i = 0; i < placements.length; i++) { let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'sizes'); + expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes', 'schain'); + expect(placement.schain).to.be.an('object') expect(placement.placementId).to.be.a('number'); expect(placement.bidId).to.be.a('string'); + expect(placement.traffic).to.be.a('string'); expect(placement.sizes).to.be.an('array'); } }); @@ -72,6 +102,7 @@ describe('HuddledmassesAdapter', function () { let resObject = { body: [ { requestId: '123', + mediaType: 'banner', cpm: 0.3, width: 320, height: 50, @@ -88,7 +119,7 @@ describe('HuddledmassesAdapter', function () { for (let i = 0; i < serverResponses.length; i++) { let dataItem = serverResponses[i]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency'); + 'netRevenue', 'currency', 'mediaType'); expect(dataItem.requestId).to.be.a('string'); expect(dataItem.cpm).to.be.a('number'); expect(dataItem.width).to.be.a('number'); @@ -98,6 +129,7 @@ describe('HuddledmassesAdapter', function () { expect(dataItem.creativeId).to.be.a('string'); expect(dataItem.netRevenue).to.be.a('boolean'); expect(dataItem.currency).to.be.a('string'); + expect(dataItem.mediaType).to.be.a('string'); } it('Returns an empty array if invalid response is passed', function () { serverResponses = spec.interpretResponse('invalid_response'); @@ -113,7 +145,7 @@ describe('HuddledmassesAdapter', function () { expect(userSync[0].type).to.exist; expect(userSync[0].url).to.exist; expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//huddledmassessupply.com/?c=o&m=cookie'); + expect(userSync[0].url).to.be.equal('https://stat.adfinity.pro/?c=o&m=cookie'); }); }); }); diff --git a/test/spec/modules/adformBidAdapter_spec.js b/test/spec/modules/adformBidAdapter_spec.js index f50474ae500..9233ca1dd7a 100644 --- a/test/spec/modules/adformBidAdapter_spec.js +++ b/test/spec/modules/adformBidAdapter_spec.js @@ -1,8 +1,7 @@ import {assert, expect} from 'chai'; -import * as url from 'src/url'; -import {spec} from 'modules/adformBidAdapter'; -import { BANNER, VIDEO } from 'src/mediaTypes'; -import { config } from 'src/config'; +import {spec} from 'modules/adformBidAdapter.js'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; +import { config } from 'src/config.js'; describe('Adform adapter', function () { let serverResponse, bidRequest, bidResponses; @@ -38,7 +37,7 @@ describe('Adform adapter', function () { let parsedUrl = parseUrl(spec.buildRequests([bids[0]]).url); let query = parsedUrl.query; - assert.equal(parsedUrl.path, '//newDomain/adx'); + assert.equal(parsedUrl.path, 'https://newDomain/adx'); assert.equal(query.tid, 45); assert.equal(query.rp, 4); assert.equal(query.fd, 1); @@ -258,6 +257,14 @@ describe('Adform adapter', function () { }; }); + it('should set a renderer only for an outstream context', function () { + serverResponse.body = [serverResponse.body[3], serverResponse.body[2]]; + bidRequest.bids = [bidRequest.bids[6], bidRequest.bids[6]]; + let result = spec.interpretResponse(serverResponse, bidRequest); + assert.ok(result[0].renderer); + assert.equal(result[1].renderer, undefined); + }); + describe('verifySizes', function () { it('should respond with empty response when sizes doesn\'t match', function () { serverResponse.body[0].response = 'banner'; @@ -307,8 +314,9 @@ describe('Adform adapter', function () { beforeEach(function () { config.setConfig({ currency: {} }); - let sizes = [[250, 300], [300, 250], [300, 600]]; + let sizes = [[250, 300], [300, 250], [300, 600], [600, 300]]; let placementCode = ['div-01', 'div-02', 'div-03', 'div-04', 'div-05']; + let mediaTypes = [{video: {context: 'outstream'}, banner: {sizes: sizes[3]}}]; let params = [{ mid: 1, url: 'some// there' }, {adxDomain: null, mid: 2, someVar: 'someValue', pt: 'gross'}, { adxDomain: null, mid: 3, pdom: 'home' }, {mid: 5, pt: 'net'}, {mid: 6, pt: 'gross'}]; bids = [ { @@ -388,6 +396,7 @@ describe('Adform adapter', function () { params: params[4], placementCode: placementCode[2], sizes: [], + mediaTypes: mediaTypes[0], transactionId: '5f33781f-9552-7ev3' } ]; diff --git a/test/spec/modules/adformOpenRTBBidAdapter_spec.js b/test/spec/modules/adformOpenRTBBidAdapter_spec.js index 32795c24ef6..77dbc17cdb2 100644 --- a/test/spec/modules/adformOpenRTBBidAdapter_spec.js +++ b/test/spec/modules/adformOpenRTBBidAdapter_spec.js @@ -1,9 +1,8 @@ // jshint esversion: 6, es3: false, node: true import {assert, expect} from 'chai'; -import * as url from 'src/url'; -import {spec} from 'modules/adformOpenRTBBidAdapter'; -import { NATIVE } from 'src/mediaTypes'; -import { config } from 'src/config'; +import {spec} from 'modules/adformOpenRTBBidAdapter.js'; +import { NATIVE } from 'src/mediaTypes.js'; +import { config } from 'src/config.js'; describe('AdformOpenRTB adapter', function () { let serverResponse, bidRequest, bidResponses; @@ -39,7 +38,7 @@ describe('AdformOpenRTB adapter', function () { let request = spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }); assert.equal(request.method, 'POST'); - assert.equal(request.url, '//10.8.57.207/adx/openrtb'); + assert.equal(request.url, 'https://10.8.57.207/adx/openrtb'); assert.deepEqual(request.options, {contentType: 'application/json'}); assert.ok(request.data); }); diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js index 2b8834f1e1d..927e7910723 100644 --- a/test/spec/modules/adgenerationBidAdapter_spec.js +++ b/test/spec/modules/adgenerationBidAdapter_spec.js @@ -1,13 +1,13 @@ import {expect} from 'chai'; -import {spec} from 'modules/adgenerationBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import {NATIVE} from 'src/mediaTypes'; -import {config} from 'src/config'; +import {spec} from 'modules/adgenerationBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {NATIVE} from 'src/mediaTypes.js'; +import {config} from 'src/config.js'; import prebid from '../../../package.json'; describe('AdgenerationAdapter', function () { const adapter = newBidder(spec); - const ENDPOINT = ['http://api-test.scaleout.jp/adsv/v1', 'https://d.socdm.com/adsv/v1']; + const ENDPOINT = ['https://api-test.scaleout.jp/adsv/v1', 'https://d.socdm.com/adsv/v1']; describe('inherited functions', function () { it('exists and is a function', function () { @@ -88,13 +88,13 @@ describe('AdgenerationAdapter', function () { ]; const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const data = { - banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=http%3A%2F%2Fexample.com`, - bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=http%3A%2F%2Fexample.com`, - native: 'posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1¤cy=JPY&pbver=' + prebid.version + '&sdkname=prebidjs&adapterver=1.0.1&tp=http%3A%2F%2Fexample.com' + banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=https%3A%2F%2Fexample.com`, + bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=https%3A%2F%2Fexample.com`, + native: 'posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1¤cy=JPY&pbver=' + prebid.version + '&sdkname=prebidjs&adapterver=1.0.1&tp=https%3A%2F%2Fexample.com' }; it('sends bid request to ENDPOINT via GET', function () { const request = spec.buildRequests(bidRequests, bidderRequest)[0]; @@ -215,7 +215,7 @@ describe('AdgenerationAdapter', function () { dealid: 'fd5sa5fa7f', ttl: 1000, results: [ - {ad: '
'}, + {ad: '
'}, ] }, native: { diff --git a/test/spec/modules/adglareBidAdapter_spec.js b/test/spec/modules/adglareBidAdapter_spec.js new file mode 100644 index 00000000000..d0dbe891f9d --- /dev/null +++ b/test/spec/modules/adglareBidAdapter_spec.js @@ -0,0 +1,138 @@ +import {expect} from 'chai'; +import {spec} from 'modules/adglareBidAdapter.js'; + +describe('AdGlare Adapter Tests', function () { + let bidRequests; + + beforeEach(function () { + bidRequests = [ + { + bidder: 'adglare', + params: { + domain: 'try.engine.adglare.net', + zID: '475579334', + type: 'banner' + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: '23acc48ad47af5', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + } + ]; + }); + + describe('implementation', function () { + describe('for requests', function () { + it('should accept valid bid', function () { + let validBid = { + bidder: 'adglare', + params: { + domain: 'try.engine.adglare.net', + zID: '475579334', + type: 'banner' + } + }, + isValid = spec.isBidRequestValid(validBid); + + expect(isValid).to.equal(true); + }); + + it('should reject invalid bid', function () { + let invalidBid = { + bidder: 'adglare', + params: { + domain: 'somedomain.com', + zID: 'not an integer', + type: 'unsupported' + } + }, + isValid = spec.isBidRequestValid(invalidBid); + + expect(isValid).to.equal(false); + }); + + it('should build a valid endpoint URL', function () { + let bidRequests = [ + { + bidder: 'adglare', + params: { + domain: 'try.engine.adglare.net', + zID: '475579334', + type: 'banner' + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: '23acc48ad47af5', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + } + ], + bidderRequest = { + bidderCode: 'adglare', + auctionID: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + auctionStart: 1581497568252, + timeout: 5000, + refererInfo: { + referer: 'https://www.somedomain.com', + reachedTop: true, + numFrames: 0 + }, + start: 1581497568254 + }, + requests = spec.buildRequests(bidRequests, bidderRequest), + requestURL = requests[0].url; + + expect(requestURL).to.have.string('https://try.engine.adglare.net/?475579334'); + }); + }); + + describe('bid responses', function () { + it('should return complete bid response', function () { + let serverResponse = { + body: { + status: 'OK', + zID: 475579334, + cID: 501658124, + crID: 442123173, + cpm: 1.5, + ttl: 3600, + currency: 'USD', + width: 300, + height: 250, + adhtml: 'I am an ad.' + } + }, + bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + + expect(bids).to.be.lengthOf(1); + expect(bids[0].bidderCode).to.equal('adglare'); + expect(bids[0].cpm).to.equal(1.5); + expect(bids[0].width).to.equal(300); + expect(bids[0].height).to.equal(250); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].netRevenue).to.equal(true); + }); + + it('should return empty bid response', function () { + let serverResponse = { + body: { + status: 'NOADS' + } + }, + bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + + expect(bids).to.be.lengthOf(0); + }); + }); + }); +}); diff --git a/test/spec/modules/adheseBidAdapter_spec.js b/test/spec/modules/adheseBidAdapter_spec.js index 348fb772319..81f2a66425f 100644 --- a/test/spec/modules/adheseBidAdapter_spec.js +++ b/test/spec/modules/adheseBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/adheseBidAdapter'; +import {spec} from 'modules/adheseBidAdapter.js'; const BID_ID = 456; const TTL = 360; @@ -153,6 +153,16 @@ describe('AdheseAdapter', function () { mediaType: 'banner', netRevenue: NET_REVENUE, ttl: TTL, + adhese: { + originData: { + seatbid: [ + { + bid: [ { crid: '60613369', dealid: null } ], + seat: '958' + } + ] + } + } }]; expect(spec.interpretResponse(sspBannerResponse, bidRequest)).to.deep.equal(expectedResponse); }); @@ -185,6 +195,7 @@ describe('AdheseAdapter', function () { mediaType: 'video', netRevenue: NET_REVENUE, ttl: TTL, + adhese: { originData: {} } }]; expect(spec.interpretResponse(sspVideoResponse, bidRequest)).to.deep.equal(expectedResponse); }); @@ -235,6 +246,17 @@ describe('AdheseAdapter', function () { let expectedResponse = [{ requestId: BID_ID, ad: '', + adhese: { + originData: { + adFormat: 'largeleaderboard', + adType: 'largeleaderboard', + adspaceId: '162363', + libId: '90511', + orderProperty: undefined, + priority: undefined, + viewableImpressionCounter: undefined + } + }, cpm: 5.96, currency: 'USD', creativeId: '742898', @@ -279,6 +301,17 @@ describe('AdheseAdapter', function () { let expectedResponse = [{ requestId: BID_ID, vastXml: '', + adhese: { + originData: { + adFormat: '', + adType: 'preroll', + adspaceId: '164196', + libId: '89860', + orderProperty: undefined, + priority: undefined, + viewableImpressionCounter: undefined + } + }, cpm: 0, currency: 'USD', creativeId: '742470', diff --git a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js b/test/spec/modules/adkernelAdnAnalytics_spec.js similarity index 98% rename from test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js rename to test/spec/modules/adkernelAdnAnalytics_spec.js index 26fd13afd1f..e7ef831080c 100644 --- a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js +++ b/test/spec/modules/adkernelAdnAnalytics_spec.js @@ -1,6 +1,6 @@ -import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/adkernelAdnAnalyticsAdapter'; +import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/adkernelAdnAnalyticsAdapter.js'; import {expect} from 'chai'; -import adapterManager from 'src/adapterManager'; +import adapterManager from 'src/adapterManager.js'; import CONSTANTS from 'src/constants.json'; const events = require('../../../src/events'); diff --git a/test/spec/modules/adkernelAdnBidAdapter_spec.js b/test/spec/modules/adkernelAdnBidAdapter_spec.js index 1147520131b..3d3e64aeec9 100644 --- a/test/spec/modules/adkernelAdnBidAdapter_spec.js +++ b/test/spec/modules/adkernelAdnBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/adkernelAdnBidAdapter'; +import {spec} from 'modules/adkernelAdnBidAdapter.js'; describe('AdkernelAdn adapter', function () { const bid1_pub1 = { @@ -74,7 +74,6 @@ describe('AdkernelAdn adapter', function () { bidderRequestId: 'req1', auctionId: '5c66da22-426a-4bac-b153-77360bef5337', bidId: 'bidid_5', - sizes: [[1920, 1080]], mediaTypes: { video: { playerSize: [1920, 1080], @@ -91,7 +90,6 @@ describe('AdkernelAdn adapter', function () { bidderRequestId: 'req-001', auctionId: 'auc-001', bidId: 'Bid_01', - sizes: [[300, 250], [300, 200]], mediaTypes: { banner: {sizes: [[300, 250], [300, 200]]}, video: {context: 'instream', playerSize: [[640, 480]]} @@ -122,7 +120,7 @@ describe('AdkernelAdn adapter', function () { impid: '57d602ad1c9545', crid: '108_158802', bid: 10.0, - vast_url: 'http://vast.com/vast.xml' + vast_url: 'https://vast.com/vast.xml' }], syncpages: ['https://dsp.adkernel.com/sync'] }, usersyncOnlyResponse = { @@ -245,17 +243,18 @@ describe('AdkernelAdn adapter', function () { expect(tagRequest).to.not.have.property('user'); }); - it('shouldn\'t contain gdpr-related information for default request', function () { + it('shouldn\'t contain gdpr nor ccpa information for default request', function () { let [_, tagRequests] = buildRequest([bid1_pub1]); expect(tagRequests[0]).to.not.have.property('user'); }); - it('should contain gdpr-related information if consent is configured', function () { + it('should contain gdpr and ccpa information if consent is configured', function () { let [_, bidRequests] = buildRequest([bid1_pub1], - {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}}); + {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}, uspConsent: '1YNN'}); expect(bidRequests[0]).to.have.property('user'); expect(bidRequests[0].user).to.have.property('gdpr', 1); expect(bidRequests[0].user).to.have.property('consent', 'test-consent-string'); + expect(bidRequests[0].user).to.have.property('us_privacy', '1YNN'); }); it('should\'t contain consent string if gdpr isn\'t applied', function () { @@ -325,8 +324,8 @@ describe('AdkernelAdn adapter', function () { it('should issue a request for each host', function () { let [pbRequests, tagRequests] = buildRequest([bid1_pub1, bid1_pub2]); expect(pbRequests).to.have.length(2); - expect(pbRequests[0].url).to.have.string('//tag.adkernel.com/tag'); - expect(pbRequests[1].url).to.have.string(`//${bid1_pub2.params.host}/tag`); + expect(pbRequests[0].url).to.have.string('https://tag.adkernel.com/tag'); + expect(pbRequests[1].url).to.have.string(`https://${bid1_pub2.params.host}/tag`); expect(tagRequests[0].imp).to.have.length(1); expect(tagRequests[1].imp).to.have.length(1); }); @@ -367,7 +366,7 @@ describe('AdkernelAdn adapter', function () { expect(resp).to.have.property('currency'); expect(resp).to.have.property('ttl'); expect(resp).to.have.property('mediaType', 'video'); - expect(resp).to.have.property('vastUrl', 'http://vast.com/vast.xml'); + expect(resp).to.have.property('vastUrl', 'https://vast.com/vast.xml'); expect(resp).to.not.have.property('ad'); }); diff --git a/test/spec/modules/adkernelBidAdapter_spec.js b/test/spec/modules/adkernelBidAdapter_spec.js index 621b9971304..ef95febf13d 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -1,6 +1,7 @@ import {expect} from 'chai'; -import {spec} from 'modules/adkernelBidAdapter'; -import * as utils from 'src/utils'; +import {spec} from 'modules/adkernelBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {NATIVE, BANNER, VIDEO} from 'src/mediaTypes'; describe('Adkernel adapter', function () { const bid1_zone1 = { @@ -81,7 +82,6 @@ describe('Adkernel adapter', function () { bidId: 'Bid_Video', bidderRequestId: '18b2a61ea5d9a7', auctionId: 'de45acf1-9109-4e52-8013-f2b7cf5f6766', - sizes: [[640, 480]], params: { zoneId: 1, host: 'rtb.adkernel.com', @@ -103,7 +103,57 @@ describe('Adkernel adapter', function () { }, adUnitCode: 'ad-unit-1', transactionId: 'f82c64b8-c602-42a4-9791-4a268f6559ed', - sizes: [[300, 250], [300, 200]], + bidId: 'Bid_01', + bidderRequestId: 'req-001', + auctionId: 'auc-001' + }, bid_native = { + bidder: 'adkernel', + params: {zoneId: 1, host: 'rtb.adkernel.com'}, + mediaTypes: { + native: { + title: { + required: true, + len: 80 + }, + body: { + required: true + }, + body2: { + required: true + }, + icon: { + required: true, + aspect_ratios: [{min_width: 50, min_height: 50}] + }, + image: { + required: true, + sizes: [300, 200] + }, + clickUrl: { + required: true + }, + rating: { + required: false + }, + price: { + required: false + }, + privacyLink: { + required: false + }, + cta: { + required: false + }, + sponsoredBy: { + required: false + }, + displayUrl: { + required: false + } + } + }, + adUnitCode: 'ad-unit-1', + transactionId: 'f82c64b8-c602-42a4-9791-4a268f6559ed', bidId: 'Bid_01', bidderRequestId: 'req-001', auctionId: 'auc-001' @@ -125,22 +175,8 @@ describe('Adkernel adapter', function () { }], cur: 'USD', ext: { - adk_usersync: ['http://adk.sync.com/sync'] + adk_usersync: ['https://adk.sync.com/sync'] } - }, bidResponse2 = { - id: 'bid2', - seatbid: [{ - bid: [{ - id: '2', - impid: 'Bid_02', - crid: '100_002', - price: 1.31, - adm: '', - w: 300, - h: 250 - }] - }], - cur: 'USD' }, videoBidResponse = { id: '47ce4badcf7482', seatbid: [{ @@ -158,14 +194,45 @@ describe('Adkernel adapter', function () { }, usersyncOnlyResponse = { id: 'nobid1', ext: { - adk_usersync: ['http://adk.sync.com/sync'] + adk_usersync: ['https://adk.sync.com/sync'] } + }, nativeResponse = { + id: '56fbc713-b737-4651-9050-13376aed9818', + seatbid: [{ + bid: [{ + id: 'someid_01', + impid: 'Bid_01', + price: 2.25, + adid: '4', + adm: JSON.stringify({ + native: { + assets: [ + {id: 0, title: {text: 'Title'}}, + {id: 3, data: {value: 'Description'}}, + {id: 4, data: {value: 'Additional description'}}, + {id: 1, img: {url: 'http://rtb.com/thumbnail?i=pTuOlf5KHUo_0&imgt=icon', w: 50, h: 50}}, + {id: 2, img: {url: 'http://rtb.com/thumbnail?i=pTuOlf5KHUo_0', w: 300, h: 200}}, + {id: 5, data: {value: 'Sponsor.com'}}, + {id: 14, data: {value: 'displayurl.com'}} + ], + link: {url: 'http://rtb.com/click?i=pTuOlf5KHUo_0'}, + imptrackers: ['http://rtb.com/win?i=pTuOlf5KHUo_0&f=imp'] + } + }), + adomain: ['displayurl.com'], + cid: '1', + crid: '4' + }] + }], + bidid: 'pTuOlf5KHUo', + cur: 'USD' }; function buildBidderRequest(url = 'https://example.com/index.html', params = {}) { - return Object.assign({}, params, {refererInfo: {referer: url, reachedTop: true}}) + return Object.assign({}, params, {refererInfo: {referer: url, reachedTop: true}, timeout: 3000}); } const DEFAULT_BIDDER_REQUEST = buildBidderRequest(); + function buildRequest(bidRequests, bidderRequest = DEFAULT_BIDDER_REQUEST, dnt = true) { let dntmock = sinon.stub(utils, 'getDNT').callsFake(() => dnt); let pbRequests = spec.buildRequests(bidRequests, bidderRequest); @@ -192,6 +259,10 @@ describe('Adkernel adapter', function () { it('empty request shouldn\'t generate exception', function () { expect(spec.isBidRequestValid(bid_with_wrong_zoneId)).to.be.equal(false); }); + + it('valid native requests should pass', () => { + expect(spec.isBidRequestValid(bid_native)).to.be.equal(true); + }) }); describe('banner request building', function () { @@ -239,7 +310,7 @@ describe('Adkernel adapter', function () { expect(bidRequest.device).to.have.property('dnt', 1); }); - it('shouldn\'t contain gdpr-related information for default request', function () { + it('shouldn\'t contain gdpr nor ccpa information for default request', function () { let [_, bidRequests] = buildRequest([bid1_zone1]); expect(bidRequests[0]).to.not.have.property('regs'); expect(bidRequests[0]).to.not.have.property('user'); @@ -247,11 +318,11 @@ describe('Adkernel adapter', function () { it('should contain gdpr-related information if consent is configured', function () { let [_, bidRequests] = buildRequest([bid1_zone1], - buildBidderRequest('http://example.com/index.html', - {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string', vendorData: {}}})); + buildBidderRequest('https://example.com/index.html', + {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string', vendorData: {}}, uspConsent: '1YNN'})); let bidRequest = bidRequests[0]; expect(bidRequest).to.have.property('regs'); - expect(bidRequest.regs.ext).to.be.eql({'gdpr': 1}); + expect(bidRequest.regs.ext).to.be.eql({'gdpr': 1, 'us_privacy': '1YNN'}); expect(bidRequest).to.have.property('user'); expect(bidRequest.user.ext).to.be.eql({'consent': 'test-consent-string'}); }); @@ -268,6 +339,11 @@ describe('Adkernel adapter', function () { let [_, bidRequests] = buildRequest([bid1_zone1], DEFAULT_BIDDER_REQUEST, false); expect(bidRequests[0].device).to.not.have.property('dnt'); }); + + it('should forward default bidder timeout', function() { + let [_, bidRequests] = buildRequest([bid1_zone1], DEFAULT_BIDDER_REQUEST); + expect(bidRequests[0]).to.have.property('tmax', 3000); + }); }); describe('video request building', function () { @@ -315,8 +391,8 @@ describe('Adkernel adapter', function () { it('should issue a request for each host', function () { let [pbRequests, _] = buildRequest([bid1_zone1, bid3_host2]); expect(pbRequests).to.have.length(2); - expect(pbRequests[0].url).to.have.string(`//${bid1_zone1.params.host}/`); - expect(pbRequests[1].url).to.have.string(`//${bid3_host2.params.host}/`); + expect(pbRequests[0].url).to.have.string(`https://${bid1_zone1.params.host}/`); + expect(pbRequests[1].url).to.have.string(`https://${bid3_host2.params.host}/`); }); it('should issue a request for each zone', function () { @@ -338,7 +414,7 @@ describe('Adkernel adapter', function () { expect(resp).to.have.property('creativeId', '100_001'); expect(resp).to.have.property('currency'); expect(resp).to.have.property('ttl'); - expect(resp).to.have.property('mediaType', 'banner'); + expect(resp).to.have.property('mediaType', BANNER); expect(resp).to.have.property('ad'); expect(resp.ad).to.have.string(''); }); @@ -347,7 +423,7 @@ describe('Adkernel adapter', function () { let [pbRequests, _] = buildRequest([bid_video]); let resp = spec.interpretResponse({body: videoBidResponse}, pbRequests[0])[0]; expect(resp).to.have.property('requestId', 'Bid_Video'); - expect(resp.mediaType).to.equal('video'); + expect(resp.mediaType).to.equal(VIDEO); expect(resp.cpm).to.equal(0.00145); expect(resp.vastUrl).to.equal('https://rtb.com/win?i=sZSYq5zYMxo_0&f=nurl'); expect(resp.width).to.equal(640); @@ -373,14 +449,59 @@ describe('Adkernel adapter', function () { syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: bidResponse1}]); expect(syncs).to.have.length(1); expect(syncs[0]).to.have.property('type', 'iframe'); - expect(syncs[0]).to.have.property('url', 'http://adk.sync.com/sync'); + expect(syncs[0]).to.have.property('url', 'https://adk.sync.com/sync'); }); }); describe('adapter configuration', () => { it('should have aliases', () => { - expect(spec.aliases).to.have.lengthOf(3); - expect(spec.aliases).to.be.eql(['headbidding', 'adsolut', 'oftmediahb']); + expect(spec.aliases).to.have.lengthOf(6); + expect(spec.aliases).to.include.members(['headbidding', 'adsolut', 'oftmediahb', 'audiencemedia', 'waardex_ak', 'roqoon']); + }); + }); + + describe('native support', () => { + let _, bidRequests; + before(function () { + [_, bidRequests] = buildRequest([bid_native]); + }); + + it('native request building', () => { + expect(bidRequests[0].imp).to.have.length(1); + expect(bidRequests[0].imp[0]).to.have.property('native'); + expect(bidRequests[0].imp[0].native).to.have.property('request'); + let request = JSON.parse(bidRequests[0].imp[0].native.request); + expect(request).to.have.property('ver', '1.1'); + expect(request.assets).to.have.length(10); + expect(request.assets[0]).to.be.eql({id: 0, required: 1, title: {len: 80}}); + expect(request.assets[1]).to.be.eql({id: 3, required: 1, data: {type: 2}}); + expect(request.assets[2]).to.be.eql({id: 4, required: 1, data: {type: 10}}); + expect(request.assets[3]).to.be.eql({id: 1, required: 1, img: {wmin: 50, hmin: 50, type: 1}}); + expect(request.assets[4]).to.be.eql({id: 2, required: 1, img: {w: 300, h: 200, type: 3}}); + expect(request.assets[5]).to.be.eql({id: 11, required: 0, data: {type: 3}}); + expect(request.assets[6]).to.be.eql({id: 8, required: 0, data: {type: 6}}); + expect(request.assets[7]).to.be.eql({id: 10, required: 0, data: {type: 12}}); + expect(request.assets[8]).to.be.eql({id: 5, required: 0, data: {type: 1}}); + expect(request.assets[9]).to.be.eql({id: 14, required: 0, data: {type: 11}}); + }); + + it('native response processing', () => { + let [pbRequests, _] = buildRequest([bid_native]); + let resp = spec.interpretResponse({body: nativeResponse}, pbRequests[0])[0]; + expect(resp).to.have.property('requestId', 'Bid_01'); + expect(resp).to.have.property('cpm', 2.25); + expect(resp).to.have.property('currency', 'USD'); + expect(resp).to.have.property('mediaType', NATIVE); + expect(resp).to.have.property('native'); + expect(resp.native).to.have.property('clickUrl', 'http://rtb.com/click?i=pTuOlf5KHUo_0'); + expect(resp.native.impressionTrackers).to.be.eql(['http://rtb.com/win?i=pTuOlf5KHUo_0&f=imp']); + expect(resp.native).to.have.property('title', 'Title'); + expect(resp.native).to.have.property('body', 'Description'); + expect(resp.native).to.have.property('body2', 'Additional description'); + expect(resp.native.icon).to.be.eql({url: 'http://rtb.com/thumbnail?i=pTuOlf5KHUo_0&imgt=icon', width: 50, height: 50}); + expect(resp.native.image).to.be.eql({url: 'http://rtb.com/thumbnail?i=pTuOlf5KHUo_0', width: 300, height: 200}); + expect(resp.native).to.have.property('sponsoredBy', 'Sponsor.com'); + expect(resp.native).to.have.property('displayUrl', 'displayurl.com'); }); }); }); diff --git a/test/spec/modules/adliveBidAdapter_spec.js b/test/spec/modules/adliveBidAdapter_spec.js index 0048fc028b8..ddf8f82f20f 100644 --- a/test/spec/modules/adliveBidAdapter_spec.js +++ b/test/spec/modules/adliveBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/adliveBidAdapter'; +import { spec } from 'modules/adliveBidAdapter.js'; describe('adliveBidAdapterTests', function() { let bidRequestData = { diff --git a/test/spec/modules/admanBidAdapter_spec.js b/test/spec/modules/admanBidAdapter_spec.js index 37a097427d5..f3212dec2f5 100644 --- a/test/spec/modules/admanBidAdapter_spec.js +++ b/test/spec/modules/admanBidAdapter_spec.js @@ -1,215 +1,231 @@ import {expect} from 'chai'; -import {spec} from 'modules/admanBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const ENDPOINT = '//bidtor.admanmedia.com/prebid'; -const BANNER = '"'; -const VAST = ''; -const USER_SYNC_IFRAME_URL = '//cs.admanmedia.com/sync_tag/html'; - -describe('admanBidAdapter', function() { - const adapter = newBidder(spec); - - describe('inherited functions', function() { - it('exists and is a function', function() { - expect(adapter.callBids).to.exist.and.to.be.a('function'); +import {spec} from '../../../modules/admanBidAdapter.js'; + +describe('AdmanMediaBidAdapter', function () { + let bid = { + bidId: '23fhj33i987f', + bidder: 'adman', + params: { + placementId: 0, + traffic: 'banner' + } + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and placementId parameters present', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + delete bid.params.placementId; + expect(spec.isBidRequestValid(bid)).to.be.false; }); }); - describe('isBidRequestValid', function() { - let bid = { - 'bidder': 'adman', - 'params': { - 'id': '1234asdf' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'creativeId': 'er2ee' - }; - - it('should return true when required params found', function() { - expect(spec.isBidRequestValid(bid)).to.equal(true); + describe('buildRequests', function () { + let serverRequest = spec.buildRequests([bid]); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; }); - - it('should return false when id is not valid (not string)', function() { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'id': 1234 - }; - - expect(spec.isBidRequestValid(bid)).to.equal(false); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); }); - - it('should return false when required params are not passed', function() { - let bid = Object.assign({}, bid); - delete bid.params; - - bid.params = {}; - - expect(spec.isBidRequestValid(bid)).to.equal(false); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://pub.admanmedia.com/?c=o&m=multi'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + let placement = data['placements'][0]; + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); + expect(placement.placementId).to.equal(0); + expect(placement.bidId).to.equal('23fhj33i987f'); + expect(placement.traffic).to.equal('banner'); + }); + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([]); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; }); }); - - describe('buildRequests', function() { - let bidRequests = [ - { - 'bidder': 'adman', - 'bidId': '51ef8751f9aead', - 'params': { - 'id': '1234asdf' - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[320, 50], [300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1 - } - ]; - - it('sends a valid bid request to ENDPOINT via POST', function() { - const request = spec.buildRequests(bidRequests, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - } - }); - - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('POST'); - - const payload = JSON.parse(request.data); - expect(payload.gdpr).to.exist; - - expect(payload.bids).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); - expect(payload.referer).to.exist; - - const bid = payload.bids[0]; - expect(bid).to.exist; - expect(bid.params).to.exist; - expect(bid.params.id).to.exist; - expect(bid.params.bidId).to.exist; - expect(bid.sizes).to.exist.and.to.be.an('array').and.to.have.lengthOf(3); - bid.sizes.forEach(size => { - expect(size).to.be.an('array').and.to.have.lengthOf(2); - expect(size[0]).to.be.a('number'); - expect(size[1]).to.be.a('number'); - }) + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.width).to.equal(300); + expect(dataItem.height).to.equal(250); + expect(dataItem.ad).to.equal('Test'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); }); - - it('should send GDPR to endpoint and honor gdprApplies value', function() { - let consentString = 'bogusConsent'; - let bidderRequest = { - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true - } + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - expect(payload.gdpr).to.exist; - expect(payload.gdpr.consent).to.equal(consentString); - expect(payload.gdpr.applies).to.equal(true); - - let bidderRequest2 = { - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': false - } + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] }; - - const request2 = spec.buildRequests(bidRequests, bidderRequest2); - const payload2 = JSON.parse(request2.data); - - expect(payload2.gdpr).to.exist; - expect(payload2.gdpr.consent).to.equal(consentString); - expect(payload2.gdpr.applies).to.equal(false); + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); }); - }); - - describe('interpretResponse', function() { - let bids = { - 'body': { - 'bids': [{ - 'ad': BANNER, - 'height': 250, - 'cpm': 0.5, - 'currency': 'USD', - 'netRevenue': true, - 'requestId': '3ede2a3fa0db94', - 'ttl': 3599, - 'width': 300, - 'creativeId': 'er2ee' - }, - { - 'vastXml': VAST, - 'cpm': 0.5, - 'currency': 'USD', - 'height': 250, - 'netRevenue': true, - 'requestId': '3ede2a3fa0db95', - 'ttl': 3599, - 'width': 300, - 'creativeId': 'er2ef' + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' }] - } - }; - - it('should get correct bid response', function() { - let expectedResponse = [{ - 'ad': BANNER, - 'cpm': 0.5, - 'creativeId': 'er2ee', - 'currency': 'USD', - 'height': 250, - 'netRevenue': true, - 'requestId': '3ede2a3fa0db94', - 'ttl': 3599, - 'width': 300, - }, - { - 'vastXml': VAST, - 'cpm': 0.5, - 'creativeId': 'er2ef', - 'currency': 'USD', - 'height': 250, - 'netRevenue': true, - 'requestId': '3ede2a3fa0db95', - 'ttl': 3599, - 'width': 300, - }]; - // los bids vienen formateados de server - let result = spec.interpretResponse(bids); + }; - expect(result[0]).to.deep.equal(expectedResponse[0]); - expect(result[1]).to.deep.equal(expectedResponse[1]); - // expect(Object.keys(result[1])).to.deep.equal(Object.keys(bids[1])); + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; }); - - it('handles nobid responses', function() { - let bids = { - 'body': { - 'bids': [] - } + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] }; - - let result = spec.interpretResponse(bids); - expect(result.length).to.equal(0); + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; }); }); - describe('getUserSyncs', () => { - it('should get correct user sync iframe url', function() { - expect(spec.getUserSyncs({ - iframeEnabled: true - }, [{}])).to.deep.equal([{ - type: 'iframe', - url: USER_SYNC_IFRAME_URL - }]); + describe('getUserSyncs', function () { + let userSync = spec.getUserSyncs(); + it('Returns valid URL and type', function () { + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.exist; + expect(userSync[0].url).to.exist; + expect(userSync[0].type).to.be.equal('image'); + expect(userSync[0].url).to.be.equal('https://pub.admanmedia.com/?c=o&m=sync'); }); }); }); diff --git a/test/spec/modules/admediaBidAdapter_spec.js b/test/spec/modules/admediaBidAdapter_spec.js index 2e14eee938c..5dc7b9a02a8 100644 --- a/test/spec/modules/admediaBidAdapter_spec.js +++ b/test/spec/modules/admediaBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/admediaBidAdapter'; +import { spec } from 'modules/admediaBidAdapter.js'; describe('admediaAdapterTests', function () { describe('bidRequestValidity', function () { @@ -56,7 +56,7 @@ describe('admediaAdapterTests', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://test.com/index.html?pbjs_debug=true' + 'referer': 'https://test.com/index.html?pbjs_debug=true' } }; @@ -68,7 +68,7 @@ describe('admediaAdapterTests', function () { }); it('bidRequest url', function () { - expect(request.url).to.equal('//prebid.admedia.com/bidder/'); + expect(request.url).to.equal('https://prebid.admedia.com/bidder/'); }); it('bidRequest data', function () { diff --git a/test/spec/modules/admixerBidAdapter_spec.js b/test/spec/modules/admixerBidAdapter_spec.js index 54d0dbee6e4..6d2e3059dc8 100644 --- a/test/spec/modules/admixerBidAdapter_spec.js +++ b/test/spec/modules/admixerBidAdapter_spec.js @@ -1,9 +1,9 @@ import {expect} from 'chai'; -import {spec} from 'modules/admixerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/admixerBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; const BIDDER_CODE = 'admixer'; -const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; +const ENDPOINT_URL = 'https://inv-nets.admixer.net/prebid.1.0.aspx'; const ZONE_ID = '2eb6bd58-865c-47ce-af7f-a918108c3fd2'; describe('AdmixerAdapter', function () { @@ -43,7 +43,7 @@ describe('AdmixerAdapter', function () { }); describe('buildRequests', function () { - let bidRequests = [ + let validRequest = [ { 'bidder': BIDDER_CODE, 'params': { @@ -56,16 +56,21 @@ describe('AdmixerAdapter', function () { 'auctionId': '1d1a030790a475', } ]; + let bidderRequest = { + refererInfo: { + referer: 'https://example.com' + } + }; it('should add referrer and imp to be equal bidRequest', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(validRequest, bidderRequest); const payload = JSON.parse(request.data.substr(5)); expect(payload.referrer).to.not.be.undefined; - expect(payload.imps[0]).to.deep.equal(bidRequests[0]); + expect(payload.imps[0]).to.deep.equal(validRequest[0]); }); it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(validRequest, bidderRequest); expect(request.url).to.equal(ENDPOINT_URL); expect(request.method).to.equal('GET'); }); diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js new file mode 100644 index 00000000000..54ff038c083 --- /dev/null +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -0,0 +1,119 @@ +// import or require modules necessary for the test, e.g.: +import { expect } from 'chai'; // may prefer 'assert' in place of 'expect' +import { spec } from 'modules/adnuntiusBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +describe('adnuntiusBidAdapter', function () { + const ENDPOINT_URL = 'https://delivery.adnuntius.com/i?tzo=-60&format=json'; + const adapter = newBidder(spec); + const bidRequests = [ + { + bidder: 'adnuntius', + params: { + auId: '8b6bc', + network: 'adnuntius', + }, + bidId: '123' + } + ]; + + const serverResponse = { + body: { + 'adUnits': [ + { + 'auId': '000000000008b6bc', + 'targetId': '', + 'html': '

hi!

', + 'matchedAdCount': 1, + 'responseId': 'adn-rsp-1460129238', + 'ads': [ + { + 'destinationUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fc%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN%3Fct%3D2501%26r%3Dhttp%253A%252F%252Fgoogle.com', + 'assets': { + 'image': { + 'cdnId': 'https://assets.adnuntius.com/oEmZa5uYjxENfA1R692FVn6qIveFpO8wUbpyF2xSOCc.jpg', + 'width': '980', + 'height': '120' + } + }, + 'clickUrl': 'https://delivery.adnuntius.com/c/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'urls': { + 'destination': 'https://delivery.adnuntius.com/c/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN?ct=2501&r=http%3A%2F%2Fgoogle.com' + }, + 'urlsEsc': { + 'destination': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fc%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN%3Fct%3D2501%26r%3Dhttp%253A%252F%252Fgoogle.com' + }, + 'destinationUrls': { + 'destination': 'http://google.com' + }, + 'cpm': { 'amount': 5.0, 'currency': 'NOK' }, + 'bid': { 'amount': 0.005, 'currency': 'NOK' }, + 'cost': { 'amount': 0.005, 'currency': 'NOK' }, + 'impressionTrackingUrls': [], + 'impressionTrackingUrlsEsc': [], + 'adId': 'adn-id-1347343135', + 'selectedColumn': '0', + 'selectedColumnPosition': '0', + 'renderedPixel': 'https://delivery.adnuntius.com/b/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN.html', + 'renderedPixelEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fb%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN.html', + 'visibleUrl': 'https://delivery.adnuntius.com/s?rt=52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'visibleUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fs%3Frt%3D52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'viewUrl': 'https://delivery.adnuntius.com/v?rt=52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'viewUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fv%3Frt%3D52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'rt': '52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'creativeWidth': '980', + 'creativeHeight': '120', + 'creativeId': 'wgkq587vgtpchsx1', + 'lineItemId': 'scyjdyv3mzgdsnpf', + 'layoutId': 'sw6gtws2rdj1kwby', + 'layoutName': 'Responsive image' + } + ] + } + ] + } + } + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bidRequests[0])).to.equal(true); + }); + }); + + describe('buildRequests', function () { + it('Test requests', function () { + const request = spec.buildRequests(bidRequests); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('bid'); + const bid = request[0].bid[0] + expect(bid).to.have.property('bidId'); + expect(request[0]).to.have.property('url'); + expect(request[0].url).to.equal(ENDPOINT_URL); + expect(request[0]).to.have.property('data'); + expect(request[0].data).to.equal('{\"adUnits\":[{\"auId\":\"8b6bc\"}]}'); + }); + }); + + describe('interpretResponse', function () { + it('should return valid response when passed valid server response', function () { + const request = spec.buildRequests(bidRequests); + const interpretedResponse = spec.interpretResponse(serverResponse, request[0]); + const ad = serverResponse.body.adUnits[0].ads[0] + expect(interpretedResponse).to.have.lengthOf(1); + expect(interpretedResponse[0].cpm).to.equal(ad.cpm.amount); + expect(interpretedResponse[0].width).to.equal(Number(ad.creativeWidth)); + expect(interpretedResponse[0].height).to.equal(Number(ad.creativeHeight)); + expect(interpretedResponse[0].creativeId).to.equal(ad.creativeId); + expect(interpretedResponse[0].currency).to.equal(ad.cpm.currency); + expect(interpretedResponse[0].netRevenue).to.equal(false); + expect(interpretedResponse[0].ad).to.equal(serverResponse.body.adUnits[0].html); + expect(interpretedResponse[0].ttl).to.equal(360); + }); + }); +}); diff --git a/test/spec/modules/adoceanBidAdapter_spec.js b/test/spec/modules/adoceanBidAdapter_spec.js index 1fd009ce526..1c3383be5aa 100644 --- a/test/spec/modules/adoceanBidAdapter_spec.js +++ b/test/spec/modules/adoceanBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/adoceanBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/adoceanBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('AdoceanAdapter', function () { const adapter = newBidder(spec); @@ -95,7 +95,7 @@ describe('AdoceanAdapter', function () { it('sends bid request to url via GET', function () { const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`^https://${bidRequests[0].params.emiter}/ad.json`)); + expect(request.url).to.match(new RegExp(`^https://${bidRequests[0].params.emiter}/_[0-9]*/ad.json`)); }); it('should attach id to url', function () { diff --git a/test/spec/modules/adomikAnalyticsAdapter_spec.js b/test/spec/modules/adomikAnalyticsAdapter_spec.js index 16480d746b7..1414b2402b9 100644 --- a/test/spec/modules/adomikAnalyticsAdapter_spec.js +++ b/test/spec/modules/adomikAnalyticsAdapter_spec.js @@ -1,4 +1,4 @@ -import adomikAnalytics from 'modules/adomikAnalyticsAdapter'; +import adomikAnalytics from 'modules/adomikAnalyticsAdapter.js'; import {expect} from 'chai'; let events = require('src/events'); let adapterManager = require('src/adapterManager').default; @@ -7,6 +7,13 @@ let constants = require('src/constants.json'); describe('Adomik Prebid Analytic', function () { let sendEventStub; let sendWonEventStub; + let clock; + before(function () { + clock = sinon.useFakeTimers(); + }); + after(function () { + clock.restore(); + }); describe('enableAnalytics', function () { beforeEach(function () { @@ -120,7 +127,6 @@ describe('Adomik Prebid Analytic', function () { expect(adomikAnalytics.currentContext.timeouted).to.equal(true); // Step 7: Send auction end event - var clock = sinon.useFakeTimers(); events.emit(constants.EVENTS.AUCTION_END, {}); setTimeout(function() { @@ -130,7 +136,6 @@ describe('Adomik Prebid Analytic', function () { }, 3000); clock.tick(5000); - clock.restore(); sinon.assert.callCount(adomikAnalytics.track, 6); }); diff --git a/test/spec/modules/adotBidAdapter_spec.js b/test/spec/modules/adotBidAdapter_spec.js new file mode 100644 index 00000000000..594fc4ac7b7 --- /dev/null +++ b/test/spec/modules/adotBidAdapter_spec.js @@ -0,0 +1,3118 @@ +import { expect } from 'chai'; +import { executeRenderer } from 'src/Renderer.js'; +import * as utils from 'src/utils.js'; +import { spec } from 'modules/adotBidAdapter.js'; + +const BIDDER_URL = 'https://dsp.adotmob.com/headerbidding/bidrequest'; + +describe('Adot Adapter', function () { + const examples = { + adUnit_banner: { + adUnitCode: 'ad_unit_banner', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: {}, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + }, + + adUnit_video_outstream: { + adUnitCode: 'ad_unit_video_outstream', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: { + video: { + mimes: ['video/mp4'], + minDuration: 5, + maxDuration: 30, + protocols: [2, 3] + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[300, 250]] + } + } + }, + + adUnit_video_instream: { + adUnitCode: 'ad_unit_video_instream', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: { + video: { + instreamContext: 'pre-roll', + mimes: ['video/mp4'], + minDuration: 5, + maxDuration: 30, + protocols: [2, 3] + } + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[300, 250]] + } + } + }, + + adUnitContext: { + refererInfo: { + referer: 'https://we-are-adot.com/test', + }, + gdprConsent: { + consentString: 'consent_string', + gdprApplies: true + } + }, + + adUnit_position: { + adUnitCode: 'ad_unit_position', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: { + position: 1 + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + }, + + adUnit_native: { + adUnitCode: 'ad_unit_native', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: {}, + mediaTypes: { + native: { + title: {required: true, len: 140}, + icon: {required: true, sizes: [50, 50]}, + image: {required: false, sizes: [320, 200]}, + sponsoredBy: {required: false}, + body: {required: false}, + cta: {required: true} + } + } + }, + + serverRequest_banner: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_banner_0_0', + banner: { + format: [{ + w: 300, + h: 200 + }] + }, + video: null + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_banner_0_0', + adUnitCode: 'ad_unit_banner', + bidId: 'imp_id_banner' + } + ] + } + }, + + serverRequest_banner_twoImps: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_banner_0_0', + banner: { + format: [{ + w: 300, + h: 200 + }] + }, + video: null + }, + { + id: 'imp_id_banner_2_0_0', + banner: { + format: [{ + w: 300, + h: 200 + }] + }, + video: null + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_banner_0_0', + adUnitCode: 'ad_unit_banner', + bidId: 'imp_id_banner' + }, + { + impressionId: 'imp_id_banner_2_0_0', + adUnitCode: 'ad_unit_banner_2', + bidId: 'imp_id_banner_2' + } + ] + } + }, + + serverRequest_video_instream: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_video_instream_0', + banner: null, + video: { + mimes: ['video/mp4'], + w: 300, + h: 200, + startdelay: 0, + minduration: 5, + maxduration: 35, + protocols: [2, 3] + } + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_video_instream_0', + adUnitCode: 'ad_unit_video_instream', + bidId: 'imp_id_video_instream' + } + ] + } + }, + + serverRequest_video_outstream: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_video_outstream_0', + banner: null, + video: { + mimes: ['video/mp4'], + w: 300, + h: 200, + startdelay: null, + minduration: 5, + maxduration: 35, + protocols: [2, 3] + } + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_video_outstream_0', + adUnitCode: 'ad_unit_video_outstream', + bidId: 'imp_id_video_outstream' + } + ] + } + }, + + serverRequest_video_instream_outstream: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_video_instream_0', + banner: null, + video: { + mimes: ['video/mp4'], + w: 300, + h: 200, + startdelay: 0, + minduration: 5, + maxduration: 35, + protocols: [2, 3] + } + }, + { + id: 'imp_id_video_outstream_0', + banner: null, + video: { + mimes: ['video/mp4'], + w: 300, + h: 200, + startdelay: null, + minduration: 5, + maxduration: 35, + protocols: [2, 3] + } + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_video_instream_0', + adUnitCode: 'ad_unit_video_instream', + bidId: 'imp_id_video_instream' + }, + { + impressionId: 'imp_id_video_outstream_0', + adUnitCode: 'ad_unit_video_outstream', + bidId: 'imp_id_video_outstream' + } + ] + } + }, + + serverRequest_position: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_banner', + banner: { + format: [{ + w: 300, + h: 200 + }], + position: 1 + }, + video: null + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_banner', + adUnitCode: 'ad_unit_position' + } + ] + } + }, + + serverRequest_native: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_native_0', + native: { + request: { + assets: [ + { + id: 1, + required: true, + title: { + len: 140 + } + }, + { + id: 2, + required: true, + img: { + type: 1, + wmin: 50, + hmin: 50 + } + }, + { + id: 3, + required: false, + img: { + type: 3, + wmin: 320, + hmin: 200 + } + }, + { + id: 4, + required: false, + data: { + type: 1 + } + }, + { + id: 5, + required: false, + data: { + type: 2 + } + }, + { + id: 6, + required: true, + data: { + type: 12 + } + } + ] + } + }, + video: null, + banner: null + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_native_0', + adUnitCode: 'ad_unit_native', + bidId: 'imp_id_native' + } + ] + } + }, + + serverResponse_banner: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_banner_0_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + h: 350, + w: 300, + ext: { + adot: { + media_type: 'banner' + } + } + } + ] + } + ] + } + }, + + serverResponse_banner_twoBids: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_banner_0_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + h: 350, + w: 300, + ext: { + adot: { + media_type: 'banner' + } + } + }, + { + impid: 'imp_id_banner_2_0_0', + crid: 'creative_id_2', + adm: 'creative_data_2_${AUCTION_PRICE}', + nurl: 'win_notice_url_2_${AUCTION_PRICE}', + price: 2.5, + h: 400, + w: 350, + ext: { + adot: { + media_type: 'banner' + } + } + } + ] + } + ] + } + }, + + serverResponse_video_instream: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_video_instream_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'video' + } + } + } + ] + } + ] + } + }, + + serverResponse_video_outstream: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_video_outstream_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'video' + } + } + } + ] + } + ] + } + }, + + serverResponse_video_instream_outstream: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_video_instream_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'video' + } + } + }, + { + impid: 'imp_id_video_outstream_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'video' + } + } + } + ] + } + ] + } + }, + + serverResponse_native: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_native_0', + crid: 'creative_id', + adm: '{"native":{"assets":[{"id":1,"title":{"len":140,"text":"Hi everyone"}},{"id":2,"img":{"url":"https://adotmob.com","type":1,"w":50,"h":50}},{"id":3,"img":{"url":"https://adotmob.com","type":3,"w":320,"h":200}},{"id":4,"data":{"type":1,"value":"adotmob"}},{"id":5,"data":{"type":2,"value":"This is a test ad"}},{"id":6,"data":{"type":12,"value":"Click to buy"}}],"link":{"url":"https://adotmob.com?auction=${AUCTION_PRICE}"}}}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'native' + } + } + } + ] + } + ] + } + } + }; + + describe('isBidRequestValid', function () { + describe('General', function () { + it('should return false when not given an ad unit', function () { + const adUnit = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an invalid ad unit', function () { + const adUnit = 'bad_bid'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without bidder code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidder = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a bad bidder code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidder = 'unknownBidder'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without ad unit code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.adUnitCode = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid ad unit code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.adUnitCode = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without bid request identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidderRequestId = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid bid request identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidderRequestId = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without impression identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidId = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid impression identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidId = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with empty media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with invalid media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = 'bad_media_types'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + }); + + describe('Banner', function () { + it('should return true when given a valid ad unit', function () { + const adUnit = examples.adUnit_banner; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid ad unit without bidder parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.params = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return false when given an ad unit without size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = 'bad_banner_size'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an empty size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = ['bad_banner_size_value']; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with less than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with more than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, 250, 30]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative width value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[-300, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative height value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, -250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid width value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[false, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid height value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, {}]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + }); + + describe('Video', function () { + it('should return true when given a valid outstream ad unit', function () { + const adUnit = examples.adUnit_video_outstream; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid pre-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'pre-roll'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid mid-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'mid-roll'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid post-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'post-roll'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given an ad unit without size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given an ad unit with an empty size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given an ad unit without minimum duration parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.minDuration = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given an ad unit without maximum duration parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.maxDuration = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return false when given an ad unit without bidder parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with invalid bidder parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params = 'bad_bidder_parameters'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without video parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with invalid video parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video = 'bad_bidder_parameters'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without mime types parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.mimes = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid mime types parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.mimes = 'bad_mime_types'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an empty mime types parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.mimes = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid mime types parameter value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.mimes = [200]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid minimum duration parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.minDuration = 'bad_min_duration'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid maximum duration parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.maxDuration = 'bad_max_duration'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without protocols parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.protocols = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid protocols parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.protocols = 'bad_protocols'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an empty protocols parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.protocols = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid protocols parameter value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.protocols = ['bad_protocols_value']; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an instream ad unit without instream context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an instream ad unit with an invalid instream context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'bad_instream_context'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.context = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.context = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an adpod ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.context = 'adpod'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an unknown context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.context = 'invalid_context'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = 'bad_video_size'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = ['bad_video_size_value']; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with less than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[300]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with more than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[300, 250, 30]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative width value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[-300, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative height value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[300, -250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid width value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[false, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid height value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[300, {}]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + }); + }); + + describe('buildRequests', function () { + describe('ServerRequest', function () { + it('should return a server request when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + expect(serverRequests[0].method).to.exist.and.to.be.a('string').and.to.equal('POST'); + expect(serverRequests[0].url).to.exist.and.to.be.a('string').and.to.equal(BIDDER_URL); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions).to.exist.and.to.be.an('array').and.to.have.length(1); + expect(serverRequests[0]._adot_internal.impressions[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions[0].impressionId).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0]._adot_internal.impressions[0].adUnitCode).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].adUnitCode); + }); + + it('should return a server request containing a position when given a valid ad unit and a valid ad unit context and a position in the bidder params', function () { + const adUnits = [examples.adUnit_position]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + expect(serverRequests[0].method).to.exist.and.to.be.a('string').and.to.equal('POST'); + expect(serverRequests[0].url).to.exist.and.to.be.a('string').and.to.equal(BIDDER_URL); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions).to.exist.and.to.be.an('array').and.to.have.length(1); + expect(serverRequests[0]._adot_internal.impressions[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions[0].impressionId).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0]._adot_internal.impressions[0].adUnitCode).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].adUnitCode); + expect(serverRequests[0].data.imp[0].banner.pos).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.position); + }); + + it('should return a server request when given two valid ad units and a valid ad unit context', function () { + const adUnits_1 = utils.deepClone(examples.adUnit_banner); + adUnits_1.bidId = 'bid_id_1'; + adUnits_1.adUnitCode = 'ad_unit_banner_1'; + + const adUnits_2 = utils.deepClone(examples.adUnit_banner); + adUnits_2.bidId = 'bid_id_2'; + adUnits_2.adUnitCode = 'ad_unit_banner_2'; + + const adUnits = [adUnits_1, adUnits_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + expect(serverRequests[0].method).to.exist.and.to.be.a('string').and.to.equal('POST'); + expect(serverRequests[0].url).to.exist.and.to.be.a('string').and.to.equal(BIDDER_URL); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions).to.exist.and.to.be.an('array').and.to.have.length(2); + expect(serverRequests[0]._adot_internal.impressions[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions[0].impressionId).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0]._adot_internal.impressions[0].adUnitCode).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].adUnitCode); + expect(serverRequests[0]._adot_internal.impressions[1]).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions[1].impressionId).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0_0`); + expect(serverRequests[0]._adot_internal.impressions[1].adUnitCode).to.exist.and.to.be.a('string').and.to.equal(adUnits[1].adUnitCode); + }); + + it('should return an empty server request list when given an empty ad unit list and a valid ad unit context', function () { + const adUnits = []; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.length(0); + }); + + it('should not return a server request when given no ad unit and a valid ad unit context', function () { + const serverRequests = spec.buildRequests(null, examples.adUnitContext); + + expect(serverRequests).to.equal(null); + }); + + it('should not return a server request when given a valid ad unit and no ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, null); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + }); + + it('should not return a server request when given a valid ad unit and an invalid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, {}); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + }); + }); + + describe('BidRequest', function () { + it('should return a valid server request when given a valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.at).to.exist.and.to.be.a('number').and.to.equal(1); + expect(serverRequests[0].data.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.ext.adot).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.ext.adot.adapter_version).to.exist.and.to.be.a('string').and.to.equal('v1.0.0'); + }); + + it('should return one server request when given one valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + }); + + it('should return one server request when given two valid ad units with different impression identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.bidId = 'bid_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.bidId = 'bid_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[1].bidderRequestId); + }); + + it('should return two server requests when given two valid ad units with different bid request identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.bidderRequestId = 'bidder_request_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.bidderRequestId = 'bidder_request_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(2); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[1].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[1].bidderRequestId); + }); + }); + + describe('Impression', function () { + describe('Banner', function () { + it('should return a server request with one impression when given a valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + }); + + it('should return a server request with two impressions containing one banner formats when given a valid ad unit with two banner sizes', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [ + [300, 250], + [350, 300] + ]; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(2); + + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + + expect(serverRequests[0].data.imp[1]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_1`); + expect(serverRequests[0].data.imp[1].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[1][0]); + expect(serverRequests[0].data.imp[1].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[1][1]); + expect(serverRequests[0].data.imp[1].banner.format).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[1].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[1][0], + h: adUnits[0].mediaTypes.banner.sizes[1][1] + }); + }); + + it('should return a server request with two impressions when given two valid ad units with different impression identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.bidId = 'bid_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.bidId = 'bid_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(2); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + expect(serverRequests[0].data.imp[1]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0_0`); + expect(serverRequests[0].data.imp[1].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[1].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[1].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[0].data.imp[1].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[1].mediaTypes.banner.sizes[0][0], + h: adUnits[1].mediaTypes.banner.sizes[0][1] + }); + }); + + it('should return a server request with one overriden impression when given two valid ad units with identical identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.mediaTypes.banner.sizes = [[300, 250]]; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.mediaTypes.banner.sizes = [[350, 300]]; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[1].mediaTypes.banner.sizes[0][0], + h: adUnits[1].mediaTypes.banner.sizes[0][1] + }); + }); + + it('should return two server requests with one impression when given two valid ad units with different bid request identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.bidderRequestId = 'bidder_request_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.bidderRequestId = 'bidder_request_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(2); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + expect(serverRequests[1].data).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[1].bidderRequestId); + expect(serverRequests[1].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[1].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0_0`); + expect(serverRequests[1].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[1].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[1].data.imp[0].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[1].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[1].mediaTypes.banner.sizes[0][0], + h: adUnits[1].mediaTypes.banner.sizes[0][1] + }); + }); + }); + + describe('Video', function () { + it('should return a server request with one impression when given a valid outstream ad unit', function () { + const adUnit = examples.adUnit_video_outstream; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid pre-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'pre-roll'; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(0); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid mid-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'mid-roll'; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(-1); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid post-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'post-roll'; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(-2); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit without player size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = undefined; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.equal(null); + expect(serverRequests[0].data.imp[0].video.h).to.equal(null); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit with an empty player size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = []; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.equal(null); + expect(serverRequests[0].data.imp[0].video.h).to.equal(null); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit with multiple player sizes', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[350, 300], [400, 350]]; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit without minimum duration', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.minDuration = undefined; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.equal(null); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit without maximum duration', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.maxDuration = undefined; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.equal(null); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with two impressions when given two valid ad units with different impression identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_1.bidId = 'bid_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_2.bidId = 'bid_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(2); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[1]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); + expect(serverRequests[0].data.imp[1].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[1].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[1].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[1].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[1].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); + expect(serverRequests[0].data.imp[1].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); + expect(serverRequests[0].data.imp[1].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + }); + + it('should return a server request with one overridden impression when given two valid ad units with identical identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_1.params.video.minDuration = 10; + + const adUnit_2 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_2.params.video.minDuration = 15; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + }); + + it('should return two server requests with one impression when given two valid ad units with different bid request identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_1.bidderRequestId = 'bidder_request_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_2.bidderRequestId = 'bidder_request_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(2); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[1].data).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[1].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); + expect(serverRequests[1].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[1].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[1].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[1].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[1].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); + expect(serverRequests[1].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); + expect(serverRequests[1].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + }); + }); + + describe('Native', function () { + it('should return a server request with one impression when given a valid ad unit', function () { + const adUnits = [examples.adUnit_native]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnit_native); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].native).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].native.request).to.exist.and.to.be.a('string').and.to.equal(JSON.stringify(examples.serverRequest_native.data.imp[0].native.request)) + }); + }); + }); + + describe('Site', function () { + it('should return a server request with site information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.site.page).to.exist.and.to.be.an('string').and.to.equal(adUnitContext.refererInfo.referer); + expect(serverRequests[0].data.site.id).to.equal(undefined); + expect(serverRequests[0].data.site.domain).to.exist.and.to.be.an('string').and.to.equal('we-are-adot.com'); + expect(serverRequests[0].data.site.name).to.exist.and.to.be.an('string').and.to.equal('we-are-adot.com'); + }); + + it('should return a server request without site information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context without referer information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with invalid referer information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo = 'bad_referer_information'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context without referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with an invalid referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = {}; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with a misformatted referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = 'we-are-adot'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + }); + + describe('Device', function () { + it('should return a server request with device information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.device).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.device.ua).to.exist.and.to.be.a('string'); + expect(serverRequests[0].data.device.language).to.exist.and.to.be.a('string'); + }); + }); + + describe('Regs', function () { + it('should return a server request with regulations information when given a valid ad unit and a valid ad unit context with GDPR applying', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext.gdpr).to.exist.and.to.be.a('boolean').and.to.equal(adUnitContext.gdprConsent.gdprApplies); + }); + + it('should return a server request with regulations information when given a valid ad unit and a valid ad unit context with GDPR not applying', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.gdprApplies = false; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext.gdpr).to.exist.and.to.be.a('boolean').and.to.equal(adUnitContext.gdprConsent.gdprApplies); + }); + + it('should return a server request without regulations information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context without GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context with invalid GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = 'bad_gdpr_consent'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context with invalid GDPR application information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.gdprApplies = 'bad_gdpr_applies'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + }); + + describe('User', function () { + it('should return a server request with user information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.user.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.user.ext.consent).to.exist.and.to.be.a('string').and.to.equal(adUnitContext.gdprConsent.consentString); + }); + + it('should return a server request without user information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context without GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context with invalid GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = 'bad_gdpr_consent'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context with an invalid consent string', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.consentString = true; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + }); + }); + + describe('interpretResponse', function () { + describe('General', function () { + it('should return an ad when given a valid server response with one bid with USD currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = 'USD'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return two ads when given a valid server response with two bids', function () { + const serverRequest = examples.serverRequest_banner_twoImps; + + const serverResponse = examples.serverResponse_banner_twoBids; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(2); + + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + expect(ads[1].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[1].bidId); + expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[1].adm); + expect(ads[1].adUrl).to.equal(null); + expect(ads[1].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[1].crid); + expect(ads[1].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].price); + expect(ads[1].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[1].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[1].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[1].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].h); + expect(ads[1].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].w); + expect(ads[1].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[1].renderer).to.equal(null); + }); + + it('should return no ad when not given a server response', function () { + const ads = spec.interpretResponse(null); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when not given a server response body', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given an invalid server response body', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body = 'invalid_body'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response without seat bids', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with invalid seat bids', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = 'invalid_seat_bids'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an empty seat bids array', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = []; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an invalid seat bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = 'invalid_bids'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an empty bids array', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = []; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an invalid bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = ['invalid_bid']; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without impression identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].impid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid impression identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].impid = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without creative identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].crid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid creative identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].crid = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without ad markup and ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = undefined; + serverResponse.body.seatbid[0].bid[0].nurl = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid ad markup', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an ad markup without auction price macro', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = 'creative_data'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an ad serving URL without auction price macro', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = 'win_notice_url'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without bid price', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].price = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid bid price', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].price = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext = 'bad_ext'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without adot extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid adot extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot = 'bad_adot_ext'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an unknown media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = 'unknown_media_type'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and no server request', function () { + const serverRequest = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and an invalid server request', function () { + const serverRequest = 'bad_server_request'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without bid request', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with an invalid bid request', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data = 'bad_bid_request'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with an invalid impression field', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp = 'invalid_impressions'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without matching impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp[0].id = 'unknown_imp_id'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without internal data', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with invalid internal data', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal = 'bad_internal_data'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without internal impression data', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with invalid internal impression data', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions = 'bad_internal_impression_data'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without matching internal impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions[0].impressionId = 'unknown_imp_id'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without internal impression ad unit code', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions[0].adUnitCode = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with an invalid internal impression ad unit code', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions[0].adUnitCode = {}; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + }); + + describe('Banner', function () { + it('should return an ad when given a valid server response with one bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid without a win notice URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid using an ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.equal(null); + expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].nurl); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return no ad when given a server response with a bid without height', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].h = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid height', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].h = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without width', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].w = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid width', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].w = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without banner impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp[0].banner = undefined; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + }); + + describe('Video', function () { + it('should return an ad when given a valid server response with one bid on an instream impression', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = examples.serverResponse_video_instream; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid on an outstream impression', function () { + const serverRequest = examples.serverRequest_video_outstream; + + const serverResponse = examples.serverResponse_video_outstream; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.be.an('object'); + }); + + it('should return two ads when given a valid server response with two bids on both instream and outstream impressions', function () { + const serverRequest = examples.serverRequest_video_instream_outstream; + + const serverResponse = examples.serverResponse_video_instream_outstream; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(2); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + expect(ads[1].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[1].bidId); + expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[1].adm); + expect(ads[1].adUrl).to.equal(null); + expect(ads[1].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[1].vastUrl).to.equal(null); + expect(ads[1].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[1].crid); + expect(ads[1].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].price); + expect(ads[1].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[1].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[1].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[1].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[1].video.w); + expect(ads[1].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[1].renderer).to.be.an('object'); + }); + + it('should return an ad when given a valid server response with one bid without a win notice URL', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].nurl = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid using an ad serving URL', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].adm = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.equal(null); + expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].nurl); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(serverResponse.body.seatbid[0].bid[0].nurl); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with a bid with a video height', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].h = 500; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with a bid with a video width', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].w = 500; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with a bid with a video width and height', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].w = 500; + serverResponse.body.seatbid[0].bid[0].h = 400; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response and server request with a video impression without width', function () { + const serverRequest = utils.deepClone(examples.serverRequest_video_instream); + serverRequest.data.imp[0].video.w = null; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(null); + expect(ads[0].width).to.equal(null); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response and server request with a video impression without height', function () { + const serverRequest = utils.deepClone(examples.serverRequest_video_instream); + serverRequest.data.imp[0].video.h = null; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(null); + expect(ads[0].width).to.equal(null); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return no ad when given a server response with a bid with an invalid height', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].h = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid width', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].w = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without video impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_video_instream); + serverRequest.data.imp[0].video = undefined; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + describe('Outstream renderer', function () { + function spyAdRenderingQueue(ad) { + const spy = sinon.spy(ad.renderer, 'push'); + + this.sinonSpies.push(spy); + } + + function executeAdRenderer(ad, onRendererExecution, done) { + executeRenderer(ad.renderer, ad); + + setTimeout(() => { + try { + onRendererExecution(); + } catch (err) { + done(err); + } + + done() + }, 100); + } + + before('Bind helper functions to the Mocha context', function () { + this.spyAdRenderingQueue = spyAdRenderingQueue.bind(this); + + window.VASTPlayer = function VASTPlayer() {}; + window.VASTPlayer.prototype.loadXml = function loadXml() { + return new Promise((resolve, reject) => resolve()) + }; + window.VASTPlayer.prototype.load = function load() { + return new Promise((resolve, reject) => resolve()) + }; + window.VASTPlayer.prototype.on = function on(event, callback) {}; + window.VASTPlayer.prototype.startAd = function startAd() {}; + }); + + beforeEach('Initialize the Sinon spies list', function () { + this.sinonSpies = []; + }); + + afterEach('Clear the registered Sinon spies', function () { + this.sinonSpies.forEach(spy => spy.restore()); + }); + + after('clear data', () => { + window.VASTPlayer = null; + }); + + it('should return an ad with valid renderer', function () { + const serverRequest = examples.serverRequest_video_outstream; + const serverResponse = examples.serverResponse_video_outstream; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].renderer).to.be.an('object'); + }); + + it('should append a command to the ad rendering queue when executing the renderer', function (done) { + const serverRequest = examples.serverRequest_video_outstream; + const serverResponse = examples.serverResponse_video_outstream; + + const [ad] = spec.interpretResponse(serverResponse, serverRequest); + + this.spyAdRenderingQueue(ad); + + executeAdRenderer(ad, () => { + expect(ad.renderer.push.calledOnce).to.equal(true); + expect(ad.renderer.push.firstCall.args[0]).to.exist.and.to.be.a('function'); + }, done); + }); + }); + }); + + describe('Native', function () { + it('should return an ad when given a valid server response with one bid', function () { + const serverRequest = examples.serverRequest_native; + const serverResponse = examples.serverResponse_native; + const native = JSON.parse(serverResponse.body.seatbid[0].bid[0].adm).native; + const {link, assets} = native; + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('native'); + expect(ads[0].native).to.exist.and.to.be.an('object'); + expect(Object.keys(ads[0].native)).to.have.length(10); + expect(ads[0].native.title).to.equal(assets[0].title.text); + expect(ads[0].native.icon.url).to.equal(assets[1].img.url); + expect(ads[0].native.icon.width).to.equal(assets[1].img.w); + expect(ads[0].native.icon.height).to.equal(assets[1].img.h); + expect(ads[0].native.image.url).to.equal(assets[2].img.url); + expect(ads[0].native.image.width).to.equal(assets[2].img.w); + expect(ads[0].native.image.height).to.equal(assets[2].img.h); + expect(ads[0].native.sponsoredBy).to.equal(assets[3].data.value); + expect(ads[0].native.body).to.equal(assets[4].data.value); + expect(ads[0].native.cta).to.equal(assets[5].data.value); + expect(ads[0].native.clickUrl).to.equal(link.url); + }); + }); + }); +}); diff --git a/test/spec/modules/adpod_spec.js b/test/spec/modules/adpod_spec.js index 8b7701c5631..ff416e05522 100644 --- a/test/spec/modules/adpod_spec.js +++ b/test/spec/modules/adpod_spec.js @@ -1,10 +1,10 @@ -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import * as videoCache from 'src/videoCache'; -import * as auction from 'src/auction'; -import { ADPOD } from 'src/mediaTypes'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import * as videoCache from 'src/videoCache.js'; +import * as auction from 'src/auction.js'; +import { ADPOD } from 'src/mediaTypes.js'; -import { callPrebidCacheHook, checkAdUnitSetupHook, checkVideoBidSetupHook, adpodSetConfig, sortByPricePerSecond } from 'modules/adpod'; +import { callPrebidCacheHook, checkAdUnitSetupHook, checkVideoBidSetupHook, adpodSetConfig, sortByPricePerSecond } from 'modules/adpod.js'; let expect = require('chai').expect; @@ -138,7 +138,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 300, durationRangeSec: [15, 30, 45], requireExactDuration: false @@ -220,7 +220,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 120, durationRangeSec: [15, 30], requireExactDuration: false @@ -282,7 +282,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 120, durationRangeSec: [15, 30], requireExactDuration: true @@ -376,7 +376,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 45, durationRangeSec: [15, 30], requireExactDuration: false @@ -465,7 +465,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 45, durationRangeSec: [15, 30], requireExactDuration: false @@ -525,7 +525,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 45, durationRangeSec: [15, 30], requireExactDuration: false @@ -602,7 +602,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 120, durationRangeSec: [15, 30, 45], requireExactDuration: false @@ -675,7 +675,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 120, durationRangeSec: [15, 30, 45], requireExactDuration: false @@ -697,19 +697,16 @@ describe('adpod.js', function () { const customConfigObject = { 'buckets': [{ 'precision': 2, // default is 2 if omitted - means 2.1234 rounded to 2 decimal places = 2.12 - 'min': 0, 'max': 5, 'increment': 0.01 // from $0 to $5, 1-cent increments }, { 'precision': 2, - 'min': 5, 'max': 8, 'increment': 0.05 // from $5 to $8, round down to the previous 5-cent increment }, { 'precision': 2, - 'min': 8, 'max': 40, 'increment': 0.5 // from $8 to $40, round down to the previous 50-cent increment }] @@ -751,7 +748,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 45, durationRangeSec: [15, 30], requireExactDuration: false @@ -766,6 +763,83 @@ describe('adpod.js', function () { expect(storeStub.called).to.equal(false); expect(auctionBids.length).to.equal(1); }); + + it('should set deal tier in place of cpm when prioritzeDeals is true', function() { + config.setConfig({ + adpod: { + deferCaching: true, + brandCategoryExclusion: true, + prioritizeDeals: true, + dealTier: { + 'appnexus': { + 'prefix': 'tier', + 'minDealTier': 5 + } + } + } + }); + + let bidResponse1 = { + adId: 'adId01277', + auctionId: 'no_defer_123', + mediaType: 'video', + bidderCode: 'appnexus', + cpm: 5, + pbMg: '5.00', + adserverTargeting: { + hb_pb: '5.00' + }, + meta: { + adServerCatId: 'test' + }, + video: { + context: ADPOD, + durationSeconds: 15, + durationBucket: 15, + dealTier: 7 + } + }; + + let bidResponse2 = { + adId: 'adId46547', + auctionId: 'no_defer_123', + mediaType: 'video', + bidderCode: 'appnexus', + cpm: 12, + pbMg: '12.00', + adserverTargeting: { + hb_pb: '12.00' + }, + meta: { + adServerCatId: 'value' + }, + video: { + context: ADPOD, + durationSeconds: 15, + durationBucket: 15 + } + }; + + let bidderRequest = { + adUnitCode: 'adpod_1', + auctionId: 'no_defer_123', + mediaTypes: { + video: { + context: ADPOD, + playerSize: [[300, 300]], + adPodDurationSec: 300, + durationRangeSec: [15, 30, 45], + requireExactDuration: false + } + }, + }; + + callPrebidCacheHook(callbackFn, auctionInstance, bidResponse1, afterBidAddedSpy, bidderRequest); + callPrebidCacheHook(callbackFn, auctionInstance, bidResponse2, afterBidAddedSpy, bidderRequest); + + expect(auctionBids[0].adserverTargeting.hb_pb_cat_dur).to.equal('tier7_test_15s'); + expect(auctionBids[1].adserverTargeting.hb_pb_cat_dur).to.equal('12.00_value_15s'); + }) }); describe('checkAdUnitSetupHook', function () { @@ -848,7 +922,7 @@ describe('adpod.js', function () { }, video: { context: 'adpod', - playerSize: [300, 250], + playerSize: [[300, 250]], durationRangeSec: [15, 30, 45], adPodDurationSec: 300 } @@ -867,7 +941,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 360, durationRangeSec: [15, 30, 45], requireExactDuration: true @@ -915,7 +989,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 400], + playerSize: [[300, 400]], durationRangeSec: [15, 45], requireExactDuration: false, adPodDurationSec: 300 @@ -926,7 +1000,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 400], + playerSize: [[300, 400]], durationRangeSec: [15, 30, 45, 60], requireExactDuration: true, adPodDurationSec: 300 diff --git a/test/spec/modules/adponeBidAdapter_spec.js b/test/spec/modules/adponeBidAdapter_spec.js index 1c64c60bd5c..737f1c284e1 100644 --- a/test/spec/modules/adponeBidAdapter_spec.js +++ b/test/spec/modules/adponeBidAdapter_spec.js @@ -1,6 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/adponeBidAdapter'; +import { spec } from 'modules/adponeBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; +const EMPTY_ARRAY = []; describe('adponeBidAdapter', function () { let bid = { bidder: 'adpone', @@ -14,6 +17,48 @@ describe('adponeBidAdapter', function () { } }; + describe('build requests', () => { + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests([ + { + bidder: 'adpone', + adUnitCode: 'adunit-code', + sizes: [[300, 250]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + params: { + placementId: '1', + } + } + ]); + expect(request[0].method).to.equal('POST'); + }); + it('sends bid request to adpone endpoint', function () { + const request = spec.buildRequests([ + { + bidder: 'adpone', + adUnitCode: 'adunit-code', + sizes: [[300, 250]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + params: { + placementId: '1', + } + } + ]); + expect(request[0].url).to.equal('https://rtb.adpone.com/bid-request?pid=1'); + }); + }); + + describe('inherited functions', () => { + const adapter = newBidder(spec); + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + describe('isBidRequestValid', function () { it('should return true when necessary information is found', function () { expect(spec.isBidRequestValid(bid)).to.be.true; @@ -34,6 +79,36 @@ describe('adponeBidAdapter', function () { bid.adUnitCode = 'adunit-code'; }); + + it('returns false when bidder not set to "adpone"', function() { + const invalidBid = { + bidder: 'enopda', + adUnitCode: 'adunit-code', + sizes: [[300, 250]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + params: { + placementId: '1', + } + }; + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + + it('returns false when placementId is not set in params', function() { + const invalidBid = { + bidder: 'adpone', + adUnitCode: 'adunit-code', + sizes: [[300, 250]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + params: { + } + }; + + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); }); }); @@ -52,11 +127,11 @@ describe('interpretResponse', function () { id: '613673EF-A07C-4486-8EE9-3FC71A7DC73D', impid: '2579e20c0bb89_0', price: 1, - adm: '', + adm: '', adomain: [ 'www.addomain.com' ], - iurl: 'http://localhost11', + iurl: 'https://localhost11', crid: 'creative111', h: 250, w: 300, @@ -73,6 +148,19 @@ describe('interpretResponse', function () { }; }); + it('validate_response_params', function() { + const newResponse = spec.interpretResponse(serverResponse, bidRequest); + expect(newResponse[0].id).to.be.equal('613673EF-A07C-4486-8EE9-3FC71A7DC73D'); + expect(newResponse[0].requestId).to.be.equal('1234'); + expect(newResponse[0].cpm).to.be.equal(1); + expect(newResponse[0].width).to.be.equal(300); + expect(newResponse[0].height).to.be.equal(250); + expect(newResponse[0].currency).to.be.equal('USD'); + expect(newResponse[0].netRevenue).to.be.equal(true); + expect(newResponse[0].ttl).to.be.equal(300); + expect(newResponse[0].ad).to.be.equal(''); + }); + it('should correctly reorder the server response', function () { const newResponse = spec.interpretResponse(serverResponse, bidRequest); expect(newResponse.length).to.be.equal(1); @@ -86,7 +174,7 @@ describe('interpretResponse', function () { currency: 'USD', netRevenue: true, ttl: 300, - ad: '' + ad: '' }); }); @@ -99,4 +187,45 @@ describe('interpretResponse', function () { response = spec.interpretResponse(serverResponse, bidRequest); expect(response).to.deep.equal([]) }); + it('should add responses if the cpm is valid', function () { + serverResponse.body.seatbid[0].bid[0].price = 0.5; + let response = spec.interpretResponse(serverResponse, bidRequest); + expect(response).to.not.deep.equal([]); + }); +}); + +describe('getUserSyncs', function () { + it('Verifies that getUserSyncs is a function', function () { + expect((typeof (spec.getUserSyncs)).should.equals('function')); + }); + it('Verifies getUserSyncs returns expected result', function () { + expect((typeof (spec.getUserSyncs)).should.equals('function')); + expect(spec.getUserSyncs({iframeEnabled: true})).to.deep.equal({ + type: 'iframe', + url: 'https://eu-ads.adpone.com' + }); + }); + it('Verifies that iframeEnabled: false returns an empty array', function () { + expect(spec.getUserSyncs({iframeEnabled: false})).to.deep.equal(EMPTY_ARRAY); + }); + it('Verifies that iframeEnabled: null returns an empty array', function () { + expect(spec.getUserSyncs(null)).to.deep.equal(EMPTY_ARRAY); + }); +}); + +describe('test onBidWon function', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('exists and is a function', () => { + expect(spec.onBidWon).to.exist.and.to.be.a('function'); + }); + it('should return nothing', function () { + var response = spec.onBidWon({}); + expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(true); + }); }); diff --git a/test/spec/modules/adspiritBidAdapter_spec.js b/test/spec/modules/adspiritBidAdapter_spec.js deleted file mode 100644 index 7f907612384..00000000000 --- a/test/spec/modules/adspiritBidAdapter_spec.js +++ /dev/null @@ -1,142 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/adspiritBidAdapter'; - -describe('Adspirit adapter tests', function () { - let bidRequests, serverResponses; - - beforeEach(function () { - bidRequests = [ - // valid for adspirit - { - bidder: 'adspirit', - placementCode: 'ad-1', - params: { - placementId: '1', - host: 'test.adspirit.de' - }, - }, - // valid for xapadsmedia - { - bidder: 'xapadsmedia', - placementCode: 'ad-1', - params: { - placementId: '1' - }, - }, - // valid for connectad - { - bidder: 'connectad', - placementCode: 'ad-1', - params: { - placementId: '1' - }, - }, - // invalid 1 - { - bidder: 'adspirit', - placementCode: 'ad-1', - params: { - }, - }, - // invalid 2 - { - bidder: 'adspirit', - placementCode: 'ad-1', - params: { - host: 'test.adspirit.de' - }, - }, - // invalid 3 - { - bidder: '-', - placementCode: 'ad-1', - params: { - host: 'test.adspirit.de' - }, - } - ]; - serverResponses = [ - { - headers: {}, - body: { - cpm: 1.5, - w: 300, - h: 250, - placement_id: 1, - adm: '' - } - }, - { - headers: {}, - body: { - cpm: 0, - w: 0, - h: 0, - placement_id: 1, - adm: '' - } - }, - { - headers: {}, - body: { - cpm: 0, - w: 0, - h: 0, - placement_id: 0, - adm: '' - } - } - ] - }); - - describe('test bid request', function () { - it('with valid data 1', function () { - expect(spec.isBidRequestValid(bidRequests[0])).to.equal(true); - }); - it('with valid data 2', function () { - expect(spec.isBidRequestValid(bidRequests[1])).to.equal(true); - }); - it('with valid data 3', function () { - expect(spec.isBidRequestValid(bidRequests[2])).to.equal(true); - }); - it('with invalid data 1 (no host)', function () { - expect(spec.isBidRequestValid(bidRequests[3])).to.equal(false); - }); - it('with invalid data 2 (no placementId)', function () { - expect(spec.isBidRequestValid(bidRequests[4])).to.equal(false); - }); - it('with invalid data 3 (no bidder code)', function () { - expect(spec.isBidRequestValid(bidRequests[5])).to.equal(false); - }); - }); - - describe('test request build', function () { - it('normal', function () { - var requests = spec.buildRequests([bidRequests[0]]); - expect(requests).to.be.lengthOf(1); - }); - }); - - describe('test bid responses', function () { - it('success 1', function () { - var bids = spec.interpretResponse(serverResponses[0], {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(1); - expect(bids[0].cpm).to.equal(1.5); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(250); - expect(bids[0].ad).to.have.length.above(1); - }); - it('fail 1 (cpm=0)', function () { - var bids = spec.interpretResponse(serverResponses[1], {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(0); - }); - it('fail 2 (no response)', function () { - var bids = spec.interpretResponse([], {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(0); - }); - it('fail 3 (status fail)', function () { - var bids = spec.interpretResponse(serverResponses[2], {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(0); - }); - }); -}); diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js index 28bb057dffe..ad81795d0e9 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -1,25 +1,27 @@ import {expect} from 'chai'; -import {spec} from 'modules/adtelligentBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/adtelligentBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; -const ENDPOINT = '//hb.adtelligent.com/auction/'; +const ENDPOINT = 'https://ghb.adtelligent.com/auction/'; const DISPLAY_REQUEST = { 'bidder': 'adtelligent', 'params': { 'aid': 12345 }, + 'mediaTypes': {'banner': {'sizes': [300, 250]}}, 'bidderRequestId': '7101db09af0db2', 'auctionId': '2e41f65424c87c', 'adUnitCode': 'adunit-code', 'bidId': '84ab500420319d', - 'sizes': [300, 250] }; const VIDEO_REQUEST = { 'bidder': 'adtelligent', 'mediaTypes': { - 'video': {} + 'video': { + 'playerSize': [[480, 360], [640, 480]] + } }, 'params': { 'aid': 12345 @@ -27,8 +29,7 @@ const VIDEO_REQUEST = { 'bidderRequestId': '7101db09af0db2', 'auctionId': '2e41f65424c87c', 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [[480, 360], [640, 480]] + 'bidId': '84ab500420319d' }; const SERVER_VIDEO_RESPONSE = { @@ -73,7 +74,7 @@ const SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS = { 'width': 300, 'cpm': 0.9 }], - 'cookieURLs': ['link1', 'link2'], + 'cookieURLs': ['link3', 'link4'], 'cookieURLSTypes': ['image', 'iframe'] }; @@ -122,7 +123,7 @@ const displayEqResponse = [{ cpm: 0.9 }]; -describe('adtelligentBidAdapter', function () { // todo remove only +describe('adtelligentBidAdapter', function () { const adapter = newBidder(spec); describe('user syncs as image', function () { @@ -143,25 +144,37 @@ describe('adtelligentBidAdapter', function () { // todo remove only }) }) - describe('user syncs with both types', function () { - it('should be returned if pixel and iframe enabled', function () { + describe('user sync', function () { + it('should not be returned if passed syncs where already used', function () { const syncs = spec.getUserSyncs({ iframeEnabled: true, pixelEnabled: true }, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); - expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); - expect(syncs.map(s => s.type)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLSTypes); + expect(syncs).to.deep.equal([]); }) - }) + }); + + describe('user syncs with both types', function () { + it('should be returned if pixel and iframe enabled', function () { + const mockedServerResponse = Object.assign({}, SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS, {'cookieURLs': ['link5', 'link6']}); + const syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [{body: mockedServerResponse}]); + + expect(syncs.map(s => s.url)).to.deep.equal(mockedServerResponse.cookieURLs); + expect(syncs.map(s => s.type)).to.deep.equal(mockedServerResponse.cookieURLSTypes); + }); + }); describe('user syncs', function () { it('should not be returned if pixel not set', function () { const syncs = spec.getUserSyncs({}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); expect(syncs).to.be.empty; - }) - }) + }); + }); describe('inherited functions', function () { it('exists and is a function', function () { @@ -171,13 +184,13 @@ describe('adtelligentBidAdapter', function () { // todo remove only describe('isBidRequestValid', function () { it('should return true when required params found', function () { - expect(spec.isBidRequestValid(VIDEO_REQUEST)).to.equal(12345); + expect(spec.isBidRequestValid(VIDEO_REQUEST)).to.equal(true); }); it('should return false when required params are not passed', function () { let bid = Object.assign({}, VIDEO_REQUEST); delete bid.params; - expect(spec.isBidRequestValid(bid)).to.equal(undefined); + expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); diff --git a/test/spec/modules/aduptechBidAdapter_spec.js b/test/spec/modules/aduptechBidAdapter_spec.js index da0b603ebfc..1e39e0cfc8b 100644 --- a/test/spec/modules/aduptechBidAdapter_spec.js +++ b/test/spec/modules/aduptechBidAdapter_spec.js @@ -1,261 +1,502 @@ import { expect } from 'chai'; -import { BIDDER_CODE, PUBLISHER_PLACEHOLDER, ENDPOINT_URL, ENDPOINT_METHOD, spec } from 'modules/aduptechBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { + BIDDER_CODE, + PUBLISHER_PLACEHOLDER, + ENDPOINT_URL, + ENDPOINT_METHOD, + spec, + extractGdprFromBidderRequest, + extractParamsFromBidRequest, + extractSizesFromBidRequest, + extractTopWindowReferrerFromBidRequest, + extractTopWindowUrlFromBidRequest +} from '../../../modules/aduptechBidAdapter.js'; +import { newBidder } from '../../../src/adapters/bidderFactory.js'; -describe('AduptechBidAdapter', function () { - const adapter = newBidder(spec); +describe('AduptechBidAdapter', () => { + describe('extractGdprFromBidderRequest', () => { + it('should handle empty bidder request', () => { + const bidderRequest = null; + expect(extractGdprFromBidderRequest(bidderRequest)).to.be.null; + }); + + it('should handle missing gdprConsent in bidder request', () => { + const bidderRequest = {}; + expect(extractGdprFromBidderRequest(bidderRequest)).to.be.null; + }); + + it('should handle gdprConsent in bidder request', () => { + const bidderRequest = { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true + } + }; - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); + expect(extractGdprFromBidderRequest(bidderRequest)).to.deep.equal({ + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: true + }); }); }); - describe('isBidRequestValid', function () { - it('should return true when necessary information is given', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], + describe('extractParamsFromBidRequest', () => { + it('should handle empty bid request', () => { + const bidRequest = null; + expect(extractParamsFromBidRequest(bidRequest)).to.be.null; + }); + + it('should handle missing params in bid request', () => { + const bidRequest = {}; + expect(extractParamsFromBidRequest(bidRequest)).to.be.null; + }); + + it('should handle params in bid request', () => { + const bidRequest = { params: { - publisher: 'test', - placement: '1234' + foo: '123', + bar: 456 } - })).to.be.true; + }; + expect(extractParamsFromBidRequest(bidRequest)).to.deep.equal(bidRequest.params); }); + }); - it('should return false on empty bid', function () { - expect(spec.isBidRequestValid({})).to.be.false; + describe('extractSizesFromBidRequest', () => { + it('should handle empty bid request', () => { + const bidRequest = null; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal([]); }); - it('should return false on missing sizes', function () { - expect(spec.isBidRequestValid({ - params: { - publisher: 'test', - placement: '1234' + it('should handle missing sizes in bid request', () => { + const bidRequest = {}; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal([]); + }); + + it('should handle sizes in bid request', () => { + const bidRequest = { + mediaTypes: { + banner: { + sizes: [[12, 34], [56, 78]] + } } - })).to.be.false; + }; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.mediaTypes.banner.sizes); }); - it('should return false on empty sizes', function () { - expect(spec.isBidRequestValid({ - sizes: [], - params: { - publisher: 'test', - placement: '1234' + it('should handle sizes in bid request (backward compatibility)', () => { + const bidRequest = { + sizes: [[12, 34], [56, 78]] + }; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.sizes); + }); + + it('should prefer sizes in mediaTypes.banner', () => { + const bidRequest = { + sizes: [[12, 34]], + mediaTypes: { + banner: { + sizes: [[56, 78]] + } } - })).to.be.false; + }; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.mediaTypes.banner.sizes); }); + }); - it('should return false on missing params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - })).to.be.false; + describe('extractTopWindowReferrerFromBidRequest', () => { + it('should use fallback if bid request is empty', () => { + const bidRequest = null; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); }); - it('should return false on invalid params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: 'bar' - })).to.be.false; + it('should use fallback if refererInfo in bid request is missing', () => { + const bidRequest = {}; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); }); - it('should return false on empty params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: {} - })).to.be.false; + it('should use fallback if refererInfo.referer in bid request is missing', () => { + const bidRequest = { + refererInfo: {} + }; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); }); - it('should return false on missing publisher', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - placement: '1234' + it('should use fallback if refererInfo.referer in bid request is empty', () => { + const bidRequest = { + refererInfo: { + referer: '' + } + }; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); + }); + + it('should use refererInfo.referer from bid request ', () => { + const bidRequest = { + refererInfo: { + referer: 'foobar' } - })).to.be.false; + }; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(bidRequest.refererInfo.referer); }); + }); - it('should return false on missing placement', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - publisher: 'test' + describe('extractTopWindowUrlFromBidRequest', () => { + it('should use fallback if bid request is empty', () => { + const bidRequest = null; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + }); + + it('should use fallback if refererInfo in bid request is missing', () => { + const bidRequest = {}; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + }); + + it('should use fallback if refererInfo.canonicalUrl in bid request is missing', () => { + const bidRequest = { + refererInfo: {} + }; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + }); + + it('should use fallback if refererInfo.canonicalUrl in bid request is empty', () => { + const bidRequest = { + refererInfo: { + canonicalUrl: '' + } + }; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + }); + + it('should use refererInfo.canonicalUrl from bid request ', () => { + const bidRequest = { + refererInfo: { + canonicalUrl: 'foobar' } - })).to.be.false; + }; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(bidRequest.refererInfo.canonicalUrl); }); }); - describe('buildRequests', function () { - it('should send one bid request per ad unit to the endpoint via POST', function () { - const bidRequests = [ - { - bidder: BIDDER_CODE, - bidId: 'bidId1', - adUnitCode: 'adUnitCode1', - transactionId: 'transactionId1', - auctionId: 'auctionId1', - sizes: [[100, 200], [300, 400]], + describe('spec', () => { + let adapter; + + beforeEach(() => { + adapter = newBidder(spec); + }); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', () => { + it('should return true when necessary information is given', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, params: { - publisher: 'publisher1', - placement: 'placement1' + publisher: 'test', + placement: '1234' } - }, - { - bidder: BIDDER_CODE, - bidId: 'bidId2', - adUnitCode: 'adUnitCode2', - transactionId: 'transactionId2', - auctionId: 'auctionId2', - sizes: [[500, 600]], + })).to.be.true; + }); + + it('should return true when necessary information is given (backward compatibility)', () => { + expect(spec.isBidRequestValid({ + sizes: [[100, 200]], params: { - publisher: 'publisher2', - placement: 'placement2' + publisher: 'test', + placement: '1234' } - } - ]; - - const result = spec.buildRequests(bidRequests); - expect(result.length).to.equal(2); - - expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, bidRequests[0].params.publisher)); - expect(result[0].method).to.equal(ENDPOINT_METHOD); - expect(result[0].data).to.deep.equal({ - pageUrl: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - bidId: bidRequests[0].bidId, - auctionId: bidRequests[0].auctionId, - transactionId: bidRequests[0].transactionId, - adUnitCode: bidRequests[0].adUnitCode, - sizes: bidRequests[0].sizes, - params: bidRequests[0].params, - gdpr: null + })).to.be.true; }); - expect(result[1].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, bidRequests[1].params.publisher)); - expect(result[1].method).to.equal(ENDPOINT_METHOD); - expect(result[1].data).to.deep.equal({ - pageUrl: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - bidId: bidRequests[1].bidId, - auctionId: bidRequests[1].auctionId, - transactionId: bidRequests[1].transactionId, - adUnitCode: bidRequests[1].adUnitCode, - sizes: bidRequests[1].sizes, - params: bidRequests[1].params, - gdpr: null + it('should return false on empty bid', () => { + expect(spec.isBidRequestValid({})).to.be.false; }); - }); - it('should pass gdpr informations', function () { - const bidderRequest = { - gdprConsent: { - consentString: 'consentString', - gdprApplies: true - } - }; - const bidRequests = [ - { - bidder: BIDDER_CODE, - bidId: 'bidId3', - adUnitCode: 'adUnitCode3', - transactionId: 'transactionId3', - auctionId: 'auctionId3', - sizes: [[100, 200], [300, 400]], + it('should return false on missing sizes', () => { + expect(spec.isBidRequestValid({ params: { - publisher: 'publisher3', - placement: 'placement3' + publisher: 'test', + placement: '1234' } - } - ]; + })).to.be.false; + }); - const result = spec.buildRequests(bidRequests, bidderRequest); - expect(result.length).to.equal(1); - expect(result[0].data.gdpr).to.exist; - expect(result[0].data.gdpr.consentRequired).to.exist.and.to.equal(bidderRequest.gdprConsent.gdprApplies); - expect(result[0].data.gdpr.consentString).to.exist.and.to.equal(bidderRequest.gdprConsent.consentString); - }); + it('should return false on empty sizes', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [] + } + }, + params: { + publisher: 'test', + placement: '1234' + } + })).to.be.false; + }); - it('should encode publisher param in endpoint url', function () { - const bidRequests = [ - { - bidder: BIDDER_CODE, - bidId: 'bidId1', - adUnitCode: 'adUnitCode1', - transactionId: 'transactionId1', - auctionId: 'auctionId1', - sizes: [[100, 200]], + it('should return false on empty sizes (backward compatibility)', () => { + expect(spec.isBidRequestValid({ + sizes: [], params: { - publisher: 'crazy publisher key äÖÜ', - placement: 'placement1' + publisher: 'test', + placement: '1234' } - }, - ]; + })).to.be.false; + }); - const result = spec.buildRequests(bidRequests); + it('should return false on missing params', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + })).to.be.false; + }); - expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, encodeURIComponent(bidRequests[0].params.publisher))); - }); + it('should return false on invalid params', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: 'bar' + })).to.be.false; + }); + + it('should return false on empty params', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: {} + })).to.be.false; + }); + + it('should return false on missing publisher', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: { + placement: '1234' + } + })).to.be.false; + }); - it('should handle empty bidRequests', function () { - expect(spec.buildRequests([])).to.deep.equal([]); + it('should return false on missing placement', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: { + publisher: 'test' + } + })).to.be.false; + }); }); - }); - describe('interpretResponse', function () { - it('should correctly interpret the server response', function () { - const serverResponse = { - body: { - bid: { + describe('buildRequests', () => { + it('should send one bid request per ad unit to the endpoint via POST', () => { + const bidRequests = [ + { + bidder: BIDDER_CODE, bidId: 'bidId1', - price: 0.12, - net: true, - currency: 'EUR', - ttl: 123 + adUnitCode: 'adUnitCode1', + transactionId: 'transactionId1', + auctionId: 'auctionId1', + mediaTypes: { + banner: { + sizes: [[100, 200], [300, 400]] + } + }, + params: { + publisher: 'publisher1', + placement: 'placement1' + } }, - creative: { - id: 'creativeId1', - width: 100, - height: 200, - html: '
Hello World
' + { + bidder: BIDDER_CODE, + bidId: 'bidId2', + adUnitCode: 'adUnitCode2', + transactionId: 'transactionId2', + auctionId: 'auctionId2', + mediaTypes: { + banner: { + sizes: [[500, 600]] + } + }, + params: { + publisher: 'publisher2', + placement: 'placement2' + } } - } - }; + ]; - const result = spec.interpretResponse(serverResponse); - - expect(result).to.deep.equal([ - { - requestId: serverResponse.body.bid.bidId, - cpm: serverResponse.body.bid.price, - netRevenue: serverResponse.body.bid.net, - currency: serverResponse.body.bid.currency, - ttl: serverResponse.body.bid.ttl, - creativeId: serverResponse.body.creative.id, - width: serverResponse.body.creative.width, - height: serverResponse.body.creative.height, - ad: serverResponse.body.creative.html - } - ]); - }); + const result = spec.buildRequests(bidRequests); + expect(result.length).to.equal(2); - it('should handle empty serverResponse', function () { - expect(spec.interpretResponse({})).to.deep.equal([]); - }); + expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, bidRequests[0].params.publisher)); + expect(result[0].method).to.equal(ENDPOINT_METHOD); + expect(result[0].data).to.deep.equal({ + bidId: bidRequests[0].bidId, + auctionId: bidRequests[0].auctionId, + transactionId: bidRequests[0].transactionId, + adUnitCode: bidRequests[0].adUnitCode, + pageUrl: extractTopWindowUrlFromBidRequest(bidRequests[0]), + referrer: extractTopWindowReferrerFromBidRequest(bidRequests[0]), + sizes: extractSizesFromBidRequest(bidRequests[0]), + params: extractParamsFromBidRequest(bidRequests[0]), + gdpr: null + }); - it('should handle missing bid', function () { - expect(spec.interpretResponse({ - body: { - creative: {} - } - })).to.deep.equal([]); + expect(result[1].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, bidRequests[1].params.publisher)); + expect(result[1].method).to.equal(ENDPOINT_METHOD); + expect(result[1].data).to.deep.equal({ + bidId: bidRequests[1].bidId, + auctionId: bidRequests[1].auctionId, + transactionId: bidRequests[1].transactionId, + adUnitCode: bidRequests[1].adUnitCode, + pageUrl: extractTopWindowUrlFromBidRequest(bidRequests[1]), + referrer: extractTopWindowReferrerFromBidRequest(bidRequests[1]), + sizes: extractSizesFromBidRequest(bidRequests[1]), + params: extractParamsFromBidRequest(bidRequests[1]), + gdpr: null + }); + }); + + it('should pass gdpr informations', () => { + const bidderRequest = { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true + } + }; + + const bidRequests = [ + { + bidder: BIDDER_CODE, + bidId: 'bidId3', + adUnitCode: 'adUnitCode3', + transactionId: 'transactionId3', + auctionId: 'auctionId3', + mediaTypes: { + banner: { + sizes: [[100, 200], [300, 400]] + } + }, + params: { + publisher: 'publisher3', + placement: 'placement3' + } + } + ]; + + const result = spec.buildRequests(bidRequests, bidderRequest); + expect(result.length).to.equal(1); + expect(result[0].data.gdpr).to.deep.equal(extractGdprFromBidderRequest(bidderRequest)); + }); + + it('should encode publisher param in endpoint url', () => { + const bidRequests = [ + { + bidder: BIDDER_CODE, + bidId: 'bidId1', + adUnitCode: 'adUnitCode1', + transactionId: 'transactionId1', + auctionId: 'auctionId1', + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: { + publisher: 'crazy publisher key äÖÜ', + placement: 'placement1' + } + }, + ]; + + const result = spec.buildRequests(bidRequests); + expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, encodeURIComponent(bidRequests[0].params.publisher))); + }); + + it('should handle empty bidRequests', () => { + expect(spec.buildRequests([])).to.deep.equal([]); + }); }); - it('should handle missing creative', function () { - expect(spec.interpretResponse({ - body: { - bid: {} - } - })).to.deep.equal([]); + describe('interpretResponse', () => { + it('should correctly interpret the server response', () => { + const serverResponse = { + body: { + bid: { + bidId: 'bidId1', + price: 0.12, + net: true, + currency: 'EUR', + ttl: 123 + }, + creative: { + id: 'creativeId1', + width: 100, + height: 200, + html: '
Hello World
' + } + } + }; + + const result = spec.interpretResponse(serverResponse); + expect(result).to.deep.equal([ + { + requestId: serverResponse.body.bid.bidId, + cpm: serverResponse.body.bid.price, + netRevenue: serverResponse.body.bid.net, + currency: serverResponse.body.bid.currency, + ttl: serverResponse.body.bid.ttl, + creativeId: serverResponse.body.creative.id, + width: serverResponse.body.creative.width, + height: serverResponse.body.creative.height, + ad: serverResponse.body.creative.html + } + ]); + }); + + it('should handle empty serverResponse', () => { + expect(spec.interpretResponse({})).to.deep.equal([]); + }); + + it('should handle missing bid', () => { + expect(spec.interpretResponse({ + body: { + creative: {} + } + })).to.deep.equal([]); + }); + + it('should handle missing creative', () => { + expect(spec.interpretResponse({ + body: { + bid: {} + } + })).to.deep.equal([]); + }); }); }); }); diff --git a/test/spec/modules/advangelistsBidAdapter_spec.js b/test/spec/modules/advangelistsBidAdapter_spec.js index fbdfc9f30ee..2b9615fb572 100755 --- a/test/spec/modules/advangelistsBidAdapter_spec.js +++ b/test/spec/modules/advangelistsBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/advangelistsBidAdapter'; -import { BANNER, VIDEO } from 'src/mediaTypes'; +import { spec } from 'modules/advangelistsBidAdapter.js'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; describe('advangelistsBidAdapter', function () { let bidRequests; diff --git a/test/spec/modules/advenueBidAdapter_spec.js b/test/spec/modules/advenueBidAdapter_spec.js index f6ffb277bf9..2d7739361b4 100644 --- a/test/spec/modules/advenueBidAdapter_spec.js +++ b/test/spec/modules/advenueBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/advenueBidAdapter'; +import {spec} from '../../../modules/advenueBidAdapter.js'; describe('AdvenueAdapter', function () { let bid = { @@ -38,7 +38,7 @@ describe('AdvenueAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//ssp.advenuemedia.co.uk/?c=o&m=multi'); + expect(serverRequest.url).to.equal('https://ssp.advenuemedia.co.uk/?c=o&m=multi'); }); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; diff --git a/test/spec/modules/advertlyBidAdapter_spec.js b/test/spec/modules/advertlyBidAdapter_spec.js new file mode 100755 index 00000000000..7825f11948a --- /dev/null +++ b/test/spec/modules/advertlyBidAdapter_spec.js @@ -0,0 +1,159 @@ +import { expect } from 'chai'; +import { spec } from 'modules/advertlyBidAdapter.js'; + +const ENDPOINT = 'https://api.advertly.com/www/admin/plugins/Prebid/getAd.php'; + +describe('The Advertly bidding adapter', function () { + describe('isBidRequestValid', function () { + it('should return false when given an invalid bid', function () { + const bid = { + bidder: 'advertly', + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(false); + }); + + it('should return true when given a publisherId in bid', function () { + const bid = { + bidder: 'advertly', + params: { + publisherId: 2 + }, + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(true); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + 'bidder': 'advertly', + 'params': { + 'publisherId': 2 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ] + }]; + + const request = spec.buildRequests(bidRequests); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('check endpoint url', function () { + expect(request.url).to.equal(ENDPOINT) + }); + + it('sets the proper banner object', function () { + expect(bidRequests[0].params.publisherId).to.equal(2); + }) + }); + const response = { + body: [ + { + 'requestId': '2ee937f15015c6', + 'cpm': '0.2000', + 'width': 300, + 'height': 600, + 'creativeId': '4', + 'currency': 'USD', + 'netRevenue': true, + 'ad': 'ads.html', + 'mediaType': 'banner' + }, + { + 'requestId': '3e1af92622bdc', + 'cpm': '0.2000', + 'creativeId': '4', + 'context': 'outstream', + 'currency': 'USD', + 'netRevenue': true, + 'vastUrl': 'tezt.xml', + 'width': 640, + 'height': 480, + 'mediaType': 'video' + }] + }; + + const request = [ + { + 'bidder': 'advertly', + 'params': { + 'publisherId': 2 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 600] + ] + } + }, + 'bidId': '2ee937f15015c6', + 'src': 'client', + }, + { + 'bidder': 'advertly', + 'params': { + 'publisherId': 2 + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [ + [640, 480] + ] + } + }, + 'bidId': '3e1af92622bdc', + 'src': 'client', + } + ]; + + describe('interpretResponse', function () { + it('return empty array when no ad found', function () { + const response = {}; + const request = { bidRequests: [] }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('check response for banner and video', function () { + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(2); + expect(bids[0].requestId).to.equal('2ee937f15015c6'); + expect(bids[0].cpm).to.equal('0.2000'); + expect(bids[1].cpm).to.equal('0.2000'); + expect(bids[0].width).to.equal(300); + expect(bids[0].height).to.equal(600); + expect(bids[1].vastUrl).to.not.equal(''); + expect(bids[0].ad).to.not.equal(''); + expect(bids[1].adResponse).to.not.equal(''); + expect(bids[1].renderer).not.to.be.an('undefined'); + }); + }); + + describe('On winning bid', function () { + const bids = spec.interpretResponse(response, request); + spec.onBidWon(bids); + }); + + describe('On bid Time out', function () { + const bids = spec.interpretResponse(response, request); + spec.onTimeout(bids); + }); + + describe('user sync', function () { + it('to check the user sync iframe', function () { + let syncs = spec.getUserSyncs({ + iframeEnabled: true + }); + expect(syncs).to.not.be.an('undefined'); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + }); + }); +}); diff --git a/test/spec/modules/adxcgAnalyticsAdapter_spec.js b/test/spec/modules/adxcgAnalyticsAdapter_spec.js index 605da3bd6bc..a796e7e966d 100644 --- a/test/spec/modules/adxcgAnalyticsAdapter_spec.js +++ b/test/spec/modules/adxcgAnalyticsAdapter_spec.js @@ -1,23 +1,17 @@ -import adxcgAnalyticsAdapter from 'modules/adxcgAnalyticsAdapter'; +import adxcgAnalyticsAdapter from 'modules/adxcgAnalyticsAdapter.js'; import { expect } from 'chai'; import adapterManager from 'src/adapterManager.js'; +import { server } from 'test/mocks/xhr.js'; let events = require('src/events'); let constants = require('src/constants.json'); describe('adxcg analytics adapter', function () { - let xhr; - let requests; - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); sinon.stub(events, 'getEvents').returns([]); }); afterEach(function () { - xhr.restore(); events.getEvents.restore(); }); @@ -193,9 +187,9 @@ describe('adxcg analytics adapter', function () { // Step 5: Send auction end event events.emit(constants.EVENTS.AUCTION_END, {}); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - let realAfterBid = JSON.parse(requests[0].requestBody); + let realAfterBid = JSON.parse(server.requests[0].requestBody); expect(realAfterBid).to.deep.equal(expectedAfterBid); @@ -204,8 +198,8 @@ describe('adxcg analytics adapter', function () { // Step 6: Send auction bid won event events.emit(constants.EVENTS.BID_WON, wonRequest); - expect(requests.length).to.equal(2); - let winEventData = JSON.parse(requests[1].requestBody); + expect(server.requests.length).to.equal(2); + let winEventData = JSON.parse(server.requests[1].requestBody); expect(winEventData).to.deep.equal(wonExpect); }); diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 5bac9523b18..306914960c3 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -1,400 +1,548 @@ -import { expect } from 'chai' -import * as url from 'src/url' -import { spec } from 'modules/adxcgBidAdapter' +import {expect} from 'chai'; +import {spec} from 'modules/adxcgBidAdapter.js'; +import {deepClone, parseUrl} from 'src/utils.js'; describe('AdxcgAdapter', function () { - describe('isBidRequestValid', function () { - let bidBanner = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } - - let bidVideo = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1', - 'api': [2], - 'protocols': [1, 2], - 'mimes': ['video/mp4', 'video/x-flv'], - 'maxduration': 30 - }, - 'mediaTypes': { - 'video': { - 'context': 'instream' + let bidBanner = { + bidder: 'adxcg', + params: { + adzoneid: '1' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [640, 360], + [1, 1] + ] + } + }, + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: '1d1a030790a475' + }; + + let bidVideo = { + bidder: 'adxcg', + params: { + adzoneid: '20', + video: { + api: [2], + protocols: [1, 2], + mimes: ['video/mp4'], + maxduration: 30 + } + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]] + } + }, + adUnitCode: 'adunit-code', + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: '1d1a030790a475' + }; + + let bidNative = { + bidder: 'adxcg', + params: { + adzoneid: '2379' + }, + mediaTypes: { + native: { + image: { + sendId: false, + required: true, + sizes: [80, 80] + }, + title: { + required: true, + len: 75 + }, + body: { + required: true, + len: 200 + }, + sponsoredBy: { + required: false, + len: 20 } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } + } + }, + adUnitCode: 'adunit-code', + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: '1d1a030790a475' + }; + + describe('isBidRequestValid', function () { + it('should return true when required params found bidNative', function () { + expect(spec.isBidRequestValid(bidNative)).to.equal(true); + }); + + it('should return true when required params found bidVideo', function () { + expect(spec.isBidRequestValid(bidVideo)).to.equal(true); + }); - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidBanner)).to.equal(true) - }) + it('should return true when required params found bidBanner', function () { + expect(spec.isBidRequestValid(bidBanner)).to.equal(true); + }); it('should return true when required params not found', function () { - expect(spec.isBidRequestValid({})).to.be.false - }) + expect(spec.isBidRequestValid({})).to.be.false; + }); it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bidBanner) - delete bid.params - bid.params = {} - expect(spec.isBidRequestValid(bid)).to.equal(false) - }) + let bid = Object.assign({}, bidBanner); + delete bid.params; + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); it('should return true when required video params not found', function () { - const simpleVideo = JSON.parse(JSON.stringify(bidVideo)) - simpleVideo.params.adzoneid = 123 - expect(spec.isBidRequestValid(simpleVideo)).to.be.false - simpleVideo.params.mimes = [1, 2, 3] - expect(spec.isBidRequestValid(simpleVideo)).to.be.false - simpleVideo.params.mimes = 'bad type' - expect(spec.isBidRequestValid(simpleVideo)).to.be.false - }) - }) + const simpleVideo = JSON.parse(JSON.stringify(bidVideo)); + simpleVideo.params.adzoneid = 123; + expect(spec.isBidRequestValid(simpleVideo)).to.be.false; + simpleVideo.params.mimes = [1, 2, 3]; + expect(spec.isBidRequestValid(simpleVideo)).to.be.false; + simpleVideo.params.mimes = 'bad type'; + expect(spec.isBidRequestValid(simpleVideo)).to.be.false; + }); + }); describe('request function http', function () { - let bid = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } - - it('creates a valid adxcg request url', function () { - let request = spec.buildRequests([bid]) - expect(request).to.exist - expect(request.method).to.equal('GET') - let parsedRequestUrl = url.parse(request.url) - expect(parsedRequestUrl.hostname).to.equal('hbp.adxcg.net') - expect(parsedRequestUrl.pathname).to.equal('/get/adi') - - let query = parsedRequestUrl.search - expect(query.renderformat).to.equal('javascript') - expect(query.ver).to.equal('r20180703PB10') - expect(query.source).to.equal('pbjs10') - expect(query.pbjs).to.equal('$prebid.version$') - expect(query.adzoneid).to.equal('1') - expect(query.format).to.equal('300x250|640x360|1x1') - expect(query.jsonp).to.be.undefined - expect(query.prebidBidIds).to.equal('84ab500420319d') - }) - }) + it('creates a valid adxcg request url bidBanner', function () { + let request = spec.buildRequests([bidBanner]); + expect(request).to.exist; + expect(request.method).to.equal('GET'); + let parsedRequestUrl = parseUrl(request.url); + expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); + expect(parsedRequestUrl.pathname).to.equal('/get/adi'); + + let query = parsedRequestUrl.search; + expect(query.renderformat).to.equal('javascript'); + expect(query.ver).to.equal('r20191128PB30'); + expect(query.source).to.equal('pbjs10'); + expect(query.pbjs).to.equal('$prebid.version$'); + expect(query.adzoneid).to.equal('1'); + expect(query.format).to.equal('300x250|640x360|1x1'); + expect(query.jsonp).to.be.undefined; + expect(query.prebidBidIds).to.equal('84ab500420319d'); + expect(query.bidfloors).to.equal('0'); + + expect(query).to.have.property('secure'); + expect(query).to.have.property('uw'); + expect(query).to.have.property('uh'); + expect(query).to.have.property('dpr'); + expect(query).to.have.property('bt'); + expect(query).to.have.property('cookies'); + expect(query).to.have.property('tz'); + expect(query).to.have.property('dt'); + expect(query).to.have.property('iob'); + expect(query).to.have.property('rndid'); + expect(query).to.have.property('ref'); + expect(query).to.have.property('url'); + }); + + it('creates a valid adxcg request url bidVideo', function () { + let request = spec.buildRequests([bidVideo]); + expect(request).to.exist; + expect(request.method).to.equal('GET'); + let parsedRequestUrl = parseUrl(request.url); + expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); + expect(parsedRequestUrl.pathname).to.equal('/get/adi'); + + let query = parsedRequestUrl.search; + // general part + expect(query.renderformat).to.equal('javascript'); + expect(query.ver).to.equal('r20191128PB30'); + expect(query.source).to.equal('pbjs10'); + expect(query.pbjs).to.equal('$prebid.version$'); + expect(query.adzoneid).to.equal('20'); + expect(query.format).to.equal('640x480'); + expect(query.jsonp).to.be.undefined; + expect(query.prebidBidIds).to.equal('84ab500420319d'); + expect(query.bidfloors).to.equal('0'); + + expect(query).to.have.property('secure'); + expect(query).to.have.property('uw'); + expect(query).to.have.property('uh'); + expect(query).to.have.property('dpr'); + expect(query).to.have.property('bt'); + expect(query).to.have.property('cookies'); + expect(query).to.have.property('tz'); + expect(query).to.have.property('dt'); + expect(query).to.have.property('iob'); + expect(query).to.have.property('rndid'); + expect(query).to.have.property('ref'); + expect(query).to.have.property('url'); + + // video specific part + expect(query['video.maxduration.0']).to.equal('30'); + expect(query['video.mimes.0']).to.equal('video/mp4'); + expect(query['video.context.0']).to.equal('instream'); + }); + + it('creates a valid adxcg request url bidNative', function () { + let request = spec.buildRequests([bidNative]); + expect(request).to.exist; + expect(request.method).to.equal('GET'); + let parsedRequestUrl = parseUrl(request.url); + expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); + expect(parsedRequestUrl.pathname).to.equal('/get/adi'); + + let query = parsedRequestUrl.search; + expect(query.renderformat).to.equal('javascript'); + expect(query.ver).to.equal('r20191128PB30'); + expect(query.source).to.equal('pbjs10'); + expect(query.pbjs).to.equal('$prebid.version$'); + expect(query.adzoneid).to.equal('2379'); + expect(query.format).to.equal('0x0'); + expect(query.jsonp).to.be.undefined; + expect(query.prebidBidIds).to.equal('84ab500420319d'); + expect(query.bidfloors).to.equal('0'); + + expect(query).to.have.property('secure'); + expect(query).to.have.property('uw'); + expect(query).to.have.property('uh'); + expect(query).to.have.property('dpr'); + expect(query).to.have.property('bt'); + expect(query).to.have.property('cookies'); + expect(query).to.have.property('tz'); + expect(query).to.have.property('dt'); + expect(query).to.have.property('iob'); + expect(query).to.have.property('rndid'); + expect(query).to.have.property('ref'); + expect(query).to.have.property('url'); + }); + }); describe('gdpr compliance', function () { - let bid = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } - it('should send GDPR Consent data if gdprApplies', function () { - let request = spec.buildRequests([bid], {gdprConsent: {gdprApplies: true, consentString: 'consentDataString'}}) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search + let request = spec.buildRequests([bidBanner], { + gdprConsent: { + gdprApplies: true, + consentString: 'consentDataString' + } + }); + let parsedRequestUrl = parseUrl(request.url); + let query = parsedRequestUrl.search; - expect(query.gdpr).to.equal('1') - expect(query.gdpr_consent).to.equal('consentDataString') - }) + expect(query.gdpr).to.equal('1'); + expect(query.gdpr_consent).to.equal('consentDataString'); + }); it('should not send GDPR Consent data if gdprApplies is false or undefined', function () { - let request = spec.buildRequests([bid], { + let request = spec.buildRequests([bidBanner], { gdprConsent: { gdprApplies: false, consentString: 'consentDataString' } - }) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search + }); + let parsedRequestUrl = parseUrl(request.url); + let query = parsedRequestUrl.search; - expect(query.gdpr).to.be.undefined - expect(query.gdpr_consent).to.be.undefined - }) - }) + expect(query.gdpr).to.be.undefined; + expect(query.gdpr_consent).to.be.undefined; + }); + }); describe('userid pubcid should be passed to querystring', function () { - let bid = [{ - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - }] + let bidderRequests = {}; + let bid = deepClone([bidBanner]); + bid[0].userId = {pubcid: 'pubcidabcd'}; + + it('should send pubcid if available', function () { + let request = spec.buildRequests(bid, bidderRequests); + let parsedRequestUrl = parseUrl(request.url); + let query = parsedRequestUrl.search; + expect(query.pubcid).to.equal('pubcidabcd'); + }); + }); + describe('userid tdid should be passed to querystring', function () { + let bid = deepClone([bidBanner]); let bidderRequests = {}; - bid[0].userId = {'pubcid': 'pubcidabcd'}; + bid[0].userId = {tdid: 'tdidabcd'}; it('should send pubcid if available', function () { - let request = spec.buildRequests(bid, bidderRequests) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search - expect(query.pubcid).to.equal('pubcidabcd') - }) - }) + let request = spec.buildRequests(bid, bidderRequests); + let parsedRequestUrl = parseUrl(request.url); + let query = parsedRequestUrl.search; + expect(query.tdid).to.equal('tdidabcd'); + }); + }); - describe('userid tdid should be passed to querystring', function () { - let bid = [{ - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - }] + describe('userid id5id should be passed to querystring', function () { + let bid = deepClone([bidBanner]); + let bidderRequests = {}; + + bid[0].userId = {id5id: 'id5idsample'}; + it('should send pubcid if available', function () { + let request = spec.buildRequests(bid, bidderRequests); + let parsedRequestUrl = parseUrl(request.url); + let query = parsedRequestUrl.search; + expect(query.id5id).to.equal('id5idsample'); + }); + }); + + describe('userid idl_env should be passed to querystring', function () { + let bid = deepClone([bidBanner]); let bidderRequests = {}; - bid[0].userId = {'tdid': 'tdidabcd'}; + bid[0].userId = {idl_env: 'idl_envsample'}; it('should send pubcid if available', function () { - let request = spec.buildRequests(bid, bidderRequests) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search - expect(query.tdid).to.equal('tdidabcd'); - }) - }) + let request = spec.buildRequests(bid, bidderRequests); + let parsedRequestUrl = parseUrl(request.url); + let query = parsedRequestUrl.search; + expect(query.idl_env).to.equal('idl_envsample'); + }); + }); describe('response handler', function () { let BIDDER_REQUEST = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' + bidder: 'adxcg', + params: { + adzoneid: '1' }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } - - let BANNER_RESPONSE = - { - body: [{ - 'bidId': '84ab500420319d', - 'bidderCode': 'adxcg', - 'width': 300, - 'height': 250, - 'creativeId': '42', - 'cpm': 0.45, - 'currency': 'USD', - 'netRevenue': true, - 'ad': '' - }], - header: {'someheader': 'fakedata'} - } - - let BANNER_RESPONSE_WITHDEALID = - { - body: [{ - 'bidId': '84ab500420319d', - 'bidderCode': 'adxcg', - 'width': 300, - 'height': 250, - 'deal_id': '7722', - 'creativeId': '42', - 'cpm': 0.45, - 'currency': 'USD', - 'netRevenue': true, - 'ad': '' - }], - header: {'someheader': 'fakedata'} - } - - let VIDEO_RESPONSE = - { - body: [{ - 'bidId': '84ab500420319d', - 'bidderCode': 'adxcg', - 'width': 640, - 'height': 360, - 'creativeId': '42', - 'cpm': 0.45, - 'currency': 'USD', - 'netRevenue': true, - 'vastUrl': 'vastContentUrl' - }], - header: {'someheader': 'fakedata'} - } - - let NATIVE_RESPONSE = - { - body: [{ - 'bidId': '84ab500420319d', - 'bidderCode': 'adxcg', - 'width': 0, - 'height': 0, - 'creativeId': '42', - 'cpm': 0.45, - 'currency': 'USD', - 'netRevenue': true, - 'nativeResponse': { - 'assets': [{ - 'id': 1, - 'required': 0, - 'title': { - 'text': 'titleContent' - } - }, { - 'id': 2, - 'required': 0, - 'img': { - 'url': 'imageContent', - 'w': 600, - 'h': 600 - } - }, { - 'id': 3, - 'required': 0, - 'data': { - 'label': 'DESC', - 'value': 'descriptionContent' - } - }, { - 'id': 0, - 'required': 0, - 'data': { - 'label': 'SPONSORED', - 'value': 'sponsoredByContent' - } - }, { - 'id': 5, - 'required': 0, - 'icon': { - 'url': 'iconContent', - 'w': 400, - 'h': 400 + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [640, 360], + [1, 1] + ] + } + }, + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: '1d1a030790a475' + }; + + let BANNER_RESPONSE = { + body: [ + { + bidId: '84ab500420319d', + bidderCode: 'adxcg', + width: 300, + height: 250, + creativeId: '42', + cpm: 0.45, + currency: 'USD', + netRevenue: true, + ad: '' + } + ], + header: {someheader: 'fakedata'} + }; + + let BANNER_RESPONSE_WITHDEALID = { + body: [ + { + bidId: '84ab500420319d', + bidderCode: 'adxcg', + width: 300, + height: 250, + deal_id: '7722', + creativeId: '42', + cpm: 0.45, + currency: 'USD', + netRevenue: true, + ad: '' + } + ], + header: {someheader: 'fakedata'} + }; + + let VIDEO_RESPONSE = { + body: [ + { + bidId: '84ab500420319d', + bidderCode: 'adxcg', + width: 640, + height: 360, + creativeId: '42', + cpm: 0.45, + currency: 'USD', + netRevenue: true, + vastUrl: 'vastContentUrl' + } + ], + header: {someheader: 'fakedata'} + }; + + let NATIVE_RESPONSE = { + body: [ + { + bidId: '84ab500420319d', + bidderCode: 'adxcg', + width: 0, + height: 0, + creativeId: '42', + cpm: 0.45, + currency: 'USD', + netRevenue: true, + nativeResponse: { + assets: [ + { + id: 1, + required: 0, + title: { + text: 'titleContent' + } + }, + { + id: 2, + required: 0, + img: { + url: 'imageContent', + w: 600, + h: 600 + } + }, + { + id: 3, + required: 0, + data: { + label: 'DESC', + value: 'descriptionContent' + } + }, + { + id: 0, + required: 0, + data: { + label: 'SPONSORED', + value: 'sponsoredByContent' + } + }, + { + id: 5, + required: 0, + icon: { + url: 'iconContent', + w: 400, + h: 400 + } } - }], - 'link': { - 'url': 'linkContent' + ], + link: { + url: 'linkContent' }, - 'imptrackers': ['impressionTracker1', 'impressionTracker2'] + imptrackers: ['impressionTracker1', 'impressionTracker2'] } - }], - header: {'someheader': 'fakedata'} - } + } + ], + header: {someheader: 'fakedata'} + }; it('handles regular responses', function () { - let result = spec.interpretResponse(BANNER_RESPONSE, BIDDER_REQUEST) - - expect(result).to.have.lengthOf(1) - - expect(result[0]).to.exist - expect(result[0].width).to.equal(300) - expect(result[0].height).to.equal(250) - expect(result[0].creativeId).to.equal(42) - expect(result[0].cpm).to.equal(0.45) - expect(result[0].ad).to.equal('') - expect(result[0].currency).to.equal('USD') - expect(result[0].netRevenue).to.equal(true) - expect(result[0].ttl).to.equal(300) - expect(result[0].dealId).to.not.exist - }) + let result = spec.interpretResponse(BANNER_RESPONSE, BIDDER_REQUEST); + + expect(result).to.have.lengthOf(1); + + expect(result[0]).to.exist; + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].creativeId).to.equal(42); + expect(result[0].cpm).to.equal(0.45); + expect(result[0].ad).to.equal(''); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].ttl).to.equal(300); + expect(result[0].dealId).to.not.exist; + }); it('handles regular responses with dealid', function () { - let result = spec.interpretResponse(BANNER_RESPONSE_WITHDEALID, BIDDER_REQUEST) - - expect(result).to.have.lengthOf(1) - - expect(result[0].width).to.equal(300) - expect(result[0].height).to.equal(250) - expect(result[0].creativeId).to.equal(42) - expect(result[0].cpm).to.equal(0.45) - expect(result[0].ad).to.equal('') - expect(result[0].currency).to.equal('USD') - expect(result[0].netRevenue).to.equal(true) - expect(result[0].ttl).to.equal(300) - }) + let result = spec.interpretResponse( + BANNER_RESPONSE_WITHDEALID, + BIDDER_REQUEST + ); + + expect(result).to.have.lengthOf(1); + + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].creativeId).to.equal(42); + expect(result[0].cpm).to.equal(0.45); + expect(result[0].ad).to.equal(''); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].ttl).to.equal(300); + }); it('handles video responses', function () { - let result = spec.interpretResponse(VIDEO_RESPONSE, BIDDER_REQUEST) - expect(result).to.have.lengthOf(1) - - expect(result[0].width).to.equal(640) - expect(result[0].height).to.equal(360) - expect(result[0].mediaType).to.equal('video') - expect(result[0].creativeId).to.equal(42) - expect(result[0].cpm).to.equal(0.45) - expect(result[0].vastUrl).to.equal('vastContentUrl') - expect(result[0].currency).to.equal('USD') - expect(result[0].netRevenue).to.equal(true) - expect(result[0].ttl).to.equal(300) - }) + let result = spec.interpretResponse(VIDEO_RESPONSE, BIDDER_REQUEST); + expect(result).to.have.lengthOf(1); + + expect(result[0].width).to.equal(640); + expect(result[0].height).to.equal(360); + expect(result[0].mediaType).to.equal('video'); + expect(result[0].creativeId).to.equal(42); + expect(result[0].cpm).to.equal(0.45); + expect(result[0].vastUrl).to.equal('vastContentUrl'); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].ttl).to.equal(300); + }); it('handles native responses', function () { - let result = spec.interpretResponse(NATIVE_RESPONSE, BIDDER_REQUEST) - - expect(result[0].width).to.equal(0) - expect(result[0].height).to.equal(0) - expect(result[0].mediaType).to.equal('native') - expect(result[0].creativeId).to.equal(42) - expect(result[0].cpm).to.equal(0.45) - expect(result[0].currency).to.equal('USD') - expect(result[0].netRevenue).to.equal(true) - expect(result[0].ttl).to.equal(300) - - expect(result[0].native.clickUrl).to.equal('linkContent') - expect(result[0].native.impressionTrackers).to.deep.equal(['impressionTracker1', 'impressionTracker2']) - expect(result[0].native.title).to.equal('titleContent') - - expect(result[0].native.image.url).to.equal('imageContent') - expect(result[0].native.image.height).to.equal(600) - expect(result[0].native.image.width).to.equal(600) - - expect(result[0].native.icon.url).to.equal('iconContent') - expect(result[0].native.icon.height).to.equal(400) - expect(result[0].native.icon.width).to.equal(400) - - expect(result[0].native.body).to.equal('descriptionContent') - expect(result[0].native.sponsoredBy).to.equal('sponsoredByContent') - }) + let result = spec.interpretResponse(NATIVE_RESPONSE, BIDDER_REQUEST); + + expect(result[0].width).to.equal(0); + expect(result[0].height).to.equal(0); + expect(result[0].mediaType).to.equal('native'); + expect(result[0].creativeId).to.equal(42); + expect(result[0].cpm).to.equal(0.45); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].ttl).to.equal(300); + + expect(result[0].native.clickUrl).to.equal('linkContent'); + expect(result[0].native.impressionTrackers).to.deep.equal([ + 'impressionTracker1', + 'impressionTracker2' + ]); + expect(result[0].native.title).to.equal('titleContent'); + + expect(result[0].native.image.url).to.equal('imageContent'); + expect(result[0].native.image.height).to.equal(600); + expect(result[0].native.image.width).to.equal(600); + + expect(result[0].native.icon.url).to.equal('iconContent'); + expect(result[0].native.icon.height).to.equal(400); + expect(result[0].native.icon.width).to.equal(400); + + expect(result[0].native.body).to.equal('descriptionContent'); + expect(result[0].native.sponsoredBy).to.equal('sponsoredByContent'); + }); it('handles nobid responses', function () { - let response = [] - let bidderRequest = BIDDER_REQUEST + let response = []; + let bidderRequest = BIDDER_REQUEST; - let result = spec.interpretResponse(response, bidderRequest) - expect(result.length).to.equal(0) - }) - }) + let result = spec.interpretResponse(response, bidderRequest); + expect(result.length).to.equal(0); + }); + }); describe('getUserSyncs', function () { let syncoptionsIframe = { - 'iframeEnabled': 'true' - } + iframeEnabled: 'true' + }; it('should return iframe sync option', function () { - expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe') - expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('//cdn.adxcg.net/pb-sync.html') - }) - }) -}) + expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe'); + expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal( + 'https://cdn.adxcg.net/pb-sync.html' + ); + }); + }); +}); diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index 7edb9416b03..3573681dd17 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -1,19 +1,35 @@ import { expect } from 'chai'; -import { parse } from '../../../src/url'; -import { spec } from 'modules/adyoulikeBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/adyoulikeBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('Adyoulike Adapter', function () { - const canonicalUrl = 'http://canonical.url/?t=%26'; + const canonicalUrl = 'https://canonical.url/?t=%26'; + const referrerUrl = 'http://referrer.url/?param=value'; const defaultDC = 'hb-api'; + const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + const bidderRequest = { + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true + }, + refererInfo: {referer: referrerUrl} + }; const bidRequestWithEmptyPlacement = [ { 'bidId': 'bid_id_0', 'bidder': 'adyoulike', 'placementCode': 'adunit/hb-0', 'params': {}, - 'sizes': '300x250' + 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250', '300x600'] + } + } } ]; const bidRequestWithEmptySizes = { @@ -39,6 +55,11 @@ describe('Adyoulike Adapter', function () { 'placement': 'placement_0' }, 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250'] + } + }, 'transactionId': 'bid_id_0_transaction_id' } ]; @@ -53,6 +74,11 @@ describe('Adyoulike Adapter', function () { 'DC': 'fra01' }, 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250'] + } + }, 'transactionId': 'bid_id_0_transaction_id' } ]; @@ -66,6 +92,11 @@ describe('Adyoulike Adapter', function () { 'placement': 'placement_0' }, 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250'] + } + }, 'transactionId': 'bid_id_0_transaction_id' }, { @@ -76,6 +107,11 @@ describe('Adyoulike Adapter', function () { 'placement': 'placement_1' }, 'sizes': [[300, 600]], + 'mediaTypes': + { 'banner': + {'sizes': ['300x600'] + } + }, 'transactionId': 'bid_id_1_transaction_id' }, { @@ -97,6 +133,33 @@ describe('Adyoulike Adapter', function () { } ]; + const requestDataOnePlacement = { + 'bid_id_0': + { 'PlacementID': 'e622af275681965d3095808561a1e510', + 'TransactionID': '1bca18cc-c0fe-439b-88c2-8247d3448f22', + 'Width': 300, + 'Height': 600, + 'AvailableSizes': '300x600' + } + } + + const requestDataMultiPlacement = { + 'bid_id_0': + { 'PlacementID': 'e622af275681965d3095808561a1e510', + 'TransactionID': '1bca18cc-c0fe-439b-88c2-8247d3448f22', + 'Width': 300, + 'Height': 600, + 'AvailableSizes': '300x600' + }, + 'bid_id_1': + { 'PlacementID': 'e622af275681965d3095808561a1e510', + 'TransactionID': 'e63b2d86-ca60-4167-9cf1-497607079634', + 'Width': 400, + 'Height': 250, + 'AvailableSizes': '300x250' + } + } + const responseWithEmptyPlacement = [ { 'Placement': 'placement_0' @@ -108,8 +171,7 @@ describe('Adyoulike Adapter', function () { 'Placement': 'placement_0', 'Ad': 'placement_0', 'Price': 0.5, - 'Height': 300, - 'Width': 300, + 'Height': 600, } ]; const responseWithMultiplePlacements = [ @@ -118,16 +180,16 @@ describe('Adyoulike Adapter', function () { 'Placement': 'placement_0', 'Ad': 'placement_0', 'Price': 0.5, - 'Height': 300, - 'Width': 300, + 'Height': 0, // test with wrong value + 'Width': 300 }, { 'BidID': 'bid_id_1', 'Placement': 'placement_1', 'Ad': 'placement_1', 'Price': 0.6, - 'Height': 300, - 'Width': 300, + 'Height': 250 + // 'Width' test with missing value } ]; const adapter = newBidder(spec); @@ -188,8 +250,9 @@ describe('Adyoulike Adapter', function () { canonicalQuery.restore(); }); - it('should add gdpr consent information to the request', function () { + it('should add gdpr/usp consent information to the request', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let uspConsentData = '1YCC'; let bidderRequest = { 'auctionId': '1d1a030790a475', 'bidderRequestId': '22edbae2733bf6', @@ -197,8 +260,10 @@ describe('Adyoulike Adapter', function () { 'gdprConsent': { consentString: consentString, gdprApplies: true - } + }, + 'uspConsent': uspConsentData }; + bidderRequest.bids = bidRequestWithSinglePlacement; const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); @@ -207,15 +272,17 @@ describe('Adyoulike Adapter', function () { expect(payload.gdprConsent).to.exist; expect(payload.gdprConsent.consentString).to.exist.and.to.equal(consentString); expect(payload.gdprConsent.consentRequired).to.exist.and.to.be.true; + expect(payload.uspConsent).to.exist.and.to.equal(uspConsentData); }); it('sends bid request to endpoint with single placement', function () { - const request = spec.buildRequests(bidRequestWithSinglePlacement); + const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint()); expect(request.method).to.equal('POST'); expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl)); + expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl)); expect(payload.Version).to.equal('1.0'); expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0'); @@ -225,7 +292,7 @@ describe('Adyoulike Adapter', function () { it('sends bid request to endpoint with single placement without canonical', function () { canonicalQuery.restore(); - const request = spec.buildRequests(bidRequestWithSinglePlacement); + const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint()); @@ -239,12 +306,13 @@ describe('Adyoulike Adapter', function () { }); it('sends bid request to endpoint with multiple placements', function () { - const request = spec.buildRequests(bidRequestMultiPlacements); + const request = spec.buildRequests(bidRequestMultiPlacements, bidderRequest); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint()); expect(request.method).to.equal('POST'); expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl)); + expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl)); expect(payload.Version).to.equal('1.0'); @@ -259,7 +327,7 @@ describe('Adyoulike Adapter', function () { }); it('sends bid request to endpoint setted by parameters', function () { - const request = spec.buildRequests(bidRequestWithDCPlacement); + const request = spec.buildRequests(bidRequestWithDCPlacement, bidderRequest); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint(`${defaultDC}-fra01`)); @@ -288,30 +356,30 @@ describe('Adyoulike Adapter', function () { it('receive reponse with single placement', function () { serverResponse.body = responseWithSinglePlacement; - let result = spec.interpretResponse(serverResponse, bidRequestWithSinglePlacement); + let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(requestDataOnePlacement) + '}'}); expect(result.length).to.equal(1); expect(result[0].cpm).to.equal(0.5); expect(result[0].ad).to.equal('placement_0'); expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(300); + expect(result[0].height).to.equal(600); }); it('receive reponse with multiple placement', function () { serverResponse.body = responseWithMultiplePlacements; - let result = spec.interpretResponse(serverResponse, bidRequestMultiPlacements); + let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(requestDataMultiPlacement) + '}'}); expect(result.length).to.equal(2); expect(result[0].cpm).to.equal(0.5); expect(result[0].ad).to.equal('placement_0'); expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(300); + expect(result[0].height).to.equal(600); expect(result[1].cpm).to.equal(0.6); expect(result[1].ad).to.equal('placement_1'); - expect(result[1].width).to.equal(300); - expect(result[1].height).to.equal(300); + expect(result[1].width).to.equal(400); + expect(result[1].height).to.equal(250); }); }); }); diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js index 642ac2f0df4..80ecab764e8 100644 --- a/test/spec/modules/ajaBidAdapter_spec.js +++ b/test/spec/modules/ajaBidAdapter_spec.js @@ -1,7 +1,7 @@ -import { spec } from 'modules/ajaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/ajaBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; -const ENDPOINT = '//ad.as.amanad.adtdp.com/v2/prebid'; +const ENDPOINT = 'https://ad.as.amanad.adtdp.com/v2/prebid'; describe('AjaAdapter', function () { const adapter = newBidder(spec); @@ -50,7 +50,7 @@ describe('AjaAdapter', function () { let bidderRequest = { refererInfo: { - referer: 'http://hoge.com' + referer: 'https://hoge.com' } }; @@ -58,7 +58,7 @@ describe('AjaAdapter', function () { const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].url).to.equal(ENDPOINT); expect(requests[0].method).to.equal('GET'); - expect(requests[0].data).to.equal('asi=123456&skt=5&prebid_id=30b31c1838de1e&prebid_ver=$prebid.version$&page_url=http%3A%2F%2Fhoge.com&'); + expect(requests[0].data).to.equal('asi=123456&skt=5&prebid_id=30b31c1838de1e&prebid_ver=$prebid.version$&page_url=https%3A%2F%2Fhoge.com&'); }); }); @@ -77,7 +77,7 @@ describe('AjaAdapter', function () { 'h': 250, 'tag': '
', 'imps': [ - '//as.amanad.adtdp.com/v1/imp' + 'https://as.amanad.adtdp.com/v1/imp' ] } }, @@ -120,7 +120,7 @@ describe('AjaAdapter', function () { 'w': 300, 'h': 250, 'vtag': '', - 'purl': 'http://cdn/player', + 'purl': 'https://cdn/player', 'progress': true, 'loop': false, 'inread': false diff --git a/test/spec/modules/andbeyondBidAdapter_spec.js b/test/spec/modules/andbeyondBidAdapter_spec.js deleted file mode 100644 index f9b0758749b..00000000000 --- a/test/spec/modules/andbeyondBidAdapter_spec.js +++ /dev/null @@ -1,208 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/andbeyondBidAdapter'; -import * as utils from 'src/utils'; - -describe('andbeyond adapter', function () { - const bid1_zone1 = { - bidder: 'andbeyond', - bidId: 'Bid_01', - params: {zoneId: 1, host: 'rtb.andbeyond.com'}, - placementCode: 'ad-unit-1', - sizes: [[300, 250], [300, 200]] - }, bid2_zone2 = { - bidder: 'andbeyond', - bidId: 'Bid_02', - params: {zoneId: 2, host: 'rtb.andbeyond.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid3_host2 = { - bidder: 'andbeyond', - bidId: 'Bid_02', - params: {zoneId: 1, host: 'rtb-private.andbeyond.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid_without_zone = { - bidder: 'andbeyond', - bidId: 'Bid_W', - params: {host: 'rtb-private.andbeyond.com'}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_without_host = { - bidder: 'andbeyond', - bidId: 'Bid_W', - params: {zoneId: 1}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_with_wrong_zoneId = { - bidder: 'andbeyond', - bidId: 'Bid_02', - params: {zoneId: 'wrong id', host: 'rtb.andbeyond.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, usersyncOnlyResponse = { - id: 'nobid1', - ext: { - adk_usersync: ['http://adk.sync.com/sync'] - } - }; - - const bidResponse1 = { - id: 'bid1', - seatbid: [{ - bid: [{ - id: '1', - impid: 'Bid_01', - crid: '100_001', - price: 3.01, - nurl: 'https://rtb.com/win?i=ZjKoPYSFI3Y_0', - adm: '', - w: 300, - h: 250 - }] - }], - cur: 'USD', - ext: { - adk_usersync: ['http://adk.sync.com/sync'] - } - }, bidResponse2 = { - id: 'bid2', - seatbid: [{ - bid: [{ - id: '2', - impid: 'Bid_02', - crid: '100_002', - price: 1.31, - adm: '', - w: 300, - h: 250 - }] - }], - cur: 'USD' - }; - - describe('input parameters validation', function () { - it('empty request shouldn\'t generate exception', function () { - expect(spec.isBidRequestValid({ - bidderCode: 'andbeyond' - })).to.be.equal(false); - }); - - it('request without zone shouldn\'t issue a request', function () { - expect(spec.isBidRequestValid(bid_without_zone)).to.be.equal(false); - }); - - it('request without host shouldn\'t issue a request', function () { - expect(spec.isBidRequestValid(bid_without_host)).to.be.equal(false); - }); - - it('empty request shouldn\'t generate exception', function () { - expect(spec.isBidRequestValid(bid_with_wrong_zoneId)).to.be.equal(false); - }); - }); - - describe('banner request building', function () { - let bidRequest; - before(function () { - let wmock = sinon.stub(utils, 'getTopWindowLocation').callsFake(() => ({ - protocol: 'https:', - hostname: 'example.com', - host: 'example.com', - pathname: '/index.html', - href: 'https://example.com/index.html' - })); - let dntmock = sinon.stub(utils, 'getDNT').callsFake(() => true); - let request = spec.buildRequests([bid1_zone1])[0]; - bidRequest = JSON.parse(request.data.r); - wmock.restore(); - dntmock.restore(); - }); - - it('should be a first-price auction', function () { - expect(bidRequest).to.have.property('at', 1); - }); - - it('should have banner object', function () { - expect(bidRequest.imp[0]).to.have.property('banner'); - }); - - it('should have w/h', function () { - expect(bidRequest.imp[0].banner).to.have.property('format'); - expect(bidRequest.imp[0].banner.format).to.be.eql([{w: 300, h: 250}, {w: 300, h: 200}]); - }); - - it('should respect secure connection', function () { - expect(bidRequest.imp[0]).to.have.property('secure', 1); - }); - - it('should have tagid', function () { - expect(bidRequest.imp[0]).to.have.property('tagid', 'ad-unit-1'); - }); - - it('should create proper site block', function () { - expect(bidRequest.site).to.have.property('domain', 'example.com'); - expect(bidRequest.site).to.have.property('page', 'https://example.com/index.html'); - }); - - it('should fill device with caller macro', function () { - expect(bidRequest).to.have.property('device'); - expect(bidRequest.device).to.have.property('ip', 'caller'); - expect(bidRequest.device).to.have.property('ua', 'caller'); - expect(bidRequest.device).to.have.property('dnt', 1); - }); - }); - - describe('requests routing', function () { - it('should issue a request for each host', function () { - let pbRequests = spec.buildRequests([bid1_zone1, bid3_host2]); - expect(pbRequests).to.have.length(2); - expect(pbRequests[0].url).to.have.string(`//${bid1_zone1.params.host}/`); - expect(pbRequests[1].url).to.have.string(`//${bid3_host2.params.host}/`); - }); - - it('should issue a request for each zone', function () { - let pbRequests = spec.buildRequests([bid1_zone1, bid2_zone2]); - expect(pbRequests).to.have.length(2); - expect(pbRequests[0].data.zone).to.be.equal(bid1_zone1.params.zoneId); - expect(pbRequests[1].data.zone).to.be.equal(bid2_zone2.params.zoneId); - }); - }); - - describe('responses processing', function () { - it('should return fully-initialized banner bid-response', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: bidResponse1}, request)[0]; - expect(resp).to.have.property('requestId', 'Bid_01'); - expect(resp).to.have.property('cpm', 3.01); - expect(resp).to.have.property('width', 300); - expect(resp).to.have.property('height', 250); - expect(resp).to.have.property('creativeId', '100_001'); - expect(resp).to.have.property('currency'); - expect(resp).to.have.property('ttl'); - expect(resp).to.have.property('mediaType', 'banner'); - expect(resp).to.have.property('ad'); - expect(resp.ad).to.have.string(''); - }); - - it('should add nurl as pixel for banner response', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: bidResponse1}, request)[0]; - let expectedNurl = bidResponse1.seatbid[0].bid[0].nurl + '&px=1'; - expect(resp.ad).to.have.string(expectedNurl); - }); - - it('should handle bidresponse with user-sync only', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: usersyncOnlyResponse}, request); - expect(resp).to.have.length(0); - }); - - it('should perform usersync', function () { - let syncs = spec.getUserSyncs({iframeEnabled: false}, [{body: bidResponse1}]); - expect(syncs).to.have.length(0); - syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: bidResponse1}]); - expect(syncs).to.have.length(1); - expect(syncs[0]).to.have.property('type', 'iframe'); - expect(syncs[0]).to.have.property('url', 'http://adk.sync.com/sync'); - }); - }); -}); diff --git a/test/spec/modules/aniviewBidAdapter_spec.js b/test/spec/modules/aniviewBidAdapter_spec.js index ce8a34509c4..56a4dadbde3 100644 --- a/test/spec/modules/aniviewBidAdapter_spec.js +++ b/test/spec/modules/aniviewBidAdapter_spec.js @@ -1,5 +1,5 @@ -import { spec } from 'modules/aniviewBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/aniviewBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const { expect } = require('chai'); describe('ANIVIEW Bid Adapter Test', function () { diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index 8386c2c2462..dd10a57bbfe 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -1,7 +1,7 @@ import {expect} from 'chai'; -import * as utils from 'src/utils'; -import {spec} from 'modules/aolBidAdapter'; -import {config} from 'src/config'; +import * as utils from 'src/utils.js'; +import {spec} from 'modules/aolBidAdapter.js'; +import {config} from 'src/config.js'; const DEFAULT_AD_CONTENT = ''; @@ -227,11 +227,11 @@ describe('AolAdapter', function () { params: { placement: 1234567, network: '9599.1', - server: 'http://adserver-eu.adtech.advertising.com' + server: 'https://adserver-eu.adtech.advertising.com' } }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf('http://adserver-eu.adtech.advertising.com/pubapi/3.0/')) + expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) .to.equal(0); }); @@ -240,7 +240,7 @@ describe('AolAdapter', function () { params: { placement: 1234567, network: '9599.1', - server: '//adserver-eu.adtech.advertising.com' + server: 'https://adserver-eu.adtech.advertising.com' } }); let [request] = spec.buildRequests(bidRequest.bids); @@ -386,13 +386,13 @@ describe('AolAdapter', function () { it('should return One Mobile url with different host when host option is present', function () { let bidParams = Object.assign({ - host: 'http://qa-hb.nexage.com' + host: 'https://qa-hb.nexage.com' }, getNexageGetBidParams()); let bidRequest = createCustomBidRequest({ params: bidParams }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('http://qa-hb.nexage.com/bidRequest?'); + expect(request.url).to.contain('https://qa-hb.nexage.com/bidRequest?'); }); it('should return One Mobile url when One Mobile and Marketplace params are present', function () { @@ -495,6 +495,94 @@ describe('AolAdapter', function () { }); }); + describe('buildOpenRtbRequestData', () => { + const bid = { + params: { + id: 'bid-id', + imp: [] + } + }; + let euConsentRequiredStub; + + beforeEach(function () { + euConsentRequiredStub = sinon.stub(spec, 'isEUConsentRequired'); + }); + + afterEach(function () { + euConsentRequiredStub.restore(); + }); + + it('returns the basic bid info when regulation data is omitted', () => { + expect(spec.buildOpenRtbRequestData(bid)).to.deep.equal({ + id: 'bid-id', + imp: [] + }); + }); + + it('returns the basic bid info with gdpr data when gdpr consent data is included', () => { + let consentData = { + gdpr: { + consentString: 'someEUConsent' + } + }; + euConsentRequiredStub.returns(true); + expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ + id: 'bid-id', + imp: [], + regs: { + ext: { + gdpr: 1 + } + }, + user: { + ext: { + consent: 'someEUConsent' + } + } + }); + }); + + it('returns the basic bid info with CCPA data when CCPA consent data is included', () => { + let consentData = { + uspConsent: 'someUSPConsent' + }; + expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ + id: 'bid-id', + imp: [], + regs: { + ext: { + us_privacy: 'someUSPConsent' + } + } + }); + }); + + it('returns the basic bid info with GDPR and CCPA data when GDPR and CCPA consent data is included', () => { + let consentData = { + gdpr: { + consentString: 'someEUConsent' + }, + uspConsent: 'someUSPConsent' + }; + euConsentRequiredStub.returns(true); + expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ + id: 'bid-id', + imp: [], + regs: { + ext: { + gdpr: 1, + us_privacy: 'someUSPConsent' + } + }, + user: { + ext: { + consent: 'someEUConsent' + } + } + }); + }); + }); + describe('getUserSyncs()', function () { let serverResponses; let bidResponse; @@ -545,36 +633,42 @@ describe('AolAdapter', function () { }); }); - describe('isConsentRequired()', function () { + describe('isEUConsentRequired()', function () { it('should return false when consentData object is not present', function () { - expect(spec.isConsentRequired(null)).to.be.false; + expect(spec.isEUConsentRequired(null)).to.be.false; }); it('should return true when gdprApplies equals true and consentString is not present', function () { let consentData = { - consentString: null, - gdprApplies: true + gdpr: { + consentString: null, + gdprApplies: true + } }; - expect(spec.isConsentRequired(consentData)).to.be.true; + expect(spec.isEUConsentRequired(consentData)).to.be.true; }); it('should return false when consentString is present and gdprApplies equals false', function () { let consentData = { - consentString: 'consent-string', - gdprApplies: false + gdpr: { + consentString: 'consent-string', + gdprApplies: false + } }; - expect(spec.isConsentRequired(consentData)).to.be.false; + expect(spec.isEUConsentRequired(consentData)).to.be.false; }); it('should return true when consentString is present and gdprApplies equals true', function () { let consentData = { - consentString: 'consent-string', - gdprApplies: true + gdpr: { + consentString: 'consent-string', + gdprApplies: true + } }; - expect(spec.isConsentRequired(consentData)).to.be.true; + expect(spec.isEUConsentRequired(consentData)).to.be.true; }); }); @@ -596,7 +690,7 @@ describe('AolAdapter', function () { expect(spec.formatMarketplaceDynamicParams()).to.be.equal(''); }); - it('should return formatted params when formatConsentData returns data', function () { + it('should return formatted EU consent params when formatConsentData returns GDPR data', function () { formatConsentDataStub.returns({ euconsent: 'test-consent', gdpr: 1 @@ -604,6 +698,23 @@ describe('AolAdapter', function () { expect(spec.formatMarketplaceDynamicParams()).to.be.equal('euconsent=test-consent;gdpr=1;'); }); + it('should return formatted US privacy params when formatConsentData returns USP data', function () { + formatConsentDataStub.returns({ + us_privacy: 'test-usp-consent' + }); + expect(spec.formatMarketplaceDynamicParams()).to.be.equal('us_privacy=test-usp-consent;'); + }); + + it('should return formatted EU and USP consent params when formatConsentData returns all data', function () { + formatConsentDataStub.returns({ + euconsent: 'test-consent', + gdpr: 1, + us_privacy: 'test-usp-consent' + }); + expect(spec.formatMarketplaceDynamicParams()).to.be.equal( + 'euconsent=test-consent;gdpr=1;us_privacy=test-usp-consent;'); + }); + it('should return formatted params when formatKeyValues returns data', function () { formatKeyValuesStub.returns({ param1: 'val1', @@ -622,16 +733,16 @@ describe('AolAdapter', function () { }); describe('formatOneMobileDynamicParams()', function () { - let consentRequiredStub; + let euConsentRequiredStub; let secureProtocolStub; beforeEach(function () { - consentRequiredStub = sinon.stub(spec, 'isConsentRequired'); + euConsentRequiredStub = sinon.stub(spec, 'isEUConsentRequired'); secureProtocolStub = sinon.stub(spec, 'isSecureProtocol'); }); afterEach(function () { - consentRequiredStub.restore(); + euConsentRequiredStub.restore(); secureProtocolStub.restore(); }); @@ -648,14 +759,35 @@ describe('AolAdapter', function () { expect(spec.formatOneMobileDynamicParams(params)).to.contain('¶m1=val1¶m2=val2¶m3=val3'); }); - it('should return formatted gdpr params when isConsentRequired returns true', function () { + it('should return formatted gdpr params when isEUConsentRequired returns true', function () { let consentData = { - consentString: 'test-consent' + gdpr: { + consentString: 'test-consent' + } }; - consentRequiredStub.returns(true); + euConsentRequiredStub.returns(true); expect(spec.formatOneMobileDynamicParams({}, consentData)).to.be.equal('&gdpr=1&euconsent=test-consent'); }); + it('should return formatted US privacy params when consentData contains USP data', function () { + let consentData = { + uspConsent: 'test-usp-consent' + }; + expect(spec.formatMarketplaceDynamicParams({}, consentData)).to.be.equal('us_privacy=test-usp-consent;'); + }); + + it('should return formatted EU and USP consent params when consentData contains gdpr and usp values', function () { + euConsentRequiredStub.returns(true); + let consentData = { + gdpr: { + consentString: 'test-consent' + }, + uspConsent: 'test-usp-consent' + }; + expect(spec.formatMarketplaceDynamicParams({}, consentData)).to.be.equal( + 'gdpr=1;euconsent=test-consent;us_privacy=test-usp-consent;'); + }); + it('should return formatted secure param when isSecureProtocol returns true', function () { secureProtocolStub.returns(true); expect(spec.formatOneMobileDynamicParams()).to.be.equal('&secure=1'); diff --git a/test/spec/modules/appierAnalyticsAdapter_spec.js b/test/spec/modules/appierAnalyticsAdapter_spec.js index 07b9796a4cb..cd026f64d49 100644 --- a/test/spec/modules/appierAnalyticsAdapter_spec.js +++ b/test/spec/modules/appierAnalyticsAdapter_spec.js @@ -1,7 +1,7 @@ import { appierAnalyticsAdapter, getCpmInUsd, parseBidderCode, parseAdUnitCode, ANALYTICS_VERSION, BIDDER_STATUS -} from 'modules/appierAnalyticsAdapter'; +} from 'modules/appierAnalyticsAdapter.js'; import {expect} from 'chai'; const events = require('src/events'); const constants = require('src/constants.json'); @@ -15,8 +15,6 @@ const auctionId = 'b0b39610-b941-4659-a87c-de9f62d3e13e'; describe('Appier Prebid AnalyticsAdapter Testing', function () { describe('event tracking and message cache manager', function () { - let xhr; - beforeEach(function () { const configOptions = { affiliateId: affiliateId, @@ -32,12 +30,10 @@ describe('Appier Prebid AnalyticsAdapter Testing', function () { provider: 'appierAnalytics', options: configOptions }); - xhr = sinon.useFakeXMLHttpRequest(); }); afterEach(function () { appierAnalyticsAdapter.disableAnalytics(); - xhr.restore(); }); describe('#getCpmInUsd()', function() { diff --git a/test/spec/modules/appierBidAdapter_spec.js b/test/spec/modules/appierBidAdapter_spec.js index c7fc5744d1c..5b6ccf14162 100644 --- a/test/spec/modules/appierBidAdapter_spec.js +++ b/test/spec/modules/appierBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec, API_SERVERS_MAP, ADAPTER_VERSION } from 'modules/appierBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { config } from 'src/config'; +import { spec, API_SERVERS_MAP, ADAPTER_VERSION } from 'modules/appierBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; describe('AppierAdapter', function () { const adapter = newBidder(spec); diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index d5b11e95351..8934d1cdaef 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -1,12 +1,12 @@ import { expect } from 'chai'; -import { spec } from 'modules/appnexusBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as bidderFactory from 'src/adapters/bidderFactory'; -import { auctionManager } from 'src/auctionManager'; -import { deepClone } from 'src/utils'; -import { config } from 'src/config'; +import { spec } from 'modules/appnexusBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as bidderFactory from 'src/adapters/bidderFactory.js'; +import { auctionManager } from 'src/auctionManager.js'; +import { deepClone } from 'src/utils.js'; +import { config } from 'src/config.js'; -const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; +const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid'; describe('AppNexusAdapter', function () { const adapter = newBidder(spec); @@ -164,6 +164,7 @@ describe('AppNexusAdapter', function () { const payload = JSON.parse(request.data); expect(payload.tags[0].ad_types).to.deep.equal(['video']); + expect(payload.tags[0].hb_source).to.deep.equal(1); }); it('sends bid request to ENDPOINT via POST', function () { @@ -193,6 +194,7 @@ describe('AppNexusAdapter', function () { id: 123, minduration: 100 }); + expect(payload.tags[0].hb_source).to.deep.equal(1); }); it('should add video property when adUnit includes a renderer', function () { @@ -215,7 +217,7 @@ describe('AppNexusAdapter', function () { let bidRequest1 = deepClone(bidRequests[0]); bidRequest1 = Object.assign({}, bidRequest1, videoData, { renderer: { - url: 'http://test.renderer.url', + url: 'https://test.renderer.url', render: function () {} } }); @@ -256,7 +258,7 @@ describe('AppNexusAdapter', function () { expect(payload.user).to.exist; expect(payload.user).to.deep.equal({ - externalUid: '123', + external_uid: '123', }); }); @@ -417,6 +419,44 @@ describe('AppNexusAdapter', function () { expect(payload3.tags.length).to.equal(15); }); + it('should contain hb_source value for adpod', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 300, + durationRangeSec: [15, 30], + } + } + } + ); + const request = spec.buildRequests([bidRequest])[0]; + const payload = JSON.parse(request.data); + expect(payload.tags[0].hb_source).to.deep.equal(7); + }); + + it('should contain hb_source value for other media', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + mediaType: 'banner', + params: { + sizes: [[300, 250], [300, 600]], + placementId: 13144370 + } + } + ); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tags[0].hb_source).to.deep.equal(1); + }); + it('adds brand_category_exclusion to request when set', function() { let bidRequest = Object.assign({}, bidRequests[0]); sinon @@ -480,6 +520,7 @@ describe('AppNexusAdapter', function () { saleprice: {required: true}, privacy_supported: true }); + expect(payload.tags[0].hb_source).to.equal(1); }); it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () { @@ -583,6 +624,7 @@ describe('AppNexusAdapter', function () { bidderRequest.bids = bidRequests; const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.options).to.be.empty; const payload = JSON.parse(request.data); expect(payload.gdpr_consent).to.exist; @@ -590,6 +632,24 @@ describe('AppNexusAdapter', function () { expect(payload.gdpr_consent.consent_required).to.exist.and.to.be.true; }); + it('should add us privacy string to payload', function() { + let consentString = '1YA-'; + let bidderRequest = { + 'bidderCode': 'appnexus', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'uspConsent': consentString + }; + bidderRequest.bids = bidRequests; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.us_privacy).to.exist; + expect(payload.us_privacy).to.exist.and.to.equal(consentString); + }); + it('supports sending hybrid mobile app parameters', function () { let appRequest = Object.assign({}, bidRequests[0], @@ -638,13 +698,13 @@ describe('AppNexusAdapter', function () { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequest = { refererInfo: { - referer: 'http://example.com/page.html', + referer: 'https://example.com/page.html', reachedTop: true, numIframes: 2, stack: [ - 'http://example.com/page.html', - 'http://example.com/iframe1.html', - 'http://example.com/iframe2.html' + 'https://example.com/page.html', + 'https://example.com/iframe1.html', + 'https://example.com/iframe2.html' ] } } @@ -653,7 +713,7 @@ describe('AppNexusAdapter', function () { expect(payload.referrer_detection).to.exist; expect(payload.referrer_detection).to.deep.equal({ - rd_ref: 'http%3A%2F%2Fexample.com%2Fpage.html', + rd_ref: 'https%3A%2F%2Fexample.com%2Fpage.html', rd_top: true, rd_ifs: 2, rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') @@ -663,11 +723,7 @@ describe('AppNexusAdapter', function () { it('should populate tpids array when userId is available', function () { const bidRequest = Object.assign({}, bidRequests[0], { userId: { - criteortus: { - appnexus: { - userid: 'sample-userid' - } - } + criteoId: 'sample-userid' } }); @@ -675,6 +731,76 @@ describe('AppNexusAdapter', function () { const payload = JSON.parse(request.data); expect(payload.tpuids).to.deep.equal([{provider: 'criteo', user_id: 'sample-userid'}]); }); + + it('should populate schain if available', function () { + const bidRequest = Object.assign({}, bidRequests[0], { + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + 'asi': 'blob.com', + 'sid': '001', + 'hp': 1 + } + ] + } + }); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.schain).to.deep.equal({ + ver: '1.0', + complete: 1, + nodes: [ + { + 'asi': 'blob.com', + 'sid': '001', + 'hp': 1 + } + ] + }); + }); + + it('should populate coppa if set in config', function () { + let bidRequest = Object.assign({}, bidRequests[0]); + sinon.stub(config, 'getConfig') + .withArgs('coppa') + .returns(true); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.user.coppa).to.equal(true); + + config.getConfig.restore(); + }); + + it('should set withCredentials to false if purpose 1 consent is not given', function () { + let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let bidderRequest = { + 'bidderCode': 'appnexus', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true, + apiVersion: 2, + vendorData: { + purpose: { + consents: { + 1: false + } + } + } + } + }; + bidderRequest.bids = bidRequests; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.options).to.deep.equal({withCredentials: false}); + }); }) describe('interpretResponse', function () { @@ -695,7 +821,7 @@ describe('AppNexusAdapter', function () { 'tag_id': 10433394, 'auction_id': '4534722592064951574', 'nobid': false, - 'no_ad_url': 'http://lax1-ib.adnxs.com/no-ad', + 'no_ad_url': 'https://lax1-ib.adnxs.com/no-ad', 'timeout_ms': 10000, 'ad_profile_id': 27079, 'ads': [ @@ -711,7 +837,7 @@ describe('AppNexusAdapter', function () { 'publisher_currency_code': '$', 'client_initiated_ad_counting': true, 'viewability': { - 'config': '' + 'config': '' }, 'rtb': { 'banner': { @@ -722,7 +848,7 @@ describe('AppNexusAdapter', function () { 'trackers': [ { 'impression_urls': [ - 'http://lax1-ib.adnxs.com/impression' + 'https://lax1-ib.adnxs.com/impression' ], 'video_events': {} } @@ -780,7 +906,7 @@ describe('AppNexusAdapter', function () { expect(result.length).to.equal(0); }); - it('handles non-banner media responses', function () { + it('handles outstream video responses', function () { let response = { 'tags': [{ 'uuid': '84ab500420319d', @@ -790,17 +916,57 @@ describe('AppNexusAdapter', function () { 'notify_url': 'imptracker.com', 'rtb': { 'video': { - 'content': '' + 'content': '' } }, - 'javascriptTrackers': '' + 'javascriptTrackers': '' }] }] }; let bidderRequest = { bids: [{ bidId: '84ab500420319d', - adUnitCode: 'code' + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'outstream' + } + } + }] + } + + let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result[0]).to.have.property('vastXml'); + expect(result[0]).to.have.property('vastImpUrl'); + expect(result[0]).to.have.property('mediaType', 'video'); + }); + + it('handles instream video responses', function () { + let response = { + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'cpm': 0.500000, + 'notify_url': 'imptracker.com', + 'rtb': { + 'video': { + 'asset_url': 'https://sample.vastURL.com/here/vid' + } + }, + 'javascriptTrackers': '' + }] + }] + }; + let bidderRequest = { + bids: [{ + bidId: '84ab500420319d', + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'instream' + } + } }] } @@ -821,12 +987,12 @@ describe('AppNexusAdapter', function () { 'notify_url': 'imptracker.com', 'rtb': { 'video': { - 'content': '', + 'asset_url': 'https://sample.vastURL.com/here/adpod', 'duration_ms': 30000, } }, 'viewability': { - 'config': '' + 'config': '' } }] }] @@ -846,6 +1012,7 @@ describe('AppNexusAdapter', function () { bfStub.returns('1'); let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result[0]).to.have.property('vastUrl'); expect(result[0].video.context).to.equal('adpod'); expect(result[0].video.durationSeconds).to.equal(30); }); @@ -862,29 +1029,29 @@ describe('AppNexusAdapter', function () { 'icon': { 'width': 0, 'height': 0, - 'url': 'http://cdn.adnxs.com/icon.png' + 'url': 'https://cdn.adnxs.com/icon.png' }, 'main_img': { 'width': 2352, 'height': 1516, - 'url': 'http://cdn.adnxs.com/img.png' + 'url': 'https://cdn.adnxs.com/img.png' }, 'link': { 'url': 'https://www.appnexus.com', 'fallback_url': '', - 'click_trackers': ['http://nym1-ib.adnxs.com/click'] + 'click_trackers': ['https://nym1-ib.adnxs.com/click'] }, - 'impression_trackers': ['http://example.com'], + 'impression_trackers': ['https://example.com'], 'rating': '5', - 'displayurl': 'http://AppNexus.com/?url=display_url', + 'displayurl': 'https://AppNexus.com/?url=display_url', 'likes': '38908320', 'downloads': '874983', 'price': '9.99', 'saleprice': 'FREE', 'phone': '1234567890', 'address': '28 W 23rd St, New York, NY 10010', - 'privacy_link': 'http://appnexus.com/?url=privacy_url', - 'javascriptTrackers': '' + 'privacy_link': 'https://appnexus.com/?url=privacy_url', + 'javascriptTrackers': '' }; let bidderRequest = { bids: [{ @@ -897,7 +1064,7 @@ describe('AppNexusAdapter', function () { expect(result[0].native.title).to.equal('Native Creative'); expect(result[0].native.body).to.equal('Cool description great stuff'); expect(result[0].native.cta).to.equal('Do it'); - expect(result[0].native.image.url).to.equal('http://cdn.adnxs.com/img.png'); + expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png'); }); it('supports configuring outstream renderers', function () { @@ -912,6 +1079,11 @@ describe('AppNexusAdapter', function () { options: { adText: 'configured' } + }, + mediaTypes: { + video: { + context: 'outstream' + } } }] }; @@ -924,17 +1096,29 @@ describe('AppNexusAdapter', function () { it('should add deal_priority and deal_code', function() { let responseWithDeal = deepClone(response); - responseWithDeal.tags[0].ads[0].deal_priority = 'high'; + responseWithDeal.tags[0].ads[0].ad_type = 'video'; + responseWithDeal.tags[0].ads[0].deal_priority = 5; responseWithDeal.tags[0].ads[0].deal_code = '123'; + responseWithDeal.tags[0].ads[0].rtb.video = { + duration_ms: 1500, + player_width: 640, + player_height: 340, + }; let bidderRequest = { bids: [{ bidId: '3db3773286ee59', - adUnitCode: 'code' + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'adpod' + } + } }] } let result = spec.interpretResponse({ body: responseWithDeal }, {bidderRequest}); expect(Object.keys(result[0].appnexus)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']); + expect(result[0].video.dealTier).to.equal(5); }); it('should add advertiser id', function() { diff --git a/test/spec/modules/arteebeeBidAdapter_spec.js b/test/spec/modules/arteebeeBidAdapter_spec.js deleted file mode 100644 index 013e1bd6c0c..00000000000 --- a/test/spec/modules/arteebeeBidAdapter_spec.js +++ /dev/null @@ -1,156 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/arteebeeBidAdapter'; - -describe('Arteebee adapater', function () { - describe('Test validate req', function () { - it('should accept minimum valid bid', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(true); - }); - - it('should reject missing pub', function () { - let bid = { - bidder: 'arteebee', - params: { - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - - it('should reject missing source', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - }); - - describe('Test build request', function () { - it('minimum request', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest' - }, - sizes: [[300, 250]] - }; - - const req = JSON.parse(spec.buildRequests([bid])[0].data); - - expect(req).to.not.have.property('reg'); - expect(req).to.not.have.property('test'); - expect(req.imp[0]).to.not.have.property('secure'); - }); - - it('make test request', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest', - test: true - }, - sizes: [[300, 250]] - }; - - const req = JSON.parse(spec.buildRequests([bid])[0].data); - - expect(req).to.not.have.property('reg'); - expect(req).to.have.property('test', 1); - expect(req.imp[0]).to.not.have.property('secure'); - }); - - it('test coppa', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest', - coppa: true - }, - sizes: [[300, 250]] - }; - - const req = JSON.parse(spec.buildRequests([bid])[0].data); - - expect(req.regs).to.have.property('coppa', 1); - expect(req).to.not.have.property('test'); - expect(req.imp[0]).to.not.have.property('secure'); - }); - - it('test gdpr', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest' - }, - sizes: [[300, 250]] - }; - let consentString = 'ABCD'; - let bidderRequest = { - 'gdprConsent': { - consentString: consentString, - gdprApplies: true - } - }; - - const req = JSON.parse(spec.buildRequests([bid], bidderRequest)[0].data); - - expect(req.regs).to.exist; - expect(req.regs.ext).to.exist; - expect(req.regs.ext).to.have.property('gdpr', 1); - - expect(req.user).to.exist; - expect(req.user.ext).to.exist; - expect(req.user.ext).to.have.property('consent', consentString); - }); - }); - - describe('Test interpret response', function () { - it('General banner response', function () { - let resp = spec.interpretResponse({ - body: { - id: 'abcd', - seatbid: [{ - bid: [{ - id: 'abcd', - impid: 'banner-bid', - price: 0.3, - adm: 'hello', - crid: 'efgh', - w: 300, - h: 250, - exp: 5 - }] - }] - } - }, null)[0]; - - expect(resp).to.have.property('requestId', 'banner-bid'); - expect(resp).to.have.property('cpm', 0.3); - expect(resp).to.have.property('width', 300); - expect(resp).to.have.property('height', 250); - expect(resp).to.have.property('creativeId', 'efgh'); - expect(resp).to.have.property('ttl', 5); - expect(resp).to.have.property('ad', 'hello'); - }); - }); -}); diff --git a/test/spec/modules/astraoneBidAdapter_spec.js b/test/spec/modules/astraoneBidAdapter_spec.js new file mode 100644 index 00000000000..e422f64b570 --- /dev/null +++ b/test/spec/modules/astraoneBidAdapter_spec.js @@ -0,0 +1,210 @@ +import { expect } from 'chai' +import { spec } from 'modules/astraoneBidAdapter.js' + +function getSlotConfigs(mediaTypes, params) { + return { + params: params, + sizes: [], + bidId: '2df8c0733f284e', + bidder: 'astraone', + mediaTypes: mediaTypes, + transactionId: '31a58515-3634-4e90-9c96-f86196db1459' + } +} + +describe('AstraOne Adapter', function() { + describe('isBidRequestValid method', function() { + const PLACE_ID = '5af45ad34d506ee7acad0c26'; + const IMAGE_URL = 'https://creative.astraone.io/files/default_image-1-600x400.jpg'; + + describe('returns true', function() { + describe('when banner slot config has all mandatory params', () => { + describe('and placement has the correct value', function() { + const createBannerSlotConfig = placement => { + return getSlotConfigs( + { banner: {} }, + { + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + placement + } + ) + } + const placements = ['inImage']; + placements.forEach(placement => { + it('should be ' + placement, function() { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig(placement) + ) + expect(isBidRequestValid).to.equal(true) + }) + }) + }) + }) + }) + describe('returns false', function() { + describe('when params are not correct', function() { + function createSlotconfig(params) { + return getSlotConfigs({ banner: {} }, params) + } + it('does not have the placeId.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + imageUrl: IMAGE_URL, + placement: 'inImage' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the imageUrl.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + placement: 'inImage' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have a the correct placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + placement: 'something' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + }) + }) + + describe('buildRequests method', function() { + const bidderRequest = { + refererInfo: { referer: 'referer' } + } + const mandatoryParams = { + placeId: '5af45ad34d506ee7acad0c26', + imageUrl: 'https://creative.astraone.io/files/default_image-1-600x400.jpg', + placement: 'inImage' + } + const validBidRequests = [ + getSlotConfigs({ banner: {} }, mandatoryParams) + ] + it('Url params should be correct ', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + expect(request.method).to.equal('POST') + expect(request.url).to.equal('https://ssp.astraone.io/auction/prebid') + }) + + it('Common data request should be correct', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(Array.isArray(data.bidRequests)).to.equal(true) + data.bidRequests.forEach(bid => { + expect(bid.placeId).to.equal('5af45ad34d506ee7acad0c26') + expect(typeof bid.imageUrl).to.equal('string') + }) + }) + + describe('GDPR params', function() { + describe('when there are not consent management platform', function() { + it('cmp should be false', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(false) + }) + }) + describe('when there are consent management platform', function() { + it('cmps should be true and ga should not sended, when gdprApplies is undefined', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: undefined, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(Object.keys(data).indexOf('data')).to.equal(-1) + expect(data.cs).to.equal('consentString') + }) + it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: true, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(data.ga).to.equal(true) + expect(data.cs).to.equal('consentString') + }) + }) + }) + + describe('BidRequests params', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + const bidRequests = data.bidRequests + it('should request a Banner', function() { + const bannerBid = bidRequests[0] + expect(bannerBid.bidId).to.equal('2df8c0733f284e') + expect(bannerBid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459') + expect(bannerBid.placeId).to.equal('5af45ad34d506ee7acad0c26') + }) + }) + }) + + describe('interpret response method', function() { + it('should return a void array, when the server response have not got bids.', function() { + const serverResponse = { + body: [] + } + const bids = spec.interpretResponse(serverResponse) + expect(Array.isArray(bids)).to.equal(true) + expect(bids.length).to.equal(0) + }) + describe('when the server response return a bid', function() { + describe('the bid is a banner', function() { + it('should return a banner bid', function() { + const serverResponse = { + body: [ + { + bidId: '2df8c0733f284e', + price: 0.5, + currency: 'USD', + content: { + content: 'html', + actionUrls: {}, + seanceId: '123123' + }, + width: 100, + height: 100, + ttl: 360 + } + ] + } + const bids = spec.interpretResponse(serverResponse) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2df8c0733f284e') + expect(bids[0].creativeId).to.equal('123123') + expect(bids[0].cpm).to.equal(0.5) + expect(bids[0].width).to.equal(100) + expect(bids[0].height).to.equal(100) + expect(bids[0].currency).to.equal('USD') + expect(bids[0].netRevenue).to.equal(true) + expect(typeof bids[0].ad).to.equal('string') + expect(typeof bids[0].content).to.equal('object') + }) + }) + }) + }) +}) diff --git a/test/spec/modules/atomxBidAdapter_spec.js b/test/spec/modules/atomxBidAdapter_spec.js index fdcdb55ec7f..d798bd6308c 100644 --- a/test/spec/modules/atomxBidAdapter_spec.js +++ b/test/spec/modules/atomxBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/atomxBidAdapter'; +import { spec } from 'modules/atomxBidAdapter.js'; describe('atomxAdapterTest', function () { describe('bidRequestValidity', function () { @@ -96,7 +96,7 @@ describe('atomxAdapterTest', function () { 'cpm': 0.00009, 'width': 300, 'height': 250, - 'url': 'http://atomx.com', + 'url': 'https://atomx.com', 'creative_id': 456, 'code': '22aidtbx5eabd9', }, @@ -113,7 +113,7 @@ describe('atomxAdapterTest', function () { expect(result[0].creativeId).to.equal(456); expect(result[0].currency).to.equal('USD'); expect(result[0].ttl).to.equal(60); - expect(result[0].adUrl).to.equal('http://atomx.com'); + expect(result[0].adUrl).to.equal('https://atomx.com'); }); }); }); diff --git a/test/spec/modules/atsAnalyticsAdapter_spec.js b/test/spec/modules/atsAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..10fe7de7203 --- /dev/null +++ b/test/spec/modules/atsAnalyticsAdapter_spec.js @@ -0,0 +1,150 @@ +import atsAnalyticsAdapter from '../../../modules/atsAnalyticsAdapter.js'; +import { expect } from 'chai'; +import adapterManager from 'src/adapterManager.js'; +import {server} from '../../mocks/xhr.js'; +import {browserIsChrome, browserIsEdge, browserIsFirefox, browserIsSafari} from '../../../modules/atsAnalyticsAdapter.js'; +let events = require('src/events'); +let constants = require('src/constants.json'); + +describe('ats analytics adapter', function () { + beforeEach(function () { + sinon.stub(events, 'getEvents').returns([]); + }); + + afterEach(function () { + events.getEvents.restore(); + atsAnalyticsAdapter.disableAnalytics(); + }); + + describe('track', function () { + it('builds and sends request and response data', function () { + sinon.spy(atsAnalyticsAdapter, 'track'); + + let initOptions = { + pid: '10433394', + host: 'https://example.com/dev', + }; + let auctionTimestamp = 1496510254326; + + // prepare general auction - request + let bidRequest = { + 'bidderCode': 'appnexus', + 'auctionStart': 1580739265161, + 'bids': [{ + 'bidder': 'appnexus', + 'params': { + 'placementId': '10433394' + }, + 'userId': { + 'idl_env': 'AmThEbO1ssIWjrNdU4noT4ZFBILSVBBYHbipOYt_JP40e5nZdXns2g' + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': '2f481ff1-8d20-4c28-8e36-e384e9e3eec6', + 'sizes': '300x250,300x600', + 'bidId': '30c77d079cdf17' + }], + 'refererInfo': { + 'referer': 'https://example.com/dev' + }, + 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', + }; + // prepare general auction - response + let bidResponse = { + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '2eddfdc0c791dc', + 'mediaType': 'banner', + 'source': 'client', + 'requestId': '30c77d079cdf17', + 'cpm': 0.5, + 'creativeId': 29681110, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', + 'responseTimestamp': 1580739791978, + 'requestTimestamp': 1580739265164, + 'bidder': 'appnexus', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'timeToRespond': 2510, + 'size': '300x250' + }; + + // what we expect after general auction + let expectedAfterBid = { + 'Data': [{ + 'has_envelope': true, + 'bidder': 'appnexus', + 'bid_id': '30c77d079cdf17', + 'auction_id': 'a5b849e5-87d7-4205-8300-d063084fcfb7', + 'user_browser': (browserIsFirefox() || browserIsEdge() || browserIsChrome() || browserIsSafari()), + 'user_platform': navigator.platform, + 'auction_start': '2020-02-03T14:14:25.161Z', + 'domain': 'https://example.com/dev', + 'pid': '10433394', + 'response_time_stamp': '2020-02-03T14:23:11.978Z', + 'currency': 'USD', + 'cpm': 0.5, + 'net_revenue': true + }] + }; + + // lets simulate that some bidders timeout + let bidTimeoutArgsV1 = [ + { + bidId: '2baa51527bd015', + bidder: 'bidderOne', + adUnitCode: '/19968336/header-bid-tag-0', + auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' + }, + { + bidId: '6fe3b4c2c23092', + bidder: 'bidderTwo', + adUnitCode: '/19968336/header-bid-tag-0', + auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' + } + ]; + + adapterManager.registerAnalyticsAdapter({ + code: 'atsAnalytics', + adapter: atsAnalyticsAdapter + }); + + adapterManager.enableAnalytics({ + provider: 'atsAnalytics', + options: initOptions + }); + + // Step 1: Send auction init event + events.emit(constants.EVENTS.AUCTION_INIT, { + timestamp: auctionTimestamp + }); + // Step 2: Send bid requested event + events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); + + // Step 3: Send bid response event + events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); + + // Step 4: Send bid time out event + events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeoutArgsV1); + + // Step 5: Send auction end event + events.emit(constants.EVENTS.AUCTION_END, {}); + + let requests = server.requests.filter(req => { + return req.url.indexOf(initOptions.host) > -1; + }); + + expect(requests.length).to.equal(1); + + let realAfterBid = JSON.parse(requests[0].requestBody); + + // Step 6: assert real data after bid and expected data + expect(realAfterBid['Data']).to.deep.equal(expectedAfterBid['Data']); + + // check that the host and publisher ID is configured via options + expect(atsAnalyticsAdapter.context.host).to.equal(initOptions.host); + expect(atsAnalyticsAdapter.context.pid).to.equal(initOptions.pid); + }) + }) +}) diff --git a/test/spec/modules/audienceNetworkBidAdapter_spec.js b/test/spec/modules/audienceNetworkBidAdapter_spec.js index a495b33438c..04694731981 100644 --- a/test/spec/modules/audienceNetworkBidAdapter_spec.js +++ b/test/spec/modules/audienceNetworkBidAdapter_spec.js @@ -3,8 +3,8 @@ */ import { expect } from 'chai'; -import { spec } from 'modules/audienceNetworkBidAdapter'; -import * as utils from 'src/utils'; +import { spec } from 'modules/audienceNetworkBidAdapter.js'; +import * as utils from 'src/utils.js'; const { code, @@ -20,7 +20,22 @@ const playerwidth = 320; const playerheight = 180; const requestId = 'test-request-id'; const debug = 'adapterver=1.3.0&platform=241394079772386&platver=$prebid.version$&cb=test-uuid'; -const pageUrl = encodeURIComponent(utils.getTopWindowUrl()); +const expectedPageUrl = encodeURIComponent('http://www.prebid-test.com/audienceNetworkTest.html?pbjs_debug=true'); +const mockBidderRequest = { + bidderCode: 'audienceNetwork', + auctionId: '720146a0-8f32-4db0-bb30-21f1d057efb4', + bidderRequestId: '1312d48561657e', + auctionStart: 1579711852920, + timeout: 3000, + refererInfo: { + referer: 'http://www.prebid-test.com/audienceNetworkTest.html?pbjs_debug=true', + reachedTop: true, + numIframes: 0, + stack: ['http://www.prebid-test.com/audienceNetworkTest.html?pbjs_debug=true'], + canonicalUrl: undefined + }, + start: 1579711852925 +}; describe('AudienceNetwork adapter', function () { describe('Public API', function () { @@ -129,19 +144,40 @@ describe('AudienceNetwork adapter', function () { utils.generateUUID.restore(); }); + it('takes the canonicalUrl as priority over referer for pageurl', function () { + let expectedCanonicalUrl = encodeURIComponent('http://www.this-is-canonical-url.com/hello-world.html?pbjs_debug=true'); + mockBidderRequest.refererInfo.canonicalUrl = 'http://www.this-is-canonical-url.com/hello-world.html?pbjs_debug=true'; + expect(buildRequests([{ + bidder, + bidId: requestId, + sizes: [[300, 50], [300, 250], [320, 50]], + params: { placementId } + }], mockBidderRequest)).to.deep.equal([{ + adformats: ['300x250'], + method: 'GET', + pageurl: expectedCanonicalUrl, + requestIds: [requestId], + sizes: ['300x250'], + url: 'https://an.facebook.com/v2/placementbid.json', + data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${expectedCanonicalUrl}&sdk[]=6.0.web&${debug}` + }]); + mockBidderRequest.refererInfo.canonicalUrl = undefined; + }); + it('can build URL for IAB unit', function () { expect(buildRequests([{ bidder, bidId: requestId, sizes: [[300, 50], [300, 250], [320, 50]], params: { placementId } - }])).to.deep.equal([{ + }], mockBidderRequest)).to.deep.equal([{ adformats: ['300x250'], method: 'GET', + pageurl: expectedPageUrl, requestIds: [requestId], sizes: ['300x250'], url: 'https://an.facebook.com/v2/placementbid.json', - data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${pageUrl}&sdk[]=6.0.web&${debug}` + data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${expectedPageUrl}&sdk[]=6.0.web&${debug}` }]); }); @@ -154,13 +190,14 @@ describe('AudienceNetwork adapter', function () { placementId, format: 'video' } - }])).to.deep.equal([{ + }], mockBidderRequest)).to.deep.equal([{ adformats: ['video'], method: 'GET', + pageurl: expectedPageUrl, requestIds: [requestId], sizes: ['640x480'], url: 'https://an.facebook.com/v2/placementbid.json', - data: `placementids[]=test-placement-id&adformats[]=video&testmode=false&pageurl=${pageUrl}&sdk[]=&${debug}&playerwidth=640&playerheight=480` + data: `placementids[]=test-placement-id&adformats[]=video&testmode=false&pageurl=${expectedPageUrl}&sdk[]=&${debug}&playerwidth=640&playerheight=480` }]); }); @@ -173,13 +210,14 @@ describe('AudienceNetwork adapter', function () { placementId, format: 'native' } - }])).to.deep.equal([{ + }], mockBidderRequest)).to.deep.equal([{ adformats: ['native'], method: 'GET', + pageurl: expectedPageUrl, requestIds: [requestId], sizes: ['728x90'], url: 'https://an.facebook.com/v2/placementbid.json', - data: `placementids[]=test-placement-id&adformats[]=native&testmode=false&pageurl=${pageUrl}&sdk[]=6.0.web&${debug}` + data: `placementids[]=test-placement-id&adformats[]=native&testmode=false&pageurl=${expectedPageUrl}&sdk[]=6.0.web&${debug}` }]); }); @@ -196,13 +234,14 @@ describe('AudienceNetwork adapter', function () { platform, format: 'fullwidth' } - }])).to.deep.equal([{ + }], mockBidderRequest)).to.deep.equal([{ adformats: ['300x250'], method: 'GET', + pageurl: expectedPageUrl, requestIds: [requestId], sizes: ['300x250'], url: 'https://an.facebook.com/v2/placementbid.json', - data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${pageUrl}&sdk[]=6.0.web&${debugPlatform}` + data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${expectedPageUrl}&sdk[]=6.0.web&${debugPlatform}` }]); }); }); @@ -233,7 +272,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['native'], requestIds: [requestId], - sizes: [[300, 250]] + sizes: [[300, 250]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); @@ -274,7 +314,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['300x250'], requestIds: [requestId], - sizes: [[300, 250]] + sizes: [[300, 250]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); @@ -314,7 +355,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['300x250'], requestIds: [requestId], - sizes: [[300, 250]] + sizes: [[300, 250]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); @@ -358,7 +400,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['native', '300x250'], requestIds: [requestId, requestId], - sizes: ['300x250', [300, 250]] + sizes: ['300x250', [300, 250]], + pageurl: expectedPageUrl }); expect(bidResponseNative.cpm).to.equal(1.23); @@ -415,14 +458,15 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['video'], requestIds: [requestId], - sizes: [[playerwidth, playerheight]] + sizes: [[playerwidth, playerheight]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); expect(bidResponse.requestId).to.equal(requestId); expect(bidResponse.ttl).to.equal(3600); expect(bidResponse.mediaType).to.equal('video'); - expect(bidResponse.vastUrl).to.equal(`https://an.facebook.com/v1/instream/vast.xml?placementid=${placementId}&pageurl=${pageUrl}&playerwidth=${playerwidth}&playerheight=${playerheight}&bidid=${bidId}`); + expect(bidResponse.vastUrl).to.equal(`https://an.facebook.com/v1/instream/vast.xml?placementid=${placementId}&pageurl=${expectedPageUrl}&playerwidth=${playerwidth}&playerheight=${playerheight}&bidid=${bidId}`); expect(bidResponse.width).to.equal(playerwidth); expect(bidResponse.height).to.equal(playerheight); }); @@ -456,14 +500,15 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['video', 'native'], requestIds: [requestId, requestId], - sizes: [[playerwidth, playerheight], [300, 250]] + sizes: [[playerwidth, playerheight], [300, 250]], + pageurl: expectedPageUrl }); expect(bidResponseVideo.cpm).to.equal(1.23); expect(bidResponseVideo.requestId).to.equal(requestId); expect(bidResponseVideo.ttl).to.equal(3600); expect(bidResponseVideo.mediaType).to.equal('video'); - expect(bidResponseVideo.vastUrl).to.equal(`https://an.facebook.com/v1/instream/vast.xml?placementid=${videoPlacementId}&pageurl=${pageUrl}&playerwidth=${playerwidth}&playerheight=${playerheight}&bidid=${videoBidId}`); + expect(bidResponseVideo.vastUrl).to.equal(`https://an.facebook.com/v1/instream/vast.xml?placementid=${videoPlacementId}&pageurl=${expectedPageUrl}&playerwidth=${playerwidth}&playerheight=${playerheight}&bidid=${videoBidId}`); expect(bidResponseVideo.width).to.equal(playerwidth); expect(bidResponseVideo.height).to.equal(playerheight); @@ -495,7 +540,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['native'], requestIds: [requestId], - sizes: [[300, 250]] + sizes: [[300, 250]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); diff --git a/test/spec/modules/audiencerunBidAdapter_spec.js b/test/spec/modules/audiencerunBidAdapter_spec.js new file mode 100644 index 00000000000..826944abaf5 --- /dev/null +++ b/test/spec/modules/audiencerunBidAdapter_spec.js @@ -0,0 +1,204 @@ +import { expect } from 'chai'; +import { spec } from 'modules/audiencerunBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +const ENDPOINT = 'https://d.audiencerun.com/prebid'; + +const BID_SERVER_RESPONSE = { + body: { + bid: [ + { + 'bidId': '51ef8751f9aead', + 'zoneId': '12345abcde', + 'adId': '1234', + 'crid': '5678', + 'cpm': 8.021951999999999999, + 'currency': 'USD', + 'w': 728, + 'h': 90, + 'isNet': false, + 'buying_type': 'rtb', + 'syncUrl': 'https://ac.audiencerun.com/f/sync.html', + 'adm': '' + } + ] + } +}; + +describe('AudienceRun bid adapter tests', function() { + const adapter = newBidder(spec); + + describe('inherited functions', function() { + it('exists and is a function', function() { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function() { + let bid = { + 'bidder': 'audiencerun', + 'params': { + 'zoneId': '12345abcde' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'creativeId': 'er2ee' + }; + + it('should return true when required params found', function() { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return true when zoneId is valid', function() { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'zoneId': '12345abcde' + }; + + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function() { + let bid = Object.assign({}, bid); + delete bid.params; + + bid.params = {}; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function() { + let bidRequests = [ + { + 'bidder': 'audiencerun', + 'bidId': '51ef8751f9aead', + 'params': { + 'zoneId': '12345abcde' + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'mediaTypes': { + 'banner': { + 'sizes': [[320, 50], [300, 250], [300, 600]] + } + }, + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1 + } + ]; + + it('sends a valid bid request to ENDPOINT via POST', function() { + const request = spec.buildRequests(bidRequests, { + gdprConsent: { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }, + refererInfo: { + canonicalUrl: 'https://example.com/canonical', + referer: 'https://example.com' + } + }); + + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + + const payload = JSON.parse(request.data); + expect(payload.gdpr).to.exist; + + expect(payload.bids).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(payload.referer).to.exist; + + const bid = payload.bids[0]; + expect(bid).to.exist; + expect(bid).to.have.property('bidId'); + expect(bid).to.have.property('zoneId'); + expect(bid).to.have.property('sizes'); + expect(bid.sizes[0].w).to.be.a('number'); + expect(bid.sizes[0].h).to.be.a('number'); + }); + + it('should send GDPR to endpoint and honor gdprApplies value', function() { + let consentString = 'bogusConsent'; + let bidderRequest = { + 'gdprConsent': { + 'consentString': consentString, + 'gdprApplies': true + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.gdpr).to.exist; + expect(payload.gdpr.consent).to.equal(consentString); + expect(payload.gdpr.applies).to.equal(true); + + let bidderRequest2 = { + 'gdprConsent': { + 'consentString': consentString, + 'gdprApplies': false + } + }; + + const request2 = spec.buildRequests(bidRequests, bidderRequest2); + const payload2 = JSON.parse(request2.data); + + expect(payload2.gdpr).to.exist; + expect(payload2.gdpr.consent).to.equal(consentString); + expect(payload2.gdpr.applies).to.equal(false); + }); + }); + + describe('interpretResponse', function () { + const expectedResponse = [{ + 'requestId': '51ef8751f9aead', + 'adId': '12345abcde', + 'cpm': 8.021951999999999999, + 'width': '728', + 'height': '90', + 'creativeId': '5678', + 'currency': 'USD', + 'netRevenue': false, + 'ttl': 300, + 'ad': '', + 'mediaType': 'banner' + }]; + + it('should get the correct bid response by display ad', function () { + let result = spec.interpretResponse(BID_SERVER_RESPONSE); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + + it('handles empty bid response', function () { + const response = { + body: {} + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); + + describe('getUserSyncs', function () { + const serverResponses = [ BID_SERVER_RESPONSE ]; + const syncOptions = { iframeEnabled: true }; + + it('should return empty if no server responses', function() { + const syncs = spec.getUserSyncs(syncOptions, []); + expect(syncs).to.deep.equal([]) + }); + + it('should return user syncs', function () { + const syncs = spec.getUserSyncs(syncOptions, serverResponses); + expect(syncs).to.deep.equal([{type: 'iframe', url: 'https://ac.audiencerun.com/f/sync.html'}]) + }); + }); +}); diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js new file mode 100644 index 00000000000..788fd3aefc4 --- /dev/null +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -0,0 +1,144 @@ +import { expect } from 'chai' +import { spec } from 'modules/automatadBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' + +describe('automatadBidAdapter', function () { + const adapter = newBidder(spec) + + let bidRequest = { + bidder: 'automatad', + params: {siteId: '123ad', placementId: '123abc345'}, + mediaTypes: { + banner: { + sizes: [[300, 600]], + } + }, + adUnitCode: 'some-ad-unit-code', + transactionId: '1465569e-52cc-4c36-88a1-7174cfef4b44', + sizes: [[300, 600]], + bidId: '123abc', + bidderRequestId: '3213887463c059', + auctionId: 'abc-123', + src: 'client', + bidRequestsCount: 1 + } + + let expectedResponse = [{ + 'body': { + 'id': 'abc-123', + 'seatbid': [ + { + 'bid': [ + { + 'adm': '', + 'adomain': [ + 'someAdDomain' + ], + 'crid': 123, + 'h': 600, + 'id': 'bid1', + 'impid': '1', + 'nurl': 'https://example/win', + 'price': 0.5, + 'w': 300 + } + ] + } + ] + } + }] + + describe('codes', function () { + it('should return a bidder code of automatad', function () { + expect(spec.code).to.equal('automatad') + }) + it('should alias atd', function () { + expect(spec.aliases.length > 0 && spec.aliases[0] === 'atd').to.be.true + }) + }) + + describe('isBidRequestValid', function () { + let inValidBid = Object.assign({}, bidRequest) + delete inValidBid.params + it('should return true if all params present', function () { + expect(spec.isBidRequestValid(bidRequest)).to.equal(true) + }) + + it('should return false if any parameter missing', function () { + expect(spec.isBidRequestValid(inValidBid)).to.be.false + }) + }) + + describe('buildRequests', function () { + let req = spec.buildRequests([ bidRequest ], { refererInfo: { } }) + let rdata + + it('should return request object', function () { + expect(req).to.not.be.null + }) + + it('should build request data', function () { + expect(req.data).to.not.be.null + }) + + it('should include one request', function () { + rdata = JSON.parse(req.data) + expect(rdata.imp.length).to.equal(1) + }) + + it('should include media types', function () { + let r = rdata.imp[0] + expect(r.media_types !== null).to.be.true + }) + + it('should include all publisher params', function () { + let r = rdata.imp[0] + expect(r.siteID !== null && r.placementID !== null).to.be.true + }) + }) + + describe('interpretResponse', function () { + it('should get the correct bid response', function () { + let result = spec.interpretResponse(expectedResponse[0]) + expect(result).to.be.an('array').that.is.not.empty + }) + + it('handles empty bid response', function () { + let response = { + body: '' + } + let result = spec.interpretResponse(response) + expect(result.length).to.equal(0) + }) + }) + + describe('getUserSyncs', function () { + it('should return iframe sync', function () { + let sync = spec.getUserSyncs() + expect(sync.length).to.equal(1) + expect(sync[0].type === 'iframe') + expect(typeof sync[0].url === 'string') + }) + }) + + describe('onBidWon', function () { + let serverResponses = spec.interpretResponse(expectedResponse[0]) + let wonbid = serverResponses[0] + let ajaxStub + + beforeEach(() => { + ajaxStub = sinon.stub(spec, 'ajaxCall') + }) + + afterEach(() => { + ajaxStub.restore() + }) + + it('Returns true is nurl is good/not blank', function () { + expect(wonbid.nurl).to.not.equal('') + expect(spec.onBidWon(wonbid)).to.be.true + expect(ajaxStub.calledOnce).to.equal(true) + expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0) + }) + }) +}) diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 4598a4e00c7..f7dcc1305e5 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import sinon from 'sinon'; -import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter'; -import { parse as parseUrl } from 'src/url'; +import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter.js'; +import { parseUrl } from 'src/utils.js'; describe('BeachfrontAdapter', function () { let bidRequests; @@ -234,6 +234,16 @@ describe('BeachfrontAdapter', function () { expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement }); }); + it('must add US privacy data to the request', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: {} }; + const uspConsent = '2112YYZ'; + const bidderRequest = { uspConsent }; + const requests = spec.buildRequests([ bidRequest ], bidderRequest); + const data = requests[0].data; + expect(data.regs.ext.us_privacy).to.equal(uspConsent); + }); + it('must add GDPR consent data to the request', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; @@ -372,6 +382,16 @@ describe('BeachfrontAdapter', function () { expect(data.slots[0].sizes).to.deep.contain({ w: width, h: height }); }); + it('must add US privacy data to the request', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { banner: {} }; + const uspConsent = '2112YYZ'; + const bidderRequest = { uspConsent }; + const requests = spec.buildRequests([ bidRequest ], bidderRequest); + const data = requests[0].data; + expect(data.usPrivacy).to.equal(uspConsent); + }); + it('must add GDPR consent data to the request', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { banner: {} }; @@ -496,15 +516,16 @@ describe('BeachfrontAdapter', function () { const serverResponse = { bidPrice: 5.00, url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', - cmpId: '123abc' + crid: '123abc' }; const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); expect(bidResponse).to.deep.equal({ requestId: bidRequest.bidId, bidderCode: spec.code, cpm: serverResponse.bidPrice, - creativeId: serverResponse.cmpId, + creativeId: serverResponse.crid, vastUrl: serverResponse.url, + vastXml: undefined, width: width, height: height, renderer: null, @@ -515,6 +536,48 @@ describe('BeachfrontAdapter', function () { }); }); + it('should default to the legacy "cmpId" value for the creative ID', () => { + const width = 640; + const height = 480; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { + video: { + playerSize: [ width, height ] + } + }; + const serverResponse = { + bidPrice: 5.00, + url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', + cmpId: '123abc' + }; + const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); + expect(bidResponse).to.deep.contain({ + creativeId: serverResponse.cmpId + }); + }); + + it('should return vast xml if found on the bid response', () => { + const width = 640; + const height = 480; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { + video: { + playerSize: [ width, height ] + } + }; + const serverResponse = { + bidPrice: 5.00, + url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', + vast: '', + crid: '123abc' + }; + const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); + expect(bidResponse).to.deep.contain({ + vastUrl: serverResponse.url, + vastXml: serverResponse.vast + }); + }); + it('should return a renderer for outstream video bids', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { @@ -525,7 +588,7 @@ describe('BeachfrontAdapter', function () { const serverResponse = { bidPrice: 5.00, url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', - cmpId: '123abc' + crid: '123abc' }; const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); expect(bidResponse.renderer).to.deep.contain({ @@ -547,7 +610,7 @@ describe('BeachfrontAdapter', function () { const serverResponse = { bidPrice: 5.00, url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', - cmpId: '123abc' + crid: '123abc' }; const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); window.Beachfront = { Player: sinon.spy() }; @@ -581,7 +644,7 @@ describe('BeachfrontAdapter', function () { const serverResponse = { bidPrice: 5.00, url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', - cmpId: '123abc' + crid: '123abc' }; const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); window.Beachfront = { Player: sinon.spy() }; @@ -662,7 +725,7 @@ describe('BeachfrontAdapter', function () { bidResponse = { bidPrice: 5.00, url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', - cmpId: '123abc' + crid: '123abc' }; }); diff --git a/test/spec/modules/betweenBidAdapter_spec.js b/test/spec/modules/betweenBidAdapter_spec.js index f2d770805c5..5dff32ca4d8 100644 --- a/test/spec/modules/betweenBidAdapter_spec.js +++ b/test/spec/modules/betweenBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/betweenBidAdapter'; +import { spec } from 'modules/betweenBidAdapter.js'; describe('betweenBidAdapterTests', function () { it('validate_pub_params', function () { @@ -23,6 +23,122 @@ describe('betweenBidAdapterTests', function () { let req_data = request[0].data; expect(req_data.bidid).to.equal('bid1234'); }); + it('validate itu param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + itu: 'https://something.url' + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.itu).to.equal('https://something.url'); + }); + it('validate cur param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + cur: 'THX' + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.cur).to.equal('THX'); + }); + it('validate subid param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + subid: 1138, + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.subid).to.equal(1138); + }); + it('validate click3rd param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + click3rd: 'https://something.url', + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.click3rd).to.equal('https://something.url'); + }); + it('validate pubdata param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + pubdata: { + param: '&test=tset' + }, + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data['pubside_macro[param]']).to.equal('%26test%3Dtset'); + }); + it('validate gdprConsent', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + }, + sizes: [[240, 400]] + }]; + let bidderRequest = { + gdprConsent: { + consentString: 'BOtGbjbOtGbjbBQABBENC3-AAAAtR7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4u_1vf99yfm1-7etr3tp_87ues2_Xur__79__3z3_9pxP78k89r7337Ew_v-_v-b7JCON_IA', + gdprApplies: true + } + } + + let request = spec.buildRequests(bidRequestData, bidderRequest); + let req_data = request[0].data; + + expect(req_data.gdprApplies).to.equal(bidderRequest.gdprConsent.gdprApplies); + expect(req_data.consentString).to.equal(bidderRequest.gdprConsent.consentString); + }); it('validate_response_params', function () { let serverResponse = { body: [{ @@ -66,4 +182,43 @@ describe('betweenBidAdapterTests', function () { expect(bid.requestId).to.equal('bid1234'); expect(bid.ad).to.equal('Ad html'); }); + it('validate response params without currency', function () { + let serverResponse = { + body: [{ + bidid: 'bid1234', + w: 240, + h: 400, + ad: 'Ad html' + }] + }; + let bids = spec.interpretResponse(serverResponse); + expect(bids).to.have.lengthOf(1); + let bid = bids[0]; + expect(bid.currency).to.equal('RUB'); + }); + it('check getUserSyncs', function() { + const syncs = spec.getUserSyncs({}, {}); + expect(syncs).to.be.an('array').that.to.have.lengthOf(1); + expect(syncs[0]).to.deep.equal({type: 'iframe', url: 'https://ads.betweendigital.com/sspmatch-iframe'}); + }); + + it('check sizes', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + mediaTypes: { + banner: { + sizes: [[970, 250], [240, 400], [728, 90]] + } + }, + params: { + s: 1112, + }, + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.sizes).to.deep.equal(['970x250', '240x400', '728x90']); + }); }); diff --git a/test/spec/modules/bidfluenceBidAdapter_spec.js b/test/spec/modules/bidfluenceBidAdapter_spec.js index 9ce6e808c6b..6b3a0c2b044 100644 --- a/test/spec/modules/bidfluenceBidAdapter_spec.js +++ b/test/spec/modules/bidfluenceBidAdapter_spec.js @@ -1,114 +1,114 @@ -import { expect } from 'chai'; -import { spec } from 'modules/bidfluenceBidAdapter'; - -const BIDDER_CODE = 'bidfluence'; -const PLACEMENT_ID = '1000'; -const PUB_ID = '1000'; -const CONSENT_STRING = 'DUXDSDFSFWRRR8345F=='; - -const validBidRequests = [{ - 'bidder': BIDDER_CODE, - 'params': { - 'placementId': PLACEMENT_ID, - 'publisherId': PUB_ID, - 'reservePrice': 0 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '2b1f23307fb8ef', - 'bidderRequestId': '10edf38ec1a719', - 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304' -}]; - -const bidderRequest = { - 'bidderCode': 'bidfluence', - 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304', - 'bidderRequestId': '10edf38ec1a719', - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'test', - 'stack': ['test'] - }, - 'timeout': 1000, - 'gdprConsent': { - 'gdprApplies': true, - 'consentString': CONSENT_STRING, - 'vendorData': '' - } -}; - -bidderRequest.bids = validBidRequests; - -describe('Bidfluence Adapter test', () => { - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(validBidRequests[0])).to.equal(true); - }); - it('should return the right bidder code', function () { - expect(spec.code).to.eql(BIDDER_CODE); - }); - }); - - describe('buildRequests', function () { - const request = spec.buildRequests(validBidRequests, bidderRequest); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - const payload = JSON.parse(request.data); - - expect(payload.bids[0].bid).to.equal(validBidRequests[0].bidId); - expect(payload.azr).to.equal(true); - expect(payload.ck).to.not.be.undefined; - expect(payload.bids[0].tid).to.equal(PLACEMENT_ID); - expect(payload.bids[0].pid).to.equal(PUB_ID); - expect(payload.bids[0].rp).to.be.a('number'); - expect(payload.re).to.not.be.undefined; - expect(payload.st).to.not.be.undefined; - expect(payload.tz).to.not.be.undefined; - expect(payload.sr).to.not.be.undefined; - expect(payload.vp).to.not.be.undefined; - expect(payload.sdt).to.not.be.undefined; - expect(payload.bids[0].w).to.equal('300'); - expect(payload.bids[0].h).to.equal('250'); - - it('sends gdpr info if exists', function () { - expect(payload.gdpr).to.equal(true); - expect(payload.gdprc).to.equal(CONSENT_STRING); - }); - }); - - describe('interpretResponse', function () { - const response = { - body: { - Bids: - [{ - 'CreativeId': '1000', - 'Cpm': 0.50, - 'Ad': '
', - 'Height': 250, - 'Width': 300 - }] - } - }; - - it('should get correct bid response', function () { - const expectedResponse = [{ - requestId: response.body.Bids[0].BidId, - cpm: response.body.Bids[0].Cpm, - width: response.body.Bids[0].Width, - height: response.body.Bids[0].Height, - creativeId: response.body.Bids[0].CreativeId, - ad: response.body.Bids[0].Ad, - currency: 'USD', - netRevenue: true, - ttl: 360 - }]; - - let result = spec.interpretResponse(response, { 'bidderRequest': validBidRequests[0] }); - expect(result).to.deep.equal(expectedResponse); - }); - }); -}); +import { expect } from 'chai'; +import { spec } from 'modules/bidfluenceBidAdapter.js'; + +const BIDDER_CODE = 'bidfluence'; +const PLACEMENT_ID = '1000'; +const PUB_ID = '1000'; +const CONSENT_STRING = 'DUXDSDFSFWRRR8345F=='; + +const validBidRequests = [{ + 'bidder': BIDDER_CODE, + 'params': { + 'placementId': PLACEMENT_ID, + 'publisherId': PUB_ID, + 'reservePrice': 0 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '2b1f23307fb8ef', + 'bidderRequestId': '10edf38ec1a719', + 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304' +}]; + +const bidderRequest = { + 'bidderCode': 'bidfluence', + 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304', + 'bidderRequestId': '10edf38ec1a719', + 'refererInfo': { + 'numIframes': 0, + 'reachedTop': true, + 'referer': 'test', + 'stack': ['test'] + }, + 'timeout': 1000, + 'gdprConsent': { + 'gdprApplies': true, + 'consentString': CONSENT_STRING, + 'vendorData': '' + } +}; + +bidderRequest.bids = validBidRequests; + +describe('Bidfluence Adapter test', () => { + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(validBidRequests[0])).to.equal(true); + }); + it('should return the right bidder code', function () { + expect(spec.code).to.eql(BIDDER_CODE); + }); + }); + + describe('buildRequests', function () { + it('sends bid request to our endpoint via POST', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.method).to.equal('POST'); + const payload = JSON.parse(request.data); + + expect(payload.bids[0].bid).to.equal(validBidRequests[0].bidId); + expect(payload.azr).to.equal(true); + expect(payload.ck).to.not.be.undefined; + expect(payload.bids[0].tid).to.equal(PLACEMENT_ID); + expect(payload.bids[0].pid).to.equal(PUB_ID); + expect(payload.bids[0].rp).to.be.a('number'); + expect(payload.re).to.not.be.undefined; + expect(payload.st).to.not.be.undefined; + expect(payload.tz).to.not.be.undefined; + expect(payload.sr).to.not.be.undefined; + expect(payload.vp).to.not.be.undefined; + expect(payload.sdt).to.not.be.undefined; + expect(payload.bids[0].w).to.equal('300'); + expect(payload.bids[0].h).to.equal('250'); + }); + + it('sends gdpr info if exists', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.gdpr).to.equal(true); + expect(payload.gdprc).to.equal(CONSENT_STRING); + }); + }); + + describe('interpretResponse', function () { + const response = { + body: { + Bids: + [{ + 'CreativeId': '1000', + 'Cpm': 0.50, + 'Ad': '
', + 'Height': 250, + 'Width': 300 + }] + } + }; + + it('should get correct bid response', function () { + const expectedResponse = [{ + requestId: response.body.Bids[0].BidId, + cpm: response.body.Bids[0].Cpm, + width: response.body.Bids[0].Width, + height: response.body.Bids[0].Height, + creativeId: response.body.Bids[0].CreativeId, + ad: response.body.Bids[0].Ad, + currency: 'USD', + netRevenue: true, + ttl: 360 + }]; + + let result = spec.interpretResponse(response, { 'bidderRequest': validBidRequests[0] }); + expect(result).to.deep.equal(expectedResponse); + }); + }); +}); diff --git a/test/spec/modules/bidglassAdapter_spec.js b/test/spec/modules/bidglassAdapter_spec.js index 00a47fc997a..d153430103d 100644 --- a/test/spec/modules/bidglassAdapter_spec.js +++ b/test/spec/modules/bidglassAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/bidglassBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/bidglassBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('Bid Glass Adapter', function () { const adapter = newBidder(spec); diff --git a/test/spec/modules/bidlabBidAdapter_spec.js b/test/spec/modules/bidlabBidAdapter_spec.js new file mode 100644 index 00000000000..cffd43ae6ca --- /dev/null +++ b/test/spec/modules/bidlabBidAdapter_spec.js @@ -0,0 +1,235 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/bidlabBidAdapter.js'; + +describe('BidlabBidAdapter', function () { + let bid = { + bidId: '23fhj33i987f', + bidder: 'bidlab', + params: { + placementId: 0, + traffic: 'banner' + } + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and placementId parameters present', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + delete bid.params.placementId; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests([bid]); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://service.bidlab.ai/?c=o&m=multi'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + let placement = data['placements'][0]; + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); + expect(placement.placementId).to.equal(0); + expect(placement.bidId).to.equal('23fhj33i987f'); + expect(placement.traffic).to.equal('banner'); + }); + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([]); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.width).to.equal(300); + expect(dataItem.height).to.equal(250); + expect(dataItem.ad).to.equal('Test'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + describe('getUserSyncs', function () { + let userSync = spec.getUserSyncs(); + it('Returns valid URL and type', function () { + if (spec.noSync) { + expect(userSync).to.be.equal(false); + } else { + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.exist; + expect(userSync[0].url).to.exist; + expect(userSync[0].type).to.be.equal('image'); + expect(userSync[0].url).to.be.equal('https://service.bidlab.ai/?c=o&m=sync'); + } + }); + }); +}); diff --git a/test/spec/modules/bidphysicsBidAdapter_spec.js b/test/spec/modules/bidphysicsBidAdapter_spec.js index ba93642ad81..fc15c39cf81 100644 --- a/test/spec/modules/bidphysicsBidAdapter_spec.js +++ b/test/spec/modules/bidphysicsBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/bidphysicsBidAdapter'; +import {spec} from 'modules/bidphysicsBidAdapter.js'; const REQUEST = { 'bidderCode': 'bidphysics', @@ -50,7 +50,7 @@ const RESPONSE = { 'adm': '', 'adid': '144762342', 'adomain': [ - 'http://dummydomain.com' + 'https://dummydomain.com' ], 'iurl': 'iurl', 'cid': '109', @@ -79,7 +79,7 @@ const RESPONSE = { 'adm': '', 'adid': '144762342', 'adomain': [ - 'http://dummydomain.com' + 'https://dummydomain.com' ], 'iurl': 'iurl', 'cid': '109', diff --git a/test/spec/modules/bizzclickBidAdapter_spec.js b/test/spec/modules/bizzclickBidAdapter_spec.js deleted file mode 100644 index 6f518f32ccf..00000000000 --- a/test/spec/modules/bizzclickBidAdapter_spec.js +++ /dev/null @@ -1,117 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/bizzclickBidAdapter'; - -describe('BizzclickBidAdapter', function () { - let bid = { - bidId: '67d581a232281d', - bidder: 'bizzclickBidAdapter', - bidderRequestId: 'a7837c9145e136', - params: { - placementId: 0, - type: 'banner' - }, - placementCode: 'placementId', - auctionId: 'bfe951372e62-a92d-4cf1-869f-d24029', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-1b244bbfb5' - }; - - describe('isBidRequestValid', function () { - it('Should return true when placement_id can be cast to a number', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false when placement_id is not a number', function () { - bid.params.placementId = 'aaa'; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//supply.bizzclick.com/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placements = data['placements']; - for (let i = 0; i < placements.length; i++) { - let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'type', 'sizes'); - expect(placement.placementId).to.be.a('number'); - expect(placement.bidId).to.be.a('string'); - expect(placement.type).to.be.a('string'); - expect(placement.sizes).to.be.an('array'); - } - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - let resObject = { - body: [ { - requestId: '123', - mediaType: 'banner', - cpm: 0.3, - width: 320, - height: 50, - ad: '

Hello ad

', - ttl: 1000, - creativeId: '123asd', - netRevenue: true, - currency: 'USD' - }] - }; - let serverResponses = spec.interpretResponse(resObject); - it('Returns an array of valid server responses if response object is valid', function () { - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType'); - expect(dataItem.requestId).to.be.a('string'); - expect(dataItem.cpm).to.be.a('number'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); - expect(dataItem.ad).to.be.a('string'); - expect(dataItem.ttl).to.be.a('number'); - expect(dataItem.creativeId).to.be.a('string'); - expect(dataItem.netRevenue).to.be.a('boolean'); - expect(dataItem.currency).to.be.a('string'); - expect(dataItem.mediaType).to.be.a('string'); - } - it('Returns an empty array if invalid response is passed', function () { - serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - }); - - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//supply.bizzclick.com/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/brainyBidAdapter_spec.js b/test/spec/modules/brainyBidAdapter_spec.js deleted file mode 100644 index a3ce90d927a..00000000000 --- a/test/spec/modules/brainyBidAdapter_spec.js +++ /dev/null @@ -1,128 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/brainyBidAdapter'; - -const URL = '//proparm.jp/ssp/p/pbjs'; -const BIDDER_CODE = 'brainy'; - -const validBidReq = { - bidder: BIDDER_CODE, - params: { - accountID: '12345', - slotID: '12345' - } -}; - -const invalidBidReq = { - bidder: BIDDER_CODE, - params: { - accountID: '', - slotID: '' - } -}; - -const bidReq = [{ - bidder: BIDDER_CODE, - params: { - accountID: '12345', - slotID: '12345' - } -}]; - -const correctReq = { - accountID: '12345', - slotID: '12345' -}; - -const bidResponse = { - ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223', - adm: '', - syncUrl: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34', - cpm: 100, - height: 250, - width: 300 -}; - -const bidSyncResponse = [{ - body: { - ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223', - adm: '', - syncUrl: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34', - cpm: 100, - height: 250, - width: 300 - } -}]; - -const invalidSyncBidResponse = [{ - body: { - ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223', - adm: '', - syncUrl: 'null', - cpm: 100, - height: 250, - width: 300 - } -}]; - -describe('brainy Adapter', function () { - describe('request', function () { - it('should validate bid request', function () { - expect(spec.isBidRequestValid(validBidReq)).to.equal(true); - }); - it('should not validate incorrect bid request', function () { - expect(spec.isBidRequestValid(invalidBidReq)).to.equal(false); - }); - }); - describe('build request', function () { - it('Verify bid request', function () { - const request = spec.buildRequests(bidReq); - expect(request[0].method).to.equal('GET'); - expect(request[0].url).to.equal(URL); - expect(request[0].data).to.match(new RegExp(`${correctReq.accountID}`)); - expect(request[0].data).to.match(new RegExp(`${correctReq.slotID}`)); - }); - }); - - describe('interpretResponse', function () { - it('should build bid array', function () { - const request = spec.buildRequests(bidReq); - const result = spec.interpretResponse({body: bidResponse}, request[0]); - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const request = spec.buildRequests(bidReq); - const result = spec.interpretResponse({body: bidResponse}, request[0]); - const bid = result[0]; - - expect(bid.cpm).to.equal(bidResponse.cpm); - expect(bid.width).to.equal(bidResponse.width); - expect(bid.height).to.equal(bidResponse.height); - }); - }); - - describe('spec.getUserSyncs', function () { - let syncOptions - beforeEach(function () { - syncOptions = { - enabledBidders: ['brainy'], - pixelEnabled: true - } - }); - it('sucess with usersync url', function () { - const result = []; - result.push({type: 'image', url: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34'}); - expect(spec.getUserSyncs(syncOptions, bidSyncResponse)).to.deep.equal(result); - }); - - it('sucess without usersync url', function () { - const result = []; - expect(spec.getUserSyncs(syncOptions, invalidSyncBidResponse)).to.deep.equal(result); - }); - it('empty response', function () { - const serverResponse = [{body: {}}]; - const result = []; - expect(spec.getUserSyncs(syncOptions, serverResponse)).to.deep.equal(result); - }); - }); -}); diff --git a/test/spec/modules/bridgewellBidAdapter_spec.js b/test/spec/modules/bridgewellBidAdapter_spec.js index 6ca9675a1bb..644f468abe8 100644 --- a/test/spec/modules/bridgewellBidAdapter_spec.js +++ b/test/spec/modules/bridgewellBidAdapter_spec.js @@ -1,172 +1,8 @@ import { expect } from 'chai'; -import { spec } from 'modules/bridgewellBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { spec } from 'modules/bridgewellBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('bridgewellBidAdapter', function () { - let bidRequests = [ - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ', - 'cpmWeight': 0.5 - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - 'cpmWeight': -0.5 - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [728, 90], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - }, - 'adUnitCode': 'adunit-code-2', - 'mediaTypes': { - 'banner': { - 'sizes': [728, 90] - } - }, - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [1, 1], - 'mediaTypes': { - 'native': { - 'title': { - 'required': true, - 'len': 15 - }, - 'body': { - 'required': true - }, - 'image': { - 'required': true, - 'sizes': [150, 150] - }, - 'icon': { - 'required': true, - 'sizes': [50, 50] - }, - 'clickUrl': { - 'required': true - }, - 'cta': { - 'required': true - }, - 'sponsoredBy': { - 'required': true - } - } - }, - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [1, 1], - 'mediaTypes': { - 'native': { - 'title': { - 'required': false, - 'len': 15 - }, - 'body': { - 'required': false - }, - 'image': { - 'required': false, - 'sizes': [150, 150] - }, - 'icon': { - 'required': false, - 'sizes': [50, 50] - }, - 'clickUrl': { - 'required': false - }, - 'cta': { - 'required': false - }, - 'sponsoredBy': { - 'required': false - } - } - }, - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; const adapter = newBidder(spec); describe('inherited functions', function () { @@ -176,113 +12,108 @@ describe('bridgewellBidAdapter', function () { }); describe('isBidRequestValid', function () { - let bidWithoutCpmWeight = { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - let bidWithCorrectCpmWeight = { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk', - 'cpmWeight': 0.5 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - let bidWithUncorrectCpmWeight = { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk', - 'cpmWeight': -1.0 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - let bidWithZeroCpmWeight = { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk', - 'cpmWeight': 0 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidWithoutCpmWeight)).to.equal(true); - expect(spec.isBidRequestValid(bidWithCorrectCpmWeight)).to.equal(true); - expect(spec.isBidRequestValid(bidWithUncorrectCpmWeight)).to.equal(false); - expect(spec.isBidRequestValid(bidWithZeroCpmWeight)).to.equal(false); + const validTag = { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk' + }, + }; + expect(spec.isBidRequestValid(validTag)).to.equal(true); }); it('should return false when required params not found', function () { - expect(spec.isBidRequestValid({})).to.equal(false); - }); - - it('should return false when required params are not passed', function () { - let bidWithoutCpmWeight = Object.assign({}, bidWithoutCpmWeight); - let bidWithCorrectCpmWeight = Object.assign({}, bidWithCorrectCpmWeight); - let bidWithUncorrectCpmWeight = Object.assign({}, bidWithUncorrectCpmWeight); - let bidWithZeroCpmWeight = Object.assign({}, bidWithZeroCpmWeight); - - delete bidWithoutCpmWeight.params; - delete bidWithCorrectCpmWeight.params; - delete bidWithUncorrectCpmWeight.params; - delete bidWithZeroCpmWeight.params; - - bidWithoutCpmWeight.params = { - 'ChannelID': 0 - }; - - bidWithCorrectCpmWeight.params = { - 'ChannelID': 0 - }; - - bidWithUncorrectCpmWeight.params = { - 'ChannelID': 0 + const invalidTag = { + 'bidder': 'bridgewell', + 'params': {}, }; + expect(spec.isBidRequestValid(invalidTag)).to.equal(false); + }); - bidWithZeroCpmWeight.params = { - 'ChannelID': 0 + it('should return false when required params are empty', function () { + const invalidTag = { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': '', + }, }; - - expect(spec.isBidRequestValid(bidWithoutCpmWeight)).to.equal(false); - expect(spec.isBidRequestValid(bidWithCorrectCpmWeight)).to.equal(false); - expect(spec.isBidRequestValid(bidWithUncorrectCpmWeight)).to.equal(false); - expect(spec.isBidRequestValid(bidWithZeroCpmWeight)).to.equal(false); + expect(spec.isBidRequestValid(invalidTag)).to.equal(false); }); }); describe('buildRequests', function () { + const bidRequests = [ + { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', + }, + 'adUnitCode': 'adunit-code-2', + 'mediaTypes': { + 'banner': { + 'sizes': [728, 90] + } + }, + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [1, 1], + 'mediaTypes': { + 'native': { + 'title': { + 'required': true, + 'len': 15 + }, + 'body': { + 'required': true + }, + 'image': { + 'required': true, + 'sizes': [150, 150] + }, + 'icon': { + 'required': true, + 'sizes': [50, 50] + }, + 'clickUrl': { + 'required': true + }, + 'cta': { + 'required': true + }, + 'sponsoredBy': { + 'required': true + } + } + }, + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + it('should attach valid params to the tag', function () { - const request = spec.buildRequests(bidRequests); + const bidderRequest = { + refererInfo: { + referer: 'https://www.bridgewell.com/' + } + } + const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; - const adUnits = payload.adUnits; expect(payload).to.be.an('object'); - expect(adUnits).to.be.an('array'); - for (let i = 0, max_i = adUnits.length; i < max_i; i++) { - let adUnit = adUnits[i]; - expect(adUnit).to.have.property('ChannelID').that.is.a('string'); + expect(payload.adUnits).to.be.an('array'); + expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/'); + for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) { + expect(payload.adUnits[i]).to.have.property('ChannelID').that.is.a('string'); + expect(payload.adUnits[i]).to.have.property('adUnitCode').and.to.equal('adunit-code-2'); } }); @@ -294,96 +125,54 @@ describe('bridgewellBidAdapter', function () { }); describe('interpretResponse', function () { - const request = spec.buildRequests(bidRequests); - const serverResponses = [ - { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'mediaType': 'banner', - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 728, - 'height': 90, - 'mediaType': 'banner', - 'ad': '
test 728x90
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '8f12c646-3b87-4326-a837-c2a76999f168', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'mediaType': 'banner', - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '8f12c646-3b87-4326-a837-c2a76999f168', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'mediaType': 'banner', - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 728, - 'height': 90, - 'mediaType': 'banner', - 'ad': '
test 728x90
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 728, - 'height': 90, - 'mediaType': 'banner', - 'ad': '
test 728x90
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 728, - 'height': 90, - 'mediaType': 'banner', - 'ad': '
test 728x90
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, + const nativeBidRequests = { + validBidRequests: [ + { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [1, 1], + 'mediaTypes': { + 'native': { + 'title': { + 'required': true, + 'len': 15 + }, + 'body': { + 'required': true + }, + 'image': { + 'required': true, + 'sizes': [150, 150] + }, + 'icon': { + 'required': true, + 'sizes': [50, 50] + }, + 'clickUrl': { + 'required': true + }, + 'cta': { + 'required': true + }, + 'sponsoredBy': { + 'required': true + } + } + }, + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + ] + }; + const nativeServerResponses = [ { 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', 'bidder_code': 'bridgewell', - 'cpm': 5.0, + 'cpm': 7.0, 'width': 1, 'height': 1, 'mediaType': 'native', @@ -405,317 +194,373 @@ describe('bridgewellBidAdapter', function () { 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'ttl': 360, + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' }, + ]; + const bannerBidRequests = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da321', + }, + ] + }; + const bannerServerResponses = [ { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', 'bidder_code': 'bridgewell', 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', 'ttl': 360, 'netRevenue': true, 'currency': 'NTD' - } + }, ]; it('should return all required parameters', function () { - const result = spec.interpretResponse({'body': serverResponses}, request); - result.every(res => expect(res.cpm).to.be.a('number')); - result.every(res => expect(res.width).to.be.a('number')); - result.every(res => expect(res.height).to.be.a('number')); - result.every(res => expect(res.ttl).to.be.a('number')); - result.every(res => expect(res.netRevenue).to.be.a('boolean')); - result.every(res => expect(res.currency).to.be.a('string')); - result.every(res => { - if (res.ad) { - expect(res.ad).to.be.an('string'); - } else if (res.native) { - expect(res.native).to.be.an('object'); - } - }); + const result = spec.interpretResponse({ 'body': nativeServerResponses }, nativeBidRequests); + + expect(result[0].requestId).to.equal('3150ccb55da321'); + expect(result[0].cpm).to.equal(7.0); + expect(result[0].width).to.equal(1); + expect(result[0].height).to.equal(1); + expect(result[0].ttl).to.equal(400); + expect(result[0].creativeId).to.equal('0e4048d3-5c74-4380-a21a-00ba35629f7d'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].currency).to.equal('NTD'); + expect(result[0].mediaType).to.equal('native'); + expect(result[0].native.image.url).to.equal('https://img.scupio.com/test/test-image.jpg'); + }); + + it('should return all required parameters banner', function () { + const result = spec.interpretResponse({ 'body': bannerServerResponses }, bannerBidRequests); + + expect(result[0].requestId).to.equal('3150ccb55da321'); + expect(result[0].cpm).to.equal(5.0); + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].ttl).to.equal(360); + expect(result[0].creativeId).to.equal('e5b10774-32bf-4931-85ee-05095e8cff21'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].currency).to.equal('NTD'); + expect(result[0].mediaType).to.equal('banner'); + expect(result[0].ad).to.equal('
test 300x250
'); }); it('should give up bid if server response is undefiend', function () { - const result = spec.interpretResponse({'body': undefined}, request); + let result = spec.interpretResponse({ 'body': undefined }, bannerBidRequests); + expect(result).to.deep.equal([]); }); it('should give up bid if request sizes is missing', function () { - let target = Object.assign({}, serverResponses[0]); - target.consumed = false; - const result = spec.interpretResponse({'body': [target]}, spec.buildRequests([{ - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk' - }, - 'adUnitCode': 'adunit-code-1', - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }])); + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': {} + }, + 'bidId': '3150ccb55da321', + }, + ] + }; + const result = spec.interpretResponse({ 'body': bannerServerResponses }, request); expect(result).to.deep.equal([]); }); it('should give up bid if response sizes is invalid', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [728, 90] + } + }, + 'bidId': '3150ccb55da321', + }, + ] }; - - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': bannerServerResponses }, request); expect(result).to.deep.equal([]); }); it('should give up bid if cpm is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'width': 300, - 'height': 250, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + const response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if width or height is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + const response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); + expect(result).to.deep.equal([]); }); it('should give up bid if ad is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'mediaType': 'banner', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + const response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if revenue mode is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'ad': '
test 300x250
', - 'ttl': 360, - 'currency': 'NTD' - }; + const response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 360, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if currency is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true - }; + const response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if mediaType is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + const response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 300, + 'height': 250, + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if mediaType is not support', function () { + const responses = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 300, + 'height': 250, + 'mediaType': 'superNiceAd', + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': responses }, bannerBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if property native of mediaType native is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if native title is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if native title is too long', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-titletest-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-titletest-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if native body is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); + }); - it('should give up bid if native image url is missing', function () { - let target = { + it('should give up bid if native image url is missing', function () { + const response = [ + { 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', 'bidder_code': 'bridgewell', - 'cpm': 5.0, + 'cpm': 7.0, 'width': 1, 'height': 1, 'mediaType': 'native', @@ -736,429 +581,639 @@ describe('bridgewellBidAdapter', function () { 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'ttl': 360, + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' - }; + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); + expect(result).to.deep.equal([]); }); it('should give up bid if native image is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); - it('should give up bid if native image url is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + it('should give up bid if native image is empty', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': {}, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); - it('should give up bid if native image sizes is unmatch', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg' - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + it('should give up bid if native image sizes is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg' + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if native sponsoredBy is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if native icon is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); it('should give up bid if native icon url is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'width': 50, - 'height': 50 + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native icon sizes is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); - it('should give up bid if native icon sizes is unmatch', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 + it('should give up bid if native clickUrl is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg' + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native clickTrackers is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native clickTrackers is empty', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': [], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); - it('should give up bid if native clickUrl is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + it('should give up bid if native impressionTrackers is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], }, - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); - it('should give up bid if native clickTrackers is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + it('should give up bid if native impressionTrackers is empty', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': [] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); }); - it('should give up bid if native clickTrackers is empty', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + it('should contain every request bid id in responses', function () { + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da321', }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': [], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da322', + } + ], + }; + const response = [{ + 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' - }; + }, { + 'id': '8a740063-6820-45e4-b01f-34ce9b38e858', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }]; + const result = spec.interpretResponse({ 'body': response }, request); + let actualBidId = result.map(obj => obj.requestId); + let expectedBidId = ['3150ccb55da321', '3150ccb55da322']; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]); }); - it('should give up bid if native impressionTrackers is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + it('should have 2 consumed responses when two requests with same sizes are given', function () { + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da321', }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'] - }, - 'ttl': 360, + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da322', + } + ], + }; + const response = [{ + 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' + }, { + 'id': '8a740063-6820-45e4-b01f-34ce9b38e858', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }]; + const reducer = function(accumulator, currentValue) { + if (currentValue.consumed) accumulator++; + return accumulator; }; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + spec.interpretResponse({ 'body': response }, request); + expect(response.reduce(reducer, 0)).to.equal(2); }); - it('should give up bid if native impressionTrackers is empty', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 + it('should use adUnitCode to build bidResponses', function () { + const request = { + validBidRequests: [ + { + 'adUnitCode': 'div-gpt-ad-1564632520056-0', + 'bidId': '3150ccb55da321', }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': [] - }, - 'ttl': 360, + { + 'adUnitCode': 'div-gpt-ad-1564632520056-1', + 'bidId': '3150ccb55da322', + } + ], + }; + const response = [{ + 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9', + 'bidder_code': 'bridgewell', + 'adUnitCode': 'div-gpt-ad-1564632520056-0', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' - }; + }, { + 'id': '8a740063-6820-45e4-b01f-34ce9b38e858', + 'bidder_code': 'bridgewell', + 'adUnitCode': 'div-gpt-ad-1564632520056-1', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }]; + const result = spec.interpretResponse({ 'body': response }, request); + let actualBidId = result.map(obj => obj.requestId); + let expectedBidId = ['3150ccb55da321', '3150ccb55da322']; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]); }); - it('should give up bid if mediaType is not support', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + it('should use size to match when adUnitCode is empty string in server response', function () { + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'adUnitCode': 'div-gpt-ad-1564632520056-0', + 'bidId': '3150ccb55da321', + }, + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'adUnitCode': 'div-gpt-ad-1564632520056-1', + 'bidId': '3150ccb55da322', + } + ], + }; + const response = [{ + 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9', 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'superNiceAd', - 'ttl': 360, + 'adUnitCode': '', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' - }; + }, { + 'id': '8a740063-6820-45e4-b01f-34ce9b38e858', + 'bidder_code': 'bridgewell', + 'adUnitCode': '', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }]; + const result = spec.interpretResponse({ 'body': response }, request); + let actualBidId = result.map(obj => obj.requestId); + let expectedBidId = ['3150ccb55da321', '3150ccb55da322']; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]); }); }); }); diff --git a/test/spec/modules/brightcomBidAdapter_spec.js b/test/spec/modules/brightcomBidAdapter_spec.js index 73186250f5b..6477e94d9d6 100644 --- a/test/spec/modules/brightcomBidAdapter_spec.js +++ b/test/spec/modules/brightcomBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import * as utils from 'src/utils'; -import { spec } from 'modules/brightcomBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import * as utils from 'src/utils.js'; +import { spec } from 'modules/brightcomBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const URL = 'https://brightcombid.marphezis.com/hb'; @@ -45,10 +45,11 @@ describe('brightcomBidAdapter', function() { 'publisherId': 1234567 }, 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '5fb26ac22bde4', 'bidderRequestId': '4bf93aeb730cb9', 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e' @@ -71,10 +72,11 @@ describe('brightcomBidAdapter', function() { 'publisherId': 1234567 }, 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, 'bidId': '5fb26ac22bde4', 'bidderRequestId': '4bf93aeb730cb9', 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e', @@ -84,7 +86,7 @@ describe('brightcomBidAdapter', function() { expect(spec.isBidRequestValid(bid)).to.equal(true); }); - it('should return false when tagid not passed correctly', function () { + it('should return false when publisherId not passed correctly', function () { bid.params.publisherId = undefined; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -114,7 +116,7 @@ describe('brightcomBidAdapter', function() { }); it('accepts a single array as a size', function() { - bidRequests[0].sizes = [300, 250]; + bidRequests[0].mediaTypes.banner.sizes = [300, 250]; const request = spec.buildRequests(bidRequests); const payload = JSON.parse(request.data); expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}]); @@ -169,7 +171,7 @@ describe('brightcomBidAdapter', function() { context('when width or height of the element is zero', function() { it('try to use alternative values', function() { Object.assign(element, { width: 0, height: 0 }); - bidRequests[0].sizes = [[800, 2400]]; + bidRequests[0].mediaTypes.banner.sizes = [[800, 2400]]; const request = spec.buildRequests(bidRequests); const payload = JSON.parse(request.data); expect(payload.imp[0].banner.ext.viewability).to.equal(25); diff --git a/test/spec/modules/britepoolIdSystem_spec.js b/test/spec/modules/britepoolIdSystem_spec.js new file mode 100644 index 00000000000..2c6dd234a90 --- /dev/null +++ b/test/spec/modules/britepoolIdSystem_spec.js @@ -0,0 +1,67 @@ +import { expect } from 'chai'; +import {britepoolIdSubmodule} from 'modules/britepoolIdSystem.js'; + +describe('BritePool Submodule', () => { + const api_key = '1111'; + const aaid = '4421ea96-34a9-45df-a4ea-3c41a48a18b1'; + const idfa = '2d1c4fac-5507-4e28-991c-ca544e992dba'; + const bpid = '279c0161-5152-487f-809e-05d7f7e653fd'; + const url_override = 'https://override'; + const getter_override = function(params) { + return JSON.stringify({ 'primaryBPID': bpid }); + }; + const getter_callback_override = function(params) { + return callback => { + callback(JSON.stringify({ 'primaryBPID': bpid })); + }; + }; + + it('sends x-api-key in header and one identifier', () => { + const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid }); + assert(errors.length === 0, errors); + expect(headers['x-api-key']).to.equal(api_key); + expect(params).to.eql({ aaid }); + }); + + it('sends x-api-key in header and two identifiers', () => { + const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid, idfa }); + assert(errors.length === 0, errors); + expect(headers['x-api-key']).to.equal(api_key); + expect(params).to.eql({ aaid, idfa }); + }); + + it('allows call without api_key', () => { + const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ aaid, idfa }); + expect(params).to.eql({ aaid, idfa }); + expect(errors.length).to.equal(0); + }); + + it('test url override', () => { + const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid, url: url_override }); + expect(url).to.equal(url_override); + // Making sure it did not become part of params + expect(params.url).to.be.undefined; + }); + + it('test getter override with value', () => { + const { params, headers, url, getter, errors } = britepoolIdSubmodule.createParams({ api_key, aaid, url: url_override, getter: getter_override }); + expect(getter).to.equal(getter_override); + // Making sure it did not become part of params + expect(params.getter).to.be.undefined; + const response = britepoolIdSubmodule.getId({ api_key, aaid, url: url_override, getter: getter_override }); + assert.deepEqual(response, { id: { 'primaryBPID': bpid } }); + }); + + it('test getter override with callback', done => { + const { params, headers, url, getter, errors } = britepoolIdSubmodule.createParams({ api_key, aaid, url: url_override, getter: getter_callback_override }); + expect(getter).to.equal(getter_callback_override); + // Making sure it did not become part of params + expect(params.getter).to.be.undefined; + const response = britepoolIdSubmodule.getId({ api_key, aaid, url: url_override, getter: getter_callback_override }); + expect(response.callback).to.not.be.undefined; + response.callback(result => { + assert.deepEqual(result, { 'primaryBPID': bpid }); + done(); + }); + }); +}); diff --git a/test/spec/modules/bucksenseBidAdapter_spec.js b/test/spec/modules/bucksenseBidAdapter_spec.js index 17b5c3ceff5..f49a63d2003 100644 --- a/test/spec/modules/bucksenseBidAdapter_spec.js +++ b/test/spec/modules/bucksenseBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/bucksenseBidAdapter'; +import {spec} from 'modules/bucksenseBidAdapter.js'; describe('Bucksense Adapter', function() { const BIDDER_CODE = 'bucksense'; @@ -75,11 +75,11 @@ describe('Bucksense Adapter', function() { 'auctionStart': 1557176022728, 'timeout': 1000, 'refererInfo': { - 'referer': 'http://stefanod.hera.pe/prebid/?pbjs_debug=true', + 'referer': 'https://stefanod.hera.pe/prebid/?pbjs_debug=true', 'reachedTop': true, 'numIframes': 0, 'stack': [ - 'http://stefanod.hera.pe/prebid/?pbjs_debug=true' + 'https://stefanod.hera.pe/prebid/?pbjs_debug=true' ] }, 'start': 1557176022731 @@ -104,12 +104,12 @@ describe('Bucksense Adapter', function() { beforeEach(function() { serverRequest = { 'method': 'POST', - 'url': 'https://prebid.bksn.se:445/prebidjs/', + 'url': 'https://prebid.bksn.se/prebidjs/', 'data': { 'pub_id': 'prebid.org', 'pl_id': '1000', 'secure': 0, - 'href': 'http://prebid.org/developers.html', + 'href': 'https://prebid.org/developers.html', 'bid_id': '27aaf8e96d9fd5', 'params': { 'placementId': '1000' diff --git a/test/spec/modules/buzzoolaBidAdapter_spec.js b/test/spec/modules/buzzoolaBidAdapter_spec.js index e6f22d1da20..8a04999219d 100644 --- a/test/spec/modules/buzzoolaBidAdapter_spec.js +++ b/test/spec/modules/buzzoolaBidAdapter_spec.js @@ -1,8 +1,8 @@ import {expect} from 'chai'; -import {spec} from 'modules/buzzoolaBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import {executeRenderer, Renderer} from '../../../src/Renderer'; -import {deepClone} from '../../../src/utils'; +import {spec} from 'modules/buzzoolaBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {executeRenderer, Renderer} from '../../../src/Renderer.js'; +import {deepClone} from '../../../src/utils.js'; const ENDPOINT = 'https://exchange.buzzoola.com/ssp/prebidjs'; const RENDERER_SRC = 'https://tube.buzzoola.com/new/build/buzzlibrary.js'; diff --git a/test/spec/modules/byplayBidAdapter_spec.js b/test/spec/modules/byplayBidAdapter_spec.js new file mode 100644 index 00000000000..57aad403c4e --- /dev/null +++ b/test/spec/modules/byplayBidAdapter_spec.js @@ -0,0 +1,93 @@ +import { expect } from 'chai'; +import { spec } from 'modules/byplayBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as bidderFactory from 'src/adapters/bidderFactory.js'; + +describe('byplayBidAdapter', () => { + describe('isBidRequestValid', () => { + describe('exist sectionId', () => { + const bid = { + 'bidder': 'byplay', + 'params': { + 'sectionId': '11111' + }, + }; + + it('should equal true', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + }); + + describe('not exist sectionId', () => { + const bid = { + 'bidder': 'byplay', + 'params': { + }, + }; + + it('should equal false', () => { + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + }); + + describe('buildRequests', () => { + const bids = [ + { + 'bidder': 'byplay', + 'bidId': '1234', + 'params': { + 'sectionId': '1111' + }, + } + ]; + + const request = spec.buildRequests(bids); + + it('should return POST', () => { + expect(request[0].method).to.equal('POST'); + }); + + it('should return data', () => { + expect(request[0].data).to.equal('{"requestId":"1234","sectionId":"1111"}'); + }); + }); + + describe('interpretResponse', () => { + const serverResponse = { + body: { + 'cpm': 1500, + 'width': 320, + 'height': 180, + 'netRevenue': true, + 'creativeId': '1', + 'requestId': '209c1fb5ad88f5', + 'vastXml': '' + } + }; + + const bidderRequest = { + 'method': 'GET', + 'url': 'https://tasp0g98f2.execute-api.ap-northeast-1.amazonaws.com/v1/bidder', + 'data': '{"requestId":"209c1fb5ad88f5","sectionId":7986}' + }; + + const result = spec.interpretResponse(serverResponse, bidderRequest); + + it('should return Array', () => { + expect(Array.isArray(result)).to.equal(true); + }); + + it('should get the correct bid response', () => { + expect(result[0].cpm).to.equal(1500); + expect(result[0].creativeId).to.equal('1'); + expect(result[0].width).to.equal(320); + expect(result[0].height).to.equal(180); + expect(result[0].mediaType).to.equal('video'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].requestId).to.equal('209c1fb5ad88f5'); + expect(result[0].ttl).to.equal(3000); + expect(result[0].vastXml).to.equal(''); + }); + }); +}); diff --git a/test/spec/modules/c1xBidAdapter_spec.js b/test/spec/modules/c1xBidAdapter_spec.js index 268ad46d0ce..00741abda7a 100644 --- a/test/spec/modules/c1xBidAdapter_spec.js +++ b/test/spec/modules/c1xBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { c1xAdapter } from 'modules/c1xBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { c1xAdapter } from 'modules/c1xBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const ENDPOINT = 'https://ht.c1exchange.com/ht'; const BIDDER_CODE = 'c1x'; @@ -106,13 +106,13 @@ describe('C1XAdapter', function () { { 'params': { 'siteId': '9999', - 'pageurl': 'http://c1exchange.com/' + 'pageurl': 'https://c1exchange.com/' } }); const request = c1xAdapter.buildRequests([bidRequest]); const originalPayload = parseRequest(request.data); const payloadObj = JSON.parse(originalPayload); - expect(payloadObj.pageurl).to.equal('http://c1exchange.com/'); + expect(payloadObj.pageurl).to.equal('https://c1exchange.com/'); }); it('should convert GDPR Consent to proper form and attach to request', function () { diff --git a/test/spec/modules/categoryTranslation_spec.js b/test/spec/modules/categoryTranslation_spec.js index 17cc07269b0..555fe3d6357 100644 --- a/test/spec/modules/categoryTranslation_spec.js +++ b/test/spec/modules/categoryTranslation_spec.js @@ -1,6 +1,6 @@ -import { getAdserverCategoryHook, initTranslation } from 'modules/categoryTranslation'; -import { config } from 'src/config'; -import * as utils from 'src/utils'; +import { getAdserverCategoryHook, initTranslation, storage } from 'modules/categoryTranslation.js'; +import { config } from 'src/config.js'; +import * as utils from 'src/utils.js'; import { expect } from 'chai'; describe('category translation', function () { @@ -9,7 +9,7 @@ describe('category translation', function () { beforeEach(function () { fakeTranslationServer = sinon.fakeServer.create(); - getLocalStorageStub = sinon.stub(utils, 'getDataFromLocalStorage'); + getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); }); afterEach(function() { diff --git a/test/spec/modules/ccxBidAdapter_spec.js b/test/spec/modules/ccxBidAdapter_spec.js index a89a0402a97..f14612629b1 100644 --- a/test/spec/modules/ccxBidAdapter_spec.js +++ b/test/spec/modules/ccxBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/ccxBidAdapter'; -import * as utils from 'src/utils'; +import { spec } from 'modules/ccxBidAdapter.js'; +import * as utils from 'src/utils.js'; describe('ccxAdapter', function () { let bids = [ @@ -248,6 +248,31 @@ describe('ccxAdapter', function () { }); }); + describe('GDPR conformity', function () { + it('should transmit correct data', function () { + let bidsClone = utils.deepClone(bids); + let gdprConsent = { + consentString: 'awefasdfwefasdfasd', + gdprApplies: true + }; + let response = spec.buildRequests(bidsClone, {'bids': bidsClone, 'gdprConsent': gdprConsent}); + let data = JSON.parse(response.data); + + expect(data.regs.ext.gdpr).to.equal(1); + expect(data.user.ext.consent).to.equal('awefasdfwefasdfasd'); + }); + }); + + describe('GDPR absence conformity', function () { + it('should transmit correct data', function () { + let response = spec.buildRequests(bids, {bids}); + let data = JSON.parse(response.data); + + expect(data.regs).to.be.undefined; + expect(data.user).to.be.undefined; + }); + }); + let response = { id: '0b9de793-8eda-481e-a548-c187d58b28d9', seatbid: [ diff --git a/test/spec/modules/cedatoBidAdapter_spec.js b/test/spec/modules/cedatoBidAdapter_spec.js index d6c1333c262..a7f4875afff 100644 --- a/test/spec/modules/cedatoBidAdapter_spec.js +++ b/test/spec/modules/cedatoBidAdapter_spec.js @@ -1,10 +1,10 @@ import {expect} from 'chai'; -import {spec} from 'modules/cedatoBidAdapter'; +import {spec} from 'modules/cedatoBidAdapter.js'; describe('the cedato adapter', function () { function getValidBidObject() { return { - bidId: 123, + bidId: '2f4a613a702b6c', mediaTypes: { banner: { sizes: [[300, 250]] @@ -33,24 +33,42 @@ describe('the cedato adapter', function () { expect(result).to.equal(false); }); }); + describe('buildRequests', function() { var bid, bidRequestObj; beforeEach(function() { bid = getValidBidObject(); - bidRequestObj = {refererInfo: {referer: 'prebid.js'}}; + bidRequestObj = { + refererInfo: {referer: 'prebid.js'}, + gdprConsent: { + consentString: 'test-string', + gdprApplies: true + }, + uspConsent: '1NYN' + }; }); it('should build a very basic request', function() { - var request = spec.buildRequests([bid], bidRequestObj); + var [request] = spec.buildRequests([bid], bidRequestObj); expect(request.method).to.equal('POST'); }); + + it('should pass gdpr and usp strings to server', function() { + var [request] = spec.buildRequests([bid], bidRequestObj); + var payload = JSON.parse(request.data); + expect(payload.gdpr_consent).to.not.be.undefined; + expect(payload.gdpr_consent.consent_string).to.equal(bidRequestObj.gdprConsent.consentString); + expect(payload.gdpr_consent.consent_required).to.equal(bidRequestObj.gdprConsent.gdprApplies); + expect(payload.us_privacy).to.equal(bidRequestObj.uspConsent); + }); }); describe('interpretResponse', function() { - var serverResponse; + var bid, serverResponse, bidderRequest; beforeEach(function() { + bid = getValidBidObject(); serverResponse = { body: { bidid: '0.36157306192821', @@ -65,9 +83,9 @@ describe('the cedato adapter', function () { }, id: '0.75549202124378', adomain: 'cedato.com', - uuid: '2f4a613a702b6c', + uuid: bid.bidId, crid: '1450133326', - adm: "
\n\n\n", + adm: "
\n\n\n", h: 250, w: 300, price: '0.1' @@ -77,11 +95,39 @@ describe('the cedato adapter', function () { cur: 'USD' } }; + bidderRequest = { + bids: [bid] + }; }); it('should return an array of bid responses', function() { - var responses = spec.interpretResponse(serverResponse); + var responses = spec.interpretResponse(serverResponse, {bidderRequest}); expect(responses).to.be.an('array').with.length(1); }); }); + + describe('getUserSyncs', function() { + var bid; + + beforeEach(function() { + bid = getValidBidObject(); + }); + + it('should sync with iframe', function() { + var syncs = spec.getUserSyncs({ iframeEnabled: true }, null, { + consentString: '', + gdprApplies: true + }); + + expect(syncs).to.be.an('array').with.length(1); + expect(syncs[0].type).to.equal('iframe'); + }); + + it('should sync with image', function() { + var syncs = spec.getUserSyncs({ pixelEnabled: true }); + + expect(syncs).to.be.an('array').with.length(1); + expect(syncs[0].type).to.equal('image'); + }); + }); }); diff --git a/test/spec/modules/cleanmedianetBidAdapter_spec.js b/test/spec/modules/cleanmedianetBidAdapter_spec.js index 09f76806fd7..5438f6c8701 100644 --- a/test/spec/modules/cleanmedianetBidAdapter_spec.js +++ b/test/spec/modules/cleanmedianetBidAdapter_spec.js @@ -1,15 +1,13 @@ -import { expect } from 'chai'; -import { spec } from 'modules/cleanmedianetBidAdapter'; -import { helper } from 'modules/cleanmedianetBidAdapter'; -import * as utils from 'src/utils'; -import { newBidder } from '../../../src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; +import {expect} from 'chai'; +import {spec, helper} from 'modules/cleanmedianetBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {newBidder} from '../../../src/adapters/bidderFactory.js'; const supplyPartnerId = '123'; const adapter = newBidder(spec); -describe('CleanmedianetAdapter', function() { - describe('Is String start with search ', function() { - it('check if a string started with', function() { +describe('CleanmedianetAdapter', function () { + describe('Is String start with search ', function () { + it('check if a string started with', function () { expect(helper.startsWith('cleanmediaads.com', 'cleanmediaads')).to.equal( true ); @@ -103,7 +101,7 @@ describe('CleanmedianetAdapter', function() { }, sizes: [[300, 250], [300, 600]], transactionId: 'a123456789', - refererInfo: { referer: 'http://examplereferer.com' }, + refererInfo: { referer: 'https://examplereferer.com' }, gdprConsent: { consentString: 'some string', gdprApplies: true @@ -131,15 +129,12 @@ describe('CleanmedianetAdapter', function() { }); it('builds request correctly', function() { - let stub = sinon - .stub(utils, 'getTopWindowUrl') - .returns('http://www.test.com/page.html'); - let bidRequest2 = deepClone(bidRequest); - bidRequest2.refererInfo.referer = 'http://www.test.com/page.html'; + let bidRequest2 = utils.deepClone(bidRequest); + bidRequest2.refererInfo.referer = 'https://www.test.com/page.html'; let response = spec.buildRequests([bidRequest], bidRequest2)[0]; expect(response.data.site.domain).to.equal('www.test.com'); - expect(response.data.site.page).to.equal('http://www.test.com/page.html'); - expect(response.data.site.ref).to.equal('http://www.test.com/page.html'); + expect(response.data.site.page).to.equal('https://www.test.com/page.html'); + expect(response.data.site.ref).to.equal('https://www.test.com/page.html'); expect(response.data.imp.length).to.equal(1); expect(response.data.imp[0].id).to.equal(bidRequest.transactionId); expect(response.data.imp[0].instl).to.equal(0); @@ -173,7 +168,6 @@ describe('CleanmedianetAdapter', function() { expect(response.data.imp[0].bidfloor).to.equal( bidRequestWithBidfloorEquals1.params.bidfloor ); - stub.restore(); }); it('builds request banner object correctly', function() { @@ -290,7 +284,7 @@ describe('CleanmedianetAdapter', function() { sizes: [[300, 250], [300, 600]], transactionId: 'a123456789', bidId: '111', - refererInfo: { referer: 'http://examplereferer.com' } + refererInfo: { referer: 'https://examplereferer.com' } }; const videoBidRequest = { @@ -305,7 +299,7 @@ describe('CleanmedianetAdapter', function() { sizes: [[300, 250], [300, 600]], transactionId: 'a123456789', bidId: '111', - refererInfo: { referer: 'http://examplereferer.com' } + refererInfo: { referer: 'https://examplereferer.com' } }; const rtbResponse = { @@ -329,7 +323,7 @@ describe('CleanmedianetAdapter', function() { price: 2.016, adid: '579ef31bfa788b9d2000d562', nurl: - 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0&p=${AUCTION_PRICE}', + 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', adm: '', adomain: ['aaa.com'], @@ -339,7 +333,7 @@ describe('CleanmedianetAdapter', function() { h: 600, w: 120, ext: { - vast_url: 'http://my.vast.com', + vast_url: 'https://my.vast.com', utrk: [{ type: 'iframe', url: '//p.partner1.io/user/sync/1' }] } } @@ -355,7 +349,7 @@ describe('CleanmedianetAdapter', function() { price: 3, adid: '542jlhdfd2112jnjf3x', nurl: - 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0&p=${AUCTION_PRICE}', + 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', adm: ' ', adomain: ['bbb.com'], @@ -400,7 +394,7 @@ describe('CleanmedianetAdapter', function() { expect(ad0.cpm).to.equal(rtbResponse.seatbid[1].bid[0].price); expect(ad0.width).to.equal(rtbResponse.seatbid[1].bid[0].w); expect(ad0.height).to.equal(rtbResponse.seatbid[1].bid[0].h); - expect(ad0.ttl).to.equal(60 * 10); + expect(ad0.ttl).to.equal(360); expect(ad0.creativeId).to.equal(rtbResponse.seatbid[1].bid[0].crid); expect(ad0.netRevenue).to.equal(true); expect(ad0.currency).to.equal( @@ -424,7 +418,7 @@ describe('CleanmedianetAdapter', function() { expect(ad0.cpm).to.equal(rtbResponse.seatbid[0].bid[0].price); expect(ad0.width).to.equal(rtbResponse.seatbid[0].bid[0].w); expect(ad0.height).to.equal(rtbResponse.seatbid[0].bid[0].h); - expect(ad0.ttl).to.equal(60 * 10); + expect(ad0.ttl).to.equal(360); expect(ad0.creativeId).to.equal(rtbResponse.seatbid[0].bid[0].crid); expect(ad0.netRevenue).to.equal(true); expect(ad0.currency).to.equal( @@ -477,7 +471,7 @@ describe('CleanmedianetAdapter', function() { price: 5.0, adid: '1274', nurl: - 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', + 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1', adomain: [], adm: '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', @@ -508,7 +502,7 @@ describe('CleanmedianetAdapter', function() { ] } }; - const videoRequest = deepClone(videoBidRequest); + const videoRequest = utils.deepClone(videoBidRequest); videoRequest.mediaTypes.video.context = 'outstream'; const result = spec.interpretResponse( { body: videoResponse }, @@ -533,7 +527,7 @@ describe('CleanmedianetAdapter', function() { price: 5.0, adid: '1274', nurl: - 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', + 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1', adomain: [], adm: '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', diff --git a/test/spec/modules/clickforceBidAdapter_spec.js b/test/spec/modules/clickforceBidAdapter_spec.js index 3d4fc70c057..dad00f94641 100644 --- a/test/spec/modules/clickforceBidAdapter_spec.js +++ b/test/spec/modules/clickforceBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/clickforceBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/clickforceBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('ClickforceAdapter', function () { const adapter = newBidder(spec); @@ -175,7 +175,7 @@ describe('ClickforceAdapter', function () { } let userSync = spec.getUserSyncs(syncOptions); expect(userSync[0].type).to.equal('iframe'); - expect(userSync[0].url).to.equal('https://cdn.doublemax.net/js/capmapping.htm'); + expect(userSync[0].url).to.equal('https://cdn.holmesmind.com/js/capmapping.htm'); }); it('should register type is image', function () { @@ -184,7 +184,7 @@ describe('ClickforceAdapter', function () { } let userSync = spec.getUserSyncs(syncOptions); expect(userSync[0].type).to.equal('image'); - expect(userSync[0].url).to.equal('https://c.doublemax.net/cm'); + expect(userSync[0].url).to.equal('https://c.holmesmind.com/cm'); }); }); }); diff --git a/test/spec/modules/clicktripzBidAdapter_spec.js b/test/spec/modules/clicktripzBidAdapter_spec.js new file mode 100644 index 00000000000..fed94811c4e --- /dev/null +++ b/test/spec/modules/clicktripzBidAdapter_spec.js @@ -0,0 +1,152 @@ +import {expect} from 'chai'; +import {spec} from 'modules/clicktripzBidAdapter.js'; + +const ENDPOINT_URL = 'https://www.clicktripz.com/x/prebid/v1'; + +describe('clicktripzBidAdapter', function () { + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'clicktripz', + 'params': { + placementId: 'testPlacementId', + siteId: 'testSiteId' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '1234asdf1234', + 'bidderRequestId': '1234asdf1234asdf', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' + }; + + let bid2 = { + 'bidder': 'clicktripz', + 'params': { + placementId: 'testPlacementId' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '1234asdf1234', + 'bidderRequestId': '1234asdf1234asdf', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' + }; + + let bid3 = { + 'bidder': 'clicktripz', + 'params': { + siteId: 'testSiteId' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '1234asdf1234', + 'bidderRequestId': '1234asdf1234asdf', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are NOT found', function () { + expect(spec.isBidRequestValid(bid2)).to.equal(false); + expect(spec.isBidRequestValid(bid3)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let validBidRequests = [{ + 'bidder': 'clicktripz', + 'params': { + placementId: 'testPlacementId', + siteId: 'testSiteId' + }, + 'sizes': [ + [300, 250], + [300, 300] + ], + 'bidId': '23beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + }, { + 'bidder': 'clicktripz', + 'params': { + placementId: 'testPlacementId2', + siteId: 'testSiteId2' + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '25beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + }]; + + const request = spec.buildRequests(validBidRequests); + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('sends bid request to our endpoint at the correct URL', function () { + expect(request.url).to.equal(ENDPOINT_URL); + }); + it('sends bid request to our endpoint at the correct URL', function () { + expect(request.url).to.equal(ENDPOINT_URL); + }); + + it('transforms sizes into an array of strings. Pairs of concatenated sizes joined with an x', function () { + expect(request.data[0].sizes.toString()).to.equal('300x250,300x300'); + }); + it('transforms sizes into an array of strings. Pairs of concatenated sizes joined with an x', function () { + expect(request.data[1].sizes.toString()).to.equal('300x250'); + }); + + it('includes bidId, siteId, and placementId in payload', function () { + expect(request.data[0].bidId).to.equal('23beaa6af6cdde'); + expect(request.data[0].siteId).to.equal('testSiteId'); + expect(request.data[0].placementId).to.equal('testPlacementId'); + }); + it('includes bidId, siteId, and placementId in payload', function () { + expect(request.data[1].bidId).to.equal('25beaa6af6cdde'); + expect(request.data[1].siteId).to.equal('testSiteId2'); + expect(request.data[1].placementId).to.equal('testPlacementId2'); + }); + }); + + describe('interpretResponse', function () { + let serverResponse = { + body: [{ + 'bidId': 'bid-request-id', + 'ttl': 120, + 'netRevenue': true, + 'size': '300x200', + 'currency': 'USD', + 'adUrl': 'https://www.clicktripz.com/n3/crane/v0/render?t=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoiaHR0cHM6XC9cL3d3dy5jbGlja3RyaXB6LmNvbVwvY2xpY2sucGhwP2NhbXBhaWduSUQ9MTkxNTYmcHJlQ2hlY2tlZD0xJnB1Ymxpc2hlcklEPTM2MCZzZWFyY2hLZXk9N2M5MzQ0NzhlM2M1NTc3Y2EyN2ZmN2Y1NTg5N2NkMzkmc2VhcmNoRGlzcGxheVR5cGU9MSZkaXNwbGF5VHlwZT00JmNyZWF0aXZlVHlwZT1zaW5nbGUmaXNQb3BVbmRlcj0wJnBvc2l0aW9uPTEmdHlwZT0xJmNpdHk9TWFkcmlkJTJDK1NwYWluJmNoZWNrSW5EYXRlPTAzJTJGMDElMkYyMDIwJmNoZWNrT3V0RGF0ZT0wMyUyRjA1JTJGMjAyMCZndWVzdHM9MiZyb29tcz0xIn0.WBDGYr1qfkSvOuK02VpMW3iAua1E02jjDGDViFc2kaE', + 'creativeId': '25ef9876abc5681f153', + 'cpm': 50 + }] + }; + it('should get the correct bid response', function () { + let expectedResponse = [{ + 'requestId': 'bid-request-id', + 'cpm': 50, + 'netRevenue': true, + 'width': '300', + 'height': '200', + 'creativeId': '25ef9876abc5681f153', + 'currency': 'USD', + 'adUrl': 'https://www.clicktripz.com/n3/crane/v0/render?t=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoiaHR0cHM6XC9cL3d3dy5jbGlja3RyaXB6LmNvbVwvY2xpY2sucGhwP2NhbXBhaWduSUQ9MTkxNTYmcHJlQ2hlY2tlZD0xJnB1Ymxpc2hlcklEPTM2MCZzZWFyY2hLZXk9N2M5MzQ0NzhlM2M1NTc3Y2EyN2ZmN2Y1NTg5N2NkMzkmc2VhcmNoRGlzcGxheVR5cGU9MSZkaXNwbGF5VHlwZT00JmNyZWF0aXZlVHlwZT1zaW5nbGUmaXNQb3BVbmRlcj0wJnBvc2l0aW9uPTEmdHlwZT0xJmNpdHk9TWFkcmlkJTJDK1NwYWluJmNoZWNrSW5EYXRlPTAzJTJGMDElMkYyMDIwJmNoZWNrT3V0RGF0ZT0wMyUyRjA1JTJGMjAyMCZndWVzdHM9MiZyb29tcz0xIn0.WBDGYr1qfkSvOuK02VpMW3iAua1E02jjDGDViFc2kaE', + 'ttl': 120 + }]; + let result = spec.interpretResponse(serverResponse); + expect(result).to.deep.equal(expectedResponse); + }); + }); +}); diff --git a/test/spec/modules/coinzillaBidAdapter_spec.js b/test/spec/modules/coinzillaBidAdapter_spec.js index 7a0c745d57d..a3438b80126 100644 --- a/test/spec/modules/coinzillaBidAdapter_spec.js +++ b/test/spec/modules/coinzillaBidAdapter_spec.js @@ -1,6 +1,6 @@ import {assert, expect} from 'chai'; -import {spec} from 'modules/coinzillaBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/coinzillaBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; const ENDPOINT_URL = 'https://request.czilladx.com/serve/request.php'; @@ -57,8 +57,8 @@ describe('coinzillaBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; diff --git a/test/spec/modules/collectcentBidAdapter_spec.js b/test/spec/modules/collectcentBidAdapter_spec.js index 04c819992cd..0ab83a8024b 100644 --- a/test/spec/modules/collectcentBidAdapter_spec.js +++ b/test/spec/modules/collectcentBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/collectcentBidAdapter'; +import {spec} from '../../../modules/collectcentBidAdapter.js'; describe('Collectcent', function () { let bid = { @@ -38,7 +38,7 @@ describe('Collectcent', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//publishers.motionspots.com/?c=o&m=multi'); + expect(serverRequest.url).to.equal('https://publishers.motionspots.com/?c=o&m=multi'); }); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; @@ -112,7 +112,7 @@ describe('Collectcent', function () { expect(userSync[0].type).to.exist; expect(userSync[0].url).to.exist; expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//publishers.motionspots.com/?c=o&m=cookie'); + expect(userSync[0].url).to.be.equal('https://publishers.motionspots.com/?c=o&m=cookie'); }); }); }); diff --git a/test/spec/modules/colombiaBidAdapter_spec.js b/test/spec/modules/colombiaBidAdapter_spec.js deleted file mode 100644 index 5a8678e866c..00000000000 --- a/test/spec/modules/colombiaBidAdapter_spec.js +++ /dev/null @@ -1,152 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/colombiaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const HOST_NAME = document.location.protocol + '//' + window.location.host; -const ENDPOINT = 'https://ade.clmbtech.com/cde/prebid.htm'; - -describe('colombiaBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when placementId not passed correctly', function () { - bid.params.placementId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code1', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }, - { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code2', - 'sizes': [ - [300, 250] - ], - 'bidId': '382091349b149f"', - 'bidderRequestId': '"1f9c98192de251"', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - } - ]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via POST', function () { - expect(request[0].method).to.equal('POST'); - expect(request[1].method).to.equal('POST'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request[0].url).to.equal(ENDPOINT); - expect(request[1].url).to.equal(ENDPOINT); - }); - }); - - describe('interpretResponse', function () { - let bidRequest = [ - { - 'method': 'POST', - 'url': ENDPOINT, - 'data': { - 'v': 'hb1', - 'p': '307466', - 'w': '300', - 'h': '250', - 'cb': 12892917383, - 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', - 'uid': '23beaa6af6cdde', - 't': 'i', - 'd': HOST_NAME - } - } - ]; - - let serverResponse = { - body: { - 'ad': '
This is test case
', - 'cpm': 3.14, - 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', - 'currency': 'USD', - 'statusMessage': 'Bid available', - 'uid': '23beaa6af6cdde', - 'width': 300, - 'height': 250, - 'netRevenue': true, - 'ttl': 600 - } - }; - - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 3.14, - 'width': 300, - 'height': 250, - 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', - 'dealId': '', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'ad': '
This is test case
' - }]; - let result = spec.interpretResponse(serverResponse, bidRequest[0]); - expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'uid': '2c0b634db95a01', - 'height': 0, - 'crid': '', - 'statusMessage': 'Bid returned empty or error response', - 'width': 0, - 'cpm': 0 - } - }; - let result = spec.interpretResponse(response, bidRequest[0]); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js index 62b4158676e..d2343516b6a 100644 --- a/test/spec/modules/colossussspBidAdapter_spec.js +++ b/test/spec/modules/colossussspBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/colossussspBidAdapter'; +import {spec} from '../../../modules/colossussspBidAdapter.js'; describe('ColossussspAdapter', function () { let bid = { @@ -11,9 +11,41 @@ describe('ColossussspAdapter', function () { }, placementCode: 'placementid_0', auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'example.com', + sid: '0', + hp: 1, + rid: 'bidrequestid', + // name: 'alladsallthetime', + domain: 'example.com' + } + ] + } }; + let bidderRequest = { + bidderCode: 'colossus', + auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff', + bidderRequestId: 'ffffffffffffff', + start: 1472239426002, + auctionStart: 1472239426000, + timeout: 5000, + uspConsent: '1YN-', + refererInfo: { + referer: 'http://www.example.com', + reachedTop: true, + }, + bids: [bid] + } describe('isBidRequestValid', function () { it('Should return true when placement_id can be cast to a number', function () { @@ -26,7 +58,7 @@ describe('ColossussspAdapter', function () { }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); + let serverRequest = spec.buildRequests([bid], bidderRequest); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -37,12 +69,16 @@ describe('ColossussspAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//colossusssp.com/?c=o&m=multi'); + expect(serverRequest.url).to.equal('https://colossusssp.com/?c=o&m=multi'); }); + it('Should contain ccpa', function() { + expect(serverRequest.data.ccpa).to.be.an('string') + }) + it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa'); expect(data.deviceWidth).to.be.a('number'); expect(data.deviceHeight).to.be.a('number'); expect(data.language).to.be.a('string'); @@ -52,7 +88,8 @@ describe('ColossussspAdapter', function () { let placements = data['placements']; for (let i = 0; i < placements.length; i++) { let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes'); + expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes', 'schain'); + expect(placement.schain).to.be.an('object') expect(placement.placementId).to.be.a('number'); expect(placement.bidId).to.be.a('string'); expect(placement.traffic).to.be.a('string'); @@ -112,7 +149,7 @@ describe('ColossussspAdapter', function () { expect(userSync[0].type).to.exist; expect(userSync[0].url).to.exist; expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//colossusssp.com/?c=o&m=cookie'); + expect(userSync[0].url).to.be.equal('https://colossusssp.com/?c=o&m=cookie'); }); }); }); diff --git a/test/spec/modules/connectadBidAdapter_spec.js b/test/spec/modules/connectadBidAdapter_spec.js new file mode 100644 index 00000000000..626018241c4 --- /dev/null +++ b/test/spec/modules/connectadBidAdapter_spec.js @@ -0,0 +1,453 @@ +import {expect} from 'chai'; +import {spec} from 'modules/connectadBidAdapter.js'; +import { config } from 'src/config.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; + +describe('ConnectAd Adapter', function () { + let bidRequests; + let bidderRequest; + let bidRequestsUserIds; + + beforeEach(function () { + bidRequests = [ + { + bidder: 'conntectad', + params: { + siteId: 123456, + networkId: 123456 + }, + adUnitCode: '/19968336/header-bid-tag-1', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + bidId: '2f95c00074b931', + auctionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df' + } + ]; + + bidRequestsUserIds = [{ + bidder: 'conntectad', + params: { + siteId: 123456, + networkId: 123456 + }, + adUnitCode: '/19968336/header-bid-tag-1', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + bidId: '2f95c00074b931', + auctionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df', + userId: { + tdid: '123456', + digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}} + } + }]; + + bidderRequest = { + timeout: 3000, + gdprConsent: { + gdprApplies: true, + consentString: 'consentDataString', + vendorData: {} + } + } + }); + + describe('inherited functions', function () { + it('should exists and is a function', function () { + const adapter = newBidder(spec); + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('implementation', function () { + describe('for requests', function () { + it('should accept bid', function () { + let validBid = { + bidder: 'connectad', + params: { + siteId: 123456, + networkId: 123456 + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + } + }; + const isValid = spec.isBidRequestValid(validBid); + + expect(isValid).to.equal(true); + }); + + it('should reject if missing sizes', function () { + let invalidBid = { + bidder: 'connectad', + params: { + siteId: 123456, + } + }; + const isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should return true when optional bidFloor params found for an ad', function () { + let validBid = { + bidder: 'connectad', + params: { + siteId: 123456, + networkId: 123456, + bidfloor: 0.20 + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + } + }; + const isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true) + }); + + it('should reject if missing siteId/networkId', function () { + let invalidBid = { + bidder: 'connectad', + params: {}, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + } + }; + const isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should reject if missing networkId', function () { + let invalidBid = { + bidder: 'connectad', + params: { + siteId: 123456 + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + } + }; + const isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should contain SiteId and NetworkId', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.placements[0].siteId).to.equal(123456); + expect(requestparse.placements[0].networkId).to.equal(123456); + }); + + it('should contain gdpr info', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + + expect(requestparse.user.ext.gdpr).to.equal(1); + expect(requestparse.user.ext.consent).to.equal('consentDataString'); + }); + + it('should build a request if Consent but no gdprApplies', function () { + let bidderRequest = { + timeout: 3000, + gdprConsent: { + gdprApplies: false, + consentString: 'consentDataString', + }, + } + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + + expect(requestparse.placements[0].adTypes).to.be.an('array'); + expect(requestparse.placements[0].siteId).to.equal(123456); + expect(requestparse.user.ext.consent).to.equal('consentDataString'); + }); + + it('should build a request if gdprConsent empty', function () { + let bidderRequest = { + timeout: 3000, + gdprConsent: {} + } + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + + expect(requestparse.placements[0].adTypes).to.be.an('array'); + expect(requestparse.placements[0].siteId).to.equal(123456); + }); + + it('should have CCPA Consent if defined', function () { + const uspConsent = '1YYN' + bidderRequest.uspConsent = uspConsent + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + + expect(requestparse.user.ext.us_privacy).to.equal(uspConsent); + }); + + it('should not have CCPA Consent if not defined', function () { + bidderRequest.uspConsent = undefined + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.user.ext.us_privacy).to.be.undefined; + }); + + it('should not include schain when not provided', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.source).to.not.exist; + }); + + it('should submit coppa if set in config', function () { + sinon.stub(config, 'getConfig') + .withArgs('coppa') + .returns(true); + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.user.coppa).to.equal(1); + config.getConfig.restore(); + }); + + it('should send all UserData data', function () { + const request = spec.buildRequests(bidRequestsUserIds, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.user.ext.eids).to.be.an('array'); + expect(requestparse.user.ext.eids[0].uids[0].id).to.equal('123456'); + expect(requestparse.user.ext.digitrust.id).to.equal('DTID'); + }); + + it('should add referer info', function () { + const bidRequest = Object.assign({}, bidRequests[0]) + const bidderRequ = { + refererInfo: { + referer: 'https://connectad.io/page.html', + reachedTop: true, + numIframes: 2, + stack: [ + 'https://connectad.io/page.html', + 'https://connectad.io/iframe1.html', + 'https://connectad.io/iframe2.html' + ] + } + } + const request = spec.buildRequests([bidRequest], bidderRequ); + const requestparse = JSON.parse(request.data); + + expect(requestparse.referrer_info).to.exist; + }); + + it('should populate schain', function () { + const bidRequest = Object.assign({}, bidRequests[0], { + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + 'asi': 'reseller1.com', + 'sid': 'absc1', + 'hp': 1 + } + ] + } + }); + + const request = spec.buildRequests([bidRequest], bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.source.ext.schain).to.deep.equal({ + ver: '1.0', + complete: 1, + nodes: [ + { + 'asi': 'reseller1.com', + 'sid': 'absc1', + 'hp': 1 + } + ] + }); + }); + }); + + describe('bid responses', function () { + it('should return complete bid response', function () { + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '250', + width: '300', + pricing: { + clearPrice: 11.899999999999999 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + + expect(bids).to.be.lengthOf(1); + expect(bids[0].cpm).to.equal(11.899999999999999); + expect(bids[0].width).to.equal('300'); + expect(bids[0].height).to.equal('250'); + expect(bids[0].ad).to.have.length.above(1); + }); + + it('should return empty bid response', function () { + let serverResponse = { + body: { + decisions: [] + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + expect(bids).to.be.lengthOf(0); + }); + + it('should return empty bid response on incorrect size', function () { + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '160', + width: '600', + pricing: { + clearPrice: 0 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + expect(bids).to.be.lengthOf(0); + }); + + it('should return empty bid response on 0 cpm', function () { + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '300', + width: '250', + pricing: { + clearPrice: 0 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + expect(bids).to.be.lengthOf(0); + }); + + it('should process a deal id', function () { + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + dealid: 'ABC90210', + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '300', + width: '250', + pricing: { + clearPrice: 11.899999999999999 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + expect(bids).to.be.lengthOf(1); + expect(bids[0].dealid).to.equal('ABC90210'); + }); + }); + }); + + describe('getUserSyncs', () => { + let testParams = [ + { + name: 'iframe/no gdpr or ccpa', + arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, null], + expect: { + type: 'iframe', + pixels: ['https://cdn.connectad.io/connectmyusers.php?'] + } + }, + { + name: 'iframe/gdpr', + arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}], + expect: { + type: 'iframe', + pixels: ['https://cdn.connectad.io/connectmyusers.php?gdpr=1&gdpr_consent=234234&'] + } + }, + { + name: 'iframe/ccpa', + arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, null, 'YN12'], + expect: { + type: 'iframe', + pixels: ['https://cdn.connectad.io/connectmyusers.php?us_privacy=YN12&'] + } + }, + { + name: 'iframe/ccpa & gdpr', + arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}, 'YN12'], + expect: { + type: 'iframe', + pixels: ['https://cdn.connectad.io/connectmyusers.php?gdpr=1&gdpr_consent=234234&us_privacy=YN12&'] + } + } + ]; + + for (let i = 0; i < testParams.length; i++) { + let currParams = testParams[i]; + it(currParams.name, function () { + const result = spec.getUserSyncs.apply(this, currParams.arguments); + expect(result).to.have.lengthOf(currParams.expect.pixels.length); + for (let ix = 0; ix < currParams.expect.pixels.length; ix++) { + expect(result[ix].url).to.equal(currParams.expect.pixels[ix]); + expect(result[ix].type).to.equal(currParams.expect.type); + } + }); + } + }); +}); diff --git a/test/spec/modules/consentManagementUsp_spec.js b/test/spec/modules/consentManagementUsp_spec.js new file mode 100644 index 00000000000..2e8d7db92b5 --- /dev/null +++ b/test/spec/modules/consentManagementUsp_spec.js @@ -0,0 +1,361 @@ +import { + setConsentConfig, + requestBidsHook, + resetConsentData, + consentAPI, + consentTimeout, + staticConsentData +} from 'modules/consentManagementUsp.js'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import { uspDataHandler } from 'src/adapterManager.js'; + +let assert = require('chai').assert; +let expect = require('chai').expect; + +function createIFrameMarker() { + var ifr = document.createElement('iframe'); + ifr.width = 0; + ifr.height = 0; + ifr.name = '__uspapiLocator'; + document.body.appendChild(ifr); + return ifr; +} + +describe('consentManagement', function () { + describe('setConsentConfig tests:', function () { + describe('empty setConsentConfig value', function () { + beforeEach(function () { + sinon.stub(utils, 'logInfo'); + sinon.stub(utils, 'logWarn'); + }); + + afterEach(function () { + utils.logInfo.restore(); + utils.logWarn.restore(); + config.resetConfig(); + resetConsentData(); + }); + + it('should not run if no config', function () { + setConsentConfig({}); + expect(consentAPI).to.be.undefined; + expect(consentTimeout).to.be.undefined; + sinon.assert.callCount(utils.logWarn, 1); + }); + + it('should use system default values', function () { + setConsentConfig({usp: {}}); + expect(consentAPI).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(50); + sinon.assert.callCount(utils.logInfo, 3); + }); + + it('should exit the consent manager if config.usp is not an object', function() { + setConsentConfig({}); + expect(consentAPI).to.be.undefined; + sinon.assert.calledOnce(utils.logWarn); + sinon.assert.notCalled(utils.logInfo); + }); + + it('should exit the consent manager if only config.gdpr is an object', function() { + setConsentConfig({ gdpr: { cmpApi: 'iab' } }); + expect(consentAPI).to.be.undefined; + sinon.assert.calledOnce(utils.logWarn); + sinon.assert.notCalled(utils.logInfo); + }); + }); + + describe('valid setConsentConfig value', function () { + afterEach(function () { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + }); + + it('results in all user settings overriding system defaults', function () { + let allConfig = { + usp: { + cmpApi: 'daa', + timeout: 7500 + } + }; + + setConsentConfig(allConfig); + expect(consentAPI).to.be.equal('daa'); + expect(consentTimeout).to.be.equal(7500); + }); + }); + + describe('static consent string setConsentConfig value', () => { + afterEach(() => { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + }); + it('results in user settings overriding system defaults', () => { + let staticConfig = { + usp: { + cmpApi: 'static', + timeout: 7500, + consentData: { + getUSPData: { + uspString: '1YYY' + } + } + } + }; + + setConsentConfig(staticConfig); + expect(consentAPI).to.be.equal('static'); + expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used + expect(staticConsentData.usPrivacy).to.be.equal(staticConfig.usp.consentData.getUSPData.uspString); + }); + }); + }); + + describe('requestBidsHook tests:', function () { + let goodConfig = { + usp: { + cmpApi: 'iab', + timeout: 7500 + } + }; + + let noConfig = {}; + + let didHookReturn; + + afterEach(function () { + uspDataHandler.consentData = null; + resetConsentData(); + }); + + describe('error checks:', function () { + beforeEach(function () { + didHookReturn = false; + sinon.stub(utils, 'logWarn'); + sinon.stub(utils, 'logError'); + }); + + afterEach(function () { + utils.logWarn.restore(); + utils.logError.restore(); + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + resetConsentData(); + }); + + it('should throw a warning and return to hooked function when an unknown USPAPI framework ID is used', function () { + let badCMPConfig = { usp: { cmpApi: 'bad' } }; + setConsentConfig(badCMPConfig); + expect(consentAPI).to.be.equal(badCMPConfig.usp.cmpApi); + requestBidsHook(() => { didHookReturn = true; }, {}); + let consent = uspDataHandler.getConsentData(); + sinon.assert.calledOnce(utils.logWarn); + expect(didHookReturn).to.be.true; + expect(consent).to.be.null; + }); + + it('should throw proper errors when USP config is not found', function () { + setConsentConfig(noConfig); + requestBidsHook(() => { didHookReturn = true; }, {}); + let consent = uspDataHandler.getConsentData(); + // throw 2 warnings; one for no bidsBackHandler and for CMP not being found (this is an error due to gdpr config) + sinon.assert.calledTwice(utils.logWarn); + expect(didHookReturn).to.be.true; + expect(consent).to.be.null; + }); + }); + + describe('already known consentData:', function () { + let uspStub = sinon.stub(); + let ifr = null; + + beforeEach(function () { + didHookReturn = false; + ifr = createIFrameMarker(); + window.__uspapi = function() {}; + }); + + afterEach(function () { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + uspStub.restore(); + document.body.removeChild(ifr); + delete window.__uspapi; + resetConsentData(); + }); + + it('should bypass CMP and simply use previously stored consentData', function () { + let testConsentData = { + uspString: '1YY' + }; + + uspStub = sinon.stub(window, '__uspapi').callsFake((...args) => { + args[2](testConsentData, true); + }); + + setConsentConfig(goodConfig); + requestBidsHook(() => {}, {}); + uspStub.restore(); + + // reset the stub to ensure it wasn't called during the second round of calls + uspStub = sinon.stub(window, '__uspapi').callsFake((...args) => { + args[2](testConsentData, true); + }); + + requestBidsHook(() => { didHookReturn = true; }, {}); + + let consent = uspDataHandler.getConsentData(); + expect(didHookReturn).to.be.true; + expect(consent).to.equal(testConsentData.uspString); + sinon.assert.notCalled(uspStub); + }); + }); + + describe('USPAPI workflow for iframed page', function () { + let ifr = null; + let stringifyResponse = false; + + beforeEach(function () { + sinon.stub(utils, 'logError'); + sinon.stub(utils, 'logWarn'); + ifr = createIFrameMarker(); + window.addEventListener('message', uspapiMessageHandler, false); + }); + + afterEach(function () { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + delete window.__uspapi; + utils.logError.restore(); + utils.logWarn.restore(); + resetConsentData(); + document.body.removeChild(ifr); + window.removeEventListener('message', uspapiMessageHandler); + }); + + function uspapiMessageHandler(event) { + if (event && event.data) { + var data = event.data; + if (data.__uspapiCall) { + var callId = data.__uspapiCall.callId; + var response = { + __uspapiReturn: { + callId, + returnValue: { uspString: '1YY' }, + success: true + } + }; + event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*'); + } + } + } + + // Run tests with JSON response and String response + // from CMP window postMessage listener. + testIFramedPage('with/JSON response', false); + // testIFramedPage('with/String response', true); + + function testIFramedPage(testName, messageFormatString) { + it(`should return the consent string from a postmessage + addEventListener response - ${testName}`, (done) => { + stringifyResponse = messageFormatString; + setConsentConfig(goodConfig); + requestBidsHook(() => { + let consent = uspDataHandler.getConsentData(); + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + expect(consent).to.equal('1YY'); + done(); + }, {}); + }); + } + }); + + describe('test without iframe locater', function() { + let uspapiStub = sinon.stub(); + + beforeEach(function () { + didHookReturn = false; + sinon.stub(utils, 'logError'); + sinon.stub(utils, 'logWarn'); + window.__uspapi = function() {}; + }); + + afterEach(function () { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + uspapiStub.restore(); + utils.logError.restore(); + utils.logWarn.restore(); + delete window.__uspapi; + resetConsentData(); + }); + + it('Workflow for normal page withoout iframe locater', function() { + let testConsentData = { + uspString: '1NY' + }; + + uspapiStub = sinon.stub(window, '__uspapi').callsFake((...args) => { + args[2](testConsentData, true); + }); + + setConsentConfig(goodConfig); + requestBidsHook(() => { didHookReturn = true; }, {}); + + let consent = uspDataHandler.getConsentData(); + + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + + expect(didHookReturn).to.be.true; + expect(consent).to.equal(testConsentData.uspString); + }); + }); + + describe('USPAPI workflow for normal pages:', function () { + let uspapiStub = sinon.stub(); + let ifr = null; + + beforeEach(function () { + didHookReturn = false; + ifr = createIFrameMarker(); + sinon.stub(utils, 'logError'); + sinon.stub(utils, 'logWarn'); + window.__uspapi = function() {}; + }); + + afterEach(function () { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + uspapiStub.restore(); + utils.logError.restore(); + utils.logWarn.restore(); + document.body.removeChild(ifr); + delete window.__uspapi; + resetConsentData(); + }); + + it('performs lookup check and stores consentData for a valid existing user', function () { + let testConsentData = { + uspString: '1NY' + }; + + uspapiStub = sinon.stub(window, '__uspapi').callsFake((...args) => { + args[2](testConsentData, true); + }); + + setConsentConfig(goodConfig); + requestBidsHook(() => { didHookReturn = true; }, {}); + + let consent = uspDataHandler.getConsentData(); + + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + + expect(didHookReturn).to.be.true; + expect(consent).to.equal(testConsentData.uspString); + }); + }); + }); +}); diff --git a/test/spec/modules/consentManagement_spec.js b/test/spec/modules/consentManagement_spec.js index 6be96427750..fb33094e151 100644 --- a/test/spec/modules/consentManagement_spec.js +++ b/test/spec/modules/consentManagement_spec.js @@ -1,9 +1,8 @@ -import {setConsentConfig, requestBidsHook, resetConsentData, userCMP, consentTimeout, allowAuction, staticConsentData} from 'modules/consentManagement'; -import {gdprDataHandler} from 'src/adapterManager'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; +import { setConsentConfig, requestBidsHook, resetConsentData, userCMP, consentTimeout, allowAuction, staticConsentData, gdprScope } from 'modules/consentManagement.js'; +import { gdprDataHandler } from 'src/adapterManager.js'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; -let assert = require('chai').assert; let expect = require('chai').expect; describe('consentManagement', function () { @@ -11,11 +10,14 @@ describe('consentManagement', function () { describe('empty setConsentConfig value', function () { beforeEach(function () { sinon.stub(utils, 'logInfo'); + sinon.stub(utils, 'logWarn'); }); afterEach(function () { utils.logInfo.restore(); + utils.logWarn.restore(); config.resetConfig(); + resetConsentData(); }); it('should use system default values', function () { @@ -23,35 +25,101 @@ describe('consentManagement', function () { expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(10000); expect(allowAuction).to.be.true; + expect(gdprScope).to.be.equal(false); sinon.assert.callCount(utils.logInfo, 4); }); + + it('should exit consent manager if config is not an object', function () { + setConsentConfig(''); + expect(userCMP).to.be.undefined; + sinon.assert.calledOnce(utils.logWarn); + }); + + it('should exit consent manager if gdpr not set with new config structure', function () { + setConsentConfig({ usp: { cmpApi: 'iab', timeout: 50 } }); + expect(userCMP).to.be.undefined; + sinon.assert.calledOnce(utils.logWarn); + }); }); describe('valid setConsentConfig value', function () { afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); + it('results in all user settings overriding system defaults', function () { let allConfig = { cmpApi: 'iab', timeout: 7500, - allowAuctionWithoutConsent: false + allowAuctionWithoutConsent: false, + defaultGdprScope: true }; setConsentConfig(allConfig); expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(7500); expect(allowAuction).to.be.false; + expect(gdprScope).to.be.true; + }); + + it('should use new consent manager config structure for gdpr', function () { + setConsentConfig({ + gdpr: { cmpApi: 'daa', timeout: 8700 } + }); + + expect(userCMP).to.be.equal('daa'); + expect(consentTimeout).to.be.equal(8700); + }); + + it('should ignore config.usp and use config.gdpr, with default cmpApi', function () { + setConsentConfig({ + gdpr: { timeout: 5000 }, + usp: { cmpApi: 'daa', timeout: 50 } + }); + + expect(userCMP).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(5000); + }); + + it('should ignore config.usp and use config.gdpr, with default cmpAip and timeout', function () { + setConsentConfig({ + gdpr: {}, + usp: { cmpApi: 'daa', timeout: 50 } + }); + + expect(userCMP).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(10000); + }); + + it('should recognize config.gdpr, with default cmpAip and timeout', function () { + setConsentConfig({ + gdpr: {} + }); + + expect(userCMP).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(10000); + }); + + it('should fallback to old consent manager config object if no config.gdpr', function () { + setConsentConfig({ + cmpApi: 'iab', + timeout: 3333, + allowAuctionWithoutConsent: false, + gdpr: false + }); + + expect(userCMP).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(3333); + expect(allowAuction).to.be.equal(false); + expect(gdprScope).to.be.equal(false); }); }); describe('static consent string setConsentConfig value', () => { afterEach(() => { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); - it('results in user settings overriding system defaults', () => { + it('results in user settings overriding system defaults for v1 spec', () => { let staticConfig = { cmpApi: 'static', timeout: 7500, @@ -87,361 +155,7 @@ describe('consentManagement', function () { '2': true, '3': true, '4': true, - '5': false, - '6': true, - '7': true, - '8': true, - '9': true, - '10': true, - '11': true, - '12': true, - '13': true, - '14': true, - '15': true, - '16': true, - '17': true, - '18': true, - '19': true, - '20': true, - '21': true, - '22': true, - '23': true, - '24': true, - '25': true, - '26': true, - '27': true, - '28': true, - '29': true, - '30': true, - '31': true, - '32': true, - '33': true, - '34': true, - '35': true, - '36': true, - '37': true, - '38': true, - '39': true, - '40': true, - '41': true, - '42': true, - '43': true, - '44': true, - '45': true, - '46': true, - '47': true, - '48': true, - '49': true, - '50': true, - '51': true, - '52': true, - '53': true, - '54': false, - '55': true, - '56': true, - '57': true, - '58': true, - '59': true, - '60': true, - '61': true, - '62': true, - '63': true, - '64': true, - '65': true, - '66': true, - '67': true, - '68': true, - '69': true, - '70': true, - '71': true, - '72': true, - '73': true, - '74': true, - '75': true, - '76': true, - '77': true, - '78': true, - '79': true, - '80': true, - '81': true, - '82': true, - '83': false, - '84': true, - '85': true, - '86': true, - '87': true, - '88': true, - '89': true, - '90': true, - '91': true, - '92': true, - '93': true, - '94': true, - '95': true, - '96': false, - '97': true, - '98': true, - '99': false, - '100': true, - '101': true, - '102': true, - '103': false, - '104': true, - '105': true, - '106': false, - '107': false, - '108': true, - '109': true, - '110': true, - '111': true, - '112': true, - '113': true, - '114': true, - '115': true, - '116': false, - '117': false, - '118': false, - '119': true, - '120': true, - '121': false, - '122': true, - '123': false, - '124': true, - '125': true, - '126': true, - '127': true, - '128': true, - '129': true, - '130': true, - '131': true, - '132': true, - '133': true, - '134': true, - '135': false, - '136': true, - '137': false, - '138': true, - '139': true, - '140': true, - '141': true, - '142': true, - '143': true, - '144': true, - '145': true, - '146': false, - '147': true, - '148': true, - '149': true, - '150': true, - '151': true, - '152': false, - '153': true, - '154': true, - '155': true, - '156': true, - '157': true, - '158': true, - '159': true, - '160': true, - '161': true, - '162': true, - '163': true, - '164': true, - '165': true, - '166': false, - '167': true, - '168': true, - '169': true, - '170': true, - '171': false, - '172': false, - '173': true, - '174': true, - '175': true, - '176': false, - '177': true, - '178': false, - '179': true, - '180': true, - '181': false, - '182': true, - '183': true, - '184': false, - '185': true, - '186': false, - '187': false, - '188': true, - '189': true, - '190': true, - '191': false, - '192': true, - '193': true, - '194': true, - '195': true, - '196': false, - '197': true, - '198': true, - '199': true, - '200': true, - '201': true, - '202': true, - '203': true, - '204': false, - '205': true, - '206': false, - '207': false, - '208': true, - '209': true, - '210': true, - '211': true, - '212': true, - '213': true, - '214': false, - '215': true, - '216': false, - '217': true, - '218': false, - '219': false, - '220': false, - '221': false, - '222': false, - '223': false, - '224': true, - '225': true, - '226': true, - '227': true, - '228': true, - '229': true, - '230': true, - '231': false, - '232': true, - '233': false, - '234': true, - '235': true, - '236': true, - '237': true, - '238': true, - '239': true, - '240': true, - '241': true, - '242': false, - '243': false, - '244': true, - '245': true, - '246': true, - '247': false, - '248': true, - '249': true, - '250': false, - '251': false, - '252': true, - '253': true, - '254': true, - '255': true, - '256': true, - '257': true, - '258': true, - '259': true, - '260': true, - '261': false, - '262': true, - '263': false, - '264': true, - '265': true, - '266': true, - '267': false, - '268': false, - '269': true, - '270': true, - '271': false, - '272': true, - '273': true, - '274': true, - '275': true, - '276': true, - '277': true, - '278': true, - '279': true, - '280': true, - '281': true, - '282': true, - '283': false, - '284': true, - '285': true, - '286': false, - '287': false, - '288': true, - '289': true, - '290': true, - '291': true, - '292': false, - '293': false, - '294': true, - '295': true, - '296': false, - '297': true, - '298': false, - '299': true, - '300': false, - '301': true, - '302': true, - '303': true, - '304': true, - '305': false, - '306': false, - '307': false, - '308': true, - '309': true, - '310': true, - '311': false, - '312': false, - '313': false, - '314': true, - '315': true, - '316': true, - '317': true, - '318': true, - '319': true, - '320': true, - '321': false, - '322': false, - '323': true, - '324': false, - '325': true, - '326': true, - '327': false, - '328': true, - '329': false, - '330': false, - '331': true, - '332': false, - '333': true, - '334': false, - '335': false, - '336': false, - '337': false, - '338': false, - '339': true, - '340': false, - '341': false, - '342': false, - '343': false, - '344': false, - '345': true, - '346': false, - '347': false, - '348': false, - '349': true, - '350': false, - '351': false, - '352': false, - '353': false, - '354': true, - '355': false, - '356': false, - '357': false, - '358': false, - '359': true + '5': false } } } @@ -453,6 +167,87 @@ describe('consentManagement', function () { expect(allowAuction).to.be.false; expect(staticConsentData).to.be.equal(staticConfig.consentData); }); + + it('results in user settings overriding system defaults for v2 spec', () => { + let staticConfig = { + cmpApi: 'static', + timeout: 7500, + allowAuctionWithoutConsent: false, + consentData: { + getTCData: { + 'tcString': 'COuqj-POu90rDBcBkBENAZCgAPzAAAPAACiQFwwBAABAA1ADEAbQC4YAYAAgAxAG0A', + 'cmpId': 92, + 'cmpVersion': 100, + 'tcfPolicyVersion': 2, + 'gdprApplies': true, + 'isServiceSpecific': true, + 'useNonStandardStacks': false, + 'purposeOneTreatment': false, + 'publisherCC': 'US', + 'cmpStatus': 'loaded', + 'eventStatus': 'tcloaded', + 'outOfBand': { + 'allowedVendors': {}, + 'discloseVendors': {} + }, + 'purpose': { + 'consents': { + '1': true, + '2': true, + '3': true + }, + 'legitimateInterests': { + '1': false, + '2': false, + '3': false + } + }, + 'vendor': { + 'consents': { + '1': false, + '2': true, + '3': false + }, + 'legitimateInterests': { + '1': false, + '2': true, + '3': false, + '4': false, + '5': false + } + }, + 'specialFeatureOptins': { + '1': false, + '2': false + }, + 'restrictions': {}, + 'publisher': { + 'consents': { + '1': false, + '2': false, + '3': false + }, + 'legitimateInterests': { + '1': false, + '2': false, + '3': false + }, + 'customPurpose': { + 'consents': {}, + 'legitimateInterests': {} + } + } + } + } + }; + + setConsentConfig(staticConfig); + expect(userCMP).to.be.equal('static'); + expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used + expect(allowAuction).to.be.false; + expect(gdprScope).to.be.equal(false); + expect(staticConsentData).to.be.equal(staticConfig.consentData); + }); }); }); @@ -487,7 +282,6 @@ describe('consentManagement', function () { utils.logWarn.restore(); utils.logError.restore(); config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); resetConsentData(); }); @@ -526,12 +320,11 @@ describe('consentManagement', function () { beforeEach(function () { didHookReturn = false; - window.__cmp = function() {}; + window.__cmp = function () { }; }); afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); cmpStub.restore(); delete window.__cmp; resetConsentData(); @@ -547,7 +340,7 @@ describe('consentManagement', function () { args[2](testConsentData); }); setConsentConfig(goodConfigWithAllowAuction); - requestBidsHook(() => {}, {}); + requestBidsHook(() => { }, {}); cmpStub.restore(); // reset the stub to ensure it wasn't called during the second round of calls @@ -565,123 +358,66 @@ describe('consentManagement', function () { expect(consent.gdprApplies).to.be.true; sinon.assert.notCalled(cmpStub); }); - }); - - describe('CMP workflow for safeframe page', function () { - let registerStub = sinon.stub(); - beforeEach(function () { - didHookReturn = false; - window.$sf = { - ext: { - register: function() {}, - cmp: function() {} - } + it('should not set consent.gdprApplies to true if defaultGdprScope is true', function () { + let testConsentData = { + gdprApplies: false, + consentData: 'xyz' }; - sinon.stub(utils, 'logError'); - sinon.stub(utils, 'logWarn'); - }); - afterEach(function () { - delete window.$sf; - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - registerStub.restore(); - utils.logError.restore(); - utils.logWarn.restore(); - resetConsentData(); - }); + cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { + args[2](testConsentData); + }); - it('should return the consent data from a safeframe callback', function () { - var testConsentData = { - data: { - msgName: 'cmpReturn', - vendorConsents: { - metadata: 'abc123def', - gdprApplies: true - }, - vendorConsentData: { - consentData: 'abc123def', - gdprApplies: true - } - } - }; - registerStub = sinon.stub(window.$sf.ext, 'register').callsFake((...args) => { - args[2](testConsentData.data.msgName, testConsentData.data); + setConsentConfig({ + cmpApi: 'iab', + timeout: 7500, + defaultGdprScope: true }); - setConsentConfig(goodConfigWithAllowAuction); requestBidsHook(() => { didHookReturn = true; - }, {adUnits: [{ sizes: [[300, 250]] }]}); + }, {}); + let consent = gdprDataHandler.getConsentData(); - sinon.assert.notCalled(utils.logWarn); - sinon.assert.notCalled(utils.logError); - expect(didHookReturn).to.be.true; - expect(consent.consentString).to.equal('abc123def'); - expect(consent.gdprApplies).to.be.true; + expect(consent.gdprApplies).to.be.false; }); }); - describe('CMP workflow for iframed page', function () { - let ifr = null; - let stringifyResponse = false; - - beforeEach(function () { - sinon.stub(utils, 'logError'); - sinon.stub(utils, 'logWarn'); - ifr = createIFrameMarker(); - window.addEventListener('message', cmpMessageHandler, false); - }); - - afterEach(function () { - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - delete window.__cmp; - utils.logError.restore(); - utils.logWarn.restore(); - resetConsentData(); - document.body.removeChild(ifr); - window.removeEventListener('message', cmpMessageHandler); - }); + describe('iframe tests', function () { + let cmpPostMessageCb = () => { }; + let stringifyResponse; - function createIFrameMarker() { - var ifr = document.createElement('iframe'); + function createIFrameMarker(frameName) { + let ifr = document.createElement('iframe'); ifr.width = 0; ifr.height = 0; - ifr.name = '__cmpLocator'; + ifr.name = frameName; document.body.appendChild(ifr); return ifr; } - function cmpMessageHandler(event) { - if (event && event.data) { - var data = event.data; - if (data.__cmpCall) { - var callId = data.__cmpCall.callId; - var returnValue = null; - var response = { - __cmpReturn: { - callId, - returnValue: { - consentData: 'encoded_consent_data_via_post_message', - gdprApplies: true, - }, - success: true - } - }; - event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*'); + function creatCmpMessageHandler(prefix, returnValue) { + return function (event) { + if (event && event.data) { + let data = event.data; + if (data[`${prefix}Call`]) { + let callId = data[`${prefix}Call`].callId; + let response = { + [`${prefix}Return`]: { + callId, + returnValue, + success: true + } + }; + event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*'); + } } } } - // Run tests with JSON response and String response - // from CMP window postMessage listener. - testIFramedPage('with/JSON response', false); - testIFramedPage('with/String response', true); - - function testIFramedPage(testName, messageFormatString) { + function testIFramedPage(testName, messageFormatString, tarConsentString, ver) { it(`should return the consent string from a postmessage + addEventListener response - ${testName}`, (done) => { stringifyResponse = messageFormatString; setConsentConfig(goodConfigWithAllowAuction); @@ -689,96 +425,256 @@ describe('consentManagement', function () { let consent = gdprDataHandler.getConsentData(); sinon.assert.notCalled(utils.logWarn); sinon.assert.notCalled(utils.logError); - expect(consent.consentString).to.equal('encoded_consent_data_via_post_message'); + expect(consent.consentString).to.equal(tarConsentString); expect(consent.gdprApplies).to.be.true; + expect(consent.apiVersion).to.equal(ver); done(); }, {}); }); } + + beforeEach(function () { + sinon.stub(utils, 'logError'); + sinon.stub(utils, 'logWarn'); + }); + + afterEach(function () { + utils.logError.restore(); + utils.logWarn.restore(); + config.resetConfig(); + resetConsentData(); + }); + + describe('v1 CMP workflow for safeframe page', function () { + let registerStub = sinon.stub(); + let ifrSf = null; + beforeEach(function () { + didHookReturn = false; + window.$sf = { + ext: { + register: function () { }, + cmp: function () { } + } + }; + ifrSf = createIFrameMarker('__cmpLocator'); + }); + + afterEach(function () { + delete window.$sf; + registerStub.restore(); + document.body.removeChild(ifrSf); + }); + + it('should return the consent data from a safeframe callback', function () { + let testConsentData = { + data: { + msgName: 'cmpReturn', + vendorConsents: { + metadata: 'abc123def', + gdprApplies: true + }, + vendorConsentData: { + consentData: 'abc123def', + gdprApplies: true + } + } + }; + registerStub = sinon.stub(window.$sf.ext, 'register').callsFake((...args) => { + args[2](testConsentData.data.msgName, testConsentData.data); + }); + + setConsentConfig(goodConfigWithAllowAuction); + requestBidsHook(() => { + didHookReturn = true; + }, { adUnits: [{ sizes: [[300, 250]] }] }); + let consent = gdprDataHandler.getConsentData(); + + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + expect(didHookReturn).to.be.true; + expect(consent.consentString).to.equal('abc123def'); + expect(consent.gdprApplies).to.be.true; + expect(consent.apiVersion).to.equal(1); + }); + }); + + describe('v1 CMP workflow for iframe pages', function () { + stringifyResponse = false; + let ifr1 = null; + + beforeEach(function () { + ifr1 = createIFrameMarker('__cmpLocator'); + cmpPostMessageCb = creatCmpMessageHandler('__cmp', { + consentData: 'encoded_consent_data_via_post_message', + gdprApplies: true, + }); + window.addEventListener('message', cmpPostMessageCb, false); + }); + + afterEach(function () { + delete window.__cmp; // deletes the local copy made by the postMessage CMP call function + document.body.removeChild(ifr1); + window.removeEventListener('message', cmpPostMessageCb); + }); + + // Run tests with JSON response and String response + // from CMP window postMessage listener. + testIFramedPage('with/JSON response', false, 'encoded_consent_data_via_post_message', 1); + testIFramedPage('with/String response', true, 'encoded_consent_data_via_post_message', 1); + }); + + describe('v2 CMP workflow for iframe pages:', function () { + stringifyResponse = false; + let ifr2 = null; + + beforeEach(function () { + ifr2 = createIFrameMarker('__tcfapiLocator'); + cmpPostMessageCb = creatCmpMessageHandler('__tcfapi', { + tcString: 'abc12345234', + gdprApplies: true, + purposeOneTreatment: false, + eventStatus: 'tcloaded' + }); + window.addEventListener('message', cmpPostMessageCb, false); + }); + + afterEach(function () { + delete window.__tcfapi; // deletes the local copy made by the postMessage CMP call function + document.body.removeChild(ifr2); + window.removeEventListener('message', cmpPostMessageCb); + }); + + testIFramedPage('with/JSON response', false, 'abc12345234', 2); + testIFramedPage('with/String response', true, 'abc12345234', 2); + }); }); - describe('CMP workflow for normal pages:', function () { + describe('direct calls to CMP API tests', function () { let cmpStub = sinon.stub(); beforeEach(function () { didHookReturn = false; sinon.stub(utils, 'logError'); sinon.stub(utils, 'logWarn'); - window.__cmp = function() {}; }); afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); cmpStub.restore(); utils.logError.restore(); utils.logWarn.restore(); - delete window.__cmp; resetConsentData(); }); - it('performs lookup check and stores consentData for a valid existing user', function () { - let testConsentData = { - gdprApplies: true, - consentData: 'BOJy+UqOJy+UqABAB+AAAAAZ+A==' - }; - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); + describe('v1 CMP workflow for normal pages:', function () { + beforeEach(function () { + window.__cmp = function () { }; }); - setConsentConfig(goodConfigWithAllowAuction); + afterEach(function () { + delete window.__cmp; + }); - requestBidsHook(() => { - didHookReturn = true; - }, {}); - let consent = gdprDataHandler.getConsentData(); + it('performs lookup check and stores consentData for a valid existing user', function () { + let testConsentData = { + gdprApplies: true, + consentData: 'BOJy+UqOJy+UqABAB+AAAAAZ+A==' + }; + cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { + args[2](testConsentData); + }); - sinon.assert.notCalled(utils.logWarn); - sinon.assert.notCalled(utils.logError); - expect(didHookReturn).to.be.true; - expect(consent.consentString).to.equal(testConsentData.consentData); - expect(consent.gdprApplies).to.be.true; + setConsentConfig(goodConfigWithAllowAuction); + + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gdprDataHandler.getConsentData(); + + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + expect(didHookReturn).to.be.true; + expect(consent.consentString).to.equal(testConsentData.consentData); + expect(consent.gdprApplies).to.be.true; + expect(consent.apiVersion).to.equal(1); + }); }); - it('throws an error when processCmpData check failed while config had allowAuction set to false', function () { - let testConsentData = {}; - let bidsBackHandlerReturn = false; + describe('v2 CMP workflow for normal pages:', function () { + beforeEach(function() { + window.__tcfapi = function () { }; + }); - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); + afterEach(function () { + delete window.__tcfapi; }); - setConsentConfig(goodConfigWithCancelAuction); + it('performs lookup check and stores consentData for a valid existing user', function () { + let testConsentData = { + tcString: 'abc12345234', + gdprApplies: true, + purposeOneTreatment: false, + eventStatus: 'tcloaded' + }; + cmpStub = sinon.stub(window, '__tcfapi').callsFake((...args) => { + args[2](testConsentData, true); + }); - requestBidsHook(() => { - didHookReturn = true; - }, { bidsBackHandler: () => bidsBackHandlerReturn = true }); - let consent = gdprDataHandler.getConsentData(); + setConsentConfig(goodConfigWithAllowAuction); - sinon.assert.calledOnce(utils.logError); - expect(didHookReturn).to.be.false; - expect(bidsBackHandlerReturn).to.be.true; - expect(consent).to.be.null; - }); + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gdprDataHandler.getConsentData(); + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + expect(didHookReturn).to.be.true; + expect(consent.consentString).to.equal(testConsentData.tcString); + expect(consent.gdprApplies).to.be.true; + expect(consent.apiVersion).to.equal(2); + }); - it('throws a warning + stores consentData + calls callback when processCmpData check failed while config had allowAuction set to true', function () { - let testConsentData = {}; + it('throws an error when processCmpData check failed while config had allowAuction set to false', function () { + let testConsentData = {}; + let bidsBackHandlerReturn = false; - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); + cmpStub = sinon.stub(window, '__tcfapi').callsFake((...args) => { + args[2](testConsentData); + }); + + setConsentConfig(goodConfigWithCancelAuction); + + requestBidsHook(() => { + didHookReturn = true; + }, { bidsBackHandler: () => bidsBackHandlerReturn = true }); + let consent = gdprDataHandler.getConsentData(); + + sinon.assert.calledOnce(utils.logError); + expect(didHookReturn).to.be.false; + expect(bidsBackHandlerReturn).to.be.true; + expect(consent).to.be.null; }); - setConsentConfig(goodConfigWithAllowAuction); + it('throws a warning + stores consentData + calls callback when processCmpData check failed while config had allowAuction set to true', function () { + let testConsentData = {}; - requestBidsHook(() => { - didHookReturn = true; - }, {}); - let consent = gdprDataHandler.getConsentData(); + cmpStub = sinon.stub(window, '__tcfapi').callsFake((...args) => { + args[2](testConsentData); + }); - sinon.assert.calledOnce(utils.logWarn); - expect(didHookReturn).to.be.true; - expect(consent.consentString).to.be.undefined; - expect(consent.gdprApplies).to.be.undefined; + setConsentConfig(goodConfigWithAllowAuction); + + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gdprDataHandler.getConsentData(); + + sinon.assert.calledOnce(utils.logWarn); + expect(didHookReturn).to.be.true; + expect(consent.consentString).to.be.undefined; + expect(consent.gdprApplies).to.be.false; + expect(consent.apiVersion).to.equal(2); + }); }); }); }); diff --git a/test/spec/modules/consumableBidAdapter_spec.js b/test/spec/modules/consumableBidAdapter_spec.js index fc5e1d1b45a..44076194885 100644 --- a/test/spec/modules/consumableBidAdapter_spec.js +++ b/test/spec/modules/consumableBidAdapter_spec.js @@ -1,58 +1,127 @@ -import { expect } from 'chai'; -import { spec } from 'modules/consumableBidAdapter'; -import { createBid } from 'src/bidfactory'; +import {expect} from 'chai'; +import {spec} from 'modules/consumableBidAdapter.js'; +import {createBid} from 'src/bidfactory.js'; const ENDPOINT = 'https://e.serverbid.com/api/v2'; const SMARTSYNC_CALLBACK = 'serverbidCallBids'; -const REQUEST = { - 'bidderCode': 'consumable', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d', - 'bidderRequestId': '109f2a181342a9', - 'bidRequest': [{ - 'bidder': 'consumable', - 'params': { - 'networkId': 9969, - 'siteId': 730181, - 'unitId': 123456, - 'unitName': 'cnsmbl-unit' - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '2b0f82502298c9', - 'bidderRequestId': '109f2a181342a9', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d' +const BIDDER_REQUEST_1 = { + bidderCode: 'consumable', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + bidRequest: [ + { + bidder: 'consumable', + params: { + networkId: '9969', + siteId: '730181', + unitId: '123456', + unitName: 'cnsmbl-unit' + }, + placementCode: 'header-bid-tag-1', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: '23acc48ad47af5', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + } + ], + gdprConsent: { + consentString: 'consent-test', + gdprApplies: false }, - { - 'bidder': 'consumable', - 'params': { - 'networkId': 9969, - 'siteId': 730181, - 'unitId': 123456, - 'unitName': 'cnsmbl-unit' + refererInfo: { + referer: 'http://example.com/page.html', + reachedTop: true, + numIframes: 2, + stack: [ + 'http://example.com/page.html', + 'http://example.com/iframe1.html', + 'http://example.com/iframe2.html' + ] + } +}; + +const BIDDER_REQUEST_2 = { + bidderCode: 'consumable', + auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d', + bidderRequestId: '109f2a181342a9', + bidRequest: [ + { + bidder: 'consumable', + params: { + networkId: 9969, + siteId: 730181, + unitId: 123456, + unitName: 'cnsmbl-unit' + }, + placementCode: 'div-gpt-ad-1487778092495-0', + mediaTypes: { + banner: { + sizes: [ + [728, 90], + [970, 90] + ] + } + }, + bidId: '2b0f82502298c9', + bidderRequestId: '109f2a181342a9', + auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d' }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '123', - 'bidderRequestId': '109f2a181342a9', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }], - 'gdprConsent': { - 'consentString': 'consent-test', - 'gdprApplies': true + { + bidder: 'consumable', + params: { + networkId: 9969, + siteId: 730181, + unitId: 123456, + unitName: 'cnsmbl-unit' + }, + placementCode: 'div-gpt-ad-1487778092495-0', + mediaTypes: { + banner: { + sizes: [ + [728, 90], + [970, 90] + ] + } + }, + bidId: '123', + bidderRequestId: '109f2a181342a9', + auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d' + } + ], + gdprConsent: { + consentString: 'consent-test', + gdprApplies: true }, - 'start': 1487883186070, - 'auctionStart': 1487883186069, - 'timeout': 3000 + refererInfo: { + referer: 'http://example.com/page.html', + reachedTop: true, + numIframes: 2, + stack: [ + 'http://example.com/page.html', + 'http://example.com/iframe1.html', + 'http://example.com/iframe2.html' + ] + } }; -const RESPONSE = { +const BIDDER_REQUEST_EMPTY = { + bidderCode: 'consumable', + auctionId: 'b06458ef-4fe5-4a0b-a61b-bccbcedb7b11', + bidderRequestId: '8c8006750b10fd', + bidRequest: [], + gdprConsent: { + consentString: 'consent-test', + gdprApplies: false + } +}; + +const AD_SERVER_RESPONSE = { 'headers': null, 'body': { 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, @@ -108,30 +177,17 @@ const RESPONSE = { } }; +const BUILD_REQUESTS_OUTPUT = { + method: 'POST', + url: 'https://e.serverbid.com/api/v2', + data: '', + bidRequest: BIDDER_REQUEST_2.bidRequest, + bidderRequest: BIDDER_REQUEST_2 +}; + describe('Consumable BidAdapter', function () { - let bidRequests; let adapter = spec; - beforeEach(function () { - bidRequests = [ - { - bidder: 'consumable', - params: { - networkId: '9969', - siteId: '730181', - unitId: '123456', - unitName: 'cnsmbl-unit' - }, - placementCode: 'header-bid-tag-1', - sizes: [[300, 250], [300, 600]], - bidId: '23acc48ad47af5', - auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - describe('bid request validation', function () { it('should accept valid bid requests', function () { let bid = { @@ -187,43 +243,49 @@ describe('Consumable BidAdapter', function () { describe('buildRequests validation', function () { it('creates request data', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1); expect(request).to.exist.and.to.be.a('object'); }); it('request to consumable should contain a url', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1); expect(request.url).to.have.string('serverbid.com'); }); it('requires valid bids to make request', function () { - let request = spec.buildRequests([]); + let request = spec.buildRequests(BIDDER_REQUEST_EMPTY.bidRequest, BIDDER_REQUEST_EMPTY); expect(request.bidRequest).to.be.empty; }); it('sends bid request to ENDPOINT via POST', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1); expect(request.method).to.have.string('POST'); }); + + it('passes through bidderRequest', function () { + let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1); + + expect(request.bidderRequest).to.equal(BIDDER_REQUEST_1); + }) }); describe('interpretResponse validation', function () { it('response should have valid bidderCode', function () { - let bidRequest = spec.buildRequests(REQUEST.bidRequest, REQUEST); + let bidRequest = spec.buildRequests(BIDDER_REQUEST_2.bidRequest, BIDDER_REQUEST_2); let bid = createBid(1, bidRequest.bidRequest[0]); expect(bid.bidderCode).to.equal('consumable'); }); it('response should include objects for all bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); + let bids = spec.interpretResponse(AD_SERVER_RESPONSE, BUILD_REQUESTS_OUTPUT); expect(bids.length).to.equal(2); }); it('registers bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); + let bids = spec.interpretResponse(AD_SERVER_RESPONSE, BUILD_REQUESTS_OUTPUT); bids.forEach(b => { expect(b).to.have.property('cpm'); expect(b.cpm).to.be.above(0); @@ -243,14 +305,14 @@ describe('Consumable BidAdapter', function () { }); it('handles nobid responses', function () { - let EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {'decisions': null}}) - let bids = spec.interpretResponse(EMPTY_RESP, REQUEST); + let EMPTY_RESP = Object.assign({}, AD_SERVER_RESPONSE, {'body': {'decisions': null}}) + let bids = spec.interpretResponse(EMPTY_RESP, BUILD_REQUESTS_OUTPUT); expect(bids).to.be.empty; }); it('handles no server response', function () { - let bids = spec.interpretResponse(null, REQUEST); + let bids = spec.interpretResponse(null, BUILD_REQUESTS_OUTPUT); expect(bids).to.be.empty; }); @@ -272,7 +334,7 @@ describe('Consumable BidAdapter', function () { it('should return a sync url if pixel syncs are enabled and some are returned from the server', function () { let syncOptions = {'pixelEnabled': true}; - let opts = spec.getUserSyncs(syncOptions, [RESPONSE]); + let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE]); expect(opts.length).to.equal(1); }); diff --git a/test/spec/modules/contentigniteBidAdapter_spec.js b/test/spec/modules/contentigniteBidAdapter_spec.js deleted file mode 100644 index 1867791a234..00000000000 --- a/test/spec/modules/contentigniteBidAdapter_spec.js +++ /dev/null @@ -1,186 +0,0 @@ -import { expect } from 'chai'; -import { spec } from '../../../modules/contentigniteBidAdapter'; - -describe('Content Ignite adapter', function () { - let bidRequests; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'contentignite', - params: { - accountID: '168237', - zoneID: '299680', - keyword: 'business', - minCPM: '0.10', - maxCPM: '1.00' - }, - placementCode: '/19968336/header-bid-tag-1', - sizes: [[728, 90]], - bidId: '23acc48ad47af5', - auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - - describe('implementation', function () { - describe('for requests', function () { - it('should accept valid bid', function () { - const validBid = { - bidder: 'contentignite', - params: { - accountID: '168237', - zoneID: '299680' - } - }, - isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject invalid bid', function () { - const invalidBid = { - bidder: 'contentignite', - params: { - accountID: '168237' - } - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should set the keyword parameter', function () { - const requests = spec.buildRequests(bidRequests), - requestURL = requests[0].url; - - expect(requestURL).to.have.string(';kw=business;'); - }); - - it('should increment the count for the same zone', function () { - const bidRequests = [ - { - sizes: [[728, 90]], - bidder: 'contentignite', - params: { - accountID: '107878', - zoneID: '86133' - } - }, - { - sizes: [[728, 90]], - bidder: 'contentignite', - params: { - accountID: '107878', - zoneID: '86133' - } - } - ], - requests = spec.buildRequests(bidRequests), - firstRequest = requests[0].url, - secondRequest = requests[1].url; - - expect(firstRequest).to.have.string(';place=0;'); - expect(secondRequest).to.have.string(';place=1;'); - }); - }); - - describe('bid responses', function () { - it('should return complete bid response', function () { - const serverResponse = { - body: { - status: 'SUCCESS', - account_id: 107878, - zone_id: 86133, - cpm: 0.1, - width: 728, - height: 90, - place: 0, - ad_code: - '
', - tracking_pixels: [] - } - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(1); - expect(bids[0].cpm).to.equal(0.1); - expect(bids[0].width).to.equal(728); - expect(bids[0].height).to.equal(90); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].ad).to.have.length.above(1); - }); - - it('should return empty bid response', function () { - const serverResponse = { - status: 'NO_ELIGIBLE_ADS', - zone_id: 299680, - width: 728, - height: 90, - place: 0 - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response on incorrect size', function () { - const serverResponse = { - status: 'SUCCESS', - account_id: 168237, - zone_id: 299680, - cpm: 0.1, - width: 300, - height: 250, - place: 0 - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with CPM too low', function () { - const serverResponse = { - status: 'SUCCESS', - account_id: 168237, - zone_id: 299680, - cpm: 0.05, - width: 728, - height: 90, - place: 0 - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with CPM too high', function () { - const serverResponse = { - status: 'SUCCESS', - account_id: 168237, - zone_id: 299680, - cpm: 7.0, - width: 728, - height: 90, - place: 0 - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(0); - }); - }); - }); -}); diff --git a/test/spec/modules/convergeBidAdapter_spec.js b/test/spec/modules/convergeBidAdapter_spec.js new file mode 100644 index 00000000000..e92ed475497 --- /dev/null +++ b/test/spec/modules/convergeBidAdapter_spec.js @@ -0,0 +1,899 @@ +import { expect } from 'chai'; +import { spec, resetUserSync, getSyncUrl } from 'modules/convergeBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +describe('ConvergeAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'converge', + 'params': { + 'uid': '1' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'uid': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + function parseRequest(url) { + const res = {}; + url.split('&').forEach((it) => { + const couple = it.split('='); + res[couple[0]] = decodeURIComponent(couple[1]); + }); + return res; + } + + const bidderRequest = { + refererInfo: { + referer: 'https://example.com' + } + }; + const referrer = bidderRequest.refererInfo.referer; + + let bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90], [300, 250]], + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '42dbe3a7168a6a', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should attach valid params to the tag', function () { + const request = spec.buildRequests([bidRequests[0]], bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'net'); + expect(payload).to.have.property('auids', '59'); + expect(payload).to.have.property('sizes', '300x250,300x600'); + expect(payload).to.have.property('r', '22edbae2733bf6'); + expect(payload).to.have.property('wrapperType', 'Prebid_js'); + expect(payload).to.have.property('wrapperVersion', '$prebid.version$'); + }); + + it('sizes must not be duplicated', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'net'); + expect(payload).to.have.property('auids', '59,59,60'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); + expect(payload).to.have.property('r', '22edbae2733bf6'); + }); + + it('pt parameter must be "gross" if params.priceType === "gross"', function () { + bidRequests[1].params.priceType = 'gross'; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'gross'); + expect(payload).to.have.property('auids', '59,59,60'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); + expect(payload).to.have.property('r', '22edbae2733bf6'); + delete bidRequests[1].params.priceType; + }); + + it('pt parameter must be "net" or "gross"', function () { + bidRequests[1].params.priceType = 'some'; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'net'); + expect(payload).to.have.property('auids', '59,59,60'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); + expect(payload).to.have.property('r', '22edbae2733bf6'); + delete bidRequests[1].params.priceType; + }); + + it('if gdprConsent is present payload must have gdpr params', function () { + const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: true}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('gdpr_consent', 'AAA'); + expect(payload).to.have.property('gdpr_applies', '1'); + }); + + it('if gdprApplies is false gdpr_applies must be 0', function () { + const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: false}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('gdpr_consent', 'AAA'); + expect(payload).to.have.property('gdpr_applies', '0'); + }); + + it('if gdprApplies is undefined gdpr_applies must be 1', function () { + const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA'}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('gdpr_consent', 'AAA'); + expect(payload).to.have.property('gdpr_applies', '1'); + }); + + it('if usPrivacy is present payload must have us_privacy param', function () { + const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithUSP); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('us_privacy', '1YNN'); + }); + + it('should convert keyword params to proper form and attaches to request', function () { + const bidRequestWithKeywords = [].concat(bidRequests); + bidRequestWithKeywords[1] = Object.assign({}, + bidRequests[1], + { + params: { + uid: '59', + keywords: { + single: 'val', + singleArr: ['val'], + singleArrNum: [5], + multiValMixed: ['value1', 2, 'value3'], + singleValNum: 123, + emptyStr: '', + emptyArr: [''], + badValue: {'foo': 'bar'} // should be dropped + } + } + } + ); + + const request = spec.buildRequests(bidRequestWithKeywords, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.keywords).to.be.an('string'); + payload.keywords = JSON.parse(payload.keywords); + + expect(payload.keywords).to.deep.equal([{ + 'key': 'single', + 'value': ['val'] + }, { + 'key': 'singleArr', + 'value': ['val'] + }, { + 'key': 'singleArrNum', + 'value': ['5'] + }, { + 'key': 'multiValMixed', + 'value': ['value1', '2', 'value3'] + }, { + 'key': 'singleValNum', + 'value': ['123'] + }, { + 'key': 'emptyStr' + }, { + 'key': 'emptyArr' + }]); + }); + }); + + describe('interpretResponse', function () { + const responses = [ + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 60, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 59, 'h': 90, 'w': 728}], 'seat': '1'}, + {'bid': [{'price': 0, 'auid': 61, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0, 'adm': '
test content 5
', 'h': 250, 'w': 300}], 'seat': '1'}, + undefined, + {'bid': [], 'seat': '1'}, + {'seat': '1'}, + ]; + + it('should get correct bid response', function () { + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '659423fff799cb', + 'bidderRequestId': '5f2009617a7c0a', + 'auctionId': '1cbd2feafe5e8b', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '659423fff799cb', + 'cpm': 1.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('should get correct multi bid response', function () { + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '300bfeb0d71a5b', + 'bidderRequestId': '2c2bb1972df9a', + 'auctionId': '1fa09aee5c8c99', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '4dff80cc4ee346', + 'bidderRequestId': '2c2bb1972df9a', + 'auctionId': '1fa09aee5c8c99', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '5703af74d0472a', + 'bidderRequestId': '2c2bb1972df9a', + 'auctionId': '1fa09aee5c8c99', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '300bfeb0d71a5b', + 'cpm': 1.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '4dff80cc4ee346', + 'cpm': 0.5, + 'creativeId': 60, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
test content 2
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '5703af74d0472a', + 'cpm': 0.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 728, + 'height': 90, + 'ad': '
test content 3
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': responses.slice(0, 3)}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('handles wrong and nobid responses', function () { + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '61' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '300bfeb0d7190gf', + 'bidderRequestId': '2c2bb1972d23af', + 'auctionId': '1fa09aee5c84d34', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '65' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '300bfeb0d71321', + 'bidderRequestId': '2c2bb1972d23af', + 'auctionId': '1fa09aee5c84d34', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '70' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '300bfeb0d7183bb', + 'bidderRequestId': '2c2bb1972d23af', + 'auctionId': '1fa09aee5c84d34', + } + ]; + const request = spec.buildRequests(bidRequests); + const result = spec.interpretResponse({'body': {'seatbid': responses.slice(3)}}, request); + expect(result.length).to.equal(0); + }); + + it('complicated case', function () { + const fullResponse = [ + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 60, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 59, 'h': 90, 'w': 728}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 4
', 'auid': 59, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 5
', 'auid': 60, 'h': 600, 'w': 350}], 'seat': '1'}, + ]; + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2164be6358b9', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '326bde7fbf69', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '4e111f1b66e4', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '26d6f897b516', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '1751cd90161', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '2164be6358b9', + 'cpm': 1.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '4e111f1b66e4', + 'cpm': 0.5, + 'creativeId': 60, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
test content 2
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '26d6f897b516', + 'cpm': 0.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 728, + 'height': 90, + 'ad': '
test content 3
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '326bde7fbf69', + 'cpm': 0.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
test content 4
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('dublicate uids and sizes in one slot', function () { + const fullResponse = [ + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, + ]; + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '5126e301f4be', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '57b2ebe70e16', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '225fcd44b18c', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '5126e301f4be', + 'cpm': 1.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '57b2ebe70e16', + 'cpm': 0.5, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 2
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + }); + + it('should get correct video bid response', function () { + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '58' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '57dfefb80eca', + 'bidderRequestId': '20394420a762a2', + 'auctionId': '140132d07b031', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'e893c787c22dd', + 'bidderRequestId': '20394420a762a2', + 'auctionId': '140132d07b031', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + } + ]; + const response = [ + {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 58, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, + {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 60, content_type: 'video'}], 'seat': '2'} + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '57dfefb80eca', + 'cpm': 1.15, + 'creativeId': 58, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'video', + 'netRevenue': true, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + } + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': response}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('should have right renderer in the bid response', function () { + const spySetRenderer = sinon.spy(); + const stubRenderer = { + setRender: spySetRenderer + }; + const spyRendererInstall = sinon.spy(function() { return stubRenderer; }); + const stubRendererConst = { + install: spyRendererInstall + }; + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '58' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'e6e65553fc8', + 'bidderRequestId': '1380f393215dc7', + 'auctionId': '10b8d2f3c697e3', + 'mediaTypes': { + 'video': { + 'context': 'outstream' + } + } + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'c8fdcb3f269f', + 'bidderRequestId': '1380f393215dc7', + 'auctionId': '10b8d2f3c697e3' + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '61' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '1de036c37685', + 'bidderRequestId': '1380f393215dc7', + 'auctionId': '10b8d2f3c697e3', + 'renderer': {} + } + ]; + const response = [ + {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 58, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, + {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 60, content_type: 'video', w: 300, h: 250}], 'seat': '2'}, + {'bid': [{'price': 1.20, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 61, content_type: 'video', w: 300, h: 250}], 'seat': '2'} + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': 'e6e65553fc8', + 'cpm': 1.15, + 'creativeId': 58, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'video', + 'netRevenue': true, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + }, + 'renderer': stubRenderer + }, + { + 'requestId': 'c8fdcb3f269f', + 'cpm': 1.00, + 'creativeId': 60, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'video', + 'netRevenue': true, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + }, + 'renderer': stubRenderer + }, + { + 'requestId': '1de036c37685', + 'cpm': 1.20, + 'creativeId': 61, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'video', + 'netRevenue': true, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + } + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': response}}, request, stubRendererConst); + + expect(spySetRenderer.calledTwice).to.equal(true); + expect(spySetRenderer.getCall(0).args[0]).to.be.a('function'); + expect(spySetRenderer.getCall(1).args[0]).to.be.a('function'); + + expect(spyRendererInstall.calledTwice).to.equal(true); + expect(spyRendererInstall.getCall(0).args[0]).to.deep.equal({ + id: 'e6e65553fc8', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + loaded: false + }); + expect(spyRendererInstall.getCall(1).args[0]).to.deep.equal({ + id: 'c8fdcb3f269f', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + loaded: false + }); + + expect(result).to.deep.equal(expectedResponse); + }); + + describe('user sync', function () { + const syncUrl = getSyncUrl(); + + beforeEach(function () { + resetUserSync(); + }); + + it('should register sync image', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + }); + + it('should not register sync image more than once', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + + // when called again, should still have only been called once + syncs = spec.getUserSyncs(); + expect(syncs).to.equal(undefined); + }); + + it('should pass gdpr params if consent is true', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: true, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=1&gdpr_consent=foo` + }); + }); + + it('should pass gdpr params if consent is false', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: false, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=0&gdpr_consent=foo` + }); + }); + + it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr_consent=foo` + }); + }); + + it('should pass no params if gdpr consentString is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {})).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a number', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 0 + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is null', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: null + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a object', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: {} + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined)).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass usPrivacy param if it is available', function() { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {}, '1YNN')).to.deep.equal({ + type: 'image', url: `${syncUrl}&us_privacy=1YNN` + }); + }); + }); +}); diff --git a/test/spec/modules/conversantBidAdapter_spec.js b/test/spec/modules/conversantBidAdapter_spec.js index bfe3c6e8fa1..28075628d5a 100644 --- a/test/spec/modules/conversantBidAdapter_spec.js +++ b/test/spec/modules/conversantBidAdapter_spec.js @@ -1,11 +1,11 @@ import {expect} from 'chai'; -import {spec} from 'modules/conversantBidAdapter'; -import * as utils from 'src/utils'; - -var Adapter = require('modules/conversantBidAdapter'); +import {spec, storage} from 'modules/conversantBidAdapter.js'; +import * as utils from 'src/utils.js'; +import { createEidsArray } from 'modules/userId/eids.js'; describe('Conversant adapter tests', function() { const siteId = '108060'; + const versionPattern = /^\d+\.\d+\.\d+(.)*$/; const bidRequests = [ // banner with single size @@ -15,7 +15,6 @@ describe('Conversant adapter tests', function() { site_id: siteId, position: 1, tag_id: 'tagid-1', - secure: false, bidfloor: 0.5 }, placementCode: 'pcode000', @@ -29,8 +28,7 @@ describe('Conversant adapter tests', function() { { bidder: 'conversant', params: { - site_id: siteId, - secure: false + site_id: siteId }, mediaTypes: { banner: { @@ -49,8 +47,7 @@ describe('Conversant adapter tests', function() { params: { site_id: siteId, position: 2, - tag_id: '', - secure: false + tag_id: '' }, placementCode: 'pcode002', transactionId: 'tx002', @@ -160,6 +157,14 @@ describe('Conversant adapter tests', function() { price: 3.99, adomain: ['https://example.com'], id: 'bid003' + }, { + nurl: 'notify004', + adm: '', + crid: '1004', + impid: 'bid004', + price: 4.99, + adomain: ['https://example.com'], + id: 'bid004' }] }] }, @@ -197,9 +202,15 @@ describe('Conversant adapter tests', function() { }); it('Verify buildRequest', function() { - const request = spec.buildRequests(bidRequests); + const page = 'http://test.com?a=b&c=123'; + const bidderRequest = { + refererInfo: { + referer: page + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.method).to.equal('POST'); - expect(request.url).to.equal('//web.hb.ad.cpe.dotomi.com/s2s/header/24'); + expect(request.url).to.equal('https://web.hb.ad.cpe.dotomi.com/s2s/header/24'); const payload = request.data; expect(payload).to.have.property('id', 'req000'); @@ -208,10 +219,10 @@ describe('Conversant adapter tests', function() { expect(payload.imp).to.be.an('array').with.lengthOf(6); expect(payload.imp[0]).to.have.property('id', 'bid000'); - expect(payload.imp[0]).to.have.property('secure', 0); + expect(payload.imp[0]).to.have.property('secure', 1); expect(payload.imp[0]).to.have.property('bidfloor', 0.5); expect(payload.imp[0]).to.have.property('displaymanager', 'Prebid.js'); - expect(payload.imp[0]).to.have.property('displaymanagerver').that.matches(/^\d+\.\d+\.\d+$/); + expect(payload.imp[0]).to.have.property('displaymanagerver').that.matches(versionPattern); expect(payload.imp[0]).to.have.property('tagid', 'tagid-1'); expect(payload.imp[0]).to.have.property('banner'); expect(payload.imp[0].banner).to.have.property('pos', 1); @@ -220,10 +231,10 @@ describe('Conversant adapter tests', function() { expect(payload.imp[0]).to.not.have.property('video'); expect(payload.imp[1]).to.have.property('id', 'bid001'); - expect(payload.imp[1]).to.have.property('secure', 0); + expect(payload.imp[1]).to.have.property('secure', 1); expect(payload.imp[1]).to.have.property('bidfloor', 0); expect(payload.imp[1]).to.have.property('displaymanager', 'Prebid.js'); - expect(payload.imp[1]).to.have.property('displaymanagerver').that.matches(/^\d+\.\d+\.\d+$/); + expect(payload.imp[1]).to.have.property('displaymanagerver').that.matches(versionPattern); expect(payload.imp[1]).to.not.have.property('tagid'); expect(payload.imp[1]).to.have.property('banner'); expect(payload.imp[1].banner).to.not.have.property('pos'); @@ -231,20 +242,20 @@ describe('Conversant adapter tests', function() { expect(payload.imp[1].banner.format).to.deep.equal([{w: 728, h: 90}, {w: 468, h: 60}]); expect(payload.imp[2]).to.have.property('id', 'bid002'); - expect(payload.imp[2]).to.have.property('secure', 0); + expect(payload.imp[2]).to.have.property('secure', 1); expect(payload.imp[2]).to.have.property('bidfloor', 0); expect(payload.imp[2]).to.have.property('displaymanager', 'Prebid.js'); - expect(payload.imp[2]).to.have.property('displaymanagerver').that.matches(/^\d+\.\d+\.\d+$/); + expect(payload.imp[2]).to.have.property('displaymanagerver').that.matches(versionPattern); expect(payload.imp[2]).to.have.property('banner'); expect(payload.imp[2].banner).to.have.property('pos', 2); expect(payload.imp[2].banner).to.have.property('format'); expect(payload.imp[2].banner.format).to.deep.equal([{w: 300, h: 600}, {w: 160, h: 600}]); expect(payload.imp[3]).to.have.property('id', 'bid003'); - expect(payload.imp[3]).to.have.property('secure', 0); + expect(payload.imp[3]).to.have.property('secure', 1); expect(payload.imp[3]).to.have.property('bidfloor', 0); expect(payload.imp[3]).to.have.property('displaymanager', 'Prebid.js'); - expect(payload.imp[3]).to.have.property('displaymanagerver').that.matches(/^\d+\.\d+\.\d+$/); + expect(payload.imp[3]).to.have.property('displaymanagerver').that.matches(versionPattern); expect(payload.imp[3]).to.not.have.property('tagid'); expect(payload.imp[3]).to.have.property('video'); expect(payload.imp[3].video).to.not.have.property('pos'); @@ -260,10 +271,10 @@ describe('Conversant adapter tests', function() { expect(payload.imp[3]).to.not.have.property('banner'); expect(payload.imp[4]).to.have.property('id', 'bid004'); - expect(payload.imp[4]).to.have.property('secure', 0); + expect(payload.imp[4]).to.have.property('secure', 1); expect(payload.imp[4]).to.have.property('bidfloor', 0); expect(payload.imp[4]).to.have.property('displaymanager', 'Prebid.js'); - expect(payload.imp[4]).to.have.property('displaymanagerver').that.matches(/^\d+\.\d+\.\d+$/); + expect(payload.imp[4]).to.have.property('displaymanagerver').that.matches(versionPattern); expect(payload.imp[4]).to.not.have.property('tagid'); expect(payload.imp[4]).to.have.property('video'); expect(payload.imp[4].video).to.not.have.property('pos'); @@ -279,10 +290,10 @@ describe('Conversant adapter tests', function() { expect(payload.imp[4]).to.not.have.property('banner'); expect(payload.imp[5]).to.have.property('id', 'bid005'); - expect(payload.imp[5]).to.have.property('secure', 0); + expect(payload.imp[5]).to.have.property('secure', 1); expect(payload.imp[5]).to.have.property('bidfloor', 0); expect(payload.imp[5]).to.have.property('displaymanager', 'Prebid.js'); - expect(payload.imp[5]).to.have.property('displaymanagerver').that.matches(/^\d+\.\d+\.\d+$/); + expect(payload.imp[5]).to.have.property('displaymanagerver').that.matches(versionPattern); expect(payload.imp[5]).to.not.have.property('tagid'); expect(payload.imp[5]).to.have.property('video'); expect(payload.imp[5].video).to.not.have.property('pos'); @@ -298,8 +309,7 @@ describe('Conversant adapter tests', function() { expect(payload).to.have.property('site'); expect(payload.site).to.have.property('id', siteId); expect(payload.site).to.have.property('mobile').that.is.oneOf([0, 1]); - const loc = utils.getTopWindowLocation(); - const page = loc.href; + expect(payload.site).to.have.property('page', page); expect(payload).to.have.property('device'); @@ -314,7 +324,7 @@ describe('Conversant adapter tests', function() { it('Verify interpretResponse', function() { const request = spec.buildRequests(bidRequests); const response = spec.interpretResponse(bidResponses, request); - expect(response).to.be.an('array').with.lengthOf(3); + expect(response).to.be.an('array').with.lengthOf(4); let bid = response[0]; expect(bid).to.have.property('requestId', 'bid000'); @@ -351,6 +361,9 @@ describe('Conversant adapter tests', function() { expect(bid).to.have.property('mediaType', 'video'); expect(bid).to.have.property('ttl', 300); expect(bid).to.have.property('netRevenue', true); + + bid = response[3]; + expect(bid).to.have.property('vastXml', ''); }); it('Verify handling of bad responses', function() { @@ -364,7 +377,7 @@ describe('Conversant adapter tests', function() { it('Verify publisher commond id support', function() { // clone bidRequests - let requests = utils.deepClone(bidRequests) + let requests = utils.deepClone(bidRequests); // add pubcid to every entry requests.forEach((unit) => { @@ -373,45 +386,199 @@ describe('Conversant adapter tests', function() { // construct http post payload const payload = spec.buildRequests(requests).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', 12345); + expect(payload).to.not.have.nested.property('user.ext.eids'); }); it('Verify User ID publisher commond id support', function() { // clone bidRequests - let requests = utils.deepClone(bidRequests) + let requests = utils.deepClone(bidRequests); // add pubcid to every entry requests.forEach((unit) => { Object.assign(unit, {userId: {pubcid: 67890}}); + Object.assign(unit, {userIdAsEids: createEidsArray(unit.userId)}); }); // construct http post payload const payload = spec.buildRequests(requests).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', 67890); + expect(payload).to.not.have.nested.property('user.ext.eids'); }); it('Verify GDPR bid request', function() { // add gdpr info - const bidRequest = { + const bidderRequest = { gdprConsent: { consentString: 'BOJObISOJObISAABAAENAA4AAAAAoAAA', gdprApplies: true } }; - const payload = spec.buildRequests(bidRequests, bidRequest).data; + const payload = spec.buildRequests(bidRequests, bidderRequest).data; expect(payload).to.have.deep.nested.property('user.ext.consent', 'BOJObISOJObISAABAAENAA4AAAAAoAAA'); expect(payload).to.have.deep.nested.property('regs.ext.gdpr', 1); }); it('Verify GDPR bid request without gdprApplies', function() { // add gdpr info - const bidRequest = { + const bidderRequest = { gdprConsent: { consentString: '' } }; - const payload = spec.buildRequests(bidRequests, bidRequest).data; + const payload = spec.buildRequests(bidRequests, bidderRequest).data; expect(payload).to.have.deep.nested.property('user.ext.consent', ''); expect(payload).to.not.have.deep.nested.property('regs.ext.gdpr'); }); -}) + + describe('CCPA', function() { + it('should have us_privacy', function() { + const bidderRequest = { + uspConsent: '1NYN' + }; + + const payload = spec.buildRequests(bidRequests, bidderRequest).data; + expect(payload).to.have.deep.nested.property('regs.ext.us_privacy', '1NYN'); + expect(payload).to.not.have.deep.nested.property('regs.ext.gdpr'); + }); + + it('should have no us_privacy', function() { + const payload = spec.buildRequests(bidRequests, {}).data; + expect(payload).to.not.have.deep.nested.property('regs.ext.us_privacy'); + }); + + it('should have both gdpr and us_privacy', function() { + const bidderRequest = { + gdprConsent: { + consentString: 'BOJObISOJObISAABAAENAA4AAAAAoAAA', + gdprApplies: true + }, + uspConsent: '1NYN' + }; + + const payload = spec.buildRequests(bidRequests, bidderRequest).data; + expect(payload).to.have.deep.nested.property('user.ext.consent', 'BOJObISOJObISAABAAENAA4AAAAAoAAA'); + expect(payload).to.have.deep.nested.property('regs.ext.gdpr', 1); + expect(payload).to.have.deep.nested.property('regs.ext.us_privacy', '1NYN'); + }); + }); + + describe('Extended ID', function() { + it('Verify unifiedid and liveramp', function() { + // clone bidRequests + let requests = utils.deepClone(bidRequests); + + // add pubcid to every entry + requests.forEach((unit) => { + Object.assign(unit, {userId: {pubcid: '112233', tdid: '223344', idl_env: '334455'}}); + Object.assign(unit, {userIdAsEids: createEidsArray(unit.userId)}); + }); + // construct http post payload + const payload = spec.buildRequests(requests).data; + expect(payload).to.have.deep.nested.property('user.ext.eids', [ + {source: 'adserver.org', uids: [{id: '223344', atype: 1, ext: {rtiPartner: 'TDID'}}]}, + {source: 'liveramp.com', uids: [{id: '334455', atype: 1}]} + ]); + }); + }); + + describe('direct reading pubcid', function() { + const ID_NAME = '_pubcid'; + const CUSTOM_ID_NAME = 'myid'; + const EXP = '_exp'; + const TIMEOUT = 2000; + + function cleanUp(key) { + window.document.cookie = key + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; + localStorage.removeItem(key); + localStorage.removeItem(key + EXP); + } + + function expStr(timeout) { + return (new Date(Date.now() + timeout * 60 * 60 * 24 * 1000)).toUTCString(); + } + + afterEach(() => { + cleanUp(ID_NAME); + cleanUp(CUSTOM_ID_NAME); + }); + + it('reading cookie', function() { + // clone bidRequests + const requests = utils.deepClone(bidRequests); + + // add a pubcid cookie + storage.setCookie(ID_NAME, '12345', expStr(TIMEOUT)); + + // construct http post payload + const payload = spec.buildRequests(requests).data; + expect(payload).to.have.deep.nested.property('user.ext.fpc', '12345'); + }); + + it('reading custom cookie', function() { + // clone bidRequests + const requests = utils.deepClone(bidRequests); + requests[0].params.pubcid_name = CUSTOM_ID_NAME; + + // add a pubcid cookie + storage.setCookie(CUSTOM_ID_NAME, '12345', expStr(TIMEOUT)); + + // construct http post payload + const payload = spec.buildRequests(requests).data; + expect(payload).to.have.deep.nested.property('user.ext.fpc', '12345'); + }); + + it('reading local storage with empty exp time', function() { + // clone bidRequests + const requests = utils.deepClone(bidRequests); + + // add a pubcid in local storage + storage.setDataInLocalStorage(ID_NAME + EXP, ''); + storage.setDataInLocalStorage(ID_NAME, 'abcde'); + + // construct http post payload + const payload = spec.buildRequests(requests).data; + expect(payload).to.have.deep.nested.property('user.ext.fpc', 'abcde'); + }); + + it('reading local storage with valid exp time', function() { + // clone bidRequests + const requests = utils.deepClone(bidRequests); + + // add a pubcid in local storage + storage.setDataInLocalStorage(ID_NAME + EXP, expStr(TIMEOUT)); + storage.setDataInLocalStorage(ID_NAME, 'fghijk'); + + // construct http post payload + const payload = spec.buildRequests(requests).data; + expect(payload).to.have.deep.nested.property('user.ext.fpc', 'fghijk'); + }); + + it('reading expired local storage', function() { + // clone bidRequests + const requests = utils.deepClone(bidRequests); + + // add a pubcid in local storage + storage.setDataInLocalStorage(ID_NAME + EXP, expStr(-TIMEOUT)); + storage.setDataInLocalStorage(ID_NAME, 'lmnopq'); + + // construct http post payload + const payload = spec.buildRequests(requests).data; + expect(payload).to.not.have.deep.nested.property('user.ext.fpc'); + }); + + it('reading local storage with custom name', function() { + // clone bidRequests + const requests = utils.deepClone(bidRequests); + requests[0].params.pubcid_name = CUSTOM_ID_NAME; + + // add a pubcid in local storage + storage.setDataInLocalStorage(CUSTOM_ID_NAME + EXP, expStr(TIMEOUT)); + storage.setDataInLocalStorage(CUSTOM_ID_NAME, 'fghijk'); + + // construct http post payload + const payload = spec.buildRequests(requests).data; + expect(payload).to.have.deep.nested.property('user.ext.fpc', 'fghijk'); + }); + }); +}); diff --git a/test/spec/modules/cosmosBidAdapter_spec.js b/test/spec/modules/cosmosBidAdapter_spec.js index 348f5ae3ddf..b33f53221e2 100644 --- a/test/spec/modules/cosmosBidAdapter_spec.js +++ b/test/spec/modules/cosmosBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/cosmosBidAdapter'; -import * as utils from 'src/utils'; +import { spec } from 'modules/cosmosBidAdapter.js'; +import * as utils from 'src/utils.js'; const constants = require('src/constants.json'); describe('Cosmos adapter', function () { @@ -87,7 +87,7 @@ describe('Cosmos adapter', function () { 'id': '82DAAE22-FF66-4FAB-84AB-347B0C5CD02C', 'impid': '39f5cc6eff9b37', 'price': 0.858309, - 'adm': 'CosmosHQVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1https://track.cosmoshq.com/event?data=%7B%22id%22%3A%221566011421045%22%2C%22bid%22%3A%2282DAAE22-FF66-4FAB-84AB-347B0C5CD02C%22%2C%22ts%22%3A%2220190817031021%22%2C%22pid%22%3A1001%2C%22plcid%22%3A1%2C%22aid%22%3A1%2C%22did%22%3A1%2C%22cid%22%3A%2222918%22%2C%22af%22%3A3%2C%22at%22%3A1%2C%22w%22%3A300%2C%22h%22%3A250%2C%22crid%22%3A%22v55jutrh%22%2C%22pp%22%3A0.858309%2C%22cp%22%3A0.858309%2C%22mg%22%3A0%7D&type=1http://track.dsp.impression.com/impression00:00:60http://sync.cosmoshq.com/static/video/SampleVideo_1280x720_10mb.mp4', + 'adm': 'CosmosHQVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1https://track.cosmoshq.com/event?data=%7B%22id%22%3A%221566011421045%22%2C%22bid%22%3A%2282DAAE22-FF66-4FAB-84AB-347B0C5CD02C%22%2C%22ts%22%3A%2220190817031021%22%2C%22pid%22%3A1001%2C%22plcid%22%3A1%2C%22aid%22%3A1%2C%22did%22%3A1%2C%22cid%22%3A%2222918%22%2C%22af%22%3A3%2C%22at%22%3A1%2C%22w%22%3A300%2C%22h%22%3A250%2C%22crid%22%3A%22v55jutrh%22%2C%22pp%22%3A0.858309%2C%22cp%22%3A0.858309%2C%22mg%22%3A0%7D&type=1https//track.dsp.impression.com/impression00:00:60https//sync.cosmoshq.com/static/video/SampleVideo_1280x720_10mb.mp4', 'adid': 'v55jutrh', 'adomain': ['febreze.com'], 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', @@ -202,7 +202,7 @@ describe('Cosmos adapter', function () { it('build request object: endpoint check', function () { let request = spec.buildRequests(bannerBidRequests); - expect(request[0].url).to.equal('//bid.cosmoshq.com/openrtb2/bids'); + expect(request[0].url).to.equal('https://bid.cosmoshq.com/openrtb2/bids'); expect(request[0].method).to.equal('POST'); }); diff --git a/test/spec/modules/cpmstarBidAdapter_spec.js b/test/spec/modules/cpmstarBidAdapter_spec.js index 3dd06a484d9..9e794d3e098 100755 --- a/test/spec/modules/cpmstarBidAdapter_spec.js +++ b/test/spec/modules/cpmstarBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/cpmstarBidAdapter'; -import { deepClone } from 'src/utils'; +import { spec } from 'modules/cpmstarBidAdapter.js'; +import { deepClone } from 'src/utils.js'; describe('Cpmstar Bid Adapter', function () { describe('isBidRequestValid', function () { @@ -59,7 +59,7 @@ describe('Cpmstar Bid Adapter', function () { expect(requests[0]).to.have.property('method'); expect(requests[0]).to.have.property('url'); expect(requests[0]).to.have.property('bidRequest'); - expect(requests[0].url).to.include('//server.cpmstar.com/view.aspx'); + expect(requests[0].url).to.include('https://server.cpmstar.com/view.aspx'); }); it('should produce a valid staging request', function () { var stgReq = deepClone(valid_bid_requests); @@ -68,7 +68,7 @@ describe('Cpmstar Bid Adapter', function () { expect(requests[0]).to.have.property('method'); expect(requests[0]).to.have.property('url'); expect(requests[0]).to.have.property('bidRequest'); - expect(requests[0].url).to.include('//staging.server.cpmstar.com/view.aspx'); + expect(requests[0].url).to.include('https://staging.server.cpmstar.com/view.aspx'); }); it('should produce a valid dev request', function () { var devReq = deepClone(valid_bid_requests); @@ -77,7 +77,7 @@ describe('Cpmstar Bid Adapter', function () { expect(requests[0]).to.have.property('method'); expect(requests[0]).to.have.property('url'); expect(requests[0]).to.have.property('bidRequest'); - expect(requests[0].url).to.include('//dev.server.cpmstar.com/view.aspx'); + expect(requests[0].url).to.include('https://dev.server.cpmstar.com/view.aspx'); }); }) diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index f85e5957950..b1319871b34 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -1,23 +1,26 @@ import { expect } from 'chai'; -import { tryGetCriteoFastBid, spec, PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, PUBLISHER_TAG_URL } from 'modules/criteoBidAdapter'; -import { createBid } from 'src/bidfactory'; +import { tryGetCriteoFastBid, spec, PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, PUBLISHER_TAG_URL } from 'modules/criteoBidAdapter.js'; +import { createBid } from 'src/bidfactory.js'; import CONSTANTS from 'src/constants.json'; -import * as utils from 'src/utils'; -import { config } from '../../../src/config'; -import { VIDEO } from '../../../src/mediaTypes'; +import * as utils from 'src/utils.js'; +import { config } from '../../../src/config.js'; +import { NATIVE, VIDEO } from '../../../src/mediaTypes.js'; describe('The Criteo bidding adapter', function () { - let utilsMock; + let utilsMock, sandbox; beforeEach(function () { // Remove FastBid to avoid side effects localStorage.removeItem('criteo_fast_bid'); utilsMock = sinon.mock(utils); + + sandbox = sinon.sandbox.create(); }); afterEach(function() { global.Criteo = undefined; utilsMock.restore(); + sandbox.restore(); }); describe('isBidRequestValid', function () { @@ -368,7 +371,11 @@ describe('The Criteo bidding adapter', function () { }); describe('buildRequests', function () { + const refererUrl = 'https://criteo.com?pbt_debug=1&pbt_nolog=1'; const bidderRequest = { + refererInfo: { + referer: refererUrl + }, timeout: 3000, gdprConsent: { gdprApplies: 1, @@ -385,10 +392,23 @@ describe('The Criteo bidding adapter', function () { config.resetConfig(); }); - it('should properly build a zoneId request', function () { - const publisherUrl = 'https://criteo.com?pbt_debug=1&pbt_nolog=1'; - utilsMock.expects('getTopWindowUrl').withExactArgs().once().returns(publisherUrl); + it('should properly build a request if refererInfo is not provided', function () { + const bidderRequest = {}; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: {} + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.publisher.url).to.equal(''); + }); + it('should properly build a zoneId request', function () { const bidRequests = [ { bidder: 'criteo', @@ -404,10 +424,10 @@ describe('The Criteo bidding adapter', function () { }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&im=1&debug=1&nolog=1/); + expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&im=1&debug=1&nolog=1/); expect(request.method).to.equal('POST'); const ortbRequest = request.data; - expect(ortbRequest.publisher.url).to.equal(publisherUrl); + expect(ortbRequest.publisher.url).to.equal(refererUrl); expect(ortbRequest.slots).to.have.lengthOf(1); expect(ortbRequest.slots[0].impid).to.equal('bid-123'); expect(ortbRequest.slots[0].transactionid).to.equal('transaction-123'); @@ -421,6 +441,9 @@ describe('The Criteo bidding adapter', function () { it('should properly build a networkId request', function () { const bidderRequest = { + refererInfo: { + referer: refererUrl + }, timeout: 3000, gdprConsent: { gdprApplies: 0, @@ -448,10 +471,10 @@ describe('The Criteo bidding adapter', function () { }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); + expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); expect(request.method).to.equal('POST'); const ortbRequest = request.data; - expect(ortbRequest.publisher.url).to.equal(utils.getTopWindowUrl()); + expect(ortbRequest.publisher.url).to.equal(refererUrl); expect(ortbRequest.publisher.networkid).to.equal(456); expect(ortbRequest.slots).to.have.lengthOf(1); expect(ortbRequest.slots[0].impid).to.equal('bid-123'); @@ -465,7 +488,12 @@ describe('The Criteo bidding adapter', function () { }); it('should properly build a mixed request', function () { - const bidderRequest = { timeout: 3000 }; + const bidderRequest = { + refererInfo: { + referer: refererUrl + }, + timeout: 3000 + }; const bidRequests = [ { bidder: 'criteo', @@ -487,10 +515,10 @@ describe('The Criteo bidding adapter', function () { }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); + expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); expect(request.method).to.equal('POST'); const ortbRequest = request.data; - expect(ortbRequest.publisher.url).to.equal(utils.getTopWindowUrl()); + expect(ortbRequest.publisher.url).to.equal(refererUrl); expect(ortbRequest.publisher.networkid).to.equal(456); expect(ortbRequest.slots).to.have.lengthOf(2); expect(ortbRequest.slots[0].impid).to.equal('bid-123'); @@ -517,9 +545,9 @@ describe('The Criteo bidding adapter', function () { }, }, ]; - const bidderRequest = { timeout: 3000, - gdprConsent: { - }, + const bidderRequest = { + timeout: 3000, + gdprConsent: {}, }; const ortbRequest = spec.buildRequests(bidRequests, bidderRequest).data; @@ -528,6 +556,49 @@ describe('The Criteo bidding adapter', function () { expect(ortbRequest.gdprConsent.consentGiven).to.equal(undefined); }); + it('should properly build a request with ccpa consent field', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { + timeout: 3000, + uspConsent: '1YNY', + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.user).to.not.be.null; + expect(request.data.user.uspIab).to.equal('1YNY'); + }); + + it('should properly build a request with if ccpa consent field is not provided', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { + timeout: 3000 + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.user).to.not.be.null; + expect(request.data.user.uspIab).to.equal(undefined); + }); + it('should properly build a video request', function () { const bidRequests = [ { @@ -557,7 +628,7 @@ describe('The Criteo bidding adapter', function () { }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); + expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); expect(request.method).to.equal('POST'); const ortbRequest = request.data; expect(ortbRequest.slots[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']); @@ -601,7 +672,7 @@ describe('The Criteo bidding adapter', function () { }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); + expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); expect(request.method).to.equal('POST'); const ortbRequest = request.data; expect(ortbRequest.slots[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']); @@ -637,6 +708,115 @@ describe('The Criteo bidding adapter', function () { expect(request.data.user).to.not.be.null; expect(request.data.user.ceh).to.equal('hashedemail'); }); + + it('should properly build a request without first party data', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123 + } + }, + ]; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + }; + return utils.deepAccess(config, key); + }); + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.publisher.ext).to.equal(undefined); + expect(request.data.user.ext).to.equal(undefined); + expect(request.data.slots[0].ext).to.equal(undefined); + }); + + it('should properly build a request with criteo specific ad unit first party data', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + ext: { + bidfloor: 0.75 + } + } + }, + ]; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + }; + return utils.deepAccess(config, key); + }); + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.slots[0].ext).to.deep.equal({ + bidfloor: 0.75, + }); + }); + + it('should properly build a request with first party data', function () { + const contextData = { + keywords: ['power tools'], + data: { + pageType: 'article' + } + }; + const userData = { + gender: 'M', + data: { + registered: true + } + }; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + ext: { + bidfloor: 0.75 + } + }, + fpd: { + context: { + data: { + someContextAttribute: 'abc' + } + } + } + }, + ]; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + fpd: { + context: contextData, + user: userData + } + }; + return utils.deepAccess(config, key); + }); + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.publisher.ext).to.deep.equal(contextData); + expect(request.data.user.ext).to.deep.equal(userData); + expect(request.data.slots[0].ext).to.deep.equal({ + bidfloor: 0.75, + data: { + someContextAttribute: 'abc' + } + }); + }); }); describe('interpretResponse', function () { @@ -679,7 +859,7 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].dealId).to.equal('myDealCode'); }); - it('should properly parse a bid responsewith with a zoneId', function () { + it('should properly parse a bid response with a zoneId', function () { const response = { body: { slots: [{ @@ -712,7 +892,7 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].height).to.equal(90); }); - it('should properly parse a bid responsewith with a video', function () { + it('should properly parse a bid response with a video', function () { const response = { body: { slots: [{ @@ -745,7 +925,120 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].mediaType).to.equal(VIDEO); }); - it('should properly parse a bid responsewith with a zoneId passed as a string', function () { + it('should properly parse a bid response with native', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + width: 728, + height: 90, + zoneid: 123, + native: { + 'products': [{ + 'title': 'Product title', + 'description': 'Product desc', + 'price': '100', + 'click_url': 'https://product.click', + 'image': { + 'url': 'https://publisherdirect.criteo.com/publishertag/preprodtest/creative.png', + 'height': 300, + 'width': 300 + }, + 'call_to_action': 'Try it now!' + }], + 'advertiser': { + 'description': 'sponsor', + 'domain': 'criteo.com', + 'logo': {'url': 'https://www.criteo.com/images/criteo-logo.svg', 'height': 300, 'width': 300} + }, + 'privacy': { + 'optout_click_url': 'https://info.criteo.com/privacy/informations', + 'optout_image_url': 'https://static.criteo.net/flash/icon/nai_small.png', + }, + 'impression_pixels': [{'url': 'https://my-impression-pixel/test/impression'}, {'url': 'https://cas.com/lg.com'}] + } + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + params: { + zoneId: 123, + }, + native: true, + }] + }; + config.setConfig({'enableSendAllBids': false}); + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(1); + expect(bids[0].requestId).to.equal('test-bidId'); + expect(bids[0].adId).to.equal('abc123'); + expect(bids[0].cpm).to.equal(1.23); + expect(bids[0].mediaType).to.equal(NATIVE); + }); + + it('should not parse bid response with native when enableSendAllBids is true', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + width: 728, + height: 90, + zoneid: 123, + native: {} + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + params: { + zoneId: 123, + }, + native: true, + }] + }; + config.setConfig({'enableSendAllBids': true}); + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('should not parse bid response with native when enableSendAllBids is not set', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + width: 728, + height: 90, + zoneid: 123, + native: {} + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + params: { + zoneId: 123, + }, + native: true, + }] + }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('should properly parse a bid response with a zoneId passed as a string', function () { const response = { body: { slots: [{ @@ -825,6 +1118,7 @@ describe('The Criteo bidding adapter', function () { utilsMock.expects('logInfo').withExactArgs('Using Criteo FastBid').once(); utilsMock.expects('logWarn').withExactArgs('No hash found in FastBid').never(); utilsMock.expects('logWarn').withExactArgs('Invalid Criteo FastBid found').never(); + utilsMock.expects('insertElement').once(); tryGetCriteoFastBid(); diff --git a/test/spec/modules/criteoIdSystem_spec.js b/test/spec/modules/criteoIdSystem_spec.js new file mode 100644 index 00000000000..aa5807da0da --- /dev/null +++ b/test/spec/modules/criteoIdSystem_spec.js @@ -0,0 +1,156 @@ +import { criteoIdSubmodule, storage } from 'modules/criteoIdSystem.js'; +import * as utils from 'src/utils.js'; +import * as ajaxLib from 'src/ajax.js'; + +const pastDateString = new Date(0).toString() + +function mockResponse(responseText, fakeResponse = (url, callback) => callback(responseText)) { + return function() { + return fakeResponse; + } +} + +describe('CriteoId module', function () { + const cookiesMaxAge = 13 * 30 * 24 * 60 * 60 * 1000; + + const nowTimestamp = new Date().getTime(); + + let getCookieStub; + let setCookieStub; + let getLocalStorageStub; + let setLocalStorageStub; + let removeFromLocalStorageStub; + let timeStampStub; + let parseUrlStub; + let ajaxBuilderStub; + let triggerPixelStub; + + beforeEach(function (done) { + getCookieStub = sinon.stub(storage, 'getCookie'); + setCookieStub = sinon.stub(storage, 'setCookie'); + getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + setLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage'); + removeFromLocalStorageStub = sinon.stub(storage, 'removeDataFromLocalStorage'); + timeStampStub = sinon.stub(utils, 'timestamp').returns(nowTimestamp); + ajaxBuilderStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockResponse('{}')); + parseUrlStub = sinon.stub(utils, 'parseUrl').returns({protocol: 'https', hostname: 'testdev.com'}) + triggerPixelStub = sinon.stub(utils, 'triggerPixel'); + done(); + }); + + afterEach(function () { + getCookieStub.restore(); + setCookieStub.restore(); + getLocalStorageStub.restore(); + setLocalStorageStub.restore(); + removeFromLocalStorageStub.restore(); + timeStampStub.restore(); + ajaxBuilderStub.restore(); + triggerPixelStub.restore(); + parseUrlStub.restore(); + }); + + const storageTestCases = [ + { cookie: 'bidId', localStorage: 'bidId2', expected: 'bidId' }, + { cookie: 'bidId', localStorage: undefined, expected: 'bidId' }, + { cookie: undefined, localStorage: 'bidId', expected: 'bidId' }, + { cookie: undefined, localStorage: undefined, expected: undefined }, + ] + + storageTestCases.forEach(testCase => it('getId() should return the bidId when it exists in local storages', function () { + getCookieStub.withArgs('cto_bidid').returns(testCase.cookie); + getLocalStorageStub.withArgs('cto_bidid').returns(testCase.localStorage); + + const id = criteoIdSubmodule.getId(); + expect(id).to.be.deep.equal({id: testCase.expected ? { criteoId: testCase.expected } : undefined}); + })) + + it('decode() should return the bidId when it exists in local storages', function () { + const id = criteoIdSubmodule.decode('testDecode'); + expect(id).to.equal('testDecode') + }); + + it('should call user sync url with the right params', function () { + getCookieStub.withArgs('cto_test_cookie').returns('1'); + getCookieStub.withArgs('cto_bundle').returns('bundle'); + window.criteo_pubtag = {} + + const emptyObj = '{}'; + let ajaxStub = sinon.stub().callsFake((url, callback) => callback(emptyObj)); + ajaxBuilderStub.callsFake(mockResponse(undefined, ajaxStub)) + + criteoIdSubmodule.getId(); + const expectedUrl = `https://gum.criteo.com/sid/json?origin=prebid&topUrl=https%3A%2F%2Ftestdev.com%2F&domain=testdev.com&bundle=bundle&cw=1&pbt=1`; + + expect(ajaxStub.calledWith(expectedUrl)).to.be.true; + + window.criteo_pubtag = undefined; + }); + + const responses = [ + { bundle: 'bundle', bidId: 'bidId', acwsUrl: 'acwsUrl' }, + { bundle: 'bundle', bidId: undefined, acwsUrl: 'acwsUrl' }, + { bundle: 'bundle', bidId: 'bidId', acwsUrl: undefined }, + { bundle: undefined, bidId: 'bidId', acwsUrl: 'acwsUrl' }, + { bundle: 'bundle', bidId: undefined, acwsUrl: undefined }, + { bundle: undefined, bidId: 'bidId', acwsUrl: undefined }, + { bundle: undefined, bidId: undefined, acwsUrl: 'acwsUrl' }, + { bundle: undefined, bidId: undefined, acwsUrl: ['acwsUrl', 'acwsUrl2'] }, + { bundle: undefined, bidId: undefined, acwsUrl: undefined }, + ] + + responses.forEach(response => describe('test user sync response behavior', function () { + const expirationTs = new Date(nowTimestamp + cookiesMaxAge).toString(); + + beforeEach(function (done) { + const fakeResponse = (url, callback) => { + callback(JSON.stringify(response)); + setTimeout(done, 0); + } + ajaxBuilderStub.callsFake(mockResponse(undefined, fakeResponse)); + criteoIdSubmodule.getId(); + }) + + it('should save bidId if it exists', function () { + if (response.acwsUrl) { + expect(triggerPixelStub.called).to.be.true; + expect(setCookieStub.calledWith('cto_bundle')).to.be.false; + expect(setLocalStorageStub.calledWith('cto_bundle')).to.be.false; + } else if (response.bundle) { + expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs)).to.be.true; + expect(setLocalStorageStub.calledWith('cto_bundle', response.bundle)).to.be.true; + expect(triggerPixelStub.called).to.be.false; + } + + if (response.bidId) { + expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs)).to.be.true; + expect(setLocalStorageStub.calledWith('cto_bidid', response.bidId)).to.be.true; + } else { + expect(setCookieStub.calledWith('cto_bidid', '', pastDateString)).to.be.true; + expect(removeFromLocalStorageStub.calledWith('cto_bidid')).to.be.true; + } + }); + })); + + const gdprConsentTestCases = [ + { consentData: { gdprApplies: true, consentString: 'expectedConsentString' }, expected: 'expectedConsentString' }, + { consentData: { gdprApplies: false, consentString: 'expectedConsentString' }, expected: undefined }, + { consentData: { gdprApplies: true, consentString: undefined }, expected: undefined }, + { consentData: { gdprApplies: 'oui', consentString: 'expectedConsentString' }, expected: undefined }, + { consentData: undefined, expected: undefined } + ]; + + gdprConsentTestCases.forEach(testCase => it('should call user sync url with the gdprConsent', function () { + const emptyObj = '{}'; + let ajaxStub = sinon.stub().callsFake((url, callback) => callback(emptyObj)); + ajaxBuilderStub.callsFake(mockResponse(undefined, ajaxStub)) + + criteoIdSubmodule.getId(undefined, testCase.consentData); + + if (testCase.expected) { + expect(ajaxStub.calledWithMatch(`gdprString=${testCase.expected}`)).to.be.true; + } else { + expect(ajaxStub.calledWithMatch('gdprString')).not.to.be.true; + } + })); +}); diff --git a/test/spec/modules/criteortusIdSystem_spec.js b/test/spec/modules/criteortusIdSystem_spec.js deleted file mode 100644 index 578f14d066d..00000000000 --- a/test/spec/modules/criteortusIdSystem_spec.js +++ /dev/null @@ -1,88 +0,0 @@ -import { criteortusIdSubmodule } from 'modules/criteortusIdSystem'; -import * as utils from 'src/utils'; - -describe('Criteo RTUS', function() { - let xhr; - let requests; - let getCookieStub; - let logErrorStub; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - getCookieStub = sinon.stub(utils, 'getCookie'); - logErrorStub = sinon.stub(utils, 'logError'); - }); - - afterEach(function () { - xhr.restore(); - getCookieStub.restore(); - logErrorStub.restore(); - }); - - it('should log error when configParams are not passed', function() { - criteortusIdSubmodule.getId(); - expect(logErrorStub.calledOnce).to.be.true; - }) - - it('should call criteo endpoint to get user id', function() { - getCookieStub.returns(null); - let configParams = { - clientIdentifier: { - 'sampleBidder': 1 - } - } - - let response = { 'status': 'ok', 'userid': 'sample-userid' } - let callBackSpy = sinon.spy(); - let submoduleCallback = criteortusIdSubmodule.getId(configParams); - submoduleCallback(callBackSpy); - requests[0].respond( - 200, - { 'Content-Type': 'text/plain' }, - JSON.stringify(response) - ); - expect(callBackSpy.calledOnce).to.be.true; - expect(callBackSpy.calledWith({'sampleBidder': response})).to.be.true; - }) - - it('should get uid from cookie and not call endpoint', function() { - let response = {'appnexus': {'status': 'ok', 'userid': 'sample-userid'}} - getCookieStub.returns(JSON.stringify(response)); - let configParams = { - clientIdentifier: { - 'sampleBidder': 1 - } - } - let uid = criteortusIdSubmodule.getId(configParams); - expect(requests.length).to.equal(0); - }) - - it('should call criteo endpoint for multiple bidders', function() { - getCookieStub.returns(null); - let configParams = { - clientIdentifier: { - 'sampleBidder': 1, - 'sampleBidder2': 2 - } - } - - let response = { 'status': 'ok', 'userid': 'sample-userid' } - let callBackSpy = sinon.spy(); - let submoduleCallback = criteortusIdSubmodule.getId(configParams); - submoduleCallback(callBackSpy); - requests[0].respond( - 200, - { 'Content-Type': 'text/plain' }, - JSON.stringify(response) - ); - expect(callBackSpy.calledOnce).to.be.false; - requests[1].respond( - 200, - { 'Content-Type': 'text/plain' }, - JSON.stringify(response) - ); - expect(callBackSpy.calledOnce).to.be.true; - }) -}); diff --git a/test/spec/modules/currency_spec.js b/test/spec/modules/currency_spec.js index 98f51b72251..ccd205964a9 100644 --- a/test/spec/modules/currency_spec.js +++ b/test/spec/modules/currency_spec.js @@ -1,14 +1,16 @@ import { getCurrencyRates -} from 'test/fixtures/fixtures'; +} from 'test/fixtures/fixtures.js'; + +import { getGlobal } from 'src/prebidGlobal.js'; import { setConfig, addBidResponseHook, currencySupportEnabled, currencyRates -} from 'modules/currency'; +} from 'modules/currency.js'; var assert = require('chai').assert; var expect = require('chai').expect; @@ -43,8 +45,12 @@ describe('currency', function () { it('results in currencySupportEnabled = false when currency not configured', function () { setConfig({}); expect(currencySupportEnabled).to.equal(false); + expect(getGlobal().convertCurrency).to.be.undefined; + }); + it('adds conversion function onto pbjs global var once initiated', function () { + setConfig({ 'adServerCurrency': 'JPY' }); + expect(getGlobal().convertCurrency).to.be.a('function'); }); - it('results in currencySupportEnabled = true and currencyRates being loaded when configured', function () { fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates())); setConfig({ 'adServerCurrency': 'JPY' }); @@ -124,6 +130,38 @@ describe('currency', function () { }); }); + describe('global currency function', function () { + it('still returns conversion if default rates present with fetch not returned yet', function () { + setConfig({ + 'adServerCurrency': 'USD', + 'defaultRates': { + 'USD': { EUR: 2, JPY: 100 } + } + }); + // first conversion should use default rates + expect(getGlobal().convertCurrency(1.0, 'USD', 'EUR')).to.equal(2); + expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(100); + fakeCurrencyFileServer.respond(); + }); + it('uses fetch rates if returned', function () { + fakeCurrencyFileServer.respondWith(JSON.stringify({ + 'dataAsOf': '2017-04-25', + 'conversions': { + 'USD': { EUR: 4, JPY: 200 } + } + })); + setConfig({ + 'adServerCurrency': 'USD', + 'defaultRates': { + 'USD': { EUR: 2, JPY: 100 } + } + }); + // now respond and should use updates rates + fakeCurrencyFileServer.respond(); + expect(getGlobal().convertCurrency(1.0, 'USD', 'EUR')).to.equal(4); + expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(200); + }); + }); describe('bidder override', function () { it('allows setConfig to set bidder currency', function () { setConfig({}); diff --git a/test/spec/modules/dailyhuntBidAdapter_spec.js b/test/spec/modules/dailyhuntBidAdapter_spec.js new file mode 100644 index 00000000000..de384d0a1f7 --- /dev/null +++ b/test/spec/modules/dailyhuntBidAdapter_spec.js @@ -0,0 +1,289 @@ +import { expect } from 'chai'; +import { spec } from 'modules/dailyhuntBidAdapter.js'; + +const PROD_PREBID_ENDPOINT_URL = 'https://money.dailyhunt.in/openrtb2/auction'; + +const PROD_ENDPOINT_URL = 'https://money.dailyhunt.in/openx/ads/index.php'; + +const _encodeURIComponent = function (a) { + if (!a) { return } + let b = window.encodeURIComponent(a); + b = b.replace(/'/g, '%27'); + return b; +} + +describe('DailyhuntAdapter', function () { + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'dailyhunt', + 'params': { + partnerId: 'pb-partnerId' + } + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let bidRequests = [ + { + 'bidder': 'dailyhunt', + 'params': { + 'placementId': '10433394' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 50]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843' + } + ]; + let bidderRequest = { + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'bidderCode': 'dailyhunt', + 'bids': [ + { + ...bidRequests[0] + } + ], + 'refererInfo': { + 'referer': 'http://m.dailyhunt.in/' + } + }; + + let nativeBidRequests = [ + { + 'bidder': 'dailyhunt', + 'params': { + 'placementId': '10433394' + }, + nativeParams: { + image: { + required: true, + }, + title: { + required: true, + }, + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 50]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843' + } + ]; + let nativeBidderRequest = { + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'bidderCode': 'dailyhunt', + 'bids': [ + { + ...nativeBidRequests[0] + } + ], + 'refererInfo': { + 'referer': 'http://m.dailyhunt.in/' + } + }; + + it('sends display bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.url).to.equal(PROD_PREBID_ENDPOINT_URL); + expect(request.method).to.equal('POST'); + }); + + it('sends native bid request to ENDPOINT via GET', function () { + const request = spec.buildRequests(nativeBidRequests, nativeBidderRequest)[0]; + expect(request.url).to.equal(PROD_ENDPOINT_URL); + expect(request.method).to.equal('GET'); + }); + }) + + describe('interpretResponse', function () { + let nativeResponse = [ + [ + { + 'ad': { + 'requestId': '12345', + 'type': 'native-banner', + 'aduid': 'notId=ad-123679', + 'srcUrlExpiry': '60', + 'position': 'web', + 'width': 300, + 'height': 250, + 'card-position': 6, + 'positionWithTicker': 6, + 'min-ad-distance': 9, + 'banner-fill': 'fill-width', + 'bannerid': '70459', + 'adTemplate': 'H', + 'showOnlyImage': 'false', + 'id': '4210005ddbed0f096078.05613283', + 'span': 60, + 'useInternalBrowser': 'false', + 'useWideViewPort': 'true', + 'adCacheGood': '1', + 'adCacheAverage': '1', + 'adCacheSlow': '1', + 'allowDelayedAdInsert': 'true', + 'adGroupId': '4210005ddbed0f0982f4.86287578', + 'adContext': null, + 'showPlayIcon': 'false', + 'showBorder': 'false', + 'adid': '123679', + 'typeId': '3', + 'subTypeId': '0', + 'orderId': '1', + 'data-subSlot': 'web-3', + 'data-partner': 'DH', + 'data-origin': 'pbs', + 'pbAdU': '0', + 'price': '1.4', + 'beaconUrl': 'beacon-url', + 'landingUrl': null, + 'content': { + 'bg-color': '#ffffff', + 'bg-color-night': '#000000', + 'language': 'en', + 'sourceAlphabet': 'A', + 'iconLink': 'icon-link', + 'itemTag': { + 'color': '#0889ac', + 'color-night': '#a5a5a5', + 'data': 'Promoted' + }, + 'itemTitle': { + 'color': '#000000', + 'color-night': '#ffffff', + 'data': 'PREBID TEST' + }, + 'itemSubtitle1': { + 'color': '#000000', + 'color-night': '#ffffff', + 'data': 'Lorem Ipsum lorem ipsum' + }, + 'itemSubtitle2': { + 'color': '#4caf79', + 'color-night': '#ffffff', + 'data': 'CLICK ME' + } + }, + 'action': 'action-url', + 'shareability': null + } + } + ] + ]; + + let bannerResponse = { + 'id': 'da32def7-6779-403c-ada7-0b201dbc9744', + 'seatbid': [ + { + 'bid': [ + { + 'id': '3db3773286ee59', + 'impid': '1', + 'price': 0.14, + 'adm': "\r\n\r\n\r\n\t\r\n\tWidgets Magazine\r\n\t\r\n\t\r\n\t\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n
\r\n\r\n\r\n", + 'adid': '66658', + 'crid': 'asd5ddbf014cac993.66466212', + 'dealid': 'asd5ddbf014cac993.66466212', + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + } + } + } + ], + 'seat': 'dailyhunt' + } + ], + 'ext': { + 'responsetimemillis': { + 'dailyhunt': 119 + } + } + }; + + it('should get correct native bid response', function () { + let expectedResponse = [ + { + requestId: '12345', + cpm: '10', + creativeId: '70459', + currency: 'USD', + ttl: 360, + netRevenue: true, + mediaType: 'native', + native: { + title: 'PREBID TEST', + body: 'Lorem Ipsum lorem ipsum', + body2: 'Lorem Ipsum lorem ipsum', + cta: 'CLICK ME', + clickUrl: _encodeURIComponent('action-url'), + impressionTrackers: [], + clickTrackers: [], + image: { + url: 'icon-link', + height: 250, + width: 300 + }, + icon: { + url: 'icon-link', + height: 300, + width: 250 + } + } + } + ]; + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code', + 'requestId': '12345' + }] + } + let result = spec.interpretResponse({ body: nativeResponse }, { bidderRequest }); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + + it('should get correct banner bid response', function () { + let expectedResponse = [ + { + requestId: '12345', + cpm: 0.14, + creativeId: 'asd5ddbf014cac993.66466212', + width: 300, + height: 250, + ttl: 360, + netRevenue: true, + currency: 'USD', + ad: "\r\n\r\n\r\n\t\r\n\tWidgets Magazine\r\n\t\r\n\t\r\n\t\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n
\r\n\r\n\r\n", + } + ]; + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code', + 'requestId': '12345' + }] + } + let result = spec.interpretResponse({ body: bannerResponse }, bidderRequest); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + }) +}) diff --git a/test/spec/modules/danmarketBidAdapter_spec.js b/test/spec/modules/danmarketBidAdapter_spec.js deleted file mode 100644 index 973cd2afb1c..00000000000 --- a/test/spec/modules/danmarketBidAdapter_spec.js +++ /dev/null @@ -1,309 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/danmarketBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('DAN_Marketplace Adapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'danmarket', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'danmarket', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5'); - }); - - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - - it('if gdprConsent is present payload must have gdpr params', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}}); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', 1); - }); - - it('if gdprApplies is false gdpr_applies must be 0', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: false}}); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', 0); - }); - - it('if gdprApplies is undefined gdpr_applies must be 1', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA'}}); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', 1); - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 4, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 5, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 6, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 4
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'danmarket', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'danmarket', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 5, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'danmarket', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '7' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '8' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/datablocksBidAdapter_spec.js b/test/spec/modules/datablocksBidAdapter_spec.js index 07989b86535..18b8aac7371 100644 --- a/test/spec/modules/datablocksBidAdapter_spec.js +++ b/test/spec/modules/datablocksBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from '../../../modules/datablocksBidAdapter'; +import { spec } from '../../../modules/datablocksBidAdapter.js'; let bid = { bidId: '2dd581a2b6281d', @@ -84,17 +84,40 @@ let nativeBid = { transactionId: '0a4e9788-4def-4b94-bc25-564d7cac99f6' } +let videoBid = { + adUnitCode: '/19968336/header-bid-tag-0', + auctionId: '160c78a4-f808-410f-b682-d8728f3a79e1', + bidId: '332045ee374b99', + bidder: 'datablocks', + bidderRequestId: '15d9012765e36d', + mediaTypes: { + video: { + context: 'instream', + playerSize: [501, 400], + durationRangeSec: [15, 60] + } + }, + params: { + sourceId: 7560, + host: 'v5demo.datablocks.net', + video: { + minduration: 14 + } + }, + transactionId: '0a4e9788-4def-4b94-bc25-564d7cac99f7' +} + const bidderRequest = { auctionId: '8bfef1be-d3ac-4d18-8859-754c7b4cf017', auctionStart: Date.now(), biddeCode: 'datablocks', bidderRequestId: '10c47a5fc3c41', - bids: [bid, bid2, nativeBid], + bids: [bid, bid2, nativeBid, videoBid], refererInfo: { numIframes: 0, reachedTop: true, - referer: 'http://v5demo.datablocks.net/test', - stack: ['http://v5demo.datablocks.net/test'] + referer: 'https://v5demo.datablocks.net/test', + stack: ['https://v5demo.datablocks.net/test'] }, start: Date.now(), timeout: 10000 @@ -110,7 +133,7 @@ let resObject = { id: '1090738570', impid: '2966b257c81d27', price: 24.000000, - adm: 'RON', + adm: 'RON', cid: '55', adid: '177654', crid: '177656', @@ -122,7 +145,7 @@ let resObject = { id: '1090738571', impid: '2966b257c81d28', price: 24.000000, - adm: 'RON', + adm: 'RON', cid: '55', adid: '177654', crid: '177656', @@ -134,12 +157,24 @@ let resObject = { id: '1090738570', impid: '15d9012765e36c', price: 24.000000, - adm: '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"Example Title"}},{"id":2,"required":1,"data":{"value":"Example Body"}},{"id":3,"required":1,"img":{"url":"http://example.image.com/"}}],"link":{"url":"http://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["http://impression.example.com/i/264597/?fcid=29699699045816"]}}', + adm: '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"Example Title"}},{"id":2,"required":1,"data":{"value":"Example Body"}},{"id":3,"required":1,"img":{"url":"https://example.image.com/"}}],"link":{"url":"https://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["https://impression.example.com/i/264597/?fcid=29699699045816"]}}', cid: '132145', adid: '154321', crid: '177432', cat: [], api: [] + }, { + id: '1090738575', + impid: '15d9012765e36f', + price: 25.000000, + cid: '12345', + adid: '12345', + crid: '123456', + nurl: 'https://click.v5demo.datablocks.net/m//?fcid=435235435432', + cat: [], + api: [], + w: 500, + h: 400 }] }], cur: 'USD', @@ -148,7 +183,7 @@ let resObject = { }; let bidRequest = { method: 'POST', - url: '//v5demo.datablocks.net/search/?sid=7560', + url: 'https://v5demo.datablocks.net/search/?sid=7560', options: { withCredentials: false }, @@ -175,11 +210,16 @@ let bidRequest = { native: {request: '{"native":{"assets":[{"id":"1","required":true,"title":{"len":140}},{"id":"2","required":true,"data":{"type":2}},{"id":"3","img":{"w":728,"h":90,"type":3}}]}}'}, secure: false, tagid: '/19968336/header-bid-tag-0' + }, { + id: '15d9012765e36f', + video: {w: 500, h: 400, minduration: 15, maxduration: 60}, + secure: false, + tagid: '/19968336/header-bid-tag-0' }], site: { domain: '', id: 'blank', - page: 'http://v5demo.datablocks.net/test' + page: 'https://v5demo.datablocks.net/test' } } } @@ -198,7 +238,7 @@ describe('DatablocksAdapter', function() { }); describe('buildRequests', function() { - let requests = spec.buildRequests([bid, bid2, nativeBid], bidderRequest); + let requests = spec.buildRequests([bid, bid2, nativeBid, videoBid], bidderRequest); it('Creates an array of request objects', function() { expect(requests).to.be.an('array').that.is.not.empty; }); @@ -211,7 +251,7 @@ describe('DatablocksAdapter', function() { }); it('Returns valid URL', function() { expect(request.url).to.exist; - expect(request.url).to.equal('//v5demo.datablocks.net/search/?sid=7560'); + expect(request.url).to.equal('https://v5demo.datablocks.net/search/?sid=7560'); }); it('Should be a valid openRTB request', function() { @@ -232,6 +272,9 @@ describe('DatablocksAdapter', function() { expect(imp.native.request).to.be.a('string'); let native = JSON.parse(imp.native.request); expect(native).to.be.a('object'); + } else if (imp.video) { + expect(imp).to.have.all.keys('video', 'id', 'secure', 'tagid'); + expect(imp.video).to.have.all.keys('w', 'h', 'minduration', 'maxduration') } else { expect(true).to.equal(false); } @@ -276,6 +319,10 @@ describe('DatablocksAdapter', function() { expect(dataItem.native.title).to.be.a('string'); expect(dataItem.native.body).to.be.a('string'); expect(dataItem.native.clickUrl).to.be.a('string'); + } else if (dataItem.mediaType == 'video') { + expect(dataItem.vastUrl).to.be.a('string'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); } } it('Returns an empty array if invalid response is passed', function() { diff --git a/test/spec/modules/decenteradsBidAdapter_spec.js b/test/spec/modules/decenteradsBidAdapter_spec.js deleted file mode 100644 index 3c8569b3b61..00000000000 --- a/test/spec/modules/decenteradsBidAdapter_spec.js +++ /dev/null @@ -1,207 +0,0 @@ -import { expect } from 'chai' -import { spec } from '../../../modules/decenteradsBidAdapter' -import { deepStrictEqual, notEqual, ok, strictEqual } from 'assert' - -describe('DecenteradsAdapter', () => { - const bid = { - bidId: '9ec5b177515ee2e5', - bidder: 'decenterads', - params: { - placementId: 0, - traffic: 'banner' - } - } - - describe('isBidRequestValid', () => { - it('Should return true if there are bidId, params and placementId parameters present', () => { - strictEqual(true, spec.isBidRequestValid(bid)) - }) - - it('Should return false if at least one of parameters is not present', () => { - const b = { ...bid } - delete b.params.placementId - strictEqual(false, spec.isBidRequestValid(b)) - }) - }) - - describe('buildRequests', () => { - const serverRequest = spec.buildRequests([bid]) - - it('Creates a ServerRequest object with method, URL and data', () => { - ok(serverRequest) - ok(serverRequest.method) - ok(serverRequest.url) - ok(serverRequest.data) - }) - - it('Returns POST method', () => { - strictEqual('POST', serverRequest.method) - }) - - it('Returns valid URL', () => { - strictEqual('//supply.decenterads.com/?c=o&m=multi', serverRequest.url) - }) - - it('Returns valid data if array of bids is valid', () => { - const { data } = serverRequest - strictEqual('object', typeof data) - deepStrictEqual(['deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'], Object.keys(data)) - strictEqual('number', typeof data.deviceWidth) - strictEqual('number', typeof data.deviceHeight) - strictEqual('string', typeof data.language) - strictEqual('string', typeof data.host) - strictEqual('string', typeof data.page) - notEqual(-1, [0, 1].indexOf(data.secure)) - - const placement = data.placements[0] - deepStrictEqual(['placementId', 'bidId', 'traffic'], Object.keys(placement)) - strictEqual(0, placement.placementId) - strictEqual('9ec5b177515ee2e5', placement.bidId) - strictEqual('banner', placement.traffic) - }) - - it('Returns empty data if no valid requests are passed', () => { - const { placements } = spec.buildRequests([]).data - - expect(spec.buildRequests([]).data.placements).to.be.an('array') - strictEqual(0, placements.length) - }) - }) - - describe('interpretResponse', () => { - const validData = [ - { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '9ec5b177515ee2e5', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }, - { - body: [{ - vastUrl: 'decenterads.com', - mediaType: 'video', - cpm: 0.5, - requestId: '9ec5b177515ee2e5', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }, - { - body: [{ - mediaType: 'native', - clickUrl: 'decenterads.com', - title: 'Test', - image: 'decenterads.com', - creativeId: '2', - impressionTrackers: ['decenterads.com'], - ttl: 120, - cpm: 0.4, - requestId: '9ec5b177515ee2e5', - netRevenue: true, - currency: 'USD', - }] - } - ] - - for (const obj of validData) { - const { mediaType } = obj.body[0] - - it(`Should interpret ${mediaType} response`, () => { - const response = spec.interpretResponse(obj) - - expect(response).to.be.an('array') - strictEqual(1, response.length) - - const copy = { ...obj.body[0] } - delete copy.mediaType - deepStrictEqual(copy, response[0]) - }) - } - - const invalidData = [ - { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '9ec5b177515ee2e5', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }, - { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '9ec5b177515ee2e5', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }, - { - body: [{ - mediaType: 'native', - clickUrl: 'decenterads.com', - title: 'Test', - impressionTrackers: ['decenterads.com'], - ttl: 120, - requestId: '9ec5b177515ee2e5', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - } - ] - - for (const obj of invalidData) { - const { mediaType } = obj.body[0] - - it(`Should return an empty array if invalid ${mediaType} response is passed `, () => { - const response = spec.interpretResponse(obj) - - expect(response).to.be.an('array') - strictEqual(0, response.length) - }) - } - - it('Should return an empty array if invalid response is passed', () => { - const response = spec.interpretResponse({ - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }) - - expect(response).to.be.an('array') - strictEqual(0, response.length) - }) - }) - - describe('getUserSyncs', () => { - it('Returns valid URL and type', () => { - const expectedResult = [{ type: 'image', url: '//supply.decenterads.com/?c=o&m=cookie' }] - deepStrictEqual(expectedResult, spec.getUserSyncs()) - }) - }) -}) diff --git a/test/spec/modules/deepintentBidAdapter_spec.js b/test/spec/modules/deepintentBidAdapter_spec.js new file mode 100644 index 00000000000..8b462b3217d --- /dev/null +++ b/test/spec/modules/deepintentBidAdapter_spec.js @@ -0,0 +1,193 @@ +import {expect} from 'chai'; +import {spec} from 'modules/deepintentBidAdapter.js'; +import * as utils from '../../../src/utils.js'; + +describe('Deepintent adapter', function () { + let request; + let bannerResponse; + + beforeEach(function () { + request = [ + { + bidder: 'deepintent', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + params: { + tagId: '100013', + w: 728, + h: 90, + pos: 1, + user: { + id: 'di_testuid', + buyeruid: 'di_testbuyeruid', + yob: 2002, + gender: 'F' + }, + custom: { + 'position': 'right-box' + } + } + } + ]; + bannerResponse = { + 'body': { + 'id': '303e1fae-9677-41e2-9a92-15a23445363f', + 'seatbid': [{ + 'bid': [{ + 'id': '11447bb1-a266-470d-b0d7-8810f5b1b75f', + 'impid': 'a7e92b9b-d9db-4de8-9c3f-f90737335445', + 'price': 0.6, + 'adid': '10001', + 'adm': "\r\n", + 'adomain': ['deepintent.com'], + 'cid': '103389', + 'crid': '13665', + 'w': 300, + 'h': 250, + 'dealId': 'dee_12312stdszzsx' + }], + 'seat': '10000' + }], + 'bidid': '0b08b09f-aaa1-4c14-b1c8-7debb1a7c1cd' + } + } + }); + + describe('validations', function () { + it('validBid : tagId is passed', function () { + let bid = { + bidder: 'deepintent', + params: { + tagId: '1232' + } + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equals(true); + }); + it('invalidBid : tagId is not passed', function () { + let bid = { + bidder: 'deepintent', + params: { + h: 200, + w: 300 + } + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equals(false); + }); + it('invalidBid : tagId is not a string', function () { + let bid = { + bidder: 'deepintent', + params: { + tagId: 12345 + } + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equals(false); + }); + }); + describe('request check', function () { + it('unmutaable bid request check', function () { + let oRequest = utils.deepClone(request), + bidRequest = spec.buildRequests(request); + expect(request).to.deep.equal(oRequest); + }); + it('bidder connection check', function () { + let bRequest = spec.buildRequests(request); + expect(bRequest.url).to.equal('https://prebid.deepintent.com/prebid'); + expect(bRequest.method).to.equal('POST'); + expect(bRequest.options.contentType).to.equal('application/json'); + }); + it('bid request check : Device', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.device.ua).to.be.a('string'); + expect(data.device.js).to.equal(1); + expect(data.device.dnt).to.be.a('number'); + expect(data.device.h).to.be.a('number'); + expect(data.device.w).to.be.a('number'); + }); + it('bid request check : Impression', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.at).to.equal(1); // auction type + expect(data.imp[0].id).to.equal(request[0].bidId); + expect(data.imp[0].tagid).to.equal('100013'); + }); + it('bid request check : ad size', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.imp[0].banner).to.be.a('object'); + expect(data.imp[0].banner.w).to.equal(300); + expect(data.imp[0].banner.h).to.equal(250); + }); + it('bid request check : custom params', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.imp[0].ext).to.be.a('object'); + expect(data.imp[0].ext.deepintent.position).to.equal('right-box'); + }); + it('bid request check: position check', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.imp[0].banner.pos).to.equal(1); + }); + it('bid request check: displaymanager check', function() { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.imp[0].displaymanager).to.equal('di_prebid'); + expect(data.imp[0].displaymanagerver).to.equal('1.0.0'); + }); + it('bid request check: user object check', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.user).to.be.a('object'); + expect(data.user.id).to.equal('di_testuid'); + expect(data.user.buyeruid).to.equal('di_testbuyeruid'); + expect(data.user.yob).to.equal(2002); + expect(data.user.gender).to.equal('F'); + }); + it('bid request check: CCPA Check', function () { + let bidRequest = { + uspConsent: '1NYN' + }; + let bRequest = spec.buildRequests(request, bidRequest); + let data = JSON.parse(bRequest.data); + expect(data.regs.ext.us_privacy).to.equal('1NYN'); + let bidRequest2 = {}; + let bRequest2 = spec.buildRequests(request, bidRequest2); + let data2 = JSON.parse(bRequest2.data); + expect(data2.regs).to.equal(undefined); + }); + }); + describe('user sync check', function () { + it('user sync url check', function () { + let syncOptions = { + iframeEnabled: true + }; + let userSync = spec.getUserSyncs(syncOptions); + expect(userSync).to.be.an('array').with.length.above(0); + expect(userSync[0].type).to.equal('iframe'); + expect(userSync[0].url).to.equal('https://cdn.deepintent.com/syncpixel.html'); + }); + }); + describe('response check', function () { + it('bid response check: valid bid response', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + let bResponse = spec.interpretResponse(bannerResponse, request); + expect(bResponse).to.be.an('array').with.length.above(0); + expect(bResponse[0].requestId).to.equal(bannerResponse.body.seatbid[0].bid[0].impid); + expect(bResponse[0].width).to.equal(bannerResponse.body.seatbid[0].bid[0].w); + expect(bResponse[0].height).to.equal(bannerResponse.body.seatbid[0].bid[0].h); + expect(bResponse[0].currency).to.equal('USD'); + expect(bResponse[0].netRevenue).to.equal(false); + expect(bResponse[0].ttl).to.equal(300); + expect(bResponse[0].creativeId).to.equal(bannerResponse.body.seatbid[0].bid[0].crid); + expect(bResponse[0].dealId).to.equal(bannerResponse.body.seatbid[0].bid[0].dealId); + }); + }) +}); diff --git a/test/spec/modules/dfpAdServerVideo_spec.js b/test/spec/modules/dfpAdServerVideo_spec.js index bd417189aef..895416bae2b 100644 --- a/test/spec/modules/dfpAdServerVideo_spec.js +++ b/test/spec/modules/dfpAdServerVideo_spec.js @@ -1,14 +1,14 @@ import { expect } from 'chai'; import parse from 'url-parse'; -import { buildDfpVideoUrl, buildAdpodVideoUrl } from 'modules/dfpAdServerVideo'; -import { parseQS } from 'src/url'; -import adUnit from 'test/fixtures/video/adUnit'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import { targeting } from 'src/targeting'; -import { auctionManager } from 'src/auctionManager'; -import * as adpod from 'modules/adpod'; +import { buildDfpVideoUrl, buildAdpodVideoUrl } from 'modules/dfpAdServerVideo.js'; +import adUnit from 'test/fixtures/video/adUnit.json'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import { targeting } from 'src/targeting.js'; +import { auctionManager } from 'src/auctionManager.js'; +import * as adpod from 'modules/adpod.js'; +import { server } from 'test/mocks/xhr.js'; const bid = { videoCacheKey: 'abc', @@ -30,9 +30,9 @@ describe('The DFP video support module', function () { })); expect(url.protocol).to.equal('https:'); - expect(url.host).to.equal('pubads.g.doubleclick.net'); + expect(url.host).to.equal('securepubads.g.doubleclick.net'); - const queryParams = parseQS(url.query); + const queryParams = utils.parseQS(url.query); expect(queryParams).to.have.property('correlator'); expect(queryParams).to.have.property('description_url', 'someUrl.com'); expect(queryParams).to.have.property('env', 'vp'); @@ -56,7 +56,7 @@ describe('The DFP video support module', function () { expect(url.host).to.equal('video.adserver.example'); - const queryObject = parseQS(url.query); + const queryObject = utils.parseQS(url.query); expect(queryObject.description_url).to.equal('vastUrl.example'); }); @@ -77,7 +77,7 @@ describe('The DFP video support module', function () { params: { iu: 'my/adUnit' } })); - const queryObject = parseQS(url.query); + const queryObject = utils.parseQS(url.query); expect(queryObject.iu).to.equal('my/adUnit'); }); @@ -91,7 +91,7 @@ describe('The DFP video support module', function () { } })); - expect(parseQS(url.query)).to.have.property('output', 'vast'); + expect(utils.parseQS(url.query)).to.have.property('output', 'vast'); }); it('should include the cache key and adserver targeting in cust_params', function () { @@ -107,8 +107,8 @@ describe('The DFP video support module', function () { 'iu': 'my/adUnit' } })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_adid', 'ad_id'); expect(customParams).to.have.property('hb_uuid', bid.videoCacheKey); @@ -177,8 +177,8 @@ describe('The DFP video support module', function () { 'iu': 'my/adUnit' } })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_adid', 'ad_id'); expect(customParams).to.have.property('hb_uuid', bid.videoCacheKey); @@ -204,8 +204,8 @@ describe('The DFP video support module', function () { }, }, })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_adid', 'ad_id'); expect(customParams).to.have.property('my_targeting', 'foo'); @@ -223,8 +223,8 @@ describe('The DFP video support module', function () { url: 'https://video.adserver.example/ads?sz=640x480&iu=/123/aduniturl&impl=s&cust_params=section%3dblog%26mykey%3dmyvalue' })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_adid', 'ad_id'); expect(customParams).to.have.property('section', 'blog'); @@ -246,7 +246,7 @@ describe('The DFP video support module', function () { } })); - const queryObject = parseQS(url.query); + const queryObject = utils.parseQS(url.query); expect(queryObject.description_url).to.equal('descriptionurl.example'); }); @@ -271,8 +271,8 @@ describe('The DFP video support module', function () { 'iu': 'my/adUnit' } })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_uuid', bid.videoCacheKey); expect(customParams).to.have.property('hb_cache_id', bid.videoCacheKey); @@ -292,8 +292,8 @@ describe('The DFP video support module', function () { 'iu': 'my/adUnit' } })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_uuid', 'def'); expect(customParams).to.have.property('hb_cache_id', 'def'); @@ -302,8 +302,6 @@ describe('The DFP video support module', function () { describe('adpod unit tests', function () { let amStub; let amGetAdUnitsStub; - let xhr; - let requests; before(function () { let adUnits = [{ @@ -333,10 +331,6 @@ describe('The DFP video support module', function () { }); beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - config.setConfig({ adpod: { brandCategoryExclusion: true, @@ -347,7 +341,6 @@ describe('The DFP video support module', function () { afterEach(function() { config.resetConfig(); - xhr.restore(); }); after(function () { @@ -374,9 +367,9 @@ describe('The DFP video support module', function () { url = parse(masterTag); expect(url.protocol).to.equal('https:'); - expect(url.host).to.equal('pubads.g.doubleclick.net'); + expect(url.host).to.equal('securepubads.g.doubleclick.net'); - const queryParams = parseQS(url.query); + const queryParams = utils.parseQS(url.query); expect(queryParams).to.have.property('correlator'); expect(queryParams).to.have.property('description_url', 'someUrl.com'); expect(queryParams).to.have.property('env', 'vp'); @@ -388,7 +381,7 @@ describe('The DFP video support module', function () { expect(queryParams).to.have.property('url'); expect(queryParams).to.have.property('cust_params'); - const custParams = parseQS(decodeURIComponent(queryParams.cust_params)); + const custParams = utils.parseQS(decodeURIComponent(queryParams.cust_params)); expect(custParams).to.have.property('hb_cache_id', '123'); expect(custParams).to.have.property('hb_pb_cat_dur', '15.00_395_15s,15.00_406_30s,10.00_395_15s'); } @@ -428,9 +421,9 @@ describe('The DFP video support module', function () { } url = parse(masterTag); expect(url.protocol).to.equal('https:'); - expect(url.host).to.equal('pubads.g.doubleclick.net'); + expect(url.host).to.equal('securepubads.g.doubleclick.net'); - const queryParams = parseQS(url.query); + const queryParams = utils.parseQS(url.query); expect(queryParams).to.have.property('correlator'); expect(queryParams).to.have.property('description_url', 'someUrl.com'); expect(queryParams).to.have.property('env', 'vp'); @@ -442,7 +435,7 @@ describe('The DFP video support module', function () { expect(queryParams).to.have.property('url'); expect(queryParams).to.have.property('cust_params'); - const custParams = parseQS(decodeURIComponent(queryParams.cust_params)); + const custParams = utils.parseQS(decodeURIComponent(queryParams.cust_params)); expect(custParams).to.have.property('hb_cache_id', '123'); expect(custParams).to.have.property('hb_pb_cat_dur', '10.00_15s,15.00_15s,15.00_30s'); } @@ -466,7 +459,7 @@ describe('The DFP video support module', function () { } })); - requests[0].respond(503, { + server.requests[0].respond(503, { 'Content-Type': 'plain/text', }, 'The server could not save anything at the moment.'); diff --git a/test/spec/modules/dgadsBidAdapter_spec.js b/test/spec/modules/dgadsBidAdapter_spec.js deleted file mode 100644 index 2454885217d..00000000000 --- a/test/spec/modules/dgadsBidAdapter_spec.js +++ /dev/null @@ -1,299 +0,0 @@ -import {expect} from 'chai'; -import * as utils from 'src/utils'; -import {spec, getCookieUid} from 'modules/dgadsBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import { BANNER, NATIVE } from 'src/mediaTypes'; - -describe('dgadsBidAdapter', function () { - const adapter = newBidder(spec); - const UID_NAME = 'dgads_uid'; - const VALID_ENDPOINT = 'https://ads-tr.bigmining.com/ad/p/bid'; - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'dgads', - params: { - site_id: '1', - location_id: '1' - } - }; - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params(location_id) are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - site_id: '1' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when required params(site_id) are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - location_id: '1' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { // banner - bidder: 'dgads', - mediaType: 'banner', - params: { - site_id: '1', - location_id: '1' - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250]], - bidId: '2db3101abaec66', - bidderRequestId: '14a9f773e30243', - auctionId: 'c0cd37c5-af11-464d-b83e-35863e533b1f', - transactionId: 'c1f1eff6-23c6-4844-a321-575212939e37' - }, - { // native - bidder: 'dgads', - sizes: [[300, 250]], - params: { - site_id: '1', - location_id: '10' - }, - mediaTypes: { - native: { - image: { - required: true - }, - title: { - required: true, - len: 25 - }, - clickUrl: { - required: true - }, - body: { - required: true, - len: 140 - }, - sponsoredBy: { - required: true, - len: 40 - } - }, - }, - adUnitCode: 'adunit-code', - bidId: '2db3101abaec66', - bidderRequestId: '14a9f773e30243', - auctionId: 'c0cd37c5-af11-464d-b83e-35863e533b1f', - transactionId: 'c1f1eff6-23c6-4844-a321-575212939e37' - } - ]; - it('no bidRequests', function () { - const noBidRequests = []; - expect(Object.keys(spec.buildRequests(noBidRequests)).length).to.equal(0); - }); - it('getCookieUid return empty if cookie not found', function () { - expect(getCookieUid(UID_NAME)).to.equal(''); - }); - const data = { - location_id: '1', - site_id: '1', - transaction_id: 'c1f1eff6-23c6-4844-a321-575212939e37', - bid_id: '2db3101abaec66', - referer: utils.getTopWindowUrl(), - _uid: '' - }; - it('sends bid request to VALID_ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(VALID_ENDPOINT); - expect(request.method).to.equal('GET'); - }); - it('should attache params to the request', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.data['_loc']).to.equal(data['location_id']); - expect(request.data['_medium']).to.equal(data['site_id']); - expect(request.data['transaction_id']).to.equal(data['transaction_id']); - expect(request.data['bid_id']).to.equal(data['bid_id']); - expect(request.data['referer']).to.equal(data['referer']); - expect(request.data['_uid']).to.equal(data['_uid']); - }); - }); - - describe('interpretResponse', function () { - const bidRequests = { - banner: { - bidRequest: { - bidder: 'dgads', - params: { - location_id: '1', - site_id: '1' - }, - transactionId: 'c1f1eff6-23c6-4844-a321-575212939e37', - bidId: '2db3101abaec66', - adUnitCode: 'adunit-code', - sizes: [[300, 250]], - bidderRequestId: '14a9f773e30243', - auctionId: 'c0cd37c5-af11-464d-b83e-35863e533b1f' - }, - }, - native: { - bidRequest: { - bidder: 'adg', - params: { - site_id: '1', - location_id: '10' - }, - mediaTypes: { - native: { - image: { - required: true - }, - title: { - required: true, - len: 25 - }, - body: { - required: true, - len: 140 - }, - sponsoredBy: { - required: true, - len: 40 - } - } - }, - transactionId: 'f76f6dfd-d64f-4645-a29f-682bac7f431a', - bidId: '2f6ac468a9c15e', - adUnitCode: 'adunit-code', - sizes: [[1, 1]], - bidderRequestId: '14a9f773e30243', - auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', - }, - }, - }; - - const serverResponse = { - noAd: { - results: [], - }, - banner: { - bids: { - ads: { - ad: '', - cpm: 1.22, - w: 300, - h: 250, - creativeId: 'xuidx62944aab4fx37f', - ttl: 60, - bidId: '2f6ac468a9c15e' - } - } - }, - native: { - bids: { - ads: { - cpm: 1.22, - title: 'title', - desc: 'description', - sponsoredBy: 'sponsoredBy', - image: 'https://ads-tr.bigmining.com/img/300_250_1.jpg', - w: 300, - h: 250, - ttl: 60, - bidId: '2f6ac468a9c15e', - creativeId: 'xuidx62944aab4fx37f', - isNative: 1, - impressionTrackers: ['https://ads-tr.bigmining.com/ad/view/beacon.gif'], - clickTrackers: ['https://ads-tr.bigmining.com/ad/view/beacon.png'], - clickUrl: 'http://www.garage.co.jp/ja/' - }, - } - } - }; - - const bidResponses = { - banner: { - requestId: '2f6ac468a9c15e', - cpm: 1.22, - width: 300, - height: 250, - creativeId: 'xuidx62944aab4fx37f', - currency: 'JPY', - netRevenue: true, - ttl: 60, - referrer: utils.getTopWindowUrl(), - ad: '', - }, - native: { - requestId: '2f6ac468a9c15e', - cpm: 1.22, - creativeId: 'xuidx62944aab4fx37f', - currency: 'JPY', - netRevenue: true, - ttl: 60, - native: { - image: { - url: 'https://ads-tr.bigmining.com/img/300_250_1.jpg', - width: 300, - height: 250 - }, - title: 'title', - body: 'description', - sponsoredBy: 'sponsoredBy', - clickUrl: 'http://www.garage.co.jp/ja/', - impressionTrackers: ['https://ads-tr.bigmining.com/ad/view/beacon.gif'], - clickTrackers: ['https://ads-tr.bigmining.com/ad/view/beacon.png'] - }, - referrer: utils.getTopWindowUrl(), - creativeid: 'xuidx62944aab4fx37f', - mediaType: NATIVE - } - }; - - it('no bid responses', function () { - const result = spec.interpretResponse({body: serverResponse.noAd}, bidRequests.banner); - expect(result.length).to.equal(0); - }); - it('handles banner responses', function () { - const result = spec.interpretResponse({body: serverResponse.banner}, bidRequests.banner)[0]; - expect(result.requestId).to.equal(bidResponses.banner.requestId); - expect(result.width).to.equal(bidResponses.banner.width); - expect(result.height).to.equal(bidResponses.banner.height); - expect(result.creativeId).to.equal(bidResponses.banner.creativeId); - expect(result.currency).to.equal(bidResponses.banner.currency); - expect(result.netRevenue).to.equal(bidResponses.banner.netRevenue); - expect(result.ttl).to.equal(bidResponses.banner.ttl); - expect(result.referrer).to.equal(bidResponses.banner.referrer); - expect(result.ad).to.equal(bidResponses.banner.ad); - }); - - it('handles native responses', function () { - const result = spec.interpretResponse({body: serverResponse.native}, bidRequests.native)[0]; - expect(result.requestId).to.equal(bidResponses.native.requestId); - expect(result.creativeId).to.equal(bidResponses.native.creativeId); - expect(result.currency).to.equal(bidResponses.native.currency); - expect(result.netRevenue).to.equal(bidResponses.native.netRevenue); - expect(result.ttl).to.equal(bidResponses.native.ttl); - expect(result.referrer).to.equal(bidResponses.native.referrer); - expect(result.native.title).to.equal(bidResponses.native.native.title); - expect(result.native.body).to.equal(bidResponses.native.native.body); - expect(result.native.sponsoredBy).to.equal(bidResponses.native.native.sponsoredBy); - expect(result.native.image.url).to.equal(bidResponses.native.native.image.url); - expect(result.native.image.width).to.equal(bidResponses.native.native.image.width); - expect(result.native.image.height).to.equal(bidResponses.native.native.image.height); - expect(result.native.clickUrl).to.equal(bidResponses.native.native.clickUrl); - expect(result.native.impressionTrackers[0]).to.equal(bidResponses.native.native.impressionTrackers[0]); - expect(result.native.clickTrackers[0]).to.equal(bidResponses.native.native.clickTrackers[0]); - }); - }); -}); diff --git a/test/spec/modules/digitrustIdSystem_spec.js b/test/spec/modules/digitrustIdSystem_spec.js index 55035bc4b4e..befd6eb75b6 100644 --- a/test/spec/modules/digitrustIdSystem_spec.js +++ b/test/spec/modules/digitrustIdSystem_spec.js @@ -1,13 +1,42 @@ import { digiTrustIdSubmodule, surfaceTestHook -} from 'modules/digiTrustIdSystem'; +} from 'modules/digiTrustIdSystem.js'; let assert = require('chai').assert; let expect = require('chai').expect; - var testHook = null; +/** +* A mock implementation of IAB Consent Provider +*/ +function mockCmp(command, version, callback, parameter) { + var resultVal; + if (command == 'ping') { + resultVal = { + gdprAppliesGlobally: mockCmp.stubSettings.isGlobal + }; + callback(resultVal); + } else if (command == 'getVendorConsents') { + let cbResult = { + vendorConsents: [] + } + cbResult.vendorConsents[version] = mockCmp.stubSettings.consents; + callback(cbResult); + } +} + +mockCmp.stubSettings = { + isGlobal: false, + consents: true +}; + +function setupCmpMock(isGlobal, consents) { + window.__cmp = mockCmp; + mockCmp.stubSettings.isGlobal = isGlobal; + mockCmp.stubSettings.consents = consents; +} + describe('DigiTrust Id System', function () { it('Should create the test hook', function (done) { testHook = surfaceTestHook(); @@ -47,4 +76,56 @@ describe('DigiTrust Id System', function () { expect(window.DigiTrust.isClient).to.be.true; done(); }); + + it('Should allow consent when given', function (done) { + testHook = surfaceTestHook(); + setupCmpMock(true, true); + var handler = function(result) { + expect(result).to.be.true; + done(); + } + + testHook.gdpr.hasConsent(null, handler); + }); + + it('Should consent if does not apply', function (done) { + testHook = surfaceTestHook(); + setupCmpMock(false, true); + var handler = function (result) { + expect(result).to.be.true; + done(); + } + + testHook.gdpr.hasConsent(null, handler); + }); + + it('Should not allow consent when not given', function (done) { + testHook = surfaceTestHook(); + setupCmpMock(true, false); + var handler = function (result) { + expect(result).to.be.false; + done(); + } + + testHook.gdpr.hasConsent(null, handler); + }); + it('Should deny consent if timeout', function (done) { + window.__cmp = function () { }; + var handler = function (result) { + expect(result).to.be.false; + done(); + } + + testHook.gdpr.hasConsent({ consentTimeout: 1 }, handler); + }); + it('Should pass consent test if cmp not present', function (done) { + delete window.__cmp + testHook = surfaceTestHook(); + var handler = function (result) { + expect(result).to.be.true; + done(); + } + + testHook.gdpr.hasConsent(null, handler); + }); }); diff --git a/test/spec/modules/districtmDmxBidAdapter_spec.js b/test/spec/modules/districtmDmxBidAdapter_spec.js index 64f76eb026d..d8f0beb9a36 100644 --- a/test/spec/modules/districtmDmxBidAdapter_spec.js +++ b/test/spec/modules/districtmDmxBidAdapter_spec.js @@ -1,12 +1,46 @@ import {expect} from 'chai'; import * as _ from 'lodash'; -import {spec, matchRequest, checkDeepArray, defaultSize} from '../../../modules/districtmDMXBidAdapter'; +import {spec, matchRequest, checkDeepArray, defaultSize, upto5, cleanSizes, shuffle} from '../../../modules/districtmDMXBidAdapter.js'; +const supportedSize = [ + { + size: [300, 250], + s: 100 + }, + { + size: [728, 90], + s: 95 + }, + { + size: [300, 600], + s: 90 + }, + { + size: [160, 600], + s: 88 + }, + { + size: [320, 50], + s: 85 + }, + { + size: [300, 50], + s: 80 + }, + { + size: [970, 250], + s: 75 + }, + { + size: [970, 90], + s: 60 + }, +]; const bidRequest = [{ 'bidder': 'districtmDMX', 'params': { 'dmxid': 100001, - 'memberid': 100003 + 'memberid': 100003, }, 'adUnitCode': 'div-gpt-ad-12345678-1', 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', @@ -19,6 +53,22 @@ const bidRequest = [{ 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' }]; +const bidRequestNoCoppa = [{ + 'bidder': 'districtmDMX', + 'params': { + 'dmxid': 100001, + 'memberid': 100003 + }, + 'adUnitCode': 'div-gpt-ad-12345678-1', + 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '29a28a1bbc8a8d', + 'bidderRequestId': '124b579a136515', + 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' +}]; const bidderRequest = { 'bidderCode': 'districtmDMX', 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf', @@ -27,7 +77,7 @@ const bidderRequest = { 'bidder': 'districtmDMX', 'params': { 'dmxid': 100001, - 'memberid': 100003 + 'memberid': 100003, }, 'adUnitCode': 'div-gpt-ad-12345678-1', 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', @@ -41,6 +91,7 @@ const bidderRequest = { }], 'auctionStart': 1529511035677, 'timeout': 700, + 'uspConsent': '1NY', 'gdprConsent': { 'consentString': 'BOPqNzUOPqNzUAHABBAAA5AAAAAAAA', 'vendorData': { @@ -385,6 +436,32 @@ const bidderRequest = { 'doneCbCallCount': 0 }; +const bidderRequestNoCoppa = { + 'bidderCode': 'districtmDMX', + 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf', + 'bidderRequestId': '124b579a136515', + 'bids': [{ + 'bidder': 'districtmDMX', + 'params': { + 'dmxid': 100001, + 'memberid': 100003, + }, + 'adUnitCode': 'div-gpt-ad-12345678-1', + 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '29a28a1bbc8a8d', + 'bidderRequestId': '124b579a136515', + 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' + }], + 'auctionStart': 1529511035677, + 'timeout': 700, + 'start': 1529511035686, + 'doneCbCallCount': 0 +}; + const responses = { 'body': { 'id': '1f45b37c-5298-4934-b517-4d911aadabfd', @@ -422,6 +499,12 @@ const emptyResponseSeatBid = { body: { seatbid: [] } }; describe('DistrictM Adaptor', function () { const districtm = spec; + describe('verification of upto5', function() { + it('upto5 function should always break 12 imps into 3 request same for 15', function() { + expect(upto5([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], bidRequest, bidderRequest, 'https://google').length).to.be.equal(3) + expect(upto5([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], bidRequest, bidderRequest, 'https://google').length).to.be.equal(3) + }) + }) describe('All needed functions are available', function () { it(`isBidRequestValid is present and type function`, function () { expect(districtm.isBidRequestValid).to.exist.and.to.be.a('function') @@ -481,9 +564,26 @@ describe('DistrictM Adaptor', function () { describe(`buildRequests test usage`, function () { const buildRequestResults = districtm.buildRequests(bidRequest, bidderRequest); + const buildRequestResultsNoCoppa = districtm.buildRequests(bidRequestNoCoppa, bidderRequestNoCoppa); it(`the function should return an array`, function () { expect(buildRequestResults).to.be.an('object'); }); + it(`contain gdpr consent & ccpa`, function() { + const bidr = JSON.parse(buildRequestResults.data) + expect(bidr.regs.ext.gdpr).to.be.equal(1); + expect(bidr.regs.ext.us_privacy).to.be.equal('1NY'); + expect(bidr.user.ext.consent).to.be.an('string'); + }); + it(`test contain COPPA`, function() { + const bidr = JSON.parse(buildRequestResults.data) + bidr.regs = bidr.regs || {}; + bidr.regs.coppa = 1; + expect(bidr.regs.coppa).to.be.equal(1) + }) + it(`test should not contain COPPA`, function() { + const bidr = JSON.parse(buildRequestResultsNoCoppa.data) + expect(bidr.regs.coppa).to.be.equal(0) + }) it(`the function should return array length of 1`, function () { expect(buildRequestResults.data).to.be.a('string'); }); @@ -512,6 +612,32 @@ describe('DistrictM Adaptor', function () { }); }); + describe(`check validation for id sync gdpr ccpa`, () => { + let allin = spec.getUserSyncs({iframeEnabled: true}, {}, bidderRequest.gdprConsent, bidderRequest.uspConsent)[0] + let noCCPA = spec.getUserSyncs({iframeEnabled: true}, {}, bidderRequest.gdprConsent, null)[0] + let noGDPR = spec.getUserSyncs({iframeEnabled: true}, {}, null, bidderRequest.uspConsent)[0] + let nothing = spec.getUserSyncs({iframeEnabled: true}, {}, null, null)[0] + + /* + + 'uspConsent': '1NY', + 'gdprConsent': { + 'consentString': 'BOPqNzUOPqNzUAHABBAAA5AAAAAAAA', + */ + it(`gdpr & ccpa should be present`, () => { + expect(allin.url).to.be.equal('https://cdn.districtm.io/ids/index.html?gdpr=BOPqNzUOPqNzUAHABBAAA5AAAAAAAA&ccpa=1NY') + }) + it(`ccpa should be present`, () => { + expect(noGDPR.url).to.be.equal('https://cdn.districtm.io/ids/index.html?ccpa=1NY') + }) + it(`gdpr should be present`, () => { + expect(noCCPA.url).to.be.equal('https://cdn.districtm.io/ids/index.html?gdpr=BOPqNzUOPqNzUAHABBAAA5AAAAAAAA') + }) + it(`gdpr & ccpa shouldn't be present`, () => { + expect(nothing.url).to.be.equal('https://cdn.districtm.io/ids/index.html') + }) + }) + describe(`Helper function testing`, function () { const bid = matchRequest('29a28a1bbc8a8d', {bidderRequest}); const {width, height} = defaultSize(bid); diff --git a/test/spec/modules/djaxBidAdapter_spec.js b/test/spec/modules/djaxBidAdapter_spec.js new file mode 100644 index 00000000000..bef2b1fddc5 --- /dev/null +++ b/test/spec/modules/djaxBidAdapter_spec.js @@ -0,0 +1,159 @@ +import { expect } from 'chai'; +import { spec } from 'modules/djaxBidAdapter.js'; + +const ENDPOINT = 'https://demo.reviveadservermod.com/headerbidding_adminshare/www/admin/plugins/Prebid/getAd.php'; + +describe('The Djax bidding adapter', function () { + describe('isBidRequestValid', function () { + it('should return false when given an invalid bid', function () { + const bid = { + bidder: 'djax', + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(false); + }); + + it('should return true when given a publisherId in bid', function () { + const bid = { + bidder: 'djax', + params: { + publisherId: 2 + }, + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(true); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + 'bidder': 'djax', + 'params': { + 'publisherId': 2 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ] + }]; + + const request = spec.buildRequests(bidRequests); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('check endpoint url', function () { + expect(request.url).to.equal(ENDPOINT) + }); + + it('sets the proper banner object', function () { + expect(bidRequests[0].params.publisherId).to.equal(2); + }) + }); + const response = { + body: [ + { + 'requestId': '2ee937f15015c6', + 'cpm': '0.2000', + 'width': 300, + 'height': 600, + 'creativeId': '4', + 'currency': 'USD', + 'netRevenue': true, + 'ad': 'ads.html', + 'mediaType': 'banner' + }, + { + 'requestId': '3e1af92622bdc', + 'cpm': '0.2000', + 'creativeId': '4', + 'context': 'outstream', + 'currency': 'USD', + 'netRevenue': true, + 'vastUrl': 'tezt.xml', + 'width': 640, + 'height': 480, + 'mediaType': 'video' + }] + }; + + const request = [ + { + 'bidder': 'djax', + 'params': { + 'publisherId': 2 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 600] + ] + } + }, + 'bidId': '2ee937f15015c6', + 'src': 'client', + }, + { + 'bidder': 'djax', + 'params': { + 'publisherId': 2 + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [ + [640, 480] + ] + } + }, + 'bidId': '3e1af92622bdc', + 'src': 'client', + } + ]; + + describe('interpretResponse', function () { + it('return empty array when no ad found', function () { + const response = {}; + const request = { bidRequests: [] }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('check response for banner and video', function () { + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(2); + expect(bids[0].requestId).to.equal('2ee937f15015c6'); + expect(bids[0].cpm).to.equal('0.2000'); + expect(bids[1].cpm).to.equal('0.2000'); + expect(bids[0].width).to.equal(300); + expect(bids[0].height).to.equal(600); + expect(bids[1].vastUrl).to.not.equal(''); + expect(bids[0].ad).to.not.equal(''); + expect(bids[1].adResponse).to.not.equal(''); + expect(bids[1].renderer).not.to.be.an('undefined'); + }); + }); + + describe('On winning bid', function () { + const bids = spec.interpretResponse(response, request); + spec.onBidWon(bids); + }); + + describe('On bid Time out', function () { + const bids = spec.interpretResponse(response, request); + spec.onTimeout(bids); + }); + + describe('user sync', function () { + it('to check the user sync iframe', function () { + let syncs = spec.getUserSyncs({ + iframeEnabled: true + }); + expect(syncs).to.not.be.an('undefined'); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + }); + }); +}); diff --git a/test/spec/modules/dspxBidAdapter_spec.js b/test/spec/modules/dspxBidAdapter_spec.js index 7eeac43680a..2513a6174cd 100644 --- a/test/spec/modules/dspxBidAdapter_spec.js +++ b/test/spec/modules/dspxBidAdapter_spec.js @@ -1,8 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/dspxBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/dspxBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; +const ENDPOINT_URL_DEV = 'https://dcbuyer.dspx.tv/request/'; describe('dspxAdapter', function () { const adapter = newBidder(spec); @@ -61,7 +62,22 @@ describe('dspxAdapter', function () { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475' - }]; + }, + { + 'bidder': 'dspx', + 'params': { + 'placement': '101', + 'devMode': true + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + } + + ]; let bidderRequest = { refererInfo: { @@ -72,9 +88,17 @@ describe('dspxAdapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest); it('sends bid request to our endpoint via GET', function () { expect(request[0].method).to.equal('GET'); + expect(request[0].url).to.equal(ENDPOINT_URL); let data = request[0].data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid'); expect(data).to.equal('_f=html&alternative=prebid_js&inventory_item_id=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bprivate_auction%5D=0&pfilter%5Bgeo%5D%5Bcountry%5D=DE&bcat=IAB2%2CIAB4&dvt=desktop'); }); + + it('sends bid request to our DEV endpoint via GET', function () { + expect(request[1].method).to.equal('GET'); + expect(request[1].url).to.equal(ENDPOINT_URL_DEV); + let data = request[1].data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid'); + expect(data).to.equal('_f=html&alternative=prebid_js&inventory_item_id=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e&prebidDevMode=1'); + }); }); describe('interpretResponse', function () { @@ -84,6 +108,7 @@ describe('dspxAdapter', function () { 'crid': 100500, 'width': '300', 'height': '250', + 'type': 'sspHTML', 'tag': '', 'requestId': '220ed41385952a', 'currency': 'EUR', @@ -103,7 +128,7 @@ describe('dspxAdapter', function () { currency: 'EUR', netRevenue: true, ttl: 300, - referrer: '', + type: 'sspHTML', ad: '' }]; diff --git a/test/spec/modules/e_volutionBidAdapter_spec.js b/test/spec/modules/e_volutionBidAdapter_spec.js new file mode 100644 index 00000000000..447420616d1 --- /dev/null +++ b/test/spec/modules/e_volutionBidAdapter_spec.js @@ -0,0 +1,235 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/e_volutionBidAdapter.js'; + +describe('EvolutionTechBidAdapter', function () { + let bid = { + bidId: '23fhj33i987f', + bidder: 'e_volution', + params: { + placementId: 0, + traffic: 'banner' + } + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and placementId parameters present', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + delete bid.params.placementId; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests([bid]); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://service.e-volution.ai/?c=o&m=multi'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + let placement = data['placements'][0]; + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); + expect(placement.placementId).to.equal(0); + expect(placement.bidId).to.equal('23fhj33i987f'); + expect(placement.traffic).to.equal('banner'); + }); + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([]); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.width).to.equal(300); + expect(dataItem.height).to.equal(250); + expect(dataItem.ad).to.equal('Test'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + describe('getUserSyncs', function () { + let userSync = spec.getUserSyncs(); + it('Returns valid URL and type', function () { + if (spec.noSync) { + expect(userSync).to.be.equal(false); + } else { + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.exist; + expect(userSync[0].url).to.exist; + expect(userSync[0].type).to.be.equal('image'); + expect(userSync[0].url).to.be.equal('https://service.e-volution.ai/?c=o&m=sync'); + } + }); + }); +}); diff --git a/test/spec/modules/ebdrBidAdapter_spec.js b/test/spec/modules/ebdrBidAdapter_spec.js index d742e28f2e6..ba1cad475da 100644 --- a/test/spec/modules/ebdrBidAdapter_spec.js +++ b/test/spec/modules/ebdrBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/ebdrBidAdapter'; -import { VIDEO, BANNER } from 'src/mediaTypes'; -import * as utils from 'src/utils'; +import { spec } from 'modules/ebdrBidAdapter.js'; +import { VIDEO, BANNER } from 'src/mediaTypes.js'; +import * as utils from 'src/utils.js'; describe('ebdrBidAdapter', function () { let bidRequests; @@ -147,7 +147,7 @@ describe('ebdrBidAdapter', function () { h: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1] }; }); - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '23a01e95856577', impid: '23a01e95856577', price: 0.81, adid: 'abcde-12345', nurl: 'https://cdn0.bnmla.com/vtest.xml', adm: '\nStatic VASTStatic VAST Tag00:00:15http://www.engagebdr.com/c', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD'}; + const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '23a01e95856577', impid: '23a01e95856577', price: 0.81, adid: 'abcde-12345', nurl: 'https://cdn0.bnmla.com/vtest.xml', adm: '\nStatic VASTStatic VAST Tag00:00:15https//www.engagebdr.com/c', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD'}; const bidResponse = spec.interpretResponse({ body: serverResponse }, ebdrReq); expect(bidResponse[0]).to.deep.equal({ requestId: bidRequests[1].bidId, @@ -189,7 +189,7 @@ describe('ebdrBidAdapter', function () { h: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1] }; }); - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; + const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; const bidResponse = spec.interpretResponse({ body: serverResponse }, ebdrReq); expect(bidResponse[0]).to.deep.equal({ requestId: bidRequests[ 0 ].bidId, @@ -215,14 +215,14 @@ describe('ebdrBidAdapter', function () { } }); it('sucess with usersync url', function () { - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '//match.bnmla.com/usersync?sspid=59&redir=', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; + const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: 'https://match.bnmla.com/usersync?sspid=59&redir=', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; const result = []; - result.push({type: 'image', url: '//match.bnmla.com/usersync?sspid=59&redir='}); + result.push({type: 'image', url: 'https://match.bnmla.com/usersync?sspid=59&redir='}); expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result); }); it('sucess without usersync url', function () { - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; + const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; const result = []; expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result); }); diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js new file mode 100644 index 00000000000..ed32ecc51d2 --- /dev/null +++ b/test/spec/modules/eids_spec.js @@ -0,0 +1,181 @@ +import {createEidsArray} from 'modules/userId/eids.js'; +import {expect} from 'chai'; + +// Note: In unit tets cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids +// this way the request will stay consistent and unit test cases will not need lots of changes. + +describe('eids array generation for known sub-modules', function() { + it('pubCommonId', function() { + const userId = { + pubcid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'pubcid.org', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('unifiedId: ext generation', function() { + const userId = { + tdid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'adserver.org', + uids: [{id: 'some-random-id-value', atype: 1, ext: { rtiPartner: 'TDID' }}] + }); + }); + + it('id5Id', function() { + const userId = { + id5id: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'id5-sync.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('parrableId', function() { + const userId = { + parrableid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'parrable.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('identityLink', function() { + const userId = { + idl_env: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'liveramp.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('liveIntentId; getValue call and ext', function() { + const userId = { + lipb: { + lipbid: 'some-random-id-value', + segments: ['s1', 's2'] + } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'liveintent.com', + uids: [{id: 'some-random-id-value', atype: 1}], + ext: {segments: ['s1', 's2']} + }); + }); + + it('liveIntentId; getValue call and NO ext', function() { + const userId = { + lipb: { + lipbid: 'some-random-id-value' + } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'liveintent.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('britepoolId', function() { + const userId = { + britepoolid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'britepool.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('DigiTrust; getValue call', function() { + const userId = { + digitrustid: { + data: { + id: 'some-random-id-value' + } + } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'digitru.st', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('criteo', function() { + const userId = { + criteoId: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'criteo.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('NetId', function() { + const userId = { + netId: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'netid.de', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); +}); + +describe('Negative case', function() { + it('eids array generation for UN-known sub-module', function() { + // UnknownCommonId + const userId = { + unknowncid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + }); + + it('eids array generation for known sub-module with non-string value', function() { + // pubCommonId + let userId = { + pubcid: undefined + }; + let newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + userId.pubcid = 123; + newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + userId.pubcid = []; + newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + userId.pubcid = {}; + newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + userId.pubcid = null; + newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + }); +}); diff --git a/test/spec/modules/emoteevBidAdapter_spec.js b/test/spec/modules/emoteevBidAdapter_spec.js index aa97b58ec38..43ae62f1eb9 100644 --- a/test/spec/modules/emoteevBidAdapter_spec.js +++ b/test/spec/modules/emoteevBidAdapter_spec.js @@ -47,10 +47,10 @@ import { validateExternalId, VENDOR_ID, WALLPAPER, -} from 'modules/emoteevBidAdapter'; -import * as url from '../../../src/url'; -import * as utils from '../../../src/utils'; -import {config} from '../../../src/config'; + storage +} from 'modules/emoteevBidAdapter.js'; +import * as utils from '../../../src/utils.js'; +import {config} from '../../../src/config.js'; const cannedValidBidRequests = [{ adUnitCode: '/19968336/header-bid-tag-1', @@ -78,8 +78,8 @@ const cannedBidderRequest = { canonicalUrl: undefined, numIframes: 0, reachedTop: true, - referer: 'http://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html', - stack: ['http://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html'] + referer: 'https://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html', + stack: ['https://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html'] }, start: 1544200012839, timeout: 3000, @@ -329,108 +329,108 @@ describe('emoteevBidAdapter', function () { }); describe('eventsUrl', function () { - expect(eventsUrl(null)).to.deep.equal(url.format({ + expect(eventsUrl(null)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: EVENTS_PATH })); - expect(eventsUrl('anything')).to.deep.equal(url.format({ + expect(eventsUrl('anything')).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: EVENTS_PATH })); - expect(eventsUrl(PRODUCTION)).to.deep.equal(url.format({ + expect(eventsUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(PRODUCTION), pathname: EVENTS_PATH })); - expect(eventsUrl(STAGING)).to.deep.equal(url.format({ + expect(eventsUrl(STAGING)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(STAGING), pathname: EVENTS_PATH })); - expect(eventsUrl(DEVELOPMENT)).to.deep.equal(url.format({ + expect(eventsUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ hostname: domain(DEVELOPMENT), pathname: EVENTS_PATH })); }); describe('bidderUrl', function () { - expect(bidderUrl(null)).to.deep.equal(url.format({ + expect(bidderUrl(null)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: BIDDER_PATH })); - expect(bidderUrl('anything')).to.deep.equal(url.format({ + expect(bidderUrl('anything')).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: BIDDER_PATH })); - expect(bidderUrl(PRODUCTION)).to.deep.equal(url.format({ + expect(bidderUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(PRODUCTION), pathname: BIDDER_PATH })); - expect(bidderUrl(STAGING)).to.deep.equal(url.format({ + expect(bidderUrl(STAGING)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(STAGING), pathname: BIDDER_PATH })); - expect(bidderUrl(DEVELOPMENT)).to.deep.equal(url.format({ + expect(bidderUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ hostname: domain(DEVELOPMENT), pathname: BIDDER_PATH })); }); describe('userSyncIframeUrl', function () { - expect(userSyncIframeUrl(null)).to.deep.equal(url.format({ + expect(userSyncIframeUrl(null)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: USER_SYNC_IFRAME_PATH })); - expect(userSyncIframeUrl('anything')).to.deep.equal(url.format({ + expect(userSyncIframeUrl('anything')).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: USER_SYNC_IFRAME_PATH })); - expect(userSyncIframeUrl(PRODUCTION)).to.deep.equal(url.format({ + expect(userSyncIframeUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(PRODUCTION), pathname: USER_SYNC_IFRAME_PATH })); - expect(userSyncIframeUrl(STAGING)).to.deep.equal(url.format({ + expect(userSyncIframeUrl(STAGING)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(STAGING), pathname: USER_SYNC_IFRAME_PATH })); - expect(userSyncIframeUrl(DEVELOPMENT)).to.deep.equal(url.format({ + expect(userSyncIframeUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ hostname: domain(DEVELOPMENT), pathname: USER_SYNC_IFRAME_PATH })); }); describe('userSyncImageUrl', function () { - expect(userSyncImageUrl(null)).to.deep.equal(url.format({ + expect(userSyncImageUrl(null)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: USER_SYNC_IMAGE_PATH })); - expect(userSyncImageUrl('anything')).to.deep.equal(url.format({ + expect(userSyncImageUrl('anything')).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: USER_SYNC_IMAGE_PATH })); - expect(userSyncImageUrl(PRODUCTION)).to.deep.equal(url.format({ + expect(userSyncImageUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(PRODUCTION), pathname: USER_SYNC_IMAGE_PATH })); - expect(userSyncImageUrl(STAGING)).to.deep.equal(url.format({ + expect(userSyncImageUrl(STAGING)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(STAGING), pathname: USER_SYNC_IMAGE_PATH })); - expect(userSyncImageUrl(DEVELOPMENT)).to.deep.equal(url.format({ + expect(userSyncImageUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ hostname: domain(DEVELOPMENT), pathname: USER_SYNC_IMAGE_PATH })); @@ -736,18 +736,25 @@ describe('emoteevBidAdapter', function () { }); describe('side effects', function () { - let triggerPixelSpy; + let triggerPixelStub; let getCookieSpy; let getConfigSpy; let getParameterByNameSpy; + + before(function() { + config.resetConfig(); + }); + after(function() { + config.resetConfig(); + }); beforeEach(function () { - triggerPixelSpy = sinon.spy(utils, 'triggerPixel'); - getCookieSpy = sinon.spy(utils, 'getCookie'); + triggerPixelStub = sinon.stub(utils, 'triggerPixel'); + getCookieSpy = sinon.spy(storage, 'getCookie'); getConfigSpy = sinon.spy(config, 'getConfig'); getParameterByNameSpy = sinon.spy(utils, 'getParameterByName'); }); afterEach(function () { - triggerPixelSpy.restore(); + triggerPixelStub.restore(); getCookieSpy.restore(); getConfigSpy.restore(); getParameterByNameSpy.restore(); @@ -769,16 +776,19 @@ describe('emoteevBidAdapter', function () { }; spec.isBidRequestValid(validBidRequest); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.notCalled(config.getConfig); sinon.assert.notCalled(utils.getParameterByName); }); - it('has intended side-effects', function () { + }); + describe('isBidRequestValid empty request', function() { + it('has intended side-effects empty request', function () { const invalidBidRequest = {}; spec.isBidRequestValid(invalidBidRequest); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // disabling these getConfig tests as they have been flaky in browserstack testing + // sinon.assert.notCalled(config.getConfig); sinon.assert.notCalled(utils.getParameterByName); }); }); @@ -786,8 +796,8 @@ describe('emoteevBidAdapter', function () { it('has intended side-effects', function () { spec.buildRequests(cannedValidBidRequests, cannedBidderRequest); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.callCount(config.getConfig, 3); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.callCount(config.getConfig, 3); sinon.assert.callCount(utils.getParameterByName, 2); }); }); @@ -795,8 +805,8 @@ describe('emoteevBidAdapter', function () { it('has intended side-effects', function () { spec.interpretResponse(serverResponse); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.notCalled(config.getConfig); sinon.assert.notCalled(utils.getParameterByName); }); }); @@ -805,8 +815,8 @@ describe('emoteevBidAdapter', function () { const bidObject = serverResponse.body[0]; spec.onBidWon(bidObject); sinon.assert.calledOnce(utils.triggerPixel); - sinon.assert.calledOnce(utils.getCookie); - sinon.assert.calledOnce(config.getConfig); + sinon.assert.calledOnce(storage.getCookie); + // sinon.assert.calledOnce(config.getConfig); sinon.assert.calledOnce(utils.getParameterByName); }); }); @@ -814,8 +824,8 @@ describe('emoteevBidAdapter', function () { it('has intended side-effects', function () { spec.onTimeout(cannedValidBidRequests[0]); sinon.assert.calledOnce(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.calledOnce(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.calledOnce(config.getConfig); sinon.assert.calledOnce(utils.getParameterByName); }); }); @@ -823,8 +833,8 @@ describe('emoteevBidAdapter', function () { it('has intended side-effects', function () { spec.getUserSyncs({}); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.calledOnce(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.calledOnce(config.getConfig); sinon.assert.calledOnce(utils.getParameterByName); }); }); diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js index 10d0d74c49c..e064c4833e6 100644 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ b/test/spec/modules/emx_digitalBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/emx_digitalBidAdapter'; -import * as utils from 'src/utils'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/emx_digitalBidAdapter.js'; +import * as utils from 'src/utils.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('emx_digital Adapter', function () { describe('callBids', function () { @@ -276,9 +276,9 @@ describe('emx_digital Adapter', function () { it('properly sends site information and protocol', function () { request = spec.buildRequests(bidderRequest.bids, bidderRequest); request = JSON.parse(request.data); - expect(request.site.domain).to.equal(utils.getTopWindowLocation().hostname); - expect(decodeURIComponent(request.site.page)).to.equal(bidderRequest.refererInfo.referer); - expect(request.site.ref).to.equal(window.top.document.referrer); + expect(request.site).to.have.property('domain', 'example.com'); + expect(request.site).to.have.property('page', 'https://example.com/index.html?pbjs_debug=true'); + expect(request.site).to.have.property('ref', window.top.document.referrer); }); it('builds correctly formatted request banner object', function () { @@ -300,15 +300,15 @@ describe('emx_digital Adapter', function () { bidRequestWithVideo[0].mediaTypes = { video: { context: 'instream', - playerSize: [640, 480] + playerSize: [[640, 480]] }, }; bidRequestWithVideo[0].params.video = {}; let request = spec.buildRequests(bidRequestWithVideo, bidderRequest); const data = JSON.parse(request.data); expect(data.imp[0].video).to.exist.and.to.be.a('object'); - expect(data.imp[0].video.h).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][0]); - expect(data.imp[0].video.w).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][1]); + expect(data.imp[0].video.w).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][0]); + expect(data.imp[0].video.h).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][1]); }); it('builds correctly formatted request video object for outstream', function () { @@ -316,15 +316,15 @@ describe('emx_digital Adapter', function () { bidRequestWithOutstreamVideo[0].mediaTypes = { video: { context: 'outstream', - playerSize: [640, 480] + playerSize: [[640, 480]] }, }; bidRequestWithOutstreamVideo[0].params.video = {}; let request = spec.buildRequests(bidRequestWithOutstreamVideo, bidderRequest); const data = JSON.parse(request.data); expect(data.imp[0].video).to.exist.and.to.be.a('object'); - expect(data.imp[0].video.h).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][0]); - expect(data.imp[0].video.w).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][1]); + expect(data.imp[0].video.w).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][0]); + expect(data.imp[0].video.h).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][1]); }); it('shouldn\'t contain a user obj without GDPR information', function () { @@ -355,9 +355,39 @@ describe('emx_digital Adapter', function () { expect(request.regs.ext).to.have.property('gdpr', 0); expect(request).to.not.have.property('user'); }); + it('should add us privacy info to request', function() { + let consentString = '1YNN'; + bidderRequest.uspConsent = consentString; + let request = spec.buildRequests(bidderRequest.bids, bidderRequest); + request = JSON.parse(request.data); + expect(request.us_privacy).to.exist; + expect(request.us_privacy).to.exist.and.to.equal(consentString); + }); }); describe('interpretResponse', function () { + let bid = { + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + const serverResponse = { 'id': '12819a18-56e1-4256-b836-b69a10202668', 'seatbid': [{ @@ -458,7 +488,8 @@ describe('emx_digital Adapter', function () { it('returns a banner bid for non-xml creatives', function () { let result = spec.interpretResponse({ body: serverResponse - }); + }, { bidRequest: bid } + ); const ad0 = result[0]; const ad1 = result[1]; expect(ad0.mediaType).to.equal('banner'); @@ -480,7 +511,8 @@ describe('emx_digital Adapter', function () { let result = spec.interpretResponse({ body: serverResponse - }); + }, { bidRequest: bid } + ); const ad0 = result[0]; const ad1 = result[1]; expect(ad0.mediaType).to.equal('video'); @@ -503,6 +535,15 @@ describe('emx_digital Adapter', function () { }); expect(result.length).to.equal(0); }); + + it('should not throw an error when decoding an improperly encoded adm', function () { + serverResponse.seatbid[0].bid[0].adm = '\\<\\/script\\>'; + serverResponse.seatbid[1].bid[0].adm = '%3F%%3Demx%3C3prebid' + + assert.doesNotThrow(() => spec.interpretResponse({ + body: serverResponse + })); + }); }); describe('getUserSyncs', function () { diff --git a/test/spec/modules/envivoBidAdapter_spec.js b/test/spec/modules/envivoBidAdapter_spec.js new file mode 100644 index 00000000000..7bd1dd1ccf1 --- /dev/null +++ b/test/spec/modules/envivoBidAdapter_spec.js @@ -0,0 +1,159 @@ +import { expect } from 'chai'; +import { spec } from 'modules/envivoBidAdapter.js'; + +const ENDPOINT = 'https://ad.nvivo.tv/ads/www/admin/plugins/Prebid/getAd.php'; + +describe('The Envivo bidding adapter', function () { + describe('isBidRequestValid', function () { + it('should return false when given an invalid bid', function () { + const bid = { + bidder: 'envivo', + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(false); + }); + + it('should return true when given a publisherId in bid', function () { + const bid = { + bidder: 'envivo', + params: { + publisherId: 14 + }, + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(true); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + 'bidder': 'envivo', + 'params': { + 'publisherId': 14 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ] + }]; + + const request = spec.buildRequests(bidRequests); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('check endpoint url', function () { + expect(request.url).to.equal(ENDPOINT) + }); + + it('sets the proper banner object', function () { + expect(bidRequests[0].params.publisherId).to.equal(14); + }) + }); + const response = { + body: [ + { + 'requestId': '2ee937f15015c6', + 'cpm': '0.2000', + 'width': 300, + 'height': 600, + 'creativeId': '4', + 'currency': 'USD', + 'netRevenue': true, + 'ad': 'ads.html', + 'mediaType': 'banner' + }, + { + 'requestId': '3e1af92622bdc', + 'cpm': '0.2000', + 'creativeId': '4', + 'context': 'outstream', + 'currency': 'USD', + 'netRevenue': true, + 'vastUrl': 'tezt.xml', + 'width': 640, + 'height': 480, + 'mediaType': 'video' + }] + }; + + const request = [ + { + 'bidder': 'envivo', + 'params': { + 'publisherId': 14 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 600] + ] + } + }, + 'bidId': '2ee937f15015c6', + 'src': 'client', + }, + { + 'bidder': 'envivo', + 'params': { + 'publisherId': 14 + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [ + [640, 480] + ] + } + }, + 'bidId': '3e1af92622bdc', + 'src': 'client', + } + ]; + + describe('interpretResponse', function () { + it('return empty array when no ad found', function () { + const response = {}; + const request = { bidRequests: [] }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('check response for banner and video', function () { + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(2); + expect(bids[0].requestId).to.equal('2ee937f15015c6'); + expect(bids[0].cpm).to.equal('0.2000'); + expect(bids[1].cpm).to.equal('0.2000'); + expect(bids[0].width).to.equal(300); + expect(bids[0].height).to.equal(600); + expect(bids[1].vastUrl).to.not.equal(''); + expect(bids[0].ad).to.not.equal(''); + expect(bids[1].adResponse).to.not.equal(''); + expect(bids[1].renderer).not.to.be.an('undefined'); + }); + }); + + describe('On winning bid', function () { + const bids = spec.interpretResponse(response, request); + spec.onBidWon(bids); + }); + + describe('On bid Time out', function () { + const bids = spec.interpretResponse(response, request); + spec.onTimeout(bids); + }); + + describe('user sync', function () { + it('to check the user sync iframe', function () { + let syncs = spec.getUserSyncs({ + iframeEnabled: true + }); + expect(syncs).to.not.be.an('undefined'); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + }); + }); +}); diff --git a/test/spec/modules/eplanningAnalyticsAdapter_spec.js b/test/spec/modules/eplanningAnalyticsAdapter_spec.js index 8609024c7d9..9bb71e7033d 100644 --- a/test/spec/modules/eplanningAnalyticsAdapter_spec.js +++ b/test/spec/modules/eplanningAnalyticsAdapter_spec.js @@ -1,24 +1,18 @@ -import eplAnalyticsAdapter from 'modules/eplanningAnalyticsAdapter'; -import includes from 'core-js/library/fn/array/includes'; +import eplAnalyticsAdapter from 'modules/eplanningAnalyticsAdapter.js'; +import includes from 'core-js/library/fn/array/includes.js'; import { expect } from 'chai'; -import {parse as parseURL} from 'src/url'; +import { parseUrl } from 'src/utils.js'; +import { server } from 'test/mocks/xhr.js'; let adapterManager = require('src/adapterManager').default; let events = require('src/events'); let constants = require('src/constants.json'); describe('eplanning analytics adapter', function () { - let xhr; - let requests; - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => { requests.push(request) }; sinon.stub(events, 'getEvents').returns([]); }); afterEach(function () { - xhr.restore(); events.getEvents.restore(); eplAnalyticsAdapter.disableAnalytics(); }); @@ -115,7 +109,7 @@ describe('eplanning analytics adapter', function () { events.emit(constants.EVENTS.AUCTION_END, {auctionId: pauctionId}); // Step 7: Find the request data sent (filtering other hosts) - requests = requests.filter(req => { + let requests = server.requests.filter(req => { return req.url.indexOf(initOptions.host) > -1; }); expect(requests.length).to.equal(1); @@ -124,7 +118,7 @@ describe('eplanning analytics adapter', function () { expect(includes(['https://ads.ar.e-planning.net/hba/1/12345?d='], requests[0].url)); let info = requests[0].url; - let purl = parseURL(info); + let purl = parseUrl(info); let eplData = JSON.parse(decodeURIComponent(purl.search.d)); // Step 8 check that 6 events were sent diff --git a/test/spec/modules/eplanningBidAdapter_spec.js b/test/spec/modules/eplanningBidAdapter_spec.js index 93290229ce3..ff03bf033af 100644 --- a/test/spec/modules/eplanningBidAdapter_spec.js +++ b/test/spec/modules/eplanningBidAdapter_spec.js @@ -1,17 +1,21 @@ import { expect } from 'chai'; -import { spec } from 'modules/eplanningBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { spec, storage } from 'modules/eplanningBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('E-Planning Adapter', function () { const adapter = newBidder('spec'); const CI = '12345'; const ADUNIT_CODE = 'adunit-co:de'; const ADUNIT_CODE2 = 'adunit-code-dos'; - const CLEAN_ADUNIT_CODE2 = 'adunitcodedos'; - const CLEAN_ADUNIT_CODE = 'adunitco_de'; + const ADUNIT_CODE_VIEW = 'adunit-code-view'; + const ADUNIT_CODE_VIEW2 = 'adunit-code-view2'; + const ADUNIT_CODE_VIEW3 = 'adunit-code-view3'; + const CLEAN_ADUNIT_CODE2 = '300x250_1'; + const CLEAN_ADUNIT_CODE = '300x250_0'; + const CLEAN_ADUNIT_CODE_ML = 'adunitco_de'; const BID_ID = '123456789'; const BID_ID2 = '987654321'; + const BID_ID3 = '998877665'; const CPM = 1.3; const W = '300'; const H = '250'; @@ -28,6 +32,17 @@ describe('E-Planning Adapter', function () { 'adUnitCode': ADUNIT_CODE, 'sizes': [[300, 250], [300, 600]], }; + const ML = '1'; + const validBidMappingLinear = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'ml': ML, + }, + 'adUnitCode': ADUNIT_CODE, + 'sizes': [[300, 250], [300, 600]], + }; const validBid2 = { 'bidder': 'eplanning', 'bidId': BID_ID2, @@ -37,6 +52,33 @@ describe('E-Planning Adapter', function () { 'adUnitCode': ADUNIT_CODE2, 'sizes': [[300, 250], [300, 600]], }; + const validBidView = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + }, + 'adUnitCode': ADUNIT_CODE_VIEW, + 'sizes': [[300, 250], [300, 600]], + }; + const validBidView2 = { + 'bidder': 'eplanning', + 'bidId': BID_ID2, + 'params': { + 'ci': CI, + }, + 'adUnitCode': ADUNIT_CODE_VIEW2, + 'sizes': [[300, 250], [300, 600]], + }; + const validBidView3 = { + 'bidder': 'eplanning', + 'bidId': BID_ID3, + 'params': { + 'ci': CI, + }, + 'adUnitCode': ADUNIT_CODE_VIEW3, + 'sizes': [[300, 250], [300, 600]], + }; const testBid = { 'bidder': 'eplanning', 'params': { @@ -166,6 +208,22 @@ describe('E-Planning Adapter', function () { ] } }; + const refererUrl = 'https://localhost'; + const bidderRequest = { + refererInfo: { + referer: refererUrl + }, + gdprConsent: { + gdprApplies: 1, + consentString: 'concentDataString', + vendorData: { + vendorConsents: { + '90': 1 + }, + }, + }, + uspConsent: 'consentCcpa' + }; describe('inherited functions', function () { it('exists and is a function', function () { @@ -189,30 +247,35 @@ describe('E-Planning Adapter', function () { describe('buildRequests', function () { let bidRequests = [validBid]; - it('should create the url correctly', function () { - const url = spec.buildRequests(bidRequests).url; - expect(url).to.equal('//ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); + const url = spec.buildRequests(bidRequests, bidderRequest).url; + expect(url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); }); it('should return GET method', function () { - const method = spec.buildRequests(bidRequests).method; + const method = spec.buildRequests(bidRequests, bidderRequest).method; expect(method).to.equal('GET'); }); it('should return r parameter with value pbjs', function () { - const r = spec.buildRequests(bidRequests).data.r; + const r = spec.buildRequests(bidRequests, bidderRequest).data.r; expect(r).to.equal('pbjs'); }); it('should return pbv parameter with value prebid version', function () { - const pbv = spec.buildRequests(bidRequests).data.pbv; + const pbv = spec.buildRequests(bidRequests, bidderRequest).data.pbv; expect(pbv).to.equal('$prebid.version$'); }); it('should return e parameter with value according to the adunit sizes', function () { - const e = spec.buildRequests(bidRequests).data.e; - expect(e).to.equal(CLEAN_ADUNIT_CODE + ':300x250,300x600'); + const e = spec.buildRequests(bidRequests, bidderRequest).data.e; + expect(e).to.equal('300x250_0:300x250,300x600'); + }); + + it('should return e parameter with linear mapping attribute with value according to the adunit sizes', function () { + let bidRequestsML = [validBidMappingLinear]; + const e = spec.buildRequests(bidRequestsML, bidderRequest).data.e; + expect(e).to.equal(CLEAN_ADUNIT_CODE_ML + ':300x250,300x600'); }); it('should return correct e parameter with more than one adunit', function () { @@ -228,8 +291,27 @@ describe('E-Planning Adapter', function () { }; bidRequests.push(anotherBid); - const e = spec.buildRequests(bidRequests).data.e; - expect(e).to.equal(CLEAN_ADUNIT_CODE + ':300x250,300x600+' + CLEAN_NEW_CODE + ':100x100'); + const e = spec.buildRequests(bidRequests, bidderRequest).data.e; + expect(e).to.equal('300x250_0:300x250,300x600+100x100_0:100x100'); + }); + + it('should return correct e parameter with linear mapping attribute with more than one adunit', function () { + let bidRequestsML = [validBidMappingLinear]; + const NEW_CODE = ADUNIT_CODE + '2'; + const CLEAN_NEW_CODE = CLEAN_ADUNIT_CODE_ML + '2'; + const anotherBid = { + 'bidder': 'eplanning', + 'params': { + 'ci': CI, + 'ml': ML, + }, + 'adUnitCode': NEW_CODE, + 'sizes': [[100, 100]], + }; + bidRequestsML.push(anotherBid); + + const e = spec.buildRequests(bidRequestsML, bidderRequest).data.e; + expect(e).to.equal(CLEAN_ADUNIT_CODE_ML + ':300x250,300x600+' + CLEAN_NEW_CODE + ':100x100'); }); it('should return correct e parameter when the adunit has no size', function () { @@ -241,22 +323,33 @@ describe('E-Planning Adapter', function () { 'adUnitCode': ADUNIT_CODE, }; - const e = spec.buildRequests([noSizeBid]).data.e; - expect(e).to.equal(CLEAN_ADUNIT_CODE + ':1x1'); + const e = spec.buildRequests([noSizeBid], bidderRequest).data.e; + expect(e).to.equal('1x1_0:1x1'); + }); + + it('should return correct e parameter with linear mapping attribute when the adunit has no size', function () { + const noSizeBid = { + 'bidder': 'eplanning', + 'params': { + 'ci': CI, + 'ml': ML, + }, + 'adUnitCode': ADUNIT_CODE, + }; + + const e = spec.buildRequests([noSizeBid], bidderRequest).data.e; + expect(e).to.equal(CLEAN_ADUNIT_CODE_ML + ':1x1'); }); it('should return ur parameter with current window url', function () { - const ur = spec.buildRequests(bidRequests).data.ur; - expect(ur).to.equal(utils.getTopWindowUrl()); + const ur = spec.buildRequests(bidRequests, bidderRequest).data.ur; + expect(ur).to.equal(encodeURIComponent(bidderRequest.refererInfo.referer)); }); it('should return fr parameter when there is a referrer', function () { - const referrer = 'thisisafakereferrer'; - const stubGetReferrer = sinon.stub(utils, 'getTopWindowReferrer'); - stubGetReferrer.returns(referrer); - const fr = spec.buildRequests(bidRequests).data.fr; - expect(fr).to.equal(referrer); - stubGetReferrer.restore() + const request = spec.buildRequests(bidRequests, bidderRequest); + const dataRequest = request.data; + expect(dataRequest.fr).to.equal(encodeURIComponent(refererUrl)); }); it('should return crs parameter with document charset', function () { @@ -267,21 +360,34 @@ describe('E-Planning Adapter', function () { expected = document.characterSet; } - const chset = spec.buildRequests(bidRequests).data.crs; + const chset = spec.buildRequests(bidRequests, bidderRequest).data.crs; expect(chset).to.equal(expected); }); it('should return the testing url when the request has the t parameter', function () { - const url = spec.buildRequests([testBid]).url; - const expectedUrl = '//' + TEST_ISV + '/layers/t_pbjs_2.json'; + const url = spec.buildRequests([testBid], bidderRequest).url; + const expectedUrl = 'https://' + TEST_ISV + '/layers/t_pbjs_2.json'; expect(url).to.equal(expectedUrl); }); it('should return the parameter ncb with value 1', function () { - const ncb = spec.buildRequests(bidRequests).data.ncb; + const ncb = spec.buildRequests(bidRequests, bidderRequest).data.ncb; expect(ncb).to.equal('1'); }); + + it('should properly build a gdpr request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const dataRequest = request.data; + expect(dataRequest.gdpr).to.equal('1'); + expect(dataRequest.gdprcs).to.equal('concentDataString'); + }); + + it('should properly build a uspConsent request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const dataRequest = request.data; + expect(dataRequest.ccpa).to.equal('consentCcpa'); + }); }); describe('interpretResponse', function () { @@ -354,10 +460,340 @@ describe('E-Planning Adapter', function () { describe('adUnits mapping to bidId', function () { it('should correctly map the bidId to the adunit', function () { - const requests = spec.buildRequests([validBid, validBid2]); + const requests = spec.buildRequests([validBid, validBid2], bidderRequest); const responses = spec.interpretResponse(responseWithTwoAdunits, requests); expect(responses[0].requestId).to.equal(BID_ID); expect(responses[1].requestId).to.equal(BID_ID2); }); }); + describe('viewability', function() { + let storageIdRender = 'pbsr_' + validBidView.adUnitCode; + let storageIdView = 'pbvi_' + validBidView.adUnitCode; + let bidRequests = [validBidView]; + let bidRequestMultiple = [validBidView, validBidView2, validBidView3]; + let getLocalStorageSpy; + let setDataInLocalStorageSpy; + let hasLocalStorageStub; + let clock; + let element; + let getBoundingClientRectStub; + let sandbox = sinon.sandbox.create(); + let focusStub; + function createElement(id) { + element = document.createElement('div'); + element.id = id || ADUNIT_CODE_VIEW; + element.style.width = '50px'; + element.style.height = '50px'; + if (frameElement) { + frameElement.style.width = '100px'; + frameElement.style.height = '100px'; + } + element.style.background = 'black'; + document.body.appendChild(element); + } + function createElementVisible(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 0, + y: 0, + width: 50, + height: 50, + top: 0, + right: 50, + bottom: 50, + left: 0, + }); + } + function createElementOutOfView(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 100, + y: 100, + width: 250, + height: 250, + top: 100, + right: 350, + bottom: 350, + left: 100, + }); + } + + function createPartiallyVisibleElement(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 0, + y: 0, + width: 50, + height: 150, + top: 0, + right: 50, + bottom: 150, + left: 0, + }); + } + function createPartiallyInvisibleElement(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 0, + y: 0, + width: 150, + height: 150, + top: 0, + right: 150, + bottom: 150, + left: 0, + }); + } + function createElementOutOfRange(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 200, + y: 200, + width: 350, + height: 350, + top: 200, + right: 350, + bottom: 350, + left: 200, + }); + } + beforeEach(function () { + getLocalStorageSpy = sandbox.spy(storage, 'getDataFromLocalStorage'); + setDataInLocalStorageSpy = sandbox.spy(storage, 'setDataInLocalStorage'); + + hasLocalStorageStub = sandbox.stub(storage, 'hasLocalStorage'); + hasLocalStorageStub.returns(true); + + clock = sandbox.useFakeTimers(); + + focusStub = sandbox.stub(window.top.document, 'hasFocus'); + focusStub.returns(true); + }); + afterEach(function () { + sandbox.restore(); + if (document.getElementById(ADUNIT_CODE_VIEW)) { + document.body.removeChild(element); + } + window.top.localStorage.removeItem(storageIdRender); + window.top.localStorage.removeItem(storageIdView); + }); + + it('should create the url correctly without LocalStorage', function() { + createElementVisible(); + hasLocalStorageStub.returns(false); + const response = spec.buildRequests(bidRequests, bidderRequest); + + expect(response.url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); + expect(response.data.vs).to.equal('F'); + + sinon.assert.notCalled(getLocalStorageSpy); + sinon.assert.notCalled(setDataInLocalStorageSpy); + }); + + it('should create the url correctly with LocalStorage', function() { + createElementVisible(); + const response = spec.buildRequests(bidRequests, bidderRequest); + expect(response.url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); + + expect(response.data.vs).to.equal('F'); + + sinon.assert.called(getLocalStorageSpy); + sinon.assert.called(setDataInLocalStorageSpy); + sinon.assert.calledWith(getLocalStorageSpy, storageIdRender); + sinon.assert.calledWith(setDataInLocalStorageSpy, storageIdRender); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + }); + + context('when element is fully in view', function() { + let respuesta; + beforeEach(function () { + createElementVisible(); + }); + it('when you have a render', function() { + respuesta = spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + + expect(respuesta.data.vs).to.equal('F'); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal('1'); + }); + it('when you have more than four render', function() { + storage.setDataInLocalStorage(storageIdRender, 4); + respuesta = spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + + expect(respuesta.data.vs).to.equal('0'); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal('1'); + }); + it('when you have more than four render and already record visibility', function() { + storage.setDataInLocalStorage(storageIdRender, 4); + storage.setDataInLocalStorage(storageIdView, 4); + respuesta = spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + + expect(respuesta.data.vs).to.equal('a'); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal('5'); + }); + }); + + context('when element is out of view', function() { + let respuesta; + beforeEach(function () { + createElementOutOfView(); + }); + + it('when you have a render', function() { + respuesta = spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + expect(respuesta.data.vs).to.equal('F'); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + it('when you have more than four render', function() { + storage.setDataInLocalStorage(storageIdRender, 4); + respuesta = spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + expect(respuesta.data.vs).to.equal('0'); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + + context('when element is partially in view', function() { + let respuesta; + it('should register visibility with more than 50%', function() { + createPartiallyVisibleElement(); + respuesta = spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal('1'); + }); + it('you should not register visibility with less than 50%', function() { + createPartiallyInvisibleElement(); + respuesta = spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + context('when width or height of the element is zero', function() { + beforeEach(function () { + createElementVisible(); + }); + it('if the width is zero but the height is within the range', function() { + element.style.width = '0px'; + spec.buildRequests(bidRequests, bidderRequest) + clock.tick(1005); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + it('if the height is zero but the width is within the range', function() { + element.style.height = '0px'; + spec.buildRequests(bidRequests, bidderRequest) + clock.tick(1005); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + it('if both are zero', function() { + element.style.height = '0px'; + element.style.width = '0px'; + spec.buildRequests(bidRequests, bidderRequest) + clock.tick(1005); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + context('when tab is inactive', function() { + it('I should not register if it is not in focus', function() { + createElementVisible(); + focusStub.returns(false); + spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + context('segmentBeginsBeforeTheVisibleRange', function() { + it('segmentBeginsBeforeTheVisibleRange', function() { + createElementOutOfRange(); + spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + context('when there are multiple adunit', function() { + let respuesta; + beforeEach(function () { + [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + storage.setDataInLocalStorage('pbsr_' + ac, 5); + storage.setDataInLocalStorage('pbvi_' + ac, 5); + }); + }); + afterEach(function () { + [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + if (document.getElementById(ac)) { + document.body.removeChild(document.getElementById(ac)); + } + window.top.localStorage.removeItem(ac); + window.top.localStorage.removeItem(ac); + }); + }); + it('all visibles', function() { + createElementVisible(ADUNIT_CODE_VIEW); + createElementVisible(ADUNIT_CODE_VIEW2); + createElementVisible(ADUNIT_CODE_VIEW3); + + respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); + clock.tick(1005); + [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + expect(storage.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(storage.getDataFromLocalStorage('pbvi_' + ac)).to.equal('6'); + }); + expect('aaa').to.equal(respuesta.data.vs); + }); + it('none visible', function() { + createElementOutOfView(ADUNIT_CODE_VIEW); + createElementOutOfView(ADUNIT_CODE_VIEW2); + createElementOutOfView(ADUNIT_CODE_VIEW3); + + respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); + clock.tick(1005); + [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + expect(storage.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(storage.getDataFromLocalStorage('pbvi_' + ac)).to.equal('5'); + }); + + expect('aaa').to.equal(respuesta.data.vs); + }); + it('some visible and others not visible', function() { + createElementVisible(ADUNIT_CODE_VIEW); + createElementOutOfView(ADUNIT_CODE_VIEW2); + createElementOutOfView(ADUNIT_CODE_VIEW3); + + respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); + clock.tick(1005); + expect(storage.getDataFromLocalStorage('pbsr_' + ADUNIT_CODE_VIEW)).to.equal('6'); + expect(storage.getDataFromLocalStorage('pbvi_' + ADUNIT_CODE_VIEW)).to.equal('6'); + [ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + expect(storage.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(storage.getDataFromLocalStorage('pbvi_' + ac)).to.equal('5'); + }); + expect('aaa').to.equal(respuesta.data.vs); + }); + }); + }); }); diff --git a/test/spec/modules/etargetBidAdapter_spec.js b/test/spec/modules/etargetBidAdapter_spec.js index e4cccbf5cf3..4f5e0c224ec 100644 --- a/test/spec/modules/etargetBidAdapter_spec.js +++ b/test/spec/modules/etargetBidAdapter_spec.js @@ -1,7 +1,6 @@ import {assert, expect} from 'chai'; -import * as url from 'src/url'; -import {spec} from 'modules/etargetBidAdapter'; -import { BANNER, VIDEO } from 'src/mediaTypes'; +import {spec} from 'modules/etargetBidAdapter.js'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; describe('etarget adapter', function () { let serverResponse, bidRequest, bidResponses; @@ -29,7 +28,7 @@ describe('etarget adapter', function () { it('should handle global request parameters', function () { let parsedUrl = parseUrl(spec.buildRequests([bids[0]]).url); - assert.equal(parsedUrl.path, '//sk.search.etargetnet.com/hb'); + assert.equal(parsedUrl.path, 'https://sk.search.etargetnet.com/hb'); }); it('should set correct request method', function () { diff --git a/test/spec/modules/eywamediaBidAdapter_spec.js b/test/spec/modules/eywamediaBidAdapter_spec.js deleted file mode 100644 index 945c0dd0d01..00000000000 --- a/test/spec/modules/eywamediaBidAdapter_spec.js +++ /dev/null @@ -1,253 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/eywamediaBidAdapter'; - -describe('EywamediaAdapter', function () { - let serverResponse, bidRequests, bidRequest, bidResponses; - const ENDPOINT = 'https://adtarbostg.eywamedia.com/auctions/prebidjs/3000'; - - bidRequests = [ - { - 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', - 'sizes': [[300, 250]], - 'bidRequestsCount': 1, - 'params': { - 'publisherId': '1234_abcd' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'crumbs': { - 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' - }, - 'bidId': '28b09d0543d671', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', - 'src': 'client', - 'bidder': 'eywamedia', - 'bidderRequestId': '14d8cbc769114b' - }, - { - 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', - 'sizes': [[728, 90]], - 'bidRequestsCount': 1, - 'params': { - 'publisherId': '1234_abcd' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[728, 90]] - } - }, - 'crumbs': { - 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' - }, - 'bidId': '28b09d0543d672', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', - 'src': 'client', - 'bidder': 'eywamedia', - 'bidderRequestId': '14d8cbc769114b' - } - ]; - - bidRequest = { - 'auctionId': 'c88115a4-7e71-43d0-9c96-a9b43ebd143d', - 'auctionStart': 1564725164517, - 'bidderCode': 'eywamedia', - 'bidderRequestId': '191afa18994fdd', - 'bids': [], - 'refererInfo': { - 'canonicalUrl': '', - 'numIframes': 0, - 'reachedTop': true, - 'referer': '' - }, - 'stack': [ - '' - ], - 'start': 1564725164520, - 'timeout': 3000 - }; - - let testBid = { - 'bidder': 'eywamedia', - 'params': { - 'publisherId': '1234_abcd' - } - }; - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - assert(spec.isBidRequestValid(testBid)); - }); - - it('should return false when required params are missing', function () { - testBid.params = { - test: '231212312' - }; - assert.isFalse(spec.isBidRequestValid(testBid)); - }); - }); - - describe('buildRequests', function () { - it('should attempt to send bid requests to the endpoint via POST', function () { - const requests = spec.buildRequests(bidRequests, bidRequest); - expect(requests.method).to.equal('POST'); - expect(requests.url).to.be.equal(ENDPOINT); - }); - - it('should not blow up if crumbs is undefined', function () { - let bidArray = [ - { ...testBid, crumbs: undefined } - ] - expect(function () { spec.buildRequests(bidArray, bidRequest) }).not.to.throw() - }) - - it('should return true when required params found', function () { - testBid.params.publisherId = '1234_abcd'; - assert(spec.isBidRequestValid(testBid)); - }); - }); - - describe('interpretResponse', function () { - beforeEach(function () { - serverResponse = { - 'body': - [ - { - 'ad': '', - 'adSlot': '', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'adUrl': 'http://eywamedia.com', - 'bidId': '28b09d0543d671', - 'bidder': 'eywamedia', - 'bidderCode': 'eywamedia', - 'cpm': 1, - 'height': 250, - 'requestTimestamp': 1564725162, - 'respType': 'banner', - 'size': '300X250', - 'statusMessage': 'Bid available', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', - 'usesGenericKeys': true, - 'width': 300 - }, - { - 'ad': '', - 'adSlot': '', - 'adUnitCode': 'div-gpt-ad-1460505748561-1', - 'adUrl': 'http://eywamedia.com', - 'bidId': '28b09d0543d672', - 'bidder': 'eywamedia', - 'bidderCode': 'eywamedia', - 'cpm': 1, - 'height': 90, - 'requestTimestamp': 1564725164, - 'respType': 'banner', - 'size': '728X90', - 'statusMessage': 'Bid available', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', - 'usesGenericKeys': true, - 'width': 728 - } - ], - 'headers': 'header?' - }; - - bidRequest = { - 'data': - { - 'bidPayload': - [ - { - 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', - 'sizes': [[300, 250]], - 'bidRequestsCount': 1, - 'params': { - 'publisherId': '1234_abcd' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'crumbs': { - 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' - }, - 'bidId': '28b09d0543d671', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', - 'src': 'client', - 'bidder': 'eywamedia', - 'bidderRequestId': '14d8cbc769114b' - }, - { - 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', - 'sizes': [[728, 90]], - 'bidRequestsCount': 1, - 'params': { - 'publisherId': '1234_abcd' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[728, 90]] - } - }, - 'crumbs': { - 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' - }, - 'bidId': '28b09d0543d672', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', - 'src': 'client', - 'bidder': 'eywamedia', - 'bidderRequestId': '14d8cbc769114b' - } - ] - } - }; - bidResponses = [ - { - 'ad': '', - 'bidderCode': 'eywamedia', - 'cpm': 1, - 'creativeId': '28b09d0543d671', - 'currency': 'USD', - 'height': 250, - 'mediaType': 'banner', - 'netRevenue': true, - 'requestId': '28b09d0543d671', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', - 'ttl': 360, - 'width': 300 - }, - { - 'ad': '', - 'bidderCode': 'eywamedia', - 'cpm': 1, - 'creativeId': '28b09d0543d672', - 'currency': 'USD', - 'height': 90, - 'mediaType': 'banner', - 'netRevenue': true, - 'requestId': '28b09d0543d672', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', - 'ttl': 360, - 'width': 728 - } - ] - }); - - it('should respond with empty response when there is empty serverResponse', function () { - let result = spec.interpretResponse({ body: {} }, bidRequest); - assert.deepEqual(result, []); - }); - - it('should respond with multile response when there is multiple serverResponse', function () { - let result = spec.interpretResponse(serverResponse, bidRequest); - assert.deepEqual(result, bidResponses); - }); - }); -}); diff --git a/test/spec/modules/fairtradeBidAdapter_spec.js b/test/spec/modules/fairtradeBidAdapter_spec.js deleted file mode 100644 index ecd5db3c051..00000000000 --- a/test/spec/modules/fairtradeBidAdapter_spec.js +++ /dev/null @@ -1,289 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/fairtradeBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('FairTradeAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'fairtrade', - 'params': { - 'uid': '166' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '167' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '165'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '165,167'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '165,167'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '165,167'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - delete bidRequests[1].params.priceType; - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 165, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 166, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 167, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 4
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 165, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '166' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 165, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 165, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 166, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '167' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '168' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '169' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/feedadBidAdapter_spec.js b/test/spec/modules/feedadBidAdapter_spec.js index 3432a40eca4..066ab6b21f6 100644 --- a/test/spec/modules/feedadBidAdapter_spec.js +++ b/test/spec/modules/feedadBidAdapter_spec.js @@ -1,7 +1,7 @@ import {expect} from 'chai'; -import {spec} from 'modules/feedadBidAdapter'; -import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes'; -import * as sinon from 'sinon'; +import {spec} from 'modules/feedadBidAdapter.js'; +import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes.js'; +import {server} from 'test/mocks/xhr.js'; const CODE = 'feedad'; @@ -382,28 +382,15 @@ describe('FeedAdAdapter', function () { cases.forEach(([name, data, eventKlass]) => { let subject = spec[name]; describe(name + ' handler', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = xhr => requests.push(xhr); - }); - - afterEach(function () { - xhr.restore(); - }); - it('should do nothing on empty data', function () { subject(undefined); subject(null); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); it('should do nothing when bid metadata is not set', function () { subject(data); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); it('should send tracking params when correct metadata was set', function () { @@ -420,8 +407,8 @@ describe('FeedAdAdapter', function () { sdk_version: '1.0.0' }; subject(data); - expect(requests.length).to.equal(1); - let call = requests[0]; + expect(server.requests.length).to.equal(1); + let call = server.requests[0]; expect(call.url).to.equal('https://api.feedad.com/1/prebid/web/events'); expect(JSON.parse(call.requestBody)).to.deep.equal(expectedData); expect(call.method).to.equal('POST'); diff --git a/test/spec/modules/fidelityBidAdapter_spec.js b/test/spec/modules/fidelityBidAdapter_spec.js index e8e008103e6..1232c20b0d7 100644 --- a/test/spec/modules/fidelityBidAdapter_spec.js +++ b/test/spec/modules/fidelityBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/fidelityBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/fidelityBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('FidelityAdapter', function () { const adapter = newBidder(spec); @@ -15,9 +15,9 @@ describe('FidelityAdapter', function () { let bid = { 'bidder': 'fidelity', 'params': { - 'zoneid': '37', + 'zoneid': '27248', 'floor': '0.05', - 'server': 't.fidelity-media.com', + 'server': 'x.fidelity-media.com', }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -34,7 +34,7 @@ describe('FidelityAdapter', function () { let bid = Object.assign({}, bid); delete bid.params; bid.params = { - 'zoneid': '37', + 'zoneid': '27248', }; expect(spec.isBidRequestValid(bid)).to.equal(true); }); @@ -58,24 +58,40 @@ describe('FidelityAdapter', function () { { bidder: 'fidelity', params: { - zoneid: '37', + zoneid: '27248', floor: '0.05', - server: 't.fidelity-media.com', + server: 'x.fidelity-media.com', }, placementCode: '/19968336/header-bid-tag-0', sizes: [[300, 250], [320, 50]], bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' + transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + schain: { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'exchange1.com', + sid: '1234', + hp: 1, + rid: 'bid-request-1', + name: 'publisher', + domain: 'publisher.com' + }] + } } ], start: 1472239426002, auctionStart: 1472239426000, - timeout: 5000 + timeout: 5000, + refererInfo: { + referer: 'http://test.com/index.html' + } }; - it('should add source and verison to the tag', function () { + it('should add params to the request', function () { + let schainString = '1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com'; const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); const payload = request.data; expect(payload.from).to.exist; @@ -89,12 +105,16 @@ describe('FidelityAdapter', function () { expect(payload.flashver).to.exist; expect(payload.tmax).to.exist; expect(payload.defloc).to.exist; + expect(payload.schain).to.exist.and.to.be.a('string'); + expect(payload.schain).to.equal(schainString); }); - it('should add gdpr consent information to the request', function () { + it('should add consent information to the request', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let uspConsentString = '1YN-'; bidderRequest.gdprConsent = { gdprApplies: true, + allowAuctionWithoutConsent: true, consentString: consentString, vendorData: { vendorConsents: { @@ -102,6 +122,7 @@ describe('FidelityAdapter', function () { }, }, }; + bidderRequest.uspConsent = uspConsentString; const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); const payload = request.data; expect(payload.gdpr).to.exist.and.to.be.a('number'); @@ -110,11 +131,13 @@ describe('FidelityAdapter', function () { expect(payload.consent_str).to.equal(consentString); expect(payload.consent_given).to.exist.and.to.be.a('number'); expect(payload.consent_given).to.equal(1); + expect(payload.us_privacy).to.exist.and.to.be.a('string'); + expect(payload.us_privacy).to.equal(uspConsentString); }); it('sends bid request to ENDPOINT via GET', function () { const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.url).to.equal('//t.fidelity-media.com/delivery/hb.php'); + expect(request.url).to.equal('https://x.fidelity-media.com/delivery/hb.php'); expect(request.method).to.equal('GET'); }); }) @@ -165,7 +188,7 @@ describe('FidelityAdapter', function () { }); describe('user sync', function () { - const syncUrl = '//x.fidelity-media.com/delivery/matches.php?type=iframe'; + const syncUrl = 'https://x.fidelity-media.com/delivery/matches.php?type=iframe'; it('should register the sync iframe', function () { expect(spec.getUserSyncs({})).to.be.undefined; diff --git a/test/spec/modules/fintezaAnalyticsAdapter_spec.js b/test/spec/modules/fintezaAnalyticsAdapter_spec.js index 33b24f5f50f..ae9ceceecc3 100644 --- a/test/spec/modules/fintezaAnalyticsAdapter_spec.js +++ b/test/spec/modules/fintezaAnalyticsAdapter_spec.js @@ -1,21 +1,26 @@ -import fntzAnalyticsAdapter from 'modules/fintezaAnalyticsAdapter'; -import includes from 'core-js/library/fn/array/includes'; +import fntzAnalyticsAdapter from 'modules/fintezaAnalyticsAdapter.js'; +import includes from 'core-js/library/fn/array/includes.js'; import { expect } from 'chai'; -import { parse as parseURL } from 'src/url'; +import { parseUrl } from 'src/utils.js'; +import { server } from 'test/mocks/xhr.js'; + let adapterManager = require('src/adapterManager').default; let events = require('src/events'); let constants = require('src/constants.json'); +function setCookie(name, value, expires) { + document.cookie = name + '=' + value + + '; path=/' + + (expires ? ('; expires=' + expires.toUTCString()) : '') + + '; SameSite=None'; +} + describe('finteza analytics adapter', function () { const clientId = 'fntz-client-32145'; - - let xhr; - let requests; + const uniqCookie = '5045380421580287382'; beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => { requests.push(request) }; + setCookie('_fz_uniq', uniqCookie); sinon.stub(events, 'getEvents').returns([]); sinon.spy(fntzAnalyticsAdapter, 'track'); @@ -38,7 +43,7 @@ describe('finteza analytics adapter', function () { }); afterEach(function () { - xhr.restore(); + setCookie('_fz_uniq', '', new Date(0)); events.getEvents.restore(); fntzAnalyticsAdapter.track.restore(); fntzAnalyticsAdapter.disableAnalytics(); @@ -71,16 +76,18 @@ describe('finteza analytics adapter', function () { // Emit the events with the "real" arguments events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - expect(requests[0].method).to.equal('GET'); + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); - const url = parseURL(requests[0].url); + const url = parseUrl(server.requests[0].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); expect(url.pathname).to.equal('/tr'); expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); expect(decodeURIComponent(url.search.event)).to.equal(`Bid Request ${bidderCode.toUpperCase()}`); sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); @@ -112,28 +119,32 @@ describe('finteza analytics adapter', function () { // Emit the events with the "real" arguments events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); - expect(requests.length).to.equal(2); + expect(server.requests.length).to.equal(2); - expect(requests[0].method).to.equal('GET'); + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); - let url = parseURL(requests[0].url); + let url = parseUrl(server.requests[0].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); expect(url.pathname).to.equal('/tr'); expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Price ${bidderCode.toLowerCase()}`); expect(url.search.value).to.equal(String(cpm)); expect(url.search.unit).to.equal('usd'); - expect(requests[1].method).to.equal('GET'); + expect(server.requests[1].method).to.equal('GET'); + expect(server.requests[1].withCredentials).to.equal(true); - url = parseURL(requests[1].url); + url = parseUrl(server.requests[1].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); expect(url.pathname).to.equal('/tr'); expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Time ${bidderCode.toLowerCase()}`); expect(url.search.value).to.equal(String(timeToRespond)); expect(url.search.unit).to.equal('ms'); @@ -162,16 +173,18 @@ describe('finteza analytics adapter', function () { // Emit the events with the "real" arguments events.emit(constants.EVENTS.BID_WON, bidWon); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - expect(requests[0].method).to.equal('GET'); + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); - const url = parseURL(requests[0].url); + const url = parseUrl(server.requests[0].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); expect(url.pathname).to.equal('/tr'); expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); expect(decodeURIComponent(url.search.event)).to.equal(`Bid Won ${bidderCode.toUpperCase()}`); expect(url.search.value).to.equal(String(cpm)); expect(url.search.unit).to.equal('usd'); @@ -199,16 +212,18 @@ describe('finteza analytics adapter', function () { // Emit the events with the "real" arguments events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeout); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - expect(requests[0].method).to.equal('GET'); + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); - const url = parseURL(requests[0].url); + const url = parseUrl(server.requests[0].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); expect(url.pathname).to.equal('/tr'); expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); expect(decodeURIComponent(url.search.event)).to.equal(`Bid Timeout Bidder789`); expect(url.search.value).to.equal(String(timeout)); expect(url.search.unit).to.equal('ms'); diff --git a/test/spec/modules/fluctBidAdapter_spec.js b/test/spec/modules/fluctBidAdapter_spec.js new file mode 100644 index 00000000000..6530a3c36cf --- /dev/null +++ b/test/spec/modules/fluctBidAdapter_spec.js @@ -0,0 +1,201 @@ +import {expect} from 'chai'; +import {spec} from 'modules/fluctBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {config} from 'src/config.js'; + +describe('fluctAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + const bid = { + bidder: 'fluct', + params: { + dfpUnitCode: '/1000/dfp_unit_code', + tagId: '10000:100000001', + groupId: '1000000002', + } + }; + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true when dfpUnitCode is not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + tagId: '10000:100000001', + groupId: '1000000002', + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when groupId is not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + dfpUnitCode: '/1000/dfp_unit_code', + tagId: '10000:100000001', + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + bidder: 'fluct', + params: { + dfpUnitCode: '/100000/unit_code', + tagId: '10000:100000001', + groupId: '1000000002', + }, + adUnitCode: '/10000/unit_code', + sizes: [[300, 250], [336, 280]], + bidId: '237f4d1a293f99', + bidderRequestId: '1a857fa34c1c96', + auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', + transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', + }]; + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.method).to.equal('POST'); + }); + }); + + describe('interpretResponse', function() { + const callBeaconSnippet = ''; + + it('should get correct bid response', function() { + const bidRequest = { + bidder: 'fluct', + params: { + dfpUnitCode: '/10000/unit_code', + tagid: '10000:100000001', + groupId: '1000000002', + }, + adUnitCode: '/10000/unit_code', + sizes: [[300, 250], [336, 280]], + bidId: '237f4d1a293f99', + bidderRequestId: '1a857fa34c1c96', + auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', + transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', + }; + + const serverResponse = { + body: { + id: '237f4d1a293f99', + cur: 'JPY', + seatbid: [{ + bid: [{ + price: 100, + w: 300, + h: 250, + adm: '', + burl: 'https://i.adingo.jp/?test=1&et=hb&bidid=237f4d1a293f99', + crid: 'test_creative', + }] + }] + } + }; + + const expectedResponse = [ + { + bidderCode: 'fluct', + requestId: '237f4d1a293f99', + currency: 'JPY', + cpm: 100, + netRevenue: true, + width: 300, + height: 250, + creativeId: 'test_creative', + ttl: 300, + ad: '' + callBeaconSnippet, + } + ]; + + const result = spec.interpretResponse(serverResponse, bidRequest); + expect(result).to.have.lengthOf(1); + expect(result).to.deep.have.same.members(expectedResponse); + }); + + it('should get correct bid response with dealId', function() { + const bidRequest = { + bidder: 'fluct', + params: { + dfpUnitCode: '/10000/unit_code', + tagid: '10000:100000001', + groupId: '1000000002' + }, + adUnitCode: '/10000/unit_code', + sizes: [[300, 250], [336, 280]], + bidId: '237f4d1a293f99', + bidderRequestId: '1a857fa34c1c96', + auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', + transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', + }; + + const serverResponse = { + body: { + id: '237f4d1a293f99', + cur: 'JPY', + seatbid: [{ + bid: [{ + price: 100, + w: 300, + h: 250, + adm: '', + burl: 'https://i.adingo.jp/?test=1&et=hb&bidid=237f4d1a293f99', + crid: 'test_creative', + dealid: 'test_deal', + }] + }] + } + }; + + const expectedResponse = [ + { + bidderCode: 'fluct', + requestId: '237f4d1a293f99', + currency: 'JPY', + cpm: 100, + netRevenue: true, + width: 300, + height: 250, + creativeId: 'test_creative', + ttl: 300, + ad: '' + callBeaconSnippet, + dealId: 'test_deal', + } + ]; + + const result = spec.interpretResponse(serverResponse, bidRequest); + expect(result).to.have.lengthOf(1); + expect(result).to.deep.have.same.members(expectedResponse); + }); + + it('should get empty response when bid server returns 204', function() { + expect(spec.interpretResponse({})).to.be.empty; + }); + }); +}); diff --git a/test/spec/modules/freeWheelAdserverVideo_spec.js b/test/spec/modules/freeWheelAdserverVideo_spec.js index f958a2733db..172909f99ca 100644 --- a/test/spec/modules/freeWheelAdserverVideo_spec.js +++ b/test/spec/modules/freeWheelAdserverVideo_spec.js @@ -1,13 +1,12 @@ import { expect } from 'chai'; -import { adpodUtils } from 'modules/freeWheelAdserverVideo'; -import { auctionManager } from 'src/auctionManager'; -import { config } from 'src/config'; +import { adpodUtils } from 'modules/freeWheelAdserverVideo.js'; +import { auctionManager } from 'src/auctionManager.js'; +import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr.js'; describe('freeWheel adserver module', function() { let amStub; let amGetAdUnitsStub; - let xhr; - let requests; before(function () { let adUnits = [{ @@ -56,10 +55,6 @@ describe('freeWheel adserver module', function() { }); beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - config.setConfig({ adpod: { brandCategoryExclusion: false, @@ -70,7 +65,6 @@ describe('freeWheel adserver module', function() { afterEach(function() { config.resetConfig(); - xhr.restore(); }); after(function () { @@ -188,7 +182,7 @@ describe('freeWheel adserver module', function() { } }); - requests[0].respond( + server.requests[0].respond( 200, { 'Content-Type': 'text/plain' }, JSON.stringify({'responses': getBidsReceived().slice(0, 4)}) @@ -197,6 +191,96 @@ describe('freeWheel adserver module', function() { expect(targeting['preroll_1'].length).to.equal(3); expect(targeting['midroll_1'].length).to.equal(3); }); + + it('should prioritize bids with deal', function() { + config.setConfig({ + adpod: { + deferCaching: true, + prioritizeDeals: true + } + }); + + let tier6Bid = createBid(10, 'preroll_1', 15, 'tier6_395_15s', '123', '395'); + tier6Bid['video']['dealTier'] = 'tier6' + + let tier7Bid = createBid(11, 'preroll_1', 45, 'tier7_395_15s', '123', '395'); + tier7Bid['video']['dealTier'] = 'tier7' + + let bidsReceived = [ + tier6Bid, + tier7Bid, + createBid(15, 'preroll_1', 90, '15.00_395_90s', '123', '395'), + ] + amStub.returns(bidsReceived); + let targeting; + adpodUtils.getTargeting({ + callback: function(errorMsg, targetingResult) { + targeting = targetingResult; + } + }); + + server.requests[0].respond( + 200, + { 'Content-Type': 'text/plain' }, + JSON.stringify({'responses': bidsReceived.slice(1)}) + ); + + expect(targeting['preroll_1'].length).to.equal(3); + expect(targeting['preroll_1']).to.deep.include({'hb_pb_cat_dur': 'tier6_395_15s'}); + expect(targeting['preroll_1']).to.deep.include({'hb_pb_cat_dur': 'tier7_395_15s'}); + expect(targeting['preroll_1']).to.deep.include({'hb_cache_id': '123'}); + }); + + it('should apply minDealTier to bids if configured', function() { + config.setConfig({ + adpod: { + deferCaching: true, + prioritizeDeals: true, + dealTier: { + 'appnexus': { + prefix: 'tier', + minDealTier: 5 + } + } + } + }); + + let tier2Bid = createBid(10, 'preroll_1', 15, 'tier2_395_15s', '123', '395'); + tier2Bid['video']['dealTier'] = 2 + tier2Bid['adserverTargeting']['hb_pb'] = '10.00' + + let tier7Bid = createBid(11, 'preroll_1', 45, 'tier7_395_15s', '123', '395'); + tier7Bid['video']['dealTier'] = 7 + tier7Bid['adserverTargeting']['hb_pb'] = '11.00' + + let bid = createBid(15, 'preroll_1', 15, '15.00_395_90s', '123', '395'); + bid['adserverTargeting']['hb_pb'] = '15.00' + + let bidsReceived = [ + tier2Bid, + tier7Bid, + bid + ] + amStub.returns(bidsReceived); + let targeting; + adpodUtils.getTargeting({ + callback: function(errorMsg, targetingResult) { + targeting = targetingResult; + } + }); + + server.requests[0].respond( + 200, + { 'Content-Type': 'text/plain' }, + JSON.stringify({'responses': [tier7Bid, bid]}) + ); + + expect(targeting['preroll_1'].length).to.equal(3); + expect(targeting['preroll_1']).to.deep.include({'hb_pb_cat_dur': 'tier7_395_15s'}); + expect(targeting['preroll_1']).to.deep.include({'hb_pb_cat_dur': '15.00_395_90s'}); + expect(targeting['preroll_1']).to.not.include({'hb_pb_cat_dur': 'tier2_395_15s'}); + expect(targeting['preroll_1']).to.deep.include({'hb_cache_id': '123'}); + }) }); function getBidsReceived() { diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js index 45754d0250c..4b80cce8017 100644 --- a/test/spec/modules/freewheel-sspBidAdapter_spec.js +++ b/test/spec/modules/freewheel-sspBidAdapter_spec.js @@ -1,239 +1,498 @@ -import { expect } from 'chai'; -import { spec } from 'modules/freewheel-sspBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const ENDPOINT = '//ads.stickyadstv.com/www/delivery/swfIndex.php'; - -describe('freewheel-ssp BidAdapter Test', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - wrong: 'missing zone id' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225', - 'gdpr_consented_providers': '123,345', - 'vastUrlParams': {'ownerId': 'kombRJ'} - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'gdprConsent': { - 'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', - 'gdprApplies': true - } - } - ]; - - it('should add parameters to the tag', function () { - const request = spec.buildRequests(bidRequests, bidRequests[0]); - const payload = request.data; - expect(payload.reqType).to.equal('AdsSetup'); - expect(payload.protocolVersion).to.equal('2.0'); - expect(payload.zoneId).to.equal('277225'); - expect(payload.componentId).to.equal('mustang'); - expect(payload.ownerId).to.equal('kombRJ'); - expect(payload.playerSize).to.equal('300x600'); - expect(payload._fw_gdpr).to.equal(true); - expect(payload._fw_gdpr_consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); - expect(payload._fw_gdpr_consented_providers).to.equal('123,345'); - }); - - it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests, bidRequests[0]); - expect(request.url).to.contain(ENDPOINT); - expect(request.method).to.equal('GET'); - }); - }); - - describe('interpretResponse - formated', function () { - let intextBidRequests = [ - { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225', - 'format': 'intext-roll' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[600, 250], [300, 600]], - 'bidId': '30b3other1c1838de1e', - 'bidderRequestId': '22edbae273other3bf6', - 'auctionId': '1d1a03079test0a475', - }, - { - 'bidder': 'stickyadstv', - 'params': { - 'zoneId': '277225', - 'format': 'test' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 600]], - 'bidId': '2', - 'bidderRequestId': '3', - 'auctionId': '4', - } - ]; - - let expandBidRequests = [ - { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225', - 'format': 'expand-banner', - 'vastUrlParams': {'ownerId': 'kombRJ'} - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[600, 250], [300, 600]], - 'bidId': '30b3other1c1838de1e', - 'bidderRequestId': '22edbae273other3bf6', - 'auctionId': '1d1a03079test0a475', - } - ]; - - let bannerBidRequests = [ - { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[600, 250], [300, 600]], - 'bidId': '30b3other1c1838de1e', - 'bidderRequestId': '22edbae273other3bf6', - 'auctionId': '1d1a03079test0a475', - } - ]; - - let response = '' + - '' + - ' ' + - ' Adswizz' + - ' ' + - ' ' + - ' ' + - ' 00:00:09' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' 0.2000' + - ' ' + - ' ' + - ' ' + - ''; - - let ad = '
'; - let intextAd = '
'; - let expandAd = '
'; - - it('should get correct intext bid response', function () { - var request = spec.buildRequests(bannerBidRequests, bannerBidRequests[0]); - - let expectedResponse = [ - { - requestId: '30b31c1838de1e', - cpm: '0.2000', - width: 300, - height: 600, - creativeId: '28517153', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: ad - } - ]; - - let result = spec.interpretResponse(response, request); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('should get correct expand bid response', function () { - var request = spec.buildRequests(expandBidRequests, expandBidRequests[0]); - - let expectedResponse = [ - { - requestId: '30b31c1838de1e', - cpm: '0.2000', - width: 300, - height: 600, - creativeId: '28517153', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: expandAd - } - ]; - - let result = spec.interpretResponse(response, request); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('should get correct bid response with formated ad', function () { - var request = spec.buildRequests(intextBidRequests, intextBidRequests[0]); - - let expectedResponse = [ - { - requestId: '30b31c1838de1e', - cpm: '0.2000', - width: 300, - height: 600, - creativeId: '28517153', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: intextAd - } - ]; - - let result = spec.interpretResponse(response, request); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - var reqest = spec.buildRequests(intextBidRequests, intextBidRequests[0]); - let response = ''; - - let result = spec.interpretResponse(response, reqest); - expect(result.length).to.equal(0); - }); - }); -}); +import { expect } from 'chai'; +import { spec } from 'modules/freewheel-sspBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +const ENDPOINT = '//ads.stickyadstv.com/www/delivery/swfIndex.php'; + +describe('freewheelSSP BidAdapter Test', () => { + const adapter = newBidder(spec); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValidForBanner', () => { + let bid = { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', () => { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + wrong: 'missing zone id' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('isBidRequestValidForVideo', () => { + let bid = { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 250], + } + }, + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', () => { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + wrong: 'missing zone id' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequestsForBanner', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should add parameters to the tag', () => { + const request = spec.buildRequests(bidRequests); + const payload = request[0].data; + expect(payload.reqType).to.equal('AdsSetup'); + expect(payload.protocolVersion).to.equal('2.0'); + expect(payload.zoneId).to.equal('277225'); + expect(payload.componentId).to.equal('mustang'); + expect(payload.playerSize).to.equal('300x600'); + }); + + it('sends bid request to ENDPOINT via GET', () => { + const request = spec.buildRequests(bidRequests); + expect(request[0].url).to.contain(ENDPOINT); + expect(request[0].method).to.equal('GET'); + }); + + it('should add usp consent to the request', () => { + let uspConsentString = '1FW-SSP-uspConsent-'; + let bidderRequest = {}; + bidderRequest.uspConsent = uspConsentString; + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request[0].data; + expect(payload.reqType).to.equal('AdsSetup'); + expect(payload.protocolVersion).to.equal('2.0'); + expect(payload.zoneId).to.equal('277225'); + expect(payload.componentId).to.equal('mustang'); + expect(payload.playerSize).to.equal('300x600'); + expect(payload._fw_us_privacy).to.exist.and.to.be.a('string'); + expect(payload._fw_us_privacy).to.equal(uspConsentString); + }); + + it('should add gdpr consent to the request', () => { + let gdprConsentString = '1FW-SSP-gdprConsent-'; + let bidderRequest = { + 'gdprConsent': { + 'consentString': gdprConsentString + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request[0].data; + expect(payload.reqType).to.equal('AdsSetup'); + expect(payload.protocolVersion).to.equal('2.0'); + expect(payload.zoneId).to.equal('277225'); + expect(payload.componentId).to.equal('mustang'); + expect(payload.playerSize).to.equal('300x600'); + expect(payload._fw_gdpr_consent).to.exist.and.to.be.a('string'); + expect(payload._fw_gdpr_consent).to.equal(gdprConsentString); + }); + }) + + describe('buildRequestsForVideo', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should add parameters to the tag', () => { + const request = spec.buildRequests(bidRequests); + const payload = request[0].data; + expect(payload.reqType).to.equal('AdsSetup'); + expect(payload.protocolVersion).to.equal('2.0'); + expect(payload.zoneId).to.equal('277225'); + expect(payload.componentId).to.equal('mustang'); + expect(payload.playerSize).to.equal('300x600'); + }); + + it('sends bid request to ENDPOINT via GET', () => { + const request = spec.buildRequests(bidRequests); + expect(request[0].url).to.contain(ENDPOINT); + expect(request[0].method).to.equal('GET'); + }); + + it('should add usp consent to the request', () => { + let uspConsentString = '1FW-SSP-uspConsent-'; + let bidderRequest = {}; + bidderRequest.uspConsent = uspConsentString; + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request[0].data; + expect(payload.reqType).to.equal('AdsSetup'); + expect(payload.protocolVersion).to.equal('2.0'); + expect(payload.zoneId).to.equal('277225'); + expect(payload.componentId).to.equal('mustang'); + expect(payload.playerSize).to.equal('300x600'); + expect(payload._fw_us_privacy).to.exist.and.to.be.a('string'); + expect(payload._fw_us_privacy).to.equal(uspConsentString); + }); + + it('should add gdpr consent to the request', () => { + let gdprConsentString = '1FW-SSP-gdprConsent-'; + let bidderRequest = { + 'gdprConsent': { + 'consentString': gdprConsentString + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request[0].data; + expect(payload.reqType).to.equal('AdsSetup'); + expect(payload.protocolVersion).to.equal('2.0'); + expect(payload.zoneId).to.equal('277225'); + expect(payload.componentId).to.equal('mustang'); + expect(payload.playerSize).to.equal('300x600'); + expect(payload._fw_gdpr_consent).to.exist.and.to.be.a('string'); + expect(payload._fw_gdpr_consent).to.equal(gdprConsentString); + }); + }) + + describe('interpretResponseForBanner', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + let formattedBidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225', + 'format': 'floorad' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'sizes': [[600, 250], [300, 600]], + 'bidId': '30b3other1c1838de1e', + 'bidderRequestId': '22edbae273other3bf6', + 'auctionId': '1d1a03079test0a475', + }, + { + 'bidder': 'stickyadstv', + 'params': { + 'zoneId': '277225', + 'format': 'test' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 600] + ] + } + }, + 'sizes': [[300, 600]], + 'bidId': '2', + 'bidderRequestId': '3', + 'auctionId': '4', + } + ]; + + let response = '' + + '' + + ' ' + + ' Adswizz' + + ' ' + + ' ' + + ' ' + + ' 00:00:09' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0.2000' + + ' ' + + ' ' + + ' ' + + ''; + + let ad = '
'; + let formattedAd = '
'; + + it('should get correct bid response', () => { + var request = spec.buildRequests(bidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + ad: ad + } + ]; + + let result = spec.interpretResponse(response, request[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('should get correct bid response with formated ad', () => { + var request = spec.buildRequests(formattedBidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + ad: formattedAd + } + ]; + + let result = spec.interpretResponse(response, request[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('handles nobid responses', () => { + var request = spec.buildRequests(formattedBidRequests); + let response = ''; + + let result = spec.interpretResponse(response, request[0]); + expect(result.length).to.equal(0); + }); + }); + describe('interpretResponseForVideo', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 400]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + let formattedBidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225', + 'format': 'floorad' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 400]], + 'bidId': '30b3other1c1838de1e', + 'bidderRequestId': '22edbae273other3bf6', + 'auctionId': '1d1a03079test0a475', + }, + { + 'bidder': 'stickyadstv', + 'params': { + 'zoneId': '277225', + 'format': 'test' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 400]], + 'bidId': '2', + 'bidderRequestId': '3', + 'auctionId': '4', + } + ]; + + let response = '' + + '' + + ' ' + + ' Adswizz' + + ' ' + + ' ' + + ' ' + + ' 00:00:09' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0.2000' + + ' ' + + ' ' + + ' ' + + ''; + + let ad = '
'; + let formattedAd = '
'; + + it('should get correct bid response', () => { + var request = spec.buildRequests(bidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + vastXml: response, + mediaType: 'video', + ad: ad + } + ]; + + let result = spec.interpretResponse(response, request[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('should get correct bid response with formated ad', () => { + var request = spec.buildRequests(formattedBidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + vastXml: response, + mediaType: 'video', + ad: formattedAd + } + ]; + + let result = spec.interpretResponse(response, request[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('handles nobid responses', () => { + var request = spec.buildRequests(formattedBidRequests); + let response = ''; + + let result = spec.interpretResponse(response, request[0]); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/fyberBidAdapter_spec.js b/test/spec/modules/fyberBidAdapter_spec.js deleted file mode 100644 index a16c069d2a0..00000000000 --- a/test/spec/modules/fyberBidAdapter_spec.js +++ /dev/null @@ -1,154 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/fyberBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import bidRequest from '../../fixtures/video/bidRequest.json'; - -const bidId = '21b2499bf34cf8'; -const mock = { - bid: { - bidder: 'fyber', - params: { - appId: 'MyCompany_MyApp', - spotType: 'rectangle', - gdprPrivacyConsent: true, - qa: { - // url: 'http://ia-test08.inner-active.mobi:8080/simpleM2M/requestJsonAd', - cpm: 10 - }, - customParams: { - // referrer: 'referrer', - // page: 'aaaa', - portal: 7002 - // KEYWORDS: 'bbb' - } - } - }, - bidsRequest: [ - { - adUnitCode: '/19968336/header-bid-tag-1', - auctionId: 'f270d8dd-29c6-4aca-8648-7d722590b899', - bidId, - bidder: 'fyber', - bidderRequestId: '1bcd667e09f48e', - params: { - spotType: 'rectangle', - gdprPrivacyConsent: true, - qa: {cpm: 10}, - customParams: {portal: 7002}, - appId: 'MyCompany_MyApp' - }, - sizes: [[300, 250], [300, 600]], - transactionId: 'a0253346-df4e-4f1a-b004-1f50e8e6af69' - } - ], - validResponse: { - body: { - ad: { - html: '

Fyber Ad

' - }, - config: { - tracking: { - clicks: ['c1'], - impressions: ['i1'] - } - } - }, - headers: { - get(headerName) { - if (headerName === 'X-IA-Pricing-Value') { - return 10; - } - return headerName; - } - } - }, - invalidResponse: { - body: {}, - headers: { - get(headerName) { - return headerName; - } - } - } -}; - -describe('FyberAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('callBids exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('Verifies bidder code', function () { - it('Verifies bidder code', function () { - expect(spec.code).to.equal('fyber'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - const bid = Object.assign({}, mock.bid); - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params{spotType} not found', function () { - const bid = Object.assign({}, mock.bid); - delete bid.params.spotType; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when required{appId} params not found', function () { - const bid = Object.assign({}, mock.bid); - delete bid.params.appId; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidsRequest = Object.assign([], mock.bidsRequest); - const requests = spec.buildRequests(bidsRequest); - - it('Verify only one build request', function () { - expect(requests.length).to.equal(1); - }); - - const request = requests[0]; - - it('Verify build request http method', function () { - expect(request.method).to.equal('GET'); - }); - - it('Verify build request bidId', function () { - expect(request.bidId).to.equal(bidId); - }); - }); - - describe('interpretResponse', function () { - const request = Object.assign([], mock.bidsRequest)[0]; - const validResponse = Object.assign({}, mock.validResponse); - const validResult = spec.interpretResponse(validResponse, request); - - it('Verify only one bid response', function () { - expect(validResult.length).to.equal(1); - }); - - const bidResponse = validResult[0]; - - it('Verify CPM', function () { - expect(bidResponse.cpm).to.equal(10000); - }); - - it('Verify requestId', function () { - expect(bidResponse.requestId).to.equal(bidId); - }); - - const invalidResponse = Object.assign({}, mock.invalidResponse); - const invalidResult = spec.interpretResponse(invalidResponse, request); - - it('Verify empty bid response', function () { - expect(invalidResult.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js index 99593e6e06f..cdaa1b5448a 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -1,7 +1,6 @@ -import * as utils from 'src/utils'; import { expect } from 'chai'; -import { spec } from 'modules/gammaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/gammaBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('gammaBidAdapter', function() { const adapter = newBidder(spec); @@ -22,26 +21,26 @@ describe('gammaBidAdapter', function() { }; let bidArray = [bid]; - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { + describe('isBidRequestValid', () => { + it('should return true when required params found', () => { expect(spec.isBidRequestValid(bid)).to.equal(true); }); - it('should return false when require params are not passed', function () { + it('should return false when require params are not passed', () => { let bid = Object.assign({}, bid); bid.params = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false when params not passed correctly', function () { + it('should return false when params not passed correctly', () => { bid.params.siteId = ''; bid.params.zoneId = ''; expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); - describe('buildRequests', function () { - it('should attempt to send bid requests to the endpoint via GET', function () { + describe('buildRequests', () => { + it('should attempt to send bid requests to the endpoint via GET', () => { const requests = spec.buildRequests(bidArray); requests.forEach(function(requestItem) { expect(requestItem.method).to.equal('GET'); @@ -50,10 +49,10 @@ describe('gammaBidAdapter', function() { }); }); - describe('interpretResponse', function () { + describe('interpretResponse', () => { let serverResponse; - beforeEach(function () { + beforeEach(() => { serverResponse = { body: { 'id': '23beaa6af6cdde', @@ -77,7 +76,7 @@ describe('gammaBidAdapter', function() { }; }) - it('should get the correct bid response', function () { + it('should get the correct bid response', () => { let expectedResponse = [{ 'requestId': '23beaa6af6cdde', 'cpm': 0.45, @@ -94,7 +93,7 @@ describe('gammaBidAdapter', function() { expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); }); - it('handles empty bid response', function () { + it('handles empty bid response', () => { let response = { body: {} }; diff --git a/test/spec/modules/gamoshiBidAdapter_spec.js b/test/spec/modules/gamoshiBidAdapter_spec.js index a2c4eebc213..79f58470cb3 100644 --- a/test/spec/modules/gamoshiBidAdapter_spec.js +++ b/test/spec/modules/gamoshiBidAdapter_spec.js @@ -1,41 +1,231 @@ import {expect} from 'chai'; -import {spec} from 'modules/gamoshiBidAdapter'; -import {helper} from 'modules/gamoshiBidAdapter'; -import * as utils from 'src/utils'; -import {newBidder} from '../../../src/adapters/bidderFactory'; -import {deepClone} from 'src/utils'; +import {spec, helper} from 'modules/gamoshiBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {newBidder} from '../../../src/adapters/bidderFactory.js'; const supplyPartnerId = '123'; const adapter = newBidder(spec); -describe('GamoshiAdapter', function () { - describe('Get top Frame', function () { - it('check if you are in the top frame', function () { +const TTL = 360; + +describe('GamoshiAdapter', () => { + let schainConfig, + bidRequest, + bannerBidRequest, + videoBidRequest, + rtbResponse, + videoResponse, + gdprConsent; + + beforeEach(() => { + schainConfig = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + + bidRequest = { + 'adUnitCode': 'adunit-code', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + banner: {} + }, + 'params': { + 'supplyPartnerId': supplyPartnerId + }, + 'sizes': [[300, 250], [300, 600]], + 'transactionId': 'a123456789', + refererInfo: {referer: 'http://examplereferer.com'}, + gdprConsent: { + consentString: 'some string', + gdprApplies: true + }, + schain: schainConfig, + uspConsent: 'gamoshiCCPA' + }; + + bannerBidRequest = { + 'adUnitCode': 'adunit-code', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + banner: {} + }, + 'params': { + 'supplyPartnerId': supplyPartnerId + }, + 'sizes': [[300, 250], [300, 600]], + 'transactionId': 'a123456789', + 'bidId': '111', + refererInfo: {referer: 'http://examplereferer.com'} + }; + + videoBidRequest = { + 'adUnitCode': 'adunit-code', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + video: {} + }, + 'params': { + 'supplyPartnerId': supplyPartnerId + }, + 'sizes': [[300, 250], [300, 600]], + 'transactionId': 'a123456789', + 'bidId': '111', + refererInfo: {referer: 'http://examplereferer.com'} + }; + + rtbResponse = { + 'id': 'imp_5b05b9fde4b09084267a556f', + 'bidid': 'imp_5b05b9fde4b09084267a556f', + 'cur': 'USD', + 'ext': { + 'utrk': [ + {'type': 'iframe', 'url': '//rtb.gamoshi.io/user/sync/1?gdpr=[GDPR]&consent=[CONSENT]&usp=[US_PRIVACY]'}, + {'type': 'image', 'url': '//rtb.gamoshi.io/user/sync/2'} + ] + }, + 'seatbid': [ + { + 'seat': 'seat1', + 'group': 0, + 'bid': [ + { + 'id': '0', + 'impid': '1', + 'price': 2.016, + 'adid': '579ef31bfa788b9d2000d562', + 'nurl': 'https://rtb.gamoshi.io/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', + 'adm': '', + 'adomain': ['aaa.com'], + 'cid': '579ef268fa788b9d2000d55c', + 'crid': '579ef31bfa788b9d2000d562', + 'attr': [], + 'h': 600, + 'w': 120, + 'ext': { + 'vast_url': 'http://my.vast.com', + 'utrk': [ + {'type': 'iframe', 'url': '//p.partner1.io/user/sync/1'} + ] + } + } + ] + }, + { + 'seat': 'seat2', + 'group': 0, + 'bid': [ + { + 'id': '1', + 'impid': '1', + 'price': 3, + 'adid': '542jlhdfd2112jnjf3x', + 'nurl': 'https://rtb.gamoshi.io/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', + 'adm': ' ', + 'adomain': ['bbb.com'], + 'cid': 'fgdlwjh2498ydjhg1', + 'crid': 'kjh34297ydh2133d', + 'attr': [], + 'h': 250, + 'w': 300, + 'ext': { + 'utrk': [ + {'type': 'image', 'url': '//p.partner2.io/user/sync/1'} + ] + } + } + ] + } + ] + }; + + videoResponse = { + 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', + 'bidid': 'imp_5c24924de4b0d106447af333', + 'cur': 'USD', + 'seatbid': [ + { + 'seat': '3668', + 'group': 0, + 'bid': [ + { + 'id': 'gb_1', + 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', + 'price': 5.0, + 'adid': '1274', + 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1', + 'adomain': [], + 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', + 'cid': '3668', + 'crid': '1274', + 'cat': [], + 'attr': [], + 'h': 250, + 'w': 300, + 'ext': { + 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', + 'imptrackers': [ + 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] + } + } + ] + } + ], + 'ext': { + 'utrk': [{ + 'type': 'image', + 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gdpr=[GDPR]&consent=[CONSENT]&us_privacy=[US_PRIVACY]' + }] + } + }; + + gdprConsent = { + gdprApplies: true, + consentString: 'consent string' + }; + }); + + describe('Get top Frame', () => { + it('check if you are in the top frame', () => { expect(helper.getTopFrame()).to.equal(0); }); - it('verify domain parsing', function () { + + it('verify domain parsing', () => { expect(helper.getTopWindowDomain('http://www.domain.com')).to.equal('www.domain.com'); }); }); - describe('Is String start with search ', function () { - it('check if a string started with', function () { + + describe('Is String start with search', () => { + it('check if a string started with', () => { expect(helper.startsWith('gamoshi.com', 'gamo')).to.equal(true); }); }); - describe('inherited functions', function () { - it('exists and is a function', function () { + describe('inherited functions', () => { + it('exists and is a function', () => { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); }); - describe('isBidRequestValid', function () { - it('should validate supply-partner ID', function () { + describe('isBidRequestValid', () => { + it('should validate supply-partner ID', () => { expect(spec.isBidRequestValid({params: {}})).to.equal(false); expect(spec.isBidRequestValid({params: {supplyPartnerId: 123}})).to.equal(false); expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); }); - it('should validate RTB endpoint', function () { + it('should validate RTB endpoint', () => { expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // RTB endpoint has a default expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', rtbEndpoint: 123}})).to.equal(false); expect(spec.isBidRequestValid({ @@ -46,19 +236,19 @@ describe('GamoshiAdapter', function () { })).to.equal(true); }); - it('should validate bid floor', function () { + it('should validate bid floor', () => { expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // bidfloor has a default expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', bidfloor: '123'}})).to.equal(false); expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', bidfloor: 0.1}})).to.equal(true); }); - it('should validate adpos', function () { + it('should validate adpos', () => { expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // adpos has a default expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', adpos: '123'}})).to.equal(false); expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', adpos: 0.1}})).to.equal(true); }); - it('should validate instl', function () { + it('should validate instl', () => { expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // adpos has a default expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: '123'}})).to.equal(false); expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: -1}})).to.equal(false); @@ -68,25 +258,8 @@ describe('GamoshiAdapter', function () { }); }); - describe('buildRequests', function () { - const bidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - banner: {} - }, - 'params': { - 'supplyPartnerId': supplyPartnerId - }, - 'sizes': [[300, 250], [300, 600]], - 'transactionId': 'a123456789', - refererInfo: {referer: 'http://examplereferer.com'}, - gdprConsent: { - consentString: 'some string', - gdprApplies: true - } - }; - it('returns an array', function () { + describe('buildRequests', () => { + it('returns an array', () => { let response; response = spec.buildRequests([]); expect(Array.isArray(response)).to.equal(true); @@ -101,7 +274,7 @@ describe('GamoshiAdapter', function () { expect(response.length).to.equal(2); }); - it('targets correct endpoint', function () { + it('targets correct endpoint', () => { let response; response = spec.buildRequests([bidRequest], bidRequest)[0]; expect(response.method).to.equal('POST'); @@ -113,11 +286,11 @@ describe('GamoshiAdapter', function () { expect(response.url).to.match(new RegExp(`^https://rtb2\\.gamoshi\\.io/a12/r/${supplyPartnerId}/bidr\\?rformat=open_rtb&reqformat=rtb_json&bidder=prebid$`, 'g')); }); - it('builds request correctly', function () { - let stub = sinon.stub(utils, 'getTopWindowUrl').returns('http://www.test.com/page.html'); - let bidRequest2 = deepClone(bidRequest); + it('builds request correctly', () => { + let bidRequest2 = utils.deepClone(bidRequest); bidRequest2.refererInfo.referer = 'http://www.test.com/page.html'; let response = spec.buildRequests([bidRequest], bidRequest2)[0]; + expect(response.data.site.domain).to.equal('www.test.com'); expect(response.data.site.page).to.equal('http://www.test.com/page.html'); expect(response.data.site.ref).to.equal('http://www.test.com/page.html'); @@ -127,6 +300,9 @@ describe('GamoshiAdapter', function () { expect(response.data.imp[0].tagid).to.equal(bidRequest.adUnitCode); expect(response.data.imp[0].bidfloor).to.equal(0); expect(response.data.imp[0].bidfloorcur).to.equal('USD'); + expect(response.data.regs.ext.us_privacy).to.equal('gamoshiCCPA');// USP/CCPAs + expect(response.data.source.ext.schain).to.deep.equal(bidRequest2.schain); + const bidRequestWithInstlEquals1 = utils.deepClone(bidRequest); bidRequestWithInstlEquals1.params.instl = 1; response = spec.buildRequests([bidRequestWithInstlEquals1], bidRequest2)[0]; @@ -139,10 +315,9 @@ describe('GamoshiAdapter', function () { bidRequestWithBidfloorEquals1.params.bidfloor = 1; response = spec.buildRequests([bidRequestWithBidfloorEquals1], bidRequest2)[0]; expect(response.data.imp[0].bidfloor).to.equal(bidRequestWithBidfloorEquals1.params.bidfloor); - stub.restore(); }); - it('builds request banner object correctly', function () { + it('builds request banner object correctly', () => { let response; const bidRequestWithBanner = utils.deepClone(bidRequest); bidRequestWithBanner.mediaTypes = { @@ -161,33 +336,41 @@ describe('GamoshiAdapter', function () { expect(response.data.imp[0].banner.pos).to.equal(bidRequestWithPosEquals1.params.pos); }); - it('builds request video object correctly', function () { + it('builds request video object correctly', () => { let response; const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes = { video: { - playerSize: [302, 252] + playerSize: [[302, 252]] } }; response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0][0]); expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0][1]); expect(response.data.imp[0].video.pos).to.equal(0); + bidRequestWithVideo.mediaTypes = { + video: { + playerSize: [302, 252] + } + }; + const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); + expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0]); + expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[1]); + bidRequestWithPosEquals1.params.pos = 1; response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; expect(response.data.imp[0].video.pos).to.equal(bidRequestWithPosEquals1.params.pos); }); - it('builds request video object correctly with context', function () { - let response; + it('builds request video object correctly with context', () => { const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes = { video: { context: 'instream' } }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; expect(response.data.imp[0].video.ext.context).to.equal('instream'); bidRequestWithVideo.mediaTypes.video.context = 'outstream'; @@ -202,7 +385,7 @@ describe('GamoshiAdapter', function () { expect(response.data.imp[0].video.ext.context).to.equal(null); }); - it('builds request video object correctly with multi-dimensions size array', function () { + it('builds request video object correctly with multi-dimensions size array', () => { let response; const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes.video = { @@ -225,116 +408,54 @@ describe('GamoshiAdapter', function () { expect(response.data.imp[1].video.ext.context).to.equal(null); }); - it('builds request with gdpr consent', function () { + it('builds request with gdpr consent', () => { let response = spec.buildRequests([bidRequest], bidRequest)[0]; + + expect(response.data.ext.gdpr_consent).to.not.equal(null).and.not.equal(undefined); expect(response.data.ext).to.have.property('gdpr_consent'); expect(response.data.ext.gdpr_consent.consent_string).to.equal('some string'); expect(response.data.ext.gdpr_consent.consent_required).to.equal(true); - }); - }); - describe('interpretResponse', function () { - const bannerBidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - banner: {} - }, - 'params': { - 'supplyPartnerId': supplyPartnerId - }, - 'sizes': [[300, 250], [300, 600]], - 'transactionId': 'a123456789', - 'bidId': '111', - refererInfo: {referer: 'http://examplereferer.com'} - }; - - const videoBidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - video: {} - }, - 'params': { - 'supplyPartnerId': supplyPartnerId - }, - 'sizes': [[300, 250], [300, 600]], - 'transactionId': 'a123456789', - 'bidId': '111', - refererInfo: {referer: 'http://examplereferer.com'} - }; - - const rtbResponse = { - 'id': 'imp_5b05b9fde4b09084267a556f', - 'bidid': 'imp_5b05b9fde4b09084267a556f', - 'cur': 'USD', - 'ext': { - 'utrk': [ - {'type': 'iframe', 'url': '//rtb.gamoshi.io/user/sync/1'}, - {'type': 'image', 'url': '//rtb.gamoshi.io/user/sync/2'} - ] - }, - 'seatbid': [ - { - 'seat': 'seat1', - 'group': 0, - 'bid': [ - { - 'id': '0', - 'impid': '1', - 'price': 2.016, - 'adid': '579ef31bfa788b9d2000d562', - 'nurl': 'https://rtb.gamoshi.io/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0&p=${AUCTION_PRICE}', - 'adm': '', - 'adomain': ['aaa.com'], - 'cid': '579ef268fa788b9d2000d55c', - 'crid': '579ef31bfa788b9d2000d562', - 'attr': [], - 'h': 600, - 'w': 120, - 'ext': { - 'vast_url': 'http://my.vast.com', - 'utrk': [ - {'type': 'iframe', 'url': '//p.partner1.io/user/sync/1'} - ] - } - } - ] - }, - { - 'seat': 'seat2', - 'group': 0, - 'bid': [ - { - 'id': '1', - 'impid': '1', - 'price': 3, - 'adid': '542jlhdfd2112jnjf3x', - 'nurl': 'https://rtb.gamoshi.io/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0&p=${AUCTION_PRICE}', - 'adm': ' ', - 'adomain': ['bbb.com'], - 'cid': 'fgdlwjh2498ydjhg1', - 'crid': 'kjh34297ydh2133d', - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'utrk': [ - {'type': 'image', 'url': '//p.partner2.io/user/sync/1'} - ] - } - } - ] - } - ] - }; + expect(response.data.regs.ext.gdpr).to.not.equal(null).and.not.equal(undefined); + expect(response.data.user.ext.consent).to.equal('some string'); + }); - const TTL = 360; + it('build request with ID5 Id', () => { + const bidRequestClone = utils.deepClone(bidRequest); + bidRequestClone.userId = {}; + bidRequestClone.userId.id5id = 'id5-user-id'; + let request = spec.buildRequests([bidRequestClone], bidRequestClone)[0]; + expect(request.data.user.ext.eids).to.deep.equal([{ + 'source': 'id5-sync.com', + 'uids': [{ + 'id': 'id5-user-id', + 'ext': { + 'rtiPartner': 'ID5ID' + } + }] + }]); + }); - it('returns an empty array on missing response', function () { - let response; + it('build request with unified Id', () => { + const bidRequestClone = utils.deepClone(bidRequest); + bidRequestClone.userId = {}; + bidRequestClone.userId.tdid = 'tdid-user-id'; + let request = spec.buildRequests([bidRequestClone], bidRequestClone)[0]; + expect(request.data.user.ext.eids).to.deep.equal([{ + 'source': 'adserver.org', + 'uids': [{ + 'id': 'tdid-user-id', + 'ext': { + 'rtiPartner': 'TDID' + } + }] + }]); + }); + }); - response = spec.interpretResponse(undefined, {bidRequest: bannerBidRequest}); + describe('interpretResponse', () => { + it('returns an empty array on missing response', () => { + let response = spec.interpretResponse(undefined, {bidRequest: bannerBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(0); @@ -343,7 +464,7 @@ describe('GamoshiAdapter', function () { expect(response.length).to.equal(0); }); - it('aggregates banner bids from all seat bids', function () { + it('aggregates banner bids from all seat bids', () => { const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: bannerBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); @@ -361,7 +482,7 @@ describe('GamoshiAdapter', function () { expect(ad0.vastUrl).to.be.an('undefined'); }); - it('aggregates video bids from all seat bids', function () { + it('aggregates video bids from all seat bids', () => { const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: videoBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); @@ -379,129 +500,62 @@ describe('GamoshiAdapter', function () { expect(ad0.vastUrl).to.equal(rtbResponse.seatbid[0].bid[0].ext.vast_url); }); - it('aggregates user-sync pixels', function () { + it('aggregates user-sync pixels', () => { const response = spec.getUserSyncs({}, [{body: rtbResponse}]); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(4); expect(response[0].type).to.equal(rtbResponse.ext.utrk[0].type); - expect(response[0].url).to.equal(rtbResponse.ext.utrk[0].url + '?gc=missing'); + expect(response[0].url).to.equal('//rtb.gamoshi.io/user/sync/1?gdpr=0&consent=&usp='); expect(response[1].type).to.equal(rtbResponse.ext.utrk[1].type); - expect(response[1].url).to.equal(rtbResponse.ext.utrk[1].url + '?gc=missing'); + expect(response[1].url).to.equal('//rtb.gamoshi.io/user/sync/2'); expect(response[2].type).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].type); - expect(response[2].url).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].url + '?gc=missing'); + expect(response[2].url).to.equal('//p.partner1.io/user/sync/1'); expect(response[3].type).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].type); - expect(response[3].url).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].url + '?gc=missing'); + expect(response[3].url).to.equal('//p.partner2.io/user/sync/1'); }); - it('supports configuring outstream renderers', function () { - const videoResponse = { - 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', - 'bidid': 'imp_5c24924de4b0d106447af333', - 'cur': 'USD', - 'seatbid': [ - { - 'seat': '3668', - 'group': 0, - 'bid': [ - { - 'id': 'gb_1', - 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - 'price': 5.0, - 'adid': '1274', - 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - 'adomain': [], - 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - 'cid': '3668', - 'crid': '1274', - 'cat': [], - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - 'imptrackers': [ - 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] - } - } - ] - } - ], - 'ext': { - 'utrk': [{ - 'type': 'image', - 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675' - }] - } - }; - const videoRequest = deepClone(videoBidRequest); + it('supports configuring outstream renderers', () => { + const videoRequest = utils.deepClone(videoBidRequest); videoRequest.mediaTypes.video.context = 'outstream'; const result = spec.interpretResponse({body: videoResponse}, {bidRequest: videoRequest}); expect(result[0].renderer).to.not.equal(undefined); }); - it('validates in/existing of gdpr consent', function () { - let videoResponse = { - 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', - 'bidid': 'imp_5c24924de4b0d106447af333', - 'cur': 'USD', - 'seatbid': [ - { - 'seat': '3668', - 'group': 0, - 'bid': [ - { - 'id': 'gb_1', - 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - 'price': 5.0, - 'adid': '1274', - 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - 'adomain': [], - 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - 'cid': '3668', - 'crid': '1274', - 'cat': [], - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - 'imptrackers': [ - 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] - } - } - ] - } - ], - 'ext': { - 'utrk': [{ - 'type': 'image', - 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675' - }] - } - }; - let gdprConsent = { - gdprApplies: true, - consentString: 'consent string' - }; - let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); + it('validates in/existing of gdpr consent', () => { + let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'gamoshiCCPA'); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gc=consent%20string'); + expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gdpr=1&consent=consent%20string&us_privacy=gamoshiCCPA'); gdprConsent.gdprApplies = false; - result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); + result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'gamoshiCCPA'); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gc=missing'); + expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gdpr=0&consent=&us_privacy=gamoshiCCPA'); videoResponse.ext.utrk[0].url = 'https://rtb.gamoshi.io/pix/1275/scm'; result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?gc=missing'); + expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm'); + }); + + it('validates existence of gdpr, gdpr consent and usp consent', () => { + let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'gamoshiCCPA'); + expect(result).to.be.an('array'); + expect(result.length).to.equal(1); + expect(result[0].type).to.equal('image'); + expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gdpr=1&consent=consent%20string&us_privacy=gamoshiCCPA'); + + gdprConsent.gdprApplies = false; + result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, ''); + expect(result).to.be.an('array'); + expect(result.length).to.equal(1); + expect(result[0].type).to.equal('image'); + expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gdpr=0&consent=&us_privacy='); }); }); }); diff --git a/test/spec/modules/gdprEnforcement_spec.js b/test/spec/modules/gdprEnforcement_spec.js new file mode 100644 index 00000000000..5b46441cbbb --- /dev/null +++ b/test/spec/modules/gdprEnforcement_spec.js @@ -0,0 +1,418 @@ +import { deviceAccessHook, setEnforcementConfig, userSyncHook, userIdHook } from 'modules/gdprEnforcement.js'; +import { config } from 'src/config.js'; +import adapterManager, { gdprDataHandler } from 'src/adapterManager.js'; +import * as utils from 'src/utils.js'; +import { validateStorageEnforcement } from 'src/storageManager.js'; +import { executeStorageCallbacks } from 'src/prebid.js'; + +describe('gdpr enforcement', function() { + let nextFnSpy; + let logWarnSpy; + let gdprDataHandlerStub; + let staticConfig = { + cmpApi: 'static', + timeout: 7500, + allowAuctionWithoutConsent: false, + consentData: { + getTCData: { + 'tcString': 'COuqj-POu90rDBcBkBENAZCgAPzAAAPAACiQFwwBAABAA1ADEAbQC4YAYAAgAxAG0A', + 'cmpId': 92, + 'cmpVersion': 100, + 'tcfPolicyVersion': 2, + 'gdprApplies': true, + 'isServiceSpecific': true, + 'useNonStandardStacks': false, + 'purposeOneTreatment': false, + 'publisherCC': 'US', + 'cmpStatus': 'loaded', + 'eventStatus': 'tcloaded', + 'outOfBand': { + 'allowedVendors': {}, + 'discloseVendors': {} + }, + 'purpose': { + 'consents': { + '1': true, + '2': true, + '3': true + }, + 'legitimateInterests': { + '1': false, + '2': false, + '3': false + } + }, + 'vendor': { + 'consents': { + '1': true, + '2': true, + '3': false + }, + 'legitimateInterests': { + '1': false, + '2': true, + '3': false, + '4': false, + '5': false + } + }, + 'specialFeatureOptins': { + '1': false, + '2': false + }, + 'restrictions': {}, + 'publisher': { + 'consents': { + '1': false, + '2': false, + '3': false + }, + 'legitimateInterests': { + '1': false, + '2': false, + '3': false + }, + 'customPurpose': { + 'consents': {}, + 'legitimateInterests': {} + } + } + } + } + }; + + after(function() { + validateStorageEnforcement.getHooks({hook: deviceAccessHook}).remove(); + $$PREBID_GLOBAL$$.requestBids.getHooks({hook: executeStorageCallbacks}).remove(); + }) + + describe('deviceAccessHook', function() { + beforeEach(function() { + nextFnSpy = sinon.spy(); + gdprDataHandlerStub = sinon.stub(gdprDataHandler, 'getConsentData'); + logWarnSpy = sinon.spy(utils, 'logWarn'); + }); + afterEach(function() { + config.resetConfig(); + gdprDataHandler.getConsentData.restore(); + logWarnSpy.restore(); + }); + it('should not allow device access when device access flag is set to false', function() { + config.setConfig({ + deviceAccess: false, + consentManagement: { + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: false, + vendorExceptions: ['appnexus', 'rubicon'] + }] + } + } + }); + + deviceAccessHook(nextFnSpy); + expect(nextFnSpy.calledOnce).to.equal(true); + let result = { + hasEnforcementHook: true, + valid: false + } + expect(nextFnSpy.calledWith(undefined, result)); + }); + + it('should only check for consent for vendor exceptions when enforcePurpose and enforceVendor are false', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: false, + vendorExceptions: ['appnexus'] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.gdprApplies = true; + consentData.apiVersion = 2; + gdprDataHandlerStub.returns(consentData); + + deviceAccessHook(nextFnSpy, 1, 'appnexus'); + deviceAccessHook(nextFnSpy, 5, 'rubicon'); + expect(logWarnSpy.callCount).to.equal(0); + }); + + it('should check consent for all vendors when enforcePurpose and enforceVendor are true', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: true, + enforceVendor: true, + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.gdprApplies = true; + consentData.apiVersion = 2; + gdprDataHandlerStub.returns(consentData); + + deviceAccessHook(nextFnSpy, 1, 'appnexus'); + deviceAccessHook(nextFnSpy, 3, 'rubicon'); + expect(logWarnSpy.callCount).to.equal(1); + }); + + it('should allow device access when gdprApplies is false and hasDeviceAccess flag is true', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: true, + enforceVendor: true, + vendorExceptions: [] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.gdprApplies = false; + consentData.apiVersion = 2; + gdprDataHandlerStub.returns(consentData); + + deviceAccessHook(nextFnSpy, 1, 'appnexus'); + expect(nextFnSpy.calledOnce).to.equal(true); + let result = { + hasEnforcementHook: true, + valid: true + } + expect(nextFnSpy.calledWith(undefined, result)); + }); + }); + + describe('userSyncHook', function() { + let curBidderStub; + let adapterManagerStub; + + beforeEach(function() { + gdprDataHandlerStub = sinon.stub(gdprDataHandler, 'getConsentData'); + logWarnSpy = sinon.spy(utils, 'logWarn'); + curBidderStub = sinon.stub(config, 'getCurrentBidder'); + adapterManagerStub = sinon.stub(adapterManager, 'getBidAdapter'); + nextFnSpy = sinon.spy(); + }); + + afterEach(function() { + config.getCurrentBidder.restore(); + config.resetConfig(); + gdprDataHandler.getConsentData.restore(); + adapterManager.getBidAdapter.restore(); + logWarnSpy.restore(); + }); + + it('should allow bidder to do user sync if consent is true', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: true, + vendorExceptions: ['sampleBidder2'] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.gdprApplies = true; + consentData.apiVersion = 2; + gdprDataHandlerStub.returns(consentData); + + curBidderStub.returns('sampleBidder1'); + adapterManagerStub.withArgs('sampleBidder1').returns({ + getSpec: function() { + return { + 'gvlid': 1 + } + } + }); + userSyncHook(nextFnSpy); + + curBidderStub.returns('sampleBidder2'); + adapterManagerStub.withArgs('sampleBidder2').returns({ + getSpec: function() { + return { + 'gvlid': 3 + } + } + }); + userSyncHook(nextFnSpy); + expect(nextFnSpy.calledTwice).to.equal(true); + }); + + it('should not allow bidder to do user sync if user has denied consent', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: true, + vendorExceptions: [] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.apiVersion = 2; + consentData.gdprApplies = true; + gdprDataHandlerStub.returns(consentData); + + curBidderStub.returns('sampleBidder1'); + adapterManagerStub.withArgs('sampleBidder1').returns({ + getSpec: function() { + return { + 'gvlid': 1 + } + } + }); + userSyncHook(nextFnSpy); + + curBidderStub.returns('sampleBidder2'); + adapterManagerStub.withArgs('sampleBidder2').returns({ + getSpec: function() { + return { + 'gvlid': 3 + } + } + }); + userSyncHook(nextFnSpy); + expect(nextFnSpy.calledOnce).to.equal(true); + expect(logWarnSpy.callCount).to.equal(1); + }); + + it('should not check vendor consent when enforceVendor is false', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: true, + enforceVendor: false, + vendorExceptions: ['sampleBidder1'] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.apiVersion = 2; + consentData.gdprApplies = true; + gdprDataHandlerStub.returns(consentData); + + curBidderStub.returns('sampleBidder1'); + adapterManagerStub.withArgs('sampleBidder1').returns({ + getSpec: function() { + return { + 'gvlid': 1 + } + } + }); + userSyncHook(nextFnSpy); + + curBidderStub.returns('sampleBidder2'); + adapterManagerStub.withArgs('sampleBidder2').returns({ + getSpec: function() { + return { + 'gvlid': 3 + } + } + }); + userSyncHook(nextFnSpy); + expect(nextFnSpy.calledTwice).to.equal(true); + expect(logWarnSpy.callCount).to.equal(0); + }); + }); + + describe('userIdHook', function() { + beforeEach(function() { + logWarnSpy = sinon.spy(utils, 'logWarn'); + nextFnSpy = sinon.spy(); + }); + afterEach(function() { + config.resetConfig(); + logWarnSpy.restore(); + }); + it('should allow user id module if consent is given', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: true, + vendorExceptions: [] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.apiVersion = 2; + consentData.gdprApplies = true; + let submodules = [{ + submodule: { + gvlid: 1, + name: 'sampleUserId' + } + }] + userIdHook(nextFnSpy, submodules, consentData); + expect(nextFnSpy.calledOnce).to.equal(true); + }); + + it('should allow userId module if gdpr not in scope', function() { + let submodules = [{ + submodule: { + gvlid: 1, + name: 'sampleUserId' + } + }]; + let consentData = null; + userIdHook(nextFnSpy, submodules, consentData); + expect(nextFnSpy.calledOnce).to.equal(true); + expect(nextFnSpy.calledWith(undefined, submodules, consentData)); + }); + + it('should not allow user id module if user denied consent', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: true, + vendorExceptions: [] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.apiVersion = 2; + consentData.gdprApplies = true; + let submodules = [{ + submodule: { + gvlid: 1, + name: 'sampleUserId' + } + }, { + submodule: { + gvlid: 3, + name: 'sampleUserId1' + } + }] + userIdHook(nextFnSpy, submodules, consentData); + expect(logWarnSpy.callCount).to.equal(1); + let expectedSubmodules = [{ + submodule: { + gvlid: 1, + name: 'sampleUserId' + } + }] + expect(nextFnSpy.calledWith(undefined, expectedSubmodules, consentData)); + }); + }); +}); diff --git a/test/spec/modules/getintentBidAdapter_spec.js b/test/spec/modules/getintentBidAdapter_spec.js index ebbda7e108e..1959bda5c39 100644 --- a/test/spec/modules/getintentBidAdapter_spec.js +++ b/test/spec/modules/getintentBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { spec } from 'modules/getintentBidAdapter' +import { spec } from 'modules/getintentBidAdapter.js' describe('GetIntent Adapter Tests:', function () { const bidRequests = [{ @@ -37,7 +37,7 @@ describe('GetIntent Adapter Tests:', function () { it('Verify build request', function () { const serverRequests = spec.buildRequests(bidRequests); let serverRequest = serverRequests[0]; - expect(serverRequest.url).to.equal('//px.adhigh.net/rtb/direct_banner'); + expect(serverRequest.url).to.equal('https://px.adhigh.net/rtb/direct_banner'); expect(serverRequest.method).to.equal('GET'); expect(serverRequest.data.bid_id).to.equal('bid12345'); expect(serverRequest.data.pid).to.equal('p1000'); @@ -51,7 +51,7 @@ describe('GetIntent Adapter Tests:', function () { it('Verify build video request', function () { const serverRequests = spec.buildRequests([videoBidRequest]); let serverRequest = serverRequests[0]; - expect(serverRequest.url).to.equal('//px.adhigh.net/rtb/direct_vast'); + expect(serverRequest.url).to.equal('https://px.adhigh.net/rtb/direct_vast'); expect(serverRequest.method).to.equal('GET'); expect(serverRequest.data.bid_id).to.equal('bid789'); expect(serverRequest.data.pid).to.equal('p1001'); @@ -98,7 +98,7 @@ describe('GetIntent Adapter Tests:', function () { currency: 'USD', size: '300x250', creative_id: '2000', - vast_url: '//vast.xml/url' + vast_url: 'https://vast.xml/url' }, headers: { } @@ -113,7 +113,7 @@ describe('GetIntent Adapter Tests:', function () { expect(bid.height).to.equal(250); expect(bid.requestId).to.equal('bid789'); expect(bid.mediaType).to.equal('video'); - expect(bid.vastUrl).to.equal('//vast.xml/url'); + expect(bid.vastUrl).to.equal('https://vast.xml/url'); }); it('Verify bidder code', function () { diff --git a/test/spec/modules/giantsBidAdapter_spec.js b/test/spec/modules/giantsBidAdapter_spec.js deleted file mode 100644 index bab2415745d..00000000000 --- a/test/spec/modules/giantsBidAdapter_spec.js +++ /dev/null @@ -1,301 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/giantsBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; -import * as utils from 'src/utils'; - -const ENDPOINT = '//d.admp.io/hb/multi?url='; - -describe('GiantsAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'giants', - 'params': { - 'zoneId': '584072408' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'zoneId': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'giants', - 'params': { - 'zoneId': '584072408' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should parse out private sizes', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - zoneId: '584072408', - privateSizes: [300, 250] - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].private_sizes).to.exist; - expect(payload.tags[0].private_sizes).to.deep.equal([{width: 300, height: 250}]); - }); - - it('should add source and verison to the tag', function () { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.sdk).to.exist; - expect(payload.sdk).to.deep.equal({ - source: 'pbjs', - version: '$prebid.version$' - }); - }); - - it('should populate the ad_types array on all requests', function () { - ['banner', 'video', 'native'].forEach(type => { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes[type] = {}; - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].ad_types).to.deep.equal([type]); - }); - }); - - it('should populate the ad_types array on outstream requests', function () { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes.video = {context: 'outstream'}; - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].ad_types).to.deep.equal(['video']); - }); - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.equal(ENDPOINT + utils.getTopWindowUrl()); - expect(request.method).to.equal('POST'); - }); - - it('should attach valid video params to the tag', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - zoneId: '584072408', - video: { - id: 123, - minduration: 100, - foobar: 'invalid' - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.tags[0].video).to.deep.equal({ - id: 123, - minduration: 100 - }); - }); - - it('sets minimum native asset params when not provided on adunit', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - image: {required: true}, - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - main_image: {required: true, sizes: [{}]}, - }); - }); - - it('does not overwrite native ad unit params with mimimum params', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - image: { - aspect_ratios: [{ - min_width: 100, - ratio_width: 2, - ratio_height: 3, - }] - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - main_image: { - required: true, - aspect_ratios: [{ - min_width: 100, - ratio_width: 2, - ratio_height: 3, - }] - }, - }); - }); - - it('should convert keyword params to proper form and attaches to request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - zoneId: '584072408', - keywords: { - single: 'val', - singleArr: ['val'], - singleArrNum: [5], - multiValMixed: ['value1', 2, 'value3'], - singleValNum: 123, - badValue: {'foo': 'bar'} // should be dropped - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].keywords).to.deep.equal([{ - 'key': 'single', - 'value': ['val'] - }, { - 'key': 'singleArr', - 'value': ['val'] - }, { - 'key': 'singleArrNum', - 'value': ['5'] - }, { - 'key': 'multiValMixed', - 'value': ['value1', '2', 'value3'] - }, { - 'key': 'singleValNum', - 'value': ['123'] - }]); - }); - - it('should add payment rules to the request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - zoneId: '584072408', - usePaymentRule: true - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].use_pmt_rule).to.equal(true); - }); - }) - - describe('interpretResponse', function () { - let response = { - 'version': '3.0.0', - 'tags': [ - { - 'uuid': '3db3773286ee59', - 'creative_id': '584944065', - 'height': 600, - 'width': 300, - 'zoneId': '584072408', - 'adUrl': '//d.admp.io/pbc/v1/cache-banner/f7aca005-8171-4299-90bf-0750a864a61c', - 'cpm': 0.5 - } - ] - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '3db3773286ee59', - 'cpm': 0.5, - 'creativeId': 29681110, - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'width': 300, - 'height': 250, - 'ad': '', - 'mediaType': 'banner' - } - ]; - let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - let response = { - 'version': '0.0.1', - 'tags': [{ - 'uuid': '84ab500420319d', - 'tag_id': 5976557, - 'auction_id': '297492697822162468', - 'nobid': true - }] - }; - let bidderRequest; - - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/gjirafaBidAdapter_spec.js b/test/spec/modules/gjirafaBidAdapter_spec.js deleted file mode 100644 index a18ea1b99c3..00000000000 --- a/test/spec/modules/gjirafaBidAdapter_spec.js +++ /dev/null @@ -1,172 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/gjirafaBidAdapter'; - -describe('gjirafaAdapterTest', function () { - describe('bidRequestValidity', function () { - it('bidRequest with placementId, minCPM and minCPC params', function () { - expect(spec.isBidRequestValid({ - bidder: 'gjirafa', - params: { - placementId: 'test-div', - minCPM: 0.0001, - minCPC: 0.001 - } - })).to.equal(true); - }); - - it('bidRequest with only placementId param', function () { - expect(spec.isBidRequestValid({ - bidder: 'gjirafa', - params: { - placementId: 'test-div' - } - })).to.equal(true); - }); - - it('bidRequest with minCPM and minCPC params', function () { - expect(spec.isBidRequestValid({ - bidder: 'gjirafa', - params: { - minCPM: 0.0001, - minCPC: 0.001 - } - })).to.equal(true); - }); - - it('bidRequest with no placementId, minCPM or minCPC params', function () { - expect(spec.isBidRequestValid({ - bidder: 'gjirafa', - params: { - } - })).to.equal(false); - }); - }); - - describe('bidRequest', function () { - const bidRequests = [{ - 'bidder': 'gjirafa', - 'params': { - 'placementId': '71-3' - }, - 'adUnitCode': 'hb-leaderboard', - 'transactionId': 'b6b889bb-776c-48fd-bc7b-d11a1cf0425e', - 'sizes': [[728, 90], [980, 200], [980, 150], [970, 90], [970, 250]], - 'bidId': '10bdc36fe0b48c8', - 'bidderRequestId': '70deaff71c281d', - 'auctionId': 'f9012acc-b6b7-4748-9098-97252914f9dc' - }, - { - 'bidder': 'gjirafa', - 'params': { - 'minCPM': 0.0001, - 'minCPC': 0.001, - 'explicit': true - }, - 'adUnitCode': 'hb-inarticle', - 'transactionId': '8757194d-ea7e-4c06-abc0-cfe92bfc5295', - 'sizes': [[300, 250]], - 'bidId': '81a6dcb65e2bd9', - 'bidderRequestId': '70deaff71c281d', - 'auctionId': 'f9012acc-b6b7-4748-9098-97252914f9dc' - }]; - - const bidderRequest = { - 'bids': bidRequests, - 'gdprConsent': { - 'consentString': 'consentString', - 'gdprApplies': true - } - }; - - it('bidRequest HTTP method', function () { - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - }); - }); - - it('bidRequest url', function () { - const endpointUrl = 'https://gjc.gjirafa.com/Home/GetBid'; - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.url).to.match(new RegExp(`${endpointUrl}`)); - }); - }); - - it('bidRequest data', function () { - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.data).to.exist; - }); - }); - - it('bidRequest sizes', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].data.sizes).to.equal('728x90;980x200;980x150;970x90;970x250'); - expect(requests[1].data.sizes).to.equal('300x250'); - }); - - it('should add GDPR data', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].data.consent_string).to.exist; - expect(requests[0].data.consent_required).to.exist; - expect(requests[1].data.consent_string).to.exist; - expect(requests[1].data.consent_required).to.exist; - }); - }); - - describe('interpretResponse', function () { - const bidRequest = { - 'method': 'GET', - 'url': 'https://gjc.gjirafa.com/Home/GetBid', - 'data': { - 'gjid': 2323007, - 'sizes': '728x90;980x200;980x150;970x90;970x250', - 'configId': '71-3', - 'minCPM': 0, - 'minCPC': 0, - 'allowExplicit': 0, - 'referrer': 'http://localhost:9999/integrationExamples/gpt/hello_world.html?pbjs_debug=true', - 'requestid': '26ee8fe87940da7', - 'bidid': '2962dbedc4768bf' - } - }; - - const bidResponse = { - body: [{ - 'CPM': 1, - 'Width': 728, - 'Height': 90, - 'Referrer': 'https://example.com/', - 'Ad': 'test ad', - 'CreativeId': '123abc', - 'NetRevenue': false, - 'Currency': 'EUR', - 'TTL': 360 - }], - headers: {} - }; - - it('all keys present', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - - let keys = [ - 'requestId', - 'cpm', - 'width', - 'height', - 'creativeId', - 'currency', - 'netRevenue', - 'ttl', - 'referrer', - 'ad' - ]; - - let resultKeys = Object.keys(result[0]); - resultKeys.forEach(function(key) { - expect(keys.indexOf(key) !== -1).to.equal(true); - }); - }) - }); -}); diff --git a/test/spec/modules/googleAnalyticsAdapter_spec.js b/test/spec/modules/googleAnalyticsAdapter_spec.js index 20517f4138d..b801b5fe696 100644 --- a/test/spec/modules/googleAnalyticsAdapter_spec.js +++ b/test/spec/modules/googleAnalyticsAdapter_spec.js @@ -1,15 +1,27 @@ -import ga from 'modules/googleAnalyticsAdapter'; +import ga from 'modules/googleAnalyticsAdapter.js'; var assert = require('assert'); describe('Ga', function () { describe('enableAnalytics', function () { - it('should accept a tracker name option and output prefixed send string', function () { - var config = { options: { trackerName: 'foo' } }; - ga.enableAnalytics(config); + var cpmDistribution = function(cpm) { + return cpm <= 1 ? '<= 1$' : '> 1$'; + } + var config = { options: { trackerName: 'foo', enableDistribution: true, cpmDistribution: cpmDistribution } }; + + // enableAnalytics can only be called once + ga.enableAnalytics(config); + it('should accept a tracker name option and output prefixed send string', function () { var output = ga.getTrackerSend(); assert.equal(output, 'foo.send'); }); + + it('should use the custom cpm distribution', function() { + assert.equal(ga.getCpmDistribution(0.5), '<= 1$'); + assert.equal(ga.getCpmDistribution(1), '<= 1$'); + assert.equal(ga.getCpmDistribution(2), '> 1$'); + assert.equal(ga.getCpmDistribution(5.23), '> 1$'); + }); }); }); diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index a191d2211f5..26ab27f5273 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/gridBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec, resetUserSync, getSyncUrl } from 'modules/gridBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('TheMediaGrid Adapter', function () { const adapter = newBidder(spec); @@ -47,7 +47,7 @@ describe('TheMediaGrid Adapter', function () { }); return res; } - const bidderRequest = {refererInfo: {referer: 'http://example.com'}}; + const bidderRequest = {refererInfo: {referer: 'https://example.com'}}; const referrer = bidderRequest.refererInfo.referer; let bidRequests = [ { @@ -93,9 +93,11 @@ describe('TheMediaGrid Adapter', function () { expect(payload).to.have.property('auids', '1'); expect(payload).to.have.property('sizes', '300x250,300x600'); expect(payload).to.have.property('r', '22edbae2733bf6'); + expect(payload).to.have.property('wrapperType', 'Prebid_js'); + expect(payload).to.have.property('wrapperVersion', '$prebid.version$'); }); - it('auids must not be duplicated', function () { + it('sizes must not be duplicated', function () { const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); @@ -129,6 +131,14 @@ describe('TheMediaGrid Adapter', function () { expect(payload).to.have.property('gdpr_consent', 'AAA'); expect(payload).to.have.property('gdpr_applies', '1'); }); + + it('if usPrivacy is present payload must have us_privacy param', function () { + const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithUSP); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('us_privacy', '1YNN'); + }); }); describe('interpretResponse', function () { @@ -575,4 +585,97 @@ describe('TheMediaGrid Adapter', function () { expect(result).to.deep.equal(expectedResponse); }); }); + + describe('user sync', function () { + const syncUrl = getSyncUrl(); + + beforeEach(function () { + resetUserSync(); + }); + + it('should register the Emily iframe', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + }); + + it('should not register the Emily iframe more than once', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + + // when called again, should still have only been called once + syncs = spec.getUserSyncs(); + expect(syncs).to.equal(undefined); + }); + + it('should pass gdpr params if consent is true', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: true, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=1&gdpr_consent=foo` + }); + }); + + it('should pass gdpr params if consent is false', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: false, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=0&gdpr_consent=foo` + }); + }); + + it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr_consent=foo` + }); + }); + + it('should pass no params if gdpr consentString is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {})).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a number', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 0 + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is null', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: null + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a object', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: {} + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined)).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass usPrivacy param if it is available', function() { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {}, '1YNN')).to.deep.equal({ + type: 'image', url: `${syncUrl}&us_privacy=1YNN` + }); + }); + }); }); diff --git a/test/spec/modules/gridNMBidAdapter_spec.js b/test/spec/modules/gridNMBidAdapter_spec.js new file mode 100644 index 00000000000..0dbaac0c526 --- /dev/null +++ b/test/spec/modules/gridNMBidAdapter_spec.js @@ -0,0 +1,461 @@ +import { expect } from 'chai'; +import { spec, resetUserSync, getSyncUrl } from 'modules/gridNMBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +describe('TheMediaGridNM Adapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + const paramsList = [ + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + } + }, + { + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + { + 'source': 'jwp', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + { + 'source': 'jwp', + 'secid': '11', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + } + ]; + paramsList.forEach((params) => { + const invalidBid = Object.assign({}, bid); + delete invalidBid.params; + invalidBid.params = params; + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + }); + + it('should return false when required params has invalid values', function () { + const paramsList = [ + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': '1,2,3,4,5' + } + }, + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': [1, 2], + 'protocols': [1, 2, 3, 4, 5] + } + }, + { + 'source': 'jwp', + 'secid': 11, + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5] + } + }, + { + 'source': 111, + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5] + } + } + ]; + + paramsList.forEach((params) => { + const invalidBid = Object.assign({}, bid); + delete invalidBid.params; + invalidBid.params = params; + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + }); + }); + + describe('buildRequests', function () { + function parseRequestUrl(url) { + const res = {}; + url.replace(/^[^\?]+\?/, '').split('&').forEach((it) => { + const couple = it.split('='); + res[couple[0]] = decodeURIComponent(couple[1]); + }); + return res; + } + const bidderRequest = {refererInfo: {referer: 'https://example.com'}}; + const referrer = bidderRequest.refererInfo.referer; + let bidRequests = [ + { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3], + 'skip': 1 + } + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should attach valid params to the tag', function () { + const requests = spec.buildRequests(bidRequests, bidderRequest); + const requestsSizes = ['300x250,300x600', '728x90']; + requests.forEach((req, i) => { + expect(req.url).to.be.an('string'); + const payload = parseRequestUrl(req.url); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('r', '22edbae2733bf6'); + expect(payload).to.have.property('wrapperType', 'Prebid_js'); + expect(payload).to.have.property('wrapperVersion', '$prebid.version$'); + expect(payload).to.have.property('sizes', requestsSizes[i]); + expect(req.data).to.deep.equal(bidRequests[i].params); + }); + }); + + it('if gdprConsent is present payload must have gdpr params', function () { + const [request] = spec.buildRequests([bidRequests[0]], {gdprConsent: {consentString: 'AAA', gdprApplies: true}, refererInfo: bidderRequest.refererInfo}); + expect(request.url).to.be.an('string'); + const payload = parseRequestUrl(request.url); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('gdpr_consent', 'AAA'); + expect(payload).to.have.property('gdpr_applies', '1'); + }); + + it('if gdprApplies is false gdpr_applies must be 0', function () { + const [request] = spec.buildRequests([bidRequests[0]], {gdprConsent: {consentString: 'AAA', gdprApplies: false}}); + expect(request.url).to.be.an('string'); + const payload = parseRequestUrl(request.url); + expect(payload).to.have.property('gdpr_consent', 'AAA'); + expect(payload).to.have.property('gdpr_applies', '0'); + }); + + it('if gdprApplies is undefined gdpr_applies must be 1', function () { + const [request] = spec.buildRequests([bidRequests[0]], {gdprConsent: {consentString: 'AAA'}}); + expect(request.url).to.be.an('string'); + const payload = parseRequestUrl(request.url); + expect(payload).to.have.property('gdpr_consent', 'AAA'); + expect(payload).to.have.property('gdpr_applies', '1'); + }); + + it('if usPrivacy is present payload must have us_privacy param', function () { + const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); + const [request] = spec.buildRequests([bidRequests[0]], bidderRequestWithUSP); + expect(request.url).to.be.an('string'); + const payload = parseRequestUrl(request.url); + expect(payload).to.have.property('us_privacy', '1YNN'); + }); + }); + + describe('interpretResponse', function () { + const responses = [ + {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'content_type': 'video', 'h': 250, 'w': 300, 'dealid': 11}], 'seat': '2'}, + {'bid': [{'price': 0.5, 'adm': '\n<\/Ad>\n<\/VAST>', 'content_type': 'video', 'h': 600, 'w': 300}], 'seat': '2'}, + {'bid': [{'price': 0, 'h': 250, 'w': 300}], 'seat': '2'}, + {'bid': [{'price': 0, 'adm': '\n<\/Ad>\n<\/VAST>', 'h': 250, 'w': 300}], 'seat': '2'}, + undefined, + {'bid': [], 'seat': '2'}, + {'seat': '2'}, + ]; + + it('should get correct video bid response', function () { + const bidRequests = [ + { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '659423fff799cb', + 'bidderRequestId': '5f2009617a7c0a', + 'auctionId': '1cbd2feafe5e8b', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + }, + { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5], + 'skip': 1 + } + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2bc598e42b6a', + 'bidderRequestId': '1e8b5a465f404', + 'auctionId': '1cbd2feafe5e8b', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + } + ]; + const requests = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '659423fff799cb', + 'cpm': 1.15, + 'creativeId': '5f2009617a7c0a', + 'dealId': 11, + 'width': 300, + 'height': 250, + 'bidderCode': 'gridNM', + 'currency': 'USD', + 'mediaType': 'video', + 'netRevenue': false, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + } + }, + { + 'requestId': '2bc598e42b6a', + 'cpm': 0.5, + 'creativeId': '1e8b5a465f404', + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'bidderCode': 'gridNM', + 'currency': 'USD', + 'mediaType': 'video', + 'netRevenue': false, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + } + } + ]; + + requests.forEach((req, i) => { + const result = spec.interpretResponse({'body': {'seatbid': [responses[i]]}}, req); + expect(result[0]).to.deep.equal(expectedResponse[i]); + }); + }); + + it('handles wrong and nobid responses', function () { + responses.slice(2).forEach((resp) => { + const request = spec.buildRequests([{ + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5], + 'skip': 1 + } + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2bc598e42b6a', + 'bidderRequestId': '39d74f5b71464', + 'auctionId': '1cbd2feafe5e8b', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + }]); + const result = spec.interpretResponse({'body': {'seatbid': [resp]}}, request[0]); + expect(result.length).to.equal(0); + }); + }); + }); + + describe('user sync', function () { + const syncUrl = getSyncUrl(); + + beforeEach(function () { + resetUserSync(); + }); + + it('should register the Emily iframe', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + }); + + it('should not register the Emily iframe more than once', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + + // when called again, should still have only been called once + syncs = spec.getUserSyncs(); + expect(syncs).to.equal(undefined); + }); + + it('should pass gdpr params if consent is true', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: true, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=1&gdpr_consent=foo` + }); + }); + + it('should pass gdpr params if consent is false', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: false, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=0&gdpr_consent=foo` + }); + }); + + it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr_consent=foo` + }); + }); + + it('should pass no params if gdpr consentString is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {})).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a number', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 0 + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is null', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: null + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a object', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: {} + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined)).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass usPrivacy param if it is available', function() { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {}, '1YNN')).to.deep.equal({ + type: 'image', url: `${syncUrl}&us_privacy=1YNN` + }); + }); + }); +}); diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index cedef568d56..9073ad3bfda 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { spec } from 'modules/gumgumBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { spec } from 'modules/gumgumBidAdapter.js'; const ENDPOINT = 'https://g2.gumgum.com/hbid/imp'; @@ -21,7 +21,11 @@ describe('gumgumAdapter', function () { 'bidfloor': 0.05 }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600], [1, 1]], + 'mediaTypes': { + 'banner': { + sizes: [[300, 250], [300, 600], [1, 1]] + } + }, 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', @@ -70,7 +74,29 @@ describe('gumgumAdapter', function () { }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e' + 'bidId': '30b31c1838de1e', + 'schain': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'exchange1.com', + 'sid': '1234', + 'hp': 1, + 'rid': 'bid-request-1', + 'name': 'publisher', + 'domain': 'publisher.com' + }, + { + 'asi': 'exchange2.com', + 'sid': 'abcd', + 'hp': 1, + 'rid': 'bid-request-2', + 'name': 'intermediary', + 'domain': 'intermediary.com' + } + ] + } } ]; @@ -80,7 +106,7 @@ describe('gumgumAdapter', function () { expect(request.method).to.equal('GET'); expect(request.id).to.equal('30b31c1838de1e'); }); - it('should correctly set the request paramters depending on params field', function () { + it('should set t and fp parameters in bid request if inScreen request param is found', function () { const request = Object.assign({}, bidRequests[0]); delete request.params; request.params = { @@ -92,7 +118,18 @@ describe('gumgumAdapter', function () { expect(bidRequest.data).to.include.any.keys('t'); expect(bidRequest.data).to.include.any.keys('fp'); }); - it('should correctly set the request paramters depending on params field', function () { + it('should send pubId if inScreenPubID param is specified', function () { + const request = Object.assign({}, bidRequests[0]); + delete request.params; + request.params = { + 'inScreenPubID': 123 + }; + const bidRequest = spec.buildRequests([request])[0]; + expect(bidRequest.data).to.include.any.keys('pubId'); + expect(bidRequest.data.pubId).to.equal(request.params.inScreenPubID); + expect(bidRequest.data).to.not.include.any.keys('t'); + }); + it('should set a ni parameter in bid request if ICV request param is found', function () { const request = Object.assign({}, bidRequests[0]); delete request.params; request.params = { @@ -102,6 +139,36 @@ describe('gumgumAdapter', function () { expect(bidRequest.data.pi).to.equal(5); expect(bidRequest.data).to.include.any.keys('ni'); }); + it('should add parameters associated with video if video request param is found', function () { + const videoVals = { + playerSize: [640, 480], + context: 'instream', + minduration: 1, + maxduration: 2, + linearity: 1, + startdelay: 1, + placement: 123456, + protocols: [1, 2] + }; + const request = Object.assign({}, bidRequests[0]); + delete request.params; + request.mediaTypes = { + video: videoVals + }; + request.params = { + 'video': '10433395' + }; + const bidRequest = spec.buildRequests([request])[0]; + expect(bidRequest.data.pi).to.eq(7); + expect(bidRequest.data.mind).to.eq(videoVals.minduration); + expect(bidRequest.data.maxd).to.eq(videoVals.maxduration); + expect(bidRequest.data.li).to.eq(videoVals.linearity); + expect(bidRequest.data.sd).to.eq(videoVals.startdelay); + expect(bidRequest.data.pt).to.eq(videoVals.placement); + expect(bidRequest.data.pr).to.eq(videoVals.protocols.join(',')); + expect(bidRequest.data.viw).to.eq(videoVals.playerSize[0].toString()); + expect(bidRequest.data.vih).to.eq(videoVals.playerSize[1].toString()); + }); it('should not add additional parameters depending on params field', function () { const request = spec.buildRequests(bidRequests)[0]; expect(request.data).to.not.include.any.keys('ni'); @@ -109,7 +176,7 @@ describe('gumgumAdapter', function () { expect(request.data).to.not.include.any.keys('eAdBuyId'); expect(request.data).to.not.include.any.keys('adBuyId'); }); - it('should add consent parameters if gdprConsent is present', function () { + it('should add gdpr consent parameters if gdprConsent is present', function () { const gdprConsent = { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', gdprApplies: true }; const fakeBidRequest = { gdprConsent: gdprConsent }; const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0]; @@ -122,6 +189,14 @@ describe('gumgumAdapter', function () { const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0]; expect(bidRequest.data).to.not.include.any.keys('gdprConsent') }); + it('should add uspConsent parameter if it is present in the bidderRequest', function () { + const noUspBidRequest = spec.buildRequests(bidRequests)[0]; + const uspConsentObj = { uspConsent: '1YYY' }; + const bidRequest = spec.buildRequests(bidRequests, uspConsentObj)[0]; + expect(noUspBidRequest.data).to.not.include.any.keys('uspConsent'); + expect(bidRequest.data).to.include.any.keys('uspConsent'); + expect(bidRequest.data.uspConsent).to.eq(uspConsentObj.uspConsent); + }); it('should add a tdid parameter if request contains unified id from TradeDesk', function () { const unifiedId = { 'userId': { @@ -136,6 +211,12 @@ describe('gumgumAdapter', function () { const request = spec.buildRequests(bidRequests)[0]; expect(request.data).to.not.include.any.keys('tdid'); }); + it('should send schain parameter in serialized form', function () { + const serializedForm = '1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com!exchange2.com,abcd,1,bid-request-2,intermediary,intermediary.com' + const request = spec.buildRequests(bidRequests)[0]; + expect(request.data).to.include.any.keys('schain'); + expect(request.data.schain).to.eq(serializedForm); + }); it('should send ns parameter if browser contains navigator.connection property', function () { const bidRequest = spec.buildRequests(bidRequests)[0]; const connection = window.navigator && window.navigator.connection; @@ -179,24 +260,33 @@ describe('gumgumAdapter', function () { method: 'GET', pi: 3 } + let expectedResponse = { + 'ad': '

I am an ad

', + 'cpm': 0, + 'creativeId': 29593, + 'currency': 'USD', + 'height': '250', + 'netRevenue': true, + 'requestId': 12345, + 'width': '300', + // dealId: DEAL_ID, + // referrer: REFERER, + ttl: 60 + }; it('should get correct bid response', function () { - let expectedResponse = { - 'ad': '

I am an ad

', - 'cpm': 0, - 'creativeId': 29593, - 'currency': 'USD', - 'height': '250', - 'netRevenue': true, - 'requestId': 12345, - 'width': '300', - // dealId: DEAL_ID, - // referrer: REFERER, - ttl: 60 - }; expect(spec.interpretResponse({ body: serverResponse }, bidRequest)).to.deep.equal([expectedResponse]); }); + it('should pass correct currency if found in bid response', function () { + const cur = 'EURO'; + let response = Object.assign({}, serverResponse); + let expected = Object.assign({}, expectedResponse); + response.ad.cur = cur; + expected.currency = cur; + expect(spec.interpretResponse({ body: response }, bidRequest)).to.deep.equal([expected]); + }); + it('handles nobid responses', function () { let response = { 'ad': {}, @@ -245,8 +335,8 @@ describe('gumgumAdapter', function () { 'thms': 10000 } let result = spec.interpretResponse({ body: inscreenServerResponse }, inscreenBidRequest); - expect(result[0].width).to.equal(inscreenBidRequest.sizes[0][0].toString()); - expect(result[0].height).to.equal(inscreenBidRequest.sizes[0][1].toString()); + expect(result[0].width).to.equal('1'); + expect(result[0].height).to.equal('1'); }) }) describe('getUserSyncs', function () { diff --git a/test/spec/modules/gxoneBidAdapter_spec.js b/test/spec/modules/gxoneBidAdapter_spec.js deleted file mode 100644 index afeb2c781f5..00000000000 --- a/test/spec/modules/gxoneBidAdapter_spec.js +++ /dev/null @@ -1,293 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/gxoneBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('GXOne Adapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'gxone', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - function parseRequest(url) { - const res = {}; - url.split('&').forEach((it) => { - const couple = it.split('='); - res[couple[0]] = decodeURIComponent(couple[1]); - }); - return res; - } - let bidRequests = [ - { - 'bidder': 'gxone', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5'); - }); - - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 4, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 5, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 6, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 4
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'gxone', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'gxone', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 5, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'gxone', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '7' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '8' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/hpmdnetworkBidAdapter_spec.js b/test/spec/modules/hpmdnetworkBidAdapter_spec.js index 37ec44f07c4..9023fb248e9 100644 --- a/test/spec/modules/hpmdnetworkBidAdapter_spec.js +++ b/test/spec/modules/hpmdnetworkBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/hpmdnetworkBidAdapter'; +import { spec } from 'modules/hpmdnetworkBidAdapter.js'; describe('HPMDNetwork Adapter', function() { describe('isBidRequestValid', function () { @@ -51,7 +51,7 @@ describe('HPMDNetwork Adapter', function() { it('should build single POST request for multiple bids', function() { expect(bidRequest.method).to.equal('POST'); - expect(bidRequest.url).to.equal('//banner.hpmdnetwork.ru/bidder/request'); + expect(bidRequest.url).to.equal('https://banner.hpmdnetwork.ru/bidder/request'); expect(bidRequest.data).to.be.an('object'); expect(bidRequest.data.places).to.be.an('array'); expect(bidRequest.data.places).to.have.lengthOf(2); @@ -90,14 +90,14 @@ describe('HPMDNetwork Adapter', function() { { 'cpm': 20, 'currency': 'RUB', - 'displayUrl': '//banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=168', + 'displayUrl': 'https://banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=168', 'id': '1', 'creativeId': '11111', }, { 'cpm': 30, 'currency': 'RUB', - 'displayUrl': '//banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=170', + 'displayUrl': 'https://banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=170', 'id': '2', 'creativeId': '22222', 'width': 300, @@ -129,7 +129,7 @@ describe('HPMDNetwork Adapter', function() { expect(bids[0]).to.have.property('creativeId'); expect(bids[0].creativeId).to.equal('11111'); expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].ad).to.include(''); + expect(bids[0].ad).to.include(''); }); it('should parse bid with sizes', function() { @@ -142,7 +142,7 @@ describe('HPMDNetwork Adapter', function() { expect(bids[1]).to.have.property('creativeId'); expect(bids[1].creativeId).to.equal('22222'); expect(bids[1].netRevenue).to.equal(true); - expect(bids[1].ad).to.include(''); + expect(bids[1].ad).to.include(''); }); }); }); diff --git a/test/spec/modules/hybridBidAdapter_spec.js b/test/spec/modules/hybridBidAdapter_spec.js new file mode 100644 index 00000000000..e5ad878c9b1 --- /dev/null +++ b/test/spec/modules/hybridBidAdapter_spec.js @@ -0,0 +1,275 @@ +import { expect } from 'chai' +import { spec } from 'modules/hybridBidAdapter.js' + +function getSlotConfigs(mediaTypes, params) { + return { + params: params, + sizes: [], + bidId: '2df8c0733f284e', + bidder: 'hybrid', + mediaTypes: mediaTypes, + transactionId: '31a58515-3634-4e90-9c96-f86196db1459' + } +} + +describe('Hybrid.ai Adapter', function() { + const PLACE_ID = '5af45ad34d506ee7acad0c26'; + const bidderRequest = { + refererInfo: { referer: 'referer' } + } + const bannerMandatoryParams = { + placeId: PLACE_ID, + placement: 'banner' + } + const videoMandatoryParams = { + placeId: PLACE_ID, + placement: 'video' + } + const validBidRequests = [ + getSlotConfigs({ banner: {} }, bannerMandatoryParams), + getSlotConfigs({ video: {playerSize: [[640, 480]]} }, videoMandatoryParams) + ] + describe('isBidRequestValid method', function() { + describe('returns true', function() { + describe('when banner slot config has all mandatory params', () => { + describe('and placement has the correct value', function() { + const slotConfig = getSlotConfigs( + { banner: {} }, + { + placeId: PLACE_ID, + placement: 'banner' + } + ) + const isBidRequestValid = spec.isBidRequestValid(slotConfig) + expect(isBidRequestValid).to.equal(true) + }) + describe('when video slot has all mandatory params.', function() { + it('should return true, when video mediatype object are correct.', function() { + const slotConfig = getSlotConfigs( + { + video: { + context: 'instream', + playerSize: [[640, 480]] + } + }, + { + placeId: PLACE_ID, + placement: 'video' + } + ) + const isBidRequestValid = spec.isBidRequestValid(slotConfig) + expect(isBidRequestValid).to.equal(true) + }) + }) + }) + }) + describe('returns false', function() { + describe('when params are not correct', function() { + function createSlotconfig(params) { + return getSlotConfigs({ banner: {} }, params) + } + it('does not have the placeId.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placement: 'banner' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have a the correct placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + placement: 'something' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + describe('when video mediaType object is not correct.', function() { + function createVideoSlotconfig(mediaType) { + return getSlotConfigs(mediaType, { + placeId: PLACE_ID, + placement: 'video' + }) + } + it('is a void object', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ video: {} }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have playerSize.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ video: { context: 'instream' } }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have context', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ + video: { + playerSize: [[640, 480]] + } + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + }) + }) + it('Url params should be correct ', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + expect(request.method).to.equal('POST') + expect(request.url).to.equal('https://hbe198.hybrid.ai/prebidhb') + }) + + describe('buildRequests method', function() { + it('Common data request should be correct', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(Array.isArray(data.bidRequests)).to.equal(true) + expect(data.url).to.equal('referer') + data.bidRequests.forEach(bid => { + expect(bid.bidId).to.equal('2df8c0733f284e') + expect(bid.placeId).to.equal(PLACE_ID) + expect(bid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459') + }) + }) + + describe('GDPR params', function() { + describe('when there are not consent management platform', function() { + it('cmp should be false', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(false) + }) + }) + describe('when there are consent management platform', function() { + it('cmps should be true and ga should not sended, when gdprApplies is undefined', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: undefined, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(Object.keys(data).indexOf('data')).to.equal(-1) + expect(data.cs).to.equal('consentString') + }) + it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: true, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(data.ga).to.equal(true) + expect(data.cs).to.equal('consentString') + }) + }) + }) + + describe('BidRequests params', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + const bidRequests = data.bidRequests + it('should request a Banner', function() { + const bannerBid = bidRequests[0] + expect(bannerBid.placement).to.equal(spec.placementTypes[bannerMandatoryParams.placement]) + }) + it('should request a Video', function() { + const bannerBid = bidRequests[1] + expect(bannerBid.placement).to.equal(spec.placementTypes[videoMandatoryParams.placement]) + }) + }) + }) + + describe('interpret response method', function() { + it('should return a void array, when the server response are not correct.', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { + body: {} + } + const bids = spec.interpretResponse(serverResponse, request) + expect(typeof bids).to.equal('object') + expect(bids.length).to.equal(0) + }) + it('should return a void array, when the server response have not got bids.', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { body: { bids: [] } } + const bids = spec.interpretResponse(serverResponse, request) + expect(typeof bids).to.equal('object') + expect(bids.length).to.equal(0) + }) + describe('when the server response return a bid', function() { + describe('the bid is a banner', function() { + it('should return a banner bid', function() { + const request = spec.buildRequests([validBidRequests[0]], bidderRequest) + const serverResponse = { + body: { + bids: [ + { + bidId: '2df8c0733f284e', + price: 0.5, + currency: 'USD', + content: 'html', + width: 100, + height: 100 + } + ] + } + } + const bids = spec.interpretResponse(serverResponse, request) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2df8c0733f284e') + expect(bids[0].mediaType).to.equal(spec.supportedMediaTypes[0]) + expect(bids[0].cpm).to.equal(0.5) + expect(bids[0].width).to.equal(100) + expect(bids[0].height).to.equal(100) + expect(bids[0].currency).to.equal('USD') + expect(bids[0].netRevenue).to.equal(true) + expect(typeof bids[0].ad).to.equal('string') + }) + }) + describe('the bid is a video', function() { + it('should return a video bid', function() { + const request = spec.buildRequests([validBidRequests[1]], bidderRequest) + const serverResponse = { + body: { + bids: [ + { + bidId: '2df8c0733f284e', + price: 0.5, + currency: 'USD', + content: 'html', + width: 100, + height: 100 + } + ] + } + } + const bids = spec.interpretResponse(serverResponse, request) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2df8c0733f284e') + expect(bids[0].mediaType).to.equal(spec.supportedMediaTypes[1]) + expect(bids[0].cpm).to.equal(0.5) + expect(bids[0].width).to.equal(100) + expect(bids[0].height).to.equal(100) + expect(bids[0].currency).to.equal('USD') + expect(bids[0].netRevenue).to.equal(true) + expect(typeof bids[0].vastXml).to.equal('string') + }) + }) + }) + }) +}) diff --git a/test/spec/modules/iasBidAdapter_spec.js b/test/spec/modules/iasBidAdapter_spec.js index 8197ee25856..1743ac947e6 100644 --- a/test/spec/modules/iasBidAdapter_spec.js +++ b/test/spec/modules/iasBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/iasBidAdapter'; +import { spec } from 'modules/iasBidAdapter.js'; describe('iasBidAdapter is an adapter that', function () { it('has the correct bidder code', function () { @@ -44,7 +44,7 @@ describe('iasBidAdapter is an adapter that', function () { describe('given bid requests, returns a `ServerRequest` instance that', function () { let bidRequests, IAS_HOST; beforeEach(function () { - IAS_HOST = '//pixel.adsafeprotected.com/services/pub'; + IAS_HOST = 'https://pixel.adsafeprotected.com/services/pub'; bidRequests = [ { adUnitCode: 'one-div-id', diff --git a/test/spec/modules/imonomyBidAdapter_spec.js b/test/spec/modules/imonomyBidAdapter_spec.js index 206e227a3b1..45b3bed6e77 100644 --- a/test/spec/modules/imonomyBidAdapter_spec.js +++ b/test/spec/modules/imonomyBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/imonomyBidAdapter'; +import { spec } from 'modules/imonomyBidAdapter.js'; describe('Imonomy Adapter Tests', function () { const bidsRequest = [ @@ -44,7 +44,7 @@ describe('Imonomy Adapter Tests', function () { width: 300, height: 250, cpm: 0.51, - creative: '', + creative: '', ttl: 360, currency: 'USD', netRevenue: true, @@ -73,7 +73,7 @@ describe('Imonomy Adapter Tests', function () { var startTime = new Date().getTime(); const request = spec.buildRequests(bidsRequest); - expect(request.url).to.equal('//b.imonomy.com/openrtb/hb/14567718624'); + expect(request.url).to.equal('https://b.imonomy.com/openrtb/hb/14567718624'); expect(request.method).to.equal('POST'); const requestData = JSON.parse(request.data); @@ -159,6 +159,6 @@ describe('Imonomy Adapter Tests', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('iframe'); - expect(options[0].url).to.equal('//b.imonomy.com/UserMatching/b/'); + expect(options[0].url).to.equal('https://b.imonomy.com/UserMatching/b/'); }); }); diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 8b8f6c4bf4c..676f6ab0fd0 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { ImproveDigitalAdServerJSClient, spec } from 'modules/improvedigitalBidAdapter'; -import { config } from 'src/config'; -import { userSync } from 'src/userSync'; +import { ImproveDigitalAdServerJSClient, spec } from 'modules/improvedigitalBidAdapter.js'; +import { config } from 'src/config.js'; +import { userSync } from 'src/userSync.js'; describe('Improve Digital Adapter Tests', function () { let idClient = new ImproveDigitalAdServerJSClient('hb'); @@ -103,6 +103,8 @@ describe('Improve Digital Adapter Tests', function () { expect(params.bid_request).to.be.an('object'); expect(params.bid_request.id).to.be.a('string'); expect(params.bid_request.version).to.equal(`${spec.version}-${idClient.CONSTANTS.CLIENT_VERSION}`); + expect(params.bid_request.gdpr).to.not.exist; + expect(params.bid_request.us_privacy).to.not.exist; expect(params.bid_request.imp).to.deep.equal([ { id: '33e9500b21129f', @@ -186,6 +188,13 @@ describe('Improve Digital Adapter Tests', function () { expect(params.bid_request.gdpr).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); }); + it('should add CCPA consent string', function () { + const bidRequest = Object.assign({}, simpleBidRequest); + const request = spec.buildRequests([bidRequest], { uspConsent: '1YYY' })[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.us_privacy).to.equal('1YYY'); + }); + it('should add referrer', function () { const bidRequest = Object.assign({}, simpleBidRequest); const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0]; @@ -193,6 +202,63 @@ describe('Improve Digital Adapter Tests', function () { expect(params.bid_request.referrer).to.equal('https://blah.com/test.html'); }); + it('should add ad type for instream video', function () { + let bidRequest = Object.assign({}, simpleBidRequest); + bidRequest.mediaType = 'video'; + let request = spec.buildRequests([bidRequest])[0]; + let params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].ad_types).to.deep.equal(['video']); + + bidRequest = Object.assign({}, simpleBidRequest); + bidRequest.mediaTypes = { + video: { + context: 'instream', + playerSize: [640, 480] + } + }; + request = spec.buildRequests([bidRequest])[0]; + params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].ad_types).to.deep.equal(['video']); + }); + + it('should not set Prebid sizes in bid request for instream video', function () { + const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); + const bidRequest = Object.assign({}, simpleBidRequest); + bidRequest.mediaTypes = { + video: { + context: 'instream', + playerSize: [640, 480] + } + }; + const request = spec.buildRequests([bidRequest])[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].banner.format).to.not.exist; + getConfigStub.restore(); + }); + + it('should not set ad type for outstream video', function() { + const bidRequest = Object.assign({}, simpleBidRequest); + bidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }; + const request = spec.buildRequests([bidRequest])[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].ad_types).to.not.exist; + }); + + it('should add schain', function () { + const schain = '{"ver":"1.0","complete":1,"nodes":[{"asi":"headerlift.com","sid":"xyz","hp":1}]}'; + const bidRequest = Object.assign({}, simpleBidRequest); + bidRequest.schain = schain; + const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.schain).to.equal(schain); + }); + it('should return 2 requests', function () { const requests = spec.buildRequests([ simpleBidRequest, @@ -259,17 +325,17 @@ describe('Improve Digital Adapter Tests', function () { 'id': '33e9500b21129f', 'advid': '5279', 'price': 1.45888594164456, - 'nurl': 'http://ice.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', + 'nurl': 'https://ice.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', 'h': 290, 'pid': 1053688, 'sync': [ - 'http://link1', - 'http://link2' + 'https://link1', + 'https://link2' ], 'crid': '422031', 'w': 600, 'cid': '99006', - 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' + 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' } ], 'debug': '' @@ -287,16 +353,16 @@ describe('Improve Digital Adapter Tests', function () { 'id': '1234', 'advid': '5280', 'price': 1.23, - 'nurl': 'http://link/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', + 'nurl': 'https://link/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', 'h': 400, 'pid': 1053688, 'sync': [ - 'http://link3' + 'https://link3' ], 'crid': '422033', 'w': 700, 'cid': '99006', - 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' + 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' } ], 'debug': '' @@ -313,12 +379,12 @@ describe('Improve Digital Adapter Tests', function () { id: '33e9500b21129f', advid: '5279', price: 1.45888594164456, - nurl: 'http://ice.360yield.com/imp_pixel?ic=wVm', + nurl: 'https://ice.360yield.com/imp_pixel?ic=wVm', h: 290, pid: 1053688, sync: [ - 'http://link1', - 'http://link2' + 'https://link1', + 'https://link2' ], crid: '422031', w: 600, @@ -413,7 +479,7 @@ describe('Improve Digital Adapter Tests', function () { { img: { type: 2, - url: 'http://blah.com/icon.jpg', + url: 'https://blah.com/icon.jpg', h: 30, w: 40 } @@ -422,23 +488,23 @@ describe('Improve Digital Adapter Tests', function () { { img: { type: 3, - url: 'http://blah.com/image.jpg', + url: 'https://blah.com/image.jpg', h: 200, w: 800 } } ], link: { - url: 'http://advertiser.com', + url: 'https://advertiser.com', clicktrackers: [ - 'http://click.tracker.com/click?impid=123' + 'https://click.tracker.com/click?impid=123' ] }, imptrackers: [ - 'http://imptrack1.com', - 'http://imptrack2.com' + 'https://imptrack1.com', + 'https://imptrack2.com' ], - jstracker: '', + jstracker: '', privacy: 'https://www.myprivacyurl.com' } } @@ -447,23 +513,51 @@ describe('Improve Digital Adapter Tests', function () { } }; + const serverResponseVideo = { + 'body': { + 'id': '687a06c541d8d1', + 'site_id': 191642, + 'bid': [ + { + 'isNet': false, + 'id': '33e9500b21129f', + 'advid': '5279', + 'price': 1.45888594164456, + 'nurl': 'http://ice.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', + 'h': 290, + 'pid': 1053688, + 'sync': [ + 'http://link1', + 'http://link2' + ], + 'crid': '422031', + 'w': 600, + 'cid': '99006', + 'adm': '', + 'ad_type': 'video' + } + ], + 'debug': '' + } + }; + const nativeEventtrackers = [ { event: 1, method: 1, - url: 'http://www.mytracker.com/imptracker' + url: 'https://www.mytracker.com/imptracker' }, { event: 1, method: 2, - url: 'http://www.mytracker.com/tracker.js' + url: 'https://www.mytracker.com/tracker.js' } ]; describe('interpretResponse', function () { let expectedBid = [ { - 'ad': '', + 'ad': '', 'adId': '33e9500b21129f', 'creativeId': '422031', 'cpm': 1.45888594164456, @@ -480,7 +574,7 @@ describe('Improve Digital Adapter Tests', function () { let expectedTwoBids = [ expectedBid[0], { - 'ad': '', + 'ad': '', 'adId': '1234', 'creativeId': '422033', 'cpm': 1.23, @@ -521,28 +615,44 @@ describe('Improve Digital Adapter Tests', function () { address: '123 Main Street, Anywhere USA', displayUrl: 'https://myurl.com', icon: { - url: 'http://blah.com/icon.jpg', + url: 'https://blah.com/icon.jpg', height: 30, width: 40 }, image: { - url: 'http://blah.com/image.jpg', + url: 'https://blah.com/image.jpg', height: 200, width: 800 }, - clickUrl: 'http://advertiser.com', - clickTrackers: ['http://click.tracker.com/click?impid=123'], + clickUrl: 'https://advertiser.com', + clickTrackers: ['https://click.tracker.com/click?impid=123'], impressionTrackers: [ - 'http://ice.360yield.com/imp_pixel?ic=wVm', - 'http://imptrack1.com', - 'http://imptrack2.com' + 'https://ice.360yield.com/imp_pixel?ic=wVm', + 'https://imptrack1.com', + 'https://imptrack2.com' ], - javascriptTrackers: '', + javascriptTrackers: '', privacyLink: 'https://www.myprivacyurl.com' } } ]; + let expectedBidVideo = [ + { + 'vastXml': '', + 'adId': '33e9500b21129f', + 'creativeId': '422031', + 'cpm': 1.45888594164456, + 'currency': 'USD', + 'height': 290, + 'mediaType': 'video', + 'netRevenue': false, + 'requestId': '33e9500b21129f', + 'ttl': 300, + 'width': 600 + } + ]; + it('should return a well-formed bid', function () { const bids = spec.interpretResponse(serverResponse); expect(bids).to.deep.equal(expectedBid); @@ -650,14 +760,20 @@ describe('Improve Digital Adapter Tests', function () { const expectedBids = JSON.parse(JSON.stringify(expectedBidNative)); response.body.bid[0].native.eventtrackers = nativeEventtrackers; expectedBids[0].native.impressionTrackers = [ - 'http://ice.360yield.com/imp_pixel?ic=wVm', - 'http://www.mytracker.com/imptracker' + 'https://ice.360yield.com/imp_pixel?ic=wVm', + 'https://www.mytracker.com/imptracker' ]; - expectedBids[0].native.javascriptTrackers = ''; + expectedBids[0].native.javascriptTrackers = ''; bids = spec.interpretResponse(response); delete bids[0].ortbNative; expect(bids).to.deep.equal(expectedBids); }); + + // Video + it('should return a well-formed video bid', function () { + const bids = spec.interpretResponse(serverResponseVideo); + expect(bids).to.deep.equal(expectedBidVideo); + }); }); describe('getUserSyncs', function () { @@ -671,9 +787,9 @@ describe('Improve Digital Adapter Tests', function () { it('should return user syncs', function () { const syncs = spec.getUserSyncs({ pixelEnabled: true }, serverResponses); const expected = [ - { type: 'image', url: 'http://link1' }, - { type: 'image', url: 'http://link2' }, - { type: 'image', url: 'http://link3' } + { type: 'image', url: 'https://link1' }, + { type: 'image', url: 'https://link2' }, + { type: 'image', url: 'https://link3' } ]; expect(syncs).to.deep.equal(expected); }); diff --git a/test/spec/modules/innityBidAdapter_spec.js b/test/spec/modules/innityBidAdapter_spec.js index 0132f093ca1..80c00252632 100644 --- a/test/spec/modules/innityBidAdapter_spec.js +++ b/test/spec/modules/innityBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/innityBidAdapter'; +import { spec } from 'modules/innityBidAdapter.js'; -describe('innityAdapterTest', function () { - describe('bidRequestValidity', function () { - it('bidRequest with pub ID and zone ID param', function () { +describe('innityAdapterTest', () => { + describe('bidRequestValidity', () => { + it('bidRequest with pub ID and zone ID param', () => { expect(spec.isBidRequestValid({ bidder: 'innity', params: { @@ -13,7 +13,7 @@ describe('innityAdapterTest', function () { })).to.equal(true); }); - it('bidRequest with no required params', function () { + it('bidRequest with no required params', () => { expect(spec.isBidRequestValid({ bidder: 'innity', params: { @@ -22,14 +22,14 @@ describe('innityAdapterTest', function () { }); }); - describe('bidRequest', function () { + describe('bidRequest', () => { const bidRequests = [{ 'bidder': 'innity', 'params': { 'pub': 267, 'zone': 62546 }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'adUnitCode': '/19968336/header-bid-tag-0', 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', 'sizes': [300, 250], 'bidId': '51ef8751f9aead', @@ -37,15 +37,21 @@ describe('innityAdapterTest', function () { 'auctionId': '18fd8b8b0bd757' }]; - it('bidRequest HTTP method', function () { - const requests = spec.buildRequests(bidRequests); + const bidderRequest = { + refererInfo: { + referer: 'https://example.com' + } + }; + + it('bidRequest HTTP method', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); requests.forEach(function(requestItem) { expect(requestItem.method).to.equal('GET'); }); }); - it('bidRequest data', function () { - const requests = spec.buildRequests(bidRequests); + it('bidRequest data', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].data.pub).to.equal(267); expect(requests[0].data.zone).to.equal(62546); expect(requests[0].data.width).to.equal('300'); @@ -54,7 +60,7 @@ describe('innityAdapterTest', function () { }); }); - describe('interpretResponse', function () { + describe('interpretResponse', () => { const bidRequest = { 'method': 'GET', 'url': 'https://as.innity.com/synd/?', @@ -85,7 +91,7 @@ describe('innityAdapterTest', function () { headers: {} }; - it('result is correct', function () { + it('result is correct', () => { const result = spec.interpretResponse(bidResponse, bidRequest); expect(result[0].requestId).to.equal('51ef8751f9aead'); expect(result[0].cpm).to.equal(1); @@ -94,7 +100,7 @@ describe('innityAdapterTest', function () { expect(result[0].creativeId).to.equal('148186'); expect(result[0].currency).to.equal('USD'); expect(result[0].ttl).to.equal(60); - expect(result[0].ad).to.equal(''); + expect(result[0].ad).to.equal(''); }); }); }); diff --git a/test/spec/modules/inskinBidAdapter_spec.js b/test/spec/modules/inskinBidAdapter_spec.js index 896fe36d443..1be79a5a963 100644 --- a/test/spec/modules/inskinBidAdapter_spec.js +++ b/test/spec/modules/inskinBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/inskinBidAdapter'; -import { createBid } from 'src/bidfactory'; +import { spec } from 'modules/inskinBidAdapter.js'; +import { createBid } from 'src/bidfactory.js'; const ENDPOINT = 'https://mfad.inskinad.com/api/v2'; @@ -101,6 +101,18 @@ const RESPONSE = { } }; +const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; +const bidderRequest = { + bidderCode: 'inskin', + gdprConsent: { + consentString: consentString, + gdprApplies: true + }, + refererInfo: { + referer: 'https://www.inskinmedia.com' + } +}; + describe('InSkin BidAdapter', function () { let bidRequests; let adapter = spec; @@ -170,37 +182,29 @@ describe('InSkin BidAdapter', function () { describe('buildRequests validation', function () { it('creates request data', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequest); expect(request).to.exist.and.to.be.a('object'); }); it('request to inskin should contain a url', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.url).to.have.string('inskinad.com'); }); it('requires valid bids to make request', function () { - let request = spec.buildRequests([]); + let request = spec.buildRequests([], bidderRequest); expect(request.bidRequest).to.be.empty; }); it('sends bid request to ENDPOINT via POST', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.method).to.have.string('POST'); }); it('should add gdpr consent information to the request', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let bidderRequest = { - 'bidderCode': 'inskin', - 'gdprConsent': { - consentString: consentString, - gdprApplies: true - } - }; bidderRequest.bids = bidRequests; const request = spec.buildRequests(bidRequests, bidderRequest); @@ -214,7 +218,7 @@ describe('InSkin BidAdapter', function () { }); describe('interpretResponse validation', function () { it('response should have valid bidderCode', function () { - let bidRequest = spec.buildRequests(REQUEST.bidRequest); + let bidRequest = spec.buildRequests(REQUEST.bidRequest, bidderRequest); let bid = createBid(1, bidRequest.bidRequest[0]); expect(bid.bidderCode).to.equal('inskin'); @@ -240,7 +244,6 @@ describe('InSkin BidAdapter', function () { expect(b).to.have.property('creativeId'); expect(b).to.have.property('ttl', 360); expect(b).to.have.property('netRevenue', true); - expect(b).to.have.property('referrer'); }); }); diff --git a/test/spec/modules/interactiveOffersBidAdapter_spec.js b/test/spec/modules/interactiveOffersBidAdapter_spec.js deleted file mode 100644 index 8921a302738..00000000000 --- a/test/spec/modules/interactiveOffersBidAdapter_spec.js +++ /dev/null @@ -1,177 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/interactiveOffersBidAdapter'; - -describe('interactiveOffers adapter', function () { - describe('implementation', function () { - describe('for requests', function () { - it('should accept valid bid', function () { - let validBid = { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - }, - isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject invalid bid', function () { - let invalidBid = { - bidder: 'interactiveOffers' - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - describe('for requests', function () { - it('should accept valid bid with optional params', function () { - let validBid = { - bidder: 'interactiveOffers', - params: { - pubId: '42', - loc: 'http://test.com/prebid', - tmax: 1500 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - - let buildRequest = spec.buildRequests([validBid])[0]; - let requestUrlCustomParams = buildRequest.data; - expect(requestUrlCustomParams).have.property('loc', 'http://test.com/prebid'); - expect(requestUrlCustomParams).have.property('tmax', 1500); - }); - - it('should accept valid bid without optional params', function () { - let validBid = { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - - let buildRequest = spec.buildRequests([validBid])[0]; - let requestUrlCustomParams = buildRequest.data; - expect(requestUrlCustomParams).have.property('loc'); - expect(requestUrlCustomParams).have.property('tmax'); - }); - - it('should reject invalid bid without pubId', function () { - let invalidBid = { - bidder: 'interactiveOffers', - params: {} - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - describe('bid responses', function () { - it('should return complete bid response', function () { - let serverResponse = { - body: { - 'success': 'true', - 'message': 'Request Valid', - 'payloadData': { - bidId: '3842b02f7ec0fd', - cpm: 0.5, - width: 300, - height: 600, - ad: '
...
', - } - } - }; - - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(1); - expect(bids[0].cpm).to.equal(0.5); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(600); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].ad).to.have.length.above(1); - }); - - it('should return empty bid response', function () { - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let serverResponse = { - body: { - 'success': 'true', - 'message': 'Request Valid', - 'payloadData': { - bidId: '3842b02f7ec0fd', - cpm: 0 - } - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with error', function () { - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let serverResponse = {body: {'success': 'false', 'message': 'Request Error'}}, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response without payload', function () { - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let serverResponse = {body: {'success': 'true', 'message': 'Empty Payload', 'payloadData': []}}, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response on empty body', function () { - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let serverResponse, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - }); - }); -}); diff --git a/test/spec/modules/invibesBidAdapter_spec.js b/test/spec/modules/invibesBidAdapter_spec.js index 6391f168599..d21405a8b9d 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -1,11 +1,11 @@ import { expect } from 'chai'; -import { spec, resetInvibes, stubDomainOptions } from 'modules/invibesBidAdapter'; +import { spec, resetInvibes, stubDomainOptions } from 'modules/invibesBidAdapter.js'; describe('invibesBidAdapter:', function () { const BIDDER_CODE = 'invibes'; const PLACEMENT_ID = '12345'; - const ENDPOINT = '//bid.videostep.com/Bid/VideoAdContent'; - const SYNC_ENDPOINT = '//k.r66net.com/GetUserSync'; + const ENDPOINT = 'https://bid.videostep.com/Bid/VideoAdContent'; + const SYNC_ENDPOINT = 'https://k.r66net.com/GetUserSync'; let bidRequests = [ { @@ -135,6 +135,42 @@ describe('invibesBidAdapter:', function () { expect(parsedData.height).to.exist; }); + it('has capped ids if local storage variable is correctly formatted', function () { + localStorage.ivvcap = '{"9731":[1,1768600800000]}'; + const request = spec.buildRequests(bidRequests, { auctionStart: Date.now() }); + expect(request.data.capCounts).to.equal('9731=1'); + }); + + it('does not have capped ids if local storage variable is incorrectly formatted', function () { + localStorage.ivvcap = ':[1,1574334216992]}'; + const request = spec.buildRequests(bidRequests, { auctionStart: Date.now() }); + expect(request.data.capCounts).to.equal(''); + }); + + it('does not have capped ids if local storage variable is expired', function () { + localStorage.ivvcap = '{"9731":[1,1574330064104]}'; + const request = spec.buildRequests(bidRequests, { auctionStart: Date.now() }); + expect(request.data.capCounts).to.equal(''); + }); + + it('sends query string params from localstorage 1', function () { + localStorage.ivbs = JSON.stringify({ bvci: 1 }); + const request = spec.buildRequests(bidRequests, { auctionStart: Date.now() }); + expect(request.data.bvci).to.equal(1); + }); + + it('sends query string params from localstorage 2', function () { + localStorage.ivbs = JSON.stringify({ invibbvlog: true }); + const request = spec.buildRequests(bidRequests, { auctionStart: Date.now() }); + expect(request.data.invibbvlog).to.equal(true); + }); + + it('does not send query string params from localstorage if unknwon', function () { + localStorage.ivbs = JSON.stringify({ someparam: true }); + const request = spec.buildRequests(bidRequests, { auctionStart: Date.now() }); + expect(request.data.someparam).to.be.undefined; + }); + it('sends all Placement Ids', function () { const request = spec.buildRequests(bidRequests); expect(JSON.parse(request.data.bidParamsJson).placementIds).to.contain(bidRequests[0].params.placementId); @@ -154,7 +190,7 @@ describe('invibesBidAdapter:', function () { }); it('try to graduate but not enough count - doesnt send the domain id', function () { - global.document.cookie = 'ivbsdid={"id":"dvdjkams6nkq","cr":1521818537626,"hc":5}'; + global.document.cookie = 'ivbsdid={"id":"dvdjkams6nkq","cr":1521818537626,"hc":0}'; let bidderRequest = { gdprConsent: { vendorData: { vendorConsents: { 436: true } } } }; let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.lId).to.not.exist; @@ -179,6 +215,7 @@ describe('invibesBidAdapter:', function () { stubDomainOptions(new StubbedPersistence('{"id":"f8zoh044p9oi"}')); let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.lId).to.exist; + expect(top.window.invibes.dom.tempId).to.exist; }); it('send the domain id after replacing it with new format', function () { @@ -186,6 +223,7 @@ describe('invibesBidAdapter:', function () { stubDomainOptions(new StubbedPersistence('{"id":"f8zoh044p9oi.8537626"}')); let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.lId).to.exist; + expect(top.window.invibes.dom.tempId).to.exist; }); it('dont send the domain id if consent declined', function () { @@ -193,6 +231,7 @@ describe('invibesBidAdapter:', function () { stubDomainOptions(new StubbedPersistence('{"id":"f8zoh044p9oi.8537626"}')); let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.lId).to.not.exist; + expect(top.window.invibes.dom.tempId).to.not.exist; }); it('dont send the domain id if no consent', function () { @@ -200,6 +239,16 @@ describe('invibesBidAdapter:', function () { stubDomainOptions(new StubbedPersistence('{"id":"f8zoh044p9oi.8537626"}')); let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.lId).to.not.exist; + expect(top.window.invibes.dom.tempId).to.not.exist; + }); + + it('try to init id but was already loaded on page - does not increment the id again', function () { + let bidderRequest = { gdprConsent: { vendorData: { vendorConsents: { 436: true } } } }; + global.document.cookie = 'ivbsdid={"id":"dvdjkams6nkq","cr":1521818537626,"hc":0}'; + let request = spec.buildRequests(bidRequests, bidderRequest); + request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.lId).to.not.exist; + expect(top.window.invibes.dom.tempId).to.exist; }); }); @@ -273,6 +322,8 @@ describe('invibesBidAdapter:', function () { context('when the response is valid', function () { it('responds with a valid bid', function () { + top.window.invibes.setCookie('a', 'b', 370); + top.window.invibes.setCookie('c', 'd', 0); let result = spec.interpretResponse({ body: response }, { bidRequests }); expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); }); diff --git a/test/spec/modules/invisiblyAnalyticsAdapter_spec.js b/test/spec/modules/invisiblyAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..419d5a29700 --- /dev/null +++ b/test/spec/modules/invisiblyAnalyticsAdapter_spec.js @@ -0,0 +1,491 @@ +import invisiblyAdapter from 'modules/invisiblyAnalyticsAdapter.js'; +import { expect } from 'chai'; +import { server } from 'test/mocks/xhr.js'; +let events = require('src/events'); +let constants = require('src/constants.json'); + +describe('Invisibly Analytics Adapter test suite', function() { + const BID1 = { + width: 980, + height: 240, + cpm: 1.1, + timeToRespond: 200, + bidId: '2ecff0db240757', + requestId: '2ecff0db240757', + adId: '2ecff0db240757', + auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa', + adUnitCode: '/19968336/header-bid-tag-0', + adserverTargeting: { + hb_bidder: 'testBidder', + hb_adid: '2ecff0db240757', + hb_pb: 1.2, + hb_size: '640x480', + hb_source: 'client' + }, + getStatusCode() { + return CONSTANTS.STATUS.GOOD; + } + }; + + const BID2 = Object.assign({}, BID1, { + width: 300, + height: 250, + cpm: 2.2, + timeToRespond: 300, + bidId: '3ecff0db240757', + requestId: '3ecff0db240757', + adId: '3ecff0db240757' + }); + + const BID3 = { + bidId: '4ecff0db240757', + requestId: '4ecff0db240757', + adId: '4ecff0db240757', + auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa', + adUnitCode: '/19968336/header-bid-tag1', + adserverTargeting: { + hb_bidder: 'testBidder', + hb_adid: '3bd4ebb1c900e2', + hb_pb: '1.500', + hb_size: '728x90', + hb_source: 'server' + }, + getStatusCode() { + return CONSTANTS.STATUS.NO_BID; + } + }; + + const MOCK = { + config: { + provider: 'invisiblyAnalytics', + options: { + bundleId: '', + account: 'invisibly' + } + }, + AUCTION_INIT: { + auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa' + }, + BID_REQUESTED: { + bidder: 'mockBidder', + auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa', + bidderRequestId: '1be65d7958826a', + bids: [ + { + bidder: 'mockBidder', + adUnitCode: 'panorama_d_1', + bidId: '2ecff0db240757' + }, + { + bidder: 'mockBidder', + adUnitCode: 'box_d_1', + bidId: '3ecff0db240757' + }, + { + bidder: 'mockBidder', + adUnitCode: 'box_d_2', + bidId: '4ecff0db240757' + } + ], + start: 1519149562216 + }, + BID_RESPONSE: [BID1, BID2], + AUCTION_END: { + auctionId: 'test_timeout_auction_id', + timestamp: 1234567890, + timeout: 3000, + auctionEnd: 1234567990 + }, + BID_WON: { + bidderCode: 'appnexus', + width: 300, + height: 250, + adId: '1ebb82ec35375e', + mediaType: 'banner', + cpm: 0.5, + requestId: '1582271863760569973', + creative_id: '96846035', + creativeId: '96846035', + ttl: 60, + currency: 'USD', + netRevenue: true, + auctionId: '9c7b70b9-b6ab-4439-9e71-b7b382797c18', + responseTimestamp: 1537521629657, + requestTimestamp: 1537521629331, + bidder: 'appnexus', + adUnitCode: 'div-gpt-ad-1460505748561-0', + timeToRespond: 326, + size: '300x250', + status: 'rendered', + eventType: 'bidWon', + ad: 'some ad', + adUrl: 'ad url' + }, + BIDDER_DONE: { + bidderCode: 'mockBidder', + bids: [BID1, BID2, BID3] + }, + BID_TIMEOUT: [ + { + bidId: '2ecff0db240757', + auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa' + } + ], + BID_ADJUSTMENT: { + ad: 'html', + adId: '298bf14ecbafb', + cpm: 1.01, + creativeId: '2249:92806132', + currency: 'USD', + height: 250, + mediaType: 'banner', + requestId: '298bf14ecbafb', + size: '300x250', + source: 'client', + status: 'rendered', + statusMessage: 'Bid available', + timeToRespond: 421, + ttl: 300, + width: 300 + }, + NO_BID: { + testKey: false + }, + SET_TARGETING: { + [BID1.adUnitCode]: BID1.adserverTargeting, + [BID3.adUnitCode]: BID3.adserverTargeting + }, + REQUEST_BIDS: { + call: 'request' + }, + ADD_AD_UNITS: { call: 'addAdUnits' }, + AD_RENDER_FAILED: { call: 'adRenderFailed' }, + INVALID_EVENT: { + mockKey: 'this event should not emit' + } + }; + + describe('Invisibly Analytic tests specs', function() { + beforeEach(function() { + sinon.stub(events, 'getEvents').returns([]); + sinon.spy(invisiblyAdapter, 'track'); + }); + + afterEach(function() { + invisiblyAdapter.disableAnalytics(); + events.getEvents.restore(); + invisiblyAdapter.track.restore(); + }); + + // specs to test invisibly account input to enableAnaylitcs + describe('monitor enableAnalytics method', function() { + it('should catch all events triggered with invisibly account config', function() { + invisiblyAdapter.enableAnalytics({ + provider: 'invisiblyAnalytics', + options: { + account: 'invisibly' + } + }); + + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); + sinon.assert.callCount(invisiblyAdapter.track, 5); + }); + + it('should not catch events triggered without invisibly account config', function() { + invisiblyAdapter.enableAnalytics({ + provider: 'invisiblyAnalytics', + options: {} + }); + + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); + invisiblyAdapter.flush(); + sinon.assert.callCount(invisiblyAdapter.track, 0); + }); + // spec to test custom api endpoint + it('support custom endpoint', function() { + let custom_url = 'custom url'; + invisiblyAdapter.enableAnalytics({ + provider: 'invisiblyAnalytics', + options: { + url: custom_url, + bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', + account: 'invisibly' + } + }); + expect(invisiblyAdapter.getOptions().url).to.equal(custom_url); + }); + }); + + // spec for auction init event + it('auction init event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[1].requestBody.substring(0)); + // pageView is default event initially hence expecting 2 requests + expect(server.requests.length).to.equal(2); + expect(server.requests[1].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.auctionId).to.equal( + MOCK.AUCTION_INIT.auctionId + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_type).to.equal('PREBID_auctionInit'); + expect(invisiblyEvents.event_data.ver).to.equal(1); + }); + + // spec for bid adjustment event + it('bid adjustment event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BID_ADJUSTMENT, MOCK.BID_ADJUSTMENT); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidAdjustment'); + expect(invisiblyEvents.event_data.bidders.cpm).to.equal( + MOCK.BID_ADJUSTMENT.cpm + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bid timeout event + it('bid timeout event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BID_TIMEOUT, MOCK.BID_TIMEOUT); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidTimeout'); + expect(invisiblyEvents.event_data.bidders.bidId).to.equal( + MOCK.BID_TIMEOUT.bidId + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bid requested event + it('bid requested event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidRequested'); + expect(invisiblyEvents.event_data.auctionId).to.equal( + MOCK.BID_REQUESTED.auctionId + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bid response event + it('bid response event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidResponse'); + expect(invisiblyEvents.event_data.cpm).to.equal(MOCK.BID_REQUESTED.cpm); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for no bid event + it('no bid event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.NO_BID, MOCK.NO_BID); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_noBid'); + expect(invisiblyEvents.event_data.noBid.testKey).to.equal( + MOCK.NO_BID.testKey + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bid won event + it('bid won event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidWon'); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bidder done event + it('bidder done event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BIDDER_DONE, MOCK.BIDDER_DONE); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidderDone'); + expect(invisiblyEvents.event_data.bidderCode).to.equal( + MOCK.BIDDER_DONE.bidderCode + ); + expect(invisiblyEvents.event_data.bids.length).to.equal( + MOCK.BIDDER_DONE.bids.length + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for set targeting event + it('set targeting event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.SET_TARGETING, MOCK.SET_TARGETING); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_setTargeting'); + expect( + invisiblyEvents.event_data.targetings[BID1.adUnitCode] + ).to.deep.equal(BID1.adserverTargeting); + expect( + invisiblyEvents.event_data.targetings[BID3.adUnitCode] + ).to.deep.equal(BID3.adserverTargeting); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for request bids event + it('request bids event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.REQUEST_BIDS, MOCK.REQUEST_BIDS); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_requestBids'); + expect(invisiblyEvents.event_data.call).to.equal(MOCK.REQUEST_BIDS.call); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for add ad units event + it('add ad units event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.ADD_AD_UNITS, MOCK.ADD_AD_UNITS); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_addAdUnits'); + expect(invisiblyEvents.event_data.call).to.equal(MOCK.ADD_AD_UNITS.call); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for ad render failed event + it('ad render failed event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.AD_RENDER_FAILED, MOCK.AD_RENDER_FAILED); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_adRenderFailed'); + expect(invisiblyEvents.event_data.call).to.equal( + MOCK.AD_RENDER_FAILED.call + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for auction end event + it('auction end event', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse(server.requests[0].requestBody.substring(0)); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_auctionEnd'); + expect(invisiblyEvents.event_data.auctionId).to.equal( + MOCK.AUCTION_END.auctionId + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // should not call sendEvent for events not supported by the adapter + it('it should not call sendEvent for this event emit', function() { + sinon.spy(invisiblyAdapter, 'sendEvent'); + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.INVALID_EVENT, MOCK.INVALID_EVENT); + invisiblyAdapter.flush(); + + expect(server.requests.length).to.equal(0); + sinon.assert.callCount(invisiblyAdapter.track, 0); + sinon.assert.callCount(invisiblyAdapter.sendEvent, 0); + }); + + // spec to emit all events + it('track all event without errors', function() { + invisiblyAdapter.enableAnalytics(MOCK.config); + + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + events.emit(constants.EVENTS.BID_ADJUSTMENT, MOCK.BID_ADJUSTMENT); + events.emit(constants.EVENTS.BID_TIMEOUT, MOCK.BID_TIMEOUT); + events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + events.emit(constants.EVENTS.NO_BID, MOCK.NO_BID); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); + events.emit(constants.EVENTS.BIDDER_DONE, MOCK.BIDDER_DONE); + events.emit(constants.EVENTS.SET_TARGETING, MOCK.SET_TARGETING); + events.emit(constants.EVENTS.REQUEST_BIDS, MOCK.REQUEST_BIDS); + events.emit(constants.EVENTS.ADD_AD_UNITS, MOCK.ADD_AD_UNITS); + events.emit(constants.EVENTS.AD_RENDER_FAILED, MOCK.AD_RENDER_FAILED); + + sinon.assert.callCount(invisiblyAdapter.track, 13); + }); + }); +}); diff --git a/test/spec/modules/iqmBidAdapter_spec.js b/test/spec/modules/iqmBidAdapter_spec.js deleted file mode 100644 index 5535c52af9b..00000000000 --- a/test/spec/modules/iqmBidAdapter_spec.js +++ /dev/null @@ -1,219 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/iqmBidAdapter' -import * as utils from 'src/utils'; - -describe('iqmBidAdapter', function () { - const ENDPOINT_URL = 'https://pbd.bids.iqm.com'; - const bidRequests = [{ - bidder: 'iqm', - params: { - position: 1, - tagId: 'tagId-1', - placementId: 'placementId-1', - pubId: 'pubId-1', - secure: true, - bidfloor: 0.5 - }, - placementCode: 'pcode000', - transactionId: 'tx000', - sizes: [[300, 250]], - bidId: 'bid000', - bidderRequestId: '117d765b87bed38', - requestId: 'req000' - }]; - - const bidResponses = { - body: { - id: 'req000', - seatbid: [{ - bid: [{ - nurl: 'nurl', - adm: '', - crid: 'cr-65981', - impid: 'bid000', - price: 0.99, - w: 300, - h: 250, - adomain: ['https://example.com'], - id: 'bid000', - ttl: 300 - }] - }] - }, - headers: {}}; - - const bidResponseEmptySeat = { - body: { - id: 'req000', - seatbid: [] - }, - headers: {} - }; - - const bidResponseEmptyBid = { - body: { - id: 'req000', - seatbid: [{ - bid: [] - }] - }, - headers: {} - }; - - const bidResponseNoImpId = { - body: { - id: 'req000', - seatbid: [{ - bid: [{ - nurl: 'nurl', - adm: '', - crid: 'cr-65981', - price: 0.99, - w: 300, - h: 250, - adomain: ['https://example.com'], - id: 'bid000', - ttl: 300 - }] - }] - }, - headers: {} - }; - - describe('Request verification', function () { - it('basic property verification', function () { - expect(spec.code).to.equal('iqm'); - expect(spec.aliases).to.be.an('array'); - // expect(spec.aliases).to.be.ofSize(1); - expect(spec.aliases).to.have.lengthOf(1); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'iqm', - 'params': { - 'placementId': 'placementId', - 'tagId': 'tagId', - 'publisherId': 'pubId' - }, - 'adUnitCode': 'ad-unit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }; - - it('should return false for empty object', function () { - expect(spec.isBidRequestValid({})).to.equal(false); - }); - - it('should return false for request without param', function () { - let bid = Object.assign({}, bid); - delete bid.params; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false for invalid params', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 'placementId' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true for proper request', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - it('sends every bid request to ENDPOINT_URL via POST method', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].method).to.equal('POST'); - expect(requests[0].url).to.equal(ENDPOINT_URL); - // expect(requests[1].method).to.equal('POST'); - // expect(requests[1].url).to.equal(ENDPOINT_URL); - }); - - it('should send request data with every request', function () { - const requests = spec.buildRequests(bidRequests); - const data = requests[0].data; - expect(data.id).to.equal(bidRequests[0].requestId); - - expect(data.imp.id).to.equal(bidRequests[0].bidId); - expect(data.imp.bidfloor).to.equal(bidRequests[0].params.bidfloor); - expect(data.imp.secure).to.equal(1); - expect(data.imp.displaymanager).to.equal('Prebid.js'); - expect(data.imp.displaymanagerver).to.equal('v.1.0.0'); - expect(data.imp.mediatype).to.equal('banner'); - expect(data.imp.banner).to.deep.equal({ - w: 300, - h: 250 - }); - expect(data.publisherId).to.equal(utils.getBidIdParameter('publisherId', bidRequests[0].params)); - expect(data.tagId).to.equal(utils.getBidIdParameter('tagId', bidRequests[0].params)); - expect(data.placementId).to.equal(utils.getBidIdParameter('placementId', bidRequests[0].params)); - expect(data.device.w).to.equal(screen.width); - expect(data.device.h).to.equal(screen.height); - expect(data.device.make).to.equal(navigator.vendor ? navigator.vendor : ''); - expect(data.device.ua).to.equal(navigator.userAgent); - expect(data.device.dnt).to.equal(navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNotTrack === '1' || navigator.doNotTrack === 'yes' ? 1 : 0); - expect(data.site).to.deep.equal({ - id: utils.getBidIdParameter('tagId', bidRequests[0].params), - page: utils.getTopWindowLocation().href, - domain: utils.getTopWindowLocation().host - }); - - expect(data.device.ua).to.equal(navigator.userAgent); - expect(data.device.h).to.equal(screen.height); - expect(data.device.w).to.equal(screen.width); - - expect(data.site.id).to.equal(bidRequests[0].params.tagId); - expect(data.site.page).to.equal(utils.getTopWindowLocation().href); - expect(data.site.domain).to.equal(utils.getTopWindowLocation().host); - }); - }); - - describe('interpretResponse', function () { - it('should handle no bid response', function () { - const response = spec.interpretResponse({ body: null }, { bidRequests }); - expect(response.length).to.equal(0); - }); - - it('should have at least one Seat Object', function () { - const request = spec.buildRequests(bidRequests); - const response = spec.interpretResponse(bidResponseEmptySeat, request); - expect(response.length).to.equal(0); - }); - - it('should have at least one Bid Object', function () { - const request = spec.buildRequests(bidRequests); - const response = spec.interpretResponse(bidResponseEmptyBid, request); - expect(response.length).to.equal(0); - }); - - it('should have impId in Bid Object', function () { - const request = spec.buildRequests(bidRequests); - const response = spec.interpretResponse(bidResponseNoImpId, request); - expect(response.length).to.equal(0); - }); - - it('should handle valid response', function () { - const request = spec.buildRequests(bidRequests); - const response = spec.interpretResponse(bidResponses, request); - expect(response).to.be.an('array').to.have.lengthOf(1); - - let bid = response[0]; - expect(bid).to.have.property('requestId', 'bid000'); - expect(bid).to.have.property('currency', 'USD'); - expect(bid).to.have.property('cpm', 0.99); - expect(bid).to.have.property('creativeId', 'cr-65981'); - expect(bid).to.have.property('width', 300); - expect(bid).to.have.property('height', 250); - expect(bid).to.have.property('ttl', 300); - expect(bid).to.have.property('ad', ''); - }); - }); - }); -}); diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index 38e64e8d338..114a2226770 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -1,13 +1,31 @@ -import * as utils from 'src/utils'; -import { config } from 'src/config'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; import { expect } from 'chai'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { spec } from 'modules/ixBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { spec } from 'modules/ixBidAdapter.js'; describe('IndexexchangeAdapter', function () { - const IX_INSECURE_ENDPOINT = 'http://as.casalemedia.com/cygnus'; const IX_SECURE_ENDPOINT = 'https://as-sec.casalemedia.com/cygnus'; - const BIDDER_VERSION = 7.2; + const VIDEO_ENDPOINT_VERSION = 8.1; + const BANNER_ENDPOINT_VERSION = 7.2; + + const SAMPLE_SCHAIN = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; const DEFAULT_BANNER_VALID_BID = [ { @@ -26,20 +44,42 @@ describe('IndexexchangeAdapter', function () { transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229', bidId: '1a2b3c4d', bidderRequestId: '11a22b33c44d', - auctionId: '1aa2bb3cc4dd' + auctionId: '1aa2bb3cc4dd', + schain: SAMPLE_SCHAIN } ]; - const DEFAULT_BANNER_OPTION = { - gdprConsent: { - gdprApplies: true, - consentString: '3huaa11=qu3198ae', - vendorData: {} - }, - refererInfo: { - referer: 'http://www.prebid.org', - canonicalUrl: 'http://www.prebid.org/the/link/to/the/page' + + const DEFAULT_VIDEO_VALID_BID = [ + { + bidder: 'ix', + params: { + siteId: '456', + video: { + skippable: false, + mimes: [ + 'video/mp4', + 'video/webm' + ], + minduration: 0 + }, + size: [400, 100] + }, + sizes: [[400, 100], [200, 400]], + mediaTypes: { + video: { + context: 'instream', + playerSize: [[400, 100], [200, 400]] + } + }, + adUnitCode: 'div-gpt-ad-1460505748562-0', + transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230', + bidId: '1a2b3c4e', + bidderRequestId: '11a22b33c44e', + auctionId: '1aa2bb3cc4de', + schain: SAMPLE_SCHAIN } - }; + ]; + const DEFAULT_BANNER_BID_RESPONSE = { cur: 'USD', id: '11a22b33c44d', @@ -62,13 +102,55 @@ describe('IndexexchangeAdapter', function () { advbrandid: 303325, advbrand: 'OECTA' }, - adm: '
' + adm: '' } ], seat: '3970' } ] }; + + const DEFAULT_VIDEO_BID_RESPONSE = { + cur: 'USD', + id: '1aa2bb3cc4de', + seatbid: [ + { + bid: [ + { + crid: '12346', + adomain: ['www.abcd.com'], + adid: '14851456', + impid: '1a2b3c4e', + cid: '3051267', + price: 110, + id: '2', + ext: { + vasturl: 'www.abcd.com/vast', + errorurl: 'www.abcd.com/error', + dspid: 51, + pricelevel: '_110', + advbrandid: 303326, + advbrand: 'OECTB' + } + } + ], + seat: '3971' + } + ] + }; + + const DEFAULT_OPTION = { + gdprConsent: { + gdprApplies: true, + consentString: '3huaa11=qu3198ae', + vendorData: {} + }, + refererInfo: { + referer: 'https://www.prebid.org', + canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' + } + }; + const DEFAULT_IDENTITY_RESPONSE = { IdentityIp: { responsePending: false, @@ -83,6 +165,31 @@ describe('IndexexchangeAdapter', function () { } }; + const DEFAULT_BIDDER_REQUEST_DATA = { + ac: 'j', + r: JSON.stringify({ + id: '345', + imp: [ + { + id: '1a2b3c4e', + video: { + w: 640, + h: 480, + placement: 1 + } + } + ], + site: { + ref: 'https://ref.com/ref.html', + page: 'https://page.com' + }, + }), + s: '21', + sd: 1, + t: 1000, + v: 8.1 + }; + describe('inherited functions', function () { it('should exists and is a function', function () { const adapter = newBidder(spec); @@ -90,12 +197,33 @@ describe('IndexexchangeAdapter', function () { }); }); + describe('getUserSync tests', function () { + it('UserSync test : check type = iframe, check usermatch URL', function () { + const syncOptions = { + 'iframeEnabled': true + } + let userSync = spec.getUserSyncs(syncOptions); + expect(userSync[0].type).to.equal('iframe'); + const USER_SYNC_URL = 'https://js-sec.indexww.com/um/ixmatch.html'; + expect(userSync[0].url).to.equal(USER_SYNC_URL); + }); + + it('When iframeEnabled is false, no userSync should be returned', function () { + const syncOptions = { + 'iframeEnabled': false + } + let userSync = spec.getUserSyncs(syncOptions); + expect(userSync).to.be.an('array').that.is.empty; + }); + }); + describe('isBidRequestValid', function () { - it('should return true when required params found for a banner ad', function () { + it('should return true when required params found for a banner or video ad', function () { expect(spec.isBidRequestValid(DEFAULT_BANNER_VALID_BID[0])).to.equal(true); + expect(spec.isBidRequestValid(DEFAULT_VIDEO_VALID_BID[0])).to.equal(true); }); - it('should return true when optional params found for a banner ad', function () { + it('should return true when optional bidFloor params found for an ad', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.bidFloor = 50; bid.params.bidFloorCur = 'USD'; @@ -136,10 +264,10 @@ describe('IndexexchangeAdapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false when mediaTypes is not banner', function () { + it('should return false when mediaTypes is not banner or video', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.mediaTypes = { - video: { + native: { sizes: [[300, 250]] } }; @@ -156,19 +284,13 @@ describe('IndexexchangeAdapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false when mediaType is not banner', function () { - const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); - delete bid.params.mediaTypes; - bid.mediaType = 'banne'; - bid.sizes = [[300, 250]]; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when mediaType is video', function () { - const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); - delete bid.params.mediaTypes; - bid.mediaType = 'video'; - bid.sizes = [[300, 250]]; + it('should return false when mediaTypes.video does not have sizes', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.mediaTypes = { + video: { + size: [[300, 250]] + } + }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -195,6 +317,14 @@ describe('IndexexchangeAdapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(true); }); + it('should return true when mediaType is video', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + delete bid.mediaTypes; + bid.mediaType = 'video'; + bid.sizes = [[400, 100]]; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should return false when there is only bidFloor', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.bidFloor = 50; @@ -227,19 +357,19 @@ describe('IndexexchangeAdapter', function () { let query; let testCopy; - beforeEach(function() { + beforeEach(function () { window.headertag = {}; - window.headertag.getIdentityInfo = function() { + window.headertag.getIdentityInfo = function () { return testCopy; }; - request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; query = request.data; }); - afterEach(function() { + afterEach(function () { delete window.headertag; }); - describe('buildRequestSingleRTI', function() { - before(function() { + describe('buildRequestSingleRTI', function () { + before(function () { testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); }); it('payload should have correct format and value (single identity partner)', function () { @@ -258,15 +388,17 @@ describe('IndexexchangeAdapter', function () { }); }); - describe('buildRequestMultipleIds', function() { - before(function() { + describe('buildRequestMultipleIds', function () { + before(function () { testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); - testCopy.IdentityIp.data.uids.push({ - id: '1234567' - }, - { - id: '2019-04-01TF2:34:41' - }); + testCopy.IdentityIp.data.uids.push( + { + id: '1234567' + }, + { + id: '2019-04-01TF2:34:41' + } + ); }); it('payload should have correct format and value (single identity w/ multi ids)', function () { const payload = JSON.parse(query.r); @@ -285,8 +417,8 @@ describe('IndexexchangeAdapter', function () { }); }); - describe('buildRequestMultipleRTI', function() { - before(function() { + describe('buildRequestMultipleRTI', function () { + before(function () { testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); testCopy.JackIp = { responsePending: false, @@ -334,16 +466,16 @@ describe('IndexexchangeAdapter', function () { }); }); - describe('buildRequestNoData', function() { - beforeEach(function() { + describe('buildRequestNoData', function () { + beforeEach(function () { testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); }); it('payload should not have any user eids with an undefined identity data response', function () { - window.headertag.getIdentityInfo = function() { + window.headertag.getIdentityInfo = function () { return undefined; }; - request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; query = request.data; const payload = JSON.parse(query.r); @@ -356,7 +488,7 @@ describe('IndexexchangeAdapter', function () { responsePending: true, data: {} } - request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; query = request.data; const payload = JSON.parse(query.r); @@ -366,7 +498,7 @@ describe('IndexexchangeAdapter', function () { it('payload should not have any user eids if identity data is pending for all partners', function () { testCopy.IdentityIp.responsePending = true; - request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; query = request.data; const payload = JSON.parse(query.r); @@ -377,7 +509,7 @@ describe('IndexexchangeAdapter', function () { it('payload should not have any user eids if identity data is pending or not available for all partners', function () { testCopy.IdentityIp.responsePending = false; testCopy.IdentityIp.data = {}; - request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; query = request.data; const payload = JSON.parse(query.r); @@ -387,45 +519,56 @@ describe('IndexexchangeAdapter', function () { }); }); - describe('buildRequestsBanner', function () { - const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + describe('buildRequests', function () { + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; const requestUrl = request.url; const requestMethod = request.method; const query = request.data; + const bidWithoutSchain = utils.deepClone(DEFAULT_BANNER_VALID_BID); + delete bidWithoutSchain[0].schain; + const requestWithoutSchain = spec.buildRequests(bidWithoutSchain, DEFAULT_OPTION)[0]; + const queryWithoutSchain = requestWithoutSchain.data; + const bidWithoutMediaType = utils.deepClone(DEFAULT_BANNER_VALID_BID); delete bidWithoutMediaType[0].mediaTypes; bidWithoutMediaType[0].sizes = [[300, 250], [300, 600]]; - const requestWithoutMediaType = spec.buildRequests(bidWithoutMediaType, DEFAULT_BANNER_OPTION); + const requestWithoutMediaType = spec.buildRequests(bidWithoutMediaType, DEFAULT_OPTION)[0]; const queryWithoutMediaType = requestWithoutMediaType.data; it('request should be made to IX endpoint with GET method', function () { expect(requestMethod).to.equal('GET'); - expect(requestUrl).to.equal(IX_INSECURE_ENDPOINT); + expect(requestUrl).to.equal(IX_SECURE_ENDPOINT); }); it('query object (version, siteID and request) should be correct', function () { - expect(query.v).to.equal(BIDDER_VERSION); + expect(query.v).to.equal(BANNER_ENDPOINT_VERSION); expect(query.s).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId); expect(query.r).to.exist; expect(query.ac).to.equal('j'); expect(query.sd).to.equal(1); + expect(query.nf).not.to.exist; }); it('payload should have correct format and value', function () { const payload = JSON.parse(query.r); - expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId); expect(payload.site).to.exist; - expect(payload.site.page).to.equal(DEFAULT_BANNER_OPTION.refererInfo.referer); + expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.referer); expect(payload.site.ref).to.equal(document.referrer); expect(payload.ext).to.exist; expect(payload.ext.source).to.equal('prebid'); + expect(payload.source.ext.schain).to.deep.equal(SAMPLE_SCHAIN); expect(payload.imp).to.exist; expect(payload.imp).to.be.an('array'); expect(payload.imp).to.have.lengthOf(1); }); + it('payload should not include schain when not provided', function () { + const payload = JSON.parse(queryWithoutSchain.r); + expect(payload.source).to.not.exist; // source object currently only written for schain + }); + it('impression should have correct format and value', function () { const impression = JSON.parse(query.r).imp[0]; const sidValue = `${DEFAULT_BANNER_VALID_BID[0].params.size[0].toString()}x${DEFAULT_BANNER_VALID_BID[0].params.size[1].toString()}`; @@ -445,7 +588,7 @@ describe('IndexexchangeAdapter', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.bidFloor = 50; bid.params.bidFloorCur = 'USD'; - const requestBidFloor = spec.buildRequests([bid]); + const requestBidFloor = spec.buildRequests([bid])[0]; const impression = JSON.parse(requestBidFloor.data.r).imp[0]; expect(impression.bidfloor).to.equal(bid.params.bidFloor); @@ -457,7 +600,7 @@ describe('IndexexchangeAdapter', function () { expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId); expect(payload.site).to.exist; - expect(payload.site.page).to.equal(DEFAULT_BANNER_OPTION.refererInfo.referer); + expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.referer); expect(payload.site.ref).to.equal(document.referrer); expect(payload.ext).to.exist; expect(payload.ext.source).to.equal('prebid'); @@ -484,7 +627,7 @@ describe('IndexexchangeAdapter', function () { it('impression should have sid if id is configured as number', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.id = 50; - const requestBidFloor = spec.buildRequests([bid]); + const requestBidFloor = spec.buildRequests([bid])[0]; const impression = JSON.parse(requestBidFloor.data.r).imp[0]; expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); @@ -501,7 +644,7 @@ describe('IndexexchangeAdapter', function () { it('impression should have sid if id is configured as string', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.id = 'abc'; - const requestBidFloor = spec.buildRequests([bid]); + const requestBidFloor = spec.buildRequests([bid])[0]; const impression = JSON.parse(requestBidFloor.data.r).imp[0]; expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); expect(impression.banner).to.exist; @@ -526,9 +669,9 @@ describe('IndexexchangeAdapter', function () { } }); - const requestWithFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + const requestWithFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; const pageUrl = JSON.parse(requestWithFirstPartyData.data.r).site.page; - const expectedPageUrl = DEFAULT_BANNER_OPTION.refererInfo.referer + '?ab=123&cd=123%23ab&e%2Ff=456&h%3Fg=456%23cd'; + const expectedPageUrl = DEFAULT_OPTION.refererInfo.referer + '?ab=123&cd=123%23ab&e%2Ff=456&h%3Fg=456%23cd'; expect(pageUrl).to.equal(expectedPageUrl); }); @@ -540,10 +683,10 @@ describe('IndexexchangeAdapter', function () { } }); - const requestFirstPartyDataNumber = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + const requestFirstPartyDataNumber = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; const pageUrl = JSON.parse(requestFirstPartyDataNumber.data.r).site.page; - expect(pageUrl).to.equal(DEFAULT_BANNER_OPTION.refererInfo.referer); + expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer); }); it('should not set first party or timeout if it is not present', function () { @@ -551,18 +694,18 @@ describe('IndexexchangeAdapter', function () { ix: {} }); - const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; const pageUrl = JSON.parse(requestWithoutConfig.data.r).site.page; - expect(pageUrl).to.equal(DEFAULT_BANNER_OPTION.refererInfo.referer); + expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer); expect(requestWithoutConfig.data.t).to.be.undefined; }); it('should not set first party or timeout if it is setConfig is not called', function () { - const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; const pageUrl = JSON.parse(requestWithoutConfig.data.r).site.page; - expect(pageUrl).to.equal(DEFAULT_BANNER_OPTION.refererInfo.referer); + expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer); expect(requestWithoutConfig.data.t).to.be.undefined; }); @@ -572,7 +715,7 @@ describe('IndexexchangeAdapter', function () { timeout: 500 } }); - const requestWithTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID); + const requestWithTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; expect(requestWithTimeout.data.t).to.equal(500); }); @@ -583,14 +726,99 @@ describe('IndexexchangeAdapter', function () { timeout: '500' } }); - const requestStringTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID); + const requestStringTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; expect(requestStringTimeout.data.t).to.be.undefined; }); + + it('request should contain both banner and video requests', function () { + const request = spec.buildRequests([DEFAULT_BANNER_VALID_BID[0], DEFAULT_VIDEO_VALID_BID[0]]); + + const bannerImp = JSON.parse(request[0].data.r).imp[0]; + expect(JSON.parse(request[0].data.v)).to.equal(BANNER_ENDPOINT_VERSION); + expect(bannerImp.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); + expect(bannerImp.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); + expect(bannerImp.banner).to.exist; + expect(bannerImp.banner.w).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[0]); + expect(bannerImp.banner.h).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[1]); + + const videoImp = JSON.parse(request[1].data.r).imp[0]; + expect(JSON.parse(request[1].data.v)).to.equal(VIDEO_ENDPOINT_VERSION); + expect(videoImp.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(videoImp.video).to.exist; + expect(videoImp.video.w).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[0]); + expect(videoImp.video.h).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[1]); + }); }); - describe('interpretResponseBanner', function () { - it('should get correct bid response', function () { + describe('buildRequestVideo', function () { + const request = spec.buildRequests(DEFAULT_VIDEO_VALID_BID, DEFAULT_OPTION); + const query = request[0].data; + + it('query object (version, siteID and request) should be correct', function () { + expect(query.v).to.equal(VIDEO_ENDPOINT_VERSION); + expect(query.s).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.siteId); + expect(query.r).to.exist; + expect(query.ac).to.equal('j'); + expect(query.sd).to.equal(1); + expect(query.nf).to.equal(1); + }); + + it('impression should have correct format and value', function () { + const impression = JSON.parse(query.r).imp[0]; + const sidValue = `${DEFAULT_VIDEO_VALID_BID[0].params.size[0].toString()}x${DEFAULT_VIDEO_VALID_BID[0].params.size[1].toString()}`; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video).to.exist; + expect(impression.video.w).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[0]); + expect(impression.video.h).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[1]); + expect(impression.video.placement).to.exist; + expect(impression.video.placement).to.equal(1); + expect(impression.video.minduration).to.exist; + expect(impression.video.minduration).to.equal(0); + expect(impression.video.mimes).to.exist; + expect(impression.video.mimes[0]).to.equal('video/mp4'); + expect(impression.video.mimes[1]).to.equal('video/webm'); + + expect(impression.video.skippable).to.equal(false); + expect(impression.ext).to.exist; + expect(impression.ext.siteID).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.siteId.toString()); + expect(impression.ext.sid).to.equal(sidValue); + }); + + it('impression should have correct format when mediaType is specified.', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + delete bid.mediaTypes; + bid.mediaType = 'video'; + const requestBidFloor = spec.buildRequests([bid])[0]; + const impression = JSON.parse(requestBidFloor.data.r).imp[0]; + const sidValue = `${DEFAULT_VIDEO_VALID_BID[0].params.size[0].toString()}x${DEFAULT_VIDEO_VALID_BID[0].params.size[1].toString()}`; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video).to.exist; + expect(impression.video.w).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[0]); + expect(impression.video.h).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[1]); + expect(impression.video.placement).to.not.exist; + expect(impression.ext).to.exist; + expect(impression.ext.siteID).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.siteId.toString()); + expect(impression.ext.sid).to.equal(sidValue); + }); + + it('should set correct placement if context is outstream', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.mediaTypes.video.context = 'outstream'; + const request = spec.buildRequests([bid])[0]; + const impression = JSON.parse(request.data.r).imp[0]; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video).to.exist; + expect(impression.video.placement).to.exist; + expect(impression.video.placement).to.equal(4); + }); + }); + + describe('interpretResponse', function () { + it('should get correct bid response for banner ad', function () { const expectedParse = [ { requestId: '1a2b3c4d', @@ -598,9 +826,10 @@ describe('IndexexchangeAdapter', function () { creativeId: '12345', width: 300, height: 250, - ad: '', + mediaType: 'banner', + ad: '', currency: 'USD', - ttl: 35, + ttl: 300, netRevenue: true, dealId: undefined, meta: { @@ -610,7 +839,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }); + const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA }); expect(result[0]).to.deep.equal(expectedParse[0]); }); @@ -624,9 +853,10 @@ describe('IndexexchangeAdapter', function () { creativeId: '-', width: 300, height: 250, - ad: '', + mediaType: 'banner', + ad: '', currency: 'USD', - ttl: 35, + ttl: 300, netRevenue: true, dealId: undefined, meta: { @@ -636,8 +866,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: bidResponse }); - expect(result[0]).to.deep.equal(expectedParse[0]); + const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA }); }); it('should set Japanese price correctly', function () { @@ -650,9 +879,10 @@ describe('IndexexchangeAdapter', function () { creativeId: '12345', width: 300, height: 250, - ad: '', + mediaType: 'banner', + ad: '', currency: 'JPY', - ttl: 35, + ttl: 300, netRevenue: true, dealId: undefined, meta: { @@ -662,7 +892,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: bidResponse }); + const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA }); expect(result[0]).to.deep.equal(expectedParse[0]); }); @@ -676,9 +906,10 @@ describe('IndexexchangeAdapter', function () { creativeId: '12345', width: 300, height: 250, - ad: '', + mediaType: 'banner', + ad: '', currency: 'USD', - ttl: 35, + ttl: 300, netRevenue: true, dealId: 'deal', meta: { @@ -688,19 +919,79 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: bidResponse }); + const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA }); expect(result[0]).to.deep.equal(expectedParse[0]); }); - it('bidrequest should have consent info if gdprApplies and consentString exist', function () { - const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); - const requestWithConsent = JSON.parse(validBidWithConsent.data.r); + it('should get correct bid response for video ad', function () { + const expectedParse = [ + { + requestId: '1a2b3c4e', + cpm: 1.1, + creativeId: '12346', + mediaType: 'video', + width: 640, + height: 480, + currency: 'USD', + ttl: 3600, + netRevenue: true, + dealId: undefined, + vastUrl: 'www.abcd.com/vast', + meta: { + networkId: 51, + brandId: 303326, + brandName: 'OECTB' + } + } + ]; + const result = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA }); + expect(result[0]).to.deep.equal(expectedParse[0]); + }); + + it('bidrequest should not have page if options is undefined', function () { + const options = {}; + const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); + const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r); + + expect(requestWithoutreferInfo.site.page).to.be.undefined; + expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT); + }); + + it('bidrequest should not have page if options.refererInfo is an empty object', function () { + const options = { + refererInfo: {} + }; + const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); + const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r); + + expect(requestWithoutreferInfo.site.page).to.be.undefined; + expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT); + }); + + it('bidrequest should sent to secure endpoint if page url is secure', function () { + const options = { + refererInfo: { + referer: 'https://www.prebid.org' + } + }; + const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); + const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r); + + expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.referer); + expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT); + }); + }); + + describe('bidrequest consent', function () { + it('should have consent info if gdprApplies and consentString exist', function () { + const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); + const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); expect(requestWithConsent.regs.ext.gdpr).to.equal(1); expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae'); }); - it('bidrequest should not have consent field if consentString is undefined', function () { + it('should not have consent field if consentString is undefined', function () { const options = { gdprConsent: { gdprApplies: true, @@ -708,13 +999,13 @@ describe('IndexexchangeAdapter', function () { } }; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent.data.r); + const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); expect(requestWithConsent.regs.ext.gdpr).to.equal(1); expect(requestWithConsent.user).to.be.undefined; }); - it('bidrequest should not have gdpr field if gdprApplies is undefined', function () { + it('should not have gdpr field if gdprApplies is undefined', function () { const options = { gdprConsent: { consentString: '3huaa11=qu3198ae', @@ -722,52 +1013,51 @@ describe('IndexexchangeAdapter', function () { } }; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent.data.r); + const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); expect(requestWithConsent.regs).to.be.undefined; expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae'); }); - it('bidrequest should not have consent info if options.gdprConsent is undefined', function () { + it('should not have consent info if options.gdprConsent is undefined', function () { const options = {}; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent.data.r); + const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); expect(requestWithConsent.regs).to.be.undefined; expect(requestWithConsent.user).to.be.undefined; }); - it('bidrequest should not have page if options is undefined', function () { - const options = {}; - const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo.data.r); + it('should have us_privacy if uspConsent is defined', function () { + const options = { + uspConsent: '1YYN' + }; + const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); + const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r); - expect(requestWithoutreferInfo.site.page).to.be.undefined; - expect(validBidWithoutreferInfo.url).to.equal(IX_SECURE_ENDPOINT); + expect(requestWithUspConsent.regs.ext.us_privacy).to.equal('1YYN'); }); - it('bidrequest should not have page if options.refererInfo is an empty object', function () { - const options = { - refererInfo: {} - }; - const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo.data.r); + it('should not have us_privacy if uspConsent undefined', function () { + const options = {}; + const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); + const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r); - expect(requestWithoutreferInfo.site.page).to.be.undefined; - expect(validBidWithoutreferInfo.url).to.equal(IX_SECURE_ENDPOINT); + expect(requestWithUspConsent.regs).to.be.undefined; }); - it('bidrequest should sent to secure endpoint if page url is secure', function () { + it('should have both gdpr and us_privacy if both are defined', function () { const options = { - refererInfo: { - referer: 'https://www.prebid.org' - } + gdprConsent: { + gdprApplies: true, + vendorData: {} + }, + uspConsent: '1YYN' }; - const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo.data.r); - - expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.referer); - expect(validBidWithoutreferInfo.url).to.equal(IX_SECURE_ENDPOINT); + const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); + const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); + expect(requestWithConsent.regs.ext.gdpr).to.equal(1); + expect(requestWithConsent.regs.ext.us_privacy).to.equal('1YYN'); }); }); }); diff --git a/test/spec/modules/jcmBidAdapter_spec.js b/test/spec/modules/jcmBidAdapter_spec.js index 0b467e1ecfb..9d84bca5513 100644 --- a/test/spec/modules/jcmBidAdapter_spec.js +++ b/test/spec/modules/jcmBidAdapter_spec.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { spec } from 'modules/jcmBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/jcmBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; -const ENDPOINT = '//media.adfrontiers.com/'; +const ENDPOINT = 'https://media.adfrontiers.com/'; describe('jcmAdapter', function () { const adapter = newBidder(spec); @@ -124,7 +124,7 @@ describe('jcmAdapter', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('iframe'); - expect(options[0].url).to.equal('//media.adfrontiers.com/hb/jcm_usersync.html'); + expect(options[0].url).to.equal('https://media.adfrontiers.com/hb/jcm_usersync.html'); }); it('Verifies sync image option', function () { @@ -133,7 +133,7 @@ describe('jcmAdapter', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('image'); - expect(options[0].url).to.equal('//media.adfrontiers.com/hb/jcm_usersync.png'); + expect(options[0].url).to.equal('https://media.adfrontiers.com/hb/jcm_usersync.png'); }); }); }); diff --git a/test/spec/modules/justpremiumBidAdapter_spec.js b/test/spec/modules/justpremiumBidAdapter_spec.js index c3cd015b6e3..c162b785aed 100644 --- a/test/spec/modules/justpremiumBidAdapter_spec.js +++ b/test/spec/modules/justpremiumBidAdapter_spec.js @@ -1,13 +1,11 @@ import { expect } from 'chai' -import { spec, pixel } from 'modules/justpremiumBidAdapter' +import { spec } from 'modules/justpremiumBidAdapter.js' describe('justpremium adapter', function () { let sandbox; - let pixelStub; beforeEach(function() { sandbox = sinon.sandbox.create(); - pixelStub = sandbox.stub(pixel, 'fire'); }); afterEach(function() { @@ -46,8 +44,9 @@ describe('justpremium adapter', function () { ] let bidderRequest = { + uspConsent: '1YYN', refererInfo: { - referer: 'http://justpremium.com' + referer: 'https://justpremium.com' } } @@ -73,20 +72,21 @@ describe('justpremium adapter', function () { const jpxRequest = JSON.parse(request.data) expect(jpxRequest).to.not.equal(null) expect(jpxRequest.zone).to.not.equal('undefined') - expect(bidderRequest.refererInfo.referer).to.equal('http://justpremium.com') + expect(bidderRequest.refererInfo.referer).to.equal('https://justpremium.com') expect(jpxRequest.sw).to.equal(window.top.screen.width) expect(jpxRequest.sh).to.equal(window.top.screen.height) expect(jpxRequest.ww).to.equal(window.top.innerWidth) expect(jpxRequest.wh).to.equal(window.top.innerHeight) expect(jpxRequest.c).to.not.equal('undefined') expect(jpxRequest.id).to.equal(adUnits[0].params.zone) - expect(jpxRequest.sizes).to.not.equal('undefined') + expect(jpxRequest.mediaTypes && jpxRequest.mediaTypes.banner && jpxRequest.mediaTypes.banner.sizes).to.not.equal('undefined') expect(jpxRequest.version.prebid).to.equal('$prebid.version$') - expect(jpxRequest.version.jp_adapter).to.equal('1.4') + expect(jpxRequest.version.jp_adapter).to.equal('1.7') expect(jpxRequest.pubcid).to.equal('0000000') expect(jpxRequest.uids.tdid).to.equal('1111111') expect(jpxRequest.uids.id5id).to.equal('2222222') expect(jpxRequest.uids.digitrustid.data.id).to.equal('3333333') + expect(jpxRequest.us_privacy).to.equal('1YYN') }) }) @@ -157,40 +157,12 @@ describe('justpremium adapter', function () { describe('getUserSyncs', function () { it('Verifies sync options', function () { - const options = spec.getUserSyncs({iframeEnabled: true}) + const options = spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true, consentString: 'BOOgjO9OOgjO9APABAENAi-AAAAWd'}, '1YYN') expect(options).to.not.be.undefined expect(options[0].type).to.equal('iframe') expect(options[0].url).to.match(/\/\/pre.ads.justpremium.com\/v\/1.0\/t\/sync/) - }) - }) - - describe('onTimeout', function () { - it('onTimeout', function(done) { - spec.onTimeout([{ - 'bidId': '25cd3ec3fd6ed7', - 'bidder': 'justpremium', - 'adUnitCode': 'div-gpt-ad-1471513102552-1', - 'auctionId': '6fbd0562-f613-4151-a6df-6cb446fc717b', - 'params': [{ - 'adType': 'iab', - 'zone': 21521 - }], - 'timeout': 1 - }, { - 'bidId': '3b51df1f254e32', - 'bidder': 'justpremium', - 'adUnitCode': 'div-gpt-ad-1471513102552-3', - 'auctionId': '6fbd0562-f613-4151-a6df-6cb446fc717b', - 'params': [{ - 'adType': 'iab', - 'zone': 21521 - }], - 'timeout': 1 - }]); - - expect(pixelStub.calledOnce).to.equal(true); - - done() + expect(options[0].url).to.match(/&consentString=BOOgjO9OOgjO9APABAENAi-AAAAWd/) + expect(options[0].url).to.match(/&usPrivacy=1YYN/) }) }) }) diff --git a/test/spec/modules/kargoBidAdapter_spec.js b/test/spec/modules/kargoBidAdapter_spec.js index fd0e22b91b9..be73e140839 100644 --- a/test/spec/modules/kargoBidAdapter_spec.js +++ b/test/spec/modules/kargoBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect, assert} from 'chai'; -import {spec} from 'modules/kargoBidAdapter'; -import {config} from 'src/config'; +import {spec} from 'modules/kargoBidAdapter.js'; +import {config} from 'src/config.js'; describe('kargo adapter tests', function () { var sandbox, clock, frozenNow = new Date(); @@ -49,6 +49,8 @@ describe('kargo adapter tests', function () { } return {adServerCurrency: 'USD'}; } + if (key === 'debug') return true; + if (key === 'deviceAccess') return true; throw new Error(`Config stub incomplete! Missing key "${key}"`) }); @@ -253,7 +255,8 @@ describe('kargo adapter tests', function () { '2_80': 'd2a855a5-1b1c-4300-940e-a708fa1f1bde', '2_93': '5ee24138-5e03-4b9d-a953-38e833f2849f' }, - optOut: false + optOut: false, + usp: '1---' }, krux: { userID: 'rsgr9pnij', @@ -298,7 +301,8 @@ describe('kargo adapter tests', function () { if (excludeUserIds === true) { base.userIDs = { - crbIDs: {} + crbIDs: {}, + usp: '1---' }; delete base.prebidRawBidRequests[0].userId.tdid; } @@ -318,7 +322,7 @@ describe('kargo adapter tests', function () { if (excludeTdid) { delete clonedBids[0].userId.tdid; } - var request = spec.buildRequests(clonedBids, {timeout: 200, foo: 'bar'}); + var request = spec.buildRequests(clonedBids, {timeout: 200, uspConsent: '1---', foo: 'bar'}); expected.sessionId = getSessionId(); sessionIds.push(expected.sessionId); var krakenParams = JSON.parse(decodeURIComponent(request.data.slice(5))); @@ -437,7 +441,8 @@ describe('kargo adapter tests', function () { cpm: 3, adm: '
', width: 320, - height: 50 + height: 50, + metadata: {} }, 2: { id: 'bar', @@ -445,7 +450,10 @@ describe('kargo adapter tests', function () { adm: '
', width: 300, height: 250, - targetingCustom: 'dmpmptest1234' + targetingCustom: 'dmpmptest1234', + metadata: { + landingPageDomain: 'https://foobar.com' + } }, 3: { id: 'bar', @@ -483,7 +491,8 @@ describe('kargo adapter tests', function () { creativeId: 'foo', dealId: undefined, netRevenue: true, - currency: 'USD' + currency: 'USD', + meta: undefined }, { requestId: '2', cpm: 2.5, @@ -494,7 +503,10 @@ describe('kargo adapter tests', function () { creativeId: 'bar', dealId: 'dmpmptest1234', netRevenue: true, - currency: 'USD' + currency: 'USD', + meta: { + clickUrl: 'https://foobar.com' + } }, { requestId: '3', cpm: 2.5, @@ -505,7 +517,8 @@ describe('kargo adapter tests', function () { creativeId: 'bar', dealId: undefined, netRevenue: true, - currency: 'USD' + currency: 'USD', + meta: undefined }]; expect(resp).to.deep.equal(expectation); }); diff --git a/test/spec/modules/komoonaBidAdapter_spec.js b/test/spec/modules/komoonaBidAdapter_spec.js index b6d17c7b20c..3d62f91cae6 100644 --- a/test/spec/modules/komoonaBidAdapter_spec.js +++ b/test/spec/modules/komoonaBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/komoonaBidAdapter'; +import { spec } from 'modules/komoonaBidAdapter.js'; describe('Komoona.com Adapter Tests', function () { const bidsRequest = [ @@ -44,7 +44,7 @@ describe('Komoona.com Adapter Tests', function () { width: 300, height: 250, cpm: 0.51, - creative: '', + creative: '', ttl: 360, currency: 'USD', netRevenue: true, @@ -73,7 +73,7 @@ describe('Komoona.com Adapter Tests', function () { var startTime = new Date().getTime(); const request = spec.buildRequests(bidsRequest); - expect(request.url).to.equal('//bidder.komoona.com/v1/GetSBids'); + expect(request.url).to.equal('https://bidder.komoona.com/v1/GetSBids'); expect(request.method).to.equal('POST'); const requestData = JSON.parse(request.data); @@ -159,6 +159,6 @@ describe('Komoona.com Adapter Tests', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('iframe'); - expect(options[0].url).to.equal('//s.komoona.com/sync/usync.html'); + expect(options[0].url).to.equal('https://s.komoona.com/sync/usync.html'); }); }); diff --git a/test/spec/modules/konduitWrapper_spec.js b/test/spec/modules/konduitWrapper_spec.js index bcc65ddd683..4a0c627e885 100644 --- a/test/spec/modules/konduitWrapper_spec.js +++ b/test/spec/modules/konduitWrapper_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; import parse from 'url-parse'; -import { buildVastUrl } from 'modules/konduitWrapper'; -import { parseQS } from 'src/url'; -import { config } from 'src/config'; +import { buildVastUrl } from 'modules/konduitWrapper.js'; +import { parseQS } from 'src/utils.js'; +import { config } from 'src/config.js'; describe('The Konduit vast wrapper module', function () { it('should make a wrapped request url when `bid` passed', function () { diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js new file mode 100644 index 00000000000..a236ac17d71 --- /dev/null +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -0,0 +1,335 @@ +import { expect } from 'chai'; +import { spec } from 'modules/lemmaBidAdapter.js'; +import * as utils from 'src/utils.js'; +const constants = require('src/constants.json'); + +describe('lemmaBidAdapter', function() { + var bidRequests; + var videoBidRequests; + var bidResponses; + beforeEach(function() { + bidRequests = [{ + bidder: 'lemma', + mediaType: 'banner', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD', + geo: { + lat: '12.3', + lon: '23.7', + } + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + videoBidRequests = [{ + code: 'video1', + mediaType: 'video', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bidder: 'lemma', + params: { + pubId: 1001, + adunitId: 1, + video: { + mimes: ['video/mp4', 'video/x-flv'], + skippable: true, + minduration: 5, + maxduration: 30 + } + } + }]; + bidResponses = { + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [{ + 'bid': [{ + 'id': '74858439-49D7-4169-BA5D-44A046315B2F', + 'impid': '22bddb28db77d', + 'price': 1.3, + 'adm': '

lemma"Connecting Advertisers and Publishers directly"

', + 'adomain': ['amazon.com'], + 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', + 'cid': '22918', + 'crid': 'v55jutrh', + 'h': 250, + 'w': 300, + 'ext': {} + }] + }] + } + }; + }); + describe('implementation', function() { + describe('Bid validations', function() { + it('valid bid case', function() { + var validBid = { + bidder: 'lemma', + params: { + pubId: 1001, + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); + it('invalid bid case', function() { + var isValid = spec.isBidRequestValid(); + expect(isValid).to.equal(false); + }); + it('invalid bid case: pubId not passed', function() { + var validBid = { + bidder: 'lemma', + params: { + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: pubId is not number', function() { + var validBid = { + bidder: 'lemma', + params: { + pubId: '301', + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: adunitId is not passed', function() { + var validBid = { + bidder: 'lemma', + params: { + pubId: 1001 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: video bid request mimes is not passed', function() { + var validBid = { + bidder: 'lemma', + params: { + pubId: 1001, + adunitId: 1, + video: { + skippable: true, + minduration: 5, + maxduration: 30 + } + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + validBid.params.video.mimes = []; + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + }); + describe('Request formation', function() { + it('buildRequests function should not modify original bidRequests object', function() { + var originalBidRequests = utils.deepClone(bidRequests); + var request = spec.buildRequests(bidRequests); + expect(bidRequests).to.deep.equal(originalBidRequests); + }); + it('Endpoint checking', function() { + var request = spec.buildRequests(bidRequests); + expect(request.url).to.equal('https://ads.lemmatechnologies.com/lemma/servad?pid=1001&aid=1'); + expect(request.method).to.equal('POST'); + }); + it('Request params check', function() { + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id + expect(data.imp[0].tagid).to.equal('1'); // tagid + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + }); + it('Request params check without mediaTypes object', function() { + var bidRequests = [{ + bidder: 'lemma', + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].banner.format).exist.and.to.be.an('array'); + expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); + expect(data.imp[0].banner.format[0].w).to.equal(300); // width + expect(data.imp[0].banner.format[0].h).to.equal(600); // height + }); + it('Request params check: without tagId', function() { + delete bidRequests[0].params.adunitId; + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id + expect(data.imp[0].tagid).to.equal(undefined); // tagid + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + }); + it('Request params multi size format object check', function() { + var bidRequests = [{ + bidder: 'lemma', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + /* case 1 - size passed in adslot */ + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + /* case 2 - size passed in adslot as well as in sizes array */ + bidRequests[0].sizes = [ + [300, 600], + [300, 250] + ]; + bidRequests[0].mediaTypes = { + banner: { + sizes: [ + [300, 600], + [300, 250] + ] + } + }; + request = spec.buildRequests(bidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(600); // height + /* case 3 - size passed in sizes but not in adslot */ + bidRequests[0].params.adunitId = 1; + bidRequests[0].sizes = [ + [300, 250], + [300, 600] + ]; + bidRequests[0].mediaTypes = { + banner: { + sizes: [ + [300, 250], + [300, 600] + ] + } + }; + request = spec.buildRequests(bidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].banner.format).exist.and.to.be.an('array'); + expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); + expect(data.imp[0].banner.format[0].w).to.equal(300); // width + expect(data.imp[0].banner.format[0].h).to.equal(250); // height + }); + it('Request params currency check', function() { + var bidRequest = [{ + bidder: 'lemma', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + /* case 1 - + currency specified in adunits + output: imp[0] use currency specified in bidRequests[0].params.currency + */ + var request = spec.buildRequests(bidRequest); + var data = JSON.parse(request.data); + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + /* case 2 - + currency specified in adunit + output: imp[0] use default currency - USD + */ + delete bidRequest[0].params.currency; + request = spec.buildRequests(bidRequest); + data = JSON.parse(request.data); + expect(data.imp[0].bidfloorcur).to.equal('USD'); + }); + it('Request params check for video ad', function() { + var request = spec.buildRequests(videoBidRequests); + var data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist; + expect(data.imp[0].tagid).to.equal('1'); + 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]); + expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); + expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); + expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); + }); + describe('Response checking', function() { + it('should check for valid response values', function() { + var request = spec.buildRequests(bidRequests); + var data = JSON.parse(request.data); + var response = spec.interpretResponse(bidResponses, request); + expect(response).to.be.an('array').with.length.above(0); + expect(response[0].requestId).to.equal(bidResponses.body.seatbid[0].bid[0].impid); + expect(response[0].cpm).to.equal((bidResponses.body.seatbid[0].bid[0].price).toFixed(2)); + expect(response[0].width).to.equal(bidResponses.body.seatbid[0].bid[0].w); + expect(response[0].height).to.equal(bidResponses.body.seatbid[0].bid[0].h); + if (bidResponses.body.seatbid[0].bid[0].crid) { + expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].crid); + } else { + expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].id); + } + expect(response[0].dealId).to.equal(bidResponses.body.seatbid[0].bid[0].dealid); + expect(response[0].currency).to.equal('USD'); + expect(response[0].netRevenue).to.equal(false); + expect(response[0].ttl).to.equal(300); + }); + }); + }); + }); +}); diff --git a/test/spec/modules/lifestreetBidAdapter_spec.js b/test/spec/modules/lifestreetBidAdapter_spec.js index 7f8c5f6c44d..d66727da644 100644 --- a/test/spec/modules/lifestreetBidAdapter_spec.js +++ b/test/spec/modules/lifestreetBidAdapter_spec.js @@ -1,222 +1,232 @@ -import {expect} from 'chai'; -import * as utils from 'src/utils'; -import {spec} from 'modules/lifestreetBidAdapter'; -import {config} from 'src/config'; - -let getDefaultBidRequest = () => { - return { - bidderCode: 'lifestreet', - auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', - bidderRequestId: '7101db09af0dg2', - start: new Date().getTime(), - bids: [{ - bidder: 'lifestreet', - bidId: '84ab500420329d', - bidderRequestId: '7101db09af0dg2', - auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', - placementCode: 'foo', - params: getBidParams() - }] - }; -}; - -let getVASTAd = () => { - return ` - - - Lifestreet wrapper - - - - - - `; -}; - -let getBidParams = () => { - return { - slot: 'slot166704', - adkey: '78c', - ad_size: '160x600' - }; -}; - -let getDefaultBidResponse = (isBanner, noBid = 0) => { - let noBidContent = isBanner ? '{"advertisementAvailable": false}' : ''; - let content = isBanner ? '' : getVASTAd(); - return { - status: noBid ? 0 : 1, - cpm: 1.0, - width: 160, - height: 600, - creativeId: 'test', - dealId: 'test', - content: noBid ? noBidContent : content, - content_type: isBanner ? 'display' : 'vast_2_0' - }; -}; - -describe('LifestreetAdapter', function () { - const LIFESTREET_URL = '//ads.lfstmedia.com/gate/'; - const ADAPTER_VERSION = 'prebidJS-2.0'; - - describe('buildRequests()', function () { - it('method exists and is a function', function () { - expect(spec.buildRequests).to.exist.and.to.be.a('function'); - }); - - it('should not return request when no bids are present', function () { - let [request] = spec.buildRequests([]); - expect(request).to.be.undefined; - }); - - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - it('should return request for Lifestreet endpoint', function () { - expect(request.url).to.contain(LIFESTREET_URL); - }); +import { expect } from 'chai'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; +import { spec } from 'modules/lifestreetBidAdapter.js'; - it('should use json adapter', function () { - expect(request.url).to.contain('/prebid/'); - }); +describe('lifestreetBidAdapter', function() { + let bidRequests; + let videoBidRequests; + let bidResponses; + let videoBidResponses; + beforeEach(function() { + bidRequests = [ + { + bidder: 'lifestreet', + params: { + slot: 'slot166704', + adkey: '78c', + ad_size: '160x600' + }, + mediaTypes: { + banner: { + sizes: [ + [160, 600], + [300, 600] + ] + } + }, + sizes: [ + [160, 600], + [300, 600] + ] + } + ]; - it('should contain slot', function () { - expect(request.url).to.contain('slot166704'); - }); - it('should contain adkey', function () { - expect(request.url).to.contain('adkey=78c'); - }); - it('should contain ad_size', function () { - expect(request.url).to.contain('ad_size=160x600'); - }); - - it('should contain location and rferrer paramters', function () { - expect(request.url).to.contain('__location='); - expect(request.url).to.contain('__referrer='); - }); - it('should contain info parameters', function () { - expect(request.url).to.contain('__wn='); - expect(request.url).to.contain('__sf='); - expect(request.url).to.contain('__fif='); - expect(request.url).to.contain('__if='); - expect(request.url).to.contain('__stamp='); - expect(request.url).to.contain('__pp='); - }); - - it('should contain HB enabled', function () { - expect(request.url).to.contain('__hb=1'); - }); - it('should include gzip', function () { - expect(request.url).to.contain('__gz=1'); - }); - it('should not contain __gdpr parameter', function () { - expect(request.url).to.not.contain('__gdpr'); - }); - it('should not contain __concent parameter', function () { - expect(request.url).to.not.contain('__consent'); - }); - - it('should contain the right version of adapter', function () { - expect(request.url).to.contain('__hbver=' + ADAPTER_VERSION); - }); - - it('should contain __gdpr and __consent parameters', function () { - const options = { - gdprConsent: { - gdprApplies: true, - consentString: 'test', - vendorData: {} - } - }; - let [request] = spec.buildRequests(bidRequest.bids, options); - expect(request.url).to.contain('__gdpr=1'); - expect(request.url).to.contain('__consent=test'); - }); - it('should contain __gdpr parameters', function () { - const options = { - gdprConsent: { - gdprApplies: true, - vendorData: {} - } - }; - let [request] = spec.buildRequests(bidRequest.bids, options); - expect(request.url).to.contain('__gdpr=1'); - expect(request.url).to.not.contain('__consent'); - }); - it('should contain __consent parameters', function () { - const options = { - gdprConsent: { - consentString: 'test', - vendorData: {} - } - }; - let [request] = spec.buildRequests(bidRequest.bids, options); - expect(request.url).to.not.contain('__gdpr'); - expect(request.url).to.contain('__consent=test'); - }); - }); - describe('interpretResponse()', function () { - it('should return formatted bid response with required properties', function () { - let bidRequest = getDefaultBidRequest().bids[0]; - let bidResponse = { body: getDefaultBidResponse(true) }; - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.deep.equal([{ - requestId: bidRequest.bidId, - cpm: 1.0, - width: 160, - height: 600, - ad: '', - creativeId: 'test', - currency: 'USD', - dealId: 'test', + bidResponses = { + body: { + cpm: 0.1, netRevenue: true, - ttl: 86400, - mediaType: 'banner' - }]); - }); - it('should return formatted VAST bid response with required properties', function () { - let bidRequest = getDefaultBidRequest().bids[0]; - let bidResponse = { body: getDefaultBidResponse(false) }; - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.deep.equal([{ - requestId: bidRequest.bidId, - cpm: 1.0, + content_type: 'display_flash', width: 160, - height: 600, - vastXml: getVASTAd(), - creativeId: 'test', currency: 'USD', - dealId: 'test', - netRevenue: true, ttl: 86400, - mediaType: 'video' - }]); - }); - it('should return formatted VAST bid response with vastUrl', function () { - let bidRequest = getDefaultBidRequest().bids[0]; - let bidResponse = { body: getDefaultBidResponse(false) }; - bidResponse.body.vastUrl = 'http://lifestreet.com'; // set vastUrl - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.deep.equal([{ - requestId: bidRequest.bidId, - cpm: 1.0, - width: 160, + content: '', - 'price': 0.8, - 'creativeId': '12610997325162499419', - 'exp': 30, - 'cookies': [{ - 'src': 'https://sync.com', - 'type': 'iframe' - }, { - 'src': 'https://sync.com', - 'type': 'img' + results: [{ + 'ad': '', + 'price': 0.8, + 'creativeId': '12610997325162499419', + 'exp': 30, + 'width': 300, + 'height': 250, + 'cookies': [{ + 'src': 'https://sync.com', + 'type': 'iframe' + }, { + 'src': 'https://sync.com', + 'type': 'img' + }] }] } }; @@ -111,37 +119,20 @@ describe('VidazooBidAdapter', function () { let sandbox; before(function () { sandbox = sinon.sandbox.create(); - sandbox.stub(utils, 'getTopWindowUrl').returns('http://www.greatsite.com'); sandbox.stub(Date, 'now').returns(1000); }); it('should build request for each size', function () { const requests = adapter.buildRequests([BID], BIDDER_REQUEST); - expect(requests).to.have.length(2); + expect(requests).to.have.length(1); expect(requests[0]).to.deep.equal({ - method: 'GET', - url: `${URL}/prebid/59db6b3b4ffaa70004f45cdc`, + method: 'POST', + url: `${URL}/prebid/multi/59db6b3b4ffaa70004f45cdc`, data: { - consent: 'consent_string', - width: '300', - height: '250', - url: 'http://www.greatsite.com', - cb: 1000, - bidFloor: 0.1, - bidId: '2d52001cabd527', - publisherId: '59ac17c192832d0011283fe3', - 'ext.param1': 'loremipsum', - 'ext.param2': 'dolorsitamet', - } - }); - expect(requests[1]).to.deep.equal({ - method: 'GET', - url: `${URL}/prebid/59db6b3b4ffaa70004f45cdc`, - data: { - consent: 'consent_string', - width: '300', - height: '600', - url: 'http://www.greatsite.com', + gdprConsent: 'consent_string', + gdpr: 1, + sizes: ['300x250', '300x600'], + url: 'https%3A%2F%2Fwww.greatsite.com', cb: 1000, bidFloor: 0.1, bidId: '2d52001cabd527', @@ -156,6 +147,25 @@ describe('VidazooBidAdapter', function () { sandbox.restore(); }); }); + describe('getUserSyncs', function () { + it('should have valid user sync with iframeEnabled', function () { + const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]); + + expect(result).to.deep.equal([{ + type: 'iframe', + url: 'https://static.cootlogix.com/basev/sync/user_sync.html' + }]); + }); + + it('should have valid user sync with pixelEnabled', function () { + const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE]); + + expect(result).to.deep.equal([{ + 'url': 'https://sync.com', + 'type': 'image' + }]); + }) + }); describe('interpret response', function () { it('should return empty array when there is no response', function () { @@ -191,7 +201,7 @@ describe('VidazooBidAdapter', function () { it('should take default TTL', function () { const serverResponse = utils.deepClone(SERVER_RESPONSE); - delete serverResponse.body.exp; + delete serverResponse.body.results[0].exp; const responses = adapter.interpretResponse(serverResponse, REQUEST); expect(responses).to.have.length(1); expect(responses[0].ttl).to.equal(300); diff --git a/test/spec/modules/videoNowBidAdapter_spec.js b/test/spec/modules/videoNowBidAdapter_spec.js new file mode 100644 index 00000000000..a419c73456b --- /dev/null +++ b/test/spec/modules/videoNowBidAdapter_spec.js @@ -0,0 +1,599 @@ +import { expect } from 'chai' +import { spec } from 'modules/videoNowBidAdapter.js' +import { replaceAuctionPrice } from 'src/utils.js' +import * as utils from 'src/utils.js'; + +// childNode.remove polyfill for ie11 +// suggested by: https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove + +// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md +(function (arr) { + arr.forEach(function (item) { + if (item.hasOwnProperty('remove')) { + return; + } + Object.defineProperty(item, 'remove', { + configurable: true, + enumerable: true, + writable: true, + value: function remove() { + if (this.parentNode === null) { + return; + } + this.parentNode.removeChild(this); + } + }); + }); +})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); + +const placementId = 'div-gpt-ad-1438287399331-1' +const LS_ITEM_NAME = 'videonow-config' + +const getValidServerResponse = () => { + const serverResponse = { + body: { + id: '111-111', + bidid: '2955a162-699e-4811-ce88-5c3ac973e73c', + cur: 'RUB', + seatbid: [ + { + bid: [ + { + id: 'e3bf2b82e3e9485113fad6c9b27f8768.1', + impid: '1', + price: 10.97, + nurl: 'https://localhost:8086/event/nurl', + netRevenue: false, + ttl: 800, + adm: '', + crid: 'e3bf2b82e3e9485113fad6c9b27f8768.1', + h: 640, + w: 480, + ext: { + init: 'https://localhost:8086/vn_init.js', + module: { + min: 'https://localhost:8086/vn_module.js', + log: 'https://localhost:8086/vn_module.js?log=1' + }, + format: { + name: 'flyRoll', + }, + }, + + }, + ], + group: 0, + }, + ], + price: 10, + ext: { + placementId, + pixels: [ + 'https://localhost:8086/event/pxlcookiematching?uiid=1', + 'https://localhost:8086/event/pxlcookiematching?uiid=2', + ], + iframes: [ + 'https://localhost:8086/event/ifrcookiematching?uiid=1', + 'https://localhost:8086/event/ifrcookiematching?uiid=2', + ], + }, + }, + headers: {}, + } + + return JSON.parse(JSON.stringify(serverResponse)) +} + +describe('videonowAdapterTests', function() { + describe('bidRequestValidity', function() { + it('bidRequest with pId', function() { + expect(spec.isBidRequestValid({ + bidder: 'videonow', + params: { + pId: '86858', + }, + })).to.equal(true) + }) + + it('bidRequest without pId', function() { + expect(spec.isBidRequestValid({ + bidder: 'videonow', + params: { + nomater: 86858, + }, + })).to.equal(false) + + it('bidRequest is empty', function() { + expect(spec.isBidRequestValid({})).to.equal(false) + }) + + it('bidRequest is undefned', function() { + expect(spec.isBidRequestValid(undefined)).to.equal(false) + }) + }) + + describe('bidRequest', function() { + const validBidRequests = [ + { + bidder: 'videonow', + params: { + pId: '1', + placementId, + url: 'https://localhost:8086/bid?p=exists', + bidFloor: 10, + cur: 'RUB' + }, + crumbs: { + pubcid: 'feded041-35dd-4b54-979a-6d7805abfa75', + }, + mediaTypes: { + banner: { + sizes: [[640, 480], [320, 200]] + }, + }, + adUnitCode: 'test-ad', + transactionId: '676403c7-09c9-4b56-be82-e7cae81f40b9', + sizes: [[640, 480], [320, 200]], + bidId: '268c309f46390d', + bidderRequestId: '1dfdd514c36ef6', + auctionId: '4d523546-889a-4029-9a79-13d3c69f9922', + src: 'client', + bidRequestsCount: 1, + }, + ] + + const bidderRequest = { + bidderCode: 'videonow', + auctionId: '4d523546-889a-4029-9a79-13d3c69f9922', + bidderRequestId: '1dfdd514c36ef6', + bids: [ + { + bidder: 'videonow', + params: { + pId: '1', + placementId, + url: 'https://localhost:8086/bid', + bidFloor: 10, + cur: 'RUB', + }, + crumbs: { + pubcid: 'feded041-35dd-4b54-979a-6d7805abfa75', + }, + mediaTypes: { + banner: { + sizes: [[640, 480], [320, 200]], + }, + }, + adUnitCode: 'test-ad', + transactionId: '676403c7-09c9-4b56-be82-e7cae81f40b9', + sizes: [[640, 480], [320, 200]], + bidId: '268c309f46390d', + bidderRequestId: '1dfdd514c36ef6', + auctionId: '4d523546-889a-4029-9a79-13d3c69f9922', + src: 'client', + bidRequestsCount: 1, + }, + ], + auctionStart: 1565794308584, + timeout: 3000, + refererInfo: { + referer: 'https://localhost:8086/page', + reachedTop: true, + numIframes: 0, + stack: [ + 'https://localhost:8086/page', + ], + }, + start: 1565794308589, + } + + const requests = spec.buildRequests(validBidRequests, bidderRequest) + const request = (requests && requests.length && requests[0]) || {} + + it('bidRequest count', function() { + expect(requests.length).to.equal(1) + }) + + it('bidRequest method', function() { + expect(request.method).to.equal('POST') + }) + + it('bidRequest url', function() { + expect(request.url).to.equal('https://localhost:8086/bid?p=exists&profile_id=1') + }) + + it('bidRequest data', function() { + const data = request.data + expect(data.aid).to.be.eql(validBidRequests[0].params.aid) + expect(data.id).to.be.eql(validBidRequests[0].bidId) + expect(data.sizes).to.be.eql(validBidRequests[0].sizes) + }) + + describe('bidRequest advanced', function() { + const bidderRequestEmptyParamsAndExtParams = { + bidder: 'videonow', + params: { + pId: '1', + }, + ext: { + p1: 'ext1', + p2: 'ext2', + }, + } + + it('bidRequest count', function() { + const requests = spec.buildRequests([bidderRequestEmptyParamsAndExtParams], bidderRequest) + expect(requests.length).to.equal(1) + }) + + it('bidRequest default url', function() { + const requests = spec.buildRequests([bidderRequestEmptyParamsAndExtParams], bidderRequest) + const request = (requests && requests.length && requests[0]) || {} + expect(request.url).to.equal('https://bidder.videonow.ru/prebid?profile_id=1') + }) + + it('bidRequest default currency', function() { + const requests = spec.buildRequests([bidderRequestEmptyParamsAndExtParams], bidderRequest) + const request = (requests && requests.length && requests[0]) || {} + const data = (request && request.data) || {} + expect(data.cur).to.equal('RUB') + }) + + it('bidRequest ext parameters ', function() { + const requests = spec.buildRequests([bidderRequestEmptyParamsAndExtParams], bidderRequest) + const request = (requests && requests.length && requests[0]) || {} + const data = (request && request.data) || {} + expect(data['ext_p1']).to.equal('ext1') + expect(data['ext_p2']).to.equal('ext2') + }) + + it('bidRequest without params', function() { + const bidderReq = { + bidder: 'videonow', + } + const requests = spec.buildRequests([bidderReq], bidderRequest) + expect(requests.length).to.equal(1) + }) + }) + }) + + describe('onBidWon', function() { + const cpm = 10 + const nurl = 'https://fakedomain.nld?price=${AUCTION_PRICE}' + const imgSrc = replaceAuctionPrice(nurl, cpm) + + beforeEach(function() { + sinon.stub(utils, 'triggerPixel') + }) + + afterEach(function() { + utils.triggerPixel.restore() + }) + + it('Should not create nurl pixel if bid is undefined', function() { + spec.onBidWon() + expect(utils.triggerPixel.called).to.equal(false); + }) + + it('Should not create nurl pixel if bid does not contains nurl', function() { + spec.onBidWon({}) + expect(utils.triggerPixel.called).to.equal(false); + }) + + it('Should create nurl pixel if bid nurl', function() { + spec.onBidWon({ nurl, cpm }) + expect(utils.triggerPixel.calledWith(imgSrc)).to.equal(true); + }) + }) + + describe('getUserSyncs', function() { + it('Should return an empty array if not get serverResponses', function() { + expect(spec.getUserSyncs({}).length).to.equal(0) + }) + + it('Should return an empty array if get serverResponses as empty array', function() { + expect(spec.getUserSyncs({}, []).length).to.equal(0) + }) + + it('Should return an empty array if serverResponses has no body', function() { + const serverResp = getValidServerResponse() + delete serverResp.body + const syncs = spec.getUserSyncs({}, [serverResp]) + expect(syncs.length).to.equal(0) + }) + + it('Should return an empty array if serverResponses has no ext', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.ext + const syncs = spec.getUserSyncs({}, [serverResp]) + expect(syncs.length).to.equal(0) + }) + + it('Should return an array', function() { + const serverResp = getValidServerResponse() + const syncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [serverResp]) + expect(syncs.length).to.equal(4) + }) + + it('Should return pixels', function() { + const serverResp = getValidServerResponse() + const syncs = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [serverResp]) + expect(syncs.length).to.equal(2) + expect(syncs[0].type).to.equal('image') + expect(syncs[1].type).to.equal('image') + }) + + it('Should return iframes', function() { + const serverResp = getValidServerResponse() + const syncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [serverResp]) + expect(syncs.length).to.equal(2) + expect(syncs[0].type).to.equal('iframe') + expect(syncs[1].type).to.equal('iframe') + }) + }) + + describe('interpretResponse', function() { + const bidRequest = { + method: 'POST', + url: 'https://localhost:8086/bid?profile_id=1', + data: { + id: '217b8ab59a18e8', + cpm: 10, + sizes: [[640, 480], [320, 200]], + cur: 'RUB', + placementId, + ref: 'https://localhost:8086/page', + }, + } + + it('Should have only one bid', function() { + const serverResponse = getValidServerResponse() + const result = spec.interpretResponse(serverResponse, bidRequest) + expect(result.length).to.equal(1) + }) + + it('Should have required keys', function() { + const serverResponse = getValidServerResponse() + const result = spec.interpretResponse(serverResponse, bidRequest) + const bid = serverResponse.body.seatbid[0].bid[0] + const res = result[0] + expect(res.requestId).to.be.eql(bidRequest.data.id) + expect(res.cpm).to.be.eql(bid.price) + expect(res.creativeId).to.be.eql(bid.crid) + expect(res.netRevenue).to.be.a('boolean') + expect(res.ttl).to.be.eql(bid.ttl) + expect(res.renderer).to.be.a('Object') + expect(res.renderer.render).to.be.a('function') + }) + + it('Should return an empty array if empty or no bids in response', function() { + expect(spec.interpretResponse({ body: '' }, {}).length).to.equal(0) + }) + + it('Should return an empty array if bidRequest\'s data is absent', function() { + const serverResponse = getValidServerResponse() + expect(spec.interpretResponse(serverResponse, undefined).length).to.equal(0) + }) + + it('Should return an empty array if bidRequest\'s data is not contains bidId ', function() { + const serverResponse = getValidServerResponse() + expect(spec.interpretResponse(serverResponse, { data: {} }).length).to.equal(0) + }) + + it('Should return an empty array if bidRequest\'s data bidId is undefined', function() { + const serverResponse = getValidServerResponse() + expect(spec.interpretResponse(serverResponse, { data: { id: null } }).length).to.equal(0) + }) + + it('Should return an empty array if serverResponse do not contains seatbid', function() { + expect(spec.interpretResponse({ body: {} }, bidRequest).length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s seatbid is empty', function() { + expect(spec.interpretResponse({ body: { seatbid: [] } }, bidRequest).length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s placementId is undefined', function() { + expect(spec.interpretResponse({ body: { seatbid: [1, 2] } }, bidRequest).length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s id in the bid is undefined', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].id + let res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s price in the bid is undefined', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].price + const res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s price in the bid is 0', function() { + const serverResp = getValidServerResponse() + serverResp.body.seatbid[0].bid[0].price = 0 + const res = spec.interpretResponse(serverResp, bidRequest) + + expect(res.length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s init in the bid\'s ext is undefined', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].ext.init + const res = spec.interpretResponse(serverResp, bidRequest) + + expect(res.length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s module in the bid\'s ext is undefined', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].ext.module + const res = spec.interpretResponse(serverResp, bidRequest) + + expect(res.length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s adm in the bid is undefined', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].adm + const res = spec.interpretResponse(serverResp, bidRequest) + + expect(res.length).to.equal(0) + }) + + it('Should return an empty array if serverResponse\'s the bid\'s ext is undefined', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].ext + const res = spec.interpretResponse(serverResp, bidRequest) + + expect(res.length).to.equal(0) + }) + + it('Default ttl is 300', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].ttl + const res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(1) + expect(res[0].ttl).to.equal(300) + }) + + it('Default netRevenue is true', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].netRevenue + const res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(1) + expect(res[0].netRevenue).to.be.true; + }) + + it('Default currency is RUB', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.cur + const res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(1) + expect(res[0].currency).to.equal('RUB') + }) + + describe('different module paths', function() { + beforeEach(function() { + window.localStorage && localStorage.setItem(LS_ITEM_NAME, '{}') + }) + + afterEach(function() { + const serverResp = getValidServerResponse() + const { module: { log, min }, init } = serverResp.body.seatbid[0].bid[0].ext + remove(init) + remove(log) + remove(min) + + function remove(src) { + if (!src) return + const d = document.querySelectorAll(`script[src^="${src}"]`) + // using the Array.prototype.forEach as a workaround for IE11... + // see https://developer.mozilla.org/en-US/docs/Web/API/NodeList + d && d.length && Array.prototype.forEach.call(d, el => el && el.remove()) + } + }) + + it('should use prod module by default', function() { + const serverResp = getValidServerResponse() + const res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(1) + + const renderer = res[0].renderer + expect(renderer).to.be.an('object') + expect(renderer.url).to.equal(serverResp.body.seatbid[0].bid[0].ext.module.min) + }) + + it('should use "log" module if "prod" is not exists', function() { + const serverResp = getValidServerResponse() + delete serverResp.body.seatbid[0].bid[0].ext.module.min + const res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(1) + + const renderer = res[0].renderer + expect(renderer).to.be.an('object') + expect(renderer.url).to.equal(serverResp.body.seatbid[0].bid[0].ext.module.log) + }) + + it('should correct combine src for init', function() { + const serverResp = getValidServerResponse() + + const src = `${serverResp.body.seatbid[0].bid[0].ext.init}?profileId=1` + const placementElement = document.createElement('div') + placementElement.setAttribute('id', placementId) + + const resp = spec.interpretResponse(serverResp, bidRequest) + expect(resp.length).to.equal(1) + + const renderer = resp[0].renderer + expect(renderer).to.be.an('object') + + document.body.appendChild(placementElement) + + renderer.render() + + // const res = document.querySelectorAll(`script[src="${src}"]`) + // expect(res.length).to.equal(1) + }) + + it('should correct combine src for init if init url contains "?"', function() { + const serverResp = getValidServerResponse() + + serverResp.body.seatbid[0].bid[0].ext.init += '?div=1' + const src = `${serverResp.body.seatbid[0].bid[0].ext.init}&profileId=1` + + const placementElement = document.createElement('div') + placementElement.setAttribute('id', placementId) + + const resp = spec.interpretResponse(serverResp, bidRequest) + expect(resp.length).to.equal(1) + + const renderer = resp[0].renderer + expect(renderer).to.be.an('object') + + document.body.appendChild(placementElement) + + renderer.render() + + // const res = document.querySelectorAll(`script[src="${src}"]`) + // expect(res.length).to.equal(1) + }) + }) + + describe('renderer object', function() { + it('execute renderer.render() should create window.videonow object', function() { + const serverResp = getValidServerResponse() + const res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(1) + + const renderer = res[0].renderer + expect(renderer).to.be.an('object') + expect(renderer.render).to.a('function') + + const doc = window.document + const placementElement = doc.createElement('div') + placementElement.setAttribute('id', placementId) + doc.body.appendChild(placementElement) + + renderer.render() + expect(window.videonow).to.an('object') + }) + }) + + it('execute renderer.render() should not create window.videonow object if placement element not found', function() { + const serverResp = getValidServerResponse() + const res = spec.interpretResponse(serverResp, bidRequest) + expect(res.length).to.equal(1) + + const renderer = res[0].renderer + expect(renderer).to.be.an('object') + expect(renderer.render).to.a('function') + + renderer.render() + expect(window.videonow).to.be.undefined + }) + }) + }) +}) diff --git a/test/spec/modules/videoreachBidAdapter_spec.js b/test/spec/modules/videoreachBidAdapter_spec.js index 237821f7102..e5c6b9b30ad 100644 --- a/test/spec/modules/videoreachBidAdapter_spec.js +++ b/test/spec/modules/videoreachBidAdapter_spec.js @@ -1,8 +1,8 @@ import {expect} from 'chai'; -import {spec} from 'modules/videoreachBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/videoreachBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; -const ENDPOINT_URL = '//a.videoreach.com/hb/'; +const ENDPOINT_URL = 'https://a.videoreach.com/hb/'; describe('videoreachBidAdapter', function () { describe('isBidRequestValid', function () { @@ -86,7 +86,7 @@ describe('videoreachBidAdapter', function () { 'cpm': 10.0, 'width': '1', 'height': '1', - 'ad': '', + 'ad': '', 'ttl': 360, 'creativeId': '5cb5dc9375c0e', 'netRevenue': true, diff --git a/test/spec/modules/viewdeosDXBidAdapter_spec.js b/test/spec/modules/viewdeosDXBidAdapter_spec.js new file mode 100644 index 00000000000..f9bee1b0efe --- /dev/null +++ b/test/spec/modules/viewdeosDXBidAdapter_spec.js @@ -0,0 +1,336 @@ +import {expect} from 'chai'; +import {spec} from 'modules/viewdeosDXBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; + +const ENDPOINT = 'https://ghb.sync.viewdeos.com/auction/'; + +const DISPLAY_REQUEST = { + 'bidder': 'viewdeos', + 'params': { + 'aid': 12345 + }, + 'bidderRequestId': '7101db09af0db2', + 'auctionId': '2e41f65424c87c', + 'adUnitCode': 'adunit-code', + 'bidId': '84ab500420319d', + 'mediaTypes': {'banner': {'sizes': [[300, 250], [300, 600]]}} +}; + +const VIDEO_REQUEST = { + 'bidder': 'viewdeos', + 'params': { + 'aid': 12345 + }, + 'bidderRequestId': '7101db09af0db2', + 'auctionId': '2e41f65424c87c', + 'adUnitCode': 'adunit-code', + 'bidId': '84ab500420319d', + 'mediaTypes': {'video': {'playerSize': [480, 360], 'context': 'instream'}} +}; + +const SERVER_VIDEO_RESPONSE = { + 'source': {'aid': 12345, 'pubId': 54321}, + 'bids': [{ + 'vastUrl': 'http://rtb.sync.viewdeos.com/vast/?adid=44F2AEB9BFC881B3', + 'requestId': '2e41f65424c87c', + 'url': '44F2AEB9BFC881B3', + 'creative_id': 342516, + 'cmpId': 342516, + 'height': 480, + 'cur': 'USD', + 'width': 640, + 'cpm': 0.9 + } + ] +}; +const SERVER_OUSTREAM_VIDEO_RESPONSE = SERVER_VIDEO_RESPONSE; + +const SERVER_DISPLAY_RESPONSE = { + 'source': {'aid': 12345, 'pubId': 54321}, + 'bids': [{ + 'ad': '', + 'requestId': '2e41f65424c87c', + 'creative_id': 342516, + 'cmpId': 342516, + 'height': 250, + 'cur': 'USD', + 'width': 300, + 'cpm': 0.9 + }], + 'cookieURLs': ['link1', 'link2'] +}; +const SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS = { + 'source': {'aid': 12345, 'pubId': 54321}, + 'bids': [{ + 'ad': '', + 'requestId': '2e41f65424c87c', + 'creative_id': 342516, + 'cmpId': 342516, + 'height': 250, + 'cur': 'USD', + 'width': 300, + 'cpm': 0.9 + }], + 'cookieURLs': ['link3', 'link4'], + 'cookieURLSTypes': ['image', 'iframe'] +}; + +const outstreamVideoBidderRequest = { + bidderCode: 'bidderCode', + bids: [{ + 'params': { + 'aid': 12345, + 'outstream': { + 'video_controls': 'show' + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }, + bidId: '2e41f65424c87c' + }] +}; + +const videoBidderRequest = { + bidderCode: 'bidderCode', + bids: [{mediaTypes: {video: {}}, bidId: '2e41f65424c87c'}] +}; + +const displayBidderRequest = { + bidderCode: 'bidderCode', + bids: [{bidId: '2e41f65424c87c'}] +}; + +const displayBidderRequestWithGdpr = { + bidderCode: 'bidderCode', + bids: [{bidId: '2e41f65424c87c'}], + gdprConsent: { + gdprApplies: true, + consentString: 'test' + } +}; + +const videoEqResponse = [{ + vastUrl: 'http://rtb.sync.viewdeos.com/vast/?adid=44F2AEB9BFC881B3', + requestId: '2e41f65424c87c', + creativeId: 342516, + mediaType: 'video', + netRevenue: true, + currency: 'USD', + height: 480, + width: 640, + ttl: 3600, + cpm: 0.9 +}]; + +const displayEqResponse = [{ + requestId: '2e41f65424c87c', + creativeId: 342516, + mediaType: 'display', + netRevenue: true, + currency: 'USD', + ad: '', + height: 250, + width: 300, + ttl: 3600, + cpm: 0.9 +}]; + +describe('viewdeosDXBidAdapter', function () { + const adapter = newBidder(spec); + + describe('when outstream params are passing properly', function() { + const videoBids = spec.interpretResponse({body: SERVER_OUSTREAM_VIDEO_RESPONSE}, {bidderRequest: outstreamVideoBidderRequest}); + it('should return renderer with expected outstream params config', function() { + expect(!!videoBids[0].renderer).to.equal(true); + expect(videoBids[0].renderer.getConfig().video_controls).to.equal('show'); + }) + }) + + describe('user syncs as image', function () { + it('should be returned if pixel enabled', function () { + const syncs = spec.getUserSyncs({pixelEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); + + expect(syncs.map(s => s.url)).to.deep.equal([SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs[0]]); + expect(syncs.map(s => s.type)).to.deep.equal(['image']); + }) + }) + + describe('user syncs as iframe', function () { + it('should be returned if iframe enabled', function () { + const syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); + + expect(syncs.map(s => s.url)).to.deep.equal([SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs[1]]); + expect(syncs.map(s => s.type)).to.deep.equal(['iframe']); + }) + }) + + describe('user syncs with both types', function () { + it('should be returned if pixel and iframe enabled', function () { + const syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); + + expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); + expect(syncs.map(s => s.type)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLSTypes); + }) + }) + + describe('user syncs', function () { + it('should not be returned if pixel not set', function () { + const syncs = spec.getUserSyncs({}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); + + expect(syncs).to.be.empty; + }) + }) + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(VIDEO_REQUEST)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, VIDEO_REQUEST); + delete bid.params; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let videoBidRequests = [VIDEO_REQUEST]; + let displayBidRequests = [DISPLAY_REQUEST]; + let videoAndDisplayBidRequests = [DISPLAY_REQUEST, VIDEO_REQUEST]; + + const displayRequest = spec.buildRequests(displayBidRequests, {}); + const videoRequest = spec.buildRequests(videoBidRequests, {}); + const videoAndDisplayRequests = spec.buildRequests(videoAndDisplayBidRequests, {}); + + it('sends bid request to ENDPOINT via GET', function () { + expect(videoRequest.method).to.equal('GET'); + expect(displayRequest.method).to.equal('GET'); + expect(videoAndDisplayRequests.method).to.equal('GET'); + }); + + it('sends bid request to correct ENDPOINT', function () { + expect(videoRequest.url).to.equal(ENDPOINT); + expect(displayRequest.url).to.equal(ENDPOINT); + expect(videoAndDisplayRequests.url).to.equal(ENDPOINT); + }); + + it('sends correct video bid parameters', function () { + const bid = Object.assign({}, videoRequest.data); + delete bid.domain; + + const eq = { + callbackId: '84ab500420319d', + ad_type: 'video', + aid: 12345, + sizes: '480x360' + }; + + expect(bid).to.deep.equal(eq); + }); + + it('sends correct display bid parameters', function () { + const bid = Object.assign({}, displayRequest.data); + delete bid.domain; + + const eq = { + callbackId: '84ab500420319d', + ad_type: 'display', + aid: 12345, + sizes: '300x250,300x600' + }; + + expect(bid).to.deep.equal(eq); + }); + + it('sends correct video and display bid parameters', function () { + const bid = Object.assign({}, videoAndDisplayRequests.data); + delete bid.domain; + + const eq = { + callbackId: '84ab500420319d', + ad_type: 'display', + aid: 12345, + sizes: '300x250,300x600', + callbackId2: '84ab500420319d', + ad_type2: 'video', + aid2: 12345, + sizes2: '480x360' + }; + + expect(bid).to.deep.equal(eq); + }); + }); + + describe('interpretResponse', function () { + let serverResponse; + let bidderRequest; + let eqResponse; + + afterEach(function () { + serverResponse = null; + bidderRequest = null; + eqResponse = null; + }); + + it('should get correct video bid response', function () { + serverResponse = SERVER_VIDEO_RESPONSE; + bidderRequest = videoBidderRequest; + eqResponse = videoEqResponse; + + bidServerResponseCheck(); + }); + + it('should get correct display bid response', function () { + serverResponse = SERVER_DISPLAY_RESPONSE; + bidderRequest = displayBidderRequest; + eqResponse = displayEqResponse; + + bidServerResponseCheck(); + }); + + it('should set gdpr data correctly', function () { + const builtRequestData = spec.buildRequests([DISPLAY_REQUEST], displayBidderRequestWithGdpr); + + expect(builtRequestData.data.gdpr).to.be.equal(1); + expect(builtRequestData.data.gdpr_consent).to.be.equal(displayBidderRequestWithGdpr.gdprConsent.consentString); + }); + + function bidServerResponseCheck() { + const result = spec.interpretResponse({body: serverResponse}, {bidderRequest}); + + expect(result).to.deep.equal(eqResponse); + } + + function nobidServerResponseCheck() { + const noBidServerResponse = {bids: []}; + const noBidResult = spec.interpretResponse({body: noBidServerResponse}, {bidderRequest}); + + expect(noBidResult.length).to.equal(0); + } + + it('handles video nobid responses', function () { + bidderRequest = videoBidderRequest; + + nobidServerResponseCheck(); + }); + + it('handles display nobid responses', function () { + bidderRequest = displayBidderRequest; + + nobidServerResponseCheck(); + }); + }); +}); diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js index 09ce92479f9..7720bb2a3e4 100755 --- a/test/spec/modules/visxBidAdapter_spec.js +++ b/test/spec/modules/visxBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/visxBidAdapter'; -import { config } from 'src/config'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/visxBidAdapter.js'; +import { config } from 'src/config.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('VisxAdapter', function () { const adapter = newBidder(spec); @@ -42,10 +42,18 @@ describe('VisxAdapter', function () { describe('buildRequests', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; - const encodedReferrer = encodeURIComponent(bidderRequest.refererInfo.referer); + const referrer = bidderRequest.refererInfo.referer; + const schainObject = { + ver: '1.0', + nodes: [ + {asi: 'exchange2.com', sid: 'abcd', hp: 1}, + {asi: 'exchange1.com', sid: '1234!abcd', hp: 1, name: 'publisher, Inc.', domain: 'publisher.com'} + ] + }; + const schainString = JSON.stringify(schainObject); let bidRequests = [ { 'bidder': 'visx', @@ -86,7 +94,7 @@ describe('VisxAdapter', function () { const request = spec.buildRequests([bidRequests[0]], bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u', encodedReferrer); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('pt', 'net'); expect(payload).to.have.property('auids', '903535'); expect(payload).to.have.property('sizes', '300x250,300x600'); @@ -98,7 +106,7 @@ describe('VisxAdapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u', encodedReferrer); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('pt', 'net'); expect(payload).to.have.property('auids', '903535,903535,903536'); expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); @@ -111,7 +119,7 @@ describe('VisxAdapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u', encodedReferrer); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('pt', 'net'); expect(payload).to.have.property('auids', '903535,903535,903536'); expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); @@ -124,7 +132,7 @@ describe('VisxAdapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u', encodedReferrer); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('pt', 'net'); expect(payload).to.have.property('auids', '903535,903535,903536'); expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); @@ -138,7 +146,7 @@ describe('VisxAdapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u', encodedReferrer); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('pt', 'net'); expect(payload).to.have.property('auids', '903535,903535,903536'); expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); @@ -149,16 +157,16 @@ describe('VisxAdapter', function () { it('should add currency from currency.bidderCurrencyDefault', function () { const getConfigStub = sinon.stub(config, 'getConfig').callsFake( - arg => arg === 'currency.bidderCurrencyDefault.visx' ? 'JPY' : 'USD'); + arg => arg === 'currency.bidderCurrencyDefault.visx' ? 'GBP' : 'USD'); const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u', encodedReferrer); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('pt', 'net'); expect(payload).to.have.property('auids', '903535,903535,903536'); expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); expect(payload).to.have.property('r', '22edbae2733bf6'); - expect(payload).to.have.property('cur', 'JPY'); + expect(payload).to.have.property('cur', 'GBP'); getConfigStub.restore(); }); @@ -168,7 +176,7 @@ describe('VisxAdapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u', encodedReferrer); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('pt', 'net'); expect(payload).to.have.property('auids', '903535,903535,903536'); expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); @@ -200,15 +208,51 @@ describe('VisxAdapter', function () { expect(payload).to.have.property('gdpr_consent', 'AAA'); expect(payload).to.have.property('gdpr_applies', 1); }); + + it('if schain is present payload must have schain param', function () { + const schainBidRequests = [ + Object.assign({schain: schainObject}, bidRequests[0]), + bidRequests[1], + bidRequests[2] + ]; + const request = spec.buildRequests(schainBidRequests, bidderRequest); + const payload = request.data; + expect(payload).to.be.an('object'); + expect(payload).to.have.property('schain', schainString); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'net'); + expect(payload).to.have.property('auids', '903535,903535,903536'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); + expect(payload).to.have.property('r', '22edbae2733bf6'); + expect(payload).to.have.property('cur', 'EUR'); + }); + + it('if userId is available payload must have appropriate params', function () { + const schainBidRequests = [ + Object.assign({userId: { + tdid: '111', + id5id: '222', + digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}} + }}, bidRequests[0]), + bidRequests[1], + bidRequests[2] + ]; + const request = spec.buildRequests(schainBidRequests, bidderRequest); + const payload = request.data; + expect(payload).to.be.an('object'); + expect(payload).to.have.property('tdid', '111'); + expect(payload).to.have.property('id5', '222'); + expect(payload).to.have.property('dtid', 'DTID'); + }); }); describe('interpretResponse', function () { const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 903535, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 903536, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 903535, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 903537, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 5
', 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 903535, 'h': 250, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 903536, 'h': 600, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 903535, 'h': 90, 'w': 728, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0, 'auid': 903537, 'h': 250, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0, 'adm': '
test content 5
', 'h': 250, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, undefined, {'bid': [], 'seat': '1'}, {'seat': '1'}, @@ -346,7 +390,7 @@ describe('VisxAdapter', function () { 'auctionId': '1cbd2feafe5e8b', } ]; - const getConfigStub = sinon.stub(config, 'getConfig').returns('JPY'); + const getConfigStub = sinon.stub(config, 'getConfig').returns('PLN'); const request = spec.buildRequests(bidRequests); const expectedResponse = [ { @@ -358,13 +402,15 @@ describe('VisxAdapter', function () { 'height': 250, 'ad': '
test content 1
', 'bidderCode': 'visx', - 'currency': 'JPY', + 'currency': 'PLN', 'netRevenue': true, 'ttl': 360, } ]; - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); + const response = Object.assign({}, responses[0]); + Object.assign(response.bid[0], {'cur': 'PLN'}); + const result = spec.interpretResponse({'body': {'seatbid': [response]}}, request); expect(result).to.deep.equal(expectedResponse); getConfigStub.restore(); }); @@ -412,11 +458,11 @@ describe('VisxAdapter', function () { it('complicated case', function () { const fullResponse = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 903535, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 903536, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 903535, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 4
', 'auid': 903535, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 5
', 'auid': 903536, 'h': 600, 'w': 350}], 'seat': '1'}, + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 903535, 'h': 250, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 903536, 'h': 600, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 903535, 'h': 90, 'w': 728, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 4
', 'auid': 903535, 'h': 600, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 5
', 'auid': 903536, 'h': 600, 'w': 350, 'cur': 'EUR'}], 'seat': '1'}, ]; const bidRequests = [ { @@ -550,8 +596,8 @@ describe('VisxAdapter', function () { it('dublicate uids and sizes in one slot', function () { const fullResponse = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 903535, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 903535, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 903535, 'h': 250, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 903535, 'h': 250, 'w': 300, 'cur': 'EUR'}], 'seat': '1'}, ]; const bidRequests = [ { diff --git a/test/spec/modules/vmgBidAdapter_spec.js b/test/spec/modules/vmgBidAdapter_spec.js index 688c03577fd..41aa077adc7 100644 --- a/test/spec/modules/vmgBidAdapter_spec.js +++ b/test/spec/modules/vmgBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/vmgBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/vmgBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('VmgAdapter', function () { const adapter = newBidder(spec); diff --git a/test/spec/modules/vrtcalBidAdapter_spec.js b/test/spec/modules/vrtcalBidAdapter_spec.js new file mode 100644 index 00000000000..729b0a723e4 --- /dev/null +++ b/test/spec/modules/vrtcalBidAdapter_spec.js @@ -0,0 +1,135 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/vrtcalBidAdapter.js'; + +describe('Vrtcal Adapter', function () { + let bid = { + bidId: 'bidID0001', + bidder: 'vrtcal', + bidderRequestId: 'brID0001', + auctionId: 'auID0001', + sizes: [[300, 250]], + transactionId: 'tid0001', + adUnitCode: 'vrtcal-test-adunit' + }; + + describe('isBidRequestValid', function () { + it('Should return true when base params as set', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false when bid.bidId is blank', function () { + bid.bidId = ''; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false when bid.auctionId is blank', function () { + bid.auctionId = ''; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequests = spec.buildRequests([bid]); + + let serverRequest = serverRequests[0]; + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://rtb.vrtcal.com/bidder_prebid.vap?ssp=1804'); + }); + + it('Returns valid data if array of bids is valid', function () { + let data = JSON.parse(serverRequest.data); + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('prebidJS', 'prebidAdUnitCode', 'id', 'imp', 'site', 'device'); + expect(data.prebidJS).to.not.equal(''); + expect(data.prebidAdUnitCode).to.not.equal(''); + }); + + it('Sets width and height based on existence of bid.mediaTypes.banner', function () { + let data = JSON.parse(serverRequest.data); + if (typeof (bid.mediaTypes) !== 'undefined' && typeof (bid.mediaTypes.banner) !== 'undefined' && typeof (bid.mediaTypes.banner.sizes) !== 'undefined') { + expect(data.imp[0].banner.w).to.equal(bid.mediaTypes.banner.sizes[0][0]); + expect(data.imp[0].banner.h).to.equal(bid.mediaTypes.banner.sizes[0][1]); + } else { + expect(data.imp[0].banner.w).to.equal(bid.sizes[0][0]); + expect(data.imp[0].banner.h).to.equal(bid.sizes[0][1]); + } + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequests = spec.buildRequests([]); + expect(serverRequests).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + let bid = { + bidId: 'bidID0001', + bidder: 'vrtcal', + bidderRequestId: 'brID0001', + auctionId: 'auID0001', + sizes: [[300, 250]], + transactionId: 'tid0001', + adUnitCode: 'vrtcal-test-adunit' + }; + + let serverRequests = spec.buildRequests([bid]); + + let resObject = {body: {id: 'vrtcal-test-id', width: 300, height: 250, seatbid: [{bid: [{price: 3.0, w: 300, h: 250, crid: 'testcrid', adm: 'testad', nurl: 'https://vrtcal.com/faketracker'}]}], currency: 'USD', netRevenue: true, ttl: 900}}; + + let serverResponses = spec.interpretResponse(resObject, serverRequests); + + it('Returns an array of valid server responses if response object is valid', function () { + expect(serverResponses).to.be.an('array').that.is.not.empty; + for (let i = 0; i < serverResponses.length; i++) { + let dataItem = serverResponses[i]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'nurl'); + expect(dataItem.requestId).to.be.a('string'); + expect(dataItem.cpm).to.be.a('number'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); + expect(dataItem.ad).to.be.a('string'); + expect(dataItem.ttl).to.be.a('number'); + expect(dataItem.creativeId).to.be.a('string'); + expect(dataItem.netRevenue).to.be.a('boolean'); + expect(dataItem.currency).to.be.a('string'); + expect(dataItem.nurl).to.be.a('string'); + } + + it('Returns an empty array if invalid response is passed', function () { + serverResponses = spec.interpretResponse('invalid_response'); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + }); + + describe('onBidWon', function () { + let bid = { + bidId: '2dd581a2b6281d', + bidder: 'vrtcal', + bidderRequestId: '145e1d6a7837c9', + auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + sizes: [[300, 250]], + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', + adUnitCode: 'vrtcal-test-adunit' + }; + + let serverRequests = spec.buildRequests([bid]); + let resObject = {body: {id: 'vrtcal-test-id', width: 300, height: 250, seatbid: [{bid: [{price: 3.0, w: 300, h: 250, crid: 'testcrid', adm: 'testad', nurl: 'https://vrtcal.com/faketracker'}]}], currency: 'USD', netRevenue: true, ttl: 900}}; + let serverResponses = spec.interpretResponse(resObject, serverRequests); + let wonbid = serverResponses[0]; + + it('Returns true is nurl is good/not blank', function () { + expect(wonbid.nurl).to.not.equal(''); + expect(spec.onBidWon(wonbid)).to.be.true; + }); + }); +}); diff --git a/test/spec/modules/vubleAnalyticsAdapter_spec.js b/test/spec/modules/vubleAnalyticsAdapter_spec.js index 841a53c6dee..e69de29bb2d 100644 --- a/test/spec/modules/vubleAnalyticsAdapter_spec.js +++ b/test/spec/modules/vubleAnalyticsAdapter_spec.js @@ -1,122 +0,0 @@ -import vubleAnalytics from 'modules/vubleAnalyticsAdapter'; -import { expect } from 'chai'; -let events = require('src/events'); -let adapterManager = require('src/adapterManager').default; -let constants = require('src/constants.json'); - -describe('Vuble Prebid Analytic', function () { - let xhr; - before(function () { - xhr = sinon.useFakeXMLHttpRequest(); - }); - after(function () { - vubleAnalytics.disableAnalytics(); - xhr.restore(); - }); - - describe('enableAnalytics', function () { - beforeEach(function () { - sinon.spy(vubleAnalytics, 'track'); - sinon.stub(events, 'getEvents').returns([]); - }); - - afterEach(function () { - vubleAnalytics.track.restore(); - events.getEvents.restore(); - }); - it('should catch all events', function () { - adapterManager.registerAnalyticsAdapter({ - code: 'vuble', - adapter: vubleAnalytics - }); - - adapterManager.enableAnalytics({ - provider: 'vuble', - options: { - pubId: 18, - env: 'net' - } - }); - - let auction_id = 'test'; - - // Step 1: Auction init - events.emit(constants.EVENTS.AUCTION_INIT, { - auctionId: auction_id, - timestamp: 1496510254313, - }); - - // Step 2: Bid request - events.emit(constants.EVENTS.BID_REQUESTED, { - auctionId: auction_id, - auctionStart: 1509369418387, - timeout: 3000, - bids: [ - { - bidder: 'vuble', - params: { - env: 'net', - pubId: '3', - zoneId: '12345', - floorPrice: 5.50 // optional - }, - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'instream' - } - }, - bidId: 'abdc' - }, - { - bidder: 'vuble', - params: { - env: 'com', - pubId: '8', - zoneId: '2468', - referrer: 'http://www.vuble.fr/' - }, - sizes: '640x360', - mediaTypes: { - video: { - context: 'outstream' - } - }, - bidId: 'efgh', - }, - ], - }); - - // Step 3: Bid response - events.emit(constants.EVENTS.BID_RESPONSE, { - width: '640', - height: '360', - pub_id: '3', - dealId: 'aDealId', - zone_id: '12345', - context: 'instream', - floor_price: 5.5, - url: 'http://www.vuble.tv/', - env: 'net', - bid_id: 'abdc' - }); - - // Step 4: Bid won - events.emit(constants.EVENTS.BID_WON, { - adId: 'adIdTestWin', - ad: 'adContentTestWin', - auctionId: auction_id, - width: 640, - height: 360 - }); - - // Step 4: Auction end - events.emit(constants.EVENTS.AUCTION_END, { - auctionId: auction_id - }); - - // Step 5: Check if the number of call is good (5) - sinon.assert.callCount(vubleAnalytics.track, 5); - }); - }); -}); diff --git a/test/spec/modules/vubleBidAdapter_spec.js b/test/spec/modules/vubleBidAdapter_spec.js index 8996c1b4957..2f0d1c1e262 100644 --- a/test/spec/modules/vubleBidAdapter_spec.js +++ b/test/spec/modules/vubleBidAdapter_spec.js @@ -1,8 +1,8 @@ // import or require modules necessary for the test, e.g.: import {expect} from 'chai'; -import {spec as adapter} from 'modules/vubleBidAdapter'; -import * as utils from 'src/utils'; +import {spec as adapter} from 'modules/vubleBidAdapter.js'; +import * as utils from 'src/utils.js'; describe('VubleAdapter', function () { describe('Check methods existance', function () { @@ -36,9 +36,25 @@ describe('VubleAdapter', function () { } }, }; + let bid2 = { + bidder: 'vuble', + params: { + env: 'net', + pubId: '3', + zoneId: '12345', + floorPrice: 5.00 // optional + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 360] + } + }, + }; it('should be true', function () { expect(adapter.isBidRequestValid(bid)).to.be.true; + expect(adapter.isBidRequestValid(bid2)).to.be.true; }); it('should be false because the sizes are missing or in the wrong format', function () { @@ -85,12 +101,6 @@ describe('VubleAdapter', function () { }); describe('Check buildRequests method', function () { - let sandbox; - before(function () { - sandbox = sinon.sandbox.create(); - sandbox.stub(utils, 'getTopWindowUrl').returns('http://www.vuble.tv/'); - }); - // Bids to be formatted let bid1 = { bidder: 'vuble', @@ -115,7 +125,7 @@ describe('VubleAdapter', function () { env: 'com', pubId: '8', zoneId: '2468', - referrer: 'http://www.vuble.fr/' + referrer: 'https://www.vuble.fr/' }, sizes: '640x360', mediaTypes: { @@ -126,11 +136,27 @@ describe('VubleAdapter', function () { bidId: 'efgh', adUnitCode: 'code' }; + let bid3 = { + bidder: 'vuble', + params: { + env: 'net', + pubId: '3', + zoneId: '3579', + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 360] + } + }, + bidId: 'ijkl', + adUnitCode: '' + }; // Formatted requets let request1 = { method: 'POST', - url: '//player.mediabong.net/prebid/request', + url: 'https://player.mediabong.net/prebid/request', data: { width: '640', height: '360', @@ -138,7 +164,7 @@ describe('VubleAdapter', function () { zone_id: '12345', context: 'instream', floor_price: 5.5, - url: 'http://www.vuble.tv/', + url: '', env: 'net', bid_id: 'abdc', adUnitCode: '' @@ -146,7 +172,7 @@ describe('VubleAdapter', function () { }; let request2 = { method: 'POST', - url: '//player.mediabong.com/prebid/request', + url: 'https://player.mediabong.com/prebid/request', data: { width: '640', height: '360', @@ -154,20 +180,71 @@ describe('VubleAdapter', function () { zone_id: '2468', context: 'outstream', floor_price: 0, - url: 'http://www.vuble.fr/', + url: 'https://www.vuble.fr/', env: 'com', bid_id: 'efgh', adUnitCode: 'code' } }; + let request3 = { + method: 'POST', + url: 'https://player.mediabong.net/prebid/request', + data: { + width: '640', + height: '360', + pub_id: '3', + zone_id: '3579', + context: 'instream', + floor_price: 0, + url: 'https://www.vuble.tv/', + env: 'net', + bid_id: 'ijkl', + adUnitCode: '' + } + }; + let request4 = { + method: 'POST', + url: 'https://player.mediabong.net/prebid/request', + data: { + width: '640', + height: '360', + pub_id: '3', + zone_id: '3579', + context: 'instream', + floor_price: 0, + url: '', + env: 'net', + bid_id: 'ijkl', + adUnitCode: '', + gdpr_consent: { + consent_string: 'test', + gdpr_applies: true + } + } + }; + let bidderRequest1 = { + refererInfo: { + referer: 'https://www.vuble.tv/', + reachedTop: true, + numIframes: 1, + stack: [ + 'http://example.com/page.html', + 'http://example.com/iframe1.html', + 'http://example.com/iframe2.html' + ] + } + }; + let bidderRequest2 = { + 'gdprConsent': { + consentString: 'test', + gdprApplies: true + } + }; it('must return the right formatted requests', function () { - let rs = adapter.buildRequests([bid1, bid2]); expect(adapter.buildRequests([bid1, bid2])).to.deep.equal([request1, request2]); - }); - - after(function () { - sandbox.restore(); + expect(adapter.buildRequests([bid3], bidderRequest1)).to.deep.equal([request3]); + expect(adapter.buildRequests([bid3], bidderRequest2)).to.deep.equal([request4]); }); }); @@ -196,7 +273,7 @@ describe('VubleAdapter', function () { adUnitCode: 'code' }, method: 'POST', - url: '//player.mediabong.net/prebid/request' + url: 'https://player.mediabong.net/prebid/request' }; // Formatted reponse let result = { @@ -262,7 +339,7 @@ describe('VubleAdapter', function () { // Formatted reponse let result = { type: 'iframe', - url: 'http://player.mediabong.net/csifr?1234' + url: 'https://player.mediabong.net/csifr?1234' }; it('should return an empty array', function () { @@ -276,8 +353,60 @@ describe('VubleAdapter', function () { }); it('should be equal to the expected result', function () { - response.body.iframeSync = 'http://player.mediabong.net/csifr?1234'; + response.body.iframeSync = 'https://player.mediabong.net/csifr?1234'; expect(adapter.getUserSyncs(syncOptions, [response])).to.deep.equal([result]); }) }); + + describe('Check outstream scenario with renderer', function () { + // bid Request + let bid = { + data: { + context: 'outstream', + env: 'net', + width: '640', + height: '360', + pub_id: '3', + zone_id: '12345', + bid_id: 'abdc', + floor_price: 5.50, // optional + adUnitCode: 'code' + }, + method: 'POST', + url: 'https://player.mediabong.net/prebid/request' + }; + // Server's response + let response = { + body: { + status: 'ok', + cpm: 5.00, + creativeId: '2468', + url: 'https//player.mediabong.net/prebid/ad/a1b2c3d4', + dealId: 'MDB-TEST-1357', + renderer_id: 0, + renderer_url: 'vuble_renderer.js', + content: 'test' + } + }; + + let adResponse = { + ad: { + video: { + content: 'test' + } + } + }; + let adUnitCode = 'code'; + let rendererUrl = 'vuble_renderer.js'; + let rendererId = 0; + + let formattedResponses = adapter.interpretResponse(response, bid); + it('should equal to the expected format result', function () { + expect(formattedResponses[0].adResponse).to.deep.equal(adResponse); + expect(formattedResponses[0].adUnitCode).to.deep.equal(adUnitCode); + expect(formattedResponses[0].renderer.url).to.equal(rendererUrl); + expect(formattedResponses[0].renderer.id).to.equal(rendererId); + expect(formattedResponses[0].renderer.render).to.exist.and.to.be.a('function'); + }); + }); }); diff --git a/test/spec/modules/weboramaBidAdapter_spec.js b/test/spec/modules/weboramaBidAdapter_spec.js deleted file mode 100644 index d0b119825a6..00000000000 --- a/test/spec/modules/weboramaBidAdapter_spec.js +++ /dev/null @@ -1,118 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/weboramaBidAdapter'; - -describe('WeboramaAdapter', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'weborama', - bidderRequestId: '145e1d6a7837c9', - params: { - placementId: 123, - traffic: 'banner' - }, - placementCode: 'placement_0', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' - }; - - describe('isBidRequestValid', function () { - it('Should return true when placementId can be cast to a number', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false when placementId is not a number', function () { - bid.params.placementId = 'aaa'; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//supply.nl.weborama.fr/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placements = data['placements']; - for (let i = 0; i < placements.length; i++) { - let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes'); - expect(placement.placementId).to.be.a('number'); - expect(placement.bidId).to.be.a('string'); - expect(placement.traffic).to.be.a('string'); - expect(placement.sizes).to.be.an('array'); - } - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - let resObject = { - body: [ { - requestId: '123', - mediaType: 'banner', - cpm: 0.3, - width: 320, - height: 50, - ad: '

Hello ad

', - ttl: 1000, - creativeId: '123asd', - netRevenue: true, - currency: 'USD' - } ] - }; - let serverResponses = spec.interpretResponse(resObject); - it('Returns an array of valid server responses if response object is valid', function () { - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'mediaType'); - expect(dataItem.requestId).to.be.a('string'); - expect(dataItem.cpm).to.be.a('number'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); - expect(dataItem.ad).to.be.a('string'); - expect(dataItem.ttl).to.be.a('number'); - expect(dataItem.creativeId).to.be.a('string'); - expect(dataItem.netRevenue).to.be.a('boolean'); - expect(dataItem.currency).to.be.a('string'); - expect(dataItem.mediaType).to.be.a('string'); - } - it('Returns an empty array if invalid response is passed', function () { - serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - }); - - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and `', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//supply.nl.weborama.fr/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/widespaceBidAdapter_spec.js b/test/spec/modules/widespaceBidAdapter_spec.js index 55afbead72c..95f0117e5d1 100644 --- a/test/spec/modules/widespaceBidAdapter_spec.js +++ b/test/spec/modules/widespaceBidAdapter_spec.js @@ -1,6 +1,6 @@ -import { expect } from 'chai'; -import { spec } from 'modules/widespaceBidAdapter'; -import includes from 'core-js/library/fn/array/includes'; +import {expect} from 'chai'; +import {spec, storage} from 'modules/widespaceBidAdapter.js'; +import includes from 'core-js/library/fn/array/includes.js'; describe('+widespaceAdatperTest', function () { // Dummy bid request @@ -141,8 +141,40 @@ describe('+widespaceAdatperTest', function () { }); describe('+bidRequest', function () { - const request = spec.buildRequests(bidRequest, bidderRequest); + let request; const UrlRegExp = /^((ftp|http|https):)?\/\/[^ "]+$/; + before(function() { + request = spec.buildRequests(bidRequest, bidderRequest); + }) + + let fakeLocalStorage = {}; + let lsSetStub; + let lsGetStub; + let lsRemoveStub; + + beforeEach(function () { + lsSetStub = sinon.stub(storage, 'setDataInLocalStorage').callsFake(function (name, value) { + fakeLocalStorage[name] = value; + }); + + lsGetStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(function (key) { + return fakeLocalStorage[key] || null; + }); + + lsRemoveStub = sinon.stub(storage, 'removeDataFromLocalStorage').callsFake(function (key) { + if (key && (fakeLocalStorage[key] !== null || fakeLocalStorage[key] !== undefined)) { + delete fakeLocalStorage[key]; + } + return true; + }); + }); + + afterEach(function () { + lsSetStub.restore(); + lsGetStub.restore(); + lsRemoveStub.restore(); + fakeLocalStorage = {}; + }); it('-bidRequest method is POST', function () { expect(request[0].method).to.equal('POST'); diff --git a/test/spec/modules/kummaBidAdapter_spec.js b/test/spec/modules/windtalkerBidAdapter_spec.js similarity index 87% rename from test/spec/modules/kummaBidAdapter_spec.js rename to test/spec/modules/windtalkerBidAdapter_spec.js index 7d33bd085b5..222a7611b01 100644 --- a/test/spec/modules/kummaBidAdapter_spec.js +++ b/test/spec/modules/windtalkerBidAdapter_spec.js @@ -1,12 +1,15 @@ import {expect} from 'chai'; -import {spec} from 'modules/kummaBidAdapter'; -import {getTopWindowLocation} from 'src/utils'; +import {spec} from 'modules/windtalkerBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; -describe('Kumma Adapter Tests', function () { +describe('Windtalker Adapter Tests', function () { const slotConfigs = [{ placementCode: '/DfpAccount1/slot1', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bidId: 'bid12345', mediaType: 'banner', params: { @@ -20,7 +23,11 @@ describe('Kumma Adapter Tests', function () { } }, { placementCode: '/DfpAccount2/slot2', - sizes: [[728, 90]], + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, bidId: 'bid23456', mediaType: 'banner', params: { @@ -49,7 +56,11 @@ describe('Kumma Adapter Tests', function () { }]; const videoSlotConfig = [{ placementCode: '/DfpAccount1/slot4', - sizes: [[640, 480]], + mediaTypes: { + video: { + playerSize: [[640, 480]] + } + }, bidId: 'bid12345678', mediaType: 'video', video: { @@ -70,16 +81,16 @@ describe('Kumma Adapter Tests', function () { app: { id: '1111', name: 'app name', - bundle: 'com.kumma.apps', - storeUrl: 'http://kumma.com/apps', - domain: 'kumma.com' + bundle: 'io.windtalker.apps', + storeUrl: 'https://windtalker.io/apps', + domain: 'windtalker.io' } } }]; it('Verify build request', function () { const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); // site object @@ -87,7 +98,7 @@ describe('Kumma Adapter Tests', function () { expect(ortbRequest.site.publisher).to.not.equal(null); expect(ortbRequest.site.publisher.id).to.equal('29521'); expect(ortbRequest.site.ref).to.equal(window.top.document.referrer); - expect(ortbRequest.site.page).to.equal(getTopWindowLocation().href); + expect(ortbRequest.site.page).to.equal(window.location.href); expect(ortbRequest.imp).to.have.lengthOf(2); // device object expect(ortbRequest.device).to.not.equal(null); @@ -117,7 +128,9 @@ describe('Kumma Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - adm: 'This is an Ad' + adm: 'This is an Ad', + w: 300, + h: 250 }] }], cur: 'USD' @@ -145,7 +158,7 @@ describe('Kumma Adapter Tests', function () { it('Verify Native request', function () { const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); // native impression @@ -183,7 +196,7 @@ describe('Kumma Adapter Tests', function () { it('Verify Native response', function () { const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); const nativeResponse = { @@ -195,7 +208,7 @@ describe('Kumma Adapter Tests', function () { { id: 4, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_icon.png', w: 100, h: 100 } }, { id: 5, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_image.png', w: 300, h: 300 } } ], - link: { url: 'http://brand.com/' } + link: { url: 'https://brand.com/' } } }; const ortbResponse = { @@ -203,7 +216,7 @@ describe('Kumma Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - nurl: 'http://rtb.adx1.com/log', + nurl: 'https://rtb.adx1.com/log', adm: JSON.stringify(nativeResponse) }] }], @@ -226,21 +239,21 @@ describe('Kumma Adapter Tests', function () { expect(nativeBid.image.height).to.equal(300); expect(nativeBid.icon.width).to.equal(100); expect(nativeBid.icon.height).to.equal(100); - expect(nativeBid.clickUrl).to.equal(encodeURIComponent('http://brand.com/')); + expect(nativeBid.clickUrl).to.equal(encodeURIComponent('https://brand.com/')); expect(nativeBid.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('http://rtb.adx1.com/log'); + expect(nativeBid.impressionTrackers[0]).to.equal('https://rtb.adx1.com/log'); }); it('Verify Video request', function () { const request = spec.buildRequests(videoSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const videoRequest = JSON.parse(request.data); // site object expect(videoRequest.site).to.not.equal(null); expect(videoRequest.site.publisher.id).to.equal('29521'); expect(videoRequest.site.ref).to.equal(window.top.document.referrer); - expect(videoRequest.site.page).to.equal(getTopWindowLocation().href); + expect(videoRequest.site.page).to.equal(window.location.href); // device object expect(videoRequest.device).to.not.equal(null); expect(videoRequest.device.ua).to.equal(navigator.userAgent); @@ -261,7 +274,7 @@ describe('Kumma Adapter Tests', function () { bid: [{ impid: videoRequest.imp[0].id, price: 1.90, - adm: 'http://vid.example.com/9876', + adm: 'https://vid.example.com/9876', crid: '510511_754567308' }] }], @@ -272,7 +285,7 @@ describe('Kumma Adapter Tests', function () { // verify first bid const bid = bids[0]; expect(bid.cpm).to.equal(1.90); - expect(bid.vastUrl).to.equal('http://vid.example.com/9876'); + expect(bid.vastUrl).to.equal('https://vid.example.com/9876'); expect(bid.crid).to.equal('510511_754567308'); expect(bid.width).to.equal(640); expect(bid.height).to.equal(480); @@ -283,7 +296,7 @@ describe('Kumma Adapter Tests', function () { }); it('Verifies bidder code', function () { - expect(spec.code).to.equal('kumma'); + expect(spec.code).to.equal('windtalker'); }); it('Verifies supported media types', function () { @@ -309,9 +322,9 @@ describe('Kumma Adapter Tests', function () { expect(ortbRequest.app.publisher.id).to.equal('29521'); expect(ortbRequest.app.id).to.equal('1111'); expect(ortbRequest.app.name).to.equal('app name'); - expect(ortbRequest.app.bundle).to.equal('com.kumma.apps'); - expect(ortbRequest.app.storeurl).to.equal('http://kumma.com/apps'); - expect(ortbRequest.app.domain).to.equal('kumma.com'); + expect(ortbRequest.app.bundle).to.equal('io.windtalker.apps'); + expect(ortbRequest.app.storeurl).to.equal('https://windtalker.io/apps'); + expect(ortbRequest.app.domain).to.equal('windtalker.io'); }); it('Verify GDPR', function () { @@ -322,7 +335,7 @@ describe('Kumma Adapter Tests', function () { } }; const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); expect(ortbRequest.user).to.not.equal(null); diff --git a/test/spec/modules/wipesBidAdapter_spec.js b/test/spec/modules/wipesBidAdapter_spec.js new file mode 100644 index 00000000000..b5935563526 --- /dev/null +++ b/test/spec/modules/wipesBidAdapter_spec.js @@ -0,0 +1,148 @@ +import {expect} from 'chai'; +import {spec} from 'modules/wipesBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; + +const ENDPOINT_URL = 'https://adn-srv.reckoner-api.com/v1/prebid'; + +describe('wipesBidAdapter', function () { + const adapter = newBidder(spec); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'wipes', + 'params': { + asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' + }, + 'adUnitCode': 'adunit-code', + 'bidId': '51ef8751f9aead', + 'bidderRequestId': '15246a574e859f', + 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when asid not passed correctly', function () { + bid.params.asid = ''; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when require params are not passed', function () { + let bid = Object.assign({}, bid); + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let bidRequests = [ + { + 'bidder': 'wipes', + 'params': { + asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' + }, + 'adUnitCode': 'adunit-code', + 'bidId': '51ef8751f9aead', + 'bidderRequestId': '15246a574e859f', + 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + }, + { + 'bidder': 'wipes', + 'params': { + asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' + }, + 'adUnitCode': 'adunit-code2', + 'bidId': '51ef8751f9aead', + 'bidderRequestId': '15246a574e859f', + 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + } + ]; + + let bidderRequest = { + refererInfo: { + numIframes: 0, + reachedTop: true, + referer: 'http://example.com', + stack: ['http://example.com'] + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + it('sends bid request to our endpoint via GET', function () { + expect(request[0].method).to.equal('GET'); + expect(request[1].method).to.equal('GET'); + }); + + it('attaches source and version to endpoint URL as query params', function () { + expect(request[0].url).to.equal(ENDPOINT_URL); + expect(request[1].url).to.equal(ENDPOINT_URL); + }); + + it('adUnitCode should be sent as uc parameters on any requests', function () { + expect(request[0].data.asid).to.equal('dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ'); + expect(request[1].data.asid).to.equal('dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ'); + }); + }); + + describe('interpretResponse', function () { + let bidRequestVideo = [ + { + 'method': 'GET', + 'url': ENDPOINT_URL, + 'data': { + 'asid': 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ', + } + } + ]; + + let serverResponseVideo = { + body: { + 'uuid': 'a42947f8-f8fd-4cf7-bb72-31a87ab1f6ff', + 'ad_tag': '', + 'height': 160, + 'width': 300, + 'cpm': 850, + 'status_message': '', + 'currency': 'JPY', + 'video_creative_id': 600004 + } + }; + + it('should get the correct bid response for video', function () { + let expectedResponse = [{ + 'requestId': '23beaa6af6cdde', + 'cpm': 850, + 'width': 300, + 'height': 160, + 'creativeId': '600004', + 'dealId': undefined, + 'currency': 'JPY', + 'netRevenue': true, + 'ttl': 3000, + 'referrer': '', + 'mediaType': 'banner', + 'ad': '' + }]; + let result = spec.interpretResponse(serverResponseVideo, bidRequestVideo[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); + }); + + it('handles empty bid response', function () { + let response = { + body: { + 'uid': 'a42947f8-f8fd-4cf7-bb72-31a87ab1f6ff', + 'height': 0, + 'crid': '', + 'statusMessage': '', + 'width': 0, + 'cpm': 0 + } + }; + let result = spec.interpretResponse(response, bidRequestVideo[0]); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/xendizBidAdapter_spec.js b/test/spec/modules/xendizBidAdapter_spec.js deleted file mode 100644 index 4d1aa3c935f..00000000000 --- a/test/spec/modules/xendizBidAdapter_spec.js +++ /dev/null @@ -1,119 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/xendizBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const VALID_ENDPOINT = '//prebid.xendiz.com/request'; -const bidRequest = { - bidder: 'xendiz', - adUnitCode: 'test-div', - sizes: [[300, 250], [300, 600]], - params: { - pid: '550e8400-e29b-41d4-a716-446655440000' - }, - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', -}; - -const bidResponse = { - body: { - id: '1d1a030790a475', - bids: [{ - id: '30b31c1838de1e', - price: 3, - cur: 'USD', - h: 250, - w: 300, - crid: 'test', - dealid: '1', - exp: 900, - adm: 'tag' - }] - } -}; - -const noBidResponse = { body: { id: '1d1a030790a475', bids: [] } }; - -describe('xendizBidAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return false', function () { - let bid = Object.assign({}, bidRequest); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true', function () { - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - it('should format valid url', function () { - const request = spec.buildRequests([bidRequest]); - expect(request.url).to.equal(VALID_ENDPOINT); - }); - - it('should format valid url', function () { - const request = spec.buildRequests([bidRequest]); - expect(request.url).to.equal(VALID_ENDPOINT); - }); - - it('should format valid request body', function () { - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.id).to.exist; - expect(payload.items).to.exist; - expect(payload.device).to.exist; - }); - - it('should attach valid device info', function () { - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.device).to.deep.equal([ - navigator.language || '', - window.screen.width, - window.screen.height - ]); - }); - - it('should transform sizes', function () { - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - const item = payload.items[0]; - expect(item[item.length - 1]).to.deep.equal(['300x250', '300x600']); - }); - }); - - describe('interpretResponse', function () { - it('should get correct bid response', function () { - const result = spec.interpretResponse(bidResponse); - const validResponse = [{ - requestId: '30b31c1838de1e', - cpm: 3, - width: 300, - height: 250, - creativeId: 'test', - netRevenue: true, - dealId: '1', - currency: 'USD', - ttl: 900, - ad: 'tag' - }]; - - expect(result).to.deep.equal(validResponse); - }); - - it('handles nobid responses', function () { - let result = spec.interpretResponse(noBidResponse); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/xhbBidAdapter_spec.js b/test/spec/modules/xhbBidAdapter_spec.js index e48d3011ed2..a12abc74c64 100644 --- a/test/spec/modules/xhbBidAdapter_spec.js +++ b/test/spec/modules/xhbBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/xhbBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; +import { spec } from 'modules/xhbBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { deepClone } from 'src/utils.js'; -const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; +const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid'; describe('xhbAdapter', function () { const adapter = newBidder(spec); @@ -337,7 +337,7 @@ describe('xhbAdapter', function () { 'tag_id': 10433394, 'auction_id': '4534722592064951574', 'nobid': false, - 'no_ad_url': 'http://lax1-ib.adnxs.com/no-ad', + 'no_ad_url': 'https://lax1-ib.adnxs.com/no-ad', 'timeout_ms': 10000, 'ad_profile_id': 27079, 'ads': [ @@ -361,7 +361,7 @@ describe('xhbAdapter', function () { 'trackers': [ { 'impression_urls': [ - 'http://lax1-ib.adnxs.com/impression' + 'https://lax1-ib.adnxs.com/impression' ], 'video_events': {} } @@ -448,19 +448,19 @@ describe('xhbAdapter', function () { 'icon': { 'width': 0, 'height': 0, - 'url': 'http://cdn.adnxs.com/icon.png' + 'url': 'https://cdn.adnxs.com/icon.png' }, 'main_img': { 'width': 2352, 'height': 1516, - 'url': 'http://cdn.adnxs.com/img.png' + 'url': 'https://cdn.adnxs.com/img.png' }, 'link': { 'url': 'https://www.appnexus.com', 'fallback_url': '', - 'click_trackers': ['http://nym1-ib.adnxs.com/click'] + 'click_trackers': ['https://nym1-ib.adnxs.com/click'] }, - 'impression_trackers': ['http://example.com'], + 'impression_trackers': ['https://example.com'], }; let bidderRequest; @@ -468,7 +468,7 @@ describe('xhbAdapter', function () { expect(result[0].native.title).to.equal('Native Creative'); expect(result[0].native.body).to.equal('Cool description great stuff'); expect(result[0].native.cta).to.equal('Do it'); - expect(result[0].native.image.url).to.equal('http://cdn.adnxs.com/img.png'); + expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png'); }); it('supports configuring outstream renderers', function () { diff --git a/test/spec/modules/yieldbotBidAdapter_spec.js b/test/spec/modules/yieldbotBidAdapter_spec.js deleted file mode 100644 index 2548bb31fdc..00000000000 --- a/test/spec/modules/yieldbotBidAdapter_spec.js +++ /dev/null @@ -1,1383 +0,0 @@ -import { expect } from 'chai'; -import find from 'core-js/library/fn/array/find'; -import { newBidder } from 'src/adapters/bidderFactory'; -import AdapterManager from 'src/adapterManager'; -import { newAuctionManager } from 'src/auctionManager'; -import * as utils from 'src/utils'; -import * as urlUtils from 'src/url'; -import events from 'src/events'; -import { YieldbotAdapter, spec } from 'modules/yieldbotBidAdapter'; - -before(function() { - YieldbotAdapter.clearAllCookies(); -}); -describe('Yieldbot Adapter Unit Tests', function() { - const ALL_SEARCH_PARAMS = ['apie', 'bt', 'cb', 'cts_ad', 'cts_imp', 'cts_ini', 'cts_js', 'cts_ns', 'cts_rend', 'cts_res', 'e', 'ioa', 'it', 'la', 'lo', 'lpv', 'lpvi', 'mtp', 'np', 'pvd', 'pvi', 'r', 'ri', 'sb', 'sd', 'si', 'slot', 'sn', 'ssz', 'to', 'ua', 'v', 'vi']; - - const BID_LEADERBOARD_728x90 = { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'leaderboard' - }, - adUnitCode: '/0000000/leaderboard', - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c19', - sizes: [728, 90], - bidId: '2240b2af6064bb', - bidderRequestId: '1e878e3676fb85', - auctionId: 'c9964bd5-f835-4c91-916e-00295819f932' - }; - - const BID_MEDREC_300x600 = { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'medrec' - }, - adUnitCode: '/0000000/side-bar', - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c20', - sizes: [300, 600], - bidId: '332067957eaa33', - bidderRequestId: '1e878e3676fb85', - auctionId: 'c9964bd5-f835-4c91-916e-00295819f932' - }; - - const BID_MEDREC_300x250 = { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'medrec' - }, - adUnitCode: '/0000000/medrec', - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c21', - sizes: [[300, 250]], - bidId: '49d7fe5c3a15ed', - bidderRequestId: '1e878e3676fb85', - auctionId: 'c9964bd5-f835-4c91-916e-00295819f932' - }; - - const BID_SKY160x600 = { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'skyscraper' - }, - adUnitCode: '/0000000/side-bar', - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c21', - sizes: [160, 600], - bidId: '49d7fe5c3a16ee', - bidderRequestId: '1e878e3676fb85', - auctionId: 'c9964bd5-f835-4c91-916e-00295819f932' - }; - - const AD_UNITS = [ - { - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c19', - code: '/00000000/leaderboard', - sizes: [728, 90], - bids: [ - { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'leaderboard' - } - } - ] - }, - { - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c20', - code: '/00000000/medrec', - sizes: [[300, 250]], - bids: [ - { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'medrec' - } - } - ] - }, - { - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c21', - code: '/00000000/multi-size', - sizes: [[300, 600]], - bids: [ - { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'medrec' - } - } - ] - }, - { - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c22', - code: '/00000000/skyscraper', - sizes: [[160, 600]], - bids: [ - { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'skyscraper' - } - } - ] - } - ]; - - const INTERPRET_RESPONSE_BID_REQUEST = { - method: 'GET', - url: '//i.yldbt.com/m/1234/v1/init', - data: { - cts_js: 1518184900582, - cts_ns: 1518184900582, - v: 'pbjs-yb-1.0.0', - vi: 'jdg00eijgpvemqlz73', - si: 'jdg00eil9y4mcdo850', - pvd: 6, - pvi: 'jdg03ai5kp9k1rkheh', - lpv: 1518184868108, - lpvi: 'jdg02lfwmdx8n0ncgc', - bt: 'init', - ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', - np: 'MacIntel', - la: 'en-US', - to: 5, - sd: '2560x1440', - lo: 'http://localhost:9999/test/spec/e2e/gpt-examples/gpt_yieldbot.html', - r: '', - e: '', - sn: 'leaderboard|medrec|medrec|skyscraper', - ssz: '728x90|300x250|300x600|160x600', - cts_ini: 1518184900591 - }, - yieldbotSlotParams: { - psn: '1234', - sn: 'leaderboard|medrec|medrec|skyscraper', - ssz: '728x90|300x250|300x600|160x600', - bidIdMap: { - 'jdg03ai5kp9k1rkheh:leaderboard:728x90': '2240b2af6064bb', - 'jdg03ai5kp9k1rkheh:medrec:300x250': '49d7fe5c3a15ed', - 'jdg03ai5kp9k1rkheh:medrec:300x600': '332067957eaa33', - 'jdg03ai5kp9k1rkheh:skyscraper:160x600': '49d7fe5c3a16ee' - } - }, - options: { - withCredentials: true, - customHeaders: { - Accept: 'application/json' - } - } - }; - - const INTERPRET_RESPONSE_SERVER_RESPONSE = { - body: { - pvi: 'jdg03ai5kp9k1rkheh', - subdomain_iframe: 'ads-adseast-vpc', - url_prefix: 'http://ads-adseast-vpc.yldbt.com/m/', - slots: [ - { - slot: 'leaderboard', - cpm: '800', - size: '728x90' - }, - { - slot: 'medrec', - cpm: '300', - size: '300x250' - }, - { - slot: 'medrec', - cpm: '800', - size: '300x600' - }, - { - slot: 'skyscraper', - cpm: '300', - size: '160x600' - } - ], - user_syncs: [ - 'https://usersync.dd9693a32aa1.com/00000000.gif?p=a', - 'https://usersync.3b19503b37d8.com/00000000.gif?p=b', - 'https://usersync.5cb389d36d30.com/00000000.gif?p=c' - ] - }, - headers: {} - }; - - let FIXTURE_AD_UNITS, FIXTURE_SERVER_RESPONSE, FIXTURE_BID_REQUEST, FIXTURE_BID_REQUESTS, FIXTURE_BIDS; - beforeEach(function() { - FIXTURE_AD_UNITS = utils.deepClone(AD_UNITS); - FIXTURE_BIDS = { - BID_LEADERBOARD_728x90: utils.deepClone(BID_LEADERBOARD_728x90), - BID_MEDREC_300x600: utils.deepClone(BID_MEDREC_300x600), - BID_MEDREC_300x250: utils.deepClone(BID_MEDREC_300x250), - BID_SKY160x600: utils.deepClone(BID_SKY160x600) - }; - - FIXTURE_BID_REQUEST = utils.deepClone(INTERPRET_RESPONSE_BID_REQUEST); - FIXTURE_SERVER_RESPONSE = utils.deepClone(INTERPRET_RESPONSE_SERVER_RESPONSE); - FIXTURE_BID_REQUESTS = [ - FIXTURE_BIDS.BID_LEADERBOARD_728x90, - FIXTURE_BIDS.BID_MEDREC_300x600, - FIXTURE_BIDS.BID_MEDREC_300x250, - FIXTURE_BIDS.BID_SKY160x600 - ]; - }); - - afterEach(function() { - YieldbotAdapter._optOut = false; - YieldbotAdapter.clearAllCookies(); - YieldbotAdapter._isInitialized = false; - YieldbotAdapter.initialize(); - }); - - describe('Adapter exposes BidderSpec API', function() { - it('code', function() { - expect(spec.code).to.equal('yieldbot'); - }); - it('supportedMediaTypes', function() { - expect(spec.supportedMediaTypes).to.deep.equal(['banner']); - }); - it('isBidRequestValid', function() { - expect(spec.isBidRequestValid).to.be.a('function'); - }); - it('buildRequests', function() { - expect(spec.buildRequests).to.be.a('function'); - }); - it('interpretResponse', function() { - expect(spec.interpretResponse).to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function() { - let bid = { - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - }; - - it('valid parameters', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(true); - }); - - it('undefined parameters', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - }); - - it('falsey string parameters', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: '', - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: '' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 0 - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - }); - - it('parameters type invalid', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 0 - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: { name: 'foo' }, - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - }); - - it('invalid sizes type', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 'bar' - }, - sizes: {} - })).to.equal(true); - }); - }); - - describe('getSlotRequestParams', function() { - const EMPTY_SLOT_PARAMS = { sn: '', ssz: '', bidIdMap: {} }; - - it('should default to empty slot params', function() { - expect(YieldbotAdapter.getSlotRequestParams('')).to.deep.equal(EMPTY_SLOT_PARAMS); - expect(YieldbotAdapter.getSlotRequestParams()).to.deep.equal(EMPTY_SLOT_PARAMS); - expect(YieldbotAdapter.getSlotRequestParams('', [])).to.deep.equal(EMPTY_SLOT_PARAMS); - expect(YieldbotAdapter.getSlotRequestParams(0, [])).to.deep.equal(EMPTY_SLOT_PARAMS); - }); - - it('should build slot bid request parameters', function() { - const bidRequests = [ - FIXTURE_BIDS.BID_LEADERBOARD_728x90, - FIXTURE_BIDS.BID_MEDREC_300x600, - FIXTURE_BIDS.BID_MEDREC_300x250 - ]; - const slotParams = YieldbotAdapter.getSlotRequestParams('f0e1d2c', bidRequests); - - expect(slotParams.psn).to.equal('1234'); - expect(slotParams.sn).to.equal('leaderboard|medrec'); - expect(slotParams.ssz).to.equal('728x90|300x600.300x250'); - - let bidId = slotParams.bidIdMap['f0e1d2c:leaderboard:728x90']; - expect(bidId).to.equal('2240b2af6064bb'); - - bidId = slotParams.bidIdMap['f0e1d2c:medrec:300x250']; - expect(bidId).to.equal('49d7fe5c3a15ed'); - - bidId = slotParams.bidIdMap['f0e1d2c:medrec:300x600']; - expect(bidId).to.equal('332067957eaa33'); - }); - - it('should build slot bid request parameters in order of bidRequests', function() { - const bidRequests = [ - FIXTURE_BIDS.BID_MEDREC_300x600, - FIXTURE_BIDS.BID_LEADERBOARD_728x90, - FIXTURE_BIDS.BID_MEDREC_300x250 - ]; - - const slotParams = YieldbotAdapter.getSlotRequestParams('f0e1d2c', bidRequests); - - expect(slotParams.psn).to.equal('1234'); - expect(slotParams.sn).to.equal('medrec|leaderboard'); - expect(slotParams.ssz).to.equal('300x600.300x250|728x90'); - - let bidId = slotParams.bidIdMap['f0e1d2c:leaderboard:728x90']; - expect(bidId).to.equal('2240b2af6064bb'); - - bidId = slotParams.bidIdMap['f0e1d2c:medrec:300x250']; - expect(bidId).to.equal('49d7fe5c3a15ed'); - - bidId = slotParams.bidIdMap['f0e1d2c:medrec:300x600']; - expect(bidId).to.equal('332067957eaa33'); - }); - - it('should exclude slot bid requests with malformed sizes', function() { - const bid = FIXTURE_BIDS.BID_MEDREC_300x250; - bid.sizes = ['300x250']; - const bidRequests = [bid, FIXTURE_BIDS.BID_LEADERBOARD_728x90]; - const slotParams = YieldbotAdapter.getSlotRequestParams('affffffe', bidRequests); - expect(slotParams.psn).to.equal('1234'); - expect(slotParams.sn).to.equal('leaderboard'); - expect(slotParams.ssz).to.equal('728x90'); - }); - }); - - describe('getCookie', function() { - it('should return null if cookie name not found', function() { - const cookieName = YieldbotAdapter.newId(); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - }); - - describe('setCookie', function() { - it('should set a root path first-party cookie with temporal expiry', function() { - const cookieName = YieldbotAdapter.newId(); - const cookieValue = YieldbotAdapter.newId(); - - YieldbotAdapter.setCookie(cookieName, cookieValue, 2000, '/'); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(cookieValue); - - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should set a root path first-party cookie with session expiry', function() { - const cookieName = YieldbotAdapter.newId(); - const cookieValue = YieldbotAdapter.newId(); - - YieldbotAdapter.setCookie(cookieName, cookieValue, null, '/'); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(cookieValue); - - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should fail to set a cookie x-domain', function() { - const cookieName = YieldbotAdapter.newId(); - const cookieValue = YieldbotAdapter.newId(); - - YieldbotAdapter.setCookie(cookieName, cookieValue, null, '/', `${cookieName}.com`); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - }); - - describe('clearAllcookies', function() { - it('should delete all first-party cookies', function() { - let idx, cookieLabels = YieldbotAdapter._cookieLabels, cookieName, cookieValue; - for (idx = 0; idx < cookieLabels.length; idx++) { - YieldbotAdapter.deleteCookie('__ybot' + cookieLabels[idx]); - } - - YieldbotAdapter.sessionBlocked = true; - expect(YieldbotAdapter.sessionBlocked, 'sessionBlocked').to.equal(true); - - const userId = YieldbotAdapter.userId; - expect(YieldbotAdapter.userId, 'userId').to.equal(userId); - - const sessionId = YieldbotAdapter.sessionId; - expect(YieldbotAdapter.sessionId, 'sessionId').to.equal(sessionId); - - const pageviewDepth = YieldbotAdapter.pageviewDepth; - expect(pageviewDepth, 'returned pageviewDepth').to.equal(1); - expect(YieldbotAdapter.pageviewDepth, 'get pageviewDepth').to.equal(2); - - const lastPageviewId = YieldbotAdapter.newId(); - YieldbotAdapter.lastPageviewId = lastPageviewId; - expect(YieldbotAdapter.lastPageviewId, 'get lastPageviewId').to.equal(lastPageviewId); - - const lastPageviewTime = Date.now(); - YieldbotAdapter.lastPageviewTime = lastPageviewTime; - expect(YieldbotAdapter.lastPageviewTime, 'lastPageviewTime').to.equal(lastPageviewTime); - - const urlPrefix = YieldbotAdapter.urlPrefix('http://here.there.com/ad/'); - expect(YieldbotAdapter.urlPrefix(), 'urlPrefix').to.equal('http://here.there.com/ad/'); - - for (idx = 0; idx < cookieLabels.length; idx++) { - cookieValue = YieldbotAdapter.getCookie('__ybot' + cookieLabels[idx]); - expect(!!cookieValue, 'setter: ' + cookieLabels[idx]).to.equal(true); - } - - YieldbotAdapter.clearAllCookies(); - - for (idx = 0; idx < cookieLabels.length; idx++) { - cookieName = '__ybot' + cookieLabels[idx]; - cookieValue = YieldbotAdapter.getCookie(cookieName); - expect(cookieValue, cookieName).to.equal(null); - }; - }); - }); - - describe('sessionBlocked', function() { - const cookieName = '__ybotn'; - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should return true if cookie value is interpreted as non-zero', function() { - YieldbotAdapter.setCookie(cookieName, '1', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "1"').to.equal(true); - - YieldbotAdapter.setCookie(cookieName, '10.01', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "10.01"').to.equal(true); - - YieldbotAdapter.setCookie(cookieName, '-10.01', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "-10.01"').to.equal(true); - - YieldbotAdapter.setCookie(cookieName, 1, 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the number 1').to.equal(true); - }); - - it('should return false if cookie name not found', function() { - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - }); - - it('should return false if cookie value is interpreted as zero', function() { - YieldbotAdapter.setCookie(cookieName, '0', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "0"').to.equal(false); - - YieldbotAdapter.setCookie(cookieName, '.01', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string ".01"').to.equal(false); - - YieldbotAdapter.setCookie(cookieName, '-.9', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "-.9"').to.equal(false); - - YieldbotAdapter.setCookie(cookieName, 0, 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the number 0').to.equal(false); - }); - - it('should return false if cookie value source is a non-numeric string', function() { - YieldbotAdapter.setCookie(cookieName, 'true', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - }); - - it('should return false if cookie value source is a boolean', function() { - YieldbotAdapter.setCookie(cookieName, true, 2000, '/'); - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - }); - - it('should set sessionBlocked', function() { - YieldbotAdapter.sessionBlocked = true; - expect(YieldbotAdapter.sessionBlocked).to.equal(true); - YieldbotAdapter.sessionBlocked = false; - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - - YieldbotAdapter.sessionBlocked = 1; - expect(YieldbotAdapter.sessionBlocked).to.equal(true); - YieldbotAdapter.sessionBlocked = 0; - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - - YieldbotAdapter.sessionBlocked = '1'; - expect(YieldbotAdapter.sessionBlocked).to.equal(true); - YieldbotAdapter.sessionBlocked = ''; - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - }); - }); - - describe('userId', function() { - const cookieName = '__ybotu'; - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should set a user Id if cookie does not exist', function() { - const userId = YieldbotAdapter.userId; - expect(userId).to.match(/[0-9a-z]{18}/); - }); - - it('should return user Id if cookie exists', function() { - const expectedUserId = YieldbotAdapter.newId(); - YieldbotAdapter.setCookie(cookieName, expectedUserId, 2000, '/'); - const userId = YieldbotAdapter.userId; - expect(userId).to.equal(expectedUserId); - }); - }); - - describe('sessionId', function() { - const cookieName = '__ybotsi'; - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should set a session Id if cookie does not exist', function() { - const sessionId = YieldbotAdapter.sessionId; - expect(sessionId).to.match(/[0-9a-z]{18}/); - }); - - it('should return session Id if cookie exists', function() { - const expectedSessionId = YieldbotAdapter.newId(); - YieldbotAdapter.setCookie(cookieName, expectedSessionId, 2000, '/'); - const sessionId = YieldbotAdapter.sessionId; - expect(sessionId).to.equal(expectedSessionId); - }); - }); - - describe('lastPageviewId', function() { - const cookieName = '__ybotlpvi'; - - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should return empty string if cookie does not exist', function() { - const lastBidId = YieldbotAdapter.lastPageviewId; - expect(lastBidId).to.equal(''); - }); - - it('should set an id string', function() { - const id = YieldbotAdapter.newId(); - YieldbotAdapter.lastPageviewId = id; - const lastBidId = YieldbotAdapter.lastPageviewId; - expect(lastBidId).to.equal(id); - }); - }); - - describe('lastPageviewTime', function() { - const cookieName = '__ybotlpv'; - - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should return zero if cookie does not exist', function() { - const lastBidTime = YieldbotAdapter.lastPageviewTime; - expect(lastBidTime).to.equal(0); - }); - - it('should set a timestamp', function() { - const ts = Date.now(); - YieldbotAdapter.lastPageviewTime = ts; - const lastBidTime = YieldbotAdapter.lastPageviewTime; - expect(lastBidTime).to.equal(ts); - }); - }); - - describe('pageviewDepth', function() { - const cookieName = '__ybotpvd'; - - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should return one (1) if cookie does not exist', function() { - const pageviewDepth = YieldbotAdapter.pageviewDepth; - expect(pageviewDepth).to.equal(1); - }); - - it('should increment the integer string for depth', function() { - let pageviewDepth = YieldbotAdapter.pageviewDepth; - expect(pageviewDepth).to.equal(1); - - pageviewDepth = YieldbotAdapter.pageviewDepth; - expect(pageviewDepth).to.equal(2); - }); - }); - - describe('urlPrefix', function() { - const cookieName = '__ybotc'; - const protocol = document.location.protocol; - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should set the default prefix if cookie does not exist', function(done) { - const urlPrefix = YieldbotAdapter.urlPrefix(); - expect(urlPrefix).to.equal('//i.yldbt.com/m/'); - done(); - }); - - it('should return prefix if cookie exists', function() { - YieldbotAdapter.setCookie(cookieName, protocol + '//closest.az.com/path/', 2000, '/'); - const urlPrefix = YieldbotAdapter.urlPrefix(); - expect(urlPrefix).to.equal(protocol + '//closest.az.com/path/'); - }); - - it('should reset prefix if default already set', function() { - const defaultUrlPrefix = YieldbotAdapter.urlPrefix(); - const url = protocol + '//close.az.com/path/'; - expect(defaultUrlPrefix).to.equal('//i.yldbt.com/m/'); - - let urlPrefix = YieldbotAdapter.urlPrefix(url); - expect(urlPrefix, 'reset prefix').to.equal(url); - - urlPrefix = YieldbotAdapter.urlPrefix(); - expect(urlPrefix, 'subsequent request').to.equal(url); - }); - - it('should set containing document protocol', function() { - let urlPrefix = YieldbotAdapter.urlPrefix('http://close.az.com/path/'); - expect(urlPrefix, 'http - use: ' + protocol).to.equal(protocol + '//close.az.com/path/'); - - urlPrefix = YieldbotAdapter.urlPrefix('https://close.az.com/path/'); - expect(urlPrefix, 'https - use: ' + protocol).to.equal(protocol + '//close.az.com/path/'); - }); - - it('should fallback to default for invalid argument', function() { - let urlPrefix = YieldbotAdapter.urlPrefix('//close.az.com/path/'); - expect(urlPrefix, 'Url w/o protocol').to.equal('//i.yldbt.com/m/'); - - urlPrefix = YieldbotAdapter.urlPrefix('mumble'); - expect(urlPrefix, 'Invalid Url').to.equal('//i.yldbt.com/m/'); - }); - }); - - describe('initBidRequestParams', function() { - it('should build common bid request state parameters', function() { - const params = YieldbotAdapter.initBidRequestParams( - [ - { - 'params': { - psn: '1234', - slot: 'medrec' - }, - sizes: [[300, 250], [300, 600]] - } - ] - ); - - const expectedParamKeys = [ - 'v', - 'vi', - 'si', - 'pvi', - 'pvd', - 'lpvi', - 'bt', - 'lo', - 'r', - 'sd', - 'to', - 'la', - 'np', - 'ua', - 'lpv', - 'cts_ns', - 'cts_js', - 'e' - ]; - - const missingKeys = []; - expectedParamKeys.forEach((item) => { - if (item in params === false) { - missingKeys.push(item); - } - }); - const extraKeys = []; - Object.keys(params).forEach((item) => { - if (!find(expectedParamKeys, param => param === item)) { - extraKeys.push(item); - } - }); - - expect( - missingKeys.length, - `\nExpected: ${expectedParamKeys}\nMissing keys: ${JSON.stringify(missingKeys)}`) - .to.equal(0); - expect( - extraKeys.length, - `\nExpected: ${expectedParamKeys}\nExtra keys: ${JSON.stringify(extraKeys)}`) - .to.equal(0); - }); - }); - - describe('buildRequests', function() { - it('should not return bid requests if optOut', function() { - YieldbotAdapter._optOut = true; - const requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(0); - }); - - it('should not return bid requests if sessionBlocked', function() { - YieldbotAdapter.sessionBlocked = true; - const requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(0); - YieldbotAdapter.sessionBlocked = false; - }); - - it('should re-enable requests when sessionBlocked expires', function() { - const cookieName = '__ybotn'; - YieldbotAdapter.setCookie( - cookieName, - 1, - 2000, - '/'); - let requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(0); - YieldbotAdapter.deleteCookie(cookieName); - requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(1); - }); - - it('should return a single BidRequest object', function() { - const requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(1); - }); - - it('should have expected server options', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - const expectedOptions = { - withCredentials: true, - customHeaders: { - Accept: 'application/json' - } - }; - expect(request.options).to.eql(expectedOptions); - }); - - it('should be a GET request', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.method).to.equal('GET'); - }); - - it('should have bid request specific params', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.data).to.not.equal(undefined); - - const expectedParamKeys = [ - 'v', - 'vi', - 'si', - 'pvi', - 'pvd', - 'lpvi', - 'bt', - 'lo', - 'r', - 'sd', - 'to', - 'la', - 'np', - 'ua', - 'sn', - 'ssz', - 'lpv', - 'cts_ns', - 'cts_js', - 'cts_ini', - 'e' - ]; - - const missingKeys = []; - expectedParamKeys.forEach((item) => { - if (item in request.data === false) { - missingKeys.push(item); - } - }); - const extraKeys = []; - Object.keys(request.data).forEach((item) => { - if (!find(expectedParamKeys, param => param === item)) { - extraKeys.push(item); - } - }); - - expect( - missingKeys.length, - `\nExpected: ${expectedParamKeys}\nMissing keys: ${JSON.stringify(missingKeys)}`) - .to.equal(0); - expect( - extraKeys.length, - `\nExpected: ${expectedParamKeys}\nExtra keys: ${JSON.stringify(extraKeys)}`) - .to.equal(0); - }); - - it('should have the correct bidUrl form', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - const bidUrl = '//i.yldbt.com/m/1234/v1/init'; - expect(request.url).to.equal(bidUrl); - }); - - it('should set the bid request slot/bidId mapping', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.yieldbotSlotParams).to.not.equal(undefined); - expect(request.yieldbotSlotParams.bidIdMap).to.not.equal(undefined); - - const map = {}; - map[request.data.pvi + ':leaderboard:728x90'] = '2240b2af6064bb'; - map[request.data.pvi + ':medrec:300x250'] = '49d7fe5c3a15ed'; - map[request.data.pvi + ':medrec:300x600'] = '332067957eaa33'; - map[request.data.pvi + ':skyscraper:160x600'] = '49d7fe5c3a16ee'; - expect(request.yieldbotSlotParams.bidIdMap).to.eql(map); - }); - - it('should set the bid request publisher number', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.yieldbotSlotParams.psn).to.equal('1234'); - }); - - it('should have unique slot name parameter', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.yieldbotSlotParams.sn).to.equal('leaderboard|medrec|skyscraper'); - }); - - it('should have slot sizes parameter', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.yieldbotSlotParams.ssz).to.equal('728x90|300x600.300x250|160x600'); - }); - - it('should use edge server Url prefix if set', function() { - const cookieName = '__ybotc'; - YieldbotAdapter.setCookie( - cookieName, - 'http://close.edge.adserver.com/', - 2000, - '/'); - - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.url).to.match(/^http:\/\/close\.edge\.adserver\.com\//); - }); - - it('should be adapter loaded before navigation start time', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - const timeDiff = request.data.cts_ns - request.data.cts_js; - expect(timeDiff >= 0, 'adapter loaded < nav').to.equal(true); - }); - - it('should be navigation start before bid request time', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - const timeDiff = request.data.cts_ini - request.data.cts_ns; - expect(timeDiff >= 0, 'nav start < request').to.equal(true); - }); - }); - - describe('interpretResponse', function() { - it('should not return Bids if optOut', function() { - YieldbotAdapter._optOut = true; - const responses = YieldbotAdapter.interpretResponse(); - expect(responses.length).to.equal(0); - }); - - it('should not return Bids if no server response slot bids', function() { - FIXTURE_SERVER_RESPONSE.body.slots = []; - const responses = YieldbotAdapter.interpretResponse(FIXTURE_SERVER_RESPONSE, FIXTURE_BID_REQUEST); - expect(responses.length).to.equal(0); - }); - - it('should not include Bid if missing cpm', function() { - delete FIXTURE_SERVER_RESPONSE.body.slots[1].cpm; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses.length).to.equal(3); - }); - - it('should not include Bid if missing size', function() { - delete FIXTURE_SERVER_RESPONSE.body.slots[2].size; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses.length).to.equal(3); - }); - - it('should not include Bid if missing slot', function() { - delete FIXTURE_SERVER_RESPONSE.body.slots[3].slot; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses.length).to.equal(3); - }); - - it('should have a valid creativeId', function() { - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses.length).to.equal(4); - responses.forEach((bid) => { - expect(bid.creativeId).to.match(/[0-9a-z]{18}/); - const containerDivId = 'ybot-' + bid.creativeId; - const re = new RegExp(containerDivId); - expect(re.test(bid.ad)).to.equal(true); - }); - }); - - it('should specify Net revenue type for bid', function() { - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses[0].netRevenue).to.equal(true); - }); - - it('should specify USD currency for bid', function() { - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses[1].currency).to.equal('USD'); - }); - - it('should set edge server Url prefix', function() { - FIXTURE_SERVER_RESPONSE.body.url_prefix = 'http://close.edge.adserver.com/'; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - const edgeServerUrlPrefix = YieldbotAdapter.getCookie('__ybotc'); - - const protocol = document.location.protocol; - const beginsRegex = new RegExp('^' + protocol + '\/\/close\.edge\.adserver\.com\/'); - const containsRegex = new RegExp(protocol + '\/\/close\.edge\.adserver\.com\/'); - expect(edgeServerUrlPrefix).to.match(beginsRegex); - expect(responses[0].ad).to.match(containsRegex); - }); - - it('should not use document.open() in ad markup', function() { - FIXTURE_SERVER_RESPONSE.body.url_prefix = 'http://close.edge.adserver.com/'; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses[0].ad).to.not.match(/var innerFrameDoc=innerFrame\.contentWindow\.document;innerFrameDoc\.open\(\);innerFrameDoc\.write\(iframeHtml\);innerFrameDoc\.close\(\);/); - expect(responses[0].ad).to.match(/var innerFrameDoc=innerFrame\.contentWindow\.document;innerFrameDoc\.write\(iframeHtml\);innerFrameDoc\.close\(\);/); - }); - }); - - describe('getUserSyncs', function() { - let responses; - beforeEach(function () { - responses = [FIXTURE_SERVER_RESPONSE]; - }); - it('should return empty Array when server response property missing', function() { - delete responses[0].body.user_syncs; - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelEnabled: true }, responses); - expect(userSyncs.length).to.equal(0); - }); - - it('should return empty Array when server response property is empty', function() { - responses[0].body.user_syncs = []; - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelEnabled: true }, responses); - expect(userSyncs.length).to.equal(0); - }); - - it('should return empty Array pixel disabled', function() { - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelEnabled: false }, responses); - expect(userSyncs.length).to.equal(0); - }); - - it('should return empty Array pixel option not provided', function() { - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelNotHere: true }, responses); - expect(userSyncs.length).to.equal(0); - }); - - it('should return image type pixels', function() { - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelEnabled: true }, responses); - expect(userSyncs).to.eql( - [ - { type: 'image', url: 'https://usersync.dd9693a32aa1.com/00000000.gif?p=a' }, - { type: 'image', url: 'https://usersync.3b19503b37d8.com/00000000.gif?p=b' }, - { type: 'image', url: 'https://usersync.5cb389d36d30.com/00000000.gif?p=c' } - ] - ); - }); - }); - - describe('Adapter Auction Behavior', function() { - AdapterManager.bidderRegistry['yieldbot'] = newBidder(spec); - let sandbox, server, auctionManager; - const bidUrlRegexp = /yldbt\.com\/m\/1234\/v1\/init/; - beforeEach(function() { - sandbox = sinon.sandbox.create({ useFakeServer: true }); - server = sandbox.server; - server.respondImmediately = true; - server.respondWith( - 'GET', - bidUrlRegexp, - [ - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify(FIXTURE_SERVER_RESPONSE.body) - ] - ); - FIXTURE_SERVER_RESPONSE.user_syncs = []; - auctionManager = newAuctionManager(); - }); - - afterEach(function() { - auctionManager = null; - sandbox.restore(); - YieldbotAdapter._bidRequestCount = 0; - }); - - it('should provide auction bids', function(done) { - let bidCount = 0; - const firstAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - const bidResponseHandler = (event) => { - bidCount++; - if (bidCount === 4) { - events.off('bidResponse', bidResponseHandler); - done(); - } - }; - events.on('bidResponse', bidResponseHandler); - firstAuction.callBids(); - }); - - it('should provide multiple auctions with correct bid cpms', function(done) { - let bidCount = 0; - let firstAuctionId = ''; - let secondAuctionId = ''; - /* - * 'bidResponse' event handler checks for respective adUnit auctions and bids - */ - const bidResponseHandler = (event) => { - try { - switch (true) { - case event.adUnitCode === '/00000000/leaderboard' && event.auctionId === firstAuctionId: - expect(event.cpm, 'leaderboard, first auction cpm').to.equal(8); - break; - case event.adUnitCode === '/00000000/medrec' && event.auctionId === firstAuctionId: - expect(event.cpm, 'medrec, first auction cpm').to.equal(3); - break; - case event.adUnitCode === '/00000000/multi-size' && event.auctionId === firstAuctionId: - expect(event.cpm, 'multi-size, first auction cpm').to.equal(8); - break; - case event.adUnitCode === '/00000000/skyscraper' && event.auctionId === firstAuctionId: - expect(event.cpm, 'skyscraper, first auction cpm').to.equal(3); - break; - case event.adUnitCode === '/00000000/medrec' && event.auctionId === secondAuctionId: - expect(event.cpm, 'medrec, second auction cpm').to.equal(1.11); - break; - case event.adUnitCode === '/00000000/multi-size' && event.auctionId === secondAuctionId: - expect(event.cpm, 'multi-size, second auction cpm').to.equal(2.22); - break; - case event.adUnitCode === '/00000000/skyscraper' && event.auctionId === secondAuctionId: - expect(event.cpm, 'skyscraper, second auction cpm').to.equal(3.33); - break; - default: - done(new Error(`Bid response to assert not found: ${event.adUnitCode}:${event.size}:${event.auctionId}, [${firstAuctionId}, ${secondAuctionId}]`)); - } - bidCount++; - if (bidCount === 7) { - events.off('bidResponse', bidResponseHandler); - done(); - } - } catch (err) { - done(err); - } - }; - events.on('bidResponse', bidResponseHandler); - - /* - * First auction - */ - const firstAdUnits = FIXTURE_AD_UNITS; - const firstAdUnitCodes = FIXTURE_AD_UNITS.map(unit => unit.code); - const firstAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - firstAuctionId = firstAuction.getAuctionId(); - firstAuction.callBids(); - - /* - * Second auction with different bid values and fewer slots - */ - FIXTURE_AD_UNITS.shift(); - const FIXTURE_SERVER_RESPONSE_2 = utils.deepClone(FIXTURE_SERVER_RESPONSE); - FIXTURE_SERVER_RESPONSE_2.user_syncs = []; - FIXTURE_SERVER_RESPONSE_2.body.slots.shift(); - FIXTURE_SERVER_RESPONSE_2.body.slots.forEach((bid, idx) => { const num = idx + 1; bid.cpm = `${num}${num}${num}`; }); - const secondAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - secondAuctionId = secondAuction.getAuctionId(); - server.respondWith( - 'GET', - bidUrlRegexp, - [ - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify(FIXTURE_SERVER_RESPONSE_2.body) - ] - ); - secondAuction.callBids(); - }); - - it('should have refresh bid type after the first auction', function(done) { - const firstAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - firstAuction.callBids(); - - const secondAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - secondAuction.callBids(); - - const firstRequest = urlUtils.parse(server.firstRequest.url); - expect(firstRequest.search.bt, 'First request bid type').to.equal('init'); - - const secondRequest = urlUtils.parse(server.secondRequest.url); - expect(secondRequest.search.bt, 'Second request bid type').to.equal('refresh'); - - done(); - }); - - it('should use server response url_prefix property value after the first auction', function(done) { - const firstAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - firstAuction.callBids(); - - const secondAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - secondAuction.callBids(); - - expect(server.firstRequest.url, 'Default url prefix').to.match(/i\.yldbt\.com\/m\//); - expect(server.secondRequest.url, 'Locality url prefix').to.match(/ads-adseast-vpc\.yldbt\.com\/m\//); - - done(); - }); - - it('should increment the session page view depth only before the first auction', function(done) { - /* - * First visit: two bid requests - */ - for (let idx = 0; idx < 2; idx++) { - auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ).callBids(); - } - - const firstRequest = urlUtils.parse(server.firstRequest.url); - expect(firstRequest.search.pvd, 'First pvd').to.equal('1'); - - const secondRequest = urlUtils.parse(server.secondRequest.url); - expect(secondRequest.search.pvd, 'Second pvd').to.equal('1'); - - /* - * Next visit: two bid requests - */ - YieldbotAdapter._isInitialized = false; - YieldbotAdapter.initialize(); - for (let idx = 0; idx < 2; idx++) { - auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ).callBids(); - } - - const nextVisitFirstRequest = urlUtils.parse(server.thirdRequest.url); - expect(nextVisitFirstRequest.search.pvd, 'Second visit, first pvd').to.equal('2'); - - const nextVisitSecondRequest = urlUtils.parse(server.lastRequest.url); - expect(nextVisitSecondRequest.search.pvd, 'Second visit, second pvd').to.equal('2'); - - done(); - }); - }); - - describe('Adapter Request Timestamps', function() { - let sandbox; - beforeEach(function() { - sandbox = sinon.sandbox.create(); - sandbox.stub(Date, 'now').callsFake(() => { - return new Date(); - }); - }); - - afterEach(function() { - sandbox.restore(); - }); - - it('should have overridden Date.now() function', function() { - expect(Date.now().getTime()).to.match(/^[0-9]+/); - }); - - it('should be milliseconds past epoch query param values', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.data).to.not.equal(undefined); - - const timestampParams = [ - 'cts_ns', - 'cts_js', - 'cts_ini' - ]; - - timestampParams.forEach((item) => { - expect(!isNaN(request.data[item])).to.equal(true); - expect(request.data[item] > 0).to.equal(true); - expect(request.data[item]).to.match(/^[0-9]+/); - }); - }); - - it('should use (new Date()).getTime() for timestamps in ad markup', function() { - FIXTURE_SERVER_RESPONSE.body.url_prefix = 'http://close.edge.adserver.com/'; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - - expect(responses[0].ad).to.match(/cts_rend_.*='\+\(new Date\(\)\)\.getTime\(\)/); - expect(responses[0].ad).to.match(/cts_ad='\+\(new Date\(\)\)\.getTime\(\)/); - expect(responses[0].ad).to.match(/cts_imp='\+\(new Date\(\)\)\.getTime\(\)/); - }); - }); -}); diff --git a/test/spec/modules/yieldlabBidAdapter_spec.js b/test/spec/modules/yieldlabBidAdapter_spec.js index c8709969e00..5dcd112228a 100644 --- a/test/spec/modules/yieldlabBidAdapter_spec.js +++ b/test/spec/modules/yieldlabBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai' -import { spec } from 'modules/yieldlabBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' +import { spec } from 'modules/yieldlabBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' const REQUEST = { 'bidder': 'yieldlab', @@ -18,7 +18,14 @@ const REQUEST = { 'auctionId': '2e41f65424c87c', 'adUnitCode': 'adunit-code', 'bidId': '2d925f27f5079f', - 'sizes': [728, 90] + 'sizes': [728, 90], + 'userIdAsEids': [{ + 'source': 'netid.de', + 'uids': [{ + 'id': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', + 'atype': 1 + }] + }] } const RESPONSE = { @@ -27,9 +34,14 @@ const RESPONSE = { format: 0, id: 1111, price: 1, - pid: 2222 + pid: 2222, + adtype: 'BANNER' } +const VIDEO_RESPONSE = Object.assign({}, RESPONSE, { + 'adtype': 'VIDEO' +}) + describe('yieldlabBidAdapter', function () { const adapter = newBidder(spec) @@ -72,6 +84,10 @@ describe('yieldlabBidAdapter', function () { expect(request.url).to.include('t=key1%3Dvalue1%26key2%3Dvalue2') }) + it('passes userids to bid request', function () { + expect(request.url).to.include('ids=netid.de%3AfH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg') + }) + const gdprRequest = spec.buildRequests(bidRequests, { gdprConsent: { consentString: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA', @@ -140,7 +156,7 @@ describe('yieldlabBidAdapter', function () { } } }) - const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [VIDEO_REQUEST]}) + const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [VIDEO_REQUEST]}) expect(result[0].requestId).to.equal('2d925f27f5079f') expect(result[0].cpm).to.equal(0.01) @@ -158,7 +174,7 @@ describe('yieldlabBidAdapter', function () { } } }) - const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [OUTSTREAM_REQUEST]}) + const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [OUTSTREAM_REQUEST]}) expect(result[0].renderer.id).to.equal('2d925f27f5079f') expect(result[0].renderer.url).to.equal('https://ad2.movad.net/dynamic.ad?a=o193092&ma_loadEvent=ma-start-event') diff --git a/test/spec/modules/yieldliftBidAdapter_spec.js b/test/spec/modules/yieldliftBidAdapter_spec.js new file mode 100644 index 00000000000..640a0f4e613 --- /dev/null +++ b/test/spec/modules/yieldliftBidAdapter_spec.js @@ -0,0 +1,257 @@ +import {expect} from 'chai'; +import {spec} from 'modules/yieldliftBidAdapter.js'; + +const REQUEST = { + 'bidderCode': 'yieldlift', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708', + 'bidderRequestId': 'requestId', + 'bidRequest': [{ + 'bidder': 'yieldlift', + 'params': { + 'unitId': 123456, + }, + 'placementCode': 'div-gpt-dummy-placement-code', + 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, + 'bidId': 'bidId1', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' + }, + { + 'bidder': 'yieldlift', + 'params': { + 'unitId': 123456, + }, + 'placementCode': 'div-gpt-dummy-placement-code', + 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, + 'bidId': 'bidId2', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' + }], + 'start': 1487883186070, + 'auctionStart': 1487883186069, + 'timeout': 3000 +}; + +const RESPONSE = { + 'headers': null, + 'body': { + 'id': 'responseId', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'bidId1', + 'impid': 'bidId1', + 'price': 0.18, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'https://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 334553, + 'auction_id': 514667951122925701, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + }, + { + 'id': 'bidId2', + 'impid': 'bidId2', + 'price': 0.1, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'https://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 386046, + 'auction_id': 517067951122925501, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } + ], + 'seat': 'yieldlift' + } + ], + 'ext': { + 'usersync': { + 'sovrn': { + 'status': 'none', + 'syncs': [ + { + 'url': 'urlsovrn', + 'type': 'iframe' + } + ] + }, + 'appnexus': { + 'status': 'none', + 'syncs': [ + { + 'url': 'urlappnexus', + 'type': 'pixel' + } + ] + } + }, + 'responsetimemillis': { + 'appnexus': 127 + } + } + } +}; + +describe('YieldLift', function () { + describe('isBidRequestValid', function () { + it('should accept request if only unitId is passed', function () { + let bid = { + bidder: 'yieldlift', + params: { + unitId: 'unitId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should accept request if only networkId is passed', function () { + let bid = { + bidder: 'yieldlift', + params: { + networkId: 'networkId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should accept request if only publisherId is passed', function () { + let bid = { + bidder: 'yieldlift', + params: { + publisherId: 'publisherId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('reject requests without params', function () { + let bid = { + bidder: 'yieldlift', + params: {} + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + it('creates request data', function () { + let request = spec.buildRequests(REQUEST.bidRequest, REQUEST); + + expect(request).to.exist.and.to.be.a('object'); + const payload = JSON.parse(request.data); + expect(payload.imp[0]).to.have.property('id', REQUEST.bidRequest[0].bidId); + expect(payload.imp[1]).to.have.property('id', REQUEST.bidRequest[1].bidId); + }); + + it('has gdpr data if applicable', function () { + const req = Object.assign({}, REQUEST, { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true, + } + }); + let request = spec.buildRequests(REQUEST.bidRequest, req); + + const payload = JSON.parse(request.data); + expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString); + expect(payload.regs.ext).to.have.property('gdpr', 1); + }); + }); + + describe('interpretResponse', function () { + it('have bids', function () { + let bids = spec.interpretResponse(RESPONSE, REQUEST); + expect(bids).to.be.an('array').that.is.not.empty; + validateBidOnIndex(0); + validateBidOnIndex(1); + + function validateBidOnIndex(index) { + expect(bids[index]).to.have.property('currency', 'USD'); + expect(bids[index]).to.have.property('requestId', RESPONSE.body.seatbid[0].bid[index].impid); + expect(bids[index]).to.have.property('cpm', RESPONSE.body.seatbid[0].bid[index].price); + expect(bids[index]).to.have.property('width', RESPONSE.body.seatbid[0].bid[index].w); + expect(bids[index]).to.have.property('height', RESPONSE.body.seatbid[0].bid[index].h); + expect(bids[index]).to.have.property('ad', RESPONSE.body.seatbid[0].bid[index].adm); + expect(bids[index]).to.have.property('creativeId', RESPONSE.body.seatbid[0].bid[index].crid); + expect(bids[index]).to.have.property('ttl', 30); + expect(bids[index]).to.have.property('netRevenue', true); + } + }); + + it('handles empty response', function () { + const EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {}}); + const bids = spec.interpretResponse(EMPTY_RESP, REQUEST); + + expect(bids).to.be.empty; + }); + }); + + describe('getUserSyncs', function () { + it('handles no parameters', function () { + let opts = spec.getUserSyncs({}); + expect(opts).to.be.an('array').that.is.empty; + }); + it('returns non if sync is not allowed', function () { + let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}); + + expect(opts).to.be.an('array').that.is.empty; + }); + + it('iframe sync enabled should return results', function () { + let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [RESPONSE]); + + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('iframe'); + expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['sovrn'].syncs[0].url); + }); + + it('pixel sync enabled should return results', function () { + let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [RESPONSE]); + + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('image'); + expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['appnexus'].syncs[0].url); + }); + + it('all sync enabled should return all results', function () { + let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [RESPONSE]); + + expect(opts.length).to.equal(2); + }); + }); +}); diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index 60fe25db95e..5904113bd42 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -1,32 +1,55 @@ import { expect } from 'chai'; -import { spec } from 'modules/yieldmoBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { spec } from 'modules/yieldmoBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; describe('YieldmoAdapter', function () { const adapter = newBidder(spec); const ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; let tdid = '8d146286-91d4-4958-aff4-7e489dd1abd6'; + let criteoId = 'aff4'; let bid = { bidder: 'yieldmo', params: { - bidFloor: 0.1 + bidFloor: 0.1, }, adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', crumbs: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da' + pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da', }, userId: { tdid, - } + }, }; let bidArray = [bid]; + let bidderRequest = { + bidderCode: 'yieldmo', + auctionId: 'e3a336ad-2761-4a1c-b421-ecc7c5294a34', + bidderRequestId: '14c4ede8c693f', + bids: bidArray, + auctionStart: 1520001292880, + timeout: 3000, + start: 1520001292884, + doneCbCallCount: 0, + refererInfo: { + numIframes: 1, + reachedTop: true, + referer: 'yieldmo.com', + }, + }; describe('isBidRequestValid', function () { it('should return true when necessary information is found', function () { @@ -52,57 +75,66 @@ describe('YieldmoAdapter', function () { describe('buildRequests', function () { it('should attempt to send bid requests to the endpoint via GET', function () { - const request = spec.buildRequests(bidArray); + const request = spec.buildRequests(bidArray, bidderRequest); expect(request.method).to.equal('GET'); expect(request.url).to.be.equal(ENDPOINT); }); it('should not blow up if crumbs is undefined', function () { - let bidArray = [ - { ...bid, crumbs: undefined } - ] - expect(function () { spec.buildRequests(bidArray) }).not.to.throw() - }) + let bidArray = [{ ...bid, crumbs: undefined }]; + expect(function () { + spec.buildRequests(bidArray, bidderRequest); + }).not.to.throw(); + }); it('should place bid information into the p parameter of data', function () { - let placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]'); - + let placementInfo = spec.buildRequests(bidArray, bidderRequest).data.p; + expect(placementInfo).to.equal( + '[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]' + ); bidArray.push({ bidder: 'yieldmo', params: { - bidFloor: 0.2 + bidFloor: 0.2, }, adUnitCode: 'adunit-code-1', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, bidId: '123456789', bidderRequestId: '987654321', auctionId: '0246810', crumbs: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da' - } - + pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da', + }, }); // multiple placements - placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]],"bidFloor":0.2}]'); + placementInfo = spec.buildRequests(bidArray, bidderRequest).data.p; + expect(placementInfo).to.equal( + '[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]],"bidFloor":0.2}]' + ); }); it('should add placement id if given', function () { bidArray[0].params.placementId = 'ym_1293871298'; - let placementInfo = spec.buildRequests(bidArray).data.p; + let placementInfo = spec.buildRequests(bidArray, bidderRequest).data.p; expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"'); bidArray[1].params.placementId = 'ym_0987654321'; - placementInfo = spec.buildRequests(bidArray).data.p; + placementInfo = spec.buildRequests(bidArray, bidderRequest).data.p; expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"'); }); it('should add additional information to data parameter of request', function () { - const data = spec.buildRequests(bidArray).data; + const data = spec.buildRequests(bidArray, bidderRequest).data; expect(data.hasOwnProperty('page_url')).to.be.true; expect(data.hasOwnProperty('bust')).to.be.true; expect(data.hasOwnProperty('pr')).to.be.true; @@ -121,16 +153,25 @@ describe('YieldmoAdapter', function () { bidder: 'yieldmo', params: {}, adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', userId: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2' - } + pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2', + }, }; - const data = spec.buildRequests([pubcidBid]).data; - expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2'); + const data = spec.buildRequests([pubcidBid], bidderRequest).data; + expect(data.pubcid).to.deep.equal( + 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2' + ); }); it('should add unified id as parameter of request', function () { @@ -138,17 +179,81 @@ describe('YieldmoAdapter', function () { bidder: 'yieldmo', params: {}, adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', userId: { tdid, - } + }, }; - const data = spec.buildRequests([unifiedIdBid]).data; + const data = spec.buildRequests([unifiedIdBid], bidderRequest).data; expect(data.tdid).to.deep.equal(tdid); }); + + it('should add CRITEO RTUS id as parameter of request', function () { + const criteoIdBid = { + bidder: 'yieldmo', + params: {}, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: { + criteoId, + }, + }; + const data = spec.buildRequests([criteoIdBid], bidderRequest).data; + expect(data.cri_prebid).to.deep.equal(criteoId); + }); + + it('should add gdpr information to request if available', () => { + bidderRequest.gdprConsent = { + consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + vendorData: { blerp: 1 }, + gdprApplies: true, + }; + const data = spec.buildRequests(bidArray, bidderRequest).data; + expect(data.userConsent).equal( + JSON.stringify({ + gdprApplies: true, + cmp: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + }) + ); + }); + + it('should add ccpa information to request if available', () => { + const privacy = '1YNY'; + bidderRequest.us_privacy = privacy; + const data = spec.buildRequests(bidArray, bidderRequest).data; + expect(data.us_privacy).equal(privacy); + }); + + it('should add schain if it is in the bidRequest', () => { + const schain = { + ver: '1.0', + complete: 1, + nodes: [{ asi: 'indirectseller.com', sid: '00001', hp: 1 }], + }; + bidArray[0].schain = schain; + const request = spec.buildRequests([bidArray[0]], bidderRequest); + expect(request.data.schain).equal(JSON.stringify(schain)); + }); }); describe('interpretResponse', function () { @@ -156,17 +261,20 @@ describe('YieldmoAdapter', function () { beforeEach(function () { serverResponse = { - body: [{ - callback_id: '21989fdbef550a', - cpm: 3.45455, - width: 300, - height: 250, - ad: '
', - creative_id: '9874652394875' - }], - header: 'header?' + body: [ + { + callback_id: '21989fdbef550a', + cpm: 3.45455, + width: 300, + height: 250, + ad: + '
', + creative_id: '9874652394875', + }, + ], + header: 'header?', }; - }) + }); it('should correctly reorder the server response', function () { const newResponse = spec.interpretResponse(serverResponse); @@ -180,7 +288,8 @@ describe('YieldmoAdapter', function () { currency: 'USD', netRevenue: true, ttl: 300, - ad: '
' + ad: + '
', }); }); @@ -191,7 +300,7 @@ describe('YieldmoAdapter', function () { serverResponse.body[0].cpm = null; response = spec.interpretResponse(serverResponse); - expect(response).to.deep.equal([]) + expect(response).to.deep.equal([]); }); }); @@ -199,15 +308,17 @@ describe('YieldmoAdapter', function () { const SYNC_ENDPOINT = 'https://static.yieldmo.com/blank.min.html?orig='; let options = { iframeEnabled: true, - pixelEnabled: true + pixelEnabled: true, }; it('should return a tracker with type and url as parameters', function () { if (/iPhone|iPad|iPod/i.test(window.navigator.userAgent)) { - expect(spec.getUserSync(options)).to.deep.equal([{ - type: 'iframe', - url: SYNC_ENDPOINT + utils.getOrigin() - }]); + expect(spec.getUserSync(options)).to.deep.equal([ + { + type: 'iframe', + url: SYNC_ENDPOINT + utils.getOrigin(), + }, + ]); options.iframeEnabled = false; expect(spec.getUserSync(options)).to.deep.equal([]); diff --git a/test/spec/modules/yieldnexusBidAdapter_spec.js b/test/spec/modules/yieldnexusBidAdapter_spec.js deleted file mode 100644 index 8f2e40d1810..00000000000 --- a/test/spec/modules/yieldnexusBidAdapter_spec.js +++ /dev/null @@ -1,418 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/yieldnexusBidAdapter'; -import * as utils from 'src/utils'; - -const spid = '123'; - -describe('YieldNexusAdapter', () => { - describe('isBidRequestValid', () => { - it('should validate supply', () => { - expect(spec.isBidRequestValid({params: {}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: 123}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123'}})).to.equal(true); - }); - it('should validate bid floor', () => { - expect(spec.isBidRequestValid({params: {spid: '123'}})).to.equal(true); // bidfloor has a default - expect(spec.isBidRequestValid({params: {spid: '123', bidfloor: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123', bidfloor: 0.1}})).to.equal(true); - }); - it('should validate adpos', () => { - expect(spec.isBidRequestValid({params: {spid: '123'}})).to.equal(true); // adpos has a default - expect(spec.isBidRequestValid({params: {spid: '123', adpos: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123', adpos: 0.1}})).to.equal(true); - }); - it('should validate instl', () => { - expect(spec.isBidRequestValid({params: {spid: '123'}})).to.equal(true); // adpos has a default - expect(spec.isBidRequestValid({params: {spid: '123', instl: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123', instl: -1}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123', instl: 0}})).to.equal(true); - expect(spec.isBidRequestValid({params: {spid: '123', instl: 1}})).to.equal(true); - expect(spec.isBidRequestValid({params: {spid: '123', instl: 2}})).to.equal(false); - }); - }); - describe('buildRequests', () => { - const bidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': 'fdkhjg3s7ahjja', - 'mediaTypes': { - banner: {} - }, - 'params': {spid}, - 'sizes': [[300, 250], [300, 600]] - }; - - it('returns an array', () => { - let response; - - response = spec.buildRequests([]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - - response = spec.buildRequests([bidRequest]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - - const adUnit1 = Object.assign({}, utils.deepClone(bidRequest), {auctionId: '1', adUnitCode: 'a'}); - const adUnit2 = Object.assign({}, utils.deepClone(bidRequest), {auctionId: '1', adUnitCode: 'b'}); - response = spec.buildRequests([adUnit1, adUnit2]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(2); - }); - - it('uses yieldnexus dns', () => { - const response = spec.buildRequests([bidRequest])[0]; - expect(response.method).to.equal('POST'); - expect(response.url).to.match(new RegExp(`^https://ssp\\.ynxs\\.io/r/${spid}/bidr\\?bidder=prebid&rformat=open_rtb&reqformat=rtb_json$`, 'g')); - expect(response.data.id).to.equal(bidRequest.auctionId); - }); - - it('builds request correctly', () => { - let stub = sinon.stub(utils, 'getTopWindowUrl').returns('http://www.test.com/page.html'); - - let response; - response = spec.buildRequests([bidRequest])[0]; - expect(response.data.site.domain).to.equal('www.test.com'); - expect(response.data.site.page).to.equal('http://www.test.com/page.html'); - expect(response.data.site.ref).to.equal(''); - expect(response.data.imp.length).to.equal(1); - expect(response.data.imp[0].id).to.equal(bidRequest.transactionId); - expect(response.data.imp[0].instl).to.equal(0); - expect(response.data.imp[0].tagid).to.equal(bidRequest.adUnitCode); - expect(response.data.imp[0].bidfloor).to.equal(0); - expect(response.data.imp[0].bidfloorcur).to.equal('USD'); - - const bidRequestWithInstlEquals1 = utils.deepClone(bidRequest); - bidRequestWithInstlEquals1.params.instl = 1; - response = spec.buildRequests([bidRequestWithInstlEquals1])[0]; - expect(response.data.imp[0].instl).to.equal(bidRequestWithInstlEquals1.params.instl); - - const bidRequestWithInstlEquals0 = utils.deepClone(bidRequest); - bidRequestWithInstlEquals0.params.instl = 1; - response = spec.buildRequests([bidRequestWithInstlEquals0])[0]; - expect(response.data.imp[0].instl).to.equal(bidRequestWithInstlEquals0.params.instl); - - const bidRequestWithBidfloorEquals1 = utils.deepClone(bidRequest); - bidRequestWithBidfloorEquals1.params.bidfloor = 1; - response = spec.buildRequests([bidRequestWithBidfloorEquals1])[0]; - expect(response.data.imp[0].bidfloor).to.equal(bidRequestWithBidfloorEquals1.params.bidfloor); - - stub.restore(); - }); - - it('builds request banner object correctly', () => { - let response; - - const bidRequestWithBanner = utils.deepClone(bidRequest); - bidRequestWithBanner.mediaTypes = { - banner: { - sizes: [[300, 250], [120, 600]] - } - }; - - response = spec.buildRequests([bidRequestWithBanner])[0]; - expect(response.data.imp[0].banner.w).to.equal(bidRequestWithBanner.mediaTypes.banner.sizes[0][0]); - expect(response.data.imp[0].banner.h).to.equal(bidRequestWithBanner.mediaTypes.banner.sizes[0][1]); - expect(response.data.imp[0].banner.pos).to.equal(0); - expect(response.data.imp[0].banner.topframe).to.equal(0); - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithBanner); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1])[0]; - expect(response.data.imp[0].banner.pos).to.equal(bidRequestWithPosEquals1.params.pos); - }); - - it('builds request video object correctly', () => { - let response; - - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - sizes: [[300, 250], [120, 600]] - } - }; - - response = spec.buildRequests([bidRequestWithVideo])[0]; - expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.sizes[0][0]); - expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.sizes[0][1]); - expect(response.data.imp[0].video.pos).to.equal(0); - expect(response.data.imp[0].video.topframe).to.equal(0); - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1])[0]; - expect(response.data.imp[0].video.pos).to.equal(bidRequestWithPosEquals1.params.pos); - }); - - it('builds request video object correctly with multi-dimensions size array', function () { - let bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [[304, 254], [305, 255]], - context: 'instream' - }; - - let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.w).to.equal(304); - expect(response.data.imp[0].video.h).to.equal(254); - - bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [304, 254] - }; - - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.w).to.equal(304); - expect(response.data.imp[0].video.h).to.equal(254); - }); - }); - describe('interpretResponse', () => { - const bannerBidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': 'fdkhjg3s7ahjja', - 'mediaTypes': { - banner: {} - }, - 'params': { - 'spid': spid - }, - 'sizes': [[300, 250], [300, 600]], - 'bidId': '111' - }; - const videoBidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': 'fdkhjg3s7ahjja', - 'mediaTypes': { - video: {} - }, - 'params': { - 'spid': spid - }, - 'sizes': [[300, 250], [300, 600]], - 'bidId': '111' - }; - const rtbResponse = { - 'id': 'imp_5b05b9fde4b09084267a556f', - 'bidid': 'imp_5b05b9fde4b09084267a556f', - 'cur': 'USD', - 'ext': { - 'utrk': [ - {'type': 'iframe', 'url': '//ssp.ynxs.io/user/sync/1'}, - {'type': 'image', 'url': '//ssp.ynxs.io/user/sync/2'} - ] - }, - 'seatbid': [ - { - 'seat': 'testSeatBidA', - 'bid': [ - { - 'id': '0', - 'impid': '1', - 'price': 2.016, - 'adm': '', - 'adomain': ['nike.com'], - 'h': 600, - 'w': 120, - 'ext': { - 'vast_url': 'http://vast.tag.com', - 'utrk': [ - {'type': 'iframe', 'url': '//pix.usersync.io/user-sync'} - ] - } - } - ] - }, - { - 'seat': 'testSeatBidB', - 'bid': [ - { - 'id': '1', - 'impid': '1', - 'price': 3, - 'adid': '542jlhdfd2112jnjf3x', - 'adm': '', - 'adomain': ['adidas.com'], - 'h': 250, - 'w': 300, - 'ext': { - 'utrk': [ - {'type': 'image', 'url': '//pix.usersync.io/user-sync'} - ] - } - } - ] - } - ] - }; - it('fails gracefully on empty response body', () => { - let response; - - response = spec.interpretResponse(undefined, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - - response = spec.interpretResponse({}, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - }); - it('collects banner bids', () => { - const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - - const ad0 = response[0]; - expect(ad0.requestId).to.equal(bannerBidRequest.bidId); - expect(ad0.cpm).to.equal(rtbResponse.seatbid[1].bid[0].price); - expect(ad0.width).to.equal(rtbResponse.seatbid[1].bid[0].w); - expect(ad0.height).to.equal(rtbResponse.seatbid[1].bid[0].h); - expect(ad0.ttl).to.equal(15 * 60); - expect(ad0.creativeId).to.equal(rtbResponse.seatbid[1].bid[0].crid); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal(rtbResponse.seatbid[1].bid[0].cur || rtbResponse.cur || 'USD'); - expect(ad0.ad).to.equal(rtbResponse.seatbid[1].bid[0].adm); - expect(ad0.vastXml).to.be.an('undefined'); - expect(ad0.vastUrl).to.be.an('undefined'); - }); - it('collects video bids', () => { - const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: videoBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - - const ad0 = response[0]; - expect(ad0.requestId).to.equal(videoBidRequest.bidId); - expect(ad0.cpm).to.equal(rtbResponse.seatbid[0].bid[0].price); - expect(ad0.width).to.equal(rtbResponse.seatbid[0].bid[0].w); - expect(ad0.height).to.equal(rtbResponse.seatbid[0].bid[0].h); - expect(ad0.ttl).to.equal(15 * 60); - expect(ad0.creativeId).to.equal(rtbResponse.seatbid[0].bid[0].crid); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal(rtbResponse.seatbid[0].bid[0].cur || rtbResponse.cur || 'USD'); - expect(ad0.ad).to.be.an('undefined'); - expect(ad0.vastXml).to.equal(rtbResponse.seatbid[0].bid[0].adm); - expect(ad0.vastUrl).to.equal(rtbResponse.seatbid[0].bid[0].ext.vast_url); - }); - - it('applies user-syncs', () => { - const response = spec.getUserSyncs({}, [{body: rtbResponse}]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(4); - expect(response[0].type).to.equal(rtbResponse.ext.utrk[0].type); - expect(response[0].url).to.equal(rtbResponse.ext.utrk[0].url + '?gc=missing'); - expect(response[1].type).to.equal(rtbResponse.ext.utrk[1].type); - expect(response[1].url).to.equal(rtbResponse.ext.utrk[1].url + '?gc=missing'); - expect(response[2].type).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].type); - expect(response[2].url).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].url + '?gc=missing'); - expect(response[3].type).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].type); - expect(response[3].url).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].url + '?gc=missing'); - }); - - it('supports outstream renderers', function () { - const videoResponse = { - 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', - 'bidid': 'imp_5c24924de4b0d106447af333', - 'cur': 'USD', - 'seatbid': [ - { - 'seat': '3668', - 'group': 0, - 'bid': [ - { - 'id': 'gb_1', - 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - 'price': 5.0, - 'adid': '1274', - 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - 'adomain': [], - 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - 'cid': '3668', - 'crid': '1274', - 'cat': [], - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - 'imptrackers': [ - 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] - } - } - ] - } - ], - 'ext': { - 'utrk': [{ - 'type': 'image', - 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675' - }] - } - }; - const videoRequest = utils.deepClone(videoBidRequest); - videoRequest.mediaTypes.video.context = 'outstream'; - const result = spec.interpretResponse({body: videoResponse}, {bidRequest: videoRequest}); - expect(result[0].renderer).to.not.equal(undefined); - }); - - it('supports gdpr consent', function () { - let videoResponse = { - 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', - 'bidid': 'imp_5c24924de4b0d106447af333', - 'cur': 'USD', - 'seatbid': [ - { - 'seat': '3668', - 'group': 0, - 'bid': [ - { - 'id': 'gb_1', - 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - 'price': 5.0, - 'adid': '1274', - 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - 'adomain': [], - 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - 'cid': '3668', - 'crid': '1274', - 'cat': [], - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - 'imptrackers': [ - 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] - } - } - ] - } - ], - 'ext': { - 'utrk': [{ - 'type': 'image', - 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675' - }] - } - }; - let gdprConsent = { - gdprApplies: true, - consentString: 'consent string' - }; - let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gc=consent%20string'); - - gdprConsent.gdprApplies = false; - result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gc=missing'); - - videoResponse.ext.utrk[0].url = 'https://rtb.gamoshi.io/pix/1275/scm'; - result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?gc=missing'); - }); - }); -}); diff --git a/test/spec/modules/yieldoneAnalyticsAdapter_spec.js b/test/spec/modules/yieldoneAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..bc1001cc6c1 --- /dev/null +++ b/test/spec/modules/yieldoneAnalyticsAdapter_spec.js @@ -0,0 +1,288 @@ +import yieldoneAnalytics from 'modules/yieldoneAnalyticsAdapter.js'; +import { targeting } from 'src/targeting.js'; +import { expect } from 'chai'; +let events = require('src/events'); +let adapterManager = require('src/adapterManager').default; +let constants = require('src/constants.json'); + +describe('Yieldone Prebid Analytic', function () { + let sendStatStub; + let getAllTargetingStub; + const fakeTargeting = { + '0000': {'someId': 'someValue'} + }; + + describe('enableAnalytics', function () { + beforeEach(function () { + sendStatStub = sinon.stub(yieldoneAnalytics, 'sendStat'); + getAllTargetingStub = sinon.stub(targeting, 'getAllTargeting').returns(fakeTargeting); + sinon.stub(events, 'getEvents').returns([]); + }); + + afterEach(function () { + sendStatStub.restore(); + getAllTargetingStub.restore(); + events.getEvents.restore(); + }); + + after(function () { + yieldoneAnalytics.disableAnalytics(); + }); + + it('should catch all events', function (done) { + adapterManager.registerAnalyticsAdapter({ + code: 'yieldone', + adapter: yieldoneAnalytics + }); + + const initOptions = { + pubId: '123456' + }; + + const auctionId = 'test-test-test'; + const testReferrer = 'http://test'; + + const request = [ + { + bidderCode: 'biddertest_1', + auctionId: auctionId, + refererInfo: {referer: testReferrer}, + bids: [ + { + adUnitCode: '0000', + auctionId: auctionId, + bidId: '1234', + bidder: 'biddertest_1', + mediaTypes: {banner: {sizes: [[300, 250], [336, 280]]}}, + params: {param1: '111', param2: '222'}, + sizes: [[300, 250], [336, 280]] + }, + { + adUnitCode: '0000', + auctionId: auctionId, + bidId: '5678', + bidder: 'biddertest_1', + mediaTypes: {banner: {sizes: [[300, 250], [336, 280]]}}, + params: {param1: '222', param2: '222'}, + sizes: [[300, 250], [336, 280]] + } + ] + }, + { + bidderCode: 'biddertest_2', + auctionId: auctionId, + refererInfo: {referer: testReferrer}, + bids: [ + { + adUnitCode: '0000', + auctionId: auctionId, + bidId: '91011', + bidder: 'biddertest_2', + mediaTypes: {banner: {sizes: [[300, 250], [336, 280]]}}, + params: {paramA: '111', paramB: '222'}, + sizes: [[300, 250], [336, 280]] + } + ] + }, + { + bidderCode: 'biddertest_3', + auctionId: auctionId, + refererInfo: {referer: testReferrer}, + bids: [ + { + adUnitCode: '0000', + auctionId: auctionId, + bidId: '12131', + bidder: 'biddertest_3', + mediaTypes: {banner: {sizes: [[300, 250], [336, 280]]}}, + params: {param_1: '111', param_2: '222'}, + sizes: [[300, 250], [336, 280]] + }, + { + adUnitCode: '0000', + auctionId: auctionId, + bidId: '14151', + bidder: 'biddertest_3', + mediaTypes: {banner: {sizes: [[300, 250], [336, 280]]}}, + params: {param_1: '333', param_2: '222'}, + sizes: [[300, 250], [336, 280]] + } + ] + } + ]; + + const responses = [ + { + ad: 'test ad content 1', + width: 300, + height: 250, + statusMessage: 'Bid available', + bidId: '1234', + auctionId: auctionId, + cpm: 0.1, + bidder: 'biddertest_1', + adUnitCode: '0000', + timeToRespond: 100 + }, + { + ad: 'test ad content 2', + width: 336, + height: 280, + statusMessage: 'Bid available', + bidId: '5678', + auctionId: auctionId, + cpm: 0.2, + bidder: 'biddertest_1', + adUnitCode: '0000', + timeToRespond: 100 + }, + { + ad: 'test ad content 3', + width: 300, + height: 250, + statusMessage: 'Bid available', + bidId: '91011', + auctionId: auctionId, + cpm: 0.3, + bidder: 'biddertest_2', + adUnitCode: '0000', + timeToRespond: 100 + }, + { + bidId: '12131', + auctionId: auctionId, + bidder: 'biddertest_3' + }, + { + bidId: '14151', + auctionId: auctionId, + bidder: 'biddertest_3' + } + ]; + + const winner = { + ad: 'test ad content 3', + width: 300, + height: 250, + statusMessage: 'Bid available', + bidId: '91011', + auctionId: auctionId, + cpm: 0.3, + bidder: 'biddertest_2', + adUnitCode: '0000', + timeToRespond: 100 + }; + + const auctionEnd = { + auctionId: auctionId, + bidsReceived: responses.slice(0, 3) + }; + + const preparedResponses = responses.map((resp) => { + const res = Object.assign({}, resp); + delete res.ad; + return res; + }); + + const expectedEvents = [ + { + eventType: constants.EVENTS.AUCTION_INIT, + params: { + config: initOptions, + auctionId: auctionId + } + }, + { + eventType: constants.EVENTS.BID_REQUESTED, + params: Object.assign(request[0]) + }, + { + eventType: constants.EVENTS.BID_REQUESTED, + params: Object.assign(request[1]) + }, + { + eventType: constants.EVENTS.BID_REQUESTED, + params: Object.assign(request[2]) + }, + { + eventType: constants.EVENTS.BID_RESPONSE, + params: Object.assign(preparedResponses[0]) + }, + { + eventType: constants.EVENTS.BID_RESPONSE, + params: Object.assign(preparedResponses[1]) + }, + { + eventType: constants.EVENTS.BID_RESPONSE, + params: Object.assign(preparedResponses[2]) + }, + { + eventType: constants.EVENTS.BID_TIMEOUT, + params: Object.assign(request[2]) + }, + { + eventType: constants.EVENTS.AUCTION_END, + params: { + auctionId: auctionId, + adServerTargeting: fakeTargeting, + bidsReceived: preparedResponses.slice(0, 3) + } + } + ]; + const expectedResult = { + pubId: initOptions.pubId, + page: {url: testReferrer}, + wrapper_version: '$prebid.version$', + events: expectedEvents + }; + + const preparedWinnerParams = Object.assign({adServerTargeting: fakeTargeting}, winner); + delete preparedWinnerParams.ad; + const wonExpectedEvents = [ + { + eventType: constants.EVENTS.BID_WON, + params: preparedWinnerParams + } + ]; + const wonExpectedResult = { + pubId: initOptions.pubId, + page: {url: testReferrer}, + wrapper_version: '$prebid.version$', + events: wonExpectedEvents + }; + + adapterManager.enableAnalytics({ + provider: 'yieldone', + options: initOptions + }); + + events.emit(constants.EVENTS.AUCTION_INIT, {config: initOptions, auctionId: auctionId}); + + events.emit(constants.EVENTS.BID_REQUESTED, request[0]); + events.emit(constants.EVENTS.BID_REQUESTED, request[1]); + events.emit(constants.EVENTS.BID_REQUESTED, request[2]); + + events.emit(constants.EVENTS.BID_RESPONSE, responses[0]); + events.emit(constants.EVENTS.BID_RESPONSE, responses[1]); + events.emit(constants.EVENTS.BID_RESPONSE, responses[2]); + + events.emit(constants.EVENTS.BID_TIMEOUT, [responses[3], responses[4]]); + + events.emit(constants.EVENTS.AUCTION_END, auctionEnd); + + expect(yieldoneAnalytics.eventsStorage[auctionId]).to.deep.equal(expectedResult); + + delete yieldoneAnalytics.eventsStorage[auctionId]; + + setTimeout(function() { + events.emit(constants.EVENTS.BID_WON, winner); + + sinon.assert.callCount(sendStatStub, 2); + expect(yieldoneAnalytics.eventsStorage[auctionId]).to.deep.equal(wonExpectedResult); + + delete yieldoneAnalytics.eventsStorage[auctionId]; + done(); + }, 1000); + }); + }); +}); diff --git a/test/spec/modules/yieldoneBidAdapter_spec.js b/test/spec/modules/yieldoneBidAdapter_spec.js index abc579514ef..84065682297 100644 --- a/test/spec/modules/yieldoneBidAdapter_spec.js +++ b/test/spec/modules/yieldoneBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/yieldoneBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/yieldoneBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const ENDPOINT = 'https://y.one.impact-ad.jp/h_bid'; const USER_SYNC_URL = 'https://y.one.impact-ad.jp/push_sync'; @@ -64,7 +64,16 @@ describe('yieldoneBidAdapter', function() { } ]; - const request = spec.buildRequests(bidRequests); + let bidderRequest = { + refererInfo: { + numIframes: 0, + reachedTop: true, + referer: 'http://example.com', + stack: ['http://example.com'] + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); it('sends bid request to our endpoint via GET', function () { expect(request[0].method).to.equal('GET'); @@ -85,7 +94,7 @@ describe('yieldoneBidAdapter', function() { const bidRequest = Object.assign({}, bidRequests[0]); bidRequest.mediaTypes = {}; bidRequest.mediaTypes.video = {context: 'outstream'}; - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], bidderRequest); expect(request[0].data.w).to.equal('300'); expect(request[0].data.h).to.equal('250'); }); diff --git a/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js b/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js index f6efa077f35..24a524c85c7 100644 --- a/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js +++ b/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js @@ -1,22 +1,18 @@ -import yuktamediaAnalyticsAdapter from 'modules/yuktamediaAnalyticsAdapter'; +import yuktamediaAnalyticsAdapter from 'modules/yuktamediaAnalyticsAdapter.js'; import { expect } from 'chai'; -let adapterManager = require('src/adapterManager').default; +import adapterManager from 'src/adapterManager.js'; +import * as utils from 'src/utils.js'; +import { server } from 'test/mocks/xhr.js'; + let events = require('src/events'); let constants = require('src/constants.json'); -describe('YuktaMedia analytics adapter', function () { - let xhr; - let requests; - +describe('yuktamedia analytics adapter', function () { beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); sinon.stub(events, 'getEvents').returns([]); }); afterEach(function () { - xhr.restore(); events.getEvents.restore(); }); @@ -26,152 +22,767 @@ describe('YuktaMedia analytics adapter', function () { pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==' }; - adapterManager.registerAnalyticsAdapter({ - code: 'yuktamedia', - adapter: yuktamediaAnalyticsAdapter - }); - - beforeEach(function () { - adapterManager.enableAnalytics({ - provider: 'yuktamedia', - options: initOptions - }); - }); - - afterEach(function () { - yuktamediaAnalyticsAdapter.disableAnalytics(); - }); - - it('builds and sends auction data', function () { - let auctionTimestamp = 1496510254313; - let bidRequest = { + let prebidEvent = { + 'addAdUnits': {}, + 'requestBids': {}, + 'auctionInit': { + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'timestamp': 1576823893836, + 'auctionStatus': 'inProgress', + 'adUnits': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + } + } + ], + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98' + } + ], + 'adUnitCodes': [ + 'div-gpt-ad-1460505748561-0' + ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + } + ], + 'noBids': [], + 'bidsReceived': [], + 'winningBids': [], + 'timeout': 1000 + }, + 'bidRequested': { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + }, + 'bidAdjustment': { + 'bidderCode': 'appnexus', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '393976d8770041', + 'requestId': '263efc09896d0c', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 0.5, + 'creativeId': 96846035, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'ad': '', + 'originalCpm': 0.5, + 'originalCurrency': 'USD', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'responseTimestamp': 1576823894050, + 'requestTimestamp': 1576823893838, + 'bidder': 'appnexus', + 'timeToRespond': 212 + }, + 'bidTimeout': [ + ], + 'bidResponse': { 'bidderCode': 'appnexus', - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', - 'bidderRequestId': '173209942f8bdd', - 'bids': [{ - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394' - }, - 'crumbs': { - 'pubcid': '9a2a4e71-f39b-405f-aecc-19efc22b618d' - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'transactionId': '2f481ff1-8d20-4c28-8e36-e384e9e3eec6', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '2eddfdc0c791dc', - 'bidderRequestId': '173209942f8bdd', - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7' + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '393976d8770041', + 'requestId': '263efc09896d0c', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 0.5, + 'creativeId': 96846035, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'ad': '', + 'originalCpm': 0.5, + 'originalCurrency': 'USD', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'responseTimestamp': 1576823894050, + 'requestTimestamp': 1576823893838, + 'bidder': 'appnexus', + 'timeToRespond': 212, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'pbDg': '0.50', + 'pbCg': '', + 'size': '300x250', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '393976d8770041', + 'hb_pb': '0.50', + 'hb_size': '300x250', + 'hb_source': 'client', + 'hb_format': 'banner' + } + }, + 'auctionEnd': { + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'timestamp': 1576823893836, + 'auctionEnd': 1576823894054, + 'auctionStatus': 'completed', + 'adUnits': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + } + } + ], + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98' + } + ], + 'adUnitCodes': [ + 'div-gpt-ad-1460505748561-0' + ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + } + ], + 'noBids': [], + 'bidsReceived': [ + { + 'bidderCode': 'appnexus', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '393976d8770041', + 'requestId': '263efc09896d0c', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 0.5, + 'creativeId': 96846035, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'ad': '', + 'originalCpm': 0.5, + 'originalCurrency': 'USD', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'responseTimestamp': 1576823894050, + 'requestTimestamp': 1576823893838, + 'bidder': 'appnexus', + 'timeToRespond': 212, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'pbDg': '0.50', + 'pbCg': '', + 'size': '300x250', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '393976d8770041', + 'hb_pb': '0.50', + 'hb_size': '300x250', + 'hb_source': 'client', + 'hb_format': 'banner' + } + } + ], + 'winningBids': [], + 'timeout': 1000 + }, + 'setTargeting': { + 'div-gpt-ad-1460505748561-0': { + 'hb_format': 'banner', + 'hb_source': 'client', + 'hb_size': '300x250', + 'hb_pb': '0.50', + 'hb_adid': '393976d8770041', + 'hb_bidder': 'appnexus', + 'hb_format_appnexus': 'banner', + 'hb_source_appnexus': 'client', + 'hb_size_appnexus': '300x250', + 'hb_pb_appnexus': '0.50', + 'hb_adid_appnexus': '393976d8770041', + 'hb_bidder_appnexus': 'appnexus' } + }, + 'bidderDone': { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } ], - 'auctionStart': 1522265863591, - 'timeout': 3000, - 'start': 1522265863600, - 'doneCbCallCount': 1 - }; - let bidResponse = { + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + }, + 'bidWon': { + 'bidderCode': 'appnexus', + 'width': 300, 'height': 250, 'statusMessage': 'Bid available', - 'adId': '2eddfdc0c791dc', + 'adId': '393976d8770041', + 'requestId': '263efc09896d0c', 'mediaType': 'banner', 'source': 'client', - 'requestId': '2eddfdc0c791dc', 'cpm': 0.5, - 'creativeId': 29681110, + 'creativeId': 96846035, 'currency': 'USD', 'netRevenue': true, 'ttl': 300, - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', - 'responseTimestamp': 1522265866110, - 'requestTimestamp': 1522265863600, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'ad': '', + 'originalCpm': 0.5, + 'originalCurrency': 'USD', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'responseTimestamp': 1576823894050, + 'requestTimestamp': 1576823893838, 'bidder': 'appnexus', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'timeToRespond': 2510, - 'size': '300x250' - }; - let bidTimeoutArgsV1 = [ - { - bidId: '2baa51527bd015', - bidder: 'bidderOne', - adUnitCode: '/19968336/header-bid-tag-0', - auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' + 'timeToRespond': 212, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'pbDg': '0.50', + 'pbCg': '', + 'size': '300x250', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '393976d8770041', + 'hb_pb': '0.50', + 'hb_size': '300x250', + 'hb_source': 'client', + 'hb_format': 'banner' }, + 'status': 'rendered', + 'params': [ + { + 'placementId': 13144370 + } + ] + } + }; + let location = utils.getWindowLocation(); + + let expectedAfterBid = { + 'bids': [ { - bidId: '6fe3b4c2c23092', - bidder: 'bidderTwo', - adUnitCode: '/19968336/header-bid-tag-0', - auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidId': '263efc09896d0c', + 'bidderCode': 'appnexus', + 'cpm': 0.5, + 'creativeId': 96846035, + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': true, + 'renderStatus': 2, + 'requestId': '155975c76e13b1', + 'requestTimestamp': 1576823893838, + 'responseTimestamp': 1576823894050, + 'sizes': '300x250,300x600', + 'statusMessage': 'Bid available', + 'timeToRespond': 212 } - ]; - let bid = { + ], + 'auctionInit': { + 'host': location.host, + 'path': location.pathname, + 'search': location.search, + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'timestamp': 1576823893836, + 'auctionStatus': 'inProgress', + 'adUnits': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + } + } + ], + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98' + } + ], + 'adUnitCodes': [ + 'div-gpt-ad-1460505748561-0' + ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + } + ], + 'noBids': [], + 'bidsReceived': [], + 'winningBids': [], + 'timeout': 1000, + 'config': initOptions + }, + 'initOptions': initOptions + }; + + let expectedAfterBidWon = { + 'bidWon': { 'bidderCode': 'appnexus', - 'bidId': '2eddfdc0c791dc', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'requestId': '173209942f8bdd', - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', - 'renderStatus': 2, - 'cpm': 0.5, - 'creativeId': 29681110, + 'bidId': '263efc09896d0c', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'creativeId': 96846035, 'currency': 'USD', - 'mediaType': 'banner', + 'cpm': 0.5, 'netRevenue': true, - 'requestTimestamp': 1522265863600, - 'responseTimestamp': 1522265866110, - 'sizes': '300x250,300x600', + 'renderedSize': '300x250', + 'mediaType': 'banner', 'statusMessage': 'Bid available', - 'timeToRespond': 2510 + 'status': 'rendered', + 'renderStatus': 4, + 'timeToRespond': 212, + 'requestTimestamp': 1576823893838, + 'responseTimestamp': 1576823894050 + }, + 'initOptions': { + 'pubId': '1', + 'pubKey': 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==' } + } - // Step 1: Send auction init event - events.emit(constants.EVENTS.AUCTION_INIT, { - timestamp: auctionTimestamp + adapterManager.registerAnalyticsAdapter({ + code: 'yuktamedia', + adapter: yuktamediaAnalyticsAdapter + }); + + beforeEach(function () { + adapterManager.enableAnalytics({ + provider: 'yuktamedia', + options: initOptions }); + }); + + afterEach(function () { + yuktamediaAnalyticsAdapter.disableAnalytics(); + }); + + it('builds and sends auction data', function () { + // Step 1: Send auction init event + events.emit(constants.EVENTS.AUCTION_INIT, prebidEvent['auctionInit']); // Step 2: Send bid requested event - events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); + events.emit(constants.EVENTS.BID_REQUESTED, prebidEvent['bidRequested']); // Step 3: Send bid response event - events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); + events.emit(constants.EVENTS.BID_RESPONSE, prebidEvent['bidResponse']); // Step 4: Send bid time out event - events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeoutArgsV1); + events.emit(constants.EVENTS.BID_TIMEOUT, prebidEvent['bidTimeout']); // Step 5: Send auction end event - events.emit(constants.EVENTS.AUCTION_END, {}, 'auctionEnd'); - - expect(requests.length).to.equal(1); + events.emit(constants.EVENTS.AUCTION_END, prebidEvent['auctionEnd']); - let auctionEventData = JSON.parse(requests[0].requestBody); + expect(server.requests.length).to.equal(1); - expect(auctionEventData.bids.length).to.equal(1); - expect(auctionEventData.bids[0]).to.deep.equal(bid); + let realAfterBid = JSON.parse(server.requests[0].requestBody); - expect(auctionEventData.initOptions).to.deep.equal(initOptions); + expect(realAfterBid).to.deep.equal(expectedAfterBid); // Step 6: Send auction bid won event - events.emit(constants.EVENTS.BID_WON, { - 'bidderCode': 'appnexus', - 'statusMessage': 'Bid available', - 'adId': '108abedd106b669', - 'auctionId': '6355d610-7cdc-4009-a866-f91997fd24bb', - 'responseTimestamp': 1522144433058, - 'requestTimestamp': 1522144432923, - 'bidder': 'appnexus', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'timeToRespond': 135, - 'size': '300x250', - 'status': 'rendered' - }, 'won'); + events.emit(constants.EVENTS.BID_WON, prebidEvent['bidWon']); - expect(requests.length).to.equal(2); + expect(server.requests.length).to.equal(2); - let winEventData = JSON.parse(requests[1].requestBody); + let winEventData = JSON.parse(server.requests[1].requestBody); - expect(winEventData.bidWon.status).to.equal('rendered'); - expect(winEventData.initOptions).to.deep.equal(initOptions); + expect(winEventData).to.deep.equal(expectedAfterBidWon); }); }); }); diff --git a/test/spec/modules/zedoBidAdapter_spec.js b/test/spec/modules/zedoBidAdapter_spec.js deleted file mode 100644 index 76301ba9018..00000000000 --- a/test/spec/modules/zedoBidAdapter_spec.js +++ /dev/null @@ -1,354 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/zedoBidAdapter'; - -describe('The ZEDO bidding adapter', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'zedo', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - - it('should return true when given a channelcode bid', function () { - const bid = { - bidder: 'zedo', - params: { - channelCode: 20000000, - dimId: 9 - }, - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidderRequest = { - timeout: 3000, - }; - - it('should properly build a channelCode request for dim Id with type not defined', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [[300, 200]], - params: { - channelCode: 20000000, - dimId: 10, - pubId: 1 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^\/\/saxp.zedo.com\/asw\/fmh.json/); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":1,"width":300,"height":200,"dimension":10,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"display"}]}]}'); - }); - - it('should properly build a channelCode request for video with type defined', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [640, 480], - mediaTypes: { - video: { - context: 'instream', - }, - }, - params: { - channelCode: 20000000, - dimId: 85 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^\/\/saxp.zedo.com\/asw\/fmh.json/); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":0,"width":640,"height":480,"dimension":85,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"Inarticle"}]}]}'); - }); - - describe('buildGDPRRequests', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - const bidderRequest = { - timeout: 3000, - gdprConsent: { - 'consentString': consentString, - 'gdprApplies': true - } - }; - - it('should properly build request with gdpr consent', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [[300, 200]], - params: { - channelCode: 20000000, - dimId: 10 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":0,"width":300,"height":200,"dimension":10,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"display"}]}],"gdpr":1,"gdpr_consent":"BOJ8RZsOJ8RZsABAB8AAAAAZ+A=="}'); - }); - }); - }); - describe('interpretResponse', function () { - it('should return an empty array when there is bid response', function () { - const response = {}; - const request = { bidRequests: [] }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('should properly parse a bid response with no valid creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '600', - 'width': '160', - 'isFoc': true, - 'creativeDetails': { - 'type': 'StdBanner', - 'adContent': { - 'focImage': { - 'url': 'https://c13.zedo.com/OzoDB/0/0/0/blank.gif', - 'target': '_blank', - } - } - }, - 'cpm': '0' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'p12345', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 9 - } - }] - }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('should properly parse a bid response with valid display creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '600', - 'width': '160', - 'isFoc': true, - 'creativeDetails': { - 'type': 'StdBanner', - 'adContent': '' - }, - 'cpm': '1200000' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'test-requestId', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 9 - }, - }] - }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('ad1d762'); - expect(bids[0].cpm).to.equal(0.72); - expect(bids[0].width).to.equal('160'); - expect(bids[0].height).to.equal('600'); - }); - - it('should properly parse a bid response with valid video creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '480', - 'width': '640', - 'isFoc': true, - 'creativeDetails': { - 'type': 'VAST', - 'adContent': '' - }, - 'cpm': '1200000' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'test-requestId', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 85 - }, - }] - }; - - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('ad1d762'); - expect(bids[0].cpm).to.equal(0.78); - expect(bids[0].width).to.equal('640'); - expect(bids[0].height).to.equal('480'); - expect(bids[0].adType).to.equal('VAST'); - expect(bids[0].vastXml).to.not.equal(''); - expect(bids[0].ad).to.be.an('undefined'); - expect(bids[0].renderer).not.to.be.an('undefined'); - }); - }); - - describe('user sync', function () { - it('should register the iframe sync url', function () { - let syncs = spec.getUserSyncs({ - iframeEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - }); - - it('should pass gdpr params', function () { - let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { - gdprApplies: false, consentString: 'test' - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.contains('gdpr=0'); - }); - }); - - describe('bid events', function () { - it('should trigger a win pixel', function () { - const bid = { - 'bidderCode': 'zedo', - 'width': '300', - 'height': '250', - 'statusMessage': 'Bid available', - 'adId': '148018fe5e', - 'cpm': 0.5, - 'ad': 'dummy data', - 'ad_id': '12345', - 'sizeId': '15', - 'adResponse': - { - 'creatives': [ - { - 'adId': '12345', - 'height': '480', - 'width': '640', - 'isFoc': true, - 'creativeDetails': { - 'type': 'VAST', - 'adContent': '' - }, - 'seeder': { - 'network': 1234, - 'servedChan': 1234567, - }, - 'cpm': '1200000', - 'servedChan': 1234, - }] - }, - 'params': [{ - 'channelCode': '123456', - 'dimId': '85' - }], - 'requestTimestamp': 1540401686, - 'responseTimestamp': 1540401687, - 'timeToRespond': 6253, - 'pbLg': '0.50', - 'pbMg': '0.50', - 'pbHg': '0.53', - 'adUnitCode': '/123456/header-bid-tag-0', - 'bidder': 'zedo', - 'size': '300x250', - 'adserverTargeting': { - 'hb_bidder': 'zedo', - 'hb_adid': '148018fe5e', - 'hb_pb': '10.00', - } - }; - spec.onBidWon(bid); - spec.onTimeout(bid); - }); - it('should trigger a timeout pixel', function () { - const bid = { - 'bidderCode': 'zedo', - 'width': '300', - 'height': '250', - 'statusMessage': 'Bid available', - 'adId': '148018fe5e', - 'cpm': 0.5, - 'ad': 'dummy data', - 'ad_id': '12345', - 'sizeId': '15', - 'params': [{ - 'channelCode': '123456', - 'dimId': '85' - }], - 'timeout': 1, - 'requestTimestamp': 1540401686, - 'responseTimestamp': 1540401687, - 'timeToRespond': 6253, - 'adUnitCode': '/123456/header-bid-tag-0', - 'bidder': 'zedo', - 'size': '300x250', - }; - spec.onBidWon(bid); - spec.onTimeout(bid); - }); - }); -}); diff --git a/test/spec/native_spec.js b/test/spec/native_spec.js index 2fb2fd810fa..bd56ba53e4a 100644 --- a/test/spec/native_spec.js +++ b/test/spec/native_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { fireNativeTrackers, getNativeTargeting, nativeBidIsValid, getAssetMessage } from 'src/native'; +import { fireNativeTrackers, getNativeTargeting, nativeBidIsValid, getAssetMessage } from 'src/native.js'; import CONSTANTS from 'src/constants.json'; const utils = require('src/utils'); diff --git a/test/spec/refererDetection_spec.js b/test/spec/refererDetection_spec.js index b2ef4e2058f..90892d915fe 100644 --- a/test/spec/refererDetection_spec.js +++ b/test/spec/refererDetection_spec.js @@ -1,4 +1,4 @@ -import { detectReferer } from 'src/refererDetection'; +import { detectReferer } from 'src/refererDetection.js'; import { expect } from 'chai'; var mocks = { diff --git a/test/spec/renderer_spec.js b/test/spec/renderer_spec.js index f9a670c1315..2688c6437fe 100644 --- a/test/spec/renderer_spec.js +++ b/test/spec/renderer_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; -import { Renderer } from 'src/Renderer'; -import * as utils from 'src/utils'; +import { Renderer } from 'src/Renderer.js'; +import * as utils from 'src/utils.js'; +import { loadExternalScript } from 'src/adloader.js'; describe('Renderer', function () { describe('Renderer: A renderer installed on a bid response', function () { @@ -127,5 +128,22 @@ describe('Renderer', function () { }); expect(utilsSpy.callCount).to.equal(1); }); + + it('should call loadExternalScript() for script not defined on adUnit', function() { + $$PREBID_GLOBAL$$.adUnits = [{ + code: 'video1', + renderer: { + url: 'http://cdn.adnxs.com/renderer/video/ANOutstreamVideo.js', + render: sinon.spy() + } + }]; + let testRenderer = Renderer.install({ + url: 'https://httpbin.org/post', + config: { test: 'config1' }, + id: 1, + adUnitCode: undefined + }); + expect(loadExternalScript.called).to.be.true; + }); }); }); diff --git a/test/spec/sizeMapping_spec.js b/test/spec/sizeMapping_spec.js index 254dcb8003e..b6b8c00ada3 100644 --- a/test/spec/sizeMapping_spec.js +++ b/test/spec/sizeMapping_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { resolveStatus, setSizeConfig, sizeSupported } from 'src/sizeMapping'; -import includes from 'core-js/library/fn/array/includes'; +import { resolveStatus, setSizeConfig, sizeSupported } from 'src/sizeMapping.js'; +import includes from 'core-js/library/fn/array/includes.js'; let utils = require('src/utils'); let deepClone = utils.deepClone; diff --git a/test/spec/unit/adServerManager_spec.js b/test/spec/unit/adServerManager_spec.js index 4ae475ac013..ec58ff7f5b3 100644 --- a/test/spec/unit/adServerManager_spec.js +++ b/test/spec/unit/adServerManager_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { getGlobal } from 'src/prebidGlobal'; -import { registerVideoSupport } from 'src/adServerManager'; +import { getGlobal } from 'src/prebidGlobal.js'; +import { registerVideoSupport } from 'src/adServerManager.js'; const prebid = getGlobal(); diff --git a/test/spec/unit/adUnits_spec.js b/test/spec/unit/adUnits_spec.js index ff77315ba4a..a8443d36522 100644 --- a/test/spec/unit/adUnits_spec.js +++ b/test/spec/unit/adUnits_spec.js @@ -1,23 +1,49 @@ import { expect } from 'chai'; -import { adunitCounter } from 'src/adUnits'; +import { adunitCounter } from 'src/adUnits.js'; describe('Adunit Counter', function () { const ADUNIT_ID_1 = 'test1'; const ADUNIT_ID_2 = 'test2'; + const BIDDER_ID_1 = 'bidder1'; + const BIDDER_ID_2 = 'bidder2'; - it('increments and checks counter of adunit 1', function () { - adunitCounter.incrementCounter(ADUNIT_ID_1); - expect(adunitCounter.getCounter(ADUNIT_ID_1)).to.be.equal(1); + it('increments and checks requests counter of adunit 1', function () { + adunitCounter.incrementRequestsCounter(ADUNIT_ID_1); + expect(adunitCounter.getRequestsCounter(ADUNIT_ID_1)).to.be.equal(1); }); - it('checks counter of adunit 2', function () { - expect(adunitCounter.getCounter(ADUNIT_ID_2)).to.be.equal(0); + it('checks requests counter of adunit 2', function () { + expect(adunitCounter.getRequestsCounter(ADUNIT_ID_2)).to.be.equal(0); }); - it('increments and checks counter of adunit 1', function () { - adunitCounter.incrementCounter(ADUNIT_ID_1); - expect(adunitCounter.getCounter(ADUNIT_ID_1)).to.be.equal(2); + it('increments and checks requests counter of adunit 1', function () { + adunitCounter.incrementRequestsCounter(ADUNIT_ID_1); + expect(adunitCounter.getRequestsCounter(ADUNIT_ID_1)).to.be.equal(2); }); - it('increments and checks counter of adunit 2', function () { - adunitCounter.incrementCounter(ADUNIT_ID_2); - expect(adunitCounter.getCounter(ADUNIT_ID_2)).to.be.equal(1); + it('increments and checks requests counter of adunit 2', function () { + adunitCounter.incrementRequestsCounter(ADUNIT_ID_2); + expect(adunitCounter.getRequestsCounter(ADUNIT_ID_2)).to.be.equal(1); + }); + it('increments and checks requests counter of adunit 1 for bidder 1', function () { + adunitCounter.incrementBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_1); + expect(adunitCounter.getBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_1)).to.be.equal(1); + }); + it('increments and checks requests counter of adunit 1 for bidder 2', function () { + adunitCounter.incrementBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_2); + expect(adunitCounter.getBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_2)).to.be.equal(1); + }); + it('increments and checks requests counter of adunit 1 for bidder 1', function () { + adunitCounter.incrementBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_1); + expect(adunitCounter.getBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_1)).to.be.equal(2); + }); + it('increments and checks wins counter of adunit 1 for bidder 1', function () { + adunitCounter.incrementBidderWinsCounter(ADUNIT_ID_1, BIDDER_ID_1); + expect(adunitCounter.getBidderWinsCounter(ADUNIT_ID_1, BIDDER_ID_1)).to.be.equal(1); + }); + it('increments and checks wins counter of adunit 2 for bidder 1', function () { + adunitCounter.incrementBidderWinsCounter(ADUNIT_ID_2, BIDDER_ID_1); + expect(adunitCounter.getBidderWinsCounter(ADUNIT_ID_2, BIDDER_ID_1)).to.be.equal(1); + }); + it('increments and checks wins counter of adunit 1 for bidder 2', function () { + adunitCounter.incrementBidderWinsCounter(ADUNIT_ID_1, BIDDER_ID_2); + expect(adunitCounter.getBidderWinsCounter(ADUNIT_ID_1, BIDDER_ID_2)).to.be.equal(1); }); }); diff --git a/test/spec/unit/core/adapterManager_spec.js b/test/spec/unit/core/adapterManager_spec.js index f52aadba647..8ee345166e1 100644 --- a/test/spec/unit/core/adapterManager_spec.js +++ b/test/spec/unit/core/adapterManager_spec.js @@ -1,16 +1,19 @@ import { expect } from 'chai'; -import adapterManager, { - gdprDataHandler -} from 'src/adapterManager'; -import { getAdUnits } from 'test/fixtures/fixtures'; +import adapterManager, { gdprDataHandler } from 'src/adapterManager.js'; +import { + getAdUnits, + getServerTestingConfig, + getServerTestingsAds, + getBidRequests +} from 'test/fixtures/fixtures.js'; import CONSTANTS from 'src/constants.json'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import { setSizeConfig } from 'src/sizeMapping'; -import find from 'core-js/library/fn/array/find'; -import includes from 'core-js/library/fn/array/includes'; -import s2sTesting from 'modules/s2sTesting'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import { registerBidder } from 'src/adapters/bidderFactory.js'; +import { setSizeConfig } from 'src/sizeMapping.js'; +import find from 'core-js/library/fn/array/find.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import s2sTesting from 'modules/s2sTesting.js'; var events = require('../../../../src/events'); const CONFIG = { @@ -40,16 +43,23 @@ var rubiconAdapterMock = { callBids: sinon.stub() }; +var badAdapterMock = { + bidder: 'badBidder', + callBids: sinon.stub().throws(Error('some fake error')) +}; + describe('adapterManager tests', function () { let orgAppnexusAdapter; let orgAdequantAdapter; let orgPrebidServerAdapter; let orgRubiconAdapter; + let orgBadBidderAdapter; before(function () { orgAppnexusAdapter = adapterManager.bidderRegistry['appnexus']; orgAdequantAdapter = adapterManager.bidderRegistry['adequant']; orgPrebidServerAdapter = adapterManager.bidderRegistry['prebidServer']; orgRubiconAdapter = adapterManager.bidderRegistry['rubicon']; + orgBadBidderAdapter = adapterManager.bidderRegistry['badBidder']; }); after(function () { @@ -57,6 +67,7 @@ describe('adapterManager tests', function () { adapterManager.bidderRegistry['adequant'] = orgAdequantAdapter; adapterManager.bidderRegistry['prebidServer'] = orgPrebidServerAdapter; adapterManager.bidderRegistry['rubicon'] = orgRubiconAdapter; + adapterManager.bidderRegistry['badBidder'] = orgBadBidderAdapter; config.setConfig({s2sConfig: { enabled: false }}); }); @@ -69,11 +80,16 @@ describe('adapterManager tests', function () { sinon.stub(utils, 'logError'); appnexusAdapterMock.callBids.reset(); adapterManager.bidderRegistry['appnexus'] = appnexusAdapterMock; + adapterManager.bidderRegistry['rubicon'] = rubiconAdapterMock; + adapterManager.bidderRegistry['badBidder'] = badAdapterMock; }); afterEach(function () { utils.logError.restore(); delete adapterManager.bidderRegistry['appnexus']; + delete adapterManager.bidderRegistry['rubicon']; + delete adapterManager.bidderRegistry['badBidder']; + config.resetConfig(); }); it('should log an error if a bidder is used that does not exist', function () { @@ -92,6 +108,34 @@ describe('adapterManager tests', function () { sinon.assert.called(utils.logError); }); + it('should catch a bidder adapter thrown error and continue with other bidders', function () { + const adUnits = [{ + code: 'adUnit-code', + sizes: [[728, 90]], + bids: [ + {bidder: 'appnexus', params: {placementId: 'id'}}, + {bidder: 'badBidder', params: {placementId: 'id'}}, + {bidder: 'rubicon', params: {account: 1111, site: 2222, zone: 3333}} + ] + }]; + let bidRequests = adapterManager.makeBidRequests(adUnits, 1111, 2222, 1000); + + let doneBidders = []; + function mockDoneCB() { + doneBidders.push(this.bidderCode) + } + adapterManager.callBids(adUnits, bidRequests, () => {}, mockDoneCB); + sinon.assert.calledOnce(appnexusAdapterMock.callBids); + sinon.assert.calledOnce(badAdapterMock.callBids); + sinon.assert.calledOnce(rubiconAdapterMock.callBids); + + expect(utils.logError.calledOnce).to.be.true; + expect(utils.logError.calledWith( + 'badBidder Bid Adapter emitted an uncaught error when parsing their bidRequest' + )).to.be.true; + // done should be called for our bidder! + expect(doneBidders.indexOf('badBidder') === -1).to.be.false; + }); it('should emit BID_REQUESTED event', function () { // function to count BID_REQUESTED events let cnt = 0; @@ -133,6 +177,112 @@ describe('adapterManager tests', function () { sinon.assert.calledOnce(appnexusAdapterMock.callBids); events.off(CONSTANTS.EVENTS.BID_REQUESTED, count); }); + + it('should give bidders access to bidder-specific config', function(done) { + let mockBidders = ['rubicon', 'appnexus', 'pubmatic']; + let bidderRequest = getBidRequests().filter(bidRequest => includes(mockBidders, bidRequest.bidderCode)); + let adUnits = getAdUnits(); + + let bidders = {}; + let results = {}; + let cbCount = 0; + + function mock(bidder) { + bidders[bidder] = adapterManager.bidderRegistry[bidder]; + adapterManager.bidderRegistry[bidder] = { + callBids: function(bidRequest, addBidResponse, done, ajax, timeout, configCallback) { + let myResults = results[bidRequest.bidderCode] = []; + myResults.push(config.getConfig('buildRequests')); + myResults.push(config.getConfig('test1')); + myResults.push(config.getConfig('test2')); + // emulate ajax callback that would register bids + setTimeout(configCallback(() => { + myResults.push(config.getConfig('interpretResponse')); + myResults.push(config.getConfig('afterInterpretResponse')); + if (++cbCount === Object.keys(bidders).length) { + assertions(); + } + }), 1); + done(); + } + } + } + + mockBidders.forEach(bidder => { + mock(bidder); + }); + + config.setConfig({ + buildRequests: { + data: 1 + }, + test1: { speedy: true, fun: { test: true } }, + interpretResponse: 'baseInterpret', + afterInterpretResponse: 'anotherBaseInterpret' + }); + config.setBidderConfig({ + bidders: [ 'appnexus' ], + config: { + buildRequests: { + test: 2 + }, + test1: { fun: { safe: true, cheap: false } }, + interpretResponse: 'appnexusInterpret' + } + }); + config.setBidderConfig({ + bidders: [ 'rubicon' ], + config: { + buildRequests: 'rubiconBuild', + interpretResponse: null + } + }); + config.setBidderConfig({ + bidders: [ 'appnexus', 'rubicon' ], + config: { + test2: { amazing: true } + } + }); + + adapterManager.callBids(adUnits, bidderRequest, () => {}, () => {}); + + function assertions() { + expect(results).to.deep.equal({ + 'appnexus': [ + { + data: 1, + test: 2 + }, + { fun: { safe: true, cheap: false, test: true }, speedy: true }, + { amazing: true }, + 'appnexusInterpret', + 'anotherBaseInterpret' + ], + 'pubmatic': [ + { + data: 1 + }, + { fun: { test: true }, speedy: true }, + undefined, + 'baseInterpret', + 'anotherBaseInterpret' + ], + 'rubicon': [ + 'rubiconBuild', + { fun: { test: true }, speedy: true }, + { amazing: true }, + null, + 'anotherBaseInterpret' + ] + }); + + // restore bid adapters + Object.keys(bidders).forEach(bidder => { + adapterManager.bidderRegistry[bidder] = bidders[bidder]; + }); + done(); + } + }); }); describe('callTimedOutBidders', function () { @@ -925,12 +1075,12 @@ describe('adapterManager tests', function () { expect(bidRequests.length).to.equal(2); let rubiconBidRequests = find(bidRequests, bidRequest => bidRequest.bidderCode === 'rubicon'); expect(rubiconBidRequests.bids.length).to.equal(1); - expect(rubiconBidRequests.bids[0].sizes).to.deep.equal(find(adUnits, adUnit => adUnit.code === rubiconBidRequests.bids[0].adUnitCode).sizes); + expect(rubiconBidRequests.bids[0].mediaTypes).to.deep.equal(find(adUnits, adUnit => adUnit.code === rubiconBidRequests.bids[0].adUnitCode).mediaTypes); let appnexusBidRequests = find(bidRequests, bidRequest => bidRequest.bidderCode === 'appnexus'); expect(appnexusBidRequests.bids.length).to.equal(2); - expect(appnexusBidRequests.bids[0].sizes).to.deep.equal(find(adUnits, adUnit => adUnit.code === appnexusBidRequests.bids[0].adUnitCode).sizes); - expect(appnexusBidRequests.bids[1].sizes).to.deep.equal(find(adUnits, adUnit => adUnit.code === appnexusBidRequests.bids[1].adUnitCode).sizes); + expect(appnexusBidRequests.bids[0].mediaTypes).to.deep.equal(find(adUnits, adUnit => adUnit.code === appnexusBidRequests.bids[0].adUnitCode).mediaTypes); + expect(appnexusBidRequests.bids[1].mediaTypes).to.deep.equal(find(adUnits, adUnit => adUnit.code === appnexusBidRequests.bids[1].adUnitCode).mediaTypes); }); it('should not filter video bids', function () { @@ -1107,8 +1257,6 @@ describe('adapterManager tests', function () { expect(bidRequests[0].adUnitsS2SCopy.length).to.equal(1); expect(bidRequests[0].adUnitsS2SCopy[0].bids.length).to.equal(1); expect(bidRequests[0].adUnitsS2SCopy[0].bids[0].bidder).to.equal('rubicon'); - expect(bidRequests[0].adUnitsS2SCopy[0].bids[0].adUnitCode).to.equal(adUnits[1].code); - expect(bidRequests[0].adUnitsS2SCopy[0].bids[0].bid_id).to.equal(bidRequests[0].bids[0].bid_id); expect(bidRequests[0].adUnitsS2SCopy[0].labelAny).to.deep.equal(['visitor-uk', 'desktop']); }); }); @@ -1142,5 +1290,128 @@ describe('adapterManager tests', function () { expect(bidRequests[0].gdprConsent).to.be.undefined; }); }); + + describe('s2sTesting - testServerOnly', () => { + beforeEach(() => { + config.setConfig({ s2sConfig: getServerTestingConfig(CONFIG) }); + }); + + afterEach(() => config.resetConfig()); + + const makeBidRequests = ads => { + let bidRequests = adapterManager.makeBidRequests( + ads, 1111, 2222, 1000 + ); + + bidRequests.sort((a, b) => { + if (a.bidderCode < b.bidderCode) return -1; + if (a.bidderCode > b.bidderCode) return 1; + return 0; + }); + + return bidRequests; + }; + + const removeAdUnitsBidSource = adUnits => adUnits.map(adUnit => { + const newAdUnit = { ...adUnit }; + newAdUnit.bids = newAdUnit.bids.map(bid => { + if (bid.bidSource) delete bid.bidSource; + return bid; + }); + return newAdUnit; + }); + + it('suppresses all client bids if there are server bids resulting from bidSource at the adUnit Level', () => { + const bidRequests = makeBidRequests(getServerTestingsAds()); + + expect(bidRequests).lengthOf(2); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[0].bids[0].bidder).equals('openx'); + expect(bidRequests[0].bids[0].finalSource).equals('server'); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[1].bids[0].bidder).equals('rubicon'); + expect(bidRequests[1].bids[0].finalSource).equals('server'); + }); + + // todo: update description + it('suppresses all, and only, client bids if there are bids resulting from bidSource at the adUnit Level', () => { + const ads = getServerTestingsAds(); + + // change this adUnit to be server based + ads[1].bids[1].bidSource.client = 0; + ads[1].bids[1].bidSource.server = 100; + + const bidRequests = makeBidRequests(ads); + + expect(bidRequests).lengthOf(3); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[0].bids[0].bidder).equals('appnexus'); + expect(bidRequests[0].bids[0].finalSource).equals('server'); + + expect(bidRequests[1].bids).lengthOf(1); + expect(bidRequests[1].bids[0].bidder).equals('openx'); + expect(bidRequests[1].bids[0].finalSource).equals('server'); + + expect(bidRequests[2].bids).lengthOf(1); + expect(bidRequests[2].bids[0].bidder).equals('rubicon'); + expect(bidRequests[2].bids[0].finalSource).equals('server'); + }); + + // we have a server call now + it('does not suppress client bids if no "test case" bids result in a server bid', () => { + const ads = getServerTestingsAds(); + + // change this adUnit to be client based + ads[0].bids[0].bidSource.client = 100; + ads[0].bids[0].bidSource.server = 0; + + const bidRequests = makeBidRequests(ads); + + expect(bidRequests).lengthOf(4); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[0].bids[0].bidder).equals('adequant'); + expect(bidRequests[0].bids[0].finalSource).equals('client'); + + expect(bidRequests[1].bids).lengthOf(2); + expect(bidRequests[1].bids[0].bidder).equals('appnexus'); + expect(bidRequests[1].bids[0].finalSource).equals('client'); + expect(bidRequests[1].bids[1].bidder).equals('appnexus'); + expect(bidRequests[1].bids[1].finalSource).equals('client'); + + expect(bidRequests[2].bids).lengthOf(1); + expect(bidRequests[2].bids[0].bidder).equals('openx'); + expect(bidRequests[2].bids[0].finalSource).equals('server'); + + expect(bidRequests[3].bids).lengthOf(2); + expect(bidRequests[3].bids[0].bidder).equals('rubicon'); + expect(bidRequests[3].bids[0].finalSource).equals('client'); + expect(bidRequests[3].bids[1].bidder).equals('rubicon'); + expect(bidRequests[3].bids[1].finalSource).equals('client'); + }); + + it( + 'should surpress client side bids if no ad unit bidSources are set, ' + + 'but bidderControl resolves to server', + () => { + const ads = removeAdUnitsBidSource(getServerTestingsAds()); + + const bidRequests = makeBidRequests(ads); + + expect(bidRequests).lengthOf(2); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[0].bids[0].bidder).equals('openx'); + expect(bidRequests[0].bids[0].finalSource).equals('server'); + + expect(bidRequests[1].bids).lengthOf(2); + expect(bidRequests[1].bids[0].bidder).equals('rubicon'); + expect(bidRequests[1].bids[0].finalSource).equals('server'); + } + ); + }); }); }); diff --git a/test/spec/unit/core/bidderFactory_spec.js b/test/spec/unit/core/bidderFactory_spec.js index fd54d2911e1..6d0595ba4d8 100644 --- a/test/spec/unit/core/bidderFactory_spec.js +++ b/test/spec/unit/core/bidderFactory_spec.js @@ -1,11 +1,11 @@ -import { newBidder, registerBidder, preloadBidderMappingFile } from 'src/adapters/bidderFactory'; -import adapterManager from 'src/adapterManager'; -import * as ajax from 'src/ajax'; +import { newBidder, registerBidder, preloadBidderMappingFile, storage } from 'src/adapters/bidderFactory.js'; +import adapterManager from 'src/adapterManager.js'; +import * as ajax from 'src/ajax.js'; import { expect } from 'chai'; -import { STATUS } from 'src/constants'; -import { userSync } from 'src/userSync' -import * as utils from 'src/utils'; -import { config } from 'src/config'; +import { userSync } from 'src/userSync.js' +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr.js'; const CODE = 'sampleBidder'; const MOCK_BIDS_REQUEST = { @@ -33,6 +33,8 @@ function onTimelyResponseStub() { } +let wrappedCallback = config.callbackWithBidder(CODE); + describe('bidders created by newBidder', function () { let spec; let bidder; @@ -54,15 +56,66 @@ describe('bidders created by newBidder', function () { describe('when the ajax response is irrelevant', function () { let ajaxStub; + let getConfigSpy; beforeEach(function () { ajaxStub = sinon.stub(ajax, 'ajax'); addBidResponseStub.reset(); + getConfigSpy = sinon.spy(config, 'getConfig'); doneStub.reset(); }); afterEach(function () { ajaxStub.restore(); + getConfigSpy.restore(); + }); + + it('should let registerSyncs run with invalid alias and aliasSync enabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: true + } + }); + spec.code = 'fakeBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); + }); + + it('should let registerSyncs run with valid alias and aliasSync enabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: true + } + }); + spec.code = 'aliasBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); + }); + + it('should let registerSyncs run with invalid alias and aliasSync disabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: false + } + }); + spec.code = 'fakeBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); + }); + + it('should not let registerSyncs run with valid alias and aliasSync disabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: false + } + }); + spec.code = 'aliasBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(false); }); it('should handle bad bid requests gracefully', function () { @@ -71,7 +124,7 @@ describe('bidders created by newBidder', function () { spec.getUserSyncs.returns([]); bidder.callBids({}); - bidder.callBids({ bids: 'nothing useful' }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids({ bids: 'nothing useful' }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.called).to.equal(false); expect(spec.isBidRequestValid.called).to.equal(false); @@ -85,7 +138,7 @@ describe('bidders created by newBidder', function () { spec.isBidRequestValid.returns(true); spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.called).to.equal(false); expect(spec.isBidRequestValid.calledTwice).to.equal(true); @@ -99,7 +152,7 @@ describe('bidders created by newBidder', function () { spec.isBidRequestValid.returns(false); spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.called).to.equal(false); expect(spec.isBidRequestValid.calledTwice).to.equal(true); @@ -113,7 +166,7 @@ describe('bidders created by newBidder', function () { spec.isBidRequestValid.onSecondCall().returns(false); spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.called).to.equal(false); expect(spec.isBidRequestValid.calledTwice).to.equal(true); @@ -127,7 +180,7 @@ describe('bidders created by newBidder', function () { spec.isBidRequestValid.returns(true); spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.called).to.equal(false); }); @@ -143,7 +196,7 @@ describe('bidders created by newBidder', function () { data: data }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0]).to.equal(url); @@ -168,7 +221,7 @@ describe('bidders created by newBidder', function () { options: options }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0]).to.equal(url); @@ -191,10 +244,10 @@ describe('bidders created by newBidder', function () { data: data }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2&`); + expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2`); expect(ajaxStub.firstCall.args[2]).to.be.undefined; expect(ajaxStub.firstCall.args[3]).to.deep.equal({ method: 'GET', @@ -215,10 +268,10 @@ describe('bidders created by newBidder', function () { options: opt }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2&`); + expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2`); expect(ajaxStub.firstCall.args[2]).to.be.undefined; expect(ajaxStub.firstCall.args[3]).to.deep.equal({ method: 'GET', @@ -244,7 +297,7 @@ describe('bidders created by newBidder', function () { } ]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.calledTwice).to.equal(true); }); @@ -257,7 +310,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns([]); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(addBidResponseStub.callCount).to.equal(0); }); @@ -297,7 +350,7 @@ describe('bidders created by newBidder', function () { }); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(spec.interpretResponse.calledOnce).to.equal(true); const response = spec.interpretResponse.firstCall.args[0] @@ -329,7 +382,7 @@ describe('bidders created by newBidder', function () { ]); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(spec.interpretResponse.calledTwice).to.equal(true); expect(doneStub.calledOnce).to.equal(true); @@ -360,10 +413,14 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns(bid); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(addBidResponseStub.calledOnce).to.equal(true); expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); + let bidObject = addBidResponseStub.firstCall.args[1]; + // checking the fields added by our code + expect(bidObject.originalCpm).to.equal(bid.cpm); + expect(bidObject.originalCurrency).to.equal(bid.currency); expect(doneStub.calledOnce).to.equal(true); expect(logErrorSpy.callCount).to.equal(0); }); @@ -379,7 +436,7 @@ describe('bidders created by newBidder', function () { }); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(spec.getUserSyncs.calledOnce).to.equal(true); expect(spec.getUserSyncs.firstCall.args[1].length).to.equal(1); @@ -398,7 +455,7 @@ describe('bidders created by newBidder', function () { url: 'usersync.com' }]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(userSyncStub.called).to.equal(true); expect(userSyncStub.firstCall.args[0]).to.equal('iframe'); @@ -427,7 +484,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns(bid); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(logErrorSpy.calledOnce).to.equal(true); }); @@ -457,7 +514,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns(bid); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(logErrorSpy.calledOnce).to.equal(true); }); @@ -489,7 +546,7 @@ describe('bidders created by newBidder', function () { }); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(spec.interpretResponse.called).to.equal(false); expect(doneStub.calledOnce).to.equal(true); @@ -507,7 +564,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns([]); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(addBidResponseStub.callCount).to.equal(0); expect(doneStub.calledOnce).to.equal(true); @@ -524,7 +581,7 @@ describe('bidders created by newBidder', function () { }); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(spec.getUserSyncs.calledOnce).to.equal(true); expect(spec.getUserSyncs.firstCall.args[1]).to.deep.equal([]); @@ -670,7 +727,7 @@ describe('validate bid response: ', function () { const bidder = newBidder(spec); spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(addBidResponseStub.calledOnce).to.equal(true); expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); @@ -707,7 +764,7 @@ describe('validate bid response: ', function () { const bidder = newBidder(spec); spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(addBidResponseStub.calledOnce).to.equal(false); expect(logErrorSpy.callCount).to.equal(1); @@ -740,7 +797,7 @@ describe('validate bid response: ', function () { const bidder = newBidder(spec); spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(addBidResponseStub.calledOnce).to.equal(true); expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); @@ -772,7 +829,7 @@ describe('validate bid response: ', function () { const bidder = newBidder(spec); spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(addBidResponseStub.calledOnce).to.equal(true); expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); @@ -786,8 +843,8 @@ describe('preload mapping url hook', function() { let adapterManagerStub; beforeEach(function () { - fakeTranslationServer = sinon.fakeServer.create(); - getLocalStorageStub = sinon.stub(utils, 'getDataFromLocalStorage'); + fakeTranslationServer = server; + getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); adapterManagerStub = sinon.stub(adapterManager, 'getBidAdapter'); }); diff --git a/test/spec/unit/core/storageManager_spec.js b/test/spec/unit/core/storageManager_spec.js new file mode 100644 index 00000000000..0b406242f90 --- /dev/null +++ b/test/spec/unit/core/storageManager_spec.js @@ -0,0 +1,46 @@ +import { resetData, getCoreStorageManager, storageCallbacks, getStorageManager } from 'src/storageManager.js'; +import { config } from 'src/config.js'; +import * as utils from 'src/utils.js'; + +describe('storage manager', function() { + beforeEach(function() { + resetData(); + }); + + afterEach(function() { + config.resetConfig(); + }) + + it('should allow to set cookie for core modules without checking gdpr enforcements', function() { + const coreStorage = getCoreStorageManager(); + let date = new Date(); + date.setTime(date.getTime() + (24 * 60 * 60 * 1000)); + let expires = date.toUTCString(); + coreStorage.setCookie('hello', 'world', expires); + expect(coreStorage.getCookie('hello')).to.equal('world'); + }); + + it('should add done callbacks to storageCallbacks array', function() { + let noop = sinon.spy(); + const coreStorage = getStorageManager(); + + coreStorage.setCookie('foo', 'bar', null, null, null, noop); + coreStorage.getCookie('foo', noop); + coreStorage.localStorageIsEnabled(noop); + coreStorage.cookiesAreEnabled(noop); + coreStorage.setDataInLocalStorage('foo', 'bar', noop); + coreStorage.getDataFromLocalStorage('foo', noop); + coreStorage.removeDataFromLocalStorage('foo', noop); + coreStorage.hasLocalStorage(noop); + + expect(storageCallbacks.length).to.equal(8); + }); + + it('should allow bidder to access device if gdpr enforcement module is not included', function() { + let deviceAccessSpy = sinon.spy(utils, 'hasDeviceAccess'); + const storage = getStorageManager(); + storage.setCookie('foo1', 'baz1'); + expect(deviceAccessSpy.calledOnce).to.equal(true); + deviceAccessSpy.restore(); + }) +}); diff --git a/test/spec/unit/core/targeting_spec.js b/test/spec/unit/core/targeting_spec.js index f4d3a5e0488..a5da1c904f0 100644 --- a/test/spec/unit/core/targeting_spec.js +++ b/test/spec/unit/core/targeting_spec.js @@ -1,10 +1,10 @@ import { expect } from 'chai'; -import { targeting as targetingInstance, filters, sortByDealAndPriceBucket } from 'src/targeting'; -import { config } from 'src/config'; -import { getAdUnits, createBidReceived } from 'test/fixtures/fixtures'; +import { targeting as targetingInstance, filters, sortByDealAndPriceBucketOrCpm } from 'src/targeting.js'; +import { config } from 'src/config.js'; +import { getAdUnits, createBidReceived } from 'test/fixtures/fixtures.js'; import CONSTANTS from 'src/constants.json'; -import { auctionManager } from 'src/auctionManager'; -import * as utils from 'src/utils'; +import { auctionManager } from 'src/auctionManager.js'; +import * as utils from 'src/utils.js'; const bid1 = { 'bidderCode': 'rubicon', @@ -32,6 +32,7 @@ const bid1 = { [CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]: '0.53', [CONSTANTS.TARGETING_KEYS.DEAL]: '1234' }, + 'dealId': '1234', 'netRevenue': true, 'currency': 'USD', 'ttl': 300 @@ -330,6 +331,179 @@ describe('targeting tests', function () { expect(logErrorStub.calledOnce).to.be.true; }); + describe('when bidLimit is present in setConfig', function () { + let bid4; + + beforeEach(function() { + bid4 = utils.deepClone(bid1); + bid4.adserverTargeting['hb_bidder'] = bid4.bidder = bid4.bidderCode = 'appnexus'; + bid4.cpm = 2.25; + enableSendAllBids = true; + + bidsReceived.push(bid4); + }); + + it('selects the top n number of bids when enableSendAllBids is true and and bitLimit is set', function () { + config.setConfig({ + sendBidsControl: { + bidLimit: 1 + } + }); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + let limitedBids = Object.keys(targeting['/123456/header-bid-tag-0']).filter(key => key.indexOf(CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_') != -1) + + expect(limitedBids.length).to.equal(1); + }); + + it('sends all bids when enableSendAllBids is true and and bitLimit is above total number of bids received', function () { + config.setConfig({ + sendBidsControl: { + bidLimit: 50 + } + }); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + let limitedBids = Object.keys(targeting['/123456/header-bid-tag-0']).filter(key => key.indexOf(CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_') != -1) + + expect(limitedBids.length).to.equal(2); + }); + + it('Sends all bids when enableSendAllBids is true and and bitLimit is set to 0', function () { + config.setConfig({ + sendBidsControl: { + bidLimit: 0 + } + }); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + let limitedBids = Object.keys(targeting['/123456/header-bid-tag-0']).filter(key => key.indexOf(CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_') != -1) + + expect(limitedBids.length).to.equal(2); + }); + }); + + describe('targetingControls.alwaysIncludeDeals', function () { + let bid4; + + beforeEach(function() { + bid4 = utils.deepClone(bid1); + bid4.adserverTargeting = { + hb_deal: '4321', + hb_pb: '0.1', + hb_adid: '567891011', + hb_bidder: 'appnexus', + }; + bid4.bidder = bid4.bidderCode = 'appnexus'; + bid4.cpm = 0.1; // losing bid so not included if enableSendAllBids === false + bid4.dealId = '4321'; + enableSendAllBids = false; + + bidsReceived.push(bid4); + }); + + it('does not include losing deals when alwaysIncludeDeals not set', function () { + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + + // Rubicon wins bid and has deal, but alwaysIncludeDeals is false, so only top bid plus deal_id + // appnexus does not get sent since alwaysIncludeDeals is not defined + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({ + 'hb_deal_rubicon': '1234', + 'hb_deal': '1234', + 'hb_pb': '0.53', + 'hb_adid': '148018fe5e', + 'hb_bidder': 'rubicon', + 'foobar': '300x250' + }); + }); + + it('does not include losing deals when alwaysIncludeDeals set to false', function () { + config.setConfig({ + targetingControls: { + alwaysIncludeDeals: false + } + }); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + + // Rubicon wins bid and has deal, but alwaysIncludeDeals is false, so only top bid plus deal_id + // appnexus does not get sent since alwaysIncludeDeals is false + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({ + 'hb_deal_rubicon': '1234', // This is just how it works before this PR, always added no matter what for winner if they have deal + 'hb_deal': '1234', + 'hb_pb': '0.53', + 'hb_adid': '148018fe5e', + 'hb_bidder': 'rubicon', + 'foobar': '300x250' + }); + }); + + it('includes losing deals when alwaysIncludeDeals set to true and also winning deals bidder KVPs', function () { + config.setConfig({ + targetingControls: { + alwaysIncludeDeals: true + } + }); + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + + // Rubicon wins bid and has a deal, so all KVPs for them are passed (top plus bidder specific) + // Appnexus had deal so passed through + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({ + 'hb_deal_rubicon': '1234', + 'hb_deal': '1234', + 'hb_pb': '0.53', + 'hb_adid': '148018fe5e', + 'hb_bidder': 'rubicon', + 'foobar': '300x250', + 'hb_pb_rubicon': '0.53', + 'hb_adid_rubicon': '148018fe5e', + 'hb_bidder_rubicon': 'rubicon', + 'hb_deal_appnexus': '4321', + 'hb_pb_appnexus': '0.1', + 'hb_adid_appnexus': '567891011', + 'hb_bidder_appnexus': 'appnexus' + }); + }); + + it('includes winning bid even when it is not a deal, plus other deal KVPs', function () { + config.setConfig({ + targetingControls: { + alwaysIncludeDeals: true + } + }); + let bid5 = utils.deepClone(bid4); + bid5.adserverTargeting = { + hb_pb: '3.0', + hb_adid: '111111', + hb_bidder: 'pubmatic', + }; + bid5.bidder = bid5.bidderCode = 'pubmatic'; + bid5.cpm = 3.0; // winning bid! + delete bid5.dealId; // no deal with winner + bidsReceived.push(bid5); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + + // Pubmatic wins but no deal. So only top bid KVPs for them is sent + // Rubicon has a dealId so passed through + // Appnexus has a dealId so passed through + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({ + 'hb_bidder': 'pubmatic', + 'hb_adid': '111111', + 'hb_pb': '3.0', + 'foobar': '300x250', + 'hb_deal_rubicon': '1234', + 'hb_pb_rubicon': '0.53', + 'hb_adid_rubicon': '148018fe5e', + 'hb_bidder_rubicon': 'rubicon', + 'hb_deal_appnexus': '4321', + 'hb_pb_appnexus': '0.1', + 'hb_adid_appnexus': '567891011', + 'hb_bidder_appnexus': 'appnexus' + }); + }); + }); + it('selects the top bid when enableSendAllBids true', function () { enableSendAllBids = true; let targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); @@ -513,7 +687,7 @@ describe('targeting tests', function () { }); }); - describe('sortByDealAndPriceBucket', function() { + describe('sortByDealAndPriceBucketOrCpm', function() { it('will properly sort bids when some bids have deals and some do not', function () { let bids = [{ adUnitTargeting: { @@ -549,7 +723,7 @@ describe('targeting tests', function () { hb_pb: '100.00', } }]; - bids.sort(sortByDealAndPriceBucket); + bids.sort(sortByDealAndPriceBucketOrCpm()); expect(bids[0].adUnitTargeting.hb_adid).to.equal('ghi'); expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); expect(bids[2].adUnitTargeting.hb_adid).to.equal('abc'); @@ -584,7 +758,7 @@ describe('targeting tests', function () { hb_deal: '9864' } }]; - bids.sort(sortByDealAndPriceBucket); + bids.sort(sortByDealAndPriceBucketOrCpm()); expect(bids[0].adUnitTargeting.hb_adid).to.equal('ghi'); expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); expect(bids[2].adUnitTargeting.hb_adid).to.equal('abc'); @@ -623,7 +797,7 @@ describe('targeting tests', function () { hb_pb: '100.00' } }]; - bids.sort(sortByDealAndPriceBucket); + bids.sort(sortByDealAndPriceBucketOrCpm()); expect(bids[0].adUnitTargeting.hb_adid).to.equal('pqr'); expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); expect(bids[2].adUnitTargeting.hb_adid).to.equal('ghi'); @@ -631,6 +805,57 @@ describe('targeting tests', function () { expect(bids[4].adUnitTargeting.hb_adid).to.equal('mno'); expect(bids[5].adUnitTargeting.hb_adid).to.equal('def'); }); + + it('will properly sort bids when some bids have deals and some do not and by cpm when flag is set to true', function () { + let bids = [{ + cpm: 1.04, + adUnitTargeting: { + hb_adid: 'abc', + hb_pb: '1.00', + hb_deal: '1234' + } + }, { + cpm: 0.50, + adUnitTargeting: { + hb_adid: 'def', + hb_pb: '0.50', + hb_deal: '4532' + } + }, { + cpm: 0.53, + adUnitTargeting: { + hb_adid: 'ghi', + hb_pb: '0.50', + hb_deal: '4532' + } + }, { + cpm: 9.04, + adUnitTargeting: { + hb_adid: 'jkl', + hb_pb: '9.00', + hb_deal: '9864' + } + }, { + cpm: 50.00, + adUnitTargeting: { + hb_adid: 'mno', + hb_pb: '50.00', + } + }, { + cpm: 100.00, + adUnitTargeting: { + hb_adid: 'pqr', + hb_pb: '100.00', + } + }]; + bids.sort(sortByDealAndPriceBucketOrCpm(true)); + expect(bids[0].adUnitTargeting.hb_adid).to.equal('jkl'); + expect(bids[1].adUnitTargeting.hb_adid).to.equal('abc'); + expect(bids[2].adUnitTargeting.hb_adid).to.equal('ghi'); + expect(bids[3].adUnitTargeting.hb_adid).to.equal('def'); + expect(bids[4].adUnitTargeting.hb_adid).to.equal('pqr'); + expect(bids[5].adUnitTargeting.hb_adid).to.equal('mno'); + }); }); describe('setTargetingForAst', function () { diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 485dd5cf077..252c074cd61 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -7,14 +7,15 @@ import { getTargetingKeysBidLandscape, getAdUnits, createBidReceived -} from 'test/fixtures/fixtures'; -import { auctionManager, newAuctionManager } from 'src/auctionManager'; -import { targeting, newTargeting, filters } from 'src/targeting'; -import { config as configObj } from 'src/config'; -import * as ajaxLib from 'src/ajax'; -import * as auctionModule from 'src/auction'; -import { newBidder, registerBidder } from 'src/adapters/bidderFactory'; -import find from 'core-js/library/fn/array/find'; +} from 'test/fixtures/fixtures.js'; +import { auctionManager, newAuctionManager } from 'src/auctionManager.js'; +import { targeting, newTargeting, filters } from 'src/targeting.js'; +import { config as configObj } from 'src/config.js'; +import * as ajaxLib from 'src/ajax.js'; +import * as auctionModule from 'src/auction.js'; +import { newBidder, registerBidder } from 'src/adapters/bidderFactory.js'; +import { _sendAdToCreative } from 'src/secureCreatives.js'; +import find from 'core-js/library/fn/array/find.js'; var assert = require('chai').assert; var expect = require('chai').expect; @@ -56,7 +57,7 @@ function resetAuction() { var Slot = function Slot(elementId, pathId) { var slot = { - targeting: [], + targeting: {}, getSlotElementId: function getSlotElementId() { return elementId; }, @@ -66,24 +67,24 @@ var Slot = function Slot(elementId, pathId) { }, setTargeting: function setTargeting(key, value) { - var obj = []; - obj[key] = value; - this.targeting.push(obj); + this.targeting[key] = Array.isArray(value) ? value : [value]; }, - getTargeting: function getTargeting() { - return this.targeting; + getTargeting: function getTargeting(key) { + return this.targeting[key] || []; }, getTargetingKeys: function getTargetingKeys() { - return []; + return Object.getOwnPropertyNames(this.targeting); }, clearTargeting: function clearTargeting() { - return googletag.pubads().getSlots(); + this.targeting = {}; + return this; } }; slot.spySetTargeting = sinon.spy(slot, 'setTargeting'); + slot.spyGetSlotElementId = sinon.spy(slot, 'getSlotElementId'); return slot; }; @@ -121,11 +122,15 @@ window.googletag = { }, setTargeting: function(key, arrayOfValues) { - self._targeting[key] = arrayOfValues; + self._targeting[key] = Array.isArray(arrayOfValues) ? arrayOfValues : [arrayOfValues]; }, - getTargeting: function() { - return self._targeting; + getTargeting: function(key) { + return self._targeting[key] || []; + }, + + getTargetingKeys: function() { + return Object.getOwnPropertyNames(self._targeting); }, clearTargeting: function() { @@ -406,10 +411,10 @@ describe('Unit: Prebid Module', function () { describe('getAdserverTargeting', function() { const customConfigObject = { 'buckets': [ - { 'precision': 2, 'min': 0, 'max': 5, 'increment': 0.01 }, - { 'precision': 2, 'min': 5, 'max': 8, 'increment': 0.05 }, - { 'precision': 2, 'min': 8, 'max': 20, 'increment': 0.5 }, - { 'precision': 2, 'min': 20, 'max': 25, 'increment': 1 } + { 'precision': 2, 'max': 5, 'increment': 0.01 }, + { 'precision': 2, 'max': 8, 'increment': 0.05 }, + { 'precision': 2, 'max': 20, 'increment': 0.5 }, + { 'precision': 2, 'max': 25, 'increment': 1 } ] }; let currentPriceBucket; @@ -700,18 +705,18 @@ describe('Unit: Prebid Module', function () { configObj.setConfig({ 'priceGranularity': { 'buckets': [ - { 'precision': 2, 'min': 0, 'max': 5, 'increment': 0.01 }, - { 'precision': 2, 'min': 5, 'max': 8, 'increment': 0.05 }, - { 'precision': 2, 'min': 8, 'max': 20, 'increment': 0.5 }, - { 'precision': 2, 'min': 20, 'max': 25, 'increment': 1 } + { 'precision': 2, 'max': 5, 'increment': 0.01 }, + { 'precision': 2, 'max': 8, 'increment': 0.05 }, + { 'precision': 2, 'max': 20, 'increment': 0.5 }, + { 'precision': 2, 'max': 25, 'increment': 1 } ] }, 'mediaTypePriceGranularity': { 'banner': { 'buckets': [ - { 'precision': 2, 'min': 0, 'max': 5, 'increment': 0.25 }, - { 'precision': 2, 'min': 6, 'max': 20, 'increment': 0.5 }, - { 'precision': 2, 'min': 21, 'max': 100, 'increment': 1 } + { 'precision': 2, 'max': 5, 'increment': 0.25 }, + { 'precision': 2, 'max': 20, 'increment': 0.5 }, + { 'precision': 2, 'max': 100, 'increment': 1 } ] }, 'video': 'low', @@ -856,17 +861,57 @@ describe('Unit: Prebid Module', function () { it('should set googletag targeting keys after calling setTargetingForGPTAsync function', function () { var slots = createSlotArrayScenario2(); window.googletag.pubads().setSlots(slots); - $$PREBID_GLOBAL$$.setTargetingForGPTAsync(); + $$PREBID_GLOBAL$$.setTargetingForGPTAsync([config.adUnitCodes[0]]); + + // we need to transform the spySetTargeting into something that looks like + // googletag's targeting structure + // googletag setTargeting will override old value if invoked with same key + + const targeting = []; + slots[1].getTargetingKeys().map(function (key) { + const value = slots[1].getTargeting(key); + targeting.push([key, value]); + }); + + var invokedTargetingMap = {}; + slots[1].spySetTargeting.args.map(function (entry) { + invokedTargetingMap[entry[0]] = entry[1]; + }); + + var invokedTargeting = []; + + Object.getOwnPropertyNames(invokedTargetingMap).map(function (key) { + const value = Array.isArray(invokedTargetingMap[key]) ? invokedTargetingMap[key] : [invokedTargetingMap[key]]; // values are always returned as array in googletag + invokedTargeting.push([key, value]); + }); + assert.deepEqual(targeting, invokedTargeting, 'google tag targeting options not matching'); + }); + + it('should set googletag targeting keys to specific slot with customSlotMatching', function () { + // same ad unit code but two differnt divs + // we make sure we can set targeting for a specific one with customSlotMatching + + $$PREBID_GLOBAL$$.setConfig({ enableSendAllBids: false }); + + var slots = [ + new Slot('div-id-one', config.adUnitCodes[0]), + new Slot('div-id-two', config.adUnitCodes[0]), + new Slot(config.adUnitElementIDs[2], config.adUnitCodes[2]) + ]; - var targeting = []; - slots[1].getTargeting().map(function (value) { - var temp = []; - temp.push(Object.keys(value).toString()); - temp.push(value[Object.keys(value)]); - targeting.push(temp); + slots[0].spySetTargeting.resetHistory(); + slots[1].spySetTargeting.resetHistory(); + window.googletag.pubads().setSlots(slots); + + $$PREBID_GLOBAL$$.setTargetingForGPTAsync([config.adUnitCodes[0]], (slot) => { + return (adUnitCode) => { + return slots[0].getSlotElementId() === slot.getSlotElementId(); + }; }); - assert.deepEqual(slots[1].spySetTargeting.args, targeting, 'google tag targeting options not matching'); + var expected = getTargetingKeys(); + expect(slots[0].spySetTargeting.args).to.deep.contain.members(expected); + expect(slots[1].spySetTargeting.args).to.not.deep.contain.members(expected); }); it('should set targeting when passed a string ad unit code with enableSendAllBids', function () { @@ -898,6 +943,40 @@ describe('Unit: Prebid Module', function () { expect(slots[0].spySetTargeting.args).to.deep.contain.members(expected); }); + it('should find correct gpt slot based on ad id rather than ad unit code when resizing secure creative', function () { + var slots = [ + new Slot('div-not-matching-adunit-code-1', config.adUnitCodes[0]), + new Slot('div-not-matching-adunit-code-2', config.adUnitCodes[0]), + new Slot('div-not-matching-adunit-code-3', config.adUnitCodes[0]) + ]; + + slots[1].setTargeting('hb_adid', ['someAdId']); + slots[1].spyGetSlotElementId.resetHistory(); + window.googletag.pubads().setSlots(slots); + + const mockAdObject = { + adId: 'someAdId', + ad: '', + adUrl: 'http://creative.prebid.org/${AUCTION_PRICE}', + width: 300, + height: 250, + renderer: null, + cpm: '1.00', + adUnitCode: config.adUnitCodes[0], + }; + + const remoteDomain = '*'; + const source = { + postMessage: sinon.stub() + }; + + _sendAdToCreative(mockAdObject, remoteDomain, source); + + expect(slots[0].spyGetSlotElementId.called).to.equal(false); + expect(slots[1].spyGetSlotElementId.called).to.equal(true); + expect(slots[2].spyGetSlotElementId.called).to.equal(false); + }); + it('Calling enableSendAllBids should set targeting to include standard keys with bidder' + ' append to key name', function () { var slots = createSlotArray(); @@ -1142,9 +1221,14 @@ describe('Unit: Prebid Module', function () { describe('requestBids', function () { let logMessageSpy; let makeRequestsStub; - let xhr; let adUnits; let clock; + before(function () { + clock = sinon.useFakeTimers(); + }); + after(function () { + clock.restore(); + }); let bidsBackHandlerStub = sinon.stub(); const BIDDER_CODE = 'sampleBidder'; @@ -1186,10 +1270,14 @@ describe('Unit: Prebid Module', function () { logMessageSpy = sinon.spy(utils, 'logMessage'); makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests'); makeRequestsStub.returns(bidRequests); - xhr = sinon.useFakeXMLHttpRequest(); adUnits = [{ code: 'adUnit-code', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bids: [ {bidder: BIDDER_CODE, params: {placementId: 'id'}}, ] @@ -1210,7 +1298,6 @@ describe('Unit: Prebid Module', function () { adapterManager.makeBidRequests.restore(); auctionModule.newAuction.restore(); utils.logMessage.restore(); - xhr.restore(); }); it('should execute callback after timeout', function () { @@ -1228,7 +1315,6 @@ describe('Unit: Prebid Module', function () { spec.isBidRequestValid.returns(true); spec.interpretResponse.returns(bids); - clock = sinon.useFakeTimers(); let requestObj = { bidsBackHandler: null, // does not need to be defined because of newAuction mock in beforeEach timeout: 2000, @@ -1282,7 +1368,6 @@ describe('Unit: Prebid Module', function () { auction.getBidsReceived = function() { return [adResponse]; } auction.getAuctionId = () => auctionId; - clock = sinon.useFakeTimers(); let requestObj = { bidsBackHandler: null, // does not need to be defined because of newAuction mock in beforeEach timeout: 2000, @@ -1314,9 +1399,11 @@ describe('Unit: Prebid Module', function () { adUnits: [ { code: 'test1', + mediaTypes: { banner: { sizes: [] } }, bids: [], }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [], } ], @@ -1330,18 +1417,6 @@ describe('Unit: Prebid Module', function () { }); describe('requestBids', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - }); - - afterEach(function () { - xhr.restore(); - }); var adUnitsBackup; var auctionManagerStub; let logMessageSpy; @@ -1385,7 +1460,7 @@ describe('Unit: Prebid Module', function () { try { $$PREBID_GLOBAL$$.requestBids({}); } catch (e) { - console.log(e); + console.log(e); // eslint-disable-line } assert.ok(logMessageSpy.calledWith('No adUnits configured. No bids requested.'), 'expected message was logged'); }); @@ -1396,9 +1471,11 @@ describe('Unit: Prebid Module', function () { { code: 'test1', transactionId: 'd0676a3c-ff32-45a5-af65-8175a8e7ddca', + mediaTypes: { banner: { sizes: [] } }, bids: [] }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [] } ] @@ -1419,9 +1496,11 @@ describe('Unit: Prebid Module', function () { adUnits: [ { code: 'test1', + mediaTypes: { banner: { sizes: [] } }, bids: [] }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [] } ] @@ -1562,7 +1641,6 @@ describe('Unit: Prebid Module', function () { expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[640, 480]]); expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.deep.equal([[640, 480]]); expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; - assert.ok(logInfoSpy.calledWith('Transforming video.playerSize from [640,480] to [[640,480]] so it\'s in the proper format.'), 'expected message was logged'); }); it('should normalize adUnit.sizes and adUnit.mediaTypes.banner.sizes', function () { @@ -1601,7 +1679,7 @@ describe('Unit: Prebid Module', function () { }); expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[300, 250], [300, 600]]); expect(auctionArgs.adUnits[0].mediaTypes.banner).to.be.undefined; - assert.ok(logErrorSpy.calledWith('Detected a mediaTypes.banner object did not include sizes. This is a required field for the mediaTypes.banner object. Removing invalid mediaTypes.banner object from request.')); + assert.ok(logErrorSpy.calledWith('Detected a mediaTypes.banner object without a proper sizes field. Please ensure the sizes are listed like: [[300, 250], ...]. Removing invalid mediaTypes.banner object from request.')); let badVideo1 = [{ code: 'testb2', @@ -1763,7 +1841,7 @@ describe('Unit: Prebid Module', function () { before(function () { adUnits = [{ code: 'adUnit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } }, bids: [ {bidder: 'appnexus', params: {placementId: '10433394'}} ] @@ -1771,13 +1849,13 @@ describe('Unit: Prebid Module', function () { let adUnitCodes = ['adUnit-code']; let auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: timeout}); - adUnits[0]['mediaType'] = 'native'; + adUnits[0]['mediaTypes'] = { native: {} }; adUnitCodes = ['adUnit-code']; let auction1 = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: timeout}); adUnits = [{ code: 'adUnit-code', - nativeParams: {type: 'image'}, + mediaTypes: { native: { type: 'image' } }, sizes: [[300, 250], [300, 600]], bids: [ {bidder: 'appnexus', params: {placementId: 'id'}} @@ -1811,7 +1889,7 @@ describe('Unit: Prebid Module', function () { it('should call callBids function on adapterManager', function () { let adUnits = [{ code: 'adUnit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } }, bids: [ {bidder: 'appnexus', params: {placementId: '10433394'}} ] @@ -1823,8 +1901,7 @@ describe('Unit: Prebid Module', function () { it('splits native type to individual native assets', function () { let adUnits = [{ code: 'adUnit-code', - nativeParams: {type: 'image'}, - sizes: [[300, 250], [300, 600]], + mediaTypes: { native: { type: 'image' } }, bids: [ {bidder: 'appnexus', params: {placementId: 'id'}} ] @@ -1972,6 +2049,228 @@ describe('Unit: Prebid Module', function () { assert.ok(spyEventsOn.calledWith('bidWon', Function)); events.on.restore(); }); + + describe('beforeRequestBids', function () { + let bidRequestedHandler; + let beforeRequestBidsHandler; + let bidsBackHandler = function bidsBackHandler() {}; + + let bidsBackSpy; + let bidRequestedSpy; + let beforeRequestBidsSpy; + + beforeEach(function () { + resetAuction(); + bidsBackSpy = sinon.spy(bidsBackHandler); + googletag.pubads().setSlots(createSlotArrayScenario2()); + }); + + afterEach(function () { + bidsBackSpy.resetHistory(); + + if (bidRequestedSpy) { + $$PREBID_GLOBAL$$.offEvent('bidRequested', bidRequestedSpy); + bidRequestedSpy.resetHistory(); + } + + if (beforeRequestBidsSpy) { + $$PREBID_GLOBAL$$.offEvent('beforeRequestBids', beforeRequestBidsSpy); + beforeRequestBidsSpy.resetHistory(); + } + }); + + it('should allow creation of a fpd.context.pbAdSlot property on adUnits from inside the event handler', function () { + // verify adUnits passed to handler then alter the adUnits + beforeRequestBidsHandler = function beforeRequestBidsHandler(beforeRequestBidsAdUnits) { + expect(beforeRequestBidsAdUnits).to.be.a('array'); + expect(beforeRequestBidsAdUnits).to.have.lengthOf(1); + expect(beforeRequestBidsAdUnits[0]).to.be.a('object'); + // adUnit should not contain a context property yet + expect(beforeRequestBidsAdUnits[0]).to.not.have.property('fpd') + // alter the adUnit by adding the property for context.pbAdSlot + beforeRequestBidsAdUnits[0].fpd = { + context: { + pbAdSlot: '/19968336/header-bid-tag-pbadslot-0' + } + }; + }; + beforeRequestBidsSpy = sinon.spy(beforeRequestBidsHandler); + + // use this handler to verify if the adUnits alterations were applied successfully by the beforeRequestBids handler + bidRequestedHandler = function bidRequestedHandler(bidRequest) { + expect(bidRequest).to.be.a('object'); + expect(bidRequest).to.have.property('bids'); + expect(bidRequest.bids).to.be.a('array'); + expect(bidRequest.bids).to.have.lengthOf(1); + const bid = bidRequest['bids'][0]; + expect(bid).to.be.a('object'); + expect(bid).to.have.property('fpd'); + expect(bid.fpd).to.be.a('object'); + expect(bid.fpd).to.have.property('context'); + expect(bid.fpd.context).to.be.a('object'); + expect(bid.fpd.context).to.have.property('pbAdSlot'); + expect(bid.fpd.context.pbAdSlot).to.equal('/19968336/header-bid-tag-pbadslot-0'); + }; + bidRequestedSpy = sinon.spy(bidRequestedHandler); + + $$PREBID_GLOBAL$$.onEvent('beforeRequestBids', beforeRequestBidsSpy); + $$PREBID_GLOBAL$$.onEvent('bidRequested', bidRequestedSpy); + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [{ + code: '/19968336/header-bid-tag-0', + mediaTypes: { + banner: { + sizes: [[750, 350]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13122370 + } + }] + }], + bidsBackHandler: bidsBackSpy + }); + + sinon.assert.calledOnce(beforeRequestBidsSpy); + sinon.assert.calledOnce(bidRequestedSpy); + }); + + it('should allow creation of a fpd.context.pbAdSlot property on adUnits from inside the event handler', function () { + // verify adUnits passed to handler then alter the adUnits + beforeRequestBidsHandler = function beforeRequestBidsHandler(beforeRequestBidsAdUnits) { + expect(beforeRequestBidsAdUnits).to.be.a('array'); + expect(beforeRequestBidsAdUnits).to.have.lengthOf(2); + expect(beforeRequestBidsAdUnits[0]).to.be.a('object'); + expect(beforeRequestBidsAdUnits[1]).to.be.a('object'); + // adUnit should not contain a context property yet + expect(beforeRequestBidsAdUnits[0]).to.not.have.property('fpd'); + expect(beforeRequestBidsAdUnits[1]).to.not.have.property('fpd'); + // alter the adUnit by adding the property for context.pbAdSlot + beforeRequestBidsAdUnits[0].fpd = { + context: { + pbAdSlot: '/19968336/header-bid-tag-pbadslot-0' + } + }; + beforeRequestBidsAdUnits[1].fpd = { + context: { + pbAdSlot: '/19968336/header-bid-tag-pbadslot-1' + } + }; + }; + beforeRequestBidsSpy = sinon.spy(beforeRequestBidsHandler); + + // use this handler to verify if the adUnits alterations were applied successfully by the beforeRequestBids handler + bidRequestedHandler = function bidRequestedHandler(bidRequest) { + expect(bidRequest).to.be.a('object'); + expect(bidRequest).to.have.property('bids'); + expect(bidRequest.bids).to.be.a('array'); + expect(bidRequest.bids).to.have.lengthOf(2); + const bid0 = bidRequest['bids'][0]; + expect(bid0).to.be.a('object'); + expect(bid0).to.have.property('fpd'); + expect(bid0.fpd).to.be.a('object'); + expect(bid0.fpd).to.have.property('context'); + expect(bid0.fpd.context).to.be.a('object'); + expect(bid0.fpd.context).to.have.property('pbAdSlot'); + expect(bid0.fpd.context.pbAdSlot).to.equal('/19968336/header-bid-tag-pbadslot-0'); + + const bid1 = bidRequest['bids'][1]; + expect(bid1).to.be.a('object'); + expect(bid1).to.have.property('fpd'); + expect(bid1.fpd).to.be.a('object'); + expect(bid1.fpd).to.have.property('context'); + expect(bid1.fpd.context).to.be.a('object'); + expect(bid1.fpd.context).to.have.property('pbAdSlot'); + expect(bid1.fpd.context.pbAdSlot).to.equal('/19968336/header-bid-tag-pbadslot-1'); + }; + bidRequestedSpy = sinon.spy(bidRequestedHandler); + + $$PREBID_GLOBAL$$.onEvent('beforeRequestBids', beforeRequestBidsSpy); + $$PREBID_GLOBAL$$.onEvent('bidRequested', bidRequestedSpy); + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [{ + code: '/19968336/header-bid-tag-0', + mediaTypes: { + banner: { + sizes: [[750, 350]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13122370 + } + }] + }, { + code: '/19968336/header-bid-tag-1', + mediaTypes: { + banner: { + sizes: [[750, 350]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 14122380 + } + }] + }], + bidsBackHandler: bidsBackSpy + }); + + sinon.assert.calledOnce(beforeRequestBidsSpy); + sinon.assert.calledOnce(bidRequestedSpy); + }); + + it('should not create a context property on adUnits if not added by handler', function () { + // verify adUnits passed to handler then alter the adUnits + beforeRequestBidsHandler = function beforeRequestBidsHandler(beforeRequestBidsAdUnits) { + expect(beforeRequestBidsAdUnits).to.be.a('array'); + expect(beforeRequestBidsAdUnits).to.have.lengthOf(1); + expect(beforeRequestBidsAdUnits[0]).to.be.a('object'); + // adUnit should not contain a context property yet + expect(beforeRequestBidsAdUnits[0]).to.not.have.property('context') + }; + beforeRequestBidsSpy = sinon.spy(beforeRequestBidsHandler); + + // use this handler to verify if the adUnits alterations were applied successfully by the beforeRequestBids handler + bidRequestedHandler = function bidRequestedHandler(bidRequest) { + expect(bidRequest).to.be.a('object'); + expect(bidRequest).to.have.property('bids'); + expect(bidRequest.bids).to.be.a('array'); + expect(bidRequest.bids).to.have.lengthOf(1); + const bid = bidRequest['bids'][0]; + expect(bid).to.be.a('object'); + expect(bid).to.not.have.property('context'); + }; + bidRequestedSpy = sinon.spy(bidRequestedHandler); + + $$PREBID_GLOBAL$$.onEvent('beforeRequestBids', beforeRequestBidsSpy); + $$PREBID_GLOBAL$$.onEvent('bidRequested', bidRequestedSpy); + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [{ + code: '/19968336/header-bid-tag-0', + mediaTypes: { + banner: { + sizes: [[750, 350]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13122370 + } + }] + }], + bidsBackHandler: bidsBackSpy + }); + + sinon.assert.calledOnce(beforeRequestBidsSpy); + sinon.assert.calledOnce(bidRequestedSpy); + }); + }); }); describe('offEvent', function () { @@ -2033,17 +2332,6 @@ describe('Unit: Prebid Module', function () { }); }); - describe('loadScript', function () { - it('should call adloader.loadScript', function () { - const tagSrc = ''; - const callback = Function; - const useCache = false; - - $$PREBID_GLOBAL$$.loadScript(tagSrc, callback, useCache); - assert.ok(adloader.loadScriptStub.calledWith(tagSrc, callback, useCache), 'called adloader.loadScript'); - }); - }); - describe('aliasBidder', function () { it('should call adapterManager.aliasBidder', function () { const aliasBidAdapterSpy = sinon.spy(adapterManager, 'aliasBidAdapter'); @@ -2080,14 +2368,12 @@ describe('Unit: Prebid Module', function () { const error = 'Invalid custom price value passed to `setPriceGranularity()`'; const badConfig = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, }, { - // missing min prop 'max': 18, - 'increment': 0.05, + // missing increment prop 'cap': true } ] @@ -2102,7 +2388,6 @@ describe('Unit: Prebid Module', function () { let customPriceBucket = configObj.getConfig('customPriceBucket'); const goodConfig = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, 'cap': true @@ -2270,13 +2555,9 @@ describe('Unit: Prebid Module', function () { }); describe('getHighestCpm', () => { - // it('returns an array of winning bid objects for each adUnit', () => { - // const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids(); - // expect(highestCpmBids.length).to.equal(2); - // expect(highestCpmBids[0]).to.deep.equal(auctionManager.getBidsReceived()[1]); - // expect(highestCpmBids[1]).to.deep.equal(auctionManager.getBidsReceived()[2]); - // }); - + after(() => { + resetAuction(); + }); it('returns an array containing the highest bid object for the given adUnitCode', function () { const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0'); expect(highestCpmBids.length).to.equal(1); @@ -2295,7 +2576,23 @@ describe('Unit: Prebid Module', function () { const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0'); expect(highestCpmBids.length).to.equal(0); - resetAuction(); + }); + + it('should not return rendered bid', function() { + let _bidsReceived = getBidResponses().slice(0, 3); + _bidsReceived[0].cpm = 12; + _bidsReceived[0].status = 'rendered'; + _bidsReceived[1].cpm = 9; + _bidsReceived[2].cpm = 11; + + _bidsReceived.forEach((bid) => { + bid.adUnitCode = '/19968336/header-bid-tag-0'; + }); + + auction.getBidsReceived = function() { return _bidsReceived }; + + const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0'); + expect(highestCpmBids[0]).to.deep.equal(auctionManager.getBidsReceived()[2]); }); }); diff --git a/test/spec/unit/secureCreatives_spec.js b/test/spec/unit/secureCreatives_spec.js index f0f26bf5653..97dfa119193 100644 --- a/test/spec/unit/secureCreatives_spec.js +++ b/test/spec/unit/secureCreatives_spec.js @@ -1,8 +1,8 @@ import { _sendAdToCreative -} from '../../../src/secureCreatives'; +} from '../../../src/secureCreatives.js'; import { expect } from 'chai'; -import * as utils from 'src/utils'; +import * as utils from 'src/utils.js'; describe('secureCreatives', () => { describe('_sendAdToCreative', () => { diff --git a/test/spec/url_spec.js b/test/spec/url_spec.js deleted file mode 100644 index 90047273043..00000000000 --- a/test/spec/url_spec.js +++ /dev/null @@ -1,94 +0,0 @@ -import {format, parse} from '../../src/url'; -import { expect } from 'chai'; - -describe('helpers.url', function () { - describe('parse()', function () { - let parsed; - - beforeEach(function () { - parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash'); - }); - - it('extracts the protocol', function () { - expect(parsed).to.have.property('protocol', 'http'); - }); - - it('extracts the hostname', function () { - expect(parsed).to.have.property('hostname', 'example.com'); - }); - - it('extracts the port', function () { - expect(parsed).to.have.property('port', 3000); - }); - - it('extracts the pathname', function () { - expect(parsed).to.have.property('pathname', '/pathname/'); - }); - - it('extracts the search query', function () { - expect(parsed).to.have.property('search'); - expect(parsed.search).to.eql({ - foo: 'xxx', - search: 'test', - bar: 'foo', - }); - }); - - it('extracts the hash', function () { - expect(parsed).to.have.property('hash', 'hash'); - }); - - it('extracts the host', function () { - expect(parsed).to.have.property('host', 'example.com:3000'); - }); - }); - - describe('parse(url, {noDecodeWholeURL: true})', function () { - let parsed; - - beforeEach(function () { - parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {noDecodeWholeURL: true}); - }); - - it('extracts the search query', function () { - expect(parsed).to.have.property('search'); - expect(parsed.search).to.eql({ - foo: 'bar', - search: 'test', - bar: 'foo%26foo%3Dxxx', - }); - }); - }); - - describe('format()', function () { - it('formats an object in to a URL', function () { - expect(format({ - protocol: 'http', - hostname: 'example.com', - port: 3000, - pathname: '/pathname/', - search: {foo: 'bar', search: 'test', bar: 'foo%26foo%3Dxxx'}, - hash: 'hash' - })).to.equal('http://example.com:3000/pathname/?foo=bar&search=test&bar=foo%26foo%3Dxxx#hash'); - }); - - it('will use defaults for missing properties', function () { - expect(format({ - hostname: 'example.com' - })).to.equal('http://example.com'); - }); - }); - - describe('parse(url, {decodeSearchAsString: true})', function () { - let parsed; - - beforeEach(function () { - parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {decodeSearchAsString: true}); - }); - - it('extracts the search query', function () { - expect(parsed).to.have.property('search'); - expect(parsed.search).to.equal('?search=test&foo=bar&bar=foo&foo=xxx'); - }); - }); -}); diff --git a/test/spec/userSync_spec.js b/test/spec/userSync_spec.js index f55fe13c528..2b68349ca31 100644 --- a/test/spec/userSync_spec.js +++ b/test/spec/userSync_spec.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { config } from 'src/config'; +import { config } from 'src/config.js'; // Use require since we need to be able to write to these vars const utils = require('../../src/utils'); -let { newUserSync } = require('../../src/userSync'); +let { newUserSync, USERSYNC_DEFAULT_CONFIG } = require('../../src/userSync'); describe('user sync', function () { let triggerPixelStub; @@ -34,6 +34,7 @@ describe('user sync', function () { }); beforeEach(function () { + config.setConfig({ userSync: USERSYNC_DEFAULT_CONFIG }); triggerPixelStub = sinon.stub(utils, 'triggerPixel'); logWarnStub = sinon.stub(utils, 'logWarn'); shuffleStub = sinon.stub(utils, 'shuffle').callsFake((array) => array.reverse()); @@ -47,6 +48,7 @@ describe('user sync', function () { shuffleStub.restore(); getUniqueIdentifierStrStub.restore(); insertUserSyncIframeStub.restore(); + config.resetConfig(); }); it('should register and fire a pixel URL', function () { @@ -85,21 +87,31 @@ describe('user sync', function () { }); it('should not register pixel URL since it is not supported', function () { - const userSync = newTestUserSync({pixelEnabled: false}); + const userSync = newTestUserSync({filterSettings: { + image: { + bidders: '*', + filter: 'exclude' + } + }}); userSync.registerSync('image', 'testBidder', 'http://example.com'); userSync.syncUsers(); expect(triggerPixelStub.getCall(0)).to.be.null; }); it('should register and load an iframe', function () { - const userSync = newTestUserSync({iframeEnabled: true}); + const userSync = newTestUserSync({filterSettings: { + iframe: { + bidders: '*', + filter: 'include' + } + }}); userSync.registerSync('iframe', 'testBidder', 'http://example.com/iframe'); userSync.syncUsers(); expect(insertUserSyncIframeStub.getCall(0).args[0]).to.equal('http://example.com/iframe'); }); it('should only trigger syncs once per page per bidder', function () { - const userSync = newTestUserSync({pixelEnabled: true}); + const userSync = newTestUserSync({ pixelEnabled: true }); userSync.registerSync('image', 'testBidder', 'http://example.com/1'); userSync.syncUsers(); userSync.registerSync('image', 'testBidder', 'http://example.com/2'); @@ -113,7 +125,7 @@ describe('user sync', function () { }); it('should not fire syncs if cookies are not supported', function () { - const userSync = newTestUserSync({pixelEnabled: true}, true); + const userSync = newTestUserSync({ pixelEnabled: true }, true); userSync.registerSync('image', 'testBidder', 'http://example.com'); userSync.syncUsers(); expect(triggerPixelStub.getCall(0)).to.be.null; @@ -132,14 +144,14 @@ describe('user sync', function () { userSync.triggerUserSyncs(); expect(syncUsersSpy.notCalled).to.be.true; // triggerUserSyncs should trigger syncUsers if enableOverride is on - userSync = newTestUserSync({enableOverride: true}); + userSync = newTestUserSync({ enableOverride: true }); syncUsersSpy = sinon.spy(userSync, 'syncUsers'); userSync.triggerUserSyncs(); expect(syncUsersSpy.called).to.be.true; }); it('should limit the number of syncs per bidder', function () { - const userSync = newTestUserSync({syncsPerBidder: 2}); + const userSync = newTestUserSync({ syncsPerBidder: 2 }); userSync.registerSync('image', 'testBidder', 'http://example.com/1'); userSync.registerSync('image', 'testBidder', 'http://example.com/2'); userSync.registerSync('image', 'testBidder', 'http://example.com/3'); @@ -151,8 +163,8 @@ describe('user sync', function () { expect(triggerPixelStub.getCall(2)).to.be.null; }); - it('should not limit the number of syncs per bidder when set to 0', function() { - const userSync = newTestUserSync({syncsPerBidder: 0}); + it('should not limit the number of syncs per bidder when set to 0', function () { + const userSync = newTestUserSync({ syncsPerBidder: 0 }); userSync.registerSync('image', 'testBidder', 'http://example.com/1'); userSync.registerSync('image', 'testBidder', 'http://example.com/2'); userSync.registerSync('image', 'testBidder', 'http://example.com/3'); @@ -182,7 +194,7 @@ describe('user sync', function () { }); it('should disable user sync', function () { - const userSync = newTestUserSync({syncEnabled: false}); + const userSync = newTestUserSync({ syncEnabled: false }); userSync.registerSync('pixel', 'testBidder', 'http://example.com'); expect(logWarnStub.getCall(0).args[0]).to.exist; userSync.syncUsers(); @@ -190,7 +202,12 @@ describe('user sync', function () { }); it('should only sync enabled bidders', function () { - const userSync = newTestUserSync({enabledBidders: ['testBidderA']}); + const userSync = newTestUserSync({filterSettings: { + image: { + bidders: ['testBidderA'], + filter: 'include' + } + }}); userSync.registerSync('image', 'testBidderA', 'http://example.com/1'); userSync.registerSync('image', 'testBidderB', 'http://example.com/2'); userSync.syncUsers(); @@ -201,9 +218,9 @@ describe('user sync', function () { it('should register config set after instantiation', function () { // start with userSync off - const userSync = newTestUserSync({syncEnabled: false}); + const userSync = newTestUserSync({ syncEnabled: false }); // turn it on with setConfig() - config.setConfig({userSync: {syncEnabled: true}}); + config.setConfig({ userSync: { syncEnabled: true } }); userSync.registerSync('image', 'testBidder', 'http://example.com'); userSync.syncUsers(); expect(triggerPixelStub.getCall(0)).to.not.be.null; @@ -359,9 +376,88 @@ describe('user sync', function () { expect(insertUserSyncIframeStub.getCall(0)).to.be.null; }); + it('should still allow default image syncs if setConfig only defined iframe', function () { + const userSync = newUserSync({ + config: config.getConfig('userSync'), + browserSupportsCookies: true + }); + + config.setConfig({ + userSync: { + filterSettings: { + iframe: { + bidders: ['bidderXYZ'], + filter: 'include' + } + } + } + }); + + userSync.registerSync('image', 'testBidder', 'http://example.com'); + userSync.registerSync('iframe', 'bidderXYZ', 'http://example.com/iframe'); + userSync.syncUsers(); + expect(triggerPixelStub.getCall(0)).to.not.be.null; + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com'); + expect(insertUserSyncIframeStub.getCall(0).args[0]).to.equal('http://example.com/iframe'); + }); + + it('should override default image syncs if setConfig used image filter', function () { + const userSync = newUserSync({ + config: config.getConfig('userSync'), + browserSupportsCookies: true + }); + + config.setConfig({ + userSync: { + filterSettings: { + image: { + bidders: ['bidderXYZ'], + filter: 'exclude' + } + } + } + }); + + userSync.registerSync('image', 'testBidder', 'http://example.com'); + userSync.registerSync('image', 'bidderXYZ', 'http://example.com/image-blocked'); + userSync.syncUsers(); + expect(triggerPixelStub.getCall(0)).to.not.be.null; + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com'); + expect(triggerPixelStub.getCall(1)).to.be.null; + }); + + it('should override default image syncs if setConfig used all filter', function() { + const userSync = newUserSync({ + config: config.getConfig('userSync'), + browserSupportsCookies: true + }); + + config.setConfig({ + userSync: { + filterSettings: { + all: { + bidders: ['bidderXYZ'], + filter: 'exclude' + } + } + } + }); + + userSync.registerSync('image', 'testBidder', 'http://example.com'); + userSync.registerSync('image', 'bidderXYZ', 'http://example.com/image-blocked'); + userSync.registerSync('iframe', 'testBidder', 'http://example.com/iframe'); + userSync.registerSync('iframe', 'bidderXYZ', 'http://example.com/iframe-blocked'); + userSync.syncUsers(); + expect(triggerPixelStub.getCall(0)).to.not.be.null; + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com'); + expect(triggerPixelStub.getCall(1)).to.be.null; + expect(insertUserSyncIframeStub.getCall(0).args[0]).to.equal('http://example.com/iframe'); + expect(insertUserSyncIframeStub.getCall(1)).to.be.null; + }); + describe('publicAPI', function () { - describe('canBidderRegisterSync', function() { - describe('with filterSettings', function() { + describe('canBidderRegisterSync', function () { + describe('with filterSettings', function () { it('should return false if filter settings does not allow it', function () { const userSync = newUserSync({ config: { @@ -397,14 +493,17 @@ describe('user sync', function () { expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(true); }); }); - describe('almost deprecated - without filterSettings', function() { - describe('enabledBidders contains testBidder', function() { + describe('almost deprecated - without filterSettings', function () { + describe('enabledBidders contains testBidder', function () { it('should return false if type is iframe and iframeEnabled is false', function () { const userSync = newUserSync({ config: { - pixelEnabled: true, - iframeEnabled: false, - enabledBidders: ['testBidder'], + filterSettings: { + iframe: { + bidders: ['testBidder'], + filter: 'exclude' + } + } } }); expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(false); @@ -424,9 +523,12 @@ describe('user sync', function () { it('should return false if type is image and pixelEnabled is false', function () { const userSync = newUserSync({ config: { - pixelEnabled: false, - iframeEnabled: true, - enabledBidders: ['testBidder'], + filterSettings: { + image: { + bidders: ['testBidder'], + filter: 'exclude' + } + } } }); expect(userSync.canBidderRegisterSync('image', 'testBidder')).to.equal(false); @@ -444,13 +546,20 @@ describe('user sync', function () { }); }); - describe('enabledBidders does not container testBidder', function() { - it('should return false since testBidder is not in enabledBidders', function() { + describe('enabledBidders does not container testBidder', function () { + it('should return false since testBidder is not in enabledBidders', function () { const userSync = newUserSync({ config: { - pixelEnabled: true, - iframeEnabled: true, - enabledBidders: ['otherTestBidder'], + filterSettings: { + image: { + bidders: ['otherTestBidder'], + filter: 'include' + }, + iframe: { + bidders: ['otherTestBidder'], + filter: 'include' + } + } } }); expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(false); diff --git a/test/spec/utils_spec.js b/test/spec/utils_spec.js old mode 100755 new mode 100644 index 5bee79d39c2..96df3cf996c --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -1,7 +1,7 @@ -import { getAdServerTargeting } from 'test/fixtures/fixtures'; +import { getAdServerTargeting } from 'test/fixtures/fixtures.js'; import { expect } from 'chai'; import CONSTANTS from 'src/constants.json'; -import * as utils from 'src/utils'; +import * as utils from 'src/utils.js'; var assert = require('assert'); @@ -18,24 +18,6 @@ describe('Utils', function () { type_array = 'Array', type_function = 'Function'; - describe('replaceTokenInString', function () { - it('should replace all given tokens in a String', function () { - var tokensToReplace = { - foo: 'bar', - zap: 'quux' - }; - - var output = utils.replaceTokenInString('hello %FOO%, I am %ZAP%', tokensToReplace, '%'); - assert.equal(output, 'hello bar, I am quux'); - }); - - it('should ignore tokens it does not see', function () { - var output = utils.replaceTokenInString('hello %FOO%', {}, '%'); - - assert.equal(output, 'hello %FOO%'); - }); - }); - describe('getBidIdParameter', function () { it('should return value of the key in input object', function () { var obj = { @@ -86,7 +68,7 @@ describe('Utils', function () { }; var output = utils.parseQueryStringParameters(obj); - var expectedResult = 'a=' + encodeURIComponent('1') + '&b=' + encodeURIComponent('2') + '&'; + var expectedResult = 'a=' + encodeURIComponent('1') + '&b=' + encodeURIComponent('2'); assert.equal(output, expectedResult); }); @@ -699,20 +681,6 @@ describe('Utils', function () { }); }); - describe('createContentToExecuteExtScriptInFriendlyFrame', function () { - it('should return empty string if url is not passed', function () { - var output = utils.createContentToExecuteExtScriptInFriendlyFrame(); - assert.equal(output, ''); - }); - - it('should have URL in returned value if url is passed', function () { - var url = 'https://abcd.com/service?a=1&b=2&c=3'; - var output = utils.createContentToExecuteExtScriptInFriendlyFrame(url); - var expected = ``; - assert.equal(output, expected); - }); - }); - describe('getDefinedParams', function () { it('builds an object consisting of defined params', function () { const adUnit = { @@ -793,93 +761,6 @@ describe('Utils', function () { }); }); - describe('getTopWindowLocation', function () { - let sandbox; - - beforeEach(function () { - sandbox = sinon.sandbox.create(); - }); - - afterEach(function () { - sandbox.restore(); - }); - - it('returns window.location if not in iFrame', function () { - sandbox.stub(utils.internal, 'getWindowLocation').returns({ - href: 'https://www.google.com/', - ancestorOrigins: {}, - origin: 'https://www.google.com', - protocol: 'https', - host: 'www.google.com', - hostname: 'www.google.com', - port: '', - pathname: '/', - search: '', - hash: '' - }); - let windowSelfAndTopObject = { self: 'is same as top' }; - sandbox.stub(utils.internal, 'getWindowSelf').returns( - windowSelfAndTopObject - ); - sandbox.stub(utils.internal, 'getWindowTop').returns( - windowSelfAndTopObject - ); - var topWindowLocation = utils.getTopWindowLocation(); - expect(topWindowLocation).to.be.a('object'); - expect(topWindowLocation.href).to.equal('https://www.google.com/'); - expect(topWindowLocation.protocol).to.equal('https'); - expect(topWindowLocation.hostname).to.equal('www.google.com'); - expect(topWindowLocation.port).to.equal(''); - expect(topWindowLocation.pathname).to.equal('/'); - expect(topWindowLocation.hash).to.equal(''); - expect(topWindowLocation.search).to.equal(''); - expect(topWindowLocation.host).to.equal('www.google.com'); - }); - - it('returns parsed dom string from ancestorOrigins if in iFrame & ancestorOrigins is populated', function () { - sandbox.stub(utils.internal, 'getWindowSelf').returns( - { self: 'is not same as top' } - ); - sandbox.stub(utils.internal, 'getWindowTop').returns( - { top: 'is not same as self' } - ); - sandbox.stub(utils.internal, 'getAncestorOrigins').returns('https://www.google.com/a/umich.edu/acs'); - var topWindowLocation = utils.getTopWindowLocation(); - expect(topWindowLocation).to.be.a('object'); - expect(topWindowLocation.pathname).to.equal('/a/umich.edu/acs'); - expect(topWindowLocation.href).to.equal('https://www.google.com/a/umich.edu/acs'); - expect(topWindowLocation.protocol).to.equal('https'); - expect(topWindowLocation.hostname).to.equal('www.google.com'); - expect(topWindowLocation.hash).to.equal(''); - expect(topWindowLocation.search).to.equal(''); - // note IE11 returns the default secure port, so we look for this alternate value as well in these tests - expect(topWindowLocation.port).to.be.oneOf([0, 443]); - expect(topWindowLocation.host).to.be.oneOf(['www.google.com', 'www.google.com:443']); - }); - - it('returns parsed referrer string if in iFrame but no ancestorOrigins', function () { - sandbox.stub(utils.internal, 'getWindowSelf').returns( - { self: 'is not same as top' } - ); - sandbox.stub(utils.internal, 'getWindowTop').returns( - { top: 'is not same as self' } - ); - sandbox.stub(utils.internal, 'getAncestorOrigins').returns(null); - sandbox.stub(utils.internal, 'getTopFrameReferrer').returns('https://www.example.com/'); - var topWindowLocation = utils.getTopWindowLocation(); - expect(topWindowLocation).to.be.a('object'); - expect(topWindowLocation.href).to.equal('https://www.example.com/'); - expect(topWindowLocation.protocol).to.equal('https'); - expect(topWindowLocation.hostname).to.equal('www.example.com'); - expect(topWindowLocation.pathname).to.equal('/'); - expect(topWindowLocation.hash).to.equal(''); - expect(topWindowLocation.search).to.equal(''); - // note IE11 returns the default secure port, so we look for this alternate value as well in these tests - expect(topWindowLocation.port).to.be.oneOf([0, 443]); - expect(topWindowLocation.host).to.be.oneOf(['www.example.com', 'www.example.com:443']); - }); - }); - describe('convertCamelToUnderscore', function () { it('returns converted string value using underscore syntax instead of camelCase', function () { let var1 = 'placementIdTest'; @@ -920,6 +801,98 @@ describe('Utils', function () { }); }); + describe('URL helpers', function () { + describe('parseUrl()', function () { + let parsed; + + beforeEach(function () { + parsed = utils.parseUrl('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash'); + }); + + it('extracts the protocol', function () { + expect(parsed).to.have.property('protocol', 'http'); + }); + + it('extracts the hostname', function () { + expect(parsed).to.have.property('hostname', 'example.com'); + }); + + it('extracts the port', function () { + expect(parsed).to.have.property('port', 3000); + }); + + it('extracts the pathname', function () { + expect(parsed).to.have.property('pathname', '/pathname/'); + }); + + it('extracts the search query', function () { + expect(parsed).to.have.property('search'); + expect(parsed.search).to.eql({ + foo: 'xxx', + search: 'test', + bar: 'foo', + }); + }); + + it('extracts the hash', function () { + expect(parsed).to.have.property('hash', 'hash'); + }); + + it('extracts the host', function () { + expect(parsed).to.have.property('host', 'example.com:3000'); + }); + }); + + describe('parseUrl(url, {noDecodeWholeURL: true})', function () { + let parsed; + + beforeEach(function () { + parsed = utils.parseUrl('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {noDecodeWholeURL: true}); + }); + + it('extracts the search query', function () { + expect(parsed).to.have.property('search'); + expect(parsed.search).to.eql({ + foo: 'bar', + search: 'test', + bar: 'foo%26foo%3Dxxx', + }); + }); + }); + + describe('buildUrl()', function () { + it('formats an object in to a URL', function () { + expect(utils.buildUrl({ + protocol: 'http', + hostname: 'example.com', + port: 3000, + pathname: '/pathname/', + search: {foo: 'bar', search: 'test', bar: 'foo%26foo%3Dxxx'}, + hash: 'hash' + })).to.equal('http://example.com:3000/pathname/?foo=bar&search=test&bar=foo%26foo%3Dxxx#hash'); + }); + + it('will use defaults for missing properties', function () { + expect(utils.buildUrl({ + hostname: 'example.com' + })).to.equal('http://example.com'); + }); + }); + + describe('parseUrl(url, {decodeSearchAsString: true})', function () { + let parsed; + + beforeEach(function () { + parsed = utils.parseUrl('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {decodeSearchAsString: true}); + }); + + it('extracts the search query', function () { + expect(parsed).to.have.property('search'); + expect(parsed.search).to.equal('?search=test&foo=bar&bar=foo&foo=xxx'); + }); + }); + }); + describe('transformBidderParamKeywords', function () { it('returns an array of objects when keyvalue is an array', function () { let keywords = { @@ -1009,4 +982,137 @@ describe('Utils', function () { }); }); }); + + describe('isSafariBrowser', function () { + let userAgentStub; + let userAgent; + + before(function () { + userAgentStub = sinon.stub(navigator, 'userAgent').get(function () { + return userAgent; + }); + }); + + after(function () { + userAgentStub.restore(); + }); + + it('properly detects safari', function () { + userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25'; + expect(utils.isSafariBrowser()).to.equal(true); + }); + it('does not flag Chrome on MacOS', function () { + userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'; + expect(utils.isSafariBrowser()).to.equal(false); + }); + it('does not flag Chrome iOS', function () { + userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/80.0.3987.95 Mobile/15E148 Safari/604.1'; + expect(utils.isSafariBrowser()).to.equal(false); + }); + it('does not flag Firefox iOS', function () { + userAgent = 'Mozilla/5.0 (iPhone; CPU OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/23.0 Mobile/15E148 Safari/605.1.15'; + expect(utils.isSafariBrowser()).to.equal(false); + }); + it('does not flag Windows Edge', function () { + userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43'; + expect(utils.isSafariBrowser()).to.equal(false); + }); + }); + + describe('mergeDeep', function() { + it('properly merge objects that share same property names', function() { + const object1 = { + propA: { + subPropA: 'abc' + } + }; + const object2 = { + propA: { + subPropB: 'def' + } + }; + + const resultWithoutMergeDeep = Object.assign({}, object1, object2); + expect(resultWithoutMergeDeep).to.deep.equal({ + propA: { + subPropB: 'def' + } + }); + + const resultWithMergeDeep = utils.mergeDeep({}, object1, object2); + expect(resultWithMergeDeep).to.deep.equal({ + propA: { + subPropA: 'abc', + subPropB: 'def' + } + }); + }); + + it('properly merge objects that have different depths', function() { + const object1 = { + depth0_A: { + depth1_A: { + depth2_A: 123 + } + } + }; + const object2 = { + depth0_A: { + depth1_A: { + depth2_B: { + depth3_A: { + depth4_A: 'def' + } + } + }, + depth1_B: 'abc' + } + }; + const object3 = { + depth0_B: 456 + }; + + const result = utils.mergeDeep({}, object1, object2, object3); + expect(result).to.deep.equal({ + depth0_A: { + depth1_A: { + depth2_A: 123, + depth2_B: { + depth3_A: { + depth4_A: 'def' + } + } + }, + depth1_B: 'abc' + }, + depth0_B: 456 + }); + }); + + it('properly merge objects with various property types', function() { + const object1 = { + depth0_A: { + depth1_A: ['a', 'b', 'c'], + depth1_B: 'abc', + depth1_C: 123 + } + }; + const object2 = { + depth0_A: { + depth1_A: ['d', 'e', 'f'], + depth1_D: true, + } + }; + + const result = utils.mergeDeep({}, object1, object2); + expect(result).to.deep.equal({ + depth0_A: { + depth1_A: ['a', 'b', 'c', 'd', 'e', 'f'], + depth1_B: 'abc', + depth1_C: 123, + depth1_D: true, + } + }); + }); + }); }); diff --git a/test/spec/videoCache_spec.js b/test/spec/videoCache_spec.js index fc4924187e8..7d706947416 100644 --- a/test/spec/videoCache_spec.js +++ b/test/spec/videoCache_spec.js @@ -1,7 +1,7 @@ -import 'mocha/mocha'; import chai from 'chai'; -import { getCacheUrl, store } from 'src/videoCache'; -import { config } from 'src/config'; +import { getCacheUrl, store } from 'src/videoCache.js'; +import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr.js'; const should = chai.should(); @@ -17,24 +17,11 @@ describe('The video cache', function () { } describe('when the cache server is unreachable', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (request) => requests.push(request); - }); - - afterEach(function () { - xhr.restore(); - }); - it('should execute the callback with an error when store() is called', function () { const callback = sinon.spy(); - store([ { vastUrl: 'my-mock-url.com' } ], callback); + store([{ vastUrl: 'my-mock-url.com' }], callback); - requests[0].respond(503, { + server.requests[0].respond(503, { 'Content-Type': 'plain/text', }, 'The server could not save anything at the moment.'); @@ -44,13 +31,7 @@ describe('The video cache', function () { }); describe('when the cache server is available', function () { - let xhr; - let requests; - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (request) => requests.push(request); config.setConfig({ cache: { url: 'https://prebid.adnxs.com/pbc/v1/cache' @@ -59,7 +40,6 @@ describe('The video cache', function () { }); afterEach(function () { - xhr.restore(); config.resetConfig(); }); @@ -139,7 +119,7 @@ describe('The video cache', function () { }]; store(bids, function () { }); - const request = requests[0]; + const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); @@ -159,10 +139,63 @@ describe('The video cache', function () { JSON.parse(request.requestBody).should.deep.equal(payload); }); + it('should include additional params in request payload should config.cache.vasttrack be true', () => { + config.setConfig({ + cache: { + url: 'https://prebid.adnxs.com/pbc/v1/cache', + vasttrack: true + } + }); + + const customKey1 = 'vasttrack_123'; + const customKey2 = 'vasttrack_abc'; + const vastXml1 = 'testvast1'; + const vastXml2 = 'testvast2'; + + const bids = [{ + vastXml: vastXml1, + ttl: 25, + customCacheKey: customKey1, + requestId: '12345abc', + bidder: 'appnexus' + }, { + vastXml: vastXml2, + ttl: 25, + customCacheKey: customKey2, + requestId: 'cba54321', + bidder: 'rubicon' + }]; + + store(bids, function () { }); + const request = server.requests[0]; + request.method.should.equal('POST'); + request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); + request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); + let payload = { + puts: [{ + type: 'xml', + value: vastXml1, + ttlseconds: 25, + key: customKey1, + bidid: '12345abc', + bidder: 'appnexus' + }, { + type: 'xml', + value: vastXml2, + ttlseconds: 25, + key: customKey2, + bidid: 'cba54321', + bidder: 'rubicon' + }] + }; + + JSON.parse(request.requestBody).should.deep.equal(payload); + }); + function assertRequestMade(bid, expectedValue) { - store([bid], function() { }); + store([bid], function () { }); - const request = requests[0]; + const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); @@ -178,8 +211,8 @@ describe('The video cache', function () { function fakeServerCall(bid, responseBody) { const callback = sinon.spy(); - store([ bid ], callback); - requests[0].respond( + store([bid], callback); + server.requests[0].respond( 200, { 'Content-Type': 'application/json', diff --git a/test/spec/video_spec.js b/test/spec/video_spec.js index dc6c11a7491..72a585049c3 100644 --- a/test/spec/video_spec.js +++ b/test/spec/video_spec.js @@ -1,4 +1,4 @@ -import { isValidVideoBid } from 'src/video'; +import { isValidVideoBid } from 'src/video.js'; describe('video.js', function () { it('validates valid instream bids', function () { diff --git a/test/test_index.js b/test/test_index.js index 206f1be1f52..53d75e36176 100644 --- a/test/test_index.js +++ b/test/test_index.js @@ -1,5 +1,6 @@ require('test/helpers/prebidGlobal.js'); require('test/mocks/adloaderStub.js'); +require('test/mocks/xhr.js'); var testsContext = require.context('.', true, /_spec$/); testsContext.keys().forEach(testsContext); diff --git a/wdio.conf.js b/wdio.conf.js index 9e816bef24b..dd94e82cf90 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -9,8 +9,14 @@ function getCapabilities() { return platformMap[os]; } - // remove the IE11 browser from functional tests + // only Edge 16, Chrome 74 & Firefox 66 run as part of functional tests + // rest of the browsers are discarded. delete browsers['bs_ie_11_windows_10']; + delete browsers['bs_edge_17_windows_10']; + delete browsers['bs_chrome_75_windows_10']; + delete browsers['bs_firefox_67_windows_10']; + delete browsers['bs_safari_11_mac_high_sierra']; + delete browsers['bs_safari_12_mac_mojave']; let capabilities = [] Object.keys(browsers).forEach(key => { From 2250e89f9dfc0c8d37f2a460dba898105184693e Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Tue, 21 Apr 2020 16:17:18 +0300 Subject: [PATCH 09/14] New method is introduced to process a bid and return dynamic CPM data --- modules/konduitWrapper.js | 204 +++++++++++++++++------ modules/konduitWrapper.md | 137 +++++++++++---- test/spec/modules/konduitWrapper_spec.js | 143 +++++++++++----- 3 files changed, 358 insertions(+), 126 deletions(-) diff --git a/modules/konduitWrapper.js b/modules/konduitWrapper.js index 33bc45f7566..3a86868fee5 100644 --- a/modules/konduitWrapper.js +++ b/modules/konduitWrapper.js @@ -2,87 +2,193 @@ import { registerVideoSupport } from '../src/adServerManager.js'; import { targeting } from '../src/targeting.js'; import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; +import { ajaxBuilder } from '../src/ajax.js'; +import { getPriceBucketString } from '../src/cpmBucketManager.js'; +import { getPriceByGranularity } from '../src/auction.js'; + +const SERVER_PROTOCOL = 'https'; +const SERVER_HOST = 'p.konduit.me'; const MODULE_NAME = 'Konduit'; +const KONDUIT_ID_CONFIG = 'konduit.konduitId'; + +export const errorMessages = { + NO_KONDUIT_ID: 'A konduitId param is required to be in configs', + NO_BID: 'A bid was not found', + CACHE_FAILURE: 'A bid was not cached', +}; + + +// This function is copy from prebid core +function formatQS(query) { + return Object + .keys(query) + .map(k => Array.isArray(query[k]) + ? query[k].map(v => `${k}[]=${v}`).join('&') + : `${k}=${query[k]}`) + .join('&'); +} + +// This function is copy from prebid core +function buildUrl(obj) { + return (obj.protocol || 'http') + '://' + + (obj.host || + obj.hostname + (obj.port ? `:${obj.port}` : '')) + + (obj.pathname || '') + + (obj.search ? `?${formatQS(obj.search || '')}` : '') + + (obj.hash ? `#${obj.hash}` : ''); +} + function addLogLabel(args) { args = [].slice.call(args); args.unshift(`${MODULE_NAME}: `); return args; } -export function logInfo() { +function logInfo() { utils.logInfo(...addLogLabel(arguments)); } -export function logError() { +function logError() { utils.logError(...addLogLabel(arguments)); } -export function buildVastUrl(options) { - if (!options.params || !options.params.konduit_id) { - logError(`'konduit_id' parameter is required for $$PREBID_GLOBAL$$.adServers.konduit.buildVastUrl function`); - - return null; +function sendRequest ({ host = SERVER_HOST, protocol = SERVER_PROTOCOL, method = 'GET', path, payload, callbacks, timeout }) { + const formattedUrlOptions = { + protocol: protocol, + hostname: host, + pathname: path, + }; + if (method === 'GET') { + formattedUrlOptions.search = payload; } - const bid = options.bid || targeting.getWinningBids()[0]; + let konduitAnalyticsRequestUrl = buildUrl(formattedUrlOptions); + const ajax = ajaxBuilder(timeout); + + ajax( + konduitAnalyticsRequestUrl, + callbacks, + method === 'POST' ? JSON.stringify(payload) : null, + { + contentType: 'application/json', + method, + withCredentials: true + } + ); +} - if (!bid) { - logError('Bid is not provided or not found'); +/** + * This function accepts an object with bid and tries to cache it while generating konduit_cache_key for it. + * In addition, it returns a list with updated bid objects where k_cpm key is added + * @param {Object} options + * @param {Object} [options.bid] - winner bid from publisher + * @param {string} [options.adUnitCode] - to look for winner bid + * @param {string} [options.timeout] - timeout for bidsProcessor request + * @param {function} [options.callback] - callback will be called in the end of the request + */ +export function processBids(options = {}) { + const konduitId = config.getConfig(KONDUIT_ID_CONFIG); + options = options || {}; + + if (!konduitId) { + logError(errorMessages.NO_KONDUIT_ID); + + if (options.callback) { + options.callback(new Error(errorMessages.NO_KONDUIT_ID)); + } return null; } - logInfo('The following bid will be wrapped: ', bid); + const bid = options.bid || targeting.getWinningBids(options.adUnitCode)[0]; - const queryParams = {}; + if (!bid) { + logError(errorMessages.NO_BID); - const vastUrl = obtainVastUrl(bid); + if (options.callback) { + options.callback(new Error(errorMessages.NO_BID)); + } - if (vastUrl) { - queryParams.konduit_id = options.params.konduit_id; - queryParams.konduit_header_bidding = 1; - queryParams.konduit_url = vastUrl; - } else { - logError('No VAST url found in the bid'); + return null; } - let resultingUrl = null; + const priceGranularity = config.getConfig('priceGranularity'); - if (queryParams.konduit_url) { - resultingUrl = utils.buildUrl({ - protocol: 'https', - host: 'p.konduit.me', - pathname: '/api/vastProxy', - search: queryParams - }); + bid.kCpm = bid.cpm; - logInfo(`Konduit wrapped VAST url: ${resultingUrl}`); + if (!bid.adserverTargeting) { + bid.adserverTargeting = {}; } - return resultingUrl; -} - -function obtainVastUrl(bid) { - const vastUrl = bid && bid.vastUrl; - - if (vastUrl) { - logInfo(`VAST url found in the bid - ${vastUrl}`); - - return encodeURIComponent(vastUrl); - } - - const cacheUrl = config.getConfig('cache.url'); - if (cacheUrl) { - const composedCacheUrl = `${cacheUrl}?uuid=${bid.videoCacheKey}`; - - logInfo(`VAST url is taken from cache.url: ${composedCacheUrl}`); - - return encodeURIComponent(composedCacheUrl); - } + bid.adserverTargeting.k_cpm = getPriceByGranularity(priceGranularity)(bid); + + const bidsToProcess = [{ + auctionId: bid.auctionId, + vastUrl: bid.vastUrl, + bidderCode: bid.bidderCode, + creativeId: bid.creativeId, + adUnitCode: bid.adUnitCode, + cpm: bid.cpm, + currency: bid.currency, + }]; + + sendRequest({ + method: 'POST', + path: '/api/bidsProcessor', + timeout: options.timeout || 1000, + payload: { + clientId: konduitId, + bids: bidsToProcess, + }, + callbacks: { + success: (data) => { + let error = null; + logInfo('Bids processed successfully ', data); + try { + const { kCpmData, cacheData } = JSON.parse(data); + const processedBidKey = `${bid.bidderCode}:${bid.creativeId}`; + + if (!utils.isEmpty(cacheData)) { + bid.adserverTargeting.konduit_id = konduitId; + } else { + error = new Error(errorMessages.CACHE_FAILURE); + } + + if (utils.isNumber(kCpmData[processedBidKey])) { + bid.kCpm = kCpmData[processedBidKey]; + const priceStringsObj = getPriceBucketString( + bid.kCpm, + config.getConfig('customPriceBucket'), + config.getConfig('currency.granularityMultiplier') + ); + bid.adserverTargeting.k_cpm = priceStringsObj.custom || priceStringsObj[priceGranularity] || priceStringsObj.med; + } + + if (utils.isStr(cacheData[processedBidKey])) { + bid.konduitCacheKey = cacheData[processedBidKey]; + bid.adserverTargeting.konduit_cache_key = cacheData[processedBidKey]; + } + } catch (err) { + error = err; + logError('Error parsing JSON response for bidsProcessor data: ', err) + } + + if (options.callback) { + options.callback(error, [bid]); + } + }, + error: (error) => { + logError('Bid was not processed successfully ', error); + if (options.callback) { + options.callback(utils.isStr(error) ? new Error(error) : error, [bid]); + } + } + } + }); } registerVideoSupport('konduit', { - buildVastUrl: buildVastUrl, + processBids: processBids, }); diff --git a/modules/konduitWrapper.md b/modules/konduitWrapper.md index adbb50487da..3097801ffab 100644 --- a/modules/konduitWrapper.md +++ b/modules/konduitWrapper.md @@ -1,11 +1,84 @@ -## Konduit video tags wrapper +# Overview + +``` +Module Name: Konduit Accelerate +Module Type: Video Module +Maintainer: support@konduit.me +``` + +# Description + +Konduit Wrapper is a prebid module that allows +- wrapping a bid response so that it is processed through Konduit platform +- obtaining a historical performance indicator for a bid + + +# Configuration + +## Building Prebid with the Konduit wrapper function + +Your Prebid build must include the **konduitWrapper** module. Follow the build instructions for Prebid as explained in the top level README.md file of the Prebid source tree. + +ex: $ gulp build --modules=konduitWrapper -Konduit Wrapper is a prebid module to generate Konduit wrapped VAST tag URLs for a provided bid or a winning bid. +## Prebid related configuration -### Setup +Konduit module should be used with a valid Konduit identifier. +```javascript +pbjs.setConfig({ + konduit: { + konduitId: your_konduit_id, + } +}); +``` + +Please contact support@konduit.me for assistance. + + +## GAM related configuration + +It is important to configure your GAM line items. +Please contact support@konduit.me for assistance. + +In most cases it would require only Creative VAST URL update with the following URL: +``` +https://p.konduit.me/api/vastProxy?konduit_hb=1&konduit_hb_awarded=1&konduit_cache_key=%%PATTERN:konduit_cache_key%%&konduit_id=%%PATTERN:konduit_id%% ``` + + +# Usage + +Konduit module contains a single function that accepts an `options` parameter. + +The `options` parameter can include: +* `bid` - prebid object with VAST url that should be cached (if not passed first winning bid from `auctionManager.getWinningBids()` will be used) +* `adUnitCode` - adUnitCode where a winner bid can be found +* `timeout` - max time to wait for Konduit response with cache key and kCpm data +* `callback` - callback function is called once Konduit cache data for the bid. Arguments of this function are - `error` and `bids` (error should be `null` if Konduit request is successful) + +The function adds two parameters into the passed bid - kCpm and konduitCacheKey. Additionally `processBids` updates bid's `adserverTargeting` with `k_cpm`, `konduti_cache_key` and `konduit_id` fields. + + +```javascript +pbjs.requestBids({ + bidsBackHandler: function (bids) { + pbjs.adServers.konduit.processBids({ + callback: function (error, bids) { + var videoUrl = pbjs.adServers.dfp.buildVideoUrl({ + ... + }); + } + }); + } +}) +``` + + +# Sample code + +```javascript var videoAdUnit = [{ code: 'videoAd', mediaTypes: { @@ -28,46 +101,48 @@ var videoAdUnit = [{ pbjs.que.push(function(){ pbjs.addAdUnits(videoAdUnit); + pbjs.setConfig({ + konduit: { + konduitId: 'your_konduit_id', + }, + }); + pbjs.requestBids({ - timeout : 700, bidsBackHandler : function(bids) { var winnerBid = pbjs.getHighestCpmBids('videoAd')[0]; - var vastTagUrl = pbjs.adServers.konduit.buildVastUrl({ - bid: winnerBid, // just in case if you want to pass your bid - params: { - konduit_id: 'your_konduit_id' + pbjs.adServers.konduit.processBids({ + bid: winnerBid, + adUnitCode: videoAdUnit[0].code, + timeout: 2000, + callback: function (error, processedBids) { + var vastTagUrl = pbjs.adServers.dfp.buildVideoUrl({ + adUnit: videoAdUnit, + params: { + iu: '', + output: 'vast', + }, + }); + + invokeVideoPlayer(vastTagUrl); } }); - - invokeVideoPlayer(vastTagUrl); } }); }); function invokeVideoPlayer(vastTagUrl) { - videojs("video_player_id").ready(function() { - this.vastClient({ - adTagUrl: vastTagUrl, - playAdAlways: true, - verbosity: 4, - autoplay: true - }); - - this.play(); + videojs("video_player_id").ready(function() { + this.vastClient({ + adTagUrl: vastTagUrl, + playAdAlways: true, + verbosity: 4, + autoplay: true }); - } -``` - -Function parameters: -* `bid` - prebid object with VAST url that should be wrapped (if not passed first winning bid from `auctionManager.getWinningBids()` is used) -* `konduit_id` - your personal unique Konduit identifier (required) - -The function returns a Konduit wrapped VAST url if valid parameters are passed in. If some of the parameters are not passed or are invalid the function returns 'null' along with related error logs providing more details. + this.play(); + }); +} +``` -### Building Prebid with the Konduit wrapper function -Your Prebid build must include the **konduitWrapper** module. Follow the build instructions for Prebid as explained in the top level README.md file of the Prebid source tree. - -ex: $ gulp build --modules=konduitWrapper diff --git a/test/spec/modules/konduitWrapper_spec.js b/test/spec/modules/konduitWrapper_spec.js index 4a0c627e885..d70cb7a6c60 100644 --- a/test/spec/modules/konduitWrapper_spec.js +++ b/test/spec/modules/konduitWrapper_spec.js @@ -1,72 +1,123 @@ import { expect } from 'chai'; -import parse from 'url-parse'; -import { buildVastUrl } from 'modules/konduitWrapper.js'; -import { parseQS } from 'src/utils.js'; +import { processBids, errorMessages } from 'modules/konduitWrapper.js'; import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr.js'; describe('The Konduit vast wrapper module', function () { - it('should make a wrapped request url when `bid` passed', function () { - const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + const konduitId = 'test'; + beforeEach(function() { + config.setConfig({ konduit: { konduitId } }); + }); - const url = parse(buildVastUrl({ - bid, - params: { 'konduit_id': 'testId' }, - })); + describe('processBids function', () => { + it(`should make a correct processBids request and add kCpm and konduitCacheKey + to the passed bids and to the adserverTargeting object`, function () { + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); - expect(url.protocol).to.equal('https:'); - expect(url.host).to.equal('p.konduit.me'); + server.respondWith(JSON.stringify({ + kCpmData: { [`${bid.bidderCode}:${bid.creativeId}`]: bid.cpm }, + cacheData: { [`${bid.bidderCode}:${bid.creativeId}`]: 'test_cache_key' }, + })); - const queryParams = parseQS(url.query); - expect(queryParams).to.have.property('konduit_url', encodeURIComponent('http://some-vast-url.com')); - expect(queryParams).to.have.property('konduit_header_bidding', '1'); - expect(queryParams).to.have.property('konduit_id', 'testId'); - }); + processBids({ bid }); + server.respond(); - it('should return null when no `konduit_id` (required param) passed', function () { - const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + expect(server.requests.length).to.equal(1); - const url = buildVastUrl({ bid }); + const requestBody = JSON.parse(server.requests[0].requestBody); - expect(url).to.equal(null); - }); + expect(requestBody.clientId).to.equal(konduitId); - it('should return null when either bid or adUnit is not passed', function () { - const url = buildVastUrl({ params: { 'konduit_id': 'testId' } }); + expect(bid.konduitCacheKey).to.equal('test_cache_key'); + expect(bid.kCpm).to.equal(bid.cpm); - expect(url).to.equal(null); - }); + expect(bid.adserverTargeting).to.be.an('object'); + + expect(bid.adserverTargeting.k_cpm).to.equal(bid.pbCg || bid.pbAg); + expect(bid.adserverTargeting.konduit_cache_key).to.equal('test_cache_key'); + expect(bid.adserverTargeting.konduit_id).to.equal(konduitId); + }); + + it(`should call callback with error object in arguments if cacheData is empty in the response`, function () { + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + + server.respondWith(JSON.stringify({ + kCpmData: { [`${bid.bidderCode}:${bid.creativeId}`]: bid.cpm }, + cacheData: {}, + })); + const callback = sinon.spy(); + processBids({ bid, callback }); + server.respond(); - it('should return null when bid does not contain vastUrl', function () { - const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + expect(server.requests.length).to.equal(1); - delete bid.vastUrl; + const requestBody = JSON.parse(server.requests[0].requestBody); - const url = buildVastUrl({ - bid, - params: { 'konduit_id': 'testId' }, + expect(requestBody.clientId).to.equal(konduitId); + + expect(bid.konduitCacheKey).to.be.undefined; + expect(bid.kCpm).to.equal(bid.cpm); + + expect(bid.adserverTargeting.k_cpm).to.equal(bid.pbCg || bid.pbAg); + expect(bid.adserverTargeting.konduit_cache_key).to.be.undefined; + expect(bid.adserverTargeting.konduit_id).to.be.undefined; + + expect(callback.firstCall.args[0]).to.be.an('error'); }); - expect(url).to.equal(null); - }); + it('should call callback if processBids request is sent successfully', function () { + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + server.respondWith(JSON.stringify({ key: 'test' })); + const callback = sinon.spy(); + processBids({ + bid, + callback + }); + server.respond(); + + expect(callback.calledOnce).to.be.true; + }); - it('should return wrapped vastUrl based on cached url in params', function () { - config.setConfig({ cache: { url: 'https://cached.url.com' } }); - const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + it('should call callback with error object in arguments if processBids request is failed', function () { + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + const callback = sinon.spy(); + processBids({ + bid, + callback + }); + server.respond(); + + expect(callback.calledOnce).to.be.true; + expect(callback.firstCall.args[0]).to.be.an('error'); + }); - delete bid.vastUrl; + it('should call callback with error object in arguments if no konduitId in configs', function () { + config.setConfig({ konduit: { konduitId: null } }); - const expectedUrl = encodeURIComponent(`https://cached.url.com?uuid=${bid.videoCacheKey}`); + const bid = createBid(10, 'video1', 15, '10.00_15s', '123', '395'); + const callback = sinon.spy(); + processBids({ + bid, + callback + }); - const url = parse(buildVastUrl({ - bid, - params: { 'konduit_id': 'testId' }, - })); - const queryParams = parseQS(url.query); + expect(callback.calledOnce).to.be.true; + expect(callback.firstCall.args[0]).to.be.an('error'); + expect(callback.firstCall.args[0].message).to.equal(errorMessages.NO_KONDUIT_ID); + }); - expect(queryParams).to.have.property('konduit_url', expectedUrl); + it('should call callback with error object in arguments if no bids found', function () { + const callback = sinon.spy(); + processBids({ + bid: null, + callback + }); - config.resetConfig(); + expect(callback.calledOnce).to.be.true; + expect(callback.firstCall.args[0]).to.be.an('error'); + expect(callback.firstCall.args[0].message).to.equal(errorMessages.NO_BID); + }); }); }); @@ -103,7 +154,7 @@ function createBid(cpm, adUnitCode, durationBucket, priceIndustryDuration, uuid, 'pbLg': '5.00', 'pbMg': '5.00', 'pbHg': '5.00', - 'pbAg': '5.00', + 'pbAg': `${cpm}.00`, 'pbDg': '5.00', 'pbCg': '', 'size': '640x360', From 048c28a3c13e91bb46374cf93ecceb3927fd5d70 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Tue, 21 Apr 2020 16:21:03 +0300 Subject: [PATCH 10/14] New Konduit Analytics adapter responsible for client auction stats collection --- modules/konduitAnalyticsAdapter.js | 225 ++++++++++++++++++ modules/konduitAnalyticsAdapter.md | 26 ++ .../modules/konduitAnalyticsAdapter_spec.js | 126 ++++++++++ 3 files changed, 377 insertions(+) create mode 100644 modules/konduitAnalyticsAdapter.js create mode 100644 modules/konduitAnalyticsAdapter.md create mode 100644 test/spec/modules/konduitAnalyticsAdapter_spec.js diff --git a/modules/konduitAnalyticsAdapter.js b/modules/konduitAnalyticsAdapter.js new file mode 100644 index 00000000000..49b7af1996b --- /dev/null +++ b/modules/konduitAnalyticsAdapter.js @@ -0,0 +1,225 @@ +import { ajax } from '../src/ajax.js'; +import adapter from '../src/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; +import { targeting } from '../src/targeting.js'; +import { config } from '../src/config.js'; +import CONSTANTS from '../src/constants.json'; + +const TRACKER_HOST = 'tracker.konduit.me'; + +const analyticsType = 'endpoint'; + +const eventDataComposerMap = { + [CONSTANTS.EVENTS.AUCTION_INIT]: obtainAuctionInfo, + [CONSTANTS.EVENTS.AUCTION_END]: obtainAuctionInfo, + [CONSTANTS.EVENTS.BID_REQUESTED]: obtainBidRequestsInfo, + [CONSTANTS.EVENTS.BID_TIMEOUT]: obtainBidTimeoutInfo, + [CONSTANTS.EVENTS.BID_RESPONSE]: obtainBidResponseInfo, + [CONSTANTS.EVENTS.BID_WON]: obtainWinnerBidInfo, + [CONSTANTS.EVENTS.NO_BID]: obtainNoBidInfo, +}; + +// This function is copy from prebid core +function formatQS(query) { + return Object + .keys(query) + .map(k => Array.isArray(query[k]) + ? query[k].map(v => `${k}[]=${v}`).join('&') + : `${k}=${query[k]}`) + .join('&'); +} + +// This function is copy from prebid core +function buildUrl(obj) { + return (obj.protocol || 'http') + '://' + + (obj.host || + obj.hostname + (obj.port ? `:${obj.port}` : '')) + + (obj.pathname || '') + + (obj.search ? `?${formatQS(obj.search || '')}` : '') + + (obj.hash ? `#${obj.hash}` : ''); +} + +const getWinnerBidFromAggregatedEvents = () => { + return konduitAnalyticsAdapter.context.aggregatedEvents + .filter(evt => evt.eventType === CONSTANTS.EVENTS.BID_WON)[0]; +}; + +const isWinnerBidDetected = () => { + return !!getWinnerBidFromAggregatedEvents(); +}; +const isWinnerBidExist = () => { + return !!targeting.getWinningBids()[0]; +}; + +const konduitAnalyticsAdapter = Object.assign( + adapter({ analyticsType }), + { + track ({ eventType, args }) { + if (CONSTANTS.EVENTS.AUCTION_INIT === eventType) { + konduitAnalyticsAdapter.context.aggregatedEvents.splice(0); + } + + if (eventDataComposerMap[eventType]) { + konduitAnalyticsAdapter.context.aggregatedEvents.push({ + eventType, + data: eventDataComposerMap[eventType](args), + }); + } + + if (eventType === CONSTANTS.EVENTS.AUCTION_END) { + if (!isWinnerBidDetected() && isWinnerBidExist()) { + const bidWonData = eventDataComposerMap[CONSTANTS.EVENTS.BID_WON](targeting.getWinningBids()[0]); + + konduitAnalyticsAdapter.context.aggregatedEvents.push({ + eventType: CONSTANTS.EVENTS.BID_WON, + data: bidWonData, + }); + } + sendRequest({ method: 'POST', path: '/analytics-initial-event', payload: composeRequestPayload() }); + } + } + } +); + +function obtainBidTimeoutInfo (args) { + return args.map(item => item.bidder).filter(utils.uniques); +} + +function obtainAuctionInfo (auction) { + return { + auctionId: auction.auctionId, + timestamp: auction.timestamp, + auctionEnd: auction.auctionEnd, + auctionStatus: auction.auctionStatus, + adUnitCodes: auction.adUnitCodes, + labels: auction.labels, + timeout: auction.timeout + }; +} + +function obtainBidRequestsInfo (bidRequests) { + return { + bidderCode: bidRequests.bidderCode, + time: bidRequests.start, + bids: bidRequests.bids.map(function (bid) { + return { + transactionId: bid.transactionId, + adUnitCode: bid.adUnitCode, + bidId: bid.bidId, + startTime: bid.startTime, + sizes: utils.parseSizesInput(bid.sizes).toString(), + params: bid.params + }; + }), + }; +} + +function obtainBidResponseInfo (bidResponse) { + return { + bidderCode: bidResponse.bidder, + transactionId: bidResponse.transactionId, + adUnitCode: bidResponse.adUnitCode, + statusMessage: bidResponse.statusMessage, + mediaType: bidResponse.mediaType, + renderedSize: bidResponse.size, + cpm: bidResponse.cpm, + currency: bidResponse.currency, + netRevenue: bidResponse.netRevenue, + timeToRespond: bidResponse.timeToRespond, + bidId: bidResponse.bidId, + requestId: bidResponse.requestId, + creativeId: bidResponse.creativeId + }; +} + +function obtainNoBidInfo (bidResponse) { + return { + bidderCode: bidResponse.bidder, + transactionId: bidResponse.transactionId, + adUnitCode: bidResponse.adUnitCode, + bidId: bidResponse.bidId, + }; +} + +function obtainWinnerBidInfo (bidResponse) { + return { + adId: bidResponse.adId, + bidderCode: bidResponse.bidder, + adUnitCode: bidResponse.adUnitCode, + statusMessage: bidResponse.statusMessage, + mediaType: bidResponse.mediaType, + renderedSize: bidResponse.size, + cpm: bidResponse.cpm, + currency: bidResponse.currency, + netRevenue: bidResponse.netRevenue, + timeToRespond: bidResponse.timeToRespond, + bidId: bidResponse.requestId, + dealId: bidResponse.dealId, + status: bidResponse.status, + creativeId: bidResponse.creativeId + }; +} + +function composeRequestPayload () { + const konduitId = config.getConfig('konduit.konduitId'); + const { width, height } = window.screen; + + return { + konduitId, + prebidVersion: $$PREBID_GLOBAL$$.version, + environment: { + screen: { width, height }, + language: navigator.language, + }, + events: konduitAnalyticsAdapter.context.aggregatedEvents, + }; +} + +function sendRequest ({ host = TRACKER_HOST, method, path, payload }) { + const formattedUrlOptions = { + protocol: 'https', + hostname: host, + pathname: path, + }; + if (method === 'GET') { + formattedUrlOptions.search = payload; + } + + let konduitAnalyticsRequestUrl = buildUrl(formattedUrlOptions); + + ajax( + konduitAnalyticsRequestUrl, + undefined, + method === 'POST' ? JSON.stringify(payload) : null, + { + contentType: 'application/json', + method, + withCredentials: true + } + ); +} + +konduitAnalyticsAdapter.originEnableAnalytics = konduitAnalyticsAdapter.enableAnalytics; + +konduitAnalyticsAdapter.enableAnalytics = function (analyticsConfig) { + const konduitId = config.getConfig('konduit.konduitId'); + + if (!konduitId) { + utils.logError('A konduitId in config is required to use konduitAnalyticsAdapter'); + return; + } + + konduitAnalyticsAdapter.context = { + aggregatedEvents: [], + }; + + konduitAnalyticsAdapter.originEnableAnalytics(analyticsConfig); +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: konduitAnalyticsAdapter, + code: 'konduit' +}); + +export default konduitAnalyticsAdapter; diff --git a/modules/konduitAnalyticsAdapter.md b/modules/konduitAnalyticsAdapter.md new file mode 100644 index 00000000000..c781d007ff1 --- /dev/null +++ b/modules/konduitAnalyticsAdapter.md @@ -0,0 +1,26 @@ +# Overview + +``` +Module Name: Konduit Analytics Adapter +Module Type: Analytics Adapter +Maintainer: TBD +``` + +# Description + +Analytics adapter for Konduit. + +# Test Parameters + +```javascript +pbjs.que.push(function () { + pbjs.setConfig({ + konduit: { + konduitId: 'your_konduit_id', + } + }); + pbjs.enableAnalytics({ + provider: 'konduit' + }) +}); +``` diff --git a/test/spec/modules/konduitAnalyticsAdapter_spec.js b/test/spec/modules/konduitAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..75fc8488b8e --- /dev/null +++ b/test/spec/modules/konduitAnalyticsAdapter_spec.js @@ -0,0 +1,126 @@ +import konduitAnalyticsAdapter from 'modules/konduitAnalyticsAdapter'; +import { expect } from 'chai'; +import { config } from '../../../src/config.js'; +import { server } from 'test/mocks/xhr.js'; +let events = require('src/events'); +let adapterManager = require('src/adapterManager').default; +let CONSTANTS = require('src/constants.json'); + +const eventsData = { + [CONSTANTS.EVENTS.AUCTION_INIT]: { + 'auctionId': 'test_auction_id', + 'timestamp': Date.now(), + 'auctionStatus': 'inProgress', + 'adUnitCodes': ['video-test'], + 'timeout': 700 + }, + [CONSTANTS.EVENTS.BID_REQUESTED]: { + 'bidderCode': 'test_bidder_code', + 'time': Date.now(), + 'bids': [{ + 'transactionId': 'test_transaction_id', + 'adUnitCode': 'video-test', + 'bidId': 'test_bid_id', + 'sizes': '640x480', + 'params': { 'testParam': 'test_param' } + }] + }, + [CONSTANTS.EVENTS.NO_BID]: { + 'bidderCode': 'test_bidder_code2', + 'transactionId': 'test_transaction_id', + 'adUnitCode': 'video-test', + 'bidId': 'test_bid_id' + }, + [CONSTANTS.EVENTS.BID_RESPONSE]: { + 'bidderCode': 'test_bidder_code', + 'adUnitCode': 'video-test', + 'statusMessage': 'Bid available', + 'mediaType': 'video', + 'renderedSize': '640x480', + 'cpm': 0.5, + 'currency': 'USD', + 'netRevenue': true, + 'timeToRespond': 124, + 'requestId': 'test_request_id', + 'creativeId': 144876543 + }, + [CONSTANTS.EVENTS.AUCTION_END]: { + 'auctionId': 'test_auction_id', + 'timestamp': Date.now(), + 'auctionEnd': Date.now() + 400, + 'auctionStatus': 'completed', + 'adUnitCodes': ['video-test'], + 'timeout': 700 + }, + [CONSTANTS.EVENTS.BID_WON]: { + 'bidderCode': 'test_bidder_code', + 'adUnitCode': 'video-test', + 'statusMessage': 'Bid available', + 'mediaType': 'video', + 'renderedSize': '640x480', + 'cpm': 0.5, + 'currency': 'USD', + 'netRevenue': true, + 'timeToRespond': 124, + 'requestId': 'test_request_id', + 'creativeId': 144876543 + }, +}; + +describe(`Konduit Analytics Adapter`, () => { + const konduitId = 'test'; + + beforeEach(function () { + sinon.spy(konduitAnalyticsAdapter, 'track'); + sinon.stub(events, 'getEvents').returns([]); + config.setConfig({ konduit: { konduitId } }); + }); + + afterEach(function () { + events.getEvents.restore(); + konduitAnalyticsAdapter.track.restore(); + konduitAnalyticsAdapter.disableAnalytics(); + }); + + it(`should add all events to an aggregatedEvents queue + inside konduitAnalyticsAdapter.context and send a request with correct data`, function () { + server.respondWith(JSON.stringify({ key: 'test' })); + + adapterManager.registerAnalyticsAdapter({ + code: 'konduit', + adapter: konduitAnalyticsAdapter + }); + + adapterManager.enableAnalytics({ + provider: 'konduit', + }); + + expect(konduitAnalyticsAdapter.context).to.be.an('object'); + expect(konduitAnalyticsAdapter.context.aggregatedEvents).to.be.an('array'); + + const eventTypes = [ + CONSTANTS.EVENTS.AUCTION_INIT, + CONSTANTS.EVENTS.BID_REQUESTED, + CONSTANTS.EVENTS.NO_BID, + CONSTANTS.EVENTS.BID_RESPONSE, + CONSTANTS.EVENTS.BID_WON, + CONSTANTS.EVENTS.AUCTION_END, + ]; + const args = eventTypes.map(eventType => eventsData[eventType]); + + eventTypes.forEach((eventType, i) => { + events.emit(eventType, args[i]); + }); + + server.respond(); + + expect(konduitAnalyticsAdapter.context.aggregatedEvents.length).to.be.equal(6); + expect(server.requests[0].url).to.match(/http(s):\/\/\w*\.konduit\.me\/analytics-initial-event/); + + const requestBody = JSON.parse(server.requests[0].requestBody); + expect(requestBody.konduitId).to.be.equal(konduitId); + expect(requestBody.prebidVersion).to.be.equal($$PREBID_GLOBAL$$.version); + expect(requestBody.environment).to.be.an('object'); + sinon.assert.callCount(konduitAnalyticsAdapter.track, 6); + }); +}); From f2f7fba16bdc3bc7dc10db34653443fb2f29e8fd Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Tue, 21 Apr 2020 16:33:50 +0300 Subject: [PATCH 11/14] Updated konduit analytics adapter .md file --- modules/konduitAnalyticsAdapter.md | 40 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/modules/konduitAnalyticsAdapter.md b/modules/konduitAnalyticsAdapter.md index c781d007ff1..c5854b77ccd 100644 --- a/modules/konduitAnalyticsAdapter.md +++ b/modules/konduitAnalyticsAdapter.md @@ -1,26 +1,32 @@ # Overview - +​ ``` Module Name: Konduit Analytics Adapter Module Type: Analytics Adapter -Maintainer: TBD +Maintainer: support@konduit.me ``` - +​ +​ # Description - -Analytics adapter for Konduit. - -# Test Parameters - +​ +Konduit Analytics adapter pushes Prebid events into Konduit platform, which is then organizes the data and presents it to a client in different insightful views. +​ +For more information, visit the [official Konduit website](https://konduitvideo.com/). +​ +​ +# Usage +​ +Konduit Analytics can be enabled with a standard `enableAnalytics` call. +Note it is also important to provide a valid Konduit identifier as a config parameter. +​ ```javascript -pbjs.que.push(function () { - pbjs.setConfig({ - konduit: { - konduitId: 'your_konduit_id', - } - }); - pbjs.enableAnalytics({ - provider: 'konduit' - }) +pbjs.setConfig({ + konduit: { + konduitId: your_konduit_id, + } }); +​ +pbjs.enableAnalytics({ + provider: 'konduit' +}) ``` From 92c80551d0170e7cbd0b99efe63fea7fad6e1598 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Fri, 24 Apr 2020 14:38:50 +0300 Subject: [PATCH 12/14] Fixed linter issue with more than 1 blank line used --- modules/konduitWrapper.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/konduitWrapper.js b/modules/konduitWrapper.js index 3a86868fee5..e015fb93616 100644 --- a/modules/konduitWrapper.js +++ b/modules/konduitWrapper.js @@ -19,7 +19,6 @@ export const errorMessages = { CACHE_FAILURE: 'A bid was not cached', }; - // This function is copy from prebid core function formatQS(query) { return Object From cb50ac887a2118c50a5858df30213571ec7ad308 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Mon, 4 May 2020 12:07:59 +0300 Subject: [PATCH 13/14] Use '$prebid.version$' instead of the $$PREBID_GLOBAL$$.version --- modules/konduitAnalyticsAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/konduitAnalyticsAdapter.js b/modules/konduitAnalyticsAdapter.js index 49b7af1996b..00df790b18a 100644 --- a/modules/konduitAnalyticsAdapter.js +++ b/modules/konduitAnalyticsAdapter.js @@ -167,7 +167,7 @@ function composeRequestPayload () { return { konduitId, - prebidVersion: $$PREBID_GLOBAL$$.version, + prebidVersion: '$prebid.version$', environment: { screen: { width, height }, language: navigator.language, From 10a284218356a5a8290dd4980351ae999124d746 Mon Sep 17 00:00:00 2001 From: Max Shevchenko Date: Mon, 4 May 2020 12:24:37 +0300 Subject: [PATCH 14/14] Updated unit tests --- test/spec/modules/konduitAnalyticsAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/konduitAnalyticsAdapter_spec.js b/test/spec/modules/konduitAnalyticsAdapter_spec.js index 75fc8488b8e..ac557d27f90 100644 --- a/test/spec/modules/konduitAnalyticsAdapter_spec.js +++ b/test/spec/modules/konduitAnalyticsAdapter_spec.js @@ -119,7 +119,7 @@ describe(`Konduit Analytics Adapter`, () => { const requestBody = JSON.parse(server.requests[0].requestBody); expect(requestBody.konduitId).to.be.equal(konduitId); - expect(requestBody.prebidVersion).to.be.equal($$PREBID_GLOBAL$$.version); + expect(requestBody.prebidVersion).to.be.equal('$prebid.version$'); expect(requestBody.environment).to.be.an('object'); sinon.assert.callCount(konduitAnalyticsAdapter.track, 6); });