From 3c7271312ec259a1d26b4cde0fe46decc009934b Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Wed, 11 Dec 2019 15:08:37 -0500 Subject: [PATCH] Prebid 3.0 (#4580) * Remove pbs depracated legacy url (#4226) * remove deprecated legacy url from pbs adapter * fix eslint errors * add and update tests for openRtb2 endpoint * sync with master * Revert "sync with master" This reverts commit 8c2b1969e4ec796fa8d23ca0a571ddbd77048a30. * removed targeting set filter and moved where render status is set to work with safeframe creatives (#4236) * Depracate adloader loadscript fn (#4228) * test commit * add callback support to loadExternalScript() * pass moduleCode for renderers * test cases for loadExternalScript() * store callbacks for cached url * fully remove adloader() * call callback() from stub * remove and update function name * getHighestCpmBids only returns non-rendered bids (#4247) * Make all adapters https (#4294) * update all adapters to https * convert all adapters to https * update unit tests * remove files confilicting with other PR * Removed pub common and unified id submodules as defaults in user id module (#4445) * Deprecate user sync (#4241) * deprecate some properties of userSync object * change bid adapter to Appnexus * fix 3 failing test cases * make all unit test cases pass * remove debugger * deprecate support for adUnit.sizes for pubs (#4458) * deprecate support for adUnit.sizes for pubs * remove commented code * Deprecations utils.js (#4249) * deprecate domain/referer type functions * delete modules that are using deprecated methods from utils.js * remove reference to getTopWindowLocation * sync with prebid-3.0 branch * remove test suite for getTopWindowLocation * add back md files of all deleted adapters * add md files of deleted analytics adapters * add adapters that are 3.0 compliant * add back the rubicon skipped test * remove min field from priceGranularity feature (#4574) --- CONTRIBUTING.md | 2 +- .../gpt/prebidServer_example.html | 6 +- modules/.submodules.json | 2 + modules/7xbidBidAdapter.js | 155 -- modules/a4gBidAdapter.js | 89 -- modules/aardvarkBidAdapter.js | 4 +- modules/adbutlerBidAdapter.js | 131 -- modules/adformBidAdapter.js | 2 +- modules/adformOpenRTBBidAdapter.js | 2 +- modules/adgenerationBidAdapter.js | 2 +- modules/adkernelAdnAnalyticsAdapter.js | 378 ----- modules/admanBidAdapter.js | 79 - modules/admaticBidAdapter.js | 4 +- modules/admediaBidAdapter.js | 2 +- modules/admixerBidAdapter.js | 73 - modules/adspendBidAdapter.js | 4 +- modules/adspiritBidAdapter.js | 72 - modules/adtelligentBidAdapter.js | 243 --- modules/aduptechBidAdapter.js | 79 - modules/advenueBidAdapter.js | 2 +- modules/ajaBidAdapter.js | 2 +- modules/andbeyondBidAdapter.js | 168 -- modules/aniviewBidAdapter.js | 191 --- modules/appnexusBidAdapter.js | 6 +- modules/arteebeeBidAdapter.js | 190 --- modules/atomxBidAdapter.js | 2 +- modules/audienceNetworkBidAdapter.js | 317 ---- modules/betweenBidAdapter.js | 6 +- modules/bidfluenceBidAdapter.js | 2 +- modules/bidglassBidAdapter.js | 46 +- modules/bidphysicsBidAdapter.js | 2 +- modules/bizzclickBidAdapter.js | 105 -- modules/brainyBidAdapter.js | 154 -- modules/bridgewellBidAdapter.js | 269 ---- modules/c1xBidAdapter.js | 5 +- modules/ccxBidAdapter.js | 216 --- modules/cedatoBidAdapter.js | 4 +- modules/cleanmedianetBidAdapter.js | 300 ---- modules/clickforceBidAdapter.js | 2 +- modules/collectcentBidAdapter.js | 4 +- modules/colombiaBidAdapter.js | 72 - modules/contentigniteBidAdapter.js | 115 -- modules/cosmosBidAdapter.js | 4 +- modules/cpmstarBidAdapter.js | 6 +- modules/danmarketBidAdapter.js | 161 -- modules/datablocksBidAdapter.js | 2 +- modules/decenteradsBidAdapter.js | 90 -- modules/dgadsBidAdapter.js | 103 -- modules/djaxBidAdapter.js | 2 +- modules/dspxBidAdapter.js | 96 -- modules/ebdrBidAdapter.js | 2 +- modules/emx_digitalBidAdapter.js | 287 ---- modules/eplanningBidAdapter.js | 395 ----- modules/etargetBidAdapter.js | 2 +- modules/eywamediaBidAdapter.js | 181 --- modules/fairtradeBidAdapter.js | 150 -- modules/fidelityBidAdapter.js | 109 -- modules/freewheel-sspBidAdapter.js | 360 ----- modules/fyberBidAdapter.js | 378 ----- modules/gammaBidAdapter.js | 100 -- modules/gamoshiBidAdapter.js | 279 ---- modules/getintentBidAdapter.js | 2 +- modules/giantsBidAdapter.js | 343 ---- modules/gjirafaBidAdapter.js | 95 -- modules/gridBidAdapter.js | 6 +- modules/gxoneBidAdapter.js | 141 -- modules/hpmdnetworkBidAdapter.js | 2 +- modules/huddledmassesBidAdapter.js | 132 -- modules/iasBidAdapter.js | 2 +- modules/imonomyBidAdapter.js | 4 +- modules/innityBidAdapter.js | 54 - modules/inskinBidAdapter.js | 246 --- modules/interactiveOffersBidAdapter.js | 99 -- modules/invibesBidAdapter.js | 4 +- modules/iqmBidAdapter.js | 137 -- modules/jcmBidAdapter.js | 6 +- modules/komoonaBidAdapter.js | 4 +- modules/kummaBidAdapter.js | 308 ---- modules/lemmaBidAdapter.js | 401 ----- modules/lifestreetBidAdapter.js | 159 -- modules/livewrappedAnalyticsAdapter.js | 2 +- modules/livewrappedBidAdapter.js | 235 --- modules/marsmediaAnalyticsAdapter.js | 2 +- modules/marsmediaBidAdapter.js | 2 +- modules/meazyBidAdapter.js | 4 +- modules/my6senseBidAdapter.js | 2 +- modules/mytargetBidAdapter.js | 2 +- modules/nasmediaAdmixerBidAdapter.js | 82 - modules/nobidBidAdapter.js | 2 +- modules/oneplanetonlyBidAdapter.js | 76 - modules/open8BidAdapter.js | 2 +- modules/openxAnalyticsAdapter.js | 2 +- modules/optimaticBidAdapter.js | 106 -- modules/orbitsoftBidAdapter.js | 147 -- modules/padsquadBidAdapter.js | 2 +- modules/papyrusBidAdapter.js | 2 +- modules/peak226BidAdapter.js | 97 -- modules/piximediaBidAdapter.js | 2 +- modules/platformioBidAdapter.js | 314 ---- modules/playgroundxyzBidAdapter.js | 172 -- modules/polluxBidAdapter.js | 120 -- modules/polymorphBidAdapter.js | 131 -- modules/prebidServerBidAdapter/index.js | 195 +-- modules/projectLimeLightBidAdapter.js | 2 +- modules/{userId => }/pubCommonIdSystem.js | 11 +- modules/pubnxBidAdapter.js | 86 - modules/quantumBidAdapter.js | 8 +- modules/rdnBidAdapter.js | 81 - modules/readpeakBidAdapter.js | 256 --- modules/realvuAnalyticsAdapter.js | 4 +- modules/reklamstoreBidAdapter.js | 2 +- modules/reloadBidAdapter.js | 10 +- modules/rexrtbBidAdapter.js | 138 -- modules/rhythmoneBidAdapter.js | 2 +- modules/rockyouBidAdapter.js | 370 ----- modules/roxotAnalyticsAdapter.js | 4 +- modules/rtbdemandBidAdapter.js | 4 +- modules/rtbdemandadkBidAdapter.js | 187 --- modules/rubiconAnalyticsAdapter.js | 483 ------ modules/saraBidAdapter.js | 141 -- modules/sekindoUMBidAdapter.js | 2 +- modules/serverbidBidAdapter.js | 234 --- modules/serverbidServerBidAdapter.js | 233 --- modules/sharethroughAnalyticsAdapter.js | 2 +- modules/sharethroughBidAdapter.js | 6 +- modules/slimcutBidAdapter.js | 4 +- modules/smartadserverBidAdapter.js | 153 -- modules/smartrtbBidAdapter.js | 2 +- modules/smartyadsBidAdapter.js | 91 -- modules/somoBidAdapter.js | 260 ---- modules/sortableBidAdapter.js | 162 -- modules/sovrnAnalyticsAdapter.js | 280 ---- modules/spotxBidAdapter.js | 6 +- modules/staqAnalyticsAdapter.js | 2 +- modules/supply2BidAdapter.js | 166 -- modules/synacormediaBidAdapter.js | 4 +- modules/teadsBidAdapter.js | 4 +- modules/telariaBidAdapter.js | 8 +- modules/theAdxBidAdapter.js | 2 +- modules/timBidAdapter.js | 2 +- modules/trafficrootsBidAdapter.js | 129 -- modules/trionBidAdapter.js | 163 -- modules/trustxBidAdapter.js | 6 +- modules/turktelekomBidAdapter.js | 6 +- modules/ucfunnelBidAdapter.js | 237 --- modules/undertoneBidAdapter.js | 8 +- modules/{userId => }/unifiedIdSystem.js | 11 +- modules/uolBidAdapter.js | 192 --- modules/userId/index.js | 6 - modules/vertamediaBidAdapter.js | 199 --- modules/vertozBidAdapter.js | 86 - modules/vidazooBidAdapter.js | 4 +- modules/videoreachBidAdapter.js | 97 -- modules/visxBidAdapter.js | 4 +- modules/vubleAnalyticsAdapter.js | 258 --- modules/weboramaBidAdapter.js | 117 -- modules/widespaceBidAdapter.js | 250 --- modules/xendizBidAdapter.js | 102 -- modules/xhbBidAdapter.js | 4 +- modules/yieldbotBidAdapter.js | 604 ------- modules/yieldmoBidAdapter.js | 336 ---- modules/yieldnexusBidAdapter.js | 232 --- modules/yieldoneBidAdapter.js | 176 --- modules/yuktamediaAnalyticsAdapter.js | 144 -- modules/zedoBidAdapter.js | 325 ---- src/Renderer.js | 9 +- src/adapters/bidderFactory.js | 4 +- src/adloader.js | 96 +- src/auctionManager.js | 1 + src/cpmBucketManager.js | 18 +- src/prebid.js | 76 +- src/targeting.js | 4 +- src/userSync.js | 22 +- src/utils.js | 78 +- test/mocks/adloaderStub.js | 10 +- test/spec/AnalyticsAdapter_spec.js | 2 +- test/spec/adloader_spec.js | 11 + test/spec/config_spec.js | 2 - test/spec/cpmBucketManager_spec.js | 16 +- test/spec/modules/33acrossBidAdapter_spec.js | 4 +- test/spec/modules/7xbidBidAdapter_spec.js | 161 -- test/spec/modules/a4gBidAdapter_spec.js | 149 -- test/spec/modules/aardvarkBidAdapter_spec.js | 24 +- test/spec/modules/adbutlerBidAdapter_spec.js | 211 --- test/spec/modules/adformBidAdapter_spec.js | 2 +- .../modules/adformOpenRTBBidAdapter_spec.js | 2 +- .../modules/adgenerationBidAdapter_spec.js | 12 +- .../adkernelAdnAnalyticsAdapter_spec.js | 268 ---- .../modules/adkernelAdnBidAdapter_spec.js | 8 +- test/spec/modules/adkernelBidAdapter_spec.js | 12 +- test/spec/modules/admanBidAdapter_spec.js | 215 --- test/spec/modules/admediaBidAdapter_spec.js | 4 +- test/spec/modules/admixerBidAdapter_spec.js | 117 -- test/spec/modules/adpod_spec.js | 3 - test/spec/modules/adponeBidAdapter_spec.js | 8 +- test/spec/modules/adspiritBidAdapter_spec.js | 142 -- .../modules/adtelligentBidAdapter_spec.js | 311 ---- test/spec/modules/aduptechBidAdapter_spec.js | 261 ---- test/spec/modules/advenueBidAdapter_spec.js | 2 +- test/spec/modules/adyoulikeBidAdapter_spec.js | 2 +- test/spec/modules/ajaBidAdapter_spec.js | 10 +- test/spec/modules/andbeyondBidAdapter_spec.js | 208 --- test/spec/modules/aniviewBidAdapter_spec.js | 183 --- test/spec/modules/aolBidAdapter_spec.js | 10 +- test/spec/modules/appnexusBidAdapter_spec.js | 46 +- test/spec/modules/arteebeeBidAdapter_spec.js | 156 -- test/spec/modules/atomxBidAdapter_spec.js | 4 +- .../modules/audienceNetworkBidAdapter_spec.js | 522 ------- .../spec/modules/bidphysicsBidAdapter_spec.js | 4 +- test/spec/modules/bizzclickBidAdapter_spec.js | 117 -- test/spec/modules/brainyBidAdapter_spec.js | 128 -- .../spec/modules/bridgewellBidAdapter_spec.js | 1164 -------------- test/spec/modules/bucksenseBidAdapter_spec.js | 6 +- test/spec/modules/c1xBidAdapter_spec.js | 4 +- test/spec/modules/ccxBidAdapter_spec.js | 403 ----- test/spec/modules/cedatoBidAdapter_spec.js | 2 +- .../modules/cleanmedianetBidAdapter_spec.js | 603 ------- test/spec/modules/coinzillaBidAdapter_spec.js | 4 +- .../modules/collectcentBidAdapter_spec.js | 4 +- test/spec/modules/colombiaBidAdapter_spec.js | 152 -- .../modules/contentigniteBidAdapter_spec.js | 186 --- test/spec/modules/cosmosBidAdapter_spec.js | 4 +- test/spec/modules/cpmstarBidAdapter_spec.js | 6 +- test/spec/modules/danmarketBidAdapter_spec.js | 309 ---- .../spec/modules/datablocksBidAdapter_spec.js | 18 +- .../modules/decenteradsBidAdapter_spec.js | 207 --- test/spec/modules/dgadsBidAdapter_spec.js | 299 ---- test/spec/modules/dspxBidAdapter_spec.js | 130 -- test/spec/modules/ebdrBidAdapter_spec.js | 10 +- test/spec/modules/emoteevBidAdapter_spec.js | 4 +- .../modules/emx_digitalBidAdapter_spec.js | 558 ------- test/spec/modules/eplanningBidAdapter_spec.js | 724 --------- test/spec/modules/etargetBidAdapter_spec.js | 2 +- test/spec/modules/eywamediaBidAdapter_spec.js | 253 --- test/spec/modules/fairtradeBidAdapter_spec.js | 289 ---- test/spec/modules/fidelityBidAdapter_spec.js | 180 --- .../modules/freewheel-sspBidAdapter_spec.js | 239 --- test/spec/modules/fyberBidAdapter_spec.js | 154 -- test/spec/modules/gammaBidAdapter_spec.js | 105 -- test/spec/modules/gamoshiBidAdapter_spec.js | 543 ------- test/spec/modules/getintentBidAdapter_spec.js | 8 +- test/spec/modules/giantsBidAdapter_spec.js | 301 ---- test/spec/modules/gjirafaBidAdapter_spec.js | 172 -- test/spec/modules/gridBidAdapter_spec.js | 2 +- test/spec/modules/gxoneBidAdapter_spec.js | 293 ---- .../modules/hpmdnetworkBidAdapter_spec.js | 10 +- .../modules/huddledmassesBidAdapter_spec.js | 119 -- test/spec/modules/iasBidAdapter_spec.js | 2 +- test/spec/modules/imonomyBidAdapter_spec.js | 6 +- .../modules/improvedigitalBidAdapter_spec.js | 70 +- test/spec/modules/innityBidAdapter_spec.js | 100 -- test/spec/modules/inskinBidAdapter_spec.js | 288 ---- .../interactiveOffersBidAdapter_spec.js | 177 --- test/spec/modules/invibesBidAdapter_spec.js | 4 +- test/spec/modules/iqmBidAdapter_spec.js | 219 --- test/spec/modules/ixBidAdapter_spec.js | 18 +- test/spec/modules/jcmBidAdapter_spec.js | 6 +- test/spec/modules/komoonaBidAdapter_spec.js | 6 +- test/spec/modules/kummaBidAdapter_spec.js | 335 ---- test/spec/modules/lemmaBidAdapter_spec.js | 335 ---- .../spec/modules/lifestreetBidAdapter_spec.js | 222 --- .../livewrappedAnalyticsAdapter_spec.js | 2 +- .../modules/livewrappedBidAdapter_spec.js | 835 ---------- test/spec/modules/lkqdBidAdapter_spec.js | 28 +- test/spec/modules/logicadBidAdapter_spec.js | 2 +- .../spec/modules/madvertiseBidAdapter_spec.js | 4 +- test/spec/modules/mantisBidAdapter_spec.js | 4 +- test/spec/modules/meazyBidAdapter_spec.js | 8 +- test/spec/modules/mgidBidAdapter_spec.js | 26 +- test/spec/modules/microadBidAdapter_spec.js | 10 +- test/spec/modules/mobfoxBidAdapter_spec.js | 4 +- test/spec/modules/mytargetBidAdapter_spec.js | 2 +- .../modules/nanointeractiveBidAdapter_spec.js | 4 +- .../modules/nasmediaAdmixerBidAdapter_spec.js | 138 -- .../modules/oneplanetonlyBidAdapter_spec.js | 100 -- test/spec/modules/open8BidAdapter_spec.js | 22 +- .../modules/openxAnalyticsAdapter_spec.js | 2 +- test/spec/modules/optimaticBidAdapter_spec.js | 178 --- test/spec/modules/orbidderBidAdapter_spec.js | 4 +- test/spec/modules/orbitsoftBidAdapter_spec.js | 248 --- test/spec/modules/ozoneBidAdapter_spec.js | 8 +- test/spec/modules/padsquadBidAdapter_spec.js | 4 +- test/spec/modules/papyrusBidAdapter_spec.js | 2 +- test/spec/modules/peak226BidAdapter_spec.js | 114 -- .../spec/modules/platformioBidAdapter_spec.js | 335 ---- .../modules/playgroundxyzBidAdapter_spec.js | 213 --- test/spec/modules/polluxBidAdapter_spec.js | 207 --- test/spec/modules/polymorphBidAdapter_spec.js | 219 --- .../modules/prebidServerBidAdapter_spec.js | 269 +--- .../projectLimeLightBidAdapter_spec.js | 2 +- test/spec/modules/pubnxBidAdapter_spec.js | 112 -- .../spec/modules/pulsepointBidAdapter_spec.js | 26 +- test/spec/modules/quantumBidAdapter_spec.js | 32 +- test/spec/modules/rdnBidAdapter_spec.js | 156 -- test/spec/modules/readpeakBidAdapter_spec.js | 207 --- .../modules/reklamstoreBidAdapter_spec.js | 10 +- test/spec/modules/rexrtbBidAdapter_spec.js | 107 -- test/spec/modules/rhythmoneBidAdapter_spec.js | 12 +- .../modules/richaudienceBidAdapter_spec.js | 35 +- test/spec/modules/rockyouBidAdapter_spec.js | 494 ------ .../modules/roxotAnalyticsAdapter_spec.js | 14 +- test/spec/modules/rtbdemandBidAdapter_spec.js | 4 +- .../modules/rtbdemandadkBidAdapter_spec.js | 268 ---- test/spec/modules/rtbhouseBidAdapter_spec.js | 16 +- .../modules/rubiconAnalyticsAdapter_spec.js | 814 ---------- test/spec/modules/rubiconBidAdapter_spec.js | 18 +- test/spec/modules/saraBidAdapter_spec.js | 293 ---- test/spec/modules/sekindoUMBidAdapter_spec.js | 4 +- test/spec/modules/serverbidBidAdapter_spec.js | 253 --- .../modules/serverbidServerBidAdapter_spec.js | 303 ---- .../modules/sharethroughBidAdapter_spec.js | 14 +- .../modules/showheroes-bsBidAdapter_spec.js | 2 +- test/spec/modules/slimcutBidAdapter_spec.js | 10 +- .../modules/smartadserverBidAdapter_spec.js | 399 ----- test/spec/modules/smartrtbBidAdapter_spec.js | 8 +- test/spec/modules/smartyadsBidAdapter_spec.js | 230 --- .../modules/smilewantedBidAdapter_spec.js | 4 +- test/spec/modules/somoBidAdapter_spec.js | 481 ------ test/spec/modules/sonobiBidAdapter_spec.js | 24 +- test/spec/modules/sortableBidAdapter_spec.js | 258 --- .../modules/sovrnAnalyticsAdapter_spec.js | 546 ------- test/spec/modules/spotxBidAdapter_spec.js | 14 +- .../spec/modules/staqAnalyticsAdapter_spec.js | 12 +- test/spec/modules/supply2BidAdapter_spec.js | 332 ---- .../modules/synacormediaBidAdapter_spec.js | 30 +- test/spec/modules/teadsBidAdapter_spec.js | 12 +- test/spec/modules/theAdxBidAdapter_spec.js | 14 +- test/spec/modules/timBidAdapter_spec.js | 4 +- test/spec/modules/topRTBBidAdapter_spec.js | 2 +- .../modules/trafficrootsBidAdapter_spec.js | 149 -- test/spec/modules/trionBidAdapter_spec.js | 274 ---- .../spec/modules/tripleliftBidAdapter_spec.js | 6 +- test/spec/modules/trustxBidAdapter_spec.js | 6 +- .../modules/turktelekomBidAdapter_spec.js | 6 +- test/spec/modules/ucfunnelBidAdapter_spec.js | 243 --- test/spec/modules/undertoneBidAdapter_spec.js | 20 +- test/spec/modules/unrulyBidAdapter_spec.js | 4 +- test/spec/modules/uolBidAdapter_spec.js | 308 ---- test/spec/modules/userId_spec.js | 4 +- .../spec/modules/vertamediaBidAdapter_spec.js | 218 --- test/spec/modules/vertozBidAdapter_spec.js | 112 -- test/spec/modules/vidazooBidAdapter_spec.js | 6 +- test/spec/modules/videoNowBidAdapter_spec.js | 32 +- .../spec/modules/videoreachBidAdapter_spec.js | 141 -- test/spec/modules/visxBidAdapter_spec.js | 2 +- .../modules/vubleAnalyticsAdapter_spec.js | 122 -- test/spec/modules/weboramaBidAdapter_spec.js | 118 -- test/spec/modules/widespaceBidAdapter_spec.js | 262 ---- test/spec/modules/xendizBidAdapter_spec.js | 119 -- test/spec/modules/xhbBidAdapter_spec.js | 16 +- test/spec/modules/yieldbotBidAdapter_spec.js | 1383 ----------------- test/spec/modules/yieldmoBidAdapter_spec.js | 220 --- .../spec/modules/yieldnexusBidAdapter_spec.js | 418 ----- test/spec/modules/yieldoneBidAdapter_spec.js | 236 --- .../yuktamediaAnalyticsAdaptor_spec.js | 177 --- test/spec/modules/zedoBidAdapter_spec.js | 354 ----- test/spec/renderer_spec.js | 18 + test/spec/unit/pbjs_api_spec.js | 91 +- test/spec/userSync_spec.js | 82 +- test/spec/utils_spec.js | 87 -- 360 files changed, 918 insertions(+), 42964 deletions(-) delete mode 100644 modules/7xbidBidAdapter.js delete mode 100644 modules/a4gBidAdapter.js delete mode 100644 modules/adbutlerBidAdapter.js delete mode 100644 modules/adkernelAdnAnalyticsAdapter.js delete mode 100644 modules/admanBidAdapter.js delete mode 100644 modules/admixerBidAdapter.js delete mode 100644 modules/adspiritBidAdapter.js delete mode 100644 modules/adtelligentBidAdapter.js delete mode 100644 modules/aduptechBidAdapter.js delete mode 100644 modules/andbeyondBidAdapter.js delete mode 100644 modules/aniviewBidAdapter.js delete mode 100644 modules/arteebeeBidAdapter.js delete mode 100644 modules/audienceNetworkBidAdapter.js delete mode 100644 modules/bizzclickBidAdapter.js delete mode 100644 modules/brainyBidAdapter.js delete mode 100644 modules/bridgewellBidAdapter.js delete mode 100644 modules/ccxBidAdapter.js delete mode 100644 modules/cleanmedianetBidAdapter.js delete mode 100644 modules/colombiaBidAdapter.js delete mode 100644 modules/contentigniteBidAdapter.js delete mode 100644 modules/danmarketBidAdapter.js delete mode 100644 modules/decenteradsBidAdapter.js delete mode 100644 modules/dgadsBidAdapter.js delete mode 100644 modules/dspxBidAdapter.js delete mode 100644 modules/emx_digitalBidAdapter.js delete mode 100644 modules/eplanningBidAdapter.js delete mode 100644 modules/eywamediaBidAdapter.js delete mode 100644 modules/fairtradeBidAdapter.js delete mode 100644 modules/fidelityBidAdapter.js delete mode 100644 modules/freewheel-sspBidAdapter.js delete mode 100644 modules/fyberBidAdapter.js delete mode 100644 modules/gammaBidAdapter.js delete mode 100644 modules/gamoshiBidAdapter.js delete mode 100644 modules/giantsBidAdapter.js delete mode 100644 modules/gjirafaBidAdapter.js delete mode 100644 modules/gxoneBidAdapter.js delete mode 100644 modules/huddledmassesBidAdapter.js delete mode 100644 modules/innityBidAdapter.js delete mode 100644 modules/inskinBidAdapter.js delete mode 100644 modules/interactiveOffersBidAdapter.js delete mode 100644 modules/iqmBidAdapter.js delete mode 100644 modules/kummaBidAdapter.js delete mode 100644 modules/lemmaBidAdapter.js delete mode 100644 modules/lifestreetBidAdapter.js delete mode 100644 modules/livewrappedBidAdapter.js delete mode 100644 modules/nasmediaAdmixerBidAdapter.js delete mode 100644 modules/oneplanetonlyBidAdapter.js delete mode 100644 modules/optimaticBidAdapter.js delete mode 100644 modules/orbitsoftBidAdapter.js delete mode 100644 modules/peak226BidAdapter.js delete mode 100644 modules/platformioBidAdapter.js delete mode 100644 modules/playgroundxyzBidAdapter.js delete mode 100644 modules/polluxBidAdapter.js delete mode 100644 modules/polymorphBidAdapter.js rename modules/{userId => }/pubCommonIdSystem.js (91%) delete mode 100644 modules/pubnxBidAdapter.js delete mode 100644 modules/rdnBidAdapter.js delete mode 100644 modules/readpeakBidAdapter.js delete mode 100644 modules/rexrtbBidAdapter.js delete mode 100644 modules/rockyouBidAdapter.js delete mode 100644 modules/rtbdemandadkBidAdapter.js delete mode 100644 modules/rubiconAnalyticsAdapter.js delete mode 100644 modules/saraBidAdapter.js delete mode 100644 modules/serverbidBidAdapter.js delete mode 100644 modules/serverbidServerBidAdapter.js delete mode 100644 modules/smartadserverBidAdapter.js delete mode 100644 modules/smartyadsBidAdapter.js delete mode 100644 modules/somoBidAdapter.js delete mode 100644 modules/sortableBidAdapter.js delete mode 100644 modules/sovrnAnalyticsAdapter.js delete mode 100644 modules/supply2BidAdapter.js delete mode 100644 modules/trafficrootsBidAdapter.js delete mode 100644 modules/trionBidAdapter.js delete mode 100644 modules/ucfunnelBidAdapter.js rename modules/{userId => }/unifiedIdSystem.js (88%) delete mode 100644 modules/uolBidAdapter.js delete mode 100644 modules/vertamediaBidAdapter.js delete mode 100644 modules/vertozBidAdapter.js delete mode 100644 modules/videoreachBidAdapter.js delete mode 100644 modules/vubleAnalyticsAdapter.js delete mode 100644 modules/weboramaBidAdapter.js delete mode 100644 modules/widespaceBidAdapter.js delete mode 100644 modules/xendizBidAdapter.js delete mode 100644 modules/yieldbotBidAdapter.js delete mode 100644 modules/yieldmoBidAdapter.js delete mode 100644 modules/yieldnexusBidAdapter.js delete mode 100644 modules/yieldoneBidAdapter.js delete mode 100644 modules/yuktamediaAnalyticsAdapter.js delete mode 100644 modules/zedoBidAdapter.js delete mode 100644 test/spec/modules/7xbidBidAdapter_spec.js delete mode 100644 test/spec/modules/a4gBidAdapter_spec.js delete mode 100644 test/spec/modules/adbutlerBidAdapter_spec.js delete mode 100644 test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js delete mode 100644 test/spec/modules/admanBidAdapter_spec.js delete mode 100644 test/spec/modules/admixerBidAdapter_spec.js delete mode 100644 test/spec/modules/adspiritBidAdapter_spec.js delete mode 100644 test/spec/modules/adtelligentBidAdapter_spec.js delete mode 100644 test/spec/modules/aduptechBidAdapter_spec.js delete mode 100644 test/spec/modules/andbeyondBidAdapter_spec.js delete mode 100644 test/spec/modules/aniviewBidAdapter_spec.js delete mode 100644 test/spec/modules/arteebeeBidAdapter_spec.js delete mode 100644 test/spec/modules/audienceNetworkBidAdapter_spec.js delete mode 100644 test/spec/modules/bizzclickBidAdapter_spec.js delete mode 100644 test/spec/modules/brainyBidAdapter_spec.js delete mode 100644 test/spec/modules/bridgewellBidAdapter_spec.js delete mode 100644 test/spec/modules/ccxBidAdapter_spec.js delete mode 100644 test/spec/modules/cleanmedianetBidAdapter_spec.js delete mode 100644 test/spec/modules/colombiaBidAdapter_spec.js delete mode 100644 test/spec/modules/contentigniteBidAdapter_spec.js delete mode 100644 test/spec/modules/danmarketBidAdapter_spec.js delete mode 100644 test/spec/modules/decenteradsBidAdapter_spec.js delete mode 100644 test/spec/modules/dgadsBidAdapter_spec.js delete mode 100644 test/spec/modules/dspxBidAdapter_spec.js delete mode 100644 test/spec/modules/emx_digitalBidAdapter_spec.js delete mode 100644 test/spec/modules/eplanningBidAdapter_spec.js delete mode 100644 test/spec/modules/eywamediaBidAdapter_spec.js delete mode 100644 test/spec/modules/fairtradeBidAdapter_spec.js delete mode 100644 test/spec/modules/fidelityBidAdapter_spec.js delete mode 100644 test/spec/modules/freewheel-sspBidAdapter_spec.js delete mode 100644 test/spec/modules/fyberBidAdapter_spec.js delete mode 100644 test/spec/modules/gammaBidAdapter_spec.js delete mode 100644 test/spec/modules/gamoshiBidAdapter_spec.js delete mode 100644 test/spec/modules/giantsBidAdapter_spec.js delete mode 100644 test/spec/modules/gjirafaBidAdapter_spec.js delete mode 100644 test/spec/modules/gxoneBidAdapter_spec.js delete mode 100644 test/spec/modules/huddledmassesBidAdapter_spec.js delete mode 100644 test/spec/modules/innityBidAdapter_spec.js delete mode 100644 test/spec/modules/inskinBidAdapter_spec.js delete mode 100644 test/spec/modules/interactiveOffersBidAdapter_spec.js delete mode 100644 test/spec/modules/iqmBidAdapter_spec.js delete mode 100644 test/spec/modules/kummaBidAdapter_spec.js delete mode 100644 test/spec/modules/lemmaBidAdapter_spec.js delete mode 100644 test/spec/modules/lifestreetBidAdapter_spec.js delete mode 100644 test/spec/modules/livewrappedBidAdapter_spec.js delete mode 100644 test/spec/modules/nasmediaAdmixerBidAdapter_spec.js delete mode 100644 test/spec/modules/oneplanetonlyBidAdapter_spec.js delete mode 100644 test/spec/modules/optimaticBidAdapter_spec.js delete mode 100644 test/spec/modules/orbitsoftBidAdapter_spec.js delete mode 100644 test/spec/modules/peak226BidAdapter_spec.js delete mode 100644 test/spec/modules/platformioBidAdapter_spec.js delete mode 100644 test/spec/modules/playgroundxyzBidAdapter_spec.js delete mode 100644 test/spec/modules/polluxBidAdapter_spec.js delete mode 100644 test/spec/modules/polymorphBidAdapter_spec.js delete mode 100644 test/spec/modules/pubnxBidAdapter_spec.js delete mode 100644 test/spec/modules/rdnBidAdapter_spec.js delete mode 100644 test/spec/modules/readpeakBidAdapter_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 delete mode 100644 test/spec/modules/rubiconAnalyticsAdapter_spec.js delete mode 100644 test/spec/modules/saraBidAdapter_spec.js delete mode 100644 test/spec/modules/serverbidBidAdapter_spec.js delete mode 100644 test/spec/modules/serverbidServerBidAdapter_spec.js delete mode 100644 test/spec/modules/smartadserverBidAdapter_spec.js delete mode 100644 test/spec/modules/smartyadsBidAdapter_spec.js delete mode 100644 test/spec/modules/somoBidAdapter_spec.js delete mode 100644 test/spec/modules/sortableBidAdapter_spec.js delete mode 100644 test/spec/modules/sovrnAnalyticsAdapter_spec.js delete mode 100644 test/spec/modules/supply2BidAdapter_spec.js delete mode 100644 test/spec/modules/trafficrootsBidAdapter_spec.js delete mode 100644 test/spec/modules/trionBidAdapter_spec.js delete mode 100644 test/spec/modules/ucfunnelBidAdapter_spec.js delete mode 100644 test/spec/modules/uolBidAdapter_spec.js delete mode 100644 test/spec/modules/vertamediaBidAdapter_spec.js delete mode 100644 test/spec/modules/vertozBidAdapter_spec.js delete mode 100644 test/spec/modules/videoreachBidAdapter_spec.js delete mode 100644 test/spec/modules/vubleAnalyticsAdapter_spec.js delete mode 100644 test/spec/modules/weboramaBidAdapter_spec.js delete mode 100644 test/spec/modules/widespaceBidAdapter_spec.js delete mode 100644 test/spec/modules/xendizBidAdapter_spec.js delete mode 100644 test/spec/modules/yieldbotBidAdapter_spec.js delete mode 100644 test/spec/modules/yieldmoBidAdapter_spec.js delete mode 100644 test/spec/modules/yieldnexusBidAdapter_spec.js delete mode 100644 test/spec/modules/yieldoneBidAdapter_spec.js delete mode 100644 test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js delete mode 100644 test/spec/modules/zedoBidAdapter_spec.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c00a2bf51a3..6188d6c2182a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,7 +48,7 @@ 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 - When writing tests you may use ES2015 syntax if desired ### Test Examples diff --git a/integrationExamples/gpt/prebidServer_example.html b/integrationExamples/gpt/prebidServer_example.html index db61a6a46d6b..7761178efa89 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/modules/.submodules.json b/modules/.submodules.json index 0841f5e9777f..3572dc2e303b 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -1,5 +1,7 @@ { "userId": [ + "unifiedIdSystem", + "pubCommonIdSystem", "digiTrustIdSystem", "id5IdSystem", "criteortusIdSystem", diff --git a/modules/7xbidBidAdapter.js b/modules/7xbidBidAdapter.js deleted file mode 100644 index 5464f87ee994..000000000000 --- a/modules/7xbidBidAdapter.js +++ /dev/null @@ -1,155 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = '7xbid'; -const BIDDER_ALIAS = '7xb'; -const ENDPOINT_BANNER = '//bidder.7xbid.com/api/v1/prebid/banner'; -const ENDPOINT_NATIVE = '//bidder.7xbid.com/api/v1/prebid/native'; -const COOKIE_SYNC_URL = '//bidder.7xbid.com/api/v1/cookie/gen'; -const SUPPORTED_MEDIA_TYPES = ['banner', 'native']; -const SUPPORTED_CURRENCIES = ['USD', 'JPY']; -const DEFAULT_CURRENCY = 'JPY'; -const NET_REVENUE = true; - -const _encodeURIComponent = function(a) { - let b = window.encodeURIComponent(a); - b = b.replace(/'/g, '%27'); - return b; -} - -export const _getUrlVars = function(url) { - var hash; - var myJson = {}; - var hashes = url.slice(url.indexOf('?') + 1).split('&'); - for (var i = 0; i < hashes.length; i++) { - hash = hashes[i].split('='); - myJson[hash[0]] = hash[1]; - } - return myJson; -} - -export const spec = { - code: BIDDER_CODE, - aliases: [BIDDER_ALIAS], // short code - supportedMediaTypes: SUPPORTED_MEDIA_TYPES, - isBidRequestValid: function(bid) { - if (!(bid.params.placementId)) { - return false; - } - - if (bid.params.hasOwnProperty('currency') && - SUPPORTED_CURRENCIES.indexOf(bid.params.currency) === -1) { - utils.logInfo('Invalid currency type, we support only JPY and USD!') - return false; - } - - return true; - }, - /** - * 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) { - let serverRequests = []; - var refererInfo; - if (bidderRequest && bidderRequest.refererInfo) { - refererInfo = bidderRequest.refererInfo; - } - validBidRequests.forEach((bid, i) => { - let endpoint = ENDPOINT_BANNER - let data = { - 'placementid': bid.params.placementId, - 'cur': bid.params.hasOwnProperty('currency') ? bid.params.currency : DEFAULT_CURRENCY, - 'ua': navigator.userAgent, - 'loc': utils.getTopWindowUrl(), - 'topframe': (window.parent === window.self) ? 1 : 0, - 'sw': screen && screen.width, - 'sh': screen && screen.height, - 'cb': Math.floor(Math.random() * 99999999999), - 'tpaf': 1, - 'cks': 1, - 'requestid': bid.bidId - }; - - if (bid.hasOwnProperty('nativeParams')) { - endpoint = ENDPOINT_NATIVE - data.tkf = 1 // return url tracker - data.ad_track = '1' - data.apiv = '1.1.0' - } - - if (refererInfo && refererInfo.referer) { - data.referer = refererInfo.referer; - } else { - data.referer = ''; - } - - serverRequests.push({ - method: 'GET', - url: endpoint, - data: utils.parseQueryStringParameters(data) - }) - }) - - return serverRequests; - }, - interpretResponse: function(serverResponse, request) { - const data = _getUrlVars(request.data) - const successBid = serverResponse.body || {}; - let bidResponses = []; - if (successBid.hasOwnProperty(data.placementid)) { - let bid = successBid[data.placementid] - let bidResponse = { - requestId: bid.requestid, - cpm: bid.price, - creativeId: bid.creativeId, - currency: bid.cur, - netRevenue: NET_REVENUE, - ttl: 700 - }; - - if (bid.hasOwnProperty('title')) { // it is native ad response - bidResponse.mediaType = 'native' - bidResponse.native = { - title: bid.title, - body: bid.description, - cta: bid.cta, - sponsoredBy: bid.advertiser, - clickUrl: _encodeURIComponent(bid.landingURL), - impressionTrackers: bid.trackings, - } - if (bid.screenshots) { - bidResponse.native.image = { - url: bid.screenshots.url, - height: bid.screenshots.height, - width: bid.screenshots.width, - } - } - if (bid.icon) { - bidResponse.native.icon = { - url: bid.icon.url, - height: bid.icon.height, - width: bid.icon.width, - } - } - } else { - bidResponse.ad = bid.adm - bidResponse.width = bid.width - bidResponse.height = bid.height - } - - bidResponses.push(bidResponse); - } - - return bidResponses; - }, - getUserSyncs: function(syncOptions, serverResponses) { - return [{ - type: 'image', - url: COOKIE_SYNC_URL - }]; - } -} -registerBidder(spec); diff --git a/modules/a4gBidAdapter.js b/modules/a4gBidAdapter.js deleted file mode 100644 index d66630ce4db7..000000000000 --- a/modules/a4gBidAdapter.js +++ /dev/null @@ -1,89 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; - -const A4G_BIDDER_CODE = 'a4g'; -const A4G_CURRENCY = 'USD'; -const A4G_DEFAULT_BID_URL = '//ads.ad4game.com/v1/bid'; -const A4G_TTL = 120; - -const LOCATION_PARAM_NAME = 'siteurl'; -const ID_PARAM_NAME = 'id'; -const IFRAME_PARAM_NAME = 'if'; -const ZONE_ID_PARAM_NAME = 'zoneId'; -const SIZE_PARAM_NAME = 'size'; - -const ARRAY_PARAM_SEPARATOR = ';'; -const ARRAY_SIZE_SEPARATOR = ','; -const SIZE_SEPARATOR = 'x'; - -export const spec = { - code: A4G_BIDDER_CODE, - isBidRequestValid: function(bid) { - return bid.params && !!bid.params.zoneId; - }, - - buildRequests: function(validBidRequests, bidderRequest) { - let deliveryUrl = ''; - const idParams = []; - const sizeParams = []; - const zoneIds = []; - - utils._each(validBidRequests, function(bid) { - if (!deliveryUrl && typeof bid.params.deliveryUrl === 'string') { - deliveryUrl = bid.params.deliveryUrl; - } - idParams.push(bid.bidId); - sizeParams.push(bid.sizes.map(size => size.join(SIZE_SEPARATOR)).join(ARRAY_SIZE_SEPARATOR)); - zoneIds.push(bid.params.zoneId); - }); - - if (!deliveryUrl) { - deliveryUrl = A4G_DEFAULT_BID_URL; - } - - let data = { - [IFRAME_PARAM_NAME]: 0, - [LOCATION_PARAM_NAME]: utils.getTopWindowUrl(), - [SIZE_PARAM_NAME]: sizeParams.join(ARRAY_PARAM_SEPARATOR), - [ID_PARAM_NAME]: idParams.join(ARRAY_PARAM_SEPARATOR), - [ZONE_ID_PARAM_NAME]: zoneIds.join(ARRAY_PARAM_SEPARATOR) - }; - - if (bidderRequest && bidderRequest.gdprConsent) { - data.gdpr = { - applies: bidderRequest.gdprConsent.gdprApplies, - consent: bidderRequest.gdprConsent.consentString - }; - } - - return { - method: 'GET', - url: deliveryUrl, - data: data - }; - }, - - interpretResponse: function(serverResponses, request) { - const bidResponses = []; - utils._each(serverResponses.body, function(response) { - if (response.cpm > 0) { - const bidResponse = { - requestId: response.id, - creativeId: response.id, - adId: response.id, - cpm: response.cpm, - width: response.width, - height: response.height, - currency: A4G_CURRENCY, - netRevenue: true, - ttl: A4G_TTL, - ad: response.ad - }; - bidResponses.push(bidResponse); - } - }); - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index 9caaaaa747ca..c1bc281e0376 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -103,7 +103,7 @@ export const spec = { var req = requestsMap[auctionId]; requests.push({ method: 'GET', - url: `//${req.endpoint}/${auctionId}/${req.shortCodes.join('_')}/aardvark`, + url: `https://${req.endpoint}/${auctionId}/${req.shortCodes.join('_')}/aardvark`, data: req.payload, bidderRequest }); @@ -162,7 +162,7 @@ export const spec = { getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { const syncs = []; - var url = '//' + SYNC_ENDPOINT + '/cs'; + var url = 'https://' + SYNC_ENDPOINT + '/cs'; var gdprApplies = false; if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { gdprApplies = gdprConsent.gdprApplies; diff --git a/modules/adbutlerBidAdapter.js b/modules/adbutlerBidAdapter.js deleted file mode 100644 index 88aa4f158b79..000000000000 --- a/modules/adbutlerBidAdapter.js +++ /dev/null @@ -1,131 +0,0 @@ -'use strict'; - -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'adbutler'; - -export const spec = { - code: BIDDER_CODE, - pageID: Math.floor(Math.random() * 10e6), - aliases: ['divreach'], - - isBidRequestValid: function (bid) { - return !!(bid.params.accountID && bid.params.zoneID); - }, - - buildRequests: function (validBidRequests) { - var i; - var zoneID; - var bidRequest; - var accountID; - var keyword; - var domain; - var requestURI; - var serverRequests = []; - var 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); - domain = utils.getBidIdParameter('domain', bidRequest.params); - - if (!(zoneID in zoneCounters)) { - zoneCounters[zoneID] = 0; - } - - if (typeof domain === 'undefined' || domain.length === 0) { - domain = 'servedbyadbutler.com'; - } - - requestURI = location.protocol + '//' + domain + '/adserve/;type=hbr;'; - requestURI += 'ID=' + encodeURIComponent(accountID) + ';'; - requestURI += 'setID=' + encodeURIComponent(zoneID) + ';'; - requestURI += 'pid=' + encodeURIComponent(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; - }, - - interpretResponse: function (serverResponse, bidRequest) { - var bidObj = bidRequest.bidRequest; - var bidResponses = []; - var bidResponse = {}; - var isCorrectSize = false; - var isCorrectCPM = true; - var CPM; - var minCPM; - var maxCPM; - var width; - var 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; - } - if (maxCPM !== '' && CPM > parseFloat(maxCPM)) { - isCorrectCPM = false; - } - - // Ensure that response ad matches one of the placement sizes. - utils._each(bidObj.sizes, function (size) { - if (width === size[0] && height === size[1]) { - isCorrectSize = true; - } - }); - if (isCorrectCPM && isCorrectSize) { - bidResponse.requestId = bidObj.bidId; - bidResponse.bidderCode = bidObj.bidder; - bidResponse.creativeId = serverResponse.placement_id; - bidResponse.cpm = CPM; - bidResponse.width = width; - bidResponse.height = height; - bidResponse.ad = serverResponse.ad_code; - bidResponse.ad += spec.addTrackingPixels(serverResponse.tracking_pixels); - bidResponse.currency = 'USD'; - bidResponse.netRevenue = true; - bidResponse.ttl = config.getConfig('_bidderTimeout'); - bidResponse.referrer = utils.getTopWindowUrl(); - bidResponses.push(bidResponse); - } - } - return bidResponses; - }, - - addTrackingPixels: function (trackingPixels) { - var trackingPixelMarkup = ''; - utils._each(trackingPixels, function (pixelURL) { - var trackingPixel = ''; - - trackingPixelMarkup += trackingPixel; - }); - return trackingPixelMarkup; - } -}; -registerBidder(spec); diff --git a/modules/adformBidAdapter.js b/modules/adformBidAdapter.js index d344908c6384..7ffd79328b16 100644 --- a/modules/adformBidAdapter.js +++ b/modules/adformBidAdapter.js @@ -42,7 +42,7 @@ export const spec = { request.push(formRequestUrl(reqParams)); } - request.unshift('//' + globalParams[0][1] + '/adx/?rp=4'); + request.unshift('https://' + globalParams[0][1] + '/adx/?rp=4'); netRevenue = netRevenue || 'gross'; request.push('pt=' + netRevenue); request.push('stid=' + validBidRequests[0].auctionId); diff --git a/modules/adformOpenRTBBidAdapter.js b/modules/adformOpenRTBBidAdapter.js index 98e6de8036a2..a936c39d6250 100644 --- a/modules/adformOpenRTBBidAdapter.js +++ b/modules/adformOpenRTBBidAdapter.js @@ -129,7 +129,7 @@ export const spec = { return { method: 'POST', - url: '//' + adxDomain + '/adx/openrtb', + url: 'https://' + adxDomain + '/adx/openrtb', data: JSON.stringify(request), options: { contentType: 'application/json' diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js index 77b6acbf0e02..0a8466ce4779 100644 --- a/modules/adgenerationBidAdapter.js +++ b/modules/adgenerationBidAdapter.js @@ -28,7 +28,7 @@ export const spec = { let serverRequests = []; for (let i = 0, len = validBidRequests.length; i < len; i++) { const validReq = validBidRequests[i]; - const DEBUG_URL = 'http://api-test.scaleout.jp/adsv/v1'; + const DEBUG_URL = 'https://api-test.scaleout.jp/adsv/v1'; const URL = 'https://d.socdm.com/adsv/v1'; const url = validReq.params.debug ? DEBUG_URL : URL; let data = ``; diff --git a/modules/adkernelAdnAnalyticsAdapter.js b/modules/adkernelAdnAnalyticsAdapter.js deleted file mode 100644 index b72fc268ea33..000000000000 --- a/modules/adkernelAdnAnalyticsAdapter.js +++ /dev/null @@ -1,378 +0,0 @@ -import adapter from '../src/AnalyticsAdapter'; -import CONSTANTS from '../src/constants.json'; -import adapterManager from '../src/adapterManager'; -import {parse} from '../src/url'; -import * as utils from '../src/utils'; -import {ajax} from '../src/ajax'; - -const ANALYTICS_VERSION = '1.0.0'; -const DEFAULT_QUEUE_TIMEOUT = 4000; -const DEFAULT_HOST = 'tag.adkernel.com'; - -const ADK_HB_EVENTS = { - AUCTION_INIT: 'auctionInit', - BID_REQUEST: 'bidRequested', - BID_RESPONSE: 'bidResponse', - BID_WON: 'bidWon', - AUCTION_END: 'auctionEnd', - TIMEOUT: 'adapterTimedOut' -}; - -function buildRequestTemplate(pubId) { - const url = utils.getTopWindowUrl(); - const ref = utils.getTopWindowReferrer(); - const topLocation = utils.getTopWindowLocation(); - - return { - ver: ANALYTICS_VERSION, - domain: topLocation.hostname, - path: topLocation.pathname, - accId: pubId, - env: { - screen: { - w: window.screen.width, - h: window.screen.height - }, - lang: navigator.language - }, - src: getUmtSource(url, ref) - } -} - -let analyticsAdapter = Object.assign(adapter({analyticsType: 'endpoint'}), - { - track({ eventType, args }) { - if (!analyticsAdapter.context) { - return; - } - let handler = null; - switch (eventType) { - case CONSTANTS.EVENTS.AUCTION_INIT: - if (analyticsAdapter.context.queue) { - analyticsAdapter.context.queue.init(); - } - handler = trackAuctionInit; - break; - case CONSTANTS.EVENTS.BID_REQUESTED: - handler = trackBidRequest; - break; - case CONSTANTS.EVENTS.BID_RESPONSE: - handler = trackBidResponse; - break; - case CONSTANTS.EVENTS.BID_WON: - handler = trackBidWon; - break; - case CONSTANTS.EVENTS.BID_TIMEOUT: - handler = trackBidTimeout; - break; - case CONSTANTS.EVENTS.AUCTION_END: - handler = trackAuctionEnd; - break; - } - if (handler) { - let events = handler(args); - if (analyticsAdapter.context.queue) { - analyticsAdapter.context.queue.push(events); - } - if (eventType === CONSTANTS.EVENTS.AUCTION_END) { - sendAll(); - } - } - } - }); - -analyticsAdapter.context = {}; - -analyticsAdapter.originEnableAnalytics = analyticsAdapter.enableAnalytics; - -analyticsAdapter.enableAnalytics = (config) => { - if (!config.options.pubId) { - utils.logError('PubId is not defined. Analytics won\'t work'); - return; - } - analyticsAdapter.context = { - host: config.options.host || DEFAULT_HOST, - pubId: config.options.pubId, - requestTemplate: buildRequestTemplate(config.options.pubId), - queue: new ExpiringQueue(sendAll, config.options.queueTimeout || DEFAULT_QUEUE_TIMEOUT) - }; - analyticsAdapter.originEnableAnalytics(config); -}; - -adapterManager.registerAnalyticsAdapter({ - adapter: analyticsAdapter, - code: 'adkernelAdn' -}); - -export default analyticsAdapter; - -function sendAll() { - let events = analyticsAdapter.context.queue.popAll(); - if (events.length !== 0) { - let req = Object.assign({}, analyticsAdapter.context.requestTemplate, {hb_ev: events}); - analyticsAdapter.ajaxCall(JSON.stringify(req)); - } -} - -analyticsAdapter.ajaxCall = function ajaxCall(data) { - ajax(`//${analyticsAdapter.context.host}/hb-analytics`, () => { - }, data); -}; - -function trackAuctionInit() { - analyticsAdapter.context.auctionTimeStart = Date.now(); - const event = createHbEvent(undefined, ADK_HB_EVENTS.AUCTION_INIT); - return [event]; -} - -function trackBidRequest(args) { - return args.bids.map(bid => - createHbEvent(args.bidderCode, ADK_HB_EVENTS.BID_REQUEST, bid.adUnitCode)); -} - -function trackBidResponse(args) { - const event = createHbEvent(args.bidderCode, ADK_HB_EVENTS.BID_RESPONSE, - args.adUnitCode, args.cpm, args.timeToRespond / 1000); - return [event]; -} - -function trackBidWon(args) { - const event = createHbEvent(args.bidderCode, ADK_HB_EVENTS.BID_WON, args.adUnitCode, args.cpm); - return [event]; -} - -function trackAuctionEnd(args) { - const event = createHbEvent(undefined, ADK_HB_EVENTS.AUCTION_END, undefined, - undefined, (Date.now() - analyticsAdapter.context.auctionTimeStart) / 1000); - return [event]; -} - -function trackBidTimeout(args) { - return args.map(bidderName => createHbEvent(bidderName, ADK_HB_EVENTS.TIMEOUT)); -} - -function createHbEvent(adapter, event, tagid = undefined, value = 0, time = 0) { - let ev = { event: event }; - if (adapter) { - ev.adapter = adapter - } - if (tagid) { - ev.tagid = tagid; - } - if (value) { - ev.val = value; - } - if (time) { - ev.time = time; - } - return ev; -} - -const UTM_TAGS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', - 'utm_c1', 'utm_c2', 'utm_c3', 'utm_c4', 'utm_c5']; -const ADKERNEL_PREBID_KEY = 'adk_dpt_analytics'; -const DIRECT = '(direct)'; -const REFERRAL = '(referral)'; -const ORGANIC = '(organic)'; - -export let storage = { - getItem: (name) => { - return localStorage.getItem(name); - }, - setItem: (name, value) => { - localStorage.setItem(name, value); - } -}; - -export function getUmtSource(pageUrl, referrer) { - let prevUtm = getPreviousTrafficSource(); - let currUtm = getCurrentTrafficSource(pageUrl, referrer); - let [updated, actual] = chooseActualUtm(prevUtm, currUtm); - if (updated) { - storeUtm(actual); - } - return actual; - - function getPreviousTrafficSource() { - let val = storage.getItem(ADKERNEL_PREBID_KEY); - if (!val) { - return getDirect(); - } - return JSON.parse(val); - } - - function getCurrentTrafficSource(pageUrl, referrer) { - var source = getUTM(pageUrl); - if (source) { - return source; - } - if (referrer) { - let se = getSearchEngine(referrer); - if (se) { - return asUtm(se, ORGANIC, ORGANIC); - } - let parsedUrl = parse(pageUrl); - let [refHost, refPath] = getReferrer(referrer); - if (refHost && refHost !== parsedUrl.hostname) { - return asUtm(refHost, REFERRAL, REFERRAL, '', refPath); - } - } - return getDirect(); - } - - function getSearchEngine(pageUrl) { - let engines = { - 'google': /^https?\:\/\/(?:www\.)?(?:google\.(?:com?\.)?(?:com|cat|[a-z]{2})|g.cn)\//i, - 'yandex': /^https?\:\/\/(?:www\.)?ya(?:ndex\.(?:com|net)?\.?(?:asia|mobi|org|[a-z]{2})?|\.ru)\//i, - 'bing': /^https?\:\/\/(?:www\.)?bing\.com\//i, - 'duckduckgo': /^https?\:\/\/(?:www\.)?duckduckgo\.com\//i, - 'ask': /^https?\:\/\/(?:www\.)?ask\.com\//i, - 'yahoo': /^https?\:\/\/(?:[-a-z]+\.)?(?:search\.)?yahoo\.com\//i - }; - - for (let engine in engines) { - if (engines.hasOwnProperty(engine) && engines[engine].test(pageUrl)) { - return engine; - } - } - } - - function getReferrer(referrer) { - let ref = parse(referrer); - return [ref.hostname, ref.pathname]; - } - - function getUTM(pageUrl) { - let urlParameters = parse(pageUrl).search; - if (!urlParameters['utm_campaign'] || !urlParameters['utm_source']) { - return; - } - let utmArgs = []; - utils._each(UTM_TAGS, (utmTagName) => { - let utmValue = urlParameters[utmTagName] || ''; - utmArgs.push(utmValue); - }); - return asUtm.apply(this, utmArgs); - } - - function getDirect() { - return asUtm(DIRECT, DIRECT, DIRECT); - } - - function storeUtm(utm) { - let val = JSON.stringify(utm); - storage.setItem(ADKERNEL_PREBID_KEY, val); - } - - function asUtm(source, medium, campaign, term = '', content = '', c1 = '', c2 = '', c3 = '', c4 = '', c5 = '') { - let result = { - source: source, - medium: medium, - campaign: campaign - }; - if (term) { - result.term = term; - } - if (content) { - result.content = content; - } - if (c1) { - result.c1 = c1; - } - if (c2) { - result.c2 = c2; - } - if (c3) { - result.c3 = c3; - } - if (c4) { - result.c4 = c4; - } - if (c5) { - result.c5 = c5; - } - return result; - } - - function chooseActualUtm(prev, curr) { - if (ord(prev) < ord(curr)) { - return [true, curr]; - } if (ord(prev) > ord(curr)) { - return [false, prev]; - } else { - if (prev.campaign === REFERRAL && prev.content !== curr.content) { - return [true, curr]; - } else if (prev.campaign === ORGANIC && prev.source !== curr.source) { - return [true, curr]; - } else if (isCampaignTraffic(prev) && (prev.campaign !== curr.campaign || prev.source !== curr.source)) { - return [true, curr]; - } - } - return [false, prev]; - } - - function ord(utm) { - switch (utm.campaign) { - case DIRECT: - return 0; - case ORGANIC: - return 1; - case REFERRAL: - return 2; - default: - return 3; - } - } - - function isCampaignTraffic(utm) { - return [DIRECT, REFERRAL, ORGANIC].indexOf(utm.campaign) === -1; - } -} - -/** - * Expiring queue implementation. Fires callback on elapsed timeout since last last update or creation. - * @param callback - * @param ttl - * @constructor - */ -export function ExpiringQueue(callback, ttl) { - let queue = []; - let timeoutId; - - this.push = (event) => { - if (event instanceof Array) { - queue.push.apply(queue, event); - } else { - queue.push(event); - } - reset(); - }; - - this.popAll = () => { - let result = queue; - queue = []; - reset(); - return result; - }; - - /** - * For test/debug purposes only - * @return {Array} - */ - this.peekAll = () => { - return queue; - }; - - this.init = reset; - - function reset() { - if (timeoutId) { - clearTimeout(timeoutId); - } - timeoutId = setTimeout(() => { - if (queue.length) { - callback(); - } - }, ttl); - } -} diff --git a/modules/admanBidAdapter.js b/modules/admanBidAdapter.js deleted file mode 100644 index 4720d06d094e..000000000000 --- a/modules/admanBidAdapter.js +++ /dev/null @@ -1,79 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; - -const BIDDER_CODE = 'adman'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['video', 'banner'], - isBidRequestValid: function(bid) { - const isValid = _validateId(utils.deepAccess(bid, 'params.id')); - if (!isValid) { - utils.logError('Adman id parameter is required. Bid aborted.'); - } - return isValid; - }, - buildRequests: function(validBidRequests, bidderRequest) { - const ENDPOINT_URL = '//bidtor.admanmedia.com/prebid'; - const bids = validBidRequests.map(buildRequestObject); - const payload = { - referer: utils.getTopWindowUrl(), - bids, - deviceWidth: screen.width - }; - - if (bidderRequest && bidderRequest.gdprConsent) { - payload.gdpr = { - consent: bidderRequest.gdprConsent.consentString, - applies: bidderRequest.gdprConsent.gdprApplies - }; - } else { - payload.gdpr = { - consent: '' - } - } - - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: ENDPOINT_URL, - data: payloadString, - }; - }, - interpretResponse: function(serverResponse) { - serverResponse = serverResponse.body; - if (serverResponse && typeof serverResponse.bids === 'object') { - return serverResponse.bids; - } - return []; - }, - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: '//cs.admanmedia.com/sync_tag/html' - }]; - } - } -}; - -function buildRequestObject(bid) { - return { - params: { - id: utils.getValue(bid.params, 'id'), - bidId: bid.bidId - }, - sizes: bid.sizes, - bidId: utils.getBidIdParameter('bidId', bid), - bidderRequestId: utils.getBidIdParameter('bidderRequestId', bid), - adUnitCode: utils.getBidIdParameter('adUnitCode', bid), - auctionId: utils.getBidIdParameter('auctionId', bid), - transactionId: utils.getBidIdParameter('transactionId', bid) - }; -} - -function _validateId(id = '') { - return (id.length === 8); -} - -registerBidder(spec); diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 727b1553d219..c0f32319d795 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -2,7 +2,7 @@ import * as utils from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; const BIDDER_CODE = 'admatic'; -const ENDPOINT_URL = '//ads4.admatic.com.tr/prebid/v3/bidrequest'; +const ENDPOINT_URL = 'https://ads4.admatic.com.tr/prebid/v3/bidrequest'; export const spec = { code: BIDDER_CODE, @@ -108,7 +108,7 @@ export const spec = { if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: '//ads4.admatic.com.tr/prebid/static/usersync/v3/async_usersync.html' + url: 'https://ads4.admatic.com.tr/prebid/static/usersync/v3/async_usersync.html' }); } diff --git a/modules/admediaBidAdapter.js b/modules/admediaBidAdapter.js index 73d6ea08eea2..d6d7044a3719 100644 --- a/modules/admediaBidAdapter.js +++ b/modules/admediaBidAdapter.js @@ -2,7 +2,7 @@ import * as utils from '../src/utils'; import {registerBidder} from '../src/adapters/bidderFactory'; const BIDDER_CODE = 'admedia'; -const ENDPOINT_URL = '//prebid.admedia.com/bidder/'; +const ENDPOINT_URL = 'https://prebid.admedia.com/bidder/'; export const spec = { code: BIDDER_CODE, diff --git a/modules/admixerBidAdapter.js b/modules/admixerBidAdapter.js deleted file mode 100644 index c6d6dd34a114..000000000000 --- a/modules/admixerBidAdapter.js +++ /dev/null @@ -1,73 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'admixer'; -const ALIASES = ['go2net']; -const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; -export const spec = { - code: BIDDER_CODE, - aliases: ALIASES, - 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.zone; - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {bidderRequest} - bidderRequest.bids[] is an array of AdUnits and bids - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function (bidderRequest) { - const payload = { - imps: [], - referrer: encodeURIComponent(utils.getTopWindowUrl()), - }; - bidderRequest.forEach((bid) => { - payload.imps.push(bid); - }); - const payloadString = JSON.stringify(payload); - return { - method: 'GET', - url: ENDPOINT_URL, - data: `data=${payloadString}`, - }; - }, - /** - * 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 bidResponses = []; - // loop through serverResponses { - try { - serverResponse = serverResponse.body; - serverResponse.forEach((bidResponse) => { - const bidResp = { - requestId: bidResponse.bidId, - cpm: bidResponse.cpm, - width: bidResponse.width, - height: bidResponse.height, - ad: bidResponse.ad, - ttl: bidResponse.ttl, - creativeId: bidResponse.creativeId, - netRevenue: bidResponse.netRevenue, - currency: bidResponse.currency, - vastUrl: bidResponse.vastUrl, - }; - bidResponses.push(bidResp); - }); - } catch (e) { - utils.logError(e); - } - return bidResponses; - } -}; -registerBidder(spec); diff --git a/modules/adspendBidAdapter.js b/modules/adspendBidAdapter.js index 7818e3fc9107..d96ae20f8950 100644 --- a/modules/adspendBidAdapter.js +++ b/modules/adspendBidAdapter.js @@ -5,8 +5,8 @@ import { registerBidder } from '../src/adapters/bidderFactory'; import { BANNER } from '../src/mediaTypes'; const BIDDER_CODE = 'adspend'; -const BID_URL = '//rtb.com.ru/headerbidding-bid'; -const SYNC_URL = '//rtb.com.ru/headerbidding-sync?uid={UUID}'; +const BID_URL = 'https://rtb.com.ru/headerbidding-bid'; +const SYNC_URL = 'https://rtb.com.ru/headerbidding-sync?uid={UUID}'; const COOKIE_NAME = 'hb-adspend-id'; const UUID_LEN = 36; const TTL = 10000; diff --git a/modules/adspiritBidAdapter.js b/modules/adspiritBidAdapter.js deleted file mode 100644 index a428a5c88293..000000000000 --- a/modules/adspiritBidAdapter.js +++ /dev/null @@ -1,72 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -const RTB_URL = '/rtb/getbid.php?rtbprovider=prebid'; -const SCRIPT_URL = '/adasync.min.js'; -export const spec = { - code: 'adspirit', - aliases: ['xapadsmedia', 'connectad'], - isBidRequestValid: function(bid) { - let host = spec.getBidderHost(bid); - if (!host) return false; - if (!bid.params.placementId) return false; - return true; - }, - buildRequests: function(validBidRequests) { - let requests = []; - let bidRequest; - let reqUrl; - let placementId; - for (let i = 0; i < validBidRequests.length; i++) { - bidRequest = validBidRequests[i]; - bidRequest.adspiritConId = spec.genAdConId(bidRequest); - reqUrl = spec.getBidderHost(bidRequest); - placementId = utils.getBidIdParameter('placementId', bidRequest.params); - reqUrl = '//' + reqUrl + RTB_URL + '&pid=' + placementId + '&ref=' + encodeURIComponent(utils.getTopWindowUrl()) + '&scx=' + (screen.width) + '&scy=' + (screen.height) + '&wcx=' + ('innerWidth' in window ? window.innerWidth : page.clientWidth) + '&wcy=' + ('innerHeight' in window ? window.innerHeight : page.clientHeight) + '&async=' + bidRequest.adspiritConId + '&t=' + Math.round(Math.random() * 100000); - requests.push({ - method: 'GET', - url: reqUrl, - data: {}, - bidRequest: bidRequest - }); - } - return requests; - }, - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - let bidObj = bidRequest.bidRequest; - - if (!serverResponse || !serverResponse.body || !bidObj) { - utils.logWarn(`No valid bids from ${spec.code} bidder!`); - return []; - } - let adData = serverResponse.body; - let cpm = adData.cpm; - if (!cpm) return []; - - let host = spec.getBidderHost(bidObj); - let adm = 'window.inDapIF=false' + '' + adData.adm; - const bidResponse = { - requestId: bidObj.bidId, - cpm: cpm, - width: adData.w, - height: adData.h, - creativeId: bidObj.params.placementId, - currency: 'EUR', - netRevenue: true, - ttl: 300, - ad: adm - }; - bidResponses.push(bidResponse); - return bidResponses; - }, - getBidderHost: function(bid) { - if (bid.bidder === 'adspirit') return utils.getBidIdParameter('host', bid.params); - if (bid.bidder === 'connectad') return 'connected-by.connectad.io'; - if (bid.bidder === 'xapadsmedia') return 'dsp.xapads.com'; - return null; - }, - genAdConId: function(bid) { - return bid.bidder + Math.round(Math.random() * 100000); - } -} -registerBidder(spec); diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js deleted file mode 100644 index 0db8394ee0fc..000000000000 --- a/modules/adtelligentBidAdapter.js +++ /dev/null @@ -1,243 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {VIDEO, BANNER} from '../src/mediaTypes'; -import {Renderer} from '../src/Renderer'; -import findIndex from 'core-js/library/fn/array/find-index'; - -const URL = '//hb.adtelligent.com/auction/'; -const OUTSTREAM_SRC = '//player.adtelligent.com/outstream-unit/2.01/outstream.min.js'; -const BIDDER_CODE = 'adtelligent'; -const OUTSTREAM = 'outstream'; -const DISPLAY = 'display'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['onefiftytwomedia'], - supportedMediaTypes: [VIDEO, BANNER], - isBidRequestValid: function (bid) { - return bid && bid.params && bid.params.aid; - }, - getUserSyncs: function (syncOptions, serverResponses) { - var syncs = []; - - function addSyncs(bid) { - const uris = bid.cookieURLs; - const types = bid.cookieURLSTypes || []; - - if (uris && uris.length) { - uris.forEach((uri, i) => { - let type = types[i] || 'image'; - - if ((!syncOptions.pixelEnabled && type == 'image') || - (!syncOptions.iframeEnabled && type == 'iframe')) { - return; - } - - syncs.push({ - type: type, - url: uri - }) - }) - } - } - - if (syncOptions.pixelEnabled || syncOptions.iframeEnabled) { - serverResponses && serverResponses.length && serverResponses.forEach((response) => { - if (response.body) { - if (utils.isArray(response.body)) { - response.body.forEach(b => { - addSyncs(b); - }) - } else { - addSyncs(response.body) - } - } - }) - } - return syncs; - }, - /** - * Make a server request from the list of BidRequests - * @param bidRequests - * @param bidderRequest - */ - buildRequests: function (bidRequests, bidderRequest) { - return { - data: bidToTag(bidRequests, bidderRequest), - bidderRequest, - method: 'GET', - url: URL - }; - }, - - /** - * Unpack the response from the server into a list of bids - * @param serverResponse - * @param bidderRequest - * @return {Bid[]} An array of bids which were nested inside the server - */ - interpretResponse: function (serverResponse, {bidderRequest}) { - serverResponse = serverResponse.body; - let bids = []; - - if (!utils.isArray(serverResponse)) { - return parseRTBResponse(serverResponse, bidderRequest); - } - - serverResponse.forEach(serverBidResponse => { - bids = utils.flatten(bids, parseRTBResponse(serverBidResponse, bidderRequest)); - }); - - return bids; - } -}; - -function parseRTBResponse(serverResponse, bidderRequest) { - const isInvalidValidResp = !serverResponse || !serverResponse.bids || !serverResponse.bids.length; - - let bids = []; - - if (isInvalidValidResp) { - let extMessage = serverResponse && serverResponse.ext && serverResponse.ext.message ? `: ${serverResponse.ext.message}` : ''; - let errorMessage = `in response for ${bidderRequest.bidderCode} adapter ${extMessage}`; - - utils.logError(errorMessage); - - return bids; - } - - serverResponse.bids.forEach(serverBid => { - const requestId = findIndex(bidderRequest.bids, (bidRequest) => { - return bidRequest.bidId === serverBid.requestId; - }); - - if (serverBid.cpm !== 0 && requestId !== -1) { - const bid = createBid(serverBid, getMediaType(bidderRequest.bids[requestId])); - - bids.push(bid); - } - }); - - return bids; -} - -function bidToTag(bidRequests, bidderRequest) { - let tag = { - domain: utils.getTopWindowLocation().hostname - }; - - if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { - tag.gdpr = 1; - tag.gdpr_consent = bidderRequest.gdprConsent.consentString; - } - - for (let i = 0, length = bidRequests.length; i < length; i++) { - Object.assign(tag, prepareRTBRequestParams(i, bidRequests[i])); - } - - return tag; -} - -/** - * Parse mediaType - * @param _index {number} - * @param bid {object} - * @returns {object} - */ -function prepareRTBRequestParams(_index, bid) { - const mediaType = utils.deepAccess(bid, 'mediaTypes.video') ? VIDEO : DISPLAY; - const index = !_index ? '' : `${_index + 1}`; - - return { - ['callbackId' + index]: bid.bidId, - ['aid' + index]: bid.params.aid, - ['ad_type' + index]: mediaType, - ['sizes' + index]: utils.parseSizesInput(bid.sizes).join() - }; -} - -/** - * Prepare all parameters for request - * @param bidderRequest {object} - * @returns {object} - */ -function getMediaType(bidderRequest) { - const videoMediaType = utils.deepAccess(bidderRequest, 'mediaTypes.video'); - const context = utils.deepAccess(bidderRequest, 'mediaTypes.video.context'); - - return !videoMediaType ? DISPLAY : context === OUTSTREAM ? OUTSTREAM : VIDEO; -} - -/** - * Configure new bid by response - * @param bidResponse {object} - * @param mediaType {Object} - * @returns {object} - */ -function createBid(bidResponse, mediaType) { - let bid = { - requestId: bidResponse.requestId, - creativeId: bidResponse.cmpId, - height: bidResponse.height, - currency: bidResponse.cur, - width: bidResponse.width, - cpm: bidResponse.cpm, - netRevenue: true, - mediaType, - ttl: 3600 - }; - - if (mediaType === DISPLAY) { - return Object.assign(bid, { - ad: bidResponse.ad - }); - } - - Object.assign(bid, { - vastUrl: bidResponse.vastUrl - }); - - if (mediaType === OUTSTREAM) { - Object.assign(bid, { - mediaType: 'video', - adResponse: bidResponse, - renderer: newRenderer(bidResponse.requestId) - }); - } - - return bid; -} - -/** - * Create Adtelligent renderer - * @param requestId - * @returns {*} - */ -function newRenderer(requestId) { - const renderer = Renderer.install({ - id: requestId, - url: OUTSTREAM_SRC, - loaded: false - }); - - renderer.setRender(outstreamRender); - - return renderer; -} - -/** - * Initialise Adtelligent outstream - * @param bid - */ -function outstreamRender(bid) { - bid.renderer.push(() => { - window.VOutstreamAPI.initOutstreams([{ - width: bid.width, - height: bid.height, - vastUrl: bid.vastUrl, - elId: bid.adUnitCode - }]); - }); -} - -registerBidder(spec); diff --git a/modules/aduptechBidAdapter.js b/modules/aduptechBidAdapter.js deleted file mode 100644 index e00b8422b81d..000000000000 --- a/modules/aduptechBidAdapter.js +++ /dev/null @@ -1,79 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes' - -export const BIDDER_CODE = 'aduptech'; -export const PUBLISHER_PLACEHOLDER = '{PUBLISHER}'; -export const ENDPOINT_URL = window.location.protocol + '//rtb.d.adup-tech.com/prebid/' + PUBLISHER_PLACEHOLDER + '_bid'; -export const ENDPOINT_METHOD = 'POST'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - isBidRequestValid: (bid) => { - return !!(bid && - bid.sizes && - bid.sizes.length > 0 && - bid.params && - bid.params.publisher && - bid.params.placement); - }, - - buildRequests: (validBidRequests, bidderRequest) => { - const bidRequests = []; - - // collect GDPR information - let gdpr = null; - if (bidderRequest && bidderRequest.gdprConsent) { - gdpr = { - consentString: bidderRequest.gdprConsent.consentString, - consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true - }; - } - - validBidRequests.forEach((bidRequest) => { - bidRequests.push({ - url: ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, encodeURIComponent(bidRequest.params.publisher)), - method: ENDPOINT_METHOD, - data: { - pageUrl: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - bidId: bidRequest.bidId, - auctionId: bidRequest.auctionId, - transactionId: bidRequest.transactionId, - adUnitCode: bidRequest.adUnitCode, - sizes: bidRequest.sizes, - params: bidRequest.params, - gdpr: gdpr - } - }); - }); - - return bidRequests; - }, - - interpretResponse: (response) => { - const bidResponses = []; - - if (!response.body || !response.body.bid || !response.body.creative) { - return bidResponses; - } - - bidResponses.push({ - requestId: response.body.bid.bidId, - cpm: response.body.bid.price, - netRevenue: response.body.bid.net, - currency: response.body.bid.currency, - ttl: response.body.bid.ttl, - creativeId: response.body.creative.id, - width: response.body.creative.width, - height: response.body.creative.height, - ad: response.body.creative.html - }); - - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/advenueBidAdapter.js b/modules/advenueBidAdapter.js index 6dc5856eacbc..567f60b6123e 100644 --- a/modules/advenueBidAdapter.js +++ b/modules/advenueBidAdapter.js @@ -3,7 +3,7 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; import * as utils from '../src/utils'; const BIDDER_CODE = 'advenue'; -const URL_MULTI = '//ssp.advenuemedia.co.uk/?c=o&m=multi'; +const URL_MULTI = 'https://ssp.advenuemedia.co.uk/?c=o&m=multi'; export const spec = { code: BIDDER_CODE, diff --git a/modules/ajaBidAdapter.js b/modules/ajaBidAdapter.js index be7e1238f648..de88198f48a6 100644 --- a/modules/ajaBidAdapter.js +++ b/modules/ajaBidAdapter.js @@ -4,7 +4,7 @@ import { registerBidder } from '../src/adapters/bidderFactory'; import { VIDEO, BANNER, NATIVE } from '../src/mediaTypes'; const BIDDER_CODE = 'aja'; -const URL = '//ad.as.amanad.adtdp.com/v2/prebid'; +const URL = 'https://ad.as.amanad.adtdp.com/v2/prebid'; const SDK_TYPE = 5; const AD_TYPE = { BANNER: 1, diff --git a/modules/andbeyondBidAdapter.js b/modules/andbeyondBidAdapter.js deleted file mode 100644 index ccb419076af1..000000000000 --- a/modules/andbeyondBidAdapter.js +++ /dev/null @@ -1,168 +0,0 @@ -import * as utils from '../src/utils'; -import { BANNER } from '../src/mediaTypes'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import find from 'core-js/library/fn/array/find'; - -const VERSION = '1.1'; - -/** - * Adapter for requesting bids from andbeyond white-label display platform - */ -export const spec = { - - code: 'andbeyond', - aliases: ['headbidding'], - supportedMediaTypes: [BANNER], - isBidRequestValid: function(bidRequest) { - return 'params' in bidRequest && typeof bidRequest.params.host !== 'undefined' && - 'zoneId' in bidRequest.params && !isNaN(Number(bidRequest.params.zoneId)); - }, - buildRequests: function(bidRequests) { - let auctionId; - let dispatch = bidRequests.map(buildImp) - .reduce((acc, curr, index) => { - let bidRequest = bidRequests[index]; - let zoneId = bidRequest.params.zoneId; - let host = bidRequest.params.host; - acc[host] = acc[host] || {}; - acc[host][zoneId] = acc[host][zoneId] || []; - acc[host][zoneId].push(curr); - auctionId = bidRequest.bidderRequestId; - return acc; - }, {}); - let requests = []; - Object.keys(dispatch).forEach(host => { - Object.keys(dispatch[host]).forEach(zoneId => { - const request = buildRtbRequest(dispatch[host][zoneId], auctionId); - requests.push({ - method: 'GET', - url: `${window.location.protocol}//${host}/rtbg`, - data: { - zone: Number(zoneId), - ad_type: 'rtb', - v: VERSION, - r: JSON.stringify(request) - } - }); - }); - }); - return requests; - }, - interpretResponse: function(serverResponse, request) { - let response = serverResponse.body; - if (!response.seatbid) { - return []; - } - - let rtbRequest = JSON.parse(request.data.r); - let rtbImps = rtbRequest.imp; - let rtbBids = response.seatbid - .map(seatbid => seatbid.bid) - .reduce((a, b) => a.concat(b), []); - - return rtbBids.map(rtbBid => { - let imp = find(rtbImps, imp => imp.id === rtbBid.impid); - let prBid = { - requestId: rtbBid.impid, - cpm: rtbBid.price, - creativeId: rtbBid.crid, - currency: 'USD', - ttl: 360, - netRevenue: true - }; - if ('banner' in imp) { - prBid.mediaType = BANNER; - prBid.width = rtbBid.w; - prBid.height = rtbBid.h; - prBid.ad = formatAdMarkup(rtbBid); - } - return prBid; - }); - }, - getUserSyncs: function(syncOptions, serverResponses) { - if (!syncOptions.iframeEnabled || !serverResponses || serverResponses.length === 0) { - return []; - } - return serverResponses.filter(rsp => rsp.body && rsp.body.ext && rsp.body.ext.adk_usersync) - .map(rsp => rsp.body.ext.adk_usersync) - .reduce((a, b) => a.concat(b), []) - .map(syncUrl => ({type: 'iframe', url: syncUrl})); - } -}; - -registerBidder(spec); - -/** - * Builds parameters object for single impression - */ -function buildImp(bid) { - const sizes = bid.sizes; - const imp = { - 'id': bid.bidId, - 'tagid': bid.placementCode - }; - - imp.banner = { - format: sizes.map(s => ({'w': s[0], 'h': s[1]})), - topframe: 0 - }; - if (utils.getTopWindowLocation().protocol === 'https:') { - imp.secure = 1; - } - return imp; -} - -/** - * Builds complete rtb request - * @param imps collection of impressions - * @param auctionId - */ -function buildRtbRequest(imps, auctionId) { - let req = { - 'id': auctionId, - 'imp': imps, - 'site': createSite(), - 'at': 1, - 'device': { - 'ip': 'caller', - 'ua': 'caller', - 'js': 1, - 'language': getLanguage() - }, - 'ext': { - 'adk_usersync': 1 - } - }; - if (utils.getDNT()) { - req.device.dnt = 1; - } - return req; -} - -function getLanguage() { - const language = navigator.language ? 'language' : 'userLanguage'; - return navigator[language].split('-')[0]; -} - -/** - * Creates site description object - */ -function createSite() { - var location = utils.getTopWindowLocation(); - return { - 'domain': location.hostname, - 'page': location.href.split('?')[0] - }; -} - -/** - * Format creative with optional nurl call - * @param bid rtb Bid object - */ -function formatAdMarkup(bid) { - var adm = bid.adm; - if ('nurl' in bid) { - adm += utils.createTrackPixelHtml(`${bid.nurl}&px=1`); - } - return `${adm} `; -} diff --git a/modules/aniviewBidAdapter.js b/modules/aniviewBidAdapter.js deleted file mode 100644 index 0d53ca8ddedb..000000000000 --- a/modules/aniviewBidAdapter.js +++ /dev/null @@ -1,191 +0,0 @@ -import { VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { Renderer } from '../src/Renderer'; - -const BIDDER_CODE = 'aniview'; -const TTL = 600; - -function avRenderer(bid) { - bid.renderer.push(function() { - let eventCallback = bid && bid.renderer && bid.renderer.handleVideoEvent ? bid.renderer.handleVideoEvent : null; - window.aniviewRenderer.renderAd({ - id: bid.adUnitCode + '_' + bid.adId, - debug: window.location.href.indexOf('pbjsDebug') >= 0, - placement: bid.adUnitCode, - width: bid.width, - height: bid.height, - vastUrl: bid.vastUrl, - vastXml: bid.vastXml, - config: bid.params[0].rendererConfig, - eventsCallback: eventCallback, - bid: bid - }); - }); -} - -function newRenderer(bidRequest) { - const renderer = Renderer.install({ - url: 'https://player.aniview.com/script/6.1/prebidRenderer.js', - config: {}, - loaded: false, - }); - - try { - renderer.setRender(avRenderer); - } catch (err) { - } - - return renderer; -} - -function isBidRequestValid(bid) { - if (!bid.params || !bid.params.AV_PUBLISHERID || !bid.params.AV_CHANNELID) { return false; } - - return true; -} - -function buildRequests(validBidRequests, bidderRequest) { - let bidRequests = []; - - for (let i = 0; i < validBidRequests.length; i++) { - let bidRequest = validBidRequests[i]; - - if (!bidRequest.sizes || !bidRequest.sizes.length) { - bidRequest.sizes = [[640, 480]]; - } - - if (bidRequest.sizes.length === 2 && typeof bidRequest.sizes[0] === 'number' && typeof bidRequest.sizes[1] === 'number') { - let adWidth = bidRequest.sizes[0]; - let adHeight = bidRequest.sizes[1]; - bidRequest.sizes = [[adWidth, adHeight]]; - } - - for (let j = 0; j < bidRequest.sizes.length; j++) { - let size = bidRequest.sizes[j]; - let playerWidth; - let playerHeight; - if (size && size.length == 2) { - playerWidth = size[0]; - playerHeight = size[1]; - } else { - playerWidth = 640; - playerHeight = 480; - } - - let s2sParams = {}; - - for (var attrname in bidRequest.params) { - if (bidRequest.params.hasOwnProperty(attrname) && attrname.indexOf('AV_') == 0) { - s2sParams[attrname] = bidRequest.params[attrname]; - } - }; - - if (s2sParams.AV_APPPKGNAME && !s2sParams.AV_URL) { s2sParams.AV_URL = s2sParams.AV_APPPKGNAME; } - if (!s2sParams.AV_IDFA && !s2sParams.AV_URL) { s2sParams.AV_URL = utils.getTopWindowUrl(); } - if (s2sParams.AV_IDFA && !s2sParams.AV_AID) { s2sParams.AV_AID = s2sParams.AV_IDFA; } - if (s2sParams.AV_AID && !s2sParams.AV_IDFA) { s2sParams.AV_IDFA = s2sParams.AV_AID; } - - s2sParams.pbjs = 1; - s2sParams.cb = Math.floor(Math.random() * 999999999); - s2sParams.AV_WIDTH = playerWidth; - s2sParams.AV_HEIGHT = playerHeight; - s2sParams.s2s = '1'; - s2sParams.bidId = bidRequest.bidId; - s2sParams.bidWidth = playerWidth; - s2sParams.bidHeight = playerHeight; - - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.gdprApplies) { - s2sParams.AV_GDPR = 1; - s2sParams.AV_CONSENT = bidderRequest.gdprConsent.consentString - } - } - - let serverDomain = bidRequest.params && bidRequest.params.serverDomain ? bidRequest.params.serverDomain : 'gov.aniview.com'; - let serverUrl = 'https://' + serverDomain + '/api/adserver/vast3/'; - - bidRequests.push({ - method: 'GET', - url: serverUrl, - data: s2sParams, - bidRequest - }); - } - } - - return bidRequests; -} -function getCpmData(xml) { - let ret = {cpm: 0, currency: 'USD'}; - if (xml) { - let ext = xml.getElementsByTagName('Extensions'); - if (ext && ext.length > 0) { - ext = ext[0].getElementsByTagName('Extension'); - if (ext && ext.length > 0) { - for (var i = 0; i < ext.length; i++) { - if (ext[i].getAttribute('type') == 'ANIVIEW') { - let price = ext[i].getElementsByTagName('Cpm'); - if (price && price.length == 1) { - ret.cpm = price[0].textContent; - } - break; - } - } - } - } - } - return ret; -} -function interpretResponse(serverResponse, bidRequest) { - let bidResponses = []; - if (serverResponse && serverResponse.body) { - if (serverResponse.error) { - return bidResponses; - } else { - try { - let bidResponse = {}; - if (bidRequest && bidRequest.data && bidRequest.data.bidId && bidRequest.data.bidId !== '') { - let xmlStr = serverResponse.body; - let xml = new window.DOMParser().parseFromString(xmlStr, 'text/xml'); - if (xml && xml.getElementsByTagName('parsererror').length == 0) { - let cpmData = getCpmData(xml); - if (cpmData && cpmData.cpm > 0) { - bidResponse.requestId = bidRequest.data.bidId; - bidResponse.bidderCode = BIDDER_CODE; - bidResponse.ad = ''; - bidResponse.cpm = cpmData.cpm; - bidResponse.width = bidRequest.data.AV_WIDTH; - bidResponse.height = bidRequest.data.AV_HEIGHT; - bidResponse.ttl = TTL; - bidResponse.creativeId = xml.getElementsByTagName('Ad') && xml.getElementsByTagName('Ad')[0] && xml.getElementsByTagName('Ad')[0].getAttribute('id') ? xml.getElementsByTagName('Ad')[0].getAttribute('id') : 'creativeId'; - bidResponse.currency = cpmData.currency; - bidResponse.netRevenue = true; - var blob = new Blob([xmlStr], { - type: 'application/xml' - }); - bidResponse.vastUrl = window.URL.createObjectURL(blob); - bidResponse.vastXml = xmlStr; - bidResponse.mediaType = VIDEO; - if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') { bidResponse.renderer = newRenderer(bidRequest); } - - bidResponses.push(bidResponse); - } - } else {} - } else {} - } catch (e) {} - } - } else {} - - return bidResponses; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [VIDEO], - isBidRequestValid, - buildRequests, - interpretResponse -} - -registerBidder(spec); diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index c387c9e48187..03ed43133538 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -9,7 +9,7 @@ import includes from 'core-js/library/fn/array/includes'; import { OUTSTREAM, INSTREAM } from '../src/video'; const BIDDER_CODE = 'appnexus'; -const URL = '//ib.adnxs.com/ut/v3/prebid'; +const URL = 'https://ib.adnxs.com/ut/v3/prebid'; const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', 'startdelay', 'skippable', 'playback_method', 'frameworks']; const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; @@ -34,7 +34,7 @@ const NATIVE_MAPPING = { }; const SOURCE = 'pbjs'; const MAX_IMPS_PER_REQUEST = 15; -const mappingFileUrl = '//acdn.adnxs.com/prebid/appnexus-mapping/mappings.json'; +const mappingFileUrl = 'https://acdn.adnxs.com/prebid/appnexus-mapping/mappings.json'; const SCRIPT_TAG_START = ' { 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/audienceNetworkBidAdapter.js b/modules/audienceNetworkBidAdapter.js deleted file mode 100644 index b4cf93363f6b..000000000000 --- a/modules/audienceNetworkBidAdapter.js +++ /dev/null @@ -1,317 +0,0 @@ -/** - * @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'; - -const code = 'audienceNetwork'; -const currency = 'USD'; -const method = 'GET'; -const url = 'https://an.facebook.com/v2/placementbid.json'; -const supportedMediaTypes = ['banner', 'video']; -const netRevenue = true; -const hbBidder = 'fan'; -const ttl = 600; -const videoTtl = 3600; -const platver = '$prebid.version$'; -const platform = '241394079772386'; -const adapterver = '1.3.0'; - -/** - * Does this bid request contain valid parameters? - * @param {Object} bid - * @returns {Boolean} - */ -const isBidRequestValid = bid => - typeof bid.params === 'object' && - typeof bid.params.placementId === 'string' && - bid.params.placementId.length > 0 && - Array.isArray(bid.sizes) && bid.sizes.length > 0 && - (isFullWidth(bid.params.format) ? bid.sizes.map(flattenSize).some(size => size === '300x250') : true) && - (isValidNonSizedFormat(bid.params.format) || bid.sizes.map(flattenSize).some(isValidSize)); - -/** - * Flattens a 2-element [W, H] array as a 'WxH' string, - * otherwise passes value through. - * @param {Array|String} size - * @returns {String} - */ -const flattenSize = size => - (Array.isArray(size) && size.length === 2) ? `${size[0]}x${size[1]}` : size; - -/** - * Expands a 'WxH' string as a 2-element [W, H] array - * @param {String} size - * @returns {Array} - */ -const expandSize = size => size.split('x').map(Number); - -/** - * Is this a valid slot size? - * @param {String} size - * @returns {Boolean} - */ -const isValidSize = size => includes(['300x250', '320x50'], size); - -/** - * Is this a valid, non-sized format? - * @param {String} size - * @returns {Boolean} - */ -const isValidNonSizedFormat = format => includes(['video', 'native'], format); - -/** - * Is this a valid size and format? - * @param {String} size - * @returns {Boolean} - */ -const isValidSizeAndFormat = (size, format) => - (isFullWidth(format) && flattenSize(size) === '300x250') || - isValidNonSizedFormat(format) || - isValidSize(flattenSize(size)); - -/** - * Find a preferred entry, if any, from an array of valid sizes. - * @param {Array} acc - * @param {String} cur - */ -const sortByPreferredSize = (acc, cur) => - (cur === '300x250') ? [cur, ...acc] : [...acc, cur]; - -/** - * Map any deprecated size/formats to new values. - * @param {String} size - * @param {String} format - */ -const mapDeprecatedSizeAndFormat = (size, format) => - isFullWidth(format) ? ['300x250', null] : [size, format]; - -/** - * Is this a video format? - * @param {String} format - * @returns {Boolean} - */ -const isVideo = format => format === 'video'; - -/** - * Is this a fullwidth format? - * @param {String} format - * @returns {Boolean} - */ -const isFullWidth = format => format === 'fullwidth'; - -/** - * Which SDK version should be used for this format? - * @param {String} format - * @returns {String} - */ -const sdkVersion = format => isVideo(format) ? '' : '6.0.web'; - -/** - * Which platform identifier should be used? - * @param {Array} platforms Possible platform identifiers - * @returns {String} First valid platform found, or default if none found - */ -const findPlatform = platforms => [...platforms.filter(Boolean), platform][0]; - -/** - * Does the search part of the URL contain "anhb_testmode" - * and therefore indicate testmode should be used? - * @returns {String} "true" or "false" - */ -const isTestmode = () => Boolean( - window && window.location && - typeof window.location.search === 'string' && - window.location.search.indexOf('anhb_testmode') !== -1 -).toString(); - -/** - * Generate ad HTML for injection into an iframe - * @param {String} placementId - * @param {String} format - * @param {String} bidId - * @returns {String} HTML - */ -const createAdHtml = (placementId, format, bidId) => { - const nativeStyle = format === 'native' ? '' : ''; - const nativeContainer = format === 'native' ? '
' : ''; - return ` - ${nativeStyle} - -
- - - ${nativeContainer} -
- -`; -}; - -/** - * 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 - * @param {String} bids[].placementCode - Prebid placement identifier - * @param {Object} bids[].params - * @param {String} bids[].params.placementId - Audience Network placement identifier - * @param {String} bids[].params.platform - Audience Network platform identifier (optional) - * @param {String} bids[].params.format - Optional format, one of 'video' or 'native' if set - * @param {Array} bids[].sizes - list of desired advert sizes - * @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 => { - // Build lists of placementids, adformats, sizes and SDK versions - const placementids = []; - const adformats = []; - const sizes = []; - const sdk = []; - const platforms = []; - const requestIds = []; - - bids.forEach(bid => bid.sizes - .map(flattenSize) - .filter(size => isValidSizeAndFormat(size, bid.params.format)) - .reduce(sortByPreferredSize, []) - .slice(0, 1) - .forEach(preferredSize => { - const [size, format] = mapDeprecatedSizeAndFormat(preferredSize, bid.params.format); - placementids.push(bid.params.placementId); - adformats.push(format || size); - sizes.push(size); - sdk.push(sdkVersion(format)); - platforms.push(bid.params.platform); - requestIds.push(bid.bidId); - }) - ); - - // Build URL - const testmode = isTestmode(); - const pageurl = getTopWindowUrlEncoded(); - const platform = findPlatform(platforms); - const cb = generateUUID(); - const search = { - placementids, - adformats, - testmode, - pageurl, - sdk, - adapterver, - platform, - platver, - cb - }; - const video = findIndex(adformats, isVideo); - if (video !== -1) { - [search.playerwidth, search.playerheight] = expandSize(sizes[video]); - } - const data = formatQS(search); - - return [{ adformats, data, method, requestIds, sizes, url }]; -}; - -/** - * Convert a server response to a bid response. - * @param {Object} response - object representing the response - * @param {Object} response.body - response body, already converted from JSON - * @param {Object} bidRequests - the original bid requests - * @param {Array} bidRequest.adformats - list of formats for the original bid requests - * @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 { bids = {} } = body; - return Object.keys(bids) - // extract Array of bid responses - .map(placementId => bids[placementId]) - // flatten - .reduce((a, b) => a.concat(b), []) - // transform to bidResponse - .map((bid, i) => { - const { - bid_id: fbBidid, - placement_id: creativeId, - bid_price_cents: cpm - } = bid; - - const format = adformats[i]; - const [width, height] = expandSize(flattenSize(sizes[i])); - const ad = createAdHtml(creativeId, format, fbBidid); - const requestId = requestIds[i]; - - const bidResponse = { - // Prebid attributes - requestId, - cpm: cpm / 100, - width, - height, - ad, - ttl, - creativeId, - netRevenue, - currency, - // Audience Network attributes - hb_bidder: hbBidder, - fb_bidid: fbBidid, - fb_format: format, - fb_placementid: creativeId - }; - // 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; - } - return bidResponse; - }); -}; - -/** - * Covert bid param types for S2S - * @param {Object} params bid params - * @param {Boolean} isOpenRtb boolean to check openrtb2 protocol - * @return {Object} params bid params - */ -const transformBidParams = (params, isOpenRtb) => { - return convertTypes({ - 'placementId': 'string' - }, params); -} - -export const spec = { - code, - supportedMediaTypes, - isBidRequestValid, - buildRequests, - interpretResponse, - transformBidParams -}; - -registerBidder(spec); diff --git a/modules/betweenBidAdapter.js b/modules/betweenBidAdapter.js index 9da6b4dbe296..374ea200b60a 100644 --- a/modules/betweenBidAdapter.js +++ b/modules/betweenBidAdapter.js @@ -96,7 +96,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 +108,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/bidfluenceBidAdapter.js b/modules/bidfluenceBidAdapter.js index 4a9c4433ee0e..c6adc2897b0d 100644 --- a/modules/bidfluenceBidAdapter.js +++ b/modules/bidfluenceBidAdapter.js @@ -81,7 +81,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 f5991f7f3a58..553a52b25f43 100644 --- a/modules/bidglassBidAdapter.js +++ b/modules/bidglassBidAdapter.js @@ -22,7 +22,7 @@ export const spec = { * @param {validBidRequests[]} - an array of bids * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(validBidRequests, bidderRequest) { + buildRequests: function(validBidRequests, bidderRequest) { /* Sample array entry for validBidRequests[]: [{ @@ -42,32 +42,32 @@ export const spec = { */ let imps = []; - let getReferer = function() { - return window === window.top ? window.location.href : window.parent === window.top ? document.referrer : null; + 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]; - - 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) { + let getOrigins = function() { + 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]); + ori.push('https://' + parts[2]); - if (window.parent !== window.top) { + if (window.parent !== window.top) { // Additional unknown origins exist - ori.push('null'); - } + ori.push('null'); + } } - return ori; + return ori; }; - utils._each(validBidRequests, function(bid) { + 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)); @@ -76,7 +76,7 @@ export const spec = { bidId: bid.bidId, sizes: bid.sizes, adUnitId: utils.getBidIdParameter('adUnitId', bid.params) - }); + }); }); // Stuff to send: page URL @@ -98,7 +98,7 @@ export const spec = { contentType: 'text/plain', withCredentials: false } - } + } }, /** @@ -107,10 +107,10 @@ export const spec = { * @param {ServerResponse} serverResponse A successful response from the server. * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function(serverResponse) { + interpretResponse: function(serverResponse) { const bidResponses = []; - utils._each(serverResponse.body.bidResponses, function(bid) { + utils._each(serverResponse.body.bidResponses, function(bid) { bidResponses.push({ requestId: bid.requestId, cpm: parseFloat(bid.cpm), @@ -123,10 +123,10 @@ export const spec = { netRevenue: true, ttl: bid.ttl || 10, ad: bid.ad - }); + }); }); - return bidResponses; + return bidResponses; } } diff --git a/modules/bidphysicsBidAdapter.js b/modules/bidphysicsBidAdapter.js index cbd76c8bc108..cdf30e670fc6 100644 --- a/modules/bidphysicsBidAdapter.js +++ b/modules/bidphysicsBidAdapter.js @@ -2,7 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory'; import * as utils from '../src/utils'; import {BANNER} from '../src/mediaTypes'; -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 a9b202b4c977..000000000000 --- 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 a5d076d8fd03..000000000000 --- 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 deleted file mode 100644 index cac827e5a5d0..000000000000 --- a/modules/bridgewellBidAdapter.js +++ /dev/null @@ -1,269 +0,0 @@ -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'; - -const BIDDER_CODE = 'bridgewell'; -const REQUEST_ENDPOINT = '//rec.scupio.com/recweb/prebid.aspx?cb=' + Math.random(); -const BIDDER_VERSION = '0.0.2'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, NATIVE], - - /** - * 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) { - 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; - } - } - } - - return valid; - }, - - /** - * 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 adUnits = []; - utils._each(validBidRequests, function(bid) { - adUnits.push({ - ChannelID: bid.params.ChannelID, - mediaTypes: bid.mediaTypes || { - banner: { - sizes: bid.sizes - } - } - }); - }); - - return { - method: 'POST', - url: REQUEST_ENDPOINT, - data: { - version: { - prebid: '$prebid.version$', - bridgewell: BIDDER_VERSION - }, - inIframe: utils.inIframe(), - url: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - adUnits: adUnits - }, - validBidRequests: validBidRequests - }; - }, - - /** - * 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) { - const bidResponses = []; - - // map responses to requests - utils._each(bidRequest.validBidRequests, function(req) { - const bidResponse = {}; - - if (!serverResponse.body) { - return; - } - - 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; - } - } - } - } - - return valid; - }); - - if (matchedResponse) { - matchedResponse.consumed = true; - - // check required parameters - if (typeof matchedResponse.cpm !== 'number') { - return; - } else if (typeof matchedResponse.netRevenue !== 'boolean') { - return; - } else if (typeof matchedResponse.currency !== 'string') { - return; - } else if (typeof matchedResponse.mediaType !== 'string') { - return; - } - - bidResponse.requestId = req.bidId; - bidResponse.cpm = matchedResponse.cpm * req.params.cpmWeight; - bidResponse.width = matchedResponse.width; - bidResponse.height = matchedResponse.height; - bidResponse.ttl = matchedResponse.ttl; - bidResponse.creativeId = matchedResponse.id; - bidResponse.netRevenue = matchedResponse.netRevenue; - bidResponse.currency = matchedResponse.currency; - bidResponse.mediaType = matchedResponse.mediaType; - - // check required parameters by matchedResponse.mediaType - switch (matchedResponse.mediaType) { - case BANNER: - // check banner required parameters - if (typeof matchedResponse.ad !== 'string') { - return; - } - - bidResponse.ad = matchedResponse.ad; - break; - case NATIVE: - // check native required parameters - if (!matchedResponse.native) { - return; - } - - let reqNativeLayout = req.mediaTypes.native; - let resNative = matchedResponse.native; - - // check title - let title = reqNativeLayout.title; - if (title && title.required) { - if (typeof resNative.title !== 'string') { - return; - } else if (title.len && title.len < resNative.title.length) { - return; - } - } - - // check body - let body = reqNativeLayout.body; - if (body && body.required) { - if (typeof resNative.body !== 'string') { - return; - } - } - - // check image - let image = reqNativeLayout.image; - if (image && image.required) { - if (resNative.image) { - if (typeof resNative.image.url !== 'string') { // check image url - return; - } else { - if (resNative.image.width !== image.sizes[0] || resNative.image.height !== image.sizes[1]) { // check image sizes - return; - } - } - } else { - return; - } - } - - // check sponsoredBy - let sponsoredBy = reqNativeLayout.sponsoredBy; - if (sponsoredBy && sponsoredBy.required) { - if (typeof resNative.sponsoredBy !== 'string') { - return; - } - } - - // check icon - let icon = reqNativeLayout.icon; - if (icon && icon.required) { - if (resNative.icon) { - if (typeof resNative.icon.url !== 'string') { // check icon url - return; - } else { - if (resNative.icon.width !== icon.sizes[0] || resNative.icon.height !== icon.sizes[0]) { // check image sizes - return; - } - } - } else { - return; - } - } - - // check clickUrl - if (typeof resNative.clickUrl !== 'string') { - return; - } - - // check clickTracker - let clickTrackers = resNative.clickTrackers; - if (clickTrackers) { - if (clickTrackers.length === 0) { - return; - } - } else { - return; - } - - // check impressionTrackers - let impressionTrackers = resNative.impressionTrackers; - if (impressionTrackers) { - if (impressionTrackers.length === 0) { - return; - } - } else { - return; - } - - bidResponse.native = matchedResponse.native; - - break; - - default: // response mediaType is not supported - return; - } - - bidResponses.push(bidResponse); - } - }); - - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/c1xBidAdapter.js b/modules/c1xBidAdapter.js index 1e8d3cf2e0ae..9364ef2256ae 100644 --- a/modules/c1xBidAdapter.js +++ b/modules/c1xBidAdapter.js @@ -4,7 +4,7 @@ import { userSync } from '../src/userSync'; 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/ccxBidAdapter.js b/modules/ccxBidAdapter.js deleted file mode 100644 index 226ed44f6da1..000000000000 --- a/modules/ccxBidAdapter.js +++ /dev/null @@ -1,216 +0,0 @@ -import * as utils from '../src/utils' -import { registerBidder } from '../src/adapters/bidderFactory' -import { config } from '../src/config' -const BIDDER_CODE = 'ccx' -const BID_URL = 'https://delivery.clickonometrics.pl/ortb/prebid/bid' -const SUPPORTED_VIDEO_PROTOCOLS = [2, 3, 5, 6] -const SUPPORTED_VIDEO_MIMES = ['video/mp4', 'video/x-flv'] -const SUPPORTED_VIDEO_PLAYBACK_METHODS = [1, 2, 3, 4] - -function _getDeviceObj () { - let device = {} - device.w = screen.width - device.y = screen.height - device.ua = navigator.userAgent - return device -} - -function _getSiteObj () { - let site = {} - let url = config.getConfig('pageUrl') || utils.getTopWindowUrl() - if (url.length > 0) { - url = url.split('?')[0] - } - site.page = url - - return site -} - -function _validateSizes (sizeObj, type) { - if (!utils.isArray(sizeObj) || typeof sizeObj[0] === 'undefined') { - return false - } - - if (type === 'video' && (!utils.isArray(sizeObj[0]) || sizeObj[0].length !== 2)) { - return false - } - - let result = true - - if (type === 'banner') { - utils._each(sizeObj, function (size) { - if (!utils.isArray(size) || (size.length !== 2)) { - result = false - } - }) - return result - } - - if (type === 'old') { - if (!utils.isArray(sizeObj[0]) && sizeObj.length !== 2) { - result = false - } else if (utils.isArray(sizeObj[0])) { - utils._each(sizeObj, function (size) { - if (!utils.isArray(size) || (size.length !== 2)) { - result = false - } - }) - } - return result; - } - - return true -} - -function _buildBid (bid) { - let placement = {} - placement.id = bid.bidId - placement.secure = 1 - - let sizes = utils.deepAccess(bid, 'mediaTypes.banner.sizes') || utils.deepAccess(bid, 'mediaTypes.video.playerSize') || utils.deepAccess(bid, 'sizes') - - if (utils.deepAccess(bid, 'mediaTypes.banner') || utils.deepAccess(bid, 'mediaType') === 'banner' || (!utils.deepAccess(bid, 'mediaTypes.video') && !utils.deepAccess(bid, 'mediaType'))) { - placement.banner = {'format': []} - if (utils.isArray(sizes[0])) { - utils._each(sizes, function (size) { - placement.banner.format.push({'w': size[0], 'h': size[1]}) - }) - } else { - placement.banner.format.push({'w': sizes[0], 'h': sizes[1]}) - } - } else if (utils.deepAccess(bid, 'mediaTypes.video') || utils.deepAccess(bid, 'mediaType') === 'video') { - placement.video = {} - - if (typeof sizes !== 'undefined') { - if (utils.isArray(sizes[0])) { - placement.video.w = sizes[0][0] - placement.video.h = sizes[0][1] - } else { - placement.video.w = sizes[0] - placement.video.h = sizes[1] - } - } - - placement.video.protocols = utils.deepAccess(bid, 'params.video.protocols') || SUPPORTED_VIDEO_PROTOCOLS - placement.video.mimes = utils.deepAccess(bid, 'params.video.mimes') || SUPPORTED_VIDEO_MIMES - placement.video.playbackmethod = utils.deepAccess(bid, 'params.video.playbackmethod') || SUPPORTED_VIDEO_PLAYBACK_METHODS - placement.video.skip = utils.deepAccess(bid, 'params.video.skip') || 0 - if (placement.video.skip === 1 && utils.deepAccess(bid, 'params.video.skipafter')) { - placement.video.skipafter = utils.deepAccess(bid, 'params.video.skipafter') - } - } - - placement.ext = {'pid': bid.params.placementId} - - return placement -} - -function _buildResponse (bid, currency, ttl) { - let resp = { - requestId: bid.impid, - cpm: bid.price, - width: bid.w, - height: bid.h, - creativeId: bid.crid, - netRevenue: false, - ttl: ttl, - currency: currency - } - - if (bid.ext.type === 'video') { - resp.vastXml = bid.adm - } else { - resp.ad = bid.adm - } - - if (utils.deepAccess(bid, 'dealid')) { - resp.dealId = bid.dealid - } - - return resp -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['banner', 'video'], - - isBidRequestValid: function (bid) { - if (!utils.deepAccess(bid, 'params.placementId')) { - utils.logWarn('placementId param is reqeuired.') - return false - } - if (utils.deepAccess(bid, 'mediaTypes.banner.sizes')) { - let isValid = _validateSizes(bid.mediaTypes.banner.sizes, 'banner') - if (!isValid) { - utils.logWarn('Bid sizes are invalid.') - } - return isValid - } else if (utils.deepAccess(bid, 'mediaTypes.video.playerSize')) { - let isValid = _validateSizes(bid.mediaTypes.video.playerSize, 'video') - if (!isValid) { - utils.logWarn('Bid sizes are invalid.') - } - return isValid - } else if (utils.deepAccess(bid, 'sizes')) { - let isValid = _validateSizes(bid.sizes, 'old') - if (!isValid) { - utils.logWarn('Bid sizes are invalid.') - } - return isValid - } else { - utils.logWarn('Bid sizes are required.') - return false - } - }, - buildRequests: function (validBidRequests, bidderRequest) { - // check if validBidRequests is not empty - if (validBidRequests.length > 0) { - let requestBody = {} - requestBody.imp = [] - requestBody.site = _getSiteObj() - requestBody.device = _getDeviceObj() - requestBody.id = bidderRequest.bids[0].auctionId - requestBody.ext = {'ce': (utils.cookiesAreEnabled() ? 1 : 0)} - utils._each(validBidRequests, function (bid) { - requestBody.imp.push(_buildBid(bid)) - }) - // Return the server request - return { - 'method': 'POST', - 'url': BID_URL, - 'data': JSON.stringify(requestBody) - } - } - }, - interpretResponse: function (serverResponse, request) { - const bidResponses = [] - - // response is not empty (HTTP 204) - if (!utils.isEmpty(serverResponse.body)) { - utils._each(serverResponse.body.seatbid, function (seatbid) { - utils._each(seatbid.bid, function (bid) { - bidResponses.push(_buildResponse(bid, serverResponse.body.cur, serverResponse.body.ext.ttl)) - }) - }) - } - - return bidResponses - }, - getUserSyncs: function (syncOptions, serverResponses) { - const syncs = [] - - if (utils.deepAccess(serverResponses[0], 'body.ext.usersync') && !utils.isEmpty(serverResponses[0].body.ext.usersync)) { - utils._each(serverResponses[0].body.ext.usersync, function (match) { - if ((syncOptions.iframeEnabled && match.type === 'iframe') || (syncOptions.pixelEnabled && match.type === 'image')) { - syncs.push({ - type: match.type, - url: match.url - }) - } - }) - } - - return syncs - } -} -registerBidder(spec) diff --git a/modules/cedatoBidAdapter.js b/modules/cedatoBidAdapter.js index a9e7814842cb..dc6b3c44f3d8 100644 --- a/modules/cedatoBidAdapter.js +++ b/modules/cedatoBidAdapter.js @@ -3,8 +3,8 @@ import { registerBidder } from '../src/adapters/bidderFactory'; import { BANNER, VIDEO } from '../src/mediaTypes'; const BIDDER_CODE = 'cedato'; -const BID_URL = '//h.cedatoplayer.com/hb'; -const SYNC_URL = '//h.cedatoplayer.com/hb_usync?uid={UUID}'; +const BID_URL = 'https://h.cedatoplayer.com/hb'; +const SYNC_URL = 'https://h.cedatoplayer.com/hb_usync?uid={UUID}'; const COOKIE_NAME = 'hb-cedato-id'; const UUID_LEN = 36; const TTL = 10000; diff --git a/modules/cleanmedianetBidAdapter.js b/modules/cleanmedianetBidAdapter.js deleted file mode 100644 index 15871e1a6ae9..000000000000 --- a/modules/cleanmedianetBidAdapter.js +++ /dev/null @@ -1,300 +0,0 @@ -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'; - -export const helper = { - startsWith: function (str, search) { - return str.substr(0, search.length) === search; - }, - getMediaType: function (bid) { - if (bid.ext) { - if (bid.ext.media_type) { - return bid.ext.media_type.toLowerCase(); - } else if (bid.ext.vast_url) { - return VIDEO; - } else { - return BANNER; - } - } - return BANNER; - } -}; - -export const spec = { - code: 'cleanmedianet', - aliases: [], - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid: function (bid) { - return ( - !!bid.params.supplyPartnerId && - typeof bid.params.supplyPartnerId === '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) - ); - }, - - buildRequests: function (validBidRequests, bidderRequest) { - return validBidRequests.map(bidRequest => { - const { - adUnitCode, - auctionId, - mediaTypes, - params, - sizes, - transactionId - } = bidRequest; - const baseEndpoint = 'https://bidder.cleanmediaads.com'; - const rtbEndpoint = - `${baseEndpoint}/r/${ - params.supplyPartnerId - }/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + - (params.query ? '&' + params.query : ''); - let url = - config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; - - const rtbBidRequest = { - id: auctionId, - site: { - domain: parse(url).hostname, - page: url, - ref: bidderRequest.refererInfo.referer - }, - device: { - ua: navigator.userAgent - }, - imp: [], - ext: {} - }; - - if ( - bidderRequest.gdprConsent && - bidderRequest.gdprConsent.consentString && - bidderRequest.gdprConsent.gdprApplies - ) { - rtbBidRequest.ext.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - } - - 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 - }; - - const hasFavoredMediaType = - params.favoredMediaType && - this.supportedMediaTypes.includes(params.favoredMediaType); - - 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: bidderRequest.refererInfo.reachedTop - } - }); - rtbBidRequest.imp.push(bannerImp); - } - } - - if (mediaTypes && mediaTypes.video) { - if (!hasFavoredMediaType || params.favoredMediaType === VIDEO) { - let videoImp = { - video: { - protocols: params.protocols || [1, 2, 3, 4, 5, 6], - pos: params.pos || 0, - ext: {context: mediaTypes.video.context} - } - }; - - let playerSize = mediaTypes.video.playerSize || sizes; - 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; - } - - videoImp = Object.assign({}, imp, videoImp); - rtbBidRequest.imp.push(videoImp); - } - } - - if (rtbBidRequest.imp.length === 0) { - return; - } - - return { - method: 'POST', - url: rtbEndpoint, - data: rtbBidRequest, - bidRequest - }; - }); - }, - - interpretResponse: function (serverResponse, bidRequest) { - const response = serverResponse && serverResponse.body; - if (!response) { - utils.logError('empty response'); - return []; - } - - const bids = response.seatbid.reduce( - (acc, seatBid) => acc.concat(seatBid.bid), - [] - ); - let outBids = []; - - bids.forEach(bid => { - const outBid = { - requestId: bidRequest.bidRequest.bidId, - cpm: bid.price, - width: bid.w, - height: bid.h, - ttl: 60 * 10, - creativeId: bid.crid || bid.adid, - netRevenue: true, - currency: bid.cur || response.cur, - mediaType: helper.getMediaType(bid) - }; - - if ( - utils.deepAccess( - bidRequest.bidRequest, - 'mediaTypes.' + outBid.mediaType - ) - ) { - if (outBid.mediaType === BANNER) { - outBids.push(Object.assign({}, outBid, {ad: bid.adm})); - } else if (outBid.mediaType === VIDEO) { - const context = utils.deepAccess( - bidRequest.bidRequest, - 'mediaTypes.video.context' - ); - outBids.push( - Object.assign({}, outBid, { - vastUrl: bid.ext.vast_url, - vastXml: bid.adm, - renderer: - context === 'outstream' - ? newRenderer(bidRequest.bidRequest, bid) - : undefined - }) - ); - } - } - }); - return outBids; - }, - - getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { - const syncs = []; - const gdprApplies = - gdprConsent && typeof gdprConsent.gdprApplies === 'boolean' - ? gdprConsent.gdprApplies - : false; - const suffix = gdprApplies - ? 'gc=' + encodeURIComponent(gdprConsent.consentString) - : 'gc=missing'; - 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}); - }); - } - 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}); - }); - } - }); - } - }); - } - } - }); - 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', - config: rendererOptions, - loaded: false - }); - try { - renderer.setRender(renderOutstream); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - return renderer; -} - -function renderOutstream(bid) { - bid.renderer.push(() => { - const unitId = bid.adUnitCode + '/' + bid.adId; - window['GamoshiPlayer'].renderAd({ - id: unitId, - debug: window.location.href.indexOf('pbjsDebug') >= 0, - placement: document.getElementById(bid.adUnitCode), - width: bid.width, - height: bid.height, - events: { - ALL_ADS_COMPLETED: () => - window.setTimeout(() => { - window['GamoshiPlayer'].removeAd(unitId); - }, 300) - }, - vastUrl: bid.vastUrl, - vastXml: bid.vastXml - }); - }); -} - -registerBidder(spec); diff --git a/modules/clickforceBidAdapter.js b/modules/clickforceBidAdapter.js index 16ecdf713d9b..43ef76cc9315 100644 --- a/modules/clickforceBidAdapter.js +++ b/modules/clickforceBidAdapter.js @@ -2,7 +2,7 @@ import * as utils from '../src/utils'; import {registerBidder} from '../src/adapters/bidderFactory'; import {BANNER, NATIVE} from '../src/mediaTypes'; 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.doublemax.net/adserver/prebid.json?cb=' + new Date().getTime() + '&hb=1&ver=1.21'; export const spec = { code: BIDDER_CODE, diff --git a/modules/collectcentBidAdapter.js b/modules/collectcentBidAdapter.js index 50ac377788eb..f7f5f3ef0c41 100644 --- a/modules/collectcentBidAdapter.js +++ b/modules/collectcentBidAdapter.js @@ -3,8 +3,8 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; import * as utils from '../src/utils'; 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 e5ebc41ebfde..000000000000 --- 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/contentigniteBidAdapter.js b/modules/contentigniteBidAdapter.js deleted file mode 100644 index 2e3092114f63..000000000000 --- 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/cosmosBidAdapter.js b/modules/cosmosBidAdapter.js index 84131bfa1319..f3a8979165b8 100644 --- a/modules/cosmosBidAdapter.js +++ b/modules/cosmosBidAdapter.js @@ -3,8 +3,8 @@ import { BANNER, VIDEO } from '../src/mediaTypes'; import * as utils from '../src/utils'; 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 84b76cbbc357..8d2ec31a2c62 100644 --- a/modules/cpmstarBidAdapter.js +++ b/modules/cpmstarBidAdapter.js @@ -5,9 +5,9 @@ import {VIDEO, BANNER} from '../src/mediaTypes'; 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/danmarketBidAdapter.js b/modules/danmarketBidAdapter.js deleted file mode 100644 index 77f90f433192..000000000000 --- 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/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js index 3e9bf219c756..cbad3ac910cd 100644 --- a/modules/datablocksBidAdapter.js +++ b/modules/datablocksBidAdapter.js @@ -232,7 +232,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, diff --git a/modules/decenteradsBidAdapter.js b/modules/decenteradsBidAdapter.js deleted file mode 100644 index 65d3032d3f87..000000000000 --- 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/dgadsBidAdapter.js b/modules/dgadsBidAdapter.js deleted file mode 100644 index c8a97d86990f..000000000000 --- 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/djaxBidAdapter.js b/modules/djaxBidAdapter.js index 58f500d2a2b5..80975f0929a4 100644 --- a/modules/djaxBidAdapter.js +++ b/modules/djaxBidAdapter.js @@ -8,7 +8,7 @@ import {Renderer} from '../src/Renderer'; const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; const BIDDER_CODE = 'djax'; const DOMAIN = 'https://demo.reviveadservermod.com/headerbidding_adminshare/'; -const RENDERER_URL = '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; +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); diff --git a/modules/dspxBidAdapter.js b/modules/dspxBidAdapter.js deleted file mode 100644 index a109bc612dbc..000000000000 --- a/modules/dspxBidAdapter.js +++ /dev/null @@ -1,96 +0,0 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'dspx'; -const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['dspx'], - isBidRequestValid: function(bid) { - return !!(bid.params.placement); - }, - 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 = bidderRequest.refererInfo.referer; - const bidId = bidRequest.bidId; - const payload = { - _f: 'html', - alternative: 'prebid_js', - inventory_item_id: placementId, - srw: width, - srh: height, - idt: 100, - rnd: rnd, - ref: referrer, - bid_id: bidId, - }; - if (params.pfilter !== undefined) { - payload.pfilter = params.pfilter; - } - if (params.bcat !== undefined) { - payload.bcat = params.bcat; - } - if (params.dvt !== undefined) { - payload.dvt = params.dvt; - } - return { - method: 'GET', - url: ENDPOINT_URL, - data: objectToQueryString(payload), - } - }); - }, - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - const response = serverResponse.body; - const crid = response.crid || 0; - const cpm = response.cpm / 1000000 || 0; - if (cpm !== 0 && crid !== 0) { - 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, - width: response.width, - height: response.height, - creativeId: crid, - dealId: dealId, - currency: currency, - netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), - referrer: referrer, - ad: response.adTag - }; - bidResponses.push(bidResponse); - } - return bidResponses; - } -} - -function objectToQueryString(obj, prefix) { - let str = []; - let p; - for (p in obj) { - if (obj.hasOwnProperty(p)) { - let k = prefix ? prefix + '[' + p + ']' : p; - let v = obj[p]; - str.push((v !== null && typeof v === 'object') - ? objectToQueryString(v, k) - : encodeURIComponent(k) + '=' + encodeURIComponent(v)); - } - } - return str.join('&'); -} - -registerBidder(spec); diff --git a/modules/ebdrBidAdapter.js b/modules/ebdrBidAdapter.js index 79bf4bb10047..d8af215f96a9 100644 --- a/modules/ebdrBidAdapter.js +++ b/modules/ebdrBidAdapter.js @@ -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/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js deleted file mode 100644 index 0768c8386fb0..000000000000 --- a/modules/emx_digitalBidAdapter.js +++ /dev/null @@ -1,287 +0,0 @@ -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'; - -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.41.2'; -const DEFAULT_CUR = 'USD'; - -export const emxAdapter = { - validateSizes: (sizes) => { - if (!utils.isArray(sizes) || typeof sizes[0] === 'undefined') { - utils.logWarn(BIDDER_CODE + ': Sizes should be an array'); - return false; - } - return sizes.every(size => utils.isArray(size) && size.length === 2); - }, - checkVideoContext: (bid) => { - return ((bid && bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context) && ((bid.mediaTypes.video.context === 'instream') || (bid.mediaTypes.video.context === 'outstream'))); - }, - buildBanner: (bid) => { - let sizes = []; - bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes; - if (!emxAdapter.validateSizes(sizes)) { - utils.logWarn(BIDDER_CODE + ': could not detect mediaType banner sizes. Assigning to bid sizes instead'); - sizes = bid.sizes - } - return { - format: sizes.map((size) => { - return { - w: size[0], - h: size[1] - }; - }), - w: sizes[0][0], - h: sizes[0][1] - }; - }, - formatVideoResponse: (bidResponse, emxBid, bidRequest) => { - bidResponse.vastXml = emxBid.adm; - if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') { - bidResponse.renderer = emxAdapter.createRenderer(bidResponse, { - id: emxBid.id, - url: RENDERER_URL - }); - } - return bidResponse; - }, - isMobile: () => { - return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); - }, - isConnectedTV: () => { - return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); - }, - getDevice: () => { - return { - ua: navigator.userAgent, - js: 1, - dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, - h: screen.height, - w: screen.width, - devicetype: emxAdapter.isMobile() ? 1 : emxAdapter.isConnectedTV() ? 3 : 2, - language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), - }; - }, - cleanProtocols: (video) => { - if (video.protocols && includes(video.protocols, 7)) { - // not supporting VAST protocol 7 (VAST 4.0); - utils.logWarn(BIDDER_CODE + ': VAST 4.0 is currently not supported. This protocol has been filtered out of the request.'); - video.protocols = video.protocols.filter(protocol => protocol !== 7); - } - return video; - }, - outstreamRender: (bid) => { - bid.renderer.push(function () { - let params = (bid && bid.params && bid.params[0] && bid.params[0].video) ? bid.params[0].video : {}; - window.emxVideoQueue = window.emxVideoQueue || []; - window.queueEmxVideo({ - id: bid.adUnitCode, - adsResponses: bid.vastXml, - options: params - }); - if (window.emxVideoReady && window.videojs) { - window.emxVideoReady(); - } - }); - }, - createRenderer: (bid, rendererParams) => { - const renderer = Renderer.install({ - id: rendererParams.id, - url: RENDERER_URL, - loaded: false - }); - try { - renderer.setRender(emxAdapter.outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - - return renderer; - }, - buildVideo: (bid) => { - 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.replace(/%(?![0-9][0-9a-fA-F]+)/g, '%25')); - } catch (err) { - utils.logError('emx_digitalBidAdapter', 'error', err); - } - }, - getReferrer: () => { - try { - return window.top.document.referrer; - } catch (err) { - return document.referrer; - } - }, - getGdpr: (bidRequests, emxData) => { - if (bidRequests.gdprConsent) { - emxData.regs = { - ext: { - gdpr: bidRequests.gdprConsent.gdprApplies === true ? 1 : 0 - } - }; - } - if (bidRequests.gdprConsent && bidRequests.gdprConsent.gdprApplies) { - emxData.user = { - ext: { - consent: bidRequests.gdprConsent.consentString - } - }; - } - - return emxData; - } -}; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - isBidRequestValid: function (bid) { - if (!bid || !bid.params) { - utils.logWarn(BIDDER_CODE + ': Missing bid or bid params.'); - return false; - } - - if (bid.bidder !== BIDDER_CODE) { - utils.logWarn(BIDDER_CODE + ': Must use "emx_digital" as bidder code.'); - return false; - } - - if (!bid.params.tagid || !utils.isStr(bid.params.tagid)) { - utils.logWarn(BIDDER_CODE + ': Missing tagid param or tagid present and not type String.'); - return false; - } - - if (bid.mediaTypes && bid.mediaTypes.banner) { - let sizes; - bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes; - if (!emxAdapter.validateSizes(sizes)) { - utils.logWarn(BIDDER_CODE + ': Missing sizes in bid'); - return false; - } - } else if (bid.mediaTypes && bid.mediaTypes.video) { - if (!emxAdapter.checkVideoContext(bid)) { - utils.logWarn(BIDDER_CODE + ': Missing video context: instream or outstream'); - return false; - } - - if (!bid.mediaTypes.video.playerSize) { - utils.logWarn(BIDDER_CODE + ': Missing video playerSize'); - return false; - } - } - - return true; - }, - buildRequests: function (validBidRequests, bidRequest) { - const emxImps = []; - const timeout = bidRequest.timeout || ''; - const timestamp = Date.now(); - const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); - const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; - const domain = utils.getTopWindowLocation().hostname; - const page = bidRequest.refererInfo.referer; - const device = emxAdapter.getDevice(); - const ref = emxAdapter.getReferrer(); - - utils._each(validBidRequests, function (bid) { - let tagid = utils.getBidIdParameter('tagid', bid.params); - let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0; - let isVideo = !!bid.mediaTypes.video; - let data = { - id: bid.bidId, - tid: bid.transactionId, - tagid, - secure - }; - let typeSpecifics = isVideo ? { video: emxAdapter.buildVideo(bid) } : { banner: emxAdapter.buildBanner(bid) }; - let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {}; - let emxBid = Object.assign(data, typeSpecifics, bidfloorObj); - - emxImps.push(emxBid); - }); - - let emxData = { - id: bidRequest.auctionId, - imp: emxImps, - device, - site: { - domain, - page, - ref - }, - cur: DEFAULT_CUR, - version: ADAPTER_VERSION - }; - - emxData = emxAdapter.getGdpr(bidRequest, Object.assign({}, emxData)); - if (bidRequest && bidRequest.uspConsent) { - emxData.us_privacy = bidRequest.uspConsent - } - return { - method: 'POST', - url: url, - data: JSON.stringify(emxData), - options: { - withCredentials: true - }, - bidRequest - }; - }, - interpretResponse: function (serverResponse, bidRequest) { - let emxBidResponses = []; - let response = serverResponse.body || {}; - if (response.seatbid && response.seatbid.length > 0 && response.seatbid[0].bid) { - response.seatbid.forEach(function (emxBid) { - emxBid = emxBid.bid[0]; - let isVideo = false; - let adm = emxAdapter.parseResponse(emxBid.adm) || ''; - let bidResponse = { - requestId: emxBid.id, - cpm: emxBid.price, - width: emxBid.w, - height: emxBid.h, - creativeId: emxBid.crid || emxBid.id, - dealId: emxBid.dealid || null, - currency: 'USD', - netRevenue: true, - ttl: emxBid.ttl, - ad: adm - }; - if (emxBid.adm && emxBid.adm.indexOf(' -1) { - isVideo = true; - bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest); - } - bidResponse.mediaType = (isVideo ? VIDEO : BANNER); - emxBidResponses.push(bidResponse); - }); - } - return emxBidResponses; - }, - getUserSyncs: function (syncOptions) { - const syncs = []; - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: '//biddr.brealtime.com/check.html' - }); - } - return syncs; - } -}; -registerBidder(spec); diff --git a/modules/eplanningBidAdapter.js b/modules/eplanningBidAdapter.js deleted file mode 100644 index d9e145544836..000000000000 --- a/modules/eplanningBidAdapter.js +++ /dev/null @@ -1,395 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; - -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 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) { - const method = 'GET'; - const dfpClientId = '1'; - const sec = 'ROS'; - let url; - let params; - const urlConfig = getUrlConfig(bidRequests); - const pcrs = getCharset(); - const spaces = getSpaces(bidRequests); - if (urlConfig.t) { - url = 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(); - - if (utils.hasLocalStorage()) { - registerViewabilityAllBids(bidRequests); - } - - params = { - rnd: rnd, - e: spaces.str, - ur: utils.getTopWindowUrl() || FILE, - r: 'pbjs', - pbv: '$prebid.version$', - ncb: '1', - vs: spaces.vs - }; - - if (pcrs) { - params.crs = pcrs; - } - - if (referrerUrl) { - params.fr = referrerUrl; - } - } - - return { - method: method, - url: url, - data: params, - adUnitToBidId: spaces.map, - }; - }, - interpretResponse: function(serverResponse, request) { - const response = serverResponse.body; - let bidResponses = []; - - if (response && !utils.isEmpty(response.sp)) { - response.sp.forEach(space => { - if (!utils.isEmpty(space.a)) { - space.a.forEach(ad => { - const bidResponse = { - requestId: request.adUnitToBidId[space.k], - cpm: ad.pr, - width: ad.w, - height: ad.h, - ad: ad.adm, - ttl: TTL, - creativeId: ad.crid, - netRevenue: NET_REVENUE, - currency: DOLLARS, - }; - bidResponses.push(bidResponse); - }); - } - }); - } - - return bidResponses; - }, - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - const response = !utils.isEmpty(serverResponses) && serverResponses[0].body; - - if (response && !utils.isEmpty(response.cs)) { - const responseSyncs = response.cs; - responseSyncs.forEach(sync => { - if (typeof sync === 'string' && syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: sync, - }); - } else if (typeof sync === 'object' && sync.ifr && syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: sync.u, - }) - } - }); - } - - return syncs; - }, -} - -function getUrlConfig(bidRequests) { - if (isTestRequest(bidRequests)) { - return getTestConfig(bidRequests.filter(br => br.params.t)); - } - - let config = {}; - bidRequests.forEach(bid => { - PARAMS.forEach(param => { - if (bid.params[param] && !config[param]) { - config[param] = bid.params[param]; - } - }); - }); - - if (config.sv) { - config.sv = '//' + config.sv; - } - - return config; -} -function isTestRequest(bidRequests) { - 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) - }; -} - -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 getSpaces(bidRequests) { - 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 = 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 (utils.hasLocalStorage()) { - s = getViewabilityData(bid); - vs += s.render >= 4 ? s.ratio.toString(16) : 'F'; - } else { - vs += 'F'; - } - return vs; -} - -function getViewabilityData(bid) { - let r = utils.getDataFromLocalStorage(STORAGE_RENDER_PREFIX + bid.adUnitCode) || 0; - let v = utils.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() { - try { - return window.top.document.charset || window.top.document.characterSet; - } catch (e) { - return document.charset || document.characterSet; - } -} - -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(); - } - } - }); - } - }); - } - }); - const config = {childList: true, subtree: true, characterData: true, attributes: true, attributeOldValue: 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 = utils.getDataFromLocalStorage(storageID); - value = value ? window.parseInt(value, 10) + 1 : 1; - utils.setDataInLocalStorage(storageID, value); - } catch (exc) { - return false; - } - - return true; -} -registerBidder(spec); diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index bdf07742497c..ad341a136b1a 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -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/eywamediaBidAdapter.js b/modules/eywamediaBidAdapter.js deleted file mode 100644 index 543775dc3aab..000000000000 --- 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 55f24ab89068..000000000000 --- 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/fidelityBidAdapter.js b/modules/fidelityBidAdapter.js deleted file mode 100644 index 078e9d2fcce3..000000000000 --- a/modules/fidelityBidAdapter.js +++ /dev/null @@ -1,109 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; - -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) { - return !!(bid && bid.params && bid.params.zoneid); - }, - buildRequests: function(validBidRequests, bidderRequest) { - return validBidRequests.map(bidRequest => { - var server = bidRequest.params.server || BIDDER_SERVER; - - const payload = { - from: 'hb', - v: '1.0', - requestid: bidRequest.bidderRequestId, - impid: bidRequest.bidId, - zoneid: bidRequest.params.zoneid, - floor: parseFloat(bidRequest.params.floor) > 0 ? bidRequest.params.floor : 0, - charset: document.charSet || document.characterSet, - subid: 'hb', - flashver: getFlashVersion(), - tmax: bidderRequest.timeout, - defloc: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - }; - setConsentParams(bidderRequest.gdprConsent, payload); - - return { - method: 'GET', - url: '//' + server + '/delivery/hb.php', - data: payload - }; - }); - }, - interpretResponse: function(serverResponse) { - serverResponse = serverResponse.body; - const bidResponses = []; - if (serverResponse && serverResponse.seatbid) { - serverResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => { - const bidResponse = { - requestId: bid.impid, - creativeId: bid.impid, - cpm: bid.price, - width: bid.width, - height: bid.height, - ad: bid.adm, - netRevenue: bid.netRevenue, - currency: bid.cur, - ttl: bid.ttl, - }; - - bidResponses.push(bidResponse); - })); - } - return bidResponses; - }, - getUserSyncs: function getUserSyncs(syncOptions, serverResponses, gdprConsent) { - if (syncOptions.iframeEnabled) { - var url = '//' + BIDDER_SERVER + '/delivery/matches.php'; - var payload = { - type: 'iframe' - }; - setConsentParams(gdprConsent, payload); - - return [{ - type: 'iframe', - url: url + '?' + utils.parseQueryStringParameters(payload).replace(/\&$/, '') - }]; - } - } -} - -function getFlashVersion() { - var plugins, plugin, result; - - if (navigator.plugins && navigator.plugins.length > 0) { - plugins = navigator.plugins; - for (var i = 0; i < plugins.length && !result; i++) { - plugin = plugins[i]; - if (plugin.name.indexOf('Shockwave Flash') > -1) { - result = plugin.description.split('Shockwave Flash ')[1]; - } - } - } - return result || ''; -} - -function setConsentParams(gdprConsent, payload) { - if (gdprConsent) { - payload.gdpr = 0; - payload.consent_str = ''; - payload.consent_given = 0; - if (typeof gdprConsent.gdprApplies !== 'undefined') { - payload.gdpr = gdprConsent.gdprApplies ? 1 : 0; - } - if (typeof gdprConsent.consentString !== 'undefined') { - payload.consent_str = gdprConsent.consentString; - } - if (gdprConsent.vendorData && gdprConsent.vendorData.vendorConsents && typeof gdprConsent.vendorData.vendorConsents[FIDELITY_VENDOR_ID.toString(10)] !== 'undefined') { - payload.consent_given = gdprConsent.vendorData.vendorConsents[FIDELITY_VENDOR_ID.toString(10)] ? 1 : 0; - } - } -} - -registerBidder(spec); diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js deleted file mode 100644 index 3e52ba2cbe9a..000000000000 --- a/modules/freewheel-sspBidAdapter.js +++ /dev/null @@ -1,360 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -// import { config } from '../src/config'; - -const BIDDER_CODE = 'freewheel-ssp'; - -const PROTOCOL = getProtocol(); -const FREEWHEEL_ADSSETUP = PROTOCOL + '://ads.stickyadstv.com/www/delivery/swfIndex.php'; -const MUSTANG_URL = PROTOCOL + '://cdn.stickyadstv.com/mustang/mustang.min.js'; -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'; - } -} - -function isValidUrl(str) { - if (!str) { - return false; - } - - // regExp for url validation - var pattern = /^(https?|ftp|file):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/; - return pattern.test(str); -} - -function getBiggerSize(array) { - var result = [0, 0]; - for (var i = 0; i < array.length; i++) { - if (array[i][0] * array[i][1] > result[0] * result[1]) { - result = array[i]; - } - } - return result; -} - -/* -* read the pricing extension with this format: 1.0000 -* @return {object} pricing data in format: {currency: "EUR", price:"1.000"} -*/ -function getPricing(xmlNode) { - var pricingExtNode; - var princingData = {}; - - var extensions = xmlNode.querySelectorAll('Extension'); - // Nodelist.forEach is not supported in IE and Edge - // Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/ - Array.prototype.forEach.call(extensions, function(node) { - if (node.getAttribute('type') === 'StickyPricing') { - pricingExtNode = node; - } - }); - - if (pricingExtNode) { - var priceNode = pricingExtNode.querySelector('Price'); - princingData = { - currency: priceNode.getAttribute('currency'), - price: priceNode.textContent || priceNode.innerText - }; - } else { - utils.logWarn('PREBID - ' + BIDDER_CODE + ': Can\'t get pricing data. Is price awareness enabled?'); - } - - return princingData; -} - -function hashcode(inputString) { - var hash = 0; - var char; - if (inputString.length == 0) return hash; - for (var i = 0; i < inputString.length; i++) { - char = inputString.charCodeAt(i); - hash = ((hash << 5) - hash) + char; - hash = hash & hash; // Convert to 32bit integer - } - return hash; -} - -function getCreativeId(xmlNode) { - var creaId = ''; - var adNodes = xmlNode.querySelectorAll('Ad'); - // Nodelist.forEach is not supported in IE and Edge - // Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/ - Array.prototype.forEach.call(adNodes, function(el) { - creaId += '[' + el.getAttribute('id') + ']'; - }); - - return creaId; -} - -/** -* returns the top most accessible window -*/ -function getTopMostWindow() { - var res = window; - - try { - while (top !== res) { - if (res.parent.location.href.length) { res = res.parent; } - } - } catch (e) {} - - return res; -} - -function getComponentId(inputFormat) { - var component = 'mustang'; // default component id - - if (inputFormat && inputFormat !== 'inbanner') { - // format identifiers are equals to their component ids. - component = inputFormat; - } - - return component; -} - -function getAPIName(componentId) { - componentId = componentId || ''; - - // remove dash in componentId to get API name - return componentId.replace('-', ''); -} - -function formatAdHTML(bid, size) { - var integrationType = bid.params.format; - - var divHtml = '
'; - - var script = ''; - var libUrl = ''; - if (integrationType && integrationType !== 'inbanner') { - libUrl = PRIMETIME_URL + getComponentId(bid.params.format) + '.min.js'; - script = getOutstreamScript(bid, size); - } else { - libUrl = MUSTANG_URL; - script = getInBannerScript(bid, size); - } - - return divHtml + - ''; -} - -var getInBannerScript = function(bid, size) { - return 'var config = {' + - ' preloadedVast:vast,' + - ' autoPlay:true' + - ' };' + - ' var ad = new window.com.stickyadstv.vpaid.Ad(document.getElementById("freewheelssp_prebid_target"),config);' + - ' (new window.com.stickyadstv.tools.ASLoader(' + bid.params.zoneId + ', \'' + getComponentId(bid.params.format) + '\')).registerEvents(ad);' + - ' ad.initAd(' + size[0] + ',' + size[1] + ',"",0,"","");'; -}; - -var getOutstreamScript = function(bid) { - var config = bid.params; - - // default placement if no placement is set - if (!config.hasOwnProperty('domId') && !config.hasOwnProperty('auto') && !config.hasOwnProperty('p') && !config.hasOwnProperty('article')) { - if (config.format === 'intext-roll') { - config.iframeMode = 'dfp'; - } else { - config.domId = 'freewheelssp_prebid_target'; - } - } - - var script = 'var config = {' + - ' preloadedVast:vast,' + - ' ASLoader:new window.com.stickyadstv.tools.ASLoader(' + bid.params.zoneId + ', \'' + getComponentId(bid.params.format) + '\')'; - - for (var key in config) { - // dont' send format parameter - // neither zone nor vastUrlParams value as Vast is already loaded - if (config.hasOwnProperty(key) && key !== 'format' && key !== 'zone' && key !== 'zoneId' && key !== 'vastUrlParams') { - script += ',' + key + ':"' + config[key] + '"'; - } - } - script += '};' + - - 'window.com.stickyadstv.' + getAPIName(bid.params.format) + '.start(config);'; - - return script; -}; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['banner', 'video'], - aliases: ['stickyadstv'], // former name for freewheel-ssp - /** - * 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) { - // 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.'); - } - - 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.gdprConsent) { - requestParams._fw_gdpr_consent = bidderRequest.gdprConsent.consentString; - - 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; - } - - 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 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 - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @param {object} request: the built request object containing the initial bidRequest. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, request) { - var bidrequest = request.bidRequest; - var playerSize = getBiggerSize(bidrequest.sizes); - - if (typeof serverResponse == 'object' && typeof serverResponse.body == 'string') { - serverResponse = serverResponse.body; - } - - var xmlDoc; - try { - var parser = new DOMParser(); - xmlDoc = parser.parseFromString(serverResponse, 'application/xml'); - } catch (err) { - utils.logWarn('Prebid.js - ' + BIDDER_CODE + ' : ' + err); - return; - } - - const princingData = getPricing(xmlDoc); - const creativeId = getCreativeId(xmlDoc); - - const topWin = getTopMostWindow(); - if (!topWin.freewheelssp_cache) { - topWin.freewheelssp_cache = {}; - } - topWin.freewheelssp_cache[bidrequest.adUnitCode] = serverResponse; - - const bidResponses = []; - - if (princingData.price) { - const bidResponse = { - requestId: bidrequest.bidId, - cpm: princingData.price, - width: playerSize[0], - height: playerSize[1], - creativeId: creativeId, - currency: princingData.currency, - netRevenue: true, - ttl: 360 - }; - - var mediaTypes = bidrequest.mediaTypes || {}; - if (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); - } - - bidResponses.push(bidResponse); - } - - return bidResponses; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: USER_SYNC_URL - }]; - } - }, - -} -registerBidder(spec); diff --git a/modules/fyberBidAdapter.js b/modules/fyberBidAdapter.js deleted file mode 100644 index 3586d0775ace..000000000000 --- 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 deleted file mode 100644 index 926dae147902..000000000000 --- a/modules/gammaBidAdapter.js +++ /dev/null @@ -1,100 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; - -const ENDPOINT = 'hb.gammaplatform.com'; -const BIDDER_CODE = 'gamma'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['gamma'], - supportedMediaTypes: ['banner', 'video'], - - /** - * 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.siteId || 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) { - const serverRequests = []; - 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()) - }); - } - return serverRequests; - }, - - /** - * 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) { - serverResponse = serverResponse.body; - - const bids = []; - - if (serverResponse.id) { - const bid = newBid(serverResponse); - bids.push(bid); - } - - return bids; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: '//' + ENDPOINT + '/adx/usersync' - }]; - } - } -} - -/** - * Unpack the Server's Bid into a Prebid-compatible one. - * @param serverBid - * @return Bid - */ -function newBid(serverBid) { - const bid = { - ad: serverBid.seatbid[0].bid[0].adm, - cpm: serverBid.seatbid[0].bid[0].price, - creativeId: serverBid.seatbid[0].bid[0].adid, - currency: serverBid.cur, - dealId: serverBid.seatbid[0].bid[0].dealid, - width: serverBid.seatbid[0].bid[0].w, - height: serverBid.seatbid[0].bid[0].h, - mediaType: serverBid.type, - netRevenue: true, - requestId: serverBid.id, - ttl: serverBid.seatbid[0].bid[0].ttl || 300 - }; - - if (serverBid.type == 'video') { - Object.assign(bid, { - vastXml: serverBid.seatbid[0].bid[0].vastXml, - vastUrl: serverBid.seatbid[0].bid[0].vastUrl, - ttl: 3600 - }); - } - - return bid; -} - -registerBidder(spec); diff --git a/modules/gamoshiBidAdapter.js b/modules/gamoshiBidAdapter.js deleted file mode 100644 index 89ffde51889f..000000000000 --- a/modules/gamoshiBidAdapter.js +++ /dev/null @@ -1,279 +0,0 @@ -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'; - -const ENDPOINTS = { - 'gamoshi': 'https://rtb.gamoshi.io' -}; - -const DEFAULT_TTL = 360; - -export const helper = { - getTopFrame: function () { - try { - return window.top === window ? 1 : 0; - } catch (e) { - } - return 0; - }, - startsWith: function (str, search) { - return str.substr(0, search.length) === search; - }, - getTopWindowDomain: function (url) { - const domainStart = url.indexOf('://') + '://'.length; - return url.substring(domainStart, url.indexOf('/', domainStart) < 0 ? url.length : url.indexOf('/', domainStart)); - }, - - getMediaType: function (bid) { - if (bid.ext) { - if (bid.ext.media_type) { - return bid.ext.media_type.toLowerCase(); - } else if (bid.ext.vast_url) { - return VIDEO; - } else { - return BANNER; - } - } - return BANNER; - } -}; - -export const spec = { - code: 'gamoshi', - aliases: ['gambid', 'cleanmedia', '9MediaOnline'], - supportedMediaTypes: ['banner', 'video'], - - isBidRequestValid: function (bid) { - 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) { - return validBidRequests.map(bidRequest => { - const {adUnitCode, auctionId, mediaTypes, params, sizes, transactionId} = bidRequest; - const baseEndpoint = params['rtbEndpoint'] || ENDPOINTS['gamoshi']; - const rtbEndpoint = `${baseEndpoint}/r/${params.supplyPartnerId}/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + (params.query ? '&' + params.query : ''); - let url = config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; - - const rtbBidRequest = { - 'id': auctionId, - 'site': { - 'domain': helper.getTopWindowDomain(url), - 'page': url, - 'ref': bidderRequest.refererInfo.referer - }, - 'device': { - 'ua': navigator.userAgent - }, - 'imp': [], - 'ext': {}, - 'user': { - 'ext': {} - } - }; - const gdprConsent = bidderRequest.gdprConsent; - - if (gdprConsent && gdprConsent.consentString && gdprConsent.gdprApplies) { - rtbBidRequest.ext.gdpr_consent = { - consent_string: gdprConsent.consentString, - consent_required: gdprConsent.gdprApplies - }; - rtbBidRequest.regs = { - ext: { - gdpr: gdprConsent.gdprApplies === true ? 1 : 0 - } - }; - rtbBidRequest.user = { - ext: { - consent: gdprConsent.consentString - } - } - } - 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 - }; - - const hasFavoredMediaType = - params.favoredMediaType && this.supportedMediaTypes.includes(params.favoredMediaType); - - 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() - } - }); - rtbBidRequest.imp.push(bannerImp); - } - } - - if (mediaTypes && mediaTypes.video) { - if (!hasFavoredMediaType || params.favoredMediaType === VIDEO) { - 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: { - context: mediaTypes.video.context - } - } - }); - 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}; - }); - }, - - interpretResponse: function (serverResponse, bidRequest) { - const response = serverResponse && serverResponse.body; - if (!response) { - utils.logError('empty response'); - return []; - } - - const bids = response.seatbid.reduce((acc, seatBid) => acc.concat(seatBid.bid), []); - let outBids = []; - - bids.forEach(bid => { - const outBid = { - requestId: bidRequest.bidRequest.bidId, - cpm: bid.price, - width: bid.w, - height: bid.h, - ttl: DEFAULT_TTL, - creativeId: bid.crid || bid.adid, - netRevenue: true, - currency: bid.cur || response.cur, - mediaType: helper.getMediaType(bid) - }; - - if (utils.deepAccess(bidRequest.bidRequest, 'mediaTypes.' + outBid.mediaType)) { - if (outBid.mediaType === BANNER) { - outBids.push(Object.assign({}, outBid, {ad: bid.adm})); - } else if (outBid.mediaType === VIDEO) { - const context = utils.deepAccess(bidRequest.bidRequest, 'mediaTypes.video.context'); - outBids.push(Object.assign({}, outBid, { - vastUrl: bid.ext.vast_url, - vastXml: bid.adm, - renderer: context === 'outstream' ? newRenderer(bidRequest.bidRequest, bid) : undefined - })); - } - } - }); - return outBids; - }, - - getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { - const syncs = []; - const gdprApplies = gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean') ? gdprConsent.gdprApplies : false; - const suffix = gdprApplies ? 'gc=' + encodeURIComponent(gdprConsent.consentString) : 'gc=missing'; - 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}); - }); - } - 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}); - }); - } - }); - } - }); - } - } - }); - 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', - config: rendererOptions, - loaded: false, - }); - try { - renderer.setRender(renderOutstream); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - return renderer; -} - -function renderOutstream(bid) { - bid.renderer.push(() => { - const unitId = bid.adUnitCode + '/' + bid.adId; - window['GamoshiPlayer'].renderAd({ - id: unitId, - debug: window.location.href.indexOf('pbjsDebug') >= 0, - placement: document.getElementById(bid.adUnitCode), - width: bid.width, - height: bid.height, - events: { - ALL_ADS_COMPLETED: () => window.setTimeout(() => { - window['GamoshiPlayer'].removeAd(unitId); - }, 300) - }, - vastUrl: bid.vastUrl, - vastXml: bid.vastXml - }); - }); -} - -function addExternalUserId(eids, value, source, rtiPartner) { - if (utils.isStr(value)) { - eids.push({ - source, - uids: [{ - id: value, - ext: { - rtiPartner - } - }] - }); - } -} - -registerBidder(spec); diff --git a/modules/getintentBidAdapter.js b/modules/getintentBidAdapter.js index bc2ed0936658..e1652602951b 100644 --- a/modules/getintentBidAdapter.js +++ b/modules/getintentBidAdapter.js @@ -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 e2693392578d..000000000000 --- 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 ` - - - - '}, + {ad: '
'}, ] }, native: { diff --git a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js b/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js deleted file mode 100644 index 26fd13afd1ff..000000000000 --- a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js +++ /dev/null @@ -1,268 +0,0 @@ -import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/adkernelAdnAnalyticsAdapter'; -import {expect} from 'chai'; -import adapterManager from 'src/adapterManager'; -import CONSTANTS from 'src/constants.json'; - -const events = require('../../../src/events'); - -const DIRECT = { - source: '(direct)', - medium: '(direct)', - campaign: '(direct)' -}; -const REFERRER = { - source: 'lander.com', - medium: '(referral)', - campaign: '(referral)', - content: '/lander.html' -}; -const GOOGLE_ORGANIC = { - source: 'google', - medium: '(organic)', - campaign: '(organic)' -}; -const CAMPAIGN = { - source: 'adkernel', - medium: 'email', - campaign: 'new_campaign', - c1: '1', - c2: '2', - c3: '3', - c4: '4', - c5: '5' - -}; -describe('', function () { - let sandbox; - - before(function () { - sandbox = sinon.sandbox.create(); - }); - - after(function () { - sandbox.restore(); - analyticsAdapter.disableAnalytics(); - }); - - describe('UTM source parser', function () { - let stubSetItem; - let stubGetItem; - - before(function () { - stubSetItem = sandbox.stub(storage, 'setItem'); - stubGetItem = sandbox.stub(storage, 'getItem'); - }); - - afterEach(function () { - sandbox.reset(); - }); - - it('should parse first direct visit as (direct)', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com'); - expect(source).to.be.eql(DIRECT); - }); - - it('should respect past campaign visits before direct', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(JSON.stringify(CAMPAIGN)); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com'); - expect(source).to.be.eql(CAMPAIGN); - }); - - it('should parse visit from google as organic', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); - expect(source).to.be.eql(GOOGLE_ORGANIC); - }); - - it('should respect previous campaign visit before organic', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(JSON.stringify(CAMPAIGN)); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); - expect(source).to.be.eql(CAMPAIGN); - }); - - it('should parse referral visit', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'http://lander.com/lander.html'); - expect(source).to.be.eql(REFERRER); - }); - - it('should respect previous campaign visit before referral', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(JSON.stringify(CAMPAIGN)); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); - expect(source).to.be.eql(CAMPAIGN); - }); - - it('should parse referral visit from same domain as direct', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://lander.com/news.html', 'http://lander.com/lander.html'); - expect(source).to.be.eql(DIRECT); - }); - - it('should parse campaign visit', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://lander.com/index.html?utm_campaign=new_campaign&utm_source=adkernel&utm_medium=email&utm_c1=1&utm_c2=2&utm_c3=3&utm_c4=4&utm_c5=5'); - expect(source).to.be.eql(CAMPAIGN); - }); - }); - - describe('ExpiringQueue', function () { - let timer; - before(function () { - timer = sandbox.useFakeTimers(0); - }); - after(function () { - timer.restore(); - }); - - it('should notify after timeout period', (done) => { - let queue = new ExpiringQueue(() => { - let elements = queue.popAll(); - expect(elements).to.be.eql([1, 2, 3, 4]); - elements = queue.popAll(); - expect(elements).to.have.lengthOf(0); - expect(Date.now()).to.be.equal(200); - done(); - }, 100); - - queue.push(1); - setTimeout(() => { - queue.push([2, 3]); - timer.tick(50); - }, 50); - setTimeout(() => { - queue.push([4]); - timer.tick(100); - }, 100); - timer.tick(50); - }); - }); - - const REQUEST = { - bidderCode: 'adapter', - auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', - bidderRequestId: '1a6fc81528d0f6', - bids: [{ - bidder: 'adapter', - params: {}, - adUnitCode: 'container-1', - transactionId: 'de90df62-7fd0-4fbc-8787-92d133a7dc06', - sizes: [[300, 250]], - bidId: '208750227436c1', - bidderRequestId: '1a6fc81528d0f6', - auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f' - }], - auctionStart: 1509369418387, - timeout: 3000, - start: 1509369418389 - }; - - const RESPONSE = { - bidderCode: 'adapter', - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '208750227436c1', - mediaType: 'banner', - cpm: 0.015, - ad: '', - auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', - responseTimestamp: 1509369418832, - requestTimestamp: 1509369418389, - bidder: 'adapter', - adUnitCode: 'container-1', - timeToRespond: 443, - size: '300x250' - }; - - describe('Analytics adapter', function () { - let ajaxStub; - let timer; - - before(function () { - ajaxStub = sandbox.stub(analyticsAdapter, 'ajaxCall'); - timer = sandbox.useFakeTimers(0); - }); - - beforeEach(function () { - sandbox.stub(events, 'getEvents').callsFake(() => { - return [] - }); - }); - - afterEach(function () { - events.getEvents.restore(); - }); - - it('should be configurable', function () { - adapterManager.registerAnalyticsAdapter({ - code: 'adkernelAdn', - adapter: analyticsAdapter - }); - - adapterManager.enableAnalytics({ - provider: 'adkernelAdn', - options: { - pubId: 777, - queueTimeout: 1000 - } - }); - - expect(analyticsAdapter.context).to.have.property('host', 'tag.adkernel.com'); - expect(analyticsAdapter.context).to.have.property('pubId', 777); - }); - - it('should handle auction init event', function () { - events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {config: {}, timeout: 3000}); - const ev = analyticsAdapter.context.queue.peekAll(); - expect(ev).to.have.length(1); - expect(ev[0]).to.be.eql({event: 'auctionInit'}); - }); - - it('should handle bid request event', function () { - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, REQUEST); - const ev = analyticsAdapter.context.queue.peekAll(); - expect(ev).to.have.length(2); - expect(ev[1]).to.be.eql({event: 'bidRequested', adapter: 'adapter', tagid: 'container-1'}); - }); - - it('should handle bid response event', function () { - events.emit(CONSTANTS.EVENTS.BID_RESPONSE, RESPONSE); - const ev = analyticsAdapter.context.queue.peekAll(); - expect(ev).to.have.length(3); - expect(ev[2]).to.be.eql({ - event: 'bidResponse', - adapter: 'adapter', - tagid: 'container-1', - val: 0.015, - time: 0.443 - }); - }); - - it('should handle auction end event', function () { - timer.tick(447); - events.emit(CONSTANTS.EVENTS.AUCTION_END, RESPONSE); - let ev = analyticsAdapter.context.queue.peekAll(); - expect(ev).to.have.length(0); - expect(ajaxStub.calledOnce).to.be.equal(true); - ev = JSON.parse(ajaxStub.firstCall.args[0]).hb_ev; - expect(ev[3]).to.be.eql({event: 'auctionEnd', time: 0.447}); - }); - - it('should handle winning bid', function () { - events.emit(CONSTANTS.EVENTS.BID_WON, RESPONSE); - timer.tick(4500); - expect(ajaxStub.calledTwice).to.be.equal(true); - let ev = JSON.parse(ajaxStub.secondCall.args[0]).hb_ev; - expect(ev[0]).to.be.eql({event: 'bidWon', adapter: 'adapter', tagid: 'container-1', val: 0.015}); - }); - }); -}); diff --git a/test/spec/modules/adkernelAdnBidAdapter_spec.js b/test/spec/modules/adkernelAdnBidAdapter_spec.js index 277faf2a351f..98e3f6b34085 100644 --- a/test/spec/modules/adkernelAdnBidAdapter_spec.js +++ b/test/spec/modules/adkernelAdnBidAdapter_spec.js @@ -120,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 = { @@ -323,8 +323,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); }); @@ -365,7 +365,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 5b3d76ef0713..294aba72a6b1 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -123,7 +123,7 @@ describe('Adkernel adapter', function () { }], cur: 'USD', ext: { - adk_usersync: ['http://adk.sync.com/sync'] + adk_usersync: ['https://adk.sync.com/sync'] } }, bidResponse2 = { id: 'bid2', @@ -156,7 +156,7 @@ describe('Adkernel adapter', function () { }, usersyncOnlyResponse = { id: 'nobid1', ext: { - adk_usersync: ['http://adk.sync.com/sync'] + adk_usersync: ['https://adk.sync.com/sync'] } }; @@ -246,7 +246,7 @@ 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', + buildBidderRequest('https://example.com/index.html', {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string', vendorData: {}}})); let bidRequest = bidRequests[0]; expect(bidRequest).to.have.property('regs'); @@ -320,8 +320,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 () { @@ -378,7 +378,7 @@ 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'); }); }); diff --git a/test/spec/modules/admanBidAdapter_spec.js b/test/spec/modules/admanBidAdapter_spec.js deleted file mode 100644 index 37a097427d53..000000000000 --- a/test/spec/modules/admanBidAdapter_spec.js +++ /dev/null @@ -1,215 +0,0 @@ -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'); - }); - }); - - 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); - }); - - 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('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': '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'); - }) - }); - - 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() { - 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 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])); - }); - - it('handles nobid responses', function() { - let bids = { - 'body': { - 'bids': [] - } - }; - - let result = spec.interpretResponse(bids); - expect(result.length).to.equal(0); - }); - }); - 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 - }]); - }); - }); -}); diff --git a/test/spec/modules/admediaBidAdapter_spec.js b/test/spec/modules/admediaBidAdapter_spec.js index 2e14eee938c7..78228b85bfff 100644 --- a/test/spec/modules/admediaBidAdapter_spec.js +++ b/test/spec/modules/admediaBidAdapter_spec.js @@ -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 deleted file mode 100644 index 54d0dbee6e46..000000000000 --- a/test/spec/modules/admixerBidAdapter_spec.js +++ /dev/null @@ -1,117 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/admixerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const BIDDER_CODE = 'admixer'; -const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; -const ZONE_ID = '2eb6bd58-865c-47ce-af7f-a918108c3fd2'; - -describe('AdmixerAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.be.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': BIDDER_CODE, - 'params': { - 'zone': ZONE_ID - }, - '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': BIDDER_CODE, - 'params': { - 'zone': ZONE_ID - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should add referrer and imp to be equal bidRequest', function () { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data.substr(5)); - expect(payload.referrer).to.not.be.undefined; - expect(payload.imps[0]).to.deep.equal(bidRequests[0]); - }); - - it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.equal(ENDPOINT_URL); - expect(request.method).to.equal('GET'); - }); - }); - - describe('interpretResponse', function () { - let response = { - body: [{ - 'currency': 'USD', - 'cpm': 6.210000, - 'ad': '
ad
', - 'width': 300, - 'height': 600, - 'creativeId': 'ccca3e5e-0c54-4761-9667-771322fbdffc', - 'ttl': 360, - 'netRevenue': false, - 'bidId': '5e4e763b6bc60b' - }] - }; - - it('should get correct bid response', function () { - const body = response.body; - let expectedResponse = [ - { - 'requestId': body[0].bidId, - 'cpm': body[0].cpm, - 'creativeId': body[0].creativeId, - 'width': body[0].width, - 'height': body[0].height, - 'ad': body[0].ad, - 'vastUrl': undefined, - 'currency': body[0].currency, - 'netRevenue': body[0].netRevenue, - 'ttl': body[0].ttl, - } - ]; - - let result = spec.interpretResponse(response); - expect(result[0]).to.deep.equal(expectedResponse[0]); - }); - - it('handles nobid responses', function () { - let response = []; - - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/adpod_spec.js b/test/spec/modules/adpod_spec.js index f8c5387b6ce5..6137d641cdfb 100644 --- a/test/spec/modules/adpod_spec.js +++ b/test/spec/modules/adpod_spec.js @@ -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 }] diff --git a/test/spec/modules/adponeBidAdapter_spec.js b/test/spec/modules/adponeBidAdapter_spec.js index da685a563945..e1535f8596be 100644 --- a/test/spec/modules/adponeBidAdapter_spec.js +++ b/test/spec/modules/adponeBidAdapter_spec.js @@ -126,11 +126,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, @@ -157,7 +157,7 @@ describe('interpretResponse', function () { 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(''); + expect(newResponse[0].ad).to.be.equal(''); }); it('should correctly reorder the server response', function () { @@ -173,7 +173,7 @@ describe('interpretResponse', function () { currency: 'USD', netRevenue: true, ttl: 300, - ad: '' + ad: '' }); }); diff --git a/test/spec/modules/adspiritBidAdapter_spec.js b/test/spec/modules/adspiritBidAdapter_spec.js deleted file mode 100644 index 7f9076123847..000000000000 --- 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 deleted file mode 100644 index 28bb057dffea..000000000000 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ /dev/null @@ -1,311 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/adtelligentBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const ENDPOINT = '//hb.adtelligent.com/auction/'; - -const DISPLAY_REQUEST = { - 'bidder': 'adtelligent', - 'params': { - 'aid': 12345 - }, - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [300, 250] -}; - -const VIDEO_REQUEST = { - 'bidder': 'adtelligent', - 'mediaTypes': { - 'video': {} - }, - 'params': { - 'aid': 12345 - }, - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [[480, 360], [640, 480]] -}; - -const SERVER_VIDEO_RESPONSE = { - 'source': {'aid': 12345, 'pubId': 54321}, - 'bids': [{ - 'vastUrl': 'http://rtb.adtelligent.com/vast/?adid=44F2AEB9BFC881B3', - 'requestId': '2e41f65424c87c', - 'url': '44F2AEB9BFC881B3', - 'creative_id': 342516, - 'cmpId': 342516, - 'height': 480, - 'cur': 'USD', - 'width': 640, - 'cpm': 0.9 - } - ] -}; - -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': ['link1', 'link2'], - 'cookieURLSTypes': ['image', 'iframe'] -}; - -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.adtelligent.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('adtelligentBidAdapter', function () { // todo remove only - const adapter = newBidder(spec); - - 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(12345); - }); - - 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); - }); - }); - - 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,640x480' - }; - - 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' - }; - - 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', - callbackId2: '84ab500420319d', - ad_type2: 'video', - aid2: 12345, - sizes2: '480x360,640x480' - }; - - 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/aduptechBidAdapter_spec.js b/test/spec/modules/aduptechBidAdapter_spec.js deleted file mode 100644 index da0b603ebfcc..000000000000 --- a/test/spec/modules/aduptechBidAdapter_spec.js +++ /dev/null @@ -1,261 +0,0 @@ -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'; - -describe('AduptechBidAdapter', 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 true when necessary information is given', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - publisher: 'test', - placement: '1234' - } - })).to.be.true; - }); - - it('should return false on empty bid', function () { - expect(spec.isBidRequestValid({})).to.be.false; - }); - - it('should return false on missing sizes', function () { - expect(spec.isBidRequestValid({ - params: { - publisher: 'test', - placement: '1234' - } - })).to.be.false; - }); - - it('should return false on empty sizes', function () { - expect(spec.isBidRequestValid({ - sizes: [], - params: { - publisher: 'test', - placement: '1234' - } - })).to.be.false; - }); - - it('should return false on missing params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - })).to.be.false; - }); - - it('should return false on invalid params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: 'bar' - })).to.be.false; - }); - - it('should return false on empty params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: {} - })).to.be.false; - }); - - it('should return false on missing publisher', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - placement: '1234' - } - })).to.be.false; - }); - - it('should return false on missing placement', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - publisher: 'test' - } - })).to.be.false; - }); - }); - - 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]], - params: { - publisher: 'publisher1', - placement: 'placement1' - } - }, - { - bidder: BIDDER_CODE, - bidId: 'bidId2', - adUnitCode: 'adUnitCode2', - transactionId: 'transactionId2', - auctionId: 'auctionId2', - sizes: [[500, 600]], - params: { - publisher: 'publisher2', - placement: 'placement2' - } - } - ]; - - 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 - }); - - 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 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]], - params: { - publisher: 'publisher3', - placement: 'placement3' - } - } - ]; - - 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 encode publisher param in endpoint url', function () { - const bidRequests = [ - { - bidder: BIDDER_CODE, - bidId: 'bidId1', - adUnitCode: 'adUnitCode1', - transactionId: 'transactionId1', - auctionId: 'auctionId1', - 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', function () { - expect(spec.buildRequests([])).to.deep.equal([]); - }); - }); - - describe('interpretResponse', function () { - it('should correctly interpret the server response', function () { - 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', function () { - expect(spec.interpretResponse({})).to.deep.equal([]); - }); - - it('should handle missing bid', function () { - expect(spec.interpretResponse({ - body: { - creative: {} - } - })).to.deep.equal([]); - }); - - it('should handle missing creative', function () { - expect(spec.interpretResponse({ - body: { - bid: {} - } - })).to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/advenueBidAdapter_spec.js b/test/spec/modules/advenueBidAdapter_spec.js index f6ffb277bf91..f00b9a9f6805 100644 --- a/test/spec/modules/advenueBidAdapter_spec.js +++ b/test/spec/modules/advenueBidAdapter_spec.js @@ -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/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index 7edb9416b038..a76468671c8f 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -5,7 +5,7 @@ import { spec } from 'modules/adyoulikeBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; describe('Adyoulike Adapter', function () { - const canonicalUrl = 'http://canonical.url/?t=%26'; + const canonicalUrl = 'https://canonical.url/?t=%26'; const defaultDC = 'hb-api'; const bidRequestWithEmptyPlacement = [ { diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js index 642ac2f0df4e..4b78711f46fb 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'; -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 f9b0758749b8..000000000000 --- 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 deleted file mode 100644 index ce8a34509c4b..000000000000 --- a/test/spec/modules/aniviewBidAdapter_spec.js +++ /dev/null @@ -1,183 +0,0 @@ -import { spec } from 'modules/aniviewBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -const { expect } = require('chai'); - -describe('ANIVIEW Bid Adapter 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': 'aniview', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'video1', - 'sizes': [[300, 250], [640, 480]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - }; - - 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 = { - something: 'is wrong' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const ENDPOINT = 'https://v.lkqd.net/ad'; - let bid2Requests = [ - { - 'bidder': 'aniview', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'test1', - 'sizes': [[300, 250], [640, 480]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - } - ]; - let bid1Request = [ - { - 'bidder': 'aniview', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'test1', - 'sizes': [640, 480], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - } - ]; - - it('Test 2 requests', function () { - const requests = spec.buildRequests(bid2Requests); - expect(requests.length).to.equal(2); - const r1 = requests[0]; - const d1 = requests[0].data; - expect(d1).to.have.property('AV_PUBLISHERID'); - expect(d1.AV_PUBLISHERID).to.equal('123456'); - expect(d1).to.have.property('AV_CHANNELID'); - expect(d1.AV_CHANNELID).to.equal('123456'); - expect(d1).to.have.property('AV_WIDTH'); - expect(d1.AV_WIDTH).to.equal(300); - expect(d1).to.have.property('AV_HEIGHT'); - expect(d1.AV_HEIGHT).to.equal(250); - expect(d1).to.have.property('AV_URL'); - expect(d1).to.have.property('cb'); - expect(d1).to.have.property('s2s'); - expect(d1.s2s).to.equal('1'); - expect(d1).to.have.property('pbjs'); - expect(d1.pbjs).to.equal(1); - expect(r1).to.have.property('url'); - expect(r1.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); - const r2 = requests[1]; - const d2 = requests[1].data; - expect(d2).to.have.property('AV_PUBLISHERID'); - expect(d2.AV_PUBLISHERID).to.equal('123456'); - expect(d2).to.have.property('AV_CHANNELID'); - expect(d2.AV_CHANNELID).to.equal('123456'); - expect(d2).to.have.property('AV_WIDTH'); - expect(d2.AV_WIDTH).to.equal(640); - expect(d2).to.have.property('AV_HEIGHT'); - expect(d2.AV_HEIGHT).to.equal(480); - expect(d2).to.have.property('AV_URL'); - expect(d2).to.have.property('cb'); - expect(d2).to.have.property('s2s'); - expect(d2.s2s).to.equal('1'); - expect(d2).to.have.property('pbjs'); - expect(d2.pbjs).to.equal(1); - expect(r2).to.have.property('url'); - expect(r2.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); - }); - - it('Test 1 request', function () { - const requests = spec.buildRequests(bid1Request); - expect(requests.length).to.equal(1); - const r = requests[0]; - const d = requests[0].data; - expect(d).to.have.property('AV_PUBLISHERID'); - expect(d.AV_PUBLISHERID).to.equal('123456'); - expect(d).to.have.property('AV_CHANNELID'); - expect(d.AV_CHANNELID).to.equal('123456'); - expect(d).to.have.property('AV_WIDTH'); - expect(d.AV_WIDTH).to.equal(640); - expect(d).to.have.property('AV_HEIGHT'); - expect(d.AV_HEIGHT).to.equal(480); - expect(d).to.have.property('AV_URL'); - expect(d).to.have.property('cb'); - expect(d).to.have.property('s2s'); - expect(d.s2s).to.equal('1'); - expect(d).to.have.property('pbjs'); - expect(d.pbjs).to.equal(1); - expect(r).to.have.property('url'); - expect(r.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); - }); - }); - - describe('interpretResponse', function () { - let bidRequest = { - 'url': 'https://gov.aniview.com/api/adserver/vast3/', - 'data': { - 'bidId': '253dcb69fb2577', - AV_PUBLISHERID: '55b78633181f4603178b4568', - AV_CHANNELID: '55b7904d181f46410f8b4568', - } - }; - let serverResponse = {}; - serverResponse.body = 'FORDFORD00:00:15'; - - it('Check bid interpretResponse', function () { - const BIDDER_CODE = 'aniview'; - let bidResponses = spec.interpretResponse(serverResponse, bidRequest); - expect(bidResponses.length).to.equal(1); - let bidResponse = bidResponses[0]; - expect(bidResponse.requestId).to.equal(bidRequest.data.bidId); - expect(bidResponse.bidderCode).to.equal(BIDDER_CODE); - expect(bidResponse.cpm).to.equal('2'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.currency).to.equal('USD'); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.mediaType).to.equal('video'); - }); - - it('safely handles XML parsing failure from invalid bid response', function () { - let invalidServerResponse = {}; - invalidServerResponse.body = ''; - - let result = spec.interpretResponse(invalidServerResponse, bidRequest); - expect(result.length).to.equal(0); - }); - - it('handles nobid responses', function () { - let nobidResponse = {}; - nobidResponse.body = ''; - - let result = spec.interpretResponse(nobidResponse, bidRequest); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index 0f99901bce41..dd624222d69f 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -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 () { diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index c1d307521a52..5365b0ac5297 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -6,7 +6,7 @@ import { auctionManager } from 'src/auctionManager'; import { deepClone } from 'src/utils'; import { config } from 'src/config'; -const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; +const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid'; describe('AppNexusAdapter', function () { const adapter = newBidder(spec); @@ -215,7 +215,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 () {} } }); @@ -656,13 +656,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' ] } } @@ -671,7 +671,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(',') @@ -757,7 +757,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': [ @@ -773,7 +773,7 @@ describe('AppNexusAdapter', function () { 'publisher_currency_code': '$', 'client_initiated_ad_counting': true, 'viewability': { - 'config': '' + 'config': '' }, 'rtb': { 'banner': { @@ -784,7 +784,7 @@ describe('AppNexusAdapter', function () { 'trackers': [ { 'impression_urls': [ - 'http://lax1-ib.adnxs.com/impression' + 'https://lax1-ib.adnxs.com/impression' ], 'video_events': {} } @@ -855,7 +855,7 @@ describe('AppNexusAdapter', function () { 'content': '' } }, - 'javascriptTrackers': '' + 'javascriptTrackers': '' }] }] }; @@ -887,10 +887,10 @@ describe('AppNexusAdapter', function () { 'notify_url': 'imptracker.com', 'rtb': { 'video': { - 'asset_url': 'http://sample.vastURL.com/here/vid' + 'asset_url': 'https://sample.vastURL.com/here/vid' } }, - 'javascriptTrackers': '' + 'javascriptTrackers': '' }] }] }; @@ -923,12 +923,12 @@ describe('AppNexusAdapter', function () { 'notify_url': 'imptracker.com', 'rtb': { 'video': { - 'asset_url': 'http://sample.vastURL.com/here/adpod', + 'asset_url': 'https://sample.vastURL.com/here/adpod', 'duration_ms': 30000, } }, 'viewability': { - 'config': '' + 'config': '' } }] }] @@ -965,29 +965,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: [{ @@ -1000,7 +1000,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 () { diff --git a/test/spec/modules/arteebeeBidAdapter_spec.js b/test/spec/modules/arteebeeBidAdapter_spec.js deleted file mode 100644 index 013e1bd6c0c7..000000000000 --- 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/atomxBidAdapter_spec.js b/test/spec/modules/atomxBidAdapter_spec.js index fdcdb55ec7f4..782619d04dba 100644 --- a/test/spec/modules/atomxBidAdapter_spec.js +++ b/test/spec/modules/atomxBidAdapter_spec.js @@ -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/audienceNetworkBidAdapter_spec.js b/test/spec/modules/audienceNetworkBidAdapter_spec.js deleted file mode 100644 index a495b33438c8..000000000000 --- a/test/spec/modules/audienceNetworkBidAdapter_spec.js +++ /dev/null @@ -1,522 +0,0 @@ -/** - * @file Tests for AudienceNetwork adapter. - */ -import { expect } from 'chai'; - -import { spec } from 'modules/audienceNetworkBidAdapter'; -import * as utils from 'src/utils'; - -const { - code, - supportedMediaTypes, - isBidRequestValid, - buildRequests, - interpretResponse -} = spec; - -const bidder = 'audienceNetwork'; -const placementId = 'test-placement-id'; -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()); - -describe('AudienceNetwork adapter', function () { - describe('Public API', function () { - it('code', function () { - expect(code).to.equal(bidder); - }); - it('supportedMediaTypes', function () { - expect(supportedMediaTypes).to.deep.equal(['banner', 'video']); - }); - it('isBidRequestValid', function () { - expect(isBidRequestValid).to.be.a('function'); - }); - it('buildRequests', function () { - expect(buildRequests).to.be.a('function'); - }); - it('interpretResponse', function () { - expect(interpretResponse).to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('missing placementId parameter', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[300, 250]] - })).to.equal(false); - }); - - it('invalid sizes parameter', function () { - expect(isBidRequestValid({ - bidder, - sizes: ['', undefined, null, '300x100', [300, 100], [300], {}], - params: { placementId } - })).to.equal(false); - }); - - it('valid when at least one valid size', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[1, 1], [300, 250]], - params: { placementId } - })).to.equal(true); - }); - - it('valid parameters', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[300, 250], [320, 50]], - params: { placementId } - })).to.equal(true); - }); - - it('fullwidth', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[300, 250], [336, 280]], - params: { - placementId, - format: 'fullwidth' - } - })).to.equal(true); - }); - - it('native', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[300, 250]], - params: { - placementId, - format: 'native' - } - })).to.equal(true); - }); - - it('native with non-IAB size', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[728, 90]], - params: { - placementId, - format: 'native' - } - })).to.equal(true); - }); - - it('video', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[playerwidth, playerheight]], - params: { - placementId, - format: 'video' - } - })).to.equal(true); - }); - }); - - describe('buildRequests', function () { - before(function () { - sinon - .stub(utils, 'generateUUID') - .returns('test-uuid'); - }); - - after(function () { - utils.generateUUID.restore(); - }); - - 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([{ - adformats: ['300x250'], - method: 'GET', - 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}` - }]); - }); - - it('can build URL for video unit', function () { - expect(buildRequests([{ - bidder, - bidId: requestId, - sizes: [[640, 480]], - params: { - placementId, - format: 'video' - } - }])).to.deep.equal([{ - adformats: ['video'], - method: 'GET', - 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` - }]); - }); - - it('can build URL for native unit in non-IAB size', function () { - expect(buildRequests([{ - bidder, - bidId: requestId, - sizes: [[728, 90]], - params: { - placementId, - format: 'native' - } - }])).to.deep.equal([{ - adformats: ['native'], - method: 'GET', - 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}` - }]); - }); - - it('can build URL for deprecated fullwidth unit, overriding platform', function () { - const platform = 'test-platform'; - const debugPlatform = debug.replace('241394079772386', platform); - - expect(buildRequests([{ - bidder, - bidId: requestId, - sizes: [[300, 250]], - params: { - placementId, - platform, - format: 'fullwidth' - } - }])).to.deep.equal([{ - adformats: ['300x250'], - method: 'GET', - 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}` - }]); - }); - }); - - describe('interpretResponse', function () { - it('error in response', function () { - expect(interpretResponse({ - body: { - errors: ['test-error-message'] - } - }, {})).to.deep.equal([]); - }); - - it('valid native bid in response', function () { - const [bidResponse] = interpretResponse({ - body: { - errors: [], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: 'test-bid-id', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['native'], - requestIds: [requestId], - sizes: [[300, 250]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.width).to.equal(300); - expect(bidResponse.height).to.equal(250); - expect(bidResponse.ad) - .to.contain(`placementid: '${placementId}',`) - .and.to.contain(`format: 'native',`) - .and.to.contain(`bidid: 'test-bid-id',`) - .and.to.contain('getElementsByTagName("style")', 'ad missing native styles') - .and.to.contain('
', 'ad missing native container'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.creativeId).to.equal(placementId); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.currency).to.equal('USD'); - - expect(bidResponse.hb_bidder).to.equal('fan'); - expect(bidResponse.fb_bidid).to.equal('test-bid-id'); - expect(bidResponse.fb_format).to.equal('native'); - expect(bidResponse.fb_placementid).to.equal(placementId); - }); - - it('valid IAB bid in response', function () { - const [bidResponse] = interpretResponse({ - body: { - errors: [], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: 'test-bid-id', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['300x250'], - requestIds: [requestId], - sizes: [[300, 250]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.width).to.equal(300); - expect(bidResponse.height).to.equal(250); - expect(bidResponse.ad) - .to.contain(`placementid: '${placementId}',`) - .and.to.contain(`format: '300x250',`) - .and.to.contain(`bidid: 'test-bid-id',`) - .and.not.to.contain('getElementsByTagName("style")', 'ad should not contain native styles') - .and.not.to.contain('
', 'ad should not contain native container'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.creativeId).to.equal(placementId); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.currency).to.equal('USD'); - expect(bidResponse.hb_bidder).to.equal('fan'); - expect(bidResponse.fb_bidid).to.equal('test-bid-id'); - expect(bidResponse.fb_format).to.equal('300x250'); - expect(bidResponse.fb_placementid).to.equal(placementId); - }); - - it('filters invalid slot sizes', function () { - const [bidResponse] = interpretResponse({ - body: { - errors: [], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: 'test-bid-id', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['300x250'], - requestIds: [requestId], - sizes: [[300, 250]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.width).to.equal(300); - expect(bidResponse.height).to.equal(250); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.creativeId).to.equal(placementId); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.currency).to.equal('USD'); - expect(bidResponse.hb_bidder).to.equal('fan'); - expect(bidResponse.fb_bidid).to.equal('test-bid-id'); - expect(bidResponse.fb_format).to.equal('300x250'); - expect(bidResponse.fb_placementid).to.equal(placementId); - }); - - it('valid multiple bids in response', function () { - const placementIdNative = 'test-placement-id-native'; - const placementIdIab = 'test-placement-id-iab'; - - const [bidResponseNative, bidResponseIab] = interpretResponse({ - body: { - errors: [], - bids: { - [placementIdNative]: [{ - placement_id: placementIdNative, - bid_id: 'test-bid-id-native', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }], - [placementIdIab]: [{ - placement_id: placementIdIab, - bid_id: 'test-bid-id-iab', - bid_price_cents: 456, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['native', '300x250'], - requestIds: [requestId, requestId], - sizes: ['300x250', [300, 250]] - }); - - expect(bidResponseNative.cpm).to.equal(1.23); - expect(bidResponseNative.requestId).to.equal(requestId); - expect(bidResponseNative.width).to.equal(300); - expect(bidResponseNative.height).to.equal(250); - expect(bidResponseNative.ad) - .to.contain(`placementid: '${placementIdNative}',`) - .and.to.contain(`format: 'native',`) - .and.to.contain(`bidid: 'test-bid-id-native',`); - expect(bidResponseNative.ttl).to.equal(600); - expect(bidResponseNative.creativeId).to.equal(placementIdNative); - expect(bidResponseNative.netRevenue).to.equal(true); - expect(bidResponseNative.currency).to.equal('USD'); - expect(bidResponseNative.hb_bidder).to.equal('fan'); - expect(bidResponseNative.fb_bidid).to.equal('test-bid-id-native'); - expect(bidResponseNative.fb_format).to.equal('native'); - expect(bidResponseNative.fb_placementid).to.equal(placementIdNative); - - expect(bidResponseIab.cpm).to.equal(4.56); - expect(bidResponseIab.requestId).to.equal(requestId); - expect(bidResponseIab.width).to.equal(300); - expect(bidResponseIab.height).to.equal(250); - expect(bidResponseIab.ad) - .to.contain(`placementid: '${placementIdIab}',`) - .and.to.contain(`format: '300x250',`) - .and.to.contain(`bidid: 'test-bid-id-iab',`); - expect(bidResponseIab.ttl).to.equal(600); - expect(bidResponseIab.creativeId).to.equal(placementIdIab); - expect(bidResponseIab.netRevenue).to.equal(true); - expect(bidResponseIab.currency).to.equal('USD'); - expect(bidResponseIab.hb_bidder).to.equal('fan'); - expect(bidResponseIab.fb_bidid).to.equal('test-bid-id-iab'); - expect(bidResponseIab.fb_format).to.equal('300x250'); - expect(bidResponseIab.fb_placementid).to.equal(placementIdIab); - }); - - it('valid video bid in response', function () { - const bidId = 'test-bid-id-video'; - - const [bidResponse] = interpretResponse({ - body: { - errors: [], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: bidId, - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['video'], - requestIds: [requestId], - sizes: [[playerwidth, playerheight]] - }); - - 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.width).to.equal(playerwidth); - expect(bidResponse.height).to.equal(playerheight); - }); - - it('mixed video and native bids', function () { - const videoPlacementId = 'test-video-placement-id'; - const videoBidId = 'test-video-bid-id'; - const nativePlacementId = 'test-native-placement-id'; - const nativeBidId = 'test-native-bid-id'; - - const [bidResponseVideo, bidResponseNative] = interpretResponse({ - body: { - errors: [], - bids: { - [videoPlacementId]: [{ - placement_id: videoPlacementId, - bid_id: videoBidId, - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }], - [nativePlacementId]: [{ - placement_id: nativePlacementId, - bid_id: nativeBidId, - bid_price_cents: 456, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['video', 'native'], - requestIds: [requestId, requestId], - sizes: [[playerwidth, playerheight], [300, 250]] - }); - - 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.width).to.equal(playerwidth); - expect(bidResponseVideo.height).to.equal(playerheight); - - expect(bidResponseNative.cpm).to.equal(4.56); - expect(bidResponseNative.requestId).to.equal(requestId); - expect(bidResponseNative.ttl).to.equal(600); - expect(bidResponseNative.width).to.equal(300); - expect(bidResponseNative.height).to.equal(250); - expect(bidResponseNative.ad) - .to.contain(`placementid: '${nativePlacementId}',`) - .and.to.contain(`format: 'native',`) - .and.to.contain(`bidid: '${nativeBidId}',`); - }); - - it('mixture of valid native bid and error in response', function () { - const [bidResponse] = interpretResponse({ - body: { - errors: ['test-error-message'], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: 'test-bid-id', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['native'], - requestIds: [requestId], - sizes: [[300, 250]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.width).to.equal(300); - expect(bidResponse.height).to.equal(250); - expect(bidResponse.ad) - .to.contain(`placementid: '${placementId}',`) - .and.to.contain(`format: 'native',`) - .and.to.contain(`bidid: 'test-bid-id',`) - .and.to.contain('getElementsByTagName("style")', 'ad missing native styles') - .and.to.contain('
', 'ad missing native container'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.creativeId).to.equal(placementId); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.currency).to.equal('USD'); - - expect(bidResponse.hb_bidder).to.equal('fan'); - expect(bidResponse.fb_bidid).to.equal('test-bid-id'); - expect(bidResponse.fb_format).to.equal('native'); - expect(bidResponse.fb_placementid).to.equal(placementId); - }); - }); -}); diff --git a/test/spec/modules/bidphysicsBidAdapter_spec.js b/test/spec/modules/bidphysicsBidAdapter_spec.js index ba93642ad810..8c46b8cefa6f 100644 --- a/test/spec/modules/bidphysicsBidAdapter_spec.js +++ b/test/spec/modules/bidphysicsBidAdapter_spec.js @@ -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 6f518f32ccf8..000000000000 --- 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 a3ce90d927ae..000000000000 --- 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 deleted file mode 100644 index 6ca9675a1bbd..000000000000 --- a/test/spec/modules/bridgewellBidAdapter_spec.js +++ /dev/null @@ -1,1164 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/bridgewellBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -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 () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('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); - }); - - 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 - }; - - bidWithZeroCpmWeight.params = { - 'ChannelID': 0 - }; - - 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); - }); - }); - - describe('buildRequests', function () { - it('should attach valid params to the tag', function () { - const request = spec.buildRequests(bidRequests); - 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'); - } - }); - - it('should attach validBidRequests to the tag', function () { - const request = spec.buildRequests(bidRequests); - const validBidRequests = request.validBidRequests; - expect(validBidRequests).to.deep.equal(bidRequests); - }); - }); - - 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' - }, - { - '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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - '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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - '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'); - } - }); - }); - - it('should give up bid if server response is undefiend', function () { - const result = spec.interpretResponse({'body': undefined}, request); - 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', - }])); - 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 result = spec.interpretResponse({'body': [target]}, 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 result = spec.interpretResponse({'body': [target]}, request); - 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([]); - }); - - 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 result = spec.interpretResponse({'body': [target]}, request); - 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 result = spec.interpretResponse({'body': [target]}, request); - 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 result = spec.interpretResponse({'body': [target]}, request); - 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 result = spec.interpretResponse({'body': [target]}, request); - 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 result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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': { - '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'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - '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': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - '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'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - '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'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': [], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - 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 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': [] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if mediaType is not support', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'superNiceAd', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/bucksenseBidAdapter_spec.js b/test/spec/modules/bucksenseBidAdapter_spec.js index 17b5c3ceff5f..b9da6c077b26 100644 --- a/test/spec/modules/bucksenseBidAdapter_spec.js +++ b/test/spec/modules/bucksenseBidAdapter_spec.js @@ -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 @@ -109,7 +109,7 @@ describe('Bucksense Adapter', function() { '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/c1xBidAdapter_spec.js b/test/spec/modules/c1xBidAdapter_spec.js index 268ad46d0ce9..a728e52dbc4d 100644 --- a/test/spec/modules/c1xBidAdapter_spec.js +++ b/test/spec/modules/c1xBidAdapter_spec.js @@ -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/ccxBidAdapter_spec.js b/test/spec/modules/ccxBidAdapter_spec.js deleted file mode 100644 index a89a0402a97a..000000000000 --- a/test/spec/modules/ccxBidAdapter_spec.js +++ /dev/null @@ -1,403 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/ccxBidAdapter'; -import * as utils from 'src/utils'; - -describe('ccxAdapter', function () { - let bids = [ - { - adUnitCode: 'banner', - auctionId: '0b9de793-8eda-481e-a548-c187d58b28d9', - bidId: '2e56e1af51a5d7', - bidder: 'ccx', - bidderRequestId: '17e7b9f58a607e', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - params: { - placementId: 607 - }, - sizes: [[300, 250]], - transactionId: 'aefddd38-cfa0-48ab-8bdd-325de4bab5f9' - }, - { - adUnitCode: 'video', - auctionId: '0b9de793-8eda-481e-a548-c187d58b28d9', - bidId: '3u94t90ut39tt3t', - bidder: 'ccx', - bidderRequestId: '23ur20r239r2r', - mediaTypes: { - video: { - playerSize: [[640, 480]] - } - }, - params: { - placementId: 608 - }, - sizes: [[640, 480]], - transactionId: 'aefddd38-cfa0-48ab-8bdd-325de4bab5f9' - } - ]; - describe('isBidRequestValid', function () { - it('Valid bid requests', function () { - expect(spec.isBidRequestValid(bids[0])).to.be.true; - expect(spec.isBidRequestValid(bids[1])).to.be.true; - }); - it('Invalid bid reqeusts - no placementId', function () { - let bidsClone = utils.deepClone(bids); - bidsClone[0].params = undefined; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.false; - }); - it('Invalid bid reqeusts - invalid banner sizes', function () { - let bidsClone = utils.deepClone(bids); - bidsClone[0].mediaTypes.banner.sizes = [300, 250]; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.false; - bidsClone[0].mediaTypes.banner.sizes = [[300, 250], [750]]; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.false; - bidsClone[0].mediaTypes.banner.sizes = []; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.false; - }); - it('Invalid bid reqeusts - invalid video sizes', function () { - let bidsClone = utils.deepClone(bids); - bidsClone[1].mediaTypes.video.playerSize = []; - expect(spec.isBidRequestValid(bidsClone[1])).to.be.false; - bidsClone[1].mediaTypes.video.sizes = [640, 480]; - expect(spec.isBidRequestValid(bidsClone[1])).to.be.false; - }); - it('Valid bid reqeust - old style sizes', function () { - let bidsClone = utils.deepClone(bids); - delete (bidsClone[0].mediaTypes); - delete (bidsClone[1].mediaTypes); - expect(spec.isBidRequestValid(bidsClone[0])).to.be.true; - expect(spec.isBidRequestValid(bidsClone[1])).to.be.true; - bidsClone[0].sizes = [300, 250]; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.true; - }); - }); - describe('buildRequests', function () { - it('No valid bids', function () { - expect(spec.buildRequests([])).to.be.undefined; - }); - - it('Valid bid request - default', function () { - let response = spec.buildRequests(bids, {bids}); - expect(response).to.be.not.empty; - expect(response.data).to.be.not.empty; - - let data = JSON.parse(response.data); - - expect(data).to.be.an('object'); - expect(data).to.have.keys('site', 'imp', 'id', 'ext', 'device'); - - let imps = [ - { - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - }, - ext: { - pid: 607 - }, - id: '2e56e1af51a5d7', - secure: 1 - }, - { - video: { - w: 640, - h: 480, - protocols: [2, 3, 5, 6], - mimes: ['video/mp4', 'video/x-flv'], - playbackmethod: [1, 2, 3, 4], - skip: 0 - }, - id: '3u94t90ut39tt3t', - secure: 1, - ext: { - pid: 608 - } - } - ]; - expect(data.imp).to.deep.have.same.members(imps); - }); - - it('Valid bid request - custom', function () { - let bidsClone = utils.deepClone(bids); - let imps = [ - { - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - }, - ext: { - pid: 607 - }, - id: '2e56e1af51a5d7', - secure: 1 - }, - { - video: { - w: 640, - h: 480, - protocols: [5, 6], - mimes: ['video/mp4'], - playbackmethod: [3], - skip: 1, - skipafter: 5 - }, - id: '3u94t90ut39tt3t', - secure: 1, - ext: { - pid: 608 - } - } - ]; - - bidsClone[1].params.video = {}; - bidsClone[1].params.video.protocols = [5, 6]; - bidsClone[1].params.video.mimes = ['video/mp4']; - bidsClone[1].params.video.playbackmethod = [3]; - bidsClone[1].params.video.skip = 1; - bidsClone[1].params.video.skipafter = 5; - - let response = spec.buildRequests(bidsClone, {'bids': bidsClone}); - let data = JSON.parse(response.data); - - expect(data.imp).to.deep.have.same.members(imps); - }); - it('Valid bid request - sizes old style', function () { - let bidsClone = utils.deepClone(bids); - delete (bidsClone[0].mediaTypes); - delete (bidsClone[1].mediaTypes); - bidsClone[0].mediaType = 'banner'; - bidsClone[1].mediaType = 'video'; - - let imps = [ - { - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - }, - ext: { - pid: 607 - }, - id: '2e56e1af51a5d7', - secure: 1 - }, - { - video: { - w: 640, - h: 480, - protocols: [2, 3, 5, 6], - mimes: ['video/mp4', 'video/x-flv'], - playbackmethod: [1, 2, 3, 4], - skip: 0 - }, - id: '3u94t90ut39tt3t', - secure: 1, - ext: { - pid: 608 - } - } - ]; - - let response = spec.buildRequests(bidsClone, {'bids': bidsClone}); - let data = JSON.parse(response.data); - - expect(data.imp).to.deep.have.same.members(imps); - }); - it('Valid bid request - sizes old style - no media type', function () { - let bidsClone = utils.deepClone(bids); - delete (bidsClone[0].mediaTypes); - delete (bidsClone[1]); - - let imps = [ - { - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - }, - ext: { - pid: 607 - }, - id: '2e56e1af51a5d7', - secure: 1 - } - ]; - - let response = spec.buildRequests(bidsClone, {'bids': bidsClone}); - let data = JSON.parse(response.data); - - expect(data.imp).to.deep.have.same.members(imps); - }); - }); - - let response = { - id: '0b9de793-8eda-481e-a548-c187d58b28d9', - seatbid: [ - { - bid: [ - { - id: '2e56e1af51a5d7_221', - impid: '2e56e1af51a5d7', - price: 8.1, - adid: '221', - adm: '', - adomain: ['clickonometrics.com'], - crid: '221', - w: 300, - h: 250, - ext: { - type: 'standard' - } - }, - { - id: '2e56e1af51a5d8_222', - impid: '2e56e1af51a5d8', - price: 5.68, - adid: '222', - adm: '', - adomain: ['clickonometrics.com'], - crid: '222', - w: 640, - h: 480, - ext: { - type: 'video' - } - } - ] - } - ], - cur: 'PLN', - ext: { - ttl: 5, - usersync: [ - { - type: 'image', - url: 'http://foo.sync?param=1' - }, - { - type: 'iframe', - url: 'http://foo.sync?param=2' - } - ] - } - }; - - describe('interpretResponse', function () { - it('Valid bid response - multi', function () { - let bidResponses = [ - { - requestId: '2e56e1af51a5d7', - cpm: 8.1, - width: 300, - height: 250, - creativeId: '221', - netRevenue: false, - ttl: 5, - currency: 'PLN', - ad: '' - }, - { - requestId: '2e56e1af51a5d8', - cpm: 5.68, - width: 640, - height: 480, - creativeId: '222', - netRevenue: false, - ttl: 5, - currency: 'PLN', - vastXml: '' - } - ]; - expect(spec.interpretResponse({body: response})).to.deep.have.same.members(bidResponses); - }); - - it('Valid bid response - single', function () { - delete response.seatbid[0].bid[1]; - let bidResponses = [ - { - requestId: '2e56e1af51a5d7', - cpm: 8.1, - width: 300, - height: 250, - creativeId: '221', - netRevenue: false, - ttl: 5, - currency: 'PLN', - ad: '' - } - ]; - expect(spec.interpretResponse({body: response})).to.deep.have.same.members(bidResponses); - }); - - it('Empty bid response', function () { - expect(spec.interpretResponse({})).to.be.empty; - }); - }); - describe('getUserSyncs', function () { - it('Valid syncs - all', function () { - let syncOptions = { - iframeEnabled: true, - pixelEnabled: true - }; - - let expectedSyncs = [ - { - type: 'image', - url: 'http://foo.sync?param=1' - }, - { - type: 'iframe', - url: 'http://foo.sync?param=2' - } - ]; - expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs); - }); - - it('Valid syncs - only image', function () { - let syncOptions = { - iframeEnabled: false, - pixelEnabled: true - }; - let expectedSyncs = [ - { - type: 'image', url: 'http://foo.sync?param=1' - } - ]; - expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs); - }); - - it('Valid syncs - only iframe', function () { - let syncOptions = {iframeEnabled: true, pixelEnabled: false}; - let expectedSyncs = [ - { - type: 'iframe', url: 'http://foo.sync?param=2' - } - ]; - expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs); - }); - - it('Valid syncs - empty', function () { - let syncOptions = {iframeEnabled: true, pixelEnabled: true}; - response.ext.usersync = {}; - expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.be.empty; - }); - }); -}); diff --git a/test/spec/modules/cedatoBidAdapter_spec.js b/test/spec/modules/cedatoBidAdapter_spec.js index 969c06a64a29..d05f3e7abbf0 100644 --- a/test/spec/modules/cedatoBidAdapter_spec.js +++ b/test/spec/modules/cedatoBidAdapter_spec.js @@ -68,7 +68,7 @@ describe('the cedato adapter', function () { adomain: 'cedato.com', uuid: bid.bidId, crid: '1450133326', - adm: "
\n\n\n", + adm: "
\n\n\n", h: 250, w: 300, price: '0.1' diff --git a/test/spec/modules/cleanmedianetBidAdapter_spec.js b/test/spec/modules/cleanmedianetBidAdapter_spec.js deleted file mode 100644 index 09f76806fd70..000000000000 --- a/test/spec/modules/cleanmedianetBidAdapter_spec.js +++ /dev/null @@ -1,603 +0,0 @@ -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'; - -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() { - expect(helper.startsWith('cleanmediaads.com', 'cleanmediaads')).to.equal( - true - ); - }); - }); - - 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 validate supply-partner ID', function() { - 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 bid floor', function() { - 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() { - 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() { - 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); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 0 } }) - ).to.equal(true); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 1 } }) - ).to.equal(true); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 2 } }) - ).to.equal(false); - }); - }); - - 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() { - let response; - response = spec.buildRequests([]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - response = spec.buildRequests([bidRequest], 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], bidRequest); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(2); - }); - - 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 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.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], - bidRequest2 - )[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], - bidRequest2 - )[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], - bidRequest2 - )[0]; - expect(response.data.imp[0].bidfloor).to.equal( - bidRequestWithBidfloorEquals1.params.bidfloor - ); - stub.restore(); - }); - - it('builds request banner object correctly', function() { - let response; - const bidRequestWithBanner = utils.deepClone(bidRequest); - bidRequestWithBanner.mediaTypes = { - banner: { - sizes: [[300, 250], [120, 600]] - } - }; - response = spec.buildRequests([bidRequestWithBanner], bidRequest)[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); - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithBanner); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].banner.pos).to.equal( - bidRequestWithPosEquals1.params.pos - ); - }); - - it('builds request video object correctly', function() { - let response; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - sizes: [[300, 250], [120, 600]] - } - }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[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); - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - 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; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - context: 'instream' - } - }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal('instream'); - bidRequestWithVideo.mediaTypes.video.context = 'outstream'; - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.mediaTypes.video.context = 'outstream'; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal('outstream'); - - const bidRequestWithPosEquals2 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals2.mediaTypes.video.context = null; - response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal(null); - }); - 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[1].video.w).to.equal(304); - expect(response.data.imp[1].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[1].video.w).to.equal(304); - expect(response.data.imp[1].video.h).to.equal(254); - }); - - it('builds request with gdpr consent', function() { - let response = spec.buildRequests([bidRequest], bidRequest)[0]; - 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: '//bidder.cleanmediaads.com/user/sync/1' }, - { type: 'image', url: '//bidder.cleanmediaads.com/user/sync/2' } - ] - }, - seatbid: [ - { - seat: 'seat1', - group: 0, - bid: [ - { - id: '0', - impid: '1', - 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}', - 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://bidder.cleanmediaads.com/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' }] - } - } - ] - } - ] - }; - - it('returns an empty array on missing response', function() { - 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('aggregates banner bids from all seat bids', function() { - 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(60 * 10); - 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('aggregates video bids from all seat bids', function() { - 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(60 * 10); - 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('aggregates user-sync pixels', function() { - 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 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://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}', - 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://bidder.cleanmediaads.com/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://bidder.cleanmediaads.com/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://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675' - } - ] - } - }; - const videoRequest = 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://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}', - 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://bidder.cleanmediaads.com/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://bidder.cleanmediaads.com/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://bidder.cleanmediaads.com/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://bidder.cleanmediaads.com/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://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gc=missing' - ); - - videoResponse.ext.utrk[0].url = - 'https://bidder.cleanmediaads.com/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://bidder.cleanmediaads.com/pix/1275/scm?gc=missing' - ); - }); - }); -}); diff --git a/test/spec/modules/coinzillaBidAdapter_spec.js b/test/spec/modules/coinzillaBidAdapter_spec.js index 7a0c745d57d3..e9157e2a7353 100644 --- a/test/spec/modules/coinzillaBidAdapter_spec.js +++ b/test/spec/modules/coinzillaBidAdapter_spec.js @@ -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 04c819992cdd..7398c5c7dd93 100644 --- a/test/spec/modules/collectcentBidAdapter_spec.js +++ b/test/spec/modules/collectcentBidAdapter_spec.js @@ -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 5a8678e866cb..000000000000 --- 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/contentigniteBidAdapter_spec.js b/test/spec/modules/contentigniteBidAdapter_spec.js deleted file mode 100644 index 1867791a2343..000000000000 --- 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/cosmosBidAdapter_spec.js b/test/spec/modules/cosmosBidAdapter_spec.js index 348f5ae3ddf3..7eb51c596e4a 100644 --- a/test/spec/modules/cosmosBidAdapter_spec.js +++ b/test/spec/modules/cosmosBidAdapter_spec.js @@ -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 3dd06a484d93..d080a2570ab1 100755 --- a/test/spec/modules/cpmstarBidAdapter_spec.js +++ b/test/spec/modules/cpmstarBidAdapter_spec.js @@ -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/danmarketBidAdapter_spec.js b/test/spec/modules/danmarketBidAdapter_spec.js deleted file mode 100644 index 973cd2afb1c8..000000000000 --- 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 d39116ccb710..af0fd8a3bc9a 100644 --- a/test/spec/modules/datablocksBidAdapter_spec.js +++ b/test/spec/modules/datablocksBidAdapter_spec.js @@ -116,8 +116,8 @@ const bidderRequest = { 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 @@ -133,7 +133,7 @@ let resObject = { id: '1090738570', impid: '2966b257c81d27', price: 24.000000, - adm: '
RON', + adm: 'RON', cid: '55', adid: '177654', crid: '177656', @@ -145,7 +145,7 @@ let resObject = { id: '1090738571', impid: '2966b257c81d28', price: 24.000000, - adm: 'RON', + adm: 'RON', cid: '55', adid: '177654', crid: '177656', @@ -157,7 +157,7 @@ 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', @@ -170,7 +170,7 @@ let resObject = { cid: '12345', adid: '12345', crid: '123456', - nurl: 'http://click.v5demo.datablocks.net/m//?fcid=435235435432', + nurl: 'https://click.v5demo.datablocks.net/m//?fcid=435235435432', cat: [], api: [], w: 500, @@ -183,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 }, @@ -219,7 +219,7 @@ let bidRequest = { site: { domain: '', id: 'blank', - page: 'http://v5demo.datablocks.net/test' + page: 'https://v5demo.datablocks.net/test' } } } @@ -251,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() { diff --git a/test/spec/modules/decenteradsBidAdapter_spec.js b/test/spec/modules/decenteradsBidAdapter_spec.js deleted file mode 100644 index 3c8569b3b616..000000000000 --- 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/dgadsBidAdapter_spec.js b/test/spec/modules/dgadsBidAdapter_spec.js deleted file mode 100644 index 2454885217df..000000000000 --- 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/dspxBidAdapter_spec.js b/test/spec/modules/dspxBidAdapter_spec.js deleted file mode 100644 index 7eeac43680a4..000000000000 --- a/test/spec/modules/dspxBidAdapter_spec.js +++ /dev/null @@ -1,130 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/dspxBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; - -describe('dspxAdapter', function () { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'dspx', - 'params': { - 'placement': '6682', - 'pfilter': { - 'floorprice': 1000000 - }, - 'bcat': 'IAB2,IAB4', - 'dvt': 'desktop' - }, - 'sizes': [ - [300, 250] - ], - '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 = { - 'someIncorrectParam': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [{ - 'bidder': 'dspx', - 'params': { - 'placement': '6682', - 'pfilter': { - 'floorprice': 1000000, - 'private_auction': 0, - 'geo': { - 'country': 'DE' - } - }, - 'bcat': 'IAB2,IAB4', - 'dvt': 'desktop' - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - let bidderRequest = { - refererInfo: { - referer: 'some_referrer.net' - } - } - - const request = spec.buildRequests(bidRequests, bidderRequest); - it('sends bid request to our endpoint via GET', function () { - expect(request[0].method).to.equal('GET'); - 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'); - }); - }); - - describe('interpretResponse', function () { - let serverResponse = { - 'body': { - 'cpm': 5000000, - 'crid': 100500, - 'width': '300', - 'height': '250', - 'tag': '', - 'requestId': '220ed41385952a', - 'currency': 'EUR', - 'ttl': 60, - 'netRevenue': true, - 'zone': '6682' - } - }; - - let expectedResponse = [{ - requestId: '23beaa6af6cdde', - cpm: 0.5, - width: 0, - height: 0, - creativeId: 100500, - dealId: '', - currency: 'EUR', - netRevenue: true, - ttl: 300, - referrer: '', - ad: '' - }]; - - it('should get the correct bid response by display ad', function () { - let bidRequest = [{ - 'method': 'GET', - 'url': ENDPOINT_URL, - 'data': { - 'bid_id': '30b31c1838de1e' - } - }]; - let result = spec.interpretResponse(serverResponse, bidRequest[0]); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles empty bid response', function () { - let response = { - body: {} - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/ebdrBidAdapter_spec.js b/test/spec/modules/ebdrBidAdapter_spec.js index d742e28f2e68..3cac03024c09 100644 --- a/test/spec/modules/ebdrBidAdapter_spec.js +++ b/test/spec/modules/ebdrBidAdapter_spec.js @@ -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/emoteevBidAdapter_spec.js b/test/spec/modules/emoteevBidAdapter_spec.js index b6a62c169636..bb0f28125bee 100644 --- a/test/spec/modules/emoteevBidAdapter_spec.js +++ b/test/spec/modules/emoteevBidAdapter_spec.js @@ -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, diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js deleted file mode 100644 index 525e5808e400..000000000000 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ /dev/null @@ -1,558 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/emx_digitalBidAdapter'; -import * as utils from 'src/utils'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('emx_digital Adapter', function () { - describe('callBids', function () { - const adapter = newBidder(spec); - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - describe('banner request validity', function () { - let bid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let badBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - } - }, - 'adUnitCode': 'adunit-code', - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let noBid = {}; - let otherBid = { - 'bidder': 'emxdigital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let noMediaSizeBid = { - 'bidder': 'emxdigital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': {} - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - expect(spec.isBidRequestValid(badBid)).to.equal(false); - expect(spec.isBidRequestValid(noBid)).to.equal(false); - expect(spec.isBidRequestValid(otherBid)).to.equal(false); - expect(spec.isBidRequestValid(noMediaSizeBid)).to.equal(false); - }); - }); - - describe('video request validity', 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' - }; - let noInstreamBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': { - 'protocols': [1, 7] - } - }, - 'mediaTypes': { - 'video': { - 'context': 'something_random' - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - let outstreamBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'outstream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - expect(spec.isBidRequestValid(noInstreamBid)).to.equal(false); - expect(spec.isBidRequestValid(outstreamBid)).to.equal(true); - }); - - it('should contain tagid param', function () { - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: {}, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '' - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '123' - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(true); - }); - }); - }); - - describe('buildRequests', function () { - let bidderRequest = { - 'bidderCode': 'emx_digital', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'bidderRequestId': '22edbae3120bf6', - 'timeout': 1500, - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'https://example.com/index.html?pbjs_debug=true' - }, - 'bids': [{ - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 250], - [300, 600] - ] - } - }, - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - }] - }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); - - it('sends bid request to ENDPOINT via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('contains the correct options', function () { - expect(request.options.withCredentials).to.equal(true); - }); - - it('contains a properly formatted endpoint url', function () { - const url = request.url.split('?'); - const queryParams = url[1].split('&'); - expect(queryParams[0]).to.match(new RegExp('^t=\d*', 'g')); - expect(queryParams[1]).to.match(new RegExp('^ts=\d*', 'g')); - }); - - it('builds with bid floor', function () { - const bidRequestWithBidFloor = utils.deepClone(bidderRequest.bids); - bidRequestWithBidFloor[0].params.bidfloor = 1; - const requestWithFloor = spec.buildRequests(bidRequestWithBidFloor, bidderRequest); - const data = JSON.parse(requestWithFloor.data); - expect(data.imp[0].bidfloor).to.equal(bidRequestWithBidFloor[0].params.bidfloor); - }); - - it('builds request properly', function () { - const data = JSON.parse(request.data); - expect(Array.isArray(data.imp)).to.equal(true); - expect(data.id).to.equal(bidderRequest.auctionId); - expect(data.imp.length).to.equal(1); - expect(data.imp[0].id).to.equal('30b31c2501de1e'); - expect(data.imp[0].tid).to.equal('d7b773de-ceaa-484d-89ca-d9f51b8d61ec'); - expect(data.imp[0].tagid).to.equal('25251'); - expect(data.imp[0].secure).to.equal(0); - expect(data.imp[0].vastXml).to.equal(undefined); - }); - - 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); - }); - - it('builds correctly formatted request banner object', function () { - let bidRequestWithBanner = utils.deepClone(bidderRequest.bids); - let request = spec.buildRequests(bidRequestWithBanner, bidderRequest); - const data = JSON.parse(request.data); - expect(data.imp[0].video).to.equal(undefined); - expect(data.imp[0].banner).to.exist.and.to.be.a('object'); - expect(data.imp[0].banner.w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); - expect(data.imp[0].banner.h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); - expect(data.imp[0].banner.format[0].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); - expect(data.imp[0].banner.format[0].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); - expect(data.imp[0].banner.format[1].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][0]); - expect(data.imp[0].banner.format[1].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][1]); - }); - - it('builds correctly formatted request video object for instream', function () { - let bidRequestWithVideo = utils.deepClone(bidderRequest.bids); - bidRequestWithVideo[0].mediaTypes = { - video: { - context: 'instream', - 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.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 () { - let bidRequestWithOutstreamVideo = utils.deepClone(bidderRequest.bids); - bidRequestWithOutstreamVideo[0].mediaTypes = { - video: { - context: 'outstream', - 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.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 () { - let request = spec.buildRequests(bidderRequest.bids, bidderRequest) - request = JSON.parse(request.data) - expect(request).to.not.have.property('user'); - }); - - it('should have the right gdpr info when enabled', function () { - let consentString = 'OIJSZsOAFsABAB8EMXZZZZZ+A=='; - bidderRequest.gdprConsent = { - 'consentString': consentString, - 'gdprApplies': true - }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); - - request = JSON.parse(request.data) - expect(request.regs.ext).to.have.property('gdpr', 1); - expect(request.user.ext).to.have.property('consent', consentString); - }); - - it('should\'t contain consent string if gdpr isn\'t applied', function () { - bidderRequest.gdprConsent = { - 'gdprApplies': false - }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); - request = JSON.parse(request.data) - 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': [{ - 'bid': [{ - 'adid': '123456abcde', - 'adm': '', - 'crid': '3434abab34', - 'h': 250, - 'id': '987654321cba', - 'price': 0.5, - 'ttl': 300, - 'w': 300 - }], - 'seat': '1356' - }, { - 'bid': [{ - 'adid': '123456abcdf', - 'adm': '', - 'crid': '3434abab35', - 'h': 600, - 'id': '987654321cba', - 'price': 0.5, - 'ttl': 300, - 'w': 300 - }] - }] - }; - - const expectedResponse = [{ - 'requestId': '12819a18-56e1-4256-b836-b69a10202668', - 'cpm': 0.5, - 'width': 300, - 'height': 250, - 'creativeId': '3434abab34', - 'dealId': null, - 'currency': 'USD', - 'netRevneue': true, - 'mediaType': 'banner', - 'ad': '', - 'ttl': 300 - }, { - 'requestId': '12819a18-56e1-4256-b836-b69a10202668', - 'cpm': 0.7, - 'width': 300, - 'height': 600, - 'creativeId': '3434abab35', - 'dealId': null, - 'currency': 'USD', - 'netRevneue': true, - 'mediaType': 'banner', - 'ad': '', - 'ttl': 300 - }]; - - it('should properly format bid response', function () { - let result = spec.interpretResponse({ - body: serverResponse - }); - expect(Object.keys(result[0]).length).to.equal(Object.keys(expectedResponse[0]).length); - expect(Object.keys(result[0]).requestId).to.equal(Object.keys(expectedResponse[0]).requestId); - expect(Object.keys(result[0]).bidderCode).to.equal(Object.keys(expectedResponse[0]).bidderCode); - expect(Object.keys(result[0]).cpm).to.equal(Object.keys(expectedResponse[0]).cpm); - expect(Object.keys(result[0]).creativeId).to.equal(Object.keys(expectedResponse[0]).creativeId); - expect(Object.keys(result[0]).width).to.equal(Object.keys(expectedResponse[0]).width); - expect(Object.keys(result[0]).height).to.equal(Object.keys(expectedResponse[0]).height); - expect(Object.keys(result[0]).ttl).to.equal(Object.keys(expectedResponse[0]).ttl); - expect(Object.keys(result[0]).adId).to.equal(Object.keys(expectedResponse[0]).adId); - expect(Object.keys(result[0]).currency).to.equal(Object.keys(expectedResponse[0]).currency); - expect(Object.keys(result[0]).netRevenue).to.equal(Object.keys(expectedResponse[0]).netRevenue); - expect(Object.keys(result[0]).ad).to.equal(Object.keys(expectedResponse[0]).ad); - }); - - it('should return multiple bids', function () { - let result = spec.interpretResponse({ - body: serverResponse - }); - expect(Array.isArray(result.seatbid)) - - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.ad).to.equal(serverResponse.seatbid[0].bid[0].adm); - expect(ad0.cpm).to.equal(serverResponse.seatbid[0].bid[0].price); - expect(ad0.creativeId).to.equal(serverResponse.seatbid[0].bid[0].crid); - expect(ad0.currency).to.equal('USD'); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.requestId).to.equal(serverResponse.seatbid[0].bid[0].id); - expect(ad0.ttl).to.equal(300); - - expect(ad1.ad).to.equal(serverResponse.seatbid[1].bid[0].adm); - expect(ad1.cpm).to.equal(serverResponse.seatbid[1].bid[0].price); - expect(ad1.creativeId).to.equal(serverResponse.seatbid[1].bid[0].crid); - expect(ad1.currency).to.equal('USD'); - expect(ad1.netRevenue).to.equal(true); - expect(ad1.requestId).to.equal(serverResponse.seatbid[1].bid[0].id); - expect(ad1.ttl).to.equal(300); - }); - - 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'); - expect(ad0.ad.indexOf(''; - serverResponse.seatbid[1].bid[0].adm = ''; - - let result = spec.interpretResponse({ - body: serverResponse - }, { bidRequest: bid } - ); - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.mediaType).to.equal('video'); - expect(ad0.ad.indexOf(' -1).to.equal(true); - expect(ad0.vastXml).to.equal(serverResponse.seatbid[0].bid[0].adm); - expect(ad0.ad).to.exist.and.to.be.a('string'); - expect(ad1.mediaType).to.equal('video'); - expect(ad1.ad.indexOf(' -1).to.equal(true); - expect(ad1.vastXml).to.equal(serverResponse.seatbid[1].bid[0].adm); - expect(ad1.ad).to.exist.and.to.be.a('string'); - }); - - it('handles nobid responses', function () { - let serverResponse = { - 'bids': [] - }; - - let result = spec.interpretResponse({ - body: serverResponse - }); - 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 () { - let syncOptionsIframe = { iframeEnabled: true }; - let syncOptionsPixel = { pixelEnabled: true }; - it('Should push the correct sync type depending on the config', function () { - let iframeSync = spec.getUserSyncs(syncOptionsIframe); - expect(iframeSync.length).to.equal(1); - expect(iframeSync[0].type).to.equal('iframe'); - }); - }); -}); diff --git a/test/spec/modules/eplanningBidAdapter_spec.js b/test/spec/modules/eplanningBidAdapter_spec.js deleted file mode 100644 index 3152c43c6ffc..000000000000 --- a/test/spec/modules/eplanningBidAdapter_spec.js +++ /dev/null @@ -1,724 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/eplanningBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -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 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 BID_ID = '123456789'; - const BID_ID2 = '987654321'; - const BID_ID3 = '998877665'; - const CPM = 1.3; - const W = '300'; - const H = '250'; - const ADM = '
This is an ad
'; - const I_ID = '7854abc56248f873'; - const CRID = '1234567890'; - const TEST_ISV = 'leles.e-planning.net'; - const validBid = { - 'bidder': 'eplanning', - 'bidId': BID_ID, - 'params': { - 'ci': CI, - }, - 'adUnitCode': ADUNIT_CODE, - 'sizes': [[300, 250], [300, 600]], - }; - const validBid2 = { - 'bidder': 'eplanning', - 'bidId': BID_ID2, - 'params': { - 'ci': CI, - }, - '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': { - 't': 1, - 'isv': TEST_ISV - }, - 'adUnitCode': ADUNIT_CODE, - 'sizes': [[300, 250], [300, 600]], - }; - const invalidBid = { - 'bidder': 'eplanning', - 'params': { - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - }; - const response = { - body: { - 'sI': { - 'k': '12345' - }, - 'sec': { - 'k': 'ROS' - }, - 'sp': [{ - 'k': CLEAN_ADUNIT_CODE, - 'a': [{ - 'adm': ADM, - 'id': '7854abc56248f874', - 'i': I_ID, - 'fi': '7854abc56248f872', - 'ip': '45621afd87462104', - 'w': W, - 'h': H, - 'crid': CRID, - 'pr': CPM - }], - }], - 'cs': [ - 'http://a-sync-url.com/', - { - 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', - 'ifr': true - } - ] - } - }; - const responseWithTwoAdunits = { - body: { - 'sI': { - 'k': '12345' - }, - 'sec': { - 'k': 'ROS' - }, - 'sp': [{ - 'k': CLEAN_ADUNIT_CODE, - 'a': [{ - 'adm': ADM, - 'id': '7854abc56248f874', - 'i': I_ID, - 'fi': '7854abc56248f872', - 'ip': '45621afd87462104', - 'w': W, - 'h': H, - 'crid': CRID, - 'pr': CPM - }] - }, { - 'k': CLEAN_ADUNIT_CODE2, - 'a': [{ - 'adm': ADM, - 'id': '7854abc56248f874', - 'i': I_ID, - 'fi': '7854abc56248f872', - 'ip': '45621afd87462104', - 'w': W, - 'h': H, - 'crid': CRID, - 'pr': CPM - }], - }, - ], - 'cs': [ - 'http://a-sync-url.com/', - { - 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', - 'ifr': true - } - ] - } - }; - const responseWithNoAd = { - body: { - 'sI': { - 'k': '12345' - }, - 'sec': { - 'k': 'ROS' - }, - 'sp': [{ - 'k': 'spname', - }], - 'cs': [ - 'http://a-sync-url.com/', - { - 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', - 'ifr': true - } - ] - } - }; - const responseWithNoSpace = { - body: { - 'sI': { - 'k': '12345' - }, - 'sec': { - 'k': 'ROS' - }, - 'cs': [ - 'http://a-sync-url.com/', - { - 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', - 'ifr': true - } - ] - } - }; - - 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 bid has ci parameter', function () { - expect(spec.isBidRequestValid(validBid)).to.equal(true); - }); - - it('should return false when bid does not have ci parameter and is not a test bid', function () { - expect(spec.isBidRequestValid(invalidBid)).to.equal(false); - }); - - it('should return true when bid does not have ci parameter but is a test bid', function () { - expect(spec.isBidRequestValid(testBid)).to.equal(true); - }); - }); - - 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'); - }); - - it('should return GET method', function () { - const method = spec.buildRequests(bidRequests).method; - expect(method).to.equal('GET'); - }); - - it('should return r parameter with value pbjs', function () { - const r = spec.buildRequests(bidRequests).data.r; - expect(r).to.equal('pbjs'); - }); - - it('should return pbv parameter with value prebid version', function () { - const pbv = spec.buildRequests(bidRequests).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('300x250_0:300x250,300x600'); - }); - - it('should return correct e parameter with more than one adunit', function () { - const NEW_CODE = ADUNIT_CODE + '2'; - const CLEAN_NEW_CODE = CLEAN_ADUNIT_CODE + '2'; - const anotherBid = { - 'bidder': 'eplanning', - 'params': { - 'ci': CI, - }, - 'adUnitCode': NEW_CODE, - 'sizes': [[100, 100]], - }; - bidRequests.push(anotherBid); - - const e = spec.buildRequests(bidRequests).data.e; - expect(e).to.equal('300x250_0:300x250,300x600+100x100_0:100x100'); - }); - - it('should return correct e parameter when the adunit has no size', function () { - const noSizeBid = { - 'bidder': 'eplanning', - 'params': { - 'ci': CI, - }, - 'adUnitCode': ADUNIT_CODE, - }; - - const e = spec.buildRequests([noSizeBid]).data.e; - expect(e).to.equal('1x1_0:1x1'); - }); - - it('should return ur parameter with current window url', function () { - const ur = spec.buildRequests(bidRequests).data.ur; - expect(ur).to.equal(utils.getTopWindowUrl()); - }); - - 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() - }); - - it('should return crs parameter with document charset', function () { - let expected; - try { - expected = window.top.document.characterSet; - } catch (e) { - expected = document.characterSet; - } - - const chset = spec.buildRequests(bidRequests).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'; - expect(url).to.equal(expectedUrl); - }); - - it('should return the parameter ncb with value 1', function () { - const ncb = spec.buildRequests(bidRequests).data.ncb; - expect(ncb).to.equal('1'); - }); - }); - - describe('interpretResponse', function () { - it('should return an empty array when there is no ads in the response', function () { - const bidResponses = spec.interpretResponse(responseWithNoAd); - expect(bidResponses).to.be.empty; - }); - - it('should return an empty array when there is no spaces in the response', function () { - const bidResponses = spec.interpretResponse(responseWithNoSpace); - expect(bidResponses).to.be.empty; - }); - - it('should correctly map the parameters in the response', function () { - const bidResponse = spec.interpretResponse(response, { adUnitToBidId: { [CLEAN_ADUNIT_CODE]: BID_ID } })[0]; - const expectedResponse = { - requestId: BID_ID, - cpm: CPM, - width: W, - height: H, - ad: ADM, - ttl: 120, - creativeId: CRID, - netRevenue: true, - currency: 'USD', - }; - expect(bidResponse).to.deep.equal(expectedResponse); - }); - }); - - describe('getUserSyncs', function () { - const sOptionsAllEnabled = { - pixelEnabled: true, - iframeEnabled: true - }; - const sOptionsAllDisabled = { - pixelEnabled: false, - iframeEnabled: false - }; - const sOptionsOnlyPixel = { - pixelEnabled: true, - iframeEnabled: false - }; - const sOptionsOnlyIframe = { - pixelEnabled: false, - iframeEnabled: true - }; - - it('should return an empty array if the response has no syncs', function () { - const noSyncsResponse = { cs: [] }; - const syncs = spec.getUserSyncs(sOptionsAllEnabled, [noSyncsResponse]); - expect(syncs).to.be.empty; - }); - - it('should return an empty array if there is no sync options enabled', function () { - const syncs = spec.getUserSyncs(sOptionsAllDisabled, [response]); - expect(syncs).to.be.empty; - }); - - it('should only return pixels if iframe is not enabled', function () { - const syncs = spec.getUserSyncs(sOptionsOnlyPixel, [response]); - syncs.forEach(sync => expect(sync.type).to.equal('image')); - }); - - it('should only return iframes if pixel is not enabled', function () { - const syncs = spec.getUserSyncs(sOptionsOnlyIframe, [response]); - syncs.forEach(sync => expect(sync.type).to.equal('iframe')); - }); - }); - - describe('adUnits mapping to bidId', function () { - it('should correctly map the bidId to the adunit', function () { - const requests = spec.buildRequests([validBid, validBid2]); - 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(utils, 'getDataFromLocalStorage'); - setDataInLocalStorageSpy = sandbox.spy(utils, 'setDataInLocalStorage'); - - hasLocalStorageStub = sandbox.stub(utils, '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); - - expect(response.url).to.equal('//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); - expect(response.url).to.equal('//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(utils.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); - clock.tick(1005); - - expect(respuesta.data.vs).to.equal('F'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); - }); - it('when you have more than four render', function() { - utils.setDataInLocalStorage(storageIdRender, 4); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - - expect(respuesta.data.vs).to.equal('0'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); - }); - it('when you have more than four render and already record visibility', function() { - utils.setDataInLocalStorage(storageIdRender, 4); - utils.setDataInLocalStorage(storageIdView, 4); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - - expect(respuesta.data.vs).to.equal('a'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.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); - clock.tick(1005); - expect(respuesta.data.vs).to.equal('F'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - it('when you have more than four render', function() { - utils.setDataInLocalStorage(storageIdRender, 4); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - expect(respuesta.data.vs).to.equal('0'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.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); - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); - }); - it('you should not register visibility with less than 50%', function() { - createPartiallyInvisibleElement(); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.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) - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.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) - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - it('if both are zero', function() { - element.style.height = '0px'; - element.style.width = '0px'; - spec.buildRequests(bidRequests) - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.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); - clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - }); - context('segmentBeginsBeforeTheVisibleRange', function() { - it('segmentBeginsBeforeTheVisibleRange', function() { - createElementOutOfRange(); - spec.buildRequests(bidRequests); - clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.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 => { - utils.setDataInLocalStorage('pbsr_' + ac, 5); - utils.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); - clock.tick(1005); - [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { - expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); - expect(utils.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); - clock.tick(1005); - [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { - expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); - expect(utils.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); - clock.tick(1005); - expect(utils.getDataFromLocalStorage('pbsr_' + ADUNIT_CODE_VIEW)).to.equal('6'); - expect(utils.getDataFromLocalStorage('pbvi_' + ADUNIT_CODE_VIEW)).to.equal('6'); - [ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { - expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); - expect(utils.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 e4cccbf5cf33..ed512e55ea94 100644 --- a/test/spec/modules/etargetBidAdapter_spec.js +++ b/test/spec/modules/etargetBidAdapter_spec.js @@ -29,7 +29,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 945c0dd0d013..000000000000 --- 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 ecd5db3c0511..000000000000 --- 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/fidelityBidAdapter_spec.js b/test/spec/modules/fidelityBidAdapter_spec.js deleted file mode 100644 index e8e008103e6d..000000000000 --- a/test/spec/modules/fidelityBidAdapter_spec.js +++ /dev/null @@ -1,180 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/fidelityBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('FidelityAdapter', 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': 'fidelity', - 'params': { - 'zoneid': '37', - 'floor': '0.05', - 'server': 't.fidelity-media.com', - }, - '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 true when required params found', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'zoneid': '37', - }; - 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 bidderRequest = { - bidderCode: 'fidelity', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - bidderRequestId: '178e34bad3658f', - bids: [ - { - bidder: 'fidelity', - params: { - zoneid: '37', - floor: '0.05', - server: 't.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' - } - ], - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000 - }; - - it('should add source and verison to the tag', function () { - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - const payload = request.data; - expect(payload.from).to.exist; - expect(payload.v).to.exist; - expect(payload.requestid).to.exist; - expect(payload.impid).to.exist; - expect(payload.zoneid).to.exist; - expect(payload.floor).to.exist; - expect(payload.charset).to.exist; - expect(payload.subid).to.exist; - expect(payload.flashver).to.exist; - expect(payload.tmax).to.exist; - expect(payload.defloc).to.exist; - }); - - it('should add gdpr consent information to the request', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - bidderRequest.gdprConsent = { - gdprApplies: true, - consentString: consentString, - vendorData: { - vendorConsents: { - '408': 1 - }, - }, - }; - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - const payload = request.data; - expect(payload.gdpr).to.exist.and.to.be.a('number'); - expect(payload.gdpr).to.equal(1); - expect(payload.consent_str).to.exist.and.to.be.a('string'); - 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); - }); - - 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.method).to.equal('GET'); - }); - }) - - describe('interpretResponse', function () { - let response = { - 'id': '543210', - 'seatbid': [ { - 'bid': [ { - 'id': '1111111', - 'impid': 'bidId-123456-1', - 'price': 0.09, - 'adm': '', - 'width': 728, - 'height': 90, - } ] - } ] - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - requestId: 'bidId-123456-1', - creativeId: 'bidId-123456-1', - cpm: 0.09, - width: 728, - height: 90, - ad: '', - netRevenue: true, - currency: 'USD', - ttl: 360, - } - ]; - - let result = spec.interpretResponse({ body: response }); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - let response = { - 'id': '543210', - 'seatbid': [ ] - }; - - let result = spec.interpretResponse({ body: response }); - expect(result.length).to.equal(0); - }); - }); - - describe('user sync', function () { - const syncUrl = '//x.fidelity-media.com/delivery/matches.php?type=iframe'; - - it('should register the sync iframe', function () { - expect(spec.getUserSyncs({})).to.be.undefined; - expect(spec.getUserSyncs({iframeEnabled: false})).to.be.undefined; - const options = spec.getUserSyncs({iframeEnabled: true}); - 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(syncUrl); - }); - }); -}); diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js deleted file mode 100644 index 45754d0250c5..000000000000 --- a/test/spec/modules/freewheel-sspBidAdapter_spec.js +++ /dev/null @@ -1,239 +0,0 @@ -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); - }); - }); -}); diff --git a/test/spec/modules/fyberBidAdapter_spec.js b/test/spec/modules/fyberBidAdapter_spec.js deleted file mode 100644 index a16c069d2a0b..000000000000 --- 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 deleted file mode 100644 index 99593e6e06fb..000000000000 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ /dev/null @@ -1,105 +0,0 @@ -import * as utils from 'src/utils'; -import { expect } from 'chai'; -import { spec } from 'modules/gammaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('gammaBidAdapter', function() { - const adapter = newBidder(spec); - - let bid = { - 'bidder': 'gamma', - 'params': { - siteId: '1465446377', - zoneId: '1515999290' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - let bidArray = [bid]; - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - 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); - }); - - it('should return false when params not passed correctly', function () { - 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 () { - const requests = spec.buildRequests(bidArray); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - expect(requestItem.url).to.match(new RegExp(`hb.gammaplatform.com`)); - }); - }); - }); - - describe('interpretResponse', function () { - let serverResponse; - - beforeEach(function () { - serverResponse = { - body: { - 'id': '23beaa6af6cdde', - 'bid': '5611802021800040585', - 'type': 'banner', - 'cur': 'USD', - 'seatbid': [{ - 'seat': '5611802021800040585', - 'bid': [{ - 'id': '1515999070', - 'impid': '1', - 'price': 0.45, - 'adm': '', - 'adid': '1515999070', - 'dealid': 'gax-paj2qarjf2g', - 'h': 250, - 'w': 300 - }] - }] - } - }; - }) - - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 0.45, - 'width': 300, - 'height': 250, - 'creativeId': '1515999070', - 'dealId': 'gax-paj2qarjf2g', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'ad': '' - }]; - let result = spec.interpretResponse(serverResponse); - expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); - }); - - it('handles empty bid response', function () { - let response = { - body: {} - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/gamoshiBidAdapter_spec.js b/test/spec/modules/gamoshiBidAdapter_spec.js deleted file mode 100644 index 2d63d47a73e2..000000000000 --- a/test/spec/modules/gamoshiBidAdapter_spec.js +++ /dev/null @@ -1,543 +0,0 @@ -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'; - -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 () { - expect(helper.getTopFrame()).to.equal(0); - }); - it('verify domain parsing', function () { - 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 () { - expect(helper.startsWith('gamoshi.com', 'gamo')).to.equal(true); - }); - }); - - 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 validate supply-partner ID', function () { - 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 () { - 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({ - params: { - supplyPartnerId: '123', - rtbEndpoint: 'https://some.url.com' - } - })).to.equal(true); - }); - - it('should validate bid floor', function () { - 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 () { - 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 () { - 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); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 0}})).to.equal(true); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 1}})).to.equal(true); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 2}})).to.equal(false); - }); - }); - - 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 () { - let response; - response = spec.buildRequests([]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - response = spec.buildRequests([bidRequest], 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], bidRequest); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(2); - }); - - it('targets correct endpoint', function () { - let response; - response = spec.buildRequests([bidRequest], bidRequest)[0]; - expect(response.method).to.equal('POST'); - expect(response.url).to.match(new RegExp(`^https://rtb\\.gamoshi\\.io/r/${supplyPartnerId}/bidr\\?rformat=open_rtb&reqformat=rtb_json&bidder=prebid$`, 'g')); - expect(response.data.id).to.equal(bidRequest.auctionId); - const bidRequestWithEndpoint = utils.deepClone(bidRequest); - bidRequestWithEndpoint.params.rtbEndpoint = 'https://rtb2.gamoshi.io/a12'; - response = spec.buildRequests([bidRequestWithEndpoint], bidRequest)[0]; - 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); - 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'); - 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], bidRequest2)[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], bidRequest2)[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], bidRequest2)[0]; - expect(response.data.imp[0].bidfloor).to.equal(bidRequestWithBidfloorEquals1.params.bidfloor); - stub.restore(); - }); - - it('builds request banner object correctly', function () { - let response; - const bidRequestWithBanner = utils.deepClone(bidRequest); - bidRequestWithBanner.mediaTypes = { - banner: { - sizes: [[300, 250], [120, 600]] - } - }; - response = spec.buildRequests([bidRequestWithBanner], bidRequest)[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], bidRequest)[0]; - expect(response.data.imp[0].banner.pos).to.equal(bidRequestWithPosEquals1.params.pos); - }); - - it('builds request video object correctly', function () { - let response; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - 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); - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - 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; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - context: 'instream' - } - }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal('instream'); - bidRequestWithVideo.mediaTypes.video.context = 'outstream'; - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.mediaTypes.video.context = 'outstream'; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal('outstream'); - - const bidRequestWithPosEquals2 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals2.mediaTypes.video.context = null; - response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal(null); - }); - - it('builds request video object correctly with multi-dimensions size array', function () { - let response; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [[304, 254], [305, 255]], - context: 'instream' - }; - - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[1].video.ext.context).to.equal('instream'); - bidRequestWithVideo.mediaTypes.video.context = 'outstream'; - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.mediaTypes.video.context = 'outstream'; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[1].video.ext.context).to.equal('outstream'); - - const bidRequestWithPosEquals2 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals2.mediaTypes.video.context = null; - response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; - expect(response.data.imp[1].video.ext.context).to.equal(null); - }); - - it('builds request with gdpr consent', function () { - let response = spec.buildRequests([bidRequest], bidRequest)[0]; - expect(response.data.ext.gdpr_consent).to.exist; - 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); - - expect(response.data.regs.ext.gdpr).to.exist; - expect(response.data.user.ext.consent).to.equal('some string'); - }); - - it('build request with ID5 Id', function () { - 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('build request with unified Id', function () { - 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' - } - }] - }]); - }); - }); - - describe('interpretResponse', () => { - 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'} - ] - } - } - ] - } - ] - }; - - const TTL = 360; - - it('returns an empty array on missing response', function () { - 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('aggregates banner bids from all seat bids', function () { - 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(TTL); - 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('aggregates video bids from all seat bids', function () { - 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(TTL); - 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('aggregates user-sync pixels', function () { - 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 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); - 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); - 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/getintentBidAdapter_spec.js b/test/spec/modules/getintentBidAdapter_spec.js index ebbda7e108e6..e743d85972cd 100644 --- a/test/spec/modules/getintentBidAdapter_spec.js +++ b/test/spec/modules/getintentBidAdapter_spec.js @@ -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 bab2415745d4..000000000000 --- 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 a18ea1b99c3f..000000000000 --- 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/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index d972ec25c8a0..e1411da6e5a9 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -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 = [ { diff --git a/test/spec/modules/gxoneBidAdapter_spec.js b/test/spec/modules/gxoneBidAdapter_spec.js deleted file mode 100644 index afeb2c781f59..000000000000 --- 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 37ec44f07c4a..8e400f20defe 100644 --- a/test/spec/modules/hpmdnetworkBidAdapter_spec.js +++ b/test/spec/modules/hpmdnetworkBidAdapter_spec.js @@ -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/huddledmassesBidAdapter_spec.js b/test/spec/modules/huddledmassesBidAdapter_spec.js deleted file mode 100644 index 7823ae53c129..000000000000 --- a/test/spec/modules/huddledmassesBidAdapter_spec.js +++ /dev/null @@ -1,119 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/huddledmassesBidAdapter'; - -describe('HuddledmassesAdapter', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'huddledmasses', - bidderRequestId: '145e1d6a7837c9', - params: { - placement_id: 0 - }, - placementCode: 'placementid_0', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' - }; - - 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 () { - 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]); - 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('//huddledmassessupply.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 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.placementId).to.be.a('number'); - expect(placement.bidId).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', - 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'); - 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'); - } - 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('//huddledmassessupply.com/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/iasBidAdapter_spec.js b/test/spec/modules/iasBidAdapter_spec.js index 8197ee258567..7ac9d1906f52 100644 --- a/test/spec/modules/iasBidAdapter_spec.js +++ b/test/spec/modules/iasBidAdapter_spec.js @@ -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 206e227a3b17..91b907186c2c 100644 --- a/test/spec/modules/imonomyBidAdapter_spec.js +++ b/test/spec/modules/imonomyBidAdapter_spec.js @@ -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 8ac8c8e85dfd..15b7e2ff3e88 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -316,17 +316,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': '' @@ -344,16 +344,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': '' @@ -370,12 +370,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, @@ -470,7 +470,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 } @@ -479,23 +479,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' } } @@ -536,19 +536,19 @@ describe('Improve Digital Adapter Tests', function () { { 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, @@ -565,7 +565,7 @@ describe('Improve Digital Adapter Tests', function () { let expectedTwoBids = [ expectedBid[0], { - 'ad': '', + 'ad': '', 'adId': '1234', 'creativeId': '422033', 'cpm': 1.23, @@ -606,23 +606,23 @@ 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' } } @@ -751,10 +751,10 @@ 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); @@ -778,9 +778,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 deleted file mode 100644 index 0132f093ca1e..000000000000 --- a/test/spec/modules/innityBidAdapter_spec.js +++ /dev/null @@ -1,100 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/innityBidAdapter'; - -describe('innityAdapterTest', function () { - describe('bidRequestValidity', function () { - it('bidRequest with pub ID and zone ID param', function () { - expect(spec.isBidRequestValid({ - bidder: 'innity', - params: { - 'pub': 267, - 'zone': 62546 - }, - })).to.equal(true); - }); - - it('bidRequest with no required params', function () { - expect(spec.isBidRequestValid({ - bidder: 'innity', - params: { - }, - })).to.equal(false); - }); - }); - - describe('bidRequest', function () { - const bidRequests = [{ - 'bidder': 'innity', - 'params': { - 'pub': 267, - 'zone': 62546 - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [300, 250], - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - it('bidRequest HTTP method', function () { - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - }); - }); - - it('bidRequest data', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].data.pub).to.equal(267); - expect(requests[0].data.zone).to.equal(62546); - expect(requests[0].data.width).to.equal('300'); - expect(requests[0].data.height).to.equal('250'); - expect(requests[0].data.callback_uid).to.equal('51ef8751f9aead'); - }); - }); - - describe('interpretResponse', function () { - const bidRequest = { - 'method': 'GET', - 'url': 'https://as.innity.com/synd/?', - 'data': { - 'ver': 2, - 'hb': 1, - 'output': 'js', - 'pub': 267, - 'zone': 62546, - 'width': '300', - 'height': '250', - 'callback': 'json', - 'callback_uid': '51ef8751f9aead', - 'url': 'https://example.com', - 'cb': '', - } - }; - - const bidResponse = { - body: { - 'cpm': 100, - 'width': '300', - 'height': '250', - 'creative_id': '148186', - 'callback_uid': '51ef8751f9aead', - 'tag': '', - }, - headers: {} - }; - - it('result is correct', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - expect(result[0].requestId).to.equal('51ef8751f9aead'); - expect(result[0].cpm).to.equal(1); - expect(result[0].width).to.equal('300'); - expect(result[0].height).to.equal('250'); - 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(''); - }); - }); -}); diff --git a/test/spec/modules/inskinBidAdapter_spec.js b/test/spec/modules/inskinBidAdapter_spec.js deleted file mode 100644 index 896fe36d443c..000000000000 --- a/test/spec/modules/inskinBidAdapter_spec.js +++ /dev/null @@ -1,288 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/inskinBidAdapter'; -import { createBid } from 'src/bidfactory'; - -const ENDPOINT = 'https://mfad.inskinad.com/api/v2'; - -const REQUEST = { - 'bidderCode': 'inskin', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d', - 'bidderRequestId': '109f2a181342a9', - 'bidRequest': [{ - 'bidder': 'inskin', - 'params': { - 'networkId': 9874, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '2b0f82502298c9', - 'bidderRequestId': '109f2a181342a9', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }, - { - 'bidder': 'inskin', - 'params': { - 'networkId': 9874, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '123', - 'bidderRequestId': '109f2a181342a9', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }], - 'start': 1487883186070, - 'auctionStart': 1487883186069, - 'timeout': 3000 -}; - -const RESPONSE = { - 'headers': null, - 'body': { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '2b0f82502298c9': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://mfad.inskinad.com/r', - 'impressionUrl': 'https://mfad.inskinad.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - }, - '123': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://mfad.inskinad.com/r', - 'impressionUrl': 'https://mfad.inskinad.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'customData': { - 'pubCPM': 1 - }, - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - } - } - } -}; - -describe('InSkin BidAdapter', function () { - let bidRequests; - let adapter = spec; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx' - }, - placementCode: 'header-bid-tag-1', - sizes: [[300, 250], [300, 600]], - bidId: '23acc48ad47af5', - requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - - describe('bid request validation', function () { - it('should accept valid bid requests', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should accept valid bid requests with extra fields', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx', - zoneId: 'xxxxx' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should reject bid requests without siteId', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should reject bid requests without networkId', function () { - let bid = { - bidder: 'inskin', - params: { - siteId: '9874' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests validation', function () { - it('creates request data', function () { - let request = spec.buildRequests(bidRequests); - - expect(request).to.exist.and.to.be.a('object'); - }); - - it('request to inskin should contain a url', function () { - let request = spec.buildRequests(bidRequests); - - expect(request.url).to.have.string('inskinad.com'); - }); - - it('requires valid bids to make request', function () { - let request = spec.buildRequests([]); - expect(request.bidRequest).to.be.empty; - }); - - it('sends bid request to ENDPOINT via POST', function () { - let request = spec.buildRequests(bidRequests); - - 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); - const payload = JSON.parse(request.data); - - expect(payload.consent.gdprConsentString).to.exist; - expect(payload.consent.gdprConsentRequired).to.exist; - expect(payload.consent.gdprConsentString).to.exist.and.to.equal(consentString); - expect(payload.consent.gdprConsentRequired).to.exist.and.to.be.true; - }); - }); - describe('interpretResponse validation', function () { - it('response should have valid bidderCode', function () { - let bidRequest = spec.buildRequests(REQUEST.bidRequest); - let bid = createBid(1, bidRequest.bidRequest[0]); - - expect(bid.bidderCode).to.equal('inskin'); - }); - - it('response should include objects for all bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - - expect(bids.length).to.equal(2); - }); - - it('registers bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - bids.forEach(b => { - expect(b).to.have.property('cpm'); - expect(b.cpm).to.be.above(0); - expect(b).to.have.property('requestId'); - expect(b).to.have.property('cpm'); - expect(b).to.have.property('width'); - expect(b).to.have.property('height'); - expect(b).to.have.property('ad'); - expect(b).to.have.property('currency', 'USD'); - 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'); - }); - }); - - it('cpm is correctly set', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - - expect(bids[0].cpm).to.equal(0.5); - expect(bids[1].cpm).to.equal(1); - }); - - it('handles nobid responses', function () { - let EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {'decisions': null}}) - let bids = spec.interpretResponse(EMPTY_RESP, REQUEST); - - expect(bids).to.be.empty; - }); - - it('handles no server response', function () { - let bids = spec.interpretResponse(null, REQUEST); - - expect(bids).to.be.empty; - }); - }); - describe('getUserSyncs', function () { - it('handles empty sync options', function () { - let opts = spec.getUserSyncs({}); - - expect(opts).to.be.empty; - }); - - it('should return two sync urls if pixel syncs are enabled', function () { - let syncOptions = {'pixelEnabled': true}; - let opts = spec.getUserSyncs(syncOptions); - - expect(opts.length).to.equal(2); - }); - - it('should return three sync urls if pixel and iframe syncs are enabled', function () { - let syncOptions = {'iframeEnabled': true, 'pixelEnabled': true}; - let opts = spec.getUserSyncs(syncOptions); - - expect(opts.length).to.equal(3); - }); - }); -}); diff --git a/test/spec/modules/interactiveOffersBidAdapter_spec.js b/test/spec/modules/interactiveOffersBidAdapter_spec.js deleted file mode 100644 index 8921a3027387..000000000000 --- 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 57ca35e2b28c..3ca31c0abb41 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -4,8 +4,8 @@ import { spec, resetInvibes, stubDomainOptions } from 'modules/invibesBidAdapter 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 = [ { diff --git a/test/spec/modules/iqmBidAdapter_spec.js b/test/spec/modules/iqmBidAdapter_spec.js deleted file mode 100644 index 5535c52af9b2..000000000000 --- 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 245cf01610c1..f3fafed7b9ac 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -82,7 +82,7 @@ describe('IndexexchangeAdapter', function () { advbrandid: 303325, advbrand: 'OECTA' }, - adm: '
' + adm: '' } ], seat: '3970' @@ -126,8 +126,8 @@ describe('IndexexchangeAdapter', function () { vendorData: {} }, refererInfo: { - referer: 'http://www.prebid.org', - canonicalUrl: 'http://www.prebid.org/the/link/to/the/page' + referer: 'https://www.prebid.org', + canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' } }; @@ -160,8 +160,8 @@ describe('IndexexchangeAdapter', function () { } ], site: { - ref: 'http://ref.com/ref.html', - page: 'http://page.com' + ref: 'https://ref.com/ref.html', + page: 'https://page.com' }, }), s: '21', @@ -775,7 +775,7 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', ttl: 35, netRevenue: true, @@ -802,7 +802,7 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', ttl: 35, netRevenue: true, @@ -828,7 +828,7 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'JPY', ttl: 35, netRevenue: true, @@ -855,7 +855,7 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', ttl: 35, netRevenue: true, diff --git a/test/spec/modules/jcmBidAdapter_spec.js b/test/spec/modules/jcmBidAdapter_spec.js index 0b467e1ecfb1..fa6791674bcf 100644 --- a/test/spec/modules/jcmBidAdapter_spec.js +++ b/test/spec/modules/jcmBidAdapter_spec.js @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { spec } from 'modules/jcmBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; -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/komoonaBidAdapter_spec.js b/test/spec/modules/komoonaBidAdapter_spec.js index b6d17c7b20c1..ed84155b28d5 100644 --- a/test/spec/modules/komoonaBidAdapter_spec.js +++ b/test/spec/modules/komoonaBidAdapter_spec.js @@ -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/kummaBidAdapter_spec.js b/test/spec/modules/kummaBidAdapter_spec.js deleted file mode 100644 index 7d33bd085b5f..000000000000 --- a/test/spec/modules/kummaBidAdapter_spec.js +++ /dev/null @@ -1,335 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/kummaBidAdapter'; -import {getTopWindowLocation} from 'src/utils'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('Kumma Adapter Tests', function () { - const slotConfigs = [{ - placementCode: '/DfpAccount1/slot1', - sizes: [[300, 250]], - bidId: 'bid12345', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '123', - bidFloor: '0.001', - ifa: 'IFA', - latitude: '40.712775', - longitude: '-74.005973' - } - }, { - placementCode: '/DfpAccount2/slot2', - sizes: [[728, 90]], - bidId: 'bid23456', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '1234', - bidFloor: '0.000001', - } - }]; - const nativeSlotConfig = [{ - placementCode: '/DfpAccount1/slot3', - bidId: 'bid12345', - mediaType: 'native', - nativeParams: { - title: { required: true, len: 200 }, - body: {}, - image: { wmin: 100 }, - sponsoredBy: { }, - icon: { } - }, - params: { - pubId: '29521', - placementId: '123', - siteId: '26047' - } - }]; - const videoSlotConfig = [{ - placementCode: '/DfpAccount1/slot4', - sizes: [[640, 480]], - bidId: 'bid12345678', - mediaType: 'video', - video: { - skippable: true - }, - params: { - pubId: '29521', - placementId: '1234567', - siteId: '26047', - } - }]; - const appSlotConfig = [{ - placementCode: '/DfpAccount1/slot5', - bidId: 'bid12345', - params: { - pubId: '29521', - placementId: '1234', - app: { - id: '1111', - name: 'app name', - bundle: 'com.kumma.apps', - storeUrl: 'http://kumma.com/apps', - domain: 'kumma.com' - } - } - }]; - - it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // site object - expect(ortbRequest.site).to.not.equal(null); - 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.imp).to.have.lengthOf(2); - // device object - expect(ortbRequest.device).to.not.equal(null); - expect(ortbRequest.device.ua).to.equal(navigator.userAgent); - expect(ortbRequest.device.ifa).to.equal('IFA'); - expect(ortbRequest.device.geo.lat).to.equal('40.712775'); - expect(ortbRequest.device.geo.lon).to.equal('-74.005973'); - // slot 1 - expect(ortbRequest.imp[0].tagid).to.equal('123'); - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - expect(ortbRequest.imp[0].bidfloor).to.equal('0.001'); - // slot 2 - expect(ortbRequest.imp[1].tagid).to.equal('1234'); - expect(ortbRequest.imp[1].banner).to.not.equal(null); - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); - expect(ortbRequest.imp[1].bidfloor).to.equal('0.000001'); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - expect(bids).to.have.lengthOf(1); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.ad).to.equal('This is an Ad'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.adId).to.equal('bid12345'); - expect(bid.creativeId).to.equal('bid12345'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verify full passback', function () { - const request = spec.buildRequests(slotConfigs); - const bids = spec.interpretResponse({ body: null }, request) - expect(bids).to.have.lengthOf(0); - }); - - it('Verify Native request', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // native impression - expect(ortbRequest.imp[0].tagid).to.equal('123'); - const nativePart = ortbRequest.imp[0]['native']; - expect(nativePart).to.not.equal(null); - expect(nativePart.ver).to.equal('1.1'); - expect(nativePart.request).to.not.equal(null); - // native request assets - const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request); - expect(nativeRequest).to.not.equal(null); - expect(nativeRequest.assets).to.have.lengthOf(5); - expect(nativeRequest.assets[0].id).to.equal(1); - expect(nativeRequest.assets[1].id).to.equal(2); - expect(nativeRequest.assets[2].id).to.equal(3); - expect(nativeRequest.assets[3].id).to.equal(4); - expect(nativeRequest.assets[4].id).to.equal(5); - expect(nativeRequest.assets[0].required).to.equal(1); - expect(nativeRequest.assets[0].title).to.not.equal(null); - expect(nativeRequest.assets[0].title.len).to.equal(200); - expect(nativeRequest.assets[1].title).to.be.undefined; - expect(nativeRequest.assets[1].data).to.not.equal(null); - expect(nativeRequest.assets[1].data.type).to.equal(2); - expect(nativeRequest.assets[1].data.len).to.equal(200); - expect(nativeRequest.assets[2].required).to.equal(0); - expect(nativeRequest.assets[3].img).to.not.equal(null); - expect(nativeRequest.assets[3].img.wmin).to.equal(50); - expect(nativeRequest.assets[3].img.hmin).to.equal(50); - expect(nativeRequest.assets[3].img.type).to.equal(1); - expect(nativeRequest.assets[4].img).to.not.equal(null); - expect(nativeRequest.assets[4].img.wmin).to.equal(100); - expect(nativeRequest.assets[4].img.hmin).to.equal(150); - expect(nativeRequest.assets[4].img.type).to.equal(3); - }); - - it('Verify Native response', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - const nativeResponse = { - 'native': { - assets: [ - { id: 1, title: { text: 'Ad Title' } }, - { id: 2, data: { value: 'Test description' } }, - { id: 3, data: { value: 'Brand' } }, - { 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/' } - } - }; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - nurl: 'http://rtb.adx1.com/log', - adm: JSON.stringify(nativeResponse) - }] - }], - cur: 'USD', - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - // verify bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.adId).to.equal('bid12345'); - expect(bid.ad).to.be.undefined; - expect(bid.mediaType).to.equal('native'); - const nativeBid = bid['native']; - expect(nativeBid).to.not.equal(null); - expect(nativeBid.title).to.equal('Ad Title'); - expect(nativeBid.sponsoredBy).to.equal('Brand'); - expect(nativeBid.icon.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_icon.png'); - expect(nativeBid.image.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_image.png'); - expect(nativeBid.image.width).to.equal(300); - 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.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('http://rtb.adx1.com/log'); - }); - - it('Verify Video request', function () { - const request = spec.buildRequests(videoSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); - 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); - // device object - expect(videoRequest.device).to.not.equal(null); - expect(videoRequest.device.ua).to.equal(navigator.userAgent); - // slot 1 - expect(videoRequest.imp[0].tagid).to.equal('1234567'); - expect(videoRequest.imp[0].video).to.not.equal(null); - expect(videoRequest.imp[0].video.w).to.equal(640); - expect(videoRequest.imp[0].video.h).to.equal(480); - expect(videoRequest.imp[0].banner).to.equal(null); - expect(videoRequest.imp[0].native).to.equal(null); - }); - - it('Verify parse video response', function () { - const request = spec.buildRequests(videoSlotConfig); - const videoRequest = JSON.parse(request.data); - const videoResponse = { - seatbid: [{ - bid: [{ - impid: videoRequest.imp[0].id, - price: 1.90, - adm: 'http://vid.example.com/9876', - crid: '510511_754567308' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: videoResponse }, request); - expect(bids).to.have.lengthOf(1); - // 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.crid).to.equal('510511_754567308'); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(480); - expect(bid.adId).to.equal('bid12345678'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verifies bidder code', function () { - expect(spec.code).to.equal('kumma'); - }); - - it('Verifies supported media types', function () { - expect(spec.supportedMediaTypes).to.have.lengthOf(3); - expect(spec.supportedMediaTypes[0]).to.equal('banner'); - expect(spec.supportedMediaTypes[1]).to.equal('native'); - expect(spec.supportedMediaTypes[2]).to.equal('video'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(slotConfigs[0])).to.equal(true); - expect(spec.isBidRequestValid(slotConfigs[1])).to.equal(true); - expect(spec.isBidRequestValid(nativeSlotConfig[0])).to.equal(true); - expect(spec.isBidRequestValid(videoSlotConfig[0])).to.equal(true); - }); - - it('Verify app requests', function () { - const request = spec.buildRequests(appSlotConfig); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.publisher).to.not.equal(null); - 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'); - }); - - it('Verify GDPR', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'serialized_gpdr_data' - } - }; - const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.user).to.not.equal(null); - expect(ortbRequest.user.ext).to.not.equal(null); - expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data'); - expect(ortbRequest.regs).to.not.equal(null); - expect(ortbRequest.regs.ext).to.not.equal(null); - expect(ortbRequest.regs.ext.gdpr).to.equal(1); - }); -}); diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js deleted file mode 100644 index 624e763ebe1d..000000000000 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ /dev/null @@ -1,335 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/lemmaBidAdapter'; -import * as utils from 'src/utils'; -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('//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 deleted file mode 100644 index 7f8c5f6c44d7..000000000000 --- a/test/spec/modules/lifestreetBidAdapter_spec.js +++ /dev/null @@ -1,222 +0,0 @@ -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); - }); - - it('should use json adapter', function () { - expect(request.url).to.contain('/prebid/'); - }); - - 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', - 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, - 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, - height: 600, - vastUrl: 'http://lifestreet.com', - creativeId: 'test', - currency: 'USD', - dealId: 'test', - netRevenue: true, - ttl: 86400, - mediaType: 'video' - }]); - }); - - it('should return no-bid', function () { - let bidRequest = getDefaultBidRequest().bids[0]; - let bidResponse = { body: getDefaultBidResponse(true, true) }; - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.be.empty; - }); - }); -}); diff --git a/test/spec/modules/livewrappedAnalyticsAdapter_spec.js b/test/spec/modules/livewrappedAnalyticsAdapter_spec.js index 611ff95a036c..649b85b9c07c 100644 --- a/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +++ b/test/spec/modules/livewrappedAnalyticsAdapter_spec.js @@ -258,7 +258,7 @@ describe('Livewrapped analytics adapter', function () { expect(requests.length).to.equal(1); let request = requests[0]; - expect(request.url).to.equal('//lwadm.com/analytics/10'); + expect(request.url).to.equal('https://lwadm.com/analytics/10'); let message = JSON.parse(request.requestBody); diff --git a/test/spec/modules/livewrappedBidAdapter_spec.js b/test/spec/modules/livewrappedBidAdapter_spec.js deleted file mode 100644 index 6db8bff4c3dd..000000000000 --- a/test/spec/modules/livewrappedBidAdapter_spec.js +++ /dev/null @@ -1,835 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/livewrappedBidAdapter'; -import {config} from 'src/config'; -import * as utils from 'src/utils'; - -describe('Livewrapped adapter tests', function () { - let sandbox, - bidderRequest; - - beforeEach(function () { - sandbox = sinon.sandbox.create(); - - bidderRequest = { - bidderCode: 'livewrapped', - auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - bidderRequestId: '178e34bad3658f', - bids: [ - { - bidder: 'livewrapped', - params: { - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']} - }, - adUnitCode: 'panorama_d_1', - sizes: [[980, 240], [980, 120]], - bidId: '2ffb201a808da7', - bidderRequestId: '178e34bad3658f', - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' - } - ], - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000 - }; - }); - - afterEach(function () { - sandbox.restore(); - }); - - describe('isBidRequestValid', function() { - it('should accept a request with id only as valid', function() { - let bid = {params: {adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.true; - }); - - it('should accept a request with adUnitName and PublisherId as valid', function() { - let bid = {params: {adUnitName: 'panorama_d_1', publisherId: '26947112-2289-405D-88C1-A7340C57E63E'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.true; - }); - - it('should accept a request with adUnitCode and PublisherId as valid', function() { - let bid = {adUnitCode: 'panorama_d_1', params: {publisherId: '26947112-2289-405D-88C1-A7340C57E63E'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.true; - }); - - it('should accept a request with placementCode and PublisherId as valid', function() { - let bid = {placementCode: 'panorama_d_1', params: {publisherId: '26947112-2289-405D-88C1-A7340C57E63E'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.true; - }); - - it('should not accept a request with adUnitName, adUnitCode, placementCode but no PublisherId as valid', function() { - let bid = {placementCode: 'panorama_d_1', adUnitCode: 'panorama_d_1', params: {adUnitName: 'panorama_d_1'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.false; - }); - }); - - describe('buildRequests', function() { - it('should make a well-formed single request object', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let result = spec.buildRequests(bidderRequest.bids, bidderRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed multiple request object', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let multiplebidRequest = clone(bidderRequest); - multiplebidRequest.bids.push(clone(bidderRequest.bids[0])); - multiplebidRequest.bids[1].adUnitCode = 'box_d_1'; - multiplebidRequest.bids[1].sizes = [[300, 250]]; - multiplebidRequest.bids[1].bidId = '3ffb201a808da7'; - delete multiplebidRequest.bids[1].params.adUnitId; - - let result = spec.buildRequests(multiplebidRequest.bids, multiplebidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }, { - callerAdUnitId: 'box_d_1', - bidId: '3ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 300, height: 250}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with AdUnitName', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - testbidRequest.bids[0].params.adUnitName = 'caller id 1'; - delete testbidRequest.bids[0].params.adUnitId; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'caller id 1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with less parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with less parameters, no publisherId', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.publisherId; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - url: 'http://www.domain.com', - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with app parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - testbidRequest.bids[0].params.deviceId = 'deviceid'; - testbidRequest.bids[0].params.ifa = 'ifa'; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - deviceId: 'deviceid', - ifa: 'ifa', - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with debug parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - testbidRequest.bids[0].params.tid = 'tracking id'; - testbidRequest.bids[0].params.test = true; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - tid: 'tracking id', - test: true, - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with optional parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - testbidRequest.bids[0].params.options = {keyvalues: [{key: 'key', value: 'value'}]}; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}], - options: {keyvalues: [{key: 'key', value: 'value'}]} - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with ad blocker revovered parameter', function() { - sandbox.stub(utils, 'getWindowTop').returns({ I12C: { Morph: 1 } }); - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - cookieSupport: true, - rcv: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should pass gdpr true parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testRequest = clone(bidderRequest); - testRequest.gdprConsent = { - gdprApplies: true, - consentString: 'test' - }; - let result = spec.buildRequests(testRequest.bids, testRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - gdprApplies: true, - gdprConsent: 'test', - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should pass gdpr false parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testRequest = clone(bidderRequest); - testRequest.gdprConsent = { - gdprApplies: false - }; - let result = spec.buildRequests(testRequest.bids, testRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - gdprApplies: false, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should pass no cookie support', function() { - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => false); - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - let result = spec.buildRequests(bidderRequest.bids, bidderRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: false, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should pass no cookie support Safari', function() { - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => true); - let result = spec.buildRequests(bidderRequest.bids, bidderRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: false, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should use params.url, then config pageUrl, then getTopWindowUrl', function() { - let testRequest = clone(bidderRequest); - sandbox.stub(utils, 'getTopWindowUrl').callsFake(() => 'http://www.topurl.com'); - - let result = spec.buildRequests(testRequest.bids, testRequest); - let data = JSON.parse(result.data); - - expect(data.url).to.equal('http://www.domain.com'); - - delete testRequest.bids[0].params.url; - - result = spec.buildRequests(testRequest.bids, testRequest); - data = JSON.parse(result.data); - - expect(data.url).to.equal('http://www.topurl.com'); - - let origGetConfig = config.getConfig; - sandbox.stub(config, 'getConfig').callsFake(function (key) { - if (key === 'pageUrl') { - return 'http://www.configurl.com'; - } - return origGetConfig.apply(config, arguments); - }); - - result = spec.buildRequests(testRequest.bids, testRequest); - data = JSON.parse(result.data); - - expect(data.url).to.equal('http://www.configurl.com'); - }); - - it('should make use of pubcid if available', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - testbidRequest.bids[0].crumbs = {pubcid: 'pubcid 123'}; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'pubcid 123', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make userId take precedence over pubcid', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - testbidRequest.bids[0].crumbs = {pubcid: 'pubcid 123'}; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - }); - - it('should make use of Id5-Id if available', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - testbidRequest.bids[0].userId = {}; - testbidRequest.bids[0].userId.id5id = 'id5-user-id'; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(data.rtbData.user.ext.eids).to.deep.equal([{ - 'source': 'id5-sync.com', - 'uids': [{ - 'id': 'id5-user-id', - 'atype': 1 - }] - }]); - }); - - it('should make use of publisher common Id if available', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - testbidRequest.bids[0].userId = {}; - testbidRequest.bids[0].userId.pubcid = 'publisher-common-id'; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(data.rtbData.user.ext.eids).to.deep.equal([{ - 'source': 'pubcommon', - 'uids': [{ - 'id': 'publisher-common-id', - 'atype': 1 - }] - }]); - }); - - describe('interpretResponse', function () { - it('should handle single success response', function() { - let lwResponse = { - ads: [ - { - id: '28e5ddf4-3c01-11e8-86a7-0a44794250d4', - callerId: 'site_outsider_0', - tag: 'ad', - width: 300, - height: 250, - cpmBid: 2.565917, - bidId: '32e50fad901ae89', - auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf', - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - ttl: 120, - meta: undefined - } - ], - currency: 'USD' - }; - - let expectedResponse = [{ - requestId: '32e50fad901ae89', - bidderCode: 'livewrapped', - cpm: 2.565917, - width: 300, - height: 250, - ad: 'ad', - ttl: 120, - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - netRevenue: true, - currency: 'USD', - meta: undefined - }]; - - let bids = spec.interpretResponse({body: lwResponse}); - - expect(bids).to.deep.equal(expectedResponse); - }) - - it('should handle multiple success response', function() { - let lwResponse = { - ads: [ - { - id: '28e5ddf4-3c01-11e8-86a7-0a44794250d4', - callerId: 'site_outsider_0', - tag: 'ad1', - width: 300, - height: 250, - cpmBid: 2.565917, - bidId: '32e50fad901ae89', - auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf', - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - ttl: 120, - meta: undefined - }, - { - id: '38e5ddf4-3c01-11e8-86a7-0a44794250d4', - callerId: 'site_outsider_1', - tag: 'ad2', - width: 980, - height: 240, - cpmBid: 3.565917, - bidId: '42e50fad901ae89', - auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf', - creativeId: '62cbd598-2715-4c43-a06f-229fc170f945:427077', - ttl: 120, - meta: undefined - } - ], - currency: 'USD' - }; - - let expectedResponse = [{ - requestId: '32e50fad901ae89', - bidderCode: 'livewrapped', - cpm: 2.565917, - width: 300, - height: 250, - ad: 'ad1', - ttl: 120, - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - netRevenue: true, - currency: 'USD', - meta: undefined - }, { - requestId: '42e50fad901ae89', - bidderCode: 'livewrapped', - cpm: 3.565917, - width: 980, - height: 240, - ad: 'ad2', - ttl: 120, - creativeId: '62cbd598-2715-4c43-a06f-229fc170f945:427077', - netRevenue: true, - currency: 'USD', - meta: undefined - }]; - - let bids = spec.interpretResponse({body: lwResponse}); - - expect(bids).to.deep.equal(expectedResponse); - }) - - it('should return meta-data', function() { - let lwResponse = { - ads: [ - { - id: '28e5ddf4-3c01-11e8-86a7-0a44794250d4', - callerId: 'site_outsider_0', - tag: 'ad', - width: 300, - height: 250, - cpmBid: 2.565917, - bidId: '32e50fad901ae89', - auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf', - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - ttl: 120, - meta: {metadata: 'metadata'} - } - ], - currency: 'USD' - }; - - let expectedResponse = [{ - requestId: '32e50fad901ae89', - bidderCode: 'livewrapped', - cpm: 2.565917, - width: 300, - height: 250, - ad: 'ad', - ttl: 120, - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - netRevenue: true, - currency: 'USD', - meta: {metadata: 'metadata'} - }]; - - let bids = spec.interpretResponse({body: lwResponse}); - - expect(bids).to.deep.equal(expectedResponse); - }) - }); - - describe('user sync', function () { - let serverResponses; - - beforeEach(function () { - serverResponses = [{ - body: { - pixels: [ - {type: 'Redirect', url: 'http://pixelsync'}, - {type: 'Iframe', url: 'http://iframesync'} - ] - } - }]; - }); - - it('should return empty if no server responses', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: true, - iframeEnabled: true - }, []); - - let expectedResponse = []; - - expect(syncs).to.deep.equal(expectedResponse) - }); - - it('should return empty if no user sync', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: true, - iframeEnabled: true - }, [{body: {}}]); - - let expectedResponse = []; - - expect(syncs).to.deep.equal(expectedResponse) - }); - - it('should returns pixel and iframe user sync', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: true, - iframeEnabled: true - }, serverResponses); - - let expectedResponse = [{type: 'image', url: 'http://pixelsync'}, {type: 'iframe', url: 'http://iframesync'}]; - - expect(syncs).to.deep.equal(expectedResponse) - }); - - it('should returns pixel only if iframe not supported user sync', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: true, - iframeEnabled: false - }, serverResponses); - - let expectedResponse = [{type: 'image', url: 'http://pixelsync'}]; - - expect(syncs).to.deep.equal(expectedResponse) - }); - - it('should returns iframe only if pixel not supported user sync', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: false, - iframeEnabled: true - }, serverResponses); - - let expectedResponse = [{type: 'iframe', url: 'http://iframesync'}]; - - expect(syncs).to.deep.equal(expectedResponse) - }); - }); -}); - -function clone(obj) { - return JSON.parse(JSON.stringify(obj)); -} diff --git a/test/spec/modules/lkqdBidAdapter_spec.js b/test/spec/modules/lkqdBidAdapter_spec.js index 73a4824f0efe..1c7f55d42426 100644 --- a/test/spec/modules/lkqdBidAdapter_spec.js +++ b/test/spec/modules/lkqdBidAdapter_spec.js @@ -173,7 +173,7 @@ https://t.lkqd.net/t?ev=3&tsid=662921&env=3&cb=761218674439&format=0&did=2&osid= ]]> - + - + @@ -194,7 +194,7 @@ https://t.lkqd.net/t?ev=9&tsid=662921&env=3&cb=761218674439&format=0&did=2&osid= 00:00:30 - + - + - + - + - + - + - + - + - + - + - + + ]]> diff --git a/test/spec/modules/logicadBidAdapter_spec.js b/test/spec/modules/logicadBidAdapter_spec.js index effb7334b69b..1cae535aee05 100644 --- a/test/spec/modules/logicadBidAdapter_spec.js +++ b/test/spec/modules/logicadBidAdapter_spec.js @@ -8,7 +8,7 @@ describe('LogicadAdapter', function () { bidId: '51ef8751f9aead', params: { tid: 'PJ2P', - page: 'http://www.logicad.com/' + page: 'https://www.logicad.com/' }, adUnitCode: 'div-gpt-ad-1460505748561-0', transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', diff --git a/test/spec/modules/madvertiseBidAdapter_spec.js b/test/spec/modules/madvertiseBidAdapter_spec.js index b2a08410532c..e10a192355af 100644 --- a/test/spec/modules/madvertiseBidAdapter_spec.js +++ b/test/spec/modules/madvertiseBidAdapter_spec.js @@ -114,7 +114,7 @@ describe('madvertise adapater', function () { expect(req[0]).to.have.property('method'); expect(req[0].method).to.equal('GET'); expect(req[0]).to.have.property('url'); - expect(req[0].url).to.contain('//mobile.mng-ads.com/?rt=bid_request&v=1.0'); + expect(req[0].url).to.contain('https://mobile.mng-ads.com/?rt=bid_request&v=1.0'); expect(req[0].url).to.contain(`&s=test`); expect(req[0].url).to.contain(`&sizes[0]=728x90`); expect(req[0].url).to.contain(`&gdpr=1`); @@ -130,7 +130,7 @@ describe('madvertise adapater', function () { expect(req[0]).to.have.property('method'); expect(req[0].method).to.equal('GET'); expect(req[0]).to.have.property('url'); - expect(req[0].url).to.contain('//mobile.mng-ads.com/?rt=bid_request&v=1.0'); + expect(req[0].url).to.contain('https://mobile.mng-ads.com/?rt=bid_request&v=1.0'); expect(req[0].url).to.contain(`&s=test`); expect(req[0].url).to.contain(`&sizes[0]=728x90`); expect(req[0].url).not.to.contain(`&gdpr=1`); diff --git a/test/spec/modules/mantisBidAdapter_spec.js b/test/spec/modules/mantisBidAdapter_spec.js index df2c6bb9a13f..7caa9b29f6fc 100644 --- a/test/spec/modules/mantisBidAdapter_spec.js +++ b/test/spec/modules/mantisBidAdapter_spec.js @@ -48,10 +48,10 @@ describe('MantisAdapter', function () { ]; it('domain override', function () { - window.mantis_domain = 'http://foo'; + window.mantis_domain = 'https://foo'; const request = spec.buildRequests(bidRequests); - expect(request.url).to.include('http://foo'); + expect(request.url).to.include('https://foo'); delete window.mantis_domain; }); diff --git a/test/spec/modules/meazyBidAdapter_spec.js b/test/spec/modules/meazyBidAdapter_spec.js index 9abe37ece62f..123d53f2fa1b 100644 --- a/test/spec/modules/meazyBidAdapter_spec.js +++ b/test/spec/modules/meazyBidAdapter_spec.js @@ -4,7 +4,7 @@ import { spec } from 'modules/meazyBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; const MEAZY_PID = '6910b7344ae566a1' -const VALID_ENDPOINT = `//rtb-filter.meazy.co/pbjs?host=${utils.getOrigin()}&api_key=${MEAZY_PID}`; +const VALID_ENDPOINT = `https://rtb-filter.meazy.co/pbjs?host=${utils.getOrigin()}&api_key=${MEAZY_PID}`; const bidderRequest = { refererInfo: { @@ -50,7 +50,7 @@ const bidContent = { const bidContentExt = { ...bidContent, ext: { - 'syncUrl': '//sync.meazy.co/sync/img?api_key=6910b7344ae566a1' + 'syncUrl': 'https://sync.meazy.co/sync/img?api_key=6910b7344ae566a1' } }; @@ -158,8 +158,8 @@ describe('meazyBidAdapter', function () { const syncOptionsEE = { pixelEnabled: true, iframeEnabled: true }; const syncOptionsFE = { pixelEnabled: true, iframeEnabled: false }; - const successIFrame = { type: 'iframe', url: '//sync.meazy.co/sync/iframe' }; - const successPixel = { type: 'image', url: '//sync.meazy.co/sync/img?api_key=6910b7344ae566a1' }; + const successIFrame = { type: 'iframe', url: 'https://sync.meazy.co/sync/iframe' }; + const successPixel = { type: 'image', url: 'https://sync.meazy.co/sync/img?api_key=6910b7344ae566a1' }; it('should return an empty array', function () { expect(spec.getUserSyncs(syncOptionsFF, [])).to.be.empty; diff --git a/test/spec/modules/mgidBidAdapter_spec.js b/test/spec/modules/mgidBidAdapter_spec.js index 4a9f25a29a75..07db18650c20 100644 --- a/test/spec/modules/mgidBidAdapter_spec.js +++ b/test/spec/modules/mgidBidAdapter_spec.js @@ -256,7 +256,7 @@ describe('Mgid bid adapter', function () { it('should return overwrite default bidurl', function () { let bid = Object.assign({}, bid); bid.params = { - bidUrl: '//newbidurl.com/', + bidUrl: 'https://newbidurl.com/', accountId: '1', placementId: '2', }; @@ -267,7 +267,7 @@ describe('Mgid bid adapter', function () { }; let bidRequests = [bid]; const request = spec.buildRequests(bidRequests); - expect(request.url).to.include('//newbidurl.com/1'); + expect(request.url).to.include('https://newbidurl.com/1'); }); it('should return overwrite default bidFloor', function () { let bid = Object.assign({}, bid); @@ -546,7 +546,7 @@ describe('Mgid bid adapter', function () { }); it('should push proper banner bid response', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': '', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': 'html: adm', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2']}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': '', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': 'html: adm', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2']}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([ @@ -560,8 +560,8 @@ describe('Mgid bid adapter', function () { 'isBurl': true, 'mediaType': 'banner', 'netRevenue': true, - 'nurl': 'http: nurl', - 'burl': 'http: burl', + 'nurl': 'https nurl', + 'burl': 'https burl', 'requestId': '61e40632c53fc2', 'ttl': 300, 'width': 300, @@ -572,26 +572,26 @@ describe('Mgid bid adapter', function () { describe('interpretResponse native', function () { it('should not push proper native bid response if adm is missing', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([]) }); it('should not push proper native bid response if assets is empty', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([]) }); it('should push proper native bid response', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}], ext: {'muidn': 'userid'}} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}], ext: {'muidn': 'userid'}} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([{ 'ad': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', - 'burl': 'http: burl', + 'burl': 'https burl', 'cpm': 1.5, 'creativeId': '2898532/2419121/2592854/2499195', 'currency': 'GBP', @@ -621,7 +621,7 @@ describe('Mgid bid adapter', function () { 'title': 'title1' }, 'netRevenue': true, - 'nurl': 'http: nurl', + 'nurl': 'https nurl', 'requestId': '61e40632c53fc2', 'ttl': 300, 'width': 0 @@ -629,7 +629,7 @@ describe('Mgid bid adapter', function () { }); it('should push proper native bid response', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([ @@ -643,8 +643,8 @@ describe('Mgid bid adapter', function () { 'isBurl': true, 'mediaType': 'native', 'netRevenue': true, - 'nurl': 'http: nurl', - 'burl': 'http: burl', + 'nurl': 'https nurl', + 'burl': 'https burl', 'requestId': '61e40632c53fc2', 'ttl': 300, 'width': 0, diff --git a/test/spec/modules/microadBidAdapter_spec.js b/test/spec/modules/microadBidAdapter_spec.js index 32bf15d53b91..b80a69384258 100644 --- a/test/spec/modules/microadBidAdapter_spec.js +++ b/test/spec/modules/microadBidAdapter_spec.js @@ -61,14 +61,14 @@ describe('microadBidAdapter', () => { describe('buildRequests', () => { const bidderRequest = { refererInfo: { - canonicalUrl: 'http://example.com/to', - referer: 'http://example.com/from' + canonicalUrl: 'https://example.com/to', + referer: 'https://example.com/from' } }; const expectedResultTemplate = { spot: 'spot-code', - url: 'http://example.com/to', - referrer: 'http://example.com/from', + url: 'https://example.com/to', + referrer: 'https://example.com/from', bid_id: 'bid-id', transaction_id: 'transaction-id', media_types: 1 @@ -127,7 +127,7 @@ describe('microadBidAdapter', () => { it('should use window.location.href if there is no canonicalUrl', () => { const bidderRequestWithoutCanonicalUrl = { refererInfo: { - referer: 'http://example.com/from' + referer: 'https://example.com/from' } }; const requests = spec.buildRequests([bidRequestTemplate], bidderRequestWithoutCanonicalUrl); diff --git a/test/spec/modules/mobfoxBidAdapter_spec.js b/test/spec/modules/mobfoxBidAdapter_spec.js index 90125f3e0d05..d3178d77a1a1 100644 --- a/test/spec/modules/mobfoxBidAdapter_spec.js +++ b/test/spec/modules/mobfoxBidAdapter_spec.js @@ -75,7 +75,7 @@ describe('mobfox adapter tests', function () { body: { request: { clicktype: 'safari', - clickurl: 'http://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0', + clickurl: 'https://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0', cpmPrice: 50, htmlString: 'test', refresh: '30', @@ -104,7 +104,7 @@ describe('mobfox adapter tests', function () { expect(bidResponses[0].currency).to.equal('USD'); expect(bidResponses[0].height).to.equal('480'); expect(bidResponses[0].netRevenue).to.equal(true); - expect(bidResponses[0].referrer).to.equal('http://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0'); + expect(bidResponses[0].referrer).to.equal('https://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0'); expect(bidResponses[0].ttl).to.equal(360); expect(bidResponses[0].width).to.equal('320'); }); diff --git a/test/spec/modules/mytargetBidAdapter_spec.js b/test/spec/modules/mytargetBidAdapter_spec.js index 4e478fee1f0d..01a94e76d607 100644 --- a/test/spec/modules/mytargetBidAdapter_spec.js +++ b/test/spec/modules/mytargetBidAdapter_spec.js @@ -55,7 +55,7 @@ describe('MyTarget Adapter', function() { it('should build single POST request for multiple bids', function() { expect(bidRequest.method).to.equal('POST'); - expect(bidRequest.url).to.equal('//ad.mail.ru/hbid_prebid/'); + expect(bidRequest.url).to.equal('https://ad.mail.ru/hbid_prebid/'); expect(bidRequest.data).to.be.an('object'); expect(bidRequest.data.places).to.be.an('array'); expect(bidRequest.data.places).to.have.lengthOf(2); diff --git a/test/spec/modules/nanointeractiveBidAdapter_spec.js b/test/spec/modules/nanointeractiveBidAdapter_spec.js index a357327fe966..f999c2a46560 100644 --- a/test/spec/modules/nanointeractiveBidAdapter_spec.js +++ b/test/spec/modules/nanointeractiveBidAdapter_spec.js @@ -178,8 +178,8 @@ describe('nanointeractive adapter tests', function () { let sandbox; function getMocks() { - let mockOriginAddress = 'http://localhost'; - let mockRefAddress = 'http://some-ref.test'; + let mockOriginAddress = 'https://localhost'; + let mockRefAddress = 'https://some-ref.test'; return { 'windowLocationAddress': mockRefAddress, 'originAddress': mockOriginAddress, diff --git a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js deleted file mode 100644 index dd6ed4686d1c..000000000000 --- a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js +++ /dev/null @@ -1,138 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/nasmediaAdmixerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('nasmediaAdmixerBidAdapter', 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': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'ax_key' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '3361d01e67dbd6', - 'bidderRequestId': '2b60dcd392628a', - 'auctionId': '124cb070528662', - }; - - 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 bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'ax_key': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'ajj7jba3' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '3361d01e67dbd6', - 'bidderRequestId': '2b60dcd392628a', - 'auctionId': '124cb070528662', - } - ]; - - it('sends bid request to url via GET', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`https://adn.admixer.co.kr`)); - }); - }); - - describe('interpretResponse', function () { - const response = { - 'body': { - 'bidder': 'nasmedia_admixer', - 'req_id': '861a8e7952c82c', - 'error_code': 0, - 'error_msg': 'OK', - 'body': [{ - 'ad_id': '20049', - 'width': 300, - 'height': 250, - 'currency': 'USD', - 'cpm': 1.769221, - 'ad': '' - }] - }, - 'headers': { - 'get': function () { - } - } - }; - - const bidRequest = { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'ajj7jba3', - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [320, 480]], - 'bidId': '31300c8b9697cd', - 'bidderRequestId': '2bf570adcf83fa', - 'auctionId': '169827a33f03cc', - }; - - it('should get correct bid response', function () { - const expectedResponse = [ - { - 'requestId': '861a8e7952c82c', - 'cpm': 1.769221, - 'currency': 'USD', - 'width': 300, - 'height': 250, - 'ad': '', - 'creativeId': '20049', - 'ttl': 360, - 'netRevenue': false - } - ]; - - const result = spec.interpretResponse(response, bidRequest); - expect(result).to.have.lengthOf(1); - let resultKeys = Object.keys(result[0]); - expect(resultKeys.sort()).to.deep.equal(Object.keys(expectedResponse[0]).sort()); - resultKeys.forEach(function (k) { - if (k === 'ad') { - expect(result[0][k]).to.match(/$/); - } else { - expect(result[0][k]).to.equal(expectedResponse[0][k]); - } - }); - }); - - it('handles nobid responses', function () { - response.body = { - 'bidder': 'nasmedia_admixer', - 'req_id': '861a8e7952c82c', - 'error_code': 0, - 'error_msg': 'OK', - 'body': [] - }; - - const result = spec.interpretResponse(response, bidRequest); - expect(result).to.have.lengthOf(0); - }); - }); -}); diff --git a/test/spec/modules/oneplanetonlyBidAdapter_spec.js b/test/spec/modules/oneplanetonlyBidAdapter_spec.js deleted file mode 100644 index fbcec66ef519..000000000000 --- a/test/spec/modules/oneplanetonlyBidAdapter_spec.js +++ /dev/null @@ -1,100 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/oneplanetonlyBidAdapter'; - -describe('OnePlanetOnlyAdapter', function () { - let bid = { - bidId: '51ef8751f9aead', - bidder: 'oneplanetonly', - params: { - siteId: '5', - adUnitId: '5-4587544', - }, - adUnitCode: 'div-gpt-ad-1460505748561-0', - transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - sizes: [[300, 250], [300, 600]], - bidderRequestId: '418b37f85e772c', - auctionId: '18fd8b8b0bd757' - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are params.siteId and params.adUnitId 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.adUnitId; - 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('//show.oneplanetonly.com/prebid?siteId=5'); - }); - 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('id', 'ver', 'prebidVer', 'transactionId', 'currency', 'timeout', 'siteId', - 'domain', 'page', 'referrer', 'adUnits'); - - let adUnit = data.adUnits[0]; - expect(adUnit).to.have.keys('id', 'bidId', 'sizes'); - expect(adUnit.id).to.equal('5-4587544'); - expect(adUnit.bidId).to.equal('51ef8751f9aead'); - expect(adUnit.sizes).to.have.members(['300x250', '300x600']); - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.adUnits).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const serverResponse = { - body: { - bids: [{ - requestId: '51ef8751f9aead', - cpm: 0.4, - width: 300, - height: 250, - creativeId: '2', - currency: 'USD', - ad: 'Test', - ttl: 120, - }] - } - }; - let bannerResponses = spec.interpretResponse(serverResponse); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let bidObject = bannerResponses[0]; - expect(bidObject).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency'); - expect(bidObject.requestId).to.equal('51ef8751f9aead'); - expect(bidObject.cpm).to.equal(0.4); - expect(bidObject.width).to.equal(300); - expect(bidObject.height).to.equal(250); - expect(bidObject.ad).to.equal('Test'); - expect(bidObject.ttl).to.equal(120); - expect(bidObject.creativeId).to.equal('2'); - expect(bidObject.netRevenue).to.be.true; - expect(bidObject.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: {} - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); -}); diff --git a/test/spec/modules/open8BidAdapter_spec.js b/test/spec/modules/open8BidAdapter_spec.js index e26811ed71c2..7ef1c38abb20 100644 --- a/test/spec/modules/open8BidAdapter_spec.js +++ b/test/spec/modules/open8BidAdapter_spec.js @@ -1,7 +1,7 @@ import { spec } from 'modules/open8BidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; -const ENDPOINT = '//as.vt.open8.com/v1/control/prebid'; +const ENDPOINT = 'https://as.vt.open8.com/v1/control/prebid'; describe('Open8Adapter', function() { const adapter = newBidder(spec); @@ -58,9 +58,9 @@ describe('Open8Adapter', function() { userId: 'userid1234', impId: 'impid1234', media: 'TEST_MEDIA', - nurl: '//example/win', + nurl: 'https://example/win', isAdReturn: true, - syncPixels: ['//example/sync/pixel.gif'], + syncPixels: ['https://example/sync/pixel.gif'], syncIFs: [], ad: { bidId: 'TEST_BID_ID', @@ -73,13 +73,13 @@ describe('Open8Adapter', function() { fa: 5678, pr: 'pr1234', mr: 'mr1234', - nurl: '//example/win', + nurl: 'https://example/win', adType: 2, banner: { w: 300, h: 250, adm: '
', - imps: ['//example.com/imp'] + imps: ['https://example.com/imp'] } } }; @@ -89,7 +89,7 @@ describe('Open8Adapter', function() { impId: 'impid1234', media: 'TEST_MEDIA', isAdReturn: true, - syncPixels: ['//example/sync/pixel.gif'], + syncPixels: ['https://example/sync/pixel.gif'], syncIFs: [], ad: { bidId: 'TEST_BID_ID', @@ -102,10 +102,10 @@ describe('Open8Adapter', function() { fa: 5678, pr: 'pr1234', mr: 'mr1234', - nurl: '//example/win', + nurl: 'https://example/win', adType: 1, video: { - purl: '//playerexample.js', + purl: 'https://playerexample.js', vastXml: '', w: 320, h: 180 @@ -124,14 +124,14 @@ describe('Open8Adapter', function() { 'fa': 5678, 'pr': 'pr1234', 'mr': 'mr1234', - 'nurl': '//example/win', + 'nurl': 'https://example/win', 'requestId': 'requestid1234', 'cpm': 1234.56, 'creativeId': 'creativeid1234', 'dealId': 'TEST_DEAL_ID', 'width': 300, 'height': 250, - 'ad': "
", + 'ad': "
", 'mediaType': 'banner', 'currency': 'JPY', 'ttl': 360, @@ -154,7 +154,7 @@ describe('Open8Adapter', function() { 'fa': 5678, 'pr': 'pr1234', 'mr': 'mr1234', - 'nurl': '//example/win', + 'nurl': 'https://example/win', 'requestId': 'requestid1234', 'cpm': 1234.56, 'creativeId': 'creativeid1234', diff --git a/test/spec/modules/openxAnalyticsAdapter_spec.js b/test/spec/modules/openxAnalyticsAdapter_spec.js index 88ab3c4c5805..b47c8a99150c 100644 --- a/test/spec/modules/openxAnalyticsAdapter_spec.js +++ b/test/spec/modules/openxAnalyticsAdapter_spec.js @@ -198,7 +198,7 @@ describe('openx analytics adapter', function() { expect(requests.length).to.equal(1); const endpoint = requests[0].url.split('?')[0]; - expect(endpoint).to.equal('http://ads.openx.net/w/1.0/pban'); + expect(endpoint).to.equal('https://ads.openx.net/w/1.0/pban'); }); describe('hb.ct, hb.rid, dddid, hb.asiid, hb.pubid', function() { diff --git a/test/spec/modules/optimaticBidAdapter_spec.js b/test/spec/modules/optimaticBidAdapter_spec.js deleted file mode 100644 index 3dd7ca79cc70..000000000000 --- a/test/spec/modules/optimaticBidAdapter_spec.js +++ /dev/null @@ -1,178 +0,0 @@ -import { expect } from 'chai'; -import { spec, ENDPOINT } from 'modules/optimaticBidAdapter'; -import * as utils from 'src/utils'; - -describe('OptimaticBidAdapter', function () { - let bidRequest; - - beforeEach(function () { - bidRequest = { - bidder: 'optimatic', - params: { - placement: '2chy7Gc2eSQL', - bidfloor: 5.00 - }, - adUnitCode: 'adunit-code', - sizes: [ 640, 480 ], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475' - }; - }); - - describe('spec.isBidRequestValid', function () { - it('should return true when the required params are passed', function () { - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return false when the "bidfloor" param is missing', function () { - bidRequest.params = { - placement: '2chy7Gc2eSQL' - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when the "placement" param is missing', function () { - bidRequest.params = { - bidfloor: 5.00 - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when no bid params are passed', function () { - bidRequest.params = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when a bid request is not passed', function () { - expect(spec.isBidRequestValid()).to.equal(false); - expect(spec.isBidRequestValid({})).to.equal(false); - }); - }); - - describe('spec.buildRequests', function () { - it('should create a POST request for every bid', function () { - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].method).to.equal('POST'); - expect(requests[0].url).to.equal(ENDPOINT + bidRequest.params.placement); - }); - - it('should attach the bid request object', function () { - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].bidRequest).to.equal(bidRequest); - }); - - it('should attach request data', function () { - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - const [ width, height ] = bidRequest.sizes; - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); - }); - - it('must parse bid size from a nested array', function () { - const width = 640; - const height = 480; - bidRequest.sizes = [[ width, height ]]; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - }); - - it('must parse bid size from a string', function () { - const width = 640; - const height = 480; - bidRequest.sizes = `${width}x${height}`; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - }); - - it('must handle an empty bid size', function () { - bidRequest.sizes = []; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.imp[0].video.w).to.equal(undefined); - expect(data.imp[0].video.h).to.equal(undefined); - }); - }); - - describe('spec.interpretResponse', function () { - it('should return no bids if the response is not valid', function () { - const bidResponse = spec.interpretResponse({ body: null }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return no bids if the response "nurl" and "adm" are missing', function () { - const serverResponse = {seatbid: [{bid: [{price: 5.01}]}]}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return no bids if the response "price" is missing', function () { - const serverResponse = {seatbid: [{bid: [{adm: ''}]}]}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return a valid bid response with just "adm"', function () { - const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, adm: ''}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - let o = { - requestId: bidRequest.bidId, - bidderCode: spec.code, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].id, - vastXml: serverResponse.seatbid[0].bid[0].adm, - width: 640, - height: 480, - mediaType: 'video', - currency: 'USD', - ttl: 300, - netRevenue: true - }; - expect(bidResponse).to.deep.equal(o); - }); - - it('should return a valid bid response with just "nurl"', function () { - const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, nurl: 'https://mg-bid-win.optimatic.com/win/134eb262-948a-463e-ad93-bc8b622d399c?wp=${AUCTION_PRICE}'}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - let o = { - requestId: bidRequest.bidId, - bidderCode: spec.code, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].id, - vastUrl: serverResponse.seatbid[0].bid[0].nurl, - width: 640, - height: 480, - mediaType: 'video', - currency: 'USD', - ttl: 300, - netRevenue: true - }; - expect(bidResponse).to.deep.equal(o); - }); - - it('should return a valid bid response with "nurl" when both nurl and adm exist', function () { - const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, adm: '', nurl: 'https://mg-bid-win.optimatic.com/win/134eb262-948a-463e-ad93-bc8b622d399c?wp=${AUCTION_PRICE}'}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - let o = { - requestId: bidRequest.bidId, - bidderCode: spec.code, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].id, - vastUrl: serverResponse.seatbid[0].bid[0].nurl, - width: 640, - height: 480, - mediaType: 'video', - currency: 'USD', - ttl: 300, - netRevenue: true - }; - expect(bidResponse).to.deep.equal(o); - }); - }); -}); diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 1b76de9841a7..9e7d10d7b047 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -31,7 +31,7 @@ describe('orbidderBidAdapter', () => { return spec.buildRequests(buildRequest, { ...bidderRequest || {}, refererInfo: { - referer: 'http://localhost:9876/' + referer: 'https://localhost:9876/' } })[0]; }; @@ -99,7 +99,7 @@ describe('orbidderBidAdapter', () => { it('sends correct bid parameters', () => { // we add one, because we add referer information from bidderRequest object expect(Object.keys(request.data).length).to.equal(Object.keys(defaultBidRequest).length + 1); - expect(request.data.pageUrl).to.equal('http://localhost:9876/'); + expect(request.data.pageUrl).to.equal('https://localhost:9876/'); // expect(request.data.referrer).to.equal(''); Object.keys(defaultBidRequest).forEach((key) => { expect(defaultBidRequest[key]).to.equal(request.data[key]); diff --git a/test/spec/modules/orbitsoftBidAdapter_spec.js b/test/spec/modules/orbitsoftBidAdapter_spec.js deleted file mode 100644 index 18ba9a6e8f3d..000000000000 --- a/test/spec/modules/orbitsoftBidAdapter_spec.js +++ /dev/null @@ -1,248 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/orbitsoftBidAdapter'; - -const ENDPOINT_URL = 'https://orbitsoft.com/php/ads/hb.phps'; -describe('Orbitsoft adapter', function () { - describe('implementation', function () { - describe('for requests', function () { - it('should accept valid bid', function () { - let validBid = { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - }, - isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject invalid bid', function () { - let invalidBid = { - bidder: 'orbitsoft' - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - describe('for requests', function () { - it('should accept valid bid with styles', function () { - let validBid = { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL, - style: { - title: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - description: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - url: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - colors: { - background: 'ffffff', - border: 'E0E0E0', - link: '5B99FE' - } - } - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - - let buildRequest = spec.buildRequests([validBid])[0]; - let requestUrl = buildRequest.url; - let requestUrlParams = buildRequest.data; - expect(requestUrl).to.equal(ENDPOINT_URL); - expect(requestUrlParams).have.property('f1', 'Tahoma'); - expect(requestUrlParams).have.property('fs1', 'medium'); - expect(requestUrlParams).have.property('w1', 'normal'); - expect(requestUrlParams).have.property('s1', 'normal'); - expect(requestUrlParams).have.property('c3', '0053F9'); - expect(requestUrlParams).have.property('f2', 'Tahoma'); - expect(requestUrlParams).have.property('fs2', 'medium'); - expect(requestUrlParams).have.property('w2', 'normal'); - expect(requestUrlParams).have.property('s2', 'normal'); - expect(requestUrlParams).have.property('c4', '0053F9'); - expect(requestUrlParams).have.property('f3', 'Tahoma'); - expect(requestUrlParams).have.property('fs3', 'medium'); - expect(requestUrlParams).have.property('w3', 'normal'); - expect(requestUrlParams).have.property('s3', 'normal'); - expect(requestUrlParams).have.property('c5', '0053F9'); - expect(requestUrlParams).have.property('c2', 'ffffff'); - expect(requestUrlParams).have.property('c1', 'E0E0E0'); - expect(requestUrlParams).have.property('c6', '5B99FE'); - }); - - it('should accept valid bid with custom params', function () { - let validBid = { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL, - customParams: { - cacheBuster: 'bf4d7c1', - clickUrl: 'http://testclickurl.com' - } - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - - let buildRequest = spec.buildRequests([validBid])[0]; - let requestUrlCustomParams = buildRequest.data; - expect(requestUrlCustomParams).have.property('c.cacheBuster', 'bf4d7c1'); - expect(requestUrlCustomParams).have.property('c.clickUrl', 'http://testclickurl.com'); - }); - - it('should reject invalid bid without requestUrl', function () { - let invalidBid = { - bidder: 'orbitsoft', - params: { - placementId: '123' - } - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should reject invalid bid without placementId', function () { - let invalidBid = { - bidder: 'orbitsoft', - params: { - requestUrl: ENDPOINT_URL - } - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - describe('bid responses', function () { - it('should return complete bid response', function () { - let serverResponse = { - body: { - callback_uid: '265b29b70cc106', - cpm: 0.5, - width: 240, - height: 240, - content_url: 'https://orbitsoft.com/php/ads/hb.html', - } - }; - - let bidRequests = [ - { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - 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(240); - expect(bids[0].height).to.equal(240); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].adUrl).to.have.length.above(1); - expect(bids[0].adUrl).to.have.string('https://orbitsoft.com/php/ads/hb.html'); - }); - - it('should return empty bid response', function () { - let bidRequests = [ - { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let serverResponse = { - body: { - callback_uid: '265b29b70cc106', - cpm: 0 - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response on incorrect size', function () { - let bidRequests = [ - { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let serverResponse = { - body: { - callback_uid: '265b29b70cc106', - cpm: 1.5, - width: 0, - height: 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: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let serverResponse = {error: 'error'}, - 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: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let serverResponse = {}, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - }); - }); -}); diff --git a/test/spec/modules/ozoneBidAdapter_spec.js b/test/spec/modules/ozoneBidAdapter_spec.js index a0b51ff7a9ff..4ea3474d2b99 100644 --- a/test/spec/modules/ozoneBidAdapter_spec.js +++ b/test/spec/modules/ozoneBidAdapter_spec.js @@ -170,10 +170,10 @@ var validResponse = { 'id': '677903815252395017', 'impid': '2899ec066a91ff8', 'price': 0.5, - 'adm': '', + 'adm': '', 'adid': '98493581', 'adomain': [ - 'http://prebid.org' + 'https://prebid.org' ], 'iurl': 'https://fra1-ib.adnxs.com/cr?id=98493581', 'cid': '9325', @@ -225,10 +225,10 @@ var validOutstreamResponse = { 'id': '677903815252395017', 'impid': '2899ec066a91ff8', 'price': 0.5, - 'adm': '', + 'adm': '', 'adid': '98493581', 'adomain': [ - 'http://prebid.org' + 'https://prebid.org' ], 'iurl': 'https://fra1-ib.adnxs.com/cr?id=98493581', 'cid': '9325', diff --git a/test/spec/modules/padsquadBidAdapter_spec.js b/test/spec/modules/padsquadBidAdapter_spec.js index aba1efea32fe..88c9680c888d 100644 --- a/test/spec/modules/padsquadBidAdapter_spec.js +++ b/test/spec/modules/padsquadBidAdapter_spec.js @@ -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/papyrusBidAdapter_spec.js b/test/spec/modules/papyrusBidAdapter_spec.js index 289da56379a2..f3c6f42f5b28 100644 --- a/test/spec/modules/papyrusBidAdapter_spec.js +++ b/test/spec/modules/papyrusBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/papyrusBidAdapter'; -const ENDPOINT = '//prebid.papyrus.global'; +const ENDPOINT = 'https://prebid.papyrus.global'; const BIDDER_CODE = 'papyrus'; describe('papyrus Adapter', function () { diff --git a/test/spec/modules/peak226BidAdapter_spec.js b/test/spec/modules/peak226BidAdapter_spec.js deleted file mode 100644 index 8b8157225bb1..000000000000 --- a/test/spec/modules/peak226BidAdapter_spec.js +++ /dev/null @@ -1,114 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/peak226BidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const URL = 'a.ad216.com/header_bid'; - -describe('PeakAdapter', function () { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - const bid = { - params: { - uid: 123 - } - }; - - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - const bid = { - params: {} - }; - - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - // xdescribe('buildRequests', function () { - // const bidRequests = [ - // { - // params: { - // uid: '1234' - // } - // } - // ]; - - // it('sends bid request to URL via GET', function () { - // const request = spec.buildRequests(bidRequests); - - // expect(request.url).to.equal(`${URL}?uids=1234`); - // expect(request.method).to.equal('GET'); - // }); - // }); - - describe('interpretResponse', function () { - it('should handle empty response', function () { - let bids = spec.interpretResponse( - {}, - { - bidsMap: {} - } - ); - - expect(bids).to.be.lengthOf(0); - }); - - it('should handle no seatbid returned', function () { - let response = {}; - - let bids = spec.interpretResponse( - { body: response }, - { - bidsMap: {} - } - ); - - expect(bids).to.be.lengthOf(0); - }); - - it('should handle empty seatbid returned', function () { - let response = { seatbid: [] }; - - let bids = spec.interpretResponse( - { body: response }, - { - bidsMap: {} - } - ); - - expect(bids).to.be.lengthOf(0); - }); - - it('should handle seatbid returned bids', function () { - const bidsMap = { 1: [{ bidId: 11 }] }; - const bid = { - price: 0.2, - auid: 1, - h: 250, - w: 300, - adm: 'content' - }; - const response = { - seatbid: [ - { - seat: 'foo', - bid: [bid] - } - ] - }; - - let bids = spec.interpretResponse({ body: response }, { bidsMap }); - - expect(bids).to.be.lengthOf(1); - - expect(bids[0].cpm).to.equal(bid.price); - expect(bids[0].width).to.equal(bid.w); - expect(bids[0].height).to.equal(bid.h); - expect(bids[0].ad).to.equal(bid.adm); - expect(bids[0].bidderCode).to.equal(spec.code); - }); - }); -}); diff --git a/test/spec/modules/platformioBidAdapter_spec.js b/test/spec/modules/platformioBidAdapter_spec.js deleted file mode 100644 index 4ef2dc1bba03..000000000000 --- a/test/spec/modules/platformioBidAdapter_spec.js +++ /dev/null @@ -1,335 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/platformioBidAdapter'; -import {getTopWindowLocation} from 'src/utils'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('Platform.io Adapter Tests', function () { - const slotConfigs = [{ - placementCode: '/DfpAccount1/slot1', - bidId: 'bid12345', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '123', - size: '300x250', - bidFloor: '0.001', - ifa: 'IFA', - latitude: '40.712775', - longitude: '-74.005973' - } - }, { - placementCode: '/DfpAccount2/slot2', - bidId: 'bid23456', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '1234', - size: '728x90', - bidFloor: '0.000001', - } - }]; - const nativeSlotConfig = [{ - placementCode: '/DfpAccount1/slot3', - bidId: 'bid12345', - mediaType: 'native', - nativeParams: { - title: { required: true, len: 200 }, - body: {}, - image: { wmin: 100 }, - sponsoredBy: { }, - icon: { } - }, - params: { - pubId: '29521', - placementId: '123', - siteId: '26047' - } - }]; - const videoSlotConfig = [{ - placementCode: '/DfpAccount1/slot4', - bidId: 'bid12345678', - mediaType: 'video', - video: { - skippable: true - }, - params: { - pubId: '29521', - placementId: '1234567', - siteId: '26047', - size: '640x480' - } - }]; - const appSlotConfig = [{ - placementCode: '/DfpAccount1/slot5', - bidId: 'bid12345', - params: { - pubId: '29521', - placementId: '1234', - app: { - id: '1111', - name: 'app name', - bundle: 'io.platform.apps', - storeUrl: 'http://platform.io/apps', - domain: 'platform.io' - } - } - }]; - - it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // site object - expect(ortbRequest.site).to.not.equal(null); - 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.imp).to.have.lengthOf(2); - // device object - expect(ortbRequest.device).to.not.equal(null); - expect(ortbRequest.device.ua).to.equal(navigator.userAgent); - expect(ortbRequest.device.ifa).to.equal('IFA'); - expect(ortbRequest.device.geo.lat).to.equal('40.712775'); - expect(ortbRequest.device.geo.lon).to.equal('-74.005973'); - // slot 1 - expect(ortbRequest.imp[0].tagid).to.equal('123'); - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - expect(ortbRequest.imp[0].bidfloor).to.equal('0.001'); - // slot 2 - expect(ortbRequest.imp[1].tagid).to.equal('1234'); - expect(ortbRequest.imp[1].banner).to.not.equal(null); - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); - expect(ortbRequest.imp[1].bidfloor).to.equal('0.000001'); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - expect(bids).to.have.lengthOf(1); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.ad).to.equal('This is an Ad'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.adId).to.equal('bid12345'); - expect(bid.creativeId).to.equal('bid12345'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verify full passback', function () { - const request = spec.buildRequests(slotConfigs); - const bids = spec.interpretResponse({ body: null }, request) - expect(bids).to.have.lengthOf(0); - }); - - it('Verify Native request', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // native impression - expect(ortbRequest.imp[0].tagid).to.equal('123'); - const nativePart = ortbRequest.imp[0]['native']; - expect(nativePart).to.not.equal(null); - expect(nativePart.ver).to.equal('1.1'); - expect(nativePart.request).to.not.equal(null); - // native request assets - const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request); - expect(nativeRequest).to.not.equal(null); - expect(nativeRequest.assets).to.have.lengthOf(5); - expect(nativeRequest.assets[0].id).to.equal(1); - expect(nativeRequest.assets[1].id).to.equal(2); - expect(nativeRequest.assets[2].id).to.equal(3); - expect(nativeRequest.assets[3].id).to.equal(4); - expect(nativeRequest.assets[4].id).to.equal(5); - expect(nativeRequest.assets[0].required).to.equal(1); - expect(nativeRequest.assets[0].title).to.not.equal(null); - expect(nativeRequest.assets[0].title.len).to.equal(200); - expect(nativeRequest.assets[1].title).to.be.undefined; - expect(nativeRequest.assets[1].data).to.not.equal(null); - expect(nativeRequest.assets[1].data.type).to.equal(2); - expect(nativeRequest.assets[1].data.len).to.equal(200); - expect(nativeRequest.assets[2].required).to.equal(0); - expect(nativeRequest.assets[3].img).to.not.equal(null); - expect(nativeRequest.assets[3].img.wmin).to.equal(50); - expect(nativeRequest.assets[3].img.hmin).to.equal(50); - expect(nativeRequest.assets[3].img.type).to.equal(1); - expect(nativeRequest.assets[4].img).to.not.equal(null); - expect(nativeRequest.assets[4].img.wmin).to.equal(100); - expect(nativeRequest.assets[4].img.hmin).to.equal(150); - expect(nativeRequest.assets[4].img.type).to.equal(3); - }); - - it('Verify Native response', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - const nativeResponse = { - 'native': { - assets: [ - { id: 1, title: { text: 'Ad Title' } }, - { id: 2, data: { value: 'Test description' } }, - { id: 3, data: { value: 'Brand' } }, - { 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/' } - } - }; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - nurl: 'http://rtb.adx1.com/log', - adm: JSON.stringify(nativeResponse) - }] - }], - cur: 'USD', - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - // verify bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.adId).to.equal('bid12345'); - expect(bid.ad).to.be.undefined; - expect(bid.mediaType).to.equal('native'); - const nativeBid = bid['native']; - expect(nativeBid).to.not.equal(null); - expect(nativeBid.title).to.equal('Ad Title'); - expect(nativeBid.sponsoredBy).to.equal('Brand'); - expect(nativeBid.icon.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_icon.png'); - expect(nativeBid.image.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_image.png'); - expect(nativeBid.image.width).to.equal(300); - 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.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('http://rtb.adx1.com/log'); - }); - - it('Verify Video request', function () { - const request = spec.buildRequests(videoSlotConfig); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - 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); - // device object - expect(videoRequest.device).to.not.equal(null); - expect(videoRequest.device.ua).to.equal(navigator.userAgent); - // slot 1 - expect(videoRequest.imp[0].tagid).to.equal('1234567'); - expect(videoRequest.imp[0].video).to.not.equal(null); - expect(videoRequest.imp[0].video.w).to.equal(640); - expect(videoRequest.imp[0].video.h).to.equal(480); - expect(videoRequest.imp[0].banner).to.equal(null); - expect(videoRequest.imp[0].native).to.equal(null); - }); - - it('Verify parse video response', function () { - const request = spec.buildRequests(videoSlotConfig); - const videoRequest = JSON.parse(request.data); - const videoResponse = { - seatbid: [{ - bid: [{ - impid: videoRequest.imp[0].id, - price: 1.90, - adm: 'http://vid.example.com/9876', - crid: '510511_754567308' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: videoResponse }, request); - expect(bids).to.have.lengthOf(1); - // 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.crid).to.equal('510511_754567308'); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(480); - expect(bid.adId).to.equal('bid12345678'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verifies bidder code', function () { - expect(spec.code).to.equal('platformio'); - }); - - it('Verifies supported media types', function () { - expect(spec.supportedMediaTypes).to.have.lengthOf(3); - expect(spec.supportedMediaTypes[0]).to.equal('banner'); - expect(spec.supportedMediaTypes[1]).to.equal('native'); - expect(spec.supportedMediaTypes[2]).to.equal('video'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(slotConfigs[0])).to.equal(true); - expect(spec.isBidRequestValid(slotConfigs[1])).to.equal(true); - expect(spec.isBidRequestValid(nativeSlotConfig[0])).to.equal(true); - expect(spec.isBidRequestValid(videoSlotConfig[0])).to.equal(true); - }); - - it('Verify app requests', function () { - const request = spec.buildRequests(appSlotConfig); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.publisher).to.not.equal(null); - 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('io.platform.apps'); - expect(ortbRequest.app.storeurl).to.equal('http://platform.io/apps'); - expect(ortbRequest.app.domain).to.equal('platform.io'); - }); - - it('Verify GDPR', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'serialized_gpdr_data' - } - }; - const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.user).to.not.equal(null); - expect(ortbRequest.user.ext).to.not.equal(null); - expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data'); - expect(ortbRequest.regs).to.not.equal(null); - expect(ortbRequest.regs.ext).to.not.equal(null); - expect(ortbRequest.regs.ext.gdpr).to.equal(1); - }); -}); diff --git a/test/spec/modules/playgroundxyzBidAdapter_spec.js b/test/spec/modules/playgroundxyzBidAdapter_spec.js deleted file mode 100644 index a90564003f4b..000000000000 --- a/test/spec/modules/playgroundxyzBidAdapter_spec.js +++ /dev/null @@ -1,213 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/playgroundxyzBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; - -const URL = 'https://ads.playground.xyz/host-config/prebid?v=2'; -const GDPR_CONSENT = 'XYZ-CONSENT'; - -describe('playgroundxyzBidAdapter', 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': 'playgroundxyz', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [320, 50]], - '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': 'playgroundxyz', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('sends bid request to ENDPOINT via POST', function () { - let bidRequest = Object.assign([], bidRequests); - - const request = spec.buildRequests(bidRequest); - const data = JSON.parse(request.data); - const banner = data.imp[0].banner; - - expect(Object.keys(data.imp[0].ext)).to.have.members(['appnexus', 'pxyz']); - expect([banner.w, banner.h]).to.deep.equal([300, 250]); - expect(banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); - expect(request.url).to.equal(URL); - expect(request.method).to.equal('POST'); - }); - }) - - describe('interpretResponse', function () { - let response = { - 'id': 'bidd_id', - 'seatbid': [ { - 'bid': [ - { - 'id': '4434762738980910431', - 'impid': '221f2bdc1fbc31', - 'price': 1, - 'adid': '91673066', - 'adm': '', - 'adomain': [ 'pg.xyz' ], - 'iurl': 'http://pgxyz.com/cr?id=91673066', - 'cid': 'c_id', - 'crid': 'c_rid', - 'h': 50, - 'w': 320, - 'ext': { - 'appnexus': { - 'brand_id': 1, - 'auction_id': 1087655594852566000, - 'bidder_id': 2, - 'bid_ad_type': 0 - } - } - } - ], - 'seat': '4321' - }], - 'bidid': '6894227111893743356', - 'cur': 'AUD' - }; - - let bidderRequest = { - 'bidderCode': 'playgroundxyz' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '221f2bdc1fbc31', - 'cpm': 1, - 'creativeId': 91673066, - 'width': 300, - 'height': 50, - 'ad': '', - 'mediaType': 'banner', - 'currency': 'AUD', - 'ttl': 300, - 'netRevenue': true - } - ]; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles nobid response', function () { - const response = undefined; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result.length).to.equal(0); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'playgroundxyz', - 'params': { - 'publisherId': 'PUB_FAKE' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '321db112312as', - 'bidderRequestId': '23edabce2731sd6', - 'auctionId': '12as040790a475' - } - ]; - - it('should not populate GDPR', function () { - let bidRequest = Object.assign([], bidRequests); - const request = spec.buildRequests(bidRequest); - let data = JSON.parse(request.data); - expect(data).to.not.have.property('user'); - expect(data).to.not.have.property('regs'); - }); - - it('should populate GDPR and consent string when consetString is presented but not gdpApplies', function () { - let bidRequest = Object.assign([], bidRequests); - const request = spec.buildRequests(bidRequest, {gdprConsent: {consentString: GDPR_CONSENT}}); - let data = JSON.parse(request.data); - expect(data.regs.ext.gdpr).to.equal(0); - expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); - }); - - it('should populate GDPR and consent string when gdpr is set to true', function () { - let bidRequest = Object.assign([], bidRequests); - const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: true, consentString: GDPR_CONSENT}}); - let data = JSON.parse(request.data); - expect(data.regs.ext.gdpr).to.equal(1); - expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); - }); - - it('should populate GDPR and consent string when gdpr is set to false', function () { - let bidRequest = Object.assign([], bidRequests); - const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: false, consentString: GDPR_CONSENT}}); - let data = JSON.parse(request.data); - expect(data.regs.ext.gdpr).to.equal(0); - expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); - }); - }); - - describe('getUserSyncs', function () { - const syncUrl = '//ib.adnxs.com/getuidnb?https://ads.playground.xyz/usersync?partner=appnexus&uid=$UID'; - - describe('when iframeEnabled is true', function () { - const syncOptions = { - 'iframeEnabled': true - } - it('should return one image type user sync pixel', function () { - let result = spec.getUserSyncs(syncOptions); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image') - expect(result[0].url).to.equal(syncUrl); - }); - }); - - describe('when iframeEnabled is false', function () { - const syncOptions = { - 'iframeEnabled': false - } - it('should return one image type user sync pixel', function () { - let result = spec.getUserSyncs(syncOptions); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image') - expect(result[0].url).to.equal(syncUrl); - }); - }); - }) -}); diff --git a/test/spec/modules/polluxBidAdapter_spec.js b/test/spec/modules/polluxBidAdapter_spec.js deleted file mode 100644 index 22c7f470f83f..000000000000 --- a/test/spec/modules/polluxBidAdapter_spec.js +++ /dev/null @@ -1,207 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/polluxBidAdapter'; -import {utils} from 'src/utils'; -import {newBidder} from 'src/adapters/bidderFactory'; -import { parseQS } from 'src/url'; - -describe('POLLUX Bid Adapter tests', function () { - // ad units setup - const setup_single_bid = [{ - placementCode: 'div-gpt-ad-1460505661587-0', - bidId: '789s6354sfg856', - bidderUrl: '//adn.polluxnetwork.com/prebid/v1', - sizes: [[728, 90], [300, 250]], - params: {zone: '1806,276'} - }]; - const setup_multi_bid = [{ - placementCode: 'div-gpt-ad-1460505661639-0', - bidId: '21fe992ca48d55', - sizes: [[300, 250]], - params: {zone: '1806'} - }, { - placementCode: 'div-gpt-ad-1460505661812-0', - bidId: '23kljh54390534', - sizes: [[728, 90]], - params: {zone: '276'} - }]; - - it('TEST: verify buildRequests no valid bid requests', function () { - let request = spec.buildRequests(false); - expect(request).to.not.equal(null); - expect(request).to.not.have.property('method'); - expect(request).to.not.have.property('url'); - expect(request).to.not.have.property('data'); - request = spec.buildRequests([]); - expect(request).to.not.equal(null); - expect(request).to.not.have.property('method'); - expect(request).to.not.have.property('url'); - expect(request).to.not.have.property('data'); - request = spec.buildRequests({}); - expect(request).to.not.equal(null); - expect(request).to.not.have.property('method'); - expect(request).to.not.have.property('url'); - expect(request).to.not.have.property('data'); - request = spec.buildRequests(null); - expect(request).to.not.equal(null); - expect(request).to.not.have.property('method'); - expect(request).to.not.have.property('url'); - expect(request).to.not.have.property('data'); - }); - - it('TEST: verify buildRequests single bid', function () { - const request = spec.buildRequests(setup_single_bid); - expect(request.method).to.equal('POST'); - const requested_bids = JSON.parse(request.data); - // bids request - expect(requested_bids).to.not.equal(null); - expect(requested_bids).to.have.lengthOf(1); - // bid objects - expect(requested_bids[0]).to.not.equal(null); - expect(requested_bids[0]).to.have.property('bidId'); - expect(requested_bids[0]).to.have.property('sizes'); - expect(requested_bids[0]).to.have.property('zones'); - // bid 0 - expect(requested_bids[0].bidId).to.equal('789s6354sfg856'); - expect(requested_bids[0].sizes).to.not.equal(null); - expect(requested_bids[0].sizes).to.have.lengthOf(2); - expect(requested_bids[0].sizes[0][0]).to.equal(728); - expect(requested_bids[0].sizes[0][1]).to.equal(90); - expect(requested_bids[0].sizes[1][0]).to.equal(300); - expect(requested_bids[0].sizes[1][1]).to.equal(250); - expect(requested_bids[0].zones).to.equal('1806,276'); - }); - - it('TEST: verify buildRequests multi bid', function () { - const request = spec.buildRequests(setup_multi_bid); - expect(request.method).to.equal('POST'); - const requested_bids = JSON.parse(request.data); - // bids request - expect(requested_bids).to.not.equal(null); - expect(requested_bids).to.have.lengthOf(2); - // bid objects - expect(requested_bids[0]).to.not.equal(null); - expect(requested_bids[0]).to.have.property('bidId'); - expect(requested_bids[0]).to.have.property('sizes'); - expect(requested_bids[0]).to.have.property('zones'); - expect(requested_bids[1]).to.not.equal(null); - expect(requested_bids[1]).to.have.property('bidId'); - expect(requested_bids[1]).to.have.property('sizes'); - expect(requested_bids[1]).to.have.property('zones'); - // bid 0 - expect(requested_bids[0].bidId).to.equal('21fe992ca48d55'); - expect(requested_bids[0].sizes).to.not.equal(null); - expect(requested_bids[0].sizes).to.have.lengthOf(1); - expect(requested_bids[0].sizes[0][0]).to.equal(300); - expect(requested_bids[0].sizes[0][1]).to.equal(250); - expect(requested_bids[0].zones).to.equal('1806'); - // bid 1 - expect(requested_bids[1].bidId).to.equal('23kljh54390534'); - expect(requested_bids[1].sizes).to.not.equal(null); - expect(requested_bids[1].sizes).to.have.lengthOf(1); - expect(requested_bids[1].sizes[0][0]).to.equal(728); - expect(requested_bids[1].sizes[0][1]).to.equal(90); - expect(requested_bids[1].zones).to.equal('276'); - }); - - it('TEST: verify interpretResponse empty', function () { - let bids = spec.interpretResponse(false, {}); - expect(bids).to.not.equal(null); - expect(bids).to.have.lengthOf(0); - bids = spec.interpretResponse([], {}); - expect(bids).to.not.equal(null); - expect(bids).to.have.lengthOf(0); - bids = spec.interpretResponse({}, {}); - expect(bids).to.not.equal(null); - expect(bids).to.have.lengthOf(0); - bids = spec.interpretResponse(null, {}); - expect(bids).to.not.equal(null); - expect(bids).to.have.lengthOf(0); - }); - - it('TEST: verify interpretResponse ad_type url', function () { - const serverResponse = { - body: [ - { - bidId: '789s6354sfg856', - cpm: '2.15', - width: '728', - height: '90', - ad: 'http://adn.polluxnetwork.com/zone/276?_plx_prebid=1&_plx_campaign=1125', - ad_type: 'url', - creativeId: '1125', - referrer: 'http://www.example.com' - } - ] - }; - const bids = spec.interpretResponse(serverResponse, {}); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('789s6354sfg856'); - expect(bids[0].cpm).to.equal(2.15); - expect(bids[0].width).to.equal(728); - expect(bids[0].height).to.equal(90); - expect(bids[0].ttl).to.equal(3600); - expect(bids[0].creativeId).to.equal('1125'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].currency).to.equal('EUR'); - expect(bids[0].referrer).to.equal('http://www.example.com'); - expect(bids[0].adUrl).to.equal('http://adn.polluxnetwork.com/zone/276?_plx_prebid=1&_plx_campaign=1125'); - expect(bids[0]).to.not.have.property('ad'); - }); - - it('TEST: verify interpretResponse ad_type html', function () { - const serverResponse = { - body: [ - { - bidId: '789s6354sfg856', - cpm: '2.15', - width: '728', - height: '90', - ad: '

I am an ad

', - ad_type: 'html', - creativeId: '1125' - } - ] - }; - const bids = spec.interpretResponse(serverResponse, {}); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('789s6354sfg856'); - expect(bids[0].cpm).to.equal(2.15); - expect(bids[0].width).to.equal(728); - expect(bids[0].height).to.equal(90); - expect(bids[0].ttl).to.equal(3600); - expect(bids[0].creativeId).to.equal('1125'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].currency).to.equal('EUR'); - expect(bids[0]).to.not.have.property('referrer'); - expect(bids[0]).to.not.have.property('adUrl'); - expect(bids[0].ad).to.equal('

I am an ad

'); - }); - - it('TEST: verify url and query params', function () { - const URL = require('url-parse'); - const request = spec.buildRequests(setup_single_bid); - const parsedUrl = new URL('https:' + request.url); - expect(parsedUrl.origin).to.equal('https://adn.polluxnetwork.com'); - expect(parsedUrl.pathname).to.equal('/prebid/v1'); - expect(parsedUrl).to.have.property('query'); - const parsedQuery = parseQS(parsedUrl.query); - expect(parsedQuery).to.have.property('domain').and.to.have.length.above(1); - }); - - it('TEST: verify isBidRequestValid', function () { - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({params: {}})).to.equal(false); - expect(spec.isBidRequestValid(setup_single_bid[0])).to.equal(true); - expect(spec.isBidRequestValid(setup_multi_bid[0])).to.equal(true); - expect(spec.isBidRequestValid(setup_multi_bid[1])).to.equal(true); - }); - - it('TEST: verify bidder code', function () { - expect(spec.code).to.equal('pollux'); - }); - - it('TEST: verify bidder aliases', function () { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.equal('plx'); - }); -}); diff --git a/test/spec/modules/polymorphBidAdapter_spec.js b/test/spec/modules/polymorphBidAdapter_spec.js deleted file mode 100644 index 6fd4bd902882..000000000000 --- a/test/spec/modules/polymorphBidAdapter_spec.js +++ /dev/null @@ -1,219 +0,0 @@ -import { expect } from 'chai'; -import { polymorphAdapterSpec } from 'modules/polymorphBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const BIDDER_CODE = 'polymorph'; -const ENDPOINT_URL = '//api.adsnative.com/v1/ad-template.json'; -const PLACEMENT_ID = 'ping'; -const NETWORK_KEY = 'abcd1234'; -const WIDGET_ID = 'xyz'; -const CATEGORIES = 'IAB1,IAB2'; - -const spec = newBidder(polymorphAdapterSpec).getSpec(); - -const bidRequests = [{ - 'bidder': BIDDER_CODE, - 'params': { - 'placementId': PLACEMENT_ID - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', -}, -{ - 'bidder': BIDDER_CODE, - 'params': { - 'placementId': PLACEMENT_ID, - 'defaultWidth': 300, - 'defaultHeight': 600, - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[700, 250], [300, 600]], - 'bidId': '30b31c1838de1d', - 'bidderRequestId': '22edbae2733bf7', - 'auctionId': '1d1a030790a476', -}, -{ - 'bidder': BIDDER_CODE, - 'params': { - 'network_key': NETWORK_KEY, - 'widget_id': WIDGET_ID, - 'cat': CATEGORIES - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[700, 250], [300, 600]], - 'bidId': '30b31c1838de1f', - 'bidderRequestId': '22edbae2733bf7', - 'auctionId': '1d1a030790a476', -}]; - -describe('Polymorph adapter test', function () { - describe('.code', function () { - it('should return a bidder code of polymorph', function () { - expect(spec.code).to.eql(BIDDER_CODE); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidRequests[0])).to.equal(true); - }); - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidRequests[2])).to.equal(true); - }); - - it('should return false if req has no placementId', function () { - const invalidBidRequest = { - bidder: BIDDER_CODE, - params: { - someKey: 'abc123' - } - }; - expect(spec.isBidRequestValid(invalidBidRequest)).to.eql(false); - }); - - it('should return false if req has wrong bidder code', function () { - const invalidBidRequest = { - bidder: 'something', - params: { - someKey: 'abc123' - } - }; - expect(spec.isBidRequestValid(invalidBidRequest)).to.eql(false); - }); - }); - - describe('buildRequests', function () { - it('payload test', function () { - const requests = spec.buildRequests(bidRequests); - var payload1 = {}; - requests[0].data.replace(/([^=&]+)=([^&]*)/g, function(m, key, value) { - payload1[decodeURIComponent(key)] = decodeURIComponent(value); - }); - expect(payload1.ref).to.not.be.undefined; - expect(payload1.url).to.not.be.undefined; - expect(payload1.hb).to.equal('1'); - expect(payload1.hb_source).to.equal('prebid'); - expect(payload1.zid).to.equal(PLACEMENT_ID); - expect(payload1.sizes).to.equal('300,250,300,600'); - expect(payload1.bid_id).to.equal('30b31c1838de1e'); - - var payload2 = {}; - requests[1].data.replace(/([^=&]+)=([^&]*)/g, function(m, key, value) { - payload2[decodeURIComponent(key)] = decodeURIComponent(value); - }); - expect(payload2.ref).to.not.be.undefined; - expect(payload2.url).to.not.be.undefined; - expect(payload2.hb).to.equal('1'); - expect(payload2.hb_source).to.equal('prebid'); - expect(payload2.zid).to.equal(PLACEMENT_ID); - expect(payload2.sizes).to.equal('700,250,300,600'); - expect(payload2.bid_id).to.equal('30b31c1838de1d'); - - var payload3 = {}; - requests[2].data.replace(/([^=&]+)=([^&]*)/g, function(m, key, value) { - payload3[decodeURIComponent(key)] = decodeURIComponent(value); - }); - expect(payload3.ref).to.not.be.undefined; - expect(payload3.url).to.not.be.undefined; - expect(payload3.hb).to.equal('1'); - expect(payload3.hb_source).to.equal('prebid'); - expect(payload3.network_key).to.equal(NETWORK_KEY); - expect(payload3.widget_id).to.equal(WIDGET_ID); - expect(payload3.cat).to.equal(CATEGORIES); - expect(payload3.sizes).to.equal('700,250,300,600'); - expect(payload3.bid_id).to.equal('30b31c1838de1f'); - }); - - it('sends bid request to ENDPOINT via GET', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].url).to.equal(ENDPOINT_URL); - expect(requests[0].method).to.equal('GET'); - }); - }); - - describe('interpretResponse', function () { - const response = { - body: { - 'status': 'OK', - 'crid': '5ISP4995', - 'ecpm': 10, - 'ad': { - 'html': '
', - 'height': 250, - 'width': 300 - } - } - }; - - const response2 = { - body: { - 'status': 'OK', - 'ecpm': 10, - 'html': '', - 'ads': [{ - 'crid': '5ISP4995', - 'ad': { - 'html': '
' - } - }, - { - 'crid': '5ISP4996', - 'ad': { - 'html': '
' - } - }] - } - }; - - it('should get correct bid response', function () { - const body = response.body; - const expectedResponse = [{ - requestId: bidRequests[0].bidId, - cpm: body.ecpm, - width: body.ad.width, - height: body.ad.height, - ad: body.ad.html, - ttl: 3600, - creativeId: body.crid, - netRevenue: false, - currency: 'USD', - mediaType: 'banner' - }]; - - let result = spec.interpretResponse(response, { 'bidderRequest': bidRequests[0] }); - expect(result).to.deep.equal(expectedResponse); - }); - - it('widget use case', function () { - const body = response2.body; - const expectedResponse = [ - { - requestId: bidRequests[1].bidId, - cpm: body.ecpm, - width: 300, - height: 600, - ad: body.html, - ttl: 3600, - creativeId: body.ads[0].crid, - netRevenue: false, - currency: 'USD', - mediaType: 'banner' - } - ]; - - let result = spec.interpretResponse(response2, { 'bidderRequest': bidRequests[1] }); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles nobid responses', function () { - let response = []; - - let result = spec.interpretResponse(response, { 'bidderRequest': bidRequests[0] }); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index c198502d4b3c..f685103b5cb1 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -13,7 +13,7 @@ let CONFIG = { bidders: ['appnexus'], timeout: 1000, cacheMarkup: 2, - endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' }; const REQUEST = { @@ -165,67 +165,6 @@ const OUTSTREAM_VIDEO_REQUEST = { let BID_REQUESTS; -const RESPONSE = { - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'status': 'OK', - 'bidder_status': [ - { - 'bidder': 'appnexus', - 'response_time_ms': 52, - 'num_bids': 1 - } - ], - 'bids': [ - { - 'bid_id': '123', - 'code': 'div-gpt-ad-1460505748561-0', - 'creative_id': '29681110', - 'bidder': 'appnexus', - 'price': 0.5, - 'adm': '', - 'width': 300, - 'height': 250, - 'deal_id': 'test-dealid', - 'ad_server_targeting': { - 'foo': 'bar' - }, - 'cache_id': '7654321', - 'cache_url': 'http://www.test.com/cache?uuid=7654321', - } - ] -}; - -const VIDEO_RESPONSE = { - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'status': 'OK', - 'bidder_status': [ - { - 'bidder': 'appnexus', - 'response_time_ms': 52, - 'num_bids': 1 - } - ], - 'bids': [ - { - 'bid_id': '123', - 'code': 'div-gpt-ad-1460505748561-0', - 'creative_id': '29681110', - 'bidder': 'appnexus', - 'price': 0.5, - 'adm': '', - 'width': 300, - 'height': 250, - 'deal_id': 'test-dealid', - 'ad_server_targeting': { - 'foo': 'bar' - }, - 'media_type': 'video', - 'cache_id': 'video_cache_id', - 'cache_url': 'video_cache_url', - } - ] -}; - const RESPONSE_NO_BID_NO_UNIT = { 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', 'status': 'OK', @@ -301,26 +240,6 @@ const RESPONSE_NO_PBS_COOKIE = { }] }; -const RESPONSE_NO_PBS_COOKIE_ERROR = { - 'tid': '882fe33e-2981-4257-bd44-bd3b0394545f', - 'status': 'no_cookie', - 'bidder_status': [{ - 'bidder': 'rubicon', - 'no_cookie': true, - 'usersync': { - 'url': 'https://pixel.rubiconproject.com/exchange/sync.php?p=prebid', - 'type': 'jsonp' - } - }, { - 'bidder': 'pubmatic', - 'no_cookie': true, - 'usersync': { - 'url': '', - 'type': 'iframe' - } - }] -}; - const RESPONSE_OPENRTB = { 'id': 'c7dcf14f', 'seatbid': [ @@ -336,6 +255,7 @@ const RESPONSE_OPENRTB = { 'iurl': 'http://lax1-ib.adnxs.com/cr?id=2968111', 'cid': '958', 'crid': '2968111', + 'dealid': 'test-dealid', 'w': 300, 'h': 250, 'ext': { @@ -375,6 +295,7 @@ const RESPONSE_OPENRTB_VIDEO = { iurl: 'http://lax1-ib.adnxs.com/cr?id=81877115', cid: '3535', crid: '81877115', + dealid: 'test-dealid', w: 1, h: 1, ext: { @@ -502,15 +423,6 @@ const RESPONSE_OPENRTB_NATIVE = { ] }; -const RESPONSE_UNSUPPORTED_BIDDER = { - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'status': 'OK', - 'bidder_status': [{ - 'bidder': '33Across', - 'error': 'Unsupported bidder' - }] -}; - describe('S2S Adapter', function () { let adapter, addBidResponse = sinon.spy(), @@ -552,7 +464,10 @@ describe('S2S Adapter', function () { 'auctionStart': 1510852447530, 'timeout': 5000, 'src': 's2s', - 'doneCbCallCount': 0 + 'doneCbCallCount': 0, + 'refererInfo': { + 'referer': 'http://mytestpage.com' + } } ]; }); @@ -594,15 +509,6 @@ describe('S2S Adapter', function () { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); - it('exists converts types', function () { - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); - expect(requestBid).to.have.property('cache_markup', 2); - expect(requestBid.ad_units[0].bids[0].params.placementId).to.exist.and.to.be.a('number'); - expect(requestBid.ad_units[0].bids[0].params.member).to.exist.and.to.be.a('string'); - }); - describe('gdpr tests', function () { afterEach(function () { config.resetConfig(); @@ -805,16 +711,6 @@ describe('S2S Adapter', function () { }); }); - it('sets invalid cacheMarkup value to 0', function () { - const s2sConfig = Object.assign({}, CONFIG, { - cacheMarkup: 999 - }); - config.setConfig({ s2sConfig: s2sConfig }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); - expect(requestBid).to.have.property('cache_markup', 0); - }); - it('adds digitrust id is present and user is not optout', function () { let ortb2Config = utils.deepClone(CONFIG); ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; @@ -1086,27 +982,6 @@ describe('S2S Adapter', function () { key: 'fizz', value: ['buzz'] }]); - - config.resetConfig(); - const oldS2sConfig = Object.assign({}, CONFIG); - config.setConfig({ s2sConfig: oldS2sConfig }); - - const myRequest2 = utils.deepClone(REQUEST); - myRequest2.ad_units[0].bids[0].params.keywords = { - foo: ['bar', 'baz'], - fizz: ['buzz'] - }; - - adapter.callBids(myRequest2, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid2 = JSON.parse(requests[1].requestBody); - - expect(requestBid2.ad_units[0].bids[0].params.keywords).to.exist.and.to.deep.equal([{ - key: 'foo', - value: ['bar', 'baz'] - }, { - key: 'fizz', - value: ['buzz'] - }]); }); it('adds limit to the cookie_sync request if userSyncLimit is greater than 0', function () { @@ -1442,47 +1317,6 @@ describe('S2S Adapter', function () { }); // TODO: test dependent on pbjs_api_spec. Needs to be isolated - it('registers bids and calls BIDDER_DONE', function () { - server.respondWith(JSON.stringify(RESPONSE)); - - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - sinon.assert.calledOnce(events.emit); - const event = events.emit.firstCall.args; - expect(event[0]).to.equal(CONSTANTS.EVENTS.BIDDER_DONE); - expect(event[1].bids[0]).to.have.property('serverResponseTimeMs', 52); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('cpm', 0.5); - expect(response).to.have.property('requestId', '123'); - expect(response).to.not.have.property('videoCacheKey'); - expect(response).to.have.property('cache_id', '7654321'); - expect(response).to.have.property('cache_url', 'http://www.test.com/cache?uuid=7654321'); - expect(response).to.not.have.property('vastUrl'); - }); - - it('registers video bids', function () { - server.respondWith(JSON.stringify(VIDEO_RESPONSE)); - - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('cpm', 0.5); - expect(response).to.have.property('requestId', '123'); - expect(response).to.have.property('videoCacheKey', 'video_cache_id'); - expect(response).to.have.property('cache_id', 'video_cache_id'); - expect(response).to.have.property('cache_url', 'video_cache_url'); - expect(response).to.have.property('vastUrl', 'video_cache_url'); - }); - it('does not call addBidResponse and calls done when ad unit not set', function () { server.respondWith(JSON.stringify(RESPONSE_NO_BID_NO_UNIT)); @@ -1517,7 +1351,7 @@ describe('S2S Adapter', function () { }); it('registers successful bids and calls done when there are less bids than requests', function () { - server.respondWith(JSON.stringify(RESPONSE)); + server.respondWith(JSON.stringify(RESPONSE_OPENRTB)); config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); @@ -1535,7 +1369,7 @@ describe('S2S Adapter', function () { }); it('should have dealId in bidObject', function () { - server.respondWith(JSON.stringify(RESPONSE)); + server.respondWith(JSON.stringify(RESPONSE_OPENRTB)); config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); @@ -1544,12 +1378,47 @@ describe('S2S Adapter', function () { expect(response).to.have.property('dealId', 'test-dealid'); }); - it('should pass through default adserverTargeting if present in bidObject', function () { - server.respondWith(JSON.stringify(RESPONSE)); + it('should pass through default adserverTargeting if present in bidObject for video request', function () { + config.setConfig({s2sConfig: CONFIG}); + const cacheResponse = utils.deepClone(RESPONSE_OPENRTB); + const targetingTestData = { + hb_cache_path: '/cache', + hb_cache_host: 'prebid-cache.testurl.com' + }; + + cacheResponse.seatbid.forEach(item => { + item.bid[0].ext.prebid.targeting = targetingTestData + }); + server.respondWith(JSON.stringify(cacheResponse)); + adapter.callBids(VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('adserverTargeting'); + expect(response.adserverTargeting).to.deep.equal({ + 'hb_cache_path': '/cache', + 'hb_cache_host': 'prebid-cache.testurl.com' + }); + }); + + it('should pass through default adserverTargeting if present in bidObject for banner request', function () { + const cacheResponse = utils.deepClone(RESPONSE_OPENRTB); + + const targetingTestData = { + 'foo': 'bar' + }; + + cacheResponse.seatbid.forEach(item => { + item.bid[0].ext.prebid.targeting = targetingTestData + }); + + server.respondWith(JSON.stringify(cacheResponse)); config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); server.respond(); + sinon.assert.calledOnce(addBidResponse); const response = addBidResponse.firstCall.args[1]; expect(response).to.have.property('adserverTargeting').that.deep.equals({ 'foo': 'bar' }); }); @@ -1591,25 +1460,6 @@ describe('S2S Adapter', function () { adapterManager.getBidAdapter.restore(); }); - it('registers bid responses when server requests cookie sync', function () { - server.respondWith(JSON.stringify(RESPONSE_NO_PBS_COOKIE)); - - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const ad_unit_code = addBidResponse.firstCall.args[0]; - expect(ad_unit_code).to.equal('div-gpt-ad-1460505748561-0'); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('source', 's2s'); - - const bid_request_passed = addBidResponse.firstCall.args[1]; - expect(bid_request_passed).to.have.property('requestId', '123'); - }); - it('handles OpenRTB responses and call BIDDER_DONE', function () { const s2sConfig = Object.assign({}, CONFIG, { endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' @@ -1631,6 +1481,8 @@ describe('S2S Adapter', function () { expect(response).to.have.property('bidderCode', 'appnexus'); expect(response).to.have.property('requestId', '123'); expect(response).to.have.property('cpm', 0.5); + expect(response).to.not.have.property('vastUrl'); + expect(response).to.not.have.property('videoCacheKey'); }); it('handles OpenRTB video responses', function () { @@ -1758,25 +1610,6 @@ describe('S2S Adapter', function () { utils.getBidRequest.restore(); }); - - it('should log warning for unsupported bidder', function () { - server.respondWith(JSON.stringify(RESPONSE_UNSUPPORTED_BIDDER)); - - const s2sConfig = Object.assign({}, CONFIG, { - bidders: ['33Across'] - }); - - const _config = { - s2sConfig: s2sConfig, - }; - - config.setConfig(_config); - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - - sinon.assert.calledOnce(logWarnSpy); - }); }); describe('s2sConfig', function () { @@ -1803,7 +1636,7 @@ describe('S2S Adapter', function () { bidders: ['appnexus'], timeout: 1000, adapter: 'prebidServer', - endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' }; config.setConfig({ s2sConfig: options }); @@ -1816,7 +1649,7 @@ describe('S2S Adapter', function () { enabled: true, timeout: 1000, adapter: 's2s', - endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' }; config.setConfig({ s2sConfig: options }); @@ -1919,7 +1752,7 @@ describe('S2S Adapter', function () { bidders: ['rubicon'], defaultVendor: 'rubicon', endpoint: '//prebid-server.rubiconproject.com/openrtb2/auction', - syncEndpoint: '//prebid-server.rubiconproject.com/cookie_sync' + syncEndpoint: '//prebid-server.rubiconproject.com/cookie_sync', }) }); diff --git a/test/spec/modules/projectLimeLightBidAdapter_spec.js b/test/spec/modules/projectLimeLightBidAdapter_spec.js index 434b3fbccb52..f51e1188b730 100644 --- a/test/spec/modules/projectLimeLightBidAdapter_spec.js +++ b/test/spec/modules/projectLimeLightBidAdapter_spec.js @@ -28,7 +28,7 @@ describe('ProjectLimeLightAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//ads.project-limelight.com/hb'); + expect(serverRequest.url).to.equal('https://ads.project-limelight.com/hb'); }); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; diff --git a/test/spec/modules/pubnxBidAdapter_spec.js b/test/spec/modules/pubnxBidAdapter_spec.js deleted file mode 100644 index 002922fa066c..000000000000 --- a/test/spec/modules/pubnxBidAdapter_spec.js +++ /dev/null @@ -1,112 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/pubnxBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const BASE_URI = '//hb.pubnxserv.com/vzhbidder/bid?'; - -describe('PubNXAdapter', 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': 'pubnx', - 'params': { - 'placementId': 'PNX-HB-G396432V4809F3' - }, - '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': 'pubnx', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(BASE_URI); - expect(request.method).to.equal('POST'); - }); - }); - - describe('interpretResponse', function () { - let response = { - 'vzhPlacementId': 'PNX-HB-G396432V4809F3', - 'bid': '76021e56-adaf-4114-b68d-ccacd1b3e551_1', - 'adWidth': '300', - 'adHeight': '250', - 'cpm': '0.16312590000000002', - 'ad': '', - 'slotBidId': '44b3fcfd24aa93', - 'nurl': '', - 'statusText': 'Success' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '44b3fcfd24aa93', - 'cpm': 0.16312590000000002, - 'width': 300, - 'height': 250, - 'netRevenue': true, - 'mediaType': 'banner', - 'currency': 'USD', - 'dealId': null, - 'creativeId': null, - 'ttl': 300, - 'ad': '' - } - ]; - let bidderRequest; - let result = spec.interpretResponse({body: response}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - expect(result[0].cpm).to.not.equal(null); - }); - - it('handles nobid responses', function () { - let response = { - 'vzhPlacementId': 'PNX-HB-G396432V4809F3', - 'slotBidId': 'f00412ac86b79', - 'statusText': 'NO_BIDS' - }; - let bidderRequest; - - let result = spec.interpretResponse({body: response}); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index 6ab05a0a0010..80cf00d2ff83 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -42,7 +42,7 @@ describe('PulsePoint Adapter Tests', function () { ct: 't10000', app: { bundle: 'com.pulsepoint.apps', - storeUrl: 'http://pulsepoint.com/apps', + storeUrl: 'https://pulsepoint.com/apps', domain: 'pulsepoint.com', } } @@ -318,10 +318,10 @@ describe('PulsePoint Adapter Tests', function () { assets: [ { title: { text: 'Ad Title' } }, { data: { type: 1, value: 'Sponsored By: Brand' } }, - { img: { type: 3, url: 'http://images.cdn.brand.com/123' } } + { img: { type: 3, url: 'https://images.cdn.brand.com/123' } } ], - link: { url: 'http://brand.clickme.com/' }, - imptrackers: ['http://imp1.trackme.com/', 'http://imp1.contextweb.com/'] + link: { url: 'https://brand.clickme.com/' }, + imptrackers: ['https://imp1.trackme.com/', 'https://imp1.contextweb.com/'] } }; const ortbResponse = { @@ -344,11 +344,11 @@ describe('PulsePoint Adapter Tests', function () { expect(nativeBid).to.not.equal(null); expect(nativeBid.title).to.equal('Ad Title'); expect(nativeBid.sponsoredBy).to.equal('Sponsored By: Brand'); - expect(nativeBid.image).to.equal('http://images.cdn.brand.com/123'); - expect(nativeBid.clickUrl).to.equal(encodeURIComponent('http://brand.clickme.com/')); + expect(nativeBid.image).to.equal('https://images.cdn.brand.com/123'); + expect(nativeBid.clickUrl).to.equal(encodeURIComponent('https://brand.clickme.com/')); expect(nativeBid.impressionTrackers).to.have.lengthOf(2); - expect(nativeBid.impressionTrackers[0]).to.equal('http://imp1.trackme.com/'); - expect(nativeBid.impressionTrackers[1]).to.equal('http://imp1.contextweb.com/'); + expect(nativeBid.impressionTrackers[0]).to.equal('https://imp1.trackme.com/'); + expect(nativeBid.impressionTrackers[1]).to.equal('https://imp1.contextweb.com/'); }); it('Verifies bidder code', function () { @@ -406,7 +406,7 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.app.publisher).to.not.equal(null); expect(ortbRequest.app.publisher.id).to.equal('p10000'); expect(ortbRequest.app.bundle).to.equal('com.pulsepoint.apps'); - expect(ortbRequest.app.storeurl).to.equal('http://pulsepoint.com/apps'); + expect(ortbRequest.app.storeurl).to.equal('https://pulsepoint.com/apps'); expect(ortbRequest.app.domain).to.equal('pulsepoint.com'); }); @@ -475,7 +475,7 @@ describe('PulsePoint Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - adm: 'http://pulsepoint.video.mp4' + adm: 'https//pulsepoint.video.mp4' }] }] }; @@ -559,7 +559,7 @@ describe('PulsePoint Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - adm: 'http://pulsepoint.video.mp4', + adm: 'https//pulsepoint.video.mp4', ext: { outstream: { type: 'Inline', @@ -567,7 +567,7 @@ describe('PulsePoint Adapter Tests', function () { text: 'ADVERTISEMENT', skipaftersec: 5 }, - rendererUrl: 'http://tag.contextweb.com/hb-outstr-renderer.js' + rendererUrl: 'https://tag.contextweb.com/hb-outstr-renderer.js' } } }] @@ -577,7 +577,7 @@ describe('PulsePoint Adapter Tests', function () { const bid = bids[0]; expect(bid.cpm).to.equal(1.25); expect(bid.renderer).to.not.be.null; - expect(bid.renderer.url).to.equal('http://tag.contextweb.com/hb-outstr-renderer.js'); + expect(bid.renderer.url).to.equal('https://tag.contextweb.com/hb-outstr-renderer.js'); expect(bid.renderer.getConfig()).to.not.be.null; expect(bid.renderer.getConfig().defaultOptions).to.eql(ortbResponse.seatbid[0].bid[0].ext.outstream.config); expect(bid.renderer.getConfig().rendererOptions).to.eql(outstreamSlotConfig[0].renderer.options); diff --git a/test/spec/modules/quantumBidAdapter_spec.js b/test/spec/modules/quantumBidAdapter_spec.js index d14d24ebfe10..ba020fbc5360 100644 --- a/test/spec/modules/quantumBidAdapter_spec.js +++ b/test/spec/modules/quantumBidAdapter_spec.js @@ -2,7 +2,7 @@ import { expect } from 'chai' import { spec } from 'modules/quantumBidAdapter' import { newBidder } from 'src/adapters/bidderFactory' -const ENDPOINT = '//s.sspqns.com/hb' +const ENDPOINT = 'https://s.sspqns.com/hb' const REQUEST = { 'bidder': 'quantum', 'sizes': [[300, 250]], @@ -27,10 +27,10 @@ const serverResponse = { '' ], 'is_fallback': false, - 'nurl': 'http://s.sspqns.com/imp/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4/', + 'nurl': 'https://s.sspqns.com/imp/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4/', 'native': { 'link': { - 'url': 'http://s.sspqns.com/click/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4///', + 'url': 'https://s.sspqns.com/click/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4///', 'clicktrackers': ['https://elasticad.net'] }, 'assets': [ @@ -46,7 +46,7 @@ const serverResponse = { 'img': { 'w': 15, 'h': 15, - 'url': 'http://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-15x15' + 'url': 'https://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-15x15' } }, { @@ -61,19 +61,19 @@ const serverResponse = { 'img': { 'w': 500, 'h': 500, - 'url': 'http://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-500x500' + 'url': 'https://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-500x500' } }, { 'id': 6, 'video': { - 'vasttag': 'http://elasticad.net/vast.xml' + 'vasttag': 'https://elasticad.net/vast.xml' } }, { 'id': 2001, 'data': { - 'value': 'http://elasticad.net' + 'value': 'https://elasticad.net' } }, { @@ -97,7 +97,7 @@ const serverResponse = { { 'id': 2003, 'data': { - 'value': 'http://elasticad.net' + 'value': 'https://elasticad.net' } }, { @@ -115,7 +115,7 @@ const serverResponse = { { 'id': 2006, 'data': { - 'value': 'http://elasticad.net/vast.xml' + 'value': 'https://elasticad.net/vast.xml' } }, { @@ -129,7 +129,7 @@ const serverResponse = { 'ver': '1.1' }, 'sync': [ - 'http://match.adsrvr.org/track/cmb/generic?ttd_pid=s6e8ued&ttd_tpi=1' + 'https://match.adsrvr.org/track/cmb/generic?ttd_pid=s6e8ued&ttd_tpi=1' ] } @@ -139,10 +139,10 @@ const nativeServerResponse = { '' ], 'is_fallback': false, - 'nurl': 'http://s.sspqns.com/imp/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4/', + 'nurl': 'https://s.sspqns.com/imp/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4/', 'native': { 'link': { - 'url': 'http://s.sspqns.com/click/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4///' + 'url': 'https://s.sspqns.com/click/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4///' }, 'assets': [ { @@ -157,7 +157,7 @@ const nativeServerResponse = { 'img': { 'w': 15, 'h': 15, - 'url': 'http://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-15x15' + 'url': 'https://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-15x15' } }, { @@ -172,7 +172,7 @@ const nativeServerResponse = { 'img': { 'w': 500, 'h': 500, - 'url': 'http://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-500x500' + 'url': 'https://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-500x500' } }, { @@ -191,7 +191,7 @@ const nativeServerResponse = { { 'id': 2003, 'data': { - 'value': 'http://elasticad.net' + 'value': 'https://elasticad.net' } } ], @@ -199,7 +199,7 @@ const nativeServerResponse = { 'ver': '1.1' }, 'sync': [ - 'http://match.adsrvr.org/track/cmb/generic?ttd_pid=s6e8ued&ttd_tpi=1' + 'https://match.adsrvr.org/track/cmb/generic?ttd_pid=s6e8ued&ttd_tpi=1' ] } diff --git a/test/spec/modules/rdnBidAdapter_spec.js b/test/spec/modules/rdnBidAdapter_spec.js deleted file mode 100644 index 8f53502bc449..000000000000 --- a/test/spec/modules/rdnBidAdapter_spec.js +++ /dev/null @@ -1,156 +0,0 @@ -import { expect } from 'chai' -import * as utils from 'src/utils' -import { spec } from 'modules/rdnBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' -import {config} from '../../../src/config'; - -describe('rdnBidAdapter', function() { - const adapter = newBidder(spec); - const ENDPOINT = 'https://s-bid.rmp.rakuten.co.jp/h'; - let sandbox; - - beforeEach(function() { - config.resetConfig(); - }); - - afterEach(function () { - config.resetConfig(); - }); - - describe('inherited functions', () => { - it('exists and is a function', () => { - expect(adapter.callBids).to.exist.and.to.be.a('function') - }) - }); - - describe('isBidRequestValid', () => { - let bid = { - bidder: 'rdn', - params: { - adSpotId: '56789' - } - }; - - 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', () => { - bid.params.adSpotId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false) - }); - - it('should return false when required params are not passed', () => { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false) - }) - }); - - describe('buildRequests', () => { - const bidRequests = [ - { - // banner - params: { - adSpotId: '58278' - } - } - ]; - - it('sends bid request to ENDPOINT via GET', () => { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('GET') - }) - - it('allows url override', () => { - config.setConfig({ - rdn: { - endpoint: '//test.rakuten.com' - } - }); - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal('//test.rakuten.com'); - }) - }); - - describe('interpretResponse', () => { - const bidRequests = { - banner: { - method: 'GET', - url: '', - data: { - t: '56789', - s: 'https', - ua: - 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Mobile Safari/537.36', - l: 'ja', - d: 'examples.com', - tp: 'https://examples.com/foo/fuga', - pp: 'https://examples.com/hoge/muga' - } - } - }; - - const serverResponse = { - noAd: [], - noAd2: { - requestId: 'biequa9oaph4we' - }, - banner: { - requestId: 'biequa9oaph4we', - cpm: 37.66, - width: 300, - height: 250, - creativeId: 140281, - dealId: 'phoh3pad-ai4ah-xoh7x-ahk7cheasae3oh', - currency: 'JPY', - netRevenue: 300, - ttl: 3000, - referrer: utils.getTopWindowUrl(), - ad: '' - } - }; - - it('handles nobid responses', () => { - const result = spec.interpretResponse( - { body: serverResponse.noAd }, - bidRequests.banner - ); - expect(result.length).to.equal(0); - - const result2 = spec.interpretResponse( - { body: serverResponse.noAd2 }, - bidRequests.banner - ); - expect(result2.length).to.equal(0); - }) - }); - describe('spec.getUserSyncs', function () { - const syncResponse = [{ - body: { - request_id: 'biequa9oaph4we', - sync_urls: ['https://rdn1.test/sync?uid=9876543210', 'https://rdn2.test/sync?uid=9876543210'] - } - }]; - const nosyncResponse = [{ - body: { - request_id: 'biequa9oaph4we', - sync_urls: [] - } - }]; - let syncOptions - beforeEach(function () { - syncOptions = { - pixelEnabled: true - } - }); - it('sucess usersync url', function () { - const result = []; - result.push({type: 'image', url: 'https://rdn1.test/sync?uid=9876543210'}); - result.push({type: 'image', url: 'https://rdn2.test/sync?uid=9876543210'}); - expect(spec.getUserSyncs(syncOptions, syncResponse)).to.deep.equal(result); - }); - }); -}); diff --git a/test/spec/modules/readpeakBidAdapter_spec.js b/test/spec/modules/readpeakBidAdapter_spec.js deleted file mode 100644 index 5fcdf9b5836c..000000000000 --- a/test/spec/modules/readpeakBidAdapter_spec.js +++ /dev/null @@ -1,207 +0,0 @@ -import { expect } from 'chai'; -import { spec, ENDPOINT } from 'modules/readpeakBidAdapter'; -import * as utils from 'src/utils'; -import {config} from 'src/config'; - -describe('ReadPeakAdapter', function () { - let bidRequest - let serverResponse - let serverRequest - - beforeEach(function () { - bidRequest = { - bidder: 'readpeak', - nativeParams: { - title: { required: true, len: 200 }, - image: { wmin: 100 }, - sponsoredBy: { }, - body: {required: false}, - cta: {required: false}, - }, - params: { - bidfloor: 5.00, - publisherId: '11bc5dd5-7421-4dd8-c926-40fa653bec76', - siteId: '11bc5dd5-7421-4dd8-c926-40fa653bec77' - }, - bidId: '2ffb201a808da7', - bidderRequestId: '178e34bad3658f', - auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' - } - serverResponse = { - id: bidRequest.bidderRequestId, - cur: 'USD', - seatbid: [{ - bid: [{ - id: 'bidRequest.bidId', - impid: bidRequest.bidId, - price: 0.12, - cid: '12', - crid: '123', - adomain: ['readpeak.com'], - adm: { - assets: [{ - id: 1, - title: { - text: 'Title', - } - }, - { - id: 3, - data: { - type: 1, - value: 'Brand Name', - }, - }, - { - id: 4, - data: { - type: 2, - value: 'Description', - }, - }, - { - id: 2, - img: { - type: 3, - url: 'http://url.to/image', - w: 750, - h: 500, - }, - }], - link: { - url: 'http://url.to/target' - }, - imptrackers: [ - 'http://url.to/pixeltracker' - ], - } - }], - }], - } - serverRequest = { - method: 'POST', - url: 'http://localhost:60080/header/prebid', - data: JSON.stringify({ - 'id': '178e34bad3658f', - 'imp': [ - { - 'id': '2ffb201a808da7', - 'native': { - 'request': '{"assets":[{"id":1,"required":1,"title":{"len":200}},{"id":2,"required":0,"data":{"type":1,"len":50}},{"id":3,"required":0,"img":{"type":3,"wmin":100,"hmin":150}}]}', - 'ver': '1.1' - }, - 'bidfloor': 5, - 'bidfloorcur': 'USD' - } - ], - 'site': { - 'publisher': { - 'id': '11bc5dd5-7421-4dd8-c926-40fa653bec76' - }, - 'id': '11bc5dd5-7421-4dd8-c926-40fa653bec77', - 'ref': '', - 'page': 'http://localhost', - 'domain': 'localhost' - }, - 'app': null, - 'device': { - 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/61.0.3163.100 Safari/537.36', - 'language': 'en-US' - }, - 'isPrebid': true - }) - } - }); - - describe('spec.isBidRequestValid', function () { - it('should return true when the required params are passed', function () { - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return false when the native params are missing', function () { - bidRequest.nativeParams = undefined; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when the "publisherId" param is missing', function () { - bidRequest.params = { - bidfloor: 5.00 - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when no bid params are passed', function () { - bidRequest.params = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when a bid request is not passed', function () { - expect(spec.isBidRequestValid()).to.equal(false); - expect(spec.isBidRequestValid({})).to.equal(false); - }); - }); - - describe('spec.buildRequests', function () { - it('should create a POST request for every bid', function () { - const request = spec.buildRequests([ bidRequest ]); - expect(request.method).to.equal('POST'); - expect(request.url).to.equal(ENDPOINT); - }); - - it('should attach request data', function () { - config.setConfig({ - currency: { - adServerCurrency: 'EUR' - } - }); - - const request = spec.buildRequests([ bidRequest ]); - - const data = JSON.parse(request.data); - - expect(data.source.ext.prebid).to.equal('$prebid.version$'); - expect(data.id).to.equal(bidRequest.bidderRequestId) - expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); - expect(data.imp[0].bidfloorcur).to.equal('USD'); - expect(data.site).to.deep.equal({ - publisher: { - id: bidRequest.params.publisherId, - domain: 'http://localhost:9876', - }, - id: bidRequest.params.siteId, - ref: window.top.document.referrer, - page: utils.getTopWindowLocation().href, - domain: utils.getTopWindowLocation().hostname, - }); - expect(data.device).to.deep.contain({ ua: navigator.userAgent, language: navigator.language }); - expect(data.cur).to.deep.equal(['EUR']); - }); - }); - - describe('spec.interpretResponse', function () { - it('should return no bids if the response is not valid', function () { - const bidResponse = spec.interpretResponse({ body: null }, serverRequest); - expect(bidResponse.length).to.equal(0); - }); - - it('should return a valid bid response', function () { - const bidResponse = spec.interpretResponse({ body: serverResponse }, serverRequest)[0]; - expect(bidResponse).to.contain({ - requestId: bidRequest.bidId, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].crid, - ttl: 300, - netRevenue: true, - mediaType: 'native', - currency: serverResponse.cur - }); - - expect(bidResponse.native.title).to.equal('Title') - expect(bidResponse.native.body).to.equal('Description') - expect(bidResponse.native.image).to.deep.equal({url: 'http://url.to/image', width: 750, height: 500}) - expect(bidResponse.native.clickUrl).to.equal('http%3A%2F%2Furl.to%2Ftarget') - expect(bidResponse.native.impressionTrackers).to.contain('http://url.to/pixeltracker') - }); - }); -}); diff --git a/test/spec/modules/reklamstoreBidAdapter_spec.js b/test/spec/modules/reklamstoreBidAdapter_spec.js index 3ac40e20eafc..92f309fd54f5 100644 --- a/test/spec/modules/reklamstoreBidAdapter_spec.js +++ b/test/spec/modules/reklamstoreBidAdapter_spec.js @@ -29,7 +29,7 @@ describe('reklamstoreBidAdapterTests', function() { it('validate_generated_params', function() { let bidderRequest = { refererInfo: { - referer: 'http://reklamstore.com' + referer: 'https://reklamstore.com' } }; request = spec.buildRequests(bidRequestData.bids, bidderRequest); @@ -47,11 +47,11 @@ describe('reklamstoreBidAdapterTests', function() { h: 250, syncs: [{ type: 'image', - url: 'http://link1' + url: 'https://link1' }, { type: 'iframe', - url: 'http://link2' + url: 'https://link2' } ] } @@ -77,8 +77,8 @@ describe('reklamstoreBidAdapterTests', function() { it('should return user syncs', function () { const syncs = spec.getUserSyncs({pixelEnabled: true, iframeEnabled: true}, [serverResponse]); const expected = [ - { type: 'image', url: 'http://link1' }, - { type: 'iframe', url: 'http://link2' }, + { type: 'image', url: 'https://link1' }, + { type: 'iframe', url: 'https://link2' }, ]; expect(syncs).to.deep.equal(expected); }); diff --git a/test/spec/modules/rexrtbBidAdapter_spec.js b/test/spec/modules/rexrtbBidAdapter_spec.js deleted file mode 100644 index b35e05bbf46d..000000000000 --- a/test/spec/modules/rexrtbBidAdapter_spec.js +++ /dev/null @@ -1,107 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/rexrtbBidAdapter'; - -describe('rexrtb adapater', function () { - describe('Test validate req', function () { - it('should accept minimum valid bid', function () { - let bid = { - bidder: 'rexrtb', - params: { - id: 89, - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(true); - }); - - it('should reject missing id', function () { - let bid = { - bidder: 'rexrtb', - params: { - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - - it('should reject id not Integer', function () { - let bid = { - bidder: 'rexrtb', - params: { - id: '123', - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - }); - - describe('Test build request', function () { - it('minimum request', function () { - let bid = { - bidder: 'rexrtb', - sizes: [[728, 90]], - bidId: '4d0a6829338a07', - adUnitCode: 'div-gpt-ad-1460505748561-0', - auctionId: '20882439e3238c', - params: { - id: 89, - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - }, - }; - const req = JSON.parse(spec.buildRequests([bid])[0].data); - - expect(req).to.have.property('id'); - expect(req).to.have.property('imp'); - expect(req).to.have.property('device'); - expect(req).to.have.property('site'); - expect(req).to.have.property('hb'); - expect(req.imp[0]).to.have.property('id'); - expect(req.imp[0]).to.have.property('banner'); - expect(req.device).to.have.property('ip'); - expect(req.device).to.have.property('ua'); - expect(req.site).to.have.property('id'); - expect(req.site).to.have.property('domain'); - }); - }); - - 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, - w: 728, - h: 98, - adm: 'hello', - crid: 'efgh', - 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', 728); - expect(resp).to.have.property('height', 98); - 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/rhythmoneBidAdapter_spec.js b/test/spec/modules/rhythmoneBidAdapter_spec.js index 29c8de43c169..80cbdb4a0afb 100644 --- a/test/spec/modules/rhythmoneBidAdapter_spec.js +++ b/test/spec/modules/rhythmoneBidAdapter_spec.js @@ -40,7 +40,7 @@ describe('rhythmone adapter tests', function () { var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - expect(bidRequest.url).to.have.string('//tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); + expect(bidRequest.url).to.have.string('https://tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); expect(bidRequest.method).to.equal('POST'); const openrtbRequest = JSON.parse(bidRequest.data); expect(openrtbRequest.site).to.not.equal(null); @@ -113,7 +113,7 @@ describe('rhythmone adapter tests', function () { var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - expect(bidRequest.url).to.have.string('//tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); + expect(bidRequest.url).to.have.string('https://tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); expect(bidRequest.method).to.equal('POST'); const openrtbRequest = JSON.parse(bidRequest.data); expect(openrtbRequest.site).to.not.equal(null); @@ -138,7 +138,7 @@ describe('rhythmone adapter tests', function () { { 'impid': 'div-gpt-ad-1438287399331-1', 'price': 1, - 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', + 'nurl': 'https://testdomain/rmp/placementid/0/path?reqId=1636037', 'adomain': [ 'test.com' ], @@ -156,7 +156,7 @@ describe('rhythmone adapter tests', function () { const bid = videoBids[0]; expect(bid.width).to.equal(800); expect(bid.height).to.equal(600); - expect(bid.vastUrl).to.equal('http://testdomain/rmp/placementid/0/path?reqId=1636037'); + expect(bid.vastUrl).to.equal('https://testdomain/rmp/placementid/0/path?reqId=1636037'); expect(bid.mediaType).to.equal('video'); expect(bid.creativeId).to.equal('cr-vid'); expect(bid.currency).to.equal('USD'); @@ -234,7 +234,7 @@ describe('rhythmone adapter tests', function () { { 'impid': 'div-gpt-ad-1438287399331-5', 'price': 1, - 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', + 'nurl': 'https://testdomain/rmp/placementid/0/path?reqId=1636037', 'adomain': [ 'test.com' ], @@ -255,7 +255,7 @@ describe('rhythmone adapter tests', function () { const bid = forRMPMultiFormatResponse[0]; expect(bid.width).to.equal(800); expect(bid.height).to.equal(600); - expect(bid.vastUrl).to.equal('http://testdomain/rmp/placementid/0/path?reqId=1636037'); + expect(bid.vastUrl).to.equal('https://testdomain/rmp/placementid/0/path?reqId=1636037'); expect(bid.mediaType).to.equal('video'); expect(bid.creativeId).to.equal('cr-vid'); expect(bid.currency).to.equal('USD'); diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 6c7030676c7e..cd6690e3276a 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -181,7 +181,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -197,7 +197,8 @@ describe('Richaudience adapter tests', function () { expect(requestContent).to.have.property('bidder').and.to.equal('richaudience'); expect(requestContent).to.have.property('bidderRequestId').and.to.equal('1858b7382993ca'); expect(requestContent).to.have.property('tagId').and.to.equal('test-div'); - expect(requestContent).to.have.property('referer').and.to.equal('http%3A%2F%2Fdomain.com'); + expect(requestContent).to.have.property('referer').and.to.equal('https%3A%2F%2Fdomain.com'); + expect(requestContent).to.have.property('sizes'); expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); @@ -224,15 +225,31 @@ describe('Richaudience adapter tests', function () { } }); - const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { + 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: { + referer: 'https://domain.com', + numIframes: 0 + } + }); const requestContent = JSON.parse(request[0].data); expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA'); }); it('Verify adding ifa when supplyType equal to app', function () { - const request = spec.buildRequests(DEFAULT_PARAMS_APP, DEFAULT_PARAMS_GDPR); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA'); + const request = spec.buildRequests(DEFAULT_PARAMS_APP, { + 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: { + referer: 'https://domain.com', + numIframes: 0 + } + }); }); it('Verify build request with GDPR without gdprApplies', function () { @@ -252,7 +269,7 @@ describe('Richaudience adapter tests', function () { consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA' }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -486,7 +503,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -513,7 +530,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); diff --git a/test/spec/modules/rockyouBidAdapter_spec.js b/test/spec/modules/rockyouBidAdapter_spec.js deleted file mode 100644 index 65d87566c268..000000000000 --- a/test/spec/modules/rockyouBidAdapter_spec.js +++ /dev/null @@ -1,494 +0,0 @@ -import { expect } from 'chai'; -import { spec, internals } from 'modules/rockyouBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('RockYouAdapter', function () { - const adapter = newBidder(spec); - - describe('bid validator', function () { - it('rejects a bid that is missing the placementId', function () { - let testBid = {}; - expect(spec.isBidRequestValid(testBid)).to.be.false; - }); - - it('accepts a bid with all the expected parameters', function () { - let testBid = { - params: { - placementId: 'f39ba81609' - } - }; - - expect(spec.isBidRequestValid(testBid)).to.be.true; - }); - }); - - describe('request builder', function () { - // Taken from the docs, so used as much as is valid - const sampleBidRequest = { - 'bidder': 'tests', - 'bidId': '51ef8751f9aead', - 'params': { - 'cId': '59ac1da80784890004047d89', - 'placementId': 'ZZZPLACEMENTZZZ' - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[999, 888]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'mediaTypes': { - banner: { - 'sizes': [[320, 50], [300, 250], [300, 600]] - } - } - }; - - it('successfully generates a URL', function () { - const placementId = 'ZZZPLACEMENTZZZ'; - - let bidRequests = [ - { - 'params': { - 'placementId': placementId - } - } - ]; - - let results = spec.buildRequests(bidRequests, { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - expect(result.url).to.not.be.undefined; - expect(result.url).to.not.be.null; - - expect(result.url).to.include('/servlet/rotator/' + placementId + '/0/vo?z=') - }); - - it('uses the bidId id as the openRtb request ID', function () { - const bidId = '51ef8751f9aead'; - - let bidRequests = [ - sampleBidRequest - ]; - - let results = spec.buildRequests(bidRequests, { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - expect(payload.id).to.equal(bidId); - }); - - it('generates the device payload as expected', function () { - let bidRequests = [ - sampleBidRequest - ]; - - let results = spec.buildRequests(bidRequests, { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - let userData = payload.user; - - expect(userData).to.not.be.null; - }); - - it('generates multiple requests with single imp bodies', function () { - const SECOND_PLACEMENT_ID = 'YYYPLACEMENTIDYYY'; - let firstBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - let secondBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - secondBidRequest.params.placementId = SECOND_PLACEMENT_ID; - - let bidRequests = [ - firstBidRequest, - secondBidRequest - ]; - - let results = spec.buildRequests(bidRequests, { - bidderRequestId: 'sample' - }); - - expect(results instanceof Array).to.be.true; - expect(results.length).to.equal(2); - - let firstRequest = results[0]; - - // Double encoded JSON - let firstPayload = JSON.parse(firstRequest.data); - - expect(firstPayload).to.not.be.null; - expect(firstPayload.imp).to.not.be.null; - expect(firstPayload.imp.length).to.equal(1); - - expect(firstRequest.url).to.not.be.null; - expect(firstRequest.url.indexOf('ZZZPLACEMENTZZZ')).to.be.gt(0); - - let secondRequest = results[1]; - - // Double encoded JSON - let secondPayload = JSON.parse(secondRequest.data); - - expect(secondPayload).to.not.be.null; - expect(secondPayload.imp).to.not.be.null; - expect(secondPayload.imp.length).to.equal(1); - - expect(secondRequest.url).to.not.be.null; - expect(secondRequest.url.indexOf(SECOND_PLACEMENT_ID)).to.be.gt(0); - }); - - it('generates a banner request as expected', function () { - // clone the sample for stability - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - - let imps = payload.imp; - - let firstImp = imps[0]; - - expect(firstImp.banner).to.not.be.null; - - let bannerData = firstImp.banner; - - expect(bannerData.w).to.equal(320); - expect(bannerData.h).to.equal(50); - }); - - it('generates a banner request using a singular adSize instead of an array', function () { - // clone the sample for stability - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - localBidRequest.sizes = [320, 50]; - localBidRequest.mediaTypes = { banner: {} }; - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - - let imps = payload.imp; - - let firstImp = imps[0]; - - expect(firstImp.banner).to.not.be.null; - - let bannerData = firstImp.banner; - - expect(bannerData.w).to.equal(320); - expect(bannerData.h).to.equal(50); - }); - - it('fails gracefully on an invalid size', function () { - // clone the sample for stability - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - localBidRequest.sizes = ['x', 'w']; - - localBidRequest.mediaTypes = { banner: { sizes: ['y', 'z'] } }; - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - - let imps = payload.imp; - - let firstImp = imps[0]; - - expect(firstImp.banner).to.not.be.null; - - let bannerData = firstImp.banner; - - expect(bannerData.w).to.equal(null); - expect(bannerData.h).to.equal(null); - }); - - it('generates a video request as expected', function () { - // clone the sample for stability - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - - localBidRequest.mediaTypes = { video: { - playerSize: [326, 56] - } }; - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - - let imps = payload.imp; - - let firstImp = imps[0]; - - expect(firstImp.video).to.not.be.null; - - let videoData = firstImp.video; - - expect(videoData.w).to.equal(326); - expect(videoData.h).to.equal(56); - }); - - it('propagates the mediaTypes object in the built request', function () { - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - - localBidRequest.mediaTypes = { video: {} }; - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - let mediaTypes = result.mediaTypes; - - expect(mediaTypes).to.not.be.null; - expect(mediaTypes).to.not.be.undefined; - expect(mediaTypes.video).to.not.be.null; - expect(mediaTypes.video).to.not.be.undefined; - }); - }); - - describe('response interpreter', function () { - it('returns an empty array when no bids present', function () { - // an empty JSON body indicates no ad was found - - let result = spec.interpretResponse({ body: '' }, {}) - - expect(result).to.eql([]); - }); - - it('gracefully fails when a non-JSON body is present', function () { - let result = spec.interpretResponse({ body: 'THIS IS NOT ' }, {}) - - expect(result).to.eql([]); - }); - - it('returns a valid bid response on sucessful banner request', function () { - let incomingRequestId = 'XXtestingXX'; - let responsePrice = 3.14 - - let responseCreative = '\n\n
\n
'; - - let responseCreativeId = '274'; - let responseCurrency = 'USD'; - - let responseWidth = 300; - let responseHeight = 250; - let responseTtl = 213; - - let sampleResponse = { - id: '66043f5ca44ecd8f8769093b1615b2d9', - seatbid: [ - { - bid: [ - { - id: 'c21bab0e-7668-4d8f-908a-63e094c09197', - impid: '1', - price: responsePrice, - adid: responseCreativeId, - adm: responseCreative, - adomain: [ - 'www.rockyouteststudios.com' - ], - cid: '274', - attr: [], - w: responseWidth, - h: responseHeight, - ext: { - ttl: responseTtl - } - } - ], - seat: '201', - group: 0 - } - ], - bidid: 'c21bab0e-7668-4d8f-908a-63e094c09197', - cur: responseCurrency - }; - - let sampleRequest = { - bidId: incomingRequestId, - mediaTypes: { banner: {} }, - requestId: incomingRequestId - }; - - let result = spec.interpretResponse( - { - body: sampleResponse - }, - sampleRequest - ); - - expect(result.length).to.equal(1); - - let processedBid = result[0]; - - // expect(processedBid.requestId).to.equal(incomingRequestId); - expect(processedBid.cpm).to.equal(responsePrice); - expect(processedBid.width).to.equal(responseWidth); - expect(processedBid.height).to.equal(responseHeight); - expect(processedBid.ad).to.equal(responseCreative); - expect(processedBid.ttl).to.equal(responseTtl); - expect(processedBid.creativeId).to.equal(responseCreativeId); - expect(processedBid.netRevenue).to.equal(true); - expect(processedBid.currency).to.equal(responseCurrency); - }); - - it('returns an valid bid response on sucessful video request', function () { - let incomingRequestId = 'XXtesting-275XX'; - let responsePrice = 6 - - let responseCreative = '\n\n \n \n Mediatastic\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n'; - - let responseCreativeId = '1556'; - let responseCurrency = 'USD'; - - let responseWidth = 284; - let responseHeight = 285; - let responseTtl = 286; - - let sampleResponse = { - id: '1234567890', - seatbid: [ - { - bid: [ - { - id: 'a8ae0b48-a8db-4220-ba0c-7458f452b1f5', - impid: '1', - price: responsePrice, - adid: responseCreativeId, - adm: responseCreative, - cid: '270', - attr: [], - w: responseWidth, - h: responseHeight, - ext: { - ttl: responseTtl - } - } - ], - seat: '201', - group: 0 - } - ], - bidid: 'a8ae0b48-a8db-4220-ba0c-7458f452b1f5', - cur: 'USD' - }; - - let sampleRequest = { - bidId: incomingRequestId, - mediaTypes: { - video: { - } - }, - requestId: incomingRequestId - }; - - let result = spec.interpretResponse( - { - body: sampleResponse - }, - sampleRequest - ); - - expect(result.length).to.equal(1); - - let processedBid = result[0]; - - // expect(processedBid.requestId).to.equal(incomingRequestId); - expect(processedBid.cpm).to.equal(responsePrice); - expect(processedBid.width).to.equal(responseWidth); - expect(processedBid.height).to.equal(responseHeight); - expect(processedBid.ad).to.equal(null); - expect(processedBid.ttl).to.equal(responseTtl); - expect(processedBid.creativeId).to.equal(responseCreativeId); - expect(processedBid.netRevenue).to.equal(true); - expect(processedBid.currency).to.equal(responseCurrency); - expect(processedBid.vastXml).to.equal(responseCreative); - }); - - it('generates event callbacks as expected', function () { - let tally = {}; - let renderer = { - handleVideoEvent: (eventObject) => { - let eventName = eventObject.eventName; - if (tally[eventName]) { - tally[eventName] = tally[eventName] + 1; - } else { - tally[eventName] = 1; - } - } - }; - - let callbacks = internals.playerCallbacks(renderer); - - let validCallbacks = ['LOAD', 'IMPRESSION', 'COMPLETE', 'ERROR']; - - validCallbacks.forEach(event => { - callbacks('n/a', event); - }); - - let callbackKeys = Object.keys(tally); - expect(callbackKeys.length).to.equal(3); - expect(tally['loaded']).to.equal(1); - expect(tally['impression']).to.equal(1); - expect(tally['ended']).to.equal(2); - }); - - it('generates a renderer that will hide on complete', function () { - let elementName = 'test_element_id'; - let selector = `#${elementName}`; - - let mockElement = { - style: { - display: 'some' - } - }; - - document.querySelector = (name) => { - if (name === selector) { - return mockElement; - } else { - return null; - } - }; - - let renderer = internals.generateRenderer({}, elementName); - - renderer.handlers['ended'](); - - expect(mockElement.style.display).to.equal('none'); - }) - }); -}); diff --git a/test/spec/modules/roxotAnalyticsAdapter_spec.js b/test/spec/modules/roxotAnalyticsAdapter_spec.js index cd48cb7f37de..d40ceb61cd5a 100644 --- a/test/spec/modules/roxotAnalyticsAdapter_spec.js +++ b/test/spec/modules/roxotAnalyticsAdapter_spec.js @@ -189,7 +189,7 @@ describe('Roxot Prebid Analytic', function () { }); expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('//' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); + expect(requests[0].url).to.equal('https://' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); requests[0].respond(200, {'Content-Type': 'application/json'}, '{"a": 1, "i": 1, "bat": 1}'); events.emit(constants.EVENTS.AUCTION_INIT, auctionInit); @@ -207,9 +207,9 @@ describe('Roxot Prebid Analytic', function () { expect(requests.length).to.equal(4); - expect(requests[1].url).to.equal('//' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); - expect(requests[2].url).to.equal('//' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); - expect(requests[3].url).to.equal('//' + roxotEventServerUrl + '/i?publisherId=' + publisherId + '&host=localhost'); + expect(requests[1].url).to.equal('https://' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); + expect(requests[2].url).to.equal('https://' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); + expect(requests[3].url).to.equal('https://' + roxotEventServerUrl + '/i?publisherId=' + publisherId + '&host=localhost'); let auction = JSON.parse(requests[1].requestBody); expect(auction).to.include.all.keys('event', 'eventName', 'options', 'data'); @@ -269,7 +269,7 @@ describe('Roxot Prebid Analytic', function () { }); expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('//' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); + expect(requests[0].url).to.equal('https://' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); requests[0].respond(200, {'Content-Type': 'application/json'}, '{"a": 1, "i": 1, "bat": 1}'); events.emit(constants.EVENTS.AUCTION_INIT, auctionInit); @@ -287,8 +287,8 @@ describe('Roxot Prebid Analytic', function () { expect(requests.length).to.equal(3); - expect(requests[1].url).to.equal('//' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); - expect(requests[2].url).to.equal('//' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); + expect(requests[1].url).to.equal('https://' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); + expect(requests[2].url).to.equal('https://' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); let auction = JSON.parse(requests[1].requestBody); expect(auction.data.adUnits).to.include.all.keys(noBidAdUnit, bidAfterTimeoutAdUnit); diff --git a/test/spec/modules/rtbdemandBidAdapter_spec.js b/test/spec/modules/rtbdemandBidAdapter_spec.js index 25178c21d88b..6b5ef2151629 100644 --- a/test/spec/modules/rtbdemandBidAdapter_spec.js +++ b/test/spec/modules/rtbdemandBidAdapter_spec.js @@ -108,7 +108,7 @@ describe('rtbdemandAdapter', function () { it('sends bid request to ENDPOINT via GET', function () { const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.url).to.equal('//bidding.rtbdemand.com/hb'); + expect(request.url).to.equal('https://bidding.rtbdemand.com/hb'); expect(request.method).to.equal('GET'); }); }) @@ -159,7 +159,7 @@ describe('rtbdemandAdapter', function () { }); describe('user sync', function () { - const syncUrl = '//bidding.rtbdemand.com/delivery/matches.php?type=iframe'; + const syncUrl = 'https://bidding.rtbdemand.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/rtbdemandadkBidAdapter_spec.js b/test/spec/modules/rtbdemandadkBidAdapter_spec.js deleted file mode 100644 index c1fbd35d6c9b..000000000000 --- a/test/spec/modules/rtbdemandadkBidAdapter_spec.js +++ /dev/null @@ -1,268 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/rtbdemandadkBidAdapter'; -import * as utils from 'src/utils'; - -describe('rtbdemandadk adapter', function () { - const bid1_zone1 = { - bidder: 'rtbdemandadk', - bidId: 'Bid_01', - params: {zoneId: 1, host: 'rtb.rtbdemand.com'}, - placementCode: 'ad-unit-1', - sizes: [[300, 250], [300, 200]] - }, bid2_zone2 = { - bidder: 'rtbdemandadk', - bidId: 'Bid_02', - params: {zoneId: 2, host: 'rtb.rtbdemand.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid3_host2 = { - bidder: 'rtbdemandadk', - bidId: 'Bid_02', - params: {zoneId: 1, host: 'rtb-private.rtbdemand.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid_without_zone = { - bidder: 'rtbdemandadk', - bidId: 'Bid_W', - params: {host: 'rtb-private.rtbdemand.com'}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_without_host = { - bidder: 'rtbdemandadk', - bidId: 'Bid_W', - params: {zoneId: 1}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_with_wrong_zoneId = { - bidder: 'rtbdemandadk', - bidId: 'Bid_02', - params: {zoneId: 'wrong id', host: 'rtb.rtbdemand.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid_video = { - bidder: 'rtbdemandadk', - bidId: 'Bid_Video', - sizes: [640, 480], - mediaType: 'video', - params: { - zoneId: 1, - host: 'rtb.rtbdemand.com', - video: { - mimes: ['video/mp4', 'video/webm', 'video/x-flv'] - } - }, - placementCode: 'ad-unit-1' - }; - - 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' - }, videoBidResponse = { - id: '47ce4badcf7482', - seatbid: [{ - bid: [{ - id: 'sZSYq5zYMxo_0', - impid: 'Bid_Video', - crid: '100_003', - price: 0.00145, - adid: '158801', - nurl: 'https://rtb.com/win?i=sZSYq5zYMxo_0&f=nurl', - cid: '16855' - }] - }], - cur: 'USD' - }, usersyncOnlyResponse = { - id: 'nobid1', - ext: { - adk_usersync: ['http://adk.sync.com/sync'] - } - }; - - describe('input parameters validation', function () { - it('empty request shouldn\'t generate exception', function () { - expect(spec.isBidRequestValid({ - bidderCode: 'rtbdemandadk' - })).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('video request building', function () { - let bidRequest; - - before(function () { - let request = spec.buildRequests([bid_video])[0]; - bidRequest = JSON.parse(request.data.r); - }); - - it('should have video object', function () { - expect(bidRequest.imp[0]).to.have.property('video'); - }); - - it('should have h/w', function () { - expect(bidRequest.imp[0].video).to.have.property('w', 640); - expect(bidRequest.imp[0].video).to.have.property('h', 480); - }); - - it('should have tagid', function () { - expect(bidRequest.imp[0]).to.have.property('tagid', 'ad-unit-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 return fully-initialized video bid-response', function () { - let request = spec.buildRequests([bid_video])[0]; - let resp = spec.interpretResponse({body: videoBidResponse}, request)[0]; - expect(resp).to.have.property('requestId', 'Bid_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); - expect(resp.height).to.equal(480); - }); - - 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/rtbhouseBidAdapter_spec.js b/test/spec/modules/rtbhouseBidAdapter_spec.js index 67845fa1983a..6c6faf4e4d01 100644 --- a/test/spec/modules/rtbhouseBidAdapter_spec.js +++ b/test/spec/modules/rtbhouseBidAdapter_spec.js @@ -75,8 +75,8 @@ describe('RTBHouseAdapter', () => { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; @@ -402,10 +402,10 @@ describe('RTBHouseAdapter', () => { native: { ver: 1.1, link: { - url: 'http://example.com' + url: 'https://example.com' }, imptrackers: [ - 'http://example.com/imptracker' + 'https://example.com/imptracker' ], assets: [{ id: OPENRTB.NATIVE.ASSET_ID.TITLE, @@ -417,7 +417,7 @@ describe('RTBHouseAdapter', () => { id: OPENRTB.NATIVE.ASSET_ID.IMAGE, required: 1, img: { - url: 'http://example.com/image.jpg', + url: 'https://example.com/image.jpg', w: 150, h: 50 } @@ -446,10 +446,10 @@ describe('RTBHouseAdapter', () => { const bids = spec.interpretResponse({body: response}, {}); expect(bids[0].native).to.deep.equal({ title: 'Title text', - clickUrl: encodeURIComponent('http://example.com'), - impressionTrackers: ['http://example.com/imptracker'], + clickUrl: encodeURIComponent('https://example.com'), + impressionTrackers: ['https://example.com/imptracker'], image: { - url: encodeURIComponent('http://example.com/image.jpg'), + url: encodeURIComponent('https://example.com/image.jpg'), width: 150, height: 50 }, diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js deleted file mode 100644 index dd34245bd8ef..000000000000 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ /dev/null @@ -1,814 +0,0 @@ -import rubiconAnalyticsAdapter, { SEND_TIMEOUT, parseBidResponse } from 'modules/rubiconAnalyticsAdapter'; -import CONSTANTS from 'src/constants.json'; -import { config } from 'src/config'; - -import { - setConfig, - addBidResponseHook, -} from 'modules/currency'; - -let Ajv = require('ajv'); -let schema = require('./rubiconAnalyticsSchema.json'); -let ajv = new Ajv({ - allErrors: true -}); - -let validator = ajv.compile(schema); - -function validate(message) { - validator(message); - expect(validator.errors).to.deep.equal(null); -} - -// using es6 "import * as events from 'src/events'" causes the events.getEvents stub not to work... -let events = require('src/events'); -let ajax = require('src/ajax'); -let utils = require('src/utils'); - -const { - EVENTS: { - AUCTION_INIT, - AUCTION_END, - BID_REQUESTED, - BID_RESPONSE, - BIDDER_DONE, - BID_WON, - BID_TIMEOUT, - SET_TARGETING - } -} = CONSTANTS; - -const BID = { - 'bidder': 'rubicon', - 'width': 640, - 'height': 480, - 'mediaType': 'video', - 'statusMessage': 'Bid available', - 'bidId': '2ecff0db240757', - 'adId': 'fake_ad_id', - 'source': 'client', - 'requestId': '2ecff0db240757', - 'currency': 'USD', - 'creativeId': '3571560', - 'cpm': 1.22752, - 'ttl': 300, - 'netRevenue': false, - 'ad': '', - 'rubiconTargeting': { - 'rpfl_elemid': '/19968336/header-bid-tag-0', - 'rpfl_14062': '2_tier0100' - }, - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'responseTimestamp': 1519149629415, - 'requestTimestamp': 1519149628471, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'timeToRespond': 944, - 'pbLg': '1.00', - 'pbMg': '1.20', - 'pbHg': '1.22', - 'pbAg': '1.20', - 'pbDg': '1.22', - 'pbCg': '', - 'size': '640x480', - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': 1.20, - 'hb_size': '640x480', - 'hb_source': 'client' - }, - getStatusCode() { - return 1; - } -}; - -const BID2 = Object.assign({}, BID, { - adUnitCode: '/19968336/header-bid-tag1', - bidId: '3bd4ebb1c900e2', - adId: 'fake_ad_id', - requestId: '3bd4ebb1c900e2', - width: 728, - height: 90, - mediaType: 'banner', - cpm: 1.52, - source: 'server', - seatBidId: 'aaaa-bbbb-cccc-dddd', - rubiconTargeting: { - 'rpfl_elemid': '/19968336/header-bid-tag1', - 'rpfl_14062': '2_tier0100' - }, - adserverTargeting: { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - } -}); - -const MOCK = { - SET_TARGETING: { - [BID.adUnitCode]: BID.adserverTargeting, - [BID2.adUnitCode]: BID2.adserverTargeting - }, - AUCTION_INIT: { - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'timestamp': 1519767010567, - 'auctionStatus': 'inProgress', - 'adUnits': [ { - 'code': '/19968336/header-bid-tag1', - 'sizes': [[640, 480]], - 'bids': [ { - 'bidder': 'rubicon', - 'params': { - 'accountId': 1001, 'siteId': 113932, 'zoneId': 535512 - } - } ], - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014' - } - ], - 'adUnitCodes': ['/19968336/header-bid-tag1'], - 'bidderRequests': [ { - 'bidderCode': 'rubicon', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'bidderRequestId': '1be65d7958826a', - 'bids': [ { - 'bidder': 'rubicon', - 'params': { - 'accountId': 1001, 'siteId': 113932, 'zoneId': 535512 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[640, 480]] - } - }, - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'sizes': [[640, 480]], - 'bidId': '2ecff0db240757', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'src': 'client', - 'bidRequestsCount': 1 - } - ], - 'timeout': 3000, - 'refererInfo': { - 'referer': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] - } - } - ], - 'bidsReceived': [], - 'winningBids': [], - 'timeout': 3000, - 'config': { - 'accountId': 1001, 'endpoint': '//localhost:9999/event' - } - }, - BID_REQUESTED: { - 'bidder': 'rubicon', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'bidderRequestId': '1be65d7958826a', - 'bids': [ - { - 'bidder': 'rubicon', - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918', - 'userId': '12346', - 'keywords': ['a', 'b', 'c'], - 'inventory': 'test', - 'visitor': {'ucat': 'new', 'lastsearch': 'iphone'}, - 'position': 'btf', - 'video': { - 'language': 'en', - 'playerHeight': 480, - 'playerWidth': 640, - 'size_id': 203, - 'skip': 1, - 'skipdelay': 15, - 'aeParams': { - 'p_aso.video.ext.skip': '1', - 'p_aso.video.ext.skipdelay': '15' - } - } - }, - 'mediaType': 'video', - 'adUnitCode': '/19968336/header-bid-tag-0', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'sizes': [[640, 480]], - 'bidId': '2ecff0db240757', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - }, - { - 'bidder': 'rubicon', - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918', - 'userId': '12346', - 'keywords': ['a', 'b', 'c'], - 'inventory': {'rating': '4-star', 'prodtype': 'tech'}, - 'visitor': {'ucat': 'new', 'lastsearch': 'iphone'}, - 'position': 'atf' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[1000, 300], [970, 250], [728, 90]] - } - }, - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'sizes': [[1000, 300], [970, 250], [728, 90]], - 'bidId': '3bd4ebb1c900e2', - 'seatBidId': 'aaaa-bbbb-cccc-dddd', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - } - ], - 'auctionStart': 1519149536560, - 'timeout': 5000, - 'start': 1519149562216 - }, - BID_RESPONSE: [ - BID, - BID2 - ], - AUCTION_END: { - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - }, - BID_WON: [ - Object.assign({}, BID, { - 'status': 'rendered' - }), - Object.assign({}, BID2, { - 'status': 'rendered' - }) - ], - BIDDER_DONE: { - 'bidderCode': 'rubicon', - 'bids': [ - BID, - Object.assign({}, BID2, { - 'serverResponseTimeMs': 42, - }) - ] - }, - BID_TIMEOUT: [ - { - 'bidId': '2ecff0db240757', - 'bidder': 'rubicon', - 'adUnitCode': '/19968336/header-bid-tag-0', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - } - ] -}; - -const ANALYTICS_MESSAGE = { - 'eventTimeMillis': 1519767013781, - 'integration': 'pbjs', - 'version': '$prebid.version$', - 'referrerUri': 'http://www.test.com/page.html', - 'auctions': [ - { - 'clientTimeoutMillis': 3000, - 'serverTimeoutMillis': 1000, - 'accountId': 1001, - 'samplingFactor': 1, - 'adUnits': [ - { - 'adUnitCode': '/19968336/header-bid-tag-0', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'videoAdFormat': 'outstream', - 'mediaTypes': [ - 'video' - ], - 'dimensions': [ - { - 'width': 640, - 'height': 480 - } - ], - 'status': 'success', - 'accountId': 1001, - 'siteId': 70608, - 'zoneId': 335918, - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': '1.200', - 'hb_size': '640x480', - 'hb_source': 'client' - }, - 'bids': [ - { - 'bidder': 'rubicon', - 'bidId': '2ecff0db240757', - 'status': 'success', - 'source': 'client', - 'clientLatencyMillis': 3214, - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'bidResponse': { - 'bidPriceUSD': 1.22752, - 'dimensions': { - 'width': 640, - 'height': 480 - }, - 'mediaType': 'video' - } - } - ] - }, - { - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'mediaTypes': [ - 'banner' - ], - 'dimensions': [ - { - 'width': 1000, - 'height': 300 - }, - { - 'width': 970, - 'height': 250 - }, - { - 'width': 728, - 'height': 90 - } - ], - 'status': 'success', - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - }, - 'bids': [ - { - 'bidder': 'rubicon', - 'bidId': 'aaaa-bbbb-cccc-dddd', - 'status': 'success', - 'source': 'server', - 'clientLatencyMillis': 3214, - 'serverLatencyMillis': 42, - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'bidResponse': { - 'bidPriceUSD': 1.52, - 'dimensions': { - 'width': 728, - 'height': 90 - }, - 'mediaType': 'banner' - } - } - ] - } - ] - } - ], - 'bidsWon': [ - { - 'bidder': 'rubicon', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'adUnitCode': '/19968336/header-bid-tag-0', - 'bidId': '2ecff0db240757', - 'status': 'success', - 'source': 'client', - 'clientLatencyMillis': 3214, - 'samplingFactor': 1, - 'accountId': 1001, - 'siteId': 70608, - 'zoneId': 335918, - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'videoAdFormat': 'outstream', - 'mediaTypes': [ - 'video' - ], - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': '1.200', - 'hb_size': '640x480', - 'hb_source': 'client' - }, - 'bidResponse': { - 'bidPriceUSD': 1.22752, - 'dimensions': { - 'width': 640, - 'height': 480 - }, - 'mediaType': 'video' - }, - 'bidwonStatus': 'success' - }, - { - 'bidder': 'rubicon', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'adUnitCode': '/19968336/header-bid-tag1', - 'bidId': 'aaaa-bbbb-cccc-dddd', - 'status': 'success', - 'source': 'server', - 'clientLatencyMillis': 3214, - 'serverLatencyMillis': 42, - 'samplingFactor': 1, - 'accountId': 1001, - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'mediaTypes': [ - 'banner' - ], - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - }, - 'bidResponse': { - 'bidPriceUSD': 1.52, - 'dimensions': { - 'width': 728, - 'height': 90 - }, - 'mediaType': 'banner' - }, - 'bidwonStatus': 'success' - } - ], - 'wrapperName': '10000_fakewrapper_test' -}; - -function performStandardAuction() { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); -} - -describe('rubicon analytics adapter', function () { - let sandbox; - let xhr; - let requests; - let oldScreen; - let clock; - - beforeEach(function () { - sandbox = sinon.sandbox.create(); - - xhr = sandbox.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - - sandbox.stub(events, 'getEvents').returns([]); - - sandbox.stub(utils, 'getTopWindowUrl').returns('http://www.test.com/page.html'); - - clock = sandbox.useFakeTimers(1519767013781); - - config.setConfig({ - s2sConfig: { - timeout: 1000, - accountId: 10000, - }, - rubicon: { - wrapperName: '10000_fakewrapper_test' - } - }) - }); - - afterEach(function () { - sandbox.restore(); - config.resetConfig(); - }); - - it('should require accountId', function () { - sandbox.stub(utils, 'logError'); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event' - } - }); - - expect(utils.logError.called).to.equal(true); - }); - - it('should require endpoint', function () { - sandbox.stub(utils, 'logError'); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - accountId: 1001 - } - }); - - expect(utils.logError.called).to.equal(true); - }); - - describe('sampling', function () { - beforeEach(function () { - sandbox.stub(Math, 'random').returns(0.08); - sandbox.stub(utils, 'logError'); - }); - - afterEach(function () { - rubiconAnalyticsAdapter.disableAnalytics(); - }); - - describe('with options.samplingFactor', function () { - it('should sample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 10 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(1); - }); - - it('should unsample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 20 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(0); - }); - - it('should throw errors for invalid samplingFactor', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 30 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(0); - expect(utils.logError.called).to.equal(true); - }); - }); - describe('with options.sampling', function () { - it('should sample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 0.1 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(1); - }); - - it('should unsample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 0.05 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(0); - }); - - it('should throw errors for invalid samplingFactor', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 1 / 30 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(0); - expect(utils.logError.called).to.equal(true); - }); - }); - }); - - describe('when handling events', function () { - beforeEach(function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001 - } - }); - }); - - afterEach(function () { - rubiconAnalyticsAdapter.disableAnalytics(); - }); - - it('should build a batched message from prebid events', function () { - performStandardAuction(); - - expect(requests.length).to.equal(1); - let request = requests[0]; - - expect(request.url).to.equal('//localhost:9999/event'); - - let message = JSON.parse(request.requestBody); - validate(message); - - expect(message).to.deep.equal(ANALYTICS_MESSAGE); - }); - - it('should pick the highest cpm bid if more than one bid per bidRequestId', function () { - // Only want one bid request in our mock auction - let bidRequested = utils.deepClone(MOCK.BID_REQUESTED); - bidRequested.bids.shift(); - let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); - auctionInit.adUnits.shift(); - - // clone the mock bidResponse and duplicate - let duplicateResponse1 = utils.deepClone(BID2); - duplicateResponse1.cpm = 1.0; - duplicateResponse1.adserverTargeting.hb_pb = '1.0'; - duplicateResponse1.adserverTargeting.hb_adid = '1111'; - let duplicateResponse2 = utils.deepClone(BID2); - duplicateResponse2.cpm = 5.5; - duplicateResponse2.adserverTargeting.hb_pb = '5.5'; - duplicateResponse2.adserverTargeting.hb_adid = '5555'; - let duplicateResponse3 = utils.deepClone(BID2); - duplicateResponse3.cpm = 0.1; - duplicateResponse3.adserverTargeting.hb_pb = '0.1'; - duplicateResponse3.adserverTargeting.hb_adid = '3333'; - - const setTargeting = { - [duplicateResponse2.adUnitCode]: duplicateResponse2.adserverTargeting - }; - - const bidWon = Object.assign({}, duplicateResponse2, { - 'status': 'rendered' - }); - - // spoof the auction with just our duplicates - events.emit(AUCTION_INIT, auctionInit); - events.emit(BID_REQUESTED, bidRequested); - events.emit(BID_RESPONSE, duplicateResponse1); - events.emit(BID_RESPONSE, duplicateResponse2); - events.emit(BID_RESPONSE, duplicateResponse3); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, setTargeting); - events.emit(BID_WON, bidWon); - - let message = JSON.parse(requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.bidPriceUSD).to.equal(5.5); - expect(message.auctions[0].adUnits[0].adserverTargeting.hb_pb).to.equal('5.5'); - expect(message.auctions[0].adUnits[0].adserverTargeting.hb_adid).to.equal('5555'); - expect(message.bidsWon.length).to.equal(1); - expect(message.bidsWon[0].bidResponse.bidPriceUSD).to.equal(5.5); - expect(message.bidsWon[0].adserverTargeting.hb_pb).to.equal('5.5'); - expect(message.bidsWon[0].adserverTargeting.hb_adid).to.equal('5555'); - }); - - it('should send batched message without BID_WON if necessary and further BID_WON events individually', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - - clock.tick(SEND_TIMEOUT + 1000); - - events.emit(BID_WON, MOCK.BID_WON[1]); - - expect(requests.length).to.equal(2); - - let message = JSON.parse(requests[0].requestBody); - validate(message); - expect(message.bidsWon.length).to.equal(1); - expect(message.auctions).to.deep.equal(ANALYTICS_MESSAGE.auctions); - expect(message.bidsWon[0]).to.deep.equal(ANALYTICS_MESSAGE.bidsWon[0]); - - message = JSON.parse(requests[1].requestBody); - validate(message); - expect(message.bidsWon.length).to.equal(1); - expect(message).to.not.have.property('auctions'); - expect(message.bidsWon[0]).to.deep.equal(ANALYTICS_MESSAGE.bidsWon[1]); - }); - - it('should properly mark bids as timed out', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_TIMEOUT, MOCK.BID_TIMEOUT); - events.emit(AUCTION_END, MOCK.AUCTION_END); - - clock.tick(SEND_TIMEOUT + 1000); - - expect(requests.length).to.equal(1); - - let message = JSON.parse(requests[0].requestBody); - validate(message); - let timedOutBid = message.auctions[0].adUnits[0].bids[0]; - expect(timedOutBid.status).to.equal('error'); - expect(timedOutBid.error.code).to.equal('timeout-error'); - expect(timedOutBid).to.not.have.property('bidResponse'); - }); - - it('should successfully convert bid price to USD in parseBidResponse', function () { - // Set the rates - setConfig({ - adServerCurrency: 'JPY', - rates: { - USD: { - JPY: 100 - } - } - }); - - // set our bid response to JPY - const bidCopy = utils.deepClone(BID2); - bidCopy.currency = 'JPY'; - bidCopy.cpm = 100; - - // Now add the bidResponse hook which hooks on the currenct conversion function onto the bid response - let innerBid; - addBidResponseHook(function(adCodeId, bid) { - innerBid = bid; - }, 'elementId', bidCopy); - - // Use the rubi analytics parseBidResponse Function to get the resulting cpm from the bid response! - const bidResponseObj = parseBidResponse(innerBid); - expect(bidResponseObj).to.have.property('bidPriceUSD'); - expect(bidResponseObj.bidPriceUSD).to.equal(1.0); - }); - }); - - describe('config with integration type', () => { - it('should use the integration type provided in the config instead of the default', () => { - sandbox.stub(config, 'getConfig').callsFake(function (key) { - const config = { - 'rubicon.int_type': 'testType' - }; - return config[key]; - }); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(1); - const request = requests[0]; - const message = JSON.parse(request.requestBody); - expect(message.integration).to.equal('testType'); - - rubiconAnalyticsAdapter.disableAnalytics(); - }); - }); -}); diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index c69415846520..d0c0773ff452 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -550,12 +550,12 @@ describe('the rubicon adapter', function () { it('should add referer info to request data', function () { let refererInfo = { - referer: 'http://www.prebid.org', + referer: 'https://www.prebid.org', reachedTop: true, numIframes: 1, stack: [ - 'http://www.prebid.org/page.html', - 'http://www.prebid.org/iframe1.html', + 'https://www.prebid.org/page.html', + 'https://www.prebid.org/iframe1.html', ] }; @@ -564,7 +564,7 @@ describe('the rubicon adapter', function () { let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); expect(parseQuery(request.data).rf).to.exist; - expect(parseQuery(request.data).rf).to.equal('http://www.prebid.org'); + expect(parseQuery(request.data).rf).to.equal('https://www.prebid.org'); }); it('page_url should use params.referrer, config.getConfig("pageUrl"), bidderRequest.refererInfo in that order', function () { @@ -572,20 +572,20 @@ describe('the rubicon adapter', function () { expect(parseQuery(request.data).rf).to.equal('localhost'); delete bidderRequest.bids[0].params.referrer; - let refererInfo = { referer: 'http://www.prebid.org' }; + let refererInfo = { referer: 'https://www.prebid.org' }; bidderRequest = Object.assign({refererInfo}, bidderRequest); [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(parseQuery(request.data).rf).to.equal('http://www.prebid.org'); + expect(parseQuery(request.data).rf).to.equal('https://www.prebid.org'); let origGetConfig = config.getConfig; sandbox.stub(config, 'getConfig').callsFake(function (key) { if (key === 'pageUrl') { - return 'http://www.rubiconproject.com'; + return 'https://www.rubiconproject.com'; } return origGetConfig.apply(config, arguments); }); [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(parseQuery(request.data).rf).to.equal('http://www.rubiconproject.com'); + expect(parseQuery(request.data).rf).to.equal('https://www.rubiconproject.com'); bidderRequest.bids[0].params.secure = true; [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); @@ -2455,7 +2455,7 @@ describe('the rubicon adapter', function () { describe('get price granularity', function() { it('should return correct buckets for all price granularity values', function() { - const CUSTOM_PRICE_BUCKET_ITEM = {min: 0, max: 5, increment: 0.5}; + const CUSTOM_PRICE_BUCKET_ITEM = {max: 5, increment: 0.5}; const mockConfig = { priceGranularity: undefined, diff --git a/test/spec/modules/saraBidAdapter_spec.js b/test/spec/modules/saraBidAdapter_spec.js deleted file mode 100644 index 6614ec652657..000000000000 --- a/test/spec/modules/saraBidAdapter_spec.js +++ /dev/null @@ -1,293 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/saraBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('Sara 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': 'sara', - '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': 'sara', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'sara', - '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': 'sara', - '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': 'sara', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'sara', - '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': 'sara', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '7' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'sara', - '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/sekindoUMBidAdapter_spec.js b/test/spec/modules/sekindoUMBidAdapter_spec.js index b699015bb3e0..2718d26b2b4a 100644 --- a/test/spec/modules/sekindoUMBidAdapter_spec.js +++ b/test/spec/modules/sekindoUMBidAdapter_spec.js @@ -143,7 +143,7 @@ describe('sekindoUMAdapter', function () { 'headers': function(header) { return 'dummy header'; }, - 'body': {'id': '30b31c1838de1e', 'bidderCode': 'sekindoUM', 'cpm': 2.1951, 'width': 300, 'height': 250, 'vastUrl': '//vastUrl', 'ttl': 36000, 'creativeId': '323774', 'netRevenue': true, 'currency': 'USD'} + 'body': {'id': '30b31c1838de1e', 'bidderCode': 'sekindoUM', 'cpm': 2.1951, 'width': 300, 'height': 250, 'vastUrl': 'https://vastUrl', 'ttl': 36000, 'creativeId': '323774', 'netRevenue': true, 'currency': 'USD'} }; bidRequests.mediaType = 'video'; bidRequests.params = videoParams; @@ -158,7 +158,7 @@ describe('sekindoUMAdapter', function () { 'currency': 'USD', 'netRevenue': true, 'ttl': 36000, - 'vastUrl': '//vastUrl' + 'vastUrl': 'https://vastUrl' } ]; let result = spec.interpretResponse(response, bidRequests); diff --git a/test/spec/modules/serverbidBidAdapter_spec.js b/test/spec/modules/serverbidBidAdapter_spec.js deleted file mode 100644 index 8949463e151b..000000000000 --- a/test/spec/modules/serverbidBidAdapter_spec.js +++ /dev/null @@ -1,253 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/serverbidBidAdapter'; -import { createBid } from 'src/bidfactory'; - -const ENDPOINT = 'https://e.serverbid.com/api/v2'; -const SMARTSYNC_CALLBACK = 'serverbidCallBids'; - -const REQUEST = { - 'bidderCode': 'serverbid', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d', - 'bidderRequestId': '109f2a181342a9', - 'bidRequest': [{ - 'bidder': 'serverbid', - 'params': { - 'networkId': 9969, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '2b0f82502298c9', - 'bidderRequestId': '109f2a181342a9', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }, - { - 'bidder': 'serverbid', - 'params': { - 'networkId': 9969, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '123', - 'bidderRequestId': '109f2a181342a9', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }], - 'start': 1487883186070, - 'auctionStart': 1487883186069, - 'timeout': 3000 -}; - -const RESPONSE = { - 'headers': null, - 'body': { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '2b0f82502298c9': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://e.serverbid.com/r', - 'impressionUrl': 'https://e.serverbid.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - }, - '123': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://e.serverbid.com/r', - 'impressionUrl': 'https://e.serverbid.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - } - } - } -}; - -describe('Serverbid BidAdapter', function () { - let bidRequests; - let adapter = spec; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'serverbid', - params: { - networkId: '9969', - siteId: '730181' - }, - 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 = { - bidder: 'serverbid', - params: { - networkId: '9969', - siteId: '123' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should accept valid bid requests with extra fields', function () { - let bid = { - bidder: 'serverbid', - params: { - networkId: '9969', - siteId: '123', - zoneId: '123' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should reject bid requests without siteId', function () { - let bid = { - bidder: 'serverbid', - params: { - networkId: '9969' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should reject bid requests without networkId', function () { - let bid = { - bidder: 'serverbid', - params: { - siteId: '9969' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests validation', function () { - it('creates request data', function () { - let request = spec.buildRequests(bidRequests); - - expect(request).to.exist.and.to.be.a('object'); - }); - - it('request to serverbid should contain a url', function () { - let request = spec.buildRequests(bidRequests); - - expect(request.url).to.have.string('serverbid.com'); - }); - - it('requires valid bids to make request', function () { - let request = spec.buildRequests([]); - expect(request.bidRequest).to.be.empty; - }); - - it('sends bid request to ENDPOINT via POST', function () { - let request = spec.buildRequests(bidRequests); - - expect(request.method).to.have.string('POST'); - }); - }); - describe('interpretResponse validation', function () { - it('response should have valid bidderCode', function () { - let bidRequest = spec.buildRequests(REQUEST.bidRequest); - let bid = createBid(1, bidRequest.bidRequest[0]); - - expect(bid.bidderCode).to.equal('serverbid'); - }); - - it('response should include objects for all bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - - expect(bids.length).to.equal(2); - }); - - it('registers bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - bids.forEach(b => { - expect(b).to.have.property('cpm'); - expect(b.cpm).to.be.above(0); - expect(b).to.have.property('requestId'); - expect(b).to.have.property('cpm'); - expect(b).to.have.property('width'); - expect(b).to.have.property('height'); - expect(b).to.have.property('ad'); - expect(b).to.have.property('currency', 'USD'); - 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'); - }); - }); - - it('handles nobid responses', function () { - let EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {'decisions': null}}) - let bids = spec.interpretResponse(EMPTY_RESP, REQUEST); - - expect(bids).to.be.empty; - }); - - it('handles no server response', function () { - let bids = spec.interpretResponse(null, REQUEST); - - expect(bids).to.be.empty; - }); - }); - describe('getUserSyncs', function () { - let syncOptions = {'iframeEnabled': true}; - - it('handles empty sync options', function () { - let opts = spec.getUserSyncs({}); - - expect(opts).to.be.undefined; - }); - - it('should return a sync url if iframe syncs are enabled', function () { - let opts = spec.getUserSyncs(syncOptions); - - expect(opts.length).to.equal(1); - }); - }); -}); diff --git a/test/spec/modules/serverbidServerBidAdapter_spec.js b/test/spec/modules/serverbidServerBidAdapter_spec.js deleted file mode 100644 index 1190648bb84b..000000000000 --- a/test/spec/modules/serverbidServerBidAdapter_spec.js +++ /dev/null @@ -1,303 +0,0 @@ -import { expect } from 'chai'; -import Adapter from 'modules/serverbidServerBidAdapter'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import { ajax } from 'src/ajax'; - -const ENDPOINT = 'https://e.serverbid.com/api/v2'; - -let CONFIG = { - enabled: true, - bidders: ['appnexus'], - timeout: 1000, - adapter: 'serverbidServer', - networkId: 9969, - siteId: 730181, - endpoint: ENDPOINT -}; - -let CONFIG_ARG = { - s2sConfig: CONFIG -} - -const REQUEST = { - 'account_id': '1', - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'max_bids': 1, - 'timeout_millis': 1000, - 'url': '', - 'prebid_version': '0.21.0-pre', - 'ad_units': [ - { - 'code': 'div-gpt-ad-1460505748561-0', - 'sizes': [ - { - 'w': 300, - 'h': 250 - }, - { - 'w': 300, - 'h': 600 - } - ], - 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', - 'bids': [ - { - 'bid_id': '123', - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394', - 'member': 123 - } - } - ] - } - ] -}; - -const BID_REQUESTS = [ - { - 'bidderCode': 'appnexus', - 'auctionId': '173afb6d132ba3', - 'bidderRequestId': '3d1063078dfcc8', - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'bids': [ - { - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394', - 'member': 123 - }, - 'bid_id': '123', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', - 'sizes': [ - { - 'w': 300, - 'h': 250 - } - ], - 'bidId': '259fb43aaa06c1', - 'bidderRequestId': '3d1063078dfcc8', - 'auctionId': '173afb6d132ba3' - } - ], - 'auctionStart': 1510852447530, - 'timeout': 5000, - 'src': 's2s', - 'doneCbCallCount': 0 - } -]; - -const RESPONSE = { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '123': [{ - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://e.serverbid.com/r', - 'impressionUrl': 'https://e.serverbid.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 300, - 'width': 250, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 250, - 'width': 300, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - }], - } -}; - -const RESPONSE_NO_BID_NO_UNIT = { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '123': [] - } -}; - -const REQUEST_TWO_UNITS = { - 'account_id': '1', - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'max_bids': 1, - 'timeout_millis': 1000, - 'url': '', - 'prebid_version': '0.21.0-pre', - 'ad_units': [ - { - 'code': 'div-gpt-ad-1460505748561-0', - 'sizes': [ - { - 'w': 300, - 'h': 250 - }, - { - 'w': 300, - 'h': 600 - } - ], - 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', - 'bids': [ - { - 'bid_id': '123', - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394', - 'member': 123 - } - } - ] - }, - { - 'code': 'div-gpt-ad-1460505748561-1', - 'sizes': [ - { - 'w': 300, - 'h': 250 - }, - { - 'w': 300, - 'h': 600 - } - ], - 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786bb86d', - 'bids': [ - { - 'bid_id': '101111', - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394', - 'member': 123 - } - } - ] - } - ] -}; - -describe('ServerBid S2S Adapter', function () { - let adapter, - addBidResponse = sinon.spy(), - done = sinon.spy(); - - beforeEach(function () { - adapter = new Adapter() - }); - - afterEach(function () { - addBidResponse.resetHistory(); - done.resetHistory(); - }); - - describe('request function', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - }); - - afterEach(function () { - xhr.restore(); - }); - - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('response handler', function () { - let server; - - beforeEach(function () { - server = sinon.fakeServer.create(); - sinon.stub(utils, 'getBidRequest').returns({ - bidId: '123' - }); - }); - - afterEach(function () { - server.restore(); - utils.getBidRequest.restore(); - }); - - it('registers bids', function () { - server.respondWith(JSON.stringify(RESPONSE)); - - config.setConfig(CONFIG_ARG); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('cpm', 0.5); - expect(response).to.have.property('requestId', '123'); - }); - - it('registers no-bid response when ad unit not set', function () { - server.respondWith(JSON.stringify(RESPONSE_NO_BID_NO_UNIT)); - - config.setConfig(CONFIG_ARG); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const ad_unit_code = addBidResponse.firstCall.args[0]; - expect(ad_unit_code).to.equal('div-gpt-ad-1460505748561-0'); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid returned empty or error response'); - - const bid_request_passed = addBidResponse.firstCall.args[1]; - expect(bid_request_passed).to.have.property('requestId', '123'); - }); - - it('registers no-bid response when ad unit is set', function () { - server.respondWith(JSON.stringify(RESPONSE_NO_BID_NO_UNIT)); - - config.setConfig(CONFIG_ARG); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const ad_unit_code = addBidResponse.firstCall.args[0]; - expect(ad_unit_code).to.equal('div-gpt-ad-1460505748561-0'); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid returned empty or error response'); - }); - - it('registers no-bid response when there are less bids than requests', function () { - server.respondWith(JSON.stringify(RESPONSE)); - - config.setConfig(CONFIG_ARG); - adapter.callBids(REQUEST_TWO_UNITS, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - - sinon.assert.calledTwice(addBidResponse); - - expect(addBidResponse.firstCall.args[0]).to.equal('div-gpt-ad-1460505748561-0'); - expect(addBidResponse.secondCall.args[0]).to.equal('div-gpt-ad-1460505748561-1'); - - expect(addBidResponse.firstCall.args[1]).to.have.property('requestId', '123'); - expect(addBidResponse.secondCall.args[1]).to.have.property('requestId', '101111'); - - expect(addBidResponse.firstCall.args[1]) - .to.have.property('statusMessage', 'Bid available'); - expect(addBidResponse.secondCall.args[1]) - .to.have.property('statusMessage', 'Bid returned empty or error response'); - }); - }); -}); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index 8a8ccdbbeb34..a8caefc52408 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -40,7 +40,7 @@ const bidRequests = [ const prebidRequests = [ { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -52,7 +52,7 @@ const prebidRequests = [ }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -64,7 +64,7 @@ const prebidRequests = [ }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -77,7 +77,7 @@ const prebidRequests = [ }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -89,7 +89,7 @@ const prebidRequests = [ }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -218,9 +218,9 @@ describe('sharethrough adapter spec', function () { const builtBidRequests = spec.buildRequests(bidRequests); expect(builtBidRequests[0].url).to.eq( - 'http://btlr.sharethrough.com/WYu2BXv1/v1'); + 'https://btlr.sharethrough.com/WYu2BXv1/v1'); expect(builtBidRequests[1].url).to.eq( - 'http://btlr.sharethrough.com/WYu2BXv1/v1'); + 'https://btlr.sharethrough.com/WYu2BXv1/v1'); expect(builtBidRequests[0].method).to.eq('GET'); }); diff --git a/test/spec/modules/showheroes-bsBidAdapter_spec.js b/test/spec/modules/showheroes-bsBidAdapter_spec.js index 124f98600d54..937df5a8c83e 100644 --- a/test/spec/modules/showheroes-bsBidAdapter_spec.js +++ b/test/spec/modules/showheroes-bsBidAdapter_spec.js @@ -5,7 +5,7 @@ import {VIDEO, BANNER} from 'src/mediaTypes' const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } } diff --git a/test/spec/modules/slimcutBidAdapter_spec.js b/test/spec/modules/slimcutBidAdapter_spec.js index 92649bf35561..ecbb926cdd14 100644 --- a/test/spec/modules/slimcutBidAdapter_spec.js +++ b/test/spec/modules/slimcutBidAdapter_spec.js @@ -2,8 +2,8 @@ import {expect} from 'chai'; import {spec} from 'modules/slimcutBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; -const ENDPOINT = '//sb.freeskreen.com/pbr'; -const AD_SCRIPT = '"'; +const ENDPOINT = 'https://sb.freeskreen.com/pbr'; +const AD_SCRIPT = '"'; describe('slimcutBidAdapter', function() { const adapter = newBidder(spec); @@ -116,7 +116,7 @@ describe('slimcutBidAdapter', 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 } @@ -125,7 +125,7 @@ describe('slimcutBidAdapter', function() { const payload = JSON.parse(request.data); expect(payload.referrer).to.exist; - expect(payload.referrer).to.deep.equal('http://example.com/page.html') + expect(payload.referrer).to.deep.equal('https://example.com/page.html') }); }); @@ -151,7 +151,7 @@ describe('slimcutBidAdapter', function() { it('should get the correct number of sync urls', () => { let urls = spec.getUserSyncs({iframeEnabled: true}, bids); expect(urls.length).to.equal(1); - expect(urls[0].url).to.equal('//sb.freeskreen.com/async_usersync.html'); + expect(urls[0].url).to.equal('https://sb.freeskreen.com/async_usersync.html'); }); it('should return no url if not iframe enabled', () => { diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js deleted file mode 100644 index 30afad308c71..000000000000 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ /dev/null @@ -1,399 +0,0 @@ -import { - expect -} from 'chai'; -import { - spec -} from 'modules/smartadserverBidAdapter'; -import { - newBidder -} from 'src/adapters/bidderFactory'; -import { - config -} from 'src/config'; -import * as utils from 'src/utils'; -import { requestBidsHook } from 'modules/consentManagement'; - -// Default params with optional ones -describe('Smart bid adapter tests', function () { - var DEFAULT_PARAMS = [{ - adUnitCode: 'sas_42', - bidId: 'abcd1234', - sizes: [ - [300, 250], - [300, 200] - ], - bidder: 'smartadserver', - params: { - domain: 'http://prg.smartadserver.com', - siteId: '1234', - pageId: '5678', - formatId: '90', - target: 'test=prebid', - bidfloor: 0.420, - buId: '7569', - appName: 'Mozilla', - ckId: 42 - }, - requestId: 'efgh5678', - transactionId: 'zsfgzzg' - }]; - - // Default params without optional ones - var DEFAULT_PARAMS_WO_OPTIONAL = [{ - adUnitCode: 'sas_42', - bidId: 'abcd1234', - sizes: [ - [300, 250], - [300, 200] - ], - bidder: 'smartadserver', - params: { - domain: 'http://prg.smartadserver.com', - siteId: '1234', - pageId: '5678', - formatId: '90' - }, - requestId: 'efgh5678' - }]; - - var BID_RESPONSE = { - body: { - cpm: 12, - width: 300, - height: 250, - creativeId: 'zioeufg', - currency: 'GBP', - isNetCpm: true, - ttl: 300, - adUrl: 'http://awesome.fake.url', - ad: '< --- awesome script --- >', - cSyncUrl: 'http://awesome.fake.csync.url' - } - }; - - it('Verify build request', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - } - }); - const request = spec.buildRequests(DEFAULT_PARAMS); - expect(request[0]).to.have.property('url').and.to.equal('http://prg.smartadserver.com/prebid/v1'); - expect(request[0]).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('siteid').and.to.equal('1234'); - expect(requestContent).to.have.property('pageid').and.to.equal('5678'); - expect(requestContent).to.have.property('formatid').and.to.equal('90'); - expect(requestContent).to.have.property('currencyCode').and.to.equal('EUR'); - expect(requestContent).to.have.property('bidfloor').and.to.equal(0.42); - expect(requestContent).to.have.property('targeting').and.to.equal('test=prebid'); - expect(requestContent).to.have.property('tagId').and.to.equal('sas_42'); - expect(requestContent).to.have.property('sizes'); - expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); - expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); - expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); - expect(requestContent.sizes[1]).to.have.property('h').and.to.equal(200); - expect(requestContent).to.have.property('pageDomain').and.to.equal(utils.getTopWindowUrl()); - expect(requestContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; - expect(requestContent).to.have.property('buid').and.to.equal('7569'); - expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); - expect(requestContent).to.have.property('ckid').and.to.equal(42); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(DEFAULT_PARAMS); - const bids = spec.interpretResponse(BID_RESPONSE, request[0]); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.cpm).to.equal(12); - expect(bid.adUrl).to.equal('http://awesome.fake.url'); - expect(bid.ad).to.equal('< --- awesome script --- >'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.creativeId).to.equal('zioeufg'); - expect(bid.currency).to.equal('GBP'); - expect(bid.netRevenue).to.equal(true); - expect(bid.ttl).to.equal(300); - expect(bid.requestId).to.equal(DEFAULT_PARAMS[0].bidId); - expect(bid.referrer).to.equal(utils.getTopWindowUrl()); - - expect(function () { - spec.interpretResponse(BID_RESPONSE, { - data: 'invalid Json' - }) - }).to.not.throw(); - }); - - it('Verifies bidder code', function () { - expect(spec.code).to.equal('smartadserver'); - }); - - it('Verifies bidder aliases', function () { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.equal('smart'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(DEFAULT_PARAMS[0])).to.equal(true); - expect(spec.isBidRequestValid(DEFAULT_PARAMS_WO_OPTIONAL[0])).to.equal(true); - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({ - params: {} - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - pageId: 123 - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - siteId: 123 - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - formatId: 123, - pageId: 234 - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - domain: 'www.test.com', - pageId: 234 - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - domain: 'www.test.com', - formatId: 123, - siteId: 456, - pageId: 234 - } - })).to.equal(true); - expect(spec.isBidRequestValid({ - params: { - domain: 'www.test.com', - formatId: 123, - siteId: 456, - pageId: 234, - buId: 789, - appName: 'Mozilla' - } - })).to.equal(true); - expect(spec.isBidRequestValid({ - params: { - domain: 'www.test.com', - formatId: 123, - pageId: 234, - buId: 789, - appName: 'Mozilla' - } - })).to.equal(false); - }); - - it('Verifies user sync', function () { - var syncs = spec.getUserSyncs({ - iframeEnabled: true - }, [BID_RESPONSE]); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('http://awesome.fake.csync.url'); - - syncs = spec.getUserSyncs({ - iframeEnabled: false - }, [BID_RESPONSE]); - expect(syncs).to.have.lengthOf(0); - - syncs = spec.getUserSyncs({ - iframeEnabled: true - }, []); - expect(syncs).to.have.lengthOf(0); - }); - - describe('gdpr tests', function () { - afterEach(function () { - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - }); - - it('Verify build request with GDPR', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - }, - consentManagement: { - cmp: 'iab', - consentRequired: true, - timeout: 1000, - allowAuctionWithoutConsent: true - } - }); - const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { - gdprConsent: { - consentString: 'BOKAVy4OKAVy4ABAB8AAAAAZ+A==', - gdprApplies: true - } - }); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('gdpr').and.to.equal(true); - expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOKAVy4OKAVy4ABAB8AAAAAZ+A=='); - }); - - it('Verify build request with GDPR without gdprApplies', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - }, - consentManagement: { - cmp: 'iab', - consentRequired: true, - timeout: 1000, - allowAuctionWithoutConsent: true - } - }); - const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { - gdprConsent: { - consentString: 'BOKAVy4OKAVy4ABAB8AAAAAZ+A==' - } - }); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.not.have.property('gdpr'); - expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOKAVy4OKAVy4ABAB8AAAAAZ+A=='); - }); - }); - - describe('Instream video tests', function () { - afterEach(function () { - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - }); - - const INSTREAM_DEFAULT_PARAMS = [{ - adUnitCode: 'sas_42', - bidId: 'abcd1234', - bidder: 'smartadserver', - mediaTypes: { - video: { - context: 'instream', - playerSize: [[640, 480]] // It seems prebid.js transforms the player size array into an array of array... - } - }, - params: { - siteId: '1234', - pageId: '5678', - formatId: '90', - target: 'test=prebid', - bidfloor: 0.420, - buId: '7569', - appName: 'Mozilla', - ckId: 42, - video: { - protocol: 6 - } - }, - requestId: 'efgh5678', - transactionId: 'zsfgzzg' - }]; - - var INSTREAM_BID_RESPONSE = { - body: { - cpm: 12, - width: 640, - height: 480, - creativeId: 'zioeufg', - currency: 'GBP', - isNetCpm: true, - ttl: 300, - adUrl: 'http://awesome.fake-vast.url', - ad: '', - cSyncUrl: 'http://awesome.fake.csync.url' - } - }; - - it('Verify instream video build request', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - } - }); - const request = spec.buildRequests(INSTREAM_DEFAULT_PARAMS); - expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); - expect(request[0]).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('siteid').and.to.equal('1234'); - expect(requestContent).to.have.property('pageid').and.to.equal('5678'); - expect(requestContent).to.have.property('formatid').and.to.equal('90'); - expect(requestContent).to.have.property('currencyCode').and.to.equal('EUR'); - expect(requestContent).to.have.property('bidfloor').and.to.equal(0.42); - expect(requestContent).to.have.property('targeting').and.to.equal('test=prebid'); - expect(requestContent).to.have.property('tagId').and.to.equal('sas_42'); - expect(requestContent).to.have.property('pageDomain').and.to.equal(utils.getTopWindowUrl()); - expect(requestContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; - expect(requestContent).to.have.property('buid').and.to.equal('7569'); - expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); - expect(requestContent).to.have.property('ckid').and.to.equal(42); - expect(requestContent).to.have.property('isVideo').and.to.equal(true); - expect(requestContent).to.have.property('videoData'); - expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(6); - expect(requestContent.videoData).to.have.property('playerWidth').and.to.equal(640); - expect(requestContent.videoData).to.have.property('playerHeight').and.to.equal(480); - }); - - it('Verify instream parse response', function () { - const request = spec.buildRequests(INSTREAM_DEFAULT_PARAMS); - const bids = spec.interpretResponse(INSTREAM_BID_RESPONSE, request[0]); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.cpm).to.equal(12); - expect(bid.mediaType).to.equal('video'); - expect(bid.vastUrl).to.equal('http://awesome.fake-vast.url'); - expect(bid.vastXml).to.equal(''); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(480); - expect(bid.creativeId).to.equal('zioeufg'); - expect(bid.currency).to.equal('GBP'); - expect(bid.netRevenue).to.equal(true); - expect(bid.ttl).to.equal(300); - expect(bid.requestId).to.equal(INSTREAM_DEFAULT_PARAMS[0].bidId); - expect(bid.referrer).to.equal(utils.getTopWindowUrl()); - - expect(function () { - spec.interpretResponse(INSTREAM_BID_RESPONSE, { - data: 'invalid Json' - }) - }).to.not.throw(); - }); - - it('Verify not handled media type return empty request', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - } - }); - const request = spec.buildRequests([{ - adUnitCode: 'sas_42', - bidder: 'smartadserver', - mediaTypes: { - video: { - context: 'badcontext' - } - }, - params: { - domain: 'http://prg.smartadserver.com', - siteId: '1234', - pageId: '5678', - formatId: '90', - target: 'test=prebid', - bidfloor: 0.420, - buId: '7569', - appName: 'Mozilla', - ckId: 42 - }, - requestId: 'efgh5678', - transactionId: 'zsfgzzg' - }, INSTREAM_DEFAULT_PARAMS[0]]); - expect(request[0]).to.be.empty; - expect(request[1]).to.not.be.empty; - }); - }); -}); diff --git a/test/spec/modules/smartrtbBidAdapter_spec.js b/test/spec/modules/smartrtbBidAdapter_spec.js index 7477dbf9418b..955dd3ba471e 100644 --- a/test/spec/modules/smartrtbBidAdapter_spec.js +++ b/test/spec/modules/smartrtbBidAdapter_spec.js @@ -13,8 +13,8 @@ const br = { crid: 'crid' }], pixels: [ - { type: 'image', url: 'http://smrtb.com/image' }, - { type: 'iframe', url: 'http://smrtb.com/iframe' } + { type: 'image', url: 'https://smrtb.com/image' }, + { type: 'iframe', url: 'https://smrtb.com/iframe' } ] } } @@ -30,8 +30,8 @@ const vr = { crid: 'video_crid' }], pixels: [ - { type: 'image', url: 'http://smrtb.com/image' }, - { type: 'iframe', url: 'http://smrtb.com/iframe' } + { type: 'image', url: 'https://smrtb.com/image' }, + { type: 'iframe', url: 'https://smrtb.com/iframe' } ] } } diff --git a/test/spec/modules/smartyadsBidAdapter_spec.js b/test/spec/modules/smartyadsBidAdapter_spec.js deleted file mode 100644 index e301e9733a61..000000000000 --- a/test/spec/modules/smartyadsBidAdapter_spec.js +++ /dev/null @@ -1,230 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/smartyadsBidAdapter'; - -describe('SmartyadsAdapter', function () { - let bid = { - bidId: '23fhj33i987f', - bidder: 'smartyads', - 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('//ssp-nj.webtradehub.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'); - 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'); - 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'); - expect(dataItem.mediaType).to.not.exist; - 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', - 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', 'clickUrl', 'impressionTrackers', 'title', 'image', 'ttl', 'creativeId', 'netRevenue', 'currency'); - expect(dataItem.mediaType).to.not.exist; - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.clickUrl).to.equal('test.com'); - expect(dataItem.title).to.equal('Test'); - expect(dataItem.image).to.equal('test.com'); - expect(dataItem.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.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 () { - 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('//ssp-nj.webtradehub.com/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/smilewantedBidAdapter_spec.js b/test/spec/modules/smilewantedBidAdapter_spec.js index 144c7ca60f6d..78a793137b6d 100644 --- a/test/spec/modules/smilewantedBidAdapter_spec.js +++ b/test/spec/modules/smilewantedBidAdapter_spec.js @@ -151,11 +151,11 @@ describe('smilewantedBidAdapterTests', function () { it('SmileWanted - Verify build request with referrer', function () { const request = spec.buildRequests(DISPLAY_REQUEST, { refererInfo: { - referer: 'http://localhost/Prebid.js/integrationExamples/gpt/hello_world.html' + referer: 'https://localhost/Prebid.js/integrationExamples/gpt/hello_world.html' } }); const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('pageDomain').and.to.equal('http://localhost/Prebid.js/integrationExamples/gpt/hello_world.html'); + expect(requestContent).to.have.property('pageDomain').and.to.equal('https://localhost/Prebid.js/integrationExamples/gpt/hello_world.html'); }); describe('gdpr tests', function () { diff --git a/test/spec/modules/somoBidAdapter_spec.js b/test/spec/modules/somoBidAdapter_spec.js deleted file mode 100644 index 16fd43841b7d..000000000000 --- a/test/spec/modules/somoBidAdapter_spec.js +++ /dev/null @@ -1,481 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/somoBidAdapter'; -import * as utils from 'src/utils'; - -describe('Somo Audience Adapter Tests', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'somo', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - it('should return true when given a placementId bid', function () { - const bid = { - bidder: 'somo', - params: { - placementId: 'test' - } - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - describe('buildBannerRequests', function () { - it('should properly build a banner request with type not defined and sizes not defined', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - expect(request[0].url).to.equal('//publisher-east.mobileadtrading.com/rtb/bid?s=test'); - expect(request[0].method).to.equal('POST'); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.device).to.not.equal(null); - expect(ortbRequest.device.ua).to.equal(navigator.userAgent); - expect(ortbRequest.imp[0].bidfloor).to.not.be.null; - expect(ortbRequest.imp[0].banner).to.not.equal(null); - }); - - it('should properly build a banner request with sizes defined in 2d array', function () { - const bidRequests = [{ - bidder: 'somo', - sizes: [[300, 250]], - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - expect(request[0].url).to.equal('//publisher-east.mobileadtrading.com/rtb/bid?s=test'); - expect(request[0].method).to.equal('POST'); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].bidfloor).to.not.be.null; - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - }); - it('should properly build a banner request with sizes defined in 1d array', function () { - const bidRequests = [{ - bidder: 'somo', - sizes: [300, 250], - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - expect(request[0].url).to.equal('//publisher-east.mobileadtrading.com/rtb/bid?s=test'); - expect(request[0].method).to.equal('POST'); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].bidfloor).to.not.be.null; - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - expect(ortbRequest.imp[0].banner.mimes).to.equal(undefined); - expect(ortbRequest.imp[0].banner.btype).to.equal(undefined); - expect(ortbRequest.imp[0].banner.pos).to.equal(undefined); - expect(ortbRequest.imp[0].banner.battr).to.equal(undefined); - }); - - it('should populate optional banner parameters', function () { - const bidRequests = [ - { - bidder: 'somo', - sizes: [[300, 200]], - mediaType: 'banner', - params: { - placementId: 'test', - banner: { - mimes: 'video/mp4', - btype: '4', - pos: '1', - battr: 'ibv', - } - } - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(200); - expect(ortbRequest.imp[0].banner.mimes).to.equal('video/mp4'); - expect(ortbRequest.imp[0].banner.btype).to.equal('4'); - expect(ortbRequest.imp[0].banner.pos).to.equal('1'); - expect(ortbRequest.imp[0].banner.battr).to.equal('ibv'); - }); - }); - - describe('buildVideoRequests', function () { - it('should properly build a video request with sizes defined', function () { - const bidRequests = [{ - bidder: 'somo', - mediaTypes: { - video: {} - }, - sizes: [200, 300], - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].video).to.not.equal(null); - expect(ortbRequest.imp[0].video.w).to.equal(200); - expect(ortbRequest.imp[0].video.h).to.equal(300); - }); - - it('should properly build a video request with sizes defined in 2d array', function () { - const bidRequests = [{ - bidder: 'somo', - mediaTypes: { - video: {} - }, - sizes: [[200, 300]], - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].video).to.not.equal(null); - expect(ortbRequest.imp[0].video.w).to.equal(200); - expect(ortbRequest.imp[0].video.h).to.equal(300); - }); - it('should properly build a video request with sizes not defined', function () { - const bidRequests = [{ - bidder: 'somo', - mediaType: 'video', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].video).to.not.equal(null); - expect(ortbRequest.imp[0].video.mimes).to.equal(undefined); - expect(ortbRequest.imp[0].video.minduration).to.equal(undefined); - expect(ortbRequest.imp[0].video.maxduration).to.equal(undefined); - expect(ortbRequest.imp[0].video.protocols).to.equal(undefined); - expect(ortbRequest.imp[0].video.startdelay).to.equal(undefined); - expect(ortbRequest.imp[0].video.linearity).to.equal(undefined); - expect(ortbRequest.imp[0].video.skip).to.equal(undefined); - expect(ortbRequest.imp[0].video.delivery).to.equal(undefined); - expect(ortbRequest.imp[0].video.pos).to.equal(undefined); - expect(ortbRequest.imp[0].video.api).to.equal(undefined); - expect(ortbRequest.imp[0].video.battr).to.equal(undefined); - }); - - it('should populate optional video parameters', function () { - const bidRequests = [ - { - bidder: 'somo', - sizes: [[200, 300]], - mediaType: 'video', - params: { - placementId: 'test', - video: { - mimes: 'video/mp4', - minduration: '15', - maxduration: '30', - protocols: 'mp4', - startdelay: '0', - linearity: 'linear', - skip: '1', - delivery: 'web', - pos: '1', - api: 'VPAID 1.0', - battr: 'ibv', - } - } - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.imp[0].video).to.not.equal(null); - expect(ortbRequest.imp[0].video.w).to.equal(200); - expect(ortbRequest.imp[0].video.h).to.equal(300); - expect(ortbRequest.imp[0].video.mimes).to.equal('video/mp4'); - expect(ortbRequest.imp[0].video.minduration).to.equal('15'); - expect(ortbRequest.imp[0].video.maxduration).to.equal('30'); - expect(ortbRequest.imp[0].video.protocols).to.equal('mp4'); - expect(ortbRequest.imp[0].video.startdelay).to.equal('0'); - expect(ortbRequest.imp[0].video.linearity).to.equal('linear'); - expect(ortbRequest.imp[0].video.skip).to.equal('1'); - expect(ortbRequest.imp[0].video.delivery).to.equal('web'); - expect(ortbRequest.imp[0].video.pos).to.equal('1'); - expect(ortbRequest.imp[0].video.api).to.equal('VPAID 1.0'); - expect(ortbRequest.imp[0].video.battr).to.equal('ibv'); - }); - }); - - describe('buildSiteRequests', function () { - it('should fill in basic site parameters', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.app).to.equal(null); - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - }); - - it('should fill in optional site parameters', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test', - site: { - domain: 'somoaudience.com', - name: 'Somo Audience', - cat: 'IAB-25', - keywords: 'unit testing', - content: 'Unit Testing' - } - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.app).to.equal(null); - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.name).to.equal('Somo Audience'); - expect(ortbRequest.site.domain).to.equal('somoaudience.com'); - expect(ortbRequest.site.cat).to.equal('IAB-25'); - expect(ortbRequest.site.keywords).to.equal('unit testing'); - expect(ortbRequest.site.content).to.equal('Unit Testing'); - }) - }); - - describe('buildAppRequests', function () { - it('should fill in app parameters', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test', - app: { - bundle: 'com.somoaudience.apps', - storeUrl: 'http://somoaudience.com/apps', - domain: 'somoaudience.com', - name: 'Generic SomoAudience App 5', - cat: 'IAB-25', - keywords: 'unit testing', - content: 'Unit Testing', - ver: '5.423-s', - } - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.bundle).to.equal('com.somoaudience.apps'); - expect(ortbRequest.app.storeUrl).to.equal('http://somoaudience.com/apps'); - expect(ortbRequest.app.domain).to.equal('somoaudience.com'); - expect(ortbRequest.app.name).to.equal('Generic SomoAudience App 5'); - expect(ortbRequest.app.ver).to.equal('5.423-s'); - expect(ortbRequest.app.cat).to.equal('IAB-25'); - expect(ortbRequest.app.keywords).to.equal('unit testing'); - expect(ortbRequest.app.content).to.equal('Unit Testing'); - }); - }); - - describe('buildGDPRRequests', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'test' - }, - }; - - it('should properly build request with gdpr consent', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests, bidderRequest); - const ortbRequest = request[0].data; - expect(ortbRequest.reqs).to.not.equal(undefined); - expect(ortbRequest.reqs.ext).to.not.equal(undefined); - expect(ortbRequest.reqs.ext.gdpr).to.equal(true); - expect(ortbRequest.user).to.not.equal(undefined); - expect(ortbRequest.user.ext).to.not.equal(undefined); - expect(ortbRequest.user.ext.consent).to.equal('test'); - }); - it('should properly build request with gdpr not applies', function () { - bidderRequest.gdprConsent.gdprApplies = false; - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests, bidderRequest); - const ortbRequest = request[0].data; - expect(ortbRequest.reqs).to.not.equal(undefined); - expect(ortbRequest.reqs.ext).to.not.equal(undefined); - expect(ortbRequest.reqs.ext.gdpr).to.equal(false); - expect(ortbRequest.user).to.not.equal(undefined); - expect(ortbRequest.user.ext).to.not.equal(undefined); - expect(ortbRequest.user.ext.consent).to.equal('test'); - }); - }); - - describe('buildExtraArgsRequests', function () { - it('should populate optional parameters', function () { - const bidRequests = [ - { - bidder: 'somo', - params: { - placementId: 'test', - bcat: ['IAB-2', 'IAB-7'], - badv: ['somoaudience.com', 'mobileadtrading.com'], - bidfloor: '0.05', - }, - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.imp[0].bidfloor).to.not.be.null; - expect(ortbRequest.imp[0].bidfloor).to.be.equal('0.05'); - expect(ortbRequest.bcat).to.not.be.null; - expect(ortbRequest.bcat).to.have.lengthOf(2); - expect(ortbRequest.bcat).to.contain('IAB-2'); - expect(ortbRequest.badv).to.not.be.null; - expect(ortbRequest.badv).to.have.lengthOf(2); - expect(ortbRequest.badv).to.contain('somoaudience.com'); - }); - }); - }); - - describe('interpretResponse', function () { - it('Verify banner parse response', function () { - const bidRequests = [ - { - bidder: 'somo', - params: { - placementId: 'test', - }, - bidId: '234234234', - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'Somo Test Ad' - }], - bidId: '234234234' - }] - }; - const bids = spec.interpretResponse({ body: ortbResponse }, {bidRequest: bidRequests[0]}); - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.ad).to.equal('Somo Test Ad'); - }); - - it('Verify video parse response', function () { - const bidRequests = [ - { - bidder: 'somo', - mediaTypes: { - video: { - } - }, - params: { - placementId: 'test', - }, - bidId: '234234234', - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'Somo Test Ad' - }], - bidId: '234234234' - }] - }; - const bids = spec.interpretResponse({ body: ortbResponse }, {bidRequest: bidRequests[0]}); - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.vastXml).to.equal('Somo Test Ad'); - }); - }); - - describe('user sync', function () { - it('should register the pixel sync url', function () { - let syncs = spec.getUserSyncs({ - pixelEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - }); - - it('should pass gdpr params', function () { - let syncs = spec.getUserSyncs({ pixelEnabled: true }, {}, { - gdprApplies: false, consentString: 'test' - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.contains('gdpr=0'); - }); - - it('should pass gdpr applies params', function () { - let syncs = spec.getUserSyncs({ pixelEnabled: true }, {}, { - gdprApplies: true, consentString: 'test' - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.contains('gdpr=1'); - expect(syncs[0].url).to.contains('gdpr_consent=test'); - }); - }); -}); diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index a6bf88cfc74b..aac7d8396afb 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -297,8 +297,8 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; it('should include the digitrust id and keyv', () => { @@ -369,7 +369,7 @@ describe('SonobiBidAdapter', function () { it('should return a properly formatted request with referer', function () { bidRequest[0].params.referrer = '' const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.data.ref).to.equal('http://example.com') + expect(bidRequests.data.ref).to.equal('https://example.com') }) it('should return a properly formatted request with GDPR applies set to false', function () { @@ -390,8 +390,8 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; const bidRequests = spec.buildRequests(bidRequest, bidderRequests) @@ -410,8 +410,8 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; const bidRequests = spec.buildRequests(bidRequest, bidderRequests) @@ -547,7 +547,7 @@ describe('SonobiBidAdapter', function () { 'url': 'https://apex.go.sonobi.com/trinity.json', 'withCredentials': true, 'data': { - 'key_maker': '{"30b31c1838de1f":"1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25","/7780971/sparks_prebid_LB|30b31c1838de1e":"300x250,300x600"}', 'ref': 'http://localhost/', 's': '2474372d-c0ff-4f46-aef4-a173058403d9', 'pv': 'c9cfc207-cd83-4a01-b591-8bb29389d4b0' + 'key_maker': '{"30b31c1838de1f":"1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25","/7780971/sparks_prebid_LB|30b31c1838de1e":"300x250,300x600"}', 'ref': 'https://localhost/', 's': '2474372d-c0ff-4f46-aef4-a173058403d9', 'pv': 'c9cfc207-cd83-4a01-b591-8bb29389d4b0' }, 'bidderRequests': [ { @@ -653,7 +653,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.07, 'width': 300, 'height': 600, - 'ad': ``, + 'ad': ``, 'ttl': 500, 'creativeId': '1234abcd', 'netRevenue': true, @@ -665,7 +665,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.25, 'width': 300, 'height': 250, - 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=http%3A%2F%2Flocalhost%2F', + 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=https%3A%2F%2Flocalhost%2F', 'ttl': 500, 'creativeId': '30292e432662bd5f86d90774b944b038', 'netRevenue': true, @@ -679,7 +679,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.07, 'width': 300, 'height': 600, - 'ad': ``, + 'ad': ``, 'ttl': 500, 'creativeId': '1234abcd', 'netRevenue': true, @@ -691,7 +691,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.25, 'width': 640, 'height': 480, - 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=http%3A%2F%2Flocalhost%2F', + 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=https%3A%2F%2Flocalhost%2F', 'ttl': 500, 'creativeId': 'somecrid', 'netRevenue': true, diff --git a/test/spec/modules/sortableBidAdapter_spec.js b/test/spec/modules/sortableBidAdapter_spec.js deleted file mode 100644 index 98695f44ee09..000000000000 --- a/test/spec/modules/sortableBidAdapter_spec.js +++ /dev/null @@ -1,258 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/sortableBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -const ENDPOINT = `//c.deployads.com/openrtb2/auction?src=$$REPO_AND_VERSION$$&host=${utils.getTopWindowLocation().host}`; - -describe('sortableBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - function makeBid() { - return { - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'keywords': { - 'key1': 'val1', - 'key2': 'val2' - }, - 'floorSizeMap': { - '728x90': 0.15, - '300x250': 1.20 - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - } - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(makeBid())).to.equal(true); - }); - - it('should return false when tagId not passed correctly', function () { - let bid = makeBid(); - delete bid.params.tagId; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when sizes not passed correctly', function () { - let bid = makeBid(); - delete bid.sizes; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when sizes are wrong length', function () { - let bid = makeBid(); - bid.sizes = [[300]]; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = makeBid(); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when the floorSizeMap is invalid', function () { - let bid = makeBid(); - bid.params.floorSizeMap = { - 'sixforty by foureighty': 1234 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - bid.params.floorSizeMap = { - '728x90': 'three' - } - expect(spec.isBidRequestValid(bid)).to.equal(false); - bid.params.floorSizeMap = 'a'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when the floorSizeMap is missing or empty', function () { - let bid = makeBid(); - bid.params.floorSizeMap = {}; - expect(spec.isBidRequestValid(bid)).to.equal(true); - delete bid.params.floorSizeMap; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - it('should return false when the keywords are invalid', function () { - let bid = makeBid(); - bid.params.keywords = { - 'badval': 1234 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - bid.params.keywords = 'a'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when the keywords are missing or empty', function () { - let bid = makeBid(); - bid.params.keywords = {}; - expect(spec.isBidRequestValid(bid)).to.equal(true); - delete bid.params.keywords; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [{ - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'floor': 0.21, - 'keywords': { - 'key1': 'val1', - 'key2': 'val2' - }, - 'floorSizeMap': { - '728x90': 0.15, - '300x250': 1.20 - } - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - const request = spec.buildRequests(bidRequests); - const requestBody = JSON.parse(request.data); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request.url).to.equal(ENDPOINT); - }); - - it('sends screen dimensions', function () { - expect(requestBody.site.device.w).to.equal(screen.width); - expect(requestBody.site.device.h).to.equal(screen.height); - }); - - it('includes the ad size in the bid request', function () { - expect(requestBody.imp[0].banner.format[0].w).to.equal(300); - expect(requestBody.imp[0].banner.format[0].h).to.equal(250); - }); - - it('includes the params in the bid request', function () { - expect(requestBody.imp[0].ext.keywords).to.deep.equal( - {'key1': 'val1', - 'key2': 'val2'} - ); - expect(requestBody.site.publisher.id).to.equal('example.com'); - expect(requestBody.imp[0].tagid).to.equal('403370'); - expect(requestBody.imp[0].bidfloor).to.equal(0.21); - }); - - it('should have the floor size map set', function () { - expect(requestBody.imp[0].ext.floorSizeMap).to.deep.equal({ - '728x90': 0.15, - '300x250': 1.20 - }); - }); - }); - - describe('interpretResponse', function () { - function makeResponse() { - return { - body: { - 'id': '5e5c23a5ba71e78', - 'seatbid': [ - { - 'bid': [ - { - 'id': '6vmb3isptf', - 'crid': 'sortablescreative', - 'impid': '322add653672f68', - 'price': 1.22, - 'adm': '', - 'attr': [5], - 'h': 90, - 'nurl': 'http://nurl', - 'w': 728 - } - ], - 'seat': 'MOCK' - } - ], - 'bidid': '5e5c23a5ba71e78' - } - }; - } - - const expectedBid = { - 'requestId': '322add653672f68', - 'cpm': 1.22, - 'width': 728, - 'height': 90, - 'creativeId': 'sortablescreative', - 'dealId': null, - 'currency': 'USD', - 'netRevenue': true, - 'mediaType': 'banner', - 'ttl': 60, - 'ad': '
' - }; - - it('should get the correct bid response', function () { - let result = spec.interpretResponse(makeResponse()); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(expectedBid); - }); - - it('should handle a missing crid', function () { - let noCridResponse = makeResponse(); - delete noCridResponse.body.seatbid[0].bid[0].crid; - const fallbackCrid = noCridResponse.body.seatbid[0].bid[0].id; - let noCridResult = Object.assign({}, expectedBid, {'creativeId': fallbackCrid}); - let result = spec.interpretResponse(noCridResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noCridResult); - }); - - it('should handle a missing nurl', function () { - let noNurlResponse = makeResponse(); - delete noNurlResponse.body.seatbid[0].bid[0].nurl; - let noNurlResult = Object.assign({}, expectedBid); - noNurlResult.ad = ''; - let result = spec.interpretResponse(noNurlResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noNurlResult); - }); - - it('should handle a missing adm', function () { - let noAdmResponse = makeResponse(); - delete noAdmResponse.body.seatbid[0].bid[0].adm; - let noAdmResult = Object.assign({}, expectedBid); - delete noAdmResult.ad; - noAdmResult.adUrl = 'http://nurl'; - let result = spec.interpretResponse(noAdmResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noAdmResult); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'id': '5e5c23a5ba71e78', - 'seatbid': [] - } - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/sovrnAnalyticsAdapter_spec.js b/test/spec/modules/sovrnAnalyticsAdapter_spec.js deleted file mode 100644 index 299e22ca7903..000000000000 --- a/test/spec/modules/sovrnAnalyticsAdapter_spec.js +++ /dev/null @@ -1,546 +0,0 @@ -import sovrnAnalyticsAdapter from '../../../modules/sovrnAnalyticsAdapter' -import { expect } from 'chai' -import {config} from 'src/config' -import adaptermanager from 'src/adapterManager' -var assert = require('assert'); - -let events = require('src/events'); -let constants = require('src/constants.json'); - -/** - * Emit analytics events - * @param {array} eventArr - array of objects to define the events that will fire - * @param {object} eventObj - key is eventType, value is event - * @param {string} auctionId - the auction id to attached to the events - */ -function emitEvent(eventType, event, auctionId) { - event.auctionId = auctionId; - events.emit(constants.EVENTS[eventType], event); -} - -let auctionStartTimestamp = Date.now(); -let timeout = 3000; -let auctionInit = { - timestamp: auctionStartTimestamp, - timeout: timeout -}; -let bidderCode = 'sovrn'; -let bidderRequestId = '123bri'; -let adUnitCode = 'div'; -let adUnitCode2 = 'div2'; -let bidId = 'bidid'; -let bidId2 = 'bidid2'; -let tId = '7aafa3ee-a80a-46d7-a4a0-cbcba463d97a'; -let tId2 = '99dca3ee-a80a-46d7-a4a0-cbcba463d97e'; -let bidRequested = { - auctionStart: auctionStartTimestamp, - bidderCode: bidderCode, - bidderRequestId: bidderRequestId, - bids: [ - { - adUnitCode: adUnitCode, - bidId: bidId, - bidder: bidderCode, - bidderRequestId: '10340af0c7dc72', - sizes: [[300, 250]], - startTime: auctionStartTimestamp + 100, - transactionId: tId - }, - { - adUnitCode: adUnitCode2, - bidId: bidId2, - bidder: bidderCode, - bidderRequestId: '10340af0c7dc72', - sizes: [[300, 250]], - startTime: auctionStartTimestamp + 100, - transactionId: tId2 - } - ], - doneCbCallCount: 1, - start: auctionStartTimestamp, - timeout: timeout -}; -let bidResponse = { - bidderCode: bidderCode, - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '3870e27a5752fb', - mediaType: 'banner', - source: 'client', - requestId: bidId, - cpm: 0.8584999918937682, - creativeId: 'cridprebidrtb', - dealId: null, - currency: 'USD', - netRevenue: true, - ad: '
divvy mcdiv
', - ttl: 60000, - responseTimestamp: auctionStartTimestamp + 150, - requestTimestamp: auctionStartTimestamp + 100, - bidder: bidderCode, - adUnitCode: adUnitCode, - timeToRespond: 50, - pbLg: '0.50', - pbMg: '0.80', - pbHg: '0.85', - pbAg: '0.85', - pbDg: '0.85', - pbCg: '', - size: '300x250', - adserverTargeting: { - hb_bidder: bidderCode, - hb_adid: '3870e27a5752fb', - hb_pb: '0.85' - }, - status: 'rendered' -}; - -let bidResponse2 = { - bidderCode: bidderCode, - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '9999e27a5752fb', - mediaType: 'banner', - source: 'client', - requestId: bidId2, - cpm: 0.12, - creativeId: 'cridprebidrtb', - dealId: null, - currency: 'USD', - netRevenue: true, - ad: '
divvy mcdiv
', - ttl: 60000, - responseTimestamp: auctionStartTimestamp + 150, - requestTimestamp: auctionStartTimestamp + 100, - bidder: bidderCode, - adUnitCode: adUnitCode2, - timeToRespond: 50, - pbLg: '0.10', - pbMg: '0.10', - pbHg: '0.10', - pbAg: '0.10', - pbDg: '0.10', - pbCg: '', - size: '300x250', - adserverTargeting: { - hb_bidder: bidderCode, - hb_adid: '9999e27a5752fb', - hb_pb: '0.10' - }, - status: 'rendered' -}; -let bidAdjustment = {}; -for (var k in bidResponse) bidAdjustment[k] = bidResponse[k]; -bidAdjustment.cpm = 0.8; -let bidAdjustmentNoMatchingRequest = { - bidderCode: 'not-sovrn', - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '1', - mediaType: 'banner', - source: 'client', - requestId: '1', - cpm: 0.10, - creativeId: '', - dealId: null, - currency: 'USD', - netRevenue: true, - ad: '
divvy mcdiv
', - ttl: 60000, - responseTimestamp: auctionStartTimestamp + 150, - requestTimestamp: auctionStartTimestamp + 100, - bidder: 'not-sovrn', - adUnitCode: '', - timeToRespond: 50, - pbLg: '0.00', - pbMg: '0.10', - pbHg: '0.10', - pbAg: '0.10', - pbDg: '0.10', - pbCg: '', - size: '300x250', - adserverTargeting: { - hb_bidder: 'not-sovrn', - hb_adid: '1', - hb_pb: '0.10' - }, -}; -let bidResponseNoMatchingRequest = bidAdjustmentNoMatchingRequest; - -describe('Sovrn Analytics Adapter', function () { - let xhr; - let requests; - beforeEach(() => { - xhr = sinon.useFakeXMLHttpRequest(); - xhr.onCreate = request => requests.push(request); - requests = []; - sinon.stub(events, 'getEvents').returns([]); - }); - afterEach(() => { - xhr.restore(); - events.getEvents.restore(); - }); - - describe('enableAnalytics ', function () { - beforeEach(() => { - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - - it('should catch all events if affiliate id present', function () { - adaptermanager.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - - sinon.assert.callCount(sovrnAnalyticsAdapter.track, 5); - }); - - it('should catch no events if no affiliate id', function () { - adaptermanager.enableAnalytics({ - provider: 'sovrn', - options: { - } - }); - - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - - sinon.assert.callCount(sovrnAnalyticsAdapter.track, 0); - }); - }); - - describe('sovrnAnalyticsAdapter ', function() { - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - it('should have correct type', function () { - assert.equal(sovrnAnalyticsAdapter.getAdapterType(), 'endpoint') - }) - }); - - describe('auction data collector ', function() { - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - it('should create auctiondata record from init ', function () { - let auctionId = '123.123.123.123'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - assert(currentAuction); - let expectedTimeOutData = { - buffer: config.getConfig('timeoutBuffer'), - bidder: config.getConfig('bidderTimeout'), - }; - expect(currentAuction.auction.timeouts).to.deep.equal(expectedTimeOutData); - assert.equal(currentAuction.auction.payload, 'auction'); - assert.equal(currentAuction.auction.priceGranularity, config.getConfig('priceGranularity')) - assert.equal(currentAuction.auction.auctionId, auctionId); - assert.equal(currentAuction.auction.sovrnId, 123); - }); - it('should create a bidrequest object ', function() { - let auctionId = '234.234.234.234'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - assert(currentAuction); - let requests = currentAuction.auction.requests; - assert(requests); - assert.equal(requests.length, 1); - assert.equal(requests[0].bidderCode, bidderCode); - assert.equal(requests[0].bidderRequestId, bidderRequestId); - assert.equal(requests[0].timeout, timeout); - let bids = requests[0].bids; - assert(bids); - assert.equal(bids.length, 2); - assert.equal(bids[0].bidId, bidId); - assert.equal(bids[0].bidder, bidderCode); - assert.equal(bids[0].transactionId, tId); - assert.equal(bids[0].sizes.length, 1); - assert.equal(bids[0].sizes[0][0], 300); - assert.equal(bids[0].sizes[0][1], 250); - expect(requests[0]).to.not.have.property('doneCbCallCount'); - expect(requests[0]).to.not.have.property('auctionId'); - }); - it('should add results to the bid with response ', function () { - let auctionId = '345.345.345.345'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - emitEvent('BID_RESPONSE', bidResponse, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - let returnedBid = currentAuction.auction.requests[0].bids[0]; - assert.equal(returnedBid.bidId, bidId); - assert.equal(returnedBid.bidder, bidderCode); - assert.equal(returnedBid.transactionId, tId); - assert.equal(returnedBid.sizes.length, 1); - assert.equal(returnedBid.sizes[0][0], 300); - assert.equal(returnedBid.sizes[0][1], 250); - assert.equal(returnedBid.adserverTargeting.hb_adid, '3870e27a5752fb'); - assert.equal(returnedBid.adserverTargeting.hb_bidder, bidderCode); - assert.equal(returnedBid.adserverTargeting.hb_pb, '0.85'); - assert.equal(returnedBid.cpm, 0.8584999918937682); - }); - it('should add new unsynced bid if no request exists for response ', function () { - let auctionId = '456.456.456.456'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - emitEvent('BID_RESPONSE', bidResponseNoMatchingRequest, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - let requests = currentAuction.auction.requests; - assert(requests); - assert.equal(requests.length, 1); - let bidRequest = requests[0].bids[0]; - expect(bidRequest).to.not.have.property('adserverTargeting'); - expect(bidRequest).to.not.have.property('cpm'); - expect(currentAuction.auction.unsynced[0]).to.deep.equal(bidResponseNoMatchingRequest); - }); - it('should adjust the bid ', function () { - let auctionId = '567.567.567.567'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - emitEvent('BID_ADJUSTMENT', bidResponse, auctionId); - emitEvent('BID_RESPONSE', bidAdjustment, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - let returnedBid = currentAuction.auction.requests[0].bids[0]; - assert.equal(returnedBid.cpm, 0.8); - assert.equal(returnedBid.originalValues.cpm, 0.8584999918937682); - }); - }); - describe('auction data send ', function() { - let expectedPostBody = { - sovrnId: 123, - auctionId: '678.678.678.678', - payload: 'auction', - priceGranularity: 'medium', - }; - let expectedRequests = { - bidderCode: 'sovrn', - bidderRequestId: '123bri', - timeout: 3000 - }; - let expectedBids = { - adUnitCode: 'div', - bidId: 'bidid', - bidder: 'sovrn', - bidderRequestId: '10340af0c7dc72', - transactionId: '7aafa3ee-a80a-46d7-a4a0-cbcba463d97a', - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '3870e27a5752fb', - mediaType: 'banner', - source: 'client', - cpm: 0.8584999918937682, - creativeId: 'cridprebidrtb', - dealId: null, - currency: 'USD', - netRevenue: true, - ttl: 60000, - timeToRespond: 50, - size: '300x250', - status: 'rendered', - isAuctionWinner: true - }; - let SecondAdUnitExpectedBids = { - adUnitCode: 'div2', - bidId: 'bidid2', - bidder: 'sovrn', - bidderRequestId: '10340af0c7dc72', - transactionId: '99dca3ee-a80a-46d7-a4a0-cbcba463d97e', - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '9999e27a5752fb', - mediaType: 'banner', - source: 'client', - cpm: 0.12, - creativeId: 'cridprebidrtb', - dealId: null, - currency: 'USD', - netRevenue: true, - ttl: 60000, - timeToRespond: 50, - size: '300x250', - status: 'rendered', - isAuctionWinner: true - }; - let expectedAdServerTargeting = { - hb_bidder: 'sovrn', - hb_adid: '3870e27a5752fb', - hb_pb: '0.85' - }; - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - it('should send auction data ', function () { - let auctionId = '678.678.678.678'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - emitEvent('BID_RESPONSE', bidResponse, auctionId); - emitEvent('BID_RESPONSE', bidResponse2, auctionId) - emitEvent('AUCTION_END', {}, auctionId); - let requestBody = JSON.parse(requests[0].requestBody); - let requestsFromRequestBody = requestBody.requests[0]; - let bidsFromRequests = requestsFromRequestBody.bids[0]; - expect(requestBody).to.deep.include(expectedPostBody); - expect(requestBody.timeouts).to.deep.equal({buffer: 400, bidder: 3000}); - expect(requestsFromRequestBody).to.deep.include(expectedRequests); - expect(bidsFromRequests).to.deep.include(expectedBids); - let bidsFromRequests2 = requestsFromRequestBody.bids[1]; - expect(bidsFromRequests2).to.deep.include(SecondAdUnitExpectedBids); - expect(bidsFromRequests.adserverTargeting).to.deep.include(expectedAdServerTargeting); - }); - }); - describe('bid won data send ', function() { - let auctionId = '789.789.789.789'; - let creativeId = 'cridprebidrtb'; - let requestId = 'requestId69'; - let bidWonEvent = { - ad: 'html', - adId: 'adId', - adUnitCode: adUnitCode, - auctionId: auctionId, - bidder: bidderCode, - bidderCode: bidderCode, - cpm: 1.01, - creativeId: creativeId, - currency: 'USD', - height: 250, - mediaType: 'banner', - requestId: requestId, - size: '300x250', - source: 'client', - status: 'rendered', - statusMessage: 'Bid available', - timeToRespond: 421, - ttl: 60, - width: 300 - }; - let expectedBidWonBody = { - sovrnId: 123, - payload: 'winner' - }; - let expectedWinningBid = { - bidderCode: bidderCode, - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: 'adId', - mediaType: 'banner', - source: 'client', - requestId: requestId, - cpm: 1.01, - creativeId: creativeId, - currency: 'USD', - ttl: 60, - auctionId: auctionId, - bidder: bidderCode, - adUnitCode: adUnitCode, - timeToRespond: 421, - size: '300x250', - }; - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - it('should send bid won data ', function () { - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_WON', bidWonEvent, auctionId); - let requestBody = JSON.parse(requests[0].requestBody); - expect(requestBody).to.deep.include(expectedBidWonBody); - expect(requestBody.winningBid).to.deep.include(expectedWinningBid); - }); - }); - describe('Error Tracking', function() { - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics() - sovrnAnalyticsAdapter.track.restore() - }); - it('should send an error message when a bid is received for a closed auction', function() { - let auctionId = '678.678.678.678'; - emitEvent('AUCTION_INIT', auctionInit, auctionId) - emitEvent('BID_REQUESTED', bidRequested, auctionId) - emitEvent('AUCTION_END', {}, auctionId) - requests[0].respond(200) - emitEvent('BID_RESPONSE', bidResponse, auctionId) - let requestBody = JSON.parse(requests[1].requestBody) - expect(requestBody.payload).to.equal('error') - expect(requestBody.message).to.include('Event Received after Auction Close Auction Id') - }) - }) -}) diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js index be550e8fc837..d1be55865835 100644 --- a/test/spec/modules/spotxBidAdapter_spec.js +++ b/test/spec/modules/spotxBidAdapter_spec.js @@ -100,7 +100,7 @@ describe('the spotx adapter', function () { it('should build a very basic request', function() { var request = spec.buildRequests([bid], bidRequestObj)[0]; expect(request.method).to.equal('POST'); - expect(request.url).to.equal('//search.spotxchange.com/openrtb/2.3/dados/12345'); + expect(request.url).to.equal('https://search.spotxchange.com/openrtb/2.3/dados/12345'); expect(request.bidRequest).to.equal(bidRequestObj); expect(request.data.id).to.equal(12345); expect(request.data.ext.wrap_response).to.equal(1); @@ -359,7 +359,7 @@ describe('the spotx adapter', function () { expect(responses[0].netRevenue).to.equal(true); expect(responses[0].requestId).to.equal(123); expect(responses[0].ttl).to.equal(360); - expect(responses[0].vastUrl).to.equal('//search.spotxchange.com/ad/vast.html?key=cache123'); + expect(responses[0].vastUrl).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); expect(responses[0].width).to.equal(400); expect(responses[1].cache_key).to.equal('cache124'); expect(responses[1].channel_id).to.equal(12345); @@ -371,7 +371,7 @@ describe('the spotx adapter', function () { expect(responses[1].netRevenue).to.equal(true); expect(responses[1].requestId).to.equal(124); expect(responses[1].ttl).to.equal(360); - expect(responses[1].vastUrl).to.equal('//search.spotxchange.com/ad/vast.html?key=cache124'); + expect(responses[1].vastUrl).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache124'); expect(responses[1].width).to.equal(200); }); }); @@ -440,9 +440,9 @@ describe('the spotx adapter', function () { responses[0].renderer.render(responses[0]); expect(scriptTag.getAttribute('type')).to.equal('text/javascript'); - expect(scriptTag.getAttribute('src')).to.equal('//js.spotx.tv/easi/v1/12345.js'); + expect(scriptTag.getAttribute('src')).to.equal('https://js.spotx.tv/easi/v1/12345.js'); expect(scriptTag.getAttribute('data-spotx_channel_id')).to.equal('12345'); - expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('//search.spotxchange.com/ad/vast.html?key=cache123'); + expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); expect(scriptTag.getAttribute('data-spotx_ad_unit')).to.equal('incontent'); expect(scriptTag.getAttribute('data-spotx_collapse')).to.equal('0'); expect(scriptTag.getAttribute('data-spotx_autoplay')).to.equal('1'); @@ -472,9 +472,9 @@ describe('the spotx adapter', function () { responses[0].renderer.render(responses[0]); expect(scriptTag.getAttribute('type')).to.equal('text/javascript'); - expect(scriptTag.getAttribute('src')).to.equal('//js.spotx.tv/easi/v1/12345.js'); + expect(scriptTag.getAttribute('src')).to.equal('https://js.spotx.tv/easi/v1/12345.js'); expect(scriptTag.getAttribute('data-spotx_channel_id')).to.equal('12345'); - expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('//search.spotxchange.com/ad/vast.html?key=cache123'); + expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); expect(scriptTag.getAttribute('data-spotx_ad_unit')).to.equal('incontent'); expect(scriptTag.getAttribute('data-spotx_collapse')).to.equal('0'); expect(scriptTag.getAttribute('data-spotx_autoplay')).to.equal('1'); diff --git a/test/spec/modules/staqAnalyticsAdapter_spec.js b/test/spec/modules/staqAnalyticsAdapter_spec.js index 593871fd9d61..1b35f4918547 100644 --- a/test/spec/modules/staqAnalyticsAdapter_spec.js +++ b/test/spec/modules/staqAnalyticsAdapter_spec.js @@ -60,35 +60,35 @@ describe('', function() { it('should parse first direct visit as (direct)', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com'); + let source = getUmtSource('https://example.com'); expect(source).to.be.eql(DIRECT); }); it('should parse visit from google as organic', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); + let source = getUmtSource('https://example.com', 'https://www.google.com/search?q=pikachu'); expect(source).to.be.eql(GOOGLE_ORGANIC); }); it('should parse referral visit', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'http://lander.com/lander.html'); + let source = getUmtSource('https://example.com', 'https://lander.com/lander.html'); expect(source).to.be.eql(REFERRER); }); it('should parse referral visit from same domain as direct', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://lander.com/news.html', 'http://lander.com/lander.html'); + let source = getUmtSource('https://lander.com/news.html', 'https://lander.com/lander.html'); expect(source).to.be.eql(DIRECT); }); it('should parse campaign visit', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://lander.com/index.html?utm_campaign=new_campaign&utm_source=adkernel&utm_medium=email&utm_c1=1&utm_c2=2&utm_c3=3&utm_c4=4&utm_c5=5'); + let source = getUmtSource('https://lander.com/index.html?utm_campaign=new_campaign&utm_source=adkernel&utm_medium=email&utm_c1=1&utm_c2=2&utm_c3=3&utm_c4=4&utm_c5=5'); expect(source).to.be.eql(CAMPAIGN); }); }); @@ -208,7 +208,7 @@ describe('', function() { options: { connId: 777, queueTimeout: 1000, - url: 'http://localhost/prebid' + url: 'https://localhost/prebid' } }); diff --git a/test/spec/modules/supply2BidAdapter_spec.js b/test/spec/modules/supply2BidAdapter_spec.js deleted file mode 100644 index 8abbecd801c4..000000000000 --- a/test/spec/modules/supply2BidAdapter_spec.js +++ /dev/null @@ -1,332 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/supply2BidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('Supply2Adapter', 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': 'supply2', - 'params': { - 'uid': '16' - }, - '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': 'supply2', - 'params': { - 'uid': '16' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '16' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '17' - }, - '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', '16'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - 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', '16,17'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - it('if timeout is present, payload must have wtimeout parameter', function () { - const request = spec.buildRequests(bidRequests, {timeout: 2000}); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('wtimeout', '2000'); - }); - - 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', '16,17'); - 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); - 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', '16,17'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - 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}}); - 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 request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: false}}); - 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 request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA'}}); - 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'); - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 23, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 24, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 25, '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': 'supply2', - 'params': { - 'uid': '23' - }, - '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': 23, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'supply2', - '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': 'supply2', - 'params': { - 'uid': '23' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '24' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '23' - }, - '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': 23, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'supply2', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 23, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'supply2', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 24, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'bidderCode': 'supply2', - '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': 'supply2', - 'params': { - 'uid': '25' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '26' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '27' - }, - '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/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js index d2f024181a42..918e4e394bd0 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -133,10 +133,10 @@ describe('synacormediaBidAdapter ', function () { auctionStart: 1553624929697, timeout: 700, refererInfo: { - referer: 'http://localhost:9999/test/pages/video.html?pbjs_debug=true', + referer: 'https://localhost:9999/test/pages/video.html?pbjs_debug=true', reachedTop: true, numIframes: 0, - stack: [ 'http://localhost:9999/test/pages/video.html?pbjs_debug=true' ] + stack: [ 'https://localhost:9999/test/pages/video.html?pbjs_debug=true' ] }, start: 1553624929700 }; @@ -197,7 +197,7 @@ describe('synacormediaBidAdapter ', function () { expect(req).be.an('object'); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); expect(req.data).to.exist.and.to.be.an('object'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([expectedDataImp1, expectedDataImp2]); @@ -207,7 +207,7 @@ describe('synacormediaBidAdapter ', function () { expect(reqVideo).be.an('object'); expect(reqVideo).to.have.property('method', 'POST'); expect(reqVideo).to.have.property('url'); - expect(reqVideo.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(reqVideo.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); expect(reqVideo.data).to.exist.and.to.be.an('object'); expect(reqVideo.data.id).to.equal('VideoAuctionId124'); expect(reqVideo.data.imp).to.eql([expectedDataVideo1]); @@ -227,7 +227,7 @@ describe('synacormediaBidAdapter ', function () { expect(req).to.exist.and.be.an('object'); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([expectedDataImp1, expectedDataImp2, { banner: { @@ -254,7 +254,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([mismatchedSeatBidRequest, validBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/somethingelse?'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/somethingelse?'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -283,7 +283,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([badFloorBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -310,7 +310,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([badFloorBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -338,7 +338,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([newPosBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -365,7 +365,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([newPosBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -453,7 +453,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([validBidRequestVideo], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -511,7 +511,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([validBidRequestVideo], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -542,7 +542,7 @@ describe('synacormediaBidAdapter ', function () { price: 0.13, crid: '1022-250', adm: '', - nurl: '//uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=${AUCTION_PRICE}' + nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=${AUCTION_PRICE}' }; let bidResponse2 = { id: '10865933907263800~9999~0', @@ -550,7 +550,7 @@ describe('synacormediaBidAdapter ', function () { price: 1.99, crid: '9993-013', adm: '', - nurl: '//uat-net.technoratimedia.com/openrtb/tags?ID=OTk5OX4wJkFVQ1RJT05fU0VBVF9JR&AUCTION_PRICE=${AUCTION_PRICE}' + nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=OTk5OX4wJkFVQ1RJT05fU0VBVF9JR&AUCTION_PRICE=${AUCTION_PRICE}' }; let serverResponse; @@ -685,7 +685,7 @@ describe('synacormediaBidAdapter ', function () { expect(usersyncs).to.be.an('array').that.is.not.empty; expect(usersyncs[0]).to.have.property('type', 'iframe'); expect(usersyncs[0]).to.have.property('url'); - expect(usersyncs[0].url).to.contain('//ad-cdn.technoratimedia.com/html/usersync.html'); + expect(usersyncs[0].url).to.contain('https://ad-cdn.technoratimedia.com/html/usersync.html'); }); it('should not return a usersync when iframes are not enabled', function () { diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index 5d92f9d7a08f..5809be995dd1 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -2,8 +2,8 @@ import {expect} from 'chai'; import {spec} from 'modules/teadsBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; -const ENDPOINT = '//a.teads.tv/hb/bid-request'; -const AD_SCRIPT = '"'; +const ENDPOINT = 'https://a.teads.tv/hb/bid-request'; +const AD_SCRIPT = '"'; describe('teadsBidAdapter', () => { const adapter = newBidder(spec); @@ -136,7 +136,7 @@ describe('teadsBidAdapter', () => { 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 } @@ -145,7 +145,7 @@ describe('teadsBidAdapter', () => { const payload = JSON.parse(request.data); expect(payload.referrer).to.exist; - expect(payload.referrer).to.deep.equal('http://example.com/page.html') + expect(payload.referrer).to.deep.equal('https://example.com/page.html') }); it('should send GDPR to endpoint with 11 status', function() { @@ -380,7 +380,7 @@ describe('teadsBidAdapter', () => { } }; let hb_version = '$prebid.version$' - let finalUrl = `//sync.teads.tv/iframe?hb_provider=prebid&hb_version=${hb_version}&gdprIab={"status":12,"consent":"${consentString}"}&placementId=34&`; + let finalUrl = `https://sync.teads.tv/iframe?hb_provider=prebid&hb_version=${hb_version}&gdprIab={"status":12,"consent":"${consentString}"}&placementId=34&`; const userSync = spec.getUserSyncs(syncOptions, bids, gdprConsent); expect(userSync[0].type).to.equal('iframe'); @@ -413,7 +413,7 @@ describe('teadsBidAdapter', () => { } }; let hb_version = '$prebid.version$' - let finalUrl = `//sync.teads.tv/iframe?hb_provider=prebid&hb_version=${hb_version}&gdprIab={"status":12,"consent":"${consentString}"}&`; + let finalUrl = `https://sync.teads.tv/iframe?hb_provider=prebid&hb_version=${hb_version}&gdprIab={"status":12,"consent":"${consentString}"}&`; const userSync = spec.getUserSyncs(syncOptions, bids, gdprConsent); expect(userSync[0].type).to.equal('iframe'); diff --git a/test/spec/modules/theAdxBidAdapter_spec.js b/test/spec/modules/theAdxBidAdapter_spec.js index 5381709369c6..4874fbd08411 100644 --- a/test/spec/modules/theAdxBidAdapter_spec.js +++ b/test/spec/modules/theAdxBidAdapter_spec.js @@ -13,8 +13,8 @@ describe('TheAdxAdapter', function () { const adapter = newBidder(spec); describe('getUserSyncs', () => { - const USER_SYNC_IFRAME_URL = '//ssp.theadx.com/async_usersync_iframe.html' - const USER_SYNC_IMAGE_URL = '//ssp.theadx.com/async_usersync_image.gif' + const USER_SYNC_IFRAME_URL = 'https://ssp.theadx.com/async_usersync_iframe.html' + const USER_SYNC_IMAGE_URL = 'https://ssp.theadx.com/async_usersync_image.gif' expect(spec.getUserSyncs({ iframeEnabled: true, @@ -87,8 +87,8 @@ describe('TheAdxAdapter', function () { const sampleBidderRequest = { bidderRequestId: 'sample', refererInfo: { - canonicalUrl: 'http://domain.com/to', - referer: 'http://domain.com/from' + canonicalUrl: 'https://domain.com/to', + referer: 'https://domain.com/from' } } @@ -449,7 +449,7 @@ describe('TheAdxAdapter', function () { it('returns an valid bid response on sucessful video request', function () { let incomingRequestId = 'XXtesting-275XX'; let responsePrice = 6 - let vast_url = 'http://theadx.com/vast?rid=a8ae0b48-a8db-4220-ba0c-7458f452b1f5&{FOR_COVARAGE}' + let vast_url = 'https://theadx.com/vast?rid=a8ae0b48-a8db-4220-ba0c-7458f452b1f5&{FOR_COVARAGE}' let responseCreativeId = '1556'; let responseCurrency = 'TRY'; @@ -544,7 +544,7 @@ describe('TheAdxAdapter', function () { assets: [{ id: 3, img: { - url: '//ads.theadx.com/winwords/120/17508/154712307258.73.jpg', + url: 'https://ads.theadx.com/winwords/120/17508/154712307258.73.jpg', h: 627, w: 1200 } @@ -566,7 +566,7 @@ describe('TheAdxAdapter', function () { }, { id: 2, img: { - url: '//ads.theadx.com/winwords/120/17508/154712307258.74.png', + url: 'https://ads.theadx.com/winwords/120/17508/154712307258.74.png', h: 128, w: 128 } diff --git a/test/spec/modules/timBidAdapter_spec.js b/test/spec/modules/timBidAdapter_spec.js index 0dc14bf3e037..8e22d4716d72 100644 --- a/test/spec/modules/timBidAdapter_spec.js +++ b/test/spec/modules/timBidAdapter_spec.js @@ -77,7 +77,7 @@ describe('timAdapterTests', function () { describe('interpretResponse', function () { const bidRequest = { 'method': 'GET', - 'url': '//bidder.url/api/prebid/testpublisherid/header-bid-tag-0?br=%7B%22id%22%3A%223a3ac0d7fc2548%22%2C%22imp%22%3A%5B%7B%22id%22%3A%22251b8a6d3aac3e%22%2C%22banner%22%3A%7B%22w%22%3A300%2C%22h%22%3A250%7D%2C%22tagid%22%3A%22header-bid-tag-0%22%7D%5D%2C%22site%22%3A%7B%22domain%22%3A%22www.chinatimes.com%22%2C%22page%22%3A%22http%3A%2F%2Fwww.chinatimes.com%2Fa%22%2C%22publisher%22%3A%7B%22id%22%3A%22testpublisherid%22%7D%7D%2C%22device%22%3A%7B%22language%22%3A%22en%22%2C%22w%22%3A300%2C%22h%22%3A250%2C%22js%22%3A1%2C%22ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36%22%7D%2C%22bidId%22%3A%22251b8a6d3aac3e%22%7D', + 'url': 'https://bidder.url/api/prebid/testpublisherid/header-bid-tag-0?br=%7B%22id%22%3A%223a3ac0d7fc2548%22%2C%22imp%22%3A%5B%7B%22id%22%3A%22251b8a6d3aac3e%22%2C%22banner%22%3A%7B%22w%22%3A300%2C%22h%22%3A250%7D%2C%22tagid%22%3A%22header-bid-tag-0%22%7D%5D%2C%22site%22%3A%7B%22domain%22%3A%22www.chinatimes.com%22%2C%22page%22%3A%22https%3A%2F%2Fwww.chinatimes.com%2Fa%22%2C%22publisher%22%3A%7B%22id%22%3A%22testpublisherid%22%7D%7D%2C%22device%22%3A%7B%22language%22%3A%22en%22%2C%22w%22%3A300%2C%22h%22%3A250%2C%22js%22%3A1%2C%22ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36%22%7D%2C%22bidId%22%3A%22251b8a6d3aac3e%22%7D', 'data': '', 'options': {'withCredentials': false} }; @@ -97,7 +97,7 @@ describe('timAdapterTests', function () { const validBidRequest = { 'method': 'GET', - 'url': '//bidder.url/api/v2/services/prebid/testpublisherid/placementCodeTest?br=%7B%22id%22%3A%2248640869bd9db94%22%2C%22imp%22%3A%5B%7B%22id%22%3A%224746fcaa11197f3%22%2C%22banner%22%3A%7B%22w%22%3A300%2C%22h%22%3A250%7D%2C%22tagid%22%3A%22placementCodeTest%22%7D%5D%2C%22site%22%3A%7B%22domain%22%3A%22mediamart.tv%22%2C%22page%22%3A%22http%3A%2F%2Fmediamart.tv%2Fsas%2Ftests%2FDesktop%2Fcaesar%2Fdfptest.html%22%2C%22publisher%22%3A%7B%22id%22%3A%22testpublisherid%22%7D%7D%2C%22device%22%3A%7B%22language%22%3A%22en%22%2C%22w%22%3A300%2C%22h%22%3A250%2C%22js%22%3A1%2C%22ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36%22%7D%2C%22bidId%22%3A%224746fcaa11197f3%22%7D', + 'url': 'https://bidder.url/api/v2/services/prebid/testpublisherid/placementCodeTest?br=%7B%22id%22%3A%2248640869bd9db94%22%2C%22imp%22%3A%5B%7B%22id%22%3A%224746fcaa11197f3%22%2C%22banner%22%3A%7B%22w%22%3A300%2C%22h%22%3A250%7D%2C%22tagid%22%3A%22placementCodeTest%22%7D%5D%2C%22site%22%3A%7B%22domain%22%3A%22mediamart.tv%22%2C%22page%22%3A%22https%3A%2F%2Fmediamart.tv%2Fsas%2Ftests%2FDesktop%2Fcaesar%2Fdfptest.html%22%2C%22publisher%22%3A%7B%22id%22%3A%22testpublisherid%22%7D%7D%2C%22device%22%3A%7B%22language%22%3A%22en%22%2C%22w%22%3A300%2C%22h%22%3A250%2C%22js%22%3A1%2C%22ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36%22%7D%2C%22bidId%22%3A%224746fcaa11197f3%22%7D', 'data': '', 'options': {'withCredentials': false} }; diff --git a/test/spec/modules/topRTBBidAdapter_spec.js b/test/spec/modules/topRTBBidAdapter_spec.js index 83e5de3e4b9b..1c88658d6df4 100644 --- a/test/spec/modules/topRTBBidAdapter_spec.js +++ b/test/spec/modules/topRTBBidAdapter_spec.js @@ -39,7 +39,7 @@ describe('topRTBBidAdapterTests', function () { let serverResponse = { body: [{ 'cpm': 1, - 'mediadata': "Banner 728x90", + 'mediadata': "Banner 728x90", 'width': 728, 'currency': 'USD', 'id': 'cd95dffec6b645afbc4e5aa9f68f2ff3', diff --git a/test/spec/modules/trafficrootsBidAdapter_spec.js b/test/spec/modules/trafficrootsBidAdapter_spec.js deleted file mode 100644 index 54c102d33efd..000000000000 --- a/test/spec/modules/trafficrootsBidAdapter_spec.js +++ /dev/null @@ -1,149 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/trafficrootsBidAdapter'; - -describe('trafficrootsAdapterTests', () => { - describe('bidRequestValidity', () => { - it('bidRequest with zoneId and deliveryUrl params', () => { - expect(spec.isBidRequestValid({ - bidder: 'trafficroots', - params: { - zoneId: 'aa0444af31', - deliveryUrl: 'https://service.trafficroosts.com/prebid' - } - })).to.equal(true); - }); - - it('bidRequest with only zoneId', () => { - expect(spec.isBidRequestValid({ - bidder: 'trafficroots', - params: { - zoneId: '8f527a4835' - } - })).to.equal(true); - }); - - it('bidRequest with only deliveryUrl', () => { - expect(spec.isBidRequestValid({ - bidder: 'trafficroots', - params: { - deliveryUrl: 'https://service.trafficroosts.com/prebid' - } - })).to.equal(false); - }); - }); - - describe('bidRequest', () => { - const bidRequests = [{ - 'bidder': 'trafficroots', - 'bidId': '29fa5c08928bde', - 'params': { - 'zoneId': 'aa0444af31', - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }, { - 'bidder': 'trafficroots', - 'bidId': '29fa5c08928bde', - 'params': { - 'zoneId': '8f527a4835', - 'deliveryUrl': 'https://service.trafficroosts.com/prebid' - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - it('bidRequest method', () => { - const request = spec.buildRequests(bidRequests); - expect(request.method).to.equal('GET'); - }); - - it('bidRequest url', () => { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.match(new RegExp(`${bidRequests[1].params.deliveryUrl}`)); - }); - - it('bidRequest data', () => { - const request = spec.buildRequests(bidRequests); - expect(request.data).to.exist; - }); - - it('bidRequest zoneIds', () => { - const request = spec.buildRequests(bidRequests); - expect(request.data.zoneId).to.equal('aa0444af31;8f527a4835'); - }); - - it('bidRequest gdpr consent', () => { - const consentString = 'consentString'; - const bidderRequest = { - bidderCode: 'trafficroots', - 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', () => { - const bidRequest = [{ - 'bidder': 'trafficroots', - 'bidId': '29fa5c08928bde', - 'params': { - 'zoneId': 'aa0444af31', - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[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', () => { - 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/trionBidAdapter_spec.js b/test/spec/modules/trionBidAdapter_spec.js deleted file mode 100644 index 63c2b71a31a7..000000000000 --- a/test/spec/modules/trionBidAdapter_spec.js +++ /dev/null @@ -1,274 +0,0 @@ -import {expect} from 'chai'; -import * as utils from 'src/utils'; -import {spec, acceptPostMessage, getStorageData, setStorageData} from 'modules/trionBidAdapter'; -const CONSTANTS = require('src/constants.json'); -const adloader = require('src/adloader'); - -const PLACEMENT_CODE = 'ad-tag'; -const BID_REQUEST_BASE_URL = 'https://in-appadvertising.com/api/bidRequest'; - -const TRION_BID = { - bidder: 'trion', - params: { - pubId: '1', - sectionId: '2' - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: 'test-bid-id', - bidRequest: 'test-bid-request' -}; - -const TRION_BID_REQUEST = [TRION_BID]; - -const TRION_BID_RESPONSE = { - bidId: 'test-bid-id', - sizes: [[300, 250], [300, 600]], - result: { - cpm: 100, - placeBid: true, - height: '250', - width: '300', - ad: 'test', - msg: 'response messaging' - } - -}; - -describe('Trion adapter tests', function () { - let adapter; - - beforeEach(function () { - // adapter = trionAdapter.createNew(); - sinon.stub(document.body, 'appendChild'); - }); - - afterEach(function () { - document.body.appendChild.restore(); - }); - - describe('isBidRequestValid', function () { - it('should return true with correct params', function () { - expect(spec.isBidRequestValid(TRION_BID)).to.equal(true); - }); - - it('should return false when params are missing', function () { - TRION_BID.params = {}; - - expect(spec.isBidRequestValid(TRION_BID)).to.equal(false); - TRION_BID.params = { - pubId: '1', - sectionId: '2' - }; - }); - - it('should return false when pubId is missing', function () { - TRION_BID.params = { - sectionId: '2' - }; - - expect(spec.isBidRequestValid(TRION_BID)).to.equal(false); - TRION_BID.params = { - pubId: '1', - sectionId: '2' - }; - }); - - it('should return false when sectionId is missing', function () { - TRION_BID.params = { - pubId: '1' - }; - - expect(spec.isBidRequestValid(TRION_BID)).to.equal(false); - TRION_BID.params = { - pubId: '1', - sectionId: '2' - }; - }); - }); - - describe('buildRequests', function () { - it('should return bids requests with empty params', function () { - let bidRequests = spec.buildRequests([]); - expect(bidRequests.length).to.equal(0); - }); - - it('should include the base bidrequest url', function () { - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - - let bidUrl = bidRequests[0].url; - expect(bidUrl).to.include(BID_REQUEST_BASE_URL); - }); - - it('should call buildRequests with the correct required params', function () { - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - - let bidUrlParams = bidRequests[0].data; - expect(bidUrlParams).to.include('pubId=1'); - expect(bidUrlParams).to.include('sectionId=2'); - expect(bidUrlParams).to.include('sizes=300x250,300x600'); - }); - - it('should call buildRequests with the correct optional params', function () { - let params = TRION_BID_REQUEST[0].params; - params.re = 1; - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - - let bidUrlParams = bidRequests[0].data; - expect(bidUrlParams).to.include('re=1'); - expect(bidUrlParams).to.include(utils.getTopWindowUrl()); - delete params.re; - }); - - describe('webdriver', function () { - let originalWD; - - beforeEach(function () { - originalWD = window.navigator.webdriver; - window.navigator['__defineGetter__']('webdriver', function () { - return 1; - }); - }); - - afterEach(function () { - window.navigator['__defineGetter__']('webdriver', function () { - return originalWD; - }); - }); - - it('should send the correct state when there is non human traffic', function () { - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - let bidUrlParams = bidRequests[0].data; - expect(bidUrlParams).to.include('tr_wd=1'); - }); - }); - - describe('visibility', function () { - let originalHD; - let originalVS; - - beforeEach(function () { - originalHD = document.hidden; - originalVS = document.visibilityState; - document['__defineGetter__']('hidden', function () { - return 1; - }); - document['__defineGetter__']('visibilityState', function () { - return 'hidden'; - }); - }); - - afterEach(function () { - document['__defineGetter__']('hidden', function () { - return originalHD; - }); - document['__defineGetter__']('visibilityState', function () { - return originalVS; - }); - }); - - it('should send the correct states when the document is not visible', function () { - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - let bidUrlParams = bidRequests[0].data; - expect(bidUrlParams).to.include('tr_hd=1'); - expect(bidUrlParams).to.include('tr_vs=hidden'); - }); - }); - }); - - describe('interpretResponse', function () { - it('when there is no response do not bid', function () { - let response = spec.interpretResponse(null, {bidRequest: TRION_BID}); - expect(response).to.deep.equal([]); - }); - - it('when place bid is returned as false', function () { - TRION_BID_RESPONSE.result.placeBid = false; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - - expect(response).to.deep.equal([]); - - TRION_BID_RESPONSE.result.placeBid = true; - }); - - it('when no cpm is in the response', function () { - TRION_BID_RESPONSE.result.cpm = 0; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - expect(response).to.deep.equal([]); - TRION_BID_RESPONSE.result.cpm = 1; - }); - - it('when no ad is in the response', function () { - TRION_BID_RESPONSE.result.ad = null; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - expect(response).to.deep.equal([]); - TRION_BID_RESPONSE.result.ad = 'test'; - }); - - it('height and width are appropriately set', function () { - let bidWidth = '1'; - let bidHeight = '2'; - TRION_BID_RESPONSE.result.width = bidWidth; - TRION_BID_RESPONSE.result.height = bidHeight; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - expect(response[0].width).to.equal(bidWidth); - expect(response[0].height).to.equal(bidHeight); - TRION_BID_RESPONSE.result.width = '300'; - TRION_BID_RESPONSE.result.height = '250'; - }); - - it('cpm is properly set and transformed to cents', function () { - let bidCpm = 2; - TRION_BID_RESPONSE.result.cpm = bidCpm * 100; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - expect(response[0].cpm).to.equal(bidCpm); - TRION_BID_RESPONSE.result.cpm = 100; - }); - }); - - describe('getUserSyncs', function () { - const USER_SYNC_URL = 'https://in-appadvertising.com/api/userSync.html'; - const BASE_KEY = '_trion_'; - - beforeEach(function () { - delete window.TR_INT_T; - }); - - it('trion int is included in bid url', function () { - window.TR_INT_T = 'test_user_sync'; - let userTag = encodeURIComponent(window.TR_INT_T); - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - let bidUrlParams = bidRequests[0].data; - - expect(bidUrlParams).to.include(userTag); - }); - - it('should register trion user script', function () { - let syncs = spec.getUserSyncs({iframeEnabled: true}); - let url = utils.getTopWindowUrl(); - let pubId = 1; - let sectionId = 2; - let syncString = `?p=${pubId}&s=${sectionId}&u=${url}`; - expect(syncs[0]).to.deep.equal({type: 'iframe', url: USER_SYNC_URL + syncString}); - }); - - it('should except posted messages from user sync script', function () { - let testId = 'testId'; - let message = BASE_KEY + 'userId=' + testId; - setStorageData(BASE_KEY + 'int_t', null); - acceptPostMessage({data: message}); - let newKey = getStorageData(BASE_KEY + 'int_t'); - expect(newKey).to.equal(testId); - }); - - it('should not try to post messages not from trion', function () { - let testId = 'testId'; - let badId = 'badId'; - let message = 'Not Trion: userId=' + testId; - setStorageData(BASE_KEY + 'int_t', badId); - acceptPostMessage({data: message}); - let newKey = getStorageData(BASE_KEY + 'int_t'); - expect(newKey).to.equal(badId); - }); - }); -}); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index aee4c4d25861..76c549c98ab5 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -105,7 +105,7 @@ describe('triplelift adapter', function () { } ], refererInfo: { - referer: 'http://examplereferer.com' + referer: 'https://examplereferer.com' }, gdprConsent: { consentString: GDPR_CONSENT_STR, @@ -279,7 +279,7 @@ describe('triplelift adapter', function () { } ], refererInfo: { - referer: 'http://examplereferer.com' + referer: 'https://examplereferer.com' }, gdprConsent: { consentString: GDPR_CONSENT_STR, @@ -353,7 +353,7 @@ describe('triplelift adapter', function () { } ], refererInfo: { - referer: 'http://examplereferer.com' + referer: 'https://examplereferer.com' }, gdprConsent: { consentString: GDPR_CONSENT_STR, diff --git a/test/spec/modules/trustxBidAdapter_spec.js b/test/spec/modules/trustxBidAdapter_spec.js index aee6311cb857..bf9c0d9c895b 100644 --- a/test/spec/modules/trustxBidAdapter_spec.js +++ b/test/spec/modules/trustxBidAdapter_spec.js @@ -50,7 +50,7 @@ describe('TrustXAdapter', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const referrer = bidderRequest.refererInfo.referer; @@ -792,12 +792,12 @@ describe('TrustXAdapter', function () { expect(spyRendererInstall.calledTwice).to.equal(true); expect(spyRendererInstall.getCall(0).args[0]).to.deep.equal({ id: 'e6e65553fc8', - url: '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', loaded: false }); expect(spyRendererInstall.getCall(1).args[0]).to.deep.equal({ id: 'c8fdcb3f269f', - url: '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', loaded: false }); diff --git a/test/spec/modules/turktelekomBidAdapter_spec.js b/test/spec/modules/turktelekomBidAdapter_spec.js index 066d2724a978..e591da905630 100644 --- a/test/spec/modules/turktelekomBidAdapter_spec.js +++ b/test/spec/modules/turktelekomBidAdapter_spec.js @@ -50,7 +50,7 @@ describe('TurkTelekomAdapter', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const referrer = bidderRequest.refererInfo.referer; @@ -735,12 +735,12 @@ describe('TurkTelekomAdapter', function () { expect(spyRendererInstall.calledTwice).to.equal(true); expect(spyRendererInstall.getCall(0).args[0]).to.deep.equal({ id: 'e6e65553fc8', - url: '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', loaded: false }); expect(spyRendererInstall.getCall(1).args[0]).to.deep.equal({ id: 'c8fdcb3f269f', - url: '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', loaded: false }); diff --git a/test/spec/modules/ucfunnelBidAdapter_spec.js b/test/spec/modules/ucfunnelBidAdapter_spec.js deleted file mode 100644 index bebd780a5870..000000000000 --- a/test/spec/modules/ucfunnelBidAdapter_spec.js +++ /dev/null @@ -1,243 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/ucfunnelBidAdapter'; -import {BANNER, VIDEO, NATIVE} from 'src/mediaTypes'; - -const URL = '//hb.aralego.com/header'; -const BIDDER_CODE = 'ucfunnel'; -const validBannerBidReq = { - bidder: BIDDER_CODE, - params: { - adid: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D', - bidfloor: 1.0 - }, - sizes: [[300, 250]], - bidId: '263be71e91dd9d', - auctionId: '9ad1fa8d-2297-4660-a018-b39945054746', - 'schain': { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ - { - 'asi': 'exchange1.com', - 'sid': '1234', - 'hp': 1, - 'rid': 'bid-request-1', - 'name': 'publisher', - 'domain': 'publisher.com' - } - ] - } -}; - -const invalidBannerBidReq = { - bidder: BIDDER_CODE, - params: { - adid: 123456789 - }, - sizes: [[300, 250]], - bidId: '263be71e91dd9d', - auctionId: '9ad1fa8d-2297-4660-a018-b39945054746' -}; - -const validBannerBidRes = { - creative_type: BANNER, - ad_id: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D', - adm: '
', - cpm: 1.01, - height: 250, - width: 300 -}; - -const invalidBannerBidRes = ''; - -const validVideoBidReq = { - bidder: BIDDER_CODE, - params: { - adid: 'ad-9A22D466494297EAC443D967B2622DA9' - }, - sizes: [[640, 360]], - bidId: '263be71e91dd9f', - auctionId: '9ad1fa8d-2297-4660-a018-b39945054746', -}; - -const validVideoBidRes = { - creative_type: VIDEO, - ad_id: 'ad-9A22D466494297EAC443D967B2622DA9', - vastUrl: 'https://ads.aralego.com/ads/58f9749f-0553-4993-8d9a-013a38b29e55', - vastXml: 'ucX I-Primo 00:00:30', - cpm: 1.01, - width: 640, - height: 360 -}; - -const validNativeBidReq = { - bidder: BIDDER_CODE, - params: { - adid: 'ad-627736446B2BD3A60E8AEABDB7BD833E' - }, - sizes: [[1, 1]], - bidId: '263be71e91dda0', - auctionId: '9ad1fa8d-2297-4660-a018-b39945054746', -}; - -const validNativeBidRes = { - creative_type: NATIVE, - ad_id: 'ad-9A22D466494297EAC443D967B2622DA9', - native: { - title: 'ucfunnel adExchange', - body: 'We monetize your traffic via historic data driven protocol', - cta: 'Learn more', - sponsoredBy: 'ucfunnel Co., Ltd.', - image: { - url: 'https://cdn.aralego.net/img/main/AdGent-1200x627.jpg', - width: 1200, - height: 627 - }, - icon: { - url: 'https://cdn.aralego.net/img/logo/logo-84x84.jpg', - widt: 84, - heigh: 84 - }, - clickUrl: 'https://www.ucfunnel.com', - impressionTrackers: ['https://www.aralego.net/imp?mf=native&adid=ad-9A22D466494297EAC443D967B2622DA9&auc=9ad1fa8d-2297-4660-a018-b39945054746'], - }, - cpm: 1.01, - height: 1, - width: 1 -}; - -describe('ucfunnel Adapter', function () { - describe('request', function () { - it('should validate bid request', function () { - expect(spec.isBidRequestValid(validBannerBidReq)).to.equal(true); - }); - it('should not validate incorrect bid request', function () { - expect(spec.isBidRequestValid(invalidBannerBidReq)).to.equal(false); - }); - }); - describe('build request', function () { - const request = spec.buildRequests([validBannerBidReq]); - it('should create a POST request for every bid', function () { - expect(request[0].method).to.equal('GET'); - expect(request[0].url).to.equal(location.protocol + spec.ENDPOINT); - }); - - it('should attach the bid request object', function () { - expect(request[0].bidRequest).to.equal(validBannerBidReq); - }); - - it('should attach request data', function () { - const data = request[0].data; - const [ width, height ] = validBannerBidReq.sizes[0]; - expect(data.w).to.equal(width); - expect(data.h).to.equal(height); - expect(data.schain).to.equal('1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com'); - }); - - it('must parse bid size from a nested array', function () { - const width = 640; - const height = 480; - validBannerBidReq.sizes = [[ width, height ]]; - const requests = spec.buildRequests([ validBannerBidReq ]); - const data = requests[0].data; - expect(data.w).to.equal(width); - expect(data.h).to.equal(height); - }); - }); - - describe('interpretResponse', function () { - describe('should support banner', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: validBannerBidRes}, request[0]); - it('should build bid array for banner', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.mediaType).to.equal(BANNER); - expect(bid.ad).to.exist; - expect(bid.requestId).to.equal('263be71e91dd9d'); - expect(bid.cpm).to.equal(1.01); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - }); - }); - - describe('handle banner no ad', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]); - it('should build bid array for banner', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.ad).to.exist; - expect(bid.requestId).to.equal('263be71e91dd9d'); - expect(bid.cpm).to.equal(0); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - }); - }); - - describe('handle banner cpm under bidfloor', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]); - it('should build bid array for banner', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.ad).to.exist; - expect(bid.requestId).to.equal('263be71e91dd9d'); - expect(bid.cpm).to.equal(0); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - }); - }); - - describe('should support video', function () { - const request = spec.buildRequests([ validVideoBidReq ]); - const result = spec.interpretResponse({body: validVideoBidRes}, request[0]); - it('should build bid array', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.mediaType).to.equal(VIDEO); - expect(bid.vastUrl).to.exist; - expect(bid.vastXml).to.exist; - expect(bid.requestId).to.equal('263be71e91dd9f'); - expect(bid.cpm).to.equal(1.01); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(360); - }); - }); - - describe('should support native', function () { - const request = spec.buildRequests([ validNativeBidReq ]); - const result = spec.interpretResponse({body: validNativeBidRes}, request[0]); - it('should build bid array', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.mediaType).to.equal(NATIVE); - expect(bid.native).to.exist; - expect(bid.requestId).to.equal('263be71e91dda0'); - expect(bid.cpm).to.equal(1.01); - expect(bid.width).to.equal(1); - expect(bid.height).to.equal(1); - }); - }); - }); -}); diff --git a/test/spec/modules/undertoneBidAdapter_spec.js b/test/spec/modules/undertoneBidAdapter_spec.js index 676f27146932..7e8084dcb0ca 100644 --- a/test/spec/modules/undertoneBidAdapter_spec.js +++ b/test/spec/modules/undertoneBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/undertoneBidAdapter'; -const URL = '//hb.undertone.com/hb'; +const URL = 'https://hb.undertone.com/hb'; const BIDDER_CODE = 'undertone'; const validBidReq = { bidder: BIDDER_CODE, @@ -218,7 +218,7 @@ describe('Undertone Adapter', function () { arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, null], expect: { type: 'iframe', - pixels: ['//cdn.undertone.com/js/usersync.html'] + pixels: ['https://cdn.undertone.com/js/usersync.html'] } }, { @@ -226,7 +226,7 @@ describe('Undertone Adapter', function () { arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}], expect: { type: 'iframe', - pixels: ['//cdn.undertone.com/js/usersync.html?gdpr=1&gdprstr=234234'] + pixels: ['https://cdn.undertone.com/js/usersync.html?gdpr=1&gdprstr=234234'] } }, { @@ -234,7 +234,7 @@ describe('Undertone Adapter', function () { arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, {gdprApplies: false}], expect: { type: 'iframe', - pixels: ['//cdn.undertone.com/js/usersync.html?gdpr=0&gdprstr='] + pixels: ['https://cdn.undertone.com/js/usersync.html?gdpr=0&gdprstr='] } }, { @@ -242,8 +242,8 @@ describe('Undertone Adapter', function () { arguments: [{ pixelEnabled: true }, {}, null], expect: { type: 'image', - pixels: ['//usr.undertone.com/userPixel/syncOne?id=1&of=2', - '//usr.undertone.com/userPixel/syncOne?id=2&of=2'] + pixels: ['https://usr.undertone.com/userPixel/syncOne?id=1&of=2', + 'https://usr.undertone.com/userPixel/syncOne?id=2&of=2'] } }, { @@ -251,8 +251,8 @@ describe('Undertone Adapter', function () { arguments: [{ pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}], expect: { type: 'image', - pixels: ['//usr.undertone.com/userPixel/syncOne?id=1&of=2&gdpr=1&gdprstr=234234', - '//usr.undertone.com/userPixel/syncOne?id=2&of=2&gdpr=1&gdprstr=234234'] + pixels: ['https://usr.undertone.com/userPixel/syncOne?id=1&of=2&gdpr=1&gdprstr=234234', + 'https://usr.undertone.com/userPixel/syncOne?id=2&of=2&gdpr=1&gdprstr=234234'] } }, { @@ -260,8 +260,8 @@ describe('Undertone Adapter', function () { arguments: [{ pixelEnabled: true }, {}, {gdprApplies: false}], expect: { type: 'image', - pixels: ['//usr.undertone.com/userPixel/syncOne?id=1&of=2&gdpr=0&gdprstr=', - '//usr.undertone.com/userPixel/syncOne?id=2&of=2&gdpr=0&gdprstr='] + pixels: ['https://usr.undertone.com/userPixel/syncOne?id=1&of=2&gdpr=0&gdprstr=', + 'https://usr.undertone.com/userPixel/syncOne?id=2&of=2&gdpr=0&gdprstr='] } } ]; diff --git a/test/spec/modules/unrulyBidAdapter_spec.js b/test/spec/modules/unrulyBidAdapter_spec.js index cb30fcf1a9d6..3cab4d865917 100644 --- a/test/spec/modules/unrulyBidAdapter_spec.js +++ b/test/spec/modules/unrulyBidAdapter_spec.js @@ -11,7 +11,7 @@ describe('UnrulyAdapter', function () { adUnitCode = 'placement2', statusCode = 1, bidId = 'foo', - vastUrl = 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22http%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347' + vastUrl = 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22https%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347' }) { return { 'ext': { @@ -144,7 +144,7 @@ describe('UnrulyAdapter', function () { cpm: 20, width: 323, height: 323, - vastUrl: 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22http%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347', + vastUrl: 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22https%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347', netRevenue: true, creativeId: 'mockBidId', ttl: 360, diff --git a/test/spec/modules/uolBidAdapter_spec.js b/test/spec/modules/uolBidAdapter_spec.js deleted file mode 100644 index e9341772e7d9..000000000000 --- a/test/spec/modules/uolBidAdapter_spec.js +++ /dev/null @@ -1,308 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/uolBidAdapter'; - -const ENDPOINT = 'https://prebid.adilligo.com/v1/prebid.json'; - -describe('UOL Bid Adapter', function () { - let sandbox; - let queryStub; - let getCurrentPositionStub; - - beforeEach(function() { - sandbox = sinon.sandbox.create(); - }); - - afterEach(function() { - sandbox.restore(); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'uol', - 'params': { - 'placementId': '19571273' - }, - 'adUnitCode': '/uol/unit/code', - 'sizes': [[300, 250], [970, 250]], - 'bidId': '3ddb6ed2d73b45', - 'bidderRequestId': 'd2b12f9d2bad975b7', - 'auctionId': 'eb511c63-df7e-4240-9b65-2f8ae50303e4', - }; - - it('should return true for valid params', function () { - let clonedBid = Object.assign({}, bid); - expect(spec.isBidRequestValid(clonedBid)).to.equal(true); - - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571277', - 'test': 'true' - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(true); - - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571278', - 'test': 'true', - 'cpmFactor': 2 - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let clonedBid = Object.assign({}, bid); - delete clonedBid.params; - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - }); - - it('should return false when params are invalid', function () { - let clonedBid = Object.assign({}, bid); - delete clonedBid.params; - clonedBid.params = { - 'placementId': 0 - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571281', - 'cpmFactor': 2 - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571282', - 'cpmFactor': 'two' - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - }); - - it('should return false when cpmFactor is passed and test flag isn\'t active', function () { - let clonedBid = Object.assign({}, bid); - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571283', - 'test': false, - 'cpmFactor': 2 - }; - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - }); - - it('should not allow empty size', function () { - let clonedBid = Object.assign({}, bid); - delete clonedBid.sizes; - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'uol', - 'params': { - 'placementId': '19571273' - }, - 'adUnitCode': '/uol/unit/code', - 'sizes': [[300, 250]], - 'bidId': '3ddb6ed2d73b45', - 'bidderRequestId': 'd2b12f9d2bad975b7', - 'auctionId': 'eb511c63-df7e-4240-9b65-2f8ae50303e4', - }, { - 'bidder': 'uol', - 'params': { - 'placementId': '19571274' - }, - 'adUnitCode': '/uol/unit/code2', - 'sizes': [[300, 600], [970, 250]], - 'bidId': '3a3ea8e80a2dc5', - 'bidderRequestId': 'd2b12f9d2bad975b7', - 'auctionId': 'eb511c63-df7e-4240-9b65-2f8ae50303e4', - } - ]; - - let bidderRequest = { - 'auctionId': 'eb511c63-df7e-4240-9b65-2f8ae50303e4', - 'auctionStart': 1530133180799, - 'bidderCode': 'uol', - 'bidderRequestId': 'd2b12f9d2bad975b7', - 'bids': bidRequests, - 'doneCbCallCount': 1, - 'start': 1530133180801, - 'timeout': 3000 - }; - - describe('buildRequest basic params', function () { - const requestObject = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(requestObject.data); - - it('should send bid requests to expected endpoint via POST method', function () { - expect(requestObject.url).to.equal(ENDPOINT); - expect(requestObject.method).to.equal('POST'); - }); - - it('should contain referrer URL', function () { - expect(payload.referrerURL).to.exist.and.to.match(/^http(s)?:\/\/.+$/) - }); - - it('should contain an array of requests with length equivalent to bid count', function () { - expect(payload.requests).to.have.length(bidRequests.length); - }); - it('should return propper ad size if at least one entry is provided', function () { - expect(payload.requests[0].sizes).to.deep.equal(bidRequests[0].sizes); - }); - }); - - if (navigator.permissions && navigator.permissions.query && navigator.geolocation) { - describe('buildRequest geolocation param', function () { // shall only be tested if browser engine supports geolocation and permissions API. - let geolocation = { lat: 4, long: 3, timestamp: 123121451 }; - - beforeEach(function() { - getCurrentPositionStub = sandbox.stub(navigator.geolocation, 'getCurrentPosition'); - queryStub = sandbox.stub(navigator.permissions, 'query'); - }); - - it('should not contain user coordinates if browser doesnt support permission query', function () { - localStorage.setItem('uolLocationTracker', JSON.stringify(geolocation)); - navigator.permissions.query = undefined; - const requestObject = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(requestObject.data); - expect(payload.geolocation).to.not.exist; - }) - - it('should contain user coordinates if (i) DNT is off; (ii) browser supports implementation; (iii) localStorage contains geolocation history', function (done) { - localStorage.setItem('uolLocationTracker', JSON.stringify(geolocation)); - queryStub.callsFake(function() { - return new Promise((resolve, reject) => { - resolve({state: 'granted'}); - }); - }); - getCurrentPositionStub.callsFake(() => done()); - const requestObject = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(requestObject.data); - expect(payload.geolocation).to.exist.and.not.be.empty; - }) - - it('should not contain user coordinates if localStorage is empty', function () { - localStorage.removeItem('uolLocationTracker'); - queryStub.callsFake(function() { - return new Promise((resolve, reject) => { - resolve({state: 'prompt'}); - }); - }); - const requestObject = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(requestObject.data); - expect(payload.geolocation).to.not.exist; - }) - }) - } - describe('buildRequest test params', function () { - it('should return test and cpmFactor params if defined', function () { - let clonedBid = JSON.parse(JSON.stringify(bidRequests)); - delete clonedBid[0].params; - clonedBid.splice(1, 1); - clonedBid[0].params = { - 'placementId': '19571277', - 'test': true - } - let requestObject = spec.buildRequests(clonedBid, bidderRequest); - let payload = JSON.parse(requestObject.data); - expect(payload.requests[0].customParams.test).to.exist.and.equal(true); - expect(payload.requests[0].customParams.cpmFactor).to.be.an('undefined'); - - delete clonedBid[0].params; - clonedBid[0].params = { - 'placementId': '19571278', - 'test': true, - 'cpmFactor': 2 - } - requestObject = spec.buildRequests(clonedBid, bidderRequest); - payload = JSON.parse(requestObject.data); - expect(payload.requests[0].customParams.test).to.exist.and.equal(true); - expect(payload.requests[0].customParams.cpmFactor).to.exist.and.equal(2); - }); - }) - }); - - describe('interpretResponse', function () { - let serverResponse = { - 'body': { - 'bidderRequestId': '2a21a2fc993ef9', - 'ads': [{ - 'currency': 'BRL', - 'creativeId': '12334', - 'cpm': 1.9, - 'ttl': 300, - 'netRevenue': false, - 'ad': '', - 'width': 300, - 'height': 250, - 'bidId': '26df49c6447b82', - 'mediaType': 'banner' - }, { - 'currency': 'BRL', - 'creativeId': '12335', - 'cpm': 1.99, - 'ttl': 300, - 'netRevenue': false, - 'ad': '', - 'width': 300, - 'height': 600, - 'bidId': '26df49c6447b82', - 'mediaType': 'banner' - }] - }, - 'headers': {} - }; - let bidRequest = {}; - - it('should return the correct bid response structure', function () { - let expectedResponse = [ - { - 'requestId': '2a21a2fc993ef9', - 'cpm': 1.9, - 'width': 300, - 'height': 250, - 'creativeId': '12335', - 'currency': 'BRL', - 'dealId': null, - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 300, - 'ad': '' - } - ]; - let result = spec.interpretResponse(serverResponse, {bidRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('should corretly return an empty array of bidResponses if no ads were received', function () { - let emptyResponse = Object.assign({}, serverResponse); - emptyResponse.body.ads = []; - let result = spec.interpretResponse(emptyResponse, {bidRequest}); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - let syncOptions = { iframeEnabled: true }; - let serverResponses = [{ body: { trackingPixel: 'https://www.uol.com.br' } }, { body: { trackingPixel: 'http://www.dynad.net/' } }]; - - it('should return the two sync params for iframeEnabled bids with a trackingPixel response', function () { - expect(spec.getUserSyncs(syncOptions, serverResponses)).to.have.length(2); - }) - - it('should not return any sync params if iframe is disabled or no trackingPixel is received', function () { - let cloneOptions = Object.assign({}, syncOptions); - delete cloneOptions.iframeEnabled; - expect(spec.getUserSyncs(cloneOptions, serverResponses)).to.have.length(0); - - let cloneResponses = Object.assign({}, serverResponses); - delete cloneResponses[0].body.trackingPixel; - delete cloneResponses[1].body.trackingPixel; - expect(spec.getUserSyncs(syncOptions, cloneResponses)).to.have.length(0); - - expect(spec.getUserSyncs(cloneOptions, cloneResponses)).to.have.length(0); - }) - }); -}); diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 40ffb726051c..ed4d565c0993 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -10,8 +10,8 @@ import {config} from 'src/config'; import * as utils from 'src/utils'; import events from 'src/events'; import CONSTANTS from 'src/constants.json'; -import {unifiedIdSubmodule} from 'modules/userId/unifiedIdSystem'; -import {pubCommonIdSubmodule} from 'modules/userId/pubCommonIdSystem'; +import {unifiedIdSubmodule} from 'modules/unifiedIdSystem'; +import {pubCommonIdSubmodule} from 'modules/pubCommonIdSystem'; import {britepoolIdSubmodule} from 'modules/britepoolIdSystem'; import {id5IdSubmodule} from 'modules/id5IdSystem'; import {identityLinkSubmodule} from 'modules/identityLinkIdSystem'; diff --git a/test/spec/modules/vertamediaBidAdapter_spec.js b/test/spec/modules/vertamediaBidAdapter_spec.js deleted file mode 100644 index fefa8e446ed8..000000000000 --- a/test/spec/modules/vertamediaBidAdapter_spec.js +++ /dev/null @@ -1,218 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/vertamediaBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const ENDPOINT = '//hb2.vertamedia.com/auction/'; - -const DISPLAY_REQUEST = { - 'bidder': 'vertamedia', - 'params': { - 'aid': 12345 - }, - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [300, 250] -}; - -const VIDEO_REQUEST = { - 'bidder': 'vertamedia', - 'mediaTypes': { - 'video': {} - }, - 'params': { - 'aid': 12345 - }, - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [[480, 360], [640, 480]] -}; - -const SERVER_VIDEO_RESPONSE = { - 'source': {'aid': 12345, 'pubId': 54321}, - 'bids': [{ - 'vastUrl': 'http://rtb.vertamedia.com/vast/?adid=44F2AEB9BFC881B3', - 'requestId': '2e41f65424c87c', - 'url': '44F2AEB9BFC881B3', - 'creative_id': 342516, - 'cmpId': 342516, - 'height': 480, - 'cur': 'USD', - 'width': 640, - 'cpm': 0.9 - } - ] -}; -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 - }] -}; - -const videoBidderRequest = { - bidderCode: 'bidderCode', - bids: [{mediaTypes: {video: {}}, bidId: '2e41f65424c87c'}] -}; - -const displayBidderRequest = { - bidderCode: 'bidderCode', - bids: [{bidId: '2e41f65424c87c'}] -}; - -const videoEqResponse = [{ - vastUrl: 'http://rtb.vertamedia.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('vertamediaBidAdapter', 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 true when required params found', function () { - expect(spec.isBidRequestValid(VIDEO_REQUEST)).to.equal(12345); - }); - - 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); - }); - }); - - describe('buildRequests', function () { - let videoBidRequests = [VIDEO_REQUEST]; - let dispalyBidRequests = [DISPLAY_REQUEST]; - - const displayRequest = spec.buildRequests(dispalyBidRequests, {}); - const videoRequest = spec.buildRequests(videoBidRequests, {}); - - it('sends bid request to ENDPOINT via GET', function () { - expect(videoRequest.method).to.equal('GET'); - expect(displayRequest.method).to.equal('GET'); - }); - - it('sends bid request to correct ENDPOINT', function () { - expect(videoRequest.url).to.equal(ENDPOINT); - expect(displayRequest.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,640x480' - }; - - 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' - }; - - 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(); - }); - - 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/vertozBidAdapter_spec.js b/test/spec/modules/vertozBidAdapter_spec.js deleted file mode 100644 index 1eb85b6b5668..000000000000 --- a/test/spec/modules/vertozBidAdapter_spec.js +++ /dev/null @@ -1,112 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/vertozBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const BASE_URI = '//hb.vrtzads.com/vzhbidder/bid?'; - -describe('VertozAdapter', 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': 'vertoz', - 'params': { - 'placementId': 'VZ-HB-B784382V6C6G3C' - }, - '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': 'vertoz', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(BASE_URI); - expect(request.method).to.equal('POST'); - }); - }); - - describe('interpretResponse', function () { - let response = { - 'vzhPlacementId': 'VZ-HB-B784382V6C6G3C', - 'bid': '76021e56-adaf-4114-b68d-ccacd1b3e551_1', - 'adWidth': '300', - 'adHeight': '250', - 'cpm': '0.16312590000000002', - 'ad': '', - 'slotBidId': '44b3fcfd24aa93', - 'nurl': '', - 'statusText': 'Vertoz:Success' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '44b3fcfd24aa93', - 'cpm': 0.16312590000000002, - 'width': 300, - 'height': 250, - 'netRevenue': true, - 'mediaType': 'banner', - 'currency': 'USD', - 'dealId': null, - 'creativeId': null, - 'ttl': 300, - 'ad': '' - } - ]; - let bidderRequest; - let result = spec.interpretResponse({body: response}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - expect(result[0].cpm).to.not.equal(null); - }); - - it('handles nobid responses', function () { - let response = { - 'vzhPlacementId': 'VZ-HB-I617046VBGE3EH', - 'slotBidId': 'f00412ac86b79', - 'statusText': 'NO_BIDS' - }; - let bidderRequest; - - let result = spec.interpretResponse({body: response}); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/vidazooBidAdapter_spec.js b/test/spec/modules/vidazooBidAdapter_spec.js index 3251a1ef8517..c1fd63f599ce 100644 --- a/test/spec/modules/vidazooBidAdapter_spec.js +++ b/test/spec/modules/vidazooBidAdapter_spec.js @@ -25,7 +25,7 @@ const BIDDER_REQUEST = { 'consentString': 'consent_string' }, 'refererInfo': { - 'referer': 'http://www.greatsite.com' + 'referer': 'https://www.greatsite.com' } }; @@ -127,7 +127,7 @@ describe('VidazooBidAdapter', function () { consent: 'consent_string', width: '300', height: '250', - url: 'http%3A%2F%2Fwww.greatsite.com', + url: 'https%3A%2F%2Fwww.greatsite.com', cb: 1000, bidFloor: 0.1, bidId: '2d52001cabd527', @@ -143,7 +143,7 @@ describe('VidazooBidAdapter', function () { consent: 'consent_string', width: '300', height: '600', - url: 'http%3A%2F%2Fwww.greatsite.com', + url: 'https%3A%2F%2Fwww.greatsite.com', cb: 1000, bidFloor: 0.1, bidId: '2d52001cabd527', diff --git a/test/spec/modules/videoNowBidAdapter_spec.js b/test/spec/modules/videoNowBidAdapter_spec.js index 337960c6edd8..f1e5b88272bd 100644 --- a/test/spec/modules/videoNowBidAdapter_spec.js +++ b/test/spec/modules/videoNowBidAdapter_spec.js @@ -18,7 +18,7 @@ const getValidServerResponse = () => { id: 'e3bf2b82e3e9485113fad6c9b27f8768.1', impid: '1', price: 10.97, - nurl: 'http://localhost:8086/event/nurl', + nurl: 'https://localhost:8086/event/nurl', netRevenue: false, ttl: 800, adm: '', @@ -26,10 +26,10 @@ const getValidServerResponse = () => { h: 640, w: 480, ext: { - init: 'http://localhost:8086/vn_init.js', + init: 'https://localhost:8086/vn_init.js', module: { - min: 'http://localhost:8086/vn_module.js', - log: 'http://localhost:8086/vn_module.js?log=1' + min: 'https://localhost:8086/vn_module.js', + log: 'https://localhost:8086/vn_module.js?log=1' }, format: { name: 'flyRoll', @@ -45,12 +45,12 @@ const getValidServerResponse = () => { ext: { placementId, pixels: [ - 'http://localhost:8086/event/pxlcookiematching?uiid=1', - 'http://localhost:8086/event/pxlcookiematching?uiid=2', + 'https://localhost:8086/event/pxlcookiematching?uiid=1', + 'https://localhost:8086/event/pxlcookiematching?uiid=2', ], iframes: [ - 'http://localhost:8086/event/ifrcookiematching?uiid=1', - 'http://localhost:8086/event/ifrcookiematching?uiid=2', + 'https://localhost:8086/event/ifrcookiematching?uiid=1', + 'https://localhost:8086/event/ifrcookiematching?uiid=2', ], }, }, @@ -95,7 +95,7 @@ describe('videonowAdapterTests', function() { params: { pId: '1', placementId, - url: 'http://localhost:8086/bid?p=exists', + url: 'https://localhost:8086/bid?p=exists', bidFloor: 10, cur: 'RUB' }, @@ -128,7 +128,7 @@ describe('videonowAdapterTests', function() { params: { pId: '1', placementId, - url: 'http://localhost:8086/bid', + url: 'https://localhost:8086/bid', bidFloor: 10, cur: 'RUB', }, @@ -153,11 +153,11 @@ describe('videonowAdapterTests', function() { auctionStart: 1565794308584, timeout: 3000, refererInfo: { - referer: 'http://localhost:8086/page', + referer: 'https://localhost:8086/page', reachedTop: true, numIframes: 0, stack: [ - 'http://localhost:8086/page', + 'https://localhost:8086/page', ], }, start: 1565794308589, @@ -175,7 +175,7 @@ describe('videonowAdapterTests', function() { }) it('bidRequest url', function() { - expect(request.url).to.equal('http://localhost:8086/bid?p=exists&profile_id=1') + expect(request.url).to.equal('https://localhost:8086/bid?p=exists&profile_id=1') }) it('bidRequest data', function() { @@ -235,7 +235,7 @@ describe('videonowAdapterTests', function() { describe('onBidWon', function() { const cpm = 10 - const nurl = 'http://fakedomain.nld?price=${AUCTION_PRICE}' + const nurl = 'https://fakedomain.nld?price=${AUCTION_PRICE}' const imgSrc = replaceAuctionPrice(nurl, cpm) const foundPixels = () => window.document.body.querySelectorAll(`img[src="${imgSrc}"]`) @@ -304,14 +304,14 @@ describe('videonowAdapterTests', function() { describe('interpretResponse', function() { const bidRequest = { method: 'POST', - url: 'http://localhost:8086/bid?profile_id=1', + url: 'https://localhost:8086/bid?profile_id=1', data: { id: '217b8ab59a18e8', cpm: 10, sizes: [[640, 480], [320, 200]], cur: 'RUB', placementId, - ref: 'http://localhost:8086/page', + ref: 'https://localhost:8086/page', }, } diff --git a/test/spec/modules/videoreachBidAdapter_spec.js b/test/spec/modules/videoreachBidAdapter_spec.js deleted file mode 100644 index 237821f71026..000000000000 --- a/test/spec/modules/videoreachBidAdapter_spec.js +++ /dev/null @@ -1,141 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/videoreachBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const ENDPOINT_URL = '//a.videoreach.com/hb/'; - -describe('videoreachBidAdapter', function () { - describe('isBidRequestValid', function () { - let bid = { - 'params': { - 'TagId': 'ABCDE' - }, - 'bidId': '242d506d4e4f15', - 'bidderRequestId': '1893a2136a84a2', - 'auctionId': '8fb7b1c7-317b-4edf-83f0-c4669a318522', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622' - }; - - 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 = { - 'TagId': '' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'videoreach', - 'params': { - 'TagId': 'ABCDE' - }, - 'adUnitCode': 'adzone', - 'auctionId': '8fb7b1c7-317b-4edf-83f0-c4669a318522', - 'sizes': [[1, 1]], - 'bidId': '242d506d4e4f15', - 'bidderRequestId': '1893a2136a84a2', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622', - 'mediaTypes': { - 'banner': { - 'sizes': [1, 1] - }, - } - } - ]; - - it('send bid request to endpoint', function () { - const request = spec.buildRequests(bidRequests); - - expect(request.url).to.equal(ENDPOINT_URL); - expect(request.method).to.equal('POST'); - }); - - it('send bid request with GDPR to endpoint', function () { - let consentString = 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'; - - let bidderRequest = { - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.gdpr.consent_required).to.exist; - expect(payload.gdpr.consent_string).to.equal(consentString); - }); - }); - - describe('interpretResponse', function () { - let serverResponse = - { - 'body': { - 'responses': [{ - 'bidId': '242d506d4e4f15', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622', - 'cpm': 10.0, - 'width': '1', - 'height': '1', - 'ad': '', - 'ttl': 360, - 'creativeId': '5cb5dc9375c0e', - 'netRevenue': true, - 'currency': 'EUR', - 'sync': ['https:\/\/SYNC_URL'] - }] - } - }; - - it('should handle response', function() { - let expectedResponse = [ - { - cpm: 10.0, - width: '1', - height: '1', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: '', - requestId: '242d506d4e4f15', - creativeId: '5cb5dc9375c0e' - } - ]; - - let result = spec.interpretResponse(serverResponse); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('should handles empty response', function() { - let serverResponse = { - 'body': { - 'responses': [] - } - }; - - let result = spec.interpretResponse(serverResponse); - expect(result.length).to.equal(0); - }); - - describe('getUserSyncs', () => { - it('should push user sync images if enabled', () => { - const syncOptions = { pixelEnabled: true }; - const syncs = spec.getUserSyncs(syncOptions, [serverResponse]); - - expect(syncs[0]).to.deep.equal({ - type: 'image', - url: 'https://SYNC_URL' - }); - }) - }); - }); -}); diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js index 167d54e37a60..b14f5331fd1d 100755 --- a/test/spec/modules/visxBidAdapter_spec.js +++ b/test/spec/modules/visxBidAdapter_spec.js @@ -42,7 +42,7 @@ describe('VisxAdapter', function () { describe('buildRequests', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const referrer = bidderRequest.refererInfo.referer; diff --git a/test/spec/modules/vubleAnalyticsAdapter_spec.js b/test/spec/modules/vubleAnalyticsAdapter_spec.js deleted file mode 100644 index 841a53c6dee4..000000000000 --- a/test/spec/modules/vubleAnalyticsAdapter_spec.js +++ /dev/null @@ -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/weboramaBidAdapter_spec.js b/test/spec/modules/weboramaBidAdapter_spec.js deleted file mode 100644 index d0b119825a67..000000000000 --- 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 deleted file mode 100644 index b3884a90b84a..000000000000 --- a/test/spec/modules/widespaceBidAdapter_spec.js +++ /dev/null @@ -1,262 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/widespaceBidAdapter'; -import includes from 'core-js/library/fn/array/includes'; - -describe('+widespaceAdatperTest', function () { - // Dummy bid request - const bidRequest = [{ - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'auctionId': 'bf1e57ee-fff2-4304-8143-91aaf423a948', - 'bidId': '4045696e2278cd', - 'bidder': 'widespace', - 'params': { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3', - currency: 'EUR', - demo: { - gender: 'M', - country: 'Sweden', - region: 'Stockholm', - postal: '15115', - city: 'Stockholm', - yob: '1984' - } - }, - 'bidderRequestId': '37a5f053efef34', - 'sizes': [[320, 320], [300, 250], [300, 300]], - 'transactionId': '4f68b713-04ba-4d7f-8df9-643bcdab5efb' - }, { - 'adUnitCode': 'div-gpt-ad-1460505748561-1', - 'auctionId': 'bf1e57ee-fff2-4304-8143-91aaf423a944', - 'bidId': '4045696e2278ab', - 'bidder': 'widespace', - 'params': { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad4', - demo: { - gender: 'M', - country: 'Sweden', - region: 'Stockholm', - postal: '15115', - city: 'Stockholm', - yob: '1984' - } - }, - 'bidderRequestId': '37a5f053efef34', - 'sizes': [[300, 300]], - 'transactionId': '4f68b713-04ba-4d7f-8df9-643bcdab5efv' - }]; - - // Dummy bidderRequest object - const bidderRequest = { - auctionId: 'bf1e57ee-fff2-4304-8143-91aaf423a944', - auctionStart: 1527418994278, - bidderCode: 'widespace', - bidderRequestId: '37a5f053efef34', - timeout: 3000, - gdprConsent: { - consentString: 'consentString', - gdprApplies: true, - vendorData: { - hasGlobalScope: false - } - } - }; - - // Dummy bid response with ad code - const bidResponse = { - body: [{ - 'adId': '12345', - 'bidId': '67890', - 'code': '
', - 'cpm': 6.6, - 'currency': 'EUR', - 'height': 300, - 'netRev': true, - 'reqId': '224804081406', - 'status': 'ad', - 'ttl': 30, - 'width': 300, - 'syncPixels': ['https://url1.com/url', 'https://url2.com/url'] - }], - headers: {} - }; - - // Dummy bid response of noad - const bidResponseNoAd = { - body: [{ - 'status': 'noad', - }], - headers: {} - }; - - // Appending a div with id of adUnitCode so we can calculate vol - const div1 = document.createElement('div'); - div1.id = bidRequest[0].adUnitCode; - document.body.appendChild(div1); - const div2 = document.createElement('div'); - div2.id = bidRequest[0].adUnitCode; - document.body.appendChild(div2); - - // Adding custom data cookie se we can test cookie is readable - const theDate = new Date(); - const expDate = new Date(theDate.setMonth(theDate.getMonth() + 1)).toGMTString(); - window.document.cookie = `wsCustomData1={id: test};path=/;expires=${expDate};`; - const PERF_DATA = JSON.stringify({perf_status: 'OK', perf_reqid: '226920425154', perf_ms: '747'}); - window.document.cookie = `wsPerfData123=${PERF_DATA};path=/;expires=${expDate};`; - - // Connect dummy data test - const CONNECTION = navigator.connection || navigator.webkitConnection; - if (CONNECTION && CONNECTION.type && CONNECTION.downlinkMax) { - navigator.connection.downlinkMax = 80; - navigator.connection.type = 'wifi'; - } - - describe('+bidRequestValidity', function () { - it('bidRequest with sid and currency params', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3', - currency: 'EUR' - } - })).to.equal(true); - }); - - it('-bidRequest with missing sid', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - currency: 'EUR' - } - })).to.equal(false); - }); - - it('-bidRequest with missing currency', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3' - } - })).to.equal(true); - }); - }); - - describe('+bidRequest', function () { - const request = spec.buildRequests(bidRequest, bidderRequest); - const UrlRegExp = /^((ftp|http|https):)?\/\/[^ "]+$/; - - let fakeLocalStorage = {}; - let lsSetStub; - let lsGetStub; - let lsRemoveStub; - - beforeEach(function() { - lsSetStub = sinon.stub(window.localStorage, 'setItem').callsFake(function (name, value) { - fakeLocalStorage[name] = value; - }); - - lsGetStub = sinon.stub(window.localStorage, 'getItem').callsFake(function (key) { - return fakeLocalStorage[key] || null; - }); - - lsRemoveStub = sinon.stub(window.localStorage, 'removeItem').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'); - }); - - it('-bidRequest url is valid', function () { - expect(UrlRegExp.test(request[0].url)).to.equal(true); - }); - - it('-bidRequest data exist', function () { - expect(request[0].data).to.exist; - }); - - it('-bidRequest data is form data', function () { - expect(typeof request[0].data).to.equal('string'); - }); - - it('-bidRequest options have header type', function () { - expect(request[0].options.contentType).to.exist; - }); - - it('-cookie test for wsCustomData ', function () { - expect(request[0].data.indexOf('hb.cd') > -1).to.equal(true); - }); - }); - - describe('+interpretResponse', function () { - it('-required params available in response', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - let requiredKeys = [ - 'requestId', - 'cpm', - 'width', - 'height', - 'creativeId', - 'currency', - 'netRevenue', - 'ttl', - 'referrer', - 'ad' - ]; - const resultKeys = Object.keys(result[0]); - requiredKeys.forEach((key) => { - expect(includes(resultKeys, key)).to.equal(true); - }); - - // Each value except referrer should not be empty|null|undefined - result.forEach((res) => { - Object.keys(res).forEach((resKey) => { - if (resKey !== 'referrer') { - expect(res[resKey]).to.not.be.null; - expect(res[resKey]).to.not.be.undefined; - expect(res[resKey]).to.not.equal(''); - } - }); - }); - }); - - it('-empty result if noad responded', function () { - const noAdResult = spec.interpretResponse(bidResponseNoAd, bidRequest); - expect(noAdResult.length).to.equal(0); - }); - - it('-empty response should not breake anything in adapter', function () { - const noResponse = spec.interpretResponse({}, bidRequest); - expect(noResponse.length).to.equal(0); - }); - }); - - describe('+getUserSyncs', function () { - it('-always return an array', function () { - const userSync_test1 = spec.getUserSyncs({}, [bidResponse]); - expect(Array.isArray(userSync_test1)).to.equal(true); - - const userSync_test2 = spec.getUserSyncs({}, [bidResponseNoAd]); - expect(Array.isArray(userSync_test2)).to.equal(true); - - const userSync_test3 = spec.getUserSyncs({}, [bidResponse, bidResponseNoAd]); - expect(Array.isArray(userSync_test3)).to.equal(true); - - const userSync_test4 = spec.getUserSyncs(); - expect(Array.isArray(userSync_test4)).to.equal(true); - - const userSync_test5 = spec.getUserSyncs({}, []); - expect(Array.isArray(userSync_test5)).to.equal(true); - }); - }); -}); diff --git a/test/spec/modules/xendizBidAdapter_spec.js b/test/spec/modules/xendizBidAdapter_spec.js deleted file mode 100644 index 4d1aa3c935f7..000000000000 --- 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 e48d3011ed28..004bdcc4b542 100644 --- a/test/spec/modules/xhbBidAdapter_spec.js +++ b/test/spec/modules/xhbBidAdapter_spec.js @@ -3,7 +3,7 @@ import { spec } from 'modules/xhbBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; -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 2548bb31fdce..000000000000 --- 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/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js deleted file mode 100644 index 60fe25db95e3..000000000000 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ /dev/null @@ -1,220 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/yieldmoBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -describe('YieldmoAdapter', function () { - const adapter = newBidder(spec); - const ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; - - let tdid = '8d146286-91d4-4958-aff4-7e489dd1abd6'; - - let bid = { - bidder: 'yieldmo', - params: { - bidFloor: 0.1 - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - crumbs: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da' - }, - userId: { - tdid, - } - }; - let bidArray = [bid]; - - describe('isBidRequestValid', function () { - it('should return true when necessary information is found', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - - it('should return false when necessary information is not found', function () { - // empty bid - expect(spec.isBidRequestValid({})).to.be.false; - - // empty bidId - bid.bidId = ''; - expect(spec.isBidRequestValid(bid)).to.be.false; - - // empty adUnitCode - bid.bidId = '30b31c1838de1e'; - bid.adUnitCode = ''; - expect(spec.isBidRequestValid(bid)).to.be.false; - - bid.adUnitCode = 'adunit-code'; - }); - }); - - describe('buildRequests', function () { - it('should attempt to send bid requests to the endpoint via GET', function () { - const request = spec.buildRequests(bidArray); - 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() - }) - - 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}]'); - - bidArray.push({ - bidder: 'yieldmo', - params: { - bidFloor: 0.2 - }, - adUnitCode: 'adunit-code-1', - sizes: [[300, 250], [300, 600]], - bidId: '123456789', - bidderRequestId: '987654321', - auctionId: '0246810', - crumbs: { - 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}]'); - }); - - it('should add placement id if given', function () { - bidArray[0].params.placementId = 'ym_1293871298'; - let placementInfo = spec.buildRequests(bidArray).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; - 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; - expect(data.hasOwnProperty('page_url')).to.be.true; - expect(data.hasOwnProperty('bust')).to.be.true; - expect(data.hasOwnProperty('pr')).to.be.true; - expect(data.hasOwnProperty('scrd')).to.be.true; - expect(data.dnt).to.be.false; - expect(data.e).to.equal(90); - expect(data.hasOwnProperty('description')).to.be.true; - expect(data.hasOwnProperty('title')).to.be.true; - expect(data.hasOwnProperty('h')).to.be.true; - expect(data.hasOwnProperty('w')).to.be.true; - expect(data.hasOwnProperty('pubcid')).to.be.true; - }); - - it('should add pubcid as parameter of request', function () { - const pubcidBid = { - bidder: 'yieldmo', - params: {}, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - userId: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2' - } - }; - const data = spec.buildRequests([pubcidBid]).data; - expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2'); - }); - - it('should add unified id as parameter of request', function () { - const unifiedIdBid = { - bidder: 'yieldmo', - params: {}, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - userId: { - tdid, - } - }; - const data = spec.buildRequests([unifiedIdBid]).data; - expect(data.tdid).to.deep.equal(tdid); - }); - }); - - describe('interpretResponse', function () { - let serverResponse; - - beforeEach(function () { - serverResponse = { - 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); - expect(newResponse.length).to.be.equal(1); - expect(newResponse[0]).to.deep.equal({ - requestId: '21989fdbef550a', - cpm: 3.45455, - width: 300, - height: 250, - creativeId: '9874652394875', - currency: 'USD', - netRevenue: true, - ttl: 300, - ad: '
' - }); - }); - - it('should not add responses if the cpm is 0 or null', function () { - serverResponse.body[0].cpm = 0; - let response = spec.interpretResponse(serverResponse); - expect(response).to.deep.equal([]); - - serverResponse.body[0].cpm = null; - response = spec.interpretResponse(serverResponse); - expect(response).to.deep.equal([]) - }); - }); - - describe('getUserSync', function () { - const SYNC_ENDPOINT = 'https://static.yieldmo.com/blank.min.html?orig='; - let options = { - iframeEnabled: 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() - }]); - - options.iframeEnabled = false; - expect(spec.getUserSync(options)).to.deep.equal([]); - } else { - // not ios, so tracker will fail - 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 8f2e40d18101..000000000000 --- 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/yieldoneBidAdapter_spec.js b/test/spec/modules/yieldoneBidAdapter_spec.js deleted file mode 100644 index abc579514efb..000000000000 --- a/test/spec/modules/yieldoneBidAdapter_spec.js +++ /dev/null @@ -1,236 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/yieldoneBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const ENDPOINT = 'https://y.one.impact-ad.jp/h_bid'; -const USER_SYNC_URL = 'https://y.one.impact-ad.jp/push_sync'; -const VIDEO_PLAYER_URL = 'https://img.ak.impact-ad.jp/ic/pone/ivt/firstview/js/dac-video-prebid.min.js'; - -describe('yieldoneBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'yieldone', - 'params': { - placementId: '36891' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [336, 280]], - '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': 'yieldone', - 'params': { - placementId: '36891' - }, - 'adUnitCode': 'adunit-code1', - 'sizes': [[300, 250], [336, 280]], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }, - { - 'bidder': 'yieldone', - 'params': { - placementId: '47919' - }, - '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 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); - expect(request[1].url).to.equal(ENDPOINT); - }); - - it('parameter sz has more than one size on banner requests', function () { - expect(request[0].data.sz).to.equal('300x250,336x280'); - expect(request[1].data.sz).to.equal('300x250'); - }); - - it('width and height should be set as separate parameters on outstream requests', function () { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes.video = {context: 'outstream'}; - const request = spec.buildRequests([bidRequest]); - expect(request[0].data.w).to.equal('300'); - expect(request[0].data.h).to.equal('250'); - }); - - it('adUnitCode should be sent as uc parameters on any requests', function () { - expect(request[0].data.uc).to.equal('adunit-code1'); - expect(request[1].data.uc).to.equal('adunit-code2'); - }); - }); - - describe('interpretResponse', function () { - let bidRequestBanner = [ - { - 'method': 'GET', - 'url': 'https://y.one.impact-ad.jp/h_bid', - 'data': { - 'v': 'hb1', - 'p': '36891', - 'sz': '300x250,336x280', - 'cb': 12892917383, - 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', - 'uid': '23beaa6af6cdde', - 't': 'i' - } - } - ]; - - let serverResponseBanner = { - body: { - 'adTag': '', - 'uid': '23beaa6af6cdde', - 'height': 250, - 'width': 300, - 'cpm': 0.0536616, - 'crid': '2494768', - 'currency': 'JPY', - 'statusMessage': 'Bid available', - 'dealId': 'P1-FIX-7800-DSP-MON' - } - }; - - it('should get the correct bid response for banner', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 53.6616, - 'width': 300, - 'height': 250, - 'creativeId': '2494768', - 'dealId': 'P1-FIX-7800-DSP-MON', - 'currency': 'JPY', - 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'mediaType': 'banner', - 'ad': '' - }]; - let result = spec.interpretResponse(serverResponseBanner, bidRequestBanner[0]); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); - }); - - let serverResponseVideo = { - body: { - 'uid': '23beaa6af6cdde', - 'height': 360, - 'width': 640, - 'cpm': 0.0536616, - 'dealId': 'P1-FIX-766-DSP-MON', - 'crid': '2494768', - 'currency': 'JPY', - 'statusMessage': 'Bid available', - 'adm': '' - } - }; - - let bidRequestVideo = [ - { - 'method': 'GET', - 'url': 'https://y.one.impact-ad.jp/h_bid', - 'data': { - 'v': 'hb1', - 'p': '41993', - 'w': '640', - 'h': '360', - 'cb': 12892917383, - 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', - 'uid': '23beaa6af6cdde', - 't': 'i' - } - } - ]; - - it('should get the correct bid response for video', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 53.6616, - 'width': 640, - 'height': 360, - 'creativeId': '2494768', - 'dealId': 'P1-FIX-7800-DSP-MON', - 'currency': 'JPY', - 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'mediaType': 'video', - 'vastXml': '', - 'renderer': { - id: '23beaa6af6cdde', - url: VIDEO_PLAYER_URL - } - }]; - 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); - expect(result[0].renderer.id).to.equal(expectedResponse[0].renderer.id); - expect(result[0].renderer.url).to.equal(expectedResponse[0].renderer.url); - }); - - 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, bidRequestBanner[0]); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - it('handles empty sync options', function () { - expect(spec.getUserSyncs({})).to.be.undefined; - }); - - it('should return a sync url if iframe syncs are enabled', function () { - expect(spec.getUserSyncs({ - 'iframeEnabled': true - })).to.deep.equal([{ - type: 'iframe', url: USER_SYNC_URL - }]); - }); - }); -}); diff --git a/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js b/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js deleted file mode 100644 index f6efa077f35b..000000000000 --- a/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js +++ /dev/null @@ -1,177 +0,0 @@ -import yuktamediaAnalyticsAdapter from 'modules/yuktamediaAnalyticsAdapter'; -import { expect } from 'chai'; -let adapterManager = require('src/adapterManager').default; -let events = require('src/events'); -let constants = require('src/constants.json'); - -describe('YuktaMedia 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(); - }); - - describe('track', function () { - let initOptions = { - pubId: '1', - 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 = { - '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' - } - ], - 'auctionStart': 1522265863591, - 'timeout': 3000, - 'start': 1522265863600, - 'doneCbCallCount': 1 - }; - let bidResponse = { - 'height': 250, - 'statusMessage': 'Bid available', - 'adId': '2eddfdc0c791dc', - 'mediaType': 'banner', - 'source': 'client', - 'requestId': '2eddfdc0c791dc', - 'cpm': 0.5, - 'creativeId': 29681110, - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', - 'responseTimestamp': 1522265866110, - 'requestTimestamp': 1522265863600, - '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' - }, - { - bidId: '6fe3b4c2c23092', - bidder: 'bidderTwo', - adUnitCode: '/19968336/header-bid-tag-0', - auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' - } - ]; - let bid = { - '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, - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': true, - 'requestTimestamp': 1522265863600, - 'responseTimestamp': 1522265866110, - 'sizes': '300x250,300x600', - 'statusMessage': 'Bid available', - 'timeToRespond': 2510 - } - - // 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, {}, 'auctionEnd'); - - expect(requests.length).to.equal(1); - - let auctionEventData = JSON.parse(requests[0].requestBody); - - expect(auctionEventData.bids.length).to.equal(1); - expect(auctionEventData.bids[0]).to.deep.equal(bid); - - expect(auctionEventData.initOptions).to.deep.equal(initOptions); - - // 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'); - - expect(requests.length).to.equal(2); - - let winEventData = JSON.parse(requests[1].requestBody); - - expect(winEventData.bidWon.status).to.equal('rendered'); - expect(winEventData.initOptions).to.deep.equal(initOptions); - }); - }); -}); diff --git a/test/spec/modules/zedoBidAdapter_spec.js b/test/spec/modules/zedoBidAdapter_spec.js deleted file mode 100644 index f6702e6f4590..000000000000 --- 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(/^https:\/\/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(/^https:\/\/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/renderer_spec.js b/test/spec/renderer_spec.js index f9a670c13159..da10c67f2237 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 { loadExternalScript } from 'src/adloader'; 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/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 485dd5cf0776..b59911153e54 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -406,10 +406,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 +700,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', @@ -1190,6 +1190,11 @@ describe('Unit: Prebid Module', function () { adUnits = [{ code: 'adUnit-code', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bids: [ {bidder: BIDDER_CODE, params: {placementId: 'id'}}, ] @@ -1314,9 +1319,11 @@ describe('Unit: Prebid Module', function () { adUnits: [ { code: 'test1', + mediaTypes: { banner: { sizes: [] } }, bids: [], }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [], } ], @@ -1396,9 +1403,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 +1428,11 @@ describe('Unit: Prebid Module', function () { adUnits: [ { code: 'test1', + mediaTypes: { banner: { sizes: [] } }, bids: [] }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [] } ] @@ -1562,7 +1573,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 +1611,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 +1773,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 +1781,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 +1821,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 +1833,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'}} ] @@ -2033,17 +2042,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 +2078,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 +2098,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 +2265,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 +2286,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/userSync_spec.js b/test/spec/userSync_spec.js index f55fe13c5282..806e86e998bd 100644 --- a/test/spec/userSync_spec.js +++ b/test/spec/userSync_spec.js @@ -85,21 +85,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 +123,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 +142,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 +161,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 +192,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 +200,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 +216,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; @@ -360,8 +375,8 @@ describe('user sync', function () { }); 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 +412,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 +442,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 +465,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 index 5bee79d39c28..012dfacd92f7 100755 --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -793,93 +793,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';