From 31d1d0e120a32b3305201b1c086af659f352622a Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 9 Jun 2021 18:48:18 -0700 Subject: [PATCH] Rule Enforcement: include support for adomain (#6986) --- modules/7xbidBidAdapter.js | 159 --- modules/aardvarkBidAdapter.js | 262 ----- modules/adbutlerBidAdapter.js | 140 --- modules/adfinityBidAdapter.js | 125 --- modules/adgenerationBidAdapter.js | 236 ----- modules/adglareBidAdapter.js | 90 -- modules/adhashBidAdapter.js | 102 -- modules/adheseBidAdapter.js | 233 ----- modules/adliveBidAdapter.js | 69 -- modules/admanBidAdapter.js | 118 --- modules/admaticBidAdapter.js | 147 --- modules/admediaBidAdapter.js | 71 -- modules/adpartnerBidAdapter.js | 124 --- modules/adprimeBidAdapter.js | 129 --- modules/advenueBidAdapter.js | 86 -- modules/advertlyBidAdapter.js | 127 --- modules/ajaBidAdapter.js | 194 ---- modules/atomxBidAdapter.js | 107 -- modules/avocetBidAdapter.js | 141 --- modules/bidlabBidAdapter.js | 112 --- modules/bidphysicsBidAdapter.js | 134 --- modules/bizzclickBidAdapter.js | 326 ------- modules/boldwinBidAdapter.js | 110 --- modules/byplayBidAdapter.js | 67 -- modules/cedatoBidAdapter.js | 229 ----- modules/clickforceBidAdapter.js | 126 --- modules/clicktripzBidAdapter.js | 67 -- modules/collectcentBidAdapter.js | 93 -- modules/colombiaBidAdapter.js | 82 -- modules/colossussspBidAdapter.js | 156 --- modules/convergeBidAdapter.js | 313 ------ modules/cpmstarBidAdapter.js | 180 ---- modules/decenteradsBidAdapter.js | 90 -- modules/djaxBidAdapter.js | 129 --- modules/e_volutionBidAdapter.js | 111 --- modules/edgequeryxBidAdapter.js | 98 -- modules/emoteevBidAdapter.js | 525 ---------- modules/engageyaBidAdapter.js | 133 --- modules/envivoBidAdapter.js | 129 --- modules/fidelityBidAdapter.js | 146 --- modules/fluctBidAdapter.js | 121 --- modules/gammaBidAdapter.js | 101 -- modules/gnetBidAdapter.js | 101 -- modules/haxmediaBidAdapter.js | 107 -- modules/hpmdnetworkBidAdapter.js | 96 -- modules/impactifyBidAdapter.js | 260 ----- modules/innityBidAdapter.js | 58 -- modules/ipromBidAdapter.js | 79 -- modules/ironsourceBidAdapter.js | 251 ----- modules/jcmBidAdapter.js | 89 -- modules/krushmediaBidAdapter.js | 123 --- modules/lifestreetBidAdapter.js | 139 --- modules/lkqdBidAdapter.js | 284 ------ modules/loganBidAdapter.js | 118 --- modules/logicadBidAdapter.js | 69 -- modules/loopmeBidAdapter.js | 149 --- modules/luponmediaBidAdapter.js | 341 ------- modules/madvertiseBidAdapter.js | 94 -- modules/mantisBidAdapter.js | 310 ------ modules/meazyBidAdapter.js | 149 --- modules/mediagoBidAdapter.js | 375 ------- modules/microadBidAdapter.js | 151 --- modules/missenaBidAdapter.js | 94 -- modules/mobfoxpbBidAdapter.js | 99 -- modules/mobsmartBidAdapter.js | 94 -- modules/nanointeractiveBidAdapter.js | 159 --- modules/nasmediaAdmixerBidAdapter.js | 85 -- modules/nextMillenniumBidAdapter.js | 75 -- modules/open8BidAdapter.js | 185 ---- modules/otmBidAdapter.js | 95 -- modules/outconBidAdapter.js | 69 -- modules/papyrusBidAdapter.js | 77 -- modules/performaxBidAdapter.js | 56 -- modules/piximediaBidAdapter.js | 47 - modules/projectLimeLightBidAdapter.js | 122 --- modules/proxistoreBidAdapter.js | 151 --- modules/pubxBidAdapter.js | 94 -- modules/reklamstoreBidAdapter.js | 148 --- modules/reloadBidAdapter.js | 419 -------- modules/resultsmediaBidAdapter.js | 269 ------ modules/riseBidAdapter.js | 251 ----- modules/rtbsapeBidAdapter.js | 142 --- modules/rtbsolutionsBidAdapter.js | 100 -- modules/seedingAllianceBidAdapter.js | 225 ----- modules/segmentoBidAdapter.js | 85 -- modules/shinezBidAdapter.js | 83 -- modules/slimcutBidAdapter.js | 128 --- modules/smarticoBidAdapter.js | 116 --- modules/smartrtbBidAdapter.js | 133 --- modules/smmsBidAdapter.js | 156 --- modules/stvBidAdapter.js | 150 --- modules/taphypeBidAdapter.js | 45 - modules/topRTBBidAdapter.js | 65 -- modules/trendqubeBidAdapter.js | 102 -- modules/turktelekomBidAdapter.js | 261 ----- modules/unicornBidAdapter.js | 160 --- modules/vdoaiBidAdapter.js | 125 --- modules/viBidAdapter.js | 393 -------- modules/vidazooBidAdapter.js | 278 ------ modules/videoNowBidAdapter.js | 187 ---- modules/videofyBidAdapter.js | 300 ------ modules/videoreachBidAdapter.js | 119 --- modules/vmgBidAdapter.js | 86 -- modules/welectBidAdapter.js | 106 -- modules/windtalkerBidAdapter.js | 307 ------ modules/wipesBidAdapter.js | 71 -- modules/zedoBidAdapter.js | 342 ------- test/spec/modules/7xbidBidAdapter_spec.js | 160 --- test/spec/modules/aardvarkBidAdapter_spec.js | 569 ----------- test/spec/modules/adbutlerBidAdapter_spec.js | 231 ----- test/spec/modules/adfinityBidAdapter_spec.js | 151 --- .../modules/adgenerationBidAdapter_spec.js | 407 -------- test/spec/modules/adglareBidAdapter_spec.js | 138 --- test/spec/modules/adhashBidAdapter_spec.js | 155 --- test/spec/modules/adheseBidAdapter_spec.js | 509 ---------- test/spec/modules/adliveBidAdapter_spec.js | 78 -- test/spec/modules/admanBidAdapter_spec.js | 231 ----- test/spec/modules/admediaBidAdapter_spec.js | 138 --- test/spec/modules/adpartnerBidAdapter_spec.js | 234 ----- test/spec/modules/adprimeBidAdapter_spec.js | 297 ------ test/spec/modules/advenueBidAdapter_spec.js | 107 -- test/spec/modules/advertlyBidAdapter_spec.js | 159 --- test/spec/modules/ajaBidAdapter_spec.js | 311 ------ test/spec/modules/atomxBidAdapter_spec.js | 119 --- test/spec/modules/avocetBidAdapter_spec.js | 167 ---- test/spec/modules/bidlabBidAdapter_spec.js | 235 ----- .../spec/modules/bidphysicsBidAdapter_spec.js | 261 ----- test/spec/modules/bizzclickBidAdapter_spec.js | 396 -------- test/spec/modules/boldwinBidAdapter_spec.js | 281 ------ test/spec/modules/byplayBidAdapter_spec.js | 93 -- test/spec/modules/cedatoBidAdapter_spec.js | 133 --- .../spec/modules/clickforceBidAdapter_spec.js | 190 ---- .../spec/modules/clicktripzBidAdapter_spec.js | 152 --- .../modules/collectcentBidAdapter_spec.js | 118 --- test/spec/modules/colombiaBidAdapter_spec.js | 152 --- .../modules/colossussspBidAdapter_spec.js | 185 ---- test/spec/modules/convergeBidAdapter_spec.js | 899 ----------------- test/spec/modules/cpmstarBidAdapter_spec.js | 231 ----- .../modules/decenteradsBidAdapter_spec.js | 207 ---- test/spec/modules/djaxBidAdapter_spec.js | 159 --- .../spec/modules/e_volutionBidAdapter_spec.js | 235 ----- .../spec/modules/edgequeryxBidAdapter_spec.js | 116 --- test/spec/modules/emoteevBidAdapter_spec.js | 876 ----------------- test/spec/modules/engageyaBidAdapter_spec.js | 161 ---- test/spec/modules/envivoBidAdapter_spec.js | 159 --- test/spec/modules/fidelityBidAdapter_spec.js | 233 ----- test/spec/modules/fluctBidAdapter_spec.js | 201 ---- test/spec/modules/gammaBidAdapter_spec.js | 104 -- test/spec/modules/gnetBidAdapter_spec.js | 145 --- test/spec/modules/haxmediaBidAdapter_spec.js | 304 ------ .../modules/hpmdnetworkBidAdapter_spec.js | 148 --- test/spec/modules/impactifyBidAdapter_spec.js | 398 -------- test/spec/modules/innityBidAdapter_spec.js | 106 -- test/spec/modules/ipromBidAdapter_spec.js | 195 ---- .../spec/modules/ironsourceBidAdapter_spec.js | 381 -------- test/spec/modules/jcmBidAdapter_spec.js | 139 --- .../spec/modules/krushmediaBidAdapter_spec.js | 329 ------- .../spec/modules/lifestreetBidAdapter_spec.js | 232 ----- test/spec/modules/lkqdBidAdapter_spec.js | 370 ------- test/spec/modules/loganBidAdapter_spec.js | 329 ------- test/spec/modules/logicadBidAdapter_spec.js | 236 ----- test/spec/modules/loopmeBidAdapter_spec.js | 167 ---- .../spec/modules/luponmediaBidAdapter_spec.js | 412 -------- .../spec/modules/madvertiseBidAdapter_spec.js | 203 ---- test/spec/modules/mantisBidAdapter_spec.js | 361 ------- test/spec/modules/meazyBidAdapter_spec.js | 177 ---- test/spec/modules/mediagoBidAdapter_spec.js | 101 -- test/spec/modules/microadBidAdapter_spec.js | 388 -------- test/spec/modules/missenaBidAdapter_spec.js | 131 --- test/spec/modules/mobfoxpbBidAdapter_spec.js | 304 ------ test/spec/modules/mobsmartBidAdapter_spec.js | 214 ---- .../modules/nanointeractiveBidAdapter_spec.js | 466 --------- .../modules/nasmediaAdmixerBidAdapter_spec.js | 143 --- .../modules/nextMillenniumBidAdapter_spec.js | 93 -- test/spec/modules/open8BidAdapter_spec.js | 251 ----- test/spec/modules/otmBidAdapter_spec.js | 105 -- test/spec/modules/outconBidAdapter_spec.js | 100 -- test/spec/modules/papyrusBidAdapter_spec.js | 115 --- test/spec/modules/performaxBidAdapter_spec.js | 274 ------ test/spec/modules/piximediaBidAdapter_spec.js | 103 -- .../projectLimeLightBidAdapter_spec.js | 259 ----- .../spec/modules/proxistoreBidAdapter_spec.js | 166 ---- test/spec/modules/pubxBidAdapter_spec.js | 189 ---- .../modules/reklamstoreBidAdapter_spec.js | 85 -- test/spec/modules/reloadBidAdapter_spec.js | 295 ------ .../modules/resultsmediaBidAdapter_spec.js | 574 ----------- test/spec/modules/riseBidAdapter_spec.js | 381 -------- test/spec/modules/rtbsapeBidAdapter_spec.js | 166 ---- .../modules/rtbsolutionsBidAdapter_spec.js | 62 -- .../modules/seedingAllianceAdapter_spec.js | 186 ---- test/spec/modules/segmentoBidAdapter_spec.js | 187 ---- test/spec/modules/shinezBidAdapter_spec.js | 152 --- test/spec/modules/slimcutBidAdapter_spec.js | 212 ---- test/spec/modules/smarticoBidAdapter_spec.js | 118 --- test/spec/modules/smartrtbBidAdapter_spec.js | 158 --- test/spec/modules/smmsBidAdapter_spec.js | 161 ---- test/spec/modules/stvBidAdapter_spec.js | 138 --- test/spec/modules/taphypeBidAdapter_spec.js | 56 -- test/spec/modules/topRTBBidAdapter_spec.js | 67 -- test/spec/modules/trendqubeBidAdapter_spec.js | 270 ------ .../modules/turktelekomBidAdapter_spec.js | 749 -------------- test/spec/modules/unicornBidAdapter_spec.js | 490 ---------- test/spec/modules/vdoaiBidAdapter_spec.js | 141 --- test/spec/modules/viBidAdapter_spec.js | 911 ------------------ test/spec/modules/vidazooBidAdapter_spec.js | 372 ------- test/spec/modules/videoNowBidAdapter_spec.js | 599 ------------ test/spec/modules/videofyBidAdapter_spec.js | 253 ----- .../spec/modules/videoreachBidAdapter_spec.js | 141 --- test/spec/modules/vmgBidAdapter_spec.js | 98 -- test/spec/modules/welectBidAdapter_spec.js | 211 ---- .../spec/modules/windtalkerBidAdapter_spec.js | 348 ------- test/spec/modules/wipesBidAdapter_spec.js | 150 --- test/spec/modules/zedoBidAdapter_spec.js | 354 ------- 213 files changed, 42492 deletions(-) delete mode 100644 modules/7xbidBidAdapter.js delete mode 100644 modules/aardvarkBidAdapter.js delete mode 100644 modules/adbutlerBidAdapter.js delete mode 100644 modules/adfinityBidAdapter.js delete mode 100644 modules/adgenerationBidAdapter.js delete mode 100644 modules/adglareBidAdapter.js delete mode 100644 modules/adhashBidAdapter.js delete mode 100644 modules/adheseBidAdapter.js delete mode 100644 modules/adliveBidAdapter.js delete mode 100644 modules/admanBidAdapter.js delete mode 100644 modules/admaticBidAdapter.js delete mode 100644 modules/admediaBidAdapter.js delete mode 100644 modules/adpartnerBidAdapter.js delete mode 100644 modules/adprimeBidAdapter.js delete mode 100644 modules/advenueBidAdapter.js delete mode 100755 modules/advertlyBidAdapter.js delete mode 100644 modules/ajaBidAdapter.js delete mode 100644 modules/atomxBidAdapter.js delete mode 100644 modules/avocetBidAdapter.js delete mode 100644 modules/bidlabBidAdapter.js delete mode 100644 modules/bidphysicsBidAdapter.js delete mode 100644 modules/bizzclickBidAdapter.js delete mode 100644 modules/boldwinBidAdapter.js delete mode 100644 modules/byplayBidAdapter.js delete mode 100644 modules/cedatoBidAdapter.js delete mode 100644 modules/clickforceBidAdapter.js delete mode 100644 modules/clicktripzBidAdapter.js delete mode 100644 modules/collectcentBidAdapter.js delete mode 100644 modules/colombiaBidAdapter.js delete mode 100644 modules/colossussspBidAdapter.js delete mode 100644 modules/convergeBidAdapter.js delete mode 100644 modules/cpmstarBidAdapter.js delete mode 100644 modules/decenteradsBidAdapter.js delete mode 100644 modules/djaxBidAdapter.js delete mode 100644 modules/e_volutionBidAdapter.js delete mode 100644 modules/edgequeryxBidAdapter.js delete mode 100644 modules/emoteevBidAdapter.js delete mode 100644 modules/engageyaBidAdapter.js delete mode 100644 modules/envivoBidAdapter.js delete mode 100644 modules/fidelityBidAdapter.js delete mode 100644 modules/fluctBidAdapter.js delete mode 100644 modules/gammaBidAdapter.js delete mode 100644 modules/gnetBidAdapter.js delete mode 100644 modules/haxmediaBidAdapter.js delete mode 100644 modules/hpmdnetworkBidAdapter.js delete mode 100644 modules/impactifyBidAdapter.js delete mode 100644 modules/innityBidAdapter.js delete mode 100644 modules/ipromBidAdapter.js delete mode 100644 modules/ironsourceBidAdapter.js delete mode 100644 modules/jcmBidAdapter.js delete mode 100644 modules/krushmediaBidAdapter.js delete mode 100644 modules/lifestreetBidAdapter.js delete mode 100644 modules/lkqdBidAdapter.js delete mode 100644 modules/loganBidAdapter.js delete mode 100644 modules/logicadBidAdapter.js delete mode 100644 modules/loopmeBidAdapter.js delete mode 100644 modules/luponmediaBidAdapter.js delete mode 100644 modules/madvertiseBidAdapter.js delete mode 100644 modules/mantisBidAdapter.js delete mode 100644 modules/meazyBidAdapter.js delete mode 100644 modules/mediagoBidAdapter.js delete mode 100644 modules/microadBidAdapter.js delete mode 100644 modules/missenaBidAdapter.js delete mode 100644 modules/mobfoxpbBidAdapter.js delete mode 100644 modules/mobsmartBidAdapter.js delete mode 100644 modules/nanointeractiveBidAdapter.js delete mode 100644 modules/nasmediaAdmixerBidAdapter.js delete mode 100644 modules/nextMillenniumBidAdapter.js delete mode 100644 modules/open8BidAdapter.js delete mode 100644 modules/otmBidAdapter.js delete mode 100644 modules/outconBidAdapter.js delete mode 100644 modules/papyrusBidAdapter.js delete mode 100644 modules/performaxBidAdapter.js delete mode 100644 modules/piximediaBidAdapter.js delete mode 100644 modules/projectLimeLightBidAdapter.js delete mode 100644 modules/proxistoreBidAdapter.js delete mode 100644 modules/pubxBidAdapter.js delete mode 100644 modules/reklamstoreBidAdapter.js delete mode 100644 modules/reloadBidAdapter.js delete mode 100644 modules/resultsmediaBidAdapter.js delete mode 100644 modules/riseBidAdapter.js delete mode 100644 modules/rtbsapeBidAdapter.js delete mode 100644 modules/rtbsolutionsBidAdapter.js delete mode 100755 modules/seedingAllianceBidAdapter.js delete mode 100644 modules/segmentoBidAdapter.js delete mode 100644 modules/shinezBidAdapter.js delete mode 100644 modules/slimcutBidAdapter.js delete mode 100644 modules/smarticoBidAdapter.js delete mode 100644 modules/smartrtbBidAdapter.js delete mode 100644 modules/smmsBidAdapter.js delete mode 100644 modules/stvBidAdapter.js delete mode 100644 modules/taphypeBidAdapter.js delete mode 100644 modules/topRTBBidAdapter.js delete mode 100644 modules/trendqubeBidAdapter.js delete mode 100644 modules/turktelekomBidAdapter.js delete mode 100644 modules/unicornBidAdapter.js delete mode 100644 modules/vdoaiBidAdapter.js delete mode 100644 modules/viBidAdapter.js delete mode 100644 modules/vidazooBidAdapter.js delete mode 100644 modules/videoNowBidAdapter.js delete mode 100644 modules/videofyBidAdapter.js delete mode 100644 modules/videoreachBidAdapter.js delete mode 100644 modules/vmgBidAdapter.js delete mode 100644 modules/welectBidAdapter.js delete mode 100644 modules/windtalkerBidAdapter.js delete mode 100644 modules/wipesBidAdapter.js delete mode 100644 modules/zedoBidAdapter.js delete mode 100644 test/spec/modules/7xbidBidAdapter_spec.js delete mode 100644 test/spec/modules/aardvarkBidAdapter_spec.js delete mode 100644 test/spec/modules/adbutlerBidAdapter_spec.js delete mode 100644 test/spec/modules/adfinityBidAdapter_spec.js delete mode 100644 test/spec/modules/adgenerationBidAdapter_spec.js delete mode 100644 test/spec/modules/adglareBidAdapter_spec.js delete mode 100644 test/spec/modules/adhashBidAdapter_spec.js delete mode 100644 test/spec/modules/adheseBidAdapter_spec.js delete mode 100644 test/spec/modules/adliveBidAdapter_spec.js delete mode 100644 test/spec/modules/admanBidAdapter_spec.js delete mode 100644 test/spec/modules/admediaBidAdapter_spec.js delete mode 100644 test/spec/modules/adpartnerBidAdapter_spec.js delete mode 100644 test/spec/modules/adprimeBidAdapter_spec.js delete mode 100644 test/spec/modules/advenueBidAdapter_spec.js delete mode 100755 test/spec/modules/advertlyBidAdapter_spec.js delete mode 100644 test/spec/modules/ajaBidAdapter_spec.js delete mode 100644 test/spec/modules/atomxBidAdapter_spec.js delete mode 100644 test/spec/modules/avocetBidAdapter_spec.js delete mode 100644 test/spec/modules/bidlabBidAdapter_spec.js delete mode 100644 test/spec/modules/bidphysicsBidAdapter_spec.js delete mode 100644 test/spec/modules/bizzclickBidAdapter_spec.js delete mode 100644 test/spec/modules/boldwinBidAdapter_spec.js delete mode 100644 test/spec/modules/byplayBidAdapter_spec.js delete mode 100644 test/spec/modules/cedatoBidAdapter_spec.js delete mode 100644 test/spec/modules/clickforceBidAdapter_spec.js delete mode 100644 test/spec/modules/clicktripzBidAdapter_spec.js delete mode 100644 test/spec/modules/collectcentBidAdapter_spec.js delete mode 100644 test/spec/modules/colombiaBidAdapter_spec.js delete mode 100644 test/spec/modules/colossussspBidAdapter_spec.js delete mode 100644 test/spec/modules/convergeBidAdapter_spec.js delete mode 100644 test/spec/modules/cpmstarBidAdapter_spec.js delete mode 100644 test/spec/modules/decenteradsBidAdapter_spec.js delete mode 100644 test/spec/modules/djaxBidAdapter_spec.js delete mode 100644 test/spec/modules/e_volutionBidAdapter_spec.js delete mode 100644 test/spec/modules/edgequeryxBidAdapter_spec.js delete mode 100644 test/spec/modules/emoteevBidAdapter_spec.js delete mode 100644 test/spec/modules/engageyaBidAdapter_spec.js delete mode 100644 test/spec/modules/envivoBidAdapter_spec.js delete mode 100644 test/spec/modules/fidelityBidAdapter_spec.js delete mode 100644 test/spec/modules/fluctBidAdapter_spec.js delete mode 100644 test/spec/modules/gammaBidAdapter_spec.js delete mode 100644 test/spec/modules/gnetBidAdapter_spec.js delete mode 100644 test/spec/modules/haxmediaBidAdapter_spec.js delete mode 100644 test/spec/modules/hpmdnetworkBidAdapter_spec.js delete mode 100644 test/spec/modules/impactifyBidAdapter_spec.js delete mode 100644 test/spec/modules/innityBidAdapter_spec.js delete mode 100644 test/spec/modules/ipromBidAdapter_spec.js delete mode 100644 test/spec/modules/ironsourceBidAdapter_spec.js delete mode 100644 test/spec/modules/jcmBidAdapter_spec.js delete mode 100644 test/spec/modules/krushmediaBidAdapter_spec.js delete mode 100644 test/spec/modules/lifestreetBidAdapter_spec.js delete mode 100644 test/spec/modules/lkqdBidAdapter_spec.js delete mode 100644 test/spec/modules/loganBidAdapter_spec.js delete mode 100644 test/spec/modules/logicadBidAdapter_spec.js delete mode 100644 test/spec/modules/loopmeBidAdapter_spec.js delete mode 100644 test/spec/modules/luponmediaBidAdapter_spec.js delete mode 100644 test/spec/modules/madvertiseBidAdapter_spec.js delete mode 100644 test/spec/modules/mantisBidAdapter_spec.js delete mode 100644 test/spec/modules/meazyBidAdapter_spec.js delete mode 100644 test/spec/modules/mediagoBidAdapter_spec.js delete mode 100644 test/spec/modules/microadBidAdapter_spec.js delete mode 100644 test/spec/modules/missenaBidAdapter_spec.js delete mode 100644 test/spec/modules/mobfoxpbBidAdapter_spec.js delete mode 100644 test/spec/modules/mobsmartBidAdapter_spec.js delete mode 100644 test/spec/modules/nanointeractiveBidAdapter_spec.js delete mode 100644 test/spec/modules/nasmediaAdmixerBidAdapter_spec.js delete mode 100644 test/spec/modules/nextMillenniumBidAdapter_spec.js delete mode 100644 test/spec/modules/open8BidAdapter_spec.js delete mode 100644 test/spec/modules/otmBidAdapter_spec.js delete mode 100644 test/spec/modules/outconBidAdapter_spec.js delete mode 100644 test/spec/modules/papyrusBidAdapter_spec.js delete mode 100644 test/spec/modules/performaxBidAdapter_spec.js delete mode 100644 test/spec/modules/piximediaBidAdapter_spec.js delete mode 100644 test/spec/modules/projectLimeLightBidAdapter_spec.js delete mode 100644 test/spec/modules/proxistoreBidAdapter_spec.js delete mode 100644 test/spec/modules/pubxBidAdapter_spec.js delete mode 100644 test/spec/modules/reklamstoreBidAdapter_spec.js delete mode 100644 test/spec/modules/reloadBidAdapter_spec.js delete mode 100644 test/spec/modules/resultsmediaBidAdapter_spec.js delete mode 100644 test/spec/modules/riseBidAdapter_spec.js delete mode 100644 test/spec/modules/rtbsapeBidAdapter_spec.js delete mode 100644 test/spec/modules/rtbsolutionsBidAdapter_spec.js delete mode 100755 test/spec/modules/seedingAllianceAdapter_spec.js delete mode 100644 test/spec/modules/segmentoBidAdapter_spec.js delete mode 100644 test/spec/modules/shinezBidAdapter_spec.js delete mode 100644 test/spec/modules/slimcutBidAdapter_spec.js delete mode 100644 test/spec/modules/smarticoBidAdapter_spec.js delete mode 100644 test/spec/modules/smartrtbBidAdapter_spec.js delete mode 100644 test/spec/modules/smmsBidAdapter_spec.js delete mode 100644 test/spec/modules/stvBidAdapter_spec.js delete mode 100644 test/spec/modules/taphypeBidAdapter_spec.js delete mode 100644 test/spec/modules/topRTBBidAdapter_spec.js delete mode 100644 test/spec/modules/trendqubeBidAdapter_spec.js delete mode 100644 test/spec/modules/turktelekomBidAdapter_spec.js delete mode 100644 test/spec/modules/unicornBidAdapter_spec.js delete mode 100644 test/spec/modules/vdoaiBidAdapter_spec.js delete mode 100644 test/spec/modules/viBidAdapter_spec.js delete mode 100644 test/spec/modules/vidazooBidAdapter_spec.js delete mode 100644 test/spec/modules/videoNowBidAdapter_spec.js delete mode 100644 test/spec/modules/videofyBidAdapter_spec.js delete mode 100644 test/spec/modules/videoreachBidAdapter_spec.js delete mode 100644 test/spec/modules/vmgBidAdapter_spec.js delete mode 100644 test/spec/modules/welectBidAdapter_spec.js delete mode 100644 test/spec/modules/windtalkerBidAdapter_spec.js delete mode 100644 test/spec/modules/wipesBidAdapter_spec.js delete mode 100644 test/spec/modules/zedoBidAdapter_spec.js diff --git a/modules/7xbidBidAdapter.js b/modules/7xbidBidAdapter.js deleted file mode 100644 index b925912a399..00000000000 --- a/modules/7xbidBidAdapter.js +++ /dev/null @@ -1,159 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -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; - -/** - * updated to support prebid 3.0 - remove utils.getTopWindowUrl() - */ - -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.deepAccess(bidderRequest, 'refererInfo.referer'), - '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/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js deleted file mode 100644 index 0b864286868..00000000000 --- a/modules/aardvarkBidAdapter.js +++ /dev/null @@ -1,262 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'aardvark'; -const DEFAULT_ENDPOINT = 'bidder.rtk.io'; -const SYNC_ENDPOINT = 'sync.rtk.io'; -const AARDVARK_TTL = 300; -const AARDVARK_CURRENCY = 'USD'; - -let hasSynced = false; - -export function resetUserSync() { - hasSynced = false; -} - -export const spec = { - code: BIDDER_CODE, - gvlid: 52, - aliases: ['adsparc', 'safereach'], - - isBidRequestValid: function(bid) { - return ((typeof bid.params.ai === 'string') && !!bid.params.ai.length && - (typeof bid.params.sc === 'string') && !!bid.params.sc.length); - }, - - buildRequests: function(validBidRequests, bidderRequest) { - var auctionCodes = []; - var requests = []; - var requestsMap = {}; - var referer = bidderRequest.refererInfo.referer; - var pageCategories = []; - var tdId = ''; - var width = window.innerWidth; - var height = window.innerHeight; - var schain = ''; - - // This reference to window.top can cause issues when loaded in an iframe if not protected with a try/catch. - try { - var topWin = utils.getWindowTop(); - if (topWin.rtkcategories && Array.isArray(topWin.rtkcategories)) { - pageCategories = topWin.rtkcategories; - } - width = topWin.innerWidth; - height = topWin.innerHeight; - } catch (e) {} - - if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { - tdId = validBidRequests[0].userId.tdid; - } - - schain = spec.serializeSupplyChain(utils.deepAccess(validBidRequests, '0.schain')); - - utils._each(validBidRequests, function(b) { - var rMap = requestsMap[b.params.ai]; - if (!rMap) { - rMap = { - shortCodes: [], - payload: { - version: 1, - jsonp: false, - rtkreferer: referer, - w: width, - h: height - }, - endpoint: DEFAULT_ENDPOINT - }; - - if (tdId) { - rMap.payload.tdid = tdId; - } - if (schain) { - rMap.payload.schain = schain; - } - - if (pageCategories && pageCategories.length) { - rMap.payload.categories = pageCategories.slice(0); - } - - if (b.params.categories && b.params.categories.length) { - rMap.payload.categories = rMap.payload.categories || [] - utils._each(b.params.categories, function(cat) { - rMap.payload.categories.push(cat); - }); - } - - if (bidderRequest.gdprConsent) { - rMap.payload.gdpr = false; - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - rMap.payload.gdpr = bidderRequest.gdprConsent.gdprApplies; - } - if (rMap.payload.gdpr) { - rMap.payload.consent = bidderRequest.gdprConsent.consentString; - } - } - - requestsMap[b.params.ai] = rMap; - auctionCodes.push(b.params.ai); - } - - if (bidderRequest.uspConsent) { - rMap.payload.us_privacy = bidderRequest.uspConsent - } - - rMap.shortCodes.push(b.params.sc); - rMap.payload[b.params.sc] = b.bidId; - - if ((typeof b.params.host === 'string') && b.params.host.length && - (b.params.host !== rMap.endpoint)) { - rMap.endpoint = b.params.host; - } - }); - - utils._each(auctionCodes, function(auctionId) { - var req = requestsMap[auctionId]; - requests.push({ - method: 'GET', - url: `https://${req.endpoint}/${auctionId}/${req.shortCodes.join('_')}/aardvark`, - data: req.payload, - bidderRequest - }); - }); - - return requests; - }, - - interpretResponse: function(serverResponse, bidRequest) { - var bidResponses = []; - - if (!Array.isArray(serverResponse.body)) { - serverResponse.body = [serverResponse.body]; - } - - utils._each(serverResponse.body, function(rawBid) { - var cpm = +(rawBid.cpm || 0); - - if (!cpm) { - return; - } - - var bidResponse = { - requestId: rawBid.cid, - cpm: cpm, - width: rawBid.width || 0, - height: rawBid.height || 0, - currency: rawBid.currency ? rawBid.currency : AARDVARK_CURRENCY, - netRevenue: rawBid.netRevenue ? rawBid.netRevenue : true, - ttl: rawBid.ttl ? rawBid.ttl : AARDVARK_TTL, - creativeId: rawBid.creativeId || 0 - }; - - if (rawBid.hasOwnProperty('dealId')) { - bidResponse.dealId = rawBid.dealId - } - - if (rawBid.hasOwnProperty('ex')) { - bidResponse.ex = rawBid.ex; - } - - switch (rawBid.media) { - case 'banner': - bidResponse.ad = rawBid.adm + utils.createTrackPixelHtml(decodeURIComponent(rawBid.nurl)); - break; - - default: - return utils.logError('bad Aardvark response (media)', rawBid); - } - - bidResponses.push(bidResponse); - }); - - return bidResponses; - }, - - getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = []; - const params = []; - var gdprApplies = false; - if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { - gdprApplies = gdprConsent.gdprApplies; - } - - if (!syncOptions.iframeEnabled) { - utils.logWarn('Aardvark: Please enable iframe based user sync.'); - return syncs; - } - - if (hasSynced) { - return syncs; - } - - hasSynced = true; - if (gdprApplies) { - params.push(['g', '1']); - params.push(['c', gdprConsent.consentString]); - } - - if (uspConsent) { - params.push(['us_privacy', uspConsent]); - } - - var queryStr = ''; - if (params.length) { - queryStr = '?' + params.map(p => p[0] + '=' + encodeURIComponent(p[1])).join('&') - } - - syncs.push({ - type: 'iframe', - url: `https://${SYNC_ENDPOINT}/cs${queryStr}` - }); - return syncs; - }, - - /** - * Serializes schain params according to OpenRTB requirements - * @param {Object} supplyChain - * @returns {String} - */ - serializeSupplyChain: function (supplyChain) { - if (!hasValidSupplyChainParams(supplyChain)) { - return ''; - } - - return `${supplyChain.ver},${supplyChain.complete}!${spec.serializeSupplyChainNodes(supplyChain.nodes)}`; - }, - - /** - * Properly sorts schain object params - * @param {Array} nodes - * @returns {String} - */ - serializeSupplyChainNodes: function (nodes) { - const nodePropOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; - return nodes.map(node => { - return nodePropOrder.map(prop => encodeURIComponent(node[prop] || '')).join(','); - }).join('!'); - }, -}; - -/** - * Make sure the required params are present - * @param {Object} schain - * @param {Bool} - */ -export function hasValidSupplyChainParams(schain) { - if (!schain || !schain.nodes) { - return false; - } - const requiredFields = ['asi', 'sid', 'hp']; - - let isValid = schain.nodes.reduce((status, node) => { - if (!status) { - return status; - } - return requiredFields.every(field => node[field]); - }, true); - if (!isValid) { - utils.logError('Aardvark: required schain params missing'); - } - return isValid; -} - -registerBidder(spec); diff --git a/modules/adbutlerBidAdapter.js b/modules/adbutlerBidAdapter.js deleted file mode 100644 index 10edd8ae3e3..00000000000 --- a/modules/adbutlerBidAdapter.js +++ /dev/null @@ -1,140 +0,0 @@ -'use strict'; - -import * as utils from '../src/utils.js'; -import {config} from '../src/config.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'adbutler'; - -export const spec = { - code: BIDDER_CODE, - pageID: Math.floor(Math.random() * 10e6), - aliases: ['divreach', 'doceree'], - - isBidRequestValid: function (bid) { - return !!(bid.params.accountID && bid.params.zoneID); - }, - - buildRequests: function (validBidRequests) { - let i; - let zoneID; - let bidRequest; - let accountID; - let keyword; - let domain; - let requestURI; - let serverRequests = []; - let zoneCounters = {}; - let extraParams = {}; - - 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); - extraParams = utils.getBidIdParameter('extra', bidRequest.params); - - if (!(zoneID in zoneCounters)) { - zoneCounters[zoneID] = 0; - } - - if (typeof domain === 'undefined' || domain.length === 0) { - domain = 'servedbyadbutler.com'; - } - - requestURI = 'https://' + 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) + ';'; - } - - for (let key in extraParams) { - if (extraParams.hasOwnProperty(key)) { - let val = encodeURIComponent(extraParams[key]); - requestURI += `${key}=${val};`; - } - } - - zoneCounters[zoneID]++; - serverRequests.push({ - method: 'GET', - url: requestURI, - data: {}, - bidRequest: bidRequest - }); - } - return serverRequests; - }, - - interpretResponse: function (serverResponse, bidRequest) { - const bidObj = bidRequest.bidRequest; - let bidResponses = []; - let 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; - } - if (maxCPM !== '' && CPM > parseFloat(maxCPM)) { - isCorrectCPM = false; - } - - // Ensure that response ad matches one of the placement sizes. - utils._each(utils.deepAccess(bidObj, 'mediaTypes.banner.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.deepAccess(bidObj, 'refererInfo.referer'); - bidResponses.push(bidResponse); - } - } - return bidResponses; - }, - - addTrackingPixels: function (trackingPixels) { - let trackingPixelMarkup = ''; - utils._each(trackingPixels, function (pixelURL) { - let trackingPixel = ''; - - trackingPixelMarkup += trackingPixel; - }); - return trackingPixelMarkup; - } -}; -registerBidder(spec); diff --git a/modules/adfinityBidAdapter.js b/modules/adfinityBidAdapter.js deleted file mode 100644 index ebf1198fba2..00000000000 --- a/modules/adfinityBidAdapter.js +++ /dev/null @@ -1,125 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'adfinity'; -const AD_URL = 'https://stat.adfinity.pro/?c=o&m=multi'; -const SYNC_URL = 'https://stat.adfinity.pro/?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: - const n = bid.native - return Boolean(n) && Boolean(n.title) && Boolean(n.body) && Boolean(n.image) && Boolean(n.impression_trackers); - default: - 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.placement_id)); - }, - - /** - * 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, bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - let placements = []; - let request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - - if (bidderRequest) { - if (bidderRequest.gdprConsent) { - request.gdpr_consent = bidderRequest.gdprConsent.consentString || 'ALL' - request.gdpr_require = bidderRequest.gdprConsent.gdprApplies ? 1 : 0 - } - } - - for (let i = 0; i < validBidRequests.length; i++) { - let bid = validBidRequests[i]; - let traff = bid.params.traffic || BANNER - let placement = { - placementId: bid.params.placement_id, - bidId: bid.bidId, - sizes: bid.mediaTypes[traff].sizes, - traffic: traff - }; - if (bid.schain) { - placement.schain = bid.schain; - } - placements.push(placement); - } - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - /** - * 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: (serverResponse) => { - let response = []; - try { - serverResponse = serverResponse.body; - for (let i = 0; i < serverResponse.length; i++) { - let resItem = serverResponse[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - } catch (e) { - utils.logMessage(e); - }; - return response; - }, - - getUserSyncs: () => { - return [{ - type: 'image', - url: SYNC_URL - }]; - } -}; - -registerBidder(spec); diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js deleted file mode 100644 index 7f92ab483f6..00000000000 --- a/modules/adgenerationBidAdapter.js +++ /dev/null @@ -1,236 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER, NATIVE} from '../src/mediaTypes.js'; -import {config} from '../src/config.js'; -const ADG_BIDDER_CODE = 'adgeneration'; - -export const spec = { - code: ADG_BIDDER_CODE, - aliases: ['adg'], // short 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) { - return !!(bid.params.id); - }, - /** - * 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) { - const ADGENE_PREBID_VERSION = '1.0.1'; - let serverRequests = []; - for (let i = 0, len = validBidRequests.length; i < len; i++) { - const validReq = validBidRequests[i]; - 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 = ``; - data = utils.tryAppendQueryString(data, 'posall', 'SSPLOC'); - const id = utils.getBidIdParameter('id', validReq.params); - data = utils.tryAppendQueryString(data, 'id', id); - data = utils.tryAppendQueryString(data, 'sdktype', '0'); - data = utils.tryAppendQueryString(data, 'hb', 'true'); - data = utils.tryAppendQueryString(data, 't', 'json3'); - data = utils.tryAppendQueryString(data, 'transactionid', validReq.transactionId); - data = utils.tryAppendQueryString(data, 'sizes', getSizes(validReq)); - data = utils.tryAppendQueryString(data, 'currency', getCurrencyType()); - data = utils.tryAppendQueryString(data, 'pbver', '$prebid.version$'); - data = utils.tryAppendQueryString(data, 'sdkname', 'prebidjs'); - data = utils.tryAppendQueryString(data, 'adapterver', ADGENE_PREBID_VERSION); - // native以外にvideo等の対応が入った場合は要修正 - if (!validReq.mediaTypes || !validReq.mediaTypes.native) { - data = utils.tryAppendQueryString(data, 'imark', '1'); - } - data = utils.tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.referer); - // remove the trailing "&" - if (data.lastIndexOf('&') === data.length - 1) { - data = data.substring(0, data.length - 1); - } - serverRequests.push({ - method: 'GET', - url: url, - data: data, - bidRequest: validBidRequests[i] - }); - } - return serverRequests; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @param {BidRequest} bidRequests - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function (serverResponse, bidRequests) { - const body = serverResponse.body; - if (!body.results || body.results.length < 1) { - return []; - } - const bidRequest = bidRequests.bidRequest; - const bidResponse = { - requestId: bidRequest.bidId, - cpm: body.cpm || 0, - width: body.w ? body.w : 1, - height: body.h ? body.h : 1, - creativeId: body.creativeid || '', - dealId: body.dealid || '', - currency: getCurrencyType(), - netRevenue: true, - ttl: body.ttl || 10, - }; - if (isNative(body)) { - bidResponse.native = createNativeAd(body); - bidResponse.mediaType = NATIVE; - } else { - // banner - bidResponse.ad = createAd(body, bidRequest); - } - return [bidResponse]; - }, - - /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @return {UserSync[]} The user syncs which should be dropped. - */ - getUserSyncs: function (syncOptions, serverResponses) { - const syncs = []; - return syncs; - } -}; - -function createAd(body, bidRequest) { - let ad = body.ad; - if (body.vastxml && body.vastxml.length > 0) { - ad = `
${createAPVTag()}${insertVASTMethod(bidRequest.bidId, body.vastxml)}`; - } - ad = appendChildToBody(ad, body.beacon); - if (removeWrapper(ad)) return removeWrapper(ad); - return ad; -} - -function isNative(body) { - if (!body) return false; - return body.native_ad && body.native_ad.assets.length > 0; -} - -function createNativeAd(body) { - let native = {}; - if (body.native_ad && body.native_ad.assets.length > 0) { - const assets = body.native_ad.assets; - for (let i = 0, len = assets.length; i < len; i++) { - switch (assets[i].id) { - case 1: - native.title = assets[i].title.text; - break; - case 2: - native.image = { - url: assets[i].img.url, - height: assets[i].img.h, - width: assets[i].img.w, - }; - break; - case 3: - native.icon = { - url: assets[i].img.url, - height: assets[i].img.h, - width: assets[i].img.w, - }; - break; - case 4: - native.sponsoredBy = assets[i].data.value; - break; - case 5: - native.body = assets[i].data.value; - break; - case 6: - native.cta = assets[i].data.value; - break; - case 502: - native.privacyLink = encodeURIComponent(assets[i].data.value); - break; - } - } - native.clickUrl = body.native_ad.link.url; - native.clickTrackers = body.native_ad.link.clicktrackers || []; - native.impressionTrackers = body.native_ad.imptrackers || []; - if (body.beaconurl && body.beaconurl != '') { - native.impressionTrackers.push(body.beaconurl) - } - } - return native; -} - -function appendChildToBody(ad, data) { - return ad.replace(/<\/\s?body>/, `${data}`); -} - -function createAPVTag() { - const APVURL = 'https://cdn.apvdr.com/js/VideoAd.min.js'; - let apvScript = document.createElement('script'); - apvScript.type = 'text/javascript'; - apvScript.id = 'apv'; - apvScript.src = APVURL; - return apvScript.outerHTML; -} - -function insertVASTMethod(targetId, vastXml) { - let apvVideoAdParam = { - s: targetId - }; - let script = document.createElement(`script`); - script.type = 'text/javascript'; - script.innerHTML = `(function(){ new APV.VideoAd(${JSON.stringify(apvVideoAdParam)}).load('${vastXml.replace(/\r?\n/g, '')}'); })();`; - return script.outerHTML; -} - -/** - * - * @param ad - */ -function removeWrapper(ad) { - const bodyIndex = ad.indexOf(''); - const lastBodyIndex = ad.lastIndexOf(''); - if (bodyIndex === -1 || lastBodyIndex === -1) return false; - return ad.substr(bodyIndex, lastBodyIndex).replace('', '').replace('', ''); -} - -/** - * request - * @param validReq request - * @returns {?string} 300x250,320x50... - */ -function getSizes(validReq) { - const sizes = validReq.sizes; - if (!sizes || sizes.length < 1) return null; - let sizesStr = ''; - for (const i in sizes) { - const size = sizes[i]; - if (size.length !== 2) return null; - sizesStr += `${size[0]}x${size[1]},`; - } - if (sizesStr || sizesStr.lastIndexOf(',') === sizesStr.length - 1) { - sizesStr = sizesStr.substring(0, sizesStr.length - 1); - } - return sizesStr; -} - -/** - * @return {?string} USD or JPY - */ -function getCurrencyType() { - if (config.getConfig('currency.adServerCurrency') && config.getConfig('currency.adServerCurrency').toUpperCase() === 'USD') return 'USD'; - return 'JPY'; -} - -registerBidder(spec); diff --git a/modules/adglareBidAdapter.js b/modules/adglareBidAdapter.js deleted file mode 100644 index d66a38482ec..00000000000 --- a/modules/adglareBidAdapter.js +++ /dev/null @@ -1,90 +0,0 @@ -'use strict'; - -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'adglare'; - -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function (bid) { - let p = bid.params; - if (typeof p.domain === 'string' && !!p.domain.length && p.zID && !isNaN(p.zID) && p.type == 'banner') return true; - return false; - }, - buildRequests: function (validBidRequests, bidderRequest) { - let i; - let j; - let bidRequest; - let zID; - let domain; - let keywords; - let url; - let type; - let availscreen = window.innerWidth + 'x' + window.innerHeight; - let pixelRatio = window.devicePixelRatio || 1; - let screen = (pixelRatio * window.screen.width) + 'x' + (pixelRatio * window.screen.height); - let sizes = []; - let serverRequests = []; - let timeout = bidderRequest.timeout || 0; - let referer = bidderRequest.refererInfo.referer || ''; - let reachedtop = bidderRequest.refererInfo.reachedTop || ''; - for (i = 0; i < validBidRequests.length; i++) { - bidRequest = validBidRequests[i]; - zID = bidRequest.params.zID; - domain = bidRequest.params.domain; - keywords = bidRequest.params.keywords || ''; - type = bidRequest.params.type; - - // Build ad unit sizes - if (bidRequest.mediaTypes && bidRequest.mediaTypes[type]) { - for (j in bidRequest.mediaTypes[type].sizes) { - sizes.push(bidRequest.mediaTypes[type].sizes[j].join('x')); - } - } - - // Build URL - url = 'https://' + domain + '/?' + encodeURIComponent(zID) + '&pbjs&pbjs_version=1'; - url += '&pbjs_type=' + encodeURIComponent(type); - url += '&pbjs_timeout=' + encodeURIComponent(timeout); - url += '&pbjs_reachedtop=' + encodeURIComponent(reachedtop); - url += '&sizes=' + encodeURIComponent(sizes.join(',')); - url += '&screen=' + encodeURIComponent(screen); - url += '&availscreen=' + encodeURIComponent(availscreen); - url += '&referer=' + encodeURIComponent(referer); - if (keywords !== '') { - url += '&keywords=' + encodeURIComponent(keywords); - } - - // Push server request - serverRequests.push({ - method: 'GET', - url: url, - data: {}, - bidRequest: bidRequest - }); - } - return serverRequests; - }, - interpretResponse: function (serverResponse, request) { - const bidObj = request.bidRequest; - let bidResponses = []; - let bidResponse = {}; - serverResponse = serverResponse.body; - - if (serverResponse && serverResponse.status == 'OK' && bidObj) { - bidResponse.requestId = bidObj.bidId; - bidResponse.bidderCode = bidObj.bidder; - bidResponse.cpm = serverResponse.cpm; - bidResponse.width = serverResponse.width; - bidResponse.height = serverResponse.height; - bidResponse.ad = serverResponse.adhtml; - bidResponse.ttl = serverResponse.ttl; - bidResponse.creativeId = serverResponse.crID; - bidResponse.netRevenue = true; - bidResponse.currency = serverResponse.currency; - bidResponses.push(bidResponse); - } - return bidResponses; - }, -}; -registerBidder(spec); diff --git a/modules/adhashBidAdapter.js b/modules/adhashBidAdapter.js deleted file mode 100644 index b30f9cebbc1..00000000000 --- a/modules/adhashBidAdapter.js +++ /dev/null @@ -1,102 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import includes from 'core-js-pure/features/array/includes.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const VERSION = '1.0'; - -export const spec = { - code: 'adhash', - url: 'https://bidder.adhash.org/rtb?version=' + VERSION + '&prebid=true', - supportedMediaTypes: [ BANNER ], - - isBidRequestValid: (bid) => { - try { - const { publisherId, platformURL } = bid.params; - return ( - includes(Object.keys(bid.mediaTypes), BANNER) && - typeof publisherId === 'string' && - publisherId.length === 42 && - typeof platformURL === 'string' && - platformURL.length >= 13 - ); - } catch (error) { - return false; - } - }, - - buildRequests: (validBidRequests, bidderRequest) => { - const { gdprConsent } = bidderRequest; - const { url } = spec; - const bidRequests = []; - let referrer = ''; - if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; - } - for (var i = 0; i < validBidRequests.length; i++) { - var index = Math.floor(Math.random() * validBidRequests[i].sizes.length); - var size = validBidRequests[i].sizes[index].join('x'); - bidRequests.push({ - method: 'POST', - url: url, - bidRequest: validBidRequests[i], - data: { - timezone: new Date().getTimezoneOffset() / 60, - location: referrer, - publisherId: validBidRequests[i].params.publisherId, - size: { - screenWidth: window.screen.width, - screenHeight: window.screen.height - }, - navigator: { - platform: window.navigator.platform, - language: window.navigator.language, - userAgent: window.navigator.userAgent - }, - creatives: [{ - size: size, - position: validBidRequests[i].adUnitCode - }], - blockedCreatives: [], - currentTimestamp: new Date().getTime(), - recentAds: [], - GDPR: gdprConsent - }, - options: { - withCredentials: false, - crossOrigin: true - }, - }); - } - return bidRequests; - }, - - interpretResponse: (serverResponse, request) => { - const responseBody = serverResponse ? serverResponse.body : {}; - - if (!responseBody.creatives || responseBody.creatives.length === 0) { - return []; - } - - const publisherURL = JSON.stringify(request.bidRequest.params.platformURL); - const oneTimeId = request.bidRequest.adUnitCode + Math.random().toFixed(16).replace('0.', '.'); - const bidderResponse = JSON.stringify({ responseText: JSON.stringify(responseBody) }); - const requestData = JSON.stringify(request.data); - - return [{ - requestId: request.bidRequest.bidId, - cpm: responseBody.creatives[0].costEUR, - ad: - `
- - `, - width: request.bidRequest.sizes[0][0], - height: request.bidRequest.sizes[0][1], - creativeId: request.bidRequest.adUnitCode, - netRevenue: true, - currency: 'EUR', - ttl: 60 - }]; - } -}; - -registerBidder(spec); diff --git a/modules/adheseBidAdapter.js b/modules/adheseBidAdapter.js deleted file mode 100644 index b9dbae529ba..00000000000 --- a/modules/adheseBidAdapter.js +++ /dev/null @@ -1,233 +0,0 @@ -'use strict'; - -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'adhese'; -const GVLID = 553; -const USER_SYNC_BASE_URL = 'https://user-sync.adhese.com/iframe/user_sync.html'; - -export const spec = { - code: BIDDER_CODE, - gvlid: GVLID, - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid: function(bid) { - return !!(bid.params.account && bid.params.location && (bid.params.format || bid.mediaTypes.banner.sizes)); - }, - - buildRequests: function(validBidRequests, bidderRequest) { - if (validBidRequests.length === 0) { - return null; - } - const { gdprConsent, refererInfo } = bidderRequest; - - const gdprParams = (gdprConsent && gdprConsent.consentString) ? { xt: [gdprConsent.consentString] } : {}; - const refererParams = (refererInfo && refererInfo.referer) ? { xf: [base64urlEncode(refererInfo.referer)] } : {}; - const commonParams = { ...gdprParams, ...refererParams }; - - const slots = validBidRequests.map(bid => ({ - slotname: bidToSlotName(bid), - parameters: cleanTargets(bid.params.data) - })); - - const payload = { - slots: slots, - parameters: commonParams, - vastContentAsUrl: true, - user: { - ext: { - eids: getEids(validBidRequests), - } - } - }; - - const account = getAccount(validBidRequests); - const uri = 'https://ads-' + account + '.adhese.com/json'; - - return { - method: 'POST', - url: uri, - data: JSON.stringify(payload), - bids: validBidRequests, - options: { - contentType: 'application/json' - } - }; - }, - - interpretResponse: function(serverResponse, request) { - const serverAds = serverResponse.body.reduce(function(map, ad) { - map[ad.slotName] = ad; - return map; - }, {}); - - serverResponse.account = getAccount(request.bids); - - return request.bids - .map(bid => ({ - bid: bid, - ad: serverAds[bidToSlotName(bid)] - })) - .filter(item => item.ad) - .map(item => adResponse(item.bid, item.ad)); - }, - - getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { - if (syncOptions.iframeEnabled && serverResponses.length > 0) { - const account = serverResponses[0].account; - if (account) { - let syncurl = USER_SYNC_BASE_URL + '?account=' + account; - if (gdprConsent) { - syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); - syncurl += '&consentString=' + encodeURIComponent(gdprConsent.consentString || ''); - } - return [{type: 'iframe', url: syncurl}]; - } - } - return []; - } -}; - -function adResponse(bid, ad) { - const price = getPrice(ad); - const adDetails = getAdDetails(ad); - const markup = getAdMarkup(ad); - - const bidResponse = getbaseAdResponse({ - requestId: bid.bidId, - mediaType: ad.extension.mediaType, - cpm: Number(price.amount), - currency: price.currency, - width: Number(ad.width), - height: Number(ad.height), - creativeId: adDetails.creativeId, - dealId: adDetails.dealId, - adhese: { - originData: adDetails.originData, - origin: adDetails.origin, - originInstance: adDetails.originInstance - } - }); - - if (bidResponse.mediaType === VIDEO) { - if (ad.cachedBodyUrl) { - bidResponse.vastUrl = ad.cachedBodyUrl - } else { - bidResponse.vastXml = markup; - } - } else { - const counter = ad.impressionCounter ? "" : ''; - bidResponse.ad = markup + counter; - } - return bidResponse; -} - -function cleanTargets(target) { - const targets = {}; - if (target) { - Object.keys(target).forEach(function (key) { - const val = target[key]; - const dirtyValues = Array.isArray(val) ? val : [val]; - const values = dirtyValues.filter(v => v === 0 || v); - if (values.length > 0) { - if (targets[key]) { - const distinctValues = values.filter(v => targets[key].indexOf(v) < 0); - targets[key].push.apply(targets[key], distinctValues); - } else { - targets[key] = values; - } - } - }); - } - return targets; -} - -function bidToSlotName(bid) { - if (bid.params.format) { - return bid.params.location + '-' + bid.params.format; - } - - var sizes = bid.mediaTypes.banner.sizes; - sizes.sort(); - var format = sizes.map(size => size[0] + 'x' + size[1]).join('_'); - - if (format.length > 0) { - return bid.params.location + '-' + format; - } else { - return bid.params.location; - } -} - -function getAccount(validBidRequests) { - return validBidRequests[0].params.account; -} - -function getEids(validBidRequests) { - if (validBidRequests[0] && validBidRequests[0].userIdAsEids) { - return validBidRequests[0].userIdAsEids; - } -} - -function getbaseAdResponse(response) { - return Object.assign({ netRevenue: true, ttl: 360 }, response); -} - -function isAdheseAd(ad) { - return !ad.origin || ad.origin === 'JERLICIA'; -} - -function getAdMarkup(ad) { - if (!isAdheseAd(ad) || (ad.ext === 'js' && ad.body !== undefined && ad.body !== '' && ad.body.match(/ { - return Boolean(bid.bidId && bid.params && !isNaN(bid.params.placementId)); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - let placements = []; - let request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0]) - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - const len = validBidRequests.length; - - for (let i = 0; i < len; i++) { - let bid = validBidRequests[i]; - let traff = bid.params.traffic || BANNER - - placements.push({ - placementId: bid.params.placementId, - bidId: bid.bidId, - sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], - traffic: traff - }); - if (bid.schain) { - placements.schain = bid.schain; - } - } - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - serverResponse = serverResponse.body; - for (let i = 0; i < serverResponse.length; i++) { - let resItem = serverResponse[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, - - getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { - let syncUrl = URL_SYNC - if (gdprConsent && gdprConsent.consentString) { - if (typeof gdprConsent.gdprApplies === 'boolean') { - syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - syncUrl += `&gdpr==0&gdpr_consent=${gdprConsent.consentString}`; - } - } - if (uspConsent && uspConsent.consentString) { - syncUrl += `&ccpa_consent=${uspConsent.consentString}`; - } - return [{ - type: 'image', - url: syncUrl - }]; - } - -}; - -registerBidder(spec); diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js deleted file mode 100644 index d46c01f7f48..00000000000 --- a/modules/admaticBidAdapter.js +++ /dev/null @@ -1,147 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'admatic'; -const ENDPOINT_URL = 'https://ads4.admatic.com.tr/prebid/v3/bidrequest'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['admatic'], // short code - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function (bid) { - return !!(bid.params.pid && bid.params.wid && bid.params.url); - }, - /** - * 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) { - const payload = { - request: [] - }; - - for (var i = 0; i < validBidRequests.length; i++) { - var validBidRequest = validBidRequests[i]; - payload.auctionId = validBidRequest.auctionId; - payload.bidder = validBidRequest.bidder; - payload.bidderRequestId = validBidRequest.bidderRequestId; - payload.pid = validBidRequest.params.pid; - payload.wid = validBidRequest.params.wid; - payload.url = validBidRequest.params.url; - - var request = { - adUnitCode: validBidRequest.adUnitCode, - bidId: validBidRequest.bidId, - transactionId: validBidRequest.transactionId, - priceType: validBidRequest.params.priceType, - sizes: transformSizes(validBidRequest.sizes) - } - - payload.request.push(request); - } - - const payloadString = JSON.stringify(payload); - - return { - method: 'POST', - url: ENDPOINT_URL, - data: payloadString, - bidder: 'admatic', - bids: validBidRequests - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function (serverResponse, bidRequest) { - const serverBody = serverResponse.body; - const bidResponses = []; - - if (serverBody) { - if (serverBody.tags && serverBody.tags.length > 0) { - serverBody.tags.forEach(serverBid => { - if (serverBid != null) { - if (serverBid.cpm !== 0) { - const bidResponse = { - requestId: serverBid.bidId, - cpm: serverBid.cpm, - width: serverBid.width, - height: serverBid.height, - creativeId: serverBid.creativeId, - dealId: serverBid.dealId, - currency: serverBid.currency, - netRevenue: serverBid.netRevenue, - ttl: serverBid.ttl, - referrer: serverBid.referrer, - ad: serverBid.ad - }; - - bidResponses.push(bidResponse); - } - } - }); - } - } - - return bidResponses; - }, - /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @return {UserSync[]} The user syncs which should be dropped. - */ - getUserSyncs: function (syncOptions, serverResponses) { - const syncs = []; - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: 'https://ads4.admatic.com.tr/prebid/static/usersync/v3/async_usersync.html' - }); - } - - if (syncOptions.pixelEnabled && serverResponses.length > 0) { - syncs.push({ - type: 'image', - url: 'https://ads5.admatic.com.tr/prebid/v3/bidrequest/usersync' - }); - } - return syncs; - } -} - -/* 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; -} - -registerBidder(spec); diff --git a/modules/admediaBidAdapter.js b/modules/admediaBidAdapter.js deleted file mode 100644 index 0a9e510843c..00000000000 --- a/modules/admediaBidAdapter.js +++ /dev/null @@ -1,71 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'admedia'; -const ENDPOINT_URL = 'https://prebid.admedia.com/bidder/'; - -export const spec = { - code: BIDDER_CODE, - - isBidRequestValid: function (bid) { - return bid.params && !!bid.params.aid; - }, - - buildRequests: function (validBidRequests, bidderRequest) { - let payload = {}; - - if (bidderRequest && bidderRequest.refererInfo) { - payload.referer = encodeURIComponent(bidderRequest.refererInfo.referer); - } - - payload.tags = []; - - utils._each(validBidRequests, function (bid) { - const tag = { - id: bid.bidId, - sizes: bid.sizes, - aid: bid.params.aid - }; - payload.tags.push(tag); - }); - - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: ENDPOINT_URL, - data: payloadString, - }; - }, - - interpretResponse: function (serverResponse, bidRequest) { - const bidResponses = []; - - if (!serverResponse.body.tags) { - return bidResponses; - } - - utils._each(serverResponse.body.tags, function (response) { - if (!response.error && response.cpm > 0) { - const bidResponse = { - requestId: response.id, - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.id, - dealId: response.id, - currency: 'USD', - netRevenue: true, - ttl: 120, - // referrer: REFERER, - ad: response.ad - }; - - bidResponses.push(bidResponse); - } - }); - - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/adpartnerBidAdapter.js b/modules/adpartnerBidAdapter.js deleted file mode 100644 index 2180b472120..00000000000 --- a/modules/adpartnerBidAdapter.js +++ /dev/null @@ -1,124 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js' -import {ajax} from '../src/ajax.js'; - -const BIDDER_CODE = 'adpartner'; -export const ENDPOINT_PROTOCOL = 'https'; -export const ENDPOINT_DOMAIN = 'a4p.adpartner.pro'; -export const ENDPOINT_PATH = '/hb/bid'; - -export const spec = { - code: BIDDER_CODE, - - isBidRequestValid: function (bidRequest) { - return !!parseInt(bidRequest.params.unitId); - }, - - buildRequests: function (validBidRequests, bidderRequest) { - let referer = window.location.href; - try { - referer = typeof bidderRequest.refererInfo === 'undefined' - ? window.top.location.href - : bidderRequest.refererInfo.referer; - } catch (e) {} - - let bidRequests = []; - let beaconParams = { - tag: [], - sizes: [], - referer: '' - }; - - validBidRequests.forEach(function(validBidRequest) { - bidRequests.push({ - unitId: parseInt(validBidRequest.params.unitId), - adUnitCode: validBidRequest.adUnitCode, - sizes: validBidRequest.sizes, - bidId: validBidRequest.bidId, - referer: referer - }); - - beaconParams.tag.push(validBidRequest.params.unitId); - beaconParams.sizes.push(spec.joinSizesToString(validBidRequest.sizes)); - beaconParams.referer = encodeURIComponent(referer); - }); - - beaconParams.tag = beaconParams.tag.join(','); - beaconParams.sizes = beaconParams.sizes.join(','); - - let adPartnerRequestUrl = utils.buildUrl({ - protocol: ENDPOINT_PROTOCOL, - hostname: ENDPOINT_DOMAIN, - pathname: ENDPOINT_PATH, - search: beaconParams - }); - - return { - method: 'POST', - url: adPartnerRequestUrl, - data: JSON.stringify(bidRequests) - }; - }, - - joinSizesToString: function(sizes) { - let res = []; - sizes.forEach(function(size) { - res.push(size.join('x')); - }); - - return res.join('|'); - }, - - interpretResponse: function (serverResponse, bidRequest) { - const validBids = JSON.parse(bidRequest.data); - - if (typeof serverResponse.body === 'undefined') { - return []; - } - - return validBids - .map(bid => ({ - bid: bid, - ad: serverResponse.body[bid.adUnitCode] - })) - .filter(item => item.ad) - .map(item => spec.adResponse(item.bid, item.ad)); - }, - - adResponse: function(bid, ad) { - return { - requestId: bid.bidId, - ad: ad.ad, - cpm: ad.cpm, - width: ad.width, - height: ad.height, - ttl: 60, - creativeId: ad.creativeId, - netRevenue: ad.netRevenue, - currency: ad.currency, - winNotification: ad.winNotification - }; - }, - - onBidWon: function(data) { - data.winNotification.forEach(function(unitWon) { - let adPartnerBidWonUrl = utils.buildUrl({ - protocol: ENDPOINT_PROTOCOL, - hostname: ENDPOINT_DOMAIN, - pathname: unitWon.path - }); - - if (unitWon.method === 'POST') { - spec.postRequest(adPartnerBidWonUrl, JSON.stringify(unitWon.data)); - } - }); - - return true; - }, - - postRequest(endpoint, data) { - ajax(endpoint, null, data, {method: 'POST'}); - } -} - -registerBidder(spec); diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js deleted file mode 100644 index 12d0410a821..00000000000 --- a/modules/adprimeBidAdapter.js +++ /dev/null @@ -1,129 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'adprime'; -const AD_URL = 'https://delta.adprime.com/?c=o&m=multi'; -const SYNC_URL = 'https://delta.adprime.com/?c=rtb&m=sync'; - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native && bid.native.title && bid.native.image && bid.native.impressionTrackers); - default: - return false; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - let placements = []; - let request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - const len = validBidRequests.length; - - for (let i = 0; i < len; i++) { - let bid = validBidRequests[i]; - let sizes - let identeties = {} - if (bid.mediaTypes) { - if (bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { - sizes = bid.mediaTypes[BANNER].sizes - } else if (bid.mediaTypes[VIDEO] && bid.mediaTypes[VIDEO].playerSize) { - sizes = bid.mediaTypes[VIDEO].playerSize - } - } - if (bid.userId && bid.userId.idl_env) { - identeties.identityLink = bid.userId.idl_env - } - - placements.push({ - placementId: bid.params.placementId, - bidId: bid.bidId, - sizes: sizes || [], - wPlayer: sizes ? sizes[0] : 0, - hPlayer: sizes ? sizes[1] : 0, - traffic: bid.params.traffic || BANNER, - schain: bid.schain || {}, - keywords: bid.params.keywords || [], - identeties - }); - } - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - for (let i = 0; i < serverResponse.body.length; i++) { - let resItem = serverResponse.body[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, - - getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { - let syncUrl = SYNC_URL - if (gdprConsent && gdprConsent.consentString) { - if (typeof gdprConsent.gdprApplies === 'boolean') { - syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; - } - } - if (uspConsent && uspConsent.consentString) { - syncUrl += `&ccpa_consent=${uspConsent.consentString}`; - } - return [{ - type: 'image', - url: syncUrl - }]; - } - -}; - -registerBidder(spec); diff --git a/modules/advenueBidAdapter.js b/modules/advenueBidAdapter.js deleted file mode 100644 index d7fa614b0a7..00000000000 --- a/modules/advenueBidAdapter.js +++ /dev/null @@ -1,86 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'advenue'; -const URL_MULTI = 'https://ssp.advenuemedia.co.uk/?c=o&m=multi'; - -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) && - spec.supportedMediaTypes.indexOf(bid.params.traffic) !== -1 - ); - }, - - /** - * 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, bidderRequest) => { - let winTop; - try { - winTop = window.top; - winTop.location.toString(); - } catch (e) { - utils.logMessage(e); - winTop = window; - }; - - const location = bidderRequest ? new URL(bidderRequest.refererInfo.referer) : winTop.location; - const placements = []; - const request = { - 'secure': (location.protocol === 'https:') ? 1 : 0, - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - - for (let i = 0; i < validBidRequests.length; i++) { - const bid = validBidRequests[i]; - const params = bid.params; - placements.push({ - placementId: params.placementId, - bidId: bid.bidId, - sizes: bid.sizes, - traffic: params.traffic - }); - } - return { - method: 'POST', - url: URL_MULTI, - data: request - }; - }, - - /** - * 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: (serverResponse) => { - try { - serverResponse = serverResponse.body; - } catch (e) { - utils.logMessage(e); - }; - return serverResponse; - }, -}; - -registerBidder(spec); diff --git a/modules/advertlyBidAdapter.js b/modules/advertlyBidAdapter.js deleted file mode 100755 index 973b6dd0742..00000000000 --- a/modules/advertlyBidAdapter.js +++ /dev/null @@ -1,127 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import * as utils from '../src/utils.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import { ajax } from '../src/ajax.js'; -import {Renderer} from '../src/Renderer.js'; - -const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; -const BIDDER_CODE = 'advertly'; -const DOMAIN = 'https://api.advertly.com/'; -const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; - -function isBidRequestValid(bid) { - return (typeof bid.params !== 'undefined' && parseInt(utils.getValue(bid.params, 'publisherId')) > 0); -} - -function buildRequests(validBidRequests) { - return { - method: 'POST', - url: DOMAIN + 'www/admin/plugins/Prebid/getAd.php', - options: { - withCredentials: false, - crossOrigin: true - }, - data: validBidRequests, - }; -} - -function interpretResponse(serverResponse, request) { - const response = serverResponse.body; - const bidResponses = []; - var bidRequestResponses = []; - utils._each(response, function(bidAd) { - let bnd = {}; - Object.assign(bnd, bidAd); - bnd.adResponse = { - content: bidAd.vastXml, - height: bidAd.height, - width: bidAd.width - }; - bnd.ttl = config.getConfig('_bidderTimeout') - bnd.renderer = bidAd.context === 'outstream' ? createRenderer(bidAd, RENDERER_URL) : undefined; - bidResponses.push(bnd); - }); - - bidRequestResponses.push({ - function: 'saveResponses', - request: request, - response: bidResponses - }); - sendResponseToServer(bidRequestResponses); - return bidResponses; -} - -function outstreamRender(bidAd) { - bidAd.renderer.push(() => { - window.ANOutstreamVideo.renderAd({ - sizes: [bidAd.width, bidAd.height], - width: bidAd.width, - height: bidAd.height, - targetId: bidAd.adUnitCode, - adResponse: bidAd.adResponse, - rendererOptions: { - showVolume: false, - allowFullscreen: false - } - }); - }); -} - -function createRenderer(bidAd, url) { - const renderer = Renderer.install({ - id: bidAd.adUnitCode, - url: url, - loaded: false, - config: {'player_height': bidAd.height, 'player_width': bidAd.width}, - adUnitCode: bidAd.adUnitCode - }); - try { - renderer.setRender(outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - return renderer; -} - -function onBidWon(bid) { - let wonBids = []; - wonBids.push(bid); - wonBids[0].function = 'onBidWon'; - sendResponseToServer(wonBids); -} - -function onTimeout(details) { - details.unshift({ 'function': 'onTimeout' }); - sendResponseToServer(details); -} - -function sendResponseToServer(data) { - ajax(DOMAIN + 'www/admin/plugins/Prebid/tracking/track.php', null, JSON.stringify(data), { - withCredentials: false, - method: 'POST', - crossOrigin: true - }); -} - -function getUserSyncs(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: DOMAIN + 'www/admin/plugins/Prebid/userSync.php' - }]; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: SUPPORTED_AD_TYPES, - isBidRequestValid, - buildRequests, - interpretResponse, - getUserSyncs, - onBidWon, - onTimeout -}; - -registerBidder(spec); diff --git a/modules/ajaBidAdapter.js b/modules/ajaBidAdapter.js deleted file mode 100644 index ce4196fe249..00000000000 --- a/modules/ajaBidAdapter.js +++ /dev/null @@ -1,194 +0,0 @@ -import { Renderer } from '../src/Renderer.js'; -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO, BANNER, NATIVE } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'aja'; -const URL = 'https://ad.as.amanad.adtdp.com/v2/prebid'; -const SDK_TYPE = 5; -const AD_TYPE = { - BANNER: 1, - NATIVE: 2, - VIDEO: 3, -}; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [VIDEO, BANNER, NATIVE], - - isBidRequestValid: function(bid) { - return !!(bid.params.asi); - }, - - buildRequests: function(validBidRequests, bidderRequest) { - var bidRequests = []; - for (var i = 0, len = validBidRequests.length; i < len; i++) { - var bid = validBidRequests[i]; - var queryString = ''; - const asi = utils.getBidIdParameter('asi', bid.params); - queryString = utils.tryAppendQueryString(queryString, 'asi', asi); - queryString = utils.tryAppendQueryString(queryString, 'skt', SDK_TYPE); - queryString = utils.tryAppendQueryString(queryString, 'prebid_id', bid.bidId); - queryString = utils.tryAppendQueryString(queryString, 'prebid_ver', '$prebid.version$'); - - if (bidderRequest && bidderRequest.refererInfo) { - queryString = utils.tryAppendQueryString(queryString, 'page_url', bidderRequest.refererInfo.referer); - } - - bidRequests.push({ - method: 'GET', - url: URL, - data: queryString - }); - } - - return bidRequests; - }, - - interpretResponse: function(bidderResponse, request) { - const bidderResponseBody = bidderResponse.body; - - if (!bidderResponseBody.is_ad_return) { - return []; - } - - const ad = bidderResponseBody.ad; - - const bid = { - requestId: ad.prebid_id, - cpm: ad.price, - creativeId: ad.creative_id, - dealId: ad.deal_id, - currency: ad.currency || 'USD', - netRevenue: true, - ttl: 300, // 5 minutes - } - - if (AD_TYPE.VIDEO === ad.ad_type) { - const videoAd = bidderResponseBody.ad.video; - Object.assign(bid, { - vastXml: videoAd.vtag, - width: videoAd.w, - height: videoAd.h, - renderer: newRenderer(bidderResponseBody), - adResponse: bidderResponseBody, - mediaType: VIDEO - }); - } else if (AD_TYPE.BANNER === ad.ad_type) { - const bannerAd = bidderResponseBody.ad.banner; - Object.assign(bid, { - width: bannerAd.w, - height: bannerAd.h, - ad: bannerAd.tag, - mediaType: BANNER - }); - try { - bannerAd.imps.forEach(impTracker => { - const tracker = utils.createTrackPixelHtml(impTracker); - bid.ad += tracker; - }); - } catch (error) { - utils.logError('Error appending tracking pixel', error); - } - } else if (AD_TYPE.NATIVE === ad.ad_type) { - const nativeAds = ad.native.template_and_ads.ads; - - nativeAds.forEach(nativeAd => { - const assets = nativeAd.assets; - - Object.assign(bid, { - mediaType: NATIVE - }); - - bid.native = { - title: assets.title, - body: assets.description, - cta: assets.cta_text, - sponsoredBy: assets.sponsor, - clickUrl: assets.lp_link, - impressionTrackers: nativeAd.imps, - privacyLink: assets.adchoice_url, - }; - - if (assets.img_main !== undefined) { - bid.native.image = { - url: assets.img_main, - width: parseInt(assets.img_main_width, 10), - height: parseInt(assets.img_main_height, 10) - }; - } - - if (assets.img_icon !== undefined) { - bid.native.icon = { - url: assets.img_icon, - width: parseInt(assets.img_icon_width, 10), - height: parseInt(assets.img_icon_height, 10) - }; - } - }); - } - - return [bid]; - }, - - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - if (!serverResponses.length) { - return syncs; - } - - const bidderResponseBody = serverResponses[0].body; - - if (syncOptions.pixelEnabled && bidderResponseBody.syncs) { - bidderResponseBody.syncs.forEach(sync => { - syncs.push({ - type: 'image', - url: sync - }); - }); - } - - if (syncOptions.iframeEnabled && bidderResponseBody.sync_htmls) { - bidderResponseBody.sync_htmls.forEach(sync => { - syncs.push({ - type: 'iframe', - url: sync - }); - }); - } - - return syncs; - }, -} - -function newRenderer(bidderResponse) { - const renderer = Renderer.install({ - id: bidderResponse.ad.prebid_id, - url: bidderResponse.ad.video.purl, - loaded: false, - }); - - try { - renderer.setRender(outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on newRenderer', err); - } - - return renderer; -} - -function outstreamRender(bid) { - bid.renderer.push(() => { - window.aja_vast_player.init({ - vast_tag: bid.adResponse.ad.video.vtag, - ad_unit_code: bid.adUnitCode, // target div id to render video - width: bid.width, - height: bid.height, - progress: bid.adResponse.ad.video.progress, - loop: bid.adResponse.ad.video.loop, - inread: bid.adResponse.ad.video.inread - }); - }); -} - -registerBidder(spec); diff --git a/modules/atomxBidAdapter.js b/modules/atomxBidAdapter.js deleted file mode 100644 index e9f15218c4c..00000000000 --- a/modules/atomxBidAdapter.js +++ /dev/null @@ -1,107 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'atomx'; - -function getDomain() { - var domain = ''; - - try { - if ((domain === '') && (window.top == window)) { - domain = window.location.href; - } - - if ((domain === '') && (window.top == window.parent)) { - domain = document.referrer; - } - - if (domain == '') { - var atomxt = 'atomxtest'; - - // It should be impossible to change the window.location.ancestorOrigins. - window.location.ancestorOrigins[0] = atomxt; - if (window.location.ancestorOrigins[0] != atomxt) { - var ancestorOrigins = window.location.ancestorOrigins; - - // If the length is 0 we are a javascript tag running in the main domain. - // But window.top != window or window.location.hostname is empty. - if (ancestorOrigins.length == 0) { - // This browser is so fucked up, just return an empty string. - return ''; - } - - // ancestorOrigins is an array where [0] is our own window.location - // and [length-1] is the top window.location. - domain = ancestorOrigins[ancestorOrigins.length - 1]; - } - } - } catch (unused) { - } - - if (domain === '') { - domain = document.referrer; - } - - if (domain === '') { - domain = window.location.href; - } - - return domain.substr(0, 512); -} - -export const spec = { - code: BIDDER_CODE, - - isBidRequestValid: function(bid) { - return bid.params && (!!bid.params.id); - }, - - buildRequests: function(validBidRequests) { - return validBidRequests.map(bidRequest => { - return { - method: 'GET', - url: 'https://p.ato.mx/placement', - data: { - v: 12, - id: bidRequest.params.id, - size: utils.parseSizesInput(bidRequest.sizes)[0], - prebid: bidRequest.bidId, - b: 0, - h: '7t3y9', - type: 'javascript', - screen: window.screen.width + 'x' + window.screen.height + 'x' + window.screen.colorDepth, - timezone: new Date().getTimezoneOffset(), - domain: getDomain(), - r: document.referrer.substr(0, 512), - }, - }; - }); - }, - - interpretResponse: function (serverResponse, bidRequest) { - const body = serverResponse.body; - const res = { - requestId: body.code, - cpm: body.cpm * 1000, - width: body.width, - height: body.height, - creativeId: body.creative_id, - currency: 'USD', - netRevenue: true, - ttl: 60, - }; - - if (body.adm) { - res.ad = body.adm; - } else { - res.adUrl = body.url; - } - - return [res]; - }, - - getUserSyncs: function(syncOptions, serverResponses) { - return []; - }, -}; -registerBidder(spec); diff --git a/modules/avocetBidAdapter.js b/modules/avocetBidAdapter.js deleted file mode 100644 index 1283bb865d4..00000000000 --- a/modules/avocetBidAdapter.js +++ /dev/null @@ -1,141 +0,0 @@ -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'avct'; -const DEFAULT_BASE_URL = 'https://ads.avct.cloud'; -const DEFAULT_PREBID_PATH = '/prebid'; - -function getPrebidURL() { - let host = config.getConfig('avct.baseUrl'); - if (host && typeof host === 'string') { - return `${host}${getPrebidPath()}`; - } - return `${DEFAULT_BASE_URL}${getPrebidPath()}`; -} - -function getPrebidPath() { - let prebidPath = config.getConfig('avct.prebidPath'); - if (prebidPath && typeof prebidPath === 'string') { - return prebidPath; - } - return DEFAULT_PREBID_PATH; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid with params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function (bid) { - return ( - !!bid.params && - !!bid.params.placement && - typeof bid.params.placement === 'string' && - bid.params.placement.length === 24 - ); - }, - /** - * 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 (bidRequests, bidderRequest) { - // Get currency from config - const currency = config.getConfig('currency.adServerCurrency'); - - // Publisher domain from config - const publisherDomain = config.getConfig('publisherDomain'); - - // First-party data from config - const fpd = config.getLegacyFpd(config.getConfig('ortb2')); - - // GDPR status and TCF consent string - let tcfConsentString; - let gdprApplies = false; - if (bidderRequest.gdprConsent) { - tcfConsentString = bidderRequest.gdprConsent.consentString; - gdprApplies = !!bidderRequest.gdprConsent.gdprApplies; - } - - // US privacy string - let usPrivacyString; - if (bidderRequest.uspConsent) { - usPrivacyString = bidderRequest.uspConsent; - } - - // Supply chain - let schain; - if (bidderRequest.schain) { - schain = bidderRequest.schain; - } - - // ID5 identifier - let id5id; - if (bidRequests[0].userId && bidRequests[0].userId.id5id && bidRequests[0].userId.id5id.uid) { - id5id = bidRequests[0].userId.id5id.uid; - } - - // Build the avocet ext object - const ext = { - currency, - tcfConsentString, - gdprApplies, - usPrivacyString, - schain, - publisherDomain, - fpd, - id5id, - }; - - // Extract properties from bidderRequest - const { - auctionId, - auctionStart, - bidderCode, - bidderRequestId, - refererInfo, - timeout, - } = bidderRequest; - - // Construct payload - const payload = JSON.stringify({ - auctionId, - auctionStart, - bidderCode, - bidderRequestId, - refererInfo, - timeout, - bids: bidRequests, - ext, - }); - - return { - method: 'POST', - url: getPrebidURL(), - data: payload, - }; - }, - interpretResponse: function (serverResponse, bidRequest) { - if ( - !serverResponse || - !serverResponse.body || - typeof serverResponse.body !== 'object' - ) { - return []; - } - if (Array.isArray(serverResponse.body)) { - return serverResponse.body; - } - if (Array.isArray(serverResponse.body.responses)) { - return serverResponse.body.responses; - } - return []; - }, -}; -registerBidder(spec); diff --git a/modules/bidlabBidAdapter.js b/modules/bidlabBidAdapter.js deleted file mode 100644 index 8f501505a6d..00000000000 --- a/modules/bidlabBidAdapter.js +++ /dev/null @@ -1,112 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'bidlab'; -const AD_URL = 'https://service.bidlab.ai/?c=o&m=multi'; -const URL_SYNC = 'https://service.bidlab.ai/?c=o&m=sync'; -const NO_SYNC = true; - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native && bid.native.title && bid.native.image && bid.native.impressionTrackers); - default: - return false; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - noSync: NO_SYNC, - - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - let placements = []; - let request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0]) - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - const len = validBidRequests.length; - - for (let i = 0; i < len; i++) { - let bid = validBidRequests[i]; - let traff = bid.params.traffic || BANNER - - placements.push({ - placementId: bid.params.placementId, - bidId: bid.bidId, - sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], - traffic: traff - }); - if (bid.schain) { - placements.schain = bid.schain; - } - } - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - for (let i = 0; i < serverResponse.body.length; i++) { - let resItem = serverResponse.body[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, - - getUserSyncs: (syncOptions, serverResponses) => { - if (NO_SYNC) { - return false - } else { - return [{ - type: 'image', - url: URL_SYNC - }]; - } - } - -}; - -registerBidder(spec); diff --git a/modules/bidphysicsBidAdapter.js b/modules/bidphysicsBidAdapter.js deleted file mode 100644 index b6b5690ede5..00000000000 --- a/modules/bidphysicsBidAdapter.js +++ /dev/null @@ -1,134 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import {BANNER} from '../src/mediaTypes.js'; - -const ENDPOINT_URL = 'https://exchange.bidphysics.com/auction'; - -const DEFAULT_BID_TTL = 30; -const DEFAULT_CURRENCY = 'USD'; -const DEFAULT_NET_REVENUE = true; - -export const spec = { - code: 'bidphysics', - aliases: ['yieldlift'], - supportedMediaTypes: [BANNER], - - isBidRequestValid: function (bid) { - return (!!bid.params.unitId && typeof bid.params.unitId === 'string') || - (!!bid.params.networkId && typeof bid.params.networkId === 'string') || - (!!bid.params.publisherId && typeof bid.params.publisherId === 'string'); - }, - - buildRequests: function (validBidRequests, bidderRequest) { - if (!validBidRequests || !bidderRequest) { - return; - } - const publisherId = validBidRequests[0].params.publisherId; - const networkId = validBidRequests[0].params.networkId; - const impressions = validBidRequests.map(bidRequest => ({ - id: bidRequest.bidId, - banner: { - format: bidRequest.sizes.map(sizeArr => ({ - w: sizeArr[0], - h: sizeArr[1] - })) - }, - ext: { - bidphysics: { - unitId: bidRequest.params.unitId - } - } - })); - - const openrtbRequest = { - id: bidderRequest.auctionId, - imp: impressions, - site: { - domain: window.location.hostname, - page: window.location.href, - ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null - }, - ext: { - bidphysics: { - publisherId: publisherId, - networkId: networkId, - } - } - }; - - // apply gdpr - if (bidderRequest.gdprConsent) { - openrtbRequest.regs = {ext: {gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0}}; - openrtbRequest.user = {ext: {consent: bidderRequest.gdprConsent.consentString}}; - } - - const payloadString = JSON.stringify(openrtbRequest); - return { - method: 'POST', - url: ENDPOINT_URL, - data: payloadString, - }; - }, - - interpretResponse: function (serverResponse, request) { - const bidResponses = []; - const response = (serverResponse || {}).body; - // response is always one seat (bidphysics) with (optional) bids for each impression - if (response && response.seatbid && response.seatbid.length === 1 && response.seatbid[0].bid && response.seatbid[0].bid.length) { - response.seatbid[0].bid.forEach(bid => { - bidResponses.push({ - requestId: bid.impid, - cpm: bid.price, - width: bid.w, - height: bid.h, - ad: bid.adm, - ttl: DEFAULT_BID_TTL, - creativeId: bid.crid, - netRevenue: DEFAULT_NET_REVENUE, - currency: DEFAULT_CURRENCY, - }) - }) - } else { - utils.logInfo('bidphysics.interpretResponse :: no valid responses to interpret'); - } - return bidResponses; - }, - getUserSyncs: function (syncOptions, serverResponses) { - utils.logInfo('bidphysics.getUserSyncs', 'syncOptions', syncOptions, 'serverResponses', serverResponses); - let syncs = []; - - if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) { - return syncs; - } - - serverResponses.forEach(resp => { - const userSync = utils.deepAccess(resp, 'body.ext.usersync'); - if (userSync) { - let syncDetails = []; - Object.keys(userSync).forEach(key => { - const value = userSync[key]; - if (value.syncs && value.syncs.length) { - syncDetails = syncDetails.concat(value.syncs); - } - }); - syncDetails.forEach(syncDetails => { - syncs.push({ - type: syncDetails.type === 'iframe' ? 'iframe' : 'image', - url: syncDetails.url - }); - }); - - if (!syncOptions.iframeEnabled) { - syncs = syncs.filter(s => s.type !== 'iframe') - } - if (!syncOptions.pixelEnabled) { - syncs = syncs.filter(s => s.type !== 'image') - } - } - }); - utils.logInfo('bidphysics.getUserSyncs result=%o', syncs); - return syncs; - }, - -}; -registerBidder(spec); diff --git a/modules/bizzclickBidAdapter.js b/modules/bizzclickBidAdapter.js deleted file mode 100644 index 2af9a7afed2..00000000000 --- a/modules/bizzclickBidAdapter.js +++ /dev/null @@ -1,326 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; -import {config} from '../src/config.js'; - -const BIDDER_CODE = 'bizzclick'; -const ACCOUNTID_MACROS = '[account_id]'; -const URL_ENDPOINT = `https://us-e-node1.bizzclick.com/bid?rtb_seat_id=prebidjs&secret_key=${ACCOUNTID_MACROS}`; -const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' }; -const NATIVE_PARAMS = { - title: { - id: 0, - name: 'title' - }, - icon: { - id: 2, - type: 1, - name: 'img' - }, - image: { - id: 3, - type: 3, - name: 'img' - }, - sponsoredBy: { - id: 5, - name: 'data', - type: 1 - }, - body: { - id: 4, - name: 'data', - type: 2 - }, - cta: { - id: 1, - type: 12, - name: 'data' - } -}; -const NATIVE_VERSION = '1.2'; - -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.params.accountId) && Boolean(bid.params.placementId) - }, - - /** - * 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, bidderRequest) => { - if (validBidRequests && validBidRequests.length === 0) return [] - let accuontId = validBidRequests[0].params.accountId; - const endpointURL = URL_ENDPOINT.replace(ACCOUNTID_MACROS, accuontId); - - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - - let bids = []; - for (let bidRequest of validBidRequests) { - let impObject = prepareImpObject(bidRequest); - let data = { - id: bidRequest.bidId, - test: config.getConfig('debug') ? 1 : 0, - at: 1, - cur: ['USD'], - device: { - w: winTop.screen.width, - h: winTop.screen.height, - dnt: utils.getDNT() ? 1 : 0, - language: (navigator && navigator.language) ? navigator.language.indexOf('-') != -1 ? navigator.language.split('-')[0] : navigator.language : '', - }, - site: { - page: location.pathname, - host: location.host - }, - source: { - tid: bidRequest.transactionId - }, - regs: { - coppa: config.getConfig('coppa') === true ? 1 : 0, - ext: {} - }, - user: { - ext: {} - }, - tmax: bidRequest.timeout, - imp: [impObject], - }; - if (bidRequest) { - if (bidRequest.gdprConsent && bidRequest.gdprConsent.gdprApplies) { - utils.deepSetValue(data, 'regs.ext.gdpr', bidRequest.gdprConsent.gdprApplies ? 1 : 0); - utils.deepSetValue(data, 'user.ext.consent', bidRequest.gdprConsent.consentString); - } - - if (bidRequest.uspConsent !== undefined) { - utils.deepSetValue(data, 'regs.ext.us_privacy', bidRequest.uspConsent); - } - } - bids.push(data) - } - return { - method: 'POST', - url: endpointURL, - data: bids - }; - }, - - /** - * 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: (serverResponse) => { - if (!serverResponse || !serverResponse.body) return [] - let bizzclickResponse = serverResponse.body; - - let bids = []; - for (let response of bizzclickResponse) { - let mediaType = response.seatbid[0].bid[0].ext && response.seatbid[0].bid[0].ext.mediaType ? response.seatbid[0].bid[0].ext.mediaType : BANNER; - - let bid = { - requestId: response.id, - cpm: response.seatbid[0].bid[0].price, - width: response.seatbid[0].bid[0].w, - height: response.seatbid[0].bid[0].h, - ttl: response.ttl || 1200, - currency: response.cur || 'USD', - netRevenue: true, - creativeId: response.seatbid[0].bid[0].crid, - dealId: response.seatbid[0].bid[0].dealid, - mediaType: mediaType - }; - - switch (mediaType) { - case VIDEO: - bid.vastXml = response.seatbid[0].bid[0].adm - bid.vastUrl = response.seatbid[0].bid[0].ext.vastUrl - break - case NATIVE: - bid.native = parseNative(response.seatbid[0].bid[0].adm) - break - default: - bid.ad = response.seatbid[0].bid[0].adm - } - - bids.push(bid); - } - - return bids; - }, -}; - -/** - * Determine type of request - * - * @param bidRequest - * @param type - * @returns {boolean} - */ -const checkRequestType = (bidRequest, type) => { - return (typeof utils.deepAccess(bidRequest, `mediaTypes.${type}`) !== 'undefined'); -} - -const parseNative = admObject => { - const { assets, link, imptrackers, jstracker } = admObject.native; - const result = { - clickUrl: link.url, - clickTrackers: link.clicktrackers || undefined, - impressionTrackers: imptrackers || undefined, - javascriptTrackers: jstracker ? [ jstracker ] : undefined - }; - assets.forEach(asset => { - const kind = NATIVE_ASSET_IDS[asset.id]; - const content = kind && asset[NATIVE_PARAMS[kind].name]; - if (content) { - result[kind] = content.text || content.value || { url: content.url, width: content.w, height: content.h }; - } - }); - - return result; -} - -const prepareImpObject = (bidRequest) => { - let impObject = { - id: bidRequest.transactionId, - secure: 1, - ext: { - placementId: bidRequest.params.placementId - } - }; - if (checkRequestType(bidRequest, BANNER)) { - impObject.banner = addBannerParameters(bidRequest); - } - if (checkRequestType(bidRequest, VIDEO)) { - impObject.video = addVideoParameters(bidRequest); - } - if (checkRequestType(bidRequest, NATIVE)) { - impObject.native = { - ver: NATIVE_VERSION, - request: addNativeParameters(bidRequest) - }; - } - return impObject -}; - -const addNativeParameters = bidRequest => { - let impObject = { - id: bidRequest.transactionId, - ver: NATIVE_VERSION, - }; - - const assets = utils._map(bidRequest.mediaTypes.native, (bidParams, key) => { - const props = NATIVE_PARAMS[key]; - const asset = { - required: bidParams.required & 1, - }; - if (props) { - asset.id = props.id; - let wmin, hmin; - let aRatios = bidParams.aspect_ratios; - - if (aRatios && aRatios[0]) { - aRatios = aRatios[0]; - wmin = aRatios.min_width || 0; - hmin = aRatios.ratio_height * wmin / aRatios.ratio_width | 0; - } - - if (bidParams.sizes) { - const sizes = flatten(bidParams.sizes); - wmin = sizes[0]; - hmin = sizes[1]; - } - - asset[props.name] = {} - - if (bidParams.len) asset[props.name]['len'] = bidParams.len; - if (props.type) asset[props.name]['type'] = props.type; - if (wmin) asset[props.name]['wmin'] = wmin; - if (hmin) asset[props.name]['hmin'] = hmin; - - return asset; - } - }).filter(Boolean); - - impObject.assets = assets; - return impObject -} - -const addBannerParameters = (bidRequest) => { - let bannerObject = {}; - const size = parseSizes(bidRequest, 'banner'); - bannerObject.w = size[0]; - bannerObject.h = size[1]; - return bannerObject; -}; - -const parseSizes = (bid, mediaType) => { - let mediaTypes = bid.mediaTypes; - if (mediaType === 'video') { - let size = []; - if (mediaTypes.video && mediaTypes.video.w && mediaTypes.video.h) { - size = [ - mediaTypes.video.w, - mediaTypes.video.h - ]; - } else if (Array.isArray(utils.deepAccess(bid, 'mediaTypes.video.playerSize')) && bid.mediaTypes.video.playerSize.length === 1) { - size = bid.mediaTypes.video.playerSize[0]; - } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0 && Array.isArray(bid.sizes[0]) && bid.sizes[0].length > 1) { - size = bid.sizes[0]; - } - return size; - } - let sizes = []; - if (Array.isArray(mediaTypes.banner.sizes)) { - sizes = mediaTypes.banner.sizes[0]; - } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { - sizes = bid.sizes - } else { - utils.logWarn('no sizes are setup or found'); - } - - return sizes -} - -const addVideoParameters = (bidRequest) => { - let videoObj = {}; - let supportParamsList = ['mimes', 'minduration', 'maxduration', 'protocols', 'startdelay', 'placement', 'skip', 'skipafter', 'minbitrate', 'maxbitrate', 'delivery', 'playbackmethod', 'api', 'linearity'] - - for (let param of supportParamsList) { - if (bidRequest.mediaTypes.video[param] !== undefined) { - videoObj[param] = bidRequest.mediaTypes.video[param]; - } - } - - const size = parseSizes(bidRequest, 'video'); - videoObj.w = size[0]; - videoObj.h = size[1]; - return videoObj; -} - -const flatten = arr => { - return [].concat(...arr); -} - -registerBidder(spec); diff --git a/modules/boldwinBidAdapter.js b/modules/boldwinBidAdapter.js deleted file mode 100644 index 04f4085ba24..00000000000 --- a/modules/boldwinBidAdapter.js +++ /dev/null @@ -1,110 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'boldwin'; -const AD_URL = 'https://ssp.videowalldirect.com/?c=o&m=multi'; -const SYNC_URL = 'https://cs.videowalldirect.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 && bid.native.title && bid.native.image && bid.native.impressionTrackers); - default: - return false; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - let placements = []; - let request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - const len = validBidRequests.length; - - for (let i = 0; i < len; i++) { - let bid = validBidRequests[i]; - let sizes - if (bid.mediaTypes) { - if (bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { - sizes = bid.mediaTypes[BANNER].sizes - } else if (bid.mediaTypes[VIDEO] && bid.mediaTypes[VIDEO].playerSize) { - sizes = bid.mediaTypes[VIDEO].playerSize - } - } - placements.push({ - placementId: bid.params.placementId, - bidId: bid.bidId, - sizes: sizes || [], - wPlayer: sizes ? sizes[0] : 0, - hPlayer: sizes ? sizes[1] : 0, - traffic: bid.params.traffic || BANNER, - schain: bid.schain || {} - }); - } - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - for (let i = 0; i < serverResponse.body.length; i++) { - let resItem = serverResponse.body[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, - - getUserSyncs: () => { - return [{ - type: 'image', - url: SYNC_URL - }]; - } -}; - -registerBidder(spec); diff --git a/modules/byplayBidAdapter.js b/modules/byplayBidAdapter.js deleted file mode 100644 index 6133cdfa647..00000000000 --- a/modules/byplayBidAdapter.js +++ /dev/null @@ -1,67 +0,0 @@ -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { Renderer } from '../src/Renderer.js'; -import { VIDEO } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'byplay'; -const ENDPOINT_URL = 'https://prebid.byplay.net/bidder'; -const VIDEO_PLAYER_URL = 'https://cdn.byplay.net/prebid-byplay-v2.js'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [VIDEO], - isBidRequestValid: (bid) => { - return !!bid.params.sectionId; - }, - buildRequests: function(validBidRequests) { - return validBidRequests.map(req => { - const payload = { - requestId: req.bidId, - sectionId: req.params.sectionId, - ...(req.params.env ? { env: req.params.env } : {}) - }; - - return { - method: 'POST', - url: ENDPOINT_URL, - data: JSON.stringify(payload), - options: { - withCredentials: false - } - }; - }); - }, - interpretResponse: (serverResponse, bidderRequest) => { - const response = serverResponse.body; - const data = JSON.parse(bidderRequest.data); - const bidResponse = { - requestId: data.requestId, - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.creativeId || '0', - ttl: config.getConfig('_bidderTimeout'), - currency: 'JPY', - netRevenue: response.netRevenue, - mediaType: VIDEO, - vastXml: response.vastXml, - renderer: createRenderer() - }; - - return [bidResponse]; - } -}; - -function createRenderer() { - const renderer = Renderer.install({ url: VIDEO_PLAYER_URL }); - - renderer.setRender(bid => { - bid.renderer.push(() => { - window.adtagRender(bid); - }); - }); - - return renderer; -} - -registerBidder(spec); diff --git a/modules/cedatoBidAdapter.js b/modules/cedatoBidAdapter.js deleted file mode 100644 index ab381698f01..00000000000 --- a/modules/cedatoBidAdapter.js +++ /dev/null @@ -1,229 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const storage = getStorageManager(); - -const BIDDER_CODE = 'cedato'; -const BID_URL = 'https://h.cedatoplayer.com/hb'; -const SYNC_URL = 'https://h.cedatoplayer.com/hb_usync'; -const TTL = 10000; -const CURRENCY = 'USD'; -const NET_REVENUE = true; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid: function(bid) { - return !!( - bid && - bid.params && - bid.params.player_id && - utils.checkCookieSupport() && - storage.cookiesAreEnabled() - ); - }, - - buildRequests: function(bidRequests, bidderRequest) { - const site = { domain: document.domain }; - const device = { ua: navigator.userAgent, w: screen.width, h: screen.height }; - const currency = CURRENCY; - const tmax = bidderRequest.timeout; - const auctionId = bidderRequest.auctionId; - const auctionStart = bidderRequest.auctionStart; - const bidderRequestId = bidderRequest.bidderRequestId; - - const imp = bidRequests.map(req => { - const banner = getMediaType(req, 'banner'); - const video = getMediaType(req, 'video'); - const params = req.params; - const bidId = req.bidId; - const adUnitCode = req.adUnitCode; - const bidRequestsCount = req.bidRequestsCount; - const bidderWinsCount = req.bidderWinsCount; - const transactionId = req.transactionId; - - return { - bidId, - banner, - video, - adUnitCode, - bidRequestsCount, - bidderWinsCount, - transactionId, - params - }; - }); - - const payload = { - version: '$prebid.version$', - site, - device, - imp, - currency, - tmax, - auctionId, - auctionStart, - bidderRequestId - }; - - if (bidderRequest) { - payload.referer_info = bidderRequest.refererInfo; - payload.us_privacy = bidderRequest.uspConsent; - - if (bidderRequest.gdprConsent) { - payload.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - } - } - - return formatRequest(payload, bidderRequest); - }, - - interpretResponse: function(resp, {bidderRequest}) { - resp = resp.body; - const bids = []; - - if (!resp) { - return bids; - } - - resp.seatbid[0].bid.map(serverBid => { - const bid = newBid(serverBid, bidderRequest); - bid.currency = resp.cur; - bids.push(bid); - }); - - return bids; - }, - - getUserSyncs: function(syncOptions, resps, gdprConsent, uspConsent) { - const syncs = []; - if (syncOptions.iframeEnabled) { - syncs.push(getSync('iframe', gdprConsent, uspConsent)); - } else if (syncOptions.pixelEnabled) { - syncs.push(getSync('image', gdprConsent, uspConsent)); - } - return syncs; - } -} - -function getMediaType(req, type) { - const { mediaTypes } = req; - - if (!mediaTypes) { - return; - } - - switch (type) { - case 'banner': - if (mediaTypes.banner) { - const { sizes } = mediaTypes.banner; - return { - format: getFormats(sizes) - }; - } - break; - - case 'video': - if (mediaTypes.video) { - const { playerSize, context } = mediaTypes.video; - return { - context: context, - format: getFormats(playerSize) - }; - } - } -} - -function newBid(serverBid, bidderRequest) { - const bidRequest = utils.getBidRequest(serverBid.uuid, [bidderRequest]); - - const cpm = serverBid.price; - const requestId = serverBid.uuid; - const width = serverBid.w; - const height = serverBid.h; - const creativeId = serverBid.crid; - const dealId = serverBid.dealid; - const mediaType = serverBid.media_type; - const netRevenue = NET_REVENUE; - const ttl = TTL; - - const bid = { - cpm, - requestId, - width, - height, - mediaType, - creativeId, - dealId, - netRevenue, - ttl, - }; - - if (mediaType == 'video') { - const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); - - if (videoContext == 'instream') { - bid.vastUrl = serverBid.vast_url; - bid.vastImpUrl = serverBid.notify_url; - } - } else { - bid.ad = serverBid.adm; - } - - return bid; -} - -function formatRequest(payload, bidderRequest) { - const payloadByUrl = {}; - const requests = []; - - payload.imp.forEach(imp => { - const url = imp.params.bid_url || BID_URL; - if (!payloadByUrl[url]) { - payloadByUrl[url] = { - ...payload, - imp: [] - }; - } - payloadByUrl[url].imp.push(imp); - }); - - for (const url in payloadByUrl) { - requests.push({ - url, - method: 'POST', - data: JSON.stringify(payloadByUrl[url]), - bidderRequest - }); - } - - return requests; -} - -const getSync = (type, gdprConsent, uspConsent = '') => { - const syncUrl = SYNC_URL; - let params = '?type=' + type + '&us_privacy=' + uspConsent; - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - if (typeof gdprConsent.gdprApplies === 'boolean') { - params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - params += `&gdpr_consent=${gdprConsent.consentString}`; - } - } - return { - type: type, - url: syncUrl + params, - }; -} - -const getFormats = arr => arr.map((s) => { - return { w: s[0], h: s[1] }; -}); - -registerBidder(spec); diff --git a/modules/clickforceBidAdapter.js b/modules/clickforceBidAdapter.js deleted file mode 100644 index 20408fe9177..00000000000 --- a/modules/clickforceBidAdapter.js +++ /dev/null @@ -1,126 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER, NATIVE} from '../src/mediaTypes.js'; -const BIDDER_CODE = 'clickforce'; -const ENDPOINT_URL = 'https://ad.holmesmind.com/adserver/prebid.json?cb=' + new Date().getTime() + '&hb=1&ver=1.21'; - -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) { - return bid && bid.params && !!bid.params.zone; - }, - - /** - * 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 bidParams = []; - utils._each(validBidRequests, function(bid) { - bidParams.push({ - z: bid.params.zone, - bidId: bid.bidId - }); - }); - return { - method: 'POST', - url: ENDPOINT_URL, - data: bidParams, - 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 cfResponses = []; - const bidRequestList = []; - - if (typeof bidRequest != 'undefined') { - utils._each(bidRequest.validBidRequests, function(req) { - bidRequestList[req.bidId] = req; - }); - } - - utils._each(serverResponse.body, function(response) { - if (response.requestId != null) { - // native ad size - if (response.width == 3) { - cfResponses.push({ - requestId: response.requestId, - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.creativeId, - currency: response.currency, - netRevenue: response.netRevenue, - ttl: response.ttl, - native: { - title: response.tag.content.title, - body: response.tag.content.content, - image: { - url: response.tag.content.image, - height: 900, - width: 1600 - }, - icon: { - url: response.tag.content.icon, - height: 900, - width: 900 - }, - clickUrl: response.tag.cu, - cta: response.tag.content.button_text, - sponsoredBy: response.tag.content.advertiser, - impressionTrackers: response.tag.iu, - }, - mediaType: 'native', - }); - } else { - // display ad - cfResponses.push({ - requestId: response.requestId, - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.creativeId, - currency: response.currency, - netRevenue: response.netRevenue, - ttl: response.ttl, - ad: response.tag, - mediaType: 'banner', - }); - } - } - }); - return cfResponses; - }, - getUserSyncs: function(syncOptions, serverResponses) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: 'https://cdn.holmesmind.com/js/capmapping.htm' - }] - } else if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: 'https://c.holmesmind.com/cm' - }] - } - } -}; - -registerBidder(spec); diff --git a/modules/clicktripzBidAdapter.js b/modules/clicktripzBidAdapter.js deleted file mode 100644 index 2149cbe4527..00000000000 --- a/modules/clicktripzBidAdapter.js +++ /dev/null @@ -1,67 +0,0 @@ -import {logError, _each} from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'clicktripz'; -const ENDPOINT_URL = 'https://www.clicktripz.com/x/prebid/v1'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['ctz'], // short code - - isBidRequestValid: function (bid) { - if (bid && bid.params && bid.params.placementId && bid.params.siteId) { - return true; - } - - return false; - }, - - buildRequests: function (validBidRequests) { - let bidRequests = []; - - _each(validBidRequests, function (bid) { - bidRequests.push({ - bidId: bid.bidId, - placementId: bid.params.placementId, - siteId: bid.params.siteId, - sizes: bid.sizes.map(function (size) { - return size.join('x') - }) - }); - }); - return { - method: 'POST', - url: ENDPOINT_URL, - data: bidRequests - }; - }, - - interpretResponse: function (serverResponse) { - let bidResponses = []; - - if (serverResponse && serverResponse.body) { - _each(serverResponse.body, function (bid) { - if (bid.errors) { - logError(bid.errors); - return; - } - - const size = bid.size.split('x'); - bidResponses.push({ - requestId: bid.bidId, - cpm: bid.cpm, - width: size[0], - height: size[1], - creativeId: bid.creativeId, - currency: bid.currency, - netRevenue: bid.netRevenue, - ttl: bid.ttl, - adUrl: bid.adUrl - }); - }); - } - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/collectcentBidAdapter.js b/modules/collectcentBidAdapter.js deleted file mode 100644 index add3e06430d..00000000000 --- a/modules/collectcentBidAdapter.js +++ /dev/null @@ -1,93 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'collectcent'; -const URL_MULTI = '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, - 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) && - spec.supportedMediaTypes.indexOf(bid.params.traffic) !== -1 - ); - }, - - /** - * 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, bidderRequest) => { - let winTop; - try { - winTop = window.top; - } catch (e) { - utils.logMessage(e); - winTop = window; - }; - - const placements = []; - const location = bidderRequest ? new URL(bidderRequest.refererInfo.referer) : winTop.location; - const request = { - 'secure': (location.protocol === 'https:') ? 1 : 0, - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - - for (let i = 0; i < validBidRequests.length; i++) { - const bid = validBidRequests[i]; - const params = bid.params; - placements.push({ - placementId: params.placementId, - bidId: bid.bidId, - sizes: bid.sizes, - traffic: params.traffic - }); - } - return { - method: 'POST', - url: URL_MULTI, - data: request - }; - }, - - /** - * 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: (serverResponse) => { - try { - serverResponse = serverResponse.body; - } catch (e) { - utils.logMessage(e); - }; - return serverResponse; - }, - - getUserSyncs: () => { - return [{ - type: 'image', - url: URL_SYNC - }]; - } -}; - -registerBidder(spec); diff --git a/modules/colombiaBidAdapter.js b/modules/colombiaBidAdapter.js deleted file mode 100644 index 55109dbaab2..00000000000 --- a/modules/colombiaBidAdapter.js +++ /dev/null @@ -1,82 +0,0 @@ -import * as utils from '../src/utils.js'; -import {config} from '../src/config.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; -const BIDDER_CODE = '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'], - supportedMediaTypes: [BANNER], - isBidRequestValid: function(bid) { - return !!(bid.params.placementId); - }, - 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.placementId; - const cb = Math.floor(Math.random() * 99999999999); - const bidId = bidRequest.bidId; - const referrer = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : ''; - 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; - let cpm = response.cpm || 0; - if (width == 300 && height == 250) { - cpm = cpm * 0.2; - } - if (width == 320 && height == 50) { - cpm = cpm * 0.55; - } - if (cpm <= 0) { - return bidResponses; - } - 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 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: bidRequest.data.r, - ad: response.ad - }; - bidResponses.push(bidResponse); - } - return bidResponses; - } -} -registerBidder(spec); diff --git a/modules/colossussspBidAdapter.js b/modules/colossussspBidAdapter.js deleted file mode 100644 index 1afb343566d..00000000000 --- a/modules/colossussspBidAdapter.js +++ /dev/null @@ -1,156 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'colossusssp'; -const G_URL = 'https://colossusssp.com/?c=o&m=multi'; -const G_URL_SYNC = 'https://colossusssp.com/?c=o&m=cookie'; - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { - 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); - default: - return false; - } -} - -function getUserId(eids, id, source, uidExt) { - if (id) { - var uid = { id }; - if (uidExt) { - uid.ext = uidExt; - } - eids.push({ - source, - uids: [ uid ] - }); - } -} - -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.placement_id)); - }, - - /** - * 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, bidderRequest) => { - const winTop = utils.getWindowTop(); - const location = winTop.location; - let placements = []; - let request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language : '', - 'secure': location.protocol === 'https:' ? 1 : 0, - 'host': location.host, - 'page': location.pathname, - 'placements': placements, - }; - - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr_consent = bidderRequest.gdprConsent.consentString || 'ALL' - request.gdpr_require = bidderRequest.gdprConsent.gdprApplies ? 1 : 0 - } - } - - for (let i = 0; i < validBidRequests.length; i++) { - let bid = validBidRequests[i]; - let traff = bid.params.traffic || BANNER - let placement = { - placementId: bid.params.placement_id, - bidId: bid.bidId, - sizes: bid.mediaTypes[traff].sizes, - traffic: traff, - eids: [], - floor: {} - }; - if (typeof bid.getFloor === 'function') { - let tmpFloor = {}; - for (let size of placement.sizes) { - tmpFloor = bid.getFloor({ - currency: 'USD', - mediaType: traff, - size: size - }); - if (tmpFloor) { - placement.floor[`${size[0]}x${size[1]}`] = tmpFloor.floor; - } - } - } - if (bid.schain) { - placement.schain = bid.schain; - } - if (bid.userId) { - getUserId(placement.eids, bid.userId.britepoolid, 'britepool.com'); - getUserId(placement.eids, bid.userId.idl_env, 'identityLink'); - getUserId(placement.eids, bid.userId.id5id, 'id5-sync.com') - getUserId(placement.eids, bid.userId.tdid, 'adserver.org', { - rtiPartner: 'TDID' - }); - } - placements.push(placement); - } - return { - method: 'POST', - url: G_URL, - data: request - }; - }, - - /** - * 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: (serverResponse) => { - let response = []; - try { - serverResponse = serverResponse.body; - for (let i = 0; i < serverResponse.length; i++) { - let resItem = serverResponse[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - } catch (e) { - utils.logMessage(e); - }; - return response; - }, - - getUserSyncs: () => { - return [{ - type: 'image', - url: G_URL_SYNC - }]; - } -}; - -registerBidder(spec); diff --git a/modules/convergeBidAdapter.js b/modules/convergeBidAdapter.js deleted file mode 100644 index bea3b6cb1ab..00000000000 --- a/modules/convergeBidAdapter.js +++ /dev/null @@ -1,313 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { Renderer } from '../src/Renderer.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'converge'; -const ENDPOINT_URL = 'https://tech.convergd.com/hb'; -const TIME_TO_LIVE = 360; -const SYNC_URL = 'https://tech.convergd.com/push_sync'; -const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; - -let hasSynced = false; - -const LOG_ERROR_MESS = { - noAuid: 'Bid from response has no auid parameter - ', - noAdm: 'Bid from response has no adm parameter - ', - noBid: 'Array of bid objects is empty', - noPlacementCode: "Can't find in requested bids the bid with auid - ", - emptyUids: 'Uids should be not empty', - emptySeatbid: 'Seatbid array from response has empty item', - emptyResponse: 'Response is empty', - hasEmptySeatbidArray: 'Response has empty seatbid array', - hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' -}; -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [ BANNER, VIDEO ], - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!bid.params.uid; - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests - an array of bids - * @param {bidderRequest} bidderRequest - bidder request object - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(validBidRequests, bidderRequest) { - const auids = []; - const bidsMap = {}; - const slotsMapByUid = {}; - const sizeMap = {}; - const bids = validBidRequests || []; - let priceType = 'net'; - let pageKeywords; - let reqId; - - bids.forEach(bid => { - if (bid.params.priceType === 'gross') { - priceType = 'gross'; - } - reqId = bid.bidderRequestId; - const {params: {uid}, adUnitCode} = bid; - auids.push(uid); - const sizesId = utils.parseSizesInput(bid.sizes); - - if (!pageKeywords && !utils.isEmpty(bid.params.keywords)) { - const keywords = utils.transformBidderParamKeywords(bid.params.keywords); - - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } - pageKeywords = keywords; - } - - if (!slotsMapByUid[uid]) { - slotsMapByUid[uid] = {}; - } - const slotsMap = slotsMapByUid[uid]; - if (!slotsMap[adUnitCode]) { - slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []}; - } else { - slotsMap[adUnitCode].bids.push(bid); - } - const slot = slotsMap[adUnitCode]; - - sizesId.forEach((sizeId) => { - sizeMap[sizeId] = true; - if (!bidsMap[uid]) { - bidsMap[uid] = {}; - } - - if (!bidsMap[uid][sizeId]) { - bidsMap[uid][sizeId] = [slot]; - } else { - bidsMap[uid][sizeId].push(slot); - } - slot.parents.push({parent: bidsMap[uid], key: sizeId, uid}); - }); - }); - - const payload = { - pt: priceType, - auids: auids.join(','), - sizes: utils.getKeys(sizeMap).join(','), - r: reqId, - wrapperType: 'Prebid_js', - wrapperVersion: '$prebid.version$' - }; - - if (pageKeywords) { - payload.keywords = JSON.stringify(pageKeywords); - } - - if (bidderRequest) { - if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - payload.u = bidderRequest.refererInfo.referer; - } - if (bidderRequest.timeout) { - payload.wtimeout = bidderRequest.timeout; - } - if (bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.consentString) { - payload.gdpr_consent = bidderRequest.gdprConsent.consentString; - } - payload.gdpr_applies = - (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') - ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; - } - if (bidderRequest.uspConsent) { - payload.us_privacy = bidderRequest.uspConsent; - } - } - - return { - method: 'GET', - url: ENDPOINT_URL, - data: utils.parseQueryStringParameters(payload).replace(/\&$/, ''), - bidsMap: bidsMap, - }; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @param {*} bidRequest - * @param {Renderer} RendererConst - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest, RendererConst = Renderer) { - serverResponse = serverResponse && serverResponse.body; - const bidResponses = []; - const bidsMap = bidRequest.bidsMap; - const priceType = bidRequest.data.pt; - - let errorMessage; - - if (!serverResponse) errorMessage = LOG_ERROR_MESS.emptyResponse; - else if (serverResponse.seatbid && !serverResponse.seatbid.length) { - errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray; - } - - if (!errorMessage && serverResponse.seatbid) { - serverResponse.seatbid.forEach(respItem => { - _addBidResponse(_getBidFromResponse(respItem), bidsMap, priceType, bidResponses, RendererConst); - }); - } - if (errorMessage) utils.logError(errorMessage); - return bidResponses; - }, - getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { - if (!hasSynced && syncOptions.pixelEnabled) { - let params = ''; - - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - if (typeof gdprConsent.gdprApplies === 'boolean') { - params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - params += `&gdpr_consent=${gdprConsent.consentString}`; - } - } - if (uspConsent) { - params += `&us_privacy=${uspConsent}`; - } - - hasSynced = true; - return { - type: 'image', - url: SYNC_URL + params - }; - } - } -}; - -function isPopulatedArray(arr) { - return !!(utils.isArray(arr) && arr.length > 0); -} - -function deleteValues(keyPairObj) { - if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { - delete keyPairObj.value; - } -} - -function _getBidFromResponse(respItem) { - if (!respItem) { - utils.logError(LOG_ERROR_MESS.emptySeatbid); - } else if (!respItem.bid) { - utils.logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); - } else if (!respItem.bid[0]) { - utils.logError(LOG_ERROR_MESS.noBid); - } - return respItem && respItem.bid && respItem.bid[0]; -} - -function _addBidResponse(serverBid, bidsMap, priceType, bidResponses, RendererConst) { - if (!serverBid) return; - let errorMessage; - if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); - if (!serverBid.adm) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); - else { - const awaitingBids = bidsMap[serverBid.auid]; - if (awaitingBids) { - const sizeId = `${serverBid.w}x${serverBid.h}`; - if (awaitingBids[sizeId]) { - const slot = awaitingBids[sizeId][0]; - - const bid = slot.bids.shift(); - const bidResponse = { - requestId: bid.bidId, // bid.bidderRequestId, - bidderCode: spec.code, - cpm: serverBid.price, - width: serverBid.w, - height: serverBid.h, - creativeId: serverBid.auid, // bid.bidId, - currency: 'EUR', - netRevenue: priceType !== 'gross', - ttl: TIME_TO_LIVE, - dealId: serverBid.dealid - }; - if (serverBid.content_type === 'video' || (!serverBid.content_type && bid.mediaTypes && bid.mediaTypes.video)) { - bidResponse.vastXml = serverBid.adm; - bidResponse.mediaType = VIDEO; - bidResponse.adResponse = { - content: bidResponse.vastXml - }; - if (!bid.renderer && (!bid.mediaTypes || !bid.mediaTypes.video || bid.mediaTypes.video.context === 'outstream')) { - bidResponse.renderer = createRenderer(bidResponse, { - id: bid.bidId, - url: RENDERER_URL - }, RendererConst); - } - } else { - bidResponse.ad = serverBid.adm; - bidResponse.mediaType = BANNER; - } - - bidResponses.push(bidResponse); - - if (!slot.bids.length) { - slot.parents.forEach(({parent, key, uid}) => { - const index = parent[key].indexOf(slot); - if (index > -1) { - parent[key].splice(index, 1); - } - if (!parent[key].length) { - delete parent[key]; - if (!utils.getKeys(parent).length) { - delete bidsMap[uid]; - } - } - }); - } - } - } else { - errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; - } - } - if (errorMessage) { - utils.logError(errorMessage); - } -} - -function outstreamRender (bid) { - bid.renderer.push(() => { - window.ANOutstreamVideo.renderAd({ - targetId: bid.adUnitCode, - adResponse: bid.adResponse - }); - }); -} - -function createRenderer (bid, rendererParams, RendererConst) { - const rendererInst = RendererConst.install({ - id: rendererParams.id, - url: rendererParams.url, - loaded: false - }); - - try { - rendererInst.setRender(outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - - return rendererInst; -} - -export function resetUserSync() { - hasSynced = false; -} - -export function getSyncUrl() { - return SYNC_URL; -} - -registerBidder(spec); diff --git a/modules/cpmstarBidAdapter.js b/modules/cpmstarBidAdapter.js deleted file mode 100644 index 61ccc0e786b..00000000000 --- a/modules/cpmstarBidAdapter.js +++ /dev/null @@ -1,180 +0,0 @@ - -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; - -const BIDDER_CODE = 'cpmstar'; - -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'; - -function fixedEncodeURIComponent(str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { - return '%' + c.charCodeAt(0).toString(16); - }); -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - pageID: Math.floor(Math.random() * 10e6), - - getMediaType: function (bidRequest) { - if (bidRequest == null) return BANNER; - return !utils.deepAccess(bidRequest, 'mediaTypes.video') ? BANNER : VIDEO; - }, - - getPlayerSize: function (bidRequest) { - var playerSize = utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize'); - if (playerSize == null) return [640, 440]; - if (playerSize[0] != null) playerSize = playerSize[0]; - if (playerSize == null || playerSize[0] == null || playerSize[1] == null) return [640, 440]; - return playerSize; - }, - - isBidRequestValid: function (bid) { - return ((typeof bid.params.placementId === 'string') && !!bid.params.placementId.length) || (typeof bid.params.placementId === 'number'); - }, - - buildRequests: function (validBidRequests, bidderRequest) { - var requests = []; - // This reference to window.top can cause issues when loaded in an iframe if not protected with a try/catch. - - for (var i = 0; i < validBidRequests.length; i++) { - var bidRequest = validBidRequests[i]; - var referer = encodeURIComponent(bidderRequest.refererInfo.referer); - var e = utils.getBidIdParameter('endpoint', bidRequest.params); - var ENDPOINT = e == 'dev' ? ENDPOINT_DEV : e == 'staging' ? ENDPOINT_STAGING : ENDPOINT_PRODUCTION; - var mediaType = spec.getMediaType(bidRequest); - var playerSize = spec.getPlayerSize(bidRequest); - var videoArgs = '&fv=0' + (playerSize ? ('&w=' + playerSize[0] + '&h=' + playerSize[1]) : ''); - var url = ENDPOINT + '?media=' + mediaType + (mediaType == VIDEO ? videoArgs : '') + - '&json=c_b&mv=1&poolid=' + utils.getBidIdParameter('placementId', bidRequest.params) + - '&reachedTop=' + encodeURIComponent(bidderRequest.refererInfo.reachedTop) + - '&requestid=' + bidRequest.bidId + - '&referer=' + encodeURIComponent(referer); - - if (bidRequest.schain && bidRequest.schain.nodes) { - var schain = bidRequest.schain; - var schainString = ''; - schainString += schain.ver + ',' + schain.complete; - for (var i2 = 0; i2 < schain.nodes.length; i2++) { - var node = schain.nodes[i2]; - schainString += '!' + - fixedEncodeURIComponent(node.asi || '') + ',' + - fixedEncodeURIComponent(node.sid || '') + ',' + - fixedEncodeURIComponent(node.hp || '') + ',' + - fixedEncodeURIComponent(node.rid || '') + ',' + - fixedEncodeURIComponent(node.name || '') + ',' + - fixedEncodeURIComponent(node.domain || ''); - } - url += '&schain=' + schainString - } - - if (bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.consentString != null) { - url += '&gdpr_consent=' + bidderRequest.gdprConsent.consentString; - } - if (bidderRequest.gdprConsent.gdprApplies != null) { - url += '&gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? 1 : 0); - } - } - - if (bidderRequest.uspConsent != null) { - url += '&us_privacy=' + bidderRequest.uspConsent; - } - - if (config.getConfig('coppa')) { - url += '&tfcd=' + (config.getConfig('coppa') ? 1 : 0); - } - - requests.push({ - method: 'GET', - url: url, - bidRequest: bidRequest, - }); - } - - return requests; - }, - - interpretResponse: function (serverResponse, request) { - var bidRequest = request.bidRequest; - var mediaType = spec.getMediaType(bidRequest); - - var bidResponses = []; - - if (!Array.isArray(serverResponse.body)) { - serverResponse.body = [serverResponse.body]; - } - - for (var i = 0; i < serverResponse.body.length; i++) { - var raw = serverResponse.body[i]; - var rawBid = raw.creatives[0]; - if (!rawBid) { - utils.logWarn('cpmstarBidAdapter: server response failed check'); - return; - } - var cpm = (parseFloat(rawBid.cpm) || 0); - - if (!cpm) { - utils.logWarn('cpmstarBidAdapter: server response failed check. Missing cpm') - return; - } - - var bidResponse = { - requestId: rawBid.requestid, - cpm: cpm, - width: rawBid.width || 0, - height: rawBid.height || 0, - currency: rawBid.currency ? rawBid.currency : DEFAULT_CURRENCY, - netRevenue: rawBid.netRevenue ? rawBid.netRevenue : true, - ttl: rawBid.ttl ? rawBid.ttl : DEFAULT_TTL, - creativeId: rawBid.creativeid || 0, - }; - - if (rawBid.hasOwnProperty('dealId')) { - bidResponse.dealId = rawBid.dealId - } - - if (mediaType == BANNER && rawBid.code) { - bidResponse.ad = rawBid.code + (rawBid.px_cr ? "\n" : ''); - } else if (mediaType == VIDEO && rawBid.creativemacros && rawBid.creativemacros.HTML5VID_VASTSTRING) { - var playerSize = spec.getPlayerSize(bidRequest); - if (playerSize != null) { - bidResponse.width = playerSize[0]; - bidResponse.height = playerSize[1]; - } - bidResponse.mediaType = VIDEO; - bidResponse.vastXml = rawBid.creativemacros.HTML5VID_VASTSTRING; - } else { - return utils.logError('bad response', rawBid); - } - - bidResponses.push(bidResponse); - } - - return bidResponses; - }, - - getUserSyncs: function (syncOptions, serverResponses) { - const syncs = []; - if (serverResponses.length == 0 || !serverResponses[0].body) return syncs; - var usersyncs = serverResponses[0].body[0].syncs; - if (!usersyncs || usersyncs.length < 0) return syncs; - for (var i = 0; i < usersyncs.length; i++) { - var us = usersyncs[i]; - if ((us.type === 'image' && syncOptions.pixelEnabled) || (us.type == 'iframe' && syncOptions.iframeEnabled)) { - syncs.push(us); - } - } - return syncs; - } - -}; -registerBidder(spec); diff --git a/modules/decenteradsBidAdapter.js b/modules/decenteradsBidAdapter.js deleted file mode 100644 index 823a59a3768..00000000000 --- a/modules/decenteradsBidAdapter.js +++ /dev/null @@ -1,90 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js' -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js' -import * as utils from '../src/utils.js' - -const BIDDER_CODE = 'decenterads' -const URL = 'https://supply.decenterads.com/?c=o&m=multi' -const URL_SYNC = 'https://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.getWindowLocation() - 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.hostname, - 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/djaxBidAdapter.js b/modules/djaxBidAdapter.js deleted file mode 100644 index ffaf61a3f15..00000000000 --- a/modules/djaxBidAdapter.js +++ /dev/null @@ -1,129 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import * as utils from '../src/utils.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import { ajax } from '../src/ajax.js'; -import {Renderer} from '../src/Renderer.js'; - -const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; -const BIDDER_CODE = 'djax'; -const DOMAIN = 'https://demo.reviveadservermod.com/headerbidding_adminshare/'; -const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; - -function isBidRequestValid(bid) { - return (typeof bid.params !== 'undefined' && parseInt(utils.getValue(bid.params, 'publisherId')) > 0); -} - -function buildRequests(validBidRequests) { - return { - method: 'POST', - url: DOMAIN + 'www/admin/plugins/Prebid/getAd.php', - options: { - withCredentials: false, - crossOrigin: true - }, - data: validBidRequests, - }; -} - -function interpretResponse(serverResponse, request) { - const response = serverResponse.body; - const bidResponses = []; - var bidRequestResponses = []; - - utils._each(response, function(bidAd) { - bidAd.adResponse = { - content: bidAd.vastXml, - height: bidAd.height, - width: bidAd.width - }; - bidAd.ttl = config.getConfig('_bidderTimeout') - bidAd.renderer = bidAd.context === 'outstream' ? createRenderer(bidAd, { - id: bidAd.adUnitCode, - url: RENDERER_URL - }, bidAd.adUnitCode) : undefined; - bidResponses.push(bidAd); - }); - - bidRequestResponses.push({ - function: 'saveResponses', - request: request, - response: bidResponses - }); - sendResponseToServer(bidRequestResponses); - return bidResponses; -} - -function outstreamRender(bidAd) { - bidAd.renderer.push(() => { - window.ANOutstreamVideo.renderAd({ - sizes: [bidAd.width, bidAd.height], - width: bidAd.width, - height: bidAd.height, - targetId: bidAd.adUnitCode, - adResponse: bidAd.adResponse, - rendererOptions: { - showVolume: false, - allowFullscreen: false - } - }); - }); -} - -function createRenderer(bidAd, rendererParams, adUnitCode) { - const renderer = Renderer.install({ - id: rendererParams.id, - url: rendererParams.url, - loaded: false, - config: {'player_height': bidAd.height, 'player_width': bidAd.width}, - adUnitCode - }); - try { - renderer.setRender(outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - return renderer; -} - -function onBidWon(bid) { - let wonBids = []; - wonBids.push(bid); - wonBids[0].function = 'onBidWon'; - sendResponseToServer(wonBids); -} - -function onTimeout(details) { - details.unshift({ 'function': 'onTimeout' }); - sendResponseToServer(details); -} - -function sendResponseToServer(data) { - ajax(DOMAIN + 'www/admin/plugins/Prebid/tracking/track.php', null, JSON.stringify(data), { - withCredentials: false, - method: 'POST', - crossOrigin: true - }); -} - -function getUserSyncs(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: DOMAIN + 'www/admin/plugins/Prebid/userSync.php' - }]; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: SUPPORTED_AD_TYPES, - isBidRequestValid, - buildRequests, - interpretResponse, - getUserSyncs, - onBidWon, - onTimeout -}; - -registerBidder(spec); diff --git a/modules/e_volutionBidAdapter.js b/modules/e_volutionBidAdapter.js deleted file mode 100644 index 9fc7035db32..00000000000 --- a/modules/e_volutionBidAdapter.js +++ /dev/null @@ -1,111 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'e_volution'; -const AD_URL = 'https://service.e-volution.ai/?c=o&m=multi'; -const URL_SYNC = 'https://service.e-volution.ai/?c=o&m=sync'; -const NO_SYNC = true; - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native && bid.native.title && bid.native.image && bid.native.impressionTrackers); - default: - return false; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - noSync: NO_SYNC, - - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - let placements = []; - let request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - const len = validBidRequests.length; - - for (let i = 0; i < len; i++) { - let bid = validBidRequests[i]; - let traff = bid.params.traffic || BANNER - - placements.push({ - placementId: bid.params.placementId, - bidId: bid.bidId, - sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], - traffic: traff - }); - if (bid.schain) { - placements.schain = bid.schain; - } - } - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - for (let i = 0; i < serverResponse.body.length; i++) { - let resItem = serverResponse.body[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, - - getUserSyncs: (syncOptions, serverResponses) => { - if (NO_SYNC) { - return false - } else { - return [{ - type: 'image', - url: URL_SYNC - }]; - } - } - -}; - -registerBidder(spec); diff --git a/modules/edgequeryxBidAdapter.js b/modules/edgequeryxBidAdapter.js deleted file mode 100644 index ee50946ee18..00000000000 --- a/modules/edgequeryxBidAdapter.js +++ /dev/null @@ -1,98 +0,0 @@ -import * as utils from '../src/utils.js'; -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'edgequeryx'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['eqx'], // short code - supportedMediaTypes: [BANNER, VIDEO], - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function (bid) { - return !!(bid.params && bid.params.accountId && bid.params.widgetId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests an array of bids - * @param {BidderRequest} bidderRequest bidder request object - * @return {ServerRequest[]} Info describing the request to the server. - */ - buildRequests: function (validBidRequests, bidderRequest) { - // use bidderRequest.bids[] to get bidder-dependent request info - // if your bidder supports multiple currencies, use config.getConfig(currency) - // to find which one the ad server needs - - // pull requested transaction ID from bidderRequest.bids[].transactionId - return validBidRequests.map(bid => { - // Common bid request attributes for banner, outstream and instream. - let payload = { - accountId: bid.params.accountId, - widgetId: bid.params.widgetId, - currencyCode: 'EUR', - tagId: bid.adUnitCode, - transactionId: bid.transactionId, - timeout: config.getConfig('bidderTimeout'), - bidId: bid.bidId, - prebidVersion: '$prebid.version$' - }; - - const bannerMediaType = utils.deepAccess(bid, 'mediaTypes.banner'); - payload.sizes = bannerMediaType.sizes.map(size => ({ - w: size[0], - h: size[1] - })); - - var payloadString = JSON.stringify(payload); - - return { - method: 'POST', - url: (bid.params.domain !== undefined ? bid.params.domain : 'https://deep.edgequery.io') + '/prebid/x', - data: payloadString, - }; - }); - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @param {*} bidRequestString - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function (serverResponse, bidRequestString) { - const bidResponses = []; - let response = serverResponse.body; - try { - if (response) { - let bidResponse = { - requestId: response.requestId, - cpm: response.cpm, - currency: response.currency, - width: response.width, - height: response.height, - ad: response.ad, - ttl: response.ttl, - creativeId: response.creativeId, - netRevenue: response.netRevenue - }; - - bidResponses.push(bidResponse); - } - } catch (error) { - utils.logError('Error while parsing Edge Query X response', error); - } - return bidResponses; - } - -}; - -registerBidder(spec); diff --git a/modules/emoteevBidAdapter.js b/modules/emoteevBidAdapter.js deleted file mode 100644 index e0f88725d8a..00000000000 --- a/modules/emoteevBidAdapter.js +++ /dev/null @@ -1,525 +0,0 @@ -/** - * This file contains Emoteev bid adpater. - * - * It is organised as follows: - * - Constants values; - * - Spec API functions, which should be pristine pure; - * - Ancillary functions, which should be as pure as possible; - * - Adapter API, where unpure side-effects happen. - * - * The code style is « functional core, imperative shell ». - * - * @link https://www.emoteev.io - * @file This files defines the spec of EmoteevBidAdapter. - * @author Emoteev Engineering . - */ - -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER} from '../src/mediaTypes.js'; -import { - triggerPixel, - getUniqueIdentifierStr, - contains, - deepAccess, - isArray, - isInteger, - getParameterByName, - buildUrl -} from '../src/utils.js'; -import {config} from '../src/config.js'; -import { getStorageManager } from '../src/storageManager.js'; - -export const storage = getStorageManager(); - -export const BIDDER_CODE = 'emoteev'; - -/** - * Version number of the adapter API. - */ -export const ADAPTER_VERSION = '1.35.0'; - -export const DOMAIN = 'prebid.emoteev.xyz'; -export const DOMAIN_STAGING = 'prebid-staging.emoteev.xyz'; -export const DOMAIN_DEVELOPMENT = 'localhost:3000'; - -/** - * Path of Emoteev endpoint for events. - */ -export const EVENTS_PATH = '/api/ad_event.json'; - -/** - * Path of Emoteev bidder. - */ -export const BIDDER_PATH = '/api/prebid/bid'; -export const USER_SYNC_IFRAME_PATH = '/api/prebid/sync-iframe'; -export const USER_SYNC_IMAGE_PATH = '/api/prebid/sync-image'; - -export const PRODUCTION = 'production'; -export const STAGING = 'staging'; -export const DEVELOPMENT = 'development'; -export const DEFAULT_ENV = PRODUCTION; - -export const ON_ADAPTER_CALLED = 'on_adapter_called'; -export const ON_BID_WON = 'on_bid_won'; -export const ON_BIDDER_TIMEOUT = 'on_bidder_timeout'; - -export const IN_CONTENT = 'content'; -export const FOOTER = 'footer'; -export const OVERLAY = 'overlay'; -export const WALLPAPER = 'wallpaper'; - -/** - * Vendor ID assigned to Emoteev from the Global Vendor & CMP List. - * - * See https://vendorlist.consensu.org/vendorinfo.json for more information. - * @type {number} - */ -export const VENDOR_ID = 15; - -/** - * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#valid-build-requests-array for detailed semantic. - * - * @param {AdUnit.bidRequest} bidRequest - * @returns {boolean} Is this bidRequest valid? - */ -export const isBidRequestValid = (bidRequest) => { - return !!( - bidRequest && - bidRequest.params && - deepAccess(bidRequest, 'params.adSpaceId') && - validateContext(deepAccess(bidRequest, 'params.context')) && - validateExternalId(deepAccess(bidRequest, 'params.externalId')) && - bidRequest.bidder === BIDDER_CODE && - validateSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes'))); -}; - -/** - * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#serverrequest-objects for detailed semantic. - * - * @param {string} env Emoteev environment parameter - * @param {boolean} debug Pbjs debug parameter. - * @param {string} currency See http://prebid.org/dev-docs/modules/currency.html for detailed semantic. - * @param {Array} validBidRequests Takes an array of bid requests, which are guaranteed to have passed the isBidRequestValid() test. - * @param bidderRequest General context for a bidder request being constructed - * @returns {ServerRequest} - */ -export const buildRequests = (env, debug, currency, validBidRequests, bidderRequest) => { - return { - method: 'POST', - url: bidderUrl(env), - data: JSON.stringify(requestsPayload(debug, currency, validBidRequests, bidderRequest)) // Keys with undefined values will be filtered out. - }; -}; - -/** - * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#interpreting-the-response for detailed semantic. - * - * @param {Array} serverResponse.body The body of the server response is an array of bid objects. - * @returns {Array} - */ -export const interpretResponse = (serverResponse) => serverResponse.body; - -/** - * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#registering-on-set-targeting for detailed semantic. - * - * @param {string} env Emoteev environment parameter. - * @param {BidRequest} bidRequest - * @returns {UrlObject} - */ -export function onAdapterCalled(env, bidRequest) { - return { - protocol: 'https', - hostname: domain(env), - pathname: EVENTS_PATH, - search: { - eventName: ON_ADAPTER_CALLED, - pubcId: deepAccess(bidRequest, 'crumbs.pubcid'), - bidId: bidRequest.bidId, - adSpaceId: deepAccess(bidRequest, 'params.adSpaceId'), - cache_buster: getUniqueIdentifierStr() - } - }; -} - -/** - * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#registering-on-bid-won for detailed semantic. - * - * @param {string} env Emoteev environment parameter. - * @param {string} pubcId Publisher common id. See http://prebid.org/dev-docs/modules/pubCommonId.html for detailed semantic. - * @param bidObject - * @returns {UrlObject} - */ -export const onBidWon = (env, pubcId, bidObject) => { - const bidId = bidObject.requestId; - return { - protocol: 'https', - hostname: domain(env), - pathname: EVENTS_PATH, - search: { - eventName: ON_BID_WON, - pubcId, - bidId, - cache_buster: getUniqueIdentifierStr() - } - }; -}; - -/** - * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#registering-on-timeout for detailed semantic. - * - * @param {string} env Emoteev environment parameter. - * @param {BidRequest} bidRequest - * @returns {UrlObject} - */ -export const onTimeout = (env, bidRequest) => { - return { - protocol: 'https', - hostname: domain(env), - pathname: EVENTS_PATH, - search: { - eventName: ON_BIDDER_TIMEOUT, - pubcId: deepAccess(bidRequest, 'crumbs.pubcid'), - bidId: bidRequest.bidId, - adSpaceId: deepAccess(bidRequest, 'params.adSpaceId'), - timeout: bidRequest.timeout, - cache_buster: getUniqueIdentifierStr() - } - } -}; - -/** - * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#registering-user-syncs for detailed semantic. - * - * @param {string} env Emoteev environment parameter - * @param {SyncOptions} syncOptions - * @returns userSyncs - */ -export const getUserSyncs = (env, syncOptions) => { - let syncs = []; - if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: userSyncImageUrl(env), - }); - } - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: userSyncIframeUrl(env), - }); - } - return syncs; -}; - -/** - * Pure function. - * - * @param {string} env Emoteev environment parameter - * @returns {string} The domain for network calls to Emoteev. - */ -export const domain = (env) => { - switch (env) { - case DEVELOPMENT: - return DOMAIN_DEVELOPMENT; - case STAGING: - return DOMAIN_STAGING; - default: - return DOMAIN; - } -}; - -/** - * Pure function. - * - * @param {string} env Emoteev environment parameter - * @returns {string} The full URL which events is sent to. - */ -export const eventsUrl = env => buildUrl({ - protocol: (env === DEVELOPMENT) ? 'http' : 'https', - hostname: domain(env), - pathname: EVENTS_PATH -}); - -/** - * Pure function. - * - * @param {string} env Emoteev environment parameter - * @returns {string} The full URL which bidderRequest is sent to. - */ -export const bidderUrl = env => buildUrl({ - protocol: (env === DEVELOPMENT) ? 'http' : 'https', - hostname: domain(env), - pathname: BIDDER_PATH -}); - -/** - * Pure function. - * - * @param {string} env Emoteev environment parameter - * @returns {string} The full URL called for iframe-based user sync - */ -export const userSyncIframeUrl = env => buildUrl({ - protocol: (env === DEVELOPMENT) ? 'http' : 'https', - hostname: domain(env), - pathname: USER_SYNC_IFRAME_PATH -}); - -/** - * Pure function. - * - * @param {string} env Emoteev environment parameter - * @returns {string} The full URL called for image-based user sync - */ -export const userSyncImageUrl = env => buildUrl({ - protocol: (env === DEVELOPMENT) ? 'http' : 'https', - hostname: domain(env), - pathname: USER_SYNC_IMAGE_PATH -}); - -/** - * Pure function. - * - * @param {Array>} sizes - * @returns {boolean} are sizes valid? - */ -export const validateSizes = sizes => isArray(sizes) && sizes.length > 0 && sizes.every(size => isArray(size) && size.length === 2); - -/** - * Pure function. - * - * @param {string} context - * @returns {boolean} is param `context` valid? - */ -export const validateContext = context => contains([IN_CONTENT, FOOTER, OVERLAY, WALLPAPER], context); - -/** - * Pure function. - * - * @param {(number|null|undefined)} externalId - * @returns {boolean} is param `externalId` valid? - */ -export const validateExternalId = externalId => externalId === undefined || externalId === null || (isInteger(externalId) && externalId > 0); - -/** - * Pure function. - * - * @param {BidRequest} bidRequest - * @returns {object} An object which represents a BidRequest for Emoteev server side. - */ -export const conformBidRequest = bidRequest => { - return { - params: bidRequest.params, - crumbs: bidRequest.crumbs, - sizes: bidRequest.sizes, - bidId: bidRequest.bidId, - bidderRequestId: bidRequest.bidderRequestId, - }; -}; - -/** - * Pure function. - * - * @param {object} bidderRequest - * @returns {(boolean|undefined)} raw consent data. - */ -export const gdprConsent = (bidderRequest) => (deepAccess(bidderRequest, 'gdprConsent.vendorData.vendorConsents') || {})[VENDOR_ID]; - -/** - * Pure function. - * - * @param {boolean} debug Pbjs debug parameter - * @param {string} currency See http://prebid.org/dev-docs/modules/currency.html for detailed information - * @param {BidRequest} validBidRequests - * @param {object} bidderRequest - * @returns - */ -export const requestsPayload = (debug, currency, validBidRequests, bidderRequest) => { - return { - akPbjsVersion: ADAPTER_VERSION, - bidRequests: validBidRequests.map(conformBidRequest), - currency: currency, - debug: debug, - language: navigator.language, - refererInfo: bidderRequest.refererInfo, - deviceInfo: getDeviceInfo( - getDeviceDimensions(window), - getViewDimensions(window, document), - getDocumentDimensions(document), - isWebGLEnabled(document)), - userAgent: navigator.userAgent, - gdprApplies: deepAccess(bidderRequest, 'gdprConsent.gdprApplies'), - gdprConsent: gdprConsent(bidderRequest), - }; -}; - -/** - * Pure function - * @param {Window} window - * @param {Document} document - * @returns {{width: number, height: number}} View dimensions - */ -export const getViewDimensions = (window, document) => { - let w = window; - let prefix = 'inner'; - - if (window.innerWidth === undefined || window.innerWidth === null) { - w = document.documentElement || document.body; - prefix = 'client'; - } - - return { - width: w[`${prefix}Width`], - height: w[`${prefix}Height`], - }; -}; - -/** - * Pure function - * @param {Window} window - * @returns {{width: number, height: number}} Device dimensions - */ -export const getDeviceDimensions = (window) => { - return { - width: window.screen ? window.screen.width : '', - height: window.screen ? window.screen.height : '', - }; -}; - -/** - * Pure function - * @param {Document} document - * @returns {{width: number, height: number}} Document dimensions - */ -export const getDocumentDimensions = (document) => { - const de = document.documentElement; - const be = document.body; - - const bodyHeight = be ? Math.max(be.offsetHeight, be.scrollHeight) : 0; - - const w = Math.max(de.clientWidth, de.offsetWidth, de.scrollWidth); - const h = Math.max( - de.clientHeight, - de.offsetHeight, - de.scrollHeight, - bodyHeight - ); - - return { - width: isNaN(w) ? '' : w, - height: isNaN(h) ? '' : h, - }; -}; - -/** - * Unpure function - * @param {Document} document - * @returns {boolean} Is WebGL enabled? - */ -export const isWebGLEnabled = (document) => { - // Create test canvas - let canvas = document.createElement('canvas'); - - // The gl context - let gl = null; - - // Try to get the regular WebGL - try { - gl = canvas.getContext('webgl'); - } catch (ex) { - canvas = undefined; - return false; - } - - // No regular WebGL found - if (!gl) { - // Try experimental WebGL - try { - gl = canvas.getContext('experimental-webgl'); - } catch (ex) { - canvas = undefined; - return false; - } - } - - return !!gl; -}; - -/** - * Pure function - * @param {{width: number, height: number}} deviceDimensions - * @param {{width: number, height: number}} viewDimensions - * @param {{width: number, height: number}} documentDimensions - * @param {boolean} webGL - * @returns {object} Device information - */ -export const getDeviceInfo = (deviceDimensions, viewDimensions, documentDimensions, webGL) => { - return { - browserWidth: viewDimensions.width, - browserHeight: viewDimensions.height, - deviceWidth: deviceDimensions.width, - deviceHeight: deviceDimensions.height, - documentWidth: documentDimensions.width, - documentHeight: documentDimensions.height, - webGL: webGL, - }; -}; - -/** - * Pure function - * @param {object} config pbjs config value - * @param {string} parameter Environment override from URL query param. - * @returns {string} One of [PRODUCTION, STAGING, DEVELOPMENT]. - */ -export const resolveEnv = (config, parameter) => { - const configEnv = deepAccess(config, 'emoteev.env'); - - if (contains([PRODUCTION, STAGING, DEVELOPMENT], parameter)) return parameter; - else if (contains([PRODUCTION, STAGING, DEVELOPMENT], configEnv)) return configEnv; - else return DEFAULT_ENV; -}; - -/** - * Pure function - * @param {object} config pbjs config value - * @param {string} parameter Debug override from URL query param. - * @returns {boolean} - */ -export const resolveDebug = (config, parameter) => { - if (parameter && parameter.length && parameter.length > 0) return JSON.parse(parameter); - else if (config.debug) return config.debug; - else return false; -}; - -/** - * EmoteevBidAdapter spec - * @access public - * @type {BidderSpec} - */ -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - isBidRequestValid: isBidRequestValid, - buildRequests: (validBidRequests, bidderRequest) => - buildRequests( - resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), - resolveDebug(config.getConfig(), getParameterByName('debug')), - config.getConfig('currency'), - validBidRequests, - bidderRequest), - interpretResponse: interpretResponse, - onBidWon: (bidObject) => - triggerPixel(buildUrl(onBidWon( - resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), - storage.getCookie('_pubcid'), - bidObject))), - onTimeout: (bidRequest) => - triggerPixel(buildUrl(onTimeout( - resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), - bidRequest))), - getUserSyncs: (syncOptions) => - getUserSyncs( - resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), - syncOptions), -}; - -registerBidder(spec); diff --git a/modules/engageyaBidAdapter.js b/modules/engageyaBidAdapter.js deleted file mode 100644 index 321b3287c2b..00000000000 --- a/modules/engageyaBidAdapter.js +++ /dev/null @@ -1,133 +0,0 @@ -import { - BANNER, - NATIVE -} from '../src/mediaTypes.js'; - -const { - registerBidder -} = require('../src/adapters/bidderFactory.js'); -const BIDDER_CODE = 'engageya'; -const ENDPOINT_URL = 'https://recs.engageya.com/rec-api/getrecs.json'; -const ENDPOINT_METHOD = 'GET'; - -function getPageUrl() { - var pUrl = window.location.href; - if (isInIframe()) { - pUrl = document.referrer ? document.referrer : pUrl; - } - pUrl = encodeURIComponent(pUrl); - return pUrl; -} - -function isInIframe() { - try { - var isInIframe = (window.self !== window.top); - } catch (e) { - isInIframe = true; - } - return isInIframe; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, NATIVE], - isBidRequestValid: function(bid) { - return bid && bid.params && bid.params.hasOwnProperty('widgetId') && bid.params.hasOwnProperty('websiteId') && !isNaN(bid.params.widgetId) && !isNaN(bid.params.websiteId); - }, - - buildRequests: function(validBidRequests, bidderRequest) { - var bidRequests = []; - if (validBidRequests && validBidRequests.length > 0) { - validBidRequests.forEach(function(bidRequest) { - if (bidRequest.params) { - var mediaType = bidRequest.hasOwnProperty('nativeParams') ? 1 : 2; - var imageWidth = -1; - var imageHeight = -1; - if (bidRequest.sizes && bidRequest.sizes.length > 0) { - imageWidth = bidRequest.sizes[0][0]; - imageHeight = bidRequest.sizes[0][1]; - } else if (bidRequest.nativeParams && bidRequest.nativeParams.image && bidRequest.nativeParams.image.sizes) { - imageWidth = bidRequest.nativeParams.image.sizes[0]; - imageHeight = bidRequest.nativeParams.image.sizes[1]; - } - - var widgetId = bidRequest.params.widgetId; - var websiteId = bidRequest.params.websiteId; - var pageUrl = (bidRequest.params.pageUrl && bidRequest.params.pageUrl != '[PAGE_URL]') ? bidRequest.params.pageUrl : ''; - if (!pageUrl) { - pageUrl = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : getPageUrl(); - } - var bidId = bidRequest.bidId; - var finalUrl = ENDPOINT_URL + '?pubid=0&webid=' + websiteId + '&wid=' + widgetId + '&url=' + pageUrl + '&ireqid=' + bidId + '&pbtpid=' + mediaType + '&imw=' + imageWidth + '&imh=' + imageHeight; - if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprApplies && bidderRequest.consentString) { - finalUrl += '&is_gdpr=1&gdpr_consent=' + bidderRequest.consentString; - } - bidRequests.push({ - url: finalUrl, - method: ENDPOINT_METHOD, - data: '' - }); - } - }); - } - - return bidRequests; - }, - - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - if (serverResponse.body && serverResponse.body.recs && serverResponse.body.recs.length > 0) { - var response = serverResponse.body; - var isNative = response.pbtypeId == 1; - response.recs.forEach(function(rec) { - var imageSrc = rec.thumbnail_path.indexOf('http') == -1 ? 'https:' + rec.thumbnail_path : rec.thumbnail_path; - if (isNative) { - bidResponses.push({ - requestId: response.ireqId, - cpm: rec.ecpm, - width: response.imageWidth, - height: response.imageHeight, - creativeId: rec.postId, - currency: 'USD', - netRevenue: false, - ttl: 360, - native: { - title: rec.title, - body: '', - image: { - url: imageSrc, - width: response.imageWidth, - height: response.imageHeight - }, - privacyLink: '', - clickUrl: rec.clickUrl, - displayUrl: rec.url, - cta: '', - sponsoredBy: rec.displayName, - impressionTrackers: [], - }, - }); - } else { - // var htmlTag = ""; - var htmlTag = '
'; - var tag = rec.tag ? rec.tag : htmlTag; - bidResponses.push({ - requestId: response.ireqId, - cpm: rec.ecpm, - width: response.imageWidth, - height: response.imageHeight, - creativeId: rec.postId, - currency: 'USD', - netRevenue: false, - ttl: 360, - ad: tag, - }); - } - }); - } - - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/envivoBidAdapter.js b/modules/envivoBidAdapter.js deleted file mode 100644 index b9c80ffd468..00000000000 --- a/modules/envivoBidAdapter.js +++ /dev/null @@ -1,129 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import * as utils from '../src/utils.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import { ajax } from '../src/ajax.js'; -import {Renderer} from '../src/Renderer.js'; - -const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; -const BIDDER_CODE = 'envivo'; -const DOMAIN = 'https://ad.nvivo.tv/'; -const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; - -function isBidRequestValid(bid) { - return (typeof bid.params !== 'undefined' && parseInt(utils.getValue(bid.params, 'publisherId')) > 0); -} - -function buildRequests(validBidRequests) { - return { - method: 'POST', - url: DOMAIN + 'ads/www/admin/plugins/Prebid/getAd.php', - options: { - withCredentials: false, - crossOrigin: true - }, - data: validBidRequests, - }; -} - -function interpretResponse(serverResponse, request) { - const response = serverResponse.body; - const bidResponses = []; - var bidRequestResponses = []; - - utils._each(response, function(bidAd) { - bidAd.adResponse = { - content: bidAd.vastXml, - height: bidAd.height, - width: bidAd.width - }; - bidAd.ttl = config.getConfig('_bidderTimeout') - bidAd.renderer = bidAd.context === 'outstream' ? createRenderer(bidAd, { - id: bidAd.adUnitCode, - url: RENDERER_URL - }, bidAd.adUnitCode) : undefined; - bidResponses.push(bidAd); - }); - - bidRequestResponses.push({ - function: 'saveResponses', - request: request, - response: bidResponses - }); - sendResponseToServer(bidRequestResponses); - return bidResponses; -} - -function outstreamRender(bidAd) { - bidAd.renderer.push(() => { - window.ANOutstreamVideo.renderAd({ - sizes: [bidAd.width, bidAd.height], - width: bidAd.width, - height: bidAd.height, - targetId: bidAd.adUnitCode, - adResponse: bidAd.adResponse, - rendererOptions: { - showVolume: false, - allowFullscreen: false - } - }); - }); -} - -function createRenderer(bidAd, rendererParams, adUnitCode) { - const renderer = Renderer.install({ - id: rendererParams.id, - url: rendererParams.url, - loaded: false, - config: {'player_height': bidAd.height, 'player_width': bidAd.width}, - adUnitCode - }); - try { - renderer.setRender(outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - return renderer; -} - -function onBidWon(bid) { - let wonBids = []; - wonBids.push(bid); - wonBids[0].function = 'onBidWon'; - sendResponseToServer(wonBids); -} - -function onTimeout(details) { - details.unshift({ 'function': 'onTimeout' }); - sendResponseToServer(details); -} - -function sendResponseToServer(data) { - ajax(DOMAIN + 'ads/www/admin/plugins/Prebid/tracking/track.php', null, JSON.stringify(data), { - withCredentials: false, - method: 'POST', - crossOrigin: true - }); -} - -function getUserSyncs(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: DOMAIN + 'ads/www/admin/plugins/Prebid/userSync.php' - }]; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: SUPPORTED_AD_TYPES, - isBidRequestValid, - buildRequests, - interpretResponse, - getUserSyncs, - onBidWon, - onTimeout -}; - -registerBidder(spec); diff --git a/modules/fidelityBidAdapter.js b/modules/fidelityBidAdapter.js deleted file mode 100644 index 54483204bd1..00000000000 --- a/modules/fidelityBidAdapter.js +++ /dev/null @@ -1,146 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'fidelity'; -const BIDDER_SERVER = 'x.fidelity-media.com'; -const FIDELITY_VENDOR_ID = 408; -export const spec = { - code: BIDDER_CODE, - gvlid: 408, - isBidRequestValid: function isBidRequestValid(bid) { - return !!(bid && bid.params && bid.params.zoneid); - }, - buildRequests: function buildRequests(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: 0, - charset: document.charSet || document.characterSet, - subid: 'hb', - flashver: getFlashVersion(), - tmax: bidderRequest.timeout, - defloc: bidderRequest.refererInfo.referer, - referrer: getTopWindowReferrer(), - schain: getSupplyChain(bidRequest.schain), - }; - setConsentParams(bidderRequest.gdprConsent, bidderRequest.uspConsent, payload); - - return { - method: 'GET', - url: 'https://' + server + '/delivery/hb.php', - data: payload - }; - }); - }, - interpretResponse: function interpretResponse(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, uspConsent) { - if (syncOptions.iframeEnabled) { - var url = 'https://' + BIDDER_SERVER + '/delivery/matches.php'; - var payload = { - type: 'iframe' - }; - setConsentParams(gdprConsent, uspConsent, 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 getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } -} - -function setConsentParams(gdprConsent, uspConsent, 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.apiVersion === 1 && 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; - } - if (gdprConsent.apiVersion === 2 && gdprConsent.vendorData && gdprConsent.vendorData.vendor && gdprConsent.vendorData.vendor.consents && typeof gdprConsent.vendorData.vendor.consents[FIDELITY_VENDOR_ID.toString(10)] !== 'undefined') { - payload.consent_given = gdprConsent.vendorData.vendor.consents[FIDELITY_VENDOR_ID.toString(10)] ? 1 : 0; - } - } - if (typeof uspConsent !== 'undefined') { - payload.us_privacy = uspConsent; - } -} - -function getSupplyChain(schain) { - var supplyChain = ''; - if (schain != null && schain.nodes) { - supplyChain = schain.ver + ',' + schain.complete; - for (let i = 0; i < schain.nodes.length; i++) { - supplyChain += '!'; - supplyChain += (schain.nodes[i].asi) ? encodeURIComponent(schain.nodes[i].asi) : ''; - supplyChain += ','; - supplyChain += (schain.nodes[i].sid) ? encodeURIComponent(schain.nodes[i].sid) : ''; - supplyChain += ','; - supplyChain += (schain.nodes[i].hp) ? encodeURIComponent(schain.nodes[i].hp) : ''; - supplyChain += ','; - supplyChain += (schain.nodes[i].rid) ? encodeURIComponent(schain.nodes[i].rid) : ''; - supplyChain += ','; - supplyChain += (schain.nodes[i].name) ? encodeURIComponent(schain.nodes[i].name) : ''; - supplyChain += ','; - supplyChain += (schain.nodes[i].domain) ? encodeURIComponent(schain.nodes[i].domain) : ''; - } - } - return supplyChain; -} -registerBidder(spec); diff --git a/modules/fluctBidAdapter.js b/modules/fluctBidAdapter.js deleted file mode 100644 index 420fe04ddcb..00000000000 --- a/modules/fluctBidAdapter.js +++ /dev/null @@ -1,121 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'fluct'; -const END_POINT = 'https://hb.adingo.jp/prebid'; -const VERSION = '1.2'; -const NET_REVENUE = true; -const TTL = 300; - -export const spec = { - code: BIDDER_CODE, - aliases: ['adingo'], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: (bid) => { - return !!(bid.params.groupId && bid.params.tagId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: (validBidRequests, bidderRequest) => { - const serverRequests = []; - const referer = bidderRequest.refererInfo.referer; - - utils._each(validBidRequests, (request) => { - const data = Object(); - - data.referer = referer; - data.adUnitCode = request.adUnitCode; - data.bidId = request.bidId; - data.transactionId = request.transactionId; - - data.sizes = []; - utils._each(request.sizes, (size) => { - data.sizes.push({ - w: size[0], - h: size[1] - }); - }); - - data.params = request.params; - - serverRequests.push({ - method: 'POST', - url: END_POINT, - options: { - contentType: 'application/json', - withCredentials: true, - customHeaders: { - 'x-fluct-app': 'prebid/fluctBidAdapter', - 'x-fluct-version': VERSION, - 'x-openrtb-version': 2.5 - } - }, - data: data - }); - }); - - return serverRequests; - }, - - /* - * Unpack the respnse from the server into a list of bids. - * - * @param {serverResponse} serverResponse A successful response from the server. - * @return {bid[]} An array of bids which weer nested inside the server. - */ - interpretResponse: (serverResponse, serverRequest) => { - const bidResponses = []; - - const res = serverResponse.body; - if (!utils.isEmpty(res) && !utils.isEmpty(res.seatbid) && !utils.isEmpty(res.seatbid[0].bid)) { - const bid = res.seatbid[0].bid[0]; - const dealId = bid.dealid; - const beaconUrl = bid.burl; - const callImpBeacon = ``; - let data = { - bidderCode: BIDDER_CODE, - requestId: res.id, - currency: res.cur, - cpm: parseFloat(bid.price) || 0, - netRevenue: NET_REVENUE, - width: bid.w, - height: bid.h, - creativeId: bid.crid, - ttl: TTL, - ad: bid.adm + callImpBeacon, - }; - if (!utils.isEmpty(dealId)) { - data.dealId = dealId; - } - bidResponses.push(data); - } - return bidResponses; - }, - - /* - * Register the user sync pixels which should be dropped after the auction. - * - * @params {syncOptions} syncOptions which user syncs are allowed? - * @params {ServerResponse[]} serverResponses List of server's responses. - * @return {UserSync[]} The user syncs which should be dropped. - * - */ - getUserSyncs: (syncOptions, serverResponses) => { - return []; - }, -}; - -registerBidder(spec); diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js deleted file mode 100644 index 5fd3c56b2c6..00000000000 --- a/modules/gammaBidAdapter.js +++ /dev/null @@ -1,101 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const ENDPOINT = 'https://hb.gammaplatform.com'; -const ENDPOINT_USERSYNC = 'https://cm-supply-web.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, bidderRequest) { - const serverRequests = []; - const bidderRequestReferer = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || ''; - for (var i = 0, len = bidRequests.length; i < len; i++) { - const gaxObjParams = bidRequests[i]; - serverRequests.push({ - method: 'GET', - url: ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(bidderRequestReferer) - }); - } - 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_USERSYNC + '/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/gnetBidAdapter.js b/modules/gnetBidAdapter.js deleted file mode 100644 index 3469c897a6a..00000000000 --- a/modules/gnetBidAdapter.js +++ /dev/null @@ -1,101 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'gnet'; -const ENDPOINT = 'https://adserver.gnetproject.com/prebid.php'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function (bid) { - return !!(bid.params.websiteId && bid.params.externalId); - }, - - /** - * 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) { - const bidRequests = []; - const referer = bidderRequest.refererInfo.referer; - - utils._each(validBidRequests, (request) => { - const data = {}; - - data.referer = referer; - data.adUnitCode = request.adUnitCode; - data.bidId = request.bidId; - data.transactionId = request.transactionId; - - data.sizes = utils.parseSizesInput(request.sizes); - - data.params = request.params; - - const payloadString = JSON.stringify(data); - - bidRequests.push({ - method: 'POST', - url: ENDPOINT, - mode: 'no-cors', - options: { - withCredentials: false, - }, - data: payloadString - }); - }); - - return bidRequests; - }, - - /** - * 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, requests) { - if (typeof serverResponse !== 'object') { - return []; - } - - const res = serverResponse && serverResponse.body; - - if (utils.isEmpty(res)) { - return []; - } - - if (res.bids) { - const bids = []; - utils._each(res.bids, (bidData) => { - const bid = { - requestId: bidData.bidId, - cpm: bidData.cpm, - currency: bidData.currency, - width: bidData.width, - height: bidData.height, - ad: bidData.ad, - ttl: 300, - creativeId: bidData.creativeId, - netRevenue: true, - }; - bids.push(bid); - }); - - return bids; - } - - return []; - }, -}; - -registerBidder(spec); diff --git a/modules/haxmediaBidAdapter.js b/modules/haxmediaBidAdapter.js deleted file mode 100644 index c4ce2eb3663..00000000000 --- a/modules/haxmediaBidAdapter.js +++ /dev/null @@ -1,107 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'haxmedia'; -const AD_URL = 'https://balancer.haxmedia.io/?c=o&m=multi'; - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native && bid.native.impressionTrackers); - default: - return false; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - - const placements = []; - const request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - - const len = validBidRequests.length; - for (let i = 0; i < len; i++) { - const bid = validBidRequests[i]; - const placement = { - placementId: bid.params.placementId, - bidId: bid.bidId, - schain: bid.schain || {}, - }; - const mediaType = bid.mediaTypes - - if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) { - placement.sizes = mediaType[BANNER].sizes; - placement.traffic = BANNER; - } else if (mediaType && mediaType[VIDEO] && mediaType[VIDEO].playerSize) { - placement.wPlayer = mediaType[VIDEO].playerSize[0]; - placement.hPlayer = mediaType[VIDEO].playerSize[1]; - placement.traffic = VIDEO; - } else if (mediaType && mediaType[NATIVE]) { - placement.native = mediaType[NATIVE]; - placement.traffic = NATIVE; - } - placements.push(placement); - } - - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - for (let i = 0; i < serverResponse.body.length; i++) { - let resItem = serverResponse.body[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, -}; - -registerBidder(spec); diff --git a/modules/hpmdnetworkBidAdapter.js b/modules/hpmdnetworkBidAdapter.js deleted file mode 100644 index 5cc28ab6362..00000000000 --- a/modules/hpmdnetworkBidAdapter.js +++ /dev/null @@ -1,96 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'hpmdnetwork'; -const BIDDER_CODE_ALIAS = 'hpmd'; -const HPMDNETWORK_HOST = 'https://banner.hpmdnetwork.ru/bidder/request'; -const DEFAULT_TTL = 300; -const DEFAULT_CURRENCY = 'RUB'; - -export const spec = { - code: BIDDER_CODE, - aliases: [ BIDDER_CODE_ALIAS ], - supportedMediaTypes: [ BANNER ], - isBidRequestValid: isBidRequestValid, - buildRequests: buildRequests, - interpretResponse: interpretResponse, -}; - -function isBidRequestValid(bid) { - const { placementId } = bid.params; - return !!placementId; -} - -function buildRequests(validBidRequests, bidderRequest) { - const payload = {}; - payload.places = []; - - validBidRequests.forEach((bidRequest) => { - const place = { - id: bidRequest.bidId, - placementId: bidRequest.params.placementId + '', - }; - payload.places.push(place); - }); - - payload.url = bidderRequest.refererInfo.referer; - payload.settings = { currency: DEFAULT_CURRENCY }; - - return { - method: 'POST', - url: HPMDNETWORK_HOST, - data: payload, - }; -} - -function interpretResponse(serverResponse) { - const { body } = serverResponse; - const bidResponses = []; - - if (body.bids) { - body.bids.forEach((bid) => { - const size = getCreativeSize(bid); - const bidResponse = { - requestId: bid.id, - cpm: bid.cpm, - ad: wrapDisplayUrl(bid.displayUrl), - width: size.width, - height: size.height, - creativeId: bid.creativeId || generateRandomInt(), - currency: bid.currency || DEFAULT_CURRENCY, - netRevenue: true, - ttl: bid.ttl || DEFAULT_TTL, - }; - - bidResponses.push(bidResponse); - }); - } - - return bidResponses; -} - -function wrapDisplayUrl(displayUrl) { - return ``; -} - -function getCreativeSize(creativeSize) { - const size = { - width: 1, - height: 1, - }; - - if (!!creativeSize.width && creativeSize.width !== -1) { - size.width = creativeSize.width; - } - if (!!creativeSize.height && creativeSize.height !== -1) { - size.height = creativeSize.height; - } - - return size; -} - -function generateRandomInt() { - return Math.random().toString(16).substring(2); -} - -registerBidder(spec); diff --git a/modules/impactifyBidAdapter.js b/modules/impactifyBidAdapter.js deleted file mode 100644 index b649b5a8a73..00000000000 --- a/modules/impactifyBidAdapter.js +++ /dev/null @@ -1,260 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import { config } from '../src/config.js'; -import {ajax} from '../src/ajax.js'; - -const BIDDER_CODE = 'impactify'; -const BIDDER_ALIAS = ['imp']; -const DEFAULT_CURRENCY = 'USD'; -const DEFAULT_VIDEO_WIDTH = 640; -const DEFAULT_VIDEO_HEIGHT = 480; -const ORIGIN = 'https://sonic.impactify.media'; -const LOGGER_URI = 'https://logger.impactify.media'; -const AUCTIONURI = '/bidder'; -const COOKIESYNCURI = '/static/cookie_sync.html'; -const GVLID = 606; -const GETCONFIG = config.getConfig; - -const getDeviceType = () => { - // OpenRTB Device type - if ((/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()))) { - return 5; - } - if ((/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(navigator.userAgent.toLowerCase()))) { - return 4; - } - return 2; -} - -const createOpenRtbRequest = (validBidRequests, bidderRequest) => { - // Create request and set imp bids inside - let request = { - id: bidderRequest.auctionId, - validBidRequests, - cur: [DEFAULT_CURRENCY], - imp: [] - }; - - // Force impactify debugging parameter - if (window.localStorage.getItem('_im_db_bidder') == 3) { - request.test = 3; - } - - // Set device/user/site - if (!request.device) request.device = {}; - if (!request.site) request.site = {}; - request.device = { - w: window.innerWidth, - h: window.innerHeight, - devicetype: getDeviceType(), - ua: navigator.userAgent, - js: 1, - dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, - language: ((navigator.language || navigator.userLanguage || '').split('-'))[0] || 'en', - }; - request.site = {page: bidderRequest.refererInfo.referer}; - - // Handle privacy settings for GDPR/CCPA/COPPA - if (bidderRequest.gdprConsent) { - let gdprApplies = 0; - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') gdprApplies = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; - utils.deepSetValue(request, 'regs.ext.gdpr', gdprApplies); - utils.deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); - } - - if (bidderRequest.uspConsent) { - utils.deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); - this.syncStore.uspConsent = bidderRequest.uspConsent; - } - - if (GETCONFIG('coppa') == true) utils.deepSetValue(request, 'regs.coppa', 1); - - if (bidderRequest.uspConsent) { - utils.deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); - } - - // Set buyer uid - utils.deepSetValue(request, 'user.buyeruid', utils.generateUUID()); - - // Create imps with bids - validBidRequests.forEach((bid) => { - let imp = { - id: bid.bidId, - bidfloor: bid.params.bidfloor ? bid.params.bidfloor : 0, - ext: { - impactify: { - appId: bid.params.appId, - format: bid.params.format, - style: bid.params.style - }, - }, - video: { - playerSize: [DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT], - context: 'outstream', - mimes: ['video/mp4'], - }, - }; - if (bid.params.container) { - imp.ext.impactify.container = bid.params.container; - } - request.imp.push(imp); - }); - - return request; -}; - -export const spec = { - code: BIDDER_CODE, - gvlid: GVLID, - supportedMediaTypes: ['video'], - aliases: BIDDER_ALIAS, - /** - * 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) { - if (!bid.params.appId || typeof bid.params.appId != 'string' || !bid.params.format || typeof bid.params.format != 'string' || !bid.params.style || typeof bid.params.style != 'string') { - return false; - } - if (bid.params.format != 'screen' && bid.params.format != 'display') { - return false; - } - if (bid.params.style != 'inline' && bid.params.style != 'impact' && bid.params.style != 'static') { - return false; - } - - return true; - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids - * @param {bidderRequest} - the bidding request - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function (validBidRequests, bidderRequest) { - // Create a clean openRTB request - let request = createOpenRtbRequest(validBidRequests, bidderRequest); - - return { - method: 'POST', - url: ORIGIN + AUCTIONURI, - data: JSON.stringify(request), - }; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function (serverResponse, bidRequest) { - const serverBody = serverResponse.body; - let bidResponses = []; - - if (!serverBody) { - return bidResponses; - } - - if (!serverBody.seatbid || !serverBody.seatbid.length) { - return []; - } - - serverBody.seatbid.forEach((seatbid) => { - if (seatbid.bid.length) { - bidResponses = [ - ...bidResponses, - ...seatbid.bid - .filter((bid) => bid.price > 0) - .map((bid) => ({ - id: bid.id, - requestId: bid.impid, - cpm: bid.price, - currency: serverBody.cur, - netRevenue: true, - ad: bid.adm, - width: bid.w || 0, - height: bid.h || 0, - ttl: 300, - creativeId: bid.crid || 0, - hash: bid.hash, - expiry: bid.expiry - })), - ]; - } - }); - - return bidResponses; - }, - - /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @return {UserSync[]} The user syncs which should be dropped. - */ - getUserSyncs: function ( - syncOptions, - serverResponses, - gdprConsent, - uspConsent - ) { - if (!serverResponses || serverResponses.length === 0) { - return []; - } - - if (!syncOptions.iframeEnabled) { - return []; - } - - let params = ''; - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - if (typeof gdprConsent.gdprApplies === 'boolean') { - params += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - params += `?gdpr_consent=${gdprConsent.consentString}`; - } - } - - if (uspConsent) { - params += `${params ? '&' : '?'}us_privacy=${encodeURIComponent(uspConsent)}`; - } - - if (document.location.search.match(/pbs_debug=true/)) params += `&pbs_debug=true`; - - return [{ - type: 'iframe', - url: ORIGIN + COOKIESYNCURI + params - }]; - }, - - /** - * Register bidder specific code, which will execute if a bid from this bidder won the auction - * @param {Bid} The bid that won the auction - */ - onBidWon: function(bid) { - ajax(`${LOGGER_URI}/log/bidder/won`, null, JSON.stringify(bid), { - method: 'POST', - contentType: 'application/json' - }); - - return true; - }, - - /** - * Register bidder specific code, which will execute if bidder timed out after an auction - * @param {data} Containing timeout specific data - */ - onTimeout: function(data) { - ajax(`${LOGGER_URI}/log/bidder/timeout`, null, JSON.stringify(data[0]), { - method: 'POST', - contentType: 'application/json' - }); - - return true; - } -}; -registerBidder(spec); diff --git a/modules/innityBidAdapter.js b/modules/innityBidAdapter.js deleted file mode 100644 index aae79818daf..00000000000 --- a/modules/innityBidAdapter.js +++ /dev/null @@ -1,58 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'innity'; -const ENDPOINT = 'https://as.innity.com/synd/'; - -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function(bid) { - return !!(bid.params && bid.params.pub && bid.params.zone); - }, - buildRequests: function(validBidRequests, bidderRequest) { - let refererInfo = ''; - if (bidderRequest && bidderRequest.refererInfo) { - refererInfo = bidderRequest.refererInfo.referer || ''; - } - return validBidRequests.map(bidRequest => { - let parseSized = utils.parseSizesInput(bidRequest.sizes); - let arrSize = parseSized[0].split('x'); - return { - method: 'GET', - url: ENDPOINT, - data: { - cb: utils.timestamp(), - ver: 2, - hb: 1, - output: 'js', - pub: bidRequest.params.pub, - zone: bidRequest.params.zone, - url: encodeURIComponent(refererInfo), - width: arrSize[0], - height: arrSize[1], - vpw: window.screen.width, - vph: window.screen.height, - callback: 'json', - callback_uid: bidRequest.bidId, - auction: bidRequest.auctionId, - }, - }; - }); - }, - interpretResponse: function(serverResponse, request) { - const res = serverResponse.body; - const bidResponse = { - requestId: res.callback_uid, - cpm: parseFloat(res.cpm) / 100, - width: res.width, - height: res.height, - creativeId: res.creative_id, - currency: 'USD', - netRevenue: true, - ttl: 60, - ad: '' + res.tag, - }; - return [bidResponse]; - } -} -registerBidder(spec); diff --git a/modules/ipromBidAdapter.js b/modules/ipromBidAdapter.js deleted file mode 100644 index fed8ca2ebb0..00000000000 --- a/modules/ipromBidAdapter.js +++ /dev/null @@ -1,79 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'iprom'; -const ENDPOINT_URL = 'https://core.iprom.net/programmatic'; -const VERSION = 'v1.0.1'; -const DEFAULT_CURRENCY = 'EUR'; -const DEFAULT_NETREVENUE = true; -const DEFAULT_TTL = 360; - -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function ({ bidder, params = {} } = {}) { - // id parameter checks - if (!params.id) { - utils.logError(`${bidder}: Parameter 'id' missing`); - return false; - } else if (typeof params.id !== 'string') { - utils.logError(`${bidder}: Parameter 'id' needs to be a string`); - return false; - } - // dimension parameter checks - if (!params.dimension) { - utils.logError(`${bidder}: Required parameter 'dimension' missing`); - return false; - } else if (typeof params.dimension !== 'string') { - utils.logError(`${bidder}: Parameter 'dimension' needs to be a string`); - return false; - } - - return true; - }, - - buildRequests: function (validBidRequests, bidderRequest) { - const payload = { - bids: validBidRequests, - referer: bidderRequest.refererInfo, - version: VERSION - }; - const payloadString = JSON.stringify(payload); - - return { - method: 'POST', - url: ENDPOINT_URL, - data: payloadString - }; - }, - - interpretResponse: function (serverResponse, request) { - let bids = serverResponse.body; - - const bidResponses = []; - - bids.forEach(bid => { - const b = { - ad: bid.ad, - requestId: bid.requestId, - cpm: bid.cpm, - width: bid.width, - height: bid.height, - creativeId: bid.creativeId, - currency: bid.currency || DEFAULT_CURRENCY, - netRevenue: bid.netRevenue || DEFAULT_NETREVENUE, - ttl: bid.ttl || DEFAULT_TTL, - meta: {}, - }; - - if (bid.aDomains && bid.aDomains.length) { - b.meta.advertiserDomains = bid.aDomains; - } - - bidResponses.push(b); - }); - - return bidResponses; - }, -} - -registerBidder(spec); diff --git a/modules/ironsourceBidAdapter.js b/modules/ironsourceBidAdapter.js deleted file mode 100644 index daad0e3e4af..00000000000 --- a/modules/ironsourceBidAdapter.js +++ /dev/null @@ -1,251 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import {VIDEO} from '../src/mediaTypes.js'; -import {config} from '../src/config.js'; - -const SUPPORTED_AD_TYPES = [VIDEO]; -const BIDDER_CODE = 'ironsource'; -const BIDDER_VERSION = '4.0.0'; -const TTL = 360; -const SELLER_ENDPOINT = 'https://hb.yellowblue.io/'; -const MODES = { - PRODUCTION: 'hb', - TEST: 'hb-test' -} -const SUPPORTED_SYNC_METHODS = { - IFRAME: 'iframe', - PIXEL: 'pixel' -} - -export const spec = { - code: BIDDER_CODE, - version: BIDDER_VERSION, - supportedMediaTypes: SUPPORTED_AD_TYPES, - isBidRequestValid: function(bidRequest) { - return !!(bidRequest.params.isOrg); - }, - buildRequests: function (bidRequests, bidderRequest) { - if (bidRequests.length === 0) { - return []; - } - - const requests = []; - - bidRequests.forEach(bid => { - requests.push(buildVideoRequest(bid, bidderRequest)); - }); - - return requests; - }, - interpretResponse: function({body}) { - const bidResponses = []; - - const bidResponse = { - requestId: body.requestId, - cpm: body.cpm, - width: body.width, - height: body.height, - creativeId: body.requestId, - currency: body.currency, - netRevenue: body.netRevenue, - ttl: body.ttl || TTL, - vastXml: body.vastXml, - mediaType: VIDEO - }; - - bidResponses.push(bidResponse); - - return bidResponses; - }, - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - for (const response of serverResponses) { - if (syncOptions.iframeEnabled && response.body.userSyncURL) { - syncs.push({ - type: 'iframe', - url: response.body.userSyncURL - }); - } - if (syncOptions.pixelEnabled && utils.isArray(response.body.userSyncPixels)) { - const pixels = response.body.userSyncPixels.map(pixel => { - return { - type: 'image', - url: pixel - } - }) - syncs.push(...pixels) - } - } - return syncs; - } -}; - -registerBidder(spec); - -/** - * Build the video request - * @param bid {bid} - * @param bidderRequest {bidderRequest} - * @returns {Object} - */ -function buildVideoRequest(bid, bidderRequest) { - const sellerParams = generateParameters(bid, bidderRequest); - const {params} = bid; - return { - method: 'GET', - url: getEndpoint(params.testMode), - data: sellerParams - }; -} - -/** - * Get the the ad size from the bid - * @param bid {bid} - * @returns {Array} - */ -function getSizes(bid) { - if (utils.deepAccess(bid, 'mediaTypes.video.sizes')) { - return bid.mediaTypes.video.sizes[0]; - } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { - return bid.sizes[0]; - } - return []; -} - -/** - * Get schain string value - * @param schainObject {Object} - * @returns {string} - */ -function getSupplyChain(schainObject) { - if (utils.isEmpty(schainObject)) { - return ''; - } - let scStr = `${schainObject.ver},${schainObject.complete}`; - schainObject.nodes.forEach((node) => { - scStr += '!'; - scStr += `${getEncodedValIfNotEmpty(node.asi)},`; - scStr += `${getEncodedValIfNotEmpty(node.sid)},`; - scStr += `${getEncodedValIfNotEmpty(node.hp)},`; - scStr += `${getEncodedValIfNotEmpty(node.rid)},`; - scStr += `${getEncodedValIfNotEmpty(node.name)},`; - scStr += `${getEncodedValIfNotEmpty(node.domain)}`; - }); - return scStr; -} - -/** - * Get encoded node value - * @param val {string} - * @returns {string} - */ -function getEncodedValIfNotEmpty(val) { - return !utils.isEmpty(val) ? encodeURIComponent(val) : ''; -} - -/** - * Get preferred user-sync method based on publisher configuration - * @param bidderCode {string} - * @returns {string} - */ -function getAllowedSyncMethod(filterSettings, bidderCode) { - const iframeConfigsToCheck = ['all', 'iframe']; - const pixelConfigToCheck = 'image'; - if (filterSettings && iframeConfigsToCheck.some(config => isSyncMethodAllowed(filterSettings[config], bidderCode))) { - return SUPPORTED_SYNC_METHODS.IFRAME; - } - if (!filterSettings || !filterSettings[pixelConfigToCheck] || isSyncMethodAllowed(filterSettings[pixelConfigToCheck], bidderCode)) { - return SUPPORTED_SYNC_METHODS.PIXEL; - } -} - -/** - * Check if sync rule is supported - * @param syncRule {Object} - * @param bidderCode {string} - * @returns {boolean} - */ -function isSyncMethodAllowed(syncRule, bidderCode) { - if (!syncRule) { - return false; - } - const isInclude = syncRule.filter === 'include'; - const bidders = utils.isArray(syncRule.bidders) ? syncRule.bidders : [bidderCode]; - return isInclude && utils.contains(bidders, bidderCode); -} - -/** - * Get the seller endpoint - * @param testMode {boolean} - * @returns {string} - */ -function getEndpoint(testMode) { - return testMode - ? SELLER_ENDPOINT + MODES.TEST - : SELLER_ENDPOINT + MODES.PRODUCTION; -} - -/** - * Generate query parameters for the request - * @param bid {bid} - * @param bidderRequest {bidderRequest} - * @returns {Object} - */ -function generateParameters(bid, bidderRequest) { - const timeout = config.getConfig('bidderTimeout'); - const { syncEnabled, filterSettings } = config.getConfig('userSync'); - const [ width, height ] = getSizes(bid); - const { params } = bid; - const { bidderCode } = bidderRequest; - const domain = window.location.hostname; - - const requestParams = { - auction_start: utils.timestamp(), - ad_unit_code: utils.getBidIdParameter('adUnitCode', bid), - tmax: timeout, - width: width, - height: height, - publisher_id: params.isOrg, - floor_price: 0, - ua: navigator.userAgent, - bid_id: utils.getBidIdParameter('bidId', bid), - bidder_request_id: utils.getBidIdParameter('bidderRequestId', bid), - transaction_id: utils.getBidIdParameter('transactionId', bid), - session_id: params.sessionId || utils.getBidIdParameter('auctionId', bid), - is_wrapper: !!params.isWrapper, - publisher_name: domain, - site_domain: domain, - bidder_version: BIDDER_VERSION - }; - - if (syncEnabled) { - const allowedSyncMethod = getAllowedSyncMethod(filterSettings, bidderCode); - if (allowedSyncMethod) { - requestParams.cs_method = allowedSyncMethod; - } - } - - if (bidderRequest.uspConsent) { - requestParams.us_privacy = bidderRequest.uspConsent; - } - - if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { - requestParams.gdpr = bidderRequest.gdprConsent.gdprApplies; - requestParams.gdpr_consent = bidderRequest.gdprConsent.consentString; - } - - if (params.ifa) { - requestParams.ifa = params.ifa; - } - - if (bid.schain) { - requestParams.schain = getSupplyChain(bid.schain); - } - - if (bidderRequest && bidderRequest.refererInfo) { - requestParams.referrer = utils.deepAccess(bidderRequest, 'refererInfo.referer'); - requestParams.page_url = config.getConfig('pageUrl') || utils.deepAccess(window, 'location.href'); - } - - return requestParams; -} diff --git a/modules/jcmBidAdapter.js b/modules/jcmBidAdapter.js deleted file mode 100644 index c8d2f8bdd52..00000000000 --- a/modules/jcmBidAdapter.js +++ /dev/null @@ -1,89 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -const BIDDER_CODE = 'jcm'; -const URL = 'https://media.adfrontiers.com/pq' - -export const spec = { - code: BIDDER_CODE, - aliases: ['jcarter'], - isBidRequestValid: function(bid) { - return !!(bid.params && bid.params.siteId && bid.bidId); - }, - - buildRequests: function(validBidRequests) { - var BidRequestStr = { - bids: [] - }; - - for (var i = 0; i < validBidRequests.length; i++) { - var adSizes = ''; - var bid = validBidRequests[i]; - for (var x = 0; x < bid.sizes.length; x++) { - adSizes += utils.parseGPTSingleSizeArray(bid.sizes[x]); - if (x !== (bid.sizes.length - 1)) { - adSizes += ','; - } - } - - BidRequestStr.bids.push({ - 'callbackId': bid.bidId, - 'siteId': bid.params.siteId, - 'adSizes': adSizes, - }); - } - - var JSONStr = JSON.stringify(BidRequestStr); - var dataStr = 't=hb&ver=1.0&compact=true&bids=' + encodeURIComponent(JSONStr); - - return { - method: 'GET', - url: URL, - data: dataStr - } - }, - - interpretResponse: function(serverResponse) { - const bidResponses = []; - serverResponse = serverResponse.body; - // loop through serverResponses - if (serverResponse) { - if (serverResponse.bids) { - var bids = serverResponse.bids; - for (var i = 0; i < bids.length; i++) { - var bid = bids[i]; - const bidResponse = { - requestId: bid.callbackId, - bidderCode: spec.code, - cpm: bid.cpm, - width: bid.width, - height: bid.height, - creativeId: bid.creativeId, - currency: 'USD', - netRevenue: bid.netRevenue, - ttl: bid.ttl, - ad: decodeURIComponent(bid.ad.replace(/\+/g, '%20')) - }; - bidResponses.push(bidResponse); - }; - }; - } - return bidResponses; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: 'https://media.adfrontiers.com/hb/jcm_usersync.html' - }]; - } - if (syncOptions.image) { - return [{ - type: 'image', - url: 'https://media.adfrontiers.com/hb/jcm_usersync.png' - }]; - } - } -} - -registerBidder(spec); diff --git a/modules/krushmediaBidAdapter.js b/modules/krushmediaBidAdapter.js deleted file mode 100644 index de1cce503e3..00000000000 --- a/modules/krushmediaBidAdapter.js +++ /dev/null @@ -1,123 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'krushmedia'; -const AD_URL = 'https://ads4.krushmedia.com/?c=rtb&m=hb'; -const SYNC_URL = 'https://cs.krushmedia.com/html?src=pbjs' - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native && bid.native.impressionTrackers); - default: - return false; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.key))); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; - - const placements = []; - const request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - - const len = validBidRequests.length; - for (let i = 0; i < len; i++) { - const bid = validBidRequests[i]; - const placement = { - key: bid.params.key, - bidId: bid.bidId, - traffic: bid.params.traffic || BANNER, - schain: bid.schain || {}, - }; - - if (bid.mediaTypes && bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { - placement.sizes = bid.mediaTypes[BANNER].sizes; - } else if (bid.mediaTypes && bid.mediaTypes[VIDEO] && bid.mediaTypes[VIDEO].playerSize) { - placement.wPlayer = bid.mediaTypes[VIDEO].playerSize[0]; - placement.hPlayer = bid.mediaTypes[VIDEO].playerSize[1]; - } else if (bid.mediaTypes && bid.mediaTypes[NATIVE]) { - placement.native = bid.mediaTypes[NATIVE]; - } - placements.push(placement); - } - - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - for (let i = 0; i < serverResponse.body.length; i++) { - let resItem = serverResponse.body[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, - - getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { - let syncUrl = SYNC_URL - if (gdprConsent && gdprConsent.consentString) { - if (typeof gdprConsent.gdprApplies === 'boolean') { - syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; - } - } - if (uspConsent && uspConsent.consentString) { - syncUrl += `&ccpa_consent=${uspConsent.consentString}`; - } - return [{ - type: 'iframe', - url: syncUrl - }]; - } -}; - -registerBidder(spec); diff --git a/modules/lifestreetBidAdapter.js b/modules/lifestreetBidAdapter.js deleted file mode 100644 index 4317eb8b82e..00000000000 --- a/modules/lifestreetBidAdapter.js +++ /dev/null @@ -1,139 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'lifestreet'; -const ADAPTER_VERSION = '$prebid.version$'; - -const urlTemplate = template`https://ads.lfstmedia.com/gate/${'adapter'}/${'slot'}?adkey=${'adkey'}&ad_size=${'ad_size'}&__location=${'location'}&__referrer=${'referrer'}&__wn=${'wn'}&__sf=${'sf'}&__fif=${'fif'}&__if=${'if'}&__stamp=${'stamp'}&__pp=1&__hb=1&_prebid_json=1&__gz=1&deferred_format=vast_2_0,vast_3_0&__hbver=${'hbver'}`; - -/** - * A helper function for template to generate string from boolean - */ -function boolToString(value) { - return value ? '1' : '0'; -} - -/** - * A helper function to form URL from the template - */ -function template(strings, ...keys) { - return function(...values) { - let dict = values[values.length - 1] || {}; - let result = [strings[0]]; - keys.forEach(function(key, i) { - let value = utils.isInteger(key) ? values[key] : dict[key]; - result.push(value, strings[i + 1]); - }); - return result.join(''); - }; -} - -/** - * Creates a bid requests for a given bid. - * - * @param {BidRequest} bid The bid params to use for formatting a request - */ -function formatBidRequest(bid, bidderRequest = {}) { - const {params} = bid; - const {referer} = (bidderRequest.refererInfo || {}); - let url = urlTemplate({ - adapter: 'prebid', - slot: params.slot, - adkey: params.adkey, - ad_size: params.ad_size, - location: referer, - referrer: referer, - wn: boolToString(/fb_http/i.test(window.name)), - sf: boolToString(window['sfAPI'] || window['$sf']), - fif: boolToString(window['inDapIF'] === true), - if: boolToString(window !== window.top), - stamp: new Date().getTime(), - hbver: ADAPTER_VERSION - }); - - if (bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.gdprApplies !== undefined) { - const gdpr = '&__gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? '1' : '0'); - url += gdpr; - } - if (bidderRequest.gdprConsent.consentString !== undefined) { - url += `&__consent=${bidderRequest.gdprConsent.consentString}`; - } - } - - // ccpa support - if (bidderRequest.uspConsent) { - url += `&__us_privacy=${bidderRequest.uspConsent}` - } - - return { - method: 'GET', - url: url, - bidId: bid.bidId - }; -} - -function isResponseValid(response) { - return !/^\s*\{\s*"advertisementAvailable"\s*:\s*false/i.test(response.content) && - response.content.indexOf('') === -1 && (typeof response.cpm !== 'undefined') && - response.status === 1; -} - -export const spec = { - code: BIDDER_CODE, - aliases: ['lsm'], - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid: (bid = {}) => { - const {params = {}} = bid; - return !!(params.slot && params.adkey && params.ad_size); - }, - - buildRequests: (validBidRequests, bidderRequest) => { - return validBidRequests.map(bid => { - return formatBidRequest(bid, bidderRequest) - }); - }, - - interpretResponse: (serverResponse, bidRequest) => { - const bidResponses = []; - let response = serverResponse.body; - - if (!isResponseValid(response)) { - return bidResponses; - } - - const bidResponse = { - requestId: bidRequest.bidId, - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.creativeId, - currency: response.currency ? response.currency : 'USD', - netRevenue: response.netRevenue ? response.netRevenue : true, - ttl: response.ttl ? response.ttl : 86400 - }; - - if (response.hasOwnProperty('dealId')) { - bidResponse.dealId = response.dealId; - } - if (response.content_type.indexOf('vast') > -1) { - if (typeof response.vastUrl !== 'undefined') { - bidResponse.vastUrl = response.vastUrl; - } else { - bidResponse.vastXml = response.content; - } - - bidResponse.mediaType = VIDEO; - } else { - bidResponse.ad = response.content; - bidResponse.mediaType = BANNER; - } - - bidResponses.push(bidResponse); - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/lkqdBidAdapter.js b/modules/lkqdBidAdapter.js deleted file mode 100644 index 0f5782649ad..00000000000 --- a/modules/lkqdBidAdapter.js +++ /dev/null @@ -1,284 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO } from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; - -const BIDDER_CODE = 'lkqd'; -const BID_TTL_DEFAULT = 300; -const ENDPOINT = 'https://v.lkqd.net/ad'; - -const PARAM_OUTPUT_DEFAULT = 'vast'; -const PARAM_EXECUTION_DEFAULT = 'any'; -const PARAM_SUPPORT_DEFAULT = 'html5'; -const PARAM_PLAYINIT_DEFAULT = 'auto'; -const PARAM_VOLUME_DEFAULT = '100'; - -function _validateId(id) { - if (id && typeof id !== 'undefined' && parseInt(id) > 0) { - return true; - } - - return false; -} - -function isBidRequestValid(bidRequest) { - if (bidRequest.bidder === BIDDER_CODE && typeof bidRequest.params !== 'undefined') { - if (_validateId(bidRequest.params.siteId) && _validateId(bidRequest.params.placementId)) { - return true; - } - } - - return false; -} - -function buildRequests(validBidRequests, bidderRequest) { - let bidRequests = []; - - for (let i = 0; i < validBidRequests.length; i++) { - let bidRequest = validBidRequests[i]; - - let sizes = []; - // if width/height not provided to the ad unit for some reason then attempt request with default 640x480 size - let bidRequestSizes = bidRequest.sizes; - let bidRequestDeepSizes = utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize'); - if ((!bidRequestSizes || !bidRequestSizes.length) && (!bidRequestDeepSizes || !bidRequestDeepSizes.length)) { - utils.logWarn('Warning: Could not find valid width/height parameters on the provided adUnit'); - sizes = [[640, 480]]; - } - - // JWPlayer demo page uses sizes: [640,480] instead of sizes: [[640,480]] so need to handle single-layer array as well as nested arrays - if (bidRequestSizes && bidRequestSizes.length > 0) { - sizes = bidRequestSizes; - if (bidRequestSizes.length === 2 && typeof bidRequestSizes[0] === 'number' && typeof bidRequestSizes[1] === 'number') { - sizes = [bidRequestSizes]; - } - } else if (bidRequestDeepSizes && bidRequestDeepSizes.length > 0) { - sizes = bidRequestDeepSizes; - if (bidRequestDeepSizes.length === 2 && typeof bidRequestDeepSizes[0] === 'number' && typeof bidRequestDeepSizes[1] === 'number') { - sizes = [bidRequestDeepSizes]; - } - } - - for (let j = 0; j < sizes.length; j++) { - let size = sizes[j]; - let playerWidth; - let playerHeight; - if (size && size.length == 2) { - playerWidth = size[0]; - playerHeight = size[1]; - } else { - utils.logWarn('Warning: Could not determine width/height from the provided adUnit'); - } - - let sspUrl = ENDPOINT.concat(); - let sspData = {}; - - // required parameters - sspData.pid = bidRequest.params.placementId; - sspData.sid = bidRequest.params.siteId; - sspData.prebid = true; - - // optional parameters - if (bidRequest.params.hasOwnProperty('output') && bidRequest.params.output != null) { - sspData.output = bidRequest.params.output; - } else { - sspData.output = PARAM_OUTPUT_DEFAULT; - } - if (bidRequest.params.hasOwnProperty('execution') && bidRequest.params.execution != null) { - sspData.execution = bidRequest.params.execution; - } else { - sspData.execution = PARAM_EXECUTION_DEFAULT; - } - if (bidRequest.params.hasOwnProperty('support') && bidRequest.params.support != null) { - sspData.support = bidRequest.params.support; - } else { - sspData.support = PARAM_SUPPORT_DEFAULT; - } - if (bidRequest.params.hasOwnProperty('playinit') && bidRequest.params.playinit != null) { - sspData.playinit = bidRequest.params.playinit; - } else { - sspData.playinit = PARAM_PLAYINIT_DEFAULT; - } - if (bidRequest.params.hasOwnProperty('volume') && bidRequest.params.volume != null) { - sspData.volume = bidRequest.params.volume; - } else { - sspData.volume = PARAM_VOLUME_DEFAULT; - } - if (playerWidth) { - sspData.width = playerWidth; - } - if (playerHeight) { - sspData.height = playerHeight; - } - if (bidRequest.params.hasOwnProperty('vpaidmode') && bidRequest.params.vpaidmode != null) { - sspData.vpaidmode = bidRequest.params.vpaidmode; - } - if (bidRequest.params.hasOwnProperty('appname') && bidRequest.params.appname != null) { - sspData.appname = bidRequest.params.appname; - } - if (bidRequest.params.hasOwnProperty('bundleid') && bidRequest.params.bundleid != null) { - sspData.bundleid = bidRequest.params.bundleid; - } - if (bidRequest.params.hasOwnProperty('aid') && bidRequest.params.aid != null) { - sspData.aid = bidRequest.params.aid; - } - if (bidRequest.params.hasOwnProperty('idfa') && bidRequest.params.idfa != null) { - sspData.idfa = bidRequest.params.idfa; - } - if (bidRequest.params.hasOwnProperty('gdpr') && bidRequest.params.gdpr != null) { - sspData.gdpr = bidRequest.params.gdpr; - } - if (bidRequest.params.hasOwnProperty('gdprcs') && bidRequest.params.gdprcs != null) { - sspData.gdprcs = bidRequest.params.gdprcs; - } - if (bidRequest.params.hasOwnProperty('flrd') && bidRequest.params.flrd != null) { - sspData.flrd = bidRequest.params.flrd; - } - if (bidRequest.params.hasOwnProperty('flrmp') && bidRequest.params.flrmp != null) { - sspData.flrmp = bidRequest.params.flrmp; - } - if (bidRequest.params.hasOwnProperty('schain') && bidRequest.params.schain != null) { - sspData.schain = bidRequest.params.schain; - } - if (bidRequest.params.hasOwnProperty('placement') && bidRequest.params.placement != null) { - sspData.placement = bidRequest.params.placement; - } - if (bidRequest.params.hasOwnProperty('timeout') && bidRequest.params.timeout != null) { - sspData.timeout = bidRequest.params.timeout; - } - if (bidRequest.params.hasOwnProperty('dnt') && bidRequest.params.dnt != null) { - sspData.dnt = bidRequest.params.dnt; - } - if (config.getConfig('coppa') === true) { - sspData.coppa = 1; - } - if (bidRequest.params.hasOwnProperty('pageurl') && bidRequest.params.pageurl != null) { - sspData.pageurl = bidRequest.params.pageurl; - } else if (bidderRequest && bidderRequest.refererInfo) { - sspData.pageurl = encodeURIComponent(encodeURIComponent(bidderRequest.refererInfo.referer)); - } - if (bidRequest.params.hasOwnProperty('contentId') && bidRequest.params.contentId != null) { - sspData.contentid = bidRequest.params.contentId; - } - if (bidRequest.params.hasOwnProperty('contentTitle') && bidRequest.params.contentTitle != null) { - sspData.contenttitle = bidRequest.params.contentTitle; - } - if (bidRequest.params.hasOwnProperty('contentLength') && bidRequest.params.contentLength != null) { - sspData.contentlength = bidRequest.params.contentLength; - } - if (bidRequest.params.hasOwnProperty('contentUrl') && bidRequest.params.contentUrl != null) { - sspData.contenturl = bidRequest.params.contentUrl; - } - if (bidRequest.params.hasOwnProperty('schain') && bidRequest.params.schain) { - sspData.schain = bidRequest.params.schain; - } - - // random number to prevent caching - sspData.rnd = Math.floor(Math.random() * 999999999); - - // Prebid.js required properties - sspData.bidId = bidRequest.bidId; - sspData.bidWidth = playerWidth; - sspData.bidHeight = playerHeight; - - for (let k = 1; k <= 40; k++) { - if (bidRequest.params.hasOwnProperty(`c${k}`) && bidRequest.params[`c${k}`]) { - sspData[`c${k}`] = bidRequest.params[`c${k}`]; - } - } - - bidRequests.push({ - method: 'GET', - url: sspUrl, - data: Object.keys(sspData).map(function (key) { return key + '=' + sspData[key] }).join('&') + '&' - }); - } - } - - return bidRequests; -} - -function interpretResponse(serverResponse, bidRequest) { - let bidResponses = []; - if (serverResponse && serverResponse.body) { - if (serverResponse.error) { - utils.logError('Error: ' + serverResponse.error); - return bidResponses; - } else { - try { - let bidResponse = {}; - if (bidRequest && bidRequest.data && typeof bidRequest.data === 'string') { - let sspData; - let sspBidId; - let sspBidWidth; - let sspBidHeight; - if (window.URLSearchParams) { - sspData = new URLSearchParams(bidRequest.data); - sspBidId = sspData.get('bidId'); - sspBidWidth = sspData.get('bidWidth'); - sspBidHeight = sspData.get('bidHeight'); - } else { - if (bidRequest.data.indexOf('bidId=') >= 0) { - sspBidId = bidRequest.data.substr(bidRequest.data.indexOf('bidId=') + 6, bidRequest.data.length); - sspBidId = sspBidId.split('&')[0]; - } - if (bidRequest.data.indexOf('bidWidth=') >= 0) { - sspBidWidth = bidRequest.data.substr(bidRequest.data.indexOf('bidWidth=') + 9, bidRequest.data.length); - sspBidWidth = sspBidWidth.split('&')[0]; - } - if (bidRequest.data.indexOf('bidHeight=') >= 0) { - sspBidHeight = bidRequest.data.substr(bidRequest.data.indexOf('bidHeight=') + 10, bidRequest.data.length); - sspBidHeight = sspBidHeight.split('&')[0]; - } - } - - if (sspBidId) { - let sspXmlString = serverResponse.body; - let sspXml = new window.DOMParser().parseFromString(sspXmlString, 'text/xml'); - if (sspXml && sspXml.getElementsByTagName('parsererror').length == 0) { - let sspUrl = bidRequest.url.concat(); - - bidResponse.requestId = sspBidId; - bidResponse.bidderCode = BIDDER_CODE; - bidResponse.ad = ''; - bidResponse.cpm = parseFloat(sspXml.getElementsByTagName('Pricing')[0].textContent); - bidResponse.width = sspBidWidth; - bidResponse.height = sspBidHeight; - bidResponse.ttl = BID_TTL_DEFAULT; - bidResponse.creativeId = sspXml.getElementsByTagName('Ad')[0].getAttribute('id'); - bidResponse.currency = sspXml.getElementsByTagName('Pricing')[0].getAttribute('currency'); - bidResponse.netRevenue = true; - bidResponse.vastUrl = sspUrl; - bidResponse.vastXml = sspXmlString; - bidResponse.mediaType = VIDEO; - - bidResponses.push(bidResponse); - } else { - utils.logError('Error: Server response contained invalid XML'); - } - } else { - utils.logError('Error: Could not associate bid request to server response'); - } - } else { - utils.logError('Error: Could not associate bid request to server response'); - } - } catch (e) { - utils.logError('Error: Could not interpret server response'); - } - } - } else { - utils.logError('Error: No server response or server response was empty for the requested URL'); - } - - return bidResponses; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [VIDEO], - isBidRequestValid, - buildRequests, - interpretResponse -} - -registerBidder(spec); diff --git a/modules/loganBidAdapter.js b/modules/loganBidAdapter.js deleted file mode 100644 index e55876de675..00000000000 --- a/modules/loganBidAdapter.js +++ /dev/null @@ -1,118 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'logan'; -const AD_URL = 'https://USeast2.logan.ai/?c=o&m=multi'; -const SYNC_URL = 'https://ssp-cookie.logan.ai/html?src=pbjs' - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native && bid.native.impressionTrackers); - default: - return false; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - const winTop = utils.getWindowTop(); - const location = winTop.location; - const placements = []; - const request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - - const len = validBidRequests.length; - for (let i = 0; i < len; i++) { - const bid = validBidRequests[i]; - const placement = { - placementId: bid.params.placementId, - bidId: bid.bidId, - schain: bid.schain || {}, - }; - const mediaType = bid.mediaTypes - - if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) { - placement.sizes = mediaType[BANNER].sizes; - placement.traffic = BANNER; - } else if (mediaType && mediaType[VIDEO] && mediaType[VIDEO].playerSize) { - placement.wPlayer = mediaType[VIDEO].playerSize[0]; - placement.hPlayer = mediaType[VIDEO].playerSize[1]; - placement.traffic = VIDEO; - } else if (mediaType && mediaType[NATIVE]) { - placement.native = mediaType[NATIVE]; - placement.traffic = NATIVE; - } - placements.push(placement); - } - - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - for (let i = 0; i < serverResponse.body.length; i++) { - let resItem = serverResponse.body[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, - - getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { - let syncUrl = SYNC_URL - if (gdprConsent && gdprConsent.consentString) { - if (typeof gdprConsent.gdprApplies === 'boolean') { - syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; - } - } - if (uspConsent && uspConsent.consentString) { - syncUrl += `&ccpa_consent=${uspConsent.consentString}`; - } - return [{ - type: 'iframe', - url: syncUrl - }]; - } -}; - -registerBidder(spec); diff --git a/modules/logicadBidAdapter.js b/modules/logicadBidAdapter.js deleted file mode 100644 index 2c919f9c157..00000000000 --- a/modules/logicadBidAdapter.js +++ /dev/null @@ -1,69 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER, NATIVE} from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'logicad'; -const ENDPOINT_URL = 'https://pb.ladsp.com/adrequest/prebid'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, NATIVE], - isBidRequestValid: function (bid) { - return !!(bid.params && bid.params.tid); - }, - buildRequests: function (bidRequests, bidderRequest) { - const requests = []; - for (let i = 0, len = bidRequests.length; i < len; i++) { - const request = { - method: 'POST', - url: ENDPOINT_URL, - data: JSON.stringify(newBidRequest(bidRequests[i], bidderRequest)), - options: {}, - bidderRequest - }; - requests.push(request); - } - return requests; - }, - interpretResponse: function (serverResponse, bidderRequest) { - serverResponse = serverResponse.body; - const bids = []; - if (!serverResponse || serverResponse.error) { - return bids; - } - serverResponse.seatbid.forEach(function (seatbid) { - bids.push(seatbid.bid); - }) - return bids; - }, - getUserSyncs: function (syncOptions, serverResponses) { - if (serverResponses.length > 0 && serverResponses[0].body.userSync && - syncOptions.pixelEnabled && serverResponses[0].body.userSync.type == 'image') { - return [{ - type: 'image', - url: serverResponses[0].body.userSync.url - }]; - } - return []; - }, -}; - -function newBidRequest(bid, bidderRequest) { - return { - auctionId: bid.auctionId, - bidderRequestId: bid.bidderRequestId, - bids: [{ - adUnitCode: bid.adUnitCode, - bidId: bid.bidId, - transactionId: bid.transactionId, - sizes: bid.sizes, - params: bid.params, - mediaTypes: bid.mediaTypes - }], - prebidJsVersion: '$prebid.version$', - referrer: bidderRequest.refererInfo.referer, - auctionStartTime: bidderRequest.auctionStart, - eids: bid.userIdAsEids, - }; -} - -registerBidder(spec); diff --git a/modules/loopmeBidAdapter.js b/modules/loopmeBidAdapter.js deleted file mode 100644 index 919e0b17294..00000000000 --- a/modules/loopmeBidAdapter.js +++ /dev/null @@ -1,149 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { Renderer } from '../src/Renderer.js'; - -const LOOPME_ENDPOINT = 'https://loopme.me/api/hb'; - -const entries = (obj) => { - let output = []; - for (let key in obj) { - if (obj.hasOwnProperty(key)) { - output.push([key, obj[key]]) - } - } - return output; -} - -export const spec = { - code: 'loopme', - supportedMediaTypes: [BANNER, VIDEO], - /** - * @param {object} bid - * @return boolean - */ - isBidRequestValid: function(bid) { - if (typeof bid.params !== 'object') { - return false; - } - - return !!bid.params.ak; - }, - /** - * @param {BidRequest[]} bidRequests - * @param bidderRequest - * @return ServerRequest[] - */ - buildRequests: function(bidRequests, bidderRequest) { - return bidRequests.map(bidRequest => { - bidRequest.startTime = new Date().getTime(); - let payload = bidRequest.params; - - if (bidderRequest && bidderRequest.gdprConsent) { - payload.user_consent = bidderRequest.gdprConsent.consentString; - } - - let queryString = entries(payload) - .map(item => `${item[0]}=${encodeURI(item[1])}`) - .join('&'); - - const adUnitSizes = bidRequest.mediaTypes[BANNER] - ? utils.getAdUnitSizes(bidRequest) - : utils.deepAccess(bidRequest.mediaTypes, 'video.playerSize'); - - const sizes = - '&sizes=' + - adUnitSizes - .map(size => `${size[0]}x${size[1]}`) - .join('&sizes='); - - queryString = `${queryString}${sizes}${bidRequest.mediaTypes[VIDEO] ? '&media_type=video' : ''}`; - - return { - method: 'GET', - url: `${LOOPME_ENDPOINT}`, - options: { withCredentials: false }, - bidId: bidRequest.bidId, - data: queryString - }; - }); - }, - /** - * @param {*} responseObj - * @param {BidRequest} bidRequest - * @return {Bid[]} An array of bids which - */ - interpretResponse: function(response = {}, bidRequest) { - const responseObj = response.body; - if ( - responseObj === null || - typeof responseObj !== 'object' - ) { - return []; - } - - if ( - !responseObj.hasOwnProperty('ad') && - !responseObj.hasOwnProperty('vastUrl') - ) { - return []; - } - // responseObj.vastUrl = 'https://rawgit.com/InteractiveAdvertisingBureau/VAST_Samples/master/VAST%201-2.0%20Samples/Inline_NonLinear_Verification_VAST2.0.xml'; - if (responseObj.vastUrl) { - const renderer = Renderer.install({ - id: bidRequest.bidId, - url: 'https://i.loopme.me/html/vast/loopme_flex.js', - loaded: false - }); - renderer.setRender((bid) => { - renderer.push(function () { - var adverts = [{ - 'type': 'VAST', - 'url': bid.vastUrl, - 'autoClose': -1 - }]; - var config = { - containerId: bid.adUnitCode, - vastTimeout: 250, - ads: adverts, - user_consent: '%%USER_CONSENT%%', - }; - window.L.flex.loader.load(config); - }) - }); - return [ - { - requestId: bidRequest.bidId, - cpm: responseObj.cpm, - width: responseObj.width, - height: responseObj.height, - ttl: responseObj.ttl, - currency: responseObj.currency, - creativeId: responseObj.creativeId, - dealId: responseObj.dealId, - netRevenue: responseObj.netRevenue, - vastUrl: responseObj.vastUrl, - mediaType: VIDEO, - renderer - } - ]; - } - - return [ - { - requestId: bidRequest.bidId, - cpm: responseObj.cpm, - width: responseObj.width, - height: responseObj.height, - ad: responseObj.ad, - ttl: responseObj.ttl, - currency: responseObj.currency, - creativeId: responseObj.creativeId, - dealId: responseObj.dealId, - netRevenue: responseObj.netRevenue, - mediaType: BANNER - } - ]; - } -}; -registerBidder(spec); diff --git a/modules/luponmediaBidAdapter.js b/modules/luponmediaBidAdapter.js deleted file mode 100644 index e5c317dd06c..00000000000 --- a/modules/luponmediaBidAdapter.js +++ /dev/null @@ -1,341 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {config} from '../src/config.js'; -import {BANNER} from '../src/mediaTypes.js'; -import { ajax } from '../src/ajax.js'; - -const BIDDER_CODE = 'luponmedia'; -const ENDPOINT_URL = 'https://rtb.adxpremium.services/openrtb2/auction'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - isBidRequestValid: function (bid) { - return !!(bid.params && bid.params.siteId && bid.params.keyId); // TODO: check for siteId and keyId - }, - buildRequests: function (bidRequests, bidderRequest) { - const bRequest = { - method: 'POST', - url: ENDPOINT_URL, - data: null, - options: {}, - bidderRequest - }; - - let currentImps = []; - - for (let i = 0, len = bidRequests.length; i < len; i++) { - let newReq = newOrtbBidRequest(bidRequests[i], bidderRequest, currentImps); - currentImps = newReq.imp; - bRequest.data = JSON.stringify(newReq); - } - - return bRequest; - }, - interpretResponse: (response, request) => { - const bidResponses = []; - var respCur = 'USD'; - let parsedRequest = JSON.parse(request.data); - let parsedReferrer = parsedRequest.site && parsedRequest.site.ref ? parsedRequest.site.ref : ''; - try { - if (response.body && response.body.seatbid && utils.isArray(response.body.seatbid)) { - // Supporting multiple bid responses for same adSize - respCur = response.body.cur || respCur; - response.body.seatbid.forEach(seatbidder => { - seatbidder.bid && - utils.isArray(seatbidder.bid) && - seatbidder.bid.forEach(bid => { - let newBid = { - requestId: bid.impid, - cpm: (parseFloat(bid.price) || 0).toFixed(2), - width: bid.w, - height: bid.h, - creativeId: bid.crid || bid.id, - dealId: bid.dealid, - currency: respCur, - netRevenue: false, - ttl: 300, - referrer: parsedReferrer, - ad: bid.adm - }; - - bidResponses.push(newBid); - }); - }); - } - } catch (error) { - utils.logError(error); - } - return bidResponses; - }, - getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { - let allUserSyncs = []; - if (!hasSynced && (syncOptions.iframeEnabled || syncOptions.pixelEnabled)) { - responses.forEach(csResp => { - if (csResp.body && csResp.body.ext && csResp.body.ext.usersyncs) { - try { - let response = csResp.body.ext.usersyncs - let bidders = response.bidder_status; - for (let synci in bidders) { - let thisSync = bidders[synci]; - if (thisSync.no_cookie) { - let url = thisSync.usersync.url; - let type = thisSync.usersync.type; - - if (!url) { - utils.logError(`No sync url for bidder luponmedia.`); - } else if ((type === 'image' || type === 'redirect') && syncOptions.pixelEnabled) { - utils.logMessage(`Invoking image pixel user sync for luponmedia`); - allUserSyncs.push({type: 'image', url: url}); - } else if (type == 'iframe' && syncOptions.iframeEnabled) { - utils.logMessage(`Invoking iframe user sync for luponmedia`); - allUserSyncs.push({type: 'iframe', url: url}); - } else { - utils.logError(`User sync type "${type}" not supported for luponmedia`); - } - } - } - } catch (e) { - utils.logError(e); - } - } - }); - } else { - utils.logWarn('Luponmedia: Please enable iframe/pixel based user sync.'); - } - - hasSynced = true; - return allUserSyncs; - }, - onBidWon: bid => { - const bidString = JSON.stringify(bid); - spec.sendWinningsToServer(bidString); - }, - sendWinningsToServer: data => { - let mutation = `mutation {createWin(input: {win: {eventData: "${window.btoa(data)}"}}) {win {createTime } } }`; - let dataToSend = JSON.stringify({ query: mutation }); - - ajax('https://analytics.adxpremium.services/graphql', null, dataToSend, { - contentType: 'application/json', - method: 'POST' - }); - } -}; - -function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) { - bidRequest.startTime = new Date().getTime(); - - const bannerParams = utils.deepAccess(bidRequest, 'mediaTypes.banner'); - - let bannerSizes = []; - - if (bannerParams && bannerParams.sizes) { - const sizes = utils.parseSizesInput(bannerParams.sizes); - - // get banner sizes in form [{ w: , h: }, ...] - const format = sizes.map(size => { - const [ width, height ] = size.split('x'); - const w = parseInt(width, 10); - const h = parseInt(height, 10); - return { w, h }; - }); - - bannerSizes = format; - } - - const data = { - id: bidRequest.transactionId, - test: config.getConfig('debug') ? 1 : 0, - source: { - tid: bidRequest.transactionId - }, - tmax: config.getConfig('timeout') || 1500, - imp: currentImps.concat([{ - id: bidRequest.bidId, - secure: 1, - ext: { - [bidRequest.bidder]: bidRequest.params - }, - banner: { - format: bannerSizes - } - }]), - ext: { - prebid: { - targeting: { - includewinners: true, - // includebidderkeys always false for openrtb - includebidderkeys: false - } - } - }, - user: { - } - } - - appendSiteAppDevice(data, bidRequest, bidderRequest); - - if (bidderRequest.gdprConsent) { - // note - gdprApplies & consentString may be undefined in certain use-cases for consentManagement module - let gdprApplies; - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - gdprApplies = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; - } - - utils.deepSetValue(data, 'regs.ext.gdpr', gdprApplies); - utils.deepSetValue(data, 'user.ext.consent', bidderRequest.gdprConsent.consentString); - } - - if (bidderRequest.uspConsent) { - utils.deepSetValue(data, 'regs.ext.us_privacy', bidderRequest.uspConsent); - } - - // Set user uuid - utils.deepSetValue(data, 'user.id', utils.generateUUID()); - - // set crumbs - if (bidRequest.crumbs && bidRequest.crumbs.pubcid) { - utils.deepSetValue(data, 'user.buyeruid', bidRequest.crumbs.pubcid); - } else { - utils.deepSetValue(data, 'user.buyeruid', utils.generateUUID()); - } - - if (bidRequest.userId && typeof bidRequest.userId === 'object' && - (bidRequest.userId.tdid || bidRequest.userId.pubcid || bidRequest.userId.lipb || bidRequest.userId.idl_env)) { - utils.deepSetValue(data, 'user.ext.eids', []); - - if (bidRequest.userId.tdid) { - data.user.ext.eids.push({ - source: 'adserver.org', - uids: [{ - id: bidRequest.userId.tdid, - ext: { - rtiPartner: 'TDID' - } - }] - }); - } - - if (bidRequest.userId.pubcid) { - data.user.ext.eids.push({ - source: 'pubcommon', - uids: [{ - id: bidRequest.userId.pubcid, - }] - }); - } - - // support liveintent ID - if (bidRequest.userId.lipb && bidRequest.userId.lipb.lipbid) { - data.user.ext.eids.push({ - source: 'liveintent.com', - uids: [{ - id: bidRequest.userId.lipb.lipbid - }] - }); - - data.user.ext.tpid = { - source: 'liveintent.com', - uid: bidRequest.userId.lipb.lipbid - }; - - if (Array.isArray(bidRequest.userId.lipb.segments) && bidRequest.userId.lipb.segments.length) { - utils.deepSetValue(data, 'rp.target.LIseg', bidRequest.userId.lipb.segments); - } - } - - // support identityLink (aka LiveRamp) - if (bidRequest.userId.idl_env) { - data.user.ext.eids.push({ - source: 'liveramp.com', - uids: [{ - id: bidRequest.userId.idl_env - }] - }); - } - } - - if (config.getConfig('coppa') === true) { - utils.deepSetValue(data, 'regs.coppa', 1); - } - - if (bidRequest.schain && hasValidSupplyChainParams(bidRequest.schain)) { - utils.deepSetValue(data, 'source.ext.schain', bidRequest.schain); - } - - const fpd = config.getLegacyFpd(config.getConfig('ortb2')) || {}; - const siteData = Object.assign({}, bidRequest.params.inventory, fpd.context); - const userData = Object.assign({}, bidRequest.params.visitor, fpd.user); - - if (!utils.isEmpty(siteData) || !utils.isEmpty(userData)) { - const bidderData = { - bidders: [ bidderRequest.bidderCode ], - config: { - fpd: {} - } - }; - - if (!utils.isEmpty(siteData)) { - bidderData.config.fpd.site = siteData; - } - - if (!utils.isEmpty(userData)) { - bidderData.config.fpd.user = userData; - } - - utils.deepSetValue(data, 'ext.prebid.bidderconfig.0', bidderData); - } - - const pbAdSlot = utils.deepAccess(bidRequest, 'ortb2Imp.ext.data.pbadslot'); - if (typeof pbAdSlot === 'string' && pbAdSlot) { - utils.deepSetValue(data.imp[0].ext, 'context.data.adslot', pbAdSlot); - } - - return data; -} - -export function hasValidSupplyChainParams(schain) { - let isValid = false; - const requiredFields = ['asi', 'sid', 'hp']; - if (!schain.nodes) return isValid; - isValid = schain.nodes.reduce((status, node) => { - if (!status) return status; - return requiredFields.every(field => node[field]); - }, true); - if (!isValid) utils.logError('LuponMedia: required schain params missing'); - return isValid; -} - -function _getPageUrl(bidRequest, bidderRequest) { - let pageUrl = config.getConfig('pageUrl'); - if (bidRequest.params.referrer) { - pageUrl = bidRequest.params.referrer; - } else if (!pageUrl) { - pageUrl = bidderRequest.refererInfo.referer; - } - return bidRequest.params.secure ? pageUrl.replace(/^http:/i, 'https:') : pageUrl; -} - -function appendSiteAppDevice(data, bidRequest, bidderRequest) { - if (!data) return; - - // ORTB specifies app OR site - if (typeof config.getConfig('app') === 'object') { - data.app = config.getConfig('app'); - } else { - data.site = { - page: _getPageUrl(bidRequest, bidderRequest) - } - } - if (typeof config.getConfig('device') === 'object') { - data.device = config.getConfig('device'); - } -} - -var hasSynced = false; - -export function resetUserSync() { - hasSynced = false; -} - -registerBidder(spec); diff --git a/modules/madvertiseBidAdapter.js b/modules/madvertiseBidAdapter.js deleted file mode 100644 index 4c4217895da..00000000000 --- a/modules/madvertiseBidAdapter.js +++ /dev/null @@ -1,94 +0,0 @@ -import * as utils from '../src/utils.js'; -import {config} from '../src/config.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -// use protocol relative urls for http or https -const MADVERTISE_ENDPOINT = 'https://mobile.mng-ads.com/'; - -export const spec = { - code: 'madvertise', - /** - * @param {object} bid - * @return boolean - */ - isBidRequestValid: function (bid) { - if (typeof bid.params !== 'object') { - return false; - } - let sizes = utils.parseSizesInput(bid.sizes); - if (!sizes || sizes.length === 0) { - return false; - } - if (sizes.length > 0 && sizes[0] === undefined) { - return false; - } - bid.params.floor = 0.01; - - return typeof bid.params.s != 'undefined'; - }, - /** - * @param {BidRequest[]} bidRequests - * @param bidderRequest - * @return ServerRequest[] - */ - buildRequests: function (bidRequests, bidderRequest) { - return bidRequests.map(bidRequest => { - bidRequest.startTime = new Date().getTime(); - - // non-video request builder - var src = '?rt=bid_request&v=1.0'; - - for (var i = 0; i < bidRequest.sizes.length; i++) { - if (Array.isArray(bidRequest.sizes[i]) && bidRequest.sizes[i].length == 2) { - src = src + '&sizes[' + i + ']=' + bidRequest.sizes[i][0] + 'x' + bidRequest.sizes[i][1]; - } - } - - utils._each(bidRequest.params, (item, key) => src = src + '&' + key + '=' + item); - - if (typeof bidRequest.params.u == 'undefined') { - src = src + '&u=' + navigator.userAgent; - } - - if (bidderRequest && bidderRequest.gdprConsent) { - src = src + '&gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? '1' : '0') + '&consent[0][format]=' + config.getConfig('consentManagement.cmpApi') + '&consent[0][value]=' + bidderRequest.gdprConsent.consentString; - } - - return { - method: 'GET', - url: MADVERTISE_ENDPOINT + src, - options: {withCredentials: false}, - bidId: bidRequest.bidId - }; - }); - }, - /** - * @param {*} responseObj - * @param {BidRequest} bidRequest - * @return {Bid[]} An array of bids which - */ - interpretResponse: function (responseObj, bidRequest) { - responseObj = responseObj.body; - // check overall response - if (responseObj == null || typeof responseObj !== 'object' || !responseObj.hasOwnProperty('ad')) { - return []; - } - - let bid = { - requestId: bidRequest.bidId, - cpm: responseObj.cpm, - width: responseObj.Width, - height: responseObj.height, - ad: responseObj.ad, - ttl: responseObj.ttl, - creativeId: responseObj.creativeId, - netRevenue: responseObj.netRevenue, - currency: responseObj.currency, - dealId: responseObj.dealId - }; - return [bid]; - }, - getUserSyncs: function (syncOptions) { - } -}; -registerBidder(spec); diff --git a/modules/mantisBidAdapter.js b/modules/mantisBidAdapter.js deleted file mode 100644 index 61b7c31c8e4..00000000000 --- a/modules/mantisBidAdapter.js +++ /dev/null @@ -1,310 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { getStorageManager } from '../src/storageManager.js'; - -export const storage = getStorageManager(); - -function inIframe() { - try { - return window.self !== window.top && !window.mantis_link; - } catch (e) { - return true; - } -} -function pixel(url, parent) { - var img = document.createElement('img'); - img.src = url; - img.style.cssText = 'display:none !important;'; - (parent || document.body).appendChild(img); -} -export function onVisible(win, element, doOnVisible, time, pct) { - var started = null; - var notified = false; - var onNotVisible = null; - var whenNotVisible = function () { - if (notified && onNotVisible) { - onNotVisible(); - } - notified = false; - }; - var interval; - var listener; - var doCheck = function (winWidth, winHeight, rect) { - var hidden = typeof document.hidden !== 'undefined' && document.hidden; - if (rect.width == 0 || rect.height == 0 || hidden) { - return whenNotVisible(); - } - var minHeight = (rect.height * pct); - var minWidth = (rect.width * pct); - var inView = ( - ( - (rect.top < 0 && rect.bottom >= minHeight) || - (rect.top > 0 && (winHeight - rect.top) >= minHeight) - ) && - ( - (rect.left < 0 && rect.right >= minWidth) || - (rect.left > 0 && (winWidth - rect.left) >= minWidth) - ) - ); - if (!inView) { - return whenNotVisible(); - } - if (!started && time) { - started = Date.now(); - return whenNotVisible(); - } - if (time && Date.now() - started < time) { - return whenNotVisible(); - } - if (notified) { - return; - } - doOnVisible(function (ack) { - if (ack) { - notified = true; - } else { - interval && clearInterval(interval); - listener && listener(); - } - }, function (onHidden) { - onNotVisible = onHidden; - }); - }; - if (isAmp()) { - listener = win.context.observeIntersection(function (changes) { - changes.forEach(function (change) { - doCheck(change.rootBounds.width, change.rootBounds.height, change.boundingClientRect); - }); - }); - } - interval = setInterval(function () { - var winHeight = (win.innerHeight || document.documentElement.clientHeight); - var winWidth = (win.innerWidth || document.documentElement.clientWidth); - doCheck(winWidth, winHeight, element.getBoundingClientRect()); - }, 100); -} -function storeUuid(uuid) { - if (window.mantis_uuid) { - return false; - } - window.mantis_uuid = uuid; - if (storage.hasLocalStorage()) { - try { - storage.setDataInLocalStorage('mantis:uuid', uuid); - } catch (ex) { - } - } -} - -function onMessage(type, callback) { - window.addEventListener('message', function (event) { - if (event.data.mantis && event.data.type == type) { - callback(event.data.data); - } - }, false); -} -function isSendable(val) { - if (val === null || val === undefined) { - return false; - } - if (typeof val === 'string') { - return !(!val || /^\s*$/.test(val)); - } - if (typeof val === 'number') { - return !isNaN(val); - } - return true; -} -function isObject(value) { - return Object.prototype.toString.call(value) === '[object Object]'; -} -function isAmp() { - return typeof window.context === 'object' && (window.context.tagName === 'AMP-AD' || window.context.tagName === 'AMP-EMBED'); -} -function isSecure() { - return document.location.protocol === 'https:'; -} -function isArray(value) { - return Object.prototype.toString.call(value) === '[object Array]'; -} - -function jsonToQuery(data, chain, form) { - var parts = form || []; - for (var key in data) { - var queryKey = key; - if (chain) { - queryKey = chain + '[' + key + ']'; - } - var val = data[key]; - if (isArray(val)) { - for (var index = 0; index < val.length; index++) { - var akey = queryKey + '[' + index + ']'; - var aval = val[index]; - if (isObject(aval)) { - jsonToQuery(aval, akey, parts); - } - } - } else if (isObject(val) && val != data) { - jsonToQuery(val, queryKey, parts); - } else if (isSendable(val)) { - parts.push(queryKey + '=' + encodeURIComponent(val)); - } - } - return parts.join('&'); -} - -function buildMantisUrl(path, data, domain) { - var params = { - referrer: document.referrer, - tz: new Date().getTimezoneOffset(), - buster: new Date().getTime(), - secure: isSecure(), - version: 9 - }; - - if (window.mantis_uuid) { - params.uuid = window.mantis_uuid; - } else if (storage.hasLocalStorage()) { - var localUuid = storage.getDataFromLocalStorage('mantis:uuid'); - if (localUuid) { - params.uuid = localUuid; - } - } - if (!inIframe()) { - try { - params.title = window.top.document.title; - params.referrer = window.top.document.referrer; - params.url = window.top.document.location.href; - } catch (ex) { - } - } else { - params.iframe = true; - } - if (isAmp()) { - params.amp = true; - if (!params.url && window.context.canonicalUrl) { - params.url = window.context.canonicalUrl; - } - if (!params.url && window.context.location) { - params.url = window.context.location.href; - } - if (!params.referrer && window.context.referrer) { - params.referrer = window.context.referrer; - } - } - Object.keys(data).forEach(function (key) { - params[key] = data[key]; - }); - var query = jsonToQuery(params); - return (window.mantis_domain === undefined ? domain || 'https://mantodea.mantisadnetwork.com' : window.mantis_domain) + path + '?' + query; -} - -export const spec = { - code: 'mantis', - supportedMediaTypes: ['banner'], - isBidRequestValid: function (bid) { - return !!(bid.params.property && (bid.params.code || bid.params.zoneId || bid.params.zone)); - }, - buildRequests: function (validBidRequests, bidderRequest) { - var property = null; - validBidRequests.some(function (bid) { - if (bid.params.property) { - property = bid.params.property; - return true; - } - }); - const query = { - measurable: true, - usp: bidderRequest && bidderRequest.uspConsent, - bids: validBidRequests.map(function (bid) { - return { - bidId: bid.bidId, - config: bid.params, - sizes: bid.sizes.map(function (size) { - return {width: size[0], height: size[1]}; - }) - }; - }), - property: property - }; - - if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { - // we purposefully do not track data for users in the EU - query.consent = false; - } - - return { - method: 'GET', - url: buildMantisUrl('/prebid/display', query) + '&foo', - data: '' - }; - }, - interpretResponse: function (serverResponse) { - storeUuid(serverResponse.body.uuid); - return serverResponse.body.ads.map(function (ad) { - return { - requestId: ad.bid, - cpm: ad.cpm, - width: ad.width, - height: ad.height, - ad: ad.html, - meta: { - advertiserDomains: ad.domains || [] - }, - ttl: ad.ttl || serverResponse.body.ttl || 86400, - creativeId: ad.view, - netRevenue: true, - currency: 'USD' - }; - }); - }, - getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: buildMantisUrl('/prebid/iframe', {gdpr: gdprConsent, uspConsent: uspConsent}) - }]; - } - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: buildMantisUrl('/prebid/pixel', {gdpr: gdprConsent, uspConsent: uspConsent}) - }]; - } - } -}; - -export function sfPostMessage ($sf, width, height, callback) { - var viewed = false; - // eslint-disable-next-line no-undef - $sf.ext.register(width, height, function () { - // eslint-disable-next-line no-undef - if ($sf.ext.inViewPercentage() < 50 || viewed) { - return; - } - viewed = true; - callback(); - }); -}; - -export function iframePostMessage (win, name, callback) { - var frames = document.getElementsByTagName('iframe'); - for (var i = 0; i < frames.length; i++) { - var frame = frames[i]; - if (frame.name == name) { - onVisible(win, frame, function (stop) { - callback(); - stop(); - }, 1000, 0.50); - } - } -} - -onMessage('iframe', function (data) { - if (window.$sf) { - sfPostMessage(window.$sf, data.width, data.height, () => pixel(data.pixel)); - } else { - iframePostMessage(window, data.frame, () => pixel(data.pixel)); - } -}); - -registerBidder(spec); diff --git a/modules/meazyBidAdapter.js b/modules/meazyBidAdapter.js deleted file mode 100644 index 9640210cc12..00000000000 --- a/modules/meazyBidAdapter.js +++ /dev/null @@ -1,149 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'meazy'; -const PREBID_ENDPOINT = 'rtb-filter.meazy.co'; -const SYNC_ENDPOINT = 'https://sync.meazy.co/sync/iframe'; -const ENDPOINT_CONFIG = { - defaultCurrency: ['USD'], - availableSize: ['300x250', '320x480', '160x600'] -}; - -const buildURI = (pid) => { - return `https://${PREBID_ENDPOINT}/pbjs?host=${utils.getOrigin()}&api_key=${pid}`; -} - -const validateSize = (size) => { - return ENDPOINT_CONFIG.availableSize.indexOf(size.join('x')) !== -1; -} - -const buildImpression = (bidRequest) => { - const impression = { - id: utils.getUniqueIdentifierStr(), - tagid: bidRequest.adUnitCode, - banner: { - format: bidRequest.sizes.map(size => ({ w: size[0], h: size[1] })) - } - }; - - return impression; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!bid.params.pid && bid.sizes.some(validateSize); - }, - - /** - * 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 payload = { - id: bidRequests[0].bidId, - site: { - domain: utils.getOrigin() - }, - device: { - w: window.screen.width, - h: window.screen.height, - language: navigator.language - }, - cur: ENDPOINT_CONFIG.defaultCurrency, - imp: bidRequests.map(buildImpression), - user: {} - }; - - if (bidderRequest.refererInfo) { - if (bidderRequest.refererInfo.referer) { - payload.site.ref = bidderRequest.refererInfo.referer; - } - - if (utils.isArray(bidderRequest.refererInfo) && bidderRequest.refererInfo.stack.length > 0) { - payload.site.page = bidderRequest.refererInfo.stack[0]; - } - } - - if (utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies')) { - payload.user.ext = { - consent: bidderRequest.gdprConsent.consentString, - gdpr: bidderRequest.gdprConsent.gdprApplies & 1 - } - } - - const payloadString = JSON.stringify(payload); - - return { - method: 'POST', - url: buildURI(bidRequests[0].params.pid), - 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) { - const bids = []; - - if (!utils.isArray(serverResponse.body.seatbid) || !serverResponse.body.seatbid[0]) { - return bids; - } - - serverResponse.body.seatbid[0].bid.forEach(bidResponse => { - const bid = { - requestId: serverResponse.body.id, - cpm: bidResponse.price, - width: bidResponse.w, - height: bidResponse.h, - creativeId: bidResponse.crid, - netRevenue: bidResponse.netRevenue !== undefined ? bidResponse.netRevenue : true, - dealId: bidResponse.dealid, - currency: ENDPOINT_CONFIG.defaultCurrency[0], - ttl: bidResponse.exp || 900, - ad: bidResponse.adm - } - - bids.push(bid); - }); - - return bids; - }, - - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - - if (syncOptions.pixelEnabled && serverResponses[0] && utils.deepAccess(serverResponses[0], 'body.ext.syncUrl')) { - syncs.push({ - type: 'image', - url: serverResponses[0].body.ext.syncUrl - }); - } - - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: SYNC_ENDPOINT - }); - } - - return syncs; - } -} - -registerBidder(spec); diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js deleted file mode 100644 index 022d216a84a..00000000000 --- a/modules/mediagoBidAdapter.js +++ /dev/null @@ -1,375 +0,0 @@ -/** - * gulp serve --modules=mediagoBidAdapter --nolint --notest - */ - -import * as utils from '../src/utils.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { - registerBidder -} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'mediago'; -const PROTOCOL = window.document.location.protocol; -const IS_SECURE = (PROTOCOL === 'https:') ? 1 : 0; -const ENDPOINT_URL = - // ((PROTOCOL === 'https:') ? 'https' : 'http') + - 'https://rtb-us.mediago.io/api/bid?tn='; -const TIME_TO_LIVE = 500; -// const ENDPOINT_URL = '/api/bid?tn='; -const storage = getStorageManager(); -let globals = {}; -let itemMaps = {}; - -/** - * 获取随机id - * @param {number} a random number from 0 to 15 - * @return {string} random number or random string - */ -function getRandomId( - a // placeholder -) { - return a // if the placeholder was passed, return - ? ( // a random number from 0 to 15 - a ^ // unless b is 8, - Math.random() * // in which case - 16 >> // a random number from - a / 4 // 8 to 11 - ).toString(16) // in hexadecimal - : ( // or otherwise a concatenated string: - [1e7] + // 10000000 + - 1e3 + // -1000 + - 4e3 + // -4000 + - 8e3 + // -80000000 + - 1e11 // -100000000000, - ).replace( // replacing - /[018]/g, // zeroes, ones, and eights with - getRandomId // random hex digits - ); -} - -/* ----- mguid:start ------ */ -const COOKIE_KEY_MGUID = '__mguid_'; - -/** - * 获取用户id - * @return {string} - */ -const getUserID = () => { - const i = storage.getCookie(COOKIE_KEY_MGUID); - - if (i === null) { - const uuid = utils.generateUUID(); - storage.setCookie(COOKIE_KEY_MGUID, uuid); - return uuid; - } - return i; -}; - -/* ----- mguid:end ------ */ - -/** - * 获取一个对象的某个值,如果没有则返回空字符串 - * @param {Object} obj 对象 - * @param {...string} keys 键名 - * @return {any} - */ -function getProperty(obj, ...keys) { - let o = obj; - - for (let key of keys) { - // console.log(key, o); - if (o && o[key]) { - o = o[key]; - } else { - return ''; - } - } - return o; -} - -/** - * 是不是移动设备或者平板 - * @return {boolean} - */ -function isMobileAndTablet() { - let check = false; - (function(a) { - let reg1 = new RegExp(['(android|bb\d+|meego)', - '.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)', - '|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone', - '|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap', - '|windows ce|xda|xiino|android|ipad|playbook|silk' - ].join(''), 'i'); - let reg2 = new RegExp(['1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)', - '|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )', - '|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell', - '|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)', - '|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene', - '|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c', - '|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom', - '|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)', - '|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)', - '|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]', - '|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)', - '|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio', - '|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms', - '|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al', - '|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)', - '|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|', - 'v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)', - '|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-', - '|your|zeto|zte\-' - ].join(''), 'i'); - if (reg1.test(a) || - reg2.test(a.substr(0, 4))) { - check = true; - } - })(navigator.userAgent || navigator.vendor || window.opera); - return check; -} - -/** - * 将尺寸转为RTB识别的尺寸 - * - * @param {Array|Object} requestSizes 配置尺寸 - * @return {Object} - */ -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; -} - -/** - * 获取广告位配置 - * @param {Array} validBidRequests an an array of bids - * @param {Object} bidderRequest The master bidRequest object - * @return {Object} - */ -function getItems(validBidRequests, bidderRequest) { - let items = []; - for (let i in validBidRequests) { - let req = validBidRequests[i]; - let ret; - let mediaTypes = getProperty(req, 'mediaTypes'); - - let sizes = transformSizes(getProperty(req, 'sizes')); - let matchSize; - - // 确认尺寸是否符合我们要求 - for (let size of sizes) { - if (size.width === 300 && size.height === 250) { - matchSize = size; - break; - } - } - - // Continue only if there is a matching size - if (matchSize) { - // banner广告类型 - if (mediaTypes.banner) { - let id = '' + (+i + 1); - ret = { - id: id, - // bidFloor: 0, // todo - banner: { - h: matchSize.height, - w: matchSize.width, - pos: 1, - }, - secure: IS_SECURE // for server-side to check if it's secure page - }; - itemMaps[id] = { - req, - ret - }; - } - } - - if (ret) { - items.push(ret); - } - } - - return items; -} - -/** - * 获取rtb请求参数 - * - * @param {Array} validBidRequests an an array of bids - * @param {Object} bidderRequest The master bidRequest object - * @return {Object} - */ -function getParam(validBidRequests, bidderRequest) { - // console.log(validBidRequests, bidderRequest); - let isMobile = isMobileAndTablet() ? 1 : 0; - let isTest = 0; - let auctionId = getProperty(bidderRequest, 'auctionId') || getRandomId(); - let items = getItems(validBidRequests, bidderRequest); - - const domain = document.domain; - const location = utils.deepAccess(bidderRequest, 'refererInfo.referer'); - - if (items && items.length) { - let c = { - 'id': 'mgprebidjs_' + auctionId, - 'test': +isTest, - 'at': 1, - 'cur': ['USD'], - 'device': { - // 'dnt':0, - // 'devicetype':2, - 'js': 1, - 'os': navigator.platform || '', - 'ua': navigator.userAgent, - 'language': /en/.test(navigator.language) ? 'en' : navigator.language, - // 'geo':{ - // 'country':'USA' - // } - }, - 'user': { - 'id': getUserID() // todo - }, - 'site': { - 'name': domain, - 'domain': domain, - 'page': location, - 'ref': location, - 'mobile': isMobile, - 'cat': [], // todo - 'publisher': { // todo - 'id': domain, - 'name': domain - } - }, - 'imp': items - }; - return c; - } else { - return null; - } -} - -export const spec = { - code: BIDDER_CODE, - // aliases: ['ex'], // short code - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - // console.log('mediago', { - // bid - // }); - if (bid.params.token) { - globals['token'] = bid.params.token; - } - return !!(bid.params.token); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {Array} validBidRequests an an array of bids - * @param {Object} bidderRequest The master bidRequest object - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(validBidRequests, bidderRequest) { - let payload = getParam(validBidRequests, bidderRequest); - - // request ad only if there is a matching size - if (payload) { - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: ENDPOINT_URL + globals['token'], - data: payloadString, - }; - } else { - return null; - } - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest) { - const bids = getProperty(serverResponse, 'body', 'seatbid', 0, 'bid'); - const cur = getProperty(serverResponse, 'body', 'cur'); - - const bidResponses = []; - - for (let bid of bids) { - let impid = getProperty(bid, 'impid'); - if (itemMaps[impid]) { - let bidId = getProperty(itemMaps[impid], 'req', 'bidId'); - const bidResponse = { - requestId: bidId, - cpm: getProperty(bid, 'price'), - width: getProperty(bid, 'w'), - height: getProperty(bid, 'h'), - creativeId: getProperty(bid, 'crid'), - dealId: '', - currency: cur, - netRevenue: true, - ttl: TIME_TO_LIVE, - // referrer: REFERER, - ad: getProperty(bid, 'adm') - }; - bidResponses.push(bidResponse); - } - } - - return bidResponses; - }, - - /** - * Register bidder specific code, which will execute if bidder timed out after an auction - * @param {data} Containing timeout specific data - */ - onTimeout: function(data) { - // console.log('onTimeout', data); - // Bidder specifc code - }, - - /** - * Register bidder specific code, which will execute if a bid from this bidder won the auction - * @param {Bid} The bid that won the auction - */ - onBidWon: function(bid) { - // console.log('onBidWon', bid); - // Bidder specific code - }, - - /** - * Register bidder specific code, which will execute when the adserver targeting has been set for a bid from this bidder - * @param {Bid} The bid of which the targeting has been set - */ - onSetTargeting: function(bid) { - // console.log('onSetTargeting', bid); - // Bidder specific code - } -}; -registerBidder(spec); diff --git a/modules/microadBidAdapter.js b/modules/microadBidAdapter.js deleted file mode 100644 index 9611946b495..00000000000 --- a/modules/microadBidAdapter.js +++ /dev/null @@ -1,151 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'microad'; - -const ENDPOINT_URLS = { - 'production': 'https://s-rtb-pb.send.microad.jp/prebid', - 'test': 'https://rtbtest.send.microad.jp/prebid' -}; -export let ENVIRONMENT = 'production'; - -/* eslint-disable no-template-curly-in-string */ -const EXT_URL_STRING = '${COMPASS_EXT_URL}'; -const EXT_REF_STRING = '${COMPASS_EXT_REF}'; -const EXT_IFA_STRING = '${COMPASS_EXT_IFA}'; -const EXT_APPID_STRING = '${COMPASS_EXT_APPID}'; -const EXT_GEO_STRING = '${COMPASS_EXT_GEO}'; -/* eslint-enable no-template-curly-in-string */ - -const BANNER_CODE = 1; -const NATIVE_CODE = 2; -const VIDEO_CODE = 4; - -function createCBT() { - const randomValue = Math.floor(Math.random() * Math.pow(10, 18)).toString(16); - const date = new Date().getTime().toString(16); - return randomValue + date; -} - -function createBitSequenceFromMediaType(hi, code) { - return (hi ? -1 : 0) & code; -} - -function convertMediaTypes(bid) { - return createBitSequenceFromMediaType(bid.mediaTypes.banner, BANNER_CODE) | - createBitSequenceFromMediaType(bid.mediaTypes.native, NATIVE_CODE) | - createBitSequenceFromMediaType(bid.mediaTypes.video, VIDEO_CODE); -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - isBidRequestValid: function(bid) { - return !!(bid && bid.params && bid.params.spot && bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native || bid.mediaTypes.video)); - }, - buildRequests: function(validBidRequests, bidderRequest) { - const requests = []; - - validBidRequests.forEach(bid => { - const bidParams = bid.params; - const params = { - spot: bidParams.spot, - url: bidderRequest.refererInfo.canonicalUrl || window.location.href, - referrer: bidderRequest.refererInfo.referer, - bid_id: bid.bidId, - transaction_id: bid.transactionId, - media_types: convertMediaTypes(bid), - cbt: createCBT() - }; - - if (bidParams.url) { - params['url_macro'] = bidParams.url.replace(EXT_URL_STRING, ''); - } - - if (bidParams.referrer) { - params['referrer_macro'] = bidParams.referrer.replace(EXT_REF_STRING, ''); - } - - if (bidParams.ifa) { - params['ifa'] = bidParams.ifa.replace(EXT_IFA_STRING, ''); - } - - if (bidParams.appid) { - params['appid'] = bidParams.appid.replace(EXT_APPID_STRING, ''); - } - - if (bidParams.geo) { - const geo = bidParams.geo.replace(EXT_GEO_STRING, ''); - if (/^[0-9.\-]+,[0-9.\-]+$/.test(geo)) { - params['geo'] = geo; - } - } - - requests.push({ - method: 'GET', - url: ENDPOINT_URLS[ENVIRONMENT], - data: params, - options: { Accept: 'application/json' } - }); - }); - return requests; - }, - interpretResponse: function(serverResponse) { - const body = serverResponse.body; - const bidResponses = []; - - if (body.cpm && body.cpm > 0) { - const bidResponse = { - requestId: body.requestId, - cpm: body.cpm, - width: body.width, - height: body.height, - ad: body.ad, - ttl: body.ttl, - creativeId: body.creativeId, - netRevenue: body.netRevenue, - currency: body.currency, - }; - - if (body.dealId) { - bidResponse['dealId'] = body.dealId; - } - - bidResponses.push(bidResponse); - } - - return bidResponses; - }, - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - - if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) { - return syncs; - } - - serverResponses.forEach(resp => { - const syncIframeUrls = resp.body.syncUrls.iframe; - const syncImageUrls = resp.body.syncUrls.image; - if (syncOptions.iframeEnabled && syncIframeUrls) { - syncIframeUrls.forEach(syncIframeUrl => { - syncs.push({ - type: 'iframe', - url: syncIframeUrl - }); - }); - } - if (syncOptions.pixelEnabled && syncImageUrls) { - syncImageUrls.forEach(syncImageUrl => { - syncs.push({ - type: 'image', - url: syncImageUrl - }); - }); - } - }); - - return syncs; - } -}; - -registerBidder(spec); diff --git a/modules/missenaBidAdapter.js b/modules/missenaBidAdapter.js deleted file mode 100644 index 2b1d6bdb118..00000000000 --- a/modules/missenaBidAdapter.js +++ /dev/null @@ -1,94 +0,0 @@ -import * as utils from '../src/utils.js'; -import { BANNER } from '../src/mediaTypes.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'missena'; -const ENDPOINT_URL = 'https://bid.missena.io/'; - -export const spec = { - aliases: [BIDDER_CODE], - code: BIDDER_CODE, - gvlid: 687, - supportedMediaTypes: [BANNER], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function (bid) { - return typeof bid == 'object' && !!bid.params.apiKey; - }, - - /** - * 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) { - return validBidRequests.map((bidRequest) => { - const payload = { - request_id: bidRequest.bidId, - timeout: bidderRequest.timeout, - }; - - if (bidderRequest && bidderRequest.refererInfo) { - payload.referer = bidderRequest.refererInfo.referer; - payload.referer_canonical = bidderRequest.refererInfo.canonicalUrl; - } - - if (bidderRequest && bidderRequest.gdprConsent) { - payload.consent_string = bidderRequest.gdprConsent.consentString; - payload.consent_required = bidderRequest.gdprConsent.gdprApplies; - } - - return { - method: 'POST', - url: - ENDPOINT_URL + - '?' + - utils.formatQS({ - t: bidRequest.params.apiKey, - }), - data: JSON.stringify(payload), - }; - }); - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function (serverResponse, bidRequest) { - const bidResponses = []; - const response = serverResponse.body; - - if (response && !response.timeout && !!response.ad) { - bidResponses.push(response); - } - - return bidResponses; - }, - - /** - * Register bidder specific code, which will execute if bidder timed out after an auction - * @param {data} Containing timeout specific data - */ - onTimeout: function onTimeout(timeoutData) { - utils.logInfo('Missena - Timeout from adapter', timeoutData); - }, - - /** - * Register bidder specific code, which@ will execute if a bid from this bidder won the auction - * @param {Bid} The bid that won the auction - */ - onBidWon: function (bid) { - utils.logInfo('Missena - Bid won', bid); - }, -}; - -registerBidder(spec); diff --git a/modules/mobfoxpbBidAdapter.js b/modules/mobfoxpbBidAdapter.js deleted file mode 100644 index c7e96b95179..00000000000 --- a/modules/mobfoxpbBidAdapter.js +++ /dev/null @@ -1,99 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'mobfoxpb'; -const AD_URL = 'https://bes.mobfox.com/?c=o&m=multi'; - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native && bid.native.impressionTrackers); - default: - return false; - } -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); - }, - - buildRequests: (validBidRequests = [], bidderRequest) => { - const winTop = utils.getWindowTop(); - const location = winTop.location; - const placements = []; - const request = { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', - 'secure': 1, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - }; - - if (bidderRequest) { - if (bidderRequest.uspConsent) { - request.ccpa = bidderRequest.uspConsent; - } - if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent - } - } - - const len = validBidRequests.length; - for (let i = 0; i < len; i++) { - const bid = validBidRequests[i]; - const placement = { - placementId: bid.params.placementId, - bidId: bid.bidId, - schain: bid.schain || {}, - }; - const mediaType = bid.mediaTypes - - if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) { - placement.sizes = mediaType[BANNER].sizes; - placement.traffic = BANNER; - } else if (mediaType && mediaType[VIDEO] && mediaType[VIDEO].playerSize) { - placement.wPlayer = mediaType[VIDEO].playerSize[0]; - placement.hPlayer = mediaType[VIDEO].playerSize[1]; - placement.traffic = VIDEO; - } else if (mediaType && mediaType[NATIVE]) { - placement.native = mediaType[NATIVE]; - placement.traffic = NATIVE; - } - placements.push(placement); - } - - return { - method: 'POST', - url: AD_URL, - data: request - }; - }, - - interpretResponse: (serverResponse) => { - let response = []; - for (let i = 0; i < serverResponse.body.length; i++) { - let resItem = serverResponse.body[i]; - if (isBidResponseValid(resItem)) { - response.push(resItem); - } - } - return response; - }, -}; - -registerBidder(spec); diff --git a/modules/mobsmartBidAdapter.js b/modules/mobsmartBidAdapter.js deleted file mode 100644 index e5ff38ec69a..00000000000 --- a/modules/mobsmartBidAdapter.js +++ /dev/null @@ -1,94 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; - -const BIDDER_CODE = 'mobsmart'; -const ENDPOINT = 'https://prebid.mobsmart.net/prebid/endpoint'; - -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function(bid) { - if (bid.bidder !== BIDDER_CODE) { - return false; - } - - return true; - }, - buildRequests: function(validBidRequests, bidderRequest) { - const timeout = config.getConfig('bidderTimeout'); - const referrer = encodeURIComponent(bidderRequest.refererInfo.referer); - - return validBidRequests.map(bidRequest => { - const adUnit = { - code: bidRequest.adUnitCode, - bids: { - bidder: bidRequest.bidder, - params: bidRequest.params - }, - mediaTypes: bidRequest.mediaTypes - }; - - if (bidRequest.hasOwnProperty('sizes') && bidRequest.sizes.length > 0) { - adUnit.sizes = bidRequest.sizes; - } - - const request = { - auctionId: bidRequest.auctionId, - requestId: bidRequest.bidId, - bidRequestsCount: bidRequest.bidRequestsCount, - bidderRequestId: bidRequest.bidderRequestId, - transactionId: bidRequest.transactionId, - referrer: referrer, - timeout: timeout, - adUnit: adUnit - }; - - if (bidRequest.userId && bidRequest.userId.pubcid) { - request.userId = {pubcid: bidRequest.userId.pubcid}; - } - - return { - method: 'POST', - url: ENDPOINT, - data: JSON.stringify(request) - } - }); - }, - interpretResponse: function(serverResponse) { - const bidResponses = []; - - if (serverResponse.body) { - const response = serverResponse.body; - const bidResponse = { - requestId: response.requestId, - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.creativeId, - currency: response.currency, - netRevenue: response.netRevenue, - ttl: response.ttl, - ad: response.ad, - }; - bidResponses.push(bidResponse); - } - - return bidResponses; - }, - getUserSyncs: function(syncOptions, serverResponses) { - let syncs = []; - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: 'https://tags.mobsmart.net/tags/iframe' - }); - } else if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: 'https://tags.mobsmart.net/tags/image' - }); - } - - return syncs; - } -} -registerBidder(spec); diff --git a/modules/nanointeractiveBidAdapter.js b/modules/nanointeractiveBidAdapter.js deleted file mode 100644 index 42a343efc03..00000000000 --- a/modules/nanointeractiveBidAdapter.js +++ /dev/null @@ -1,159 +0,0 @@ -import * as utils from '../src/utils.js'; -import {config} from '../src/config.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const storage = getStorageManager(); - -export const BIDDER_CODE = 'nanointeractive'; -export const END_POINT_URL = 'https://ad.audiencemanager.de'; - -export const SSP_PLACEMENT_ID = 'pid'; -export const NQ = 'nq'; -export const NQ_NAME = 'name'; -export const CATEGORY = 'category'; -export const CATEGORY_NAME = 'categoryName'; -export const SUB_ID = 'subId'; -export const REF = 'ref'; -export const LOCATION = 'loc'; - -var nanoPid = '5a1ec660eb0a191dfa591172'; - -export const spec = { - - code: BIDDER_CODE, - aliases: ['ni'], - - isBidRequestValid(bid) { - const pid = bid.params[SSP_PLACEMENT_ID]; - return !!(pid); - }, - - buildRequests(validBidRequests, bidderRequest) { - let payload = []; - validBidRequests.forEach( - bid => payload.push(createSingleBidRequest(bid, bidderRequest)) - ); - const url = getEndpointUrl() + '/hb'; - - return { - method: 'POST', - url: url, - data: JSON.stringify(payload) - }; - }, - interpretResponse(serverResponse) { - const bids = []; - serverResponse.body.forEach(serverBid => { - if (isEngineResponseValid(serverBid)) { - bids.push(createSingleBidResponse(serverBid)); - } - }); - return bids; - }, - getUserSyncs: function(syncOptions) { - const syncs = []; - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: getEndpointUrl() + '/hb/cookieSync/' + nanoPid - }); - } - - if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: getEndpointUrl() + '/hb/cookieSync/' + nanoPid - }); - } - return syncs; - } - -}; - -function createSingleBidRequest(bid, bidderRequest) { - const location = utils.deepAccess(bidderRequest, 'refererInfo.referer'); - const origin = utils.getOrigin(); - - nanoPid = bid.params[SSP_PLACEMENT_ID] || nanoPid; - - const data = { - [SSP_PLACEMENT_ID]: bid.params[SSP_PLACEMENT_ID], - [NQ]: [createNqParam(bid)], - [CATEGORY]: [createCategoryParam(bid)], - [SUB_ID]: createSubIdParam(bid), - [REF]: createRefParam(), - sizes: bid.sizes.map(value => value[0] + 'x' + value[1]), - bidId: bid.bidId, - cors: origin, - [LOCATION]: location, - lsUserId: getLsUserId() - }; - - if (bidderRequest && bidderRequest.gdprConsent) { - data['gdprConsent'] = bidderRequest.gdprConsent.consentString; - data['gdprApplies'] = (bidderRequest.gdprConsent.gdprApplies) ? '1' : '0'; - } - - return data; -} - -function createSingleBidResponse(serverBid) { - if (serverBid.userId) { - storage.setDataInLocalStorage('lsUserId', serverBid.userId); - } - return { - requestId: serverBid.id, - cpm: serverBid.cpm, - width: serverBid.width, - height: serverBid.height, - ad: serverBid.ad, - ttl: serverBid.ttl, - creativeId: serverBid.creativeId, - netRevenue: serverBid.netRevenue || true, - currency: serverBid.currency - }; -} - -function createNqParam(bid) { - return bid.params[NQ_NAME] ? utils.getParameterByName(bid.params[NQ_NAME]) : bid.params[NQ] || null; -} - -function createCategoryParam(bid) { - return bid.params[CATEGORY_NAME] ? utils.getParameterByName(bid.params[CATEGORY_NAME]) : bid.params[CATEGORY] || null; -} - -function createSubIdParam(bid) { - return bid.params[SUB_ID] || null; -} - -function createRefParam() { - try { - return window.top.document.referrer; - } catch (ex) { - return document.referrer; - } -} - -function isEngineResponseValid(response) { - return !!response.cpm && !!response.ad; -} - -/** - * Used mainly for debugging - * - * @returns string - */ -function getEndpointUrl() { - const nanoConfig = config.getConfig('nano'); - return (nanoConfig && nanoConfig['endpointUrl']) || END_POINT_URL; -} - -function getLsUserId() { - if (storage.getDataFromLocalStorage('lsUserId') != null) { - return storage.getDataFromLocalStorage('lsUserId'); - } - return null; -} - -registerBidder(spec); diff --git a/modules/nasmediaAdmixerBidAdapter.js b/modules/nasmediaAdmixerBidAdapter.js deleted file mode 100644 index fd7a7baa58a..00000000000 --- a/modules/nasmediaAdmixerBidAdapter.js +++ /dev/null @@ -1,85 +0,0 @@ - -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER} from '../src/mediaTypes.js'; - -const ADMIXER_ENDPOINT = 'https://adn.admixer.co.kr:10443/prebid/ad_req'; -const BIDDER_CODE = 'nasmediaAdmixer'; - -const DEFAULT_BID_TTL = 360; -const DEFAULT_CURRENCY = 'USD'; -const DEFAULT_REVENUE = false; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - isBidRequestValid: function (bid) { - return !!(bid && bid.params && bid.params.media_key && bid.params.adunit_id); - }, - - buildRequests: function (validBidRequests, bidderRequest) { - return validBidRequests.map(bid => { - const payload = { - media_key: bid.params.media_key, - adunit_id: bid.params.adunit_id, - req_id: bid.bidId, - referrer: bidderRequest.refererInfo.referer, - os: getOs(), - platform: getPlatform(), - }; - - return { - method: 'GET', - url: ADMIXER_ENDPOINT, - data: payload, - } - }) - }, - - interpretResponse: function (serverResponse, bidRequest) { - const serverBody = serverResponse.body; - const bidResponses = []; - - if (serverBody && serverBody.error_code === 0 && serverBody.body && serverBody.body.length > 0) { - let bidData = serverBody.body[0]; - - const bidResponse = { - ad: bidData.ad, - requestId: serverBody.req_id, - creativeId: bidData.ad_id, - cpm: bidData.cpm, - width: bidData.width, - height: bidData.height, - currency: bidData.currency ? bidData.currency : DEFAULT_CURRENCY, - netRevenue: DEFAULT_REVENUE, - ttl: DEFAULT_BID_TTL - }; - - bidResponses.push(bidResponse); - } - return bidResponses; - } -} - -function getOs() { - let ua = navigator.userAgent; - if (ua.match(/(iPhone|iPod|iPad)/)) { - return 'ios'; - } else if (ua.match(/Android/)) { - return 'android'; - } else if (ua.match(/Window/)) { - return 'windows'; - } else { - return 'etc'; - } -} - -function getPlatform() { - return (isMobile()) ? 'm_web' : 'pc_web'; -} - -function isMobile() { - return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent.toLowerCase()); -} - -registerBidder(spec); diff --git a/modules/nextMillenniumBidAdapter.js b/modules/nextMillenniumBidAdapter.js deleted file mode 100644 index 86da82753b6..00000000000 --- a/modules/nextMillenniumBidAdapter.js +++ /dev/null @@ -1,75 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'nextMillennium'; -const ENDPOINT = 'https://pbs.nextmillmedia.com/openrtb2/auction'; -const TIME_TO_LIVE = 360; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - isBidRequestValid: function(bid) { - return !!( - bid.params.placement_id && utils.isStr(bid.params.placement_id) - ); - }, - - buildRequests: function(validBidRequests) { - let requests = []; - - utils._each(validBidRequests, function(bid) { - requests.push({ - method: 'POST', - url: ENDPOINT, - options: { - contentType: 'application/json', - withCredentials: true - }, - data: JSON.stringify({ - 'ext': { - 'prebid': { - 'storedrequest': { - 'id': utils.getBidIdParameter('placement_id', bid.params) - } - } - } - }), - bidId: bid.bidId - }); - }); - - return requests; - }, - - interpretResponse: function(serverResponse, bidRequest) { - const response = serverResponse.body; - const bidResponses = []; - - try { - utils._each(response.seatbid, (resp) => { - utils._each(resp.bid, (bid) => { - bidResponses.push({ - requestId: bidRequest.bidId, - cpm: bid.price, - width: bid.w, - height: bid.h, - creativeId: bid.adid, - currency: response.cur, - netRevenue: false, - ttl: TIME_TO_LIVE, - meta: { - advertiserDomains: bid.adomain || [] - }, - ad: bid.adm - }); - }); - }) - } catch (err) { - utils.logError(err); - } - return bidResponses; - } -}; -registerBidder(spec); diff --git a/modules/open8BidAdapter.js b/modules/open8BidAdapter.js deleted file mode 100644 index 744cce2b5f9..00000000000 --- a/modules/open8BidAdapter.js +++ /dev/null @@ -1,185 +0,0 @@ -import { Renderer } from '../src/Renderer.js'; -import {ajax} from '../src/ajax.js'; -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'open8'; -const URL = 'https://as.vt.open8.com/v1/control/prebid'; -const AD_TYPE = { - VIDEO: 1, - BANNER: 2 -}; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [VIDEO, BANNER], - - isBidRequestValid: function(bid) { - return !!(bid.params.slotKey); - }, - - buildRequests: function(validBidRequests, bidderRequest) { - var requests = []; - for (var i = 0; i < validBidRequests.length; i++) { - var bid = validBidRequests[i]; - var queryString = ''; - var slotKey = utils.getBidIdParameter('slotKey', bid.params); - queryString = utils.tryAppendQueryString(queryString, 'slot_key', slotKey); - queryString = utils.tryAppendQueryString(queryString, 'imp_id', generateImpId()); - queryString += ('bid_id=' + bid.bidId); - - requests.push({ - method: 'GET', - url: URL, - data: queryString - }); - } - return requests; - }, - - interpretResponse: function(serverResponse, request) { - var bidderResponse = serverResponse.body; - - if (!bidderResponse.isAdReturn) { - return []; - } - - var ad = bidderResponse.ad; - - const bid = { - slotKey: bidderResponse.slotKey, - userId: bidderResponse.userId, - impId: bidderResponse.impId, - media: bidderResponse.media, - ds: ad.ds, - spd: ad.spd, - fa: ad.fa, - pr: ad.pr, - mr: ad.mr, - nurl: ad.nurl, - requestId: ad.bidId, - cpm: ad.price, - creativeId: ad.creativeId, - dealId: ad.dealId, - currency: ad.currency || 'JPY', - netRevenue: true, - ttl: 360, // 6 minutes - } - - if (ad.adType === AD_TYPE.VIDEO) { - const videoAd = bidderResponse.ad.video; - Object.assign(bid, { - vastXml: videoAd.vastXml, - width: videoAd.w, - height: videoAd.h, - renderer: newRenderer(bidderResponse), - adResponse: bidderResponse, - mediaType: VIDEO - }); - } else if (ad.adType === AD_TYPE.BANNER) { - const bannerAd = bidderResponse.ad.banner; - Object.assign(bid, { - width: bannerAd.w, - height: bannerAd.h, - ad: bannerAd.adm, - mediaType: BANNER - }); - if (bannerAd.imps) { - try { - bannerAd.imps.forEach(impTrackUrl => { - const tracker = utils.createTrackPixelHtml(impTrackUrl); - bid.ad += tracker; - }); - } catch (error) { - utils.logError('Error appending imp tracking pixel', error); - } - } - } - return [bid]; - }, - - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - if (syncOptions.iframeEnabled && serverResponses.length) { - const syncIFs = serverResponses[0].body.syncIFs; - if (syncIFs) { - syncIFs.forEach(sync => { - syncs.push({ - type: 'iframe', - url: sync - }); - }); - } - } - if (syncOptions.pixelEnabled && serverResponses.length) { - const syncPixs = serverResponses[0].body.syncPixels; - if (syncPixs) { - syncPixs.forEach(sync => { - syncs.push({ - type: 'image', - url: sync - }); - }); - } - } - return syncs; - }, - onBidWon: function(bid) { - if (!bid.nurl) { return; } - const winUrl = bid.nurl.replace( - /\$\{AUCTION_PRICE\}/, - bid.cpm - ); - ajax(winUrl, null); - } -} - -function generateImpId() { - var l = 16; - var c = 'abcdefghijklmnopqrstuvwsyz0123456789'; - var cl = c.length; - var r = ''; - for (var i = 0; i < l; i++) { - r += c[Math.floor(Math.random() * cl)]; - } - return r; -} - -function newRenderer(bidderResponse) { - const renderer = Renderer.install({ - id: bidderResponse.ad.bidId, - url: bidderResponse.ad.video.purl, - loaded: false, - }); - - try { - renderer.setRender(outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on newRenderer', err); - } - - return renderer; -} - -function outstreamRender(bid) { - bid.renderer.push(() => { - window.op8.renderPrebid({ - vastXml: bid.vastXml, - adUnitCode: bid.adUnitCode, - slotKey: bid.slotKey, - impId: bid.impId, - userId: bid.userId, - media: bid.media, - ds: bid.ds, - spd: bid.spd, - fa: bid.fa, - pr: bid.pr, - mr: bid.mr, - adResponse: bid.adResponse, - mediaType: bid.mediaType - }); - }); -} - -registerBidder(spec); diff --git a/modules/otmBidAdapter.js b/modules/otmBidAdapter.js deleted file mode 100644 index 23f6d434ae1..00000000000 --- a/modules/otmBidAdapter.js +++ /dev/null @@ -1,95 +0,0 @@ -import {BANNER} from '../src/mediaTypes.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -export const spec = { - code: 'otm', - supportedMediaTypes: [BANNER], - isBidRequestValid: function (bid) { - return !!bid.params.tid; - }, - buildRequests: function (bidRequests) { - const requests = bidRequests.map(function (bid) { - const size = getMaxPrioritySize(bid.sizes); - const params = { - tz: getTz(), - w: size[0], - h: size[1], - s: bid.params.tid, - bidid: bid.bidId, - transactionid: bid.transactionId, - auctionid: bid.auctionId, - bidfloor: bid.params.bidfloor - }; - - return {method: 'GET', url: 'https://ssp.otm-r.com/adjson', data: params} - }); - - return requests; - }, - interpretResponse: function (serverResponse, bidRequest) { - if (!serverResponse || !serverResponse.body) { - return []; - } - - const answer = []; - - serverResponse.body.forEach(bid => { - if (bid.ad) { - answer.push({ - requestId: bid.bidid, - cpm: bid.cpm, - width: bid.w, - height: bid.h, - creativeId: bid.creativeid, - currency: bid.currency || 'RUB', - netRevenue: true, - ad: bid.ad, - ttl: bid.ttl, - transactionId: bid.transactionid - }); - } - }); - - return answer; - }, -}; - -function getTz() { - return new Date().getTimezoneOffset(); -} - -function getMaxPrioritySize(sizes) { - var maxPrioritySize = null; - - const sizesByPriority = [ - [300, 250], - [240, 400], - [728, 90], - [300, 600], - [970, 250], - [300, 50], - [320, 100] - ]; - - const sizeToString = (size) => { - return size[0] + 'x' + size[1]; - }; - - const sizesAsString = sizes.map(sizeToString); - - sizesByPriority.forEach(size => { - if (!maxPrioritySize) { - if (sizesAsString.indexOf(sizeToString(size)) !== -1) { - maxPrioritySize = size; - } - } - }); - - if (maxPrioritySize) { - return maxPrioritySize; - } else { - return sizes[0]; - } -} - -registerBidder(spec); diff --git a/modules/outconBidAdapter.js b/modules/outconBidAdapter.js deleted file mode 100644 index 0c3ac90172a..00000000000 --- a/modules/outconBidAdapter.js +++ /dev/null @@ -1,69 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'outcon'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['banner', 'video'], - isBidRequestValid: function(bid) { - return !!((bid.params.pod || (bid.params.internalId && bid.params.publisher)) && bid.params.env); - }, - buildRequests: function(validBidRequests) { - for (let i = 0; i < validBidRequests.length; i++) { - let url = ''; - let par = ''; - if (validBidRequests[i].params.pod != undefined) par = 'get?pod=' + validBidRequests[i].params.pod + '&bidId=' + validBidRequests[i].bidId; - else par = 'get?internalId=' + validBidRequests[i].params.internalId + '&publisher=' + validBidRequests[i].params.publisher + '&bidId=' + validBidRequests[i].bidId; - par = par + '&vast=true'; - switch (validBidRequests[i].params.env) { - case 'test': - par = par + '&demo=true'; - url = 'https://test.outcondigital.com/ad/' + par; - break; - case 'api': - url = 'https://api.outcondigital.com/ad/' + par; - break; - case 'stg': - url = 'https://stg.outcondigital.com/ad/' + par; - break; - } - return { - method: 'GET', - url: url, - data: {} - }; - } - }, - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - const bidResponse = { - requestId: serverResponse.body.bidId, - cpm: serverResponse.body.cpm, - width: serverResponse.body.creatives[0].width, - height: serverResponse.body.creatives[0].height, - creativeId: serverResponse.body.creatives[0].id, - currency: serverResponse.body.cur, - netRevenue: true, - ttl: 300, - ad: wrapDisplayUrl(serverResponse.body.creatives[0].url, serverResponse.body.type), - vastImpUrl: serverResponse.body.trackingURL, - mediaType: serverResponse.body.type - }; - if (serverResponse.body.type == 'video') { - Object.assign(bidResponse, { - vastUrl: serverResponse.body.vastURL, - ttl: 3600 - }); - } - bidResponses.push(bidResponse); - return bidResponses; - }, -} - -function wrapDisplayUrl(displayUrl, type) { - if (type == 'video') return `
`; - if (type == 'banner') return `
`; - return null; -} - -registerBidder(spec); diff --git a/modules/papyrusBidAdapter.js b/modules/papyrusBidAdapter.js deleted file mode 100644 index a27c5cf618a..00000000000 --- a/modules/papyrusBidAdapter.js +++ /dev/null @@ -1,77 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const PAPYRUS_ENDPOINT = 'https://prebid.papyrus.global'; -const PAPYRUS_CODE = 'papyrus'; - -export const spec = { - code: PAPYRUS_CODE, - - /** - * Determines whether or not the given bid request is valid. Valid bid request must have placementId and hbid - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: bid => { - return !!(bid && bid.params && bid.params.address && bid.params.placementId); - }, - - /** - * 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 bidParams = []; - utils._each(validBidRequests, function(bid) { - bidParams.push({ - address: bid.params.address, - placementId: bid.params.placementId, - bidId: bid.bidId, - transactionId: bid.transactionId, - sizes: utils.parseSizesInput(bid.sizes) - }); - }); - - return { - method: 'POST', - url: PAPYRUS_ENDPOINT, - data: bidParams - }; - }, - - /** - * 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, request) { - const bidResponses = []; - - if (serverResponse && serverResponse.body && serverResponse.body.bids) { - serverResponse.body.bids.forEach(bid => { - const bidResponse = { - requestId: bid.id, - creativeId: bid.id, - adId: bid.id, - transactionId: bid.transactionId, - cpm: bid.cpm, - width: bid.width, - height: bid.height, - currency: bid.currency, - netRevenue: true, - ttl: 300, - ad: bid.ad - } - bidResponses.push(bidResponse); - }); - } - - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/performaxBidAdapter.js b/modules/performaxBidAdapter.js deleted file mode 100644 index 8e22a0b2da9..00000000000 --- a/modules/performaxBidAdapter.js +++ /dev/null @@ -1,56 +0,0 @@ -import {logWarn} from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const CLIENT = 'hellboy:v0.0.1' -const BIDDER_CODE = 'performax'; -const BIDDER_SHORT_CODE = 'px'; -const ENDPOINT = 'https://dale.performax.cz/hb'; - -export const spec = { - code: BIDDER_CODE, - aliases: [BIDDER_SHORT_CODE], - - isBidRequestValid: function (bid) { - return !!bid.params.slotId; - }, - - buildUrl: function (validBidRequests, bidderRequest) { - const slotIds = validBidRequests.map(request => request.params.slotId); - let url = [`${ENDPOINT}?slotId[]=${slotIds.join()}`]; - url.push('client=' + CLIENT); - url.push('auctionId=' + bidderRequest.auctionId); - return url.join('&'); - }, - - buildRequests: function (validBidRequests, bidderRequest) { - return { - method: 'POST', - url: this.buildUrl(validBidRequests, bidderRequest), - data: {'validBidRequests': validBidRequests, 'bidderRequest': bidderRequest}, - options: {contentType: 'application/json'}, - } - }, - - buildHtml: function (ad) { - const keys = Object.keys(ad.data || {}); - return ad.code.replace( - new RegExp('\\$(' + keys.join('|') + ')\\$', 'g'), - (matched, key) => ad.data[key] || matched - ); - }, - - interpretResponse: function (serverResponse, request) { - let bidResponses = []; - for (let i = 0; i < serverResponse.body.length; i++) { - const ad = serverResponse.body[i].ad; - if (ad.type === 'empty') { - logWarn(`One of ads is empty (reason=${ad.reason})`); - continue; - } - serverResponse.body[i].ad = this.buildHtml(ad); - bidResponses.push(serverResponse.body[i]); - } - return bidResponses; - } -} -registerBidder(spec); diff --git a/modules/piximediaBidAdapter.js b/modules/piximediaBidAdapter.js deleted file mode 100644 index 2617cc8fe42..00000000000 --- a/modules/piximediaBidAdapter.js +++ /dev/null @@ -1,47 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'piximedia'; -const ENDPOINT = 'https://ad.piximedia.com/prebid'; - -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function(bid) { - return !!(bid.params && bid.params.siteId && bid.params.placementId); - }, - buildRequests: function(validBidRequests) { - return validBidRequests.map(bidRequest => { - let parseSized = utils.parseSizesInput(bidRequest.sizes); - let arrSize = parseSized[0].split('x'); - return { - method: 'GET', - url: ENDPOINT, - data: { - timestamp: utils.timestamp(), - pver: '1.0', - pbparams: JSON.stringify(bidRequest.params), - pbsizes: JSON.stringify(parseSized), - pbwidth: arrSize[0], - pbheight: arrSize[1], - pbbidid: bidRequest.bidId, - }, - }; - }); - }, - interpretResponse: function(serverResponse, request) { - const res = serverResponse.body; - const bidResponse = { - requestId: res.bidId, - cpm: parseFloat(res.cpm), - width: res.width, - height: res.height, - creativeId: res.creative_id, - currency: res.currency, - netRevenue: true, - ttl: 300, - ad: res.adm - }; - return [bidResponse]; - } -} -registerBidder(spec); diff --git a/modules/projectLimeLightBidAdapter.js b/modules/projectLimeLightBidAdapter.js deleted file mode 100644 index 1beba906917..00000000000 --- a/modules/projectLimeLightBidAdapter.js +++ /dev/null @@ -1,122 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import {ajax} from '../src/ajax.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'project-limelight'; - -/** - * Determines whether or not the given bid response is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ -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.vastXml || bid.vastUrl); - } - return false; -} - -export const spec = { - code: BIDDER_CODE, - 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: (bid) => { - return Boolean(bid.bidId && bid.params); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: (validBidRequests, bidderRequest) => { - let winTop; - try { - winTop = window.top; - winTop.location.toString(); - } catch (e) { - utils.logMessage(e); - winTop = window; - } - const placements = utils.groupBy(validBidRequests.map(bidRequest => buildPlacement(bidRequest)), 'host') - return Object.keys(placements) - .map(host => buildRequest(winTop, host, placements[host].map(placement => placement.adUnit))); - }, - - onBidWon: (bid) => { - const cpm = bid.pbMg; - if (bid.nurl !== '') { - bid.nurl = bid.nurl.replace( - /\$\{AUCTION_PRICE\}/, - cpm - ); - ajax(bid.nurl, null); - }; - }, - - /** - * 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 = []; - const bidResponsesBody = bidResponses.body; - const len = bidResponsesBody.length; - for (let i = 0; i < len; i++) { - const bid = bidResponsesBody[i]; - if (isBidResponseValid(bid)) { - res.push(bid); - } - } - return res; - }, -}; - -registerBidder(spec); - -function buildRequest(winTop, host, adUnits) { - return { - method: 'POST', - url: `https://${host}/hb`, - data: { - secure: (location.protocol === 'https:'), - deviceWidth: winTop.screen.width, - deviceHeight: winTop.screen.height, - adUnits: adUnits - } - } -} - -function buildPlacement(bidRequest) { - return { - host: bidRequest.params.host, - adUnit: { - id: bidRequest.params.adUnitId, - bidId: bidRequest.bidId, - transactionId: bidRequest.transactionId, - sizes: bidRequest.sizes.map(size => { - return { - width: size[0], - height: size[1] - } - }), - type: bidRequest.params.adUnitType.toUpperCase() - } - } -} diff --git a/modules/proxistoreBidAdapter.js b/modules/proxistoreBidAdapter.js deleted file mode 100644 index ff07ee9ede9..00000000000 --- a/modules/proxistoreBidAdapter.js +++ /dev/null @@ -1,151 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -const BIDDER_CODE = 'proxistore'; -const PROXISTORE_VENDOR_ID = 418; - -function _createServerRequest(bidRequests, bidderRequest) { - var sizeIds = []; - bidRequests.forEach(function (bid) { - var sizeId = { - id: bid.bidId, - sizes: bid.sizes.map(function (size) { - return { - width: size[0], - height: size[1], - }; - }), - floor: _assignFloor(bid), - segments: _assignSegments(bid), - }; - sizeIds.push(sizeId); - }); - var payload = { - auctionId: bidRequests[0].auctionId, - transactionId: bidRequests[0].auctionId, - bids: sizeIds, - website: bidRequests[0].params.website, - language: bidRequests[0].params.language, - gdpr: { - applies: false, - consentGiven: false - }, - }; - - if (bidderRequest && bidderRequest.gdprConsent) { - const { gdprConsent } = bidderRequest; - if (typeof gdprConsent.gdprApplies === 'boolean' && gdprConsent.gdprApplies) { - payload.gdpr.applies = true; - } - - if (typeof gdprConsent.consentString === 'string' && gdprConsent.consentString) { - payload.gdpr.consentString = bidderRequest.gdprConsent.consentString; - } - if (gdprConsent.vendorData) { - const {vendorData} = gdprConsent; - const {apiVersion} = gdprConsent; - if (apiVersion === 2 && vendorData.vendor && vendorData.vendor.consents && typeof vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined') { - payload.gdpr.consentGiven = !!vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)]; - } else if (apiVersion === 1 && vendorData.vendorConsents && typeof vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined') { - payload.gdpr.consentGiven = !!vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)]; - } - } - } - - const options = { - contentType: 'application/json', - withCredentials: payload.gdpr.consentGiven, - }; - - const endPointUri = payload.gdpr.consentGiven || !payload.gdpr.applies - ? `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi` - : `https://abs.cookieless-proxistore.com/${payload.language}/v3/rtb/prebid/multi`; - - return { - method: 'POST', - url: endPointUri, - data: JSON.stringify(payload), - options: options, - }; -} - -function _assignSegments(bid) { - if (bid.ortb2 && bid.ortb2.user && bid.ortb2.user.ext && bid.ortb2.user.ext.data) { - return bid.ortb2.user.ext.data || {segments: [], contextual_categories: {}}; - } - return {segments: [], contextual_categories: {}}; -} - -function _createBidResponse(response) { - return { - requestId: response.requestId, - cpm: response.cpm, - width: response.width, - height: response.height, - ad: response.ad, - ttl: response.ttl, - creativeId: response.creativeId, - currency: response.currency, - netRevenue: response.netRevenue, - vastUrl: response.vastUrl, - vastXml: response.vastXml, - dealId: response.dealId, - }; -} -/** - * Determines whether or not the given bid request is valid. - * - * @param bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - -function isBidRequestValid(bid) { - return !!(bid.params.website && bid.params.language); -} -/** - * Make a server request from the list of BidRequests. - * - * @param bidRequests - an array of bids - * @param bidderRequest - * @return ServerRequest Info describing the request to the server. - */ - -function buildRequests(bidRequests, bidderRequest) { - var request = _createServerRequest(bidRequests, bidderRequest); - return request; -} -/** - * Unpack the response from the server into a list of bids. - * - * @param serverResponse A successful response from the server. - * @param bidRequest Request original server request - * @return An array of bids which were nested inside the server. - */ - -function interpretResponse(serverResponse, bidRequest) { - return serverResponse.body.map(_createBidResponse); -} - -function _assignFloor(bid) { - if (typeof bid.getFloor === 'function') { - var floorInfo = bid.getFloor({ - currency: 'EUR', - mediaType: 'banner', - size: '*', - }); - - if (floorInfo.currency === 'EUR') { - return floorInfo.floor; - } - } - - return null; -} - -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: isBidRequestValid, - buildRequests: buildRequests, - interpretResponse: interpretResponse, - -}; - -registerBidder(spec); diff --git a/modules/pubxBidAdapter.js b/modules/pubxBidAdapter.js deleted file mode 100644 index 35d75e96f95..00000000000 --- a/modules/pubxBidAdapter.js +++ /dev/null @@ -1,94 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -const BIDDER_CODE = 'pubx'; -const BID_ENDPOINT = 'https://api.primecaster.net/adlogue/api/slot/bid'; -const USER_SYNC_URL = 'https://api.primecaster.net/primecaster_dmppv.html' -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function(bid) { - if (!(bid.params.sid)) { - return false; - } else { return true } - }, - buildRequests: function(validBidRequests) { - return validBidRequests.map(bidRequest => { - const bidId = bidRequest.bidId; - const params = bidRequest.params; - const sid = params.sid; - const payload = { - sid: sid - }; - return { - id: bidId, - method: 'GET', - url: BID_ENDPOINT, - data: payload, - } - }); - }, - interpretResponse: function(serverResponse, bidRequest) { - const body = serverResponse.body; - const bidResponses = []; - if (body.cid) { - const bidResponse = { - requestId: bidRequest.id, - cpm: body.cpm, - currency: body.currency, - width: body.width, - height: body.height, - creativeId: body.cid, - netRevenue: true, - ttl: body.TTL, - ad: body.adm - }; - bidResponses.push(bidResponse); - } else {}; - return bidResponses; - }, - /** - * Determine which user syncs should occur - * @param {object} syncOptions - * @param {array} serverResponses - * @returns {array} User sync pixels - */ - getUserSyncs: function (syncOptions, serverResponses) { - const kwTag = document.getElementsByName('keywords'); - let kwString = ''; - let kwEnc = ''; - let titleContent = !!document.title && document.title; - let titleEnc = ''; - let descContent = !!document.getElementsByName('description') && !!document.getElementsByName('description')[0] && document.getElementsByName('description')[0].content; - let descEnc = ''; - const pageUrl = location.href.replace(/\?.*$/, ''); - const pageEnc = encodeURIComponent(pageUrl); - const refUrl = document.referrer.replace(/\?.*$/, ''); - const refEnc = encodeURIComponent(refUrl); - if (kwTag.length) { - const kwContents = kwTag[0].content; - if (kwContents.length > 20) { - const kwArray = kwContents.substr(0, 20).split(','); - kwArray.pop(); - kwString = kwArray.join(); - } else { - kwString = kwContents; - } - kwEnc = encodeURIComponent(kwString) - } else { } - if (titleContent) { - if (titleContent.length > 30) { - titleContent = titleContent.substr(0, 30); - } else {}; - titleEnc = encodeURIComponent(titleContent); - } else { }; - if (descContent) { - if (descContent.length > 60) { - descContent = descContent.substr(0, 60); - } else {}; - descEnc = encodeURIComponent(descContent); - } else { }; - return (syncOptions.iframeEnabled) ? [{ - type: 'iframe', - url: USER_SYNC_URL + '?pkw=' + kwEnc + '&pd=' + descEnc + '&pu=' + pageEnc + '&pref=' + refEnc + '&pt=' + titleEnc - }] : []; - } -} -registerBidder(spec); diff --git a/modules/reklamstoreBidAdapter.js b/modules/reklamstoreBidAdapter.js deleted file mode 100644 index 3d78cf95978..00000000000 --- a/modules/reklamstoreBidAdapter.js +++ /dev/null @@ -1,148 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'reklamstore'; -const ENDPOINT_URL = 'https://ads.rekmob.com/m/prebid'; -const CURRENCY = 'USD'; -const TIME_TO_LIVE = 360; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function (bid) { - return !!(bid.params.regionId); - }, - /** - * 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) { - const url = bidderRequest.refererInfo.referer; - let requests = []; - utils._each(validBidRequests, function(bid) { - requests.push({ - method: 'GET', - url: ENDPOINT_URL, - data: { - regionId: bid.params.regionId, - dt: getDeviceType(), - os: getOS(), - ref: extractDomain(url), - _: (new Date().getTime()), - mobile_web: 1 - }, - bidId: bid.bidId - }); - }); - return requests; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function (serverResponse, bidRequest) { - try { - const bidResponse = serverResponse.body; - const bidResponses = []; - if (bidResponse) { - bidResponses.push({ - requestId: bidRequest.bidId, - cpm: parseFloat(bidResponse.cpm), - width: bidResponse.w, - height: bidResponse.h, - creativeId: bidResponse.adId || 1, - currency: CURRENCY, - netRevenue: true, - ttl: TIME_TO_LIVE, - ad: bidResponse.ad - }); - } - return bidResponses; - } catch (err) { - utils.logError(err); - return []; - } - }, - /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @return {UserSync[]} The user syncs which should be dropped. - */ - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - utils._each(serverResponses, function(bidResponse) { - utils._each(bidResponse.body.syncs, function(sync) { - if (syncOptions.pixelEnabled && sync.type == 'image') { - syncs.push({ - type: sync.type, - url: sync.url - }); - } else if (syncOptions.iframeEnabled && sync.type == 'iframe') { - syncs.push({ - type: sync.type, - url: sync.url - }); - } - }); - }); - return syncs; - } -} -registerBidder(spec); - -function getDeviceType() { - let PHONE = 0; - let TABLET = 2; - let DESKTOP = 3; - if (isPhone()) { - return PHONE; - } else if (isTablet()) { - return TABLET; - } else { - return DESKTOP; - } -} -function isPhone() { - var check = false; - (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true })(navigator.userAgent || navigator.vendor || window.opera); - return check; -} -function isTablet() { - var check = false; - (function(a) { if (/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(a)) { check = true; } })(navigator.userAgent || navigator.vendor || window.opera); - return check; -} -function getOS() { - var ua = navigator.userAgent; - if (ua.match(/(iPhone|iPod|iPad)/)) { - return '1'; - } else if (ua.match(/Android/)) { - return '0'; - } else { - return '3'; - } -} -function extractDomain(url) { - var domain; - if (url.indexOf('://') > -1) { - domain = url.split('/')[2]; - } else { - domain = url.split('/')[0]; - } - domain = domain.split(':')[0]; - return domain; -} diff --git a/modules/reloadBidAdapter.js b/modules/reloadBidAdapter.js deleted file mode 100644 index 94ea4be281f..00000000000 --- a/modules/reloadBidAdapter.js +++ /dev/null @@ -1,419 +0,0 @@ -import { - registerBidder -} - from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const storage = getStorageManager(); - -const BIDDER_CODE = 'reload'; -const VERSION_ADAPTER = '1.10'; -export const spec = { - code: BIDDER_CODE, - png: {}, - /** - * 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 && bid.params.plcmID && bid.params.partID && 'opdomID' in bid.params && - 'bsrvID' in bid.params && bid.params.bsrvID >= 0 && bid.params.bsrvID <= 99); - }, - /** - * 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 vRequests = []; - let bidReq = { - id: Math.random().toString(10).substring(2), - imp: [] - }; - let vgdprConsent = null; - if (utils.deepAccess(bidderRequest, 'gdprConsent')) { - vgdprConsent = bidderRequest.gdprConsent; - } - let vPrxClientTool = null; - let vSrvUrl = null; - for (let vIdx = 0; vIdx < validBidRequests.length; vIdx++) { - let bidRequest = validBidRequests[vIdx]; - vPrxClientTool = new ReloadClientTool({ - prxVer: VERSION_ADAPTER, - prxType: 'bd', - plcmID: bidRequest.params.plcmID, - partID: bidRequest.params.partID, - opdomID: bidRequest.params.opdomID, - bsrvID: bidRequest.params.bsrvID, - gdprObj: vgdprConsent, - mediaObj: bidRequest.mediaTypes, - wnd: utils.getWindowTop(), - rtop: utils.deepAccess(bidderRequest, 'refererInfo.reachedTop') || false - }); - if (vSrvUrl === null) vSrvUrl = vPrxClientTool.getSrvUrl(); - let vImpression = { - id: bidRequest.bidId, - bidId: bidRequest.bidId, - adUnitCode: bidRequest.adUnitCode, - transactionId: bidRequest.transactionId, - bidderRequestId: bidRequest.bidderRequestId, - auctionId: bidRequest.auctionId, - banner: { - ext: { - type: bidRequest.params.type || 'pcm', - pcmdata: vPrxClientTool.getPCMObj() - } - } - }; - bidReq.imp.push(vImpression); - } - if (bidReq.imp.length > 0) { - const payloadString = JSON.stringify(bidReq); - vRequests.push({ - method: 'POST', - url: vSrvUrl, - data: payloadString - }); - } - return vRequests; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function (serverResponse, bidRequest) { - const serverBody = serverResponse.body; - const bidResponses = []; - for (let vIdx = 0; vIdx < serverBody.seatbid.length; vIdx++) { - let vSeatBid = serverBody.seatbid[vIdx]; - for (let vIdxBid = 0; vIdxBid < vSeatBid.bid.length; vIdxBid++) { - let vBid = vSeatBid.bid[vIdxBid]; - let vPrxClientTool = new ReloadClientTool({ - plcmID: vBid.ext.plcmID, - partID: vBid.ext.partID, - opdomID: vBid.ext.opdomID, - bsrvID: vBid.ext.bsrvID - }); - vPrxClientTool.setPCMObj(vBid.ext.pcmdata); - if (vPrxClientTool.getBP() > 0) { - let bidResponse = { - requestId: vBid.impid, - ad: vPrxClientTool.getAM(), - cpm: vPrxClientTool.getBP() / 100, - width: vPrxClientTool.getW(), - height: vPrxClientTool.getH(), - creativeId: vBid.id, - currency: vPrxClientTool.getBC(), - ttl: 300, - netRevenue: true - }; - bidResponses.push(bidResponse); - this.png[vBid.ext.adUnitCode] = vPrxClientTool.getPingUrl('bidwon'); - } - } - } - return bidResponses; - }, - /** - * Register bidder specific code, which will execute if a bid from this bidder won the auction - * @param {Bid} The bid that won the auction - */ - onBidWon: function (bid) { - if (typeof this.png[bid.adUnitCode] !== 'string' || this.png[bid.adUnitCode] === '') return; - (new Image()).src = this.png[bid.adUnitCode]; - } -}; - -function ReloadClientTool(args) { - var that = this; - var _pcmClientVersion = '120'; - var _pcmFilePref = 'prx_root_'; - var _resFilePref = 'prx_pnws_'; - var _pcmInputObjVers = '120'; - var _instObj = null; - var _status = 'NA'; - var _message = ''; - var _log = ''; - var _memFile = _getMemFile(); - - if (_memFile.status !== 'ok') { - _log += 'WARNING: clnt-int mem file initialized\n'; - } - - that.getPCMObj = function () { - return { - thisVer: _pcmInputObjVers, - statStr: _memFile.statStr, - plcmData: _getPlcmData(), - clntData: _getClientData(args.wnd, args.rtop), - resultData: _getRD(), - gdprObj: _getGdpr(), - mediaObj: _getMediaObj(), - proxetString: null, - dboData: null, - plcmSett: null, - }; - }; - - that.setPCMObj = function (obj) { - if (obj.thisVer !== '100') { - _status = 'error'; - _message = 'incomp_output_obj_version'; - _log += ' ERROR incomp_output_obj_version'; - return; - } - - _status = obj.status; - _message = obj.message; - _log += ' ' + obj.log; - - if (obj.status !== 'ok') return; - - _saveMemFile(obj.statStr, obj.srvUrl); - _instObj = obj.instr; - }; - - that.getSrvUrl = function () { - var effSrvUrl = getBidServerUrl(0); - - if (isNaN(parseInt(args.bsrvID)) !== true) effSrvUrl = getBidServerUrl(parseInt(args.bsrvID)); - - if (typeof _memFile.srvUrl === 'string' && _memFile.srvUrl !== '') effSrvUrl = _memFile.srvUrl; - - return 'https://' + effSrvUrl + '/bid'; - - function getBidServerUrl (idx) { - return 'bidsrv' + getTwoDigitString(idx) + '.reload.net'; - - function getTwoDigitString (idx) { - if (idx >= 10) return '' + idx; - else return '0' + idx; - } - } - }; - - that.getMT = function () { - return _checkInstProp('mtype', 'dsp'); - }; - - that.getW = function () { - return _checkInstProp('width', 0); - }; - - that.getH = function () { - return _checkInstProp('height', 0); - }; - - that.getBP = function () { - return _checkInstProp('prc', 0); - }; - - that.getBC = function () { - return _checkInstProp('cur', 'USD'); - }; - - that.getAM = function () { - return _checkInstProp('am', null); - }; - - that.getPingUrl = function (pingName) { - var pingData = _checkInstProp('pingdata', {}); - if (pingData[pingName] !== 'undefined') return pingData[pingName]; - return ''; - }; - - that.setRD = function (data) { - return _setRD(data); - }; - - that.getStat = function () { - return _status; - }; - - that.getMsg = function () { - return _message; - }; - - that.getLog = function () { - return _log; - }; - - function _checkInstProp (key, def) { - if (_instObj === null) return def; - if (typeof _instObj === 'undefined') return def; - if (_instObj.go !== true) return def; - if (typeof _instObj[key] === 'undefined') return def; - return _instObj[key]; - } - - function _getPlcmData () { - return { - prxVer: args.prxVer, - prxType: args.prxType, - plcmID: args.plcmID, - partID: args.partID, - opdomID: args.opdomID, - bsrvID: args.bsrvID, - dmod: args.dmod, - lmod: args.lmod, - lplcmID: args.lplcmID, - }; - } - - function _getClientData (wnd, rtop) { - return { - version: 200, - locTime: Date.now(), - winInfo: _winInf(wnd), - envInfo: getEnvInfo(), - topw: rtop === true, - prot: wnd.document.location.protocol, - host: wnd.document.location.host, - title: wnd.document.title, - }; - - function _winInf (wnd) { - return { - phs: { - w: wnd.screen.width, - h: wnd.screen.height - }, - avl: { - w: wnd.screen.availWidth, - h: wnd.screen.availHeight - }, - inr: { - w: wnd.innerWidth, - h: wnd.innerHeight - }, - bdy: { - w: wnd.document.body.clientWidth, - h: wnd.document.body.clientHeight - } - }; - } - - function getEnvInfo() { - return { - userAgent: navigator.userAgent, - appName: navigator.appName, - appVersion: navigator.appVersion - }; - } - } - - function _getMemFile () { - try { - var memFileObj = _getItem(_getMemFileName()); - - if (memFileObj === null) throw { s: 'init' }; - - if (typeof memFileObj.statStr !== 'string') throw { s: 'error' }; - if (typeof memFileObj.srvUrl !== 'string') throw { s: 'error' }; - - memFileObj.status = 'ok'; - - return memFileObj; - } catch (err) { - var retObj = { - statStr: null, - srvUrl: null - }; - retObj.status = err.s; - - return retObj; - } - } - - function _saveMemFile (statStr, srvUrl) { - try { - var fileData = { - statStr: statStr, - srvUrl: srvUrl, - }; - _setItem(_getMemFileName(), fileData); - return true; - } catch (err) { - return false; - } - } - - function _getMemFileName () { - return _pcmFilePref + args.plcmID + '_' + args.partID; - } - - function _getRD () { - try { - return _getItem(_getResltStatusFileName()); - } catch (err) { - return null; - } - } - - function _setRD (fileData) { - try { - _setItem(_getResltStatusFileName(), fileData); - return true; - } catch (err) { - return false; - } - } - - function _getGdpr() { - return args.gdprObj; - } - - function _getMediaObj() { - return args.mediaObj; - } - - function _getResltStatusFileName () { - if (args.lmod === true) return _resFilePref + args.lplcmID + '_' + args.partID; - else return _resFilePref + args.plcmID + '_' + args.partID; - } - - function _setItem (name, data) { - var stgFileObj = { - ver: _pcmClientVersion, - ts: Date.now(), - }; - - if (typeof data === 'string') { - stgFileObj.objtype = false; - stgFileObj.memdata = data; - } else { - stgFileObj.objtype = true; - stgFileObj.memdata = JSON.stringify(data); - } - - var stgFileStr = JSON.stringify(stgFileObj); - - storage.setDataInLocalStorage(name, stgFileStr); - - return true; - } - - function _getItem (name) { - try { - var obStgFileStr = storage.getDataFromLocalStorage(name); - if (obStgFileStr === null) return null; - - var stgFileObj = JSON.parse(obStgFileStr); - - if (stgFileObj.ver !== _pcmClientVersion) throw { message: 'version_error' }; - - if (stgFileObj.objtype === true) return JSON.parse(stgFileObj.memdata); - else return '' + stgFileObj.memdata; - } catch (err) { - return null; - } - } -}; - -registerBidder(spec); diff --git a/modules/resultsmediaBidAdapter.js b/modules/resultsmediaBidAdapter.js deleted file mode 100644 index beb9991e1e2..00000000000 --- a/modules/resultsmediaBidAdapter.js +++ /dev/null @@ -1,269 +0,0 @@ -'use strict'; - -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -function ResultsmediaAdapter() { - this.code = 'resultsmedia'; - this.aliases = ['resultsmedia']; - this.supportedMediaTypes = [VIDEO, BANNER]; - - let SUPPORTED_VIDEO_PROTOCOLS = [2, 3, 5, 6]; - let SUPPORTED_VIDEO_MIMES = ['video/mp4']; - let SUPPORTED_VIDEO_PLAYBACK_METHODS = [1, 2, 3, 4]; - let SUPPORTED_VIDEO_DELIVERY = [1]; - let SUPPORTED_VIDEO_API = [1, 2, 5]; - let slotsToBids = {}; - let that = this; - let version = '2.1'; - - this.isBidRequestValid = function (bid) { - return !!(bid.params && bid.params.zoneId); - }; - - this.getUserSyncs = function (syncOptions, responses, gdprConsent) { - return []; - }; - - function frameImp(BRs, bidderRequest) { - var impList = []; - var isSecure = 0; - if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.stack.length) { - // clever trick to get the protocol - var el = document.createElement('a'); - el.href = bidderRequest.refererInfo.stack[0]; - isSecure = (el.protocol == 'https:') ? 1 : 0; - } - for (var i = 0; i < BRs.length; i++) { - slotsToBids[BRs[i].adUnitCode] = BRs[i]; - var impObj = {}; - impObj.id = BRs[i].adUnitCode; - impObj.secure = isSecure; - - if (utils.deepAccess(BRs[i], 'mediaTypes.banner') || utils.deepAccess(BRs[i], 'mediaType') === 'banner') { - let banner = frameBanner(BRs[i]); - if (banner) { - impObj.banner = banner; - } - } - if (utils.deepAccess(BRs[i], 'mediaTypes.video') || utils.deepAccess(BRs[i], 'mediaType') === 'video') { - impObj.video = frameVideo(BRs[i]); - } - if (!(impObj.banner || impObj.video)) { - continue; - } - impObj.ext = frameExt(BRs[i]); - impList.push(impObj); - } - return impList; - } - - function frameSite(bidderRequest) { - var site = { - domain: '', - page: '', - ref: '' - } - if (bidderRequest && bidderRequest.refererInfo) { - var ri = bidderRequest.refererInfo; - site.ref = ri.referer; - - if (ri.stack.length) { - site.page = ri.stack[ri.stack.length - 1]; - - // clever trick to get the domain - var el = document.createElement('a'); - el.href = ri.stack[0]; - site.domain = el.hostname; - } - } - return site; - } - - function frameDevice() { - return { - ua: navigator.userAgent, - ip: '', // Empty Ip string is required, server gets the ip from HTTP header - dnt: utils.getDNT() ? 1 : 0, - } - } - - function getValidSizeSet(dimensionList) { - let w = parseInt(dimensionList[0]); - let h = parseInt(dimensionList[1]); - // clever check for NaN - if (! (w !== w || h !== h)) { // eslint-disable-line - return [w, h]; - } - return false; - } - - function frameBanner(adUnit) { - // adUnit.sizes is scheduled to be deprecated, continue its support but prefer adUnit.mediaTypes.banner - var sizeList = adUnit.sizes; - if (adUnit.mediaTypes && adUnit.mediaTypes.banner) { - sizeList = adUnit.mediaTypes.banner.sizes; - } - var sizeStringList = utils.parseSizesInput(sizeList); - var format = []; - sizeStringList.forEach(function(size) { - if (size) { - var dimensionList = getValidSizeSet(size.split('x')); - if (dimensionList) { - format.push({ - 'w': dimensionList[0], - 'h': dimensionList[1], - }); - } - } - }); - if (format.length) { - return { - 'format': format - }; - } - - return false; - } - - function frameVideo(bid) { - var size = []; - if (utils.deepAccess(bid, 'mediaTypes.video.playerSize')) { - var dimensionSet = bid.mediaTypes.video.playerSize; - if (utils.isArray(bid.mediaTypes.video.playerSize[0])) { - dimensionSet = bid.mediaTypes.video.playerSize[0]; - } - var validSize = getValidSizeSet(dimensionSet) - if (validSize) { - size = validSize; - } - } - return { - mimes: utils.deepAccess(bid, 'mediaTypes.video.mimes') || SUPPORTED_VIDEO_MIMES, - protocols: utils.deepAccess(bid, 'mediaTypes.video.protocols') || SUPPORTED_VIDEO_PROTOCOLS, - w: size[0], - h: size[1], - startdelay: utils.deepAccess(bid, 'mediaTypes.video.startdelay') || 0, - skip: utils.deepAccess(bid, 'mediaTypes.video.skip') || 0, - playbackmethod: utils.deepAccess(bid, 'mediaTypes.video.playbackmethod') || SUPPORTED_VIDEO_PLAYBACK_METHODS, - delivery: utils.deepAccess(bid, 'mediaTypes.video.delivery') || SUPPORTED_VIDEO_DELIVERY, - api: utils.deepAccess(bid, 'mediaTypes.video.api') || SUPPORTED_VIDEO_API, - } - } - - function frameExt(bid) { - return { - bidder: { - zoneId: bid.params['zoneId'] - } - } - } - - function frameBid(BRs, bidderRequest) { - let bid = { - id: BRs[0].bidderRequestId, - imp: frameImp(BRs, bidderRequest), - site: frameSite(bidderRequest), - device: frameDevice(), - user: { - ext: { - consent: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') ? bidderRequest.gdprConsent.consentString : '' - } - }, - at: 1, - tmax: 1000, - regs: { - ext: { - gdpr: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') ? Boolean(bidderRequest.gdprConsent.gdprApplies & 1) : false - } - } - }; - if (BRs[0].schain) { - bid.source = { - 'ext': { - 'schain': BRs[0].schain - } - } - } - return bid; - } - - function getFirstParam(key, validBidRequests) { - for (let i = 0; i < validBidRequests.length; i++) { - if (validBidRequests[i].params && validBidRequests[i].params[key]) { - return validBidRequests[i].params[key]; - } - } - } - - this.buildRequests = function (BRs, bidderRequest) { - let fallbackZoneId = getFirstParam('zoneId', BRs); - if (fallbackZoneId === undefined || BRs.length < 1) { - return []; - } - - var uri = 'https://bid306.rtbsrv.com/bidder/?bid=3mhdom&zoneId=' + fallbackZoneId; - - var fat = /(^v|(\.0)+$)/gi; - var prebidVersion = '$prebid.version$'; - uri += '&hbv=' + prebidVersion.replace(fat, '') + ',' + version.replace(fat, ''); - - var bidRequest = frameBid(BRs, bidderRequest); - if (!bidRequest.imp.length) { - return {}; - } - - return { - method: 'POST', - url: uri, - data: JSON.stringify(bidRequest) - }; - }; - - this.interpretResponse = function (serverResponse) { - let responses = serverResponse.body || []; - let bids = []; - let i = 0; - - if (responses.seatbid) { - let temp = []; - for (i = 0; i < responses.seatbid.length; i++) { - for (let j = 0; j < responses.seatbid[i].bid.length; j++) { - temp.push(responses.seatbid[i].bid[j]); - } - } - responses = temp; - } - - for (i = 0; i < responses.length; i++) { - let bid = responses[i]; - let bidRequest = slotsToBids[bid.impid]; - let bidResponse = { - requestId: bidRequest.id, - bidderCode: that.code, - cpm: parseFloat(bid.price), - width: bid.w, - height: bid.h, - creativeId: bid.crid, - currency: 'USD', - netRevenue: true, - ttl: 350 - }; - - if (bidRequest.mediaTypes && bidRequest.mediaTypes.video) { - bidResponse.vastUrl = bid.adm; - bidResponse.mediaType = 'video'; - bidResponse.ttl = 600; - } else { - bidResponse.ad = bid.adm; - } - bids.push(bidResponse); - } - - return bids; - }; -} - -export const spec = new ResultsmediaAdapter(); -registerBidder(spec); diff --git a/modules/riseBidAdapter.js b/modules/riseBidAdapter.js deleted file mode 100644 index aa1c6cf61bf..00000000000 --- a/modules/riseBidAdapter.js +++ /dev/null @@ -1,251 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import {VIDEO} from '../src/mediaTypes.js'; -import {config} from '../src/config.js'; - -const SUPPORTED_AD_TYPES = [VIDEO]; -const BIDDER_CODE = 'rise'; -const BIDDER_VERSION = '4.0.0'; -const TTL = 360; -const SELLER_ENDPOINT = 'https://hb.yellowblue.io/'; -const MODES = { - PRODUCTION: 'hb', - TEST: 'hb-test' -} -const SUPPORTED_SYNC_METHODS = { - IFRAME: 'iframe', - PIXEL: 'pixel' -} - -export const spec = { - code: BIDDER_CODE, - version: BIDDER_VERSION, - supportedMediaTypes: SUPPORTED_AD_TYPES, - isBidRequestValid: function(bidRequest) { - return !!(bidRequest.params.org); - }, - buildRequests: function (bidRequests, bidderRequest) { - if (bidRequests.length === 0) { - return []; - } - - const requests = []; - - bidRequests.forEach(bid => { - requests.push(buildVideoRequest(bid, bidderRequest)); - }); - - return requests; - }, - interpretResponse: function({body}) { - const bidResponses = []; - - const bidResponse = { - requestId: body.requestId, - cpm: body.cpm, - width: body.width, - height: body.height, - creativeId: body.requestId, - currency: body.currency, - netRevenue: body.netRevenue, - ttl: body.ttl || TTL, - vastXml: body.vastXml, - mediaType: VIDEO - }; - - bidResponses.push(bidResponse); - - return bidResponses; - }, - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - for (const response of serverResponses) { - if (syncOptions.iframeEnabled && response.body.userSyncURL) { - syncs.push({ - type: 'iframe', - url: response.body.userSyncURL - }); - } - if (syncOptions.pixelEnabled && utils.isArray(response.body.userSyncPixels)) { - const pixels = response.body.userSyncPixels.map(pixel => { - return { - type: 'image', - url: pixel - } - }) - syncs.push(...pixels) - } - } - return syncs; - } -}; - -registerBidder(spec); - -/** - * Build the video request - * @param bid {bid} - * @param bidderRequest {bidderRequest} - * @returns {Object} - */ -function buildVideoRequest(bid, bidderRequest) { - const sellerParams = generateParameters(bid, bidderRequest); - const {params} = bid; - return { - method: 'GET', - url: getEndpoint(params.testMode), - data: sellerParams - }; -} - -/** - * Get the the ad size from the bid - * @param bid {bid} - * @returns {Array} - */ -function getSizes(bid) { - if (utils.deepAccess(bid, 'mediaTypes.video.sizes')) { - return bid.mediaTypes.video.sizes[0]; - } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { - return bid.sizes[0]; - } - return []; -} - -/** - * Get schain string value - * @param schainObject {Object} - * @returns {string} - */ -function getSupplyChain(schainObject) { - if (utils.isEmpty(schainObject)) { - return ''; - } - let scStr = `${schainObject.ver},${schainObject.complete}`; - schainObject.nodes.forEach((node) => { - scStr += '!'; - scStr += `${getEncodedValIfNotEmpty(node.asi)},`; - scStr += `${getEncodedValIfNotEmpty(node.sid)},`; - scStr += `${getEncodedValIfNotEmpty(node.hp)},`; - scStr += `${getEncodedValIfNotEmpty(node.rid)},`; - scStr += `${getEncodedValIfNotEmpty(node.name)},`; - scStr += `${getEncodedValIfNotEmpty(node.domain)}`; - }); - return scStr; -} - -/** - * Get encoded node value - * @param val {string} - * @returns {string} - */ -function getEncodedValIfNotEmpty(val) { - return !utils.isEmpty(val) ? encodeURIComponent(val) : ''; -} - -/** - * Get preferred user-sync method based on publisher configuration - * @param bidderCode {string} - * @returns {string} - */ -function getAllowedSyncMethod(filterSettings, bidderCode) { - const iframeConfigsToCheck = ['all', 'iframe']; - const pixelConfigToCheck = 'image'; - if (filterSettings && iframeConfigsToCheck.some(config => isSyncMethodAllowed(filterSettings[config], bidderCode))) { - return SUPPORTED_SYNC_METHODS.IFRAME; - } - if (!filterSettings || !filterSettings[pixelConfigToCheck] || isSyncMethodAllowed(filterSettings[pixelConfigToCheck], bidderCode)) { - return SUPPORTED_SYNC_METHODS.PIXEL; - } -} - -/** - * Check if sync rule is supported - * @param syncRule {Object} - * @param bidderCode {string} - * @returns {boolean} - */ -function isSyncMethodAllowed(syncRule, bidderCode) { - if (!syncRule) { - return false; - } - const isInclude = syncRule.filter === 'include'; - const bidders = utils.isArray(syncRule.bidders) ? syncRule.bidders : [bidderCode]; - return isInclude && utils.contains(bidders, bidderCode); -} - -/** - * Get the seller endpoint - * @param testMode {boolean} - * @returns {string} - */ -function getEndpoint(testMode) { - return testMode - ? SELLER_ENDPOINT + MODES.TEST - : SELLER_ENDPOINT + MODES.PRODUCTION; -} - -/** - * Generate query parameters for the request - * @param bid {bid} - * @param bidderRequest {bidderRequest} - * @returns {Object} - */ -function generateParameters(bid, bidderRequest) { - const timeout = config.getConfig('bidderTimeout'); - const { syncEnabled, filterSettings } = config.getConfig('userSync') || {}; - const [ width, height ] = getSizes(bid); - const { params } = bid; - const { bidderCode } = bidderRequest; - const domain = window.location.hostname; - - const requestParams = { - auction_start: utils.timestamp(), - ad_unit_code: utils.getBidIdParameter('adUnitCode', bid), - tmax: timeout, - width: width, - height: height, - publisher_id: params.org, - floor_price: 0, - ua: navigator.userAgent, - bid_id: utils.getBidIdParameter('bidId', bid), - bidder_request_id: utils.getBidIdParameter('bidderRequestId', bid), - transaction_id: utils.getBidIdParameter('transactionId', bid), - session_id: params.sessionId || utils.getBidIdParameter('auctionId', bid), - is_wrapper: !!params.isWrapper, - publisher_name: domain, - site_domain: domain, - bidder_version: BIDDER_VERSION - }; - - if (syncEnabled) { - const allowedSyncMethod = getAllowedSyncMethod(filterSettings, bidderCode); - if (allowedSyncMethod) { - requestParams.cs_method = allowedSyncMethod; - } - } - - if (bidderRequest.uspConsent) { - requestParams.us_privacy = bidderRequest.uspConsent; - } - - if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { - requestParams.gdpr = bidderRequest.gdprConsent.gdprApplies; - requestParams.gdpr_consent = bidderRequest.gdprConsent.consentString; - } - - if (params.ifa) { - requestParams.ifa = params.ifa; - } - - if (bid.schain) { - requestParams.schain = getSupplyChain(bid.schain); - } - - if (bidderRequest && bidderRequest.refererInfo) { - requestParams.referrer = utils.deepAccess(bidderRequest, 'refererInfo.referer'); - requestParams.page_url = config.getConfig('pageUrl') || utils.deepAccess(window, 'location.href'); - } - - return requestParams; -} diff --git a/modules/rtbsapeBidAdapter.js b/modules/rtbsapeBidAdapter.js deleted file mode 100644 index 8473ef4dbb3..00000000000 --- a/modules/rtbsapeBidAdapter.js +++ /dev/null @@ -1,142 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {OUTSTREAM} from '../src/video.js'; -import {Renderer} from '../src/Renderer.js'; -import {triggerPixel} from '../src/utils.js'; - -const BIDDER_CODE = 'rtbsape'; -const ENDPOINT = 'https://ssp-rtb.sape.ru/prebid'; -const RENDERER_SRC = 'https://cdn-rtb.sape.ru/js/player.js'; -const MATCH_SRC = 'https://www.acint.net/mc/?dp=141'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['sape'], - 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 && bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.video) && bid.params && bid.params.placeId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests an array of bids - * @param bidderRequest - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function (validBidRequests, bidderRequest) { - let tz = (new Date()).getTimezoneOffset() - let padInt = (v) => (v < 10 ? '0' + v : '' + v); - - return { - url: ENDPOINT, - method: 'POST', - data: { - auctionId: bidderRequest.auctionId, - requestId: bidderRequest.bidderRequestId, - bids: validBidRequests, - timezone: (tz > 0 ? '-' : '+') + padInt(Math.floor(Math.abs(tz) / 60)) + ':' + padInt(Math.abs(tz) % 60), - refererInfo: bidderRequest.refererInfo - }, - } - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @param {{data: {bids: [{mediaTypes: {banner: boolean}}]}}} bidRequest Info describing the request to the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function (serverResponse, bidRequest) { - if (!(serverResponse.body && Array.isArray(serverResponse.body.bids))) { - return []; - } - - let bids = {}; - bidRequest.data.bids.forEach(bid => bids[bid.bidId] = bid); - - return serverResponse.body.bids.map(bid => { - let requestBid = bids[bid.requestId]; - let context = utils.deepAccess(requestBid, 'mediaTypes.video.context'); - - if (context === OUTSTREAM && (bid.vastUrl || bid.vastXml)) { - let renderer = Renderer.install({ - id: bid.requestId, - url: RENDERER_SRC, - loaded: false - }); - - let muted = utils.deepAccess(requestBid, 'params.video.playerMuted'); - if (typeof muted === 'undefined') { - muted = true; - } - - bid.playerMuted = muted; - bid.renderer = renderer - - renderer.setRender(setOutstreamRenderer); - } - - return bid; - }); - }, - - /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @return {UserSync[]} The user syncs which should be dropped. - */ - getUserSyncs: function (syncOptions) { - const sync = []; - if (syncOptions.iframeEnabled) { - sync.push({ - type: 'iframe', - url: MATCH_SRC - }); - } - return sync; - }, - - /** - * Register bidder specific code, which will execute if a bid from this bidder won the auction - * @param {Bid} bid The bid that won the auction - */ - onBidWon: function(bid) { - if (bid.nurl) { - triggerPixel(bid.nurl); - } - } -} - -/** - * Initialize RtbSape outstream player - * - * @param bid - */ -function setOutstreamRenderer(bid) { - let props = {}; - if (bid.vastUrl) { - props.url = bid.vastUrl; - } - if (bid.vastXml) { - props.xml = bid.vastXml; - } - bid.renderer.push(() => { - let player = window.sapeRtbPlayerHandler(bid.adUnitCode, bid.width, bid.height, bid.playerMuted, {singleton: true}); - props.onComplete = () => player.destroy(); - props.onError = () => player.destroy(); - player.addSlot(props); - }); -} - -registerBidder(spec); diff --git a/modules/rtbsolutionsBidAdapter.js b/modules/rtbsolutionsBidAdapter.js deleted file mode 100644 index 244ab8a4eba..00000000000 --- a/modules/rtbsolutionsBidAdapter.js +++ /dev/null @@ -1,100 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import { ajax } from '../src/ajax.js'; - -const BIDDER_CODE = 'rtbsolutions'; -const ENDPOINT_URL = 'https://dsp-eu-lb.rtbsolutions.pro/bid/hb'; - -export const spec = { - version: '1.0', - code: BIDDER_CODE, - aliases: ['rtbss'], // short code - nurls: {}, - isBidRequestValid: function(bid) { - return !!bid.params.blockId; - }, - buildRequests: function(validBidRequests, bidderRequest) { - let req = []; - - bidderRequest.bids.forEach(item => { - const width = item.sizes[0][0]; - const height = item.sizes[0][1]; - - let imp = { - referer: bidderRequest.refererInfo.referer, - ua: navigator.userAgent, - lang: this.getLanguage(), - domain: this.getDomain(), - width: width, - height: height, - type: 'banner', - }; - - if (item.params.s1 !== undefined) imp.s1 = item.params.s1; - if (item.params.s2 !== undefined) imp.s2 = item.params.s2; - if (item.params.s3 !== undefined) imp.s3 = item.params.s3; - if (item.params.s4 !== undefined) imp.s4 = item.params.s4; - - req.push({ - bid_id: item.bidId, - block_id: item.params.blockId, - ver: this.version, - imp - }); - }); - - return { - method: 'POST', - url: ENDPOINT_URL, - data: req, - options: { - contentType: 'application/json' - } - } - }, - interpretResponse: function(serverResponse, request) { - const bidResponses = []; - - serverResponse.body.forEach(item => { - this.nurls[item.bid_id] = item.nurl; - - const bidResponse = { - requestId: item.bid_id, - cpm: item.cpm, - width: item.width, - height: item.height, - creativeId: item.creative_id, - currency: item.currency, - netRevenue: true, - ttl: 360, - ad: item.ad, - }; - - bidResponses.push(bidResponse); - }); - - return bidResponses; - }, - onBidWon: function(bid) { - ajax(this.nurls[bid.requestId], null); - }, - - getLanguage() { - const language = navigator.language ? 'language' : 'userLanguage'; - const lang2 = navigator[language].split('-')[0]; - if (lang2.length === 2 || lang2.length === 3) { - return lang2; - } - return ''; - }, - getDomain() { - if (!utils.inIframe()) { - return window.location.hostname - } - let origins = window.document.location.ancestorOrigins; - if (origins && origins.length > 0) { - return origins[origins.length - 1] - } - } -}; -registerBidder(spec); diff --git a/modules/seedingAllianceBidAdapter.js b/modules/seedingAllianceBidAdapter.js deleted file mode 100755 index d85ae856317..00000000000 --- a/modules/seedingAllianceBidAdapter.js +++ /dev/null @@ -1,225 +0,0 @@ -// jshint esversion: 6, es3: false, node: true -'use strict'; - -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { NATIVE } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; -import { config } from '../src/config.js'; - -const BIDDER_CODE = 'seedingAlliance'; -const DEFAULT_CUR = 'EUR'; -const ENDPOINT_URL = 'https://b.nativendo.de/cds/rtb/bid?format=openrtb2.5&ssp=nativendo'; - -const NATIVE_ASSET_IDS = {0: 'title', 1: 'body', 2: 'sponsoredBy', 3: 'image', 4: 'cta', 5: 'icon'}; - -const NATIVE_PARAMS = { - title: { - id: 0, - name: 'title' - }, - - body: { - id: 1, - name: 'data', - type: 2 - }, - - sponsoredBy: { - id: 2, - name: 'data', - type: 1 - }, - - image: { - id: 3, - type: 3, - name: 'img' - }, - - cta: { - id: 4, - type: 12, - name: 'data' - }, - - icon: { - id: 5, - type: 1, - name: 'img' - } -}; - -export const spec = { - code: BIDDER_CODE, - - supportedMediaTypes: [NATIVE], - - isBidRequestValid: function(bid) { - return !!bid.params.adUnitId; - }, - - buildRequests: (validBidRequests, bidderRequest) => { - const pt = setOnAny(validBidRequests, 'params.pt') || setOnAny(validBidRequests, 'params.priceType') || 'net'; - const tid = validBidRequests[0].transactionId; - const cur = [config.getConfig('currency.adServerCurrency') || DEFAULT_CUR]; - let url = bidderRequest.refererInfo.referer; - - const imp = validBidRequests.map((bid, id) => { - const assets = utils._map(bid.nativeParams, (bidParams, key) => { - const props = NATIVE_PARAMS[key]; - - const asset = { - required: bidParams.required & 1 - }; - - if (props) { - asset.id = props.id; - - let w, h; - - if (bidParams.sizes) { - w = bidParams.sizes[0]; - h = bidParams.sizes[1]; - } - - asset[props.name] = { - len: bidParams.len, - type: props.type, - w, - h - }; - - return asset; - } - }) - .filter(Boolean); - - if (bid.params.url) { - url = bid.params.url; - } - - return { - id: String(id + 1), - tagid: bid.params.adUnitId, - tid: tid, - pt: pt, - native: { - request: { - assets - } - } - }; - }); - - const request = { - id: bidderRequest.auctionId, - site: { - page: url - }, - device: { - ua: navigator.userAgent - }, - cur, - imp, - user: {}, - regs: { - ext: { - gdpr: 0 - } - } - }; - - if (bidderRequest && bidderRequest.gdprConsent) { - utils.deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); - utils.deepSetValue(request, 'regs.ext.gdpr', (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean' && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0); - } - - return { - method: 'POST', - url: ENDPOINT_URL, - data: JSON.stringify(request), - options: { - contentType: 'application/json' - }, - bids: validBidRequests - }; - }, - - interpretResponse: function(serverResponse, { bids }) { - if (utils.isEmpty(serverResponse.body)) { - return []; - } - - const { seatbid, cur } = serverResponse.body; - - const bidResponses = flatten(seatbid.map(seat => seat.bid)).reduce((result, bid) => { - result[bid.impid - 1] = bid; - return result; - }, []); - - return bids - .map((bid, id) => { - const bidResponse = bidResponses[id]; - - if (bidResponse) { - return { - requestId: bid.bidId, - cpm: bidResponse.price, - creativeId: bidResponse.crid, - ttl: 1000, - netRevenue: bid.netRevenue === 'net', - currency: cur, - mediaType: NATIVE, - bidderCode: BIDDER_CODE, - native: parseNative(bidResponse) - }; - } - }) - .filter(Boolean); - } -}; - -registerBidder(spec); - -function parseNative(bid) { - const {assets, link, imptrackers} = bid.adm.native; - - link.clicktrackers.forEach(function (clicktracker, index) { - link.clicktrackers[index] = clicktracker.replace(/\$\{AUCTION_PRICE\}/, bid.price); - }); - - imptrackers.forEach(function (imptracker, index) { - imptrackers[index] = imptracker.replace(/\$\{AUCTION_PRICE\}/, bid.price); - }); - - const result = { - url: link.url, - clickUrl: link.url, - clickTrackers: link.clicktrackers || undefined, - impressionTrackers: imptrackers || undefined - }; - - assets.forEach(asset => { - const kind = NATIVE_ASSET_IDS[asset.id]; - const content = kind && asset[NATIVE_PARAMS[kind].name]; - - if (content) { - result[kind] = content.text || content.value || { url: content.url, width: content.w, height: content.h }; - } - }); - - return result; -} - -function setOnAny(collection, key) { - for (let i = 0, result; i < collection.length; i++) { - result = utils.deepAccess(collection[i], key); - if (result) { - return result; - } - } -} - -function flatten(arr) { - return [].concat(...arr); -} diff --git a/modules/segmentoBidAdapter.js b/modules/segmentoBidAdapter.js deleted file mode 100644 index a042bdf4942..00000000000 --- a/modules/segmentoBidAdapter.js +++ /dev/null @@ -1,85 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'segmento'; -const URL = 'https://prebid-bidder.rutarget.ru/bid'; -const SYNC_IFRAME_URL = 'https://tag.rutarget.ru/tag?event=otherPage&check=true&response=syncframe&synconly=true'; -const SYNC_IMAGE_URL = 'https://tag.rutarget.ru/tag?event=otherPage&check=true&synconly=true'; -const RUB = 'RUB'; -const TIME_TO_LIVE = 0; - -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: (bid) => { - return Boolean(bid && bid.params && !isNaN(bid.params.placementId)); - }, - buildRequests: (validBidRequests, bidderRequest) => { - const payload = { - places: [], - settings: { - currency: RUB, - referrer: bidderRequest.refererInfo && bidderRequest.refererInfo.referer - } - }; - - for (let i = 0; i < validBidRequests.length; i++) { - const bid = validBidRequests[i]; - - payload.places.push({ - id: bid.bidId, - placementId: bid.params.placementId, - sizes: bid.sizes - }); - } - - return { - method: 'POST', - url: URL, - data: payload - }; - }, - interpretResponse: (serverResponse) => { - const bids = serverResponse.body && serverResponse.body.bids; - if (!bids) { - return []; - } - - const bidResponses = []; - - for (let i = 0; i < bids.length; i++) { - const bid = bids[i]; - - bidResponses.push({ - requestId: bid.id, - cpm: bid.cpm, - width: bid.size.width, - height: bid.size.height, - creativeId: bid.creativeId, - currency: RUB, - netRevenue: true, - ttl: TIME_TO_LIVE, - adUrl: bid.displayUrl - }); - } - - return bidResponses; - }, - getUserSyncs: (syncOptions) => { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: SYNC_IFRAME_URL - }]; - } - - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: SYNC_IMAGE_URL - }]; - } - - return []; - } -}; - -registerBidder(spec); diff --git a/modules/shinezBidAdapter.js b/modules/shinezBidAdapter.js deleted file mode 100644 index d5734d23fdc..00000000000 --- a/modules/shinezBidAdapter.js +++ /dev/null @@ -1,83 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'shinez'; -const BIDDER_SHORT_CODE = 'shz'; -const ADAPTER_VERSION = '1.0.0'; - -const TARGET_URL = 'https://shinez-ssp.shinez.workers.dev/prebid'; - -export const spec = { - code: BIDDER_CODE, - version: ADAPTER_VERSION, - aliases: { - code: BIDDER_SHORT_CODE - }, - supportedMediaTypes: [ BANNER ], - isBidRequestValid: isBidRequestValid, - buildRequests: buildRequests, - interpretResponse: interpretResponse, -}; - -export const internal = { - TARGET_URL -} - -function isBidRequestValid(bid) { - return !!(bid && bid.params && - bid.params.placementId && typeof bid.params.placementId === 'string' && - (bid.params.unit == null || (typeof bid.params.unit === 'string' && bid.params.unit.length > 0)) - ); -} - -function buildRequests(validBidRequests, bidderRequest) { - const utcOffset = (new Date()).getTimezoneOffset(); - const data = []; - validBidRequests.forEach(function(bidRequest) { - data.push(_buildServerBidRequest(bidRequest, bidderRequest, utcOffset)); - }); - const request = { - method: 'POST', - url: TARGET_URL, - data: data - }; - return request; -} - -function interpretResponse(serverResponse, request) { - const bids = []; - serverResponse.body.forEach(function(serverBid) { - bids.push(_convertServerBid(serverBid)); - }); - return bids; -} - -function _buildServerBidRequest(bidRequest, bidderRequest, utcOffset) { - return { - bidId: bidRequest.bidId, - transactionId: bidRequest.transactionId, - crumbs: bidRequest.crumbs, - mediaTypes: bidRequest.mediaTypes, - refererInfo: bidderRequest.refererInfo, - placementId: bidRequest.params.placementId, - utcOffset: utcOffset, - adUnitCode: bidRequest.adUnitCode, - unit: bidRequest.params.unit - } -} - -function _convertServerBid(response) { - return { - requestId: response.bidId, - cpm: response.cpm, - currency: response.currency, - width: response.width, - height: response.height, - ad: response.ad, - ttl: response.ttl, - creativeId: response.creativeId, - netRevenue: response.netRevenue - }; -} - -registerBidder(spec); diff --git a/modules/slimcutBidAdapter.js b/modules/slimcutBidAdapter.js deleted file mode 100644 index d717f3a88bd..00000000000 --- a/modules/slimcutBidAdapter.js +++ /dev/null @@ -1,128 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { ajax } from '../src/ajax.js'; - -const BIDDER_CODE = 'slimcut'; -const ENDPOINT_URL = 'https://sb.freeskreen.com/pbr'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['scm'], - supportedMediaTypes: ['video', 'banner'], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - let isValid = false; - if (typeof bid.params !== 'undefined' && !isNaN(parseInt(utils.getValue(bid.params, 'placementId'))) && parseInt(utils.getValue(bid.params, 'placementId')) > 0) { - isValid = true; - } - return isValid; - }, - - /** - * 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) { - const bids = validBidRequests.map(buildRequestObject); - const payload = { - referrer: getReferrerInfo(bidderRequest), - data: bids, - deviceWidth: screen.width - }; - - let gdpr = bidderRequest.gdprConsent; - if (bidderRequest && gdpr) { - let isCmp = (typeof gdpr.gdprApplies === 'boolean') - let isConsentString = (typeof gdpr.consentString === 'string') - payload.gdpr_iab = { - consent: isConsentString ? gdpr.consentString : '', - status: isCmp ? gdpr.gdprApplies : -1 - }; - } - - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: ENDPOINT_URL, - 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, request) { - const bidResponses = []; - serverResponse = serverResponse.body; - - if (serverResponse.responses) { - serverResponse.responses.forEach(function (bid) { - const bidResponse = { - cpm: bid.cpm, - width: bid.width, - height: bid.height, - currency: bid.currency, - netRevenue: bid.netRevenue, - ttl: bid.ttl, - ad: bid.ad, - requestId: bid.requestId, - creativeId: bid.creativeId, - transactionId: bid.tranactionId, - winUrl: bid.winUrl - }; - bidResponses.push(bidResponse); - }); - } - return bidResponses; - }, - - getUserSyncs: function(syncOptions, serverResponses) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: 'https://sb.freeskreen.com/async_usersync.html' - }]; - } - return []; - }, - - onBidWon: function(bid) { - ajax(bid.winUrl + bid.cpm, null); - } -} - -function buildRequestObject(bid) { - const reqObj = {}; - let placementId = utils.getValue(bid.params, 'placementId'); - - reqObj.sizes = utils.parseSizesInput(bid.sizes); - reqObj.bidId = utils.getBidIdParameter('bidId', bid); - reqObj.bidderRequestId = utils.getBidIdParameter('bidderRequestId', bid); - reqObj.placementId = parseInt(placementId); - reqObj.adUnitCode = utils.getBidIdParameter('adUnitCode', bid); - reqObj.auctionId = utils.getBidIdParameter('auctionId', bid); - reqObj.transactionId = utils.getBidIdParameter('transactionId', bid); - - return reqObj; -} - -function getReferrerInfo(bidderRequest) { - let ref = window.location.href; - if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - ref = bidderRequest.refererInfo.referer; - } - return ref; -} - -registerBidder(spec); diff --git a/modules/smarticoBidAdapter.js b/modules/smarticoBidAdapter.js deleted file mode 100644 index 9107ce5f908..00000000000 --- a/modules/smarticoBidAdapter.js +++ /dev/null @@ -1,116 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; -import find from 'core-js-pure/features/array/find.js'; - -const SMARTICO_CONFIG = { - bidRequestUrl: 'https://trmads.eu/preBidRequest', - widgetUrl: 'https://trmads.eu/get', - method: 'POST' -} - -const BIDDER_CODE = 'smartico'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - isBidRequestValid: function (bid) { - return !!(bid && bid.params && bid.params.token && bid.params.placementId); - }, - buildRequests: function (validBidRequests, bidderRequest) { - var i - var j - var bid - var bidParam - var bidParams = [] - var sizes - var frameWidth = Math.round(window.screen.width) - var frameHeight = Math.round(window.screen.height) - for (i = 0; i < validBidRequests.length; i++) { - bid = validBidRequests[i] - if (bid.sizes) { - sizes = bid.sizes - } else if (typeof (BANNER) != 'undefined' && bid.mediaTypes && bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { - sizes = bid.mediaTypes[BANNER].sizes - } else if (frameWidth && frameHeight) { - sizes = [[frameWidth, frameHeight]] - } else { - sizes = [] - } - for (j = 0; j < sizes.length; j++) { - bidParam = { - token: bid.params.token || '', - bidId: bid.bidId, - 'banner-format-width': sizes[j][0], - 'banner-format-height': sizes[j][1] - } - if (bid.params.bannerFormat) { - bidParam['banner-format'] = bid.params.bannerFormat - } - if (bid.params.language) { - bidParam.language = bid.params.language - } - if (bid.params.region) { - bidParam.region = bid.params.region - } - if (bid.params.regions && (bid.params.regions instanceof String || (bid.params.regions instanceof Array && bid.params.regions.length))) { - bidParam.regions = bid.params.regions - if (bidParam.regions instanceof Array) { - bidParam.regions = bidParam.regions.join(',') - } - } - bidParams.push(bidParam) - } - } - - var ServerRequestObjects = { - method: SMARTICO_CONFIG.method, - url: SMARTICO_CONFIG.bidRequestUrl, - bids: validBidRequests, - data: {bidParams: bidParams, auctionId: bidderRequest.auctionId, origin: window.location.origin} - } - - return ServerRequestObjects; - }, - interpretResponse: function (serverResponse, bidRequest) { - var i - var bid - var bidObject - var url - var html - var ad - var token - var language - var scriptId - var bidResponses = [] - - for (i = 0; i < serverResponse.length; i++) { - ad = serverResponse[i]; - bid = find(bidRequest.bids, bid => bid.bidId === ad.bidId) - if (bid) { - token = bid.params.token || '' - - language = bid.params.language || SMARTICO_CONFIG.language || '' - - scriptId = encodeURIComponent('smartico-widget-' + bid.params.placementId + '-' + i) - - url = SMARTICO_CONFIG.widgetUrl + '?token=' + encodeURIComponent(token) + '&auction-id=' + encodeURIComponent(bid.auctionId) + '&from-auction-buffer=1&own_session=1&ad=' + encodeURIComponent(ad.id) + '&scriptid=' + scriptId + (ad.bannerFormatAlias ? '&banner-format=' + encodeURIComponent(ad.bannerFormatAlias) : '') + (language ? '&language=' + encodeURIComponent(language) : '') - - html = '
'}, - ] - }, - native: { - ad: '↵ ↵ ↵ ↵ ↵
↵ ', - beacon: '', - cpm: 36.0008, - displaytype: '1', - ids: {}, - location_params: null, - locationid: '58279', - native_ad: { - assets: [ - { - data: { - label: 'accompanying_text', - value: 'AD' - }, - id: 501 - }, - { - data: { - label: 'optout_url', - value: 'https://supership.jp/optout/#' - }, - id: 502 - }, - { - data: { - ext: { - black_back: 'https://i.socdm.com/sdk/img/icon_adg_optout_26x26_white.png', - }, - label: 'information_icon_url', - value: 'https://i.socdm.com/sdk/img/icon_adg_optout_26x26_gray.png', - id: 503 - } - }, - { - id: 1, - required: 1, - title: {text: 'Title'} - }, - { - id: 2, - img: { - h: 250, - url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', - w: 300 - }, - required: 1 - }, - { - id: 3, - img: { - h: 300, - url: 'https://placehold.jp/300x300.png', - w: 300 - }, - required: 1 - }, - { - data: {value: 'Description'}, - id: 5, - required: 0 - }, - { - data: {value: 'CTA'}, - id: 6, - required: 0 - }, - { - data: {value: 'Sponsored'}, - id: 4, - required: 0 - } - ], - imptrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'], - link: { - clicktrackers: [ - 'https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif' - ], - url: 'https://supership.jp' - }, - }, - results: [ - {ad: 'Creative<\/body>'} - ], - rotation: '0', - scheduleid: '512603', - sdktype: '0', - creativeid: '1k2kv35vsa5r', - dealid: 'fd5sa5fa7f', - ttl: 1000 - } - }; - - const bidResponses = { - banner: { - requestId: '2f6ac468a9c15e', - cpm: 36.0008, - width: 320, - height: 100, - creativeId: '1k2kv35vsa5r', - dealId: 'fd5sa5fa7f', - currency: 'JPY', - netRevenue: true, - ttl: 1000, - ad: '
', - }, - native: { - requestId: '2f6ac468a9c15e', - cpm: 36.0008, - width: 1, - height: 1, - creativeId: '1k2kv35vsa5r', - dealId: 'fd5sa5fa7f', - currency: 'JPY', - netRevenue: true, - ttl: 1000, - ad: '↵
', - native: { - title: 'Title', - image: { - url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', - height: 250, - width: 300 - }, - icon: { - url: 'https://placehold.jp/300x300.png', - height: 300, - width: 300 - }, - sponsoredBy: 'Sponsored', - body: 'Description', - cta: 'CTA', - privacyLink: 'https://supership.jp/optout/#', - clickUrl: 'https://supership.jp', - clickTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif'], - impressionTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'] - }, - 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.dealId).to.equal(bidResponses.banner.dealId); - 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.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.width).to.equal(bidResponses.native.width); - expect(result.height).to.equal(bidResponses.native.height); - expect(result.creativeId).to.equal(bidResponses.native.creativeId); - expect(result.dealId).to.equal(bidResponses.native.dealId); - 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.native.title).to.equal(bidResponses.native.native.title); - expect(result.native.image.url).to.equal(bidResponses.native.native.image.url); - expect(result.native.image.height).to.equal(bidResponses.native.native.image.height); - expect(result.native.image.width).to.equal(bidResponses.native.native.image.width); - expect(result.native.icon.url).to.equal(bidResponses.native.native.icon.url); - expect(result.native.icon.width).to.equal(bidResponses.native.native.icon.width); - expect(result.native.icon.height).to.equal(bidResponses.native.native.icon.height); - expect(result.native.sponsoredBy).to.equal(bidResponses.native.native.sponsoredBy); - expect(result.native.body).to.equal(bidResponses.native.native.body); - expect(result.native.cta).to.equal(bidResponses.native.native.cta); - expect(decodeURIComponent(result.native.privacyLink)).to.equal(bidResponses.native.native.privacyLink); - 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]); - expect(result.mediaType).to.equal(bidResponses.native.mediaType); - }); - }); -}); diff --git a/test/spec/modules/adglareBidAdapter_spec.js b/test/spec/modules/adglareBidAdapter_spec.js deleted file mode 100644 index d0dbe891f9d..00000000000 --- a/test/spec/modules/adglareBidAdapter_spec.js +++ /dev/null @@ -1,138 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/adglareBidAdapter.js'; - -describe('AdGlare Adapter Tests', function () { - let bidRequests; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'adglare', - params: { - domain: 'try.engine.adglare.net', - zID: '475579334', - type: 'banner' - }, - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - }, - }, - bidId: '23acc48ad47af5', - auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - - describe('implementation', function () { - describe('for requests', function () { - it('should accept valid bid', function () { - let validBid = { - bidder: 'adglare', - params: { - domain: 'try.engine.adglare.net', - zID: '475579334', - type: 'banner' - } - }, - isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject invalid bid', function () { - let invalidBid = { - bidder: 'adglare', - params: { - domain: 'somedomain.com', - zID: 'not an integer', - type: 'unsupported' - } - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should build a valid endpoint URL', function () { - let bidRequests = [ - { - bidder: 'adglare', - params: { - domain: 'try.engine.adglare.net', - zID: '475579334', - type: 'banner' - }, - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - }, - }, - bidId: '23acc48ad47af5', - auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ], - bidderRequest = { - bidderCode: 'adglare', - auctionID: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - auctionStart: 1581497568252, - timeout: 5000, - refererInfo: { - referer: 'https://www.somedomain.com', - reachedTop: true, - numFrames: 0 - }, - start: 1581497568254 - }, - requests = spec.buildRequests(bidRequests, bidderRequest), - requestURL = requests[0].url; - - expect(requestURL).to.have.string('https://try.engine.adglare.net/?475579334'); - }); - }); - - describe('bid responses', function () { - it('should return complete bid response', function () { - let serverResponse = { - body: { - status: 'OK', - zID: 475579334, - cID: 501658124, - crID: 442123173, - cpm: 1.5, - ttl: 3600, - currency: 'USD', - width: 300, - height: 250, - adhtml: 'I am an ad.' - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(1); - expect(bids[0].bidderCode).to.equal('adglare'); - expect(bids[0].cpm).to.equal(1.5); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(250); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].netRevenue).to.equal(true); - }); - - it('should return empty bid response', function () { - let serverResponse = { - body: { - status: 'NOADS' - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - }); - }); -}); diff --git a/test/spec/modules/adhashBidAdapter_spec.js b/test/spec/modules/adhashBidAdapter_spec.js deleted file mode 100644 index ab4df84c093..00000000000 --- a/test/spec/modules/adhashBidAdapter_spec.js +++ /dev/null @@ -1,155 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/adhashBidAdapter.js'; - -describe('adhashBidAdapter', function () { - describe('isBidRequestValid', function () { - const validBid = { - bidder: 'adhash', - params: { - publisherId: '0xc3b09b27e9c6ef73957901aa729b9e69e5bbfbfb', - platformURL: 'https://adhash.org/p/struma/' - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250]], - bidId: '12345678901234', - bidderRequestId: '98765432109876', - auctionId: '01234567891234', - }; - - it('should return true when all mandatory parameters are there', function () { - expect(spec.isBidRequestValid(validBid)).to.equal(true); - }); - - it('should return false when there are no params', function () { - const bid = { ...validBid }; - delete bid.params; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when unsupported media type is requested', function () { - const bid = { ...validBid }; - bid.mediaTypes = { native: { sizes: [[300, 250]] } }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when publisherId is not a string', function () { - const bid = { ...validBid }; - bid.params.publisherId = 123; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when publisherId is not valid', function () { - const bid = { ...validBid }; - bid.params.publisherId = 'short string'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when publisherId is not a string', function () { - const bid = { ...validBid }; - bid.params.platformURL = 123; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when publisherId is not valid', function () { - const bid = { ...validBid }; - bid.params.platformURL = 'https://'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequest = { - params: { - publisherId: '0xc3b09b27e9c6ef73957901aa729b9e69e5bbfbfb' - }, - sizes: [[300, 250]], - adUnitCode: 'adUnitCode' - }; - it('should build the request correctly', function () { - const result = spec.buildRequests( - [ bidRequest ], - { gdprConsent: true, refererInfo: { referer: 'http://example.com/' } } - ); - expect(result.length).to.equal(1); - expect(result[0].method).to.equal('POST'); - expect(result[0].url).to.equal('https://bidder.adhash.org/rtb?version=1.0&prebid=true'); - expect(result[0].bidRequest).to.equal(bidRequest); - expect(result[0].data).to.have.property('timezone'); - expect(result[0].data).to.have.property('location'); - expect(result[0].data).to.have.property('publisherId'); - expect(result[0].data).to.have.property('size'); - expect(result[0].data).to.have.property('navigator'); - expect(result[0].data).to.have.property('creatives'); - expect(result[0].data).to.have.property('blockedCreatives'); - expect(result[0].data).to.have.property('currentTimestamp'); - expect(result[0].data).to.have.property('recentAds'); - }); - it('should build the request correctly without referer', function () { - const result = spec.buildRequests([ bidRequest ], { gdprConsent: true }); - expect(result.length).to.equal(1); - expect(result[0].method).to.equal('POST'); - expect(result[0].url).to.equal('https://bidder.adhash.org/rtb?version=1.0&prebid=true'); - expect(result[0].bidRequest).to.equal(bidRequest); - expect(result[0].data).to.have.property('timezone'); - expect(result[0].data).to.have.property('location'); - expect(result[0].data).to.have.property('publisherId'); - expect(result[0].data).to.have.property('size'); - expect(result[0].data).to.have.property('navigator'); - expect(result[0].data).to.have.property('creatives'); - expect(result[0].data).to.have.property('blockedCreatives'); - expect(result[0].data).to.have.property('currentTimestamp'); - expect(result[0].data).to.have.property('recentAds'); - }); - }); - - describe('interpretResponse', function () { - const request = { - data: { some: 'data' }, - bidRequest: { - bidId: '12345678901234', - adUnitCode: 'adunit-code', - sizes: [[300, 250]], - params: { - platformURL: 'https://adhash.org/p/struma/' - } - } - }; - - it('should interpret the response correctly', function () { - const serverResponse = { - body: { - creatives: [{ - costEUR: 1.234 - }] - } - }; - const result = spec.interpretResponse(serverResponse, request); - expect(result.length).to.equal(1); - expect(result[0].requestId).to.equal('12345678901234'); - expect(result[0].cpm).to.equal(1.234); - expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(250); - expect(result[0].creativeId).to.equal('adunit-code'); - expect(result[0].netRevenue).to.equal(true); - expect(result[0].currency).to.equal('EUR'); - expect(result[0].ttl).to.equal(60); - }); - - it('should return empty array when there are no creatives returned', function () { - expect(spec.interpretResponse({body: {creatives: []}}, request).length).to.equal(0); - }); - - it('should return empty array when there is no creatives key in the response', function () { - expect(spec.interpretResponse({body: {}}, request).length).to.equal(0); - }); - - it('should return empty array when something is not right', function () { - expect(spec.interpretResponse(null, request).length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/adheseBidAdapter_spec.js b/test/spec/modules/adheseBidAdapter_spec.js deleted file mode 100644 index 526102c51fe..00000000000 --- a/test/spec/modules/adheseBidAdapter_spec.js +++ /dev/null @@ -1,509 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/adheseBidAdapter.js'; - -const BID_ID = 456; -const TTL = 360; -const NET_REVENUE = true; - -let minimalBid = function() { - return { - 'bidId': BID_ID, - 'bidder': 'adhese', - 'params': { - account: 'demo', - location: '_main_page_', - format: 'leaderboard' - } - } -}; - -let bidWithParams = function(data) { - let bid = minimalBid(); - bid.params.data = data; - return bid; -}; - -describe('AdheseAdapter', function () { - describe('getUserSyncs', function () { - const serverResponses = [{ - account: 'demo' - }]; - const gdprConsent = { - gdprApplies: true, - consentString: 'CONSENT_STRING' - }; - it('should return empty when iframe disallowed', function () { - expect(spec.getUserSyncs({ iframeEnabled: false }, serverResponses, gdprConsent)).to.be.empty; - }); - it('should return empty when no serverResponses present', function () { - expect(spec.getUserSyncs({ iframeEnabled: true }, [], gdprConsent)).to.be.empty; - }); - it('should return empty when no account info present in the response', function () { - expect(spec.getUserSyncs({ iframeEnabled: true }, [{}], gdprConsent)).to.be.empty; - }); - it('should return usersync url when iframe allowed', function () { - expect(spec.getUserSyncs({ iframeEnabled: true }, serverResponses, gdprConsent)).to.deep.equal([{ type: 'iframe', url: 'https://user-sync.adhese.com/iframe/user_sync.html?account=demo&gdpr=1&consentString=CONSENT_STRING' }]); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(minimalBid())).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, minimalBid()); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'CONSENT_STRING' - }, - refererInfo: { - referer: 'http://prebid.org/dev-docs/subjects?_d=1' - } - }; - - it('should include requested slots', function () { - let req = spec.buildRequests([ minimalBid() ], bidderRequest); - - expect(JSON.parse(req.data).slots[0].slotname).to.equal('_main_page_-leaderboard'); - }); - - it('should include all extra bid params', function () { - let req = spec.buildRequests([ bidWithParams({ 'ag': '25' }) ], bidderRequest); - - expect(JSON.parse(req.data).slots[0].parameters).to.deep.include({ 'ag': [ '25' ] }); - }); - - it('should assign bid params per slot', function () { - let req = spec.buildRequests([ bidWithParams({ 'ag': '25' }), bidWithParams({ 'ag': '25', 'ci': 'gent' }) ], bidderRequest); - - expect(JSON.parse(req.data).slots[0].parameters).to.deep.include({ 'ag': [ '25' ] }).and.not.to.deep.include({ 'ci': [ 'gent' ] }); - expect(JSON.parse(req.data).slots[1].parameters).to.deep.include({ 'ag': [ '25' ] }).and.to.deep.include({ 'ci': [ 'gent' ] }); - }); - - it('should split multiple target values', function () { - let req = spec.buildRequests([ bidWithParams({ 'ci': 'london' }), bidWithParams({ 'ci': 'gent' }) ], bidderRequest); - - expect(JSON.parse(req.data).slots[0].parameters).to.deep.include({ 'ci': [ 'london' ] }); - expect(JSON.parse(req.data).slots[1].parameters).to.deep.include({ 'ci': [ 'gent' ] }); - }); - - it('should filter out empty params', function () { - let req = spec.buildRequests([ bidWithParams({ 'aa': [], 'bb': null, 'cc': '', 'dd': [ '', '' ], 'ee': [ 0, 1, null ], 'ff': 0, 'gg': [ 'x', 'y', '' ] }) ], bidderRequest); - - let params = JSON.parse(req.data).slots[0].parameters; - expect(params).to.not.have.any.keys('aa', 'bb', 'cc', 'dd'); - expect(params).to.deep.include({ 'ee': [ 0, 1 ], 'ff': [ 0 ], 'gg': [ 'x', 'y' ] }); - }); - - it('should include gdpr consent param', function () { - let req = spec.buildRequests([ minimalBid() ], bidderRequest); - - expect(JSON.parse(req.data).parameters).to.deep.include({ 'xt': [ 'CONSENT_STRING' ] }); - }); - - it('should include referer param in base64url format', function () { - let req = spec.buildRequests([ minimalBid() ], bidderRequest); - - expect(JSON.parse(req.data).parameters).to.deep.include({ 'xf': [ 'aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc3ViamVjdHM_X2Q9MQ' ] }); - }); - - it('should include eids', function () { - let bid = minimalBid(); - bid.userIdAsEids = [{ source: 'id5-sync.com', uids: [{ id: 'ID5@59sigaS-...' }] }]; - - let req = spec.buildRequests([ bid ], bidderRequest); - - expect(JSON.parse(req.data).user.ext.eids).to.deep.equal(bid.userIdAsEids); - }); - - it('should not include eids field when userid module disabled', function () { - let req = spec.buildRequests([ minimalBid() ], bidderRequest); - - expect(JSON.parse(req.data)).to.not.have.key('eids'); - }); - - it('should request vast content as url', function () { - let req = spec.buildRequests([ minimalBid() ], bidderRequest); - - expect(JSON.parse(req.data).vastContentAsUrl).to.equal(true); - }); - - it('should include bids', function () { - let bid = minimalBid(); - let req = spec.buildRequests([ bid ], bidderRequest); - - expect(req.bids).to.deep.equal([ bid ]); - }); - - it('should make a POST request', function () { - let req = spec.buildRequests([ minimalBid() ], bidderRequest); - - expect(req.method).to.equal('POST'); - }); - - it('should request the json endpoint', function () { - let req = spec.buildRequests([ minimalBid() ], bidderRequest); - - expect(req.url).to.equal('https://ads-demo.adhese.com/json'); - }); - }); - - describe('interpretResponse', () => { - let bidRequest = { - bids: [ minimalBid() ] - }; - - it('should get correct ssp banner response', () => { - let sspBannerResponse = { - body: [ - { - origin: 'APPNEXUS', - originInstance: '', - ext: 'js', - slotID: '10', - slotName: '_main_page_-leaderboard', - adType: 'leaderboard', - originData: { - seatbid: [{ - bid: [{ - crid: '60613369', - dealid: null - }], - seat: '958' - }] - }, - width: '728', - height: '90', - body: '
', - tracker: 'https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a', - impressionCounter: 'https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a', - extension: {'prebid': {'cpm': {'amount': '1.000000', 'currency': 'USD'}}, mediaType: 'banner'} - } - ] - }; - - let expectedResponse = [{ - requestId: BID_ID, - ad: '
', - cpm: 1, - currency: 'USD', - creativeId: '60613369', - dealId: '', - width: 728, - height: 90, - mediaType: 'banner', - netRevenue: NET_REVENUE, - ttl: TTL, - adhese: { - origin: 'APPNEXUS', - originInstance: '', - originData: { - adType: 'leaderboard', - seatbid: [ - { - bid: [ { crid: '60613369', dealid: null } ], - seat: '958' - } - ], - slotId: '10', - slotName: '_main_page_-leaderboard' - } - } - }]; - expect(spec.interpretResponse(sspBannerResponse, bidRequest)).to.deep.equal(expectedResponse); - }); - - it('should get correct ssp video response', () => { - let sspVideoResponse = { - body: [ - { - origin: 'RUBICON', - ext: 'js', - slotName: '_main_page_-leaderboard', - adType: 'leaderboard', - width: '640', - height: '350', - body: '', - extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}, mediaType: 'video'} - } - ] - }; - - let expectedResponse = [{ - requestId: BID_ID, - vastXml: '', - cpm: 2.1, - currency: 'USD', - creativeId: 'RUBICON', - dealId: '', - width: 640, - height: 350, - mediaType: 'video', - netRevenue: NET_REVENUE, - ttl: TTL, - adhese: { - origin: 'RUBICON', - originInstance: '', - originData: {} - } - }]; - expect(spec.interpretResponse(sspVideoResponse, bidRequest)).to.deep.equal(expectedResponse); - }); - - it('should get correct ssp cache video response', () => { - let sspCachedVideoResponse = { - body: [ - { - origin: 'RUBICON', - ext: 'js', - slotName: '_main_page_-leaderboard', - adType: 'leaderboard', - width: '640', - height: '350', - cachedBodyUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3', - extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}, mediaType: 'video'} - } - ] - }; - - let expectedResponse = [{ - requestId: BID_ID, - vastUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3', - cpm: 2.1, - currency: 'USD', - creativeId: 'RUBICON', - dealId: '', - width: 640, - height: 350, - mediaType: 'video', - netRevenue: NET_REVENUE, - ttl: TTL, - adhese: { - origin: 'RUBICON', - originInstance: '', - originData: {} - } - }]; - expect(spec.interpretResponse(sspCachedVideoResponse, bidRequest)).to.deep.equal(expectedResponse); - }); - - it('should get correct Adhese banner response', () => { - const adheseBannerResponse = { - body: [ - { - adType: 'largeleaderboard', // it can differ from the requested slot - adFormat: 'largeleaderboard', - timeStamp: '1544009030000', - orderId: '22051', - adspaceId: '162363', - body: '', - tag: '', - tracker: 'https://hosts-demo.adhese.com/track/tracker', - altText: '', - height: '150', - width: '840', - tagUrl: 'https://pool-demo.adhese.com/pool/lib/90511.js', - libId: '90511', - id: '742898', - advertiserId: '2081', - ext: 'js', - url: 'https://hosts-demo.adhese.com/raylene/url', - clickTag: 'https://hosts-demo.adhese.com/raylene/clickTag', - poolPath: 'https://hosts-demo.adhese.com/pool/lib/', - orderName: 'Luminus boiler comodity-Pareto -201812', - creativeName: 'nl_demo _network_ron_dlbd_840x150_fix_dir_asv_std_dis_brd_nrt_na_red', - slotName: '_main_page_-leaderboard', - slotID: '29306', - impressionCounter: 'https://hosts-demo.adhese.com/track/742898', - origin: 'JERLICIA', - originData: {}, - auctionable: true, - extension: { - prebid: { - cpm: { - amount: '5.96', - currency: 'USD' - } - }, - mediaType: 'banner' - } - } - ] - }; - - let expectedResponse = [{ - requestId: BID_ID, - ad: '', - adhese: { - origin: '', - originInstance: '', - originData: { - adFormat: 'largeleaderboard', - adId: '742898', - adType: 'largeleaderboard', - adspaceId: '162363', - libId: '90511', - orderProperty: undefined, - priority: undefined, - viewableImpressionCounter: undefined, - slotId: '29306', - slotName: '_main_page_-leaderboard', - advertiserId: '2081' - } - }, - cpm: 5.96, - currency: 'USD', - creativeId: '742898', - dealId: '22051', - width: 840, - height: 150, - mediaType: 'banner', - netRevenue: NET_REVENUE, - ttl: TTL, - }]; - expect(spec.interpretResponse(adheseBannerResponse, bidRequest)).to.deep.equal(expectedResponse); - }); - - it('should get correct Adhese video response', () => { - const adheseVideoResponse = { - body: [ - { - adType: 'preroll', - adFormat: '', - orderId: '22248', - adspaceId: '164196', - body: '', - height: '360', - width: '640', - tag: "", - libId: '89860', - id: '742470', - advertiserId: '2263', - ext: 'advar', - orderName: 'Smartphoto EOY-20181112', - creativeName: 'PREROLL', - slotName: '_main_page_-leaderboard', - slotID: '41711', - impressionCounter: 'https://hosts-demo.adhese.com/track/742898', - origin: 'JERLICIA', - originData: {}, - auctionable: true, - extension: { - mediaType: 'video' - } - } - ] - }; - - let expectedResponse = [{ - requestId: BID_ID, - vastXml: '', - adhese: { - origin: '', - originInstance: '', - originData: { - adFormat: '', - adId: '742470', - adType: 'preroll', - adspaceId: '164196', - libId: '89860', - orderProperty: undefined, - priority: undefined, - viewableImpressionCounter: undefined, - slotId: '41711', - slotName: '_main_page_-leaderboard', - advertiserId: '2263', - } - }, - cpm: 0, - currency: 'USD', - creativeId: '742470', - dealId: '22248', - width: 640, - height: 360, - mediaType: 'video', - netRevenue: NET_REVENUE, - ttl: TTL, - }]; - expect(spec.interpretResponse(adheseVideoResponse, bidRequest)).to.deep.equal(expectedResponse); - }); - - it('should get correct Adhese cached video response', () => { - const adheseVideoResponse = { - body: [ - { - adType: 'preroll', - adFormat: '', - orderId: '22248', - adspaceId: '164196', - body: '', - height: '360', - width: '640', - extension: { - mediaType: 'video' - }, - cachedBodyUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3', - libId: '89860', - id: '742470', - advertiserId: '2263', - ext: 'advar', - orderName: 'Smartphoto EOY-20181112', - creativeName: 'PREROLL', - slotName: '_main_page_-leaderboard', - slotID: '41711', - impressionCounter: 'https://hosts-demo.adhese.com/track/742898', - origin: 'JERLICIA', - originData: {}, - auctionable: true - } - ] - }; - - let expectedResponse = [{ - requestId: BID_ID, - vastUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3', - adhese: { - origin: '', - originInstance: '', - originData: { - adFormat: '', - adId: '742470', - adType: 'preroll', - adspaceId: '164196', - libId: '89860', - orderProperty: undefined, - priority: undefined, - viewableImpressionCounter: undefined, - slotId: '41711', - slotName: '_main_page_-leaderboard', - advertiserId: '2263', - } - }, - cpm: 0, - currency: 'USD', - creativeId: '742470', - dealId: '22248', - width: 640, - height: 360, - mediaType: 'video', - netRevenue: NET_REVENUE, - ttl: TTL, - }]; - expect(spec.interpretResponse(adheseVideoResponse, bidRequest)).to.deep.equal(expectedResponse); - }); - - it('should return no bids for empty adserver response', () => { - let adserverResponse = { body: [] }; - expect(spec.interpretResponse(adserverResponse, bidRequest)).to.be.empty; - }); - }); -}); diff --git a/test/spec/modules/adliveBidAdapter_spec.js b/test/spec/modules/adliveBidAdapter_spec.js deleted file mode 100644 index ddf8f82f20f..00000000000 --- a/test/spec/modules/adliveBidAdapter_spec.js +++ /dev/null @@ -1,78 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/adliveBidAdapter.js'; - -describe('adliveBidAdapterTests', function() { - let bidRequestData = { - bids: [ - { - bidId: 'transaction_1234', - bidder: 'adlive', - params: { - hashes: ['1e100887dd614b0909bf6c49ba7f69fdd1360437'] - }, - sizes: [[300, 250]] - } - ] - }; - let request = []; - - it('validate_pub_params', function() { - expect( - spec.isBidRequestValid({ - bidder: 'adlive', - params: { - hashes: ['1e100887dd614b0909bf6c49ba7f69fdd1360437'] - } - }) - ).to.equal(true); - }); - - it('validate_generated_params', function() { - request = spec.buildRequests(bidRequestData.bids); - let req_data = JSON.parse(request[0].data); - - expect(req_data.transaction_id).to.equal('transaction_1234'); - }); - - it('validate_response_params', function() { - let serverResponse = { - body: [ - { - hash: '1e100887dd614b0909bf6c49ba7f69fdd1360437', - content: 'Ad html', - price: 1.12, - size: [300, 250], - is_passback: 0 - } - ] - }; - - let bids = spec.interpretResponse(serverResponse, bidRequestData.bids[0]); - expect(bids).to.have.lengthOf(1); - - let bid = bids[0]; - - expect(bid.creativeId).to.equal('1e100887dd614b0909bf6c49ba7f69fdd1360437'); - expect(bid.ad).to.equal('Ad html'); - expect(bid.cpm).to.equal(1.12); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.currency).to.equal('USD'); - }); - - it('validate_response_params_with passback', function() { - let serverResponse = { - body: [ - { - hash: '1e100887dd614b0909bf6c49ba7f69fdd1360437', - content: 'Ad html passback', - size: [300, 250], - is_passback: 1 - } - ] - }; - let bids = spec.interpretResponse(serverResponse, bidRequestData.bids[0]); - - expect(bids).to.have.lengthOf(0); - }); -}); diff --git a/test/spec/modules/admanBidAdapter_spec.js b/test/spec/modules/admanBidAdapter_spec.js deleted file mode 100644 index f3212dec2f5..00000000000 --- a/test/spec/modules/admanBidAdapter_spec.js +++ /dev/null @@ -1,231 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/admanBidAdapter.js'; - -describe('AdmanMediaBidAdapter', function () { - let bid = { - bidId: '23fhj33i987f', - bidder: 'adman', - params: { - placementId: 0, - traffic: 'banner' - } - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are bidId, params and placementId parameters present', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false if at least one of parameters is not present', function () { - delete bid.params.placementId; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://pub.admanmedia.com/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.language).to.be.a('string'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); - expect(placement.placementId).to.equal(0); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal('banner'); - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://pub.admanmedia.com/?c=o&m=sync'); - }); - }); -}); diff --git a/test/spec/modules/admediaBidAdapter_spec.js b/test/spec/modules/admediaBidAdapter_spec.js deleted file mode 100644 index 5dc7b9a02a8..00000000000 --- a/test/spec/modules/admediaBidAdapter_spec.js +++ /dev/null @@ -1,138 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/admediaBidAdapter.js'; - -describe('admediaAdapterTests', function () { - describe('bidRequestValidity', function () { - it('bidRequest with aid', function () { - expect(spec.isBidRequestValid({ - bidder: 'admedia', - params: { - aid: 86858, - } - })).to.equal(true); - }); - - it('bidRequest without aid', function () { - expect(spec.isBidRequestValid({ - bidder: 'a4g', - params: { - key: 86858 - } - })).to.equal(false); - }); - }); - - describe('bidRequest', function () { - const validBidRequests = [{ - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'auctionId': 'e3010a3c-5b95-4475-9ba2-1b004c737c30', - 'bidId': '2758de47c84ab58', - 'bidRequestsCount': 1, - 'bidder': 'admedia', - 'bidderRequestId': '1033407c6af0c7', - 'params': { - 'aid': 86858, - }, - 'sizes': [[300, 250], [300, 600]], - 'transactionId': '5851b2cf-ee2d-4022-abd2-d581ef01604e' - }, { - 'adUnitCode': 'div-gpt-ad-1460505748561-1', - 'auctionId': 'e3010a3c-5b95-4475-9ba2-1b004c737c30', - 'bidId': '3d2aaa400371fa', - 'bidRequestsCount': 1, - 'bidder': 'admedia', - 'bidderRequestId': '1033407c6af0c7', - 'params': { - 'aid': 84977, - }, - 'sizes': [[728, 90]], - 'transactionId': 'f8b5247e-7715-4e60-9d51-33153e78c190' - }]; - - const bidderRequest = { - 'auctionId': 'e3010a3c-5b95-4475-9ba2-1b004c737c30', - 'bidderCode': 'admedia', - 'bidderRequestId': '1033407c6af0c7', - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'https://test.com/index.html?pbjs_debug=true' - } - - }; - - const request = spec.buildRequests(validBidRequests, bidderRequest); - - it('bidRequest method', function () { - expect(request.method).to.equal('POST'); - }); - - it('bidRequest url', function () { - expect(request.url).to.equal('https://prebid.admedia.com/bidder/'); - }); - - it('bidRequest data', function () { - const data = JSON.parse(request.data); - expect(decodeURIComponent(data.referer)).to.be.eql(bidderRequest.refererInfo.referer); - expect(data.tags).to.be.an('array'); - expect(data.tags[0].aid).to.be.eql(validBidRequests[0].params.aid); - expect(data.tags[0].id).to.be.eql(validBidRequests[0].bidId); - expect(data.tags[0].sizes).to.be.eql(validBidRequests[0].sizes); - expect(data.tags[1].aid).to.be.eql(validBidRequests[1].params.aid); - expect(data.tags[1].id).to.be.eql(validBidRequests[1].bidId); - expect(data.tags[1].sizes).to.be.eql(validBidRequests[1].sizes); - }); - }); - - describe('interpretResponse', function () { - const serverResponse = { - body: { - tags: [ - { - ad: '', - cpm: 0.9, - height: 250, - id: '5582180864bc41', - width: 300, - }, - { - error: 'Error message', - id: '6dc6ee4e157749' - }, - { - ad: '', - cpm: 0, - height: 728, - id: '5762180864bc41', - width: 90, - } - ] - }, - headers: {} - }; - - const bidRequest = {}; - - const result = spec.interpretResponse(serverResponse, bidRequest); - - it('Should return an empty array if empty or no tags in response', function () { - expect(spec.interpretResponse({body: ''}, {}).length).to.equal(0); - }); - - it('Should have only one bid', function () { - expect(result.length).to.equal(1); - }); - - it('Should have required keys', function () { - expect(result[0].requestId).to.be.eql(serverResponse.body.tags[0].id); - expect(result[0].cpm).to.be.eql(serverResponse.body.tags[0].cpm); - expect(result[0].width).to.be.eql(serverResponse.body.tags[0].width); - expect(result[0].height).to.be.eql(serverResponse.body.tags[0].height); - expect(result[0].creativeId).to.be.eql(serverResponse.body.tags[0].id); - expect(result[0].dealId).to.be.eql(serverResponse.body.tags[0].id); - expect(result[0].netRevenue).to.be.eql(true); - expect(result[0].ttl).to.be.eql(120); - expect(result[0].ad).to.be.eql(serverResponse.body.tags[0].ad); - }) - }); -}); diff --git a/test/spec/modules/adpartnerBidAdapter_spec.js b/test/spec/modules/adpartnerBidAdapter_spec.js deleted file mode 100644 index d30ef7ebf71..00000000000 --- a/test/spec/modules/adpartnerBidAdapter_spec.js +++ /dev/null @@ -1,234 +0,0 @@ -import {expect} from 'chai'; -import {spec, ENDPOINT_PROTOCOL, ENDPOINT_DOMAIN, ENDPOINT_PATH} from 'modules/adpartnerBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'adpartner'; - -describe('AdpartnerAdapter', 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 () { - it('should return true when required params found', function () { - let validRequest = { - 'params': { - 'unitId': 123 - } - }; - expect(spec.isBidRequestValid(validRequest)).to.equal(true); - }); - - it('should return true when required params is srting', function () { - let validRequest = { - 'params': { - 'unitId': '456' - } - }; - expect(spec.isBidRequestValid(validRequest)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let validRequest = { - 'params': { - 'unknownId': 123 - } - }; - expect(spec.isBidRequestValid(validRequest)).to.equal(false); - }); - - it('should return false when required params is 0', function () { - let validRequest = { - 'params': { - 'unitId': 0 - } - }; - expect(spec.isBidRequestValid(validRequest)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let validEndpoint = ENDPOINT_PROTOCOL + '://' + ENDPOINT_DOMAIN + ENDPOINT_PATH + '?tag=123,456&sizes=300x250|300x600,728x90&referer=https%3A%2F%2Ftest.domain'; - - let validRequest = [ - { - 'bidder': BIDDER_CODE, - 'params': { - 'unitId': 123 - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e' - }, - { - 'bidder': BIDDER_CODE, - 'params': { - 'unitId': '456' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '22aidtbx5eabd9' - } - ]; - - let bidderRequest = { - refererInfo: { - referer: 'https://test.domain' - } - }; - - it('bidRequest HTTP method', function () { - const request = spec.buildRequests(validRequest, bidderRequest); - expect(request.method).to.equal('POST'); - }); - - it('bidRequest url', function () { - const request = spec.buildRequests(validRequest, bidderRequest); - expect(request.url).to.equal(validEndpoint); - }); - - it('bidRequest data', function () { - const request = spec.buildRequests(validRequest, bidderRequest); - const payload = JSON.parse(request.data); - expect(payload[0].unitId).to.equal(123); - expect(payload[0].sizes).to.deep.equal([[300, 250], [300, 600]]); - expect(payload[0].bidId).to.equal('30b31c1838de1e'); - expect(payload[1].unitId).to.equal(456); - expect(payload[1].sizes).to.deep.equal([[728, 90]]); - expect(payload[1].bidId).to.equal('22aidtbx5eabd9'); - }); - }); - - describe('joinSizesToString', function () { - it('success convert sizes list to string', function () { - const sizesStr = spec.joinSizesToString([[300, 250], [300, 600]]); - expect(sizesStr).to.equal('300x250|300x600'); - }); - }); - - describe('interpretResponse', function () { - const bidRequest = { - 'method': 'POST', - 'url': ENDPOINT_PROTOCOL + '://' + ENDPOINT_DOMAIN + ENDPOINT_PATH + '?tag=123,456&code=adunit-code-1,adunit-code-2&bid=30b31c1838de1e,22aidtbx5eabd9&sizes=300x250|300x600,728x90&referer=https%3A%2F%2Ftest.domain', - 'data': '[{"unitId": 13144370,"adUnitCode": "div-gpt-ad-1460505748561-0","sizes": [[300, 250], [300, 600]],"bidId": "2bdcb0b203c17d","referer": "https://test.domain/index.html"},{"unitId": 13144370,"adUnitCode":"div-gpt-ad-1460505748561-1","sizes": [[768, 90]],"bidId": "3dc6b8084f91a8","referer": "https://test.domain/index.html"}]' - }; - - const bidResponse = { - body: { - 'div-gpt-ad-1460505748561-0': - { - 'ad': '
ad
', - 'width': 300, - 'height': 250, - 'creativeId': '8:123456', - 'syncs': [ - {'type': 'image', 'url': 'https://test.domain/tracker_1.gif'}, - {'type': 'image', 'url': 'https://test.domain/tracker_2.gif'}, - {'type': 'image', 'url': 'https://test.domain/tracker_3.gif'} - ], - 'winNotification': [ - { - 'method': 'POST', - 'path': '/hb/bid_won?test=1', - 'data': { - 'ad': [ - {'dsp': 8, 'id': 800008, 'cost': 1.0e-5, 'nurl': 'https://test.domain/'} - ], - 'unit_id': 1234, - 'site_id': 123 - } - } - ], - 'cpm': 0.01, - 'currency': 'USD', - 'netRevenue': true - } - }, - headers: {} - }; - - it('result is correct', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - expect(result[0].requestId).to.equal('2bdcb0b203c17d'); - expect(result[0].cpm).to.equal(0.01); - expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(250); - expect(result[0].creativeId).to.equal('8:123456'); - expect(result[0].currency).to.equal('USD'); - expect(result[0].ttl).to.equal(60); - expect(result[0].winNotification[0]).to.deep.equal({'method': 'POST', 'path': '/hb/bid_won?test=1', 'data': {'ad': [{'dsp': 8, 'id': 800008, 'cost': 1.0e-5, 'nurl': 'https://test.domain/'}], 'unit_id': 1234, 'site_id': 123}}); - }); - }); - - describe('adResponse', function () { - const bid = { - 'unitId': 13144370, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '2bdcb0b203c17d', - 'referer': 'https://test.domain/index.html' - }; - const ad = { - 'ad': '
ad
', - 'width': 300, - 'height': 250, - 'creativeId': '8:123456', - 'syncs': [], - 'winNotification': [], - 'cpm': 0.01, - 'currency': 'USD', - 'netRevenue': true - }; - - it('fill ad for response', function () { - const result = spec.adResponse(bid, ad); - expect(result.requestId).to.equal('2bdcb0b203c17d'); - expect(result.cpm).to.equal(0.01); - expect(result.width).to.equal(300); - expect(result.height).to.equal(250); - expect(result.creativeId).to.equal('8:123456'); - expect(result.currency).to.equal('USD'); - expect(result.ttl).to.equal(60); - }); - }); - - describe('onBidWon', function () { - const bid = { - winNotification: [ - { - 'method': 'POST', - 'path': '/hb/bid_won?test=1', - 'data': { - 'ad': [ - {'dsp': 8, 'id': 800008, 'cost': 0.01, 'nurl': 'http://test.domain/'} - ], - 'unit_id': 1234, - 'site_id': 123 - } - } - ] - }; - - let ajaxStub; - - beforeEach(() => { - ajaxStub = sinon.stub(spec, 'postRequest') - }) - - afterEach(() => { - ajaxStub.restore() - }) - - it('calls adpartner\'s callback endpoint', () => { - const result = spec.onBidWon(bid); - expect(result).to.equal(true); - expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(ENDPOINT_PROTOCOL + '://' + ENDPOINT_DOMAIN + '/hb/bid_won?test=1'); - expect(ajaxStub.firstCall.args[1]).to.deep.equal(JSON.stringify(bid.winNotification[0].data)); - }); - }); -}); diff --git a/test/spec/modules/adprimeBidAdapter_spec.js b/test/spec/modules/adprimeBidAdapter_spec.js deleted file mode 100644 index 8627941dc80..00000000000 --- a/test/spec/modules/adprimeBidAdapter_spec.js +++ /dev/null @@ -1,297 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/adprimeBidAdapter.js'; -import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; - -describe('AdprimebBidAdapter', function () { - const bid = { - bidId: '23fhj33i987f', - bidder: 'adprime', - params: { - placementId: 0, - traffic: BANNER - } - }; - - const bidderRequest = { - refererInfo: { - referer: 'test.com' - } - }; - - 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], bidderRequest); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://delta.adprime.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'); - expect(data.gdpr).to.not.exist; - expect(data.ccpa).to.not.exist; - let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'identeties', 'traffic', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'keywords'); - expect(placement.placementId).to.equal(0); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal(BANNER); - expect(placement.schain).to.be.an('object'); - }); - - it('Returns valid data for mediatype video', function () { - const playerSize = [300, 300]; - bid.mediaTypes = {}; - bid.params.traffic = VIDEO; - bid.mediaTypes[VIDEO] = { - playerSize - }; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data).to.be.an('object'); - let placement = data['placements'][0]; - expect(placement).to.be.an('object'); - expect(placement.traffic).to.equal(VIDEO); - expect(placement.wPlayer).to.equal(playerSize[0]); - expect(placement.hPlayer).to.equal(playerSize[1]); - }); - - it('Returns data with gdprConsent and without uspConsent', function () { - bidderRequest.gdprConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.gdpr).to.exist; - expect(data.gdpr).to.be.a('string'); - expect(data.gdpr).to.equal(bidderRequest.gdprConsent); - expect(data.ccpa).to.not.exist; - delete bidderRequest.gdprConsent; - }); - - it('Returns data with uspConsent and without gdprConsent', function () { - bidderRequest.uspConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.ccpa).to.exist; - expect(data.ccpa).to.be.a('string'); - expect(data.ccpa).to.equal(bidderRequest.uspConsent); - expect(data.gdpr).to.not.exist; - }); - - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('buildRequests with user ids', function () { - bid.userId = {} - bid.userId.idl_env = 'idl_env123'; - let serverRequest = spec.buildRequests([bid], bidderRequest); - it('Return bids with user identeties', function () { - let data = serverRequest.data; - let placements = data['placements']; - expect(data).to.be.an('object'); - for (let i = 0; i < placements.length; i++) { - let placement = placements[i]; - expect(placement).to.have.property('identeties') - expect(placement.identeties).to.be.an('object') - expect(placement.identeties).to.have.property('identityLink') - expect(placement.identeties.identityLink).to.be.equal('idl_env123') - } - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://delta.adprime.com/?c=rtb&m=sync'); - }); - }); -}); diff --git a/test/spec/modules/advenueBidAdapter_spec.js b/test/spec/modules/advenueBidAdapter_spec.js deleted file mode 100644 index 2d7739361b4..00000000000 --- a/test/spec/modules/advenueBidAdapter_spec.js +++ /dev/null @@ -1,107 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/advenueBidAdapter.js'; - -describe('AdvenueAdapter', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'advenue', - 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('https://ssp.advenuemedia.co.uk/?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; - }); - }); - }); -}); diff --git a/test/spec/modules/advertlyBidAdapter_spec.js b/test/spec/modules/advertlyBidAdapter_spec.js deleted file mode 100755 index 7825f11948a..00000000000 --- a/test/spec/modules/advertlyBidAdapter_spec.js +++ /dev/null @@ -1,159 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/advertlyBidAdapter.js'; - -const ENDPOINT = 'https://api.advertly.com/www/admin/plugins/Prebid/getAd.php'; - -describe('The Advertly bidding adapter', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'advertly', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - - it('should return true when given a publisherId in bid', function () { - const bid = { - bidder: 'advertly', - params: { - publisherId: 2 - }, - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [{ - 'bidder': 'advertly', - 'params': { - 'publisherId': 2 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ] - }]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('check endpoint url', function () { - expect(request.url).to.equal(ENDPOINT) - }); - - it('sets the proper banner object', function () { - expect(bidRequests[0].params.publisherId).to.equal(2); - }) - }); - const response = { - body: [ - { - 'requestId': '2ee937f15015c6', - 'cpm': '0.2000', - 'width': 300, - 'height': 600, - 'creativeId': '4', - 'currency': 'USD', - 'netRevenue': true, - 'ad': 'ads.html', - 'mediaType': 'banner' - }, - { - 'requestId': '3e1af92622bdc', - 'cpm': '0.2000', - 'creativeId': '4', - 'context': 'outstream', - 'currency': 'USD', - 'netRevenue': true, - 'vastUrl': 'tezt.xml', - 'width': 640, - 'height': 480, - 'mediaType': 'video' - }] - }; - - const request = [ - { - 'bidder': 'advertly', - 'params': { - 'publisherId': 2 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 600] - ] - } - }, - 'bidId': '2ee937f15015c6', - 'src': 'client', - }, - { - 'bidder': 'advertly', - 'params': { - 'publisherId': 2 - }, - 'mediaTypes': { - 'video': { - 'context': 'outstream', - 'playerSize': [ - [640, 480] - ] - } - }, - 'bidId': '3e1af92622bdc', - 'src': 'client', - } - ]; - - describe('interpretResponse', function () { - it('return empty array when no ad found', function () { - const response = {}; - const request = { bidRequests: [] }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('check response for banner and video', function () { - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(2); - expect(bids[0].requestId).to.equal('2ee937f15015c6'); - expect(bids[0].cpm).to.equal('0.2000'); - expect(bids[1].cpm).to.equal('0.2000'); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(600); - expect(bids[1].vastUrl).to.not.equal(''); - expect(bids[0].ad).to.not.equal(''); - expect(bids[1].adResponse).to.not.equal(''); - expect(bids[1].renderer).not.to.be.an('undefined'); - }); - }); - - describe('On winning bid', function () { - const bids = spec.interpretResponse(response, request); - spec.onBidWon(bids); - }); - - describe('On bid Time out', function () { - const bids = spec.interpretResponse(response, request); - spec.onTimeout(bids); - }); - - describe('user sync', function () { - it('to check the user sync iframe', function () { - let syncs = spec.getUserSyncs({ - iframeEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - }); - }); -}); diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js deleted file mode 100644 index 80ecab764e8..00000000000 --- a/test/spec/modules/ajaBidAdapter_spec.js +++ /dev/null @@ -1,311 +0,0 @@ -import { spec } from 'modules/ajaBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -const ENDPOINT = 'https://ad.as.amanad.adtdp.com/v2/prebid'; - -describe('AjaAdapter', function () { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'aja', - 'params': { - 'asi': '123456' - }, - 'adUnitCode': 'adunit', - '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 = { - 'asi': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'aja', - 'params': { - 'asi': '123456' - }, - 'adUnitCode': 'adunit', - 'sizes': [[300, 250]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - let bidderRequest = { - refererInfo: { - referer: 'https://hoge.com' - } - }; - - it('sends bid request to ENDPOINT via GET', 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=https%3A%2F%2Fhoge.com&'); - }); - }); - - describe('interpretResponse', function () { - it('should get correct banner bid response', function () { - let response = { - 'is_ad_return': true, - 'ad': { - 'ad_type': 1, - 'prebid_id': '51ef8751f9aead', - 'price': 12.34, - 'currency': 'USD', - 'creative_id': '123abc', - 'banner': { - 'w': 300, - 'h': 250, - 'tag': '
', - 'imps': [ - 'https://as.amanad.adtdp.com/v1/imp' - ] - } - }, - 'syncs': [ - 'https://example.com' - ] - }; - - let expectedResponse = [ - { - 'requestId': '51ef8751f9aead', - 'cpm': 12.34, - 'creativeId': '123abc', - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
', - 'mediaType': 'banner', - 'currency': 'USD', - 'ttl': 300, - 'netRevenue': true - } - ]; - - let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles video responses', function () { - let response = { - 'is_ad_return': true, - 'ad': { - 'ad_type': 3, - 'prebid_id': '51ef8751f9aead', - 'price': 12.34, - 'currency': 'JPY', - 'creative_id': '123abc', - 'video': { - 'w': 300, - 'h': 250, - 'vtag': '', - 'purl': 'https://cdn/player', - 'progress': true, - 'loop': false, - 'inread': false - } - }, - 'syncs': [ - 'https://example.com' - ] - }; - - let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result[0]).to.have.property('vastXml'); - expect(result[0]).to.have.property('renderer'); - expect(result[0]).to.have.property('mediaType', 'video'); - }); - - it('handles native response', function () { - let response = { - 'is_ad_return': true, - 'ad': { - 'ad_type': 2, - 'prebid_id': '51ef8751f9aead', - 'price': 12.34, - 'currency': 'JPY', - 'creative_id': '123abc', - 'native': { - 'template_and_ads': { - 'head': '', - 'body_wrapper': '', - 'body': '', - 'ads': [ - { - 'ad_format_id': 10, - 'assets': { - 'ad_spot_id': '123abc', - 'index': 0, - 'adchoice_url': 'https://aja-kk.co.jp/optout', - 'cta_text': 'cta', - 'img_icon': 'https://example.com/img_icon', - 'img_icon_width': '50', - 'img_icon_height': '50', - 'img_main': 'https://example.com/img_main', - 'img_main_width': '200', - 'img_main_height': '100', - 'lp_link': 'https://example.com/lp?k=v', - 'sponsor': 'sponsor', - 'title': 'ad_title', - 'description': 'ad_desc' - }, - 'imps': [ - 'https://example.com/imp' - ], - 'inviews': [ - 'https://example.com/inview' - ], - 'jstracker': '', - 'disable_trimming': false - } - ] - } - } - }, - 'syncs': [ - 'https://example.com' - ] - }; - - let expectedResponse = [ - { - 'requestId': '51ef8751f9aead', - 'cpm': 12.34, - 'creativeId': '123abc', - 'dealId': undefined, - 'mediaType': 'native', - 'currency': 'JPY', - 'ttl': 300, - 'netRevenue': true, - 'native': { - 'title': 'ad_title', - 'body': 'ad_desc', - 'cta': 'cta', - 'sponsoredBy': 'sponsor', - 'image': { - 'url': 'https://example.com/img_main', - 'width': 200, - 'height': 100 - }, - 'icon': { - 'url': 'https://example.com/img_icon', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://example.com/lp?k=v', - 'impressionTrackers': [ - 'https://example.com/imp' - ], - 'privacyLink': 'https://aja-kk.co.jp/optout', - } - } - ]; - - let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}) - expect(result).to.deep.equal(expectedResponse) - }); - - it('handles nobid responses', function () { - let response = { - 'is_ad_return': false, - 'ad': {} - }; - - let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - const bidResponse1 = { - body: { - 'is_ad_return': true, - 'ad': { /* ad body */ }, - 'syncs': [ - 'https://example.test/pixel/1' - ], - 'sync_htmls': [ - 'https://example.test/iframe/1' - ] - } - }; - - const bidResponse2 = { - body: { - 'is_ad_return': true, - 'ad': { /* ad body */ }, - 'syncs': [ - 'https://example.test/pixel/2' - ] - } - }; - - it('should use a sync url from first response (pixel and iframe)', function () { - const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [bidResponse1, bidResponse2]); - expect(syncs).to.deep.equal([ - { - type: 'image', - url: 'https://example.test/pixel/1' - }, - { - type: 'iframe', - url: 'https://example.test/iframe/1' - } - ]); - }); - - it('handle empty response (e.g. timeout)', function () { - const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, []); - expect(syncs).to.deep.equal([]); - }); - - it('returns empty syncs when not pixel enabled and not iframe enabled', function () { - const syncs = spec.getUserSyncs({ pixelEnabled: false, iframeEnabled: false }, [bidResponse1]); - expect(syncs).to.deep.equal([]); - }); - - it('returns pixel syncs when pixel enabled and not iframe enabled', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: false }, [bidResponse1]); - expect(syncs).to.deep.equal([ - { - type: 'image', - url: 'https://example.test/pixel/1' - } - ]); - }); - - it('returns iframe syncs when not pixel enabled and iframe enabled', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: false, iframeEnabled: true }, [bidResponse1]); - expect(syncs).to.deep.equal([ - { - type: 'iframe', - url: 'https://example.test/iframe/1' - } - ]); - }); - }); -}); diff --git a/test/spec/modules/atomxBidAdapter_spec.js b/test/spec/modules/atomxBidAdapter_spec.js deleted file mode 100644 index d798bd6308c..00000000000 --- a/test/spec/modules/atomxBidAdapter_spec.js +++ /dev/null @@ -1,119 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/atomxBidAdapter.js'; - -describe('atomxAdapterTest', function () { - describe('bidRequestValidity', function () { - it('bidRequest with id param', function () { - expect(spec.isBidRequestValid({ - bidder: 'atomx', - params: { - id: 1234, - }, - })).to.equal(true); - }); - - it('bidRequest with no id param', function () { - expect(spec.isBidRequestValid({ - bidder: 'atomx', - params: { - }, - })).to.equal(false); - }); - }); - - describe('bidRequest', function () { - const bidRequests = [{ - 'bidder': 'atomx', - 'params': { - 'id': '123' - }, - 'adUnitCode': 'aaa', - 'transactionId': '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', - 'sizes': [300, 250], - 'bidId': '1abgs362e0x48a8', - 'bidderRequestId': '70deaff71c281d', - 'auctionId': '5c66da22-426a-4bac-b153-77360bef5337' - }, - { - 'bidder': 'atomx', - 'params': { - 'id': '456', - }, - 'adUnitCode': 'bbb', - 'transactionId': '193995b4-7122-4739-959b-2463282a138b', - 'sizes': [[800, 600]], - 'bidId': '22aidtbx5eabd9', - 'bidderRequestId': '70deaff71c281d', - 'auctionId': 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a' - }]; - - 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 requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.url).to.match(new RegExp('p\\.ato\\.mx/placement')); - }); - }); - - it('bidRequest data', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].data.id).to.equal('123'); - expect(requests[0].data.size).to.equal('300x250'); - expect(requests[0].data.prebid).to.equal('1abgs362e0x48a8'); - expect(requests[1].data.id).to.equal('456'); - expect(requests[1].data.size).to.equal('800x600'); - expect(requests[1].data.prebid).to.equal('22aidtbx5eabd9'); - }); - }); - - describe('interpretResponse', function () { - const bidRequest = { - 'method': 'GET', - 'url': 'https://p.ato.mx/placement', - 'data': { - 'v': 12, - 'id': '123', - 'size': '300x250', - 'prebid': '22aidtbx5eabd9', - 'b': 0, - 'h': '7t3y9', - 'type': 'javascript', - 'screen': '800x600x32', - 'timezone': 0, - 'domain': 'https://example.com', - 'r': '', - } - }; - - const bidResponse = { - body: { - 'cpm': 0.00009, - 'width': 300, - 'height': 250, - 'url': 'https://atomx.com', - 'creative_id': 456, - 'code': '22aidtbx5eabd9', - }, - headers: {} - }; - - it('result is correct', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - - expect(result[0].requestId).to.equal('22aidtbx5eabd9'); - expect(result[0].cpm).to.equal(0.00009 * 1000); - expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(250); - 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('https://atomx.com'); - }); - }); -}); diff --git a/test/spec/modules/avocetBidAdapter_spec.js b/test/spec/modules/avocetBidAdapter_spec.js deleted file mode 100644 index 2a2f29e48d2..00000000000 --- a/test/spec/modules/avocetBidAdapter_spec.js +++ /dev/null @@ -1,167 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/avocetBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { config } from 'src/config'; - -describe('Avocet adapter', function () { - beforeEach(function () { - config.setConfig({ - currency: { - adServerCurrency: 'USD', - }, - publisherDomain: 'test.com', - fpd: { - some: 'data', - }, - }); - }); - - afterEach(function () { - config.resetConfig(); - }); - - describe('inherited functions', function () { - it('exists and is a function', function () { - const adapter = newBidder(spec); - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return false for bid request missing params', () => { - const invalidBidRequest = { - bid: {}, - }; - expect(spec.isBidRequestValid(invalidBidRequest)).to.equal(false); - }); - it('should return false for an invalid type placement param', () => { - const invalidBidRequest = { - params: { - placement: 123, - }, - }; - expect(spec.isBidRequestValid(invalidBidRequest)).to.equal(false); - }); - it('should return false for an invalid length placement param', () => { - const invalidBidRequest = { - params: { - placement: '123', - }, - }; - expect(spec.isBidRequestValid(invalidBidRequest)).to.equal(false); - }); - it('should return true for a valid length placement param', () => { - const validBidRequest = { - params: { - placement: '012345678901234567890123', - }, - }; - expect(spec.isBidRequestValid(validBidRequest)).to.equal(true); - }); - }); - describe('buildRequests', function () { - it('constructs a valid POST request', function () { - const request = spec.buildRequests( - [ - { - bidder: 'avct', - params: { - placement: '012345678901234567890123', - }, - userId: { - id5id: { - uid: 'test' - } - } - }, - { - bidder: 'avct', - params: { - placement: '012345678901234567890123', - }, - }, - ], - exampleBidderRequest - ); - expect(request.method).to.equal('POST'); - expect(request.url).to.equal('https://ads.avct.cloud/prebid'); - - const requestData = JSON.parse(request.data); - expect(requestData.ext).to.be.an('object'); - expect(requestData.ext.currency).to.equal('USD'); - expect(requestData.ext.publisherDomain).to.equal('test.com'); - expect(requestData.ext.fpd).to.deep.equal({ some: 'data' }); - expect(requestData.ext.schain).to.deep.equal({ - validation: 'strict', - config: { - ver: '1.0', - complete: 1, - nodes: [ - { - asi: 'indirectseller.com', - sid: '00001', - hp: 1, - }, - ], - }, - }); - expect(requestData.ext.id5id).to.equal('test'); - expect(requestData.bids).to.be.an('array'); - expect(requestData.bids.length).to.equal(2); - }); - }); - describe('interpretResponse', function () { - it('no response', function () { - const response = spec.interpretResponse(); - expect(response).to.be.an('array'); - expect(response.length).to.equal(0); - }); - it('no body', function () { - const response = spec.interpretResponse({}); - expect(response).to.be.an('array'); - expect(response.length).to.equal(0); - }); - it('null body', function () { - const response = spec.interpretResponse({ body: null }); - expect(response).to.be.an('array'); - expect(response.length).to.equal(0); - }); - it('empty body', function () { - const response = spec.interpretResponse({ body: {} }); - expect(response).to.be.an('array'); - expect(response.length).to.equal(0); - }); - it('null body.responses', function () { - const response = spec.interpretResponse({ body: { responses: null } }); - expect(response).to.be.an('array'); - expect(response.length).to.equal(0); - }); - it('array body', function () { - const response = spec.interpretResponse({ body: [{}] }); - expect(response).to.be.an('array'); - expect(response.length).to.equal(1); - }); - it('array body.responses', function () { - const response = spec.interpretResponse({ body: { responses: [{}] } }); - expect(response).to.be.an('array'); - expect(response.length).to.equal(1); - }); - }); -}); - -const exampleBidderRequest = { - schain: { - validation: 'strict', - config: { - ver: '1.0', - complete: 1, - nodes: [ - { - asi: 'indirectseller.com', - sid: '00001', - hp: 1, - }, - ], - }, - }, -}; diff --git a/test/spec/modules/bidlabBidAdapter_spec.js b/test/spec/modules/bidlabBidAdapter_spec.js deleted file mode 100644 index cffd43ae6ca..00000000000 --- a/test/spec/modules/bidlabBidAdapter_spec.js +++ /dev/null @@ -1,235 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/bidlabBidAdapter.js'; - -describe('BidlabBidAdapter', function () { - let bid = { - bidId: '23fhj33i987f', - bidder: 'bidlab', - params: { - placementId: 0, - traffic: 'banner' - } - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are bidId, params and placementId parameters present', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false if at least one of parameters is not present', function () { - delete bid.params.placementId; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://service.bidlab.ai/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.language).to.be.a('string'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); - expect(placement.placementId).to.equal(0); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal('banner'); - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - if (spec.noSync) { - expect(userSync).to.be.equal(false); - } else { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://service.bidlab.ai/?c=o&m=sync'); - } - }); - }); -}); diff --git a/test/spec/modules/bidphysicsBidAdapter_spec.js b/test/spec/modules/bidphysicsBidAdapter_spec.js deleted file mode 100644 index fc15c39cf81..00000000000 --- a/test/spec/modules/bidphysicsBidAdapter_spec.js +++ /dev/null @@ -1,261 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/bidphysicsBidAdapter.js'; - -const REQUEST = { - 'bidderCode': 'bidphysics', - 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708', - 'bidderRequestId': 'requestId', - 'bidRequest': [{ - 'bidder': 'bidphysics', - 'params': { - 'unitId': 123456, - }, - 'placementCode': 'div-gpt-dummy-placement-code', - 'sizes': [ - [300, 250] - ], - 'bidId': 'bidId1', - 'bidderRequestId': 'bidderRequestId', - 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' - }, - { - 'bidder': 'bidphysics', - 'params': { - 'unitId': 123456, - }, - 'placementCode': 'div-gpt-dummy-placement-code', - 'sizes': [ - [300, 250] - ], - 'bidId': 'bidId2', - 'bidderRequestId': 'bidderRequestId', - 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' - }], - 'start': 1487883186070, - 'auctionStart': 1487883186069, - 'timeout': 3000 -}; - -const RESPONSE = { - 'headers': null, - 'body': { - 'id': 'responseId', - 'seatbid': [ - { - 'bid': [ - { - 'id': 'bidId1', - 'impid': 'bidId1', - 'price': 0.18, - 'adm': '', - 'adid': '144762342', - 'adomain': [ - 'https://dummydomain.com' - ], - 'iurl': 'iurl', - 'cid': '109', - 'crid': 'creativeId', - 'cat': [], - 'w': 300, - 'h': 250, - 'ext': { - 'prebid': { - 'type': 'banner' - }, - 'bidder': { - 'appnexus': { - 'brand_id': 334553, - 'auction_id': 514667951122925701, - 'bidder_id': 2, - 'bid_ad_type': 0 - } - } - } - }, - { - 'id': 'bidId2', - 'impid': 'bidId2', - 'price': 0.1, - 'adm': '', - 'adid': '144762342', - 'adomain': [ - 'https://dummydomain.com' - ], - 'iurl': 'iurl', - 'cid': '109', - 'crid': 'creativeId', - 'cat': [], - 'w': 300, - 'h': 250, - 'ext': { - 'prebid': { - 'type': 'banner' - }, - 'bidder': { - 'appnexus': { - 'brand_id': 386046, - 'auction_id': 517067951122925501, - 'bidder_id': 2, - 'bid_ad_type': 0 - } - } - } - } - ], - 'seat': 'bidphysics' - } - ], - 'ext': { - 'usersync': { - 'sovrn': { - 'status': 'none', - 'syncs': [ - { - 'url': 'urlsovrn', - 'type': 'iframe' - } - ] - }, - 'appnexus': { - 'status': 'none', - 'syncs': [ - { - 'url': 'urlappnexus', - 'type': 'pixel' - } - ] - } - }, - 'responsetimemillis': { - 'appnexus': 127 - } - } - } -}; - -describe('BidPhysics bid adapter', function () { - describe('isBidRequestValid', function () { - it('should accept request if only unitId is passed', function () { - let bid = { - bidder: 'bidphysics', - params: { - unitId: 'unitId', - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - it('should accept request if only networkId is passed', function () { - let bid = { - bidder: 'bidphysics', - params: { - networkId: 'networkId', - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - it('should accept request if only publisherId is passed', function () { - let bid = { - bidder: 'bidphysics', - params: { - publisherId: 'publisherId', - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('reject requests without params', function () { - let bid = { - bidder: 'bidphysics', - params: {} - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - it('creates request data', function () { - let request = spec.buildRequests(REQUEST.bidRequest, REQUEST); - - expect(request).to.exist.and.to.be.a('object'); - const payload = JSON.parse(request.data); - expect(payload.imp[0]).to.have.property('id', REQUEST.bidRequest[0].bidId); - expect(payload.imp[1]).to.have.property('id', REQUEST.bidRequest[1].bidId); - }); - - it('has gdpr data if applicable', function () { - const req = Object.assign({}, REQUEST, { - gdprConsent: { - consentString: 'consentString', - gdprApplies: true, - } - }); - let request = spec.buildRequests(REQUEST.bidRequest, req); - - const payload = JSON.parse(request.data); - expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString); - expect(payload.regs.ext).to.have.property('gdpr', 1); - }); - }); - - describe('interpretResponse', function () { - it('have bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - expect(bids).to.be.an('array').that.is.not.empty; - validateBidOnIndex(0); - validateBidOnIndex(1); - - function validateBidOnIndex(index) { - expect(bids[index]).to.have.property('currency', 'USD'); - expect(bids[index]).to.have.property('requestId', RESPONSE.body.seatbid[0].bid[index].impid); - expect(bids[index]).to.have.property('cpm', RESPONSE.body.seatbid[0].bid[index].price); - expect(bids[index]).to.have.property('width', RESPONSE.body.seatbid[0].bid[index].w); - expect(bids[index]).to.have.property('height', RESPONSE.body.seatbid[0].bid[index].h); - expect(bids[index]).to.have.property('ad', RESPONSE.body.seatbid[0].bid[index].adm); - expect(bids[index]).to.have.property('creativeId', RESPONSE.body.seatbid[0].bid[index].crid); - expect(bids[index]).to.have.property('ttl', 30); - expect(bids[index]).to.have.property('netRevenue', true); - } - }); - - it('handles empty response', function () { - const EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {}}); - const bids = spec.interpretResponse(EMPTY_RESP, REQUEST); - - expect(bids).to.be.empty; - }); - }); - - describe('getUserSyncs', function () { - it('handles no parameters', function () { - let opts = spec.getUserSyncs({}); - expect(opts).to.be.an('array').that.is.empty; - }); - it('returns non if sync is not allowed', function () { - let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}); - - expect(opts).to.be.an('array').that.is.empty; - }); - - it('iframe sync enabled should return results', function () { - let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [RESPONSE]); - - expect(opts.length).to.equal(1); - expect(opts[0].type).to.equal('iframe'); - expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['sovrn'].syncs[0].url); - }); - - it('pixel sync enabled should return results', function () { - let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [RESPONSE]); - - expect(opts.length).to.equal(1); - expect(opts[0].type).to.equal('image'); - expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['appnexus'].syncs[0].url); - }); - - it('all sync enabled should return all results', function () { - let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [RESPONSE]); - - expect(opts.length).to.equal(2); - }); - }); -}); diff --git a/test/spec/modules/bizzclickBidAdapter_spec.js b/test/spec/modules/bizzclickBidAdapter_spec.js deleted file mode 100644 index e0698c9eda8..00000000000 --- a/test/spec/modules/bizzclickBidAdapter_spec.js +++ /dev/null @@ -1,396 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/bizzclickBidAdapter.js'; -import {config} from 'src/config.js'; - -const NATIVE_BID_REQUEST = { - code: 'native_example', - mediaTypes: { - native: { - title: { - required: true, - len: 800 - }, - image: { - required: true, - len: 80 - }, - sponsoredBy: { - required: true - }, - clickUrl: { - required: true - }, - privacyLink: { - required: false - }, - body: { - required: true - }, - icon: { - required: true, - sizes: [50, 50] - } - } - }, - bidder: 'bizzclick', - params: { - placementId: 'hash', - accountId: 'accountId' - }, - timeout: 1000 - -}; - -const BANNER_BID_REQUEST = { - code: 'banner_example', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidder: 'bizzclick', - params: { - placementId: 'hash', - accountId: 'accountId' - }, - timeout: 1000, - gdprConsent: { - consentString: 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA', - gdprApplies: 1, - }, - uspConsent: 'uspConsent' -} - -const bidRequest = { - refererInfo: { - referer: 'test.com' - } -} - -const VIDEO_BID_REQUEST = { - code: 'video1', - sizes: [640, 480], - mediaTypes: { video: { - minduration: 0, - maxduration: 999, - boxingallowed: 1, - skip: 0, - mimes: [ - 'application/javascript', - 'video/mp4' - ], - w: 1920, - h: 1080, - protocols: [ - 2 - ], - linearity: 1, - api: [ - 1, - 2 - ] - } - }, - - bidder: 'bizzclick', - params: { - placementId: 'hash', - accountId: 'accountId' - }, - timeout: 1000 - -} - -const BANNER_BID_RESPONSE = { - id: 'request_id', - bidid: 'request_imp_id', - seatbid: [{ - bid: [{ - id: 'bid_id', - impid: 'request_imp_id', - price: 5, - adomain: ['example.com'], - adm: 'admcode', - crid: 'crid', - ext: { - mediaType: 'banner' - } - }], - }], -}; - -const VIDEO_BID_RESPONSE = { - id: 'request_id', - bidid: 'request_imp_id', - seatbid: [{ - bid: [{ - id: 'bid_id', - impid: 'request_imp_id', - price: 5, - adomain: ['example.com'], - adm: 'admcode', - crid: 'crid', - ext: { - mediaType: 'video', - vastUrl: 'http://example.vast', - } - }], - }], -}; - -let imgData = { - url: `https://example.com/image`, - w: 1200, - h: 627 -}; - -const NATIVE_BID_RESPONSE = { - id: 'request_id', - bidid: 'request_imp_id', - seatbid: [{ - bid: [{ - id: 'bid_id', - impid: 'request_imp_id', - price: 5, - adomain: ['example.com'], - adm: { native: - { - assets: [ - {id: 0, title: 'dummyText'}, - {id: 3, image: imgData}, - { - id: 5, - data: {value: 'organization.name'} - } - ], - link: {url: 'example.com'}, - imptrackers: ['tracker1.com', 'tracker2.com', 'tracker3.com'], - jstracker: 'tracker1.com' - } - }, - crid: 'crid', - ext: { - mediaType: 'native' - } - }], - }], -}; - -describe('BizzclickAdapter', function() { - describe('with COPPA', function() { - beforeEach(function() { - sinon.stub(config, 'getConfig') - .withArgs('coppa') - .returns(true); - }); - afterEach(function() { - config.getConfig.restore(); - }); - - it('should send the Coppa "required" flag set to "1" in the request', function () { - let serverRequest = spec.buildRequests([BANNER_BID_REQUEST]); - expect(serverRequest.data[0].regs.coppa).to.equal(1); - }); - }); - - describe('isBidRequestValid', function() { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(NATIVE_BID_REQUEST)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, NATIVE_BID_REQUEST); - delete bid.params; - bid.params = { - 'IncorrectParam': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('build Native Request', function () { - const request = spec.buildRequests([NATIVE_BID_REQUEST], bidRequest); - - it('Creates a ServerRequest object with method, URL and data', function () { - expect(request).to.exist; - expect(request.method).to.exist; - expect(request.url).to.exist; - expect(request.data).to.exist; - }); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('Returns valid URL', function () { - expect(request.url).to.equal('https://us-e-node1.bizzclick.com/bid?rtb_seat_id=prebidjs&secret_key=accountId'); - }); - - it('Returns empty data if no valid requests are passed', function () { - let serverRequest = spec.buildRequests([]); - expect(serverRequest).to.be.an('array').that.is.empty; - }); - }); - - describe('build Banner Request', function () { - const request = spec.buildRequests([BANNER_BID_REQUEST]); - - it('Creates a ServerRequest object with method, URL and data', function () { - expect(request).to.exist; - expect(request.method).to.exist; - expect(request.url).to.exist; - expect(request.data).to.exist; - }); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('check consent and ccpa string is set properly', function() { - expect(request.data[0].regs.ext.gdpr).to.equal(1); - expect(request.data[0].user.ext.consent).to.equal(BANNER_BID_REQUEST.gdprConsent.consentString); - expect(request.data[0].regs.ext.us_privacy).to.equal(BANNER_BID_REQUEST.uspConsent); - }) - - it('Returns valid URL', function () { - expect(request.url).to.equal('https://us-e-node1.bizzclick.com/bid?rtb_seat_id=prebidjs&secret_key=accountId'); - }); - }); - - describe('build Video Request', function () { - const request = spec.buildRequests([VIDEO_BID_REQUEST]); - - it('Creates a ServerRequest object with method, URL and data', function () { - expect(request).to.exist; - expect(request.method).to.exist; - expect(request.url).to.exist; - expect(request.data).to.exist; - }); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('Returns valid URL', function () { - expect(request.url).to.equal('https://us-e-node1.bizzclick.com/bid?rtb_seat_id=prebidjs&secret_key=accountId'); - }); - }); - - describe('interpretResponse', function () { - it('Empty response must return empty array', function() { - const emptyResponse = null; - let response = spec.interpretResponse(emptyResponse); - - expect(response).to.be.an('array').that.is.empty; - }) - - it('Should interpret banner response', function () { - const bannerResponse = { - body: [BANNER_BID_RESPONSE] - } - - const expectedBidResponse = { - requestId: BANNER_BID_RESPONSE.id, - cpm: BANNER_BID_RESPONSE.seatbid[0].bid[0].price, - width: BANNER_BID_RESPONSE.seatbid[0].bid[0].w, - height: BANNER_BID_RESPONSE.seatbid[0].bid[0].h, - ttl: BANNER_BID_RESPONSE.ttl || 1200, - currency: BANNER_BID_RESPONSE.cur || 'USD', - netRevenue: true, - creativeId: BANNER_BID_RESPONSE.seatbid[0].bid[0].crid, - dealId: BANNER_BID_RESPONSE.seatbid[0].bid[0].dealid, - mediaType: 'banner', - ad: BANNER_BID_RESPONSE.seatbid[0].bid[0].adm - } - - let bannerResponses = spec.interpretResponse(bannerResponse); - - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); - expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); - expect(dataItem.ad).to.equal(expectedBidResponse.ad); - expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); - expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal(expectedBidResponse.currency); - expect(dataItem.width).to.equal(expectedBidResponse.width); - expect(dataItem.height).to.equal(expectedBidResponse.height); - }); - - it('Should interpret video response', function () { - const videoResponse = { - body: [VIDEO_BID_RESPONSE] - } - - const expectedBidResponse = { - requestId: VIDEO_BID_RESPONSE.id, - cpm: VIDEO_BID_RESPONSE.seatbid[0].bid[0].price, - width: VIDEO_BID_RESPONSE.seatbid[0].bid[0].w, - height: VIDEO_BID_RESPONSE.seatbid[0].bid[0].h, - ttl: VIDEO_BID_RESPONSE.ttl || 1200, - currency: VIDEO_BID_RESPONSE.cur || 'USD', - netRevenue: true, - creativeId: VIDEO_BID_RESPONSE.seatbid[0].bid[0].crid, - dealId: VIDEO_BID_RESPONSE.seatbid[0].bid[0].dealid, - mediaType: 'video', - vastXml: VIDEO_BID_RESPONSE.seatbid[0].bid[0].adm, - vastUrl: VIDEO_BID_RESPONSE.seatbid[0].bid[0].ext.vastUrl - } - - let videoResponses = spec.interpretResponse(videoResponse); - - expect(videoResponses).to.be.an('array').that.is.not.empty; - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastXml', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); - expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); - expect(dataItem.vastXml).to.equal(expectedBidResponse.vastXml) - expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); - expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal(expectedBidResponse.currency); - expect(dataItem.width).to.equal(expectedBidResponse.width); - expect(dataItem.height).to.equal(expectedBidResponse.height); - }); - - it('Should interpret native response', function () { - const nativeResponse = { - body: [NATIVE_BID_RESPONSE] - } - - const expectedBidResponse = { - requestId: NATIVE_BID_RESPONSE.id, - cpm: NATIVE_BID_RESPONSE.seatbid[0].bid[0].price, - width: NATIVE_BID_RESPONSE.seatbid[0].bid[0].w, - height: NATIVE_BID_RESPONSE.seatbid[0].bid[0].h, - ttl: NATIVE_BID_RESPONSE.ttl || 1200, - currency: NATIVE_BID_RESPONSE.cur || 'USD', - netRevenue: true, - creativeId: NATIVE_BID_RESPONSE.seatbid[0].bid[0].crid, - dealId: NATIVE_BID_RESPONSE.seatbid[0].bid[0].dealid, - mediaType: 'native', - native: {clickUrl: NATIVE_BID_RESPONSE.seatbid[0].bid[0].adm.native.link.url} - } - - let nativeResponses = spec.interpretResponse(nativeResponse); - - expect(nativeResponses).to.be.an('array').that.is.not.empty; - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'native', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); - expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); - expect(dataItem.native.clickUrl).to.equal(expectedBidResponse.native.clickUrl) - expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); - expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal(expectedBidResponse.currency); - expect(dataItem.width).to.equal(expectedBidResponse.width); - expect(dataItem.height).to.equal(expectedBidResponse.height); - }); - }); -}) diff --git a/test/spec/modules/boldwinBidAdapter_spec.js b/test/spec/modules/boldwinBidAdapter_spec.js deleted file mode 100644 index a353665ec33..00000000000 --- a/test/spec/modules/boldwinBidAdapter_spec.js +++ /dev/null @@ -1,281 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/boldwinBidAdapter.js'; -import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; - -describe('BoldwinBidAdapter', function () { - const bid = { - bidId: '23fhj33i987f', - bidder: 'boldwin', - params: { - placementId: 0, - traffic: BANNER - } - }; - - const bidderRequest = { - refererInfo: { - referer: 'test.com' - } - }; - - 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], bidderRequest); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://ssp.videowalldirect.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'); - expect(data.gdpr).to.not.exist; - expect(data.ccpa).to.not.exist; - let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'hPlayer', 'wPlayer', 'schain'); - expect(placement.placementId).to.equal(0); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal(BANNER); - expect(placement.schain).to.be.an('object'); - }); - - it('Returns valid data for mediatype video', function () { - const playerSize = [300, 300]; - bid.mediaTypes = {}; - bid.params.traffic = VIDEO; - bid.mediaTypes[VIDEO] = { - playerSize - }; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data).to.be.an('object'); - let placement = data['placements'][0]; - expect(placement).to.be.an('object'); - expect(placement.traffic).to.equal(VIDEO); - expect(placement.wPlayer).to.equal(playerSize[0]); - expect(placement.hPlayer).to.equal(playerSize[1]); - }); - - it('Returns data with gdprConsent and without uspConsent', function () { - bidderRequest.gdprConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.gdpr).to.exist; - expect(data.gdpr).to.be.a('string'); - expect(data.gdpr).to.equal(bidderRequest.gdprConsent); - expect(data.ccpa).to.not.exist; - delete bidderRequest.gdprConsent; - }); - - it('Returns data with uspConsent and without gdprConsent', function () { - bidderRequest.uspConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.ccpa).to.exist; - expect(data.ccpa).to.be.a('string'); - expect(data.ccpa).to.equal(bidderRequest.uspConsent); - expect(data.gdpr).to.not.exist; - }); - - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://cs.videowalldirect.com/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/byplayBidAdapter_spec.js b/test/spec/modules/byplayBidAdapter_spec.js deleted file mode 100644 index 57aad403c4e..00000000000 --- a/test/spec/modules/byplayBidAdapter_spec.js +++ /dev/null @@ -1,93 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/byplayBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import * as bidderFactory from 'src/adapters/bidderFactory.js'; - -describe('byplayBidAdapter', () => { - describe('isBidRequestValid', () => { - describe('exist sectionId', () => { - const bid = { - 'bidder': 'byplay', - 'params': { - 'sectionId': '11111' - }, - }; - - it('should equal true', () => { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - - describe('not exist sectionId', () => { - const bid = { - 'bidder': 'byplay', - 'params': { - }, - }; - - it('should equal false', () => { - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - }); - - describe('buildRequests', () => { - const bids = [ - { - 'bidder': 'byplay', - 'bidId': '1234', - 'params': { - 'sectionId': '1111' - }, - } - ]; - - const request = spec.buildRequests(bids); - - it('should return POST', () => { - expect(request[0].method).to.equal('POST'); - }); - - it('should return data', () => { - expect(request[0].data).to.equal('{"requestId":"1234","sectionId":"1111"}'); - }); - }); - - describe('interpretResponse', () => { - const serverResponse = { - body: { - 'cpm': 1500, - 'width': 320, - 'height': 180, - 'netRevenue': true, - 'creativeId': '1', - 'requestId': '209c1fb5ad88f5', - 'vastXml': '' - } - }; - - const bidderRequest = { - 'method': 'GET', - 'url': 'https://tasp0g98f2.execute-api.ap-northeast-1.amazonaws.com/v1/bidder', - 'data': '{"requestId":"209c1fb5ad88f5","sectionId":7986}' - }; - - const result = spec.interpretResponse(serverResponse, bidderRequest); - - it('should return Array', () => { - expect(Array.isArray(result)).to.equal(true); - }); - - it('should get the correct bid response', () => { - expect(result[0].cpm).to.equal(1500); - expect(result[0].creativeId).to.equal('1'); - expect(result[0].width).to.equal(320); - expect(result[0].height).to.equal(180); - expect(result[0].mediaType).to.equal('video'); - expect(result[0].netRevenue).to.equal(true); - expect(result[0].requestId).to.equal('209c1fb5ad88f5'); - expect(result[0].ttl).to.equal(3000); - expect(result[0].vastXml).to.equal(''); - }); - }); -}); diff --git a/test/spec/modules/cedatoBidAdapter_spec.js b/test/spec/modules/cedatoBidAdapter_spec.js deleted file mode 100644 index a7f4875afff..00000000000 --- a/test/spec/modules/cedatoBidAdapter_spec.js +++ /dev/null @@ -1,133 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/cedatoBidAdapter.js'; - -describe('the cedato adapter', function () { - function getValidBidObject() { - return { - bidId: '2f4a613a702b6c', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - params: { - player_id: 1450133326, - } - }; - }; - - describe('isBidRequestValid', function() { - var bid; - - beforeEach(function() { - bid = getValidBidObject(); - }); - - it('should fail validation if the bid isn\'t defined or not an object', function() { - var result = spec.isBidRequestValid(); - - expect(result).to.equal(false); - - result = spec.isBidRequestValid('not an object'); - - expect(result).to.equal(false); - }); - }); - - describe('buildRequests', function() { - var bid, bidRequestObj; - - beforeEach(function() { - bid = getValidBidObject(); - bidRequestObj = { - refererInfo: {referer: 'prebid.js'}, - gdprConsent: { - consentString: 'test-string', - gdprApplies: true - }, - uspConsent: '1NYN' - }; - }); - - it('should build a very basic request', function() { - var [request] = spec.buildRequests([bid], bidRequestObj); - expect(request.method).to.equal('POST'); - }); - - it('should pass gdpr and usp strings to server', function() { - var [request] = spec.buildRequests([bid], bidRequestObj); - var payload = JSON.parse(request.data); - expect(payload.gdpr_consent).to.not.be.undefined; - expect(payload.gdpr_consent.consent_string).to.equal(bidRequestObj.gdprConsent.consentString); - expect(payload.gdpr_consent.consent_required).to.equal(bidRequestObj.gdprConsent.gdprApplies); - expect(payload.us_privacy).to.equal(bidRequestObj.uspConsent); - }); - }); - - describe('interpretResponse', function() { - var bid, serverResponse, bidderRequest; - - beforeEach(function() { - bid = getValidBidObject(); - serverResponse = { - body: { - bidid: '0.36157306192821', - seatbid: [ - { - seat: '0', - bid: [{ - gp: { - 'negative': 0.496954, - 'positive': 0.503046, - 'class': '0' - }, - id: '0.75549202124378', - adomain: 'cedato.com', - uuid: bid.bidId, - crid: '1450133326', - adm: "
\n\n\n", - h: 250, - w: 300, - price: '0.1' - }] - } - ], - cur: 'USD' - } - }; - bidderRequest = { - bids: [bid] - }; - }); - - it('should return an array of bid responses', function() { - var responses = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(responses).to.be.an('array').with.length(1); - }); - }); - - describe('getUserSyncs', function() { - var bid; - - beforeEach(function() { - bid = getValidBidObject(); - }); - - it('should sync with iframe', function() { - var syncs = spec.getUserSyncs({ iframeEnabled: true }, null, { - consentString: '', - gdprApplies: true - }); - - expect(syncs).to.be.an('array').with.length(1); - expect(syncs[0].type).to.equal('iframe'); - }); - - it('should sync with image', function() { - var syncs = spec.getUserSyncs({ pixelEnabled: true }); - - expect(syncs).to.be.an('array').with.length(1); - expect(syncs[0].type).to.equal('image'); - }); - }); -}); diff --git a/test/spec/modules/clickforceBidAdapter_spec.js b/test/spec/modules/clickforceBidAdapter_spec.js deleted file mode 100644 index dad00f94641..00000000000 --- a/test/spec/modules/clickforceBidAdapter_spec.js +++ /dev/null @@ -1,190 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/clickforceBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('ClickforceAdapter', 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': 'clickforce', - 'params': { - 'zone': '6682' - }, - 'adUnitCode': 'adunit-code', - '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': 'clickforce', - 'params': { - 'zone': '6682' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - }); - - describe('interpretResponse', function () { - let response = [{ - 'cpm': 0.5, - 'width': '300', - 'height': '250', - 'callback_uid': '220ed41385952a', - 'type': 'Default Ad', - 'tag': '', - 'creativeId': '1f99ac5c3ef10a4097499a5686b30aff-6682', - 'requestId': '220ed41385952a', - 'currency': 'USD', - 'ttl': 60, - 'netRevenue': true, - 'zone': '6682' - }]; - - let response1 = [{ - 'cpm': 0.0625, - 'width': '3', - 'height': '3', - 'callback_uid': '2e27ec595bf1a', - 'type': 'public Bid', - 'tag': { - 'content': { - 'title': 'title', - 'content': 'content', - 'advertiser': 'advertiser', - 'button_text': 'button_text', - 'image': 'image', - 'icon': 'icon' - }, - 'cu': ['cu'], - 'iu': ['iu'], - 'p': '6878:11062:32586:8380573788dad9b9fc17edde444c4dcf:2795' - }, - 'creativeId': '8380573788dad9b9fc17edde444c4dcf-6878', - 'requestId': '2e27ec595bf1a', - 'currency': 'USD', - 'ttl': 60, - 'netRevenue': true, - 'zone': '6878' - }]; - - let expectedResponse = [{ - 'requestId': '220ed41385952a', - 'cpm': 0.5, - 'width': '300', - 'height': '250', - 'creativeId': '1f99ac5c3ef10a4097499a5686b30aff-6682', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 60, - 'ad': '', - 'mediaType': 'banner', - }]; - - let expectedResponse1 = [{ - 'requestId': '2e27ec595bf1a', - 'cpm': 0.0625, - 'width': '3', - 'height': '3', - 'creativeId': '8380573788dad9b9fc17edde444c4dcf-6878', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 60, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'image', - 'width': 1600, - 'height': 900 - }, - 'title': 'title', - 'sponsoredBy': 'advertiser', - 'body': 'content', - 'icon': { - 'url': 'icon', - 'width': 900, - 'height': 900 - }, - 'clickUrl': 'cu', - 'impressionTrackers': ['iu'] - } - }]; - - it('should get the correct bid response by display ad', function () { - let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('should get the correct bid response by native ad', function () { - let bidderRequest; - let result = spec.interpretResponse({ body: response1 }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse1[0])); - }); - - it('handles empty bid response', function () { - let response = { - body: {} - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs function', function () { - it('should register type is iframe', function () { - const syncOptions = { - 'iframeEnabled': 'true' - } - let userSync = spec.getUserSyncs(syncOptions); - expect(userSync[0].type).to.equal('iframe'); - expect(userSync[0].url).to.equal('https://cdn.holmesmind.com/js/capmapping.htm'); - }); - - it('should register type is image', function () { - const syncOptions = { - 'pixelEnabled': 'true' - } - let userSync = spec.getUserSyncs(syncOptions); - expect(userSync[0].type).to.equal('image'); - expect(userSync[0].url).to.equal('https://c.holmesmind.com/cm'); - }); - }); -}); diff --git a/test/spec/modules/clicktripzBidAdapter_spec.js b/test/spec/modules/clicktripzBidAdapter_spec.js deleted file mode 100644 index fed94811c4e..00000000000 --- a/test/spec/modules/clicktripzBidAdapter_spec.js +++ /dev/null @@ -1,152 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/clicktripzBidAdapter.js'; - -const ENDPOINT_URL = 'https://www.clicktripz.com/x/prebid/v1'; - -describe('clicktripzBidAdapter', function () { - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'clicktripz', - 'params': { - placementId: 'testPlacementId', - siteId: 'testSiteId' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '1234asdf1234', - 'bidderRequestId': '1234asdf1234asdf', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' - }; - - let bid2 = { - 'bidder': 'clicktripz', - 'params': { - placementId: 'testPlacementId' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '1234asdf1234', - 'bidderRequestId': '1234asdf1234asdf', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' - }; - - let bid3 = { - 'bidder': 'clicktripz', - 'params': { - siteId: 'testSiteId' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '1234asdf1234', - 'bidderRequestId': '1234asdf1234asdf', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are NOT found', function () { - expect(spec.isBidRequestValid(bid2)).to.equal(false); - expect(spec.isBidRequestValid(bid3)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let validBidRequests = [{ - 'bidder': 'clicktripz', - 'params': { - placementId: 'testPlacementId', - siteId: 'testSiteId' - }, - 'sizes': [ - [300, 250], - [300, 300] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }, { - 'bidder': 'clicktripz', - 'params': { - placementId: 'testPlacementId2', - siteId: 'testSiteId2' - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '25beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }]; - - const request = spec.buildRequests(validBidRequests); - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('sends bid request to our endpoint at the correct URL', function () { - expect(request.url).to.equal(ENDPOINT_URL); - }); - it('sends bid request to our endpoint at the correct URL', function () { - expect(request.url).to.equal(ENDPOINT_URL); - }); - - it('transforms sizes into an array of strings. Pairs of concatenated sizes joined with an x', function () { - expect(request.data[0].sizes.toString()).to.equal('300x250,300x300'); - }); - it('transforms sizes into an array of strings. Pairs of concatenated sizes joined with an x', function () { - expect(request.data[1].sizes.toString()).to.equal('300x250'); - }); - - it('includes bidId, siteId, and placementId in payload', function () { - expect(request.data[0].bidId).to.equal('23beaa6af6cdde'); - expect(request.data[0].siteId).to.equal('testSiteId'); - expect(request.data[0].placementId).to.equal('testPlacementId'); - }); - it('includes bidId, siteId, and placementId in payload', function () { - expect(request.data[1].bidId).to.equal('25beaa6af6cdde'); - expect(request.data[1].siteId).to.equal('testSiteId2'); - expect(request.data[1].placementId).to.equal('testPlacementId2'); - }); - }); - - describe('interpretResponse', function () { - let serverResponse = { - body: [{ - 'bidId': 'bid-request-id', - 'ttl': 120, - 'netRevenue': true, - 'size': '300x200', - 'currency': 'USD', - 'adUrl': 'https://www.clicktripz.com/n3/crane/v0/render?t=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoiaHR0cHM6XC9cL3d3dy5jbGlja3RyaXB6LmNvbVwvY2xpY2sucGhwP2NhbXBhaWduSUQ9MTkxNTYmcHJlQ2hlY2tlZD0xJnB1Ymxpc2hlcklEPTM2MCZzZWFyY2hLZXk9N2M5MzQ0NzhlM2M1NTc3Y2EyN2ZmN2Y1NTg5N2NkMzkmc2VhcmNoRGlzcGxheVR5cGU9MSZkaXNwbGF5VHlwZT00JmNyZWF0aXZlVHlwZT1zaW5nbGUmaXNQb3BVbmRlcj0wJnBvc2l0aW9uPTEmdHlwZT0xJmNpdHk9TWFkcmlkJTJDK1NwYWluJmNoZWNrSW5EYXRlPTAzJTJGMDElMkYyMDIwJmNoZWNrT3V0RGF0ZT0wMyUyRjA1JTJGMjAyMCZndWVzdHM9MiZyb29tcz0xIn0.WBDGYr1qfkSvOuK02VpMW3iAua1E02jjDGDViFc2kaE', - 'creativeId': '25ef9876abc5681f153', - 'cpm': 50 - }] - }; - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': 'bid-request-id', - 'cpm': 50, - 'netRevenue': true, - 'width': '300', - 'height': '200', - 'creativeId': '25ef9876abc5681f153', - 'currency': 'USD', - 'adUrl': 'https://www.clicktripz.com/n3/crane/v0/render?t=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoiaHR0cHM6XC9cL3d3dy5jbGlja3RyaXB6LmNvbVwvY2xpY2sucGhwP2NhbXBhaWduSUQ9MTkxNTYmcHJlQ2hlY2tlZD0xJnB1Ymxpc2hlcklEPTM2MCZzZWFyY2hLZXk9N2M5MzQ0NzhlM2M1NTc3Y2EyN2ZmN2Y1NTg5N2NkMzkmc2VhcmNoRGlzcGxheVR5cGU9MSZkaXNwbGF5VHlwZT00JmNyZWF0aXZlVHlwZT1zaW5nbGUmaXNQb3BVbmRlcj0wJnBvc2l0aW9uPTEmdHlwZT0xJmNpdHk9TWFkcmlkJTJDK1NwYWluJmNoZWNrSW5EYXRlPTAzJTJGMDElMkYyMDIwJmNoZWNrT3V0RGF0ZT0wMyUyRjA1JTJGMjAyMCZndWVzdHM9MiZyb29tcz0xIn0.WBDGYr1qfkSvOuK02VpMW3iAua1E02jjDGDViFc2kaE', - 'ttl': 120 - }]; - let result = spec.interpretResponse(serverResponse); - expect(result).to.deep.equal(expectedResponse); - }); - }); -}); diff --git a/test/spec/modules/collectcentBidAdapter_spec.js b/test/spec/modules/collectcentBidAdapter_spec.js deleted file mode 100644 index 0ab83a8024b..00000000000 --- a/test/spec/modules/collectcentBidAdapter_spec.js +++ /dev/null @@ -1,118 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/collectcentBidAdapter.js'; - -describe('Collectcent', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'collectcent', - 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('https://publishers.motionspots.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', '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('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 4e80c6b1d9d..00000000000 --- a/test/spec/modules/colombiaBidAdapter_spec.js +++ /dev/null @@ -1,152 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/colombiaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const HOST_NAME = document.location.protocol + '//' + window.location.host; -const ENDPOINT = 'https://ade.clmbtech.com/cde/prebid.htm'; - -describe('colombiaBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when placementId not passed correctly', function () { - bid.params.placementId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code1', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }, - { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code2', - 'sizes': [ - [300, 250] - ], - 'bidId': '382091349b149f"', - 'bidderRequestId': '"1f9c98192de251"', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - } - ]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via POST', function () { - expect(request[0].method).to.equal('POST'); - expect(request[1].method).to.equal('POST'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request[0].url).to.equal(ENDPOINT); - expect(request[1].url).to.equal(ENDPOINT); - }); - }); - - describe('interpretResponse', function () { - let bidRequest = [ - { - 'method': 'POST', - 'url': 'https://ade.clmbtech.com/cde/prebid.htm', - 'data': { - 'v': 'hb1', - 'p': '307466', - 'w': '300', - 'h': '250', - 'cb': 12892917383, - 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', - 'uid': '23beaa6af6cdde', - 't': 'i', - } - } - ]; - - let serverResponse = { - body: { - 'ad': '
This is test case for colombia adapter
', - 'cpm': 3.14, - 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', - 'currency': 'USD', - 'uid': '23beaa6af6cdde', - 'width': 728, - 'height': 90, - 'netRevenue': true, - 'ttl': 600, - 'dealid': '', - 'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836' - } - }; - - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 3.14, - 'width': 728, - 'height': 90, - 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', - 'dealId': '', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', - 'ad': '
This is test case for colombia adapter
' - }]; - let result = spec.interpretResponse(serverResponse, bidRequest[0]); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'uid': '23beaa6af6cdde', - 'height': 0, - 'creativeId': '', - 'statusMessage': 'Bid returned empty or error response', - 'width': 0, - 'cpm': 0 - } - }; - let result = spec.interpretResponse(response, bidRequest[0]); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js deleted file mode 100644 index f6e24d07c63..00000000000 --- a/test/spec/modules/colossussspBidAdapter_spec.js +++ /dev/null @@ -1,185 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/colossussspBidAdapter.js'; - -describe('ColossussspAdapter', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'colossusssp', - bidderRequestId: '145e1d6a7837c9', - params: { - placement_id: 0 - }, - placementCode: 'placementid_0', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', - schain: { - ver: '1.0', - complete: 1, - nodes: [ - { - asi: 'example.com', - sid: '0', - hp: 1, - rid: 'bidrequestid', - // name: 'alladsallthetime', - domain: 'example.com' - } - ] - } - }; - let bidderRequest = { - bidderCode: 'colossus', - auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff', - bidderRequestId: 'ffffffffffffff', - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000, - uspConsent: '1YN-', - refererInfo: { - referer: 'http://www.example.com', - reachedTop: true, - }, - bids: [bid] - } - - describe('isBidRequestValid', function () { - it('Should return true when placement_id can be cast to a number', function () { - 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; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid], bidderRequest); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://colossusssp.com/?c=o&m=multi'); - }); - it('Should contain ccpa', function() { - expect(serverRequest.data.ccpa).to.be.an('string') - }) - - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa'); - 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', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'floor'); - expect(placement.schain).to.be.an('object') - expect(placement.placementId).to.be.a('number'); - expect(placement.bidId).to.be.a('string'); - expect(placement.traffic).to.be.a('string'); - expect(placement.sizes).to.be.an('array'); - expect(placement.floor).to.be.an('object'); - } - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - - describe('buildRequests with user ids', function () { - bid.userId = {} - bid.userId.britepoolid = 'britepoolid123'; - bid.userId.idl_env = 'idl_env123'; - bid.userId.tdid = 'tdid123'; - bid.userId.id5id = { uid: 'id5id123' }; - let serverRequest = spec.buildRequests([bid], bidderRequest); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - let placements = data['placements']; - expect(data).to.be.an('object'); - for (let i = 0; i < placements.length; i++) { - let placement = placements[i]; - expect(placement).to.have.property('eids') - expect(placement.eids).to.be.an('array') - expect(placement.eids.length).to.be.equal(4) - for (let index in placement.eids) { - let v = placement.eids[index]; - expect(v).to.have.all.keys('source', 'uids') - expect(v.source).to.be.oneOf(['britepool.com', 'identityLink', 'adserver.org', 'id5-sync.com']) - expect(v.uids).to.be.an('array'); - expect(v.uids.length).to.be.equal(1) - expect(v.uids[0]).to.have.property('id') - } - } - }); - }); - - 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('https://colossusssp.com/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/convergeBidAdapter_spec.js b/test/spec/modules/convergeBidAdapter_spec.js deleted file mode 100644 index e92ed475497..00000000000 --- a/test/spec/modules/convergeBidAdapter_spec.js +++ /dev/null @@ -1,899 +0,0 @@ -import { expect } from 'chai'; -import { spec, resetUserSync, getSyncUrl } from 'modules/convergeBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('ConvergeAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'converge', - 'params': { - 'uid': '1' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - function parseRequest(url) { - const res = {}; - url.split('&').forEach((it) => { - const couple = it.split('='); - res[couple[0]] = decodeURIComponent(couple[1]); - }); - return res; - } - - const bidderRequest = { - refererInfo: { - referer: 'https://example.com' - } - }; - const referrer = bidderRequest.refererInfo.referer; - - let bidRequests = [ - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90], [300, 250]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '60' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u', referrer); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '59'); - expect(payload).to.have.property('sizes', '300x250,300x600'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - expect(payload).to.have.property('wrapperType', 'Prebid_js'); - expect(payload).to.have.property('wrapperVersion', '$prebid.version$'); - }); - - it('sizes must not be duplicated', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u', referrer); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '59,59,60'); - expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u', referrer); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '59,59,60'); - expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u', referrer); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '59,59,60'); - expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - delete bidRequests[1].params.priceType; - }); - - it('if gdprConsent is present payload must have gdpr params', function () { - const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: true}}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', '1'); - }); - - it('if gdprApplies is false gdpr_applies must be 0', function () { - const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: false}}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', '0'); - }); - - it('if gdprApplies is undefined gdpr_applies must be 1', function () { - const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA'}}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', '1'); - }); - - it('if usPrivacy is present payload must have us_privacy param', function () { - const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithUSP); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('us_privacy', '1YNN'); - }); - - it('should convert keyword params to proper form and attaches to request', function () { - const bidRequestWithKeywords = [].concat(bidRequests); - bidRequestWithKeywords[1] = Object.assign({}, - bidRequests[1], - { - params: { - uid: '59', - keywords: { - single: 'val', - singleArr: ['val'], - singleArrNum: [5], - multiValMixed: ['value1', 2, 'value3'], - singleValNum: 123, - emptyStr: '', - emptyArr: [''], - badValue: {'foo': 'bar'} // should be dropped - } - } - } - ); - - const request = spec.buildRequests(bidRequestWithKeywords, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.keywords).to.be.an('string'); - payload.keywords = JSON.parse(payload.keywords); - - expect(payload.keywords).to.deep.equal([{ - 'key': 'single', - 'value': ['val'] - }, { - 'key': 'singleArr', - 'value': ['val'] - }, { - 'key': 'singleArrNum', - 'value': ['5'] - }, { - 'key': 'multiValMixed', - 'value': ['value1', '2', 'value3'] - }, { - 'key': 'singleValNum', - 'value': ['123'] - }, { - 'key': 'emptyStr' - }, { - 'key': 'emptyArr' - }]); - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 60, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 59, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 61, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 5
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 59, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '60' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 59, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 60, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 2
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 0.15, - 'creativeId': 59, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 3
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(0, 3)}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'converge', - 'params': { - 'uid': '61' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '65' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '70' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(3)}}, request); - expect(result.length).to.equal(0); - }); - - it('complicated case', function () { - const fullResponse = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 60, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 59, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 4
', 'auid': 59, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 5
', 'auid': 60, 'h': 600, 'w': 350}], 'seat': '1'}, - ]; - const bidRequests = [ - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '2164be6358b9', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '326bde7fbf69', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '60' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4e111f1b66e4', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '26d6f897b516', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '60' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '1751cd90161', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '2164be6358b9', - 'cpm': 1.15, - 'creativeId': 59, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4e111f1b66e4', - 'cpm': 0.5, - 'creativeId': 60, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 2
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '26d6f897b516', - 'cpm': 0.15, - 'creativeId': 59, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 3
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '326bde7fbf69', - 'cpm': 0.15, - 'creativeId': 59, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 4
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('dublicate uids and sizes in one slot', function () { - const fullResponse = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, - ]; - const bidRequests = [ - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '5126e301f4be', - 'bidderRequestId': '171c5405a390', - 'auctionId': '35bcbc0f7e79c', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '57b2ebe70e16', - 'bidderRequestId': '171c5405a390', - 'auctionId': '35bcbc0f7e79c', - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '59' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '225fcd44b18c', - 'bidderRequestId': '171c5405a390', - 'auctionId': '35bcbc0f7e79c', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '5126e301f4be', - 'cpm': 1.15, - 'creativeId': 59, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '57b2ebe70e16', - 'cpm': 0.5, - 'creativeId': 59, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 2
', - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - }); - - it('should get correct video bid response', function () { - const bidRequests = [ - { - 'bidder': 'converge', - 'params': { - 'uid': '58' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '57dfefb80eca', - 'bidderRequestId': '20394420a762a2', - 'auctionId': '140132d07b031', - 'mediaTypes': { - 'video': { - 'context': 'instream' - } - } - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '60' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': 'e893c787c22dd', - 'bidderRequestId': '20394420a762a2', - 'auctionId': '140132d07b031', - 'mediaTypes': { - 'video': { - 'context': 'instream' - } - } - } - ]; - const response = [ - {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 58, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, - {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 60, content_type: 'video'}], 'seat': '2'} - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '57dfefb80eca', - 'cpm': 1.15, - 'creativeId': 58, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'video', - 'netRevenue': true, - 'ttl': 360, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - } - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': response}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should have right renderer in the bid response', function () { - const spySetRenderer = sinon.spy(); - const stubRenderer = { - setRender: spySetRenderer - }; - const spyRendererInstall = sinon.spy(function() { return stubRenderer; }); - const stubRendererConst = { - install: spyRendererInstall - }; - const bidRequests = [ - { - 'bidder': 'converge', - 'params': { - 'uid': '58' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': 'e6e65553fc8', - 'bidderRequestId': '1380f393215dc7', - 'auctionId': '10b8d2f3c697e3', - 'mediaTypes': { - 'video': { - 'context': 'outstream' - } - } - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '60' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': 'c8fdcb3f269f', - 'bidderRequestId': '1380f393215dc7', - 'auctionId': '10b8d2f3c697e3' - }, - { - 'bidder': 'converge', - 'params': { - 'uid': '61' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '1de036c37685', - 'bidderRequestId': '1380f393215dc7', - 'auctionId': '10b8d2f3c697e3', - 'renderer': {} - } - ]; - const response = [ - {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 58, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, - {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 60, content_type: 'video', w: 300, h: 250}], 'seat': '2'}, - {'bid': [{'price': 1.20, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 61, content_type: 'video', w: 300, h: 250}], 'seat': '2'} - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': 'e6e65553fc8', - 'cpm': 1.15, - 'creativeId': 58, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'video', - 'netRevenue': true, - 'ttl': 360, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - }, - 'renderer': stubRenderer - }, - { - 'requestId': 'c8fdcb3f269f', - 'cpm': 1.00, - 'creativeId': 60, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'video', - 'netRevenue': true, - 'ttl': 360, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - }, - 'renderer': stubRenderer - }, - { - 'requestId': '1de036c37685', - 'cpm': 1.20, - 'creativeId': 61, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'bidderCode': 'converge', - 'currency': 'EUR', - 'mediaType': 'video', - 'netRevenue': true, - 'ttl': 360, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - } - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': response}}, request, stubRendererConst); - - expect(spySetRenderer.calledTwice).to.equal(true); - expect(spySetRenderer.getCall(0).args[0]).to.be.a('function'); - expect(spySetRenderer.getCall(1).args[0]).to.be.a('function'); - - expect(spyRendererInstall.calledTwice).to.equal(true); - expect(spyRendererInstall.getCall(0).args[0]).to.deep.equal({ - id: 'e6e65553fc8', - url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', - loaded: false - }); - expect(spyRendererInstall.getCall(1).args[0]).to.deep.equal({ - id: 'c8fdcb3f269f', - url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', - loaded: false - }); - - expect(result).to.deep.equal(expectedResponse); - }); - - describe('user sync', function () { - const syncUrl = getSyncUrl(); - - beforeEach(function () { - resetUserSync(); - }); - - it('should register sync image', function () { - let syncs = spec.getUserSyncs({ - pixelEnabled: true - }); - - expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); - }); - - it('should not register sync image more than once', function () { - let syncs = spec.getUserSyncs({ - pixelEnabled: true - }); - expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); - - // when called again, should still have only been called once - syncs = spec.getUserSyncs(); - expect(syncs).to.equal(undefined); - }); - - it('should pass gdpr params if consent is true', function () { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { - gdprApplies: true, consentString: 'foo' - })).to.deep.equal({ - type: 'image', url: `${syncUrl}&gdpr=1&gdpr_consent=foo` - }); - }); - - it('should pass gdpr params if consent is false', function () { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { - gdprApplies: false, consentString: 'foo' - })).to.deep.equal({ - type: 'image', url: `${syncUrl}&gdpr=0&gdpr_consent=foo` - }); - }); - - it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { - consentString: 'foo' - })).to.deep.equal({ - type: 'image', url: `${syncUrl}&gdpr_consent=foo` - }); - }); - - it('should pass no params if gdpr consentString is not defined', function () { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {})).to.deep.equal({ - type: 'image', url: syncUrl - }); - }); - - it('should pass no params if gdpr consentString is a number', function () { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { - consentString: 0 - })).to.deep.equal({ - type: 'image', url: syncUrl - }); - }); - - it('should pass no params if gdpr consentString is null', function () { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { - consentString: null - })).to.deep.equal({ - type: 'image', url: syncUrl - }); - }); - - it('should pass no params if gdpr consentString is a object', function () { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { - consentString: {} - })).to.deep.equal({ - type: 'image', url: syncUrl - }); - }); - - it('should pass no params if gdpr is not defined', function () { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined)).to.deep.equal({ - type: 'image', url: syncUrl - }); - }); - - it('should pass usPrivacy param if it is available', function() { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {}, '1YNN')).to.deep.equal({ - type: 'image', url: `${syncUrl}&us_privacy=1YNN` - }); - }); - }); -}); diff --git a/test/spec/modules/cpmstarBidAdapter_spec.js b/test/spec/modules/cpmstarBidAdapter_spec.js deleted file mode 100644 index 285fca9690a..00000000000 --- a/test/spec/modules/cpmstarBidAdapter_spec.js +++ /dev/null @@ -1,231 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/cpmstarBidAdapter.js'; -import { deepClone } from 'src/utils.js'; -import { config } from 'src/config.js'; - -const valid_bid_requests = [{ - 'bidder': 'cpmstar', - 'params': { - 'placementId': '57' - }, - 'sizes': [[300, 250]], - 'bidId': 'bidId' -}]; - -const bidderRequest = { - refererInfo: { - referer: 'referer', - reachedTop: false, - } -}; - -const serverResponse = { - body: [{ - creatives: [{ - cpm: 1, - width: 0, - height: 0, - currency: 'USD', - netRevenue: true, - ttl: 1, - creativeid: '1234', - requestid: '11123', - code: 'no idea', - media: 'banner', - } - ], - syncs: [{ type: 'image', url: 'https://server.cpmstar.com/pixel.aspx' }] - }] -}; - -describe('Cpmstar Bid Adapter', function () { - describe('isBidRequestValid', function () { - it('should return true since the bid is valid', - function () { - var bid = { params: { placementId: 123456 } }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }) - - it('should return false since the bid is invalid', function () { - var bid = { params: { placementId: '' } }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }) - - it('should return a valid player size', function () { - var bid = { - mediaTypes: { - video: { - playerSize: [[960, 540]] - } - } - } - expect(spec.getPlayerSize(bid)[0]).to.equal(960); - expect(spec.getPlayerSize(bid)[1]).to.equal(540); - }) - - it('should return a default player size', function () { - var bid = { - mediaTypes: { - video: { - playerSize: null - } - } - } - expect(spec.getPlayerSize(bid)[0]).to.equal(640); - expect(spec.getPlayerSize(bid)[1]).to.equal(440); - }) - }); - - describe('buildRequests', function () { - it('should produce a valid production request', function () { - var requests = spec.buildRequests(valid_bid_requests, bidderRequest); - 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('https://server.cpmstar.com/view.aspx'); - }); - it('should produce a valid staging request', function () { - var stgReq = deepClone(valid_bid_requests); - stgReq[0].params.endpoint = 'staging'; - var requests = spec.buildRequests(stgReq, bidderRequest); - 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('https://staging.server.cpmstar.com/view.aspx'); - }); - it('should produce a valid dev request', function () { - var devReq = deepClone(valid_bid_requests); - devReq[0].params.endpoint = 'dev'; - var requests = spec.buildRequests(devReq, bidderRequest); - 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('https://dev.server.cpmstar.com/view.aspx'); - }); - it('should produce a request with support for GDPR', function () { - var gdpr_bidderRequest = deepClone(bidderRequest); - gdpr_bidderRequest.gdprConsent = { - consentString: 'consentString', - gdprApplies: true - }; - var requests = spec.buildRequests(valid_bid_requests, gdpr_bidderRequest); - expect(requests[0]).to.have.property('url'); - expect(requests[0].url).to.include('gdpr_consent=consentString'); - expect(requests[0].url).to.include('gdpr=1'); - }); - it('should produce a request with support for USP', function () { - var usp_bidderRequest = deepClone(bidderRequest); - usp_bidderRequest.uspConsent = '1YYY'; - var requests = spec.buildRequests(valid_bid_requests, usp_bidderRequest); - expect(requests[0]).to.have.property('url'); - expect(requests[0].url).to.include('us_privacy=1YYY'); - }); - it('should produce a request with support for COPPA', function () { - sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); - var requests = spec.buildRequests(valid_bid_requests, bidderRequest); - config.getConfig.restore(); - expect(requests[0]).to.have.property('url'); - expect(requests[0].url).to.include('tfcd=1'); - }); - }); - - it('should produce a request with support for OpenRTB SupplyChain', function () { - var reqs = deepClone(valid_bid_requests); - reqs[0].schain = { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ - { - 'asi': 'exchange1.com', - 'sid': '1234', - 'hp': 1 - }, - { - 'asi': 'exchange2.com', - 'sid': 'abcd', - 'hp': 1 - } - ] - }; - var requests = spec.buildRequests(reqs, bidderRequest); - expect(requests[0]).to.have.property('url'); - expect(requests[0].url).to.include('&schain=1.0,1!exchange1.com,1234,1,,,!exchange2.com,abcd,1,,,'); - }); - - describe('interpretResponse', function () { - const request = { - bidRequest: { - mediaType: 'BANNER' - } - }; - - it('should return a valid bidresponse array', function () { - var r = spec.interpretResponse(serverResponse, request) - var c = serverResponse.body[0].creatives[0]; - expect(r[0].length).to.not.equal(0); - expect(r[0].requestId).equal(c.requestid); - expect(r[0].creativeId).equal(c.creativeid); - expect(r[0].cpm).equal(c.cpm); - expect(r[0].width).equal(c.width); - expect(r[0].height).equal(c.height); - expect(r[0].currency).equal(c.currency); - expect(r[0].netRevenue).equal(c.netRevenue); - expect(r[0].ttl).equal(c.ttl); - expect(r[0].ad).equal(c.code); - }); - - it('should return a valid bidresponse array from a non-array-body', function () { - var r = spec.interpretResponse({ body: serverResponse.body[0] }, request) - var c = serverResponse.body[0].creatives[0]; - expect(r[0].length).to.not.equal(0); - expect(r[0].requestId).equal(c.requestid); - expect(r[0].creativeId).equal(c.creativeid); - expect(r[0].cpm).equal(c.cpm); - expect(r[0].width).equal(c.width); - expect(r[0].height).equal(c.height); - expect(r[0].currency).equal(c.currency); - expect(r[0].netRevenue).equal(c.netRevenue); - expect(r[0].ttl).equal(c.ttl); - expect(r[0].ad).equal(c.code); - }); - - it('should return undefined due to an invalid cpm value', function () { - var badServer = deepClone(serverResponse); - badServer.body[0].creatives[0].cpm = 0; - var c = spec.interpretResponse(badServer, request); - expect(c).to.be.undefined; - }); - - it('should return undefined due to a bad response', function () { - var badServer = deepClone(serverResponse); - badServer.body[0].creatives[0].code = null; - var c = spec.interpretResponse(badServer, request); - expect(c).to.be.undefined; - }); - - it('should return a valid response with a dealId', function () { - var dealServer = deepClone(serverResponse); - dealServer.body[0].creatives[0].dealId = 'deal'; - expect(spec.interpretResponse(dealServer, request)[0].dealId).to.equal('deal'); - }); - }); - - describe('getUserSyncs', function () { - var sres = [deepClone(serverResponse)]; - - it('should return a valid pixel sync', function () { - var syncs = spec.getUserSyncs({ pixelEnabled: true }, sres); - expect(syncs.length).equal(1); - expect(syncs[0].type).equal('image'); - expect(syncs[0].url).equal('https://server.cpmstar.com/pixel.aspx'); - }); - - it('should return a valid iframe sync', function () { - sres[0].body[0].syncs[0].type = 'iframe'; - var syncs = spec.getUserSyncs({ iframeEnabled: true }, sres); - expect(syncs.length).equal(1); - expect(syncs[0].type).equal('iframe'); - expect(syncs[0].url).equal('https://server.cpmstar.com/pixel.aspx'); - }); - }); -}); diff --git a/test/spec/modules/decenteradsBidAdapter_spec.js b/test/spec/modules/decenteradsBidAdapter_spec.js deleted file mode 100644 index 257094cae3a..00000000000 --- a/test/spec/modules/decenteradsBidAdapter_spec.js +++ /dev/null @@ -1,207 +0,0 @@ -import { expect } from 'chai' -import { spec } from '../../../modules/decenteradsBidAdapter.js' -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('https://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: 'https://supply.decenterads.com/?c=o&m=cookie' }] - deepStrictEqual(expectedResult, spec.getUserSyncs()) - }) - }) -}) diff --git a/test/spec/modules/djaxBidAdapter_spec.js b/test/spec/modules/djaxBidAdapter_spec.js deleted file mode 100644 index bef2b1fddc5..00000000000 --- a/test/spec/modules/djaxBidAdapter_spec.js +++ /dev/null @@ -1,159 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/djaxBidAdapter.js'; - -const ENDPOINT = 'https://demo.reviveadservermod.com/headerbidding_adminshare/www/admin/plugins/Prebid/getAd.php'; - -describe('The Djax bidding adapter', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'djax', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - - it('should return true when given a publisherId in bid', function () { - const bid = { - bidder: 'djax', - params: { - publisherId: 2 - }, - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [{ - 'bidder': 'djax', - 'params': { - 'publisherId': 2 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ] - }]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('check endpoint url', function () { - expect(request.url).to.equal(ENDPOINT) - }); - - it('sets the proper banner object', function () { - expect(bidRequests[0].params.publisherId).to.equal(2); - }) - }); - const response = { - body: [ - { - 'requestId': '2ee937f15015c6', - 'cpm': '0.2000', - 'width': 300, - 'height': 600, - 'creativeId': '4', - 'currency': 'USD', - 'netRevenue': true, - 'ad': 'ads.html', - 'mediaType': 'banner' - }, - { - 'requestId': '3e1af92622bdc', - 'cpm': '0.2000', - 'creativeId': '4', - 'context': 'outstream', - 'currency': 'USD', - 'netRevenue': true, - 'vastUrl': 'tezt.xml', - 'width': 640, - 'height': 480, - 'mediaType': 'video' - }] - }; - - const request = [ - { - 'bidder': 'djax', - 'params': { - 'publisherId': 2 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 600] - ] - } - }, - 'bidId': '2ee937f15015c6', - 'src': 'client', - }, - { - 'bidder': 'djax', - 'params': { - 'publisherId': 2 - }, - 'mediaTypes': { - 'video': { - 'context': 'outstream', - 'playerSize': [ - [640, 480] - ] - } - }, - 'bidId': '3e1af92622bdc', - 'src': 'client', - } - ]; - - describe('interpretResponse', function () { - it('return empty array when no ad found', function () { - const response = {}; - const request = { bidRequests: [] }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('check response for banner and video', function () { - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(2); - expect(bids[0].requestId).to.equal('2ee937f15015c6'); - expect(bids[0].cpm).to.equal('0.2000'); - expect(bids[1].cpm).to.equal('0.2000'); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(600); - expect(bids[1].vastUrl).to.not.equal(''); - expect(bids[0].ad).to.not.equal(''); - expect(bids[1].adResponse).to.not.equal(''); - expect(bids[1].renderer).not.to.be.an('undefined'); - }); - }); - - describe('On winning bid', function () { - const bids = spec.interpretResponse(response, request); - spec.onBidWon(bids); - }); - - describe('On bid Time out', function () { - const bids = spec.interpretResponse(response, request); - spec.onTimeout(bids); - }); - - describe('user sync', function () { - it('to check the user sync iframe', function () { - let syncs = spec.getUserSyncs({ - iframeEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - }); - }); -}); diff --git a/test/spec/modules/e_volutionBidAdapter_spec.js b/test/spec/modules/e_volutionBidAdapter_spec.js deleted file mode 100644 index 447420616d1..00000000000 --- a/test/spec/modules/e_volutionBidAdapter_spec.js +++ /dev/null @@ -1,235 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/e_volutionBidAdapter.js'; - -describe('EvolutionTechBidAdapter', function () { - let bid = { - bidId: '23fhj33i987f', - bidder: 'e_volution', - params: { - placementId: 0, - traffic: 'banner' - } - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are bidId, params and placementId parameters present', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false if at least one of parameters is not present', function () { - delete bid.params.placementId; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://service.e-volution.ai/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.language).to.be.a('string'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); - expect(placement.placementId).to.equal(0); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal('banner'); - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - if (spec.noSync) { - expect(userSync).to.be.equal(false); - } else { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://service.e-volution.ai/?c=o&m=sync'); - } - }); - }); -}); diff --git a/test/spec/modules/edgequeryxBidAdapter_spec.js b/test/spec/modules/edgequeryxBidAdapter_spec.js deleted file mode 100644 index a66c546bd7c..00000000000 --- a/test/spec/modules/edgequeryxBidAdapter_spec.js +++ /dev/null @@ -1,116 +0,0 @@ -import { - expect -} from 'chai'; -import { - spec -} from 'modules/edgequeryxBidAdapter.js'; -import { - newBidder -} from 'src/adapters/bidderFactory.js'; -import { - config -} from 'src/config.js'; -import * as utils from 'src/utils.js'; -import { requestBidsHook } from 'modules/consentManagement.js'; - -// Default params with optional ones -describe('Edge Query X bid adapter tests', function () { - var DEFAULT_PARAMS = [{ - bidId: 'abcd1234', - mediaTypes: { - banner: { - sizes: [ - [1, 1] - ] - } - }, - bidder: 'edgequeryx', - params: { - accountId: 'test', - widgetId: 'test' - }, - requestId: 'efgh5678', - transactionId: 'zsfgzzg' - }]; - var BID_RESPONSE = { - body: { - requestId: 'abcd1234', - cpm: 22, - width: 1, - height: 1, - creativeId: 'EQXTest', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: '< --- awesome script --- >' - } - }; - - 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('https://deep.edgequery.io/prebid/x'); - expect(request[0]).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request[0].data); - - expect(requestContent).to.have.property('accountId').and.to.equal('test'); - expect(requestContent).to.have.property('widgetId').and.to.equal('test'); - expect(requestContent).to.have.property('sizes'); - expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(1); - expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(1); - }); - - 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(22); - expect(bid.ad).to.equal('< --- awesome script --- >'); - expect(bid.width).to.equal(1); - expect(bid.height).to.equal(1); - expect(bid.creativeId).to.equal('EQXTest'); - expect(bid.currency).to.equal('EUR'); - expect(bid.netRevenue).to.equal(true); - expect(bid.ttl).to.equal(360); - expect(bid.requestId).to.equal(DEFAULT_PARAMS[0].bidId); - - expect(function () { - spec.interpretResponse(BID_RESPONSE, { - data: 'invalid Json' - }) - }).to.not.throw(); - }); - - it('Verifies bidder code', function () { - expect(spec.code).to.equal('edgequeryx'); - }); - - it('Verifies bidder aliases', function () { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.equal('eqx'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(DEFAULT_PARAMS[0])).to.equal(true); - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({ - params: {} - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - widgetyId: 'abcdef' - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - widgetId: 'test', - accountId: 'test' - } - })).to.equal(true); - }); -}); diff --git a/test/spec/modules/emoteevBidAdapter_spec.js b/test/spec/modules/emoteevBidAdapter_spec.js deleted file mode 100644 index 43ae62f1eb9..00000000000 --- a/test/spec/modules/emoteevBidAdapter_spec.js +++ /dev/null @@ -1,876 +0,0 @@ -import { - assert, expect -} from 'chai'; -import { - ADAPTER_VERSION, - DOMAIN, - DOMAIN_DEVELOPMENT, - DOMAIN_STAGING, - domain, - BIDDER_PATH, - bidderUrl, - buildRequests, - conformBidRequest, - DEFAULT_ENV, - DEVELOPMENT, - EVENTS_PATH, - eventsUrl, - FOOTER, - gdprConsent, - getDeviceDimensions, - getDeviceInfo, - getDocumentDimensions, - getUserSyncs, - getViewDimensions, - IN_CONTENT, - interpretResponse, - isBidRequestValid, - ON_ADAPTER_CALLED, - ON_BID_WON, - ON_BIDDER_TIMEOUT, - onBidWon, - onAdapterCalled, - onTimeout, - OVERLAY, - PRODUCTION, - requestsPayload, - resolveDebug, - resolveEnv, - spec, - STAGING, - USER_SYNC_IFRAME_PATH, - USER_SYNC_IMAGE_PATH, - userSyncIframeUrl, - userSyncImageUrl, - validateSizes, - validateContext, - validateExternalId, - VENDOR_ID, - WALLPAPER, - storage -} from 'modules/emoteevBidAdapter.js'; -import * as utils from '../../../src/utils.js'; -import {config} from '../../../src/config.js'; - -const cannedValidBidRequests = [{ - adUnitCode: '/19968336/header-bid-tag-1', - auctionId: 'fcbf2b27-a951-496f-b5bb-1324ce7c0558', - bidId: '2b8de6572e8193', - bidRequestsCount: 1, - bidder: 'emoteev', - bidderRequestId: '1203b39fecc6a5', - crumbs: {pubcid: 'f3371d16-4e8b-42b5-a770-7e5be1fdf03d'}, - params: { - adSpaceId: 5084, - context: IN_CONTENT, - externalId: 42 - }, - sizes: [[300, 250], [250, 300], [300, 600]], - transactionId: '58dbd732-7a39-45f1-b23e-1c24051a941c', -}]; -const cannedBidderRequest = { - auctionId: 'fcbf2b27-a951-496f-b5bb-1324ce7c0558', - auctionStart: 1544200122837, - bidderCode: 'emoteev', - bidderRequestId: '1203b39fecc6a5', - doneCbCallCount: 0, - refererInfo: { - canonicalUrl: undefined, - numIframes: 0, - reachedTop: true, - referer: 'https://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html', - stack: ['https://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html'] - }, - start: 1544200012839, - timeout: 3000, - gdprConsent: { - gdprApplies: true, - vendorData: {vendorConsents: {[VENDOR_ID]: true}}, - } -}; -const serverResponse = - { - body: [ - { - requestId: cannedValidBidRequests[0].bidId, - cpm: 1, - width: cannedValidBidRequests[0].sizes[0][0], - height: cannedValidBidRequests[0].sizes[0][1], - ad: '
', - ttl: 360, - creativeId: 123, - netRevenue: false, - currency: 'EUR', - } - ] - }; - -describe('emoteevBidAdapter', function () { - describe('isBidRequestValid', function () { - it('should return true when valid', function () { - const validBid = { - bidder: 'emoteev', - bidId: '23a45b4e3', - params: { - adSpaceId: 12345, - context: IN_CONTENT, - externalId: 42 - }, - mediaTypes: { - banner: { - sizes: [[750, 200]] - } - }, - }; - expect(isBidRequestValid(validBid)).to.equal(true); - - expect(spec.isBidRequestValid(validBid)).to.exist.and.to.be.a('boolean'); - expect(spec.isBidRequestValid({})).to.exist.and.to.be.a('boolean'); - }); - - it('should return false when required params are invalid', function () { - expect(isBidRequestValid({ - bidder: '', // invalid bidder - params: { - adSpaceId: 12345, - context: IN_CONTENT, - externalId: 42 - }, - mediaTypes: { - banner: { - sizes: [[750, 200]] - } - }, - })).to.equal(false); - expect(isBidRequestValid({ - bidder: 'emoteev', - params: { - adSpaceId: '', // invalid adSpaceId - context: IN_CONTENT, - externalId: 42 - }, - mediaTypes: { - banner: { - sizes: [[750, 200]] - } - }, - })).to.equal(false); - expect(isBidRequestValid({ - bidder: 'emoteev', - params: { - adSpaceId: 12345, - context: 'something', // invalid context - externalId: 42 - }, - mediaTypes: { - banner: { - sizes: [[750, 200]] - } - }, - })).to.equal(false); - expect(isBidRequestValid({ - bidder: 'emoteev', - params: { - adSpaceId: 12345, - context: IN_CONTENT, - externalId: 'lol' // invalid externalId - }, - mediaTypes: { - banner: { - sizes: [[750, 200]] - } - }, - })).to.equal(false); - expect(isBidRequestValid({ - bidder: 'emoteev', - params: { - adSpaceId: 12345, - context: IN_CONTENT, - externalId: 42 - }, - mediaTypes: { - banner: { - sizes: [[750]] // invalid size - } - }, - })).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const - env = DEFAULT_ENV, - debug = true, - currency = 'EUR', - request = buildRequests(env, debug, currency, cannedValidBidRequests, cannedBidderRequest); - - expect(request).to.exist.and.have.all.keys( - 'method', - 'url', - 'data', - ); - - expect(request.method).to.equal('POST'); - expect(request.url).to.equal(bidderUrl(env)); - - expect(spec.buildRequests(cannedValidBidRequests, cannedBidderRequest)).to.exist.and.to.be.an('object'); - }); - - describe('interpretResponse', function () { - it('bid objects from response', function () { - const bidResponses = interpretResponse(serverResponse); - expect(bidResponses).to.be.an('array').that.is.not.empty; - expect(bidResponses[0]).to.have.property('requestId', cannedValidBidRequests[0].bidId); - expect(bidResponses[0]).to.have.property('cpm', serverResponse.body[0].cpm); - expect(bidResponses[0]).to.have.property('width', serverResponse.body[0].width); - expect(bidResponses[0]).to.have.property('height', serverResponse.body[0].height); - expect(bidResponses[0]).to.have.property('ad', serverResponse.body[0].ad); - expect(bidResponses[0]).to.have.property('ttl', serverResponse.body[0].ttl); - expect(bidResponses[0]).to.have.property('creativeId', serverResponse.body[0].creativeId); - expect(bidResponses[0]).to.have.property('netRevenue', serverResponse.body[0].netRevenue); - expect(bidResponses[0]).to.have.property('currency', serverResponse.body[0].currency); - }); - }); - - describe('onAdapterCalled', function () { - const - bidRequest = cannedValidBidRequests[0], - url = onAdapterCalled(DEFAULT_ENV, bidRequest); - - expect(url).to.have.property('protocol'); - expect(url).to.have.property('hostname'); - expect(url).to.have.property('pathname', EVENTS_PATH); - expect(url).to.have.nested.property('search.eventName', ON_ADAPTER_CALLED); - expect(url).to.have.nested.property('search.pubcId', bidRequest.crumbs.pubcid); - expect(url).to.have.nested.property('search.bidId', bidRequest.bidId); - expect(url).to.have.nested.property('search.adSpaceId', bidRequest.params.adSpaceId); - expect(url).to.have.nested.property('search.cache_buster'); - }); - - describe('onBidWon', function () { - const - pubcId = cannedValidBidRequests[0].crumbs.pubcid, - bidObject = serverResponse.body[0], - url = onBidWon(DEFAULT_ENV, pubcId, bidObject); - - expect(url).to.have.property('protocol'); - expect(url).to.have.property('hostname'); - expect(url).to.have.property('pathname', EVENTS_PATH); - expect(url).to.have.nested.property('search.eventName', ON_BID_WON); - expect(url).to.have.nested.property('search.pubcId', pubcId); - expect(url).to.have.nested.property('search.bidId', bidObject.requestId); - expect(url).to.have.nested.property('search.cache_buster'); - }); - - describe('onTimeout', function () { - const - data = { - ...cannedValidBidRequests[0], - timeout: 123, - }, - url = onTimeout(DEFAULT_ENV, data); - - expect(url).to.have.property('protocol'); - expect(url).to.have.property('hostname'); - expect(url).to.have.property('pathname', EVENTS_PATH); - expect(url).to.have.nested.property('search.eventName', ON_BIDDER_TIMEOUT); - expect(url).to.have.nested.property('search.bidId', data.bidId); - expect(url).to.have.nested.property('search.pubcId', data.crumbs.pubcid); - expect(url).to.have.nested.property('search.adSpaceId', data.params.adSpaceId); - expect(url).to.have.nested.property('search.timeout', data.timeout); - expect(url).to.have.nested.property('search.cache_buster'); - }); - - describe('getUserSyncs', function () { - expect(getUserSyncs( - DEFAULT_ENV, - { - iframeEnabled: false, - pixelEnabled: false - })).to.deep.equal([]); - expect(getUserSyncs( - PRODUCTION, - { - iframeEnabled: false, - pixelEnabled: true - })).to.deep.equal([{ - type: 'image', - url: userSyncImageUrl(PRODUCTION) - }]); - expect(getUserSyncs( - STAGING, - { - iframeEnabled: true, - pixelEnabled: false - })).to.deep.equal([{ - type: 'iframe', - url: userSyncIframeUrl(STAGING) - }]); - expect(getUserSyncs( - DEVELOPMENT, - { - iframeEnabled: true, - pixelEnabled: true - })).to.deep.equal([{ - type: 'image', - url: userSyncImageUrl(DEVELOPMENT) - }, { - type: 'iframe', - url: userSyncIframeUrl(DEVELOPMENT) - }]); - }); - - describe('domain', function () { - expect(domain(null)).to.deep.equal(DOMAIN); - expect(domain('anything')).to.deep.equal(DOMAIN); - expect(domain(PRODUCTION)).to.deep.equal(DOMAIN); - expect(domain(STAGING)).to.deep.equal(DOMAIN_STAGING); - expect(domain(DEVELOPMENT)).to.deep.equal(DOMAIN_DEVELOPMENT); - }); - - describe('eventsUrl', function () { - expect(eventsUrl(null)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(DEFAULT_ENV), - pathname: EVENTS_PATH - })); - expect(eventsUrl('anything')).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(DEFAULT_ENV), - pathname: EVENTS_PATH - })); - expect(eventsUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(PRODUCTION), - pathname: EVENTS_PATH - })); - expect(eventsUrl(STAGING)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(STAGING), - pathname: EVENTS_PATH - })); - expect(eventsUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ - hostname: domain(DEVELOPMENT), - pathname: EVENTS_PATH - })); - }); - - describe('bidderUrl', function () { - expect(bidderUrl(null)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(DEFAULT_ENV), - pathname: BIDDER_PATH - })); - expect(bidderUrl('anything')).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(DEFAULT_ENV), - pathname: BIDDER_PATH - })); - expect(bidderUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(PRODUCTION), - pathname: BIDDER_PATH - })); - expect(bidderUrl(STAGING)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(STAGING), - pathname: BIDDER_PATH - })); - expect(bidderUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ - hostname: domain(DEVELOPMENT), - pathname: BIDDER_PATH - })); - }); - - describe('userSyncIframeUrl', function () { - expect(userSyncIframeUrl(null)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(DEFAULT_ENV), - pathname: USER_SYNC_IFRAME_PATH - })); - expect(userSyncIframeUrl('anything')).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(DEFAULT_ENV), - pathname: USER_SYNC_IFRAME_PATH - })); - expect(userSyncIframeUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(PRODUCTION), - pathname: USER_SYNC_IFRAME_PATH - })); - expect(userSyncIframeUrl(STAGING)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(STAGING), - pathname: USER_SYNC_IFRAME_PATH - })); - expect(userSyncIframeUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ - hostname: domain(DEVELOPMENT), - pathname: USER_SYNC_IFRAME_PATH - })); - }); - - describe('userSyncImageUrl', function () { - expect(userSyncImageUrl(null)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(DEFAULT_ENV), - pathname: USER_SYNC_IMAGE_PATH - })); - expect(userSyncImageUrl('anything')).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(DEFAULT_ENV), - pathname: USER_SYNC_IMAGE_PATH - })); - expect(userSyncImageUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(PRODUCTION), - pathname: USER_SYNC_IMAGE_PATH - })); - expect(userSyncImageUrl(STAGING)).to.deep.equal(utils.buildUrl({ - protocol: 'https', - hostname: domain(STAGING), - pathname: USER_SYNC_IMAGE_PATH - })); - expect(userSyncImageUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ - hostname: domain(DEVELOPMENT), - pathname: USER_SYNC_IMAGE_PATH - })); - }); - - describe('conformBidRequest', function () { - expect(conformBidRequest(cannedValidBidRequests[0])).to.deep.equal({ - params: cannedValidBidRequests[0].params, - crumbs: cannedValidBidRequests[0].crumbs, - sizes: cannedValidBidRequests[0].sizes, - bidId: cannedValidBidRequests[0].bidId, - bidderRequestId: cannedValidBidRequests[0].bidderRequestId, - }); - }); - - describe('gdprConsent', function () { - describe('gdpr applies, consent given', function () { - const bidderRequest = { - ...cannedBidderRequest, - gdprConsent: { - gdprApplies: true, - vendorData: {vendorConsents: {[VENDOR_ID]: true}}, - } - }; - expect(gdprConsent(bidderRequest)).to.deep.equal(true); - }); - describe('gdpr applies, consent withdrawn', function () { - const bidderRequest = { - ...cannedBidderRequest, - gdprConsent: { - gdprApplies: true, - vendorData: {vendorConsents: {[VENDOR_ID]: false}}, - } - }; - expect(gdprConsent(bidderRequest)).to.deep.equal(false); - }); - describe('gdpr applies, consent unknown', function () { - const bidderRequest = { - ...cannedBidderRequest, - gdprConsent: { - gdprApplies: true, - vendorData: {}, - } - }; - expect(gdprConsent(bidderRequest)).to.deep.equal(undefined); - }); - }); - - describe('requestsPayload', function () { - const - currency = 'EUR', - debug = true; - - const payload = requestsPayload(debug, currency, cannedValidBidRequests, cannedBidderRequest); - - expect(payload).to.exist.and.have.all.keys( - 'akPbjsVersion', - 'bidRequests', - 'currency', - 'debug', - 'language', - 'refererInfo', - 'deviceInfo', - 'userAgent', - 'gdprApplies', - 'gdprConsent', - ); - - expect(payload.bidRequests[0]).to.exist.and.have.all.keys( - 'params', - 'crumbs', - 'sizes', - 'bidId', - 'bidderRequestId', - ); - - expect(payload.akPbjsVersion).to.deep.equal(ADAPTER_VERSION); - expect(payload.bidRequests[0].params).to.deep.equal(cannedValidBidRequests[0].params); - expect(payload.bidRequests[0].crumbs).to.deep.equal(cannedValidBidRequests[0].crumbs); - expect(payload.bidRequests[0].mediaTypes).to.deep.equal(cannedValidBidRequests[0].mediaTypes); - expect(payload.bidRequests[0].bidId).to.deep.equal(cannedValidBidRequests[0].bidId); - expect(payload.bidRequests[0].bidderRequestId).to.deep.equal(cannedValidBidRequests[0].bidderRequestId); - expect(payload.currency).to.deep.equal(currency); - expect(payload.debug).to.deep.equal(debug); - expect(payload.language).to.deep.equal(navigator.language); - expect(payload.deviceInfo).to.exist.and.have.all.keys( - 'browserWidth', - 'browserHeight', - 'deviceWidth', - 'deviceHeight', - 'documentWidth', - 'documentHeight', - 'webGL', - ); - expect(payload.userAgent).to.deep.equal(navigator.userAgent); - expect(payload.gdprApplies).to.deep.equal(cannedBidderRequest.gdprConsent.gdprApplies); - }); - - describe('getViewDimensions', function () { - const window = { - innerWidth: 1024, - innerHeight: 768 - }; - const documentWithElement = { - documentElement: - { - clientWidth: 512, - clientHeight: 384 - } - }; - const documentWithBody = { - body: - { - clientWidth: 512, - clientHeight: 384 - } - }; - expect(getViewDimensions(window, documentWithElement)).to.deep.equal({ - width: 1024, - height: 768 - }); - expect(getViewDimensions(window, documentWithBody)).to.deep.equal({width: 1024, height: 768}); - expect(getViewDimensions(window, documentWithElement)).to.deep.equal({ - width: 1024, - height: 768 - }); - expect(getViewDimensions(window, documentWithBody)).to.deep.equal({width: 1024, height: 768}); - expect(getViewDimensions({}, documentWithElement)).to.deep.equal({width: 512, height: 384}); - expect(getViewDimensions({}, documentWithBody)).to.deep.equal({width: 512, height: 384}); - }); - - describe('getDeviceDimensions', function () { - const window = {screen: {width: 1024, height: 768}}; - expect(getDeviceDimensions(window)).to.deep.equal({width: 1024, height: 768}); - expect(getDeviceDimensions({})).to.deep.equal({width: '', height: ''}); - }); - - describe('getDocumentDimensions', function () { - expect(getDocumentDimensions({ - documentElement: { - clientWidth: 1, - clientHeight: 1, - offsetWidth: 0, - offsetHeight: 0, - scrollWidth: 0, - scrollHeight: 0, - }, - })).to.deep.equal({width: 1, height: 1}); - - expect(getDocumentDimensions({ - documentElement: { - clientWidth: 1, - clientHeight: 1, - offsetWidth: 0, - offsetHeight: 0, - scrollWidth: 0, - scrollHeight: 0, - }, - body: { - scrollHeight: 0, - offsetHeight: 0, - } - })).to.deep.equal({width: 1, height: 1}); - - expect(getDocumentDimensions({ - documentElement: { - clientWidth: 0, - clientHeight: 0, - offsetWidth: 1, - offsetHeight: 1, - scrollWidth: 0, - scrollHeight: 0, - }, - body: { - scrollHeight: 0, - offsetHeight: 0, - } - })).to.deep.equal({width: 1, height: 1}); - - expect(getDocumentDimensions({ - documentElement: { - clientWidth: 0, - clientHeight: 0, - offsetWidth: 0, - offsetHeight: 0, - scrollWidth: 1, - scrollHeight: 1, - }, - body: { - scrollHeight: 0, - offsetHeight: 0, - } - })).to.deep.equal({width: 1, height: 1}); - - expect(getDocumentDimensions({ - documentElement: { - clientWidth: undefined, - clientHeight: undefined, - offsetWidth: undefined, - offsetHeight: undefined, - scrollWidth: undefined, - scrollHeight: undefined, - }, - body: { - scrollHeight: undefined, - offsetHeight: undefined, - } - })).to.deep.equal({width: '', height: ''}); - }); - - // describe('isWebGLEnabled', function () { - // it('handles no webgl', function () { - // const - // document = new Document(), - // canvas = sinon.createStubInstance(HTMLCanvasElement); - // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); - // canvas.getContext.withArgs('webgl').returns(undefined); - // canvas.getContext.withArgs('experimental-webgl').returns(undefined); - // expect(isWebGLEnabled(document)).to.equal(false); - // }); - // - // it('handles webgl exception', function () { - // const - // document = new Document(), - // canvas = sinon.createStubInstance(HTMLCanvasElement); - // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); - // canvas.getContext.withArgs('webgl').throws(DOMException); - // expect(isWebGLEnabled(document)).to.equal(false); - // }); - // - // it('handles experimental webgl', function () { - // const - // document = new Document(), - // canvas = sinon.createStubInstance(HTMLCanvasElement); - // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); - // canvas.getContext.withArgs('webgl').returns(undefined); - // canvas.getContext.withArgs('experimental-webgl').returns(true); - // expect(isWebGLEnabled(document)).to.equal(true); - // }); - // - // it('handles experimental webgl exception', function () { - // const - // document = new Document(), - // canvas = sinon.createStubInstance(HTMLCanvasElement); - // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); - // canvas.getContext.withArgs('webgl').returns(undefined); - // canvas.getContext.withArgs('experimental-webgl').throws(DOMException); - // expect(isWebGLEnabled(document)).to.equal(false); - // }); - // - // it('handles webgl', function () { - // const - // document = new Document(), - // canvas = sinon.createStubInstance(HTMLCanvasElement); - // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); - // canvas.getContext.withArgs('webgl').returns(true); - // expect(isWebGLEnabled(document)).to.equal(true); - // }); - // }); - - describe('getDeviceInfo', function () { - expect(getDeviceInfo( - {width: 1, height: 2}, - {width: 3, height: 4}, - {width: 5, height: 6}, - true - )).to.deep.equal({ - deviceWidth: 1, - deviceHeight: 2, - browserWidth: 3, - browserHeight: 4, - documentWidth: 5, - documentHeight: 6, - webGL: true - }); - }); - - describe('resolveEnv', function () { - it('defaults to production', function () { - expect(resolveEnv({}, null)).to.deep.equal(DEFAULT_ENV); - }); - expect(resolveEnv({}, PRODUCTION)).to.deep.equal(PRODUCTION); - expect(resolveEnv({}, STAGING)).to.deep.equal(STAGING); - expect(resolveEnv({}, DEVELOPMENT)).to.deep.equal(DEVELOPMENT); - expect(resolveEnv({emoteev: {env: PRODUCTION}}, null)).to.deep.equal(PRODUCTION); - expect(resolveEnv({emoteev: {env: STAGING}}, null)).to.deep.equal(STAGING); - expect(resolveEnv({emoteev: {env: DEVELOPMENT}}, null)).to.deep.equal(DEVELOPMENT); - it('prioritizes parameter over configuration', function () { - expect(resolveEnv({emoteev: {env: STAGING}}, DEVELOPMENT)).to.deep.equal(DEVELOPMENT); - }); - }); - - describe('resolveDebug', function () { - it('defaults to production', function () { - expect(resolveDebug({}, null)).to.deep.equal(false); - }); - expect(resolveDebug({}, 'false')).to.deep.equal(false); - expect(resolveDebug({}, 'true')).to.deep.equal(true); - expect(resolveDebug({debug: true}, null)).to.deep.equal(true); - it('prioritizes parameter over configuration', function () { - expect(resolveDebug({debug: true}, 'false')).to.deep.equal(false); - }); - }); - - describe('side effects', function () { - let triggerPixelStub; - let getCookieSpy; - let getConfigSpy; - let getParameterByNameSpy; - - before(function() { - config.resetConfig(); - }); - after(function() { - config.resetConfig(); - }); - beforeEach(function () { - triggerPixelStub = sinon.stub(utils, 'triggerPixel'); - getCookieSpy = sinon.spy(storage, 'getCookie'); - getConfigSpy = sinon.spy(config, 'getConfig'); - getParameterByNameSpy = sinon.spy(utils, 'getParameterByName'); - }); - afterEach(function () { - triggerPixelStub.restore(); - getCookieSpy.restore(); - getConfigSpy.restore(); - getParameterByNameSpy.restore(); - }); - - describe('isBidRequestValid', function () { - it('has intended side-effects', function () { - const validBidRequest = { - bidder: 'emoteev', - bidId: '23a45b4e3', - params: { - adSpaceId: 12345, - }, - mediaTypes: { - banner: { - sizes: [[750, 200]] - } - }, - }; - spec.isBidRequestValid(validBidRequest); - sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(storage.getCookie); - // sinon.assert.notCalled(config.getConfig); - sinon.assert.notCalled(utils.getParameterByName); - }); - }); - describe('isBidRequestValid empty request', function() { - it('has intended side-effects empty request', function () { - const invalidBidRequest = {}; - spec.isBidRequestValid(invalidBidRequest); - sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(storage.getCookie); - // disabling these getConfig tests as they have been flaky in browserstack testing - // sinon.assert.notCalled(config.getConfig); - sinon.assert.notCalled(utils.getParameterByName); - }); - }); - describe('buildRequests', function () { - it('has intended side-effects', function () { - spec.buildRequests(cannedValidBidRequests, cannedBidderRequest); - sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(storage.getCookie); - // sinon.assert.callCount(config.getConfig, 3); - sinon.assert.callCount(utils.getParameterByName, 2); - }); - }); - describe('interpretResponse', function () { - it('has intended side-effects', function () { - spec.interpretResponse(serverResponse); - sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(storage.getCookie); - // sinon.assert.notCalled(config.getConfig); - sinon.assert.notCalled(utils.getParameterByName); - }); - }); - describe('onBidWon', function () { - it('has intended side-effects', function () { - const bidObject = serverResponse.body[0]; - spec.onBidWon(bidObject); - sinon.assert.calledOnce(utils.triggerPixel); - sinon.assert.calledOnce(storage.getCookie); - // sinon.assert.calledOnce(config.getConfig); - sinon.assert.calledOnce(utils.getParameterByName); - }); - }); - describe('onTimeout', function () { - it('has intended side-effects', function () { - spec.onTimeout(cannedValidBidRequests[0]); - sinon.assert.calledOnce(utils.triggerPixel); - sinon.assert.notCalled(storage.getCookie); - // sinon.assert.calledOnce(config.getConfig); - sinon.assert.calledOnce(utils.getParameterByName); - }); - }); - describe('getUserSyncs', function () { - it('has intended side-effects', function () { - spec.getUserSyncs({}); - sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(storage.getCookie); - // sinon.assert.calledOnce(config.getConfig); - sinon.assert.calledOnce(utils.getParameterByName); - }); - }); - }); - - describe('validateSizes', function () { - it('only accepts valid array of sizes', function () { - expect(validateSizes([])).to.deep.equal(false); - expect(validateSizes([[]])).to.deep.equal(false); - expect(validateSizes([[450, 450], undefined])).to.deep.equal(false); - expect(validateSizes([[450, 450], 'size'])).to.deep.equal(false); - expect(validateSizes([[1, 1]])).to.deep.equal(true); - expect(validateSizes([[1, 1], [450, 450]])).to.deep.equal(true); - }); - }); - - describe('validateContext', function () { - it('only accepts valid context', function () { - expect(validateContext(IN_CONTENT)).to.deep.equal(true); - expect(validateContext(FOOTER)).to.deep.equal(true); - expect(validateContext(OVERLAY)).to.deep.equal(true); - expect(validateContext(WALLPAPER)).to.deep.equal(true); - expect(validateContext(null)).to.deep.equal(false); - expect(validateContext('anything else')).to.deep.equal(false); - }); - }); - - describe('validateExternalId', function () { - it('only accepts a positive integer or null', function () { - expect(validateExternalId(0)).to.deep.equal(false); - expect(validateExternalId(42)).to.deep.equal(true); - expect(validateExternalId(42.0)).to.deep.equal(true); // edge case: valid externalId - expect(validateExternalId(3.14159)).to.deep.equal(false); - expect(validateExternalId('externalId')).to.deep.equal(false); - expect(validateExternalId(undefined)).to.deep.equal(true); - expect(validateExternalId(null)).to.deep.equal(true); - }); - }); -}); diff --git a/test/spec/modules/engageyaBidAdapter_spec.js b/test/spec/modules/engageyaBidAdapter_spec.js deleted file mode 100644 index ad411fc9350..00000000000 --- a/test/spec/modules/engageyaBidAdapter_spec.js +++ /dev/null @@ -1,161 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/engageyaBidAdapter.js'; -import * as utils from 'src/utils.js'; - -const ENDPOINT_URL = 'https://recs.engageya.com/rec-api/getrecs.json'; - -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; -} - -describe('engageya adapter', function() { - let bidRequests; - let nativeBidRequests; - - beforeEach(function() { - bidRequests = [ - { - bidder: 'engageya', - params: { - widgetId: 85610, - websiteId: 91140, - pageUrl: '[PAGE_URL]' - } - } - ] - - nativeBidRequests = [ - { - bidder: 'engageya', - params: { - widgetId: 85610, - websiteId: 91140, - pageUrl: '[PAGE_URL]' - }, - nativeParams: { - title: { - required: true, - len: 80 - }, - image: { - required: true, - sizes: [150, 50] - }, - sponsoredBy: { - required: true - } - } - } - ] - }) - describe('isBidRequestValid', function () { - it('valid bid case', function () { - let validBid = { - bidder: 'engageya', - params: { - widgetId: 85610, - websiteId: 91140, - pageUrl: '[PAGE_URL]' - } - } - let isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - }); - - it('invalid bid case: widgetId and websiteId is not passed', function() { - let validBid = { - bidder: 'engageya', - params: { - } - } - let isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }) - - it('invalid bid case: widget id must be number', function() { - let invalidBid = { - bidder: 'engageya', - params: { - widgetId: '157746a', - websiteId: 91140, - pageUrl: '[PAGE_URL]' - } - } - let isValid = spec.isBidRequestValid(invalidBid); - expect(isValid).to.equal(false); - }) - }) - - describe('buildRequests', function () { - it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.include(ENDPOINT_URL); - expect(request.method).to.equal('GET'); - }); - - it('buildRequests function should not modify original bidRequests object', function () { - let originalBidRequests = utils.deepClone(bidRequests); - let request = spec.buildRequests(bidRequests); - expect(bidRequests).to.deep.equal(originalBidRequests); - }); - - it('buildRequests function should not modify original nativeBidRequests object', function () { - let originalBidRequests = utils.deepClone(nativeBidRequests); - let request = spec.buildRequests(nativeBidRequests); - expect(nativeBidRequests).to.deep.equal(originalBidRequests); - }); - - it('Request params check', function() { - let request = spec.buildRequests(bidRequests)[0]; - const data = _getUrlVars(request.url) - expect(parseInt(data.wid)).to.exist.and.to.equal(bidRequests[0].params.widgetId); - expect(parseInt(data.webid)).to.exist.and.to.equal(bidRequests[0].params.websiteId); - }) - }) - - describe('interpretResponse', function () { - let response = {recs: [ - { - 'ecpm': 0.0920, - 'postId': '', - 'ad': '', - 'thumbnail_path': 'https://engageya.live/wp-content/uploads/2019/05/images.png' - } - ], - imageWidth: 300, - imageHeight: 250, - ireqId: '1d236f7890b', - pbtypeId: 2}; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '1d236f7890b', - 'cpm': 0.0920, - 'width': 300, - 'height': 250, - 'netRevenue': false, - 'currency': 'USD', - 'creativeId': '', - 'ttl': 700, - 'ad': '' - } - ]; - let request = spec.buildRequests(bidRequests)[0]; - let result = spec.interpretResponse({body: response}, request); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - expect(result[0].cpm).to.not.equal(null); - expect(result[0].creativeId).to.not.equal(null); - expect(result[0].ad).to.not.equal(null); - expect(result[0].currency).to.equal('USD'); - expect(result[0].netRevenue).to.equal(false); - }); - }) -}) diff --git a/test/spec/modules/envivoBidAdapter_spec.js b/test/spec/modules/envivoBidAdapter_spec.js deleted file mode 100644 index 7bd1dd1ccf1..00000000000 --- a/test/spec/modules/envivoBidAdapter_spec.js +++ /dev/null @@ -1,159 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/envivoBidAdapter.js'; - -const ENDPOINT = 'https://ad.nvivo.tv/ads/www/admin/plugins/Prebid/getAd.php'; - -describe('The Envivo bidding adapter', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'envivo', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - - it('should return true when given a publisherId in bid', function () { - const bid = { - bidder: 'envivo', - params: { - publisherId: 14 - }, - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [{ - 'bidder': 'envivo', - 'params': { - 'publisherId': 14 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ] - }]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('check endpoint url', function () { - expect(request.url).to.equal(ENDPOINT) - }); - - it('sets the proper banner object', function () { - expect(bidRequests[0].params.publisherId).to.equal(14); - }) - }); - const response = { - body: [ - { - 'requestId': '2ee937f15015c6', - 'cpm': '0.2000', - 'width': 300, - 'height': 600, - 'creativeId': '4', - 'currency': 'USD', - 'netRevenue': true, - 'ad': 'ads.html', - 'mediaType': 'banner' - }, - { - 'requestId': '3e1af92622bdc', - 'cpm': '0.2000', - 'creativeId': '4', - 'context': 'outstream', - 'currency': 'USD', - 'netRevenue': true, - 'vastUrl': 'tezt.xml', - 'width': 640, - 'height': 480, - 'mediaType': 'video' - }] - }; - - const request = [ - { - 'bidder': 'envivo', - 'params': { - 'publisherId': 14 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 600] - ] - } - }, - 'bidId': '2ee937f15015c6', - 'src': 'client', - }, - { - 'bidder': 'envivo', - 'params': { - 'publisherId': 14 - }, - 'mediaTypes': { - 'video': { - 'context': 'outstream', - 'playerSize': [ - [640, 480] - ] - } - }, - 'bidId': '3e1af92622bdc', - 'src': 'client', - } - ]; - - describe('interpretResponse', function () { - it('return empty array when no ad found', function () { - const response = {}; - const request = { bidRequests: [] }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('check response for banner and video', function () { - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(2); - expect(bids[0].requestId).to.equal('2ee937f15015c6'); - expect(bids[0].cpm).to.equal('0.2000'); - expect(bids[1].cpm).to.equal('0.2000'); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(600); - expect(bids[1].vastUrl).to.not.equal(''); - expect(bids[0].ad).to.not.equal(''); - expect(bids[1].adResponse).to.not.equal(''); - expect(bids[1].renderer).not.to.be.an('undefined'); - }); - }); - - describe('On winning bid', function () { - const bids = spec.interpretResponse(response, request); - spec.onBidWon(bids); - }); - - describe('On bid Time out', function () { - const bids = spec.interpretResponse(response, request); - spec.onTimeout(bids); - }); - - describe('user sync', function () { - it('to check the user sync iframe', function () { - let syncs = spec.getUserSyncs({ - iframeEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - }); - }); -}); diff --git a/test/spec/modules/fidelityBidAdapter_spec.js b/test/spec/modules/fidelityBidAdapter_spec.js deleted file mode 100644 index 304a98675b3..00000000000 --- a/test/spec/modules/fidelityBidAdapter_spec.js +++ /dev/null @@ -1,233 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/fidelityBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -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': '27248', - 'floor': '0.05', - 'server': 'x.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': '27248', - }; - 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: '27248', - floor: '0.05', - server: 'x.fidelity-media.com', - }, - placementCode: '/19968336/header-bid-tag-0', - sizes: [[300, 250], [320, 50]], - bidId: '2ffb201a808da7', - bidderRequestId: '178e34bad3658f', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', - schain: { - ver: '1.0', - complete: 1, - nodes: [{ - asi: 'exchange1.com', - sid: '1234', - hp: 1, - rid: 'bid-request-1', - name: 'publisher', - domain: 'publisher.com' - }] - } - } - ], - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000, - refererInfo: { - referer: 'http://test.com/index.html' - } - }; - - it('should add params to the request', function () { - let schainString = '1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com'; - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - const payload = request.data; - expect(payload.from).to.exist; - 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; - expect(payload.schain).to.exist.and.to.be.a('string'); - expect(payload.schain).to.equal(schainString); - }); - - it('should add consent information to the request - TCF v1', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let uspConsentString = '1YN-'; - bidderRequest.gdprConsent = { - gdprApplies: true, - allowAuctionWithoutConsent: true, - consentString: consentString, - vendorData: { - vendorConsents: { - '408': true - }, - }, - apiVersion: 1 - }; - bidderRequest.uspConsent = uspConsentString; - 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); - expect(payload.us_privacy).to.exist.and.to.be.a('string'); - expect(payload.us_privacy).to.equal(uspConsentString); - }); - - it('should add consent information to the request - TCF v2', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let uspConsentString = '1YN-'; - bidderRequest.gdprConsent = { - gdprApplies: true, - allowAuctionWithoutConsent: true, - consentString: consentString, - vendorData: { - vendor: { - consents: { - '408': true - } - }, - }, - apiVersion: 2 - }; - bidderRequest.uspConsent = uspConsentString; - 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); - expect(payload.us_privacy).to.exist.and.to.be.a('string'); - expect(payload.us_privacy).to.equal(uspConsentString); - }); - - it('sends bid request to ENDPOINT via GET', function () { - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.url).to.equal('https://x.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 = 'https://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/fluctBidAdapter_spec.js b/test/spec/modules/fluctBidAdapter_spec.js deleted file mode 100644 index 6530a3c36cf..00000000000 --- a/test/spec/modules/fluctBidAdapter_spec.js +++ /dev/null @@ -1,201 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/fluctBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; -import {config} from 'src/config.js'; - -describe('fluctAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - const bid = { - bidder: 'fluct', - params: { - dfpUnitCode: '/1000/dfp_unit_code', - tagId: '10000:100000001', - groupId: '1000000002', - } - }; - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when dfpUnitCode is not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - tagId: '10000:100000001', - groupId: '1000000002', - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when groupId is not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - dfpUnitCode: '/1000/dfp_unit_code', - tagId: '10000:100000001', - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [{ - bidder: 'fluct', - params: { - dfpUnitCode: '/100000/unit_code', - tagId: '10000:100000001', - groupId: '1000000002', - }, - adUnitCode: '/10000/unit_code', - sizes: [[300, 250], [336, 280]], - bidId: '237f4d1a293f99', - bidderRequestId: '1a857fa34c1c96', - auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', - transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', - }]; - const bidderRequest = { - refererInfo: { - referer: 'http://example.com' - } - }; - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.method).to.equal('POST'); - }); - }); - - describe('interpretResponse', function() { - const callBeaconSnippet = ''; - - it('should get correct bid response', function() { - const bidRequest = { - bidder: 'fluct', - params: { - dfpUnitCode: '/10000/unit_code', - tagid: '10000:100000001', - groupId: '1000000002', - }, - adUnitCode: '/10000/unit_code', - sizes: [[300, 250], [336, 280]], - bidId: '237f4d1a293f99', - bidderRequestId: '1a857fa34c1c96', - auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', - transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', - }; - - const serverResponse = { - body: { - id: '237f4d1a293f99', - cur: 'JPY', - seatbid: [{ - bid: [{ - price: 100, - w: 300, - h: 250, - adm: '', - burl: 'https://i.adingo.jp/?test=1&et=hb&bidid=237f4d1a293f99', - crid: 'test_creative', - }] - }] - } - }; - - const expectedResponse = [ - { - bidderCode: 'fluct', - requestId: '237f4d1a293f99', - currency: 'JPY', - cpm: 100, - netRevenue: true, - width: 300, - height: 250, - creativeId: 'test_creative', - ttl: 300, - ad: '' + callBeaconSnippet, - } - ]; - - const result = spec.interpretResponse(serverResponse, bidRequest); - expect(result).to.have.lengthOf(1); - expect(result).to.deep.have.same.members(expectedResponse); - }); - - it('should get correct bid response with dealId', function() { - const bidRequest = { - bidder: 'fluct', - params: { - dfpUnitCode: '/10000/unit_code', - tagid: '10000:100000001', - groupId: '1000000002' - }, - adUnitCode: '/10000/unit_code', - sizes: [[300, 250], [336, 280]], - bidId: '237f4d1a293f99', - bidderRequestId: '1a857fa34c1c96', - auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', - transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', - }; - - const serverResponse = { - body: { - id: '237f4d1a293f99', - cur: 'JPY', - seatbid: [{ - bid: [{ - price: 100, - w: 300, - h: 250, - adm: '', - burl: 'https://i.adingo.jp/?test=1&et=hb&bidid=237f4d1a293f99', - crid: 'test_creative', - dealid: 'test_deal', - }] - }] - } - }; - - const expectedResponse = [ - { - bidderCode: 'fluct', - requestId: '237f4d1a293f99', - currency: 'JPY', - cpm: 100, - netRevenue: true, - width: 300, - height: 250, - creativeId: 'test_creative', - ttl: 300, - ad: '' + callBeaconSnippet, - dealId: 'test_deal', - } - ]; - - const result = spec.interpretResponse(serverResponse, bidRequest); - expect(result).to.have.lengthOf(1); - expect(result).to.deep.have.same.members(expectedResponse); - }); - - it('should get empty response when bid server returns 204', function() { - expect(spec.interpretResponse({})).to.be.empty; - }); - }); -}); diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js deleted file mode 100644 index cdaa1b5448a..00000000000 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ /dev/null @@ -1,104 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/gammaBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -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', () => { - it('should return true when required params found', () => { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when require params are not passed', () => { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when params not passed correctly', () => { - bid.params.siteId = ''; - bid.params.zoneId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', () => { - it('should attempt to send bid requests to the endpoint via GET', () => { - const requests = spec.buildRequests(bidArray); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - expect(requestItem.url).to.match(new RegExp(`hb.gammaplatform.com`)); - }); - }); - }); - - describe('interpretResponse', () => { - let serverResponse; - - beforeEach(() => { - 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', () => { - 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', () => { - let response = { - body: {} - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/gnetBidAdapter_spec.js b/test/spec/modules/gnetBidAdapter_spec.js deleted file mode 100644 index 40f8ad50d78..00000000000 --- a/test/spec/modules/gnetBidAdapter_spec.js +++ /dev/null @@ -1,145 +0,0 @@ -import { - expect -} from 'chai'; -import { - spec -} from 'modules/gnetBidAdapter.js'; -import { - newBidder -} from 'src/adapters/bidderFactory.js'; - -const ENDPOINT = 'https://adserver.gnetproject.com/prebid.php'; - -describe('gnetAdapter', 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: 'gnet', - params: { - websiteId: '4', - externalId: '4d52cccf30309282256012cf30309282' - } - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [{ - bidder: 'gnet', - params: { - websiteId: '4', - externalId: '4d52cccf30309282256012cf30309282' - }, - adUnitCode: '/150790500/4_ZONA_IAB_300x250_5', - sizes: [ - [300, 250], - ], - bidId: '2a19afd5173318', - bidderRequestId: '1f4001782ac16c', - auctionId: 'aba03555-4802-4c45-9f15-05ffa8594cff', - transactionId: '894bdff6-61ec-4bec-a5a9-f36a5bfccef5' - }]; - - const bidderRequest = { - refererInfo: { - referer: 'https://gnetproject.com/' - } - }; - - it('sends bid request to ENDPOINT via POST', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].url).to.equal(ENDPOINT); - expect(requests[0].method).to.equal('POST'); - expect(requests[0].data).to.equal(JSON.stringify({ - 'referer': 'https://gnetproject.com/', - 'adUnitCode': '/150790500/4_ZONA_IAB_300x250_5', - 'bidId': '2a19afd5173318', - 'transactionId': '894bdff6-61ec-4bec-a5a9-f36a5bfccef5', - 'sizes': ['300x250'], - 'params': { - 'websiteId': '4', - 'externalId': '4d52cccf30309282256012cf30309282' - } - })); - }); - }); - - describe('interpretResponse', function () { - const bidderRequests = [{ - bidder: 'gnet', - params: { - clientId: '123456' - }, - adUnitCode: '/150790500/4_ZONA_IAB_300x250_5', - sizes: [ - [300, 250], - ], - bidId: '2a19afd5173318', - bidderRequestId: '1f4001782ac16c', - auctionId: 'aba03555-4802-4c45-9f15-05ffa8594cff', - transactionId: '894bdff6-61ec-4bec-a5a9-f36a5bfccef5' - }]; - - it('should get correct banner bid response', function () { - const response = { - bids: [ - { - bidId: '2a19afd5173318', - cpm: 0.1, - currency: 'BRL', - width: 300, - height: 250, - ad: '

I am an ad

', - creativeId: '173560700', - } - ] - }; - - const expectedResponse = [ - { - requestId: '2a19afd5173318', - cpm: 0.1, - currency: 'BRL', - width: 300, - height: 250, - ad: '

I am an ad

', - ttl: 300, - creativeId: '173560700', - netRevenue: true - } - ]; - - const result = spec.interpretResponse({ - body: response - }, bidderRequests); - expect(result).to.have.lengthOf(1); - expect(result).to.deep.have.same.members(expectedResponse); - }); - - it('handles nobid responses', function () { - const response = ''; - - const result = spec.interpretResponse({ - body: response - }, bidderRequests); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/haxmediaBidAdapter_spec.js b/test/spec/modules/haxmediaBidAdapter_spec.js deleted file mode 100644 index 2e39d771bdf..00000000000 --- a/test/spec/modules/haxmediaBidAdapter_spec.js +++ /dev/null @@ -1,304 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/haxmediaBidAdapter.js'; -import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; - -describe('haxmediaBidAdapter', function () { - const bid = { - bidId: '23fhj33i987f', - bidder: 'haxmedia', - mediaTypes: { - [BANNER]: { - sizes: [[300, 250]] - } - }, - params: { - placementId: 783, - traffic: BANNER - } - }; - - const bidderRequest = { - refererInfo: { - referer: 'test.com' - } - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are bidId, params and key 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], bidderRequest); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://balancer.haxmedia.io/?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'); - expect(data.gdpr).to.not.exist; - expect(data.ccpa).to.not.exist; - let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'schain'); - expect(placement.placementId).to.equal(783); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal(BANNER); - expect(placement.schain).to.be.an('object'); - expect(placement.sizes).to.be.an('array'); - }); - - it('Returns valid data for mediatype video', function () { - const playerSize = [300, 300]; - bid.mediaTypes = {}; - bid.params.traffic = VIDEO; - bid.mediaTypes[VIDEO] = { - playerSize - }; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data).to.be.an('object'); - let placement = data['placements'][0]; - expect(placement).to.be.an('object'); - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'wPlayer', 'hPlayer', 'schain'); - expect(placement.traffic).to.equal(VIDEO); - expect(placement.wPlayer).to.equal(playerSize[0]); - expect(placement.hPlayer).to.equal(playerSize[1]); - }); - - it('Returns valid data for mediatype native', function () { - const native = { - title: { - required: true - }, - body: { - required: true - }, - icon: { - required: true, - size: [64, 64] - } - }; - - bid.mediaTypes = {}; - bid.params.traffic = NATIVE; - bid.mediaTypes[NATIVE] = native; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data).to.be.an('object'); - let placement = data['placements'][0]; - expect(placement).to.be.an('object'); - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'native', 'schain'); - expect(placement.traffic).to.equal(NATIVE); - expect(placement.native).to.equal(native); - }); - - it('Returns data with gdprConsent and without uspConsent', function () { - bidderRequest.gdprConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.gdpr).to.exist; - expect(data.gdpr).to.be.a('string'); - expect(data.gdpr).to.equal(bidderRequest.gdprConsent); - expect(data.ccpa).to.not.exist; - delete bidderRequest.gdprConsent; - }); - - it('Returns data with uspConsent and without gdprConsent', function () { - bidderRequest.uspConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.ccpa).to.exist; - expect(data.ccpa).to.be.a('string'); - expect(data.ccpa).to.equal(bidderRequest.uspConsent); - expect(data.gdpr).to.not.exist; - }); - - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); -}); diff --git a/test/spec/modules/hpmdnetworkBidAdapter_spec.js b/test/spec/modules/hpmdnetworkBidAdapter_spec.js deleted file mode 100644 index 9023fb248e9..00000000000 --- a/test/spec/modules/hpmdnetworkBidAdapter_spec.js +++ /dev/null @@ -1,148 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/hpmdnetworkBidAdapter.js'; - -describe('HPMDNetwork Adapter', function() { - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - const validBid = { - bidder: 'hpmdnetwork', - params: { - placementId: '1' - } - }; - - expect(spec.isBidRequestValid(validBid)).to.equal(true); - }); - - it('should return false for when required params are not passed', function () { - const invalidBid = { - bidder: 'hpmdnetwork', - params: {} - }; - - expect(spec.isBidRequestValid(invalidBid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { - bidId: 'bid1', - bidder: 'hpmdnetwork', - params: { - placementId: '1' - } - }, - { - bidId: 'bid2', - bidder: 'hpmdnetwork', - params: { - placementId: '2', - } - } - ]; - const bidderRequest = { - refererInfo: { - referer: 'https://example.com?foo=bar' - } - }; - - const bidRequest = spec.buildRequests(bidRequests, bidderRequest); - - it('should build single POST request for multiple bids', function() { - expect(bidRequest.method).to.equal('POST'); - 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); - }); - - it('should pass bid parameters', function() { - const place1 = bidRequest.data.places[0]; - const place2 = bidRequest.data.places[1]; - - expect(place1.placementId).to.equal('1'); - expect(place2.placementId).to.equal('2'); - expect(place1.id).to.equal('bid1'); - expect(place2.id).to.equal('bid2'); - }); - - it('should pass site parameters', function() { - const url = bidRequest.data.url; - - expect(url).to.be.an('String'); - expect(url).to.equal('https://example.com?foo=bar'); - }); - - it('should pass settings', function() { - const settings = bidRequest.data.settings; - - expect(settings).to.be.an('object'); - expect(settings.currency).to.equal('RUB'); - }); - }); - - describe('interpretResponse', function () { - const serverResponse = { - body: { - 'bids': - [ - { - 'cpm': 20, - 'currency': 'RUB', - 'displayUrl': 'https://banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=168', - 'id': '1', - 'creativeId': '11111', - }, - { - 'cpm': 30, - 'currency': 'RUB', - 'displayUrl': 'https://banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=170', - 'id': '2', - 'creativeId': '22222', - 'width': 300, - 'height': 250, - }, - ] - } - }; - - const bids = spec.interpretResponse(serverResponse); - - it('should return empty array for response with no bids', function() { - const emptyBids = spec.interpretResponse({ body: {} }); - - expect(emptyBids).to.have.lengthOf(0); - }); - - it('should parse all bids from response', function() { - expect(bids).to.have.lengthOf(2); - }); - - it('should parse bid without sizes', function() { - expect(bids[0].requestId).to.equal('1'); - expect(bids[0].cpm).to.equal(20); - expect(bids[0].width).to.equal(1); - expect(bids[0].height).to.equal(1); - expect(bids[0].ttl).to.equal(300); - expect(bids[0].currency).to.equal('RUB'); - 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(''); - }); - - it('should parse bid with sizes', function() { - expect(bids[1].requestId).to.equal('2'); - expect(bids[1].cpm).to.equal(30); - expect(bids[1].width).to.equal(300); - expect(bids[1].height).to.equal(250); - expect(bids[1].ttl).to.equal(300); - expect(bids[1].currency).to.equal('RUB'); - 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(''); - }); - }); -}); diff --git a/test/spec/modules/impactifyBidAdapter_spec.js b/test/spec/modules/impactifyBidAdapter_spec.js deleted file mode 100644 index d14cea8cad3..00000000000 --- a/test/spec/modules/impactifyBidAdapter_spec.js +++ /dev/null @@ -1,398 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/impactifyBidAdapter.js'; -import * as utils from 'src/utils.js'; - -const BIDDER_CODE = 'impactify'; -const BIDDER_ALIAS = ['imp']; -const DEFAULT_CURRENCY = 'USD'; -const DEFAULT_VIDEO_WIDTH = 640; -const DEFAULT_VIDEO_HEIGHT = 480; -const ORIGIN = 'https://sonic.impactify.media'; -const LOGGER_URI = 'https://logger.impactify.media'; -const AUCTIONURI = '/bidder'; -const COOKIESYNCURI = '/static/cookie_sync.html'; -const GVLID = 606; - -var gdprData = { - 'consentString': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', - 'gdprApplies': true -}; - -describe('ImpactifyAdapter', function () { - describe('isBidRequestValid', function () { - let validBid = { - bidder: 'impactify', - params: { - appId: '1', - format: 'screen', - style: 'inline' - } - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(validBid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, validBid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when appId is missing', () => { - const bid = utils.deepClone(validBid); - delete bid.params.appId; - - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when appId is not a string', () => { - const bid = utils.deepClone(validBid); - - bid.params.appId = 123; - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.appId = false; - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.appId = void (0); - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.appId = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when format is missing', () => { - const bid = utils.deepClone(validBid); - delete bid.params.format; - - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when format is not a string', () => { - const bid = utils.deepClone(validBid); - - bid.params.format = 123; - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.format = false; - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.format = void (0); - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.format = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when format is not equals to screen or display', () => { - const bid = utils.deepClone(validBid); - if (bid.params.format != 'screen' && bid.params.format != 'display') { - expect(spec.isBidRequestValid(bid)).to.equal(false); - } - }); - - it('should return false when style is missing', () => { - const bid = utils.deepClone(validBid); - delete bid.params.style; - - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when style is not a string', () => { - const bid = utils.deepClone(validBid); - - bid.params.style = 123; - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.style = false; - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.style = void (0); - expect(spec.isBidRequestValid(bid)).to.equal(false); - - bid.params.style = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - describe('buildRequests', function () { - let videoBidRequests = [ - { - bidder: 'impactify', - params: { - appId: '1', - format: 'screen', - style: 'inline' - }, - mediaTypes: { - video: { - context: 'instream' - } - }, - adUnitCode: 'adunit-code', - sizes: [[DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT]], - bidId: '123456789', - bidderRequestId: '987654321', - auctionId: '19ab94a9-b0d7-4ed7-9f80-ad0c033cf1b1', - transactionId: 'f7b2c372-7a7b-11eb-9439-0242ac130002' - } - ]; - let videoBidderRequest = { - bidderRequestId: '98845765110', - auctionId: '165410516454', - bidderCode: 'impactify', - bids: [ - { - ...videoBidRequests[0] - } - ], - refererInfo: { - referer: 'https://impactify.io' - } - }; - - it('sends video bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(videoBidRequests, videoBidderRequest); - expect(request.url).to.equal(ORIGIN + AUCTIONURI); - expect(request.method).to.equal('POST'); - }); - }); - describe('interpretResponse', function () { - it('should get correct bid response', function () { - let response = { - id: '19ab94a9-b0d7-4ed7-9f80-ad0c033cf1b1', - seatbid: [ - { - bid: [ - { - id: '65820304700829014', - impid: '462c08f20d428', - price: 3.40, - adm: '', - adid: '97517771', - adomain: [ - '' - ], - iurl: 'https://fra1-ib.adnxs.com/cr?id=97517771', - cid: '9325', - crid: '97517771', - w: 1, - h: 1, - ext: { - prebid: { - 'type': 'video' - }, - bidder: { - prebid: { - type: 'video', - video: { - duration: 30, - primary_category: '' - } - }, - bidder: { - appnexus: { - brand_id: 182979, - auction_id: 8657683934873599656, - bidder_id: 2, - bid_ad_type: 1, - creative_info: { - video: { - duration: 30, - mimes: [ - 'video/x-flv', - 'video/mp4', - 'video/webm' - ] - } - } - } - } - } - } - } - ], - seat: 'impactify' - } - ], - cur: DEFAULT_CURRENCY, - ext: { - responsetimemillis: { - impactify: 114 - }, - prebid: { - auctiontimestamp: 1614587024591 - } - } - }; - let bidderRequest = { - bids: [ - { - bidId: '462c08f20d428', - adUnitCode: '/19968336/header-bid-tag-1', - auctionId: '19ab94a9-b0d7-4ed7-9f80-ad0c033cf1b1', - bidder: 'impactify', - sizes: [[DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT]], - mediaTypes: { - video: { - context: 'outstream' - } - } - }, - ] - } - let expectedResponse = [ - { - id: '65820304700829014', - requestId: '462c08f20d428', - cpm: 3.40, - currency: DEFAULT_CURRENCY, - netRevenue: true, - ad: '', - width: 1, - height: 1, - hash: 'test', - expiry: 166192938, - ttl: 300, - creativeId: '97517771' - } - ]; - let result = spec.interpretResponse({ body: response }, bidderRequest); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - }); - describe('getUserSyncs', function () { - let videoBidRequests = [ - { - bidder: 'impactify', - params: { - appId: '1', - format: 'screen', - style: 'inline' - }, - mediaTypes: { - video: { - context: 'instream' - } - }, - adUnitCode: 'adunit-code', - sizes: [[DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT]], - bidId: '123456789', - bidderRequestId: '987654321', - auctionId: '19ab94a9-b0d7-4ed7-9f80-ad0c033cf1b1', - transactionId: 'f7b2c372-7a7b-11eb-9439-0242ac130002' - } - ]; - let videoBidderRequest = { - bidderRequestId: '98845765110', - auctionId: '165410516454', - bidderCode: 'impactify', - bids: [ - { - ...videoBidRequests[0] - } - ], - refererInfo: { - referer: 'https://impactify.io' - } - }; - let validResponse = { - id: '19ab94a9-b0d7-4ed7-9f80-ad0c033cf1b1', - seatbid: [ - { - bid: [ - { - id: '65820304700829014', - impid: '462c08f20d428', - price: 3.40, - adm: '', - adid: '97517771', - adomain: [ - '' - ], - iurl: 'https://fra1-ib.adnxs.com/cr?id=97517771', - cid: '9325', - crid: '97517771', - w: 1, - h: 1, - ext: { - prebid: { - 'type': 'video' - }, - bidder: { - prebid: { - type: 'video', - video: { - duration: 30, - primary_category: '' - } - }, - bidder: { - appnexus: { - brand_id: 182979, - auction_id: 8657683934873599656, - bidder_id: 2, - bid_ad_type: 1, - creative_info: { - video: { - duration: 30, - mimes: [ - 'video/x-flv', - 'video/mp4', - 'video/webm' - ] - } - } - } - } - } - } - } - ], - seat: 'impactify' - } - ], - cur: DEFAULT_CURRENCY, - ext: { - responsetimemillis: { - impactify: 114 - }, - prebid: { - auctiontimestamp: 1614587024591 - } - } - }; - it('should return empty response if server response is false', function () { - const result = spec.getUserSyncs('bad', false, gdprData); - expect(result).to.be.empty; - }); - it('should return empty response if server response is empty', function () { - const result = spec.getUserSyncs('bad', [], gdprData); - expect(result).to.be.empty; - }); - it('should append the various values if they exist', function() { - const result = spec.getUserSyncs({iframeEnabled: true}, validResponse, gdprData); - expect(result[0].url).to.include('gdpr=1'); - expect(result[0].url).to.include('gdpr_consent=BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA'); - }); - }); - - describe('On winning bid', function () { - const bid = { - ad: '', - cpm: '2' - }; - const result = spec.onBidWon(bid); - assert.ok(result); - }); - - describe('On bid Time out', function () { - const bid = { - ad: '', - cpm: '2' - }; - const result = spec.onTimeout(bid); - assert.ok(result); - }); -}) diff --git a/test/spec/modules/innityBidAdapter_spec.js b/test/spec/modules/innityBidAdapter_spec.js deleted file mode 100644 index 80c00252632..00000000000 --- a/test/spec/modules/innityBidAdapter_spec.js +++ /dev/null @@ -1,106 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/innityBidAdapter.js'; - -describe('innityAdapterTest', () => { - describe('bidRequestValidity', () => { - it('bidRequest with pub ID and zone ID param', () => { - expect(spec.isBidRequestValid({ - bidder: 'innity', - params: { - 'pub': 267, - 'zone': 62546 - }, - })).to.equal(true); - }); - - it('bidRequest with no required params', () => { - expect(spec.isBidRequestValid({ - bidder: 'innity', - params: { - }, - })).to.equal(false); - }); - }); - - describe('bidRequest', () => { - const bidRequests = [{ - 'bidder': 'innity', - 'params': { - 'pub': 267, - 'zone': 62546 - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [300, 250], - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - const bidderRequest = { - refererInfo: { - referer: 'https://example.com' - } - }; - - it('bidRequest HTTP method', () => { - const requests = spec.buildRequests(bidRequests, bidderRequest); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - }); - }); - - it('bidRequest data', () => { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].data.pub).to.equal(267); - expect(requests[0].data.zone).to.equal(62546); - expect(requests[0].data.width).to.equal('300'); - expect(requests[0].data.height).to.equal('250'); - expect(requests[0].data.callback_uid).to.equal('51ef8751f9aead'); - }); - }); - - describe('interpretResponse', () => { - 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', () => { - 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/ipromBidAdapter_spec.js b/test/spec/modules/ipromBidAdapter_spec.js deleted file mode 100644 index a3310a33cc2..00000000000 --- a/test/spec/modules/ipromBidAdapter_spec.js +++ /dev/null @@ -1,195 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/ipromBidAdapter.js'; - -describe('iPROM Adapter', function () { - let bidRequests; - let bidderRequest; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'iprom', - params: { - id: '1234', - dimension: '300x250', - }, - adUnitCode: '/19966331/header-bid-tag-1', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - } - }, - bidId: '29a72b151f7bd3', - auctionId: 'e36abb27-g3b1-1ad6-8a4c-701c8919d3hh', - bidderRequestId: '2z76da40m1b3cb8', - transactionId: 'j51lhf58-1ad6-g3b1-3j6s-912c9493g0gu' - } - ]; - - bidderRequest = { - timeout: 3000, - refererInfo: { - referer: 'https://adserver.si/index.html', - reachedTop: true, - numIframes: 1, - stack: [ - 'https://adserver.si/index.html', - 'https://adserver.si/iframe1.html', - ] - } - } - }); - - describe('validating bids', function () { - it('should accept valid bid', function () { - let validBid = { - bidder: 'iprom', - params: { - id: '1234', - dimension: '300x250', - }, - }; - - const isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject bid if missing dimension and id', function () { - let invalidBid = { - bidder: 'iprom', - params: {} - }; - - const isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should reject bid if missing dimension', function () { - let invalidBid = { - bidder: 'iprom', - params: { - id: '1234', - } - }; - - const isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should reject bid if dimension is not a string', function () { - let invalidBid = { - bidder: 'iprom', - params: { - id: '1234', - dimension: 404, - } - }; - - const isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should reject bid if missing id', function () { - let invalidBid = { - bidder: 'iprom', - params: { - dimension: '300x250', - } - }; - - const isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should reject bid if id is not a string', function () { - let invalidBid = { - bidder: 'iprom', - params: { - id: 1234, - dimension: '300x250', - } - }; - - const isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - - describe('building requests', function () { - it('should go to correct endpoint', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - - expect(request.method).to.exist; - expect(request.method).to.equal('POST'); - expect(request.url).to.exist; - expect(request.url).to.equal('https://core.iprom.net/programmatic'); - }); - - it('should add referer info', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - const requestparse = JSON.parse(request.data); - - expect(requestparse.referer).to.exist; - expect(requestparse.referer.referer).to.equal('https://adserver.si/index.html'); - }); - - it('should add adapter version', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - const requestparse = JSON.parse(request.data); - - expect(requestparse.version).to.exist; - }); - - it('should contain id and dimension', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - const requestparse = JSON.parse(request.data); - - expect(requestparse.bids[0].params.id).to.equal('1234'); - expect(requestparse.bids[0].params.dimension).to.equal('300x250'); - }); - }); - - describe('handling responses', function () { - it('should return complete bid response', function () { - const serverResponse = { - body: [{ - requestId: '29a72b151f7bd3', - cpm: 0.5, - width: '300', - height: '250', - creativeId: 1234, - ad: 'Iprom Header bidding example', - aDomains: ['https://example.com'], - } - ]}; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const bids = spec.interpretResponse(serverResponse, request); - - expect(bids).to.be.lengthOf(1); - expect(bids[0].requestId).to.equal('29a72b151f7bd3'); - expect(bids[0].cpm).to.equal(0.5); - expect(bids[0].width).to.equal('300'); - expect(bids[0].height).to.equal('250'); - expect(bids[0].ad).to.have.length.above(1); - expect(bids[0].meta.advertiserDomains).to.deep.equal(['https://example.com']); - }); - - it('should return empty bid response', function () { - const emptyServerResponse = { - body: [] - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const bids = spec.interpretResponse(emptyServerResponse, request); - - expect(bids).to.be.lengthOf(0); - }); - }); -}); diff --git a/test/spec/modules/ironsourceBidAdapter_spec.js b/test/spec/modules/ironsourceBidAdapter_spec.js deleted file mode 100644 index cca928ff28b..00000000000 --- a/test/spec/modules/ironsourceBidAdapter_spec.js +++ /dev/null @@ -1,381 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/ironsourceBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import { config } from 'src/config.js'; -import { VIDEO } from '../../../src/mediaTypes.js'; - -const ENDPOINT = 'https://hb.yellowblue.io/hb'; -const TEST_ENDPOINT = 'https://hb.yellowblue.io/hb-test'; -const TTL = 360; - -describe('ironsourceAdapter', 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': spec.code, - 'adUnitCode': 'adunit-code', - 'sizes': [['640', '480']], - 'params': { - 'isOrg': 'jdye8weeyirk00000001' - } - }; - - it('should return true when required params are passed', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not found', function () { - const newBid = Object.assign({}, bid); - delete newBid.params; - newBid.params = { - 'isOrg': null - }; - expect(spec.isBidRequestValid(newBid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { - 'bidder': spec.code, - 'adUnitCode': 'adunit-code', - 'sizes': [[640, 480]], - 'params': { - 'isOrg': 'jdye8weeyirk00000001' - }, - 'bidId': '299ffc8cca0b87', - 'bidderRequestId': '1144f487e563f9', - 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', - } - ]; - - const testModeBidRequests = [ - { - 'bidder': spec.code, - 'adUnitCode': 'adunit-code', - 'sizes': [[640, 480]], - 'params': { - 'isOrg': 'jdye8weeyirk00000001', - 'testMode': true - }, - 'bidId': '299ffc8cca0b87', - 'bidderRequestId': '1144f487e563f9', - 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', - } - ]; - - const bidderRequest = { - bidderCode: 'ironsource', - } - - const customSessionId = '12345678'; - - it('sends bid request to ENDPOINT via GET', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('GET'); - } - }); - - it('sends bid request to test ENDPOINT via GET', function () { - const requests = spec.buildRequests(testModeBidRequests, bidderRequest); - for (const request of requests) { - expect(request.url).to.equal(TEST_ENDPOINT); - expect(request.method).to.equal('GET'); - } - }); - - it('should send the correct bid Id', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data.bid_id).to.equal('299ffc8cca0b87'); - } - }); - - it('sends the is_wrapper query param', function () { - bidRequests[0].params.isWrapper = true; - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data.is_wrapper).to.equal(true); - } - }); - - it('sends the custom session id as a query param', function () { - bidRequests[0].params.sessionId = customSessionId; - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data.session_id).to.equal(customSessionId); - } - }); - - it('should send the correct width and height', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('width', 640); - expect(request.data).to.have.property('height', 480); - } - }); - - it('should respect syncEnabled option', function() { - config.setConfig({ - userSync: { - syncEnabled: false, - filterSettings: { - all: { - bidders: '*', - filter: 'include' - } - } - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.not.have.property('cs_method'); - } - }); - - it('should respect "iframe" filter settings', function () { - config.setConfig({ - userSync: { - syncEnabled: true, - filterSettings: { - iframe: { - bidders: [spec.code], - filter: 'include' - } - } - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('cs_method', 'iframe'); - } - }); - - it('should respect "all" filter settings', function () { - config.setConfig({ - userSync: { - syncEnabled: true, - filterSettings: { - all: { - bidders: [spec.code], - filter: 'include' - } - } - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('cs_method', 'iframe'); - } - }); - - it('should send the pixel user sync param if userSync is enabled and no "iframe" or "all" configs are present', function () { - config.setConfig({ - userSync: { - syncEnabled: true - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('cs_method', 'pixel'); - } - }); - - it('should respect total exclusion', function() { - config.setConfig({ - userSync: { - syncEnabled: true, - filterSettings: { - image: { - bidders: [spec.code], - filter: 'exclude' - }, - iframe: { - bidders: [spec.code], - filter: 'exclude' - } - } - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.not.have.property('cs_method'); - } - }); - - it('should have us_privacy param if usPrivacy is available in the bidRequest', function () { - const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); - const requests = spec.buildRequests(bidRequests, bidderRequestWithUSP); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('us_privacy', '1YNN'); - } - }); - - it('should have an empty us_privacy param if usPrivacy is missing in the bidRequest', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.not.have.property('us_privacy'); - } - }); - - it('should not send the gdpr param if gdprApplies is false in the bidRequest', function () { - const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: false}}, bidderRequest); - const requests = spec.buildRequests(bidRequests, bidderRequestWithGDPR); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.not.have.property('gdpr'); - expect(request.data).to.not.have.property('gdpr_consent'); - } - }); - - it('should send the gdpr param if gdprApplies is true in the bidRequest', function () { - const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}}, bidderRequest); - const requests = spec.buildRequests(bidRequests, bidderRequestWithGDPR); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('gdpr', true); - expect(request.data).to.have.property('gdpr_consent', 'test-consent-string'); - } - }); - - it('should have schain param if it is available in the bidRequest', () => { - const schain = { - ver: '1.0', - complete: 1, - nodes: [{ asi: 'indirectseller.com', sid: '00001', hp: 1 }], - }; - bidRequests[0].schain = schain; - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('schain', '1.0,1!indirectseller.com,00001,,,,'); - } - }); - }); - - describe('interpretResponse', function () { - const response = { - cpm: 12.5, - vastXml: '', - width: 640, - height: 480, - requestId: '21e12606d47ba7', - netRevenue: true, - currency: 'USD' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - requestId: '21e12606d47ba7', - cpm: 12.5, - width: 640, - height: 480, - creativeId: '21e12606d47ba7', - currency: 'USD', - netRevenue: true, - ttl: TTL, - vastXml: '', - mediaType: VIDEO - } - ]; - const result = spec.interpretResponse({ body: response }); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - }) - - describe('getUserSyncs', function() { - const imageSyncResponse = { - body: { - userSyncPixels: [ - 'https://image-sync-url.test/1', - 'https://image-sync-url.test/2', - 'https://image-sync-url.test/3' - ] - } - }; - - const iframeSyncResponse = { - body: { - userSyncURL: 'https://iframe-sync-url.test' - } - }; - - it('should register all img urls from the response', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: true }, [imageSyncResponse]); - expect(syncs).to.deep.equal([ - { - type: 'image', - url: 'https://image-sync-url.test/1' - }, - { - type: 'image', - url: 'https://image-sync-url.test/2' - }, - { - type: 'image', - url: 'https://image-sync-url.test/3' - } - ]); - }); - - it('should register the iframe url from the response', function() { - const syncs = spec.getUserSyncs({ iframeEnabled: true }, [iframeSyncResponse]); - expect(syncs).to.deep.equal([ - { - type: 'iframe', - url: 'https://iframe-sync-url.test' - } - ]); - }); - - it('should register both image and iframe urls from the responses', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [iframeSyncResponse, imageSyncResponse]); - expect(syncs).to.deep.equal([ - { - type: 'iframe', - url: 'https://iframe-sync-url.test' - }, - { - type: 'image', - url: 'https://image-sync-url.test/1' - }, - { - type: 'image', - url: 'https://image-sync-url.test/2' - }, - { - type: 'image', - url: 'https://image-sync-url.test/3' - } - ]); - }); - - it('should handle an empty response', function() { - const syncs = spec.getUserSyncs({ iframeEnabled: true }, []); - expect(syncs).to.deep.equal([]); - }); - - it('should handle when user syncs are disabled', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: false }, [imageSyncResponse]); - expect(syncs).to.deep.equal([]); - }); - }) -}); diff --git a/test/spec/modules/jcmBidAdapter_spec.js b/test/spec/modules/jcmBidAdapter_spec.js deleted file mode 100644 index 9d84bca5513..00000000000 --- a/test/spec/modules/jcmBidAdapter_spec.js +++ /dev/null @@ -1,139 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/jcmBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -const ENDPOINT = 'https://media.adfrontiers.com/'; - -describe('jcmAdapter', 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': 'jcm', - 'params': { - 'siteId': '3608' - }, - '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; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'jcm', - 'params': { - 'siteId': '3608' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - - ]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to ENDPOINT via GET', function () { - expect(request.method).to.equal('GET'); - }); - - it('sends correct bid parameters', function () { - const payloadArr = request.data.split('&'); - expect(request.method).to.equal('GET'); - expect(payloadArr.length).to.equal(4); - expect(payloadArr[0]).to.equal('t=hb'); - expect(payloadArr[1]).to.equal('ver=1.0'); - expect(payloadArr[2]).to.equal('compact=true'); - const adReqStr = request.data.split('&bids=')[1]; - const adReq = JSON.parse(decodeURIComponent(adReqStr)); - const adReqBid = JSON.parse(decodeURIComponent(adReqStr)).bids[0]; - expect(adReqBid.siteId).to.equal('3608'); - expect(adReqBid.callbackId).to.equal('30b31c1838de1e'); - expect(adReqBid.adSizes).to.equal('300x250,300x600'); - }); - }); - - describe('interpretResponse', function () { - it('should get correct bid response', function () { - let serverResponse = {'bids': [{'width': 300, 'height': 250, 'creativeId': '29681110', 'ad': '', 'cpm': 0.5, 'callbackId': '30b31c1838de1e'}]}; - - let expectedResponse = [ - { - 'requestId': '30b31c1838de1e', - 'bidderCode': 'jcm', - 'cpm': 0.5, - 'creativeId': '29681110', - 'width': 300, - 'height': 250, - 'ttl': 60, - 'currency': 'USA', - 'netRevenue': true, - 'ad': '', - } - ]; - - 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]).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('handles nobid responses', function () { - let serverResponse = {'bids': []}; - - let result = spec.interpretResponse({ body: serverResponse }); - expect(result.length).to.equal(0); - }); - }); - describe('getUserSyncs', function () { - it('Verifies sync iframe option', 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('https://media.adfrontiers.com/hb/jcm_usersync.html'); - }); - - it('Verifies sync image option', function () { - expect(spec.getUserSyncs({ image: false })).to.be.undefined; - const options = spec.getUserSyncs({ image: true }); - 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('https://media.adfrontiers.com/hb/jcm_usersync.png'); - }); - }); -}); diff --git a/test/spec/modules/krushmediaBidAdapter_spec.js b/test/spec/modules/krushmediaBidAdapter_spec.js deleted file mode 100644 index 3af9ed64c43..00000000000 --- a/test/spec/modules/krushmediaBidAdapter_spec.js +++ /dev/null @@ -1,329 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/krushmediaBidAdapter.js'; -import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; - -describe('KrushmediabBidAdapter', function () { - const bid = { - bidId: '23fhj33i987f', - bidder: 'krushmedia', - mediaTypes: { - [BANNER]: { - sizes: [[300, 250]] - } - }, - params: { - key: 783, - traffic: BANNER - } - }; - - const bidderRequest = { - refererInfo: { - referer: 'test.com' - } - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are bidId, params and key 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.key; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid], bidderRequest); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://ads4.krushmedia.com/?c=rtb&m=hb'); - }); - 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'); - expect(data.gdpr).to.not.exist; - expect(data.ccpa).to.not.exist; - let placement = data['placements'][0]; - expect(placement).to.have.keys('key', 'bidId', 'traffic', 'sizes', 'schain'); - expect(placement.key).to.equal(783); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal(BANNER); - expect(placement.schain).to.be.an('object'); - expect(placement.sizes).to.be.an('array'); - }); - - it('Returns valid data for mediatype video', function () { - const playerSize = [300, 300]; - bid.mediaTypes = {}; - bid.params.traffic = VIDEO; - bid.mediaTypes[VIDEO] = { - playerSize - }; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data).to.be.an('object'); - let placement = data['placements'][0]; - expect(placement).to.be.an('object'); - expect(placement).to.have.keys('key', 'bidId', 'traffic', 'wPlayer', 'hPlayer', 'schain'); - expect(placement.traffic).to.equal(VIDEO); - expect(placement.wPlayer).to.equal(playerSize[0]); - expect(placement.hPlayer).to.equal(playerSize[1]); - }); - - it('Returns valid data for mediatype native', function () { - const native = { - title: { - required: true - }, - body: { - required: true - }, - icon: { - required: true, - size: [64, 64] - } - }; - - bid.mediaTypes = {}; - bid.params.traffic = NATIVE; - bid.mediaTypes[NATIVE] = native; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data).to.be.an('object'); - let placement = data['placements'][0]; - expect(placement).to.be.an('object'); - expect(placement).to.have.keys('key', 'bidId', 'traffic', 'native', 'schain'); - expect(placement.traffic).to.equal(NATIVE); - expect(placement.native).to.equal(native); - }); - - it('Returns data with gdprConsent and without uspConsent', function () { - bidderRequest.gdprConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.gdpr).to.exist; - expect(data.gdpr).to.be.a('string'); - expect(data.gdpr).to.equal(bidderRequest.gdprConsent); - expect(data.ccpa).to.not.exist; - delete bidderRequest.gdprConsent; - }); - - it('Returns data with uspConsent and without gdprConsent', function () { - bidderRequest.uspConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.ccpa).to.exist; - expect(data.ccpa).to.be.a('string'); - expect(data.ccpa).to.equal(bidderRequest.uspConsent); - expect(data.gdpr).to.not.exist; - }); - - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - describe('getUserSyncs', function() { - it('Should return array of objects with proper sync config , include GDPR', function() { - const syncData = spec.getUserSyncs({}, {}, { - consentString: 'ALL', - gdprApplies: true, - }, {}); - expect(syncData).to.be.an('array').which.is.not.empty; - expect(syncData[0]).to.be.an('object') - expect(syncData[0].type).to.be.a('string') - expect(syncData[0].type).to.equal('iframe') - expect(syncData[0].url).to.be.a('string') - expect(syncData[0].url).to.equal('https://cs.krushmedia.com/html?src=pbjs&gdpr=1&gdpr_consent=ALL') - }); - it('Should return array of objects with proper sync config , include CCPA', function() { - const syncData = spec.getUserSyncs({}, {}, {}, { - consentString: '1NNN' - }); - expect(syncData).to.be.an('array').which.is.not.empty; - expect(syncData[0]).to.be.an('object') - expect(syncData[0].type).to.be.a('string') - expect(syncData[0].type).to.equal('iframe') - expect(syncData[0].url).to.be.a('string') - expect(syncData[0].url).to.equal('https://cs.krushmedia.com/html?src=pbjs&ccpa_consent=1NNN') - }); - }); -}); diff --git a/test/spec/modules/lifestreetBidAdapter_spec.js b/test/spec/modules/lifestreetBidAdapter_spec.js deleted file mode 100644 index d66727da644..00000000000 --- a/test/spec/modules/lifestreetBidAdapter_spec.js +++ /dev/null @@ -1,232 +0,0 @@ -import { expect } from 'chai'; -import { BANNER, VIDEO } from 'src/mediaTypes.js'; -import { spec } from 'modules/lifestreetBidAdapter.js'; - -describe('lifestreetBidAdapter', function() { - let bidRequests; - let videoBidRequests; - let bidResponses; - let videoBidResponses; - beforeEach(function() { - bidRequests = [ - { - bidder: 'lifestreet', - params: { - slot: 'slot166704', - adkey: '78c', - ad_size: '160x600' - }, - mediaTypes: { - banner: { - sizes: [ - [160, 600], - [300, 600] - ] - } - }, - sizes: [ - [160, 600], - [300, 600] - ] - } - ]; - - bidResponses = { - body: { - cpm: 0.1, - netRevenue: true, - content_type: 'display_flash', - width: 160, - currency: 'USD', - ttl: 86400, - content: '', - 'adid': '56380110', - 'cid': '44724710', - 'crid': '443801010', - 'w': 300, - 'h': 250, - 'ext': { - 'prebid': { - 'targeting': { - 'hb_bidder': 'luponmedia', - 'hb_pb': '0.40', - 'hb_size': '300x250' - }, - 'type': 'banner' - } - } - } - ], - 'seat': 'luponmedia' - } - ], - 'cur': 'USD', - 'ext': { - 'responsetimemillis': { - 'luponmedia': 233 - }, - 'tmaxrequest': 1500, - 'usersyncs': { - 'status': 'ok', - 'bidder_status': [] - } - } - }; - - let expectedResponse = [ - { - 'requestId': '2a122246ef72ea', - 'cpm': '0.43', - 'width': 300, - 'height': 250, - 'creativeId': '443801010', - 'currency': 'USD', - 'dealId': '23425', - 'netRevenue': false, - 'ttl': 300, - 'referrer': '', - 'ad': ' ' - } - ]; - - let bidderRequest = { - 'data': '{"site":{"page":"https://novi.ba/clanak/176067/fast-car-beginner-s-guide-to-tuning-turbo-engines"}}' - }; - - 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 noBidResponse = []; - - let noBidBidderRequest = { - 'data': '{"site":{"page":""}}' - } - let noBidResult = spec.interpretResponse({ body: noBidResponse }, noBidBidderRequest); - expect(noBidResult.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - const bidResponse1 = { - 'body': { - 'ext': { - 'responsetimemillis': { - 'luponmedia': 233 - }, - 'tmaxrequest': 1500, - 'usersyncs': { - 'status': 'ok', - 'bidder_status': [ - { - 'bidder': 'luponmedia', - 'no_cookie': true, - 'usersync': { - 'url': 'https://adxpremium.services/api/usersync', - 'type': 'redirect' - } - }, - { - 'bidder': 'luponmedia', - 'no_cookie': true, - 'usersync': { - 'url': 'https://adxpremium.services/api/iframeusersync', - 'type': 'iframe' - } - } - ] - } - } - } - }; - - const bidResponse2 = { - 'body': { - 'ext': { - 'responsetimemillis': { - 'luponmedia': 233 - }, - 'tmaxrequest': 1500, - 'usersyncs': { - 'status': 'no_cookie', - 'bidder_status': [] - } - } - } - }; - - it('should use a sync url from first response (pixel and iframe)', function () { - const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [bidResponse1, bidResponse2]); - expect(syncs).to.deep.equal([ - { - type: 'image', - url: 'https://adxpremium.services/api/usersync' - }, - { - type: 'iframe', - url: 'https://adxpremium.services/api/iframeusersync' - } - ]); - }); - - it('handle empty response (e.g. timeout)', function () { - const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, []); - expect(syncs).to.deep.equal([]); - }); - - it('returns empty syncs when not pixel enabled and not iframe enabled', function () { - const syncs = spec.getUserSyncs({ pixelEnabled: false, iframeEnabled: false }, [bidResponse1]); - expect(syncs).to.deep.equal([]); - }); - - it('returns pixel syncs when pixel enabled and not iframe enabled', function() { - resetUserSync(); - - const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: false }, [bidResponse1]); - expect(syncs).to.deep.equal([ - { - type: 'image', - url: 'https://adxpremium.services/api/usersync' - } - ]); - }); - - it('returns iframe syncs when not pixel enabled and iframe enabled', function() { - resetUserSync(); - - const syncs = spec.getUserSyncs({ pixelEnabled: false, iframeEnabled: true }, [bidResponse1]); - expect(syncs).to.deep.equal([ - { - type: 'iframe', - url: 'https://adxpremium.services/api/iframeusersync' - } - ]); - }); - }); - - describe('hasValidSupplyChainParams', function () { - it('returns true if schain is valid', function () { - const schain = { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ - { - 'asi': 'novi.ba', - 'sid': '199424', - 'hp': 1 - } - ] - }; - - const checkSchain = hasValidSupplyChainParams(schain); - expect(checkSchain).to.equal(true); - }); - - it('returns false if schain is invalid', function () { - const schain = { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ - { - 'invalid': 'novi.ba' - } - ] - }; - - const checkSchain = hasValidSupplyChainParams(schain); - expect(checkSchain).to.equal(false); - }); - }); - - describe('onBidWon', function () { - const bidWonEvent = { - 'bidderCode': 'luponmedia', - 'width': 300, - 'height': 250, - 'statusMessage': 'Bid available', - 'adId': '105bbf8c54453ff', - 'requestId': '934b8752185955', - 'mediaType': 'banner', - 'source': 'client', - 'cpm': 0.364, - 'creativeId': '443801010', - 'currency': 'USD', - 'netRevenue': false, - 'ttl': 300, - 'referrer': '', - 'ad': '', - 'auctionId': '926a8ea3-3dd4-4bf2-95ab-c85c2ce7e99b', - 'responseTimestamp': 1598527728026, - 'requestTimestamp': 1598527727629, - 'bidder': 'luponmedia', - 'adUnitCode': 'div-gpt-ad-1533155193780-5', - 'timeToRespond': 397, - 'size': '300x250', - 'status': 'rendered' - }; - - let ajaxStub; - - beforeEach(() => { - ajaxStub = sinon.stub(spec, 'sendWinningsToServer') - }) - - afterEach(() => { - ajaxStub.restore() - }) - - it('calls luponmedia\'s callback endpoint', () => { - const result = spec.onBidWon(bidWonEvent); - expect(result).to.equal(undefined); - expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.deep.equal(JSON.stringify(bidWonEvent)); - }); - }); -}); diff --git a/test/spec/modules/madvertiseBidAdapter_spec.js b/test/spec/modules/madvertiseBidAdapter_spec.js deleted file mode 100644 index 041b49ef69e..00000000000 --- a/test/spec/modules/madvertiseBidAdapter_spec.js +++ /dev/null @@ -1,203 +0,0 @@ -import {expect} from 'chai'; -import {config} from 'src/config.js'; -import * as utils from 'src/utils.js'; -import {spec} from 'modules/madvertiseBidAdapter.js'; - -describe('madvertise adapater', function () { - describe('Test validate req', function () { - it('should accept minimum valid bid', function () { - let bid = { - bidder: 'madvertise', - sizes: [[728, 90]], - params: { - s: 'test' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(true); - }); - it('should reject no sizes', function () { - let bid = { - bidder: 'madvertise', - params: { - s: 'test' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - it('should reject empty sizes', function () { - let bid = { - bidder: 'madvertise', - sizes: [], - params: { - s: 'test' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - it('should reject wrong format sizes', function () { - let bid = { - bidder: 'madvertise', - sizes: [['728x90']], - params: { - s: 'test' - } - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - it('should reject no params', function () { - let bid = { - bidder: 'madvertise', - sizes: [[728, 90]] - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - it('should reject missing s', function () { - let bid = { - bidder: 'madvertise', - params: {} - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - }); - - describe('Test build request', function () { - beforeEach(function () { - let mockConfig = { - consentManagement: { - cmpApi: 'IAB', - timeout: 1111, - allowAuctionWithoutConsent: 'cancel' - } - }; - - sinon.stub(config, 'getConfig').callsFake((key) => { - return utils.deepAccess(mockConfig, key); - }); - }); - afterEach(function () { - config.getConfig.restore(); - }); - let bid = [{ - bidder: 'madvertise', - sizes: [[728, 90], [300, 100]], - bidId: '51ef8751f9aead', - adUnitCode: 'div-gpt-ad-1460505748561-0', - transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - auctionId: '18fd8b8b0bd757', - bidderRequestId: '418b37f85e772c', - params: { - s: 'test', - } - }]; - it('minimum request with gdpr consent', function () { - let bidderRequest = { - gdprConsent: { - consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', - vendorData: {}, - gdprApplies: true - } - }; - const req = spec.buildRequests(bid, bidderRequest); - - expect(req).to.exist.and.to.be.a('array'); - 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('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`); - expect(req[0].url).to.contain(`&consent[0][format]=IAB`); - expect(req[0].url).to.contain(`&consent[0][value]=BOJ/P2HOJ/P2HABABMAAAAAZ+A==`) - }); - - it('minimum request without gdpr consent', function () { - let bidderRequest = {}; - const req = spec.buildRequests(bid, bidderRequest); - - expect(req).to.exist.and.to.be.a('array'); - 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('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`); - expect(req[0].url).not.to.contain(`&consent[0][format]=`); - expect(req[0].url).not.to.contain(`&consent[0][value]=`) - }); - }); - - describe('Test interpret response', function () { - it('General banner response', function () { - let bid = { - bidder: 'madvertise', - sizes: [[728, 90]], - bidId: '51ef8751f9aead', - adUnitCode: 'div-gpt-ad-1460505748561-0', - transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - auctionId: '18fd8b8b0bd757', - bidderRequestId: '418b37f85e772c', - params: { - s: 'test', - connection_type: 'WIFI', - age: 25, - } - }; - let resp = spec.interpretResponse({body: { - requestId: 'REQUEST_ID', - cpm: 1, - ad: '

I am an ad

', - Width: 320, - height: 50, - creativeId: 'CREATIVE_ID', - dealId: 'DEAL_ID', - ttl: 180, - currency: 'EUR', - netRevenue: true - }}, {bidId: bid.bidId}); - - expect(resp).to.exist.and.to.be.a('array'); - expect(resp[0]).to.have.property('requestId', bid.bidId); - expect(resp[0]).to.have.property('cpm', 1); - expect(resp[0]).to.have.property('width', 320); - expect(resp[0]).to.have.property('height', 50); - expect(resp[0]).to.have.property('ad', '

I am an ad

'); - expect(resp[0]).to.have.property('ttl', 180); - expect(resp[0]).to.have.property('creativeId', 'CREATIVE_ID'); - expect(resp[0]).to.have.property('netRevenue', true); - expect(resp[0]).to.have.property('currency', 'EUR'); - expect(resp[0]).to.have.property('dealId', 'DEAL_ID'); - }); - it('No response', function () { - let bid = { - bidder: 'madvertise', - sizes: [[728, 90]], - bidId: '51ef8751f9aead', - adUnitCode: 'div-gpt-ad-1460505748561-0', - transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - auctionId: '18fd8b8b0bd757', - bidderRequestId: '418b37f85e772c', - params: { - s: 'test', - connection_type: 'WIFI', - age: 25, - } - }; - let resp = spec.interpretResponse({body: null}, {bidId: bid.bidId}); - - expect(resp).to.exist.and.to.be.a('array').that.is.empty; - }); - }); -}); diff --git a/test/spec/modules/mantisBidAdapter_spec.js b/test/spec/modules/mantisBidAdapter_spec.js deleted file mode 100644 index 579f41e620d..00000000000 --- a/test/spec/modules/mantisBidAdapter_spec.js +++ /dev/null @@ -1,361 +0,0 @@ -import {expect} from 'chai'; -import {spec, storage} from 'modules/mantisBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; -import {sfPostMessage, iframePostMessage} from 'modules/mantisBidAdapter'; - -describe('MantisAdapter', function () { - const adapter = newBidder(spec); - const sandbox = sinon.sandbox.create(); - let clock; - - beforeEach(function () { - clock = sandbox.useFakeTimers(); - }); - - afterEach(function () { - sandbox.restore(); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'mantis', - 'params': { - 'property': '10433394', - 'zone': 'zone' - }, - '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 = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('viewability', function() { - it('iframe (viewed)', () => { - let viewed = false; - - sandbox.stub(document, 'getElementsByTagName').withArgs('iframe').returns([ - { - name: 'mantis', - getBoundingClientRect: () => ({ - top: 10, - bottom: 260, - left: 10, - right: 190, - width: 300, - height: 250 - }) - } - ]); - - iframePostMessage({innerHeight: 500, innerWidth: 500}, 'mantis', () => viewed = true); - - sandbox.clock.runAll(); - - expect(viewed).to.equal(true); - }); - - it('safeframe (viewed)', () => { - let viewed = false; - - sfPostMessage({ - ext: { - register: (width, height, callback) => { - expect(width).to.equal(100); - expect(height).to.equal(200); - - callback(); - }, - inViewPercentage: () => 60 - } - }, 100, 200, () => viewed = true); - - expect(viewed).to.equal(true); - }); - - it('safeframe (unviewed)', () => { - let viewed = false; - - sfPostMessage({ - ext: { - register: (width, height, callback) => { - expect(width).to.equal(100); - expect(height).to.equal(200); - - callback(); - }, - inViewPercentage: () => 30 - } - }, 100, 200, () => viewed = true); - - expect(viewed).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'mantis', - 'params': { - 'property': '10433394', - 'zone': 'zone' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('gdpr consent not required', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {gdprApplies: false}}); - - expect(request.url).not.to.include('consent=false'); - }); - - it('gdpr consent required', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {gdprApplies: true}}); - - expect(request.url).to.include('consent=false'); - }); - - it('usp consent', function () { - const request = spec.buildRequests(bidRequests, {uspConsent: 'foobar'}); - - expect(request.url).to.include('usp=foobar'); - }); - - it('domain override', function () { - window.mantis_domain = 'https://foo'; - const request = spec.buildRequests(bidRequests); - - expect(request.url).to.include('https://foo'); - - delete window.mantis_domain; - }); - - it('standard request', function () { - const request = spec.buildRequests(bidRequests); - - expect(request.url).to.include('property=10433394'); - expect(request.url).to.include('bids[0][bidId]=30b31c1838de1e'); - expect(request.url).to.include('bids[0][config][zone]=zone'); - expect(request.url).to.include('bids[0][sizes][0][width]=300'); - expect(request.url).to.include('bids[0][sizes][0][height]=250'); - expect(request.url).to.include('bids[0][sizes][1][width]=300'); - expect(request.url).to.include('bids[0][sizes][1][height]=600'); - }); - - it('use window uuid', function () { - window.mantis_uuid = 'foo'; - - const request = spec.buildRequests(bidRequests); - - expect(request.url).to.include('uuid=foo'); - - delete window.mantis_uuid; - }); - - it('use storage uuid', function () { - sandbox.stub(storage, 'hasLocalStorage').callsFake(() => true); - sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('mantis:uuid').returns('bar'); - - const request = spec.buildRequests(bidRequests); - - expect(request.url).to.include('uuid=bar'); - }); - - it('detect amp', function () { - var oldContext = window.context; - - window.context = {}; - window.context.tagName = 'AMP-AD'; - window.context.canonicalUrl = 'foo'; - - const request = spec.buildRequests(bidRequests); - - expect(request.url).to.include('amp=true'); - expect(request.url).to.include('url=foo'); - - delete window.context.tagName; - delete window.context.canonicalUrl; - - window.context = oldContext; - }); - }); - - describe('getUserSyncs', function () { - it('iframe', function () { - let result = spec.getUserSyncs({ - iframeEnabled: true - }); - - expect(result[0].type).to.equal('iframe'); - expect(result[0].url).to.include('https://mantodea.mantisadnetwork.com/prebid/iframe'); - }); - - it('pixel', function () { - let result = spec.getUserSyncs({ - pixelEnabled: true - }); - - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.include('https://mantodea.mantisadnetwork.com/prebid/pixel'); - }); - }); - - describe('interpretResponse', function () { - it('use ad ttl if provided', function () { - let response = { - body: { - ttl: 360, - uuid: 'uuid', - ads: [ - { - bid: 'bid', - cpm: 1, - view: 'view', - width: 300, - ttl: 250, - height: 250, - html: '' - } - ] - } - }; - - let expectedResponse = [ - { - requestId: 'bid', - cpm: 1, - width: 300, - height: 250, - ttl: 250, - ad: '', - creativeId: 'view', - netRevenue: true, - meta: { - advertiserDomains: [] - }, - currency: 'USD' - } - ]; - let bidderRequest; - - let result = spec.interpretResponse(response, {bidderRequest}); - expect(result[0]).to.deep.equal(expectedResponse[0]); - }); - - it('use global ttl if provded', function () { - let response = { - body: { - ttl: 360, - uuid: 'uuid', - ads: [ - { - bid: 'bid', - cpm: 1, - view: 'view', - domains: ['foobar.com'], - width: 300, - height: 250, - html: '' - } - ] - } - }; - - let expectedResponse = [ - { - requestId: 'bid', - cpm: 1, - width: 300, - height: 250, - ttl: 360, - ad: '', - creativeId: 'view', - netRevenue: true, - meta: { - advertiserDomains: ['foobar.com'] - }, - currency: 'USD' - } - ]; - let bidderRequest; - - let result = spec.interpretResponse(response, {bidderRequest}); - expect(result[0]).to.deep.equal(expectedResponse[0]); - }); - - it('display ads returned', function () { - let response = { - body: { - uuid: 'uuid', - ads: [ - { - bid: 'bid', - cpm: 1, - view: 'view', - width: 300, - domains: ['foobar.com'], - height: 250, - html: '' - } - ] - } - }; - - let expectedResponse = [ - { - requestId: 'bid', - cpm: 1, - width: 300, - height: 250, - ttl: 86400, - ad: '', - creativeId: 'view', - netRevenue: true, - meta: { - advertiserDomains: ['foobar.com'] - }, - currency: 'USD' - } - ]; - let bidderRequest; - - sandbox.stub(storage, 'hasLocalStorage').returns(true); - const spy = sandbox.spy(storage, 'setDataInLocalStorage'); - - let result = spec.interpretResponse(response, {bidderRequest}); - - expect(spy.calledWith('mantis:uuid', 'uuid')); - expect(result[0]).to.deep.equal(expectedResponse[0]); - expect(window.mantis_uuid).to.equal(response.body.uuid); - }); - - it('no ads returned', function () { - let response = { - body: { - ads: [] - } - }; - let bidderRequest; - - let result = spec.interpretResponse(response, {bidderRequest}); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/meazyBidAdapter_spec.js b/test/spec/modules/meazyBidAdapter_spec.js deleted file mode 100644 index 2c24791f515..00000000000 --- a/test/spec/modules/meazyBidAdapter_spec.js +++ /dev/null @@ -1,177 +0,0 @@ -import * as utils from 'src/utils.js'; -import { expect } from 'chai'; -import { spec } from 'modules/meazyBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -const MEAZY_PID = '6910b7344ae566a1' -const VALID_ENDPOINT = `https://rtb-filter.meazy.co/pbjs?host=${utils.getOrigin()}&api_key=${MEAZY_PID}`; - -const bidderRequest = { - refererInfo: { - referer: 'page', - stack: ['page', 'page1'] - } -}; - -const bidRequest = { - bidder: 'meazy', - adUnitCode: 'test-div', - sizes: [[300, 250], [300, 600]], - params: { - pid: MEAZY_PID - }, - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', -}; - -const bidContent = { - 'id': '30b31c1838de1e', - 'bidid': '9780a52ff05c0e92780f5baf9cf3f4e8', - 'cur': 'USD', - 'seatbid': [{ - 'bid': [{ - 'id': 'ccf05fb8effb3d02', - 'impid': 'B19C34BBD69DAF9F', - 'burl': 'https://track.meazy.co/imp?bidid=9780a52ff05c0e92780f5baf9cf3f4e8&user=fdc401a2-92f1-42bd-ac22-d570520ad0ec&burl=1&ssp=5&project=2&cost=${AUCTION_PRICE}', - 'adm': '', - 'adid': 'ad-2.6.75.300x250', - 'price': 1.5, - 'w': 300, - 'h': 250, - 'cid': '2.6.75', - 'crid': '2.6.75.300x250', - 'dealid': 'default' - }], - 'seat': '2' - }] -}; - -const bidContentExt = { - ...bidContent, - ext: { - 'syncUrl': 'https://sync.meazy.co/sync/img?api_key=6910b7344ae566a1' - } -}; - -const bidResponse = { - body: bidContent -}; - -const noBidResponse = { body: {'nbr': 2} }; - -describe('meazyBidAdapter', 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], bidderRequest); - expect(request.url).to.equal(VALID_ENDPOINT); - }); - - it('should format valid url', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - expect(request.url).to.equal(VALID_ENDPOINT); - }); - - it('should format valid request body', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - const payload = JSON.parse(request.data); - expect(payload.id).to.exist; - expect(payload.imp).to.exist; - expect(payload.imp[0]).to.exist; - expect(payload.imp[0].banner).to.exist; - expect(payload.imp[0].banner.format).to.exist; - expect(payload.device).to.exist; - expect(payload.site).to.exist; - expect(payload.site.domain).to.exist; - expect(payload.cur).to.exist; - }); - - it('should format valid url', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - expect(request.url).to.equal(VALID_ENDPOINT); - }); - - it('should not fill user.ext object', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - const payload = JSON.parse(request.data); - expect(payload.user.ext).to.equal(undefined); - }); - - it('should fill user.ext object', function () { - const consentString = 'hellogdpr'; - const request = spec.buildRequests([bidRequest], { ...bidderRequest, gdprConsent: { gdprApplies: true, consentString } }); - const payload = JSON.parse(request.data); - expect(payload.user.ext).to.exist.and.to.be.a('object'); - expect(payload.user.ext.consent).to.equal(consentString); - expect(payload.user.ext.gdpr).to.equal(1); - }); - }); - - describe('interpretResponse', function () { - it('should get correct bid response', function () { - const result = spec.interpretResponse(bidResponse); - const validResponse = [{ - requestId: '30b31c1838de1e', - cpm: 1.5, - width: 300, - height: 250, - creativeId: '2.6.75.300x250', - netRevenue: true, - dealId: 'default', - currency: 'USD', - ttl: 900, - ad: '' - }]; - - expect(result).to.deep.equal(validResponse); - }); - - it('handles nobid responses', function () { - let result = spec.interpretResponse(noBidResponse); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - const syncOptionsFF = { iframeEnabled: false }; - const syncOptionsEF = { iframeEnabled: true }; - const syncOptionsEE = { pixelEnabled: true, iframeEnabled: true }; - const syncOptionsFE = { pixelEnabled: true, iframeEnabled: false }; - - 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; - expect(spec.getUserSyncs(syncOptionsFF, [ bidResponse ])).to.be.empty; - expect(spec.getUserSyncs(syncOptionsFE, [ bidResponse ])).to.be.empty; - }); - - it('should be equal to the expected result', function () { - expect(spec.getUserSyncs(syncOptionsEF, [ bidResponse ])).to.deep.equal([successIFrame]); - expect(spec.getUserSyncs(syncOptionsFE, [ { body: bidContentExt } ])).to.deep.equal([successPixel]); - expect(spec.getUserSyncs(syncOptionsEE, [ { body: bidContentExt } ])).to.deep.equal([successPixel, successIFrame]); - expect(spec.getUserSyncs(syncOptionsEE, [])).to.deep.equal([successIFrame]); - }) - }); -}); diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js deleted file mode 100644 index 25cfc72672b..00000000000 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ /dev/null @@ -1,101 +0,0 @@ -import { - expect -} from 'chai'; -import { - spec -} from 'modules/mediagoBidAdapter.js'; - -describe('mediago:BidAdapterTests', function() { - let bidRequestData = { - 'bidderCode': 'mediago', - 'auctionId': '7fae02a9-0195-472f-ba94-708d3bc2c0d9', - 'bidderRequestId': '4fec04e87ad785', - 'bids': [{ - 'bidder': 'mediago', - 'params': { - 'token': '85a6b01e41ac36d49744fad726e3655d' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [ - [ - 300, - 250 - ] - ] - } - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '5e24a2ce-db03-4565-a8a3-75dbddca9377', - 'sizes': [ - [ - 300, - 250 - ] - ], - 'bidId': '54d73f19c9d47a', - 'bidderRequestId': '4fec04e87ad785', - 'auctionId': '7fae02a9-0195-472f-ba94-708d3bc2c0d9', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - }] - }; - let request = []; - - it('mediago:validate_pub_params', function() { - expect( - spec.isBidRequestValid({ - bidder: 'mediago', - params: { - token: ['85a6b01e41ac36d49744fad726e3655d'] - } - }) - ).to.equal(true); - }); - - it('mediago:validate_generated_params', function() { - request = spec.buildRequests(bidRequestData.bids, bidRequestData); - // console.log(request); - let req_data = JSON.parse(request.data); - expect(req_data.imp).to.have.lengthOf(1); - }); - - it('mediago:validate_response_params', function() { - let serverResponse = { - body: { - 'id': '7244645c-a81a-4760-8fd6-9d908d2c4a44', - 'seatbid': [{ - 'bid': [{ - 'id': 'aa86796a857ebedda9a2d7128a87dab1', - 'impid': '1', - 'price': 0.05, - 'nurl': 'http://d21uzv52i0cqie.cloudfront.net/api/winnotice?tn=341443089c0cb829164455a42d216ee3\u0026winloss=1\u0026id=aa86796a857ebedda9a2d7128a87dab1\u0026seat_id=${AUCTION_SEAT_ID}\u0026currency=${AUCTION_CURRENCY}\u0026bid_id=${AUCTION_BID_ID}\u0026ad_id=${AUCTION_AD_ID}\u0026loss=${AUCTION_LOSS}\u0026imp_id=1\u0026price=${AUCTION_PRICE}\u0026test=0\u0026time=1597714943\u0026adp=Dtnz0O4U8sdAU-XGGijCAgMbjDIeMGyCLXeSg1laXxM\u0026dsp_id=22\u0026url=-BFDu2NYtc4PYTplFW_2JcnDSRVLOOfaERbwJABjFyG6NUB4ywA3dUaXt5zPlyCUpBCOxjH9gk4E6yWTshzuSfQSx7g_TxvcXYUgh7YtY9NQZxx14InmNCTsezqID5UztV7llz8SXWHQ-ZsutH1nJIZzl1jH3i2uCPi91shqIZLN1bLJ5guAr5O4WyxVeOqIKyD_GiVcY9Olm51iI_3wgwFyDEN_dIDv-ObgNxpbPD0L11-62bjhGw3__7RuEo6XLdox-g46Fcqk6i0zayfsPM4QeMAhWJ4lsg-xswSI0YAfzyoOIeTWB78mdpt_GmN5PKZZPqyO7VkbwHEasn-mTyYTddbz5v2fzEkRO0AQZtAZx96PANGrNvcOHnRVmCdkzN96b5Ur1_8ipdyzHOFRtJ-z_KmKaxig6himvMCePozZvrvihiGhigP4RGiFT7ytVYKHyUGAV2PF5SwtgnB0uGCltd7o1CLhZyZEQNgE7LSESyGztZ5kM9N_VZV9gPZVhvlJDfYFNRW9i6D2pZxV0Gd63rA9gpeUJ3mhbkj-B27VRKrNTBSrwIAU7P0RPD5_opl3G8nPD1Ce2vKuQK8qynHWQblfeA61nDok-fRezSKbzwepqi8oxXadFrCmN7KxP_mPqA794xYzIw5-mS64NA', - 'burl': 'http://d21uzv52i0cqie.cloudfront.net/api/winnotice?tn=341443089c0cb829164455a42d216ee3\u0026winloss=2\u0026id=aa86796a857ebedda9a2d7128a87dab1\u0026seat_id=${AUCTION_SEAT_ID}\u0026currency=${AUCTION_CURRENCY}\u0026bid_id=${AUCTION_BID_ID}\u0026ad_id=${AUCTION_AD_ID}\u0026loss=${AUCTION_LOSS}\u0026imp_id=1\u0026price=${AUCTION_PRICE}\u0026test=0\u0026time=1597714943\u0026adp=Dtnz0O4U8sdAU-XGGijCAgMbjDIeMGyCLXeSg1laXxM\u0026dsp_id=22\u0026url=dXerAvyp4zYQzsQ56eGB4JtiA4yFaYlTqcHffccrvCg', - 'lurl': 'http://d21uzv52i0cqie.cloudfront.net/api/winnotice?tn=341443089c0cb829164455a42d216ee3\u0026winloss=0\u0026id=aa86796a857ebedda9a2d7128a87dab1\u0026seat_id=${AUCTION_SEAT_ID}\u0026currency=${AUCTION_CURRENCY}\u0026bid_id=${AUCTION_BID_ID}\u0026ad_id=${AUCTION_AD_ID}\u0026loss=${AUCTION_LOSS}\u0026imp_id=1\u0026price=${AUCTION_PRICE}\u0026test=0\u0026time=1597714943\u0026adp=Dtnz0O4U8sdAU-XGGijCAgMbjDIeMGyCLXeSg1laXxM\u0026dsp_id=22\u0026url=ptSxg_vR7-fdx-WAkkUADJb__BntE5a6-RSeYdUewvk', - 'adm': '\u003clink rel=\"stylesheet\" href=\"//cdn.mediago.io/js/style/style_banner_300*250.css\"\u003e\u003cdiv id=\"mgcontainer-583ce3286b442001205b2fb9a5488efc\" class=\"mediago-placement imgTopTitleBottom\" style=\"position:relative;width:298px;height:248px;overflow:hidden\"\u003e\u003ca href=\"http://trace.mediago.io/api/bidder/track?tn=341443089c0cb829164455a42d216ee3\u0026price=PRMC8pCHtH55ipgXubUs8jlsKTBxWRSEweH8Mee_aUQ\u0026evt=102\u0026rid=aa86796a857ebedda9a2d7128a87dab1\u0026campaignid=1003540\u0026impid=25-300x175-1\u0026offerid=1107782\u0026test=0\u0026time=1597714943\u0026cp=GJA03gjm-ugPTmN7prOpvhfu1aA04IgpTcW4oRX22Lg\u0026clickid=25_aa86796a857ebedda9a2d7128a87dab1_25-300x175-1\u0026acid=164\u0026trackingid=583ce3286b442001205b2fb9a5488efc\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74\u0026jt=2\u0026url=PQFFci337KgCVkx7KTgRItClLaWH0lgTcIlgBRTpfKngVJES4uKLfxXz9mjLcDWIbWQcEVVk_gfTcIaK8oKO2YyVG5lc3hjZeZr0VaIDHbWggPJaqtfDK9T0HZIKvrpe\" target=\"_blank\"\u003e\u003cimg alt=\"Robert Vowed To Keep Silent, But Decided To Put The People First And Speak\" src=\"https://d2cli4kgl5uxre.cloudfront.net/ML/b5e361889beef5eaf69987384b7a56e8__300x175.png\" style=\"height:70%;width:100%;border-width:0;border:none;\"\u003e\u003ch3 class=\"title\" style=\"font-size:16px;\"\u003eRobert Vowed To Keep Silent, But Decided To Put The People First And Speak\u003c/h3\u003e\u003c/a\u003e\u003cspan class=\"source\"\u003e\u003ca class=\"sourcename\" href=\"//www.mediago.io\" target=\"_blank\"\u003e\u003cspan\u003eAd\u003c/span\u003e \u003c/a\u003e\u003ca class=\"srcnameadslabelurl\" href=\"//www.mediago.io/privacy\" target=\"_blank\"\u003e\u003cspan\u003eViral Net News\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\u003cscript\u003e!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){\"undefined\"!=typeof Symbol\u0026\u0026Symbol.toStringTag\u0026\u0026Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},n.t=function(e,t){if(1\u0026t\u0026\u0026(e=n(e)),8\u0026t)return e;if(4\u0026t\u0026\u0026\"object\"==typeof e\u0026\u0026e\u0026\u0026e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,\"default\",{enumerable:!0,value:e}),2\u0026t\u0026\u0026\"string\"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e\u0026\u0026e.__esModule?function(){return e.default}:function(){return e};return n.d(t,\"a\",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=\"\",n(n.s=24)}({24:function(e,t,n){\"use strict\";function o(e){var t=new Image;t.src=e,t.style=\"display:none;visibility:hidden\",t.width=0,t.height=0,document.body.appendChild(t)}o(\"http://d21uzv52i0cqie.cloudfront.net/api/bidder/track?tn=341443089c0cb829164455a42d216ee3\u0026price=PRMC8pCHtH55ipgXubUs8jlsKTBxWRSEweH8Mee_aUQ\u0026evt=101\u0026rid=aa86796a857ebedda9a2d7128a87dab1\u0026campaignid=1003540\u0026impid=25-300x175-1\u0026offerid=1107782\u0026test=0\u0026time=1597714943\u0026cp=GJA03gjm-ugPTmN7prOpvhfu1aA04IgpTcW4oRX22Lg\u0026acid=164\u0026trackingid=583ce3286b442001205b2fb9a5488efc\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74\");var r=document.getElementById(\"mgcontainer-583ce3286b442001205b2fb9a5488efc\"),i=!1;!function e(){setTimeout((function(){var t,n;!i\u0026\u0026(t=r,n=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,(t.getBoundingClientRect()\u0026\u0026t.getBoundingClientRect().top)\u003c=n-.75*(t.offsetHeight||t.clientHeight))?(i=!0,o(\"http://d21uzv52i0cqie.cloudfront.net/api/bidder/track?tn=341443089c0cb829164455a42d216ee3\u0026price=PRMC8pCHtH55ipgXubUs8jlsKTBxWRSEweH8Mee_aUQ\u0026evt=104\u0026rid=aa86796a857ebedda9a2d7128a87dab1\u0026campaignid=1003540\u0026impid=25-300x175-1\u0026offerid=1107782\u0026test=0\u0026time=1597714943\u0026cp=GJA03gjm-ugPTmN7prOpvhfu1aA04IgpTcW4oRX22Lg\u0026acid=164\u0026trackingid=583ce3286b442001205b2fb9a5488efc\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74\u0026sid=16__11__13\u0026format=\u0026crid=b5e361889beef5eaf69987384b7a56e8\")):e()}),500)}()}});\u003c/script\u003e\u003cscript type=\"text/javascript\" src=\"http://d21uzv52i0cqie.cloudfront.net/api/track?tn=341443089c0cb829164455a42d216ee3\u0026price=${AUCTION_PRICE}\u0026evt=5\u0026rid=aa86796a857ebedda9a2d7128a87dab1\u0026impid=1\u0026offerid=\u0026tagid=\u0026test=0\u0026time=1597714943\u0026adp=5zrCZ2rC-WLafYkNpeTnzA72tDqVZUlOA3Js6_eJjYU\u0026dsp_id=22\u0026cp=${cp}\u0026url=\u0026type=script\"\u003e\u003c/script\u003e\u003cscript\u003edocument.addEventListener\u0026\u0026document.addEventListener(\"click\",function(){var a=document.createElement(\"script\");a.src=\"http://d21uzv52i0cqie.cloudfront.net/api/track?tn=341443089c0cb829164455a42d216ee3\u0026price=${AUCTION_PRICE}\u0026evt=6\u0026rid=aa86796a857ebedda9a2d7128a87dab1\u0026impid=1\u0026offerid=\u0026tagid=\u0026test=0\u0026time=1597714943\u0026adp=5zrCZ2rC-WLafYkNpeTnzA72tDqVZUlOA3Js6_eJjYU\u0026dsp_id=22\u0026cp=${cp}\u0026url=\u0026clickid=25_aa86796a857ebedda9a2d7128a87dab1_1\";document.body.appendChild(a)});\u003c/script\u003e', - 'cid': '1003540', - 'crid': 'b5e361889beef5eaf69987384b7a56e8', - 'w': 300, - 'h': 250 - }] - }], - 'cur': 'USD' - } - }; - - let bids = spec.interpretResponse(serverResponse); - // console.log({ - // bids - // }); - expect(bids).to.have.lengthOf(1); - - let bid = bids[0]; - - expect(bid.creativeId).to.equal('b5e361889beef5eaf69987384b7a56e8'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.currency).to.equal('USD'); - }); -}); diff --git a/test/spec/modules/microadBidAdapter_spec.js b/test/spec/modules/microadBidAdapter_spec.js deleted file mode 100644 index 8298e2bd559..00000000000 --- a/test/spec/modules/microadBidAdapter_spec.js +++ /dev/null @@ -1,388 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/microadBidAdapter.js'; -import * as utils from 'src/utils.js'; - -describe('microadBidAdapter', () => { - const bidRequestTemplate = { - bidder: 'microad', - mediaTypes: { - banner: {} - }, - params: { - spot: 'spot-code' - }, - bidId: 'bid-id', - transactionId: 'transaction-id' - }; - - describe('isBidRequestValid', () => { - it('should return true when required parameters are set', () => { - const validBids = [ - bidRequestTemplate, - Object.assign({}, bidRequestTemplate, { - mediaTypes: { - native: {} - } - }), - Object.assign({}, bidRequestTemplate, { - mediaTypes: { - video: {} - } - }) - ]; - validBids.forEach(validBid => { - expect(spec.isBidRequestValid(validBid)).to.equal(true); - }); - }); - - it('should return false when required parameters are not set', () => { - const bidWithoutParams = utils.deepClone(bidRequestTemplate); - delete bidWithoutParams.params; - const bidWithoutSpot = utils.deepClone(bidRequestTemplate); - delete bidWithoutSpot.params.spot; - const bidWithoutMediaTypes = utils.deepClone(bidRequestTemplate); - delete bidWithoutMediaTypes.mediaTypes; - - const invalidBids = [ - {}, - bidWithoutParams, - bidWithoutSpot, - bidWithoutMediaTypes, - Object.assign({}, bidRequestTemplate, { - mediaTypes: {} - }) - ]; - invalidBids.forEach(invalidBid => { - expect(spec.isBidRequestValid(invalidBid)).to.equal(false); - }); - }); - }); - - describe('buildRequests', () => { - const bidderRequest = { - refererInfo: { - canonicalUrl: 'https://example.com/to', - referer: 'https://example.com/from' - } - }; - const expectedResultTemplate = { - spot: 'spot-code', - url: 'https://example.com/to', - referrer: 'https://example.com/from', - bid_id: 'bid-id', - transaction_id: 'transaction-id', - media_types: 1 - }; - - it('should generate valid media_types', () => { - const bidRequests = [ - bidRequestTemplate, - Object.assign({}, bidRequestTemplate, { - mediaTypes: { - banner: {}, native: {} - } - }), - Object.assign({}, bidRequestTemplate, { - mediaTypes: { - banner: {}, native: {}, video: {} - } - }), - Object.assign({}, bidRequestTemplate, { - mediaTypes: { - native: {} - } - }), - Object.assign({}, bidRequestTemplate, { - mediaTypes: { - native: {}, video: {} - } - }), - Object.assign({}, bidRequestTemplate, { - mediaTypes: { - video: {} - } - }), - Object.assign({}, bidRequestTemplate, { - mediaTypes: { - banner: {}, video: {} - } - }) - ]; - - const results = bidRequests.map(bid => { - const requests = spec.buildRequests([bid], bidderRequest); - return requests[0].data.media_types; - }); - expect(results).to.deep.equal([ - 1, // BANNER - 3, // BANNER + NATIVE - 7, // BANNER + NATIVE + VIDEO - 2, // NATIVE - 6, // NATIVE + VIDEO - 4, // VIDEO - 5 // BANNER + VIDEO - ]); - }); - - it('should use window.location.href if there is no canonicalUrl', () => { - const bidderRequestWithoutCanonicalUrl = { - refererInfo: { - referer: 'https://example.com/from' - } - }; - const requests = spec.buildRequests([bidRequestTemplate], bidderRequestWithoutCanonicalUrl); - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt, - url: window.location.href - }) - ); - }); - }); - - it('should generate valid request with no optional parameters', () => { - const requests = spec.buildRequests([bidRequestTemplate], bidderRequest); - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt - }) - ); - }); - }); - - it('should add url_macro parameter to response if request parameters contain url', () => { - const bidRequestWithUrl = Object.assign({}, bidRequestTemplate, { - params: { - spot: 'spot-code', - url: '${COMPASS_EXT_URL}url-macro' - } - }); - const requests = spec.buildRequests([bidRequestWithUrl], bidderRequest); - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt, - url_macro: 'url-macro' - }) - ); - }); - }); - - it('should add referrer_macro parameter to response if request parameters contain referrer', () => { - const bidRequestWithReferrer = Object.assign({}, bidRequestTemplate, { - params: { - spot: 'spot-code', - referrer: '${COMPASS_EXT_REF}referrer-macro' - } - }); - const requests = spec.buildRequests([bidRequestWithReferrer], bidderRequest); - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt, - referrer_macro: 'referrer-macro' - }) - ); - }); - }); - - it('should add ifa parameter to response if request parameters contain ifa', () => { - const bidRequestWithIfa = Object.assign({}, bidRequestTemplate, { - params: { - spot: 'spot-code', - ifa: '${COMPASS_EXT_IFA}ifa' - } - }); - const requests = spec.buildRequests([bidRequestWithIfa], bidderRequest); - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt, - ifa: 'ifa' - }) - ); - }); - }); - - it('should add appid parameter to response if request parameters contain appid', () => { - const bidRequestWithAppid = Object.assign({}, bidRequestTemplate, { - params: { - spot: 'spot-code', - appid: '${COMPASS_EXT_APPID}appid' - } - }); - const requests = spec.buildRequests([bidRequestWithAppid], bidderRequest); - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt, - appid: 'appid' - }) - ); - }); - }); - - it('should add geo parameter to response if request parameters contain geo', () => { - const bidRequestWithGeo = Object.assign({}, bidRequestTemplate, { - params: { - spot: 'spot-code', - geo: '${COMPASS_EXT_GEO}35.655275,139.693771' - } - }); - const requests = spec.buildRequests([bidRequestWithGeo], bidderRequest); - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt, - geo: '35.655275,139.693771' - }) - ); - }); - }); - - it('should not add geo parameter to response if request parameters contain invalid geo', () => { - const bidRequestWithGeo = Object.assign({}, bidRequestTemplate, { - params: { - spot: 'spot-code', - geo: '${COMPASS_EXT_GEO}invalid format geo' - } - }); - const requests = spec.buildRequests([bidRequestWithGeo], bidderRequest); - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt - }) - ); - }); - }); - - it('should always use the HTTPS endpoint https://s-rtb-pb.send.microad.jp/prebid even if it is served via HTTP', () => { - const requests = spec.buildRequests([bidRequestTemplate], bidderRequest); - requests.forEach(request => { - expect(request.url.lastIndexOf('https', 0) === 0).to.be.true; - }); - }); - }); - - describe('interpretResponse', () => { - const serverResponseTemplate = { - body: { - requestId: 'request-id', - cpm: 0.1, - width: 200, - height: 100, - ad: '
test
', - ttl: 10, - creativeId: 'creative-id', - netRevenue: true, - currency: 'JPY' - } - }; - const expectedBidResponseTemplate = { - requestId: 'request-id', - cpm: 0.1, - width: 200, - height: 100, - ad: '
test
', - ttl: 10, - creativeId: 'creative-id', - netRevenue: true, - currency: 'JPY' - }; - - it('should return nothing if server response body does not contain cpm', () => { - const emptyResponse = { - body: {} - }; - - expect(spec.interpretResponse(emptyResponse)).to.deep.equal([]); - }); - - it('should return nothing if returned cpm is zero', () => { - const serverResponse = { - body: { - cpm: 0 - } - }; - - expect(spec.interpretResponse(serverResponse)).to.deep.equal([]); - }); - - it('should return a valid bidResponse without deal id if serverResponse is valid, has a nonzero cpm and no deal id', () => { - expect(spec.interpretResponse(serverResponseTemplate)).to.deep.equal([expectedBidResponseTemplate]); - }); - - it('should return a valid bidResponse with deal id if serverResponse is valid, has a nonzero cpm and a deal id', () => { - const serverResponseWithDealId = Object.assign({}, utils.deepClone(serverResponseTemplate)); - serverResponseWithDealId.body['dealId'] = 10001; - const expectedBidResponse = Object.assign({}, expectedBidResponseTemplate, { - dealId: 10001 - }); - - expect(spec.interpretResponse(serverResponseWithDealId)).to.deep.equal([expectedBidResponse]); - }); - }); - - describe('getUserSyncs', () => { - const BOTH_ENABLED = { - iframeEnabled: true, pixelEnabled: true - }; - const IFRAME_ENABLED = { - iframeEnabled: true, pixelEnabled: false - }; - const PIXEL_ENABLED = { - iframeEnabled: false, pixelEnabled: true - }; - const BOTH_DISABLED = { - iframeEnabled: false, pixelEnabled: false - }; - const serverResponseTemplate = { - body: { - syncUrls: { - iframe: ['https://www.exmaple.com/iframe1', 'https://www.exmaple.com/iframe2'], - image: ['https://www.exmaple.com/image1', 'https://www.exmaple.com/image2'] - } - } - }; - const expectedIframeSyncs = [ - {type: 'iframe', url: 'https://www.exmaple.com/iframe1'}, - {type: 'iframe', url: 'https://www.exmaple.com/iframe2'} - ]; - const expectedImageSyncs = [ - {type: 'image', url: 'https://www.exmaple.com/image1'}, - {type: 'image', url: 'https://www.exmaple.com/image2'} - ]; - - it('should return nothing if no sync urls are set', () => { - const serverResponse = utils.deepClone(serverResponseTemplate); - serverResponse.body.syncUrls.iframe = []; - serverResponse.body.syncUrls.image = []; - - const syncs = spec.getUserSyncs(BOTH_ENABLED, [serverResponse]); - expect(syncs).to.deep.equal([]); - }); - - it('should return nothing if sync is disabled', () => { - const syncs = spec.getUserSyncs(BOTH_DISABLED, [serverResponseTemplate]); - expect(syncs).to.deep.equal([]); - }); - - it('should register iframe and image sync urls if sync is enabled', () => { - const syncs = spec.getUserSyncs(BOTH_ENABLED, [serverResponseTemplate]); - expect(syncs).to.deep.equal(expectedIframeSyncs.concat(expectedImageSyncs)); - }); - - it('should register iframe sync urls if iframe is enabled', () => { - const syncs = spec.getUserSyncs(IFRAME_ENABLED, [serverResponseTemplate]); - expect(syncs).to.deep.equal(expectedIframeSyncs); - }); - - it('should register image sync urls if image is enabled', () => { - const syncs = spec.getUserSyncs(PIXEL_ENABLED, [serverResponseTemplate]); - expect(syncs).to.deep.equal(expectedImageSyncs); - }); - }); -}); diff --git a/test/spec/modules/missenaBidAdapter_spec.js b/test/spec/modules/missenaBidAdapter_spec.js deleted file mode 100644 index 026e79c6d5a..00000000000 --- a/test/spec/modules/missenaBidAdapter_spec.js +++ /dev/null @@ -1,131 +0,0 @@ -import { expect } from 'chai'; -import { spec, _getPlatform } from 'modules/missenaBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('Missena Adapter', function () { - const adapter = newBidder(spec); - - const bidId = 'abc'; - - const bid = { - bidder: 'missena', - bidId: bidId, - sizes: [[1, 1]], - params: { - apiKey: 'PA-34745704', - }, - }; - - describe('codes', function () { - it('should return a bidder code of missena', function () { - expect(spec.code).to.equal('missena'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true if the apiKey param is present', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false if the apiKey is missing', function () { - expect( - spec.isBidRequestValid(Object.assign(bid, { params: {} })) - ).to.equal(false); - }); - - it('should return false if the apiKey is an empty string', function () { - expect( - spec.isBidRequestValid(Object.assign(bid, { params: { apiKey: '' } })) - ).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const consentString = 'AAAAAAAAA=='; - - const bidderRequest = { - gdprConsent: { - consentString: consentString, - gdprApplies: true, - }, - refererInfo: { - referer: 'https://referer', - canonicalUrl: 'https://canonical', - }, - }; - - const requests = spec.buildRequests([bid, bid], bidderRequest); - const request = requests[0]; - const payload = JSON.parse(request.data); - - it('should return as many server requests as bidder requests', function () { - expect(requests.length).to.equal(2); - }); - - it('should have a post method', function () { - expect(request.method).to.equal('POST'); - }); - - it('should send the bidder id', function () { - expect(payload.request_id).to.equal(bidId); - }); - - it('should send referer information to the request', function () { - expect(payload.referer).to.equal('https://referer'); - expect(payload.referer_canonical).to.equal('https://canonical'); - }); - - it('should send gdpr consent information to the request', function () { - expect(payload.consent_string).to.equal(consentString); - expect(payload.consent_required).to.equal(true); - }); - }); - - describe('interpretResponse', function () { - const serverResponse = { - requestId: bidId, - cpm: 0.5, - currency: 'USD', - ad: '', - }; - - const serverTimeoutResponse = { - requestId: bidId, - timeout: true, - ad: '', - }; - - const serverEmptyAdResponse = { - requestId: bidId, - cpm: 0.5, - currency: 'USD', - ad: '', - }; - - it('should return a proper bid response', function () { - const result = spec.interpretResponse({ body: serverResponse }, bid); - - expect(result.length).to.equal(1); - - expect(Object.keys(result[0])).to.have.members( - Object.keys(serverResponse) - ); - }); - - it('should return an empty response when the server answers with a timeout', function () { - const result = spec.interpretResponse( - { body: serverTimeoutResponse }, - bid - ); - expect(result).to.deep.equal([]); - }); - - it('should return an empty response when the server answers with an empty ad', function () { - const result = spec.interpretResponse( - { body: serverEmptyAdResponse }, - bid - ); - expect(result).to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/mobfoxpbBidAdapter_spec.js b/test/spec/modules/mobfoxpbBidAdapter_spec.js deleted file mode 100644 index a02d580ab88..00000000000 --- a/test/spec/modules/mobfoxpbBidAdapter_spec.js +++ /dev/null @@ -1,304 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/mobfoxpbBidAdapter.js'; -import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; - -describe('MobfoxHBBidAdapter', function () { - const bid = { - bidId: '23fhj33i987f', - bidder: 'mobfoxpb', - mediaTypes: { - [BANNER]: { - sizes: [[300, 250]] - } - }, - params: { - placementId: 783, - traffic: BANNER - } - }; - - const bidderRequest = { - refererInfo: { - referer: 'test.com' - } - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are bidId, params and key 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], bidderRequest); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://bes.mobfox.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'); - expect(data.gdpr).to.not.exist; - expect(data.ccpa).to.not.exist; - let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'schain'); - expect(placement.placementId).to.equal(783); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal(BANNER); - expect(placement.schain).to.be.an('object'); - expect(placement.sizes).to.be.an('array'); - }); - - it('Returns valid data for mediatype video', function () { - const playerSize = [300, 300]; - bid.mediaTypes = {}; - bid.params.traffic = VIDEO; - bid.mediaTypes[VIDEO] = { - playerSize - }; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data).to.be.an('object'); - let placement = data['placements'][0]; - expect(placement).to.be.an('object'); - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'wPlayer', 'hPlayer', 'schain'); - expect(placement.traffic).to.equal(VIDEO); - expect(placement.wPlayer).to.equal(playerSize[0]); - expect(placement.hPlayer).to.equal(playerSize[1]); - }); - - it('Returns valid data for mediatype native', function () { - const native = { - title: { - required: true - }, - body: { - required: true - }, - icon: { - required: true, - size: [64, 64] - } - }; - - bid.mediaTypes = {}; - bid.params.traffic = NATIVE; - bid.mediaTypes[NATIVE] = native; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data).to.be.an('object'); - let placement = data['placements'][0]; - expect(placement).to.be.an('object'); - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'native', 'schain'); - expect(placement.traffic).to.equal(NATIVE); - expect(placement.native).to.equal(native); - }); - - it('Returns data with gdprConsent and without uspConsent', function () { - bidderRequest.gdprConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.gdpr).to.exist; - expect(data.gdpr).to.be.a('string'); - expect(data.gdpr).to.equal(bidderRequest.gdprConsent); - expect(data.ccpa).to.not.exist; - delete bidderRequest.gdprConsent; - }); - - it('Returns data with uspConsent and without gdprConsent', function () { - bidderRequest.uspConsent = 'test'; - serverRequest = spec.buildRequests([bid], bidderRequest); - let data = serverRequest.data; - expect(data.ccpa).to.exist; - expect(data.ccpa).to.be.a('string'); - expect(data.ccpa).to.equal(bidderRequest.uspConsent); - expect(data.gdpr).to.not.exist; - }); - - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); -}); diff --git a/test/spec/modules/mobsmartBidAdapter_spec.js b/test/spec/modules/mobsmartBidAdapter_spec.js deleted file mode 100644 index b48878adff6..00000000000 --- a/test/spec/modules/mobsmartBidAdapter_spec.js +++ /dev/null @@ -1,214 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/mobsmartBidAdapter.js'; - -describe('mobsmartBidAdapter', function () { - describe('isBidRequestValid', function () { - let bid; - beforeEach(function() { - bid = { - bidder: 'mobsmart', - params: { - floorPrice: 100, - currency: 'JPY' - }, - mediaTypes: { - banner: { - size: [[300, 250]] - } - } - }; - }); - - it('should return true when valid bid request is set', function() { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when bidder is not set to "mobsmart"', function() { - bid.bidder = 'bidder'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when params are not set', function() { - delete bid.params.floorPrice; - delete bid.params.currency; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - let bidRequests; - beforeEach(function() { - bidRequests = [ - { - bidder: 'mobsmart', - adUnitCode: 'mobsmart-ad-code', - auctionId: 'auctionid-123', - bidId: 'bidid123', - bidRequestsCount: 1, - bidderRequestId: 'bidderrequestid123', - transactionId: 'transaction-id-123', - sizes: [[300, 250]], - requestId: 'requestid123', - params: { - floorPrice: 100, - currency: 'JPY' - }, - mediaTypes: { - banner: { - size: [[300, 250]] - } - }, - userId: { - pubcid: 'pubc-id-123' - } - }, { - bidder: 'mobsmart', - adUnitCode: 'mobsmart-ad-code2', - auctionId: 'auctionid-456', - bidId: 'bidid456', - bidRequestsCount: 1, - bidderRequestId: 'bidderrequestid456', - transactionId: 'transaction-id-456', - sizes: [[320, 50]], - requestId: 'requestid456', - params: { - floorPrice: 100, - currency: 'JPY' - }, - mediaTypes: { - banner: { - size: [[320, 50]] - } - }, - userId: { - pubcid: 'pubc-id-456' - } - } - ]; - }); - - let bidderRequest = { - refererInfo: { - referer: 'https://example.com' - } - }; - - it('should not contain a sizes when sizes is not set', function() { - delete bidRequests[0].sizes; - delete bidRequests[1].sizes; - let requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].data.sizes).to.be.an('undefined'); - expect(requests[1].data.sizes).to.be.an('undefined'); - }); - - it('should not contain a userId when userId is not set', function() { - delete bidRequests[0].userId; - delete bidRequests[1].userId; - let requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].data.userId).to.be.an('undefined'); - expect(requests[1].data.userId).to.be.an('undefined'); - }); - - it('should have a post method', function() { - let requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].method).to.equal('POST'); - expect(requests[1].method).to.equal('POST'); - }); - - it('should contain a request id equals to the bid id', function() { - let requests = spec.buildRequests(bidRequests, bidderRequest); - expect(JSON.parse(requests[0].data).requestId).to.equal(bidRequests[0].bidId); - expect(JSON.parse(requests[1].data).requestId).to.equal(bidRequests[1].bidId); - }); - - it('should have an url that match the default endpoint', function() { - let requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].url).to.equal('https://prebid.mobsmart.net/prebid/endpoint'); - expect(requests[1].url).to.equal('https://prebid.mobsmart.net/prebid/endpoint'); - }); - }); - - describe('interpretResponse', function () { - let serverResponse; - beforeEach(function() { - serverResponse = { - body: { - 'requestId': 'request-id', - 'cpm': 100, - 'width': 300, - 'height': 250, - 'ad': '
ad
', - 'ttl': 300, - 'creativeId': 'creative-id', - 'netRevenue': true, - 'currency': 'JPY' - } - }; - }); - - it('should return a valid response', () => { - var responses = spec.interpretResponse(serverResponse); - expect(responses).to.be.an('array').that.is.not.empty; - - let response = responses[0]; - expect(response).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency'); - expect(response.requestId).to.equal('request-id'); - expect(response.cpm).to.equal(100); - expect(response.width).to.equal(300); - expect(response.height).to.equal(250); - expect(response.ad).to.equal('
ad
'); - expect(response.ttl).to.equal(300); - expect(response.creativeId).to.equal('creative-id'); - expect(response.netRevenue).to.be.true; - expect(response.currency).to.equal('JPY'); - }); - - it('should return an empty array when serverResponse is empty', () => { - serverResponse = {}; - var responses = spec.interpretResponse(serverResponse); - expect(responses).to.deep.equal([]); - }); - }); - - describe('getUserSyncs', function () { - it('should return nothing when sync is disabled', function () { - const syncOptions = { - 'iframeEnabled': false, - 'pixelEnabled': false - } - let syncs = spec.getUserSyncs(syncOptions); - expect(syncs).to.deep.equal([]); - }); - - it('should register iframe sync when iframe is enabled', function () { - const syncOptions = { - 'iframeEnabled': true, - 'pixelEnabled': false - } - let syncs = spec.getUserSyncs(syncOptions); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://tags.mobsmart.net/tags/iframe'); - }); - - it('should register image sync when image is enabled', function () { - const syncOptions = { - 'iframeEnabled': false, - 'pixelEnabled': true - } - let syncs = spec.getUserSyncs(syncOptions); - expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://tags.mobsmart.net/tags/image'); - }); - - it('should register iframe sync when iframe is enabled', function () { - const syncOptions = { - 'iframeEnabled': true, - 'pixelEnabled': true - } - let syncs = spec.getUserSyncs(syncOptions); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://tags.mobsmart.net/tags/iframe'); - }); - }); -}); diff --git a/test/spec/modules/nanointeractiveBidAdapter_spec.js b/test/spec/modules/nanointeractiveBidAdapter_spec.js deleted file mode 100644 index 715a26a4597..00000000000 --- a/test/spec/modules/nanointeractiveBidAdapter_spec.js +++ /dev/null @@ -1,466 +0,0 @@ -import {expect} from 'chai'; -import * as utils from 'src/utils.js'; -import * as sinon from 'sinon'; - -import { - BIDDER_CODE, - CATEGORY, - CATEGORY_NAME, - SSP_PLACEMENT_ID, - END_POINT_URL, - NQ, - NQ_NAME, - REF, - spec, - SUB_ID -} from '../../../modules/nanointeractiveBidAdapter.js'; - -describe('nanointeractive adapter tests', function () { - const SIZES_PARAM = 'sizes'; - const BID_ID_PARAM = 'bidId'; - const BID_ID_VALUE = '24a1c9ec270973'; - const DATA_PARTNER_PIXEL_ID_VALUE = 'testPID'; - const NQ_VALUE = 'rumpelstiltskin'; - const NQ_NAME_QUERY_PARAM = 'nqName'; - const CATEGORY_VALUE = 'some category'; - const CATEGORY_NAME_QUERY_PARAM = 'catName'; - const SUB_ID_VALUE = '123'; - const REF_NO_VALUE = 'none'; - const REF_OTHER_VALUE = 'other'; - const WIDTH1 = 300; - const HEIGHT1 = 250; - const WIDTH2 = 468; - const HEIGHT2 = 60; - const SIZES_VALUE = [[WIDTH1, HEIGHT1], [WIDTH2, HEIGHT2]]; - const AD = ' '; - const CPM = 1; - - function getBidRequest(params) { - return { - bidder: BIDDER_CODE, - params: params, - placementCode: 'div-gpt-ad-1460505748561-0', - transactionId: 'ee335735-ddd3-41f2-b6c6-e8aa99f81c0f', - [SIZES_PARAM]: SIZES_VALUE, - [BID_ID_PARAM]: BID_ID_VALUE, - bidderRequestId: '189135372acd55', - auctionId: 'ac15bb68-4ef0-477f-93f4-de91c47f00a9' - }; - } - - describe('NanoAdapter', function () { - let nanoBidAdapter = spec; - - describe('Methods', function () { - it('Test isBidRequestValid() with valid param(s): pid', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nq', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nq, category', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ, - [CATEGORY]: CATEGORY_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nq, categoryName', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ, - [CATEGORY_NAME_QUERY_PARAM]: CATEGORY_NAME_QUERY_PARAM, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nq, subId', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ, - [SUB_ID]: SUB_ID_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nqName', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ_NAME]: NQ_NAME_QUERY_PARAM, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nqName, category', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ_NAME]: NQ_NAME_QUERY_PARAM, - [CATEGORY]: CATEGORY_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nqName, categoryName', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ_NAME]: NQ_NAME_QUERY_PARAM, - [CATEGORY_NAME_QUERY_PARAM]: CATEGORY_NAME_QUERY_PARAM, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nqName, subId', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ_NAME]: NQ_NAME_QUERY_PARAM, - [SUB_ID]: SUB_ID_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, category', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [CATEGORY]: CATEGORY_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, category, subId', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, subId', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [SUB_ID]: SUB_ID_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nq, category, subId', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nqName, categoryName, subId', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ_NAME]: NQ_NAME_QUERY_PARAM, - [CATEGORY_NAME]: CATEGORY_NAME_QUERY_PARAM, - [SUB_ID]: SUB_ID_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nq, category, subId, ref (value none)', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - [REF]: REF_NO_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with valid param(s): pid, nq, category, subId, ref (value other)', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - [REF]: REF_OTHER_VALUE, - }))).to.equal(true); - }); - it('Test isBidRequestValid() with invalid param(s): empty', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({}))).to.equal(false); - }); - it('Test isBidRequestValid() with invalid param(s): pid missing', function () { - expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [NQ]: NQ_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - }))).to.equal(false); - }); - - let sandbox; - - function getMocks() { - let mockOriginAddress = 'https://localhost'; - let mockRefAddress = 'https://some-ref.test'; - return { - 'windowLocationAddress': mockRefAddress, - 'originAddress': mockOriginAddress, - 'refAddress': '', - }; - } - - function setUpMocks() { - sinon.sandbox.restore(); - sandbox = sinon.sandbox.create(); - sandbox.stub(utils, 'getOrigin').callsFake(() => getMocks()['originAddress']); - sandbox.stub(utils, 'deepAccess').callsFake(() => getMocks()['windowLocationAddress']); - - sandbox.stub(utils, 'getParameterByName').callsFake((arg) => { - switch (arg) { - case CATEGORY_NAME_QUERY_PARAM: - return CATEGORY_VALUE; - case NQ_NAME_QUERY_PARAM: - return NQ_VALUE; - } - }); - } - - function assert( - request, - expectedPid, - expectedNq, - expectedCategory, - expectedSubId - ) { - const requestData = JSON.parse(request.data); - - expect(request.method).to.equal('POST'); - expect(request.url).to.equal(END_POINT_URL + '/hb'); - expect(requestData[0].pid).to.equal(expectedPid); - expect(requestData[0].nq.toString()).to.equal(expectedNq.toString()); - expect(requestData[0].category.toString()).to.equal(expectedCategory.toString()); - expect(requestData[0].subId).to.equal(expectedSubId); - } - - function tearDownMocks() { - sandbox.restore(); - } - - it('Test buildRequest() - pid', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [null]; - let expectedCategory = [null]; - let expectedSubId = null; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, nq', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [NQ_VALUE]; - let expectedCategory = [null]; - let expectedSubId = null; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, nq, category', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [CATEGORY]: CATEGORY_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [NQ_VALUE]; - let expectedCategory = [CATEGORY_VALUE]; - let expectedSubId = null; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, nq, categoryName', function () { - setUpMocks(); - - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [CATEGORY_NAME]: CATEGORY_NAME_QUERY_PARAM, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [NQ_VALUE]; - let expectedCategory = [CATEGORY_VALUE]; - let expectedSubId = null; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, nq, subId', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [SUB_ID]: SUB_ID_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [NQ_VALUE]; - let expectedCategory = [null]; - let expectedSubId = SUB_ID_VALUE; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, category', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [CATEGORY]: CATEGORY_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [null]; - let expectedCategory = [CATEGORY_VALUE]; - let expectedSubId = null; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, category, subId', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [null]; - let expectedCategory = [CATEGORY_VALUE]; - let expectedSubId = SUB_ID_VALUE; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, subId', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [SUB_ID]: SUB_ID_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [null]; - let expectedCategory = [null]; - let expectedSubId = SUB_ID_VALUE; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, nq, category, subId', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [NQ_VALUE]; - let expectedCategory = [CATEGORY_VALUE]; - let expectedSubId = SUB_ID_VALUE; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test buildRequest() - pid, nqName, categoryName, subId', function () { - setUpMocks(); - let requestParams = { - [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ_NAME]: NQ_NAME_QUERY_PARAM, - [CATEGORY_NAME]: CATEGORY_NAME_QUERY_PARAM, - [SUB_ID]: SUB_ID_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [NQ_VALUE]; - let expectedCategory = [CATEGORY_VALUE]; - let expectedSubId = SUB_ID_VALUE; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); - tearDownMocks(); - }); - it('Test interpretResponse() length', function () { - let bids = nanoBidAdapter.interpretResponse({ - body: [ - // valid - { - id: '24a1c9ec270973', - cpm: CPM, - width: WIDTH1, - height: HEIGHT1, - ad: AD, - ttl: 360, - creativeId: 'TEST_ID', - netRevenue: false, - currency: 'EUR', - }, - // invalid - { - id: '24a1c9ec270973', - cpm: null, - width: WIDTH1, - height: HEIGHT1, - ad: AD, - ttl: 360, - creativeId: 'TEST_ID', - netRevenue: false, - currency: 'EUR', - } - ] - }); - expect(bids.length).to.equal(1); - }); - it('Test interpretResponse() bids', function () { - let bid = nanoBidAdapter.interpretResponse({ - body: [ - // valid - { - id: '24a1c9ec270973', - cpm: CPM, - width: WIDTH1, - height: HEIGHT1, - ad: AD, - ttl: 360, - creativeId: 'TEST_ID', - netRevenue: false, - currency: 'EUR', - }, - // invalid - { - id: '24a1c9ec270973', - cpm: null, - width: WIDTH1, - height: HEIGHT1, - ad: AD, - ttl: 360, - creativeId: 'TEST_ID', - netRevenue: false, - currency: 'EUR', - } - ] - })[0]; - expect(bid.requestId).to.equal('24a1c9ec270973'); - expect(bid.cpm).to.equal(CPM); - expect(bid.width).to.equal(WIDTH1); - expect(bid.height).to.equal(HEIGHT1); - expect(bid.ad).to.equal(AD); - expect(bid.ttl).to.equal(360); - expect(bid.creativeId).to.equal('TEST_ID'); - expect(bid.currency).to.equal('EUR'); - }); - }); - }); -}); diff --git a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js deleted file mode 100644 index 4731b1a77d3..00000000000 --- a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js +++ /dev/null @@ -1,143 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/nasmediaAdmixerBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -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': { - 'media_key': 'media_key', - 'adunit_id': 'adunit_id', - }, - '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 = { - 'media_key': '', - 'adunit_id': '', - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'media_key': '19038695', - 'adunit_id': '24190632', - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '3361d01e67dbd6', - 'bidderRequestId': '2b60dcd392628a', - 'auctionId': '124cb070528662', - } - ]; - const bidderRequest = {refererInfo: {referer: 'https://example.com'}}; - - it('sends bid request to url via GET', function () { - const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`https://adn.admixer.co.kr`)); - }); - }); - - describe('interpretResponse', function () { - const response = { - 'body': { - 'bidder': 'nasmediaAdmixer', - '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': { - 'media_key': '19038695', - 'adunit_id': '24190632', - }, - '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': 'nasmediaAdmixer', - '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/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js deleted file mode 100644 index 42032eb03ea..00000000000 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ /dev/null @@ -1,93 +0,0 @@ -import { expect } from 'chai'; -import * as utils from '../../../src/utils.js'; -import { spec } from 'modules/nextMillenniumBidAdapter.js'; - -describe('nextMillenniumBidAdapterTests', function() { - let bidRequestData = { - bids: [ - { - bidId: 'transaction_1234', - bidder: 'nextMillennium', - params: { - placement_id: '12345' - }, - sizes: [[300, 250]] - } - ] - }; - - it('validate_pub_params', function() { - expect( - spec.isBidRequestValid({ - bidder: 'nextMillennium', - params: { - placement_id: '12345' - } - }) - ).to.equal(true); - }); - - it('validate_generated_params', function() { - let bidRequestData = [ - { - bidId: 'bid1234', - bidder: 'nextMillennium', - params: { placement_id: '-1' }, - sizes: [[300, 250]] - } - ]; - let request = spec.buildRequests(bidRequestData); - expect(request[0].bidId).to.equal('bid1234'); - }); - - it('validate_response_params', function() { - let serverResponse = { - body: { - id: 'f7b3d2da-e762-410c-b069-424f92c4c4b2', - seatbid: [ - { - bid: [ - { - id: '7457329903666272789', - price: 0.5, - adm: 'Hello! It\'s a test ad!', - adid: '96846035', - adomain: ['test.addomain.com'], - w: 300, - h: 250 - } - ] - } - ], - cur: 'USD' - } - }; - - let bids = spec.interpretResponse(serverResponse, bidRequestData.bids[0]); - expect(bids).to.have.lengthOf(1); - let bid = bids[0]; - - expect(bid.creativeId).to.equal('96846035'); - expect(bid.ad).to.equal('Hello! It\'s a test ad!'); - expect(bid.cpm).to.equal(0.5); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.currency).to.equal('USD'); - }); - - it('validate_response_params_with passback', function() { - let serverResponse = { - body: [ - { - hash: '1e100887dd614b0909bf6c49ba7f69fdd1360437', - content: 'Ad html passback', - size: [300, 250], - is_passback: 1 - } - ] - }; - let bids = spec.interpretResponse(serverResponse); - - expect(bids).to.have.lengthOf(0); - }); -}); diff --git a/test/spec/modules/open8BidAdapter_spec.js b/test/spec/modules/open8BidAdapter_spec.js deleted file mode 100644 index 506742bef9e..00000000000 --- a/test/spec/modules/open8BidAdapter_spec.js +++ /dev/null @@ -1,251 +0,0 @@ -import { spec } from 'modules/open8BidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -const ENDPOINT = 'https://as.vt.open8.com/v1/control/prebid'; - -describe('Open8Adapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function() { - let bid = { - 'bidder': 'open8', - 'params': { - 'slotKey': 'slotkey1234' - }, - 'adUnitCode': 'adunit', - 'sizes': [[300, 250]], - 'bidId': 'bidid1234', - 'bidderRequestId': 'requestid1234', - 'auctionId': 'auctionid1234', - }; - - 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() { - bid.params = { - ' slotKey': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function() { - let bidRequests = [ - { - 'bidder': 'open8', - 'params': { - 'slotKey': 'slotkey1234' - }, - 'adUnitCode': 'adunit', - 'sizes': [[300, 250]], - 'bidId': 'bidid1234', - 'bidderRequestId': 'requestid1234', - 'auctionId': 'auctionid1234', - } - ]; - - it('sends bid request to ENDPOINT via GET', function() { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].url).to.equal(ENDPOINT); - expect(requests[0].method).to.equal('GET'); - }); - }); - describe('interpretResponse', function() { - const bannerResponse = { - slotKey: 'slotkey1234', - userId: 'userid1234', - impId: 'impid1234', - media: 'TEST_MEDIA', - nurl: 'https://example/win', - isAdReturn: true, - syncPixels: ['https://example/sync/pixel.gif'], - syncIFs: [], - ad: { - bidId: 'TEST_BID_ID', - price: 1234.56, - creativeId: 'creativeid1234', - dealId: 'TEST_DEAL_ID', - currency: 'JPY', - ds: 876, - spd: 1234, - fa: 5678, - pr: 'pr1234', - mr: 'mr1234', - nurl: 'https://example/win', - adType: 2, - banner: { - w: 300, - h: 250, - adm: '
', - imps: ['https://example.com/imp'] - } - } - }; - const videoResponse = { - slotKey: 'slotkey1234', - userId: 'userid1234', - impId: 'impid1234', - media: 'TEST_MEDIA', - isAdReturn: true, - syncPixels: ['https://example/sync/pixel.gif'], - syncIFs: [], - ad: { - bidId: 'TEST_BID_ID', - price: 1234.56, - creativeId: 'creativeid1234', - dealId: 'TEST_DEAL_ID', - currency: 'JPY', - ds: 876, - spd: 1234, - fa: 5678, - pr: 'pr1234', - mr: 'mr1234', - nurl: 'https://example/win', - adType: 1, - video: { - purl: 'https://playerexample.js', - vastXml: '', - w: 320, - h: 180 - }, - } - }; - - it('should get correct banner bid response', function() { - let expectedResponse = [{ - 'slotKey': 'slotkey1234', - 'userId': 'userid1234', - 'impId': 'impid1234', - 'media': 'TEST_MEDIA', - 'ds': 876, - 'spd': 1234, - 'fa': 5678, - 'pr': 'pr1234', - 'mr': 'mr1234', - 'nurl': 'https://example/win', - 'requestId': 'requestid1234', - 'cpm': 1234.56, - 'creativeId': 'creativeid1234', - 'dealId': 'TEST_DEAL_ID', - 'width': 300, - 'height': 250, - 'ad': "
", - 'mediaType': 'banner', - 'currency': 'JPY', - 'ttl': 360, - 'netRevenue': true - }]; - - let bidderRequest; - let result = spec.interpretResponse({ body: bannerResponse }, { bidderRequest }); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles video responses', function() { - let expectedResponse = [{ - 'slotKey': 'slotkey1234', - 'userId': 'userid1234', - 'impId': 'impid1234', - 'media': 'TEST_MEDIA', - 'ds': 876, - 'spd': 1234, - 'fa': 5678, - 'pr': 'pr1234', - 'mr': 'mr1234', - 'nurl': 'https://example/win', - 'requestId': 'requestid1234', - 'cpm': 1234.56, - 'creativeId': 'creativeid1234', - 'dealId': 'TEST_DEAL_ID', - 'width': 320, - 'height': 180, - 'vastXml': '', - 'mediaType': 'video', - 'renderer': {}, - 'adResponse': {}, - 'currency': 'JPY', - 'ttl': 360, - 'netRevenue': true - }]; - - let bidderRequest; - let result = spec.interpretResponse({ body: videoResponse }, { bidderRequest }); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function() { - let response = { - isAdReturn: false, - 'ad': {} - }; - - let bidderRequest; - let result = spec.interpretResponse({ body: response }, { bidderRequest }); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function() { - const imgResponse1 = { - body: { - 'isAdReturn': true, - 'ad': { /* ad body */ }, - 'syncPixels': [ - 'https://example.test/1' - ] - } - }; - - const imgResponse2 = { - body: { - 'isAdReturn': true, - 'ad': { /* ad body */ }, - 'syncPixels': [ - 'https://example.test/2' - ] - } - }; - - const ifResponse = { - body: { - 'isAdReturn': true, - 'ad': { /* ad body */ }, - 'syncIFs': [ - 'https://example.test/3' - ] - } - }; - - it('should use a sync img url from first response', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: true }, [imgResponse1, imgResponse2, ifResponse]); - expect(syncs).to.deep.equal([ - { - type: 'image', - url: 'https://example.test/1' - } - ]); - }); - - it('handle ifs response', function() { - const syncs = spec.getUserSyncs({ iframeEnabled: true }, [ifResponse]); - expect(syncs).to.deep.equal([ - { - type: 'iframe', - url: 'https://example.test/3' - } - ]); - }); - - it('handle empty response (e.g. timeout)', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: true }, []); - expect(syncs).to.deep.equal([]); - }); - - it('returns empty syncs when not enabled', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: false }, [imgResponse1]); - expect(syncs).to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/otmBidAdapter_spec.js b/test/spec/modules/otmBidAdapter_spec.js deleted file mode 100644 index 8ac01c1657e..00000000000 --- a/test/spec/modules/otmBidAdapter_spec.js +++ /dev/null @@ -1,105 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/otmBidAdapter.js'; - -describe('otmBidAdapterTests', function () { - it('validate_pub_params', function () { - expect(spec.isBidRequestValid({ - bidder: 'otm', - params: { - tid: '123', - bidfloor: 20 - } - })).to.equal(true); - }); - - it('validate_generated_params', function () { - let bidRequestData = [{ - bidId: 'bid1234', - bidder: 'otm', - params: { - tid: '123', - bidfloor: 20 - }, - sizes: [[240, 400]] - }]; - - let request = spec.buildRequests(bidRequestData); - let req_data = request[0].data; - - expect(req_data.bidid).to.equal('bid1234'); - }); - - it('validate_best_size_select', function () { - // when: - let bidRequestData = [{ - bidId: 'bid1234', - bidder: 'otm', - params: { - tid: '123', - bidfloor: 20 - }, - sizes: [[300, 500], [300, 600], [240, 400], [300, 50]] - }]; - - let request = spec.buildRequests(bidRequestData); - let req_data = request[0].data; - - // then: - expect(req_data.w).to.equal(240); - expect(req_data.h).to.equal(400); - - // when: - bidRequestData = [{ - bidId: 'bid1234', - bidder: 'otm', - params: { - tid: '123', - bidfloor: 20 - }, - sizes: [[200, 240], [400, 440]] - }]; - - request = spec.buildRequests(bidRequestData); - req_data = request[0].data; - - // then: - expect(req_data.w).to.equal(200); - expect(req_data.h).to.equal(240); - }); - - it('validate_response_params', function () { - let bidRequestData = { - data: { - bidId: 'bid1234' - } - }; - - let serverResponse = { - body: [ - { - 'auctionid': '3c6f8e22-541b-485c-9214-e974d9fb1b6f', - 'cpm': 847.097, - 'ad': 'test html', - 'w': 240, - 'h': 400, - 'currency': 'RUB', - 'ttl': 300, - 'creativeid': '1_7869053', - 'bidid': '101f211def7c99', - 'transactionid': 'transaction_id_1' - } - ] - }; - - let bids = spec.interpretResponse(serverResponse, bidRequestData); - expect(bids).to.have.lengthOf(1); - let bid = bids[0]; - expect(bid.cpm).to.equal(847.097); - expect(bid.currency).to.equal('RUB'); - expect(bid.width).to.equal(240); - expect(bid.height).to.equal(400); - expect(bid.netRevenue).to.equal(true); - expect(bid.requestId).to.equal('101f211def7c99'); - expect(bid.ad).to.equal('test html'); - }); -}); diff --git a/test/spec/modules/outconBidAdapter_spec.js b/test/spec/modules/outconBidAdapter_spec.js deleted file mode 100644 index 81c3fdded62..00000000000 --- a/test/spec/modules/outconBidAdapter_spec.js +++ /dev/null @@ -1,100 +0,0 @@ -import { expect } from 'chai'; -import { spec } from '../../../modules/outconBidAdapter.js'; - -describe('outconBidAdapter', function () { - describe('bidRequestValidity', function () { - it('Check the bidRequest with pod param', function () { - expect(spec.isBidRequestValid({ - bidder: 'outcon', - params: { - pod: '5d603538eba7192ae14e39a4', - env: 'test' - } - })).to.equal(true); - }); - it('Check the bidRequest with internalID and publisherID params', function () { - expect(spec.isBidRequestValid({ - bidder: 'outcon', - params: { - internalId: '12345678', - publisher: '5d5d66f2306ea4114a37c7c2', - env: 'test' - } - })).to.equal(true); - }); - }); - describe('buildRequests', function () { - it('Build requests with pod param', function () { - expect(spec.buildRequests([{ - bidder: 'outcon', - params: { - pod: '5d603538eba7192ae14e39a4', - env: 'test' - } - }])).to.have.keys('method', 'url', 'data'); - }); - it('Build requests with internalID and publisherID params', function () { - expect(spec.buildRequests([{ - bidder: 'outcon', - params: { - internalId: '12345678', - publisher: '5d5d66f2306ea4114a37c7c2', - env: 'test' - } - }])).to.have.keys('method', 'url', 'data'); - }); - }); - describe('interpretResponse', function () { - const bidRequest = { - method: 'GET', - url: 'https://test.outcondigital.com/ad/', - data: { - pod: '5d603538eba7192ae14e39a4', - env: 'test', - vast: 'true' - } - }; - const bidResponse = { - body: { - cpm: 0.10, - cur: 'USD', - exp: 10, - creatives: [ - { - url: 'https://test.outcondigital.com/uploads/5d42e7a7306ea4689b67c122/frutas.mp4', - size: 3, - width: 1920, - height: 1080, - codec: 'video/mp4' - } - ], - ad: '5d6e6aef22063e392bf7f564', - type: 'video', - campaign: '5d42e44b306ea469593c76a2', - trackingURL: 'https://test.outcondigital.com/ad/track?track=5d6e6aef22063e392bf7f564', - vastURL: 'https://test.outcondigital.com/outcon.xml?impression=5d6e6aef22063e392bf7f564&demo=true' - }, - }; - it('check all the keys that are needed to interpret the response', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - let requiredKeys = [ - 'requestId', - 'cpm', - 'width', - 'height', - 'creativeId', - 'currency', - 'netRevenue', - 'ttl', - 'ad', - 'vastImpUrl', - 'mediaType', - 'vastUrl' - ]; - let resultKeys = Object.keys(result[0]); - resultKeys.forEach(function(key) { - expect(requiredKeys.indexOf(key) !== -1).to.equal(true); - }); - }) - }); -}); diff --git a/test/spec/modules/papyrusBidAdapter_spec.js b/test/spec/modules/papyrusBidAdapter_spec.js deleted file mode 100644 index 20fcced2950..00000000000 --- a/test/spec/modules/papyrusBidAdapter_spec.js +++ /dev/null @@ -1,115 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/papyrusBidAdapter.js'; - -const ENDPOINT = 'https://prebid.papyrus.global'; -const BIDDER_CODE = 'papyrus'; - -describe('papyrus Adapter', function () { - describe('isBidRequestValid', function () { - let validBidReq = { - bidder: BIDDER_CODE, - params: { - address: '0xd7e2a771c5dcd5df7f789477356aecdaeee6c985', - placementId: 'b57e55fd18614b0591893e9fff41fbea' - } - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(validBidReq)).to.equal(true); - }); - - let invalidBidReq = { - bidder: BIDDER_CODE, - params: { - 'placementId': '' - } - }; - - it('should not validate incorrect bid request', function () { - expect(spec.isBidRequestValid(invalidBidReq)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - bidder: BIDDER_CODE, - params: { - address: '0xd7e2a771c5dcd5df7f789477356aecdaeee6c985', - placementId: 'b57e55fd18614b0591893e9fff41fbea' - }, - '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); - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('POST'); - }); - - it('sends valid bids count', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data.length).to.equal(1); - }); - - it('sends all bid parameters', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data[0]).to.have.all.keys(['address', 'placementId', 'sizes', 'bidId', 'transactionId']); - }); - - it('sedns valid sizes parameter', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data[0].sizes[0]).to.equal('300x250'); - }); - }); - - describe('interpretResponse', function () { - let bidRequests = [ - { - bidder: BIDDER_CODE, - params: { - address: '0xd7e2a771c5dcd5df7f789477356aecdaeee6c985', - placementId: 'b57e55fd18614b0591893e9fff41fbea' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - let bidResponse = { - bids: [ - { - id: '1036e9746c-d186-49ae-90cb-2796d0f9b223', - adm: 'test adm', - cpm: 100, - height: 250, - width: 300 - } - ] - }; - - it('should build bid array', function () { - const request = spec.buildRequests(bidRequests); - 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(bidRequests); - const result = spec.interpretResponse({body: bidResponse}, request[0]); - const bid = result[0]; - - expect(bid.cpm).to.equal(bidResponse.bids[0].cpm); - expect(bid.width).to.equal(bidResponse.bids[0].width); - expect(bid.height).to.equal(bidResponse.bids[0].height); - }); - }); -}); diff --git a/test/spec/modules/performaxBidAdapter_spec.js b/test/spec/modules/performaxBidAdapter_spec.js deleted file mode 100644 index 43c256b9d13..00000000000 --- a/test/spec/modules/performaxBidAdapter_spec.js +++ /dev/null @@ -1,274 +0,0 @@ -import * as utils from 'src/utils.js'; -import { expect } from 'chai'; -import { spec } from 'modules/performaxBidAdapter'; - -describe('PerformaxAdapter', function () { - let bidRequests, bidderRequest; - let serverResponse, serverRequest; - - const URL = - 'https://dale.performax.cz/hb?slotId[]=3,2&client=hellboy:v0.0.1&auctionId=144b5079-8cbf-49a5-aca7-a68b3296cd6c'; - - bidRequests = [ - { - adUnitCode: 'postbid_iframe', - auctionId: '144b5079-8cbf-49a5-aca7-a68b3296cd6c', - bidId: '2a4332f6b2bc74', - bidRequestsCount: 1, - bidder: 'performax', - bidderRequestId: '1c7d8bf204f11e', - bidderRequestsCount: 1, - bidderWinsCount: 0, - mediaTypes: { - banner: { - sizes: [[300, 300]], - }, - }, - params: { - slotId: 3, - }, - sizes: [[300, 300]], - src: 'client', - transactionId: '14969d09-0068-4d5b-a34e-e35091561dee', - }, - { - adUnitCode: 'postbid_iframe2', - auctionId: '144b5079-8cbf-49a5-aca7-a68b3296cd6c', - bidId: '300bb0ac6a156a', - bidRequestsCount: 1, - bidder: 'performax', - bidderRequestId: '1c7d8bf204f11e', - bidderRequestsCount: 1, - bidderWinsCount: 0, - mediaTypes: { - banner: { - sizes: [[300, 300]], - }, - }, - params: { - slotId: 2, - }, - sizes: [[300, 300]], - src: 'client', - transactionId: '107cbebd-8c36-4456-b28c-91a19ba80151', - }, - ]; - - bidderRequest = { - auctionId: '144b5079-8cbf-49a5-aca7-a68b3296cd6c', - auctionStart: 1594281941845, - bidderCode: 'performax', - bidderRequestId: '1c7d8bf204f11e', - bids: bidRequests, - refererInfo: { - canonicalUrl: '', - numIframes: 0, - reachedTop: true, - referer: '', - }, - stack: [''], - start: 1594281941935, - timeout: 3600, - }; - - serverResponse = { - body: [ - { - ad: { - code: '$SYS_ID$ $VAR_NAME$ rest of the code', - data: { - SYS_ID: 1, - VAR_NAME: 'name', - }, - format_id: 2, - id: 11, - size: { - width: 300, - height: 300, - }, - tag_ids: [], - type: 'creative', - }, - cpm: 30, - creativeId: 'creative:11', - currency: 'CZK', - height: 300, - meta: { - agencyId: 1, - mediaType: 'banner', - }, - netRevenue: true, - requestId: '2a4332f6b2bc74', - ttl: 60, - width: 300, - }, - { - ad: { - code: '', - reason: 'Slot 2 does not allow HB requests', - type: 'empty', - }, - cpm: 0, - creativeId: null, - currency: 'CZK', - height: null, - meta: { - agencyId: null, - mediaType: 'banner', - }, - netRevenue: true, - requestId: '1c7d8bf204f11e', - ttl: 60, - width: 300, - }, - ], - }; - - serverRequest = { - data: { - bidderRequest: bidderRequest, - validBidRequests: bidRequests, - }, - method: 'POST', - options: { - contentType: 'application/json', - }, - url: URL, - }; - - describe('Bid validations', function () { - it('Valid bid', function () { - let validBid = { - bidder: 'performax', - params: { - slotId: 2, - }, - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - }); - - it('Invalid bid: required param is missing', function () { - let invalidBid = { - bidder: 'performax', - params: { - invalidParam: 2, - }, - }, - isValid = spec.isBidRequestValid(invalidBid); - expect(isValid).to.equal(false); - }); - }); - - describe('Build Url', function () { - it('Should return url', function () { - let url = spec.buildUrl(bidRequests, bidderRequest); - expect(url).to.equal(URL); - }); - }); - - describe('Build Request', function () { - it('Should not modify bidRequests and bidder Requests', function () { - let originalBidRequests = utils.deepClone(bidRequests); - let originalBidderRequest = utils.deepClone(bidderRequest); - let request = spec.buildRequests(bidRequests, bidderRequest); - - expect(bidRequests).to.deep.equal(originalBidRequests); - expect(bidderRequest).to.deep.equal(originalBidderRequest); - }); - - it('Endpoint checking', function () { - let request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.equal(URL); - expect(request.method).to.equal('POST'); - expect(request.options).to.deep.equal({ - contentType: 'application/json', - }); - }); - - it('Request params checking', function () { - let request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.validBidRequests).to.deep.equal(bidRequests); - expect(request.data.bidderRequest).to.deep.equal(bidderRequest); - }); - }); - - describe('Build Html', function () { - it('Ad with data: should return build html', function () { - let validAd = { - code: '$SYS_ID$ $VAR_NAME$ rest of the code', - data: { - SYS_ID: 1, - VAR_NAME: 'name', - }, - format_id: 2, - id: 11, - size: { - width: 300, - height: 300, - }, - tag_ids: [], - type: 'creative', - }; - let html = spec.buildHtml(validAd); - expect(html).to.equal('1 name rest of the code'); - }); - - it('Ad with partial data: should return html without data change', function () { - let adWithPartialData = { - code: '$SYS_ID$ $VAR_NAME$ rest of the code', - data: { - VAR_NAME: 'name', - }, - format_id: 2, - id: 11, - size: { - width: 300, - height: 300, - }, - tag_ids: [], - type: 'creative', - }; - let html = spec.buildHtml(adWithPartialData); - expect(html).to.equal('$SYS_ID$ name rest of the code'); - }); - - it('Ad without data: should return html without data change', function () { - let adWithoutData = { - code: '$SYS_ID$ $VAR_NAME$ rest of the code', - format_id: 2, - id: 11, - size: { - width: 300, - height: 300, - }, - tag_ids: [], - type: 'creative', - }; - let html = spec.buildHtml(adWithoutData); - expect(html).to.equal('$SYS_ID$ $VAR_NAME$ rest of the code'); - }); - }); - - describe('Interpret Response', function () { - it('Ad without data: should return html without data change', function () { - let ads = spec.interpretResponse(serverResponse, serverRequest); - expect(ads).to.have.length(1); - expect(ads[0]).to.deep.equal({ - ad: '1 name rest of the code', - cpm: 30, - creativeId: 'creative:11', - currency: 'CZK', - height: 300, - meta: { - agencyId: 1, - mediaType: 'banner', - }, - netRevenue: true, - requestId: '2a4332f6b2bc74', - ttl: 60, - width: 300, - }); - }); - }); -}); diff --git a/test/spec/modules/piximediaBidAdapter_spec.js b/test/spec/modules/piximediaBidAdapter_spec.js deleted file mode 100644 index 88a6433b71d..00000000000 --- a/test/spec/modules/piximediaBidAdapter_spec.js +++ /dev/null @@ -1,103 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/piximediaBidAdapter.js'; - -describe('piximediaAdapterTest', function() { - describe('bidRequestValidity', function() { - it('bidRequest with site ID and placement ID param', function() { - expect(spec.isBidRequestValid({ - bidder: 'piximedia', - params: { - 'siteId': 'PIXIMEDIA_PREBID10', - 'placementId': 'RG' - }, - })).to.equal(true); - }); - - it('bidRequest with no required params', function() { - expect(spec.isBidRequestValid({ - bidder: 'piximedia', - params: { - }, - })).to.equal(false); - }); - }); - - describe('bidRequest', function() { - const bidRequests = [{ - 'bidder': 'piximedia', - 'params': { - 'siteId': 'PIXIMEDIA_PREBID10', - 'placementId': 'RG' - }, - '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(typeof requests[0].data.timestamp).to.equal('number'); - expect(requests[0].data.pbsizes).to.equal('["300x250"]'); - expect(requests[0].data.pver).to.equal('1.0'); - expect(requests[0].data.pbparams).to.equal(JSON.stringify(bidRequests[0].params)); - expect(requests[0].data.pbwidth).to.equal('300'); - expect(requests[0].data.pbheight).to.equal('250'); - expect(requests[0].data.pbbidid).to.equal('51ef8751f9aead'); - }); - }); - - describe('interpretResponse', function() { - const bidRequest = { - 'method': 'GET', - 'url': 'https://ad.piximedia.com/', - '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: { - 'bidId': '51ef8751f9aead', - 'cpm': 4.2, - 'width': '300', - 'height': '250', - 'creative_id': '1234', - 'currency': 'EUR', - 'adm': '
', - }, - 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(4.2); - expect(result[0].width).to.equal('300'); - expect(result[0].height).to.equal('250'); - expect(result[0].creativeId).to.equal('1234'); - expect(result[0].currency).to.equal('EUR'); - expect(result[0].ttl).to.equal(300); - expect(result[0].ad).to.equal('
'); - }); - }); -}); diff --git a/test/spec/modules/projectLimeLightBidAdapter_spec.js b/test/spec/modules/projectLimeLightBidAdapter_spec.js deleted file mode 100644 index 778d8eedf7b..00000000000 --- a/test/spec/modules/projectLimeLightBidAdapter_spec.js +++ /dev/null @@ -1,259 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/projectLimeLightBidAdapter.js'; - -describe('ProjectLimeLightAdapter', function () { - const bid1 = { - bidId: '2dd581a2b6281d', - bidder: 'project-limelight', - bidderRequestId: '145e1d6a7837c9', - params: { - host: 'ads.project-limelight.com', - adUnitId: 123, - adUnitType: 'banner' - }, - placementCode: 'placement_0', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' - } - const bid2 = { - bidId: '58ee9870c3164a', - bidder: 'project-limelight', - bidderRequestId: '209fdaf1c81649', - params: { - host: 'cpm.project-limelight.com', - adUnitId: 456, - adUnitType: 'banner' - }, - placementCode: 'placement_1', - auctionId: '482f88de-29ab-45c8-981a-d25e39454a34', - sizes: [[350, 200]], - transactionId: '068867d1-46ec-40bb-9fa0-e24611786fb4' - } - const bid3 = { - bidId: '019645c7d69460', - bidder: 'project-limelight', - bidderRequestId: 'f2b15f89e77ba6', - params: { - host: 'ads.project-limelight.com', - adUnitId: 789, - adUnitType: 'video' - }, - placementCode: 'placement_2', - auctionId: 'e4771143-6aa7-41ec-8824-ced4342c96c8', - sizes: [[800, 600]], - transactionId: '738d5915-6651-43b9-9b6b-d50517350917' - } - - describe('buildRequests', function () { - const serverRequests = spec.buildRequests([bid1, bid2, bid3]) - it('Creates two ServerRequests', function() { - expect(serverRequests).to.exist - expect(serverRequests).to.have.lengthOf(2) - }) - serverRequests.forEach(serverRequest => { - 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 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', 'adUnits') - expect(data.deviceWidth).to.be.a('number') - expect(data.deviceHeight).to.be.a('number') - expect(data.secure).to.be.a('boolean') - data.adUnits.forEach(adUnit => { - expect(adUnit).to.have.all.keys('id', 'bidId', 'type', 'sizes', 'transactionId') - expect(adUnit.id).to.be.a('number') - expect(adUnit.bidId).to.be.a('string') - expect(adUnit.type).to.be.a('string') - expect(adUnit.transactionId).to.be.a('string') - expect(adUnit.sizes).to.be.an('array') - }) - }) - }) - it('Returns valid URL', function () { - expect(serverRequests[0].url).to.equal('https://ads.project-limelight.com/hb') - expect(serverRequests[1].url).to.equal('https://cpm.project-limelight.com/hb') - }) - it('Returns valid adUnits', function () { - validateAdUnit(serverRequests[0].data.adUnits[0], bid1) - validateAdUnit(serverRequests[1].data.adUnits[0], bid2) - validateAdUnit(serverRequests[0].data.adUnits[1], bid3) - }) - it('Returns empty data if no valid requests are passed', function () { - const serverRequests = spec.buildRequests([]) - expect(serverRequests).to.be.an('array').that.is.empty - }) - }) - describe('interpretBannerResponse', 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('interpretVideoResponse', function () { - let resObject = { - body: [ { - requestId: '123', - mediaType: 'video', - cpm: 0.3, - width: 320, - height: 50, - vastXml: '', - 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', 'vastXml', '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.vastXml).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('isBidRequestValid', function() { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'project-limelight', - bidderRequestId: '145e1d6a7837c9', - params: { - adUnitId: 123, - adUnitType: 'banner' - }, - placementCode: 'placement_0', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' - }; - - 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 bidFailed = { - bidder: 'project-limelight', - bidderRequestId: '145e1d6a7837c9', - params: { - adUnitId: 123, - adUnitType: 'banner' - }, - placementCode: 'placement_0', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' - }; - expect(spec.isBidRequestValid(bidFailed)).to.equal(false); - }); - }); - describe('interpretResponse', function() { - let resObject = { - requestId: '123', - mediaType: 'banner', - cpm: 0.3, - width: 320, - height: 50, - ad: '

Hello ad

', - ttl: 1000, - creativeId: '123asd', - netRevenue: true, - currency: 'USD' - }; - it('should skip responses which do not contain required params', function() { - let bidResponses = { - body: [ { - mediaType: 'banner', - cpm: 0.3, - ttl: 1000, - currency: 'USD' - }, resObject ] - } - expect(spec.interpretResponse(bidResponses)).to.deep.equal([ resObject ]); - }); - it('should skip responses which do not contain expected mediaType', function() { - let bidResponses = { - body: [ { - requestId: '123', - mediaType: 'native', - cpm: 0.3, - creativeId: '123asd', - ttl: 1000, - currency: 'USD' - }, resObject ] - } - expect(spec.interpretResponse(bidResponses)).to.deep.equal([ resObject ]); - }); - }); -}); - -function validateAdUnit(adUnit, bid) { - expect(adUnit.id).to.equal(bid.params.adUnitId) - expect(adUnit.bidId).to.equal(bid.bidId) - expect(adUnit.type).to.equal(bid.params.adUnitType.toUpperCase()) - expect(adUnit.transactionId).to.equal(bid.transactionId) - expect(adUnit.sizes).to.deep.equal(bid.sizes.map(size => { - return { - width: size[0], - height: size[1] - } - })) -} diff --git a/test/spec/modules/proxistoreBidAdapter_spec.js b/test/spec/modules/proxistoreBidAdapter_spec.js deleted file mode 100644 index bdcdca06183..00000000000 --- a/test/spec/modules/proxistoreBidAdapter_spec.js +++ /dev/null @@ -1,166 +0,0 @@ -import { expect } from 'chai'; -let { spec } = require('modules/proxistoreBidAdapter'); -const BIDDER_CODE = 'proxistore'; -describe('ProxistoreBidAdapter', function () { - const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - const bidderRequest = { - bidderCode: BIDDER_CODE, - auctionId: '1025ba77-5463-4877-b0eb-14b205cb9304', - bidderRequestId: '10edf38ec1a719', - gdprConsent: { - apiVersion: 2, - gdprApplies: true, - consentString: consentString, - vendorData: { - vendor: { - consents: { - 418: true, - }, - }, - }, - }, - }; - let bid = { - sizes: [[300, 600]], - params: { - website: 'example.fr', - language: 'fr', - }, - ortb2: { - user: { ext: { data: { segments: [], contextual_categories: {} } } }, - }, - auctionId: 442133079, - bidId: 464646969, - transactionId: 511916005, - }; - describe('isBidRequestValid', function () { - it('it should be true if required params are presents and there is no info in the local storage', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - it('it should be false if the value in the localstorage is less than 5minutes of the actual time', function () { - const date = new Date(); - date.setMinutes(date.getMinutes() - 1); - localStorage.setItem(`PX_NoAds_${bid.params.website}`, date); - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - it('it should be true if the value in the localstorage is more than 5minutes of the actual time', function () { - const date = new Date(); - date.setMinutes(date.getMinutes() - 10); - localStorage.setItem(`PX_NoAds_${bid.params.website}`, date); - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - describe('buildRequests', function () { - const url = { - cookieBase: 'https://abs.proxistore.com/fr/v3/rtb/prebid/multi', - cookieLess: - 'https://abs.cookieless-proxistore.com/fr/v3/rtb/prebid/multi', - }; - let request = spec.buildRequests([bid], bidderRequest); - it('should return a valid object', function () { - expect(request).to.be.an('object'); - expect(request.method).to.exist; - expect(request.url).to.exist; - expect(request.data).to.exist; - }); - it('request method should be POST', function () { - expect(request.method).to.equal('POST'); - }); - it('should have the value consentGiven to true bc we have 418 in the vendor list', function () { - const data = JSON.parse(request.data); - expect(data.gdpr.consentString).equal( - bidderRequest.gdprConsent.consentString - ); - expect(data.gdpr.applies).to.be.true; - expect(data.gdpr.consentGiven).to.be.true; - }); - it('should contain a valid url', function () { - // has gdpr consent - expect(request.url).equal(url.cookieBase); - // doens't have gpdr consent - bidderRequest.gdprConsent.vendorData = null; - - request = spec.buildRequests([bid], bidderRequest); - expect(request.url).equal(url.cookieLess); - - // api v2 - bidderRequest.gdprConsent = { - gdprApplies: true, - allowAuctionWithoutConsent: true, - consentString: consentString, - vendorData: { - vendor: { - consents: { - '418': true - } - }, - }, - apiVersion: 2 - }; - // has gdpr consent - request = spec.buildRequests([bid], bidderRequest); - expect(request.url).equal(url.cookieBase); - - bidderRequest.gdprConsent.vendorData.vendor = {}; - request = spec.buildRequests([bid], bidderRequest); - expect(request.url).equal(url.cookieLess); - }); - it('should have a property a length of bids equal to one if there is only one bid', function () { - const data = JSON.parse(request.data); - expect(data.hasOwnProperty('bids')).to.be.true; - expect(data.bids).to.be.an('array'); - expect(data.bids.length).equal(1); - expect(data.bids[0].hasOwnProperty('id')).to.be.true; - expect(data.bids[0].sizes).to.be.an('array'); - }); - it('should correctly set bidfloor on imp when getfloor in scope', function () { - let data = JSON.parse(request.data); - expect(data.bids[0].floor).to.be.null; - - // make it respond with a non USD floor should not send it - bid.getFloor = function () { - return { currency: 'EUR', floor: 1.0 }; - }; - let req = spec.buildRequests([bid], bidderRequest); - data = JSON.parse(req.data); - expect(data.bids[0].floor).equal(1); - bid.getFloor = function () { - return { currency: 'USD', floor: 1.0 }; - }; - req = spec.buildRequests([bid], bidderRequest); - data = JSON.parse(req.data); - expect(data.bids[0].floor).to.be.null; - }); - }); - describe('interpretResponse', function () { - const emptyResponseParam = { body: [] }; - const fakeResponseParam = { - body: [ - { - ad: '', - cpm: 6.25, - creativeId: '22c3290b-8cd5-4cd6-8e8c-28a2de180ccd', - currency: 'EUR', - dealId: '2021-03_a63ec55e-b9bb-4ca4-b2c9-f456be67e656', - height: 600, - netRevenue: true, - requestId: '3543724f2a033c9', - segments: [], - ttl: 10, - vastUrl: null, - vastXml: null, - width: 300, - }, - ], - }; - - it('should always return an array', function () { - let response = spec.interpretResponse(emptyResponseParam, bid); - expect(response).to.be.an('array'); - expect(response.length).equal(0); - response = spec.interpretResponse(fakeResponseParam, bid); - expect(response).to.be.an('array'); - expect(response.length).equal(1); - }); - }); -}); diff --git a/test/spec/modules/pubxBidAdapter_spec.js b/test/spec/modules/pubxBidAdapter_spec.js deleted file mode 100644 index 6cea8787845..00000000000 --- a/test/spec/modules/pubxBidAdapter_spec.js +++ /dev/null @@ -1,189 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/pubxBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -describe('pubxAdapter', function () { - const adapter = newBidder(spec); - const ENDPOINT = 'https://api.primecaster.net/adlogue/api/slot/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 () { - const bid = { - bidder: 'pubx', - params: { - sid: '12345abc' - } - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { - id: '26c1ee0038ac11', - params: { - sid: '12345abc' - } - } - ]; - - const data = { - banner: { - sid: '12345abc' - } - }; - - it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('GET'); - }); - - it('should attach params to the banner request', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.data).to.deep.equal(data.banner); - }); - }); - - describe('getUserSyncs', function () { - const sandbox = sinon.sandbox.create(); - - const keywordsText = 'meta1,meta2,meta3,meta4,meta5'; - const descriptionText = 'description1description2description3description4description5description'; - - let documentStubMeta; - - beforeEach(function () { - documentStubMeta = sandbox.stub(document, 'getElementsByName'); - const metaElKeywords = document.createElement('meta'); - metaElKeywords.setAttribute('name', 'keywords'); - metaElKeywords.setAttribute('content', keywordsText); - documentStubMeta.withArgs('keywords').returns([metaElKeywords]); - - const metaElDescription = document.createElement('meta'); - metaElDescription.setAttribute('name', 'description'); - metaElDescription.setAttribute('content', descriptionText); - documentStubMeta.withArgs('description').returns([metaElDescription]); - }); - - afterEach(function () { - documentStubMeta.restore(); - }); - - let kwString = ''; - let kwEnc = ''; - let descContent = ''; - let descEnc = ''; - - it('returns empty sync array when iframe is not enabled', function () { - const syncOptions = {}; - expect(spec.getUserSyncs(syncOptions)).to.deep.equal([]); - }); - - it('returns kwEnc when there is kwTag with more than 20 length', function () { - const kwArray = keywordsText.substr(0, 20).split(','); - kwArray.pop(); - kwString = kwArray.join(); - kwEnc = encodeURIComponent(kwString); - const syncs = spec.getUserSyncs({ iframeEnabled: true }); - expect(syncs[0].url).to.include(`pkw=${kwEnc}`); - }); - - it('returns kwEnc when there is kwTag with more than 60 length', function () { - descContent = descContent.substr(0, 60); - descEnc = encodeURIComponent(descContent); - const syncs = spec.getUserSyncs({ iframeEnabled: true }); - expect(syncs[0].url).to.include(`pkw=${descEnc}`); - }); - - it('returns titleEnc when there is titleContent with more than 30 length', function () { - let titleText = 'title1title2title3title4title5title'; - const documentStubTitle = sandbox.stub(document, 'title').value(titleText); - - if (titleText.length > 30) { - titleText = titleText.substr(0, 30); - } - - const syncs = spec.getUserSyncs({ iframeEnabled: true }); - expect(syncs[0].url).to.include(`pt=${encodeURIComponent(titleText)}`); - }); - }); - - describe('interpretResponse', function () { - const serverResponse = { - body: { - TTL: 300, - adm: '
some creative
', - cid: 'TKmB', - cpm: 500, - currency: 'JPY', - height: 250, - width: 300, - } - } - - const bidRequests = [ - { - id: '26c1ee0038ac11', - params: { - sid: '12345abc' - } - } - ]; - - const bidResponses = [ - { - requestId: '26c1ee0038ac11', - cpm: 500, - currency: 'JPY', - width: 300, - height: 250, - creativeId: 'TKmB', - netRevenue: true, - ttl: 300, - ad: '
some creative
' - } - ]; - it('should return empty array when required param is empty', function () { - const serverResponseWithCidEmpty = { - body: { - TTL: 300, - adm: '
some creative
', - cid: '', - cpm: '', - currency: 'JPY', - height: 250, - width: 300, - } - } - const result = spec.interpretResponse(serverResponseWithCidEmpty, bidRequests[0]); - expect(result).to.be.empty; - }); - it('handles banner responses', function () { - const result = spec.interpretResponse(serverResponse, bidRequests[0])[0]; - expect(result.requestId).to.equal(bidResponses[0].requestId); - expect(result.width).to.equal(bidResponses[0].width); - expect(result.height).to.equal(bidResponses[0].height); - expect(result.creativeId).to.equal(bidResponses[0].creativeId); - expect(result.currency).to.equal(bidResponses[0].currency); - expect(result.netRevenue).to.equal(bidResponses[0].netRevenue); - expect(result.ttl).to.equal(bidResponses[0].ttl); - expect(result.ad).to.equal(bidResponses[0].ad); - }); - }); -}); diff --git a/test/spec/modules/reklamstoreBidAdapter_spec.js b/test/spec/modules/reklamstoreBidAdapter_spec.js deleted file mode 100644 index 1dcd6c17ca4..00000000000 --- a/test/spec/modules/reklamstoreBidAdapter_spec.js +++ /dev/null @@ -1,85 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/reklamstoreBidAdapter.js'; - -describe('reklamstoreBidAdapterTests', function() { - let bidRequestData = { - bids: [ - { - bidder: 'reklamstore', - params: { - regionId: 532211 - }, - sizes: [[300, 250]] - } - ] - }; - let request = []; - - it('validate_params', function() { - expect( - spec.isBidRequestValid({ - bidder: 'reklamstore', - params: { - regionId: 532211 - } - }) - ).to.equal(true); - }); - - it('validate_generated_params', function() { - let bidderRequest = { - refererInfo: { - referer: 'https://reklamstore.com' - } - }; - request = spec.buildRequests(bidRequestData.bids, bidderRequest); - let req_data = request[0].data; - - expect(req_data.regionId).to.equal(532211); - }); - - const serverResponse = { - body: - { - cpm: 1.2, - ad: 'Ad html', - w: 300, - h: 250, - syncs: [{ - type: 'image', - url: 'https://link1' - }, - { - type: 'iframe', - url: 'https://link2' - } - ] - } - }; - - it('validate_response_params', function() { - let bids = spec.interpretResponse(serverResponse, bidRequestData.bids[0]); - expect(bids).to.have.lengthOf(1); - - let bid = bids[0]; - expect(bid.ad).to.equal('Ad html'); - expect(bid.cpm).to.equal(1.2); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.currency).to.equal('USD'); - }); - - it('should return no syncs when pixel syncing is disabled', function () { - const syncs = spec.getUserSyncs({ pixelEnabled: false }, [serverResponse]); - expect(syncs).to.deep.equal([]); - }); - - it('should return user syncs', function () { - const syncs = spec.getUserSyncs({pixelEnabled: true, iframeEnabled: true}, [serverResponse]); - const expected = [ - { type: 'image', url: 'https://link1' }, - { type: 'iframe', url: 'https://link2' }, - ]; - expect(syncs).to.deep.equal(expected); - }); -}); diff --git a/test/spec/modules/reloadBidAdapter_spec.js b/test/spec/modules/reloadBidAdapter_spec.js deleted file mode 100644 index b22dd9e7b92..00000000000 --- a/test/spec/modules/reloadBidAdapter_spec.js +++ /dev/null @@ -1,295 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/reloadBidAdapter.js'; - -let getParams = () => { - return JSON.parse(JSON.stringify({ - 'plcmID': 'placement_01', - 'partID': 'part00', - 'opdomID': 1, - 'bsrvID': 1, - 'type': 'pcm' - })); -}; - -let getBidderRequest = () => { - return JSON.parse(JSON.stringify({ - bidderCode: 'reload', - auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', - bidderRequestId: '7101db09af0db2', - start: new Date().getTime(), - bids: [{ - bidder: 'reload', - bidId: '84ab500420319d', - bidderRequestId: '7101db09af0db2', - auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', - params: getParams() - }] - })); -}; - -let getValidBidRequests = () => { - return JSON.parse(JSON.stringify([ - { - 'bidder': 'reload', - 'params': getParams(), - 'mediaTypes': { - 'banner': { - 'sizes': [[160, 600]] - } - }, - 'adUnitCode': '1b243858-3c53-43dc-9fdf-89f839ea4a0f', - 'transactionId': '8cbafa10-123d-4673-a1a5-04a1c7d62ded', - 'sizes': [[160, 600]], - 'bidId': '2236e11dc09931', - 'bidderRequestId': '1266bb886c2267', - 'auctionId': '4fb72c4d-94dc-4db1-8fac-3c2090ceeec0', - 'src': 'client', - 'bidRequestsCount': 1 - } - ])); -} - -let getExt1ServerResponse = () => { - return JSON.parse(JSON.stringify({ - 'pcmdata': { - 'thisVer': '100', - 'plcmSett': { - 'name': 'zz_test_mariano_adapter', - 'Version': '210', - 'lifeSpan': '100', - 'versionFolder': 'v4.14q', - 'versionFolderA': 'v4.14q', - 'versionFolderB': '', - 'stage': 'zz_test_mariano_adapter', - 'synchro': 1556916507000, - 'localCache': 'true', - 'testCase': 'A:00_B:100', - 'opdomain': '1', - 'checksum': '6378', - 'cpm': '0', - 'bstfct': '100', - 'totstop': 'false', - 'pcmurl': 'bidsrv01.reload.net' - }, - 'srvUrl': 'bidsrv01.reload.net', - 'instr': {'go': true, 'prc': 32, 'cur': 'USD'}, - 'statStr': 'eyN4aHYnQCk5OTotOC', - 'status': 'ok', - 'message': '', - 'log': '---- LOG ----' - }, - 'plcmID': 'zz_test_mariano_adapter', - 'partID': 'prx_part', - 'opdomID': '0', - 'bsrvID': 1, - 'adUnitCode': '1b243858-3c53-43dc-9fdf-89f839ea4a0f', - 'banner': {'w': 300, 'h': 250} - })); -} - -let getExt2ServerResponse = () => { - return JSON.parse(JSON.stringify({ - 'pcmdata': { - 'thisVer': '100', - 'plcmSett': { - 'name': 'placement_01', - 'Version': '210', - 'lifeSpan': '100', - 'versionFolder': 'v4.14q', - 'versionFolderA': 'v4.14q', - 'versionFolderB': '', - 'stage': 'placement_01', - 'synchro': 1556574760000, - 'localCache': 'true', - 'testCase': 'A:00_B:100', - 'opdomain': '1', - 'checksum': '6378', - 'cpm': '0', - 'bstfct': '100', - 'totstop': 'false', - 'pcmurl': 'bidsrv00.reload.net' - }, - 'srvUrl': 'bidsrv00.reload.net', - 'log': 'incomp_input_obj_version', - 'message': 'incomp_input_obj_version', - 'status': 'error' - }, - 'plcmID': 'placement_01', - 'partID': 'prx_part', - 'opdomID': '0', - 'bsrvID': 1, - 'adUnitCode': '1b243858-3c53-43dc-9fdf-89f839ea4a0f', - 'banner': {'w': 160, 'h': 600} - })); -} - -let getServerResponse = (pExt) => { - return JSON.parse(JSON.stringify({ - 'body': { - 'id': '2759340f70210d', - 'bidid': 'fbs-br-3mzdbycetjv8f8079', - 'seatbid': [ - { - 'bid': [ - { - 'id': 'fbs-br-stbd-bd-3mzdbycetjv8f807b', - 'price': 0, - 'nurl': '', - 'adm': '', - 'ext': pExt - } - ], - 'seat': 'fbs-br-stbd-3mzdbycetjv8f807a', - 'group': 0 - } - ] - }, - 'headers': {} - })); -} - -describe('ReloadAdapter', function () { - describe('isBidRequestValid', function () { - var bid = { - 'bidder': 'reload', - 'params': { - 'plcmID': 'placement_01', - 'partID': 'part00', - 'opdomID': 1, - 'bsrvID': 23, - 'type': 'pcm' - }, - '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 bsrvID is not number', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'plcmID': 'placement_01', - 'partID': 'part00', - 'opdomID': 1, - 'bsrvID': 'abc' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when bsrvID > 99', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'plcmID': 'placement_01', - 'partID': 'part00', - 'opdomID': 1, - 'bsrvID': 230 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when bsrvID < 0', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'plcmID': 'placement_01', - 'partID': 'part00', - 'opdomID': 1, - 'bsrvID': -3, - 'type': 'pcm' - }; - 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 = { - 'plcmID': 'placement_01' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests()', function () { - let vRequests = spec.buildRequests(getValidBidRequests(), {}); - let vData = JSON.parse(vRequests[0].data); - - it('should send one requests', () => { - expect(vRequests.length).to.equal(1); - }); - - it('should send one requests, one impression', () => { - expect(vData.imp.length).to.equal(1); - }); - - it('should exists ext.type and ext.pcmdata', () => { - expect(vData.imp[0].banner).to.exist; - expect(vData.imp[0].banner.ext).to.exist; - expect(vData.imp[0].banner.ext.type).to.exist; - expect(vData.imp[0].banner.ext.pcmdata).to.exist; - expect(vData.imp[0].banner.ext.type).to.equal('pcm'); - }); - }); - - describe('interpretResponse()', function () { - it('Returns an empty array', () => { - let vData = spec.interpretResponse(getServerResponse(getExt2ServerResponse()), {}); - - expect(vData.length).to.equal(0); - }); - - it('Returns an array with one response', () => { - let vData = spec.interpretResponse(getServerResponse(getExt1ServerResponse()), {}); - expect(vData.length).to.equal(1); - }); - - it('required fileds', () => { - let vData = spec.interpretResponse(getServerResponse(getExt1ServerResponse()), {}); - expect(vData.length).to.equal(1); - expect(vData[0]).to.have.all.keys(['requestId', 'ad', 'cpm', 'width', 'height', 'creativeId', 'currency', 'ttl', 'netRevenue']); - }); - - it('CPM great than 0', () => { - let vData = spec.interpretResponse(getServerResponse(getExt1ServerResponse()), {}); - expect(vData[0].cpm).to.greaterThan(0); - }); - - it('instruction empty', () => { - let vResponse = Object.assign({}, getServerResponse(getExt1ServerResponse())); - vResponse.body.seatbid[0].bid[0].ext.pcmdata.instr = null; - let vData = spec.interpretResponse(vResponse, {}); - expect(vData.length).to.equal(0); - - vResponse = Object.assign({}, getServerResponse(getExt1ServerResponse())); - vResponse.body.seatbid[0].bid[0].ext.pcmdata.instr = undefined; - vData = spec.interpretResponse(vResponse, {}); - expect(vData.length).to.equal(0); - - vResponse = Object.assign({}, getServerResponse(getExt1ServerResponse())); - vResponse.body.seatbid[0].bid[0].ext.pcmdata.instr.go = undefined; - vData = spec.interpretResponse(vResponse, {}); - expect(vData.length).to.equal(0); - }); - - it('instruction with go = false', () => { - let vResponse = getServerResponse(getExt1ServerResponse()); - vResponse.body.seatbid[0].bid[0].ext.pcmdata.instr.go = false; - let vData = spec.interpretResponse(vResponse, {}); - expect(vData.length).to.equal(0); - }); - - it('incompatibility output object version (thisVer)', () => { - let vResponse = getServerResponse(getExt1ServerResponse()); - vResponse.body.seatbid[0].bid[0].ext.pcmdata.thisVer = '200'; - let vData = spec.interpretResponse(vResponse, {}); - expect(vData.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/resultsmediaBidAdapter_spec.js b/test/spec/modules/resultsmediaBidAdapter_spec.js deleted file mode 100644 index 0e2d4c0013a..00000000000 --- a/test/spec/modules/resultsmediaBidAdapter_spec.js +++ /dev/null @@ -1,574 +0,0 @@ -import {spec} from '../../../modules/resultsmediaBidAdapter.js'; -import * as utils from '../../../src/utils.js'; -import * as sinon from 'sinon'; - -var r1adapter = spec; - -describe('resultsmedia adapter tests', function () { - beforeEach(function() { - this.defaultBidderRequest = { - 'refererInfo': { - 'referer': 'Reference Page', - 'stack': [ - 'aodomain.dvl', - 'page.dvl' - ] - } - }; - }); - - describe('Verify 1.0 POST Banner Bid Request', function () { - it('buildRequests works', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaType': 'banner', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]], - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - - expect(bidRequest.url).to.have.string('https://bid306.rtbsrv.com/bidder/?bid=3mhdom&zoneId=9999&hbv='); - expect(bidRequest.method).to.equal('POST'); - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.site).to.not.equal(null); - expect(openrtbRequest.site.ref).to.equal('Reference Page'); - expect(openrtbRequest.device).to.not.equal(null); - expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); - expect(openrtbRequest.device.dnt).to.equal(0); - expect(openrtbRequest.imp[0].banner).to.not.equal(null); - expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); - expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(250); - expect(openrtbRequest.imp[0].ext.bidder.zoneId).to.equal(9999); - }); - - it('interpretResponse works', function() { - var bidList = { - 'body': [ - { - 'impid': 'div-gpt-ad-1438287399331-0', - 'w': 300, - 'h': 250, - 'adm': '
My Compelling Ad
', - 'price': 1, - 'crid': 'cr-cfy24' - } - ] - }; - - var bannerBids = r1adapter.interpretResponse(bidList); - - expect(bannerBids.length).to.equal(1); - const bid = bannerBids[0]; - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.creativeId).to.equal('cr-cfy24'); - expect(bid.currency).to.equal('USD'); - expect(bid.netRevenue).to.equal(true); - expect(bid.cpm).to.equal(1.0); - expect(bid.ttl).to.equal(350); - }); - }); - - describe('Verify POST Video Bid Request', function() { - it('buildRequests works', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'video': { - 'playerSize': [640, 480], - 'context': 'instream' - } - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-1', - 'sizes': [ - [300, 250] - ], - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - - expect(bidRequest.url).to.have.string('https://bid306.rtbsrv.com/bidder/?bid=3mhdom&zoneId=9999&hbv='); - expect(bidRequest.method).to.equal('POST'); - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.site).to.not.equal(null); - expect(openrtbRequest.device).to.not.equal(null); - expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); - expect(openrtbRequest.device).to.have.property('dnt'); - expect(openrtbRequest.imp[0].video).to.not.equal(null); - expect(openrtbRequest.imp[0].video.w).to.equal(640); - expect(openrtbRequest.imp[0].video.h).to.equal(480); - expect(openrtbRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); - expect(openrtbRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); - expect(openrtbRequest.imp[0].video.startdelay).to.equal(0); - expect(openrtbRequest.imp[0].video.skip).to.equal(0); - expect(openrtbRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); - expect(openrtbRequest.imp[0].video.delivery[0]).to.equal(1); - expect(openrtbRequest.imp[0].video.api).to.eql([1, 2, 5]); - }); - - it('interpretResponse works', function() { - var bidList = { - 'body': [ - { - 'impid': 'div-gpt-ad-1438287399331-1', - 'price': 1, - 'adm': 'https://example.com/', - 'adomain': [ - 'test.com' - ], - 'cid': '467415', - 'crid': 'cr-vid', - 'w': 800, - 'h': 600 - } - ] - }; - - var videoBids = r1adapter.interpretResponse(bidList); - - expect(videoBids.length).to.equal(1); - const bid = videoBids[0]; - expect(bid.width).to.equal(800); - expect(bid.height).to.equal(600); - expect(bid.vastUrl).to.equal('https://example.com/'); - expect(bid.mediaType).to.equal('video'); - expect(bid.creativeId).to.equal('cr-vid'); - expect(bid.currency).to.equal('USD'); - expect(bid.netRevenue).to.equal(true); - expect(bid.cpm).to.equal(1.0); - expect(bid.ttl).to.equal(600); - }); - }); - - describe('misc buildRequests', function() { - it('should send GDPR Consent data to resultsmedia tag', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-3', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var consentString = 'testConsentString'; - var gdprBidderRequest = this.defaultBidderRequest; - gdprBidderRequest.gdprConsent = { - 'gdprApplies': true, - 'consentString': consentString - }; - - var bidRequest = r1adapter.buildRequests(bidRequestList, gdprBidderRequest); - - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.user.ext.consent).to.equal(consentString); - expect(openrtbRequest.regs.ext.gdpr).to.equal(true); - }); - - it('prefer 2.0 sizes', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 600]] - } - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]], - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); - expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(600); - }); - - it('does not return request for invalid banner size configuration', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300]] - } - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - expect(bidRequest.method).to.be.undefined; - }); - - it('does not return request for missing banner size configuration', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'banner': {} - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - expect(bidRequest.method).to.be.undefined; - }); - - it('reject bad sizes', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'banner': {'sizes': [['400', '500'], ['4n0', '5g0']]} - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.imp[0].banner.format.length).to.equal(1); - }); - - it('dnt is correctly set to 1', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 600]] - } - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var dntStub = sinon.stub(utils, 'getDNT').returns(1); - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - - dntStub.restore(); - - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.device.dnt).to.equal(1); - }); - - it('supports string video sizes', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': ['600', '300'] - } - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-1', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.imp[0].video.w).to.equal(600); - expect(openrtbRequest.imp[0].video.h).to.equal(300); - }); - - it('rejects bad video sizes', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': ['badWidth', 'badHeight'] - } - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-1', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.imp[0].video.w).to.be.undefined; - expect(openrtbRequest.imp[0].video.h).to.be.undefined; - }); - - it('supports missing video size', function () { - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'video': { - 'context': 'instream' - } - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-1', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - - const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.imp[0].video.w).to.be.undefined; - expect(openrtbRequest.imp[0].video.h).to.be.undefined; - }); - - it('should return empty site data when refererInfo is missing', function() { - delete this.defaultBidderRequest.refererInfo; - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaType': 'banner', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]], - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - const openrtbRequest = JSON.parse(bidRequest.data); - - expect(openrtbRequest.site.domain).to.equal(''); - expect(openrtbRequest.site.page).to.equal(''); - expect(openrtbRequest.site.ref).to.equal(''); - }); - }); - - it('should return empty site.domain and site.page when refererInfo.stack is empty', function() { - this.defaultBidderRequest.refererInfo.stack = []; - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaType': 'banner', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]], - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - const openrtbRequest = JSON.parse(bidRequest.data); - - expect(openrtbRequest.site.domain).to.equal(''); - expect(openrtbRequest.site.page).to.equal(''); - expect(openrtbRequest.site.ref).to.equal('Reference Page'); - }); - - it('should secure correctly', function() { - this.defaultBidderRequest.refererInfo.stack[0] = ['https://securesite.dvl']; - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaType': 'banner', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]], - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - const openrtbRequest = JSON.parse(bidRequest.data); - - expect(openrtbRequest.imp[0].secure).to.equal(1); - }); - - it('should pass schain', function() { - var schain = { - 'ver': '1.0', - 'complete': 1, - 'nodes': [{ - 'asi': 'indirectseller.com', - 'sid': '00001', - 'hp': 1 - }, { - 'asi': 'indirectseller-2.com', - 'sid': '00002', - 'hp': 1 - }] - }; - var bidRequestList = [ - { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaType': 'banner', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]], - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead', - 'schain': schain - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - const openrtbRequest = JSON.parse(bidRequest.data); - - expect(openrtbRequest.source.ext.schain).to.deep.equal(schain); - }); - - describe('misc interpretResponse', function () { - it('No bid response', function() { - var noBidResponse = r1adapter.interpretResponse({ - 'body': '' - }); - expect(noBidResponse.length).to.equal(0); - }); - }); - - describe('isBidRequestValid', function () { - var bid = { - 'bidder': 'resultsmedia', - 'params': { - 'zoneId': 9999 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': 'bannerDiv' - }; - - it('should return true when required params found', function () { - expect(r1adapter.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when placementId missing', function () { - delete bid.params.zoneId; - expect(r1adapter.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('getUserSyncs', function () { - it('returns an empty string', function () { - expect(r1adapter.getUserSyncs()).to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/riseBidAdapter_spec.js b/test/spec/modules/riseBidAdapter_spec.js deleted file mode 100644 index b3257cbda9d..00000000000 --- a/test/spec/modules/riseBidAdapter_spec.js +++ /dev/null @@ -1,381 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/riseBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import { config } from 'src/config.js'; -import { VIDEO } from '../../../src/mediaTypes.js'; - -const ENDPOINT = 'https://hb.yellowblue.io/hb'; -const TEST_ENDPOINT = 'https://hb.yellowblue.io/hb-test'; -const TTL = 360; - -describe('riseAdapter', 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': spec.code, - 'adUnitCode': 'adunit-code', - 'sizes': [['640', '480']], - 'params': { - 'org': 'jdye8weeyirk00000001' - } - }; - - it('should return true when required params are passed', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not found', function () { - const newBid = Object.assign({}, bid); - delete newBid.params; - newBid.params = { - 'org': null - }; - expect(spec.isBidRequestValid(newBid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { - 'bidder': spec.code, - 'adUnitCode': 'adunit-code', - 'sizes': [[640, 480]], - 'params': { - 'org': 'jdye8weeyirk00000001' - }, - 'bidId': '299ffc8cca0b87', - 'bidderRequestId': '1144f487e563f9', - 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', - } - ]; - - const testModeBidRequests = [ - { - 'bidder': spec.code, - 'adUnitCode': 'adunit-code', - 'sizes': [[640, 480]], - 'params': { - 'org': 'jdye8weeyirk00000001', - 'testMode': true - }, - 'bidId': '299ffc8cca0b87', - 'bidderRequestId': '1144f487e563f9', - 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', - } - ]; - - const bidderRequest = { - bidderCode: 'rise', - } - - const customSessionId = '12345678'; - - it('sends bid request to ENDPOINT via GET', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('GET'); - } - }); - - it('sends the is_wrapper query param', function () { - bidRequests[0].params.isWrapper = true; - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data.is_wrapper).to.equal(true); - } - }); - - it('sends the custom session id as a query param', function () { - bidRequests[0].params.sessionId = customSessionId; - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data.session_id).to.equal(customSessionId); - } - }); - - it('sends bid request to test ENDPOINT via GET', function () { - const requests = spec.buildRequests(testModeBidRequests, bidderRequest); - for (const request of requests) { - expect(request.url).to.equal(TEST_ENDPOINT); - expect(request.method).to.equal('GET'); - } - }); - - it('should send the correct bid Id', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data.bid_id).to.equal('299ffc8cca0b87'); - } - }); - - it('should send the correct width and height', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('width', 640); - expect(request.data).to.have.property('height', 480); - } - }); - - it('should respect syncEnabled option', function() { - config.setConfig({ - userSync: { - syncEnabled: false, - filterSettings: { - all: { - bidders: '*', - filter: 'include' - } - } - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.not.have.property('cs_method'); - } - }); - - it('should respect "iframe" filter settings', function () { - config.setConfig({ - userSync: { - syncEnabled: true, - filterSettings: { - iframe: { - bidders: [spec.code], - filter: 'include' - } - } - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('cs_method', 'iframe'); - } - }); - - it('should respect "all" filter settings', function () { - config.setConfig({ - userSync: { - syncEnabled: true, - filterSettings: { - all: { - bidders: [spec.code], - filter: 'include' - } - } - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('cs_method', 'iframe'); - } - }); - - it('should send the pixel user sync param if userSync is enabled and no "iframe" or "all" configs are present', function () { - config.setConfig({ - userSync: { - syncEnabled: true - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('cs_method', 'pixel'); - } - }); - - it('should respect total exclusion', function() { - config.setConfig({ - userSync: { - syncEnabled: true, - filterSettings: { - image: { - bidders: [spec.code], - filter: 'exclude' - }, - iframe: { - bidders: [spec.code], - filter: 'exclude' - } - } - } - }); - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.not.have.property('cs_method'); - } - }); - - it('should have us_privacy param if usPrivacy is available in the bidRequest', function () { - const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); - const requests = spec.buildRequests(bidRequests, bidderRequestWithUSP); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('us_privacy', '1YNN'); - } - }); - - it('should have an empty us_privacy param if usPrivacy is missing in the bidRequest', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.not.have.property('us_privacy'); - } - }); - - it('should not send the gdpr param if gdprApplies is false in the bidRequest', function () { - const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: false}}, bidderRequest); - const requests = spec.buildRequests(bidRequests, bidderRequestWithGDPR); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.not.have.property('gdpr'); - expect(request.data).to.not.have.property('gdpr_consent'); - } - }); - - it('should send the gdpr param if gdprApplies is true in the bidRequest', function () { - const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}}, bidderRequest); - const requests = spec.buildRequests(bidRequests, bidderRequestWithGDPR); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('gdpr', true); - expect(request.data).to.have.property('gdpr_consent', 'test-consent-string'); - } - }); - - it('should have schain param if it is available in the bidRequest', () => { - const schain = { - ver: '1.0', - complete: 1, - nodes: [{ asi: 'indirectseller.com', sid: '00001', hp: 1 }], - }; - bidRequests[0].schain = schain; - const requests = spec.buildRequests(bidRequests, bidderRequest); - for (const request of requests) { - expect(request.data).to.be.an('object'); - expect(request.data).to.have.property('schain', '1.0,1!indirectseller.com,00001,,,,'); - } - }); - }); - - describe('interpretResponse', function () { - const response = { - cpm: 12.5, - vastXml: '', - width: 640, - height: 480, - requestId: '21e12606d47ba7', - netRevenue: true, - currency: 'USD' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - requestId: '21e12606d47ba7', - cpm: 12.5, - width: 640, - height: 480, - creativeId: '21e12606d47ba7', - currency: 'USD', - netRevenue: true, - ttl: TTL, - vastXml: '', - mediaType: VIDEO - } - ]; - const result = spec.interpretResponse({ body: response }); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - }) - - describe('getUserSyncs', function() { - const imageSyncResponse = { - body: { - userSyncPixels: [ - 'https://image-sync-url.test/1', - 'https://image-sync-url.test/2', - 'https://image-sync-url.test/3' - ] - } - }; - - const iframeSyncResponse = { - body: { - userSyncURL: 'https://iframe-sync-url.test' - } - }; - - it('should register all img urls from the response', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: true }, [imageSyncResponse]); - expect(syncs).to.deep.equal([ - { - type: 'image', - url: 'https://image-sync-url.test/1' - }, - { - type: 'image', - url: 'https://image-sync-url.test/2' - }, - { - type: 'image', - url: 'https://image-sync-url.test/3' - } - ]); - }); - - it('should register the iframe url from the response', function() { - const syncs = spec.getUserSyncs({ iframeEnabled: true }, [iframeSyncResponse]); - expect(syncs).to.deep.equal([ - { - type: 'iframe', - url: 'https://iframe-sync-url.test' - } - ]); - }); - - it('should register both image and iframe urls from the responses', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [iframeSyncResponse, imageSyncResponse]); - expect(syncs).to.deep.equal([ - { - type: 'iframe', - url: 'https://iframe-sync-url.test' - }, - { - type: 'image', - url: 'https://image-sync-url.test/1' - }, - { - type: 'image', - url: 'https://image-sync-url.test/2' - }, - { - type: 'image', - url: 'https://image-sync-url.test/3' - } - ]); - }); - - it('should handle an empty response', function() { - const syncs = spec.getUserSyncs({ iframeEnabled: true }, []); - expect(syncs).to.deep.equal([]); - }); - - it('should handle when user syncs are disabled', function() { - const syncs = spec.getUserSyncs({ pixelEnabled: false }, [imageSyncResponse]); - expect(syncs).to.deep.equal([]); - }); - }) -}); diff --git a/test/spec/modules/rtbsapeBidAdapter_spec.js b/test/spec/modules/rtbsapeBidAdapter_spec.js deleted file mode 100644 index 4c3814385b3..00000000000 --- a/test/spec/modules/rtbsapeBidAdapter_spec.js +++ /dev/null @@ -1,166 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/rtbsapeBidAdapter.js'; -import * as utils from 'src/utils.js'; -import {executeRenderer, Renderer} from 'src/Renderer.js'; - -describe('rtbsapeBidAdapterTests', function () { - describe('isBidRequestValid', function () { - it('valid', function () { - expect(spec.isBidRequestValid({bidder: 'rtbsape', mediaTypes: {banner: true}, params: {placeId: 4321}})).to.equal(true); - expect(spec.isBidRequestValid({bidder: 'rtbsape', mediaTypes: {video: true}, params: {placeId: 4321}})).to.equal(true); - }); - - it('invalid', function () { - expect(spec.isBidRequestValid({bidder: 'rtbsape', mediaTypes: {banner: true}, params: {}})).to.equal(false); - expect(spec.isBidRequestValid({bidder: 'rtbsape', params: {placeId: 4321}})).to.equal(false); - }); - }); - - it('buildRequests', function () { - let bidRequestData = [{ - bidId: 'bid1234', - bidder: 'rtbsape', - params: {placeId: 4321}, - sizes: [[240, 400]] - }]; - let bidderRequest = { - auctionId: '2e208334-cafe-4c2c-b06b-f055ff876852', - bidderRequestId: '1392d0aa613366', - refererInfo: {} - }; - let request = spec.buildRequests(bidRequestData, bidderRequest); - expect(request.data.auctionId).to.equal('2e208334-cafe-4c2c-b06b-f055ff876852'); - expect(request.data.requestId).to.equal('1392d0aa613366'); - expect(request.data.bids[0].bidId).to.equal('bid1234'); - expect(request.data.timezone).to.not.equal(undefined); - }); - - describe('interpretResponse', function () { - it('banner', function () { - let serverResponse = { - body: { - bids: [{ - requestId: 'bid1234', - cpm: 2.21, - currency: 'RUB', - width: 240, - height: 400, - netRevenue: true, - ad: 'Ad html' - }] - } - }; - let bids = spec.interpretResponse(serverResponse, {data: {bids: [{mediaTypes: {banner: true}}]}}); - expect(bids).to.have.lengthOf(1); - let bid = bids[0]; - expect(bid.cpm).to.equal(2.21); - expect(bid.currency).to.equal('RUB'); - expect(bid.width).to.equal(240); - expect(bid.height).to.equal(400); - expect(bid.netRevenue).to.equal(true); - expect(bid.requestId).to.equal('bid1234'); - expect(bid.ad).to.equal('Ad html'); - }); - - describe('video (outstream)', function () { - let bid; - - before(() => { - let serverResponse = { - body: { - bids: [{ - requestId: 'bid1234', - adUnitCode: 'ad-bid1234', - cpm: 3.32, - currency: 'RUB', - width: 600, - height: 340, - netRevenue: true, - vastUrl: 'https://cdn-rtb.sape.ru/vast/4321.xml', - meta: { - mediaType: 'video' - } - }] - } - }; - let serverRequest = { - data: { - bids: [{ - bidId: 'bid1234', - adUnitCode: 'ad-bid1234', - mediaTypes: { - video: { - context: 'outstream' - } - }, - params: { - placeId: 4321, - video: { - playerMuted: false - } - } - }] - } - }; - let bids = spec.interpretResponse(serverResponse, serverRequest); - expect(bids).to.have.lengthOf(1); - bid = bids[0]; - }); - - it('should add renderer', () => { - expect(bid).to.have.own.property('renderer'); - expect(bid.renderer).to.be.instanceof(Renderer); - expect(bid.renderer.url).to.equal('https://cdn-rtb.sape.ru/js/player.js'); - expect(bid.playerMuted).to.equal(false); - }); - - it('should create player instance', () => { - let spy = false; - - window.sapeRtbPlayerHandler = function (id, w, h, m) { - const player = {addSlot: () => [id, w, h, m]} - expect(spy).to.equal(false); - spy = sinon.spy(player, 'addSlot'); - return player; - }; - - executeRenderer(bid.renderer, bid); - expect(spy).to.not.equal(false); - expect(spy.called).to.be.true; - - const spyCall = spy.getCall(0); - expect(spyCall.args[0].url).to.be.equal('https://cdn-rtb.sape.ru/vast/4321.xml'); - expect(spyCall.returnValue[0]).to.be.equal('ad-bid1234'); - expect(spyCall.returnValue[1]).to.be.equal(600); - expect(spyCall.returnValue[2]).to.be.equal(340); - expect(spyCall.returnValue[3]).to.be.equal(false); - }); - }); - }); - - it('getUserSyncs', function () { - const syncs = spec.getUserSyncs({iframeEnabled: true}); - expect(syncs).to.be.an('array').that.to.have.lengthOf(1); - expect(syncs[0]).to.deep.equal({type: 'iframe', url: 'https://www.acint.net/mc/?dp=141'}); - }); - - describe('onBidWon', function () { - beforeEach(function () { - sinon.stub(utils, 'triggerPixel'); - }); - - afterEach(function () { - utils.triggerPixel.restore(); - }); - - it('called once', function () { - spec.onBidWon({cpm: '2.21', nurl: 'https://ssp-rtb.sape.ru/track?event=win'}); - expect(utils.triggerPixel.calledOnce).to.equal(true); - }); - - it('called false', function () { - spec.onBidWon({cpm: '2.21'}); - expect(utils.triggerPixel.called).to.equal(false); - }); - }); -}); diff --git a/test/spec/modules/rtbsolutionsBidAdapter_spec.js b/test/spec/modules/rtbsolutionsBidAdapter_spec.js deleted file mode 100644 index c47b086fe50..00000000000 --- a/test/spec/modules/rtbsolutionsBidAdapter_spec.js +++ /dev/null @@ -1,62 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/rtbsolutionsBidAdapter.js'; - -describe('rtbsolutionsBidAdapterTests', function () { - it('validate_pub_params_1', function () { - expect(spec.isBidRequestValid({ - bidder: 'rtbsolutions', - params: { - blockId: 777 - } - })).to.equal(true); - }); - it('validate_pub_params_2', function () { - expect(spec.isBidRequestValid({ - bidder: 'rtbsolutions', - params: { - s1: 'test' - } - })).to.equal(false); - }); - it('validate_generated_params', function () { - let bidderRequest = { - bids: [], - refererInfo: { - referer: '' - } - }; - bidderRequest.bids.push({ - bidId: 'bid1234', - bidder: 'rtbsolutions', - params: {blockId: 777}, - sizes: [[240, 400]] - }); - let request = spec.buildRequests(true, bidderRequest); - let req_data = request.data[0]; - expect(req_data.bid_id).to.equal('bid1234'); - }); - it('validate_response_params', function () { - let serverResponse = { - body: [{ - ad: 'Ad html', - bid_id: 'bid1234', - cpm: 1, - creative_id: 1, - height: 480, - nurl: 'http://test.test', - width: 640, - currency: 'USD', - }] - }; - let bids = spec.interpretResponse(serverResponse); - expect(bids).to.have.lengthOf(1); - let bid = bids[0]; - expect(bid.cpm).to.equal(1); - expect(bid.currency).to.equal('USD'); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(480); - expect(bid.netRevenue).to.equal(true); - expect(bid.requestId).to.equal('bid1234'); - expect(bid.ad).to.equal('Ad html'); - }); -}); diff --git a/test/spec/modules/seedingAllianceAdapter_spec.js b/test/spec/modules/seedingAllianceAdapter_spec.js deleted file mode 100755 index 81af9546ff0..00000000000 --- a/test/spec/modules/seedingAllianceAdapter_spec.js +++ /dev/null @@ -1,186 +0,0 @@ -// jshint esversion: 6, es3: false, node: true -import {assert, expect} from 'chai'; -import {spec} from 'modules/seedingAllianceBidAdapter.js'; -import { NATIVE } from 'src/mediaTypes.js'; -import { config } from 'src/config.js'; - -describe('SeedingAlliance adapter', function () { - let serverResponse, bidRequest, bidResponses; - let bid = { - 'bidder': 'seedingAlliance', - 'params': { - 'adUnitId': '1hq8' - } - }; - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - assert(spec.isBidRequestValid(bid)); - }); - - it('should return false when AdUnitId is not set', function () { - delete bid.params.adUnitId; - assert.isFalse(spec.isBidRequestValid(bid)); - }); - }); - - describe('buildRequests', function () { - it('should send request with correct structure', function () { - let validBidRequests = [{ - bidId: 'bidId', - params: {} - }]; - - let request = spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }); - - assert.equal(request.method, 'POST'); - assert.ok(request.data); - }); - - it('should have default request structure', function () { - let keys = 'site,device,cur,imp,user,regs'.split(','); - let validBidRequests = [{ - bidId: 'bidId', - params: {} - }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); - let data = Object.keys(request); - - assert.deepEqual(keys, data); - }); - - it('Verify the auction ID', function () { - let validBidRequests = [{ - bidId: 'bidId', - params: {}, - auctionId: 'auctionId' - }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' }, auctionId: validBidRequests[0].auctionId }).data); - - assert.equal(request.id, validBidRequests[0].auctionId); - }); - - it('Verify the device', function () { - let validBidRequests = [{ - bidId: 'bidId', - params: {} - }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); - - assert.equal(request.device.ua, navigator.userAgent); - }); - - it('Verify native asset ids', function () { - let validBidRequests = [{ - bidId: 'bidId', - params: {}, - nativeParams: { - body: { - required: true, - len: 350 - }, - image: { - required: true - }, - title: { - required: true - }, - sponsoredBy: { - required: true - }, - cta: { - required: true - }, - icon: { - required: true - } - } - }]; - - let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; - - assert.equal(assets[0].id, 1); - assert.equal(assets[1].id, 3); - assert.equal(assets[2].id, 0); - assert.equal(assets[3].id, 2); - assert.equal(assets[4].id, 4); - assert.equal(assets[5].id, 5); - }); - }); - - describe('interpretResponse', function () { - const goodResponse = { - body: { - cur: 'EUR', - id: '4b516b80-886e-4ec0-82ae-9209e6d625fb', - seatbid: [ - { - seat: 'seedingAlliance', - bid: [{ - adm: { - native: { - assets: [ - {id: 0, title: {text: 'this is a title'}} - ], - imptrackers: ['https://domain.for/imp/tracker?price=${AUCTION_PRICE}'], - link: { - clicktrackers: ['https://domain.for/imp/tracker?price=${AUCTION_PRICE}'], - url: 'https://domain.for/ad/' - } - } - }, - impid: 1, - price: 0.55 - }] - } - ] - } - }; - const badResponse = { body: { - cur: 'EUR', - id: '4b516b80-886e-4ec0-82ae-9209e6d625fb', - seatbid: [] - }}; - - const bidRequest = { - data: {}, - bids: [{ bidId: 'bidId1' }] - }; - - it('should return null if body is missing or empty', function () { - const result = spec.interpretResponse(badResponse, bidRequest); - assert.equal(result.length, 0); - - delete badResponse.body - - const result1 = spec.interpretResponse(badResponse, bidRequest); - assert.equal(result.length, 0); - }); - - it('should return the correct params', function () { - const result = spec.interpretResponse(goodResponse, bidRequest); - const bid = goodResponse.body.seatbid[0].bid[0]; - - assert.deepEqual(result[0].currency, goodResponse.body.cur); - assert.deepEqual(result[0].requestId, bidRequest.bids[0].bidId); - assert.deepEqual(result[0].cpm, bid.price); - assert.deepEqual(result[0].creativeId, bid.crid); - assert.deepEqual(result[0].mediaType, 'native'); - assert.deepEqual(result[0].bidderCode, 'seedingAlliance'); - }); - - it('should return the correct tracking links', function () { - const result = spec.interpretResponse(goodResponse, bidRequest); - const bid = goodResponse.body.seatbid[0].bid[0]; - const regExpPrice = new RegExp('price=' + bid.price); - - result[0].native.clickTrackers.forEach(function (clickTracker) { - assert.ok(clickTracker.search(regExpPrice) > -1); - }); - - result[0].native.impressionTrackers.forEach(function (impTracker) { - assert.ok(impTracker.search(regExpPrice) > -1); - }); - }); - }); -}); diff --git a/test/spec/modules/segmentoBidAdapter_spec.js b/test/spec/modules/segmentoBidAdapter_spec.js deleted file mode 100644 index 17ad424f73f..00000000000 --- a/test/spec/modules/segmentoBidAdapter_spec.js +++ /dev/null @@ -1,187 +0,0 @@ -import { expect } from 'chai'; -import { spec } from '../../../modules/segmentoBidAdapter.js'; - -const BIDDER_CODE = 'segmento'; -const URL = 'https://prebid-bidder.rutarget.ru/bid'; -const SYNC_IFRAME_URL = 'https://tag.rutarget.ru/tag?event=otherPage&check=true&response=syncframe&synconly=true'; -const SYNC_IMAGE_URL = 'https://tag.rutarget.ru/tag?event=otherPage&check=true&synconly=true'; -const RUB = 'RUB'; -const TIME_TO_LIVE = 0; - -describe('SegmentoAdapter', function () { - describe('isBidRequestValid', function () { - const bid = { - bidder: BIDDER_CODE, - bidId: '51ef8751f9aead', - params: { - placementId: 34 - }, - adUnitCode: 'div-gpt-ad-1460505748561-0', - transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - sizes: [[320, 50], [300, 250], [300, 600]], - bidderRequestId: '418b37f85e772c', - auctionId: '18fd8b8b0bd757' - }; - - it('should return true if placementId is a number', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false if placementId is not a number', function () { - bid.params.placementId = 'placementId'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false if no placementId param', function () { - delete bid.params.placementId; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bids = [{ - bidder: 'segmento', - bidId: '51ef8751f9aead', - params: { - placementId: 34 - }, - adUnitCode: 'div-gpt-ad-1460505748561-0', - transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - sizes: [[320, 50], [300, 250], [300, 600]], - bidderRequestId: '418b37f85e772c', - auctionId: '18fd8b8b0bd757' - }]; - - const bidderRequest = { - refererInfo: { - referer: 'https://comepage.com' - } - }; - - const request = spec.buildRequests(bids, bidderRequest); - it('should return POST method', function () { - expect(request.method).to.equal('POST'); - }); - - it('should return valid url', function () { - expect(request.url).to.equal(URL); - }); - - it('should return valid data', function () { - const data = request.data; - expect(data).to.have.all.keys('settings', 'places'); - expect(data.settings.currency).to.be.equal(RUB); - expect(data.settings.referrer).to.be.a('string'); - expect(data.settings.referrer).to.be.equal(bidderRequest.refererInfo.referer); - const places = data.places; - for (let i = 0; i < places.length; i++) { - const place = places[i]; - const bid = bids[i]; - expect(place).to.have.all.keys('id', 'placementId', 'sizes'); - expect(place.id).to.be.a('string'); - expect(place.id).to.be.equal(bid.bidId); - expect(place.placementId).to.be.a('number'); - expect(place.placementId).to.be.equal(bid.params.placementId); - expect(place.sizes).to.be.an('array'); - expect(place.sizes).to.deep.equal(bid.sizes); - } - }); - - it('should return empty places if no valid bids are passed', function () { - const request = spec.buildRequests([], {}); - expect(request.data.places).to.be.an('array').to.deep.equal([]); - }); - }); - - describe('interpretResponse', function() { - const serverResponse = { - body: { - bids: [{ - id: '51ef8751f9aead', - cpm: 0.23, - currency: RUB, - creativeId: 123, - displayUrl: 'displayUrl?t=123&p=456', - size: { - width: 300, - height: 250 - } - }] - } - }; - - const emptyServerResponse = { - body: { - bids: [] - } - }; - - it('should return valid data', function () { - const response = spec.interpretResponse(serverResponse); - expect(response).to.be.an('array'); - for (let i = 0; i < response.length; i++) { - const item = response[i]; - const bid = serverResponse.body.bids[i]; - expect(item).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'creativeId', - 'currency', 'netRevenue', 'ttl', 'adUrl'); - expect(item.requestId).to.be.a('string'); - expect(item.requestId).to.be.equal(bid.id); - expect(item.cpm).to.be.a('number'); - expect(item.cpm).to.be.equal(bid.cpm); - expect(item.width).to.be.a('number'); - expect(item.width).to.be.equal(bid.size.width); - expect(item.height).to.be.a('number'); - expect(item.height).to.be.equal(bid.size.height); - expect(item.creativeId).to.be.a('number'); - expect(item.creativeId).to.be.equal(bid.creativeId); - expect(item.currency).to.be.a('string'); - expect(item.currency).to.be.equal(bid.currency); - expect(item.netRevenue).to.be.a('boolean'); - expect(item.netRevenue).to.equal(true); - expect(item.ttl).to.be.a('number'); - expect(item.ttl).to.be.equal(TIME_TO_LIVE); - expect(item.adUrl).to.be.a('string'); - expect(item.adUrl).to.be.equal(bid.displayUrl); - } - }); - - it('should return empty array if no bids', function () { - const response = spec.interpretResponse(emptyServerResponse); - expect(response).to.be.an('array').to.deep.equal([]); - }); - - it('should return empty array if server response is invalid', function () { - const response = spec.interpretResponse({}); - expect(response).to.be.an('array').to.deep.equal([]); - }); - }); - - describe('getUserSyncs', function() { - it('should return iframe type if iframe enabled', function () { - const syncs = spec.getUserSyncs({ iframeEnabled: true }); - const sync = syncs[0]; - expect(syncs).to.be.an('array').with.lengthOf(1); - expect(sync).to.have.all.keys('type', 'url'); - expect(sync.type).to.be.a('string'); - expect(sync.type).to.be.equal('iframe'); - expect(sync.url).to.be.a('string'); - expect(sync.url).to.be.equal(SYNC_IFRAME_URL); - }); - - it('should return iframe type if iframe disabled, but image enable', function () { - const syncs = spec.getUserSyncs({ pixelEnabled: true }); - const sync = syncs[0]; - expect(syncs).to.be.an('array').with.lengthOf(1); - expect(sync).to.have.all.keys('type', 'url'); - expect(sync.type).to.be.a('string'); - expect(sync.type).to.be.equal('image'); - expect(sync.url).to.be.a('string'); - expect(sync.url).to.be.equal(SYNC_IMAGE_URL); - }); - - it('should return empty array if iframe and pixels disabled', function () { - const syncs = spec.getUserSyncs({}); - expect(syncs).to.be.an('array').to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/shinezBidAdapter_spec.js b/test/spec/modules/shinezBidAdapter_spec.js deleted file mode 100644 index cc3c2451c5d..00000000000 --- a/test/spec/modules/shinezBidAdapter_spec.js +++ /dev/null @@ -1,152 +0,0 @@ -import { expect } from 'chai'; -import sinon from 'sinon'; -import { spec, internal } from 'modules/shinezBidAdapter.js'; - -describe('shinezBidAdapter', () => { - let sandbox; - beforeEach(() => { - sandbox = sinon.sandbox.create(); - }); - afterEach(() => { - sandbox.restore(); - }); - describe('isBidRequestValid', () => { - const cases = [ - [ - 'should return false when placementId is missing', - { - params: {}, - }, - false, - ], - [ - 'should return false when placementId has wrong type', - { - params: { - placementId: 123, - }, - }, - false, - ], - [ - 'should return false when unit has wrong type', - { - params: { - placementId: '00654321', - unit: 150, - }, - }, - false, - ], - [ - 'should return true when required params found and valid', - { - params: { - placementId: '00654321', - }, - }, - true, - ], - [ - 'should return true when all params found and valid', - { - params: { - placementId: '00654321', - unit: '__header-bid-1', - }, - }, - true, - ], - ]; - cases.map(([description, request, expected]) => { - it(description, () => { - const result = spec.isBidRequestValid(request); - expect(result).to.be.equal(expected); - }); - }); - }); - describe('buildRequests', () => { - it('should build server request correctly', () => { - const utcOffset = 300; - const validBidRequests = [ - { - params: { - placementId: '00654321', - unit: 'header-bid-tag-1-shinez', - }, - crumbs: { - pubcid: 'c8584a82-bec3-4347-8d3e-e7612438a161', - }, - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - adUnitCode: 'header-bid-tag-1', - transactionId: '665760dc-a249-4be7-ae86-91f417b2c65d', - }, - ]; - const bidderRequest = { - refererInfo: { - referer: 'http://site-with-ads.com', - }, - }; - sandbox.stub(Date.prototype, 'getTimezoneOffset').returns(utcOffset); - const result = spec.buildRequests(validBidRequests, bidderRequest); - const expectedData = [ - { - bidId: validBidRequests[0].bidId, - transactionId: validBidRequests[0].transactionId, - crumbs: validBidRequests[0].crumbs, - mediaTypes: validBidRequests[0].mediaTypes, - refererInfo: bidderRequest.refererInfo, - adUnitCode: validBidRequests[0].adUnitCode, - utcOffset: utcOffset, - placementId: validBidRequests[0].params.placementId, - unit: validBidRequests[0].params.unit, - }, - ]; - expect(result.method, "request should be POST'ed").equal('POST'); - expect(result.url, 'request should be send to correct url').equal( - internal.TARGET_URL - ); - expect(result.data, 'request should have correct payload').to.deep.equal( - expectedData - ); - }); - }); - describe('interpretResponse', () => { - it('should interpret bid responses correctly', () => { - const response = { - body: [ - { - bidId: '2ece6496f4d0c9', - cpm: 0.03, - currency: 'USD', - width: 300, - height: 250, - ad: `

The Ad

`, - ttl: 60, - creativeId: 'V8qlA6guwm', - netRevenue: true, - }, - ], - }; - const bids = [ - { - requestId: response.body[0].bidId, - cpm: response.body[0].cpm, - currency: response.body[0].currency, - width: response.body[0].width, - height: response.body[0].height, - ad: response.body[0].ad, - ttl: response.body[0].ttl, - creativeId: response.body[0].creativeId, - netRevenue: response.body[0].netRevenue, - }, - ]; - const result = spec.interpretResponse(response); - expect(result).to.deep.equal(bids); - }); - }); -}); diff --git a/test/spec/modules/slimcutBidAdapter_spec.js b/test/spec/modules/slimcutBidAdapter_spec.js deleted file mode 100644 index 44da1d87824..00000000000 --- a/test/spec/modules/slimcutBidAdapter_spec.js +++ /dev/null @@ -1,212 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/slimcutBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -const ENDPOINT = 'https://sb.freeskreen.com/pbr'; -const AD_SCRIPT = '"'; - -describe('slimcutBidAdapter', 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': 'slimcut', - 'params': { - 'placementId': 83 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '3c871ffa8ef14c', - 'bidderRequestId': 'b41642f1aee381', - 'auctionId': '4e156668c977d7' - }; - - it('should return true when required params found', function() { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when placementId is not valid (letters)', function() { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 'ABCD' - }; - - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when placementId < 0', function() { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': -1 - }; - - 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': 'teads', - 'params': { - 'placementId': 10433394 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '3c871ffa8ef14c', - 'bidderRequestId': 'b41642f1aee381', - 'auctionId': '4e156668c977d7', - 'deviceWidth': 1680 - } - ]; - - let bidderResquestDefault = { - 'auctionId': '4e156668c977d7', - 'bidderRequestId': 'b41642f1aee381', - 'timeout': 3000 - }; - - it('sends bid request to ENDPOINT via POST', function() { - const request = spec.buildRequests(bidRequests, bidderResquestDefault); - - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('POST'); - }); - - it('should send GDPR to endpoint', function() { - let consentString = 'JRJ8RKfDeBNsERRDCSAAZ+A=='; - let bidderRequest = { - 'auctionId': '4e156668c977d7', - 'bidderRequestId': 'b41642f1aee381', - 'timeout': 3000, - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true, - 'vendorData': { - 'hasGlobalConsent': false - } - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.gdpr_iab).to.exist; - expect(payload.gdpr_iab.consent).to.equal(consentString); - }); - - it('should add referer info to payload', function () { - const bidRequest = Object.assign({}, bidRequests[0]) - const bidderRequest = { - refererInfo: { - referer: 'https://example.com/page.html', - reachedTop: true, - numIframes: 2 - } - } - const request = spec.buildRequests([bidRequest], bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.referrer).to.exist; - expect(payload.referrer).to.deep.equal('https://example.com/page.html') - }); - }); - - describe('getUserSyncs', () => { - let bids = { - 'body': { - 'responses': [{ - 'ad': AD_SCRIPT, - 'cpm': 0.5, - 'currency': 'USD', - 'height': 250, - 'netRevenue': true, - 'requestId': '3ede2a3fa0db94', - 'ttl': 360, - 'width': 300, - 'creativeId': 'er2ee', - 'transactionId': 'deadb33f', - 'winUrl': 'https://sb.freeskreen.com/win' - }] - } - }; - - 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('https://sb.freeskreen.com/async_usersync.html'); - }); - - it('should return no url if not iframe enabled', () => { - let urls = spec.getUserSyncs({iframeEnabled: false}, bids); - expect(urls.length).to.equal(0); - }); - }); - - describe('interpretResponse', function() { - let bids = { - 'body': { - 'responses': [{ - 'ad': AD_SCRIPT, - 'cpm': 0.5, - 'currency': 'USD', - 'height': 250, - 'netRevenue': true, - 'requestId': '3ede2a3fa0db94', - 'ttl': 360, - 'width': 300, - 'creativeId': 'er2ee', - 'transactionId': 'deadb33f', - 'winUrl': 'https://sb.freeskreen.com/win' - }] - } - }; - - it('should get correct bid response', function() { - let expectedResponse = [{ - 'cpm': 0.5, - 'width': 300, - 'height': 250, - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - 'ad': AD_SCRIPT, - 'requestId': '3ede2a3fa0db94', - 'creativeId': 'er2ee', - 'transactionId': 'deadb33f', - 'winUrl': 'https://sb.freeskreen.com/win' - }]; - - let result = spec.interpretResponse(bids); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function() { - let bids = { - 'body': { - 'responses': [] - } - }; - - let result = spec.interpretResponse(bids); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/smarticoBidAdapter_spec.js b/test/spec/modules/smarticoBidAdapter_spec.js deleted file mode 100644 index e8ca5b0e127..00000000000 --- a/test/spec/modules/smarticoBidAdapter_spec.js +++ /dev/null @@ -1,118 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/smarticoBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -describe('smarticoBidAdapter', function () { - const adapter = newBidder(spec); - let bid = { - adUnitCode: 'adunit-code', - auctionId: '5kaj89l8-3456-2s56-c455-4g6h78jsdfgf', - bidRequestsCount: 1, - bidder: 'smartico', - bidderRequestId: '24081afs940568', - bidderRequestsCount: 1, - bidderWinsCount: 0, - bidId: '22499d052045', - mediaTypes: {banner: {sizes: [[300, 250]]}}, - params: { - token: 'FNVzUGZn9ebpIOoheh3kEJ2GQ6H6IyMH39sHXaya', - placementId: 'testPlacementId' - }, - sizes: [ - [300, 250] - ], - transactionId: '34562345-4dg7-46g7-4sg6-45gdsdj8fd56' - } - let bidderRequests = { - auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', - auctionStart: 1579746300522, - bidderCode: 'myBidderCode', - bidderRequestId: '15246a574e859f', - bids: [bid], - refererInfo: { - canonicalUrl: '', - numIframes: 0, - reachedTop: true - } - } - describe('isBidRequestValid', function () { - it('should return true where required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - describe('buildRequests', function () { - let bidRequests = [ bid ]; - let request = spec.buildRequests(bidRequests, bidderRequests); - it('sends bid request via POST', function () { - expect(request.method).to.equal('POST'); - }); - it('must contain token', function() { - expect(request.data.bidParams[0].token).to.equal('FNVzUGZn9ebpIOoheh3kEJ2GQ6H6IyMH39sHXaya'); - }); - it('must contain auctionId', function() { - expect(request.data.auctionId).to.exist.and.to.be.a('string') - }); - it('must contain valid width and height', function() { - expect(request.data.bidParams[0]['banner-format-width']).to.exist.and.to.be.a('number') - expect(request.data.bidParams[0]['banner-format-height']).to.exist.and.to.be.a('number') - }); - }); - - describe('interpretResponse', function () { - let bidRequest = { - method: 'POST', - url: 'https://trmads.eu/preBidRequest', - bids: [bid], - data: [{ - token: 'FNVzUGZn9ebpIOoheh3kEJ2GQ6H6IyMH39sHXaya', - bidId: '22499d052045', - 'banner-format-width': 300, - 'banner-format-height': 250, - placementId: 'testPlacementId', - }] - }; - let serverResponse = [{ - bidId: '22499d052045', - id: 987654, - cpm: 10, - ttl: 30, - bannerFormatWidth: 300, - bannerFormatHeight: 250, - bannerFormatAlias: 'medium_rectangle' - }]; - let expectedResponse = [{ - requestId: bid.bidId, - cpm: 10, - width: 300, - height: 250, - creativeId: 987654, - netRevenue: false, // gross - ttl: 30, - 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/vmgBidAdapter_spec.js b/test/spec/modules/vmgBidAdapter_spec.js deleted file mode 100644 index 41aa077adc7..00000000000 --- a/test/spec/modules/vmgBidAdapter_spec.js +++ /dev/null @@ -1,98 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/vmgBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('VmgAdapter', 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 bidRequest = { - adUnitCode: 'div-0', - auctionId: 'd69cdd3f-75e3-42dc-b313-e54c0a99c757', - bidId: '280e2eb8ac3891', - bidRequestsCount: 1, - bidder: 'vmg', - bidderRequestId: '14690d27b056c8', - mediaTypes: { - banner: { - sizes: [ [ 970, 250 ] ] - } - }, - sizes: [ 970, 250 ], - src: 'client', - transactionId: 'af62f065-dfa7-4564-8cb2-d277dc6069f2' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - }) - - describe('buildRequests', function () { - let validBidRequests = [ - { - adUnitCode: 'div-0', - auctionId: 'd69cdd3f-75e3-42dc-b313-e54c0a99c757', - bidId: '280e2eb8ac3891', - bidRequestsCount: 1, - bidder: 'vmg', - bidderRequestId: '14690d27b056c8', - mediaTypes: { - banner: { - sizes: [ [ 970, 250 ] ] - } - }, - sizes: [ 970, 250 ], - src: 'client', - transactionId: 'af62f065-dfa7-4564-8cb2-d277dc6069f2' - } - ]; - - let bidderRequest = { - auctionId: 'd69cdd3f-75e3-42dc-b313-e54c0a99c757', - auctionStart: 1549316149227, - bidderCode: 'vmg', - bidderRequestId: '14690d27b056c8', - refererInfo: { - canonicalUrl: undefined, - numIframes: 0, - reachedTop: true, - referer: 'https://vmg.nyc/public_assets/adapt/prebid.html', - stack: [ 'https://vmg.nyc/public_assets/adapt/prebid.html' ] - }, - start: 1549316149229, - timeout: 1000 - }; - - it('buildRequests fires', function () { - let request = spec.buildRequests(validBidRequests, bidderRequest); - expect(request).to.exist; - expect(request.method).to.equal('POST'); - expect(request.data).to.exist; - }); - }) - - describe('interpretResponse', function () { - let serverResponse = {}; - serverResponse.body = { - 'div-0': ['test'] - }; - - var bidRequest = { - data: '[{"adUnitCode":"div-0","referer":"https://vmg.nyc/public_assets/adapt/prebid.html","bidId":"280e2eb8ac3891"}]', - method: 'POST', - url: 'https://predict.vmg.nyc' - }; - - it('interpresResponse fires', function () { - let bidResponses = spec.interpretResponse(serverResponse, bidRequest); - expect(bidResponses[0].dealId[0]).to.equal('test'); - }); - }); -}); diff --git a/test/spec/modules/welectBidAdapter_spec.js b/test/spec/modules/welectBidAdapter_spec.js deleted file mode 100644 index 2f2af35eaec..00000000000 --- a/test/spec/modules/welectBidAdapter_spec.js +++ /dev/null @@ -1,211 +0,0 @@ -import { expect } from 'chai'; -import { spec as adapter } from 'modules/welectBidAdapter.js'; - -describe('WelectAdapter', function () { - describe('Check methods existance', function () { - it('exists and is a function', function () { - expect(adapter.isBidRequestValid).to.exist.and.to.be.a('function'); - }); - it('exists and is a function', function () { - expect(adapter.buildRequests).to.exist.and.to.be.a('function'); - }); - it('exists and is a function', function () { - expect(adapter.interpretResponse).to.exist.and.to.be.a('function'); - }); - }); - - describe('Check method isBidRequestValid return', function () { - let bid = { - bidder: 'welect', - params: { - placementId: 'exampleAlias', - domain: 'www.welect.de' - }, - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'instream' - } - }, - }; - let bid2 = { - bidder: 'welect', - params: { - domain: 'www.welect.de' - }, - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 360] - } - }, - }; - - it('should be true', function () { - expect(adapter.isBidRequestValid(bid)).to.be.true; - }); - - it('should be false because the placementId is missing', function () { - expect(adapter.isBidRequestValid(bid2)).to.be.false; - }); - }); - - describe('Check buildRequests method', function () { - // Bids to be formatted - let bid1 = { - bidder: 'welect', - params: { - placementId: 'exampleAlias' - }, - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'instream' - } - }, - bidId: 'abdc' - }; - let bid2 = { - bidder: 'welect', - params: { - placementId: 'exampleAlias', - domain: 'www.welect2.de' - }, - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'instream' - } - }, - bidId: 'abdc', - gdprConsent: { - gdprApplies: 1, - gdprConsent: 'some_string' - } - }; - - let data1 = { - bid_id: 'abdc', - width: 640, - height: 360 - } - - let data2 = { - bid_id: 'abdc', - width: 640, - height: 360, - gdpr_consent: { - gdprApplies: 1, - tcString: 'some_string' - } - } - - // Formatted requets - let request1 = { - method: 'POST', - url: 'https://www.welect.de/api/v2/preflight/exampleAlias', - data: data1, - options: { - contentType: 'application/json', - withCredentials: false, - crossOrigin: true, - } - }; - - let request2 = { - method: 'POST', - url: 'https://www.welect2.de/api/v2/preflight/exampleAlias', - data: data2, - options: { - contentType: 'application/json', - withCredentials: false, - crossOrigin: true, - } - } - - it('defaults to www.welect.de, without gdpr object', function () { - expect(adapter.buildRequests([bid1])).to.deep.equal([request1]); - }) - - it('must return the right formatted requests, with gdpr object', function () { - expect(adapter.buildRequests([bid2])).to.deep.equal([request2]); - }); - }); - - describe('Check interpretResponse method return', function () { - // invalid server response - let unavailableResponse = { - body: { - available: false - } - }; - - let availableResponse = { - body: { - available: true, - bidResponse: { - ad: { - video: 'some vast url' - }, - meta: { - advertiserDomains: [], - }, - cpm: 17, - creativeId: 'svmpreview', - currency: 'EUR', - netRevenue: true, - requestId: 'some bid id', - ttl: 120, - vastUrl: 'some vast url', - height: 640, - width: 320 - } - } - } - // bid Request - let bid = { - data: { - bid_id: 'some bid id', - width: 640, - height: 320, - gdpr_consent: { - gdprApplies: 1, - tcString: 'some_string' - } - }, - method: 'POST', - url: 'https://www.welect.de/api/v2/preflight/exampleAlias', - options: { - contentType: 'application/json', - withCredentials: false, - crossOrigin: true, - } - }; - // Formatted reponse - let result = { - ad: { - video: 'some vast url' - }, - meta: { - advertiserDomains: [] - }, - cpm: 17, - creativeId: 'svmpreview', - currency: 'EUR', - height: 640, - netRevenue: true, - requestId: 'some bid id', - ttl: 120, - vastUrl: 'some vast url', - width: 320 - } - - it('if response reflects unavailability, should be empty', function () { - expect(adapter.interpretResponse(unavailableResponse, bid)).to.deep.equal([]); - }); - - it('if response reflects availability, should equal result', function () { - expect(adapter.interpretResponse(availableResponse, bid)).to.deep.equal([result]) - }) - }); -}); diff --git a/test/spec/modules/windtalkerBidAdapter_spec.js b/test/spec/modules/windtalkerBidAdapter_spec.js deleted file mode 100644 index de123815cb2..00000000000 --- a/test/spec/modules/windtalkerBidAdapter_spec.js +++ /dev/null @@ -1,348 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/windtalkerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('Windtalker Adapter Tests', function () { - const slotConfigs = [{ - placementCode: '/DfpAccount1/slot1', - mediaTypes: { - banner: { - 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', - mediaTypes: { - banner: { - 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', - mediaTypes: { - video: { - playerSize: [[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: 'io.windtalker.apps', - storeUrl: 'https://windtalker.io/apps', - domain: 'windtalker.io' - } - } - }]; - - it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); - 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(window.location.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.000001'); - // 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', - w: 300, - h: 250 - }] - }], - 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('https://windtalkerdisplay.hb.adp3.net/'); - 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('https://windtalkerdisplay.hb.adp3.net/'); - 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: 'https://brand.com/' } - } - }; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - nurl: 'https://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('https://brand.com/')); - expect(nativeBid.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('https://rtb.adx1.com/log'); - }); - - it('Verify Video request', function () { - const request = spec.buildRequests(videoSlotConfig); - expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); - expect(request.method).to.equal('POST'); - const videoRequest = JSON.parse(request.data); - // site object - expect(videoRequest.site).to.not.equal(null); - expect(videoRequest.site.publisher.id).to.equal('29521'); - expect(videoRequest.site.ref).to.equal(window.top.document.referrer); - expect(videoRequest.site.page).to.equal(window.location.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: 'https://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('https://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('windtalker'); - }); - - 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.windtalker.apps'); - expect(ortbRequest.app.storeurl).to.equal('https://windtalker.io/apps'); - expect(ortbRequest.app.domain).to.equal('windtalker.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('https://windtalkerdisplay.hb.adp3.net/'); - 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/wipesBidAdapter_spec.js b/test/spec/modules/wipesBidAdapter_spec.js deleted file mode 100644 index c453eca82c5..00000000000 --- a/test/spec/modules/wipesBidAdapter_spec.js +++ /dev/null @@ -1,150 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/wipesBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -const ENDPOINT_URL = 'https://adn-srv.reckoner-api.com/v1/prebid'; - -describe('wipesBidAdapter', function () { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'wipes', - 'params': { - asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' - }, - 'adUnitCode': 'adunit-code', - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '15246a574e859f', - 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when asid not passed correctly', function () { - bid.params.asid = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'wipes', - 'params': { - asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' - }, - 'adUnitCode': 'adunit-code', - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '15246a574e859f', - 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', - }, - { - 'bidder': 'wipes', - 'params': { - asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' - }, - 'adUnitCode': 'adunit-code2', - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '15246a574e859f', - 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', - } - ]; - - let bidderRequest = { - refererInfo: { - numIframes: 0, - reachedTop: true, - referer: 'http://example.com', - stack: ['http://example.com'] - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - - it('sends bid request to our endpoint via GET', function () { - expect(request[0].method).to.equal('GET'); - expect(request[1].method).to.equal('GET'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request[0].url).to.equal(ENDPOINT_URL); - expect(request[1].url).to.equal(ENDPOINT_URL); - }); - - it('adUnitCode should be sent as uc parameters on any requests', function () { - expect(request[0].data.asid).to.equal('dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ'); - expect(request[1].data.asid).to.equal('dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ'); - }); - }); - - describe('interpretResponse', function () { - let bidRequestVideo = [ - { - 'method': 'GET', - 'url': ENDPOINT_URL, - 'data': { - 'asid': 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ', - 'bid_id': '23beaa6af6cdde', - } - } - ]; - - let serverResponseVideo = { - body: { - 'uuid': 'a42947f8-f8fd-4cf7-bb72-31a87ab1f6ff', - 'ad_tag': '', - 'height': 160, - 'width': 300, - 'cpm': 850, - 'status_message': '', - 'currency': 'JPY', - 'video_creative_id': 600004, - 'bid_id': '23beaa6af6cdde' - } - }; - - it('should get the correct bid response for video', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 850, - 'width': 300, - 'height': 160, - 'creativeId': '600004', - 'dealId': undefined, - 'currency': 'JPY', - 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'mediaType': 'banner', - 'ad': '' - }]; - let result = spec.interpretResponse(serverResponseVideo, bidRequestVideo[0]); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'uid': 'a42947f8-f8fd-4cf7-bb72-31a87ab1f6ff', - 'height': 0, - 'crid': '', - 'statusMessage': '', - 'width': 0, - 'cpm': 0 - } - }; - let result = spec.interpretResponse(response, bidRequestVideo[0]); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/zedoBidAdapter_spec.js b/test/spec/modules/zedoBidAdapter_spec.js deleted file mode 100644 index 8e5a789656e..00000000000 --- a/test/spec/modules/zedoBidAdapter_spec.js +++ /dev/null @@ -1,354 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/zedoBidAdapter'; - -describe('The ZEDO bidding adapter', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'zedo', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - - it('should return true when given a channelcode bid', function () { - const bid = { - bidder: 'zedo', - params: { - channelCode: 20000000, - dimId: 9 - }, - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidderRequest = { - timeout: 3000, - }; - - it('should properly build a channelCode request for dim Id with type not defined', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [[300, 200]], - params: { - channelCode: 20000000, - dimId: 10, - pubId: 1 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^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': '' - }, - 'bidCpm': '720000' - } - ] - } - ] - } - }; - 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': '' - }, - 'bidCpm': '780000' - } - ] - } - ] - } - }; - 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); - }); - }); -});