From 412277f72b97cab72644cb4a009f58067a165899 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 10 Jun 2021 13:43:07 -0400 Subject: [PATCH] Prebid 5.0 (#6999) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * increment pre version * rubicon: removing maxduration as a required bidder parameter (#6513) * Lemma Bid Adapter: accepting the floor to use the getFloor function (#6497) * lemmaBidAdapter.js Added lemma bid adapter file * lemmaBidAdapter.md Added lemma bid adapter md file * lemmaBidAdapter_spec.js Added lemma bid adapter test spec file * Update lemmaBidAdapter.js Fixed automated code review alert comparison between inconvertible types * Update lemmaBidAdapter.js Fixed review changes * Update lemmaBidAdapter.md Correct parameter value. * Update lemmaBidAdapter.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter_spec.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.md Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.js Added user sync support into bid adapter. * updated include modules file extension. updated include modules js file extension. * Update lemmaBidAdapter_spec.js Added unit test for user sync feature. * Update lemmaBidAdapter.js Fixed format error. * Update lemmaBidAdapter_spec.js Fixed format error and typo error. * Set mediaType key value into bid object Set mediaType key value into the bid object. * Update lemmaBidAdapter.js remove duplicate function * Update lemmaBidAdapter.js Remove non supported code. * Update lemmaBidAdapter_spec.js Remove GDPR test cases. * Update lemmaBidAdapter.js Made changes for accepting the floor to use the getFloor function * Update lemmaBidAdapter.js correct undefined keyword name. * Update lemmaBidAdapter_spec.js Added test coverage floor value * Update lemmaBidAdapter.js Remove trailing spaces on lines 379 and 381. * Update lemmaBidAdapter_spec.js Added getFloor function test case changes, Please review it. * Update lemmaBidAdapter_spec.js * Update lemmaBidAdapter.js * Update lemmaBidAdapter.js Fixed lint issue. * Update lemmaBidAdapter_spec.js Fixed test cases. * Update lemmaBidAdapter_spec.js Made suggested changes. Please review it. Co-authored-by: Abhijit Mane * Mediasquare Bid Adapter: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event (#6480) * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * removing status as it does not seem populated when called * add tests * Update nextroll ID variable name to match published ID module (#6519) * Merkle User ID Module: updates to user id submodule (#6503) * AdKernel Bid/Analytics Adapters: user privacy related changes (#6488) * SynacorMedia: remove adId from the bid response (#6520) * Rubicon: making doc data types consistent (#6526) * Synacormedia Bid Adapter: add meta.advertiserDomains (#6527) * Adloox Analytics Adapter: add new analytics adapter (#6308) * gulp: fix supplying list of browsers to test against The following now works: gulp test --browserstack --nolint --nolintfix --browsers=bs_ie_11_windows_10 --file 'test/spec/modules/adloox{AnalyticsAdapter,AdServerVideo,RtdProvider}_spec.js' * instreamTracking: unit test tidy From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * adloaderStub: expose stub for other unit tests to use From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * Adloox analytic module * Seedtag adapter: Fixing bug preventing to receive the right params onTimeout. (#6525) * adot bid adapter: add publisher path from bidder config to endpoint url (#6476) * Admixer ID System: add userId submodule (#6238) * Migrating to Prebid 1.0 * Migrating to Prebid 1.0 * Fix spec * add gdpr and usp * remove changes in gdpr_hello_world.html * Update gdpr_hello_world.html add spaces * add user syncs * remove comments * tests * admixer id system * admixer id system * admixer id system eids.md userId.md * admixer id system .submodules.json * admixer id system Co-authored-by: atkachov * PBJS Core: call custom render func after loadscript if provided (#6422) * Pubxai Analytics Adapter: bug fixes and code revamp (#6474) * Updated PubxAiAnalytics adapter - Bug fixes and Code restructuring * Updated endpoint URLs * Changed array.includes to array.indexOf to fix IE issue * Code cleanup and changes as suggested. * Updated browser testing order and edge browser token * PBJS Core: canBidderRegisterSync ignoring iframe sync disabled by default (#6535) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update userSync.js * Update userSync_spec.js * Added automatic tzo and targetId to adserver request. (#6534) * Tappx Bid Adapter: minor updates and universal id added (#6504) * UPDATE: add initial UID * UPDATE: UID change user ext * UPDATE: UID clean logs * UPDATE: add host info * UPDATE: tappx bid adapter universal id * UPDATE: fix bidder param * UPDATE: tappxBidAdapter tests * tappxBidAdapter - fix spacing * tappxBidAdapter: add test user eids array * tappxBidAdapter: update eids array * FIX: package-lock.json Co-authored-by: marc_tappx * Impactify Bid Adapter: add new bid adapter (#6518) * Add impactify adapter with MD file * Add impactify adapter * Prebid 4.34.0 Release * Increment pre version * Prebid server adapter: add config for openx hosting (#6530) * Yieldmo adapter: add meta data to bids (#6550) * Smartx Bid Adapter: Add meta.advertiserDomains support (#6547) * Onevideo / Adap.tv Adapter: updated example configuration (#6546) * Mass Deal Rendering Module: support multiple custom configs for dealId and rendering (#6500) * ZetaSsp Bid Adapter: add new bid adapter (#6432) * Adnuntius Bid Adapter: Fix for bid too low. (#6557) * Added automatic tzo and targetId to adserver request. * Fixing issues with bid price being too low. * Fixing issues with bid price being too low. * ReadPeak Bid Adapter: fix api issues, add gdpr consent, & getfloor module support (#6548) * BetweenBidAdatper: added sharedid support (#6531) * adWMG Bid Adapter: update endpoints for cookie sync (#6544) * Support floorCPM parameter, fix some minor bugs * fix space-in-parens circleci error * example fix * clean usersync URL * spaces * spaces * add new unit tests, compatibility with IE11 * remove logInfo * Check for floorCPM value * Check params before sending * New endpoints * code format * new endpoint for cookie sync * update tests Co-authored-by: Mikhail Dykun * Yieldmo Bid Adapter: add support for the floors module (#6541) * Sortable Bid Adapter: add eids support (#6565) * Add Sortable adapter for Prebid 3.x Update tests to reflect changes. * Add .js in imports * hostname not host: don't include port * Trivial change to trigger build: failure wasn't our adapter * More failures in other adapters * PR Feedback - use https for URL - fix examples in markdown - request to endpoint should work now * Feedback: add native and video examples * Update unit tests Co-authored-by: Shannon Broekhoven * Outbrain Bid Adapter: replacing Zemanta (#6558) * Sirdata Real-time Data Module: add new RTD module (#6515) * Logicad Bid Adapter: add support for userid modules (#6529) * ATS-identityLinkIdSystem - add use3P config property to control firing of 3P envelope endpoint (#6568) * Proxistore Bid Adapter: add support for tcf v2 consent (#6543) * use tcf v2 consent * set cosentGiven to false and test Gdpr api v2 * BlueBillyWig Bid Adapter: add renderer customization options (#6540) * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Update bluebillywigBidAdapter test parameters to match renderer to rendererCode rename * Blue Billywig - Also pass through site config with OpenRTB request * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Code quality update, always hit user syncs, improved video params * Remove unnecessary export * Add rendererSettings param to bluebillywig adapter * Kick off CircleCi tests manually Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie * OpenX Bid Adapter: Set Deal ID for video requests (#6573) * 33Across Bid Adapter: add support for User ID modules (#6554) * pubGENIUS bid adapter: support floor module (#6555) * Welect Bid Adapter: update url of API (#6570) * update api url * update api url in tests * Bright Mountain Media Bid Adapter: change bidder code to bmtm; alias old name (#6574) * Adtelligent Bid Adapter: add adUrl support & new alias (#6559) * add adUrl support * add adUrl test * Bright Mountain Media Bid Adapter: Change Endpoint URL (#6576) * Outbrain Bid Adapter: only trigger nurl ajax call if nurl is present (#6579) * LiveWrapper Bid Adapter: add US privacy and Coppa support (#6569) * Livewrapped bid and analytics adapter * Fixed some tests for browser compatibility * Fixed some tests for browser compatibility * Changed analytics adapter code name * Fix double quote in debug message * modified how gdpr is being passed * Added support for Publisher Common ID Module * Corrections for ttr in analytics * ANalytics updates * Auction start time stamp changed * Detect recovered ad blocked requests Make it possible to pass dynamic parameters to adapter * Collect info on ad units receiving any valid bid * Support for ID5 Pass metadata from adapter * Typo in test + eids on wrong level * Fix for Prebid 3.0 * Fix get referer * http -> https in tests * Native support * Read sizes from mediatype.banner * Revert accidental commit * Support native data collection + minor refactorings * Set analytics endpoint * Support for app parameters * Fix issue where adunits with bids were not counted on reload * Send debug info from adapter to external debugger * SChain support * Send GDPR data in analytics request * video support Video support * Report back floor via analytic * Send auction id and adunit/bidder connection id * Criteo id support * Updated example * livewrapped Analytics Adapter info file * Livewrapped gvlid * Us Privacy and Coppa support * Rubicon Analytics: Handle PBS Sending Bid ID 0 (#6584) * TrustX Bid Adapter: support new format request (#6556) * Add trustx adapter and tests for it * update integration example * Update trustx adapter * Post-review fixes of Trustx adapter * Code improvement for trustx adapter: changed default price type from gross to net * Update TrustX adapter to support the 1.0 version * Make requested changes for TrustX adapter * Updated markdown file for TrustX adapter * Fix TrustX adapter and spec file * Update TrustX adapter: r parameter was added to ad request as cache buster * Add support of gdpr to Trustx Bid Adapter * Add wtimeout to ad request params for TrustX Bid Adapter * TrustX Bid Adapter: remove last ampersand in the ad request * Update TrustX Bid Adapter to support identical uids in parameters * Update TrustX Bid Adapter to ignore bids that sizes do not match the size of the request * Update TrustX Bid Adapter to support instream and outstream video * Added wrapperType and wrapperVersion parameters in ad request for TrustX Bid Adapter * Update TrustX Bid Adapter to use refererInfo instead depricated function utils.getTopWindowUrl * HOTFIX for referrer encodind in TrustX Bid Adapter * Fix test for TrustX Bid Adapter * TrustX Bid Adapter: added keywords passing support * TrustX Bid Adapter: added us_privacy parameter in bid request * TrustX Bid Adapter: fix us_privacy parameter in bid request * Fix alias error for TrustX Bid Adapter * TrustX Bid Adapter: added new request format * TrustX Bid adapter: fix new format endpoint * TrustX Bid Adapter: update md file to support useNewFormat parameter * FeedAd Bid Adapter: add support for GDPR/TCF 2.0 & remove video support (#6538) * added file scaffold * added isBidRequestValid implementation * added local prototype of ad integration * added implementation for placement ID validation * fixed video context filter * applied lint to feedad bid adapter * added unit test for bid request validation * added buildRequest unit test * added unit tests for timeout and bid won callbacks * updated bid request to FeedAd API * added parsing of feedad api bid response * added transmisison of tracking events to FeedAd Api * code cleanup * updated feedad unit tests for buildRequest method * added unit tests for event tracking implementation * added unit test for interpretResponse method * added adapter documentation * added dedicated feedad example page * updated feedad adapter to use live system * updated FeedAd adapter placement ID regex * removed groups from FeedAd adapter placement ID regex * removed dedicated feedad example page * updated imports in FeedAd adapter file to use relative paths * updated FeedAd adapter unit test to use sinon.useFakeXMLHttpRequest() * added GDPR fields to the FeedAd bid request * removed video from supported media types of the FeedAd adapter * increased version code of FeedAd adapter to 1.0.2 * removed unnecessary check of bidder request * fixed unit test testing for old FeedAd version * removed video media type example from documentation file * added gvlid to FeedAd adapter * Ats optional 3p endpoint - keep default behavior the same (#6586) * ATS-identityLinkIdSystem - add use3P config property to control firing of 3P envelope endpoint * ATS-identityLinkIdSystem - add notUse3P config property to control firing of 3P envelope endpoint * use another uri for cookieless (#6572) * Pbjs Core: add new API to return the highest unused bid for a given adunit (#6342) * feat: add new API to return the highest unused bid for a given adunit code * feat: add unit tests for new API * Adpone Bid Adapter: remove usersync and pass gpdr via querystring (#6326) * remove usersync and add gpdr via querystring * wrap tests under describe adponeBidAdapter * remove bid.meta.advertiserDomains * support adomain * fix adpone advertiserDomains * fix test * Yieldmo bid adapter: set outstream renderer. (#6566) - adapter maintainer email: opensource@yieldmo.com * Richaudience Bid Adapter: add new config UserSync (#6523) * Add new config UserSync * Solved lint errors * Solved lint errors 2 * Solved lint errors 3 * Add changes * Add changes 2 * Add changes 3 * Add changes 4 * Add changes 5 * Solved issues Co-authored-by: sgimenez * Prebid 4.35.0 Release * Increment pre version * Deepintent ID System: add new ID module (#6537) * initial commit * feat(deepintent-dpes): adds deepintent user id module * chore(code-cleanup): removed console logs * eids config added * fix for passing the eids * docs added with minor change * tests added * remaining conflict resolution * kick off circle-ci tests manually * fix linting error * changed the atype to 3 * tests added for eids_spec.js * Change the language * added cacheIdObject signature * changed test cases * eIds passing added to adapter * docs changed removed params not required * doc added * docs added in userId base * user id tests added * lint fixes * lint fixes * code review comments fix Co-authored-by: Sourabh Gandhe Co-authored-by: ChinmoyDebnath Co-authored-by: Chris Huie * Update spotxBidAdpter renderer url to ensure onLoad is always called. (#6592) Co-authored-by: Nick Peceniak * VIS.X: add onSetTargeting, onBidWon & onTimeout handlers (#6532) * Index Exchange Bid Adapter: resolve negative size bug (#6582) * smartx Bid Adapter: Outstream render bugfix numeric elementId (#6588) * Update cookie sync call (#6567) * Add videoCacheKey back to bid response when using spotx as cache server (#6605) Co-authored-by: Nick Peceniak * Nativo Bid Adapter: add new bid adapter (#6542) * Initial nativoBidAdapter document creation (js, md and spec) * Fulling working prebid using nativoBidAdapter. Support for GDPR and CCPA in user syncs. * Added defult size settings based on the largest ad unit. Added response body validation. Added consent to request url qs params. * Changed bidder endpoint url * Changed double quotes to single quotes. * Reverted package-json.lock to remove modifications from PR * Added optional bidder param 'url' so the ad server can force- match an existing placement * Lint fix. Added space after if. * Spotx Bid Adapter: Update endpoint to indicate request is from Prebid (#6593) * Sharethrough Bid Adapter: add support for COPPA (#6602) * Pass COPPA flag to Ad Server [#177598971] * Send true instead of 1 * Upgrade adapter version number * tappx Bid Adapter: add video instream support and update testing (#6580) * tappxBidAdapter : update tests adding video * tappxBidAdapter : add video instream * tappxBidAdapter : update tappx md doc * tappxBidAdapter: Fix Newline required eol-last * tappxBidAdapter: update tests User sync and video reqs * tappxBidAdapter: Extra space after fix Co-authored-by: marc_tappx * Halo RTD Module: FPD 2.0 Updates & add ID system tests (#6505) * fix appnexus segment field format * ortb2 fpd updates * update halo ntegration example * fix cached id naming & access * gvlid storageManager and get/set update * getConfig update * re-order exports * stub local storage methods * Zemanta bid adapter: reinstate Outbrain as alias (#6617) * Index Exchange bid adapter: report which userIds available in diagnostics object (#6604) * Update Windows Testing on Chrome to v 89.0 (#6539) * PBjs Core: added `maxNestedIframes` option (#6615) * PBjs Core: added maxNestedIframes option * change default maxNestedIframes to 10 Co-authored-by: Andrea Fassina * ID5 User ID module - don't send empty fields to server (#6581) * for optional fields, only send to servers if populated * adding some logging to id5 submodule to make debugging easier * update user id integration example for id5 to user html5 not cookie * remove .only from tests * remove checks for loginfo since now we are using it more broadly * New Bid Adapter: Shinez (#6597) * Shinze adapter version 1.0.0 * map for arrays replaced with forEach, fpd temporarily removed * switched to only public interface testing * Usage of URL removed * refactor user id example to properly receive TCFv2 consent string and other improvements (#6583) * refactor user id example to properly receive TCFv2 consent string by using static consent object - added a list of user id modules' gvl ids to enable consent for them within prebid core - also reformatted the entire document to make it easier to read - added output of the eids array so it's easy to see what's happening * smaller tab size * use sinon local storage stubs for haloid module (#6619) * Adnuntius Bid Adapter: Bug fix ordered response. (#6625) * Added automatic tzo and targetId to adserver request. * Fixing issues with bid price being too low. * Fixing issues with bid price being too low. * Ad server response places bids in correct placement * Adnuntius Bid Adapter ordered responses * Ad server response places bids in correct placement * Adnuntius Bid Adapter ordered responses * RTD Provider rebase * wrongly merged to master * IX Bid Adapter: Add support for UID2.0 (#6628) * UserId Module: add support for case insensitive submodule names (#6629) * add support for case insensitive userId names * update unit test * PubMatic bid adapter: support for FPD & Preauction module (#6623) * Rubicon Bid Adapter: FPD Bug Fixes (#6578) * Yieldmo adapter: cut banner bid request parameters in case the url for bunner request is too long (#6549) Co-authored-by: Anton Tsymuk * FPD Update - Core/RP Analytics Adapter (#6612) 1) Update core to convert adUnits passed into requestBids (previously only global) 2) Update to RP Analytics adapter to look in ortb2Imp instead of legacy fpd * ADXCG Bid Adapter: add video & parameter validation & other updates (#6577) * Update adxcgBidAdapter.js * Update adxcgcom .js client side adapter * lgtm review update * check for parameter existenct onBidWon * Update adxcgBidAdapter.js * Update adxcgBidAdapter.js * Update adxcgBidAdapter.md * Update adxcgBidAdapter.md * Zeta bid adapter: add params to bid request (#6614) * Submit Zeta Adapter to Prebid * comments addressed * demo changes * additional polishing * additional polishing * Update hello_world.html * remove extraneous changes to hello_world.html * no, really this time * additional polishing * add unit test * update to include additional OpenRTB fields and objects * Update to include addtional OpenRTB fields and objects * oneVideo Bid Adapter: content object mapping bug fix (VDEFECT-5405) (#6633) * PR_REVIEW: added check for bidder name validity (#6491) * added check for bidder name validity * adding aliases in-scope for the validity check * Kobler Bid Adapter: add new bid adapter (#6479) * Implemented Kobler bidder adapter. * Added missing '' to dealId example in parameters table. * Added information on supporting the Floors module. * Implemented tests for isBidRequestValid. * Implemented tests for inherited functions. * Removed unnecessary conditions and quotation marks. * Added TODO about deciding what to do in debug mode. * Added TODO about checking which currencies are allowed. * Added information on parameters read from the first bid only. * Fixed missing indexing operator when checking if mainSize is 0x0. * Implemented tests for buildRequests. * Implemented tests for interpretResponse. * Implemented tests for onBidWon. * Implemented tests for onTimeout. * Added some missing semicolons. * Removed TODO about allowed currencies. * Removed setting test in debug mode and related TODOs. * Removed optional pos parameter. * Removed optional bidfloor parameter and use floorPrice instead of floorprice. * Added support for multiple deal ID parameters. * Fixed formatting. * Added more explanation about the value of position param. * Moved pos property into Kobler-specific banner extension. * Simplifications based on PR comments. * Use getRefererInfo to get page URL for timeout notifications. * Removed TODO about auction type. * Added information on how to generate a sample bid. * Removed reading currency from currency.adServerCurrency. * sspBC Bid Adapter: update to v4.8, bugfixes, & support for sending params.publisherId (#6575) * add sspbc adapter * tests for sspbc adapter * sspBC adapter v4.5: set correct creativeId, add adomain to bid.meta, set test mode in adexchange, read site SN from bid response * sspBC adapter v4.5: set meta.advertiserDomains, update test to expect bid.meta * sspBC Adapter: add ajax tests (test ad with & without gdpr) * sspBC Adapter: remove ajax tests * Update adapter to v4.6 Update adapter to v4.6 - add notification endpoint - send bidWon and onTimeout notifications - send CMP version to user sync endpoint * Remove console logs for notification events * Change payload data in onTimeout event * Update tests for sspBC adapter Update tests for sspBC adapter: - add onBidWon test - add onTimeout test - alter getUserSyncs test * Update sspBC adapter to v4.7; enable oneCodeId mode; change module name to ensure combatibility with prebid.org downloader * sspBc adapter: Bug fixes in v4.7 - change notification format, fix oneCode detection data, convert slot number to int * sspbc adapter: fix creating bid.crid, when not present in server response * sspbc adapter: add publisher id to payload * sspbc adapter: fix onecode issues (when bid.params is present, but incomplete) * sspbc adapter: code cleanup * sspbc adapter: ver up (4.8) * sspbc-adapter: update doc * [sspbc-adapter] update test settings Co-authored-by: Wojciech Biały * Create module registry: update build to add installModules array to pbjs global (#6601) * - Remove module list comment on build - Add pbjs.installedModules with macro to prebid.js - Update gruntfile to replace macro with module array (if empty array all modules included)) * Removed unused code * Removed comma * Recommitting changes * Updated regex to look for either '|" in macro name. Seems there is a difference between dev/prod * SynacorMedia Bid Adapter: Create bid.params.video object if it's not already present on the video request since it's an optional property (#6637) * Prebid Core: Readme.md import name change (#6638) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update README.md * Update README.md * PBS Bid Adapter: Stop overriding s2sconfig.enabled from vendor defaults (#6622) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update index.js * RP Bid Adapter: Bug fix for parsing ortb2.user.data (#6643) * Bug fix when parsing FPD data. Check for taxonomyname existence prior to match * Lint check * AdRiver Bid Adapter: add new bid adapter (#6514) * AdRiver Bid Adapter: initial prebid.js integration * Added AdRiver Bid Adapter * AdRiver Bid Adapter: update getting floor, via getFloor() * Added internal method _getFloor() * Update test for getFloor() * Remove old currency logic * AdRiver Bid Adapter: update adriverBidAdapter.md * Delete old test parameters * AdRiver Bid Adapter: add meta.advertiserDomains * Added parameter meta.advertiserDomains to interpretResponse * Update test for meta.advertiserDomains * hotfix - placement issue fix (#6641) * Prebid 4.36.0 Release * Increment pre version * PBJS RP adapter: pass analytics flag to server (#6644) * Adkernel: new alias (#6608) * Ccx Bid Adapter: adomain support (#6595) * Qwarry Bid Adapter: added gdpr field (#6635) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix * gdpr value added * merge master * gdpr value added * qwarry bid adapter: add tests Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev * Adf Bid Adapter: rename adformOpenRTB adapter; add former name as alias (#6642) * GumGum Bid Adapter: use ad response sizes when found (#6649) * adds meta field to bidresponse * adds meta mediatype and advertiserdomain default * use response sizes in bidresponse * Rubicon Bid Adapter: add outstream rendering (#6469) * Magnite renderer support for Oustream ads * add functions for hiding ad units * Add unit tests * adding open source location of renderer * better minification Co-authored-by: bretg * Halo RTD submodule: update docs (#6651) * sid into tags for ZetaSsp (#6636) Co-authored-by: Surovenko Alexey * Add module name to storage manager; catch errors (#6596) * Adnuntius Bid Adatpter: Meta field advertiser domain update. (#6652) * RTD Provider rebase * wrongly merged to master * Added meta field for advertiser domains. * Gnet Bid Adapter: add new bid adapter (#6536) * Add files via upload * Add files via upload * Change params on gnetBidder * ADJ - Use parseSizesInput to get sizes ADJ - Check serverResponse object ADJ - Remove getUserSyncs function * ADJ - Change prebid endpoint * ADJ - Change endpoint on test * TheMediaGrid Bid Adapter: added support of PBAdSlot module (#6609) * Added TheMediaGridNM Bid Adapter * Updated required params for TheMediaGridNM Bid Adapter * Update TheMediGridNM Bid Adapter * Fix tests for TheMediaGridNM Bid Adapter * Fixes after review for TheMediaGridNM Bid Adapter * Add support of multi-format in TheMediaGrid Bid Adapter * Update sync url for grid and gridNM Bid Adapters * TheMediaGrid Bid Adapter: added keywords adUnit parameter * Update TheMediaGrid Bid Adapter to support keywords from config * Implement new request format for TheMediaGrid Bid Adapter * Fix jwpseg params for TheMediaGrid Bid Adapter * Update unit tests for The Media Grid Bid Adapter * Fix typo in TheMediaGrid Bid Adapter * Added test for jwTargeting in TheMediaGrid Bid Adapter * The new request format was made by default in TheMediaGrid Bid Adapter * Update userId format in ad request for TheMediaGrid Bid Adapter * Added bidFloor parameter for TheMediaGrid Bid Adapter * Fix for review TheMediaGrid Bid Adapter * Support floorModule in TheMediaGrid Bid Adapter * Fix empty bidfloor for TheMediaGrid Bid Adapter * Some change to restart autotests * Fix userIds format for TheMediaGrid Bid Adapter * Remove digitrust userId from TheMediaGrid Bid Adapter * Protocols was added in video section in ad request for TheMediaGrid Bid Adapter * TheMediaGrid: fix trouble with alias using * TheMediaGridNM: fix trouble with alias * TheMediaGrid Bid Adapter: added support of PBAdSlot module * TheMediaGrid Bid Adapter: fix typo * Sonobi Bid Adapter: added Coppa Flag check (#6631) * Sonobi - Added Coppa Flag check * added unit test for sonobi coppa flag * GothamAds Bid Adapter: add at, ccpa, gdpr and coppa support (#6470) * update gothamAds adapter * update GothamAdsAdapter according to commetns. Add meta for adomains * Rubicon Bid Adapter: Added new size - Id 558 (640x640) (#6658) * AOL, RTBHouse, RhythmOne, Teads, OpenX and DeepIntent Bid Adapters: add support for meta.advertiserDomains (#6656) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update deepintentBidAdapter.js * Update deepintentBidAdapter_spec.js * Update rtbhouseBidAdapter.js * Update rtbhouseBidAdapter_spec.js * Update deepintentBidAdapter.js * Update rtbhouseBidAdapter.js * Update rtbhouseBidAdapter.js * Update rtbhouseBidAdapter_spec.js * Update deepintentBidAdapter.js * Update rhythmoneBidAdapter.js * Update rhythmoneBidAdapter_spec.js * Update aolBidAdapter.js * Update aolBidAdapter_spec.js * Update aolBidAdapter.js * Update aolBidAdapter.js * Update teadsBidAdapter.js * Update teadsBidAdapter_spec.js * Update openxBidAdapter_spec.js * Update openxBidAdapter.js * Update openxBidAdapter.js * Update openxBidAdapter_spec.js * Update openxBidAdapter.js * Adnuntius Bid Adapter: bugfix to set undefined if no bids (#6662) * RTD Provider rebase * wrongly merged to master * Added meta field for advertiser domains. * Fixing bug where losing bids throw undefined into the response. * Wrapped if-statement * pass auctionId (#6664) * ucfunnel Bid Adapter: add support for Unified ID 2 (#6647) * Add a new ucfunnel Adapter and test page * Add a new ucfunnel Adapter and test page * 1. Use prebid lib in the repo to keep updated 2. Replace var with let 3. Put JSON.parse(JSON.stringify()) into try catch block * utils.getTopWindowLocation is a function * Change to modules from adapters * Migrate to module design * [Dev Fix] Remove width and height which can be got from ad unit id * Update ucfunnelBidAdapter to fit into new spec * Correct the endpoint. Fix the error of query string * Add test case for ucfunnelBidAdapter * Fix lint error * Update version number * Combine all checks on bid request * Add GDPR support for ucfunnel adapter * Add in-stream video and native support for ucfunnel adapter * Remove demo page. Add more test cases. * Change request method from POST to GET * Remove unnecessary comment * Support vastXml and vastUrl for video request * update TTL to 30 mins * Avoid using arrow function which is not discuraged in mocha * ucfunnel tdid support * ucfunnel fix error message in debug mode * ucfunnel adapter add bidfloor parameter * ucfunnel adapter support CCPA * ucfunnel adapter native support clicktrackers * ucfunnel adapter change cookie sync setting * ucfunnel adapter update request parameter * Update ucfunnelBidAdapter * ucfunnel adapter add currency in ad response * ucfunnel adapter support uid2 Co-authored-by: root Co-authored-by: Ryan Chou Co-authored-by: ucfunnel Co-authored-by: jack.hsieh * Intent IQ ID Systems: first party updates (#6618) * New features in iiq * intentIqIdSystem.js updated logic & tests * Tests fix * api update * tests update * Outbrain Bid Adapter: fix usersync query parameter formatting (#6668) * Sovrn Bid Adapter: added FPD support (#6639) * added FPD support * using proper package-lock.json * Consent Management Module: TCFApi in Iframe callId fix (#6634) * fix random id * lint * fix for real Co-authored-by: Reinout Stevens * add support for non-purpose1 consent domains to appnexus and PBS bid adapters (#6484) * add support for non-purpose1 consent domains * fix logic and consentdata to clientSideSyncs * update openx vendor config * TheMediaGrid Bid Adapter: Coppa support (#6655) * Added TheMediaGridNM Bid Adapter * Updated required params for TheMediaGridNM Bid Adapter * Update TheMediGridNM Bid Adapter * Fix tests for TheMediaGridNM Bid Adapter * Fixes after review for TheMediaGridNM Bid Adapter * Add support of multi-format in TheMediaGrid Bid Adapter * Update sync url for grid and gridNM Bid Adapters * TheMediaGrid Bid Adapter: added keywords adUnit parameter * Update TheMediaGrid Bid Adapter to support keywords from config * Implement new request format for TheMediaGrid Bid Adapter * Fix jwpseg params for TheMediaGrid Bid Adapter * Update unit tests for The Media Grid Bid Adapter * Fix typo in TheMediaGrid Bid Adapter * Added test for jwTargeting in TheMediaGrid Bid Adapter * The new request format was made by default in TheMediaGrid Bid Adapter * Update userId format in ad request for TheMediaGrid Bid Adapter * Added bidFloor parameter for TheMediaGrid Bid Adapter * Fix for review TheMediaGrid Bid Adapter * Support floorModule in TheMediaGrid Bid Adapter * Fix empty bidfloor for TheMediaGrid Bid Adapter * Some change to restart autotests * Fix userIds format for TheMediaGrid Bid Adapter * Remove digitrust userId from TheMediaGrid Bid Adapter * Protocols was added in video section in ad request for TheMediaGrid Bid Adapter * TheMediaGrid: fix trouble with alias using * TheMediaGridNM: fix trouble with alias * TheMediaGrid Bid Adapter: added support of PBAdSlot module * TheMediaGrid Bid Adapter: fix typo * TheMediaGrid Bid Adapter: support coppa * Trigger AUCTION_DEBUG from utils.logWarn with type set to WARNING (#6645) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * emit AUCTION_DEBUG for logWarn with type WARNING * fixed the unit test case * Tappx Bid Adapter: optional ext on request (#6659) * UPDATE: add initial UID * UPDATE: UID change user ext * UPDATE: UID clean logs * UPDATE: add host info * UPDATE: tappx bid adapter universal id * UPDATE: fix bidder param * UPDATE: tappxBidAdapter tests * tappxBidAdapter - fix spacing * tappxBidAdapter: add test user eids array * tappxBidAdapter: update eids array * FIX: package-lock.json * Conversant adapter: add adomain, remove digitrust (#6495) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update conversantBidAdapter.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Rads Bid Adapter: add GDPR support & user sync support (#6455) * Proxistore Bid Adapter: add cookieless url endpoint & use floor module (#6427) * use floor module * call cookieless endpoint when necessary * test endpoint url * change url endpoint * delete console log * fix tests * add language to url * use ortb interface * unit test * update test unit * create proxistore module * add unit tests and documentation * delete modules * delete module * add proxistore rtd submodule * delete proxistore module * spacing * change url * AdYoulike Bid Adapter: Add an "Insertion" tracking for Native mediatype (#6481) * add insertion event * add missing campaign ID parameter * update unit test with new tracking checked * Dspx Bid Adapter : add user sync support (#6456) * Add sync support for dspx adapter * Dspx Bid Adapter : add user sync support Co-authored-by: Alexander * Multibid Module: add new module to handle multiple bids from single bidder & update rubicon adapter (#6404) * Multibid module - create new module - Expands the number of key value pairs going to the ad server in the normal Prebid way by establishing the concept of a "dynamic alias" First commit * Continued updates from 1st commit * Adding logWarn for filtered bids * Update to include passing multibid configuration to PBS requests * Update to rubicon bid adapter to pass query param rp_maxbids value taken from bidderRequest.bidLimit * Update to config to look for camelcase property names according to spec. These convert to all lowercase when passed to PBS endpoint * Adjust RP adapter to always include maxbids value - default is 1 * Added support for bidders array in multibid config * Fixed floor comparison to be <= bid cpm as oppossed to just < bid cpm. Updated md file to fix camelCase tpyo * Update to include originalBidderRequest in video call to prebid cache * Update to ignore adpod bids from multibid and allow them to return as normal bids * Adding uid2 to submodules.json (#6508) * NextRoll ID System: add new ID module (#6396) * Add Nextroll ID Module * Add nextroll to eids * Make configuration value names consistent with Adapter Module * Use parnerId instead of sellerId * Add nextroll to userId and eids md files * Remove storage configuration * Rename nextroll -> nextrollId * Add nextrollId to common ID specs * Qwarry Bid Adapter: add GDPR and consent string handling (#6489) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> * Zemanta Bid Adapter: add support for new params & consent strings to usersync URL (#6468) * add gvl id to spec * add support for bcat and badv params * add consent strings to usersync url * add bcat and badv params to doc * Automatad Bid Adapter: Add meta.advertiserDomains to bid response (#6509) * added bid meta with advertiserDomains * Adhese Bid Adapter: add support for caching video content (#6501) * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * Adhese Bid Adapter: cache video content Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz * update apacdex unit test to disable debug mode (#6511) * Telaria: not setting adid (#6507) * Prebid 4.33.0 Release * increment pre version * rubicon: removing maxduration as a required bidder parameter (#6513) * Zemanta adapter: add advertiserDomains (#6517) * Lemma Bid Adapter: accepting the floor to use the getFloor function (#6497) * lemmaBidAdapter.js Added lemma bid adapter file * lemmaBidAdapter.md Added lemma bid adapter md file * lemmaBidAdapter_spec.js Added lemma bid adapter test spec file * Update lemmaBidAdapter.js Fixed automated code review alert comparison between inconvertible types * Update lemmaBidAdapter.js Fixed review changes * Update lemmaBidAdapter.md Correct parameter value. * Update lemmaBidAdapter.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter_spec.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.md Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.js Added user sync support into bid adapter. * updated include modules file extension. updated include modules js file extension. * Update lemmaBidAdapter_spec.js Added unit test for user sync feature. * Update lemmaBidAdapter.js Fixed format error. * Update lemmaBidAdapter_spec.js Fixed format error and typo error. * Set mediaType key value into bid object Set mediaType key value into the bid object. * Update lemmaBidAdapter.js remove duplicate function * Update lemmaBidAdapter.js Remove non supported code. * Update lemmaBidAdapter_spec.js Remove GDPR test cases. * Update lemmaBidAdapter.js Made changes for accepting the floor to use the getFloor function * Update lemmaBidAdapter.js correct undefined keyword name. * Update lemmaBidAdapter_spec.js Added test coverage floor value * Update lemmaBidAdapter.js Remove trailing spaces on lines 379 and 381. * Update lemmaBidAdapter_spec.js Added getFloor function test case changes, Please review it. * Update lemmaBidAdapter_spec.js * Update lemmaBidAdapter.js * Update lemmaBidAdapter.js Fixed lint issue. * Update lemmaBidAdapter_spec.js Fixed test cases. * Update lemmaBidAdapter_spec.js Made suggested changes. Please review it. Co-authored-by: Abhijit Mane * Mediasquare Bid Adapter: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event (#6480) * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * removing status as it does not seem populated when called * add tests * Update nextroll ID variable name to match published ID module (#6519) * Merkle User ID Module: updates to user id submodule (#6503) * AdKernel Bid/Analytics Adapters: user privacy related changes (#6488) * SynacorMedia: remove adId from the bid response (#6520) * Rubicon: making doc data types consistent (#6526) * Synacormedia Bid Adapter: add meta.advertiserDomains (#6527) * Adloox Analytics Adapter: add new analytics adapter (#6308) * gulp: fix supplying list of browsers to test against The following now works: gulp test --browserstack --nolint --nolintfix --browsers=bs_ie_11_windows_10 --file 'test/spec/modules/adloox{AnalyticsAdapter,AdServerVideo,RtdProvider}_spec.js' * instreamTracking: unit test tidy From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * adloaderStub: expose stub for other unit tests to use From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * Adloox analytic module * Seedtag adapter: Fixing bug preventing to receive the right params onTimeout. (#6525) * adot bid adapter: add publisher path from bidder config to endpoint url (#6476) * Admixer ID System: add userId submodule (#6238) * Migrating to Prebid 1.0 * Migrating to Prebid 1.0 * Fix spec * add gdpr and usp * remove changes in gdpr_hello_world.html * Update gdpr_hello_world.html add spaces * add user syncs * remove comments * tests * admixer id system * admixer id system * admixer id system eids.md userId.md * admixer id system .submodules.json * admixer id system Co-authored-by: atkachov * PBJS Core: call custom render func after loadscript if provided (#6422) * Pubxai Analytics Adapter: bug fixes and code revamp (#6474) * Updated PubxAiAnalytics adapter - Bug fixes and Code restructuring * Updated endpoint URLs * Changed array.includes to array.indexOf to fix IE issue * Code cleanup and changes as suggested. * Updated browser testing order and edge browser token * PBJS Core: canBidderRegisterSync ignoring iframe sync disabled by default (#6535) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update userSync.js * Update userSync_spec.js * Added automatic tzo and targetId to adserver request. (#6534) * Impactify Bid Adapter: add new bid adapter (#6518) * Add impactify adapter with MD file * Add impactify adapter * Prebid 4.34.0 Release * Increment pre version * Prebid server adapter: add config for openx hosting (#6530) * Yieldmo adapter: add meta data to bids (#6550) * Smartx Bid Adapter: Add meta.advertiserDomains support (#6547) * Onevideo / Adap.tv Adapter: updated example configuration (#6546) * Mass Deal Rendering Module: support multiple custom configs for dealId and rendering (#6500) * ZetaSsp Bid Adapter: add new bid adapter (#6432) * Adnuntius Bid Adapter: Fix for bid too low. (#6557) * Added automatic tzo and targetId to adserver request. * Fixing issues with bid price being too low. * Fixing issues with bid price being too low. * ReadPeak Bid Adapter: fix api issues, add gdpr consent, & getfloor module support (#6548) * BetweenBidAdatper: added sharedid support (#6531) * adWMG Bid Adapter: update endpoints for cookie sync (#6544) * Support floorCPM parameter, fix some minor bugs * fix space-in-parens circleci error * example fix * clean usersync URL * spaces * spaces * add new unit tests, compatibility with IE11 * remove logInfo * Check for floorCPM value * Check params before sending * New endpoints * code format * new endpoint for cookie sync * update tests Co-authored-by: Mikhail Dykun * Yieldmo Bid Adapter: add support for the floors module (#6541) * Sortable Bid Adapter: add eids support (#6565) * Add Sortable adapter for Prebid 3.x Update tests to reflect changes. * Add .js in imports * hostname not host: don't include port * Trivial change to trigger build: failure wasn't our adapter * More failures in other adapters * PR Feedback - use https for URL - fix examples in markdown - request to endpoint should work now * Feedback: add native and video examples * Update unit tests Co-authored-by: Shannon Broekhoven * Outbrain Bid Adapter: replacing Zemanta (#6558) * Sirdata Real-time Data Module: add new RTD module (#6515) * Logicad Bid Adapter: add support for userid modules (#6529) * ATS-identityLinkIdSystem - add use3P config property to control firing of 3P envelope endpoint (#6568) * Proxistore Bid Adapter: add support for tcf v2 consent (#6543) * use tcf v2 consent * set cosentGiven to false and test Gdpr api v2 * BlueBillyWig Bid Adapter: add renderer customization options (#6540) * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Update bluebillywigBidAdapter test parameters to match renderer to rendererCode rename * Blue Billywig - Also pass through site config with OpenRTB request * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Code quality update, always hit user syncs, improved video params * Remove unnecessary export * Add rendererSettings param to bluebillywig adapter * Kick off CircleCi tests manually Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie * OpenX Bid Adapter: Set Deal ID for video requests (#6573) * 33Across Bid Adapter: add support for User ID modules (#6554) * pubGENIUS bid adapter: support floor module (#6555) * Welect Bid Adapter: update url of API (#6570) * update api url * update api url in tests * Bright Mountain Media Bid Adapter: change bidder code to bmtm; alias old name (#6574) * Adtelligent Bid Adapter: add adUrl support & new alias (#6559) * add adUrl support * add adUrl test * Bright Mountain Media Bid Adapter: Change Endpoint URL (#6576) * tappxBidAdapter: update * tasppxBidAdapter: add video * tappxBidAdapter: update video * tappxBidAdapter: update name interpret banner * tappxBidAdapter: add tests for video * tappxBidAdapter: add adomain * tappxBidAdapter: update adapter version * tappxBidAdapter: update interpretBid adomain and dealid * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update tests. Adding video to isBidRequestValid * tappxBidAdapter: update doc .md file * Tappx - Allow optional ext object * Tappx - CircleCI hotfixes * Tappx - CircleCI hotfixes2 * Tappx - Avoid outBrain Co-authored-by: marc_tappx Co-authored-by: Patrick McCann Co-authored-by: onlsol <48312668+onlsol@users.noreply.github.com> Co-authored-by: vincentproxistore <56686565+vincentproxistore@users.noreply.github.com> Co-authored-by: guiann Co-authored-by: Alexander Co-authored-by: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Co-authored-by: SKOCHERI <37454420+SKOCHERI@users.noreply.github.com> Co-authored-by: Abimael Martinez Co-authored-by: artemiokost Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Co-authored-by: Rok Sušnik Co-authored-by: Kanchika - Automatad Co-authored-by: Paweł L Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz Co-authored-by: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Co-authored-by: bretg Co-authored-by: Jason Snellbaker Co-authored-by: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Co-authored-by: Abhijit Mane Co-authored-by: matthieularere-msq <63732822+matthieularere-msq@users.noreply.github.com> Co-authored-by: Denis Logachov Co-authored-by: RAJKUMAR NATARAJAN Co-authored-by: Alexander Clouter Co-authored-by: Laura Morillo-Velarde Co-authored-by: Giudici-a <34242194+Giudici-a@users.noreply.github.com> Co-authored-by: Galphimbl Co-authored-by: atkachov Co-authored-by: Jérémie Girault Co-authored-by: Phaneendra Hegde Co-authored-by: Mikael Lundin Co-authored-by: Thomas Co-authored-by: Mike Chowla Co-authored-by: Deivydas Šabaras Co-authored-by: ym-atsymuk <81176595+ym-atsymuk@users.noreply.github.com> Co-authored-by: Skylinar <53079123+Skylinar@users.noreply.github.com> Co-authored-by: Adam Browning <19834421+adam-browning@users.noreply.github.com> Co-authored-by: Catalin Ciocov Co-authored-by: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Co-authored-by: readpeaktuomo <66239046+readpeaktuomo@users.noreply.github.com> Co-authored-by: Ignat Khaylov Co-authored-by: nyakove <43004249+nyakove@users.noreply.github.com> Co-authored-by: Mikhail Dykun Co-authored-by: ym-dlabuzov <81709888+ym-dlabuzov@users.noreply.github.com> Co-authored-by: karentnarvaez <61426156+karentnarvaez@users.noreply.github.com> Co-authored-by: Shannon Broekhoven Co-authored-by: nouchy <33549554+nouchy@users.noreply.github.com> Co-authored-by: logicad Co-authored-by: mamatic <52153441+mamatic@users.noreply.github.com> Co-authored-by: Klaas-Jan Boon Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie Co-authored-by: Kenan Gillet <1706856+kenan-gillet@users.noreply.github.com> Co-authored-by: Aparna Rao Co-authored-by: Meng <5110935+edmonl@users.noreply.github.com> Co-authored-by: Nick Duitz <42961155+nduitz@users.noreply.github.com> Co-authored-by: BrightMountainMedia <69471268+BrightMountainMediaInc@users.noreply.github.com> Co-authored-by: Gena Co-authored-by: Albert Grandes * Prebid 4.37.0 Release * oneVideo Bid Adapter: Price Floors Module Support (SAPR-16735) (#6672) * Spread adUnit.ortb2Imp.ext into imp object (#6494) * appnexus bid adapter - ensure withCredentials is always passed (#6675) * Axonix Bid Adapter: Fixed interpretResponse, support email (#6667) * Fixed interpretResponse, support email * onBidWon gets single bids * replaceAuctionPrice call fix * Version bump * Smartico Bid Adapter: add new bid adapter (#6486) * Adding smartico adapter * bug #6486 fix, added maintainer email * bug #6486 fix, modified test parameters * bug #6486 fix, modified test parameters #2 * #6486 applied review related updates & fixes * #6486 applied review related updates & fixes #2 * #6486 applied review related updates & fixes #3 Co-authored-by: Dmitri * Interactive Offers Bid Adapter: add data to response object (#6680) Co-authored-by: EC2 Default User * remove space from spread operator * revert accidental commit to master * Adkernel & AdkernelAdn: bidfloor module support (#6671) * Adkernel: bidfloor module support * AdkernelAdn: bidfloor module support * Update to change analytics flag from array to object (#6681) * support meta.advertiserDomains in bridgewell adpter (#6686) Co-authored-by: cycheng * DMD ID System: add new User ID module (#6666) * feat(prebid): DMD UserID Module reading from 1st party cookie [PREBID-1] * feat(prebid):additional parameter[PREB-1] * feat(prebid):update decode function and cacheobi[PREB-1] * test(prebid):added more test coverage[PREB-11] * feat(typo):cleared typo[PREB-11] * test(prebid):updated test cases[PREB-11] * feat(releasenote):added a release note[PREB-11] * fix(releasenote):removed unnecessary release note[PREB-11] * fix(test):updated failing test cases[PREB-11] Co-authored-by: Matt Fitzgerald Co-authored-by: Karthik Boppudi Co-authored-by: mfitzgerald_dmd * appnexus Bid Adapter - add support for gptPreAuction (#6688) * SharedId & PubcommonId: CCPA and COPPA support (#6632) * SharedId & PubcommonId: CCPA and COPPA support * Updating to check consent within the submodule * Fixing review comments and adding tests * Cleaning whitespace Co-authored-by: skocheri * AppNexus bid adapter: add price floor module support (#6653) * display bidder in utils.logs and disable bidder config on auction end (#6683) * add X-Prebid header to ajax requests fixes #6627 (#6676) * Prebid Docs: Typo fix in README.md (#6704) * Revert "add X-Prebid header to ajax requests fixes #6627 (#6676)" (#6702) This reverts commit a887289546bdf830a3ff450a664627471eec9dfc. * Criteo Bid Adapter: update contact email (#6701) * Fixing flaky adapter unit tests (#6706) * stub appendChild stuff * use ie11 safe strIncludes * update prebidManager to use storageManager * use ie safe stuff * going too fast ;P * Floc Userid System: add new ID module (#6521) * Zeta Bid Adapter: update to endpoint (#6697) * adapter updates * remove testing changes * modify endpoint path * address testing issues * prebid 4.38.0 release * 4.39.0-pre * Adkernel Bid Adapter: converge digital alias (#6714) * fix linting in gulpfile (#6694) * eslint(standard/object-curly-even-spacing) * eslint(space-before-blocks) * eslint(no-multi-spaces) * Admixer Bid Adapter: add meta key to response (#6674) * Grid Bid Adapter: add support for advertiserDomains (#6716) * Update gridBidAdapter.js * Update gridBidAdapter_spec.js * Update gridBidAdapter_spec.js * Update gridBidAdapter_spec.js * 33across bid adapter: Add adomain support (#6719) * Fix typo in UID 2.0 doc (#6724) * Bump url-parse from 1.4.7 to 1.5.0 (#6718) Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.4.7 to 1.5.0. - [Release notes](https://github.com/unshiftio/url-parse/releases) - [Commits](https://github.com/unshiftio/url-parse/compare/1.4.7...1.5.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * smartx Bid Adapter: bugfix renderer url (#6725) * Bump handlebars from 4.7.6 to 4.7.7 (#6717) Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.7.6 to 4.7.7. - [Release notes](https://github.com/wycats/handlebars.js/releases) - [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md) - [Commits](https://github.com/wycats/handlebars.js/compare/v4.7.6...v4.7.7) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Tappx Bid Adapter: add floor module support (#6626) * UPDATE: add initial UID * UPDATE: UID change user ext * UPDATE: UID clean logs * UPDATE: add host info * UPDATE: tappx bid adapter universal id * UPDATE: fix bidder param * UPDATE: tappxBidAdapter tests * tappxBidAdapter - fix spacing * tappxBidAdapter: add test user eids array * tappxBidAdapter: update eids array * FIX: package-lock.json * Conversant adapter: add adomain, remove digitrust (#6495) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update conversantBidAdapter.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Rads Bid Adapter: add GDPR support & user sync support (#6455) * Proxistore Bid Adapter: add cookieless url endpoint & use floor module (#6427) * use floor module * call cookieless endpoint when necessary * test endpoint url * change url endpoint * delete console log * fix tests * add language to url * use ortb interface * unit test * update test unit * create proxistore module * add unit tests and documentation * delete modules * delete module * add proxistore rtd submodule * delete proxistore module * spacing * change url * AdYoulike Bid Adapter: Add an "Insertion" tracking for Native mediatype (#6481) * add insertion event * add missing campaign ID parameter * update unit test with new tracking checked * Dspx Bid Adapter : add user sync support (#6456) * Add sync support for dspx adapter * Dspx Bid Adapter : add user sync support Co-authored-by: Alexander * Multibid Module: add new module to handle multiple bids from single bidder & update rubicon adapter (#6404) * Multibid module - create new module - Expands the number of key value pairs going to the ad server in the normal Prebid way by establishing the concept of a "dynamic alias" First commit * Continued updates from 1st commit * Adding logWarn for filtered bids * Update to include passing multibid configuration to PBS requests * Update to rubicon bid adapter to pass query param rp_maxbids value taken from bidderRequest.bidLimit * Update to config to look for camelcase property names according to spec. These convert to all lowercase when passed to PBS endpoint * Adjust RP adapter to always include maxbids value - default is 1 * Added support for bidders array in multibid config * Fixed floor comparison to be <= bid cpm as oppossed to just < bid cpm. Updated md file to fix camelCase tpyo * Update to include originalBidderRequest in video call to prebid cache * Update to ignore adpod bids from multibid and allow them to return as normal bids * Adding uid2 to submodules.json (#6508) * NextRoll ID System: add new ID module (#6396) * Add Nextroll ID Module * Add nextroll to eids * Make configuration value names consistent with Adapter Module * Use parnerId instead of sellerId * Add nextroll to userId and eids md files * Remove storage configuration * Rename nextroll -> nextrollId * Add nextrollId to common ID specs * Qwarry Bid Adapter: add GDPR and consent string handling (#6489) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> * Zemanta Bid Adapter: add support for new params & consent strings to usersync URL (#6468) * add gvl id to spec * add support for bcat and badv params * add consent strings to usersync url * add bcat and badv params to doc * Automatad Bid Adapter: Add meta.advertiserDomains to bid response (#6509) * added bid meta with advertiserDomains * Adhese Bid Adapter: add support for caching video content (#6501) * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * Adhese Bid Adapter: cache video content Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz * update apacdex unit test to disable debug mode (#6511) * Telaria: not setting adid (#6507) * Prebid 4.33.0 Release * increment pre version * rubicon: removing maxduration as a required bidder parameter (#6513) * Zemanta adapter: add advertiserDomains (#6517) * Lemma Bid Adapter: accepting the floor to use the getFloor function (#6497) * lemmaBidAdapter.js Added lemma bid adapter file * lemmaBidAdapter.md Added lemma bid adapter md file * lemmaBidAdapter_spec.js Added lemma bid adapter test spec file * Update lemmaBidAdapter.js Fixed automated code review alert comparison between inconvertible types * Update lemmaBidAdapter.js Fixed review changes * Update lemmaBidAdapter.md Correct parameter value. * Update lemmaBidAdapter.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter_spec.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.md Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.js Added user sync support into bid adapter. * updated include modules file extension. updated include modules js file extension. * Update lemmaBidAdapter_spec.js Added unit test for user sync feature. * Update lemmaBidAdapter.js Fixed format error. * Update lemmaBidAdapter_spec.js Fixed format error and typo error. * Set mediaType key value into bid object Set mediaType key value into the bid object. * Update lemmaBidAdapter.js remove duplicate function * Update lemmaBidAdapter.js Remove non supported code. * Update lemmaBidAdapter_spec.js Remove GDPR test cases. * Update lemmaBidAdapter.js Made changes for accepting the floor to use the getFloor function * Update lemmaBidAdapter.js correct undefined keyword name. * Update lemmaBidAdapter_spec.js Added test coverage floor value * Update lemmaBidAdapter.js Remove trailing spaces on lines 379 and 381. * Update lemmaBidAdapter_spec.js Added getFloor function test case changes, Please review it. * Update lemmaBidAdapter_spec.js * Update lemmaBidAdapter.js * Update lemmaBidAdapter.js Fixed lint issue. * Update lemmaBidAdapter_spec.js Fixed test cases. * Update lemmaBidAdapter_spec.js Made suggested changes. Please review it. Co-authored-by: Abhijit Mane * Mediasquare Bid Adapter: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event (#6480) * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * removing status as it does not seem populated when called * add tests * Update nextroll ID variable name to match published ID module (#6519) * Merkle User ID Module: updates to user id submodule (#6503) * AdKernel Bid/Analytics Adapters: user privacy related changes (#6488) * SynacorMedia: remove adId from the bid response (#6520) * Rubicon: making doc data types consistent (#6526) * Synacormedia Bid Adapter: add meta.advertiserDomains (#6527) * Adloox Analytics Adapter: add new analytics adapter (#6308) * gulp: fix supplying list of browsers to test against The following now works: gulp test --browserstack --nolint --nolintfix --browsers=bs_ie_11_windows_10 --file 'test/spec/modules/adloox{AnalyticsAdapter,AdServerVideo,RtdProvider}_spec.js' * instreamTracking: unit test tidy From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * adloaderStub: expose stub for other unit tests to use From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * Adloox analytic module * Seedtag adapter: Fixing bug preventing to receive the right params onTimeout. (#6525) * adot bid adapter: add publisher path from bidder config to endpoint url (#6476) * Admixer ID System: add userId submodule (#6238) * Migrating to Prebid 1.0 * Migrating to Prebid 1.0 * Fix spec * add gdpr and usp * remove changes in gdpr_hello_world.html * Update gdpr_hello_world.html add spaces * add user syncs * remove comments * tests * admixer id system * admixer id system * admixer id system eids.md userId.md * admixer id system .submodules.json * admixer id system Co-authored-by: atkachov * PBJS Core: call custom render func after loadscript if provided (#6422) * Pubxai Analytics Adapter: bug fixes and code revamp (#6474) * Updated PubxAiAnalytics adapter - Bug fixes and Code restructuring * Updated endpoint URLs * Changed array.includes to array.indexOf to fix IE issue * Code cleanup and changes as suggested. * Updated browser testing order and edge browser token * PBJS Core: canBidderRegisterSync ignoring iframe sync disabled by default (#6535) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update userSync.js * Update userSync_spec.js * Added automatic tzo and targetId to adserver request. (#6534) * Impactify Bid Adapter: add new bid adapter (#6518) * Add impactify adapter with MD file * Add impactify adapter * Prebid 4.34.0 Release * Increment pre version * Prebid server adapter: add config for openx hosting (#6530) * Yieldmo adapter: add meta data to bids (#6550) * Smartx Bid Adapter: Add meta.advertiserDomains support (#6547) * Onevideo / Adap.tv Adapter: updated example configuration (#6546) * Mass Deal Rendering Module: support multiple custom configs for dealId and rendering (#6500) * ZetaSsp Bid Adapter: add new bid adapter (#6432) * Adnuntius Bid Adapter: Fix for bid too low. (#6557) * Added automatic tzo and targetId to adserver request. * Fixing issues with bid price being too low. * Fixing issues with bid price being too low. * ReadPeak Bid Adapter: fix api issues, add gdpr consent, & getfloor module support (#6548) * BetweenBidAdatper: added sharedid support (#6531) * adWMG Bid Adapter: update endpoints for cookie sync (#6544) * Support floorCPM parameter, fix some minor bugs * fix space-in-parens circleci error * example fix * clean usersync URL * spaces * spaces * add new unit tests, compatibility with IE11 * remove logInfo * Check for floorCPM value * Check params before sending * New endpoints * code format * new endpoint for cookie sync * update tests Co-authored-by: Mikhail Dykun * Yieldmo Bid Adapter: add support for the floors module (#6541) * Sortable Bid Adapter: add eids support (#6565) * Add Sortable adapter for Prebid 3.x Update tests to reflect changes. * Add .js in imports * hostname not host: don't include port * Trivial change to trigger build: failure wasn't our adapter * More failures in other adapters * PR Feedback - use https for URL - fix examples in markdown - request to endpoint should work now * Feedback: add native and video examples * Update unit tests Co-authored-by: Shannon Broekhoven * Outbrain Bid Adapter: replacing Zemanta (#6558) * Sirdata Real-time Data Module: add new RTD module (#6515) * Logicad Bid Adapter: add support for userid modules (#6529) * ATS-identityLinkIdSystem - add use3P config property to control firing of 3P envelope endpoint (#6568) * Proxistore Bid Adapter: add support for tcf v2 consent (#6543) * use tcf v2 consent * set cosentGiven to false and test Gdpr api v2 * BlueBillyWig Bid Adapter: add renderer customization options (#6540) * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Update bluebillywigBidAdapter test parameters to match renderer to rendererCode rename * Blue Billywig - Also pass through site config with OpenRTB request * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Code quality update, always hit user syncs, improved video params * Remove unnecessary export * Add rendererSettings param to bluebillywig adapter * Kick off CircleCi tests manually Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie * OpenX Bid Adapter: Set Deal ID for video requests (#6573) * 33Across Bid Adapter: add support for User ID modules (#6554) * pubGENIUS bid adapter: support floor module (#6555) * Welect Bid Adapter: update url of API (#6570) * update api url * update api url in tests * Bright Mountain Media Bid Adapter: change bidder code to bmtm; alias old name (#6574) * Adtelligent Bid Adapter: add adUrl support & new alias (#6559) * add adUrl support * add adUrl test * Bright Mountain Media Bid Adapter: Change Endpoint URL (#6576) * tappxBidAdapter: update * tasppxBidAdapter: add video * tappxBidAdapter: update video * tappxBidAdapter: update name interpret banner * tappxBidAdapter: add tests for video * tappxBidAdapter: add adomain * tappxBidAdapter: update adapter version * tappxBidAdapter: update interpretBid adomain and dealid * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update tests. Adding video to isBidRequestValid * tappxBidAdapter: update doc .md file * Tappx - Change accept floor module * Tappx - feature simplification * Tappx - remove log * Change version * Try to unrevert bad merge change * Tappx - prebid recomendations and changes * Tappx - CircleCI hotfixes * Tappx - Non important fix * Tappx - Test Coverage * Tappx - CircleCI hotfixes * Tappx - Only USD allowed in module floor + test * Tappx - aesthetic change for uniformity of logs * Tappx - CircleCI hotfixes * Tappx - remove don't used module * Tappx - Change the place and only one let * Tappx - use of beforeEach * Tappx - CircleCI hotfixes Co-authored-by: marc_tappx Co-authored-by: Patrick McCann Co-authored-by: onlsol <48312668+onlsol@users.noreply.github.com> Co-authored-by: vincentproxistore <56686565+vincentproxistore@users.noreply.github.com> Co-authored-by: guiann Co-authored-by: Alexander Co-authored-by: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Co-authored-by: SKOCHERI <37454420+SKOCHERI@users.noreply.github.com> Co-authored-by: Abimael Martinez Co-authored-by: artemiokost Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Co-authored-by: Rok Sušnik Co-authored-by: Kanchika - Automatad Co-authored-by: Paweł L Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz Co-authored-by: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Co-authored-by: bretg Co-authored-by: Jason Snellbaker Co-authored-by: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Co-authored-by: Abhijit Mane Co-authored-by: matthieularere-msq <63732822+matthieularere-msq@users.noreply.github.com> Co-authored-by: Denis Logachov Co-authored-by: RAJKUMAR NATARAJAN Co-authored-by: Alexander Clouter Co-authored-by: Laura Morillo-Velarde Co-authored-by: Giudici-a <34242194+Giudici-a@users.noreply.github.com> Co-authored-by: Galphimbl Co-authored-by: atkachov Co-authored-by: Jérémie Girault Co-authored-by: Phaneendra Hegde Co-authored-by: Mikael Lundin Co-authored-by: Thomas Co-authored-by: Mike Chowla Co-authored-by: Deivydas Šabaras Co-authored-by: ym-atsymuk <81176595+ym-atsymuk@users.noreply.github.com> Co-authored-by: Skylinar <53079123+Skylinar@users.noreply.github.com> Co-authored-by: Adam Browning <19834421+adam-browning@users.noreply.github.com> Co-authored-by: Catalin Ciocov Co-authored-by: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Co-authored-by: readpeaktuomo <66239046+readpeaktuomo@users.noreply.github.com> Co-authored-by: Ignat Khaylov Co-authored-by: nyakove <43004249+nyakove@users.noreply.github.com> Co-authored-by: Mikhail Dykun Co-authored-by: ym-dlabuzov <81709888+ym-dlabuzov@users.noreply.github.com> Co-authored-by: karentnarvaez <61426156+karentnarvaez@users.noreply.github.com> Co-authored-by: Shannon Broekhoven Co-authored-by: nouchy <33549554+nouchy@users.noreply.github.com> Co-authored-by: logicad Co-authored-by: mamatic <52153441+mamatic@users.noreply.github.com> Co-authored-by: Klaas-Jan Boon Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie Co-authored-by: Kenan Gillet <1706856+kenan-gillet@users.noreply.github.com> Co-authored-by: Aparna Rao Co-authored-by: Meng <5110935+edmonl@users.noreply.github.com> Co-authored-by: Nick Duitz <42961155+nduitz@users.noreply.github.com> Co-authored-by: BrightMountainMedia <69471268+BrightMountainMediaInc@users.noreply.github.com> Co-authored-by: Gena Co-authored-by: Albert Grandes * Undertone, Unruly, Concert, Adform: stub support for advertiserDomains (#6727) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update openxBidAdapter.js * Update openxBidAdapter.js * Update concertBidAdapter.js * Update unrulyBidAdapter.js * Update undertoneBidAdapter.js * Update adformBidAdapter.js * Update adformBidAdapter_spec.js * Update unrulyBidAdapter_spec.js * Update concertBidAdapter_spec.js * Update undertoneBidAdapter_spec.js * Update undertoneBidAdapter.js * Update adformBidAdapter_spec.js * Update adformBidAdapter_spec.js * Update undertoneBidAdapter_spec.js * Update adformBidAdapter_spec.js * Update adformBidAdapter_spec.js * Bump hosted-git-info from 2.8.8 to 2.8.9 (#6728) Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9. - [Release notes](https://github.com/npm/hosted-git-info/releases) - [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md) - [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * VIS.X: add instream video support (#6687) * VIS.X: add instream video support * VIS.X: move video params from bid.params to mediaTypes.video * move reading and writing of the consent string hash for the user id module to after the gdpr checks. if no user id modules will be executed, this value isn't really necessary anyways. (#6551) * Bright Mountain Media Bid Adapter: add video support and refactor (#6607) * Update BrightMountainMedia cookie sync URL * Bright Mountain Media: Update bidder code * Bright Mountain Media: Add brightmountainmedia as alias * Bright Mountain Media: Update Bid Endpoint * Bright Mountain Media: Add support for Video and refactor * Bright Mountain Media Bid Adapter: add video support and refactor * Bright Mountain Media Bid Adapter: add video support and refactor * Bright Mountain Media Bid Adapter: update test coverage * Bright Mountain Media Bid Adapter: fix typo * Bright Mountain Media Bid Adapter: fix example * Bright Mountain Media Bid Adapter: add support for reading video params from ad unit * Bright Mountain Media Bid Adapter: update read video config from bid.mediaTypes.video object * Bright Mountain Media Bid Adapter: update playbackmethod and skip for video params * Bright Mountain Media Bid Adapter: update skip for video params in test * RTB House Bid Adapter: updated supply chain support, included floor module support and identity module support (eids) (#6721) * ParrableIdSystem : Store third-party cookie support status in first-party cookie (#6689) * Add tpcSupport, read it from xxhr and store it in compound cookie * Parse a cookie boolean number (0, 1) as a boolean value * Improve conditions * Add tests * Tests passing * Read the cookie splitting parrableId and params (tpc, tpcUntil) * Adapt tests * Revert linting in test task * Convert Date.now to seconds on reading cookie * Add tests * Replace Math.trunc with Math.floor Co-authored-by: Victor * Bump lodash from 4.17.19 to 4.17.21 (#6722) * Bump lodash from 4.17.19 to 4.17.21 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ViewDeos: add gvlid (#6737) * Revert "ParrableIdSystem : Store third-party cookie support status in first-party cookie (#6689)" (#6735) This reverts commit ca100f4709f0a1d8782f09c159554a9914217653. * Eplanning Bid Adapter: add eids (#6732) * Adkernel: alias for adomega network (#6739) * Update to move fpd data matching from taxonomyname to segtax values (#6679) * Qwarry Bid Adapter: remove gdpr field from request (#6746) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix * gdpr value added * merge master * gdpr value added * qwarry bid adapter: add tests * Qwarry bid adapter: remove gdpr field from request Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev * Halo RTD Module: add publisher params to RTD request (#6742) * add pub provided halo params to rtd request * missing semicolon * halo id url arg update * Prebid Core: Remove size check on native icons and image assets (#6678) * remove image size checking * fix unit tests * Prebid Server Bid Adapter: Bugfix for not taking defaultVendor enabled (#6740) * quick fix for enabled s2s bug * move enabled check outside of defaultVendor if * Prebid 4.39.0 Release * increment pre version * Beachfront Bid Adapter: add schain support (#6751) * add schain support to beachfront adapter * remove unnecessary mock tests for outstream player Co-authored-by: John Salis * fix: Webpack v5 complain about named export from JSON modules (#6755) * Pbs bid adapter: constants import styling for webpack v5 upgrade (#6723) * mapping spotx dealid to bid object * using proper syntax to import default json module * kick off tests * es lint fix Co-authored-by: Danny Khatib Co-authored-by: Chris Huie <3444727+ChrisHuie@users.noreply.github.com> * First Party Data module: Add new module and two submodules to populate defaults and validate ortb2 (#6452) * Creating fpd module * Continued work on FPD module. - Data validation - Pubcid optout check - Misc Fixes * Revert userId update. Committed in error * Added first party data unit tests and fixed bug * Added an unsubscribe for tests to run properly * Reworked logic to use bidderRequests hook to update global/bidder configs instead of subscribing - former method was preventing tests from completing properly * Merge master * Removing unused references. Fixing device data to point to device.h/device.w * Update to include opt out configuration for enrichments/validations * Modified logic to use ortb2 configuration mapping. This will allow for entries to be added/removed/modified from configuration as opposed to be specifically called out in the validation functions * Removed LGTM unneeded defensive code for check on object 'cur' * Remove unused conditional * Fix lint error * Updates to remove currency enrichment as well as optout for user object * Added optout flag to user.yob and user.gender fields * Added test for arbitrary values Added more comments * Broke module out into module and two submodules * Updated cur to validate as an array of strings not just a string Updated comments * Datablocks bid adapter: update adapter to conform to new bid server's format (#6696) * update datablocks bid adapter * remove TODO and fix linting errors * updated readme and changed insights to ortb2 * fixed ortb2 change Co-authored-by: John Mayor * Update to videoCache to include auction Id in vasttrack payload (#6757) * Revert "Datablocks bid adapter: update adapter to conform to new bid server's format (#6696)" (#6763) This reverts commit 2b8f888dc11d727f49867309f37e492d65eaee96. * clarify dependency on global rtdModule (#6759) As discussed with David from Permutive * Update to PBS bid adapter for video bids, pass along w and h respectively and filter out contxt and playerSize params as PBS does not use them (#6682) * Sovrn and Sharethrough Bid Adapters: support for advertiserDomains (#6764) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update openxBidAdapter.js * Update openxBidAdapter.js * Update sovrnBidAdapter.js * Update sharethroughBidAdapter.js * Update sharethroughBidAdapter_spec.js * Update sovrnBidAdapter_spec.js * Update sovrnBidAdapter_spec.js * Update sharethroughBidAdapter_spec.js * Update sharethroughBidAdapter_spec.js * Update sharethroughBidAdapter_spec.js * ucfunnel Bid Adapter: add support for FLoC and Verizon Media ConnectID (#6744) * Add a new ucfunnel Adapter and test page * Add a new ucfunnel Adapter and test page * 1. Use prebid lib in the repo to keep updated 2. Replace var with let 3. Put JSON.parse(JSON.stringify()) into try catch block * utils.getTopWindowLocation is a function * Change to modules from adapters * Migrate to module design * [Dev Fix] Remove width and height which can be got from ad unit id * Update ucfunnelBidAdapter to fit into new spec * Correct the endpoint. Fix the error of query string * Add test case for ucfunnelBidAdapter * Fix lint error * Update version number * Combine all checks on bid request * Add GDPR support for ucfunnel adapter * Add in-stream video and native support for ucfunnel adapter * Remove demo page. Add more test cases. * Change request method from POST to GET * Remove unnecessary comment * Support vastXml and vastUrl for video request * update TTL to 30 mins * Avoid using arrow function which is not discuraged in mocha * ucfunnel tdid support * ucfunnel fix error message in debug mode * ucfunnel adapter add bidfloor parameter * ucfunnel adapter support CCPA * ucfunnel adapter native support clicktrackers * ucfunnel adapter change cookie sync setting * ucfunnel adapter update request parameter * Update ucfunnelBidAdapter * ucfunnel adapter add currency in ad response * ucfunnel adapter support uid2 * ucfunnel Bid Adapter: add support for FLoC and Verizon Media ConnectID Co-authored-by: root Co-authored-by: Ryan Chou Co-authored-by: ucfunnel Co-authored-by: jack.hsieh * Permutive Rtd Submodule: register submodule in submodules list (#6768) * Beachfront Bid Adapter: update beachfront example docs (#6774) Co-authored-by: John Salis * Eplanning Bid Adapter: Adjust endpoint parameter formatting (#6772) * Beachfront Bid Adapter: add Unified ID 2.0 support (#6770) * appnexus bid adapter - create stub for meta.advertiserDomains (#6753) * Conversant adapter - picks up additional params from mediaTypes.video (#6775) * Relaido Adapter : size of the banner is checked and the banner can be bid on. (#6776) * add relaido adapter * remove event listener * fixed UserSyncs and e.data * fix conflicts * take size each mediaType Co-authored-by: ishigami_shingo Co-authored-by: cmertv-sishigami Co-authored-by: t_bun * ZetaSspBidAdapter fix typo (#6777) Co-authored-by: Surovenko Alexey * Adagio Bid Adapter: handle meta.advertiserDomains (and more) (#6781) Related to #6650 * PubMatic Adapter: add support for FloCID (#6749) * changes to support native in pubmaticbid adapter * Removed port from endpoint * Removed protocol from endpoint * Formatting * Fix request payload * Updated test case * Changed request and response as per ortb spec * Change in request and response * Removed comments and extra code * Code Review comments * Code Review Comments and Test cases for request and response * Removed data type as all data asset types are handled * Code Review Changes * Code Review Comments * Supporting both banner and native and sending 0x0 in case of native * Bug Fixes * Bug response not processed by prebid * Change warning message * Fixed typo * Do not send request in case of invalid native bid * Do not send request in case of invalid native requests * objects converted to strings in log for debug purposes * Fixed logic to check for required parmas * Fixed typo for stringify * documentation for native * Review comments from Prebid * Typo * Typo * Updated pub id for native * Code Review * Support for pubid * Test Cases for PubCommonId in PubMatic adapter * Delete yarn.lock * Rename adaptermanager.js to adapterManager.js * Rename yieldNexusBidAdapter.js to yieldnexusBidAdapter.js * Rename yieldNexusBidAdapter.md to yieldnexusBidAdapter.md * Rename yieldNexusBidAdapter_spec.js to yieldnexusBidAdapter_spec.yieldnexusBidAdaptera * Rename yieldnexusBidAdapter_spec.yieldnexusBidAdaptera to yieldnexusBidAdapter_spec.js * bluebillywig outstream player support in pubmatic adapter * removed pubcommon id test cases * BBW Renderer * Pubmatic should work with provided renderer * Review Comments * changes for flocId * code review comments * fixed for eids * code review comments * unit test cases for floc * updated md file * code review comment * TrustX Bid Adapter: added additional sync url (#6771) * Bucksense Bid Adapter: add adomain to adapter (#6779) * Update bucksenseBidAdapter.js Added support for advertiserDomains * Update bucksenseBidAdapter_spec.js Co-authored-by: Patrick McCann * Update to PBS Bid Adapter and RP Bid Adapter to pass PBJS version in auction requests (#6767) * AOL Bid Adapter: Remove client side support for already deprecated endpoint floor support (#6743) * tappx Bid Adapter: update isBidRequestValid and fix request url (#6761) * UPDATE: add initial UID * UPDATE: UID change user ext * UPDATE: UID clean logs * UPDATE: add host info * UPDATE: tappx bid adapter universal id * UPDATE: fix bidder param * UPDATE: tappxBidAdapter tests * tappxBidAdapter - fix spacing * tappxBidAdapter: add test user eids array * tappxBidAdapter: update eids array * FIX: package-lock.json * Conversant adapter: add adomain, remove digitrust (#6495) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update conversantBidAdapter.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Rads Bid Adapter: add GDPR support & user sync support (#6455) * Proxistore Bid Adapter: add cookieless url endpoint & use floor module (#6427) * use floor module * call cookieless endpoint when necessary * test endpoint url * change url endpoint * delete console log * fix tests * add language to url * use ortb interface * unit test * update test unit * create proxistore module * add unit tests and documentation * delete modules * delete module * add proxistore rtd submodule * delete proxistore module * spacing * change url * AdYoulike Bid Adapter: Add an "Insertion" tracking for Native mediatype (#6481) * add insertion event * add missing campaign ID parameter * update unit test with new tracking checked * Dspx Bid Adapter : add user sync support (#6456) * Add sync support for dspx adapter * Dspx Bid Adapter : add user sync support Co-authored-by: Alexander * Multibid Module: add new module to handle multiple bids from single bidder & update rubicon adapter (#6404) * Multibid module - create new module - Expands the number of key value pairs going to the ad server in the normal Prebid way by establishing the concept of a "dynamic alias" First commit * Continued updates from 1st commit * Adding logWarn for filtered bids * Update to include passing multibid configuration to PBS requests * Update to rubicon bid adapter to pass query param rp_maxbids value taken from bidderRequest.bidLimit * Update to config to look for camelcase property names according to spec. These convert to all lowercase when passed to PBS endpoint * Adjust RP adapter to always include maxbids value - default is 1 * Added support for bidders array in multibid config * Fixed floor comparison to be <= bid cpm as oppossed to just < bid cpm. Updated md file to fix camelCase tpyo * Update to include originalBidderRequest in video call to prebid cache * Update to ignore adpod bids from multibid and allow them to return as normal bids * Adding uid2 to submodules.json (#6508) * NextRoll ID System: add new ID module (#6396) * Add Nextroll ID Module * Add nextroll to eids * Make configuration value names consistent with Adapter Module * Use parnerId instead of sellerId * Add nextroll to userId and eids md files * Remove storage configuration * Rename nextroll -> nextrollId * Add nextrollId to common ID specs * Qwarry Bid Adapter: add GDPR and consent string handling (#6489) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> * Zemanta Bid Adapter: add support for new params & consent strings to usersync URL (#6468) * add gvl id to spec * add support for bcat and badv params * add consent strings to usersync url * add bcat and badv params to doc * Automatad Bid Adapter: Add meta.advertiserDomains to bid response (#6509) * added bid meta with advertiserDomains * Adhese Bid Adapter: add support for caching video content (#6501) * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * Adhese Bid Adapter: cache video content Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz * update apacdex unit test to disable debug mode (#6511) * Telaria: not setting adid (#6507) * Prebid 4.33.0 Release * increment pre version * rubicon: removing maxduration as a required bidder parameter (#6513) * Zemanta adapter: add advertiserDomains (#6517) * Lemma Bid Adapter: accepting the floor to use the getFloor function (#6497) * lemmaBidAdapter.js Added lemma bid adapter file * lemmaBidAdapter.md Added lemma bid adapter md file * lemmaBidAdapter_spec.js Added lemma bid adapter test spec file * Update lemmaBidAdapter.js Fixed automated code review alert comparison between inconvertible types * Update lemmaBidAdapter.js Fixed review changes * Update lemmaBidAdapter.md Correct parameter value. * Update lemmaBidAdapter.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter_spec.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.md Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.js Added user sync support into bid adapter. * updated include modules file extension. updated include modules js file extension. * Update lemmaBidAdapter_spec.js Added unit test for user sync feature. * Update lemmaBidAdapter.js Fixed format error. * Update lemmaBidAdapter_spec.js Fixed format error and typo error. * Set mediaType key value into bid object Set mediaType key value into the bid object. * Update lemmaBidAdapter.js remove duplicate function * Update lemmaBidAdapter.js Remove non supported code. * Update lemmaBidAdapter_spec.js Remove GDPR test cases. * Update lemmaBidAdapter.js Made changes for accepting the floor to use the getFloor function * Update lemmaBidAdapter.js correct undefined keyword name. * Update lemmaBidAdapter_spec.js Added test coverage floor value * Update lemmaBidAdapter.js Remove trailing spaces on lines 379 and 381. * Update lemmaBidAdapter_spec.js Added getFloor function test case changes, Please review it. * Update lemmaBidAdapter_spec.js * Update lemmaBidAdapter.js * Update lemmaBidAdapter.js Fixed lint issue. * Update lemmaBidAdapter_spec.js Fixed test cases. * Update lemmaBidAdapter_spec.js Made suggested changes. Please review it. Co-authored-by: Abhijit Mane * Mediasquare Bid Adapter: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event (#6480) * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * removing status as it does not seem populated when called * add tests * Update nextroll ID variable name to match published ID module (#6519) * Merkle User ID Module: updates to user id submodule (#6503) * AdKernel Bid/Analytics Adapters: user privacy related changes (#6488) * SynacorMedia: remove adId from the bid response (#6520) * Rubicon: making doc data types consistent (#6526) * Synacormedia Bid Adapter: add meta.advertiserDomains (#6527) * Adloox Analytics Adapter: add new analytics adapter (#6308) * gulp: fix supplying list of browsers to test against The following now works: gulp test --browserstack --nolint --nolintfix --browsers=bs_ie_11_windows_10 --file 'test/spec/modules/adloox{AnalyticsAdapter,AdServerVideo,RtdProvider}_spec.js' * instreamTracking: unit test tidy From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * adloaderStub: expose stub for other unit tests to use From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * Adloox analytic module * Seedtag adapter: Fixing bug preventing to receive the right params onTimeout. (#6525) * adot bid adapter: add publisher path from bidder config to endpoint url (#6476) * Admixer ID System: add userId submodule (#6238) * Migrating to Prebid 1.0 * Migrating to Prebid 1.0 * Fix spec * add gdpr and usp * remove changes in gdpr_hello_world.html * Update gdpr_hello_world.html add spaces * add user syncs * remove comments * tests * admixer id system * admixer id system * admixer id system eids.md userId.md * admixer id system .submodules.json * admixer id system Co-authored-by: atkachov * PBJS Core: call custom render func after loadscript if provided (#6422) * Pubxai Analytics Adapter: bug fixes and code revamp (#6474) * Updated PubxAiAnalytics adapter - Bug fixes and Code restructuring * Updated endpoint URLs * Changed array.includes to array.indexOf to fix IE issue * Code cleanup and changes as suggested. * Updated browser testing order and edge browser token * PBJS Core: canBidderRegisterSync ignoring iframe sync disabled by default (#6535) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update userSync.js * Update userSync_spec.js * Added automatic tzo and targetId to adserver request. (#6534) * Impactify Bid Adapter: add new bid adapter (#6518) * Add impactify adapter with MD file * Add impactify adapter * Prebid 4.34.0 Release * Increment pre version * Prebid server adapter: add config for openx hosting (#6530) * Yieldmo adapter: add meta data to bids (#6550) * Smartx Bid Adapter: Add meta.advertiserDomains support (#6547) * Onevideo / Adap.tv Adapter: updated example configuration (#6546) * Mass Deal Rendering Module: support multiple custom configs for dealId and rendering (#6500) * ZetaSsp Bid Adapter: add new bid adapter (#6432) * Adnuntius Bid Adapter: Fix for bid too low. (#6557) * Added automatic tzo and targetId to adserver request. * Fixing issues with bid price being too low. * Fixing issues with bid price being too low. * ReadPeak Bid Adapter: fix api issues, add gdpr consent, & getfloor module support (#6548) * BetweenBidAdatper: added sharedid support (#6531) * adWMG Bid Adapter: update endpoints for cookie sync (#6544) * Support floorCPM parameter, fix some minor bugs * fix space-in-parens circleci error * example fix * clean usersync URL * spaces * spaces * add new unit tests, compatibility with IE11 * remove logInfo * Check for floorCPM value * Check params before sending * New endpoints * code format * new endpoint for cookie sync * update tests Co-authored-by: Mikhail Dykun * Yieldmo Bid Adapter: add support for the floors module (#6541) * Sortable Bid Adapter: add eids support (#6565) * Add Sortable adapter for Prebid 3.x Update tests to reflect changes. * Add .js in imports * hostname not host: don't include port * Trivial change to trigger build: failure wasn't our adapter * More failures in other adapters * PR Feedback - use https for URL - fix examples in markdown - request to endpoint should work now * Feedback: add native and video examples * Update unit tests Co-authored-by: Shannon Broekhoven * Outbrain Bid Adapter: replacing Zemanta (#6558) * Sirdata Real-time Data Module: add new RTD module (#6515) * Logicad Bid Adapter: add support for userid modules (#6529) * ATS-identityLinkIdSystem - add use3P config property to control firing of 3P envelope endpoint (#6568) * Proxistore Bid Adapter: add support for tcf v2 consent (#6543) * use tcf v2 consent * set cosentGiven to false and test Gdpr api v2 * BlueBillyWig Bid Adapter: add renderer customization options (#6540) * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Update bluebillywigBidAdapter test parameters to match renderer to rendererCode rename * Blue Billywig - Also pass through site config with OpenRTB request * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Code quality update, always hit user syncs, improved video params * Remove unnecessary export * Add rendererSettings param to bluebillywig adapter * Kick off CircleCi tests manually Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie * OpenX Bid Adapter: Set Deal ID for video requests (#6573) * 33Across Bid Adapter: add support for User ID modules (#6554) * pubGENIUS bid adapter: support floor module (#6555) * Welect Bid Adapter: update url of API (#6570) * update api url * update api url in tests * Bright Mountain Media Bid Adapter: change bidder code to bmtm; alias old name (#6574) * Adtelligent Bid Adapter: add adUrl support & new alias (#6559) * add adUrl support * add adUrl test * Bright Mountain Media Bid Adapter: Change Endpoint URL (#6576) * tappxBidAdapter: update * tasppxBidAdapter: add video * tappxBidAdapter: update video * tappxBidAdapter: update name interpret banner * tappxBidAdapter: add tests for video * tappxBidAdapter: add adomain * tappxBidAdapter: update adapter version * tappxBidAdapter: update interpretBid adomain and dealid * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update tests. Adding video to isBidRequestValid * tappxBidAdapter: update doc .md file * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update ads sizes available * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update host depending tappx endpoint * tappxBidAdapter: update tappx adapter version * tappxBidAdapter: add EOL * revert outbrain cahnges to untrack in this pr * tappxBidAdapter: update isBidRequestValid tests * tappxBidAdapter: fix circleci error Co-authored-by: marc_tappx Co-authored-by: Patrick McCann Co-authored-by: onlsol <48312668+onlsol@users.noreply.github.com> Co-authored-by: vincentproxistore <56686565+vincentproxistore@users.noreply.github.com> Co-authored-by: guiann Co-authored-by: Alexander Co-authored-by: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Co-authored-by: SKOCHERI <37454420+SKOCHERI@users.noreply.github.com> Co-authored-by: Abimael Martinez Co-authored-by: artemiokost Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Co-authored-by: Rok Sušnik Co-authored-by: Kanchika - Automatad Co-authored-by: Paweł L Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz Co-authored-by: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Co-authored-by: bretg Co-authored-by: Jason Snellbaker Co-authored-by: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Co-authored-by: Abhijit Mane Co-authored-by: matthieularere-msq <63732822+matthieularere-msq@users.noreply.github.com> Co-authored-by: Denis Logachov Co-authored-by: RAJKUMAR NATARAJAN Co-authored-by: Alexander Clouter Co-authored-by: Laura Morillo-Velarde Co-authored-by: Giudici-a <34242194+Giudici-a@users.noreply.github.com> Co-authored-by: Galphimbl Co-authored-by: atkachov Co-authored-by: Jérémie Girault Co-authored-by: Phaneendra Hegde Co-authored-by: Mikael Lundin Co-authored-by: Thomas Co-authored-by: Mike Chowla Co-authored-by: Deivydas Šabaras Co-authored-by: ym-atsymuk <81176595+ym-atsymuk@users.noreply.github.com> Co-authored-by: Skylinar <53079123+Skylinar@users.noreply.github.com> Co-authored-by: Adam Browning <19834421+adam-browning@users.noreply.github.com> Co-authored-by: Catalin Ciocov Co-authored-by: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Co-authored-by: readpeaktuomo <66239046+readpeaktuomo@users.noreply.github.com> Co-authored-by: Ignat Khaylov Co-authored-by: nyakove <43004249+nyakove@users.noreply.github.com> Co-authored-by: Mikhail Dykun Co-authored-by: ym-dlabuzov <81709888+ym-dlabuzov@users.noreply.github.com> Co-authored-by: karentnarvaez <61426156+karentnarvaez@users.noreply.github.com> Co-authored-by: Shannon Broekhoven Co-authored-by: nouchy <33549554+nouchy@users.noreply.github.com> Co-authored-by: logicad Co-authored-by: mamatic <52153441+mamatic@users.noreply.github.com> Co-authored-by: Klaas-Jan Boon Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie Co-authored-by: Kenan Gillet <1706856+kenan-gillet@users.noreply.github.com> Co-authored-by: Aparna Rao Co-authored-by: Meng <5110935+edmonl@users.noreply.github.com> Co-authored-by: Nick Duitz <42961155+nduitz@users.noreply.github.com> Co-authored-by: BrightMountainMedia <69471268+BrightMountainMediaInc@users.noreply.github.com> Co-authored-by: Gena Co-authored-by: Chris Huie <3444727+ChrisHuie@users.noreply.github.com> * Qwarry Bid Adapter: add sizes (#6787) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix * gdpr value added * merge master * gdpr value added * qwarry bid adapter: add tests * Qwarry bid adapter: remove gdpr field from request * qwarry bid adapter: add sizes * qwarry bid adapter: add sizes Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev * Medianet bid adapter: floor module support (#6713) * Medianet floor module support * removing backslash from wildcard * add adomain support (#6791) Co-authored-by: Ignat Khaylov * Beachfront Bid Adapter: add floors module support (#6752) * add price floors support to beachfront adapter * revert doc changes to create separate pull request Co-authored-by: John Salis * Zeta Ssp Bid Adapter: merge fpd.device and params.device (#6786) * pubGENIUS bid adapter: read more video params from mediaTypes.video (#6793) * Remove camel case for adserver.adslot value in RP Analytics Adapter (#6795) * Prebid 4.40.0 Release * Increment pre version * CCX Bid Adapter: add support for mediatypes video parameters (#6736) * adomain support * adomain support * adomain support * adomain support * adomain support * video params * docs changes * Index Exchange Bid Adapter: adds support for floc (#6758) * InvibesBidAdapter - multiposition support & support for multiple id modules (#6506) * appnexus bid adapter: add support for flocid (#6801) * appnexus bid adapter: add support for uid2 (#6802) * Delete xhbBidAdapter.js * Restore xhb (#6803) * EMX Digital Bid Adapter: floor module and advertiserDomain support (#6805) * Index Exchange Bid Adapter: coppa support, dealid & ttl field updates (#6782) * set bidderRequestId to be a string in r.id * set coppa value in r.reqs.coppa * added support for seat[].bid[].exp ttl value * read dealid from openrtb first, then fallback to ext * use utils.isInteger Co-authored-by: Kajan Umakanthan Co-authored-by: punkiller * Update permutiveRtdProvider.md (#6810) Updated to reflect current audience connector support. * Conversant adapter - add support for the floor module (#6798) * appnexus bid adapter 5.0 - video params updates (#6690) * Update refererDetection.js (#6812) * Single Adform adapter (#6840) * Adf Bid Adapter: banner and video media type support added (#6726) (cherry picked from commit 6580bf446ab0196fa48f34de3969510bb2dae698) * single adform bid adapter * Revert "Adf Bid Adapter: banner and video media type support added (#6726)" This reverts commit 0ada455bc8432b1da3359d1b6a5c5f1190cae27e. * Criteo: add mapping for bid adomain (#6915) * Update dfpAdServerVideo.js (#6464) * Rule enforcement: adapters supporting OpenRTB video parameters must be capable of reading them from the ad unit (#6947) * Delete advangelistsBidAdapter.js * Delete lunamediaBidAdapter.js * Delete dailyhuntBidAdapter.js * Delete lemmaBidAdapter.js * Delete waardexBidAdapter.js * Delete advangelistsBidAdapter_spec.js * Delete dailyhuntBidAdapter_spec.js * Delete lemmaBidAdapter_spec.js * Delete lunamediaBidAdapter_spec.js * Delete waardexBidAdapter_spec.js * AOL Bid Adapter: Remove validation of bidder specific video params for Nexage endpoint call formation (#6766) * Update aolBidAdapter.js * Update aolBidAdapter.js * Outbrain: fix linting errors in 5.0 branch from merging (#6952) * add newline for linting * add newline * Invibes Bid Adapter: resolve prebid 5 merge conflict (#6960) * Pubcommon id and shared id submodules: merge into one submodule (#6808) * Rules enforcement: bidders must bid (#6945) ] * Waardex bid adapter: fixes for Prebid 5 (#6959) * Add Waardex js * Update waardexBidAdapter.md * Add files via upload * Update invibesBidAdapter.js * PBS Bid Adapter: No longer pass test=1 on debug mode (#6924) * Update index.js * Update index.js * Rule enforcement: support for floors must include the floors module (#6804) * Rule Enforcement: include support for adomain (#6986) Co-authored-by: Jason Snellbaker Co-authored-by: bretg Co-authored-by: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Co-authored-by: Abhijit Mane Co-authored-by: matthieularere-msq <63732822+matthieularere-msq@users.noreply.github.com> Co-authored-by: Abimael Martinez Co-authored-by: SKOCHERI <37454420+SKOCHERI@users.noreply.github.com> Co-authored-by: Denis Logachov Co-authored-by: RAJKUMAR NATARAJAN Co-authored-by: Alexander Clouter Co-authored-by: Laura Morillo-Velarde Co-authored-by: Giudici-a <34242194+Giudici-a@users.noreply.github.com> Co-authored-by: Galphimbl Co-authored-by: atkachov Co-authored-by: Jérémie Girault Co-authored-by: Phaneendra Hegde Co-authored-by: Mikael Lundin Co-authored-by: prebidtappx <77485538+prebidtappx@users.noreply.github.com> Co-authored-by: marc_tappx Co-authored-by: Thomas Co-authored-by: Mike Chowla Co-authored-by: Deivydas Šabaras Co-authored-by: ym-atsymuk <81176595+ym-atsymuk@users.noreply.github.com> Co-authored-by: Skylinar <53079123+Skylinar@users.noreply.github.com> Co-authored-by: Adam Browning <19834421+adam-browning@users.noreply.github.com> Co-authored-by: Catalin Ciocov Co-authored-by: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Co-authored-by: readpeaktuomo <66239046+readpeaktuomo@users.noreply.github.com> Co-authored-by: Ignat Khaylov Co-authored-by: nyakove <43004249+nyakove@users.noreply.github.com> Co-authored-by: Mikhail Dykun Co-authored-by: ym-dlabuzov <81709888+ym-dlabuzov@users.noreply.github.com> Co-authored-by: karentnarvaez <61426156+karentnarvaez@users.noreply.github.com> Co-authored-by: Shannon Broekhoven Co-authored-by: Rok Sušnik Co-authored-by: nouchy <33549554+nouchy@users.noreply.github.com> Co-authored-by: logicad Co-authored-by: mamatic <52153441+mamatic@users.noreply.github.com> Co-authored-by: vincentproxistore <56686565+vincentproxistore@users.noreply.github.com> Co-authored-by: Klaas-Jan Boon Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie Co-authored-by: Kenan Gillet <1706856+kenan-gillet@users.noreply.github.com> Co-authored-by: Aparna Rao Co-authored-by: Meng <5110935+edmonl@users.noreply.github.com> Co-authored-by: Nick Duitz <42961155+nduitz@users.noreply.github.com> Co-authored-by: BrightMountainMedia <69471268+BrightMountainMediaInc@users.noreply.github.com> Co-authored-by: Gena Co-authored-by: bjorn-lw <32431346+bjorn-lw@users.noreply.github.com> Co-authored-by: Robert Ray Martinez III Co-authored-by: PWyrembak Co-authored-by: couchcrew-thomas Co-authored-by: Matt Felstead Co-authored-by: Sergio Co-authored-by: ym-abaranov <78230460+ym-abaranov@users.noreply.github.com> Co-authored-by: Rich Audience Co-authored-by: sgimenez Co-authored-by: Scott Menzer Co-authored-by: Sourabh Gandhe Co-authored-by: Sourabh Gandhe Co-authored-by: ChinmoyDebnath Co-authored-by: Nick Peceniak Co-authored-by: Nick Peceniak Co-authored-by: Michael Kuryshev Co-authored-by: Kajan Umakanthan Co-authored-by: Maxime DEYMÈS <47388595+MaxSmileWanted@users.noreply.github.com> Co-authored-by: jsfledd Co-authored-by: Mathieu Pheulpin Co-authored-by: Anthony Lauzon Co-authored-by: fasenderos Co-authored-by: Andrea Fassina Co-authored-by: Serhii Kozlov Co-authored-by: amykwyang Co-authored-by: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Co-authored-by: Harshad Mane Co-authored-by: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Co-authored-by: Anton Tsymuk Co-authored-by: adxcgcom <31470944+adxcgcom@users.noreply.github.com> Co-authored-by: mwehr-zeta <70167335+mwehr-zeta@users.noreply.github.com> Co-authored-by: Bendegúz Ács <30595431+acsbendi@users.noreply.github.com> Co-authored-by: wojciech-bialy-wpm <67895844+wojciech-bialy-wpm@users.noreply.github.com> Co-authored-by: Wojciech Biały Co-authored-by: pratik-synacor <64602199+pratik-synacor@users.noreply.github.com> Co-authored-by: Fridoom007 Co-authored-by: mjaworskiccx <50406214+mjaworskiccx@users.noreply.github.com> Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: Jurij Sinickij Co-authored-by: susyt Co-authored-by: Serhii Mozhaiskyi <57671975+smozhaiskyi-rubi@users.noreply.github.com> Co-authored-by: Surovenko Alexey Co-authored-by: David Reischer Co-authored-by: Roberto Hsu Wu Co-authored-by: TheMediaGrid <44166371+TheMediaGrid@users.noreply.github.com> Co-authored-by: JonGoSonobi Co-authored-by: supportGothamad <75782642+supportGothamad@users.noreply.github.com> Co-authored-by: Thomas Skaarnes Nikitin <48713095+thomas-netric@users.noreply.github.com> Co-authored-by: jackhsiehucf <77815341+jackhsiehucf@users.noreply.github.com> Co-authored-by: root Co-authored-by: Ryan Chou Co-authored-by: ucfunnel Co-authored-by: jack.hsieh Co-authored-by: yuvalgg <57989766+yuvalgg@users.noreply.github.com> Co-authored-by: John Rosendahl Co-authored-by: Reinout Stevens Co-authored-by: Reinout Stevens Co-authored-by: onlsol <48312668+onlsol@users.noreply.github.com> Co-authored-by: guiann Co-authored-by: Alexander Co-authored-by: artemiokost Co-authored-by: Kanchika - Automatad Co-authored-by: Paweł L Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz Co-authored-by: Albert Grandes Co-authored-by: Eric Harper Co-authored-by: Nepomuk Seiler Co-authored-by: César Fernández Co-authored-by: cs83 Co-authored-by: Dmitri Co-authored-by: IOTiagoFaria <76956619+IOTiagoFaria@users.noreply.github.com> Co-authored-by: EC2 Default User Co-authored-by: Rigel Cheng Co-authored-by: cycheng Co-authored-by: karthik <60045218+boppudikarthikc@users.noreply.github.com> Co-authored-by: Matt Fitzgerald Co-authored-by: Karthik Boppudi Co-authored-by: mfitzgerald_dmd Co-authored-by: skocheri Co-authored-by: Rich Snapp Co-authored-by: Stephen Johnston Co-authored-by: Léonard Labat Co-authored-by: Matt Kendall <1870166+mkendall07@users.noreply.github.com> Co-authored-by: Max Duval Co-authored-by: AdmixerTech <35560933+AdmixerTech@users.noreply.github.com> Co-authored-by: Carlos Felix Co-authored-by: Richard Lee <14349+dlackty@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: rtbh-lotani <83652735+rtbh-lotani@users.noreply.github.com> Co-authored-by: Ian Flournoy Co-authored-by: Victor Co-authored-by: Chris Huie <3444727+ChrisHuie@users.noreply.github.com> Co-authored-by: hdwmsconfig Co-authored-by: John Salis Co-authored-by: John Salis Co-authored-by: Javier Marín Co-authored-by: Danny Khatib Co-authored-by: Danny Khatib Co-authored-by: htang555 Co-authored-by: John Mayor Co-authored-by: Paul Yang Co-authored-by: relaido <63339139+relaido@users.noreply.github.com> Co-authored-by: ishigami_shingo Co-authored-by: cmertv-sishigami Co-authored-by: t_bun Co-authored-by: Olivier Co-authored-by: pm-shashank-jain <40654031+pm-shashank-jain@users.noreply.github.com> Co-authored-by: Stefano <50023896+bkse-stefanodechicchis@users.noreply.github.com> Co-authored-by: Rahul Shandilya <67756716+c3p-0@users.noreply.github.com> Co-authored-by: Ignat Khaylov Co-authored-by: rcheptanariu <35690143+rcheptanariu@users.noreply.github.com> Co-authored-by: Dan Bogdan <43830380+EMXDigital@users.noreply.github.com> Co-authored-by: lksharma Co-authored-by: punkiller Co-authored-by: Steven Francolla Co-authored-by: NothingIsMatter <45894257+NothingIsMatter@users.noreply.github.com> --- .../gpt/idImportLibrary_example.html | 12 +- integrationExamples/gpt/userId_example.html | 14 +- modules/1ad4goodBidAdapter.js | 399 -- modules/1ad4goodBidAdapter.md | 87 - modules/7xbidBidAdapter.js | 159 - modules/aardvarkBidAdapter.js | 262 -- modules/adbutlerBidAdapter.js | 140 - modules/adfinityBidAdapter.js | 125 - modules/adformBidAdapter.js | 213 - modules/adformBidAdapter.md | 30 - 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/adrelevantisBidAdapter.js | 3 - modules/adspendBidAdapter.js | 164 - modules/adtrueBidAdapter.js | 11 +- modules/advangelistsBidAdapter.js | 378 -- modules/advenueBidAdapter.js | 86 - modules/advertlyBidAdapter.js | 127 - modules/ajaBidAdapter.js | 194 - modules/aolBidAdapter.js | 4 +- modules/appnexusBidAdapter.js | 46 + modules/appnexusBidAdapter.md | 13 +- modules/atomxBidAdapter.js | 107 - modules/avocetBidAdapter.js | 141 - modules/betweenBidAdapter.js | 13 +- modules/bidfluenceBidAdapter.js | 131 - modules/bidlabBidAdapter.js | 112 - modules/bidphysicsBidAdapter.js | 134 - modules/bizzclickBidAdapter.js | 326 -- modules/boldwinBidAdapter.js | 110 - modules/byplayBidAdapter.js | 67 - modules/c1xBidAdapter.js | 178 - modules/cedatoBidAdapter.js | 229 - modules/cleanmedianetBidAdapter.js | 2 +- 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/cosmosBidAdapter.js | 392 -- modules/cpmstarBidAdapter.js | 180 - modules/criteoBidAdapter.js | 86 +- modules/criteoBidAdapter.md | 5 +- modules/dailyhuntBidAdapter.js | 395 -- modules/decenteradsBidAdapter.js | 90 - modules/dfpAdServerVideo.js | 4 +- modules/districtmDMXBidAdapter.js | 1 - modules/djaxBidAdapter.js | 129 - modules/e_volutionBidAdapter.js | 111 - modules/ebdrBidAdapter.js | 151 - 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/getintentBidAdapter.js | 160 - modules/gnetBidAdapter.js | 101 - modules/haxmediaBidAdapter.js | 107 - modules/hpmdnetworkBidAdapter.js | 96 - modules/iasBidAdapter.js | 134 - modules/iasBidAdapter.md | 30 - modules/imonomyBidAdapter.js | 130 - modules/impactifyBidAdapter.js | 260 -- modules/innityBidAdapter.js | 58 - modules/ipromBidAdapter.js | 79 - modules/ironsourceBidAdapter.js | 251 -- modules/ixBidAdapter.js | 1 - modules/jcmBidAdapter.js | 89 - modules/komoonaBidAdapter.js | 121 - modules/krushmediaBidAdapter.js | 123 - modules/kubientBidAdapter.js | 111 - modules/lemmaBidAdapter.js | 442 -- modules/lifestreetBidAdapter.js | 139 - modules/lkqdBidAdapter.js | 284 -- modules/loganBidAdapter.js | 118 - modules/logicadBidAdapter.js | 69 - modules/loopmeBidAdapter.js | 149 - modules/lunamediaBidAdapter.js | 399 -- modules/luponmediaBidAdapter.js | 389 -- modules/madvertiseBidAdapter.js | 96 - modules/mantisBidAdapter.js | 310 -- modules/meazyBidAdapter.js | 149 - modules/mediaforceBidAdapter.js | 2 +- modules/mediagoBidAdapter.js | 375 -- modules/mgidBidAdapter.js | 576 --- modules/microadBidAdapter.js | 151 - modules/missenaBidAdapter.js | 94 - modules/mobfoxBidAdapter.js | 133 - modules/mobfoxpbBidAdapter.js | 99 - modules/mobsmartBidAdapter.js | 94 - modules/mytargetBidAdapter.js | 113 - modules/nafdigitalBidAdapter.js | 245 -- modules/nanointeractiveBidAdapter.js | 159 - modules/nasmediaAdmixerBidAdapter.js | 85 - modules/newborntownWebBidAdapter.js | 159 - modules/nextMillenniumBidAdapter.js | 75 - modules/nextrollBidAdapter.js | 345 -- modules/oneVideoBidAdapter.md | 2 +- modules/open8BidAdapter.js | 185 - modules/openxBidAdapter.js | 1 - modules/optimeraBidAdapter.js | 85 - modules/optimeraBidAdapter.md | 58 - modules/orbidderBidAdapter.js | 1 - modules/otmBidAdapter.js | 95 - modules/outconBidAdapter.js | 69 - modules/ozoneBidAdapter.js | 1 + modules/papyrusBidAdapter.js | 77 - modules/performaxBidAdapter.js | 56 - modules/piximediaBidAdapter.js | 47 - modules/platformioBidAdapter.js | 307 -- modules/prebidServerBidAdapter/index.js | 10 +- modules/projectLimeLightBidAdapter.js | 122 - modules/proxistoreBidAdapter.js | 151 - modules/pubCommonIdSystem.js | 345 -- modules/pubxBidAdapter.js | 94 - modules/reklamstoreBidAdapter.js | 148 - modules/reloadBidAdapter.js | 419 -- modules/resultsmediaBidAdapter.js | 269 -- modules/revcontentBidAdapter.js | 275 -- modules/rhythmoneBidAdapter.js | 2 +- modules/riseBidAdapter.js | 251 -- modules/rtbdemandBidAdapter.js | 123 - modules/rtbsapeBidAdapter.js | 142 - modules/rtbsolutionsBidAdapter.js | 100 - modules/rubiconBidAdapter.js | 6 +- modules/saambaaBidAdapter.js | 401 -- modules/seedingAllianceBidAdapter.js | 225 - modules/segmentoBidAdapter.js | 85 - modules/sekindoUMBidAdapter.js | 119 - modules/sharedIdSystem.js | 529 ++- modules/sharedIdSystem.md | 43 - modules/sharethroughBidAdapter.js | 3 - modules/shinezBidAdapter.js | 83 - modules/slimcutBidAdapter.js | 128 - modules/smarticoBidAdapter.js | 116 - modules/smartrtbBidAdapter.js | 133 - modules/smmsBidAdapter.js | 156 - modules/somoBidAdapter.js | 289 -- modules/sonobiBidAdapter.js | 2 +- modules/sortableBidAdapter.js | 351 -- modules/spotxBidAdapter.js | 4 - modules/stvBidAdapter.js | 150 - modules/taphypeBidAdapter.js | 45 - modules/timBidAdapter.js | 177 - modules/topRTBBidAdapter.js | 65 - modules/trendqubeBidAdapter.js | 102 - modules/tribeosBidAdapter.js | 165 - modules/truereachBidAdapter.js | 2 +- modules/turktelekomBidAdapter.js | 261 -- modules/ucfunnelBidAdapter.js | 8 - modules/unicornBidAdapter.js | 160 - modules/userId/eids.js | 14 - modules/userId/eids.md | 11 - modules/userId/index.js | 3 +- modules/userId/userId.md | 10 - 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/vrtcalBidAdapter.js | 88 - modules/vubleBidAdapter.js | 198 - modules/waardexBidAdapter.js | 2 +- modules/waardexBidAdapter.md | 36 +- modules/welectBidAdapter.js | 106 - modules/widespaceBidAdapter.js | 2 +- modules/windtalkerBidAdapter.js | 307 -- modules/wipesBidAdapter.js | 71 - modules/xhbBidAdapter.js | 457 -- modules/zedoBidAdapter.js | 342 -- modules/zemantaBidAdapter.js | 281 -- modules/zemantaBidAdapter.md | 111 - src/constants.json | 2 - src/prebid.js | 16 + src/refererDetection.js | 4 + src/sizeMapping.js | 21 +- test/spec/modules/1ad4goodBidAdapter_spec.js | 548 --- test/spec/modules/7xbidBidAdapter_spec.js | 160 - test/spec/modules/aardvarkBidAdapter_spec.js | 569 --- test/spec/modules/adagioBidAdapter_spec.js | 7 +- test/spec/modules/adbutlerBidAdapter_spec.js | 231 -- test/spec/modules/adfinityBidAdapter_spec.js | 151 - test/spec/modules/adformBidAdapter_spec.js | 550 --- .../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/adtrueBidAdapter_spec.js | 2 +- .../modules/advangelistsBidAdapter_spec.js | 137 - test/spec/modules/advenueBidAdapter_spec.js | 107 - test/spec/modules/advertlyBidAdapter_spec.js | 159 - test/spec/modules/ajaBidAdapter_spec.js | 311 -- test/spec/modules/apacdexBidAdapter_spec.js | 9 - test/spec/modules/appnexusBidAdapter_spec.js | 34 + test/spec/modules/atomxBidAdapter_spec.js | 119 - test/spec/modules/avocetBidAdapter_spec.js | 167 - test/spec/modules/betweenBidAdapter_spec.js | 45 - .../spec/modules/bidfluenceBidAdapter_spec.js | 114 - 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/c1xBidAdapter_spec.js | 182 - test/spec/modules/cedatoBidAdapter_spec.js | 133 - .../modules/cleanmedianetBidAdapter_spec.js | 25 - .../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/cosmosBidAdapter_spec.js | 355 -- test/spec/modules/cpmstarBidAdapter_spec.js | 231 -- test/spec/modules/criteoBidAdapter_spec.js | 64 +- test/spec/modules/dailyhuntBidAdapter_spec.js | 400 -- .../modules/decenteradsBidAdapter_spec.js | 207 - .../modules/districtmDmxBidAdapter_spec.js | 1 - test/spec/modules/djaxBidAdapter_spec.js | 159 - .../spec/modules/e_volutionBidAdapter_spec.js | 235 -- test/spec/modules/ebdrBidAdapter_spec.js | 235 -- .../spec/modules/edgequeryxBidAdapter_spec.js | 116 - test/spec/modules/eids_spec.js | 36 - 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/getintentBidAdapter_spec.js | 142 - test/spec/modules/gnetBidAdapter_spec.js | 145 - test/spec/modules/haxmediaBidAdapter_spec.js | 304 -- .../modules/hpmdnetworkBidAdapter_spec.js | 148 - test/spec/modules/iasBidAdapter_spec.js | 343 -- test/spec/modules/imonomyBidAdapter_spec.js | 164 - 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 - test/spec/modules/komoonaBidAdapter_spec.js | 164 - .../spec/modules/krushmediaBidAdapter_spec.js | 329 -- test/spec/modules/kubientBidAdapter_spec.js | 259 -- test/spec/modules/lemmaBidAdapter_spec.js | 426 -- .../spec/modules/lifestreetBidAdapter_spec.js | 232 -- .../modules/livewrappedBidAdapter_spec.js | 10 - test/spec/modules/lkqdBidAdapter_spec.js | 370 -- test/spec/modules/loganBidAdapter_spec.js | 329 -- test/spec/modules/logicadBidAdapter_spec.js | 241 -- test/spec/modules/loopmeBidAdapter_spec.js | 167 - .../modules/lotamePanoramaIdSystem_spec.js | 1 + test/spec/modules/lunamediaBidAdapter_spec.js | 137 - .../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 - .../spec/modules/mediaforceBidAdapter_spec.js | 6 +- test/spec/modules/mediagoBidAdapter_spec.js | 101 - test/spec/modules/mgidBidAdapter_spec.js | 702 ---- test/spec/modules/microadBidAdapter_spec.js | 388 -- test/spec/modules/missenaBidAdapter_spec.js | 131 - test/spec/modules/mobfoxBidAdapter_spec.js | 123 - test/spec/modules/mobfoxpbBidAdapter_spec.js | 304 -- test/spec/modules/mobsmartBidAdapter_spec.js | 214 - test/spec/modules/mytargetBidAdapter_spec.js | 229 - .../spec/modules/nafdigitalBidAdapter_spec.js | 283 -- .../modules/nanointeractiveBidAdapter_spec.js | 466 --- .../modules/nasmediaAdmixerBidAdapter_spec.js | 143 - .../modules/newborntownWebBidAdapter_spec.js | 152 - .../modules/nextMillenniumBidAdapter_spec.js | 93 - test/spec/modules/nextrollBidAdapter_spec.js | 268 -- test/spec/modules/open8BidAdapter_spec.js | 251 -- test/spec/modules/openxBidAdapter_spec.js | 1 - test/spec/modules/optimeraBidAdapter_spec.js | 99 - test/spec/modules/orbidderBidAdapter_spec.js | 15 - 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 - .../spec/modules/platformioBidAdapter_spec.js | 348 -- .../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 --- .../spec/modules/revcontentBidAdapter_spec.js | 351 -- test/spec/modules/rhythmoneBidAdapter_spec.js | 4 +- test/spec/modules/riseBidAdapter_spec.js | 381 -- test/spec/modules/rtbdemandBidAdapter_spec.js | 174 - test/spec/modules/rtbsapeBidAdapter_spec.js | 166 - .../modules/rtbsolutionsBidAdapter_spec.js | 62 - test/spec/modules/rubiconBidAdapter_spec.js | 86 +- test/spec/modules/saambaaBidAdapter_spec.js | 139 - .../modules/seedingAllianceAdapter_spec.js | 186 - test/spec/modules/segmentoBidAdapter_spec.js | 187 - test/spec/modules/sekindoUMBidAdapter_spec.js | 168 - test/spec/modules/sharedIdSystem_spec.js | 15 +- .../modules/sharethroughBidAdapter_spec.js | 10 - 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/somoBidAdapter_spec.js | 545 --- test/spec/modules/sonobiBidAdapter_spec.js | 38 +- test/spec/modules/sortableBidAdapter_spec.js | 572 --- test/spec/modules/spotxBidAdapter_spec.js | 2 - test/spec/modules/stvBidAdapter_spec.js | 138 - test/spec/modules/taphypeBidAdapter_spec.js | 56 - test/spec/modules/timBidAdapter_spec.js | 152 - test/spec/modules/topRTBBidAdapter_spec.js | 67 - test/spec/modules/trendqubeBidAdapter_spec.js | 270 -- test/spec/modules/tribeosBidAdapter_spec.js | 86 - test/spec/modules/truereachBidAdapter_spec.js | 2 +- .../modules/turktelekomBidAdapter_spec.js | 749 ---- test/spec/modules/ucfunnelBidAdapter_spec.js | 1 - test/spec/modules/unicornBidAdapter_spec.js | 490 --- test/spec/modules/userId_spec.js | 3690 +++++++---------- 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/vrtcalBidAdapter_spec.js | 135 - test/spec/modules/vubleBidAdapter_spec.js | 412 -- test/spec/modules/waardexBidAdapter_spec.js | 5 +- test/spec/modules/welectBidAdapter_spec.js | 211 - .../spec/modules/windtalkerBidAdapter_spec.js | 348 -- test/spec/modules/wipesBidAdapter_spec.js | 150 - test/spec/modules/xhbBidAdapter_spec.js | 495 --- test/spec/modules/zedoBidAdapter_spec.js | 354 -- test/spec/modules/zemantaBidAdapter_spec.js | 558 --- test/spec/refererDetection_spec.js | 25 + test/spec/sizeMapping_spec.js | 9 + test/spec/unit/pbjs_api_spec.js | 36 + 357 files changed, 2249 insertions(+), 65022 deletions(-) delete mode 100644 modules/1ad4goodBidAdapter.js delete mode 100644 modules/1ad4goodBidAdapter.md 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/adformBidAdapter.js delete mode 100644 modules/adformBidAdapter.md 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/adspendBidAdapter.js delete mode 100755 modules/advangelistsBidAdapter.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/bidfluenceBidAdapter.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/c1xBidAdapter.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/cosmosBidAdapter.js delete mode 100644 modules/cpmstarBidAdapter.js delete mode 100644 modules/dailyhuntBidAdapter.js delete mode 100644 modules/decenteradsBidAdapter.js delete mode 100644 modules/djaxBidAdapter.js delete mode 100644 modules/e_volutionBidAdapter.js delete mode 100644 modules/ebdrBidAdapter.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/getintentBidAdapter.js delete mode 100644 modules/gnetBidAdapter.js delete mode 100644 modules/haxmediaBidAdapter.js delete mode 100644 modules/hpmdnetworkBidAdapter.js delete mode 100644 modules/iasBidAdapter.js delete mode 100644 modules/iasBidAdapter.md delete mode 100644 modules/imonomyBidAdapter.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/komoonaBidAdapter.js delete mode 100644 modules/krushmediaBidAdapter.js delete mode 100644 modules/kubientBidAdapter.js delete mode 100644 modules/lemmaBidAdapter.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 100755 modules/lunamediaBidAdapter.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/mgidBidAdapter.js delete mode 100644 modules/microadBidAdapter.js delete mode 100644 modules/missenaBidAdapter.js delete mode 100644 modules/mobfoxBidAdapter.js delete mode 100644 modules/mobfoxpbBidAdapter.js delete mode 100644 modules/mobsmartBidAdapter.js delete mode 100644 modules/mytargetBidAdapter.js delete mode 100644 modules/nafdigitalBidAdapter.js delete mode 100644 modules/nanointeractiveBidAdapter.js delete mode 100644 modules/nasmediaAdmixerBidAdapter.js delete mode 100644 modules/newborntownWebBidAdapter.js delete mode 100644 modules/nextMillenniumBidAdapter.js delete mode 100644 modules/nextrollBidAdapter.js delete mode 100644 modules/open8BidAdapter.js delete mode 100644 modules/optimeraBidAdapter.js delete mode 100644 modules/optimeraBidAdapter.md 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/platformioBidAdapter.js delete mode 100644 modules/projectLimeLightBidAdapter.js delete mode 100644 modules/proxistoreBidAdapter.js delete mode 100644 modules/pubCommonIdSystem.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/revcontentBidAdapter.js delete mode 100644 modules/riseBidAdapter.js delete mode 100644 modules/rtbdemandBidAdapter.js delete mode 100644 modules/rtbsapeBidAdapter.js delete mode 100644 modules/rtbsolutionsBidAdapter.js delete mode 100755 modules/saambaaBidAdapter.js delete mode 100755 modules/seedingAllianceBidAdapter.js delete mode 100644 modules/segmentoBidAdapter.js delete mode 100644 modules/sekindoUMBidAdapter.js delete mode 100644 modules/sharedIdSystem.md 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/somoBidAdapter.js delete mode 100644 modules/sortableBidAdapter.js delete mode 100644 modules/stvBidAdapter.js delete mode 100644 modules/taphypeBidAdapter.js delete mode 100644 modules/timBidAdapter.js delete mode 100644 modules/topRTBBidAdapter.js delete mode 100644 modules/trendqubeBidAdapter.js delete mode 100644 modules/tribeosBidAdapter.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/vrtcalBidAdapter.js delete mode 100644 modules/vubleBidAdapter.js delete mode 100644 modules/welectBidAdapter.js delete mode 100644 modules/windtalkerBidAdapter.js delete mode 100644 modules/wipesBidAdapter.js delete mode 100644 modules/xhbBidAdapter.js delete mode 100644 modules/zedoBidAdapter.js delete mode 100644 modules/zemantaBidAdapter.js delete mode 100644 modules/zemantaBidAdapter.md delete mode 100644 test/spec/modules/1ad4goodBidAdapter_spec.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/adformBidAdapter_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 100755 test/spec/modules/advangelistsBidAdapter_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/bidfluenceBidAdapter_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/c1xBidAdapter_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/cosmosBidAdapter_spec.js delete mode 100644 test/spec/modules/cpmstarBidAdapter_spec.js delete mode 100644 test/spec/modules/dailyhuntBidAdapter_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/ebdrBidAdapter_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/getintentBidAdapter_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/iasBidAdapter_spec.js delete mode 100644 test/spec/modules/imonomyBidAdapter_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/komoonaBidAdapter_spec.js delete mode 100644 test/spec/modules/krushmediaBidAdapter_spec.js delete mode 100644 test/spec/modules/kubientBidAdapter_spec.js delete mode 100644 test/spec/modules/lemmaBidAdapter_spec.js delete mode 100644 test/spec/modules/lifestreetBidAdapter_spec.js delete mode 100644 test/spec/modules/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 100755 test/spec/modules/lunamediaBidAdapter_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/mgidBidAdapter_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/mobfoxBidAdapter_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/mytargetBidAdapter_spec.js delete mode 100644 test/spec/modules/nafdigitalBidAdapter_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/newborntownWebBidAdapter_spec.js delete mode 100644 test/spec/modules/nextMillenniumBidAdapter_spec.js delete mode 100644 test/spec/modules/nextrollBidAdapter_spec.js delete mode 100644 test/spec/modules/open8BidAdapter_spec.js delete mode 100644 test/spec/modules/optimeraBidAdapter_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/platformioBidAdapter_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/revcontentBidAdapter_spec.js delete mode 100644 test/spec/modules/riseBidAdapter_spec.js delete mode 100644 test/spec/modules/rtbdemandBidAdapter_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/saambaaBidAdapter_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/sekindoUMBidAdapter_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/somoBidAdapter_spec.js delete mode 100644 test/spec/modules/sortableBidAdapter_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/timBidAdapter_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/tribeosBidAdapter_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/vrtcalBidAdapter_spec.js delete mode 100644 test/spec/modules/vubleBidAdapter_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/xhbBidAdapter_spec.js delete mode 100644 test/spec/modules/zedoBidAdapter_spec.js delete mode 100644 test/spec/modules/zemantaBidAdapter_spec.js diff --git a/integrationExamples/gpt/idImportLibrary_example.html b/integrationExamples/gpt/idImportLibrary_example.html index f35b571e8f9..07a4f0fe1c5 100644 --- a/integrationExamples/gpt/idImportLibrary_example.html +++ b/integrationExamples/gpt/idImportLibrary_example.html @@ -54,17 +54,7 @@ expires: 30 } }, - { - name: "sharedId", - params: { - syncTime: 60 // in seconds, default is 24 hours - }, - storage: { - type: "html5", - name: "sharedid", - expires: 28 - } - } , { + { name: "liveIntentId", params: { publisherId: "9896876" diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index 6fbdd69aea7..4b45064bb73 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -72,7 +72,7 @@ "131": true, // id5Id "929": true, // parrableId "97": true, // identityLink - "887": true, // sharedId, uid2 + "887": true, // uid2 "95": true, // lotamePanoramaId "301": true, // zeotapIdPlus "91": true, // criteo @@ -195,18 +195,6 @@ "expires": 30 } }, - { - "name": "sharedId", - // bidders: ["rubicon", "sampleBidders"], // to allow this ID for specific bidders - "params": { - "syncTime": 60 // in seconds, default is 24 hours - }, - "storage": { - "type": "cookie", - "name": "sharedid", - "expires": 28 - } - }, { "name": "lotamePanoramaId" }, diff --git a/modules/1ad4goodBidAdapter.js b/modules/1ad4goodBidAdapter.js deleted file mode 100644 index 178f3765587..00000000000 --- a/modules/1ad4goodBidAdapter.js +++ /dev/null @@ -1,399 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import find from 'core-js-pure/features/array/find.js'; -import includes from 'core-js-pure/features/array/includes.js'; - -const BIDDER_CODE = '1ad4good'; -const URL = 'https://hb.1ad4good.org/prebid'; -const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', - 'startdelay', 'skippable', 'playback_method', 'frameworks']; -const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; -const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately -const SOURCE = 'pbjs'; -const MAX_IMPS_PER_REQUEST = 15; - -export const spec = { - code: BIDDER_CODE, - aliases: ['adsforgood', 'ads4good', '1adsforgood'], - 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.placementId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(bidRequests, bidderRequest) { - const tags = bidRequests.map(bidToTag); - const userObjBid = find(bidRequests, hasUserInfo); - let userObj; - if (userObjBid) { - userObj = {}; - Object.keys(userObjBid.params.user) - .filter(param => includes(USER_PARAMS, param)) - .forEach(param => userObj[param] = userObjBid.params.user[param]); - } - - const appDeviceObjBid = find(bidRequests, hasAppDeviceInfo); - let appDeviceObj; - if (appDeviceObjBid && appDeviceObjBid.params && appDeviceObjBid.params.app) { - appDeviceObj = {}; - Object.keys(appDeviceObjBid.params.app) - .filter(param => includes(APP_DEVICE_PARAMS, param)) - .forEach(param => appDeviceObj[param] = appDeviceObjBid.params.app[param]); - } - - const appIdObjBid = find(bidRequests, hasAppId); - let appIdObj; - if (appIdObjBid && appIdObjBid.params && appDeviceObjBid.params.app && appDeviceObjBid.params.app.id) { - appIdObj = { - appid: appIdObjBid.params.app.id - }; - } - - const payload = { - tags: [...tags], - user: userObj, - sdk: { - source: SOURCE, - version: '$prebid.version$' - } - }; - - if (appDeviceObjBid) { - payload.device = appDeviceObj - } - if (appIdObjBid) { - payload.app = appIdObj; - } - - if (bidderRequest && bidderRequest.gdprConsent) { - // note - objects for impbus use underscore instead of camelCase - payload.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - } - - if (bidderRequest && bidderRequest.refererInfo) { - let refererinfo = { - rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer), - rd_top: bidderRequest.refererInfo.reachedTop, - rd_ifs: bidderRequest.refererInfo.numIframes, - rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') - } - payload.referrer_detection = refererinfo; - } - - const request = formatRequest(payload, bidderRequest); - return 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: function(serverResponse, {bidderRequest}) { - serverResponse = serverResponse.body; - const bids = []; - if (!serverResponse || serverResponse.error) { - let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`; - if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; } - utils.logError(errorMessage); - return bids; - } - - if (serverResponse.tags) { - serverResponse.tags.forEach(serverBid => { - const rtbBid = getRtbBid(serverBid); - if (rtbBid) { - if (rtbBid.cpm !== 0 && includes(this.supportedMediaTypes, rtbBid.ad_type)) { - const bid = newBid(serverBid, rtbBid, bidderRequest); - bid.mediaType = parseMediaType(rtbBid); - bids.push(bid); - } - } - }); - } - - return bids; - }, - - transformBidParams: function(params, isOpenRtb) { - params = utils.convertTypes({ - 'placementId': 'number', - 'keywords': utils.transformBidderParamKeywords - }, params); - - if (isOpenRtb) { - params.use_pmt_rule = (typeof params.usePaymentRule === 'boolean') ? params.usePaymentRule : false; - if (params.usePaymentRule) { delete params.usePaymentRule; } - - if (isPopulatedArray(params.keywords)) { - params.keywords.forEach(deleteValues); - } - - Object.keys(params).forEach(paramKey => { - let convertedKey = utils.convertCamelToUnderscore(paramKey); - if (convertedKey !== paramKey) { - params[convertedKey] = params[paramKey]; - delete params[paramKey]; - } - }); - } - - return params; - }, - - /** - * Add element selector to javascript tracker to improve native viewability - * @param {Bid} bid - */ - onBidWon: function(bid) { - } -} - -function isPopulatedArray(arr) { - return !!(utils.isArray(arr) && arr.length > 0); -} - -function deleteValues(keyPairObj) { - if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { - delete keyPairObj.value; - } -} - -function formatRequest(payload, bidderRequest) { - let request = []; - - if (payload.tags.length > MAX_IMPS_PER_REQUEST) { - const clonedPayload = utils.deepClone(payload); - - utils.chunk(payload.tags, MAX_IMPS_PER_REQUEST).forEach(tags => { - clonedPayload.tags = tags; - const payloadString = JSON.stringify(clonedPayload); - request.push({ - method: 'POST', - url: URL, - data: payloadString, - bidderRequest - }); - }); - } else { - const payloadString = JSON.stringify(payload); - request = { - method: 'POST', - url: URL, - data: payloadString, - bidderRequest - }; - } - - return request; -} - -/** - * Unpack the Server's Bid into a Prebid-compatible one. - * @param serverBid - * @param rtbBid - * @param bidderRequest - * @return Bid - */ -function newBid(serverBid, rtbBid, bidderRequest) { - const bidRequest = utils.getBidRequest(serverBid.uuid, [bidderRequest]); - const bid = { - requestId: serverBid.uuid, - cpm: rtbBid.cpm, - creativeId: rtbBid.creative_id, - dealId: rtbBid.deal_id, - currency: 'USD', - netRevenue: true, - ttl: 300, - adUnitCode: bidRequest.adUnitCode, - ads4good: { - buyerMemberId: rtbBid.buyer_member_id, - dealPriority: rtbBid.deal_priority, - dealCode: rtbBid.deal_code - } - }; - - if (rtbBid.advertiser_id) { - bid.meta = Object.assign({}, bid.meta, { advertiserId: rtbBid.advertiser_id }); - } - - if (rtbBid.rtb.video) { - Object.assign(bid, { - width: rtbBid.rtb.video.player_width, - height: rtbBid.rtb.video.player_height, - vastUrl: rtbBid.rtb.video.asset_url, - vastImpUrl: rtbBid.notify_url, - ttl: 3600 - }); - } else { - Object.assign(bid, { - width: rtbBid.rtb.banner.width, - height: rtbBid.rtb.banner.height, - ad: rtbBid.rtb.banner.content - }); - try { - const url = rtbBid.rtb.trackers[0].impression_urls[0]; - const tracker = utils.createTrackPixelHtml(url); - bid.ad += tracker; - } catch (error) { - utils.logError('Error appending tracking pixel', error); - } - } - - return bid; -} - -function bidToTag(bid) { - const tag = {}; - tag.sizes = transformSizes(bid.sizes); - tag.primary_size = tag.sizes[0]; - tag.ad_types = []; - tag.uuid = bid.bidId; - if (bid.params.placementId) { - tag.id = parseInt(bid.params.placementId, 10); - } - if (bid.params.cpm) { - tag.cpm = bid.params.cpm; - } - tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; - tag.use_pmt_rule = bid.params.usePaymentRule || false - tag.prebid = true; - tag.disable_psa = true; - if (bid.params.reserve) { - tag.reserve = bid.params.reserve; - } - if (bid.params.position) { - tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0; - } - if (bid.params.trafficSourceCode) { - tag.traffic_source_code = bid.params.trafficSourceCode; - } - if (bid.params.privateSizes) { - tag.private_sizes = transformSizes(bid.params.privateSizes); - } - if (bid.params.supplyType) { - tag.supply_type = bid.params.supplyType; - } - if (bid.params.pubClick) { - tag.pubclick = bid.params.pubClick; - } - if (bid.params.extInvCode) { - tag.ext_inv_code = bid.params.extInvCode; - } - if (bid.params.externalImpId) { - tag.external_imp_id = bid.params.externalImpId; - } - if (!utils.isEmpty(bid.params.keywords)) { - let keywords = utils.transformBidderParamKeywords(bid.params.keywords); - - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } - tag.keywords = keywords; - } - - const videoMediaType = utils.deepAccess(bid, `mediaTypes.${VIDEO}`); - const context = utils.deepAccess(bid, 'mediaTypes.video.context'); - - if (bid.mediaType === VIDEO || videoMediaType) { - tag.ad_types.push(VIDEO); - } - - // instream gets vastUrl, outstream gets vastXml - if (bid.mediaType === VIDEO || (videoMediaType && context !== 'outstream')) { - tag.require_asset_url = true; - } - - if (bid.params.video) { - tag.video = {}; - // place any valid video params on the tag - Object.keys(bid.params.video) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => tag.video[param] = bid.params.video[param]); - } - - if (bid.renderer) { - tag.video = Object.assign({}, tag.video, {custom_renderer_present: true}); - } - - if ( - (utils.isEmpty(bid.mediaType) && utils.isEmpty(bid.mediaTypes)) || - (bid.mediaType === BANNER || (bid.mediaTypes && bid.mediaTypes[BANNER])) - ) { - tag.ad_types.push(BANNER); - } - - return tag; -} - -/* Turn bid request sizes into ut-compatible format */ -function transformSizes(requestSizes) { - let sizes = []; - let sizeObj = {}; - - if (utils.isArray(requestSizes) && requestSizes.length === 2 && - !utils.isArray(requestSizes[0])) { - sizeObj.width = parseInt(requestSizes[0], 10); - sizeObj.height = parseInt(requestSizes[1], 10); - sizes.push(sizeObj); - } else if (typeof requestSizes === 'object') { - for (let i = 0; i < requestSizes.length; i++) { - let size = requestSizes[i]; - sizeObj = {}; - sizeObj.width = parseInt(size[0], 10); - sizeObj.height = parseInt(size[1], 10); - sizes.push(sizeObj); - } - } - - return sizes; -} - -function hasUserInfo(bid) { - return !!bid.params.user; -} - -function hasAppDeviceInfo(bid) { - if (bid.params) { - return !!bid.params.app - } -} - -function hasAppId(bid) { - if (bid.params && bid.params.app) { - return !!bid.params.app.id - } - return !!bid.params.app -} - -function getRtbBid(tag) { - return tag && tag.ads && tag.ads.length && find(tag.ads, ad => ad.rtb); -} - -function parseMediaType(rtbBid) { - const adType = rtbBid.ad_type; - if (adType === VIDEO) { - return VIDEO; - } else { - return BANNER; - } -} - -registerBidder(spec); diff --git a/modules/1ad4goodBidAdapter.md b/modules/1ad4goodBidAdapter.md deleted file mode 100644 index 1e9dfe5e04c..00000000000 --- a/modules/1ad4goodBidAdapter.md +++ /dev/null @@ -1,87 +0,0 @@ -# Overview - -``` -Module Name: 1ad4good Bid Adapter -Module Type: Bidder Adapter -Maintainer: info@1ad4good.org -``` - -# Description - -Connects to 1ad4good exchange for bids. - -1ad4good bid adapter supports Banner and Video (instream). - -# Test Parameters -``` -var adUnits = [ - // Banner adUnit - { - code: 'banner-div', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]] - } - }, - bids: [{ - bidder: '1ad4good', - params: { - placementId: 13144370 - } - }] - }, - // Video instream adUnit - { - code: 'video-instream', - sizes: [[640, 480]], - mediaTypes: { - video: { - playerSize: [[640, 480]], - context: 'instream' - }, - }, - bids: [{ - bidder: '1ad4good', - params: { - placementId: 13232361, - video: { - skippable: true, - playback_methods: ['auto_play_sound_off'] - } - } - }] - }, - - // Banner adUnit in a App Webview - // Only use this for situations where prebid.js is in a webview of an App - // See Prebid Mobile for displaying ads via an SDK - { - code: 'banner-div', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]] - } - } - bids: [{ - bidder: '1ad4good', - params: { - placementId: 13144370, - app: { - id: "B1O2W3M4AN.com.prebid.webview", - geo: { - lat: 40.0964439, - lng: -75.3009142 - }, - device_id: { - idfa: "4D12078D-3246-4DA4-AD5E-7610481E7AE", // Apple advertising identifier - aaid: "38400000-8cf0-11bd-b23e-10b96e40000d", // Android advertising identifier - md5udid: "5756ae9022b2ea1e47d84fead75220c8", // MD5 hash of the ANDROID_ID - sha1udid: "4DFAA92388699AC6539885AEF1719293879985BF", // SHA1 hash of the ANDROID_ID - windowsadid: "750c6be243f1c4b5c9912b95a5742fc5" // Windows advertising identifier - } - } - } - }] - } -]; -``` 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/adformBidAdapter.js b/modules/adformBidAdapter.js deleted file mode 100644 index 3d0ed0fba79..00000000000 --- a/modules/adformBidAdapter.js +++ /dev/null @@ -1,213 +0,0 @@ -'use strict'; - -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { Renderer } from '../src/Renderer.js'; -import * as utils from '../src/utils.js'; -import includes from 'core-js-pure/features/array/includes.js'; - -const OUTSTREAM_RENDERER_URL = 'https://s2.adform.net/banners/scripts/video/outstream/render.js'; - -const BIDDER_CODE = 'adform'; -const GVLID = 50; -export const spec = { - code: BIDDER_CODE, - gvlid: GVLID, - supportedMediaTypes: [ BANNER, VIDEO ], - isBidRequestValid: function (bid) { - return !!(bid.params.mid); - }, - buildRequests: function (validBidRequests, bidderRequest) { - var i, l, j, k, bid, _key, _value, reqParams, netRevenue, gdprObject; - const currency = config.getConfig('currency.adServerCurrency'); - const eids = getEncodedEIDs(utils.deepAccess(validBidRequests, '0.userIdAsEids')); - - var request = []; - var globalParams = [ [ 'adxDomain', 'adx.adform.net' ], [ 'fd', 1 ], [ 'url', null ], [ 'tid', null ], [ 'eids', eids ] ]; - const targetingParams = { mkv: [], mkw: [], msw: [] }; - - var bids = JSON.parse(JSON.stringify(validBidRequests)); - var bidder = (bids[0] && bids[0].bidder) || BIDDER_CODE; - - // set common targeting options as query params - if (bids.length > 1) { - for (let key in targetingParams) { - if (targetingParams.hasOwnProperty(key)) { - const collection = bids.map(bid => ((bid.params[key] && bid.params[key].split(',')) || [])); - targetingParams[key] = collection.reduce(intersects); - if (targetingParams[key].length) { - bids.forEach((bid, index) => { - bid.params[key] = collection[index].filter(item => !includes(targetingParams[key], item)); - }); - } - } - } - } - - for (i = 0, l = bids.length; i < l; i++) { - bid = bids[i]; - if ((bid.params.priceType === 'net') || (bid.params.pt === 'net')) { - netRevenue = 'net'; - } - - for (j = 0, k = globalParams.length; j < k; j++) { - _key = globalParams[j][0]; - _value = bid[_key] || bid.params[_key]; - if (_value) { - bid[_key] = bid.params[_key] = null; - globalParams[j][1] = _value; - } - } - reqParams = bid.params; - reqParams.transactionId = bid.transactionId; - reqParams.rcur = reqParams.rcur || currency; - request.push(formRequestUrl(reqParams)); - } - - request.unshift('https://' + globalParams[0][1] + '/adx/?rp=4'); - netRevenue = netRevenue || 'gross'; - request.push('pt=' + netRevenue); - request.push('stid=' + validBidRequests[0].auctionId); - - const gdprApplies = utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies'); - const consentString = utils.deepAccess(bidderRequest, 'gdprConsent.consentString'); - if (gdprApplies !== undefined) { - gdprObject = { - gdpr: gdprApplies, - gdpr_consent: consentString - }; - request.push('gdpr=' + (gdprApplies & 1)); - request.push('gdpr_consent=' + consentString); - } - - if (bidderRequest && bidderRequest.uspConsent) { - request.push('us_privacy=' + bidderRequest.uspConsent); - } - - for (let key in targetingParams) { - if (targetingParams.hasOwnProperty(key)) { - globalParams.push([ key, targetingParams[key].join(',') ]); - } - } - - for (i = 1, l = globalParams.length; i < l; i++) { - _key = globalParams[i][0]; - _value = globalParams[i][1]; - if (_value) { - request.push(_key + '=' + encodeURIComponent(_value)); - } - } - - return { - method: 'GET', - url: request.join('&'), - bids: validBidRequests, - netRevenue: netRevenue, - bidder, - gdpr: gdprObject - }; - - function formRequestUrl(reqData) { - var key; - var url = []; - - for (key in reqData) { - if (reqData.hasOwnProperty(key) && reqData[key]) { url.push(key, '=', reqData[key], '&'); } - } - - return encodeURIComponent(btoa(url.join('').slice(0, -1))); - } - - function getEncodedEIDs(eids) { - if (utils.isArray(eids) && eids.length > 0) { - const parsed = parseEIDs(eids); - return btoa(JSON.stringify(parsed)); - } - } - - function parseEIDs(eids) { - return eids.reduce((result, eid) => { - const source = eid.source; - result[source] = result[source] || {}; - - eid.uids.forEach(value => { - const id = value.id + ''; - result[source][id] = result[source][id] || []; - result[source][id].push(value.atype); - }); - - return result; - }, {}); - } - - function intersects(col1, col2) { - return col1.filter(item => includes(col2, item)); - } - }, - interpretResponse: function (serverResponse, bidRequest) { - const VALID_RESPONSES = { - banner: 1, - vast_content: 1, - vast_url: 1 - }; - var bidObject, response, bid, type; - var bidRespones = []; - var bids = bidRequest.bids; - var responses = serverResponse.body; - for (var i = 0; i < responses.length; i++) { - response = responses[i]; - type = response.response === 'banner' ? BANNER : VIDEO; - bid = bids[i]; - if (VALID_RESPONSES[response.response] && (verifySize(response, utils.getAdUnitSizes(bid)) || type === VIDEO)) { - bidObject = { - requestId: bid.bidId, - cpm: response.win_bid, - width: response.width, - height: response.height, - creativeId: bid.bidId, - dealId: response.deal_id, - currency: response.win_cur, - netRevenue: bidRequest.netRevenue !== 'gross', - ttl: 360, - meta: { advertiserDomains: response && response.adomain ? response.adomain : [] }, - ad: response.banner, - bidderCode: bidRequest.bidder, - transactionId: bid.transactionId, - vastUrl: response.vast_url, - vastXml: response.vast_content, - mediaType: type - }; - - if (!bid.renderer && type === VIDEO && utils.deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { - bidObject.renderer = Renderer.install({id: bid.bidId, url: OUTSTREAM_RENDERER_URL}); - bidObject.renderer.setRender(renderer); - } - - if (bidRequest.gdpr) { - bidObject.gdpr = bidRequest.gdpr.gdpr; - bidObject.gdpr_consent = bidRequest.gdpr.gdpr_consent; - } - bidRespones.push(bidObject); - } - } - return bidRespones; - - function renderer(bid) { - bid.renderer.push(() => { - window.Adform.renderOutstream(bid); - }); - } - - function verifySize(adItem, validSizes) { - for (var j = 0, k = validSizes.length; j < k; j++) { - if (adItem.width == validSizes[j][0] && - adItem.height == validSizes[j][1]) { - return true; - } - } - return false; - } - } -}; -registerBidder(spec); diff --git a/modules/adformBidAdapter.md b/modules/adformBidAdapter.md deleted file mode 100644 index 10ebec37e08..00000000000 --- a/modules/adformBidAdapter.md +++ /dev/null @@ -1,30 +0,0 @@ -# Overview - -Module Name: Adform Bidder Adapter -Module Type: Bidder Adapter -Maintainer: Scope.FL.Scripts@adform.com - -# Description - -Module that connects to Adform demand sources to fetch bids. -Banner and video formats are supported. - -# Test Parameters -``` - var adUnits = [ - { - code: 'div-gpt-ad-1460505748561-0', - sizes: [[300, 250], [250, 300], [300, 600], [600, 300]], // a display size - bids: [ - { - bidder: "adform", - params: { - adxDomain: 'adx.adform.net', //optional - mid: '292063', - priceType: 'net' // default is 'gross' - } - } - ] - }, - ]; -``` 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/adrelevantisBidAdapter.js b/modules/adrelevantisBidAdapter.js index c6298cffde9..b3efa8a303d 100644 --- a/modules/adrelevantisBidAdapter.js +++ b/modules/adrelevantisBidAdapter.js @@ -428,9 +428,6 @@ function bidToTag(bid) { tag.use_pmt_rule = bid.params.usePaymentRule || false tag.prebid = true; tag.disable_psa = true; - if (bid.params.reserve) { - tag.reserve = bid.params.reserve; - } if (bid.params.position) { tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0; } diff --git a/modules/adspendBidAdapter.js b/modules/adspendBidAdapter.js deleted file mode 100644 index 9fe70885eeb..00000000000 --- a/modules/adspendBidAdapter.js +++ /dev/null @@ -1,164 +0,0 @@ -import * as utils from '../src/utils.js'; -import { ajax } from '../src/ajax.js' -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const storage = getStorageManager(); -const BIDDER_CODE = 'adspend'; -const BID_URL = 'https://rtb.com.ru/headerbidding-bid'; -const SYNC_URL = 'https://rtb.com.ru/headerbidding-sync?uid={UUID}'; -const COOKIE_NAME = 'hb-adspend-id'; -const TTL = 10000; -const RUB = 'RUB'; -const FIRST_PRICE = 1; -const NET_REVENUE = true; - -const winEventURLs = {}; -const placementToBidMap = {}; - -export const spec = { - code: BIDDER_CODE, - aliases: ['as'], - supportedMediaTypes: [BANNER], - - onBidWon: function(winObj) { - const requestId = winObj.requestId; - const cpm = winObj.cpm; - const event = winEventURLs[requestId].replace( - /\$\{AUCTION_PRICE\}/, - cpm - ); - - ajax(event, null); - }, - - isBidRequestValid: function(bid) { - const adServerCur = config.getConfig('currency.adServerCurrency') === RUB; - - return !!(adServerCur && - bid.params && - bid.params.bidfloor && - bid.crumbs.pubcid && - utils.checkCookieSupport() && - storage.cookiesAreEnabled() - ); - }, - - buildRequests: function(bidRequests, bidderRequest) { - const req = bidRequests[Math.floor(Math.random() * bidRequests.length)]; - const bidId = req.bidId; - const at = FIRST_PRICE; - const site = { id: req.crumbs.pubcid, domain: document.domain }; - const device = { ua: navigator.userAgent, ip: '' }; - const user = { id: getUserID() } - const cur = [ RUB ]; - const tmax = bidderRequest.timeout; - - const imp = bidRequests.map(req => { - const params = req.params; - - const tagId = params.tagId; - const id = params.placement; - const banner = { 'format': getFormats(req.sizes) }; - const bidfloor = params.bidfloor !== undefined - ? Number(params.bidfloor) : 1; - const bidfloorcur = RUB; - - placementToBidMap[id] = bidId; - - return { - id, - tagId, - banner, - bidfloor, - bidfloorcur, - secure: 0, - }; - }); - - const payload = { - bidId, - at, - site, - device, - user, - imp, - cur, - tmax, - }; - - return { - method: 'POST', - url: BID_URL, - data: JSON.stringify(payload), - }; - }, - - interpretResponse: function(resp, {bidderRequest}) { - if (resp.body === '') return []; - - const bids = resp.body.seatbid[0].bid.map(bid => { - const cpm = bid.price; - const impid = bid.impid; - const requestId = placementToBidMap[impid]; - const width = bid.w; - const height = bid.h; - const creativeId = bid.adid; - const dealId = bid.dealid; - const currency = resp.body.cur; - const netRevenue = NET_REVENUE; - const ttl = TTL; - const ad = bid.adm; - - return { - cpm, - requestId, - width, - height, - creativeId, - dealId, - currency, - netRevenue, - ttl, - ad, - }; - }); - - return bids; - }, - - getUserSyncs: function(syncOptions, resps) { - let syncs = []; - - resps.forEach(resp => { - if (syncOptions.pixelEnabled && resp.body === '') { - const uuid = getUserID(); - syncs.push({ - type: 'image', - url: SYNC_URL.replace('{UUID}', uuid), - }); - } - }); - - return syncs - } -} - -const getUserID = () => { - const i = storage.getCookie(COOKIE_NAME); - - if (i === null) { - const uuid = utils.generateUUID(); - storage.setCookie(COOKIE_NAME, uuid); - return uuid; - } - return i; -}; - -const getFormats = arr => arr.map((s) => { - return { w: s[0], h: s[1] }; -}); - -registerBidder(spec); diff --git a/modules/adtrueBidAdapter.js b/modules/adtrueBidAdapter.js index b4dc7f7ea89..96f1ceb12f0 100644 --- a/modules/adtrueBidAdapter.js +++ b/modules/adtrueBidAdapter.js @@ -77,15 +77,6 @@ function _getDomainFromURL(url) { return anchor.hostname; } -function _parseSlotParam(paramName, paramValue) { - switch (paramName) { - case 'reserve': - return parseFloat(paramValue) || UNDEFINED; - default: - return paramValue; - } -} - let platform = (function getPlatform() { var ua = navigator.userAgent; if (ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1) { @@ -380,7 +371,7 @@ function _createImpressionObject(bid, conf) { impObj = { id: bid.bidId, tagid: String(bid.params.zoneId || undefined), - bidfloor: _parseSlotParam('reserve', bid.params.reserve), + bidfloor: 0, secure: 1, ext: {}, bidfloorcur: ADTRUE_CURRENCY diff --git a/modules/advangelistsBidAdapter.js b/modules/advangelistsBidAdapter.js deleted file mode 100755 index 746baa9ae35..00000000000 --- a/modules/advangelistsBidAdapter.js +++ /dev/null @@ -1,378 +0,0 @@ -import * as utils from '../src/utils.js'; -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; -import find from 'core-js-pure/features/array/find.js'; -import includes from 'core-js-pure/features/array/includes.js'; - -const ADAPTER_VERSION = '1.0'; -const BIDDER_CODE = 'advangelists'; - -export const VIDEO_ENDPOINT = 'https://nep.advangelists.com/xp/get?pubid=';// 0cf8d6d643e13d86a5b6374148a4afac'; -export const BANNER_ENDPOINT = 'https://nep.advangelists.com/xp/get?pubid=';// 0cf8d6d643e13d86a5b6374148a4afac'; -export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js'; -export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'skip']; -export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; - -let pubid = ''; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid(bidRequest) { - if (typeof bidRequest != 'undefined') { - if (bidRequest.bidder !== BIDDER_CODE && typeof bidRequest.params === 'undefined') { return false; } - if (bidRequest === '' || bidRequest.params.placement === '' || bidRequest.params.pubid === '') { return false; } - return true; - } else { return false; } - }, - - buildRequests(bids, bidderRequest) { - let requests = []; - let videoBids = bids.filter(bid => isVideoBidValid(bid)); - let bannerBids = bids.filter(bid => isBannerBidValid(bid)); - videoBids.forEach(bid => { - pubid = getVideoBidParam(bid, 'pubid'); - requests.push({ - method: 'POST', - url: VIDEO_ENDPOINT + pubid, - data: createVideoRequestData(bid, bidderRequest), - bidRequest: bid - }); - }); - - bannerBids.forEach(bid => { - pubid = getBannerBidParam(bid, 'pubid'); - requests.push({ - method: 'POST', - url: BANNER_ENDPOINT + pubid, - data: createBannerRequestData(bid, bidderRequest), - bidRequest: bid - }); - }); - return requests; - }, - - interpretResponse(serverResponse, {bidRequest}) { - let response = serverResponse.body; - if (response !== null && utils.isEmpty(response) == false) { - if (isVideoBid(bidRequest)) { - let bidResponse = { - requestId: response.id, - bidderCode: BIDDER_CODE, - cpm: response.seatbid[0].bid[0].price, - width: response.seatbid[0].bid[0].w, - height: response.seatbid[0].bid[0].h, - ttl: response.seatbid[0].bid[0].ttl || 60, - creativeId: response.seatbid[0].bid[0].crid, - currency: response.cur, - mediaType: VIDEO, - netRevenue: true - } - - if (response.seatbid[0].bid[0].adm) { - bidResponse.vastXml = response.seatbid[0].bid[0].adm; - bidResponse.adResponse = { - content: response.seatbid[0].bid[0].adm - }; - } else { - bidResponse.vastUrl = response.seatbid[0].bid[0].nurl; - } - - return bidResponse; - } else { - return { - requestId: response.id, - bidderCode: BIDDER_CODE, - cpm: response.seatbid[0].bid[0].price, - width: response.seatbid[0].bid[0].w, - height: response.seatbid[0].bid[0].h, - ad: response.seatbid[0].bid[0].adm, - ttl: response.seatbid[0].bid[0].ttl || 60, - creativeId: response.seatbid[0].bid[0].crid, - currency: response.cur, - mediaType: BANNER, - netRevenue: true - } - } - } - } -}; - -function isBannerBid(bid) { - return utils.deepAccess(bid, 'mediaTypes.banner') || !isVideoBid(bid); -} - -function isVideoBid(bid) { - return utils.deepAccess(bid, 'mediaTypes.video'); -} - -function isVideoBidValid(bid) { - return isVideoBid(bid) && getVideoBidParam(bid, 'pubid') && getVideoBidParam(bid, 'placement'); -} - -function isBannerBidValid(bid) { - return isBannerBid(bid) && getBannerBidParam(bid, 'pubid') && getBannerBidParam(bid, 'placement'); -} - -function getVideoBidParam(bid, key) { - return utils.deepAccess(bid, 'params.video.' + key) || utils.deepAccess(bid, 'params.' + key); -} - -function getBannerBidParam(bid, key) { - return utils.deepAccess(bid, 'params.banner.' + key) || utils.deepAccess(bid, 'params.' + key); -} - -function isMobile() { - return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); -} - -function isConnectedTV() { - return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); -} - -function getDoNotTrack() { - return navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNoTrack === '1' || navigator.doNotTrack === 'yes'; -} - -function findAndFillParam(o, key, value) { - try { - if (typeof value === 'function') { - o[key] = value(); - } else { - o[key] = value; - } - } catch (ex) {} -} - -function getOsVersion() { - let clientStrings = [ - { s: 'Android', r: /Android/ }, - { s: 'iOS', r: /(iPhone|iPad|iPod)/ }, - { s: 'Mac OS X', r: /Mac OS X/ }, - { s: 'Mac OS', r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ }, - { s: 'Linux', r: /(Linux|X11)/ }, - { s: 'Windows 10', r: /(Windows 10.0|Windows NT 10.0)/ }, - { s: 'Windows 8.1', r: /(Windows 8.1|Windows NT 6.3)/ }, - { s: 'Windows 8', r: /(Windows 8|Windows NT 6.2)/ }, - { s: 'Windows 7', r: /(Windows 7|Windows NT 6.1)/ }, - { s: 'Windows Vista', r: /Windows NT 6.0/ }, - { s: 'Windows Server 2003', r: /Windows NT 5.2/ }, - { s: 'Windows XP', r: /(Windows NT 5.1|Windows XP)/ }, - { s: 'UNIX', r: /UNIX/ }, - { s: 'Search Bot', r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/ } - ]; - let cs = find(clientStrings, cs => cs.r.test(navigator.userAgent)); - return cs ? cs.s : 'unknown'; -} - -function getFirstSize(sizes) { - return (sizes && sizes.length) ? sizes[0] : { w: undefined, h: undefined }; -} - -function parseSizes(sizes) { - return utils.parseSizesInput(sizes).map(size => { - let [ width, height ] = size.split('x'); - return { - w: parseInt(width, 10) || undefined, - h: parseInt(height, 10) || undefined - }; - }); -} - -function getVideoSizes(bid) { - return parseSizes(utils.deepAccess(bid, 'mediaTypes.video.playerSize') || bid.sizes); -} - -function getBannerSizes(bid) { - return parseSizes(utils.deepAccess(bid, 'mediaTypes.banner.sizes') || bid.sizes); -} - -function getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } -} - -function getVideoTargetingParams(bid) { - return Object.keys(Object(bid.params.video)) - .filter(param => includes(VIDEO_TARGETING, param)) - .reduce((obj, param) => { - obj[ param ] = bid.params.video[ param ]; - return obj; - }, {}); -} - -function createVideoRequestData(bid, bidderRequest) { - let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); - - let sizes = getVideoSizes(bid); - let firstSize = getFirstSize(sizes); - - let video = getVideoTargetingParams(bid); - const o = { - 'device': { - 'langauge': (global.navigator.language).split('-')[0], - 'dnt': (global.navigator.doNotTrack === 1 ? 1 : 0), - 'devicetype': isMobile() ? 4 : isConnectedTV() ? 3 : 2, - 'js': 1, - 'os': getOsVersion() - }, - 'at': 2, - 'site': {}, - 'tmax': 3000, - 'cur': ['USD'], - 'id': bid.bidId, - 'imp': [], - 'regs': { - 'ext': { - } - }, - 'user': { - 'ext': { - } - } - }; - - o.site['page'] = topLocation.href; - o.site['domain'] = topLocation.hostname; - o.site['search'] = topLocation.search; - o.site['domain'] = topLocation.hostname; - o.site['ref'] = topReferrer; - o.site['mobile'] = isMobile() ? 1 : 0; - const secure = topLocation.protocol.indexOf('https') === 0 ? 1 : 0; - - o.device['dnt'] = getDoNotTrack() ? 1 : 0; - - findAndFillParam(o.site, 'name', function() { - return global.top.document.title; - }); - - findAndFillParam(o.device, 'h', function() { - return global.screen.height; - }); - findAndFillParam(o.device, 'w', function() { - return global.screen.width; - }); - - let placement = getVideoBidParam(bid, 'placement'); - - for (let j = 0; j < sizes.length; j++) { - o.imp.push({ - 'id': '' + j, - 'displaymanager': '' + BIDDER_CODE, - 'displaymanagerver': '' + ADAPTER_VERSION, - 'tagId': placement, - 'bidfloor': 2.0, - 'bidfloorcur': 'USD', - 'secure': secure, - 'video': Object.assign({ - 'id': utils.generateUUID(), - 'pos': 0, - 'w': firstSize.w, - 'h': firstSize.h, - 'mimes': DEFAULT_MIMES - }, video) - - }); - } - - if (bidderRequest && bidderRequest.gdprConsent) { - let { gdprApplies, consentString } = bidderRequest.gdprConsent; - o.regs.ext = {'gdpr': gdprApplies ? 1 : 0}; - o.user.ext = {'consent': consentString}; - } - - return o; -} - -function getTopWindowLocation(bidderRequest) { - let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return utils.parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); -} - -function createBannerRequestData(bid, bidderRequest) { - let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); - - let sizes = getBannerSizes(bid); - - const o = { - 'device': { - 'langauge': (global.navigator.language).split('-')[0], - 'dnt': (global.navigator.doNotTrack === 1 ? 1 : 0), - 'devicetype': isMobile() ? 4 : isConnectedTV() ? 3 : 2, - 'js': 1 - }, - 'at': 2, - 'site': {}, - 'tmax': 3000, - 'cur': ['USD'], - 'id': bid.bidId, - 'imp': [], - 'regs': { - 'ext': { - } - }, - 'user': { - 'ext': { - } - } - }; - - o.site['page'] = topLocation.href; - o.site['domain'] = topLocation.hostname; - o.site['search'] = topLocation.search; - o.site['domain'] = topLocation.hostname; - o.site['ref'] = topReferrer; - o.site['mobile'] = isMobile() ? 1 : 0; - const secure = topLocation.protocol.indexOf('https') === 0 ? 1 : 0; - - o.device['dnt'] = getDoNotTrack() ? 1 : 0; - - findAndFillParam(o.site, 'name', function() { - return global.top.document.title; - }); - - findAndFillParam(o.device, 'h', function() { - return global.screen.height; - }); - findAndFillParam(o.device, 'w', function() { - return global.screen.width; - }); - - let placement = getBannerBidParam(bid, 'placement'); - for (let j = 0; j < sizes.length; j++) { - let size = sizes[j]; - - o.imp.push({ - 'id': '' + j, - 'displaymanager': '' + BIDDER_CODE, - 'displaymanagerver': '' + ADAPTER_VERSION, - 'tagId': placement, - 'bidfloor': 2.0, - 'bidfloorcur': 'USD', - 'secure': secure, - 'banner': { - 'id': utils.generateUUID(), - 'pos': 0, - 'w': size['w'], - 'h': size['h'] - } - }); - } - - if (bidderRequest && bidderRequest.gdprConsent) { - let { gdprApplies, consentString } = bidderRequest.gdprConsent; - o.regs.ext = {'gdpr': gdprApplies ? 1 : 0}; - o.user.ext = {'consent': consentString}; - } - - return o; -} - -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/aolBidAdapter.js b/modules/aolBidAdapter.js index 03e4ac9021a..4ab6f53ebdc 100644 --- a/modules/aolBidAdapter.js +++ b/modules/aolBidAdapter.js @@ -86,9 +86,7 @@ function _isOneMobileBidder(bidderCode) { function _isNexageRequestPost(bid) { if (_isOneMobileBidder(bid.bidder) && bid.params.id && bid.params.imp && bid.params.imp[0]) { let imp = bid.params.imp[0]; - return imp.id && imp.tagid && - ((imp.banner && imp.banner.w && imp.banner.h) || - (imp.video && imp.video.mimes && imp.video.minduration && imp.video.maxduration)); + return imp.id && imp.tagid && imp.banner && imp.banner.w && imp.banner.h; } } diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 58aa40f5ce9..72cf0baa3bd 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -14,6 +14,7 @@ const URL = 'https://ib.adnxs.com/ut/v3/prebid'; const URL_SIMPLE = 'https://ib.adnxs-simple.com/ut/v3/prebid'; const VIDEO_TARGETING = ['id', 'minduration', 'maxduration', 'skippable', 'playback_method', 'frameworks', 'context', 'skipoffset']; +const VIDEO_RTB_TARGETING = ['minduration', 'maxduration', 'skip', 'skipafter', 'playbackmethod', 'api']; const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately const DEBUG_PARAMS = ['enabled', 'dongle', 'member_id', 'debug_timeout']; @@ -818,6 +819,51 @@ function bidToTag(bid) { } } + // use IAB ORTB values if the corresponding values weren't already set by bid.params.video + if (videoMediaType) { + tag.video = tag.video || {}; + Object.keys(videoMediaType) + .filter(param => includes(VIDEO_RTB_TARGETING, param)) + .forEach(param => { + switch (param) { + case 'minduration': + case 'maxduration': + if (typeof tag.video[param] !== 'number') tag.video[param] = videoMediaType[param]; + break; + case 'skip': + if (typeof tag.video['skippable'] !== 'boolean') tag.video['skippable'] = (videoMediaType[param] === 1); + break; + case 'skipafter': + if (typeof tag.video['skipoffset'] !== 'number') tag.video['skippoffset'] = videoMediaType[param]; + break; + case 'playbackmethod': + if (typeof tag.video['playback_method'] !== 'number') { + let type = videoMediaType[param]; + type = (utils.isArray(type)) ? type[0] : type; + + // we only support iab's options 1-4 at this time. + if (type >= 1 && type <= 4) { + tag.video['playback_method'] = type; + } + } + break; + case 'api': + if (!tag['video_frameworks'] && utils.isArray(videoMediaType[param])) { + // need to read thru array; remove 6 (we don't support it), swap 4 <> 5 if found (to match our adserver mapping for these specific values) + let apiTmp = videoMediaType[param].map(val => { + let v = (val === 4) ? 5 : (val === 5) ? 4 : val; + + if (v >= 1 && v <= 5) { + return v; + } + }).filter(v => v); + tag['video_frameworks'] = apiTmp; + } + break; + } + }); + } + if (bid.renderer) { tag.video = Object.assign({}, tag.video, { custom_renderer_present: true }); } diff --git a/modules/appnexusBidAdapter.md b/modules/appnexusBidAdapter.md index d1f61836297..7ac70e67584 100644 --- a/modules/appnexusBidAdapter.md +++ b/modules/appnexusBidAdapter.md @@ -89,7 +89,18 @@ var adUnits = [ mediaTypes: { video: { playerSize: [[300, 250]], - context: 'outstream' + context: 'outstream', + // Certain ORTB 2.5 video values can be read from the mediatypes object; below are examples of supported params. + // To note - appnexus supports additional values for our system that are not part of the ORTB spec. If you want + // to use these values, they will have to be declared in the bids[].params.video object instead using the appnexus syntax. + // Between the corresponding values of the mediaTypes.video and params.video objects, the properties in params.video will + // take precedence if declared; eg in the example below, the `skippable: true` setting will be used instead of the `skip: 0`. + minduration: 1, + maxduration: 60, + skip: 0, // 1 - true, 0 - false + skipafter: 5, + playbackmethod: [2], // note - we only support options 1-4 at this time + api: [1,2,3] // note - option 6 is not supported at this time } }, bids: [ 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/betweenBidAdapter.js b/modules/betweenBidAdapter.js index 5a351def958..feb6cae437a 100644 --- a/modules/betweenBidAdapter.js +++ b/modules/betweenBidAdapter.js @@ -1,5 +1,5 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { getAdUnitSizes, parseSizesInput, deepAccess } from '../src/utils.js'; +import { getAdUnitSizes, parseSizesInput } from '../src/utils.js'; import { getRefererInfo } from '../src/refererDetection.js'; const BIDDER_CODE = 'between'; @@ -37,8 +37,6 @@ export const spec = { tz: getTz(), fl: getFl(), rr: getRr(), - shid: getSharedId(i)('id'), - shid3: getSharedId(i)('third'), s: i.params.s, bidid: i.bidId, transactionid: i.transactionId, @@ -149,15 +147,6 @@ export const spec = { } } -function getSharedId(bid) { - const id = deepAccess(bid, 'userId.sharedid.id'); - const third = deepAccess(bid, 'userId.sharedid.third'); - return function(kind) { - if (kind === 'id') return id || ''; - return third || ''; - } -} - function getRr() { try { var td = top.document; diff --git a/modules/bidfluenceBidAdapter.js b/modules/bidfluenceBidAdapter.js deleted file mode 100644 index f8a1f9ac92f..00000000000 --- a/modules/bidfluenceBidAdapter.js +++ /dev/null @@ -1,131 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const storage = getStorageManager(); -const BIDDER_CODE = 'bidfluence'; - -function stdTimezoneOffset(t) { - const jan = new Date(t.getFullYear(), 0, 1); - const jul = new Date(t.getFullYear(), 6, 1); - return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); -} -function dst(t) { - return t.getTimezoneOffset() < stdTimezoneOffset(t); -} -function getBdfTz(d) { - let tz = d.getTimezoneOffset(); - if (dst(d)) { - tz += 60; - } - return tz.toString(); -} -function getUTCDate() { - var m = new Date(); - var dateString = m.getUTCFullYear() + '/' + - ('0' + (m.getUTCMonth() + 1)).slice(-2) + '/' + - ('0' + m.getUTCDate()).slice(-2) + ' ' + - ('0' + m.getUTCHours()).slice(-2) + ':' + - ('0' + m.getUTCMinutes()).slice(-2) + ':' + - ('0' + m.getUTCSeconds()).slice(-2); - - return dateString; -} - -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function (bid) { - return !!bid.params.placementId || !!bid.params.publisherId; - }, - - buildRequests: function (validBidRequests, bidderRequest) { - const body = document.getElementsByTagName('body')[0]; - const refInfo = bidderRequest.refererInfo; - const gdpr = bidderRequest.gdprConsent; - const vpW = Math.max(window.innerWidth || body.clientWidth || 0) + 2; - const vpH = Math.max(window.innerHeight || body.clientHeight || 0) + 2; - const sr = screen.height > screen.width ? screen.height + 'x' + screen.width + 'x' + screen.colorDepth : screen.width + 'x' + screen.height + 'x' + screen.colorDepth; - - var payload = { - v: '2.0', - azr: true, - ck: storage.cookiesAreEnabled(), - re: refInfo ? refInfo.referer : '', - st: refInfo ? refInfo.stack : [], - tz: getBdfTz(new Date()), - sr: sr, - tm: bidderRequest.timeout, - vp: vpW + 'x' + vpH, - sdt: getUTCDate(), - top: refInfo ? refInfo.reachedTop : false, - gdpr: gdpr ? gdpr.gdprApplies : false, - gdprc: gdpr ? gdpr.consentString : '', - bids: [] - }; - - utils._each(validBidRequests, function (bidRequest) { - var params = bidRequest.params; - var sizes = utils.parseSizesInput(bidRequest.sizes)[0]; - var width = sizes.split('x')[0]; - var height = sizes.split('x')[1]; - - var currentBidPayload = { - bid: bidRequest.bidId, - tid: params.placementId, - pid: params.publisherId, - rp: params.reservePrice || 0, - w: width, - h: height - }; - - payload.bids.push(currentBidPayload); - }); - - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: `https://bdf${payload.bids[0].pid}.bidfluence.com/Prebid`, - data: payloadString, - options: { contentType: 'text/plain' } - }; - }, - - interpretResponse: function (serverResponse, bidRequest) { - const bidResponses = []; - const response = serverResponse.body; - - utils._each(response.Bids, function (currentResponse) { - var cpm = currentResponse.Cpm || 0; - - if (cpm > 0) { - const bidResponse = { - requestId: currentResponse.BidId, - cpm: cpm, - width: currentResponse.Width, - height: currentResponse.Height, - creativeId: currentResponse.CreativeId, - ad: currentResponse.Ad, - currency: 'USD', - netRevenue: true, - ttl: 360 - }; - bidResponses.push(bidResponse); - } - }); - - return bidResponses; - }, - - getUserSyncs: function (serverResponses) { - if (serverResponses.userSyncs) { - const syncs = serverResponses.UserSyncs.map((sync) => { - return { - type: sync.Type === 'ifr' ? 'iframe' : 'image', - url: sync.Url - }; - }); - return syncs; - } - } -}; -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/c1xBidAdapter.js b/modules/c1xBidAdapter.js deleted file mode 100644 index 8e1f1487ba7..00000000000 --- a/modules/c1xBidAdapter.js +++ /dev/null @@ -1,178 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import { userSync } from '../src/userSync.js'; - -const BIDDER_CODE = 'c1x'; -const URL = 'https://ht.c1exchange.com/ht'; -const PIXEL_ENDPOINT = 'https://px.c1exchange.com/pubpixel/'; -const LOG_MSG = { - invalidBid: 'C1X: [ERROR] bidder returns an invalid bid', - noSite: 'C1X: [ERROR] no site id supplied', - noBid: 'C1X: [INFO] creating a NO bid for Adunit: ', - bidWin: 'C1X: [INFO] creating a bid for Adunit: ' -}; - -/** - * Adapter for requesting bids from C1X header tag server. - * v3.1 (c) C1X Inc., 2018 - */ - -export const c1xAdapter = { - code: BIDDER_CODE, - - // check the bids sent to c1x bidder - isBidRequestValid: function(bid) { - const siteId = bid.params.siteId || ''; - if (!siteId) { - utils.logError(LOG_MSG.noSite); - } - return !!(bid.adUnitCode && siteId); - }, - - buildRequests: function(bidRequests, bidderRequest) { - let payload = {}; - let tagObj = {}; - let pixelUrl = ''; - const adunits = bidRequests.length; - const rnd = new Date().getTime(); - const c1xTags = bidRequests.map(bidToTag); - const bidIdTags = bidRequests.map(bidToShortTag); // include only adUnitCode and bidId from request obj - - // flattened tags in a tag object - tagObj = c1xTags.reduce((current, next) => Object.assign(current, next)); - const pixelId = tagObj.pixelId; - - payload = { - adunits: adunits.toString(), - rnd: rnd.toString(), - response: 'json', - compress: 'gzip' - } - - // for GDPR support - if (bidderRequest && bidderRequest.gdprConsent) { - payload['consent_string'] = bidderRequest.gdprConsent.consentString; - payload['consent_required'] = (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies.toString() : 'true' - ; - } - - if (pixelId) { - pixelUrl = PIXEL_ENDPOINT + pixelId; - if (payload.consent_required) { - pixelUrl += '&gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? 1 : 0); - pixelUrl += '&consent=' + encodeURIComponent(bidderRequest.gdprConsent.consentString || ''); - } - userSync.registerSync('image', BIDDER_CODE, pixelUrl); - } - - Object.assign(payload, tagObj); - - let payloadString = stringifyPayload(payload); - // ServerRequest object - return { - method: 'GET', - url: URL, - data: payloadString, - bids: bidIdTags - }; - }, - - interpretResponse: function(serverResponse, requests) { - serverResponse = serverResponse.body; - requests = requests.bids || []; - const currency = 'USD'; - const bidResponses = []; - let netRevenue = false; - - if (!serverResponse || serverResponse.error) { - let errorMessage = serverResponse.error; - utils.logError(LOG_MSG.invalidBid + errorMessage); - return bidResponses; - } else { - serverResponse.forEach(bid => { - if (bid.bid) { - if (bid.bidType === 'NET_BID') { - netRevenue = !netRevenue; - } - const curBid = { - width: bid.width, - height: bid.height, - cpm: bid.cpm, - ad: bid.ad, - creativeId: bid.crid, - currency: currency, - ttl: 300, - netRevenue: netRevenue - }; - - for (let i = 0; i < requests.length; i++) { - if (bid.adId === requests[i].adUnitCode) { - curBid.requestId = requests[i].bidId; - } - } - utils.logInfo(LOG_MSG.bidWin + bid.adId + ' size: ' + curBid.width + 'x' + curBid.height); - bidResponses.push(curBid); - } else { - // no bid - utils.logInfo(LOG_MSG.noBid + bid.adId); - } - }); - } - - return bidResponses; - } -} - -function bidToTag(bid, index) { - const tag = {}; - const adIndex = 'a' + (index + 1).toString(); // ad unit id for c1x - const sizeKey = adIndex + 's'; - const priceKey = adIndex + 'p'; - // TODO: Multiple Floor Prices - - const sizesArr = bid.sizes; - const floorPriceMap = bid.params.floorPriceMap || ''; - tag['site'] = bid.params.siteId || ''; - - // prevent pixelId becoming undefined when publishers don't fill this param in ad units they have on the same page - if (bid.params.pixelId) { - tag['pixelId'] = bid.params.pixelId - } - - tag[adIndex] = bid.adUnitCode; - tag[sizeKey] = sizesArr.reduce((prev, current) => prev + (prev === '' ? '' : ',') + current.join('x'), ''); - - const newSizeArr = tag[sizeKey].split(','); - if (floorPriceMap) { - newSizeArr.forEach(size => { - if (size in floorPriceMap) { - tag[priceKey] = floorPriceMap[size].toString(); - } // we only accept one cpm price in floorPriceMap - }); - } - if (bid.params.pageurl) { - tag['pageurl'] = bid.params.pageurl; - } - - return tag; -} - -function bidToShortTag(bid) { - const tag = {}; - tag.adUnitCode = bid.adUnitCode; - tag.bidId = bid.bidId; - - return tag; -} - -function stringifyPayload(payload) { - let payloadString = ''; - payloadString = JSON.stringify(payload).replace(/":"|","|{"|"}/g, (foundChar) => { - if (foundChar == '":"') return '='; - else if (foundChar == '","') return '&'; - else return ''; - }); - return payloadString; -} - -registerBidder(c1xAdapter); 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/cleanmedianetBidAdapter.js b/modules/cleanmedianetBidAdapter.js index 80e4f13e7d4..7b36117d404 100644 --- a/modules/cleanmedianetBidAdapter.js +++ b/modules/cleanmedianetBidAdapter.js @@ -113,7 +113,7 @@ export const spec = { id: transactionId, instl: params.instl === 1 ? 1 : 0, tagid: adUnitCode, - bidfloor: params.bidfloor || 0, + bidfloor: 0, bidfloorcur: 'USD', secure: 1 }; 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/cosmosBidAdapter.js b/modules/cosmosBidAdapter.js deleted file mode 100644 index 73ee5c223b3..00000000000 --- a/modules/cosmosBidAdapter.js +++ /dev/null @@ -1,392 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'cosmos'; -const BID_ENDPOINT = 'https://bid.cosmoshq.com/openrtb2/bids'; -const USER_SYNC_ENDPOINT = 'https://sync.cosmoshq.com/js/v1/usersync.html'; -const HTTP_POST = 'POST'; -const LOG_PREFIX = 'COSMOS: '; -const DEFAULT_CURRENCY = 'USD'; -const HTTPS = 'https:'; -const MEDIA_TYPES = 'mediaTypes'; -const MIMES = 'mimes'; -const DEFAULT_NET_REVENUE = false; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - - /** - * generate UUID - **/ - _createUUID: function () { - return ('' + new Date().getTime()); - }, - - /** - * copy object if not null - **/ - _copyObject: function (src, dst) { - if (src) { - // copy complete object - Object.keys(src).forEach(param => dst[param] = src[param]); - } - }, - - /** - * parse object - **/ - _parse: function (rawPayload) { - try { - if (rawPayload) { - return JSON.parse(rawPayload); - } - } catch (ex) { - utils.logError(LOG_PREFIX, 'Exception: ', ex); - } - return null; - }, - - /** - * 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 || !bid.params) { - utils.logError(LOG_PREFIX, 'nil/empty bid object'); - return false; - } - - if (!utils.isEmpty(bid.params.publisherId) || - !utils.isNumber(bid.params.publisherId)) { - utils.logError(LOG_PREFIX, 'publisherId is mandatory and must be numeric. Ad Unit: ', JSON.stringify(bid)); - return false; - } - // video bid request validation - if (bid.hasOwnProperty(MEDIA_TYPES) && bid.mediaTypes.hasOwnProperty(VIDEO)) { - if (!bid.mediaTypes.video.hasOwnProperty(MIMES) || - !utils.isArray(bid.mediaTypes.video.mimes) || - bid.mediaTypes.video.mimes.length === 0) { - utils.logError(LOG_PREFIX, 'mimes are mandatory for video bid request. Ad Unit: ', JSON.stringify(bid)); - 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) { - if (validBidRequests.length === 0) { - return []; - } - - var refererInfo; - if (bidderRequest && bidderRequest.refererInfo) { - refererInfo = bidderRequest.refererInfo; - } - - let clonedBidRequests = utils.deepClone(validBidRequests); - return clonedBidRequests.map(bidRequest => { - const oRequest = spec._createRequest(bidRequest, refererInfo); - if (oRequest) { - spec._setGDPRParams(bidderRequest, oRequest); - return { - method: HTTP_POST, - url: BID_ENDPOINT, - data: JSON.stringify(oRequest) - }; - } - }); - }, - - /** - * 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, request) { - let response = serverResponse.body; - var bidResponses = []; - try { - if (response.seatbid) { - var currency = response.cur ? response.cur : DEFAULT_CURRENCY; - response.seatbid.forEach(seatbid => { - var bids = seatbid.bid ? seatbid.bid : []; - bids.forEach(bid => { - var bidResponse = { - requestId: bid.impid, - cpm: (parseFloat(bid.price) || 0).toFixed(2), - width: bid.w, - height: bid.h, - creativeId: bid.crid, - currency: currency, - netRevenue: DEFAULT_NET_REVENUE, - ttl: 300 - }; - if (bid.dealid) { - bidResponse.dealId = bid.dealid; - } - - var req = spec._parse(request.data); - if (req.imp && req.imp.length > 0) { - req.imp.forEach(impr => { - if (impr.id === bid.impid) { - if (impr.banner) { - bidResponse.ad = bid.adm; - bidResponse.mediaType = BANNER; - } else { - bidResponse.width = bid.hasOwnProperty('w') ? bid.w : impr.video.w; - bidResponse.height = bid.hasOwnProperty('h') ? bid.h : impr.video.h; - bidResponse.vastXml = bid.adm; - bidResponse.mediaType = VIDEO; - } - } - }); - } - bidResponses.push(bidResponse); - }); - }); - } - } catch (ex) { - utils.logError(LOG_PREFIX, 'Exception: ', ex); - } - 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) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: USER_SYNC_ENDPOINT - }]; - } else { - utils.logWarn(LOG_PREFIX + 'Please enable iframe based user sync.'); - } - }, - - /** - * create IAB standard OpenRTB bid request - **/ - _createRequest: function (bidRequests, refererInfo) { - var oRequest = {}; - try { - oRequest = { - id: spec._createUUID(), - imp: spec._createImpressions(bidRequests), - user: {}, - ext: {} - }; - var site = spec._createSite(bidRequests, refererInfo); - var app = spec._createApp(bidRequests); - var device = spec._createDevice(bidRequests); - if (app) { - oRequest.app = app; - } - if (site) { - oRequest.site = site; - } - if (device) { - oRequest.device = device; - } - } catch (ex) { - utils.logError(LOG_PREFIX, 'Exception: ', ex); - oRequest = null; - } - return oRequest; - }, - - /** - * create impression array objects - **/ - _createImpressions: function (request) { - var impressions = []; - var impression = spec._creatImpression(request); - if (impression) { - impressions.push(impression); - } - return impressions; - }, - - /** - * create impression (single) object - **/ - _creatImpression: function (request) { - if (!request.hasOwnProperty(MEDIA_TYPES)) { - return undefined; - } - - var params = request && request.params ? request.params : null; - var impression = { - id: request.bidId ? request.bidId : spec._createUUID(), - secure: window.location.protocol === HTTPS ? 1 : 0, - bidfloorcur: request.params.currency ? request.params.currency : DEFAULT_CURRENCY - }; - if (params.bidFloor) { - impression.bidfloor = params.bidFloor; - } - - if (params.tagId) { - impression.tagid = params.tagId.toString(); - } - - var banner; - var video; - var mediaType; - for (mediaType in request.mediaTypes) { - switch (mediaType) { - case BANNER: - banner = spec._createBanner(request); - if (banner) { - impression.banner = banner; - } - break; - case VIDEO: - video = spec._createVideo(request); - if (video) { - impression.video = video; - } - break; - } - } - - return impression.hasOwnProperty(BANNER) || - impression.hasOwnProperty(VIDEO) ? impression : undefined; - }, - - /** - * create the banner object - **/ - _createBanner: function (request) { - if (utils.deepAccess(request, 'mediaTypes.banner')) { - var banner = {}; - var sizes = request.mediaTypes.banner.sizes; - if (sizes && utils.isArray(sizes) && sizes.length > 0) { - var format = []; - banner.w = sizes[0][0]; - banner.h = sizes[0][1]; - sizes.forEach(size => { - format.push({ - w: size[0], - h: size[1] - }); - }); - banner.format = format; - } - - spec._copyObject(request.mediaTypes.banner, banner); - spec._copyObject(request.params.banner, banner); - return banner; - } - return undefined; - }, - - /** - * create video object - **/ - _createVideo: function (request) { - if (utils.deepAccess(request, 'mediaTypes.video')) { - var video = {}; - var sizes = request.mediaTypes.video.playerSize; - if (sizes && utils.isArray(sizes) && sizes.length > 1) { - video.w = sizes[0]; - video.h = sizes[1]; - } - spec._copyObject(request.mediaTypes.video, video); - spec._copyObject(request.params.video, video); - return video; - } - return undefined; - }, - - /** - * create site object - **/ - _createSite: function (request, refererInfo) { - var rSite = request.params.site; - if (rSite || !request.params.app) { - var site = {}; - spec._copyObject(rSite, site); - - if (refererInfo) { - if (refererInfo.referer) { - site.ref = encodeURIComponent(refererInfo.referer); - } - if (utils.isArray(refererInfo.stack) && refererInfo.stack.length > 0) { - site.page = encodeURIComponent(refererInfo.stack[0]); - let anchrTag = document.createElement('a'); - anchrTag.href = site.page; - site.domain = anchrTag.hostname; - } - } - - // override publisher object - site.publisher = { - id: request.params.publisherId.toString() - }; - return site; - } - return undefined; - }, - - /** - * create app object - **/ - _createApp: function (request) { - var rApp = request.params.app; - if (rApp) { - var app = {}; - spec._copyObject(rApp, app); - // override publisher object - app.publisher = { - id: request.params.publisherId.toString() - }; - return app; - } - return undefined; - }, - - /** - * create device obejct - **/ - _createDevice: function (request) { - var device = {}; - var rDevice = request.params.device; - spec._copyObject(rDevice, device); - device.dnt = utils.getDNT() ? 1 : 0; - device.ua = navigator.userAgent; - device.language = (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage); - device.w = (window.screen.width || window.innerWidth); - device.h = (window.screen.height || window.innerHeigh); - return device; - }, - - /** - * set GDPR parameters - **/ - _setGDPRParams: function (bidderRequest, oRequest) { - if (!bidderRequest || !bidderRequest.gdprConsent) { - return; - } - - oRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; - oRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; - }, - -} -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/criteoBidAdapter.js b/modules/criteoBidAdapter.js index 41cbb0670c8..b2866b8a751 100644 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -4,11 +4,11 @@ import {config} from '../src/config.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import * as utils from '../src/utils.js'; import find from 'core-js-pure/features/array/find.js'; -import { verify } from 'criteo-direct-rsa-validate/build/verify.js'; +import { verify } from 'criteo-direct-rsa-validate/build/verify.js'; // ref#2 import { getStorageManager } from '../src/storageManager.js'; const GVLID = 91; -export const ADAPTER_VERSION = 33; +export const ADAPTER_VERSION = 34; const BIDDER_CODE = 'criteo'; const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb'; const PROFILE_ID_INLINE = 207; @@ -16,9 +16,18 @@ export const PROFILE_ID_PUBLISHERTAG = 185; const storage = getStorageManager(GVLID); const LOG_PREFIX = 'Criteo: '; -// Unminified source code can be found in: https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js -const PUBLISHER_TAG_URL = 'https://static.criteo.net/js/ld/publishertag.prebid.js'; - +/* + If you don't want to use the FastBid adapter feature, you can lighten criteoBidAdapter size by : + 1. commenting the tryGetCriteoFastBid function inner content (see ref#1) + 2. removing the line 'verify' function import line (see ref#2) + + Unminified source code can be found in the privately shared repo: https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js +*/ +const FAST_BID_VERSION_PLACEHOLDER = '%FAST_BID_VERSION%'; +export const FAST_BID_VERSION_CURRENT = 105; +const FAST_BID_VERSION_LATEST = 'latest'; +const FAST_BID_VERSION_NONE = 'none'; +const PUBLISHER_TAG_URL_TEMPLATE = 'https://static.criteo.net/js/ld/publishertag.prebid' + FAST_BID_VERSION_PLACEHOLDER + '.js'; const FAST_BID_PUBKEY_E = 65537; const FAST_BID_PUBKEY_N = 'ztQYwCE5BU7T9CDM5he6rKoabstXRmkzx54zFPZkWbK530dwtLBDeaWBMxHBUT55CYyboR/EZ4efghPi3CoNGfGWezpjko9P6p2EwGArtHEeS4slhu/SpSIFMjG6fdrpRoNuIAMhq1Z+Pr/+HOd1pThFKeGFr2/NhtAg+TXAzaU='; @@ -65,15 +74,18 @@ export const spec = { }); // If publisher tag not already loaded try to get it from fast bid - if (!publisherTagAvailable()) { + const fastBidVersion = config.getConfig('criteo.fastBidVersion'); + const canLoadPublisherTag = canFastBid(fastBidVersion); + if (!publisherTagAvailable() && canLoadPublisherTag) { window.Criteo = window.Criteo || {}; window.Criteo.usePrebidEvents = false; tryGetCriteoFastBid(); + const fastBidUrl = getFastBidUrl(fastBidVersion); // Reload the PublisherTag after the timeout to ensure FastBid is up-to-date and tracking done properly setTimeout(() => { - loadExternalScript(PUBLISHER_TAG_URL, BIDDER_CODE); + loadExternalScript(fastBidUrl, BIDDER_CODE); }, bidderRequest.timeout); } @@ -127,6 +139,9 @@ export const spec = { height: slot.height, dealId: slot.dealCode, }; + if (slot.adomain) { + bid.meta = Object.assign({}, bid.meta, { advertiserDomains: slot.adomain }); + } if (slot.native) { if (bidRequest.params.nativeCallback) { bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback); @@ -305,15 +320,14 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { mimes: bidRequest.mediaTypes.video.mimes, protocols: bidRequest.mediaTypes.video.protocols, maxduration: bidRequest.mediaTypes.video.maxduration, - api: bidRequest.mediaTypes.video.api + api: bidRequest.mediaTypes.video.api, + skip: bidRequest.mediaTypes.video.skip || bidRequest.params.video.skip, + placement: bidRequest.mediaTypes.video.placement || bidRequest.params.video.placement, + minduration: bidRequest.mediaTypes.video.minduration || bidRequest.params.video.minduration, + playbackmethod: bidRequest.mediaTypes.video.playbackmethod || bidRequest.params.video.playbackmethod, + startdelay: bidRequest.mediaTypes.video.startdelay || bidRequest.params.video.startdelay }; - video.skip = bidRequest.params.video.skip; - video.placement = bidRequest.params.video.placement; - video.minduration = bidRequest.params.video.minduration; - video.playbackmethod = bidRequest.params.video.playbackmethod; - video.startdelay = bidRequest.params.video.startdelay; - slot.video = video; } return slot; @@ -367,38 +381,27 @@ function parseNativeSize(size) { } function hasVideoMediaType(bidRequest) { - if (utils.deepAccess(bidRequest, 'params.video') === undefined) { - return false; - } return utils.deepAccess(bidRequest, 'mediaTypes.video') !== undefined; } function hasValidVideoMediaType(bidRequest) { let isValid = true; - var requiredMediaTypesParams = ['mimes', 'playerSize', 'maxduration', 'protocols', 'api']; + var requiredMediaTypesParams = ['mimes', 'playerSize', 'maxduration', 'protocols', 'api', 'skip', 'placement', 'playbackmethod']; requiredMediaTypesParams.forEach(function(param) { - if (utils.deepAccess(bidRequest, 'mediaTypes.video.' + param) === undefined) { + if (utils.deepAccess(bidRequest, 'mediaTypes.video.' + param) === undefined && utils.deepAccess(bidRequest, 'params.video.' + param) === undefined) { isValid = false; utils.logError('Criteo Bid Adapter: mediaTypes.video.' + param + ' is required'); } }); - var requiredParams = ['skip', 'placement', 'playbackmethod']; - - requiredParams.forEach(function(param) { - if (utils.deepAccess(bidRequest, 'params.video.' + param) === undefined) { - isValid = false; - utils.logError('Criteo Bid Adapter: params.video.' + param + ' is required'); - } - }); - if (isValid) { + const videoPlacement = bidRequest.mediaTypes.video.placement || bidRequest.params.video.placement; // We do not support long form for now, also we have to check that context & placement are consistent - if (bidRequest.mediaTypes.video.context == 'instream' && bidRequest.params.video.placement === 1) { + if (bidRequest.mediaTypes.video.context == 'instream' && videoPlacement === 1) { return true; - } else if (bidRequest.mediaTypes.video.context == 'outstream' && bidRequest.params.video.placement !== 1) { + } else if (bidRequest.mediaTypes.video.context == 'outstream' && videoPlacement !== 1) { return true; } } @@ -454,7 +457,29 @@ for (var i = 0; i < 10; ++i) { `; } +export function canFastBid(fastBidVersion) { + return fastBidVersion !== FAST_BID_VERSION_NONE; +} + +export function getFastBidUrl(fastBidVersion) { + let version; + if (fastBidVersion === FAST_BID_VERSION_LATEST) { + version = ''; + } else if (fastBidVersion) { + let majorVersion = String(fastBidVersion).split('.')[0]; + if (majorVersion < 102) { + utils.logWarn('Specifying a Fastbid version which is not supporting version selection.') + } + version = '.' + fastBidVersion; + } else { + version = '.' + FAST_BID_VERSION_CURRENT; + } + + return PUBLISHER_TAG_URL_TEMPLATE.replace(FAST_BID_VERSION_PLACEHOLDER, version); +} + export function tryGetCriteoFastBid() { + // begin ref#1 try { const fastBidStorageKey = 'criteo_fast_bid'; const hashPrefix = '// Hash: '; @@ -485,6 +510,7 @@ export function tryGetCriteoFastBid() { } catch (e) { // Unable to get fast bid } + // end ref#1 } registerBidder(spec); diff --git a/modules/criteoBidAdapter.md b/modules/criteoBidAdapter.md index 68599f05434..6a165978f3b 100644 --- a/modules/criteoBidAdapter.md +++ b/modules/criteoBidAdapter.md @@ -31,7 +31,8 @@ Set the "ceh" property to provides the user's hashed email if available ``` pbjs.setConfig({ criteo: { - ceh: 'hashed mail' + ceh: 'hashed mail', + fastBidVersion: "none"|"latest"| } }); -``` \ No newline at end of file +``` diff --git a/modules/dailyhuntBidAdapter.js b/modules/dailyhuntBidAdapter.js deleted file mode 100644 index 1018417300a..00000000000 --- a/modules/dailyhuntBidAdapter.js +++ /dev/null @@ -1,395 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import * as mediaTypes from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; -import { ajax } from '../src/ajax.js'; -import find from 'core-js-pure/features/array/find.js'; -import { OUTSTREAM, INSTREAM } from '../src/video.js'; - -const BIDDER_CODE = 'dailyhunt'; -const BIDDER_ALIAS = 'dh'; -const SUPPORTED_MEDIA_TYPES = [mediaTypes.BANNER, mediaTypes.NATIVE, mediaTypes.VIDEO]; - -const PROD_PREBID_ENDPOINT_URL = 'https://pbs.dailyhunt.in/openrtb2/auction?partner='; -const PROD_PREBID_TEST_ENDPOINT_URL = 'https://qa-pbs-van.dailyhunt.in/openrtb2/auction?partner='; - -const ORTB_NATIVE_TYPE_MAPPING = { - img: { - '3': 'image', - '1': 'icon' - }, - data: { - '1': 'sponsoredBy', - '2': 'body', - '3': 'rating', - '4': 'likes', - '5': 'downloads', - '6': 'price', - '7': 'salePrice', - '8': 'phone', - '9': 'address', - '10': 'body2', - '11': 'displayUrl', - '12': 'cta' - } -} - -const ORTB_NATIVE_PARAMS = { - title: { - id: 0, - name: 'title' - }, - icon: { - id: 1, - type: 1, - name: 'img' - }, - image: { - id: 2, - type: 3, - name: 'img' - }, - sponsoredBy: { - id: 3, - name: 'data', - type: 1 - }, - body: { - id: 4, - name: 'data', - type: 2 - }, - cta: { - id: 5, - type: 12, - name: 'data' - }, - body2: { - id: 4, - name: 'data', - type: 10 - }, -}; - -// Encode URI. -const _encodeURIComponent = function (a) { - let b = window.encodeURIComponent(a); - b = b.replace(/'/g, '%27'); - return b; -} - -// Extract key from collections. -const extractKeyInfo = (collection, key) => { - for (let i = 0, result; i < collection.length; i++) { - result = utils.deepAccess(collection[i].params, key); - if (result) { - return result; - } - } - return undefined -} - -// Flattern Array. -const flatten = (arr) => { - return [].concat(...arr); -} - -const createOrtbRequest = (validBidRequests, bidderRequest) => { - let device = createOrtbDeviceObj(validBidRequests); - let user = createOrtbUserObj(validBidRequests) - let site = createOrtbSiteObj(validBidRequests, bidderRequest.refererInfo.referer) - return { - id: bidderRequest.auctionId, - imp: [], - site, - device, - user, - }; -} - -const createOrtbDeviceObj = (validBidRequests) => { - let device = { ...extractKeyInfo(validBidRequests, `device`) }; - device.ua = navigator.userAgent; - return device; -} - -const createOrtbUserObj = (validBidRequests) => ({ ...extractKeyInfo(validBidRequests, `user`) }) - -const createOrtbSiteObj = (validBidRequests, page) => { - let site = { ...extractKeyInfo(validBidRequests, `site`), page }; - let publisher = createOrtbPublisherObj(validBidRequests); - if (publisher) { - site.publisher = publisher - } - return site -} - -const createOrtbPublisherObj = (validBidRequests) => ({ ...extractKeyInfo(validBidRequests, `publisher`) }) - -const createOrtbImpObj = (bid) => { - let params = bid.params - let testMode = !!bid.params.test_mode - - // Validate Banner Request. - let bannerObj = utils.deepAccess(bid.mediaTypes, `banner`); - let nativeObj = utils.deepAccess(bid.mediaTypes, `native`); - let videoObj = utils.deepAccess(bid.mediaTypes, `video`); - - let imp = { - id: bid.bidId, - bidfloor: params.bidfloor ? params.bidfloor : 0, - ext: { - dailyhunt: { - placement_id: params.placement_id, - publisher_id: params.publisher_id, - partner: params.partner_name - } - } - }; - - // Test Mode Campaign. - if (testMode) { - imp.ext.test_mode = testMode; - } - - if (bannerObj) { - imp.banner = { - ...createOrtbImpBannerObj(bid, bannerObj) - } - } else if (nativeObj) { - imp.native = { - ...createOrtbImpNativeObj(bid, nativeObj) - } - } else if (videoObj) { - imp.video = { - ...createOrtbImpVideoObj(bid, videoObj) - } - } - return imp; -} - -const createOrtbImpBannerObj = (bid, bannerObj) => { - let format = []; - bannerObj.sizes.forEach(size => format.push({ w: size[0], h: size[1] })) - - return { - id: 'banner-' + bid.bidId, - format - } -} - -const createOrtbImpNativeObj = (bid, nativeObj) => { - const assets = utils._map(bid.nativeParams, (bidParams, key) => { - const props = ORTB_NATIVE_PARAMS[key]; - const asset = { - required: bidParams.required & 1, - }; - if (props) { - let h = 0; - let w = 0; - - asset.id = props.id; - - if (bidParams.sizes) { - const sizes = flatten(bidParams.sizes); - w = sizes[0]; - h = sizes[1]; - } - - asset[props.name] = { - len: bidParams.len ? bidParams.len : 20, - type: props.type, - w, - h - }; - - return asset; - } - }).filter(Boolean); - let request = { - assets, - ver: '1,0' - } - return { request: JSON.stringify(request) }; -} - -const createOrtbImpVideoObj = (bid, videoObj) => { - let obj = {}; - let params = bid.params - if (!utils.isEmpty(bid.params.video)) { - obj = { - ...params.video, - } - } else { - obj = { - mimes: ['video/mp4'], - }; - } - obj.ext = { - ...videoObj, - } - return obj; -} - -const createServerRequest = (ortbRequest, validBidRequests, isTestMode = 'false') => ({ - method: 'POST', - url: isTestMode === 'true' ? PROD_PREBID_TEST_ENDPOINT_URL + validBidRequests[0].params.partner_name : PROD_PREBID_ENDPOINT_URL + validBidRequests[0].params.partner_name, - data: JSON.stringify(ortbRequest), - options: { - contentType: 'application/json', - withCredentials: true - }, - bids: validBidRequests -}) - -const createPrebidBannerBid = (bid, bidResponse) => ({ - requestId: bid.bidId, - cpm: bidResponse.price.toFixed(2), - creativeId: bidResponse.crid, - width: bidResponse.w, - height: bidResponse.h, - ttl: 360, - netRevenue: bid.netRevenue === 'net', - currency: 'USD', - ad: bidResponse.adm, - mediaType: 'banner', - winUrl: bidResponse.nurl -}) - -const createPrebidNativeBid = (bid, bidResponse) => ({ - requestId: bid.bidId, - cpm: bidResponse.price.toFixed(2), - creativeId: bidResponse.crid, - currency: 'USD', - ttl: 360, - netRevenue: bid.netRevenue === 'net', - native: parseNative(bidResponse), - mediaType: 'native', - winUrl: bidResponse.nurl, - width: bidResponse.w, - height: bidResponse.h, -}) - -const parseNative = (bid) => { - let adm = JSON.parse(bid.adm) - const { assets, link, imptrackers, jstracker } = adm.native; - const result = { - clickUrl: _encodeURIComponent(link.url), - clickTrackers: link.clicktrackers || [], - impressionTrackers: imptrackers || [], - javascriptTrackers: jstracker ? [ jstracker ] : [] - }; - assets.forEach(asset => { - if (!utils.isEmpty(asset.title)) { - result.title = asset.title.text - } else if (!utils.isEmpty(asset.img)) { - result[ORTB_NATIVE_TYPE_MAPPING.img[asset.img.type]] = { - url: asset.img.url, - height: asset.img.h, - width: asset.img.w - } - } else if (!utils.isEmpty(asset.data)) { - result[ORTB_NATIVE_TYPE_MAPPING.data[asset.data.type]] = asset.data.value - } - }); - - return result; -} - -const createPrebidVideoBid = (bid, bidResponse) => { - let videoBid = { - requestId: bid.bidId, - cpm: bidResponse.price.toFixed(2), - creativeId: bidResponse.crid, - width: bidResponse.w, - height: bidResponse.h, - ttl: 360, - netRevenue: bid.netRevenue === 'net', - currency: 'USD', - mediaType: 'video', - winUrl: bidResponse.nurl, - }; - - let videoContext = bid.mediaTypes.video.context; - switch (videoContext) { - case OUTSTREAM: - videoBid.vastXml = bidResponse.adm; - break; - case INSTREAM: - videoBid.videoCacheKey = bidResponse.ext.bidder.cacheKey; - videoBid.vastUrl = bidResponse.ext.bidder.vastUrl; - break; - } - return videoBid; -} - -const getQueryVariable = (variable) => { - let query = window.location.search.substring(1); - let vars = query.split('&'); - for (var i = 0; i < vars.length; i++) { - let pair = vars[i].split('='); - if (decodeURIComponent(pair[0]) == variable) { - return decodeURIComponent(pair[1]); - } - } - return false; -} - -export const spec = { - code: BIDDER_CODE, - - aliases: [BIDDER_ALIAS], - - supportedMediaTypes: SUPPORTED_MEDIA_TYPES, - - isBidRequestValid: bid => !!bid.params.placement_id && !!bid.params.publisher_id && !!bid.params.partner_name, - - buildRequests: function (validBidRequests, bidderRequest) { - let serverRequests = []; - - // ORTB Request. - let ortbReq = createOrtbRequest(validBidRequests, bidderRequest); - - validBidRequests.forEach((bid) => { - let imp = createOrtbImpObj(bid) - ortbReq.imp.push(imp); - }); - - serverRequests.push({ ...createServerRequest(ortbReq, validBidRequests, getQueryVariable('dh_test')) }); - - return serverRequests; - }, - - interpretResponse: function (serverResponse, request) { - const { seatbid } = serverResponse.body; - let bids = request.bids; - let prebidResponse = []; - - let seatBids = seatbid[0].bid; - - seatBids.forEach(ortbResponseBid => { - let bidId = ortbResponseBid.impid; - let actualBid = find(bids, (bid) => bid.bidId === bidId); - let bidMediaType = ortbResponseBid.ext.prebid.type - switch (bidMediaType) { - case mediaTypes.BANNER: - prebidResponse.push(createPrebidBannerBid(actualBid, ortbResponseBid)); - break; - case mediaTypes.NATIVE: - prebidResponse.push(createPrebidNativeBid(actualBid, ortbResponseBid)); - break; - case mediaTypes.VIDEO: - prebidResponse.push(createPrebidVideoBid(actualBid, ortbResponseBid)); - break; - } - }) - return prebidResponse; - }, - - onBidWon: function(bid) { - ajax(bid.winUrl, null, null, { - method: 'GET' - }) - } -} - -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/dfpAdServerVideo.js b/modules/dfpAdServerVideo.js index 22c904b604c..79cb03ec001 100644 --- a/modules/dfpAdServerVideo.js +++ b/modules/dfpAdServerVideo.js @@ -123,7 +123,7 @@ export function notifyTranslationModule(fn) { fn.call(this, 'dfp'); } -getHook('registerAdserver').before(notifyTranslationModule); +if (config.getConfig('brandCategoryTranslation.translationFile')) { getHook('registerAdserver').before(notifyTranslationModule); } /** * @typedef {Object} DfpAdpodOptions @@ -271,7 +271,7 @@ function getCustParams(bid, options) { const prebidTargetingSet = Object.assign({}, // Why are we adding standard keys here ? Refer https://github.com/prebid/Prebid.js/issues/3664 { hb_uuid: bid && bid.videoCacheKey }, - // hb_uuid will be deprecated and replaced by hb_cache_id + // hb_cache_id became optional in prebid 5.0 after 4.x enabled the concept of optional keys. Discussion led to reversing the prior expectation of deprecating hb_uuid { hb_cache_id: bid && bid.videoCacheKey }, allTargetingData, adserverTargeting, diff --git a/modules/districtmDMXBidAdapter.js b/modules/districtmDMXBidAdapter.js index ec0a0a2f2e6..a35965c4cb4 100644 --- a/modules/districtmDMXBidAdapter.js +++ b/modules/districtmDMXBidAdapter.js @@ -120,7 +120,6 @@ export const spec = { bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.lotamePanoramaId`), 'lotame.com', 1); bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.parrableId`), 'parrable.com', 1); bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.netId`), 'netid.de', 1); - bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.sharedid`), 'sharedid.org', 1); dmxRequest.user = dmxRequest.user || {}; dmxRequest.user.ext = dmxRequest.user.ext || {}; dmxRequest.user.ext.eids = eids; 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/ebdrBidAdapter.js b/modules/ebdrBidAdapter.js deleted file mode 100644 index c30c10d8a90..00000000000 --- a/modules/ebdrBidAdapter.js +++ /dev/null @@ -1,151 +0,0 @@ -import * as utils from '../src/utils.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -const BIDDER_CODE = 'ebdr'; -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [ BANNER, VIDEO ], - isBidRequestValid: function(bid) { - return !!(bid && bid.params && bid.params.zoneid); - }, - buildRequests: function(bids) { - const rtbServerDomain = 'dsp.bnmla.com'; - let domain = window.location.host; - let page = window.location.pathname + location.search + location.hash; - let ebdrImps = []; - const ebdrReq = {}; - let ebdrParams = {}; - let zoneid = ''; - let requestId = ''; - bids.forEach(bid => { - utils.logInfo('Log bid', bid); - let bidFloor = utils.getBidIdParameter('bidfloor', bid.params); - let whArr = getWidthAndHeight(bid); - let _mediaTypes = (bid.mediaTypes && bid.mediaTypes.video) ? VIDEO : BANNER; - zoneid = utils.getBidIdParameter('zoneid', bid.params); - requestId = bid.bidderRequestId; - ebdrImps.push({ - id: bid.bidId, - [_mediaTypes]: { - w: whArr[0], - h: whArr[1] - }, - bidfloor: bidFloor - }) - ebdrReq[bid.bidId] = {mediaTypes: _mediaTypes, - w: whArr[0], - h: whArr[1] - }; - ebdrParams['latitude'] = utils.getBidIdParameter('latitude', bid.params); - ebdrParams['longitude'] = utils.getBidIdParameter('longitude', bid.params); - ebdrParams['ifa'] = (utils.getBidIdParameter('IDFA', bid.params).length > utils.getBidIdParameter('ADID', bid.params).length) ? utils.getBidIdParameter('IDFA', bid.params) : utils.getBidIdParameter('ADID', bid.params); - }); - let ebdrBidReq = { - id: requestId, - imp: ebdrImps, - site: { - domain: domain, - page: page - }, - device: { - geo: { - lat: ebdrParams.latitude, - log: ebdrParams.longitude - }, - ifa: ebdrParams.ifa - } - }; - return { - method: 'GET', - url: 'https://' + rtbServerDomain + '/hb?' + '&zoneid=' + zoneid + '&br=' + encodeURIComponent(JSON.stringify(ebdrBidReq)), - bids: ebdrReq - }; - }, - interpretResponse: function(serverResponse, bidRequest) { - utils.logInfo('Log serverResponse', serverResponse); - utils.logInfo('Log bidRequest', bidRequest); - let ebdrResponseImps = []; - const ebdrResponseObj = serverResponse.body; - if (!ebdrResponseObj || !ebdrResponseObj.seatbid || ebdrResponseObj.seatbid.length === 0 || !ebdrResponseObj.seatbid[0].bid || ebdrResponseObj.seatbid[0].bid.length === 0) { - return []; - } - ebdrResponseObj.seatbid[0].bid.forEach(ebdrBid => { - let responseCPM; - responseCPM = parseFloat(ebdrBid.price); - let adm; - let type; - let _mediaTypes; - let vastURL; - if (bidRequest.bids[ebdrBid.id].mediaTypes == BANNER) { - adm = decodeURIComponent(ebdrBid.adm) - type = 'ad'; - _mediaTypes = BANNER; - } else { - adm = ebdrBid.adm - type = 'vastXml' - _mediaTypes = VIDEO; - if (ebdrBid.nurl) { - vastURL = ebdrBid.nurl; - } - } - let response = { - requestId: ebdrBid.id, - [type]: adm, - mediaType: _mediaTypes, - creativeId: ebdrBid.crid, - cpm: responseCPM, - width: ebdrBid.w, - height: ebdrBid.h, - currency: 'USD', - netRevenue: true, - ttl: 3600 } - if (vastURL) { - response.vastUrl = vastURL; - } - ebdrResponseImps.push(response); - }); - return ebdrResponseImps; - }, - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = [] - if (syncOptions.pixelEnabled) { - const ebdrResponseObj = serverResponses.body; - if (!ebdrResponseObj || !ebdrResponseObj.seatbid || ebdrResponseObj.seatbid.length === 0 || !ebdrResponseObj.seatbid[0].bid || ebdrResponseObj.seatbid[0].bid.length === 0) { - return []; - } - ebdrResponseObj.seatbid[0].bid.forEach(ebdrBid => { - if (ebdrBid.iurl && ebdrBid.iurl.length > 0) { - syncs.push({ - type: 'image', - url: ebdrBid.iurl - }); - } - }); - } - return syncs; - } -} -function getWidthAndHeight(bid) { - let adW = null; - let adH = null; - // Handing old bidder only has size object - if (bid.sizes && bid.sizes.length) { - let sizeArrayLength = bid.sizes.length; - if (sizeArrayLength === 2 && typeof bid.sizes[0] === 'number' && typeof bid.sizes[1] === 'number') { - adW = bid.sizes[0]; - adH = bid.sizes[1]; - } - } - let _mediaTypes = bid.mediaTypes && bid.mediaTypes.video ? VIDEO : BANNER; - if (bid.mediaTypes && bid.mediaTypes[_mediaTypes]) { - if (_mediaTypes == BANNER && bid.mediaTypes[_mediaTypes].sizes && bid.mediaTypes[_mediaTypes].sizes[0] && bid.mediaTypes[_mediaTypes].sizes[0].length === 2) { - adW = bid.mediaTypes[_mediaTypes].sizes[0][0]; - adH = bid.mediaTypes[_mediaTypes].sizes[0][1]; - } else if (_mediaTypes == VIDEO && bid.mediaTypes[_mediaTypes].playerSize && bid.mediaTypes[_mediaTypes].playerSize.length === 2) { - adW = bid.mediaTypes[_mediaTypes].playerSize[0]; - adH = bid.mediaTypes[_mediaTypes].playerSize[1]; - } - } - return [adW, adH]; -} -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 fac273721ff..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: parseFloat(bidRequest.params.floor) > 0 ? bidRequest.params.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/getintentBidAdapter.js b/modules/getintentBidAdapter.js deleted file mode 100644 index 134dd0b4fc9..00000000000 --- a/modules/getintentBidAdapter.js +++ /dev/null @@ -1,160 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { isInteger } from '../src/utils.js'; - -const BIDDER_CODE = 'getintent'; -const IS_NET_REVENUE = true; -const BID_HOST = 'px.adhigh.net'; -const BID_BANNER_PATH = '/rtb/direct_banner'; -const BID_VIDEO_PATH = '/rtb/direct_vast'; -const BID_RESPONSE_TTL_SEC = 360; -const VIDEO_PROPERTIES = [ - 'protocols', 'mimes', 'min_dur', 'max_dur', 'min_btr', 'max_btr', 'vi_format', 'api', 'skippable' -]; -const OPTIONAL_PROPERTIES = [ - 'cur', 'floor', 'sid' -]; - -export const spec = { - code: BIDDER_CODE, - aliases: ['getintentAdapter'], - supportedMediaTypes: ['video', 'banner'], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid to validate. - * @return {boolean} True if this is a valid bid, and false otherwise. - * */ - isBidRequestValid: function(bid) { - return !!(bid && bid.params && bid.params.pid && bid.params.tid); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests - an array of bids. - * @return ServerRequest[] - */ - buildRequests: function(bidRequests) { - return bidRequests.map(bidRequest => { - let giBidRequest = buildGiBidRequest(bidRequest); - return { - method: 'GET', - url: buildUrl(giBidRequest), - data: giBidRequest, - }; - }); - }, - - /** - * Callback for bids, after the call to DSP completes. - * Parse the response from the server into a list of bids. - * - * @param {object} serverResponse A response from the GetIntent's server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse) { - let responseBody = serverResponse.body; - const bids = []; - if (responseBody && responseBody.no_bid !== 1) { - let size = parseSize(responseBody.size); - let bid = { - requestId: responseBody.bid_id, - ttl: BID_RESPONSE_TTL_SEC, - netRevenue: IS_NET_REVENUE, - currency: responseBody.currency, - creativeId: responseBody.creative_id, - cpm: responseBody.cpm, - width: size[0], - height: size[1] - }; - if (responseBody.vast_url) { - bid.mediaType = 'video'; - bid.vastUrl = responseBody.vast_url; - } else { - bid.mediaType = 'banner'; - bid.ad = responseBody.ad; - } - bids.push(bid); - } - return bids; - } - -} - -function buildUrl(bid) { - return 'https://' + BID_HOST + (bid.is_video ? BID_VIDEO_PATH : BID_BANNER_PATH); -} - -/** - * Builds GI bid request from BidRequest. - * - * @param {BidRequest} bidRequest. - * @return {object} GI bid request. - * */ -function buildGiBidRequest(bidRequest) { - let giBidRequest = { - bid_id: bidRequest.bidId, - pid: bidRequest.params.pid, // required - tid: bidRequest.params.tid, // required - known: bidRequest.params.known || 1, - is_video: bidRequest.mediaType === 'video', - resp_type: 'JSON', - provider: 'direct.prebidjs' - }; - if (bidRequest.sizes) { - giBidRequest.size = produceSize(bidRequest.sizes); - } - addVideo(bidRequest.params.video, giBidRequest); - addOptional(bidRequest.params, giBidRequest, OPTIONAL_PROPERTIES); - return giBidRequest; -} - -function addVideo(video, giBidRequest) { - if (giBidRequest.is_video && video) { - for (let i = 0, l = VIDEO_PROPERTIES.length; i < l; i++) { - let key = VIDEO_PROPERTIES[i]; - if (video.hasOwnProperty(key)) { - giBidRequest[key] = Array.isArray(video[key]) ? video[key].join(',') : video[key]; - } - } - } -} - -function addOptional(params, request, props) { - for (let i = 0; i < props.length; i++) { - if (params.hasOwnProperty(props[i])) { - request[props[i]] = params[props[i]]; - } - } -} - -/** - * @param {String} s The string representing a size (e.g. "300x250"). - * @return {Number[]} An array with two elements: [width, height] (e.g.: [300, 250]). - * */ -function parseSize(s) { - return s.split('x').map(Number); -} - -/** - * @param {Array} sizes An array of sizes/numbers to be joined into single string. - * May be an array (e.g. [300, 250]) or array of arrays (e.g. [[300, 250], [640, 480]]. - * @return {String} The string with sizes, e.g. array of sizes [[50, 50], [80, 80]] becomes "50x50,80x80" string. - * */ -function produceSize (sizes) { - function sizeToStr(s) { - if (Array.isArray(s) && s.length === 2 && isInteger(s[0]) && isInteger(s[1])) { - return s.join('x'); - } else { - throw "Malformed parameter 'sizes'"; - } - } - if (Array.isArray(sizes) && Array.isArray(sizes[0])) { - return sizes.map(sizeToStr).join(','); - } else { - return sizeToStr(sizes); - } -} - -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/iasBidAdapter.js b/modules/iasBidAdapter.js deleted file mode 100644 index 733c123e769..00000000000 --- a/modules/iasBidAdapter.js +++ /dev/null @@ -1,134 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'ias'; - -const otherBidIds = []; - -function isBidRequestValid(bid) { - const { pubId, adUnitPath } = bid.params; - return !!(pubId && adUnitPath); -} - -/** - * Converts GPT-style size array into a string - * @param {Array} sizes: list of GPT-style sizes, e.g. [[300, 250], [300, 300]] - * @return {String} a string containing sizes, e.g. '[300.250,300.300]' - */ -function stringifySlotSizes(sizes) { - let result = ''; - if (utils.isArray(sizes)) { - result = sizes.reduce((acc, size) => { - acc.push(size.join('.')); - return acc; - }, []); - result = '[' + result.join(',') + ']'; - } - return result; -} - -function stringifySlot(bidRequest) { - const id = bidRequest.adUnitCode; - const ss = stringifySlotSizes(bidRequest.sizes); - const p = bidRequest.params.adUnitPath; - const slot = { id, ss, p }; - const keyValues = utils.getKeys(slot).map(function(key) { - return [key, slot[key]].join(':'); - }); - return '{' + keyValues.join(',') + '}'; -} - -function stringifyWindowSize() { - return [ window.innerWidth || -1, window.innerHeight || -1 ].join('.'); -} - -function stringifyScreenSize() { - return [ (window.screen && window.screen.width) || -1, (window.screen && window.screen.height) || -1 ].join('.'); -} - -function buildRequests(bidRequests) { - const IAS_HOST = 'https://pixel.adsafeprotected.com/services/pub'; - const anId = bidRequests[0].params.pubId; - - let queries = []; - queries.push(['anId', anId]); - queries = queries.concat(bidRequests.reduce(function(acc, request) { - acc.push(['slot', stringifySlot(request)]); - return acc; - }, [])); - - queries.push(['wr', stringifyWindowSize()]); - queries.push(['sr', stringifyScreenSize()]); - queries.push(['url', encodeURIComponent(window.location.href)]); - - const queryString = encodeURI(queries.map(qs => qs.join('=')).join('&')); - - bidRequests.forEach(function (request) { - if (bidRequests[0].bidId != request.bidId) { - otherBidIds.push(request.bidId); - } - }); - - return { - method: 'GET', - url: IAS_HOST, - data: queryString, - bidRequest: bidRequests[0] - }; -} - -function getPageLevelKeywords(response) { - let result = {}; - shallowMerge(result, response.brandSafety); - result.fr = response.fr; - result.custom = response.custom; - return result; -} - -function shallowMerge(dest, src) { - utils.getKeys(src).reduce((dest, srcKey) => { - dest[srcKey] = src[srcKey]; - return dest; - }, dest); -} - -function interpretResponse(serverResponse, request) { - const iasResponse = serverResponse.body; - const bidResponses = []; - - // Keys in common bid response are not used; - // Necessary to get around with prebid's common bid response check - const commonBidResponse = { - requestId: request.bidRequest.bidId, - cpm: 0.01, - width: 100, - height: 200, - creativeId: 434, - dealId: 42, - currency: 'USD', - netRevenue: true, - ttl: 360 - }; - - shallowMerge(commonBidResponse, getPageLevelKeywords(iasResponse)); - commonBidResponse.slots = iasResponse.slots; - bidResponses.push(commonBidResponse); - - otherBidIds.forEach(function (bidId) { - var otherResponse = Object.assign({}, commonBidResponse); - otherResponse.requestId = bidId; - bidResponses.push(otherResponse); - }); - - return bidResponses; -} - -export const spec = { - code: BIDDER_CODE, - aliases: [], - isBidRequestValid: isBidRequestValid, - buildRequests: buildRequests, - interpretResponse: interpretResponse -}; - -registerBidder(spec); diff --git a/modules/iasBidAdapter.md b/modules/iasBidAdapter.md deleted file mode 100644 index 3224fbf4a26..00000000000 --- a/modules/iasBidAdapter.md +++ /dev/null @@ -1,30 +0,0 @@ -# Overview - -``` -Module Name: Integral Ad Science(IAS) Bidder Adapter -Module Type: Bidder Adapter -Maintainer: kat@integralads.com -``` - -# Description - -This module is an integration with prebid.js with an IAS product, pet.js. It is not a bidder per se but works in a similar way: retrieve data that publishers might be interested in setting keyword targeting. - -# Test Parameters -``` - var adUnits = [ - { - code: 'ias-dfp-test-async', - sizes: [[300, 250]], // a display size - bids: [ - { - bidder: "ias", - params: { - pubId: '99', - adUnitPath: '/57514611/news.com' - } - } - ] - } - ]; -``` diff --git a/modules/imonomyBidAdapter.js b/modules/imonomyBidAdapter.js deleted file mode 100644 index b9205943f65..00000000000 --- a/modules/imonomyBidAdapter.js +++ /dev/null @@ -1,130 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'imonomy'; -const ENDPOINT = 'https://b.imonomy.com/openrtb/hb/00000'; -const USYNCURL = 'https://b.imonomy.com/UserMatching/b/'; - -export const spec = { - code: BIDDER_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.placementId && bid.params.hbid); - }, - /** - * 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: validBidRequests => { - const tags = validBidRequests.map(bid => { - // map each bid id to bid object to retrieve adUnit code in callback - let tag = { - uuid: bid.bidId, - sizes: bid.sizes, - trid: bid.transactionId, - hbid: bid.params.hbid, - placementid: bid.params.placementId - }; - - // add floor price if specified (not mandatory) - if (bid.params.floorPrice) { - tag.floorprice = bid.params.floorPrice; - } - - return tag; - }); - - // Imonomy server config - const time = new Date().getTime(); - const kbConf = { - ts_as: time, - hb_placements: [], - hb_placement_bidids: {}, - hb_floors: {}, - cb: _generateCb(time), - tz: new Date().getTimezoneOffset(), - }; - - validBidRequests.forEach(bid => { - kbConf.hdbdid = kbConf.hdbdid || bid.params.hbid; - kbConf.encode_bid = kbConf.encode_bid || bid.params.encode_bid; - kbConf.hb_placement_bidids[bid.params.placementId] = bid.bidId; - if (bid.params.floorPrice) { - kbConf.hb_floors[bid.params.placementId] = bid.params.floorPrice; - } - kbConf.hb_placements.push(bid.params.placementId); - }); - - let payload = {}; - if (!utils.isEmpty(tags)) { - payload = { bids: [...tags], kbConf }; - } - - let endpointToUse = ENDPOINT; - if (kbConf.hdbdid) { - endpointToUse = endpointToUse.replace('00000', kbConf.hdbdid); - } - - return { - method: 'POST', - url: endpointToUse, - data: JSON.stringify(payload) - }; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} response A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: (response) => { - const bidResponses = []; - if (response && response.body && response.body.bids) { - response.body.bids.forEach(bid => { - // The bid ID. Used to tie this bid back to the request. - if (bid.uuid) { - bid.requestId = bid.uuid; - } else { - utils.logError('No uuid for bid'); - } - // The creative payload of the returned bid. - if (bid.creative) { - bid.ad = bid.creative; - } else { - utils.logError('No creative for bid'); - } - bidResponses.push(bid); - }); - } - return bidResponses; - }, - /** - * Register User Sync. - */ - getUserSyncs: syncOptions => { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: USYNCURL - }]; - } - } -}; - -/** -* Generated cache baster value to be sent to bid server -* @param {*} time current time to use for creating cb. -*/ -function _generateCb(time) { - return Math.floor((time % 65536) + (Math.floor(Math.random() * 65536) * 65536)); -} - -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 5b8531d7a85..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: params.floorPrice, - 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/ixBidAdapter.js b/modules/ixBidAdapter.js index d326cbaf9b1..7512619019a 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -42,7 +42,6 @@ const PROVIDERS = [ 'merkleId', 'parrableId', 'connectid', - 'sharedid', 'tapadId', 'quantcastId', 'pubcid', 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/komoonaBidAdapter.js b/modules/komoonaBidAdapter.js deleted file mode 100644 index 6adc0eb1984..00000000000 --- a/modules/komoonaBidAdapter.js +++ /dev/null @@ -1,121 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'komoona'; -const ENDPOINT = 'https://bidder.komoona.com/v1/GetSBids'; -const USYNCURL = 'https://s.komoona.com/sync/usync.html'; - -export const spec = { - code: BIDDER_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.placementId && bid.params.hbid); - }, - /** - * 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 => { - const tags = validBidRequests.map(bid => { - // map each bid id to bid object to retrieve adUnit code in callback - let tag = { - uuid: bid.bidId, - sizes: bid.sizes, - trid: bid.transactionId, - hbid: bid.params.hbid, - placementid: bid.params.placementId - }; - - // add floor price if specified (not mandatory) - if (bid.params.floorPrice) { - tag.floorprice = bid.params.floorPrice; - } - - return tag; - }); - - // Komoona server config - const time = new Date().getTime(); - const kbConf = { - ts_as: time, - hb_placements: [], - hb_placement_bidids: {}, - hb_floors: {}, - cb: _generateCb(time), - tz: new Date().getTimezoneOffset(), - }; - - validBidRequests.forEach(bid => { - kbConf.hdbdid = kbConf.hdbdid || bid.params.hbid; - kbConf.encode_bid = kbConf.encode_bid || bid.params.encode_bid; - kbConf.hb_placement_bidids[bid.params.placementId] = bid.bidId; - if (bid.params.floorPrice) { - kbConf.hb_floors[bid.params.placementId] = bid.params.floorPrice; - } - kbConf.hb_placements.push(bid.params.placementId); - }); - - let payload = {}; - if (!utils.isEmpty(tags)) { - payload = { bids: [...tags], kbConf: kbConf }; - } - - return { - method: 'POST', - url: ENDPOINT, - data: JSON.stringify(payload) - }; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} response A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: (response, request) => { - const bidResponses = []; - try { - if (response.body && response.body.bids) { - response.body.bids.forEach(bid => { - // The bid ID. Used to tie this bid back to the request. - bid.requestId = bid.uuid; - // The creative payload of the returned bid. - bid.ad = bid.creative; - bidResponses.push(bid); - }); - } - } catch (error) { - utils.logError(error); - } - return bidResponses; - }, - /** - * Register User Sync. - */ - getUserSyncs: syncOptions => { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: USYNCURL - }]; - } - } -}; - -/** -* Generated cache baster value to be sent to bid server -* @param {*} time current time to use for creating cb. -*/ -function _generateCb(time) { - return Math.floor((time % 65536) + (Math.floor(Math.random() * 65536) * 65536)); -} - -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/kubientBidAdapter.js b/modules/kubientBidAdapter.js deleted file mode 100644 index 8f6ea53ecce..00000000000 --- a/modules/kubientBidAdapter.js +++ /dev/null @@ -1,111 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER} from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'kubient'; -const END_POINT = 'https://kssp.kbntx.ch/pbjs'; -const VERSION = '1.0'; -const VENDOR_ID = 794; -export const spec = { - code: BIDDER_CODE, - gvlid: VENDOR_ID, - supportedMediaTypes: [BANNER], - isBidRequestValid: function (bid) { - return !!(bid && bid.params); - }, - buildRequests: function (validBidRequests, bidderRequest) { - if (!validBidRequests || !bidderRequest) { - return; - } - const result = validBidRequests.map(function (bid) { - let data = { - v: VERSION, - requestId: bid.bidderRequestId, - adSlots: [{ - bidId: bid.bidId, - zoneId: bid.params.zoneid || '', - floor: bid.params.floor || 0.0, - sizes: bid.sizes || [], - schain: bid.schain || {}, - mediaTypes: bid.mediaTypes - }], - referer: (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : null, - tmax: bidderRequest.timeout, - gdpr: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0, - consent: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) ? bidderRequest.gdprConsent.consentString : null, - consentGiven: kubientGetConsentGiven(bidderRequest.gdprConsent), - uspConsent: bidderRequest.uspConsent - }; - return { - method: 'POST', - url: END_POINT, - data: JSON.stringify(data) - }; - }); - return result; - }, - interpretResponse: function interpretResponse(serverResponse, request) { - if (!serverResponse || !serverResponse.body || !serverResponse.body.seatbid) { - return []; - } - let bidResponses = []; - serverResponse.body.seatbid.forEach(seatbid => { - let bids = seatbid.bid || []; - bids.forEach(bid => { - bidResponses.push({ - requestId: bid.bidId, - cpm: bid.price, - currency: bid.cur, - width: bid.w, - height: bid.h, - creativeId: bid.creativeId, - netRevenue: bid.netRevenue, - ttl: bid.ttl, - ad: bid.adm - }); - }); - }); - return bidResponses; - }, - getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = []; - let gdprParams = ''; - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - gdprParams = `?consent_str=${gdprConsent.consentString}`; - if (typeof gdprConsent.gdprApplies === 'boolean') { - gdprParams = gdprParams + `&gdpr=${Number(gdprConsent.gdprApplies)}`; - } - gdprParams = gdprParams + `&consent_given=` + kubientGetConsentGiven(gdprConsent); - } - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: 'https://kdmp.kbntx.ch/init.html' + gdprParams - }); - } - if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: 'https://kdmp.kbntx.ch/init.png' + gdprParams - }); - } - return syncs; - } -}; - -function kubientGetConsentGiven(gdprConsent) { - let consentGiven = 0; - if (typeof gdprConsent !== 'undefined') { - let apiVersion = utils.deepAccess(gdprConsent, `apiVersion`); - switch (apiVersion) { - case 1: - consentGiven = utils.deepAccess(gdprConsent, `vendorData.vendorConsents.${VENDOR_ID}`) ? 1 : 0; - break; - case 2: - consentGiven = utils.deepAccess(gdprConsent, `vendorData.vendor.consents.${VENDOR_ID}`) ? 1 : 0; - break; - } - } - return consentGiven; -} -registerBidder(spec); diff --git a/modules/lemmaBidAdapter.js b/modules/lemmaBidAdapter.js deleted file mode 100644 index c7440743d2c..00000000000 --- a/modules/lemmaBidAdapter.js +++ /dev/null @@ -1,442 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -var BIDDER_CODE = 'lemma'; -var LOG_WARN_PREFIX = 'LEMMA: '; -var ENDPOINT = 'https://ads.lemmatechnologies.com/lemma/servad'; -var USER_SYNC = 'https://sync.lemmatechnologies.com/js/usersync.html?'; -var DEFAULT_CURRENCY = 'USD'; -var AUCTION_TYPE = 2; -var DEFAULT_TMAX = 300; -var DEFAULT_NET_REVENUE = false; -var pubId = 0; -var adunitId = 0; - -export var spec = { - - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid: bid => { - if (bid && bid.params) { - if (!utils.isNumber(bid.params.pubId)) { - utils.logWarn(LOG_WARN_PREFIX + 'Error: publisherId is mandatory and cannot be string. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); - return false; - } - if (!bid.params.adunitId) { - utils.logWarn(LOG_WARN_PREFIX + 'Error: adUnitId is mandatory. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); - return false; - } - // video ad validation - if (bid.params.hasOwnProperty('video')) { - if (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0) { - utils.logWarn(LOG_WARN_PREFIX + 'Error: For video ads, mimes is mandatory and must specify atlease 1 mime value. Call to OpenBid will not be sent for ad unit:' + JSON.stringify(bid)); - return false; - } - } - return true; - } - return false; - }, - buildRequests: (bidRequests, bidderRequest) => { - var refererInfo; - if (bidderRequest && bidderRequest.refererInfo) { - refererInfo = bidderRequest.refererInfo; - } - var conf = _initConf(refererInfo); - const request = oRTBTemplate(bidRequests, conf); - if (request.imp.length == 0) { - return; - } - setOtherParams(bidderRequest, request); - const endPoint = endPointURL(bidRequests); - return { - method: 'POST', - url: endPoint, - data: JSON.stringify(request), - }; - }, - interpretResponse: (response, request) => { - return parseRTBResponse(request, response.body); - }, - getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { - let syncurl = USER_SYNC + 'pid=' + pubId; - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: syncurl - }]; - } else { - utils.logWarn(LOG_WARN_PREFIX + 'Please enable iframe based user sync.'); - } - }, -}; - -function _initConf(refererInfo) { - var conf = {}; - conf.pageURL = (refererInfo && refererInfo.referer) ? refererInfo.referer : window.location.href; - if (refererInfo && refererInfo.referer) { - conf.refURL = refererInfo.referer; - } else { - conf.refURL = ''; - } - return conf; -} - -function _setFloor(impObj, bid) { - let bidFloor = -1; - // get lowest floor from floorModule - if (typeof bid.getFloor === 'function') { - [BANNER, VIDEO].forEach(mediaType => { - if (impObj.hasOwnProperty(mediaType)) { - let floorInfo = bid.getFloor({ currency: impObj.bidfloorcur, mediaType: mediaType, size: '*' }); - if (typeof floorInfo === 'object' && floorInfo.currency === impObj.bidfloorcur && !isNaN(parseInt(floorInfo.floor))) { - let mediaTypeFloor = parseFloat(floorInfo.floor); - bidFloor = (bidFloor == -1 ? mediaTypeFloor : Math.min(mediaTypeFloor, bidFloor)) - } - } - }); - } - // get highest from impObj.bidfllor and floor from floor module - // as we are using Math.max, it is ok if we have not got any floor from floorModule, then value of bidFloor will be -1 - if (impObj.bidfloor) { - bidFloor = Math.max(bidFloor, impObj.bidfloor) - } - - // assign value only if bidFloor is > 0 - impObj.bidfloor = ((!isNaN(bidFloor) && bidFloor > 0) ? bidFloor : undefined); -} - -function parseRTBResponse(request, response) { - var bidResponses = []; - try { - if (response.seatbid) { - var currency = response.curr || DEFAULT_CURRENCY; - var seatbid = response.seatbid; - seatbid.forEach(seatbidder => { - var bidder = seatbidder.bid; - bidder.forEach(bid => { - var req = parse(request.data); - var newBid = { - requestId: bid.impid, - cpm: parseFloat(bid.price).toFixed(2), - width: bid.w, - height: bid.h, - creativeId: bid.crid, - currency: currency, - netRevenue: DEFAULT_NET_REVENUE, - ttl: 300, - referrer: req.site.ref, - ad: bid.adm - }; - if (bid.dealid) { - newBid.dealId = bid.dealid; - } - if (req.imp && req.imp.length > 0) { - req.imp.forEach(robj => { - if (bid.impid === robj.id) { - _checkMediaType(bid.adm, newBid); - switch (newBid.mediaType) { - case BANNER: - break; - case VIDEO: - newBid.width = bid.hasOwnProperty('w') ? bid.w : robj.video.w; - newBid.height = bid.hasOwnProperty('h') ? bid.h : robj.video.h; - newBid.vastXml = bid.adm; - break; - } - } - }); - } - bidResponses.push(newBid); - }); - }); - } - } catch (error) { - utils.logError(LOG_WARN_PREFIX, 'ERROR ', error); - } - return bidResponses; -} - -function oRTBTemplate(bidRequests, conf) { - try { - var oRTBObject = { - id: '' + new Date().getTime(), - at: AUCTION_TYPE, - tmax: DEFAULT_TMAX, - cur: [DEFAULT_CURRENCY], - imp: _getImpressionArray(bidRequests), - user: {}, - ext: {} - }; - var bid = bidRequests[0]; - var app = _getAppObject(bid); - var site = _getSiteObject(bid, conf); - var device = _getDeviceObject(bid); - if (app) { - oRTBObject.app = app; - } - if (site) { - oRTBObject.site = site; - } - if (device) { - oRTBObject.device = device; - } - return oRTBObject; - } catch (ex) { - utils.logError(LOG_WARN_PREFIX, 'ERROR ', ex); - } -} - -function _getImpressionArray(request) { - var impArray = []; - var map = request.map(bid => _getImpressionObject(bid)); - if (map) { - map.forEach(o => { - if (o) { - impArray.push(o); - } - }); - } - return impArray; -} - -function endPointURL(request) { - var params = request && request[0].params ? request[0].params : null; - if (params) { - pubId = params.pubId ? params.pubId : 0; - adunitId = params.adunitId ? params.adunitId : 0; - return ENDPOINT + '?pid=' + pubId + '&aid=' + adunitId; - } - return null; -} - -function _getDomain(url) { - var a = document.createElement('a'); - a.setAttribute('href', url); - return a.hostname; -} - -function _getSiteObject(request, conf) { - var params = request && request.params ? request.params : null; - if (params) { - pubId = params.pubId ? params.pubId : '0'; - var siteId = params.siteId ? params.siteId : '0'; - var appParams = params.app; - if (!appParams) { - return { - publisher: { - id: pubId.toString() - }, - domain: _getDomain(conf.pageURL), - id: siteId.toString(), - ref: conf.refURL, - page: conf.pageURL - }; - } - } - return null; -} - -function _getAppObject(request) { - var params = request && request.params ? request.params : null; - if (params) { - pubId = params.pubId ? params.pubId : 0; - var appParams = params.app; - if (appParams) { - return { - publisher: { - id: pubId.toString(), - }, - id: appParams.id, - name: appParams.name, - bundle: appParams.bundle, - storeurl: appParams.storeUrl, - domain: appParams.domain, - cat: appParams.categories, - pagecat: appParams.page_category - }; - } - } - return null; -} - -function _getDeviceObject(request) { - var params = request && request.params ? request.params : null; - if (params) { - return { - dnt: utils.getDNT() ? 1 : 0, - ua: navigator.userAgent, - language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), - w: (window.screen.width || window.innerWidth), - h: (window.screen.height || window.innerHeigh), - geo: { - country: params.country, - lat: params.latitude, - lon: params.longitude, - region: params.region, - city: params.city, - zip: params.zip - }, - ip: params.ip, - devicetype: params.device_type, - ifa: params.ifa, - }; - } - return null; -} - -function setOtherParams(request, ortbRequest) { - var params = request && request.params ? request.params : null; - if (params) { - ortbRequest.tmax = params.tmax; - ortbRequest.bcat = params.bcat; - } -} - -function _getSizes(request) { - if (request.sizes && utils.isArray(request.sizes[0]) && request.sizes[0].length > 0) { - return request.sizes[0]; - } - return null; -} - -function _getBannerRequest(bid) { - var bObj; - var adFormat = []; - if (bid.mediaType === 'banner' || utils.deepAccess(bid, 'mediaTypes.banner')) { - var params = bid ? bid.params : null; - var bannerData = params.banner; - var sizes = _getSizes(bid) || []; - if (sizes && sizes.length == 0) { - sizes = bid.mediaTypes.banner.sizes[0]; - } - if (sizes && sizes.length > 0) { - bObj = {}; - bObj.w = sizes[0]; - bObj.h = sizes[1]; - bObj.pos = 0; - if (bannerData) { - bObj = utils.deepClone(bannerData); - } - sizes = bid.mediaTypes.banner.sizes; - if (sizes.length > 0) { - adFormat = []; - sizes.forEach(function(size) { - if (size.length > 1) { - adFormat.push({ w: size[0], h: size[1] }); - } - }); - if (adFormat.length > 0) { - bObj.format = adFormat; - } - } - } else { - utils.logWarn(LOG_WARN_PREFIX + 'Error: mediaTypes.banner.sizes missing for adunit: ' + bid.params.adunitId); - } - } - return bObj; -} - -function _getVideoRequest(bid) { - var vObj; - if (bid.mediaType === 'video' || utils.deepAccess(bid, 'mediaTypes.video')) { - var params = bid ? bid.params : null; - var sizes = _getSizes(bid) || []; - if (sizes && sizes.length == 0) { - sizes = bid.mediaTypes && bid.mediaTypes.video ? bid.mediaTypes.video.playerSize : []; - } - if (sizes && sizes.length > 0) { - var videoData = params.video; - vObj = {}; - if (videoData) { - vObj = utils.deepClone(videoData); - } - vObj.w = sizes[0]; - vObj.h = sizes[1]; - } else { - utils.logWarn(LOG_WARN_PREFIX + 'Error: mediaTypes.video.sizes missing for adunit: ' + bid.params.adunitId); - } - } - return vObj; -} - -function _getImpressionObject(bid) { - var impression = {}; - var bObj; - var vObj; - var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : []; - var mediaTypes = ''; - var format = []; - var params = bid && bid.params ? bid.params : null; - impression = { - id: bid.bidId, - tagid: params.adunitId ? params.adunitId.toString() : undefined, - secure: window.location.protocol === 'https:' ? 1 : 0, - bidfloorcur: params.currency ? params.currency : DEFAULT_CURRENCY - }; - if (params.bidFloor) { - impression.bidfloor = params.bidFloor; - } - if (bid.hasOwnProperty('mediaTypes')) { - for (mediaTypes in bid.mediaTypes) { - switch (mediaTypes) { - case BANNER: - bObj = _getBannerRequest(bid); - if (bObj) { - impression.banner = bObj; - } - break; - case VIDEO: - vObj = _getVideoRequest(bid); - if (vObj) { - impression.video = vObj; - } - break; - } - } - } else { - bObj = { - pos: 0, - w: sizes && sizes[0] ? sizes[0][0] : 0, - h: sizes && sizes[0] ? sizes[0][1] : 0, - }; - if (utils.isArray(sizes) && sizes.length > 1) { - sizes = sizes.splice(1, sizes.length - 1); - sizes.forEach(size => { - format.push({ - w: size[0], - h: size[1] - }); - }); - bObj.format = format; - } - impression.banner = bObj; - } - _setFloor(impression, bid); - return impression.hasOwnProperty(BANNER) || - impression.hasOwnProperty(VIDEO) ? impression : undefined; -} - -function parse(rawResp) { - try { - if (rawResp) { - return JSON.parse(rawResp); - } - } catch (ex) { - utils.logError(LOG_WARN_PREFIX, 'ERROR', ex); - } - return null; -} - -function _checkMediaType(adm, newBid) { - // Create a regex here to check the strings - var videoRegex = new RegExp(/VAST.*version/); - if (videoRegex.test(adm)) { - newBid.mediaType = VIDEO; - } else { - newBid.mediaType = BANNER; - } -} -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/lunamediaBidAdapter.js b/modules/lunamediaBidAdapter.js deleted file mode 100755 index b309ef42240..00000000000 --- a/modules/lunamediaBidAdapter.js +++ /dev/null @@ -1,399 +0,0 @@ -import * as utils from '../src/utils.js'; -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; -import find from 'core-js-pure/features/array/find.js'; -import includes from 'core-js-pure/features/array/includes.js'; - -const ADAPTER_VERSION = '1.0'; -const BIDDER_CODE = 'lunamedia'; - -export const VIDEO_ENDPOINT = 'https://nep.advangelists.com/xp/get?pubid=';// https://api.lunamedia.io/xp/get?pubid=0cf8d6d643e13d86a5b6374148a4afac'; -export const BANNER_ENDPOINT = 'https://nep.advangelists.com/xp/get?pubid=';// 0cf8d6d643e13d86a5b6374148a4afac'; -export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js'; -export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'skip']; -export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; - -let pubid = ''; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid(bidRequest) { - if (typeof bidRequest != 'undefined') { - if (bidRequest.bidder !== BIDDER_CODE && typeof bidRequest.params === 'undefined') { return false; } - if (bidRequest === '' || bidRequest.params.placement === '' || bidRequest.params.pubid === '') { return false; } - return true; - } else { return false; } - }, - - buildRequests(bids, bidderRequest) { - let requests = []; - let videoBids = bids.filter(bid => isVideoBidValid(bid)); - let bannerBids = bids.filter(bid => isBannerBidValid(bid)); - videoBids.forEach(bid => { - pubid = getVideoBidParam(bid, 'pubid'); - requests.push({ - method: 'POST', - url: VIDEO_ENDPOINT + pubid, - data: createVideoRequestData(bid, bidderRequest), - bidRequest: bid - }); - }); - - bannerBids.forEach(bid => { - pubid = getBannerBidParam(bid, 'pubid'); - - requests.push({ - method: 'POST', - url: BANNER_ENDPOINT + pubid, - data: createBannerRequestData(bid, bidderRequest), - bidRequest: bid - }); - }); - return requests; - }, - - interpretResponse(serverResponse, {bidRequest}) { - let response = serverResponse.body; - if (response !== null && utils.isEmpty(response) == false) { - if (isVideoBid(bidRequest)) { - let bidResponse = { - requestId: response.id, - bidderCode: BIDDER_CODE, - cpm: response.seatbid[0].bid[0].price, - width: response.seatbid[0].bid[0].w, - height: response.seatbid[0].bid[0].h, - ttl: response.seatbid[0].bid[0].ttl || 60, - creativeId: response.seatbid[0].bid[0].crid, - currency: response.cur, - mediaType: VIDEO, - netRevenue: true - } - - if (response.seatbid[0].bid[0].adm) { - bidResponse.vastXml = response.seatbid[0].bid[0].adm; - bidResponse.adResponse = { - content: response.seatbid[0].bid[0].adm - }; - } else { - bidResponse.vastUrl = response.seatbid[0].bid[0].nurl; - } - - return bidResponse; - } else { - return { - requestId: response.id, - bidderCode: BIDDER_CODE, - cpm: response.seatbid[0].bid[0].price, - width: response.seatbid[0].bid[0].w, - height: response.seatbid[0].bid[0].h, - ad: response.seatbid[0].bid[0].adm, - ttl: response.seatbid[0].bid[0].ttl || 60, - creativeId: response.seatbid[0].bid[0].crid, - currency: response.cur, - mediaType: BANNER, - netRevenue: true - } - } - } - } -}; - -function isBannerBid(bid) { - return utils.deepAccess(bid, 'mediaTypes.banner') || !isVideoBid(bid); -} - -function isVideoBid(bid) { - return utils.deepAccess(bid, 'mediaTypes.video'); -} - -function isVideoBidValid(bid) { - return isVideoBid(bid) && getVideoBidParam(bid, 'pubid') && getVideoBidParam(bid, 'placement'); -} - -function isBannerBidValid(bid) { - return isBannerBid(bid) && getBannerBidParam(bid, 'pubid') && getBannerBidParam(bid, 'placement'); -} - -function getVideoBidParam(bid, key) { - return utils.deepAccess(bid, 'params.video.' + key) || utils.deepAccess(bid, 'params.' + key); -} - -function getBannerBidParam(bid, key) { - return utils.deepAccess(bid, 'params.banner.' + key) || utils.deepAccess(bid, 'params.' + key); -} - -function isMobile() { - return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); -} - -function isConnectedTV() { - return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); -} - -function getDoNotTrack() { - return navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNoTrack === '1' || navigator.doNotTrack === 'yes'; -} - -function findAndFillParam(o, key, value) { - try { - if (typeof value === 'function') { - o[key] = value(); - } else { - o[key] = value; - } - } catch (ex) {} -} - -function getOsVersion() { - let clientStrings = [ - { s: 'Android', r: /Android/ }, - { s: 'iOS', r: /(iPhone|iPad|iPod)/ }, - { s: 'Mac OS X', r: /Mac OS X/ }, - { s: 'Mac OS', r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ }, - { s: 'Linux', r: /(Linux|X11)/ }, - { s: 'Windows 10', r: /(Windows 10.0|Windows NT 10.0)/ }, - { s: 'Windows 8.1', r: /(Windows 8.1|Windows NT 6.3)/ }, - { s: 'Windows 8', r: /(Windows 8|Windows NT 6.2)/ }, - { s: 'Windows 7', r: /(Windows 7|Windows NT 6.1)/ }, - { s: 'Windows Vista', r: /Windows NT 6.0/ }, - { s: 'Windows Server 2003', r: /Windows NT 5.2/ }, - { s: 'Windows XP', r: /(Windows NT 5.1|Windows XP)/ }, - { s: 'UNIX', r: /UNIX/ }, - { s: 'Search Bot', r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/ } - ]; - let cs = find(clientStrings, cs => cs.r.test(navigator.userAgent)); - return cs ? cs.s : 'unknown'; -} - -function getFirstSize(sizes) { - return (sizes && sizes.length) ? sizes[0] : { w: undefined, h: undefined }; -} - -function parseSizes(sizes) { - return utils.parseSizesInput(sizes).map(size => { - let [ width, height ] = size.split('x'); - return { - w: parseInt(width, 10) || undefined, - h: parseInt(height, 10) || undefined - }; - }); -} - -function getVideoSizes(bid) { - return parseSizes(utils.deepAccess(bid, 'mediaTypes.video.playerSize') || bid.sizes); -} - -function getBannerSizes(bid) { - return parseSizes(utils.deepAccess(bid, 'mediaTypes.banner.sizes') || bid.sizes); -} - -function getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } -} - -function getVideoTargetingParams(bid) { - return Object.keys(Object(bid.params.video)) - .filter(param => includes(VIDEO_TARGETING, param)) - .reduce((obj, param) => { - obj[ param ] = bid.params.video[ param ]; - return obj; - }, {}); -} - -function createVideoRequestData(bid, bidderRequest) { - let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); - - // if size is explicitly given via adapter params - let paramSize = getVideoBidParam(bid, 'size'); - let sizes = []; - - if (typeof paramSize !== 'undefined' && paramSize != '') { - sizes = parseSizes(paramSize); - } else { - sizes = getVideoSizes(bid); - } - const firstSize = getFirstSize(sizes); - - let video = getVideoTargetingParams(bid); - const o = { - 'device': { - 'langauge': (global.navigator.language).split('-')[0], - 'dnt': (global.navigator.doNotTrack === 1 ? 1 : 0), - 'devicetype': isMobile() ? 4 : isConnectedTV() ? 3 : 2, - 'js': 1, - 'os': getOsVersion() - }, - 'at': 2, - 'site': {}, - 'tmax': 3000, - 'cur': ['USD'], - 'id': bid.bidId, - 'imp': [], - 'regs': { - 'ext': { - } - }, - 'user': { - 'ext': { - } - } - }; - - o.site['page'] = topLocation.href; - o.site['domain'] = topLocation.hostname; - o.site['search'] = topLocation.search; - o.site['domain'] = topLocation.hostname; - o.site['ref'] = topReferrer; - o.site['mobile'] = isMobile() ? 1 : 0; - const secure = topLocation.protocol.indexOf('https') === 0 ? 1 : 0; - - o.device['dnt'] = getDoNotTrack() ? 1 : 0; - - findAndFillParam(o.site, 'name', function() { - return global.top.document.title; - }); - - findAndFillParam(o.device, 'h', function() { - return global.screen.height; - }); - findAndFillParam(o.device, 'w', function() { - return global.screen.width; - }); - - let placement = getVideoBidParam(bid, 'placement'); - let floor = getVideoBidParam(bid, 'floor'); - if (floor == null) { floor = 0.5; } - - for (let j = 0; j < sizes.length; j++) { - o.imp.push({ - 'id': '' + j, - 'displaymanager': '' + BIDDER_CODE, - 'displaymanagerver': '' + ADAPTER_VERSION, - 'tagId': placement, - 'bidfloor': floor, - 'bidfloorcur': 'USD', - 'secure': secure, - 'video': Object.assign({ - 'id': utils.generateUUID(), - 'pos': 0, - 'w': firstSize.w, - 'h': firstSize.h, - 'mimes': DEFAULT_MIMES - }, video) - - }); - } - - if (bidderRequest && bidderRequest.gdprConsent) { - let { gdprApplies, consentString } = bidderRequest.gdprConsent; - o.regs.ext = {'gdpr': gdprApplies ? 1 : 0}; - o.user.ext = {'consent': consentString}; - } - - return o; -} - -function getTopWindowLocation(bidderRequest) { - let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return utils.parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); -} - -function createBannerRequestData(bid, bidderRequest) { - let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); - - // if size is explicitly given via adapter params - - let paramSize = getBannerBidParam(bid, 'size'); - let sizes = []; - if (typeof paramSize !== 'undefined' && paramSize != '') { - sizes = parseSizes(paramSize); - } else { - sizes = getBannerSizes(bid); - } - - const o = { - 'device': { - 'langauge': (global.navigator.language).split('-')[0], - 'dnt': (global.navigator.doNotTrack === 1 ? 1 : 0), - 'devicetype': isMobile() ? 4 : isConnectedTV() ? 3 : 2, - 'js': 1 - }, - 'at': 2, - 'site': {}, - 'tmax': 3000, - 'cur': ['USD'], - 'id': bid.bidId, - 'imp': [], - 'regs': { - 'ext': { - } - }, - 'user': { - 'ext': { - } - } - }; - - o.site['page'] = topLocation.href; - o.site['domain'] = topLocation.hostname; - o.site['search'] = topLocation.search; - o.site['domain'] = topLocation.hostname; - o.site['ref'] = topReferrer; - o.site['mobile'] = isMobile() ? 1 : 0; - const secure = topLocation.protocol.indexOf('https') === 0 ? 1 : 0; - - o.device['dnt'] = getDoNotTrack() ? 1 : 0; - - findAndFillParam(o.site, 'name', function() { - return global.top.document.title; - }); - - findAndFillParam(o.device, 'h', function() { - return global.screen.height; - }); - findAndFillParam(o.device, 'w', function() { - return global.screen.width; - }); - - let placement = getBannerBidParam(bid, 'placement'); - for (let j = 0; j < sizes.length; j++) { - let size = sizes[j]; - - let floor = getBannerBidParam(bid, 'floor'); - if (floor == null) { floor = 0.1; } - - o.imp.push({ - 'id': '' + j, - 'displaymanager': '' + BIDDER_CODE, - 'displaymanagerver': '' + ADAPTER_VERSION, - 'tagId': placement, - 'bidfloor': floor, - 'bidfloorcur': 'USD', - 'secure': secure, - 'banner': { - 'id': utils.generateUUID(), - 'pos': 0, - 'w': size['w'], - 'h': size['h'] - } - }); - } - - if (bidderRequest && bidderRequest.gdprConsent) { - let { gdprApplies, consentString } = bidderRequest.gdprConsent; - o.regs.ext = {'gdpr': gdprApplies ? 1 : 0}; - o.user.ext = {'consent': consentString}; - } - - return o; -} -registerBidder(spec); diff --git a/modules/luponmediaBidAdapter.js b/modules/luponmediaBidAdapter.js deleted file mode 100644 index 29b54f77fbb..00000000000 --- a/modules/luponmediaBidAdapter.js +++ /dev/null @@ -1,389 +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'; - -const DIGITRUST_PROP_NAMES = { - PREBID_SERVER: { - id: 'id', - keyv: 'keyv' - } -}; - -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: { - } - } - - const bidFloor = parseFloat(utils.deepAccess(bidRequest, 'params.floor')); - if (!isNaN(bidFloor)) { - data.imp[0].bidfloor = bidFloor; - } - appendSiteAppDevice(data, bidRequest, bidderRequest); - - const digiTrust = _getDigiTrustQueryParams(bidRequest, 'PREBID_SERVER'); - if (digiTrust) { - utils.deepSetValue(data, 'user.ext.digitrust', digiTrust); - } - - 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 _getDigiTrustQueryParams(bidRequest = {}, endpointName) { - if (!endpointName || !DIGITRUST_PROP_NAMES[endpointName]) { - return null; - } - const propNames = DIGITRUST_PROP_NAMES[endpointName]; - - function getDigiTrustId() { - const bidRequestDigitrust = utils.deepAccess(bidRequest, 'userId.digitrustid.data'); - if (bidRequestDigitrust) { - return bidRequestDigitrust; - } - - let digiTrustUser = (window.DigiTrust && (config.getConfig('digiTrustId') || window.DigiTrust.getUser({member: 'T9QSFKPDN9'}))); - return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || null; - } - - let digiTrustId = getDigiTrustId(); - // Verify there is an ID and this user has not opted out - if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) { - return null; - } - - const digiTrustQueryParams = { - [propNames.id]: digiTrustId.id, - [propNames.keyv]: digiTrustId.keyv - }; - if (propNames.pref) { - digiTrustQueryParams[propNames.pref] = 0; - } - return digiTrustQueryParams; -} - -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 d0cafbfd6b8..00000000000 --- a/modules/madvertiseBidAdapter.js +++ /dev/null @@ -1,96 +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; - } - if (typeof bid.params.floor == 'undefined' || parseFloat(bid.params.floor) < 0.01) { - 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/mediaforceBidAdapter.js b/modules/mediaforceBidAdapter.js index bd7e7f74f1a..4c303ea9b37 100644 --- a/modules/mediaforceBidAdapter.js +++ b/modules/mediaforceBidAdapter.js @@ -123,7 +123,7 @@ export const spec = { validBidRequests.forEach(bid => { isTest = isTest || bid.params.is_test; let tagid = bid.params.placement_id; - let bidfloor = bid.params.bidfloor ? parseFloat(bid.params.bidfloor) : 0; + let bidfloor = 0; let validImp = false; let impObj = { id: bid.bidId, 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/mgidBidAdapter.js b/modules/mgidBidAdapter.js deleted file mode 100644 index 957b9a1d703..00000000000 --- a/modules/mgidBidAdapter.js +++ /dev/null @@ -1,576 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; -import {BANNER, NATIVE} from '../src/mediaTypes.js'; -import {config} from '../src/config.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const storage = getStorageManager(); -const DEFAULT_CUR = 'USD'; -const BIDDER_CODE = 'mgid'; -const ENDPOINT_URL = 'https://prebid.mgid.com/prebid/'; -const LOG_WARN_PREFIX = '[MGID warn]: '; -const LOG_INFO_PREFIX = '[MGID info]: '; -const NATIVE_ASSETS = { - 'TITLE': { ID: 1, KEY: 'title', TYPE: 0 }, - 'IMAGE': { ID: 2, KEY: 'image', TYPE: 0 }, - 'ICON': { ID: 3, KEY: 'icon', TYPE: 0 }, - 'SPONSOREDBY': { ID: 4, KEY: 'sponsoredBy', TYPE: 1 }, // please note that type of SPONSORED is also 1 - 'DESC': { ID: 5, KEY: 'data', TYPE: 2 }, // please note that type of BODY is also set to 2 - 'PRICE': { ID: 6, KEY: 'price', TYPE: 6 }, - 'SALEPRICE': { ID: 7, KEY: 'saleprice', TYPE: 7 }, - 'DISPLAYURL': { ID: 8, KEY: 'displayurl', TYPE: 11 }, - 'CTA': { ID: 9, KEY: 'cta', TYPE: 12 }, - 'BODY': { ID: 10, KEY: 'body', TYPE: 2 }, // please note that type of DESC is also set to 2 - 'SPONSORED': { ID: 11, KEY: 'sponsored', TYPE: 1 }, // please note that type of SPONSOREDBY is also set to 1 -}; -const NATIVE_ASSET_IMAGE_TYPE = { - 'ICON': 1, - 'IMAGE': 3 -}; -const DEFAULT_IMAGE_WIDTH = 492; -const DEFAULT_IMAGE_HEIGHT = 328; -const DEFAULT_ICON_WIDTH = 50; -const DEFAULT_ICON_HEIGHT = 50; -const DEFAULT_TITLE_LENGTH = 80; - -let isInvalidNativeRequest = false; - -// check if title, image can be added with mandatory field default values -const NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS = [ - { - id: NATIVE_ASSETS.SPONSOREDBY.ID, - required: true, - data: { - type: 1 - } - }, - { - id: NATIVE_ASSETS.TITLE.ID, - required: true, - }, - { - id: NATIVE_ASSETS.IMAGE.ID, - required: true, - } -]; -let _NATIVE_ASSET_ID_TO_KEY_MAP = {}; -let _NATIVE_ASSET_KEY_TO_ASSET_MAP = {}; - -// loading _NATIVE_ASSET_ID_TO_KEY_MAP -utils._each(NATIVE_ASSETS, anAsset => { _NATIVE_ASSET_ID_TO_KEY_MAP[anAsset.ID] = anAsset.KEY }); -// loading _NATIVE_ASSET_KEY_TO_ASSET_MAP -utils._each(NATIVE_ASSETS, anAsset => { _NATIVE_ASSET_KEY_TO_ASSET_MAP[anAsset.KEY] = anAsset }); - -export const spec = { - VERSION: '1.4', - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, NATIVE], - reId: /^[1-9][0-9]*$/, - NATIVE_ASSET_ID_TO_KEY_MAP: _NATIVE_ASSET_ID_TO_KEY_MAP, - NATIVE_ASSET_KEY_TO_ASSET_MAP: _NATIVE_ASSET_KEY_TO_ASSET_MAP, - /** - * 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) => { - const banner = utils.deepAccess(bid, 'mediaTypes.banner'); - const native = utils.deepAccess(bid, 'mediaTypes.native'); - let nativeOk = utils.isPlainObject(native); - if (nativeOk) { - const nativeParams = utils.deepAccess(bid, 'nativeParams'); - let assetsCount = 0; - if (utils.isPlainObject(nativeParams)) { - for (let k in nativeParams) { - let v = nativeParams[k]; - const supportProp = spec.NATIVE_ASSET_KEY_TO_ASSET_MAP.hasOwnProperty(k); - if (supportProp) { - assetsCount++ - } - if (!utils.isPlainObject(v) || (!supportProp && utils.deepAccess(v, 'required'))) { - nativeOk = false; - break; - } - } - } - nativeOk = nativeOk && (assetsCount > 0); - } - let bannerOk = utils.isPlainObject(banner); - if (bannerOk) { - const sizes = utils.deepAccess(banner, 'sizes'); - bannerOk = utils.isArray(sizes) && sizes.length > 0; - for (let f = 0; bannerOk && f < sizes.length; f++) { - bannerOk = sizes[f].length === 2; - } - } - let acc = Number(bid.params.accountId); - let plcmt = Number(bid.params.placementId); - return (bannerOk || nativeOk) && utils.isPlainObject(bid.params) && !!bid.adUnitCode && utils.isStr(bid.adUnitCode) && (plcmt > 0 ? bid.params.placementId.toString().search(spec.reId) === 0 : true) && - !!acc && acc > 0 && bid.params.accountId.toString().search(spec.reId) === 0; - }, - /** - * 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) => { - utils.logInfo(LOG_INFO_PREFIX + `buildRequests`); - if (validBidRequests.length === 0) { - return; - } - const info = pageInfo(); - const page = info.location || utils.deepAccess(bidderRequest, 'refererInfo.referer') || utils.deepAccess(bidderRequest, 'refererInfo.canonicalUrl'); - const hostname = utils.parseUrl(page).hostname; - let domain = extractDomainFromHost(hostname) || hostname; - const accountId = setOnAny(validBidRequests, 'params.accountId'); - const muid = getLocalStorageSafely('mgMuidn'); - let url = (setOnAny(validBidRequests, 'params.bidUrl') || ENDPOINT_URL) + accountId; - if (utils.isStr(muid) && muid.length > 0) { - url += '?muid=' + muid; - } - const cur = [setOnAny(validBidRequests, 'params.currency') || setOnAny(validBidRequests, 'params.cur') || config.getConfig('currency.adServerCurrency') || DEFAULT_CUR]; - const secure = window.location.protocol === 'https:' ? 1 : 0; - let imp = []; - validBidRequests.forEach(bid => { - let tagid = utils.deepAccess(bid, 'params.placementId') || 0; - tagid = !tagid ? bid.adUnitCode : tagid + '/' + bid.adUnitCode; - let impObj = { - id: bid.bidId, - tagid, - secure, - }; - const bidFloor = utils.deepAccess(bid, 'params.bidFloor') || utils.deepAccess(bid, 'params.bidfloor') || 0; - if (bidFloor && utils.isNumber(bidFloor)) { - impObj.bidfloor = bidFloor; - } - for (let mediaTypes in bid.mediaTypes) { - switch (mediaTypes) { - case BANNER: - impObj.banner = createBannerRequest(bid); - imp.push(impObj); - break; - case NATIVE: - const native = createNativeRequest(bid.nativeParams); - if (!isInvalidNativeRequest) { - impObj.native = { - 'request': native - }; - imp.push(impObj); - } - break; - } - } - }); - - if (imp.length === 0) { - return; - } - - let request = { - id: utils.deepAccess(bidderRequest, 'bidderRequestId'), - site: {domain, page}, - cur: cur, - geo: {utcoffset: info.timeOffset}, - device: { - ua: navigator.userAgent, - js: 1, - dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, - h: screen.height, - w: screen.width, - language: getLanguage() - }, - ext: {mgid_ver: spec.VERSION, prebid_ver: $$PREBID_GLOBAL$$.version}, - imp - }; - if (bidderRequest && bidderRequest.gdprConsent) { - request.user = {ext: {consent: bidderRequest.gdprConsent.consentString}}; - request.regs = {ext: {gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0)}} - } - if (info.referrer) { - request.site.ref = info.referrer - } - utils.logInfo(LOG_INFO_PREFIX + `buildRequest:`, request); - return { - method: 'POST', - url: url, - 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: (serverResponse, bidRequests) => { - utils.logInfo(LOG_INFO_PREFIX + `interpretResponse`, serverResponse); - if (serverResponse == null || serverResponse.body == null || serverResponse.body === '' || !utils.isArray(serverResponse.body.seatbid) || !serverResponse.body.seatbid.length) { - return; - } - const returnedBids = []; - const muidn = utils.deepAccess(serverResponse.body, 'ext.muidn') - if (utils.isStr(muidn) && muidn.length > 0) { - setLocalStorageSafely('mgMuidn', muidn) - } - serverResponse.body.seatbid.forEach((bids) => { - bids.bid.forEach((bid) => { - const pbid = prebidBid(bid, serverResponse.body.cur); - if (pbid.mediaType === NATIVE && utils.isEmpty(pbid.native)) { - return; - } - returnedBids.push(pbid); - }) - }); - - utils.logInfo(LOG_INFO_PREFIX + `interpretedResponse`, returnedBids); - return returnedBids; - }, - onBidWon: (bid) => { - const cpm = utils.deepAccess(bid, 'adserverTargeting.hb_pb') || ''; - if (utils.isStr(bid.nurl) && bid.nurl !== '') { - bid.nurl = bid.nurl.replace( - /\${AUCTION_PRICE}/, - cpm - ); - utils.triggerPixel(bid.nurl); - } - if (bid.isBurl) { - if (bid.mediaType === BANNER) { - bid.ad = bid.ad.replace( - /\${AUCTION_PRICE}/, - cpm - ) - } else { - bid.burl = bid.burl.replace( - /\${AUCTION_PRICE}/, - cpm - ); - utils.triggerPixel(bid.burl); - } - } - utils.logInfo(LOG_INFO_PREFIX + `onBidWon`); - }, - getUserSyncs: (syncOptions, serverResponses) => { - utils.logInfo(LOG_INFO_PREFIX + `getUserSyncs`); - } -}; - -registerBidder(spec); - -function setOnAny(collection, key) { - for (let i = 0, result; i < collection.length; i++) { - result = utils.deepAccess(collection[i], key); - if (result) { - return result; - } - } -} - -/** - * Unpack the Server's Bid into a Prebid-compatible one. - * @param serverBid - * @return Bid - */ -function prebidBid(serverBid, cur) { - if (!utils.isStr(cur) || cur === '') { - cur = DEFAULT_CUR; - } - const bid = { - requestId: serverBid.impid, - ad: serverBid.adm, - cpm: serverBid.price, - creativeId: serverBid.adid, - currency: cur, - dealId: serverBid.dealid || '', - width: serverBid.w, - height: serverBid.h, - mediaType: 'banner', - netRevenue: true, - ttl: serverBid.ttl || 300, - nurl: serverBid.nurl || '', - burl: serverBid.burl || '', - isBurl: utils.isStr(serverBid.burl) && serverBid.burl.length > 0, - }; - setMediaType(serverBid, bid); - switch (bid.mediaType) { - case BANNER: - break; - case NATIVE: - parseNativeResponse(serverBid, bid); - break; - } - return bid; -} - -function setMediaType(bid, newBid) { - if (utils.deepAccess(bid, 'ext.crtype') === 'native') { - newBid.mediaType = NATIVE; - } else { - newBid.mediaType = BANNER; - } -} - -function extractDomainFromHost(pageHost) { - if (pageHost == 'localhost') { - return 'localhost' - } - let domain = null; - try { - let domains = /[-\w]+\.([-\w]+|[-\w]{3,}|[-\w]{1,3}\.[-\w]{2})$/i.exec(pageHost); - if (domains != null && domains.length > 0) { - domain = domains[0]; - for (let i = 1; i < domains.length; i++) { - if (domains[i].length > domain.length) { - domain = domains[i]; - } - } - } - } catch (e) { - domain = null; - } - return domain; -} - -function getLanguage() { - const language = navigator.language ? 'language' : 'userLanguage'; - const lang2 = navigator[language].split('-')[0]; - if (lang2.length === 2 || lang2.length === 3) { - return lang2; - } - return ''; -} - -function getLocalStorageSafely(key) { - try { - return storage.getDataFromLocalStorage(key); - } catch (e) { - return null; - } -} - -function setLocalStorageSafely(key, val) { - try { - return storage.setDataInLocalStorage(key, val); - } catch (e) { - return null; - } -} - -function createBannerRequest(bid) { - const sizes = utils.deepAccess(bid, 'mediaTypes.banner.sizes'); - let format = []; - if (sizes.length > 1) { - for (let f = 0; f < sizes.length; f++) { - if (sizes[f].length === 2) { - format.push({w: sizes[f][0], h: sizes[f][1]}); - } - } - } - let r = { - w: sizes && sizes[0][0], - h: sizes && sizes[0][1], - }; - if (format.length) { - r.format = format - } - return r -} - -function createNativeRequest(params) { - let nativeRequestObject = { - plcmtcnt: 1, - assets: [] - }; - for (let key in params) { - let assetObj = {}; - if (params.hasOwnProperty(key)) { - if (!(nativeRequestObject.assets && nativeRequestObject.assets.length > 0 && nativeRequestObject.assets.hasOwnProperty(key))) { - switch (key) { - case NATIVE_ASSETS.TITLE.KEY: - assetObj = { - id: NATIVE_ASSETS.TITLE.ID, - required: params[key].required ? 1 : 0, - title: { - len: params[key].len || params[key].length || DEFAULT_TITLE_LENGTH - } - }; - break; - case NATIVE_ASSETS.IMAGE.KEY: - const wmin = params[key].wmin || params[key].minimumWidth || (utils.isArray(params[key].minsizes) && params[key].minsizes.length > 0 ? params[key].minsizes[0] : 0); - const hmin = params[key].hmin || params[key].minimumHeight || (utils.isArray(params[key].minsizes) && params[key].minsizes.length > 1 ? params[key].minsizes[1] : 0); - assetObj = { - id: NATIVE_ASSETS.IMAGE.ID, - required: params[key].required ? 1 : 0, - img: { - type: NATIVE_ASSET_IMAGE_TYPE.IMAGE, - w: params[key].w || params[key].width || (utils.isArray(params[key].sizes) && params[key].sizes.length > 0 ? params[key].sizes[0] : 0), - h: params[key].h || params[key].height || (utils.isArray(params[key].sizes) && params[key].sizes.length > 1 ? params[key].sizes[1] : 0), - mimes: params[key].mimes, - ext: params[key].ext, - } - }; - if (wmin > 0) { - assetObj.img.wmin = wmin; - } - if (hmin > 0) { - assetObj.img.hmin = hmin; - } - if (!assetObj.img.w) { - assetObj.img.w = DEFAULT_IMAGE_WIDTH; - } - if (!assetObj.img.h) { - assetObj.img.h = DEFAULT_IMAGE_HEIGHT; - } - break; - case NATIVE_ASSETS.ICON.KEY: - assetObj = { - id: NATIVE_ASSETS.ICON.ID, - required: params[key].required ? 1 : 0, - img: { - type: NATIVE_ASSET_IMAGE_TYPE.ICON, - w: params[key].w || params[key].width || (utils.isArray(params[key].sizes) && params[key].sizes.length > 0 ? params[key].sizes[0] : 0), - h: params[key].h || params[key].height || (utils.isArray(params[key].sizes) && params[key].sizes.length > 0 ? params[key].sizes[1] : 0), - } - }; - if (!assetObj.img.w) { - assetObj.img.w = DEFAULT_ICON_WIDTH; - } - if (!assetObj.img.h) { - assetObj.img.h = DEFAULT_ICON_HEIGHT; - } - break; - case NATIVE_ASSETS.SPONSORED.KEY: - case NATIVE_ASSETS.SPONSOREDBY.KEY: - case NATIVE_ASSETS.PRICE.KEY: - case NATIVE_ASSETS.SALEPRICE.KEY: - case NATIVE_ASSETS.DESC.KEY: - case NATIVE_ASSETS.BODY.KEY: - case NATIVE_ASSETS.DISPLAYURL.KEY: - case NATIVE_ASSETS.CTA.KEY: - assetObj = commonNativeRequestObject(spec.NATIVE_ASSET_KEY_TO_ASSET_MAP[key], params); - break; - default: - if (params[key].required) { - isInvalidNativeRequest = true; - return; - } - } - } - } - if (assetObj.id) { - nativeRequestObject.assets[nativeRequestObject.assets.length] = assetObj; - } - } - - // for native image adtype prebid has to have few required assests i.e. title,sponsoredBy, image - // if any of these are missing from the request then request will not be sent - let requiredAssetCount = NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS.length; - let presentrequiredAssetCount = 0; - NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS.forEach(ele => { - let lengthOfExistingAssets = nativeRequestObject.assets.length; - for (let i = 0; i < lengthOfExistingAssets; i++) { - if (ele.id === nativeRequestObject.assets[i].id) { - presentrequiredAssetCount++; - break; - } else { - if (ele.id === 4 && nativeRequestObject.assets[i].id === 11) { - if (utils.deepAccess(nativeRequestObject.assets[i], 'data.type') === ele.data.type) { - presentrequiredAssetCount++; - break; - } - } - } - } - }); - isInvalidNativeRequest = requiredAssetCount !== presentrequiredAssetCount; - return nativeRequestObject; -} - -function commonNativeRequestObject(nativeAsset, params) { - const key = nativeAsset.KEY; - return { - id: nativeAsset.ID, - required: params[key].required ? 1 : 0, - data: { - type: nativeAsset.TYPE, - len: params[key].len, - ext: params[key].ext - } - }; -} - -function parseNativeResponse(bid, newBid) { - newBid.native = {}; - if (bid.hasOwnProperty('adm')) { - let adm = ''; - try { - adm = JSON.parse(bid.adm); - } catch (ex) { - utils.logWarn(LOG_WARN_PREFIX + 'Error: Cannot parse native response for ad response: ' + newBid.adm); - return; - } - if (adm && adm.native && adm.native.assets && adm.native.assets.length > 0) { - newBid.mediaType = NATIVE; - for (let i = 0, len = adm.native.assets.length; i < len; i++) { - switch (adm.native.assets[i].id) { - case NATIVE_ASSETS.TITLE.ID: - newBid.native.title = adm.native.assets[i].title && adm.native.assets[i].title.text; - break; - case NATIVE_ASSETS.IMAGE.ID: - newBid.native.image = { - url: adm.native.assets[i].img && adm.native.assets[i].img.url, - height: adm.native.assets[i].img && adm.native.assets[i].img.h, - width: adm.native.assets[i].img && adm.native.assets[i].img.w, - }; - break; - case NATIVE_ASSETS.ICON.ID: - newBid.native.icon = { - url: adm.native.assets[i].img && adm.native.assets[i].img.url, - height: adm.native.assets[i].img && adm.native.assets[i].img.h, - width: adm.native.assets[i].img && adm.native.assets[i].img.w, - }; - break; - case NATIVE_ASSETS.SPONSOREDBY.ID: - case NATIVE_ASSETS.SPONSORED.ID: - case NATIVE_ASSETS.PRICE: - case NATIVE_ASSETS.SALEPRICE.ID: - case NATIVE_ASSETS.DESC.ID: - case NATIVE_ASSETS.BODY.ID: - case NATIVE_ASSETS.DISPLAYURL.ID: - case NATIVE_ASSETS.CTA.ID: - newBid.native[spec.NATIVE_ASSET_ID_TO_KEY_MAP[adm.native.assets[i].id]] = adm.native.assets[i].data && adm.native.assets[i].data.value; - break; - } - } - newBid.native.clickUrl = adm.native.link && adm.native.link.url; - newBid.native.clickTrackers = (adm.native.link && adm.native.link.clicktrackers) || []; - newBid.native.impressionTrackers = adm.native.imptrackers || []; - newBid.native.jstracker = adm.native.jstracker || []; - newBid.width = 0; - newBid.height = 0; - } - } -} - -function pageInfo() { - var w, d, l, r, m, p, t; - for (w = window, d = w.document, l = d.location.href, r = d.referrer, m = 0, t = new Date(); w !== w.parent;) { - try { - p = w.parent; l = p.location.href; r = p.document.referrer; w = p; - } catch (e) { - m = top !== w.parent ? 2 : 1; - break - } - } - return { - location: l, - referrer: r || '', - masked: m, - wWidth: w.innerWidth, - wHeight: w.innerHeight, - date: t.toUTCString(), - timeOffset: t.getTimezoneOffset() - }; -} 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/mobfoxBidAdapter.js b/modules/mobfoxBidAdapter.js deleted file mode 100644 index 7c356e71089..00000000000 --- a/modules/mobfoxBidAdapter.js +++ /dev/null @@ -1,133 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const utils = require('../src/utils.js'); -const BIDDER_CODE = 'mobfox'; -const BID_REQUEST_BASE_URL = 'https://my.mobfox.com/request.php'; -const CPM_HEADER = 'X-Pricing-CPM'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['mf'], // short code - isBidRequestValid: function (bid) { - return bid.params.s !== null && bid.params.s !== undefined; - }, - buildRequests: function (validBidRequests) { - if (validBidRequests.length > 1) { - throw ('invalid number of valid bid requests, expected 1 element') - } - - let bidParams = validBidRequests[0].params; - let bid = validBidRequests[0]; - - let params = { - // -------------------- Mandatory Parameters ------------------ - rt: bidParams.rt || 'api-fetchip', - r_type: bidParams.r_type || 'banner', - r_resp: bidParams.r_resp || 'json', // string | vast20 - // i: bidParams.i || undefined , // string | 69.197.148.18 - s: bidParams.s, // string | 80187188f458cfde788d961b6882fd53 - u: bidParams.u || window.navigator.userAgent, // string - - // ------------------- Global Parameters ---------------------- - adspace_width: bidParams.adspace_width || bid.sizes[0][0], // integer | 320 - adspace_height: bidParams.adspace_height || bid.sizes[0][1], // integer | 48 - r_floor: bidParams.r_floor || undefined, // 0.8 - - o_andadvid: bidParams.o_andadvid || undefined, // 'c6292267-56ad-4326-965d-deef6fcd5er9' - longitude: bidParams.longitude || undefined, // 12.12 - latitude: bidParams.latitude || undefined, // 280.12 - demo_age: bidParams.demo_age || undefined, // 1978 - - // ------------------- banner / interstitial ---------------------- - adspace_strict: bidParams.adspace_strict || undefined, - - // ------------------- interstitial / video ---------------------- - imp_instl: bidParams.imp_instl || undefined, // integer | 1 - - // ------------------- mraid ---------------------- - c_mraid: bidParams.c_mraid || undefined, // integer | 1 - - // ------------------- video ---------------------- - v_dur_min: bidParams.v_dur_min || undefined, // integer | 0 - v_dur_max: bidParams.v_dur_max || undefined, // integer | 999 - v_autoplay: bidParams.v_autoplay || undefined, // integer | 1 - v_startmute: bidParams.v_startmute || undefined, // integer | 0 - v_rewarded: bidParams.v_rewarded || undefined, // integer | 0 - v_api: bidParams.v_api || undefined, // string | vpaid20 - n_ver: bidParams.n_ver || undefined, // - n_adunit: bidParams.n_adunit || undefined, // - n_layout: bidParams.n_layout || undefined, // - n_context: bidParams.n_context || undefined, // - n_plcmttype: bidParams.n_plcmttype || undefined, // - n_img_icon_req: bidParams.n_img_icon_req || undefined, // boolean0 - n_img_icon_size: bidParams.n_img_icon_size || undefined, // string80 - n_img_large_req: bidParams.n_img_large_req || undefined, // boolean0 - n_img_large_w: bidParams.n_img_large_w || undefined, // integer1200 - n_img_large_h: bidParams.n_img_large_h || undefined, // integer627 - n_title_req: bidParams.n_title_req || undefined, // boolean0 - n_title_len: bidParams.n_title_len || undefined, // string25 - n_desc_req: bidParams.n_desc_req || undefined, // boolean0 - n_desc_len: bidParams.n_desc_len || undefined, // string140 - n_rating_req: bidParams.n_rating_req || undefined - }; - - let payloadString = buildPayloadString(params); - - return { - method: 'GET', - url: BID_REQUEST_BASE_URL, - data: payloadString, - requestId: bid.bidId - }; - }, - interpretResponse: function (serverResponse, bidRequest) { - const bidResponses = []; - let serverResponseBody = serverResponse.body; - - if (!serverResponseBody || serverResponseBody.error) { - let errorMessage = `in response for ${BIDDER_CODE} adapter`; - if (serverResponseBody && serverResponseBody.error) { - errorMessage += `: ${serverResponseBody.error}`; - } - utils.logError(errorMessage); - return bidResponses; - } - try { - let serverResponseHeaders = serverResponse.headers; - let bidRequestData = bidRequest.data.split('&'); - const bidResponse = { - requestId: bidRequest.requestId, - cpm: serverResponseHeaders.get(CPM_HEADER), - width: bidRequestData[5].split('=')[1], - height: bidRequestData[6].split('=')[1], - creativeId: bidRequestData[3].split('=')[1], - currency: 'USD', - netRevenue: true, - ttl: 360, - referrer: serverResponseBody.request.clickurl, - ad: serverResponseBody.request.htmlString - }; - bidResponses.push(bidResponse); - } catch (e) { - throw 'could not build bid response: ' + e; - } - return bidResponses; - } -}; - -function buildPayloadString(params) { - for (let key in params) { - if (params.hasOwnProperty(key)) { - if (params[key] === undefined) { - delete params[key]; - } else { - params[key] = encodeURIComponent(params[key]); - } - } - } - - return utils._map(Object.keys(params), key => `${key}=${params[key]}`) - .join('&') -} - -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/mytargetBidAdapter.js b/modules/mytargetBidAdapter.js deleted file mode 100644 index bcf8e7ad17f..00000000000 --- a/modules/mytargetBidAdapter.js +++ /dev/null @@ -1,113 +0,0 @@ -import * as utils from '../src/utils.js'; -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'mytarget'; -const BIDDER_URL = 'https://ad.mail.ru/hbid_prebid/'; -const DEFAULT_CURRENCY = 'RUB'; -const DEFAULT_TTL = 180; - -function buildPlacement(bidRequest) { - let { bidId, params } = bidRequest; - let { placementId, position, response, bidfloor } = params; - let placement = { - placementId, - id: bidId, - position: position || 0, - response: response || 0 - }; - - if (typeof bidfloor !== 'undefined') { - placement.bidfloor = bidfloor; - } - - return placement; -} - -function getSiteName(referrer) { - let sitename = config.getConfig('mytarget.sitename'); - - if (!sitename) { - sitename = utils.parseUrl(referrer).hostname; - } - - return sitename; -} - -function getCurrency() { - let currency = config.getConfig('currency.adServerCurrency'); - - return (currency === 'USD') ? currency : DEFAULT_CURRENCY; -} - -function generateRandomId() { - return Math.random().toString(16).substring(2); -} - -export const spec = { - code: BIDDER_CODE, - - isBidRequestValid: function(bid) { - return !!bid.params.placementId; - }, - - buildRequests: function(validBidRequests, bidderRequest) { - let referrer = ''; - - if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; - } - - const payload = { - places: utils._map(validBidRequests, buildPlacement), - site: { - sitename: getSiteName(referrer), - page: referrer - }, - settings: { - currency: getCurrency(), - windowSize: { - width: window.screen.width, - height: window.screen.height - } - } - }; - - return { - method: 'POST', - url: BIDDER_URL, - data: payload, - }; - }, - - interpretResponse: function(serverResponse, bidRequest) { - let { body } = serverResponse; - - if (body.bids) { - return utils._map(body.bids, (bid) => { - let bidResponse = { - requestId: bid.id, - cpm: bid.price, - width: bid.size.width, - height: bid.size.height, - ttl: bid.ttl || DEFAULT_TTL, - currency: bid.currency || DEFAULT_CURRENCY, - creativeId: bid.creativeId || generateRandomId(), - netRevenue: true - } - - if (bid.adm) { - bidResponse.ad = bid.adm; - } else { - bidResponse.adUrl = bid.displayUrl; - } - - return bidResponse; - }); - } - - return []; - } -} - -registerBidder(spec); diff --git a/modules/nafdigitalBidAdapter.js b/modules/nafdigitalBidAdapter.js deleted file mode 100644 index d64e079b52a..00000000000 --- a/modules/nafdigitalBidAdapter.js +++ /dev/null @@ -1,245 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; - -const BIDDER_CODE = 'nafdigital'; -const URL = 'https://nafdigitalbidder.com/hb'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - isBidRequestValid, - buildRequests, - interpretResponse, - getUserSyncs -}; - -function buildRequests(bidReqs, bidderRequest) { - try { - let referrer = ''; - if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; - } - const nafdigitalImps = []; - const publisherId = utils.getBidIdParameter('publisherId', bidReqs[0].params); - utils._each(bidReqs, function (bid) { - bid.sizes = ((utils.isArray(bid.sizes) && utils.isArray(bid.sizes[0])) ? bid.sizes : [bid.sizes]); - bid.sizes = bid.sizes.filter(size => utils.isArray(size)); - const processedSizes = bid.sizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)})); - - const element = document.getElementById(bid.adUnitCode); - const minSize = _getMinSize(processedSizes); - const viewabilityAmount = _isViewabilityMeasurable(element) - ? _getViewability(element, utils.getWindowTop(), minSize) - : 'na'; - const viewabilityAmountRounded = isNaN(viewabilityAmount) ? viewabilityAmount : Math.round(viewabilityAmount); - - const imp = { - id: bid.bidId, - banner: { - format: processedSizes, - ext: { - viewability: viewabilityAmountRounded - } - }, - tagid: String(bid.adUnitCode) - }; - const bidFloor = utils.getBidIdParameter('bidFloor', bid.params); - if (bidFloor) { - imp.bidfloor = bidFloor; - } - nafdigitalImps.push(imp); - }); - const nafdigitalBidReq = { - id: utils.getUniqueIdentifierStr(), - imp: nafdigitalImps, - site: { - domain: utils.parseUrl(referrer).host, - page: referrer, - publisher: { - id: publisherId - } - }, - device: { - devicetype: _getDeviceType(), - w: screen.width, - h: screen.height - }, - tmax: config.getConfig('bidderTimeout') - }; - - return { - method: 'POST', - url: URL, - data: JSON.stringify(nafdigitalBidReq), - options: {contentType: 'text/plain', withCredentials: false} - }; - } catch (e) { - utils.logError(e, {bidReqs, bidderRequest}); - } -} - -function isBidRequestValid(bid) { - if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') { - return false; - } - - if (typeof bid.params.publisherId === 'undefined') { - return false; - } - - return true; -} - -function interpretResponse(serverResponse) { - if (!serverResponse.body || typeof serverResponse.body != 'object') { - utils.logWarn('NAF digital server returned empty/non-json response: ' + JSON.stringify(serverResponse.body)); - return []; - } - const { body: {id, seatbid} } = serverResponse; - try { - const nafdigitalBidResponses = []; - if (id && - seatbid && - seatbid.length > 0 && - seatbid[0].bid && - seatbid[0].bid.length > 0) { - seatbid[0].bid.map(nafdigitalBid => { - nafdigitalBidResponses.push({ - requestId: nafdigitalBid.impid, - cpm: parseFloat(nafdigitalBid.price), - width: parseInt(nafdigitalBid.w), - height: parseInt(nafdigitalBid.h), - creativeId: nafdigitalBid.crid || nafdigitalBid.id, - currency: 'USD', - netRevenue: true, - mediaType: BANNER, - ad: _getAdMarkup(nafdigitalBid), - ttl: 60 - }); - }); - } - return nafdigitalBidResponses; - } catch (e) { - utils.logError(e, {id, seatbid}); - } -} - -// Don't do user sync for now -function getUserSyncs(syncOptions, responses, gdprConsent) { - return []; -} - -function _isMobile() { - return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); -} - -function _isConnectedTV() { - return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); -} - -function _getDeviceType() { - return _isMobile() ? 1 : _isConnectedTV() ? 3 : 2; -} - -function _getAdMarkup(bid) { - let adm = bid.adm; - if ('nurl' in bid) { - adm += utils.createTrackPixelHtml(bid.nurl); - } - return adm; -} - -function _isViewabilityMeasurable(element) { - return !_isIframe() && element !== null; -} - -function _getViewability(element, topWin, { w, h } = {}) { - return utils.getWindowTop().document.visibilityState === 'visible' - ? _getPercentInView(element, topWin, { w, h }) - : 0; -} - -function _isIframe() { - try { - return utils.getWindowSelf() !== utils.getWindowTop(); - } catch (e) { - return true; - } -} - -function _getMinSize(sizes) { - return sizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min); -} - -function _getBoundingBox(element, { w, h } = {}) { - let { width, height, left, top, right, bottom } = element.getBoundingClientRect(); - - if ((width === 0 || height === 0) && w && h) { - width = w; - height = h; - right = left + w; - bottom = top + h; - } - - return { width, height, left, top, right, bottom }; -} - -function _getIntersectionOfRects(rects) { - const bbox = { - left: rects[0].left, - right: rects[0].right, - top: rects[0].top, - bottom: rects[0].bottom - }; - - for (let i = 1; i < rects.length; ++i) { - bbox.left = Math.max(bbox.left, rects[i].left); - bbox.right = Math.min(bbox.right, rects[i].right); - - if (bbox.left >= bbox.right) { - return null; - } - - bbox.top = Math.max(bbox.top, rects[i].top); - bbox.bottom = Math.min(bbox.bottom, rects[i].bottom); - - if (bbox.top >= bbox.bottom) { - return null; - } - } - - bbox.width = bbox.right - bbox.left; - bbox.height = bbox.bottom - bbox.top; - - return bbox; -} - -function _getPercentInView(element, topWin, { w, h } = {}) { - const elementBoundingBox = _getBoundingBox(element, { w, h }); - - // Obtain the intersection of the element and the viewport - const elementInViewBoundingBox = _getIntersectionOfRects([ { - left: 0, - top: 0, - right: topWin.innerWidth, - bottom: topWin.innerHeight - }, elementBoundingBox ]); - - let elementInViewArea, elementTotalArea; - - if (elementInViewBoundingBox !== null) { - // Some or all of the element is in view - elementInViewArea = elementInViewBoundingBox.width * elementInViewBoundingBox.height; - elementTotalArea = elementBoundingBox.width * elementBoundingBox.height; - - return ((elementInViewArea / elementTotalArea) * 100); - } - - // No overlap between element and the viewport; therefore, the element - // lies completely out of view - return 0; -} - -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/newborntownWebBidAdapter.js b/modules/newborntownWebBidAdapter.js deleted file mode 100644 index 56c63e2bb4d..00000000000 --- a/modules/newborntownWebBidAdapter.js +++ /dev/null @@ -1,159 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER, NATIVE} from '../src/mediaTypes.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const storage = getStorageManager(); -const BIDDER_CODE = 'newborntownWeb'; - -const REQUEST_URL = 'https://us-west.solortb.com/adx/api/rtb?from=4' - -function randomn(n) { - return parseInt((Math.random() + 1) * Math.pow(10, n - 1)) + ''; -} -function generateGUID() { - var d = new Date().getTime(); - var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = (d + Math.random() * 16) % 16 | 0; - d = Math.floor(d / 16); - return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); - }) - return guid; -} -function _isMobile() { - return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); -} -function _isConnectedTV() { - return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); -} -function _getDeviceType() { - return _isMobile() ? 1 : _isConnectedTV() ? 3 : 2; -} -var platform = (function getPlatform() { - var ua = navigator.userAgent; - if (ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1) { - return 'Android' - } - if (ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) { - return 'iOS' - } - return 'windows' -})(); -function getLanguage() { - const language = navigator.language ? 'language' : 'userLanguage'; - return navigator[language].split('-')[0]; -} -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, NATIVE], - isBidRequestValid: function(bid) { - return !!(bid.params.publisher_id && bid.params.slot_id && bid.params.bidfloor); - }, - - buildRequests: function(validBidRequests, bidderRequest) { - let requestArr = [] - if (validBidRequests.length === 0) { - return null; - } - var guid; - if (storage.getDataFromLocalStorage('sax_user_id') == null) { - storage.setDataInLocalStorage('sax_user_id', generateGUID()) - } - guid = storage.getDataFromLocalStorage('sax_user_id') - utils._each(validBidRequests, function(bidRequest) { - const bidRequestObj = bidRequest.params - var req = { - id: randomn(12) + randomn(12), - tmax: bidderRequest.timeout, - bidId: bidRequest.bidId, - user: { - id: guid - }, - imp: [ - { - id: '1', - bidfloor: bidRequestObj.bidfloor, - bidfloorcur: 'USD', - banner: { - w: 0, - h: 0 - } - } - ], - site: { - domain: window.location.host, - id: bidRequestObj.slot_id, - page: window.location.href, - publisher: { - id: bidRequestObj.publisher_id - }, - }, - device: { - ip: '', - ua: navigator.userAgent, - os: platform, - geo: { - country: '', - type: 0, - ipservice: 1, - region: '', - city: '', - }, - language: getLanguage(), - devicetype: _getDeviceType() - }, - ext: { - solomath: { - slotid: bidRequestObj.slot_id - } - } - }; - var sizes = bidRequest.sizes; - if (sizes) { - if (sizes && utils.isArray(sizes[0])) { - req.imp[0].banner.w = sizes[0][0]; - req.imp[0].banner.h = sizes[0][1]; - } else if (sizes && utils.isNumber(sizes[0])) { - req.imp[0].banner.w = sizes[0]; - req.imp[0].banner.h = sizes[1]; - } - } else { - return false; - } - const options = { - withCredentials: false - } - requestArr.push({ - method: 'POST', - url: REQUEST_URL, - data: req, - bidderRequest, - options: options - }) - }) - return requestArr; - }, - interpretResponse: function(serverResponse, request) { - var bidResponses = []; - if (serverResponse.body.seatbid && serverResponse.body.seatbid.length > 0 && serverResponse.body.seatbid[0].bid && serverResponse.body.seatbid[0].bid.length > 0 && serverResponse.body.seatbid[0].bid[0].adm) { - utils._each(serverResponse.body.seatbid[0].bid, function(bodyAds) { - var adstr = ''; - adstr = bodyAds.adm; - var bidResponse = { - requestId: request.data.bidId || 0, - cpm: bodyAds.price || 0, - width: bodyAds.w ? bodyAds.w : 0, - height: bodyAds.h ? bodyAds.h : 0, - ad: adstr, - netRevenue: true, - currency: serverResponse.body.cur || 'USD', - ttl: 600, - creativeId: bodyAds.cid - }; - bidResponses.push(bidResponse); - }); - } - return bidResponses; - } -} -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/nextrollBidAdapter.js b/modules/nextrollBidAdapter.js deleted file mode 100644 index cb317190bea..00000000000 --- a/modules/nextrollBidAdapter.js +++ /dev/null @@ -1,345 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE } from '../src/mediaTypes.js'; - -import find from 'core-js-pure/features/array/find.js'; - -const BIDDER_CODE = 'nextroll'; -const BIDDER_ENDPOINT = 'https://d.adroll.com/bid/prebid/'; -const ADAPTER_VERSION = 5; - -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 (bidRequest) { - return bidRequest !== undefined && !!bidRequest.params && !!bidRequest.bidId; - }, - - /** - * 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 topLocation = utils.parseUrl(utils.deepAccess(bidderRequest, 'refererInfo.referer')); - - return validBidRequests.map((bidRequest) => { - return { - method: 'POST', - options: { - withCredentials: true, - }, - url: BIDDER_ENDPOINT, - data: { - id: bidRequest.bidId, - imp: { - id: bidRequest.bidId, - bidfloor: utils.getBidIdParameter('bidfloor', bidRequest.params), - banner: _getBanner(bidRequest), - native: _getNative(utils.deepAccess(bidRequest, 'mediaTypes.native')), - ext: { - zone: { - id: utils.getBidIdParameter('zoneId', bidRequest.params) - }, - nextroll: { - adapter_version: ADAPTER_VERSION - } - } - }, - - user: _getUser(validBidRequests), - site: _getSite(bidRequest, topLocation), - seller: _getSeller(bidRequest), - device: _getDevice(bidRequest), - regs: _getRegs(bidderRequest) - } - }; - }); - }, - - /** - * 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) { - if (!serverResponse.body) { - return []; - } else { - let response = serverResponse.body - let bids = response.seatbid.reduce((acc, seatbid) => acc.concat(seatbid.bid), []); - return bids.map((bid) => _buildResponse(response, bid)); - } - } -} - -function _getBanner(bidRequest) { - let sizes = _getSizes(bidRequest); - if (sizes === undefined) return undefined; - return {format: sizes}; -} - -function _getNative(mediaTypeNative) { - if (mediaTypeNative === undefined) return undefined; - let assets = _getNativeAssets(mediaTypeNative); - if (assets === undefined || assets.length == 0) return undefined; - return { - request: { - native: { - assets: assets - } - } - }; -} - -/* - id: Unique numeric id for the asset - kind: OpenRTB kind of asset. Supported: title, img and data. - key: Name of property that comes in the mediaType.native object. - type: OpenRTB type for that spefic kind of asset. - required: Overrides the asset required field configured, only overrides when is true. -*/ -const NATIVE_ASSET_MAP = [ - {id: 1, kind: 'title', key: 'title', required: true}, - {id: 2, kind: 'img', key: 'image', type: 3, required: true}, - {id: 3, kind: 'img', key: 'icon', type: 1}, - {id: 4, kind: 'img', key: 'logo', type: 2}, - {id: 5, kind: 'data', key: 'sponsoredBy', type: 1}, - {id: 6, kind: 'data', key: 'body', type: 2} -]; - -const ASSET_KIND_MAP = { - title: _getTitleAsset, - img: _getImageAsset, - data: _getDataAsset, -}; - -function _getAsset(mediaTypeNative, assetMap) { - const asset = mediaTypeNative[assetMap.key]; - if (asset === undefined) return undefined; - const assetFunc = ASSET_KIND_MAP[assetMap.kind]; - return { - id: assetMap.id, - required: (assetMap.required || !!asset.required) ? 1 : 0, - [assetMap.kind]: assetFunc(asset, assetMap) - }; -} - -function _getTitleAsset(title, _assetMap) { - return {len: title.len || 0}; -} - -function _getMinAspectRatio(aspectRatio, property) { - if (!utils.isPlainObject(aspectRatio)) return 1; - - const ratio = aspectRatio['ratio_' + property]; - const min = aspectRatio['min_' + property]; - - if (utils.isNumber(ratio)) return ratio; - if (utils.isNumber(min)) return min; - - return 1; -} - -function _getImageAsset(image, assetMap) { - const sizes = image.sizes; - const aspectRatio = image.aspect_ratios ? image.aspect_ratios[0] : undefined; - - return { - type: assetMap.type, - w: (sizes ? sizes[0] : undefined), - h: (sizes ? sizes[1] : undefined), - wmin: _getMinAspectRatio(aspectRatio, 'width'), - hmin: _getMinAspectRatio(aspectRatio, 'height'), - }; -} - -function _getDataAsset(data, assetMap) { - return { - type: assetMap.type, - len: data.len || 0 - }; -} - -function _getNativeAssets(mediaTypeNative) { - return NATIVE_ASSET_MAP - .map(assetMap => _getAsset(mediaTypeNative, assetMap)) - .filter(asset => asset !== undefined); -} - -function _getUser(requests) { - const id = utils.deepAccess(requests, '0.userId.nextrollId'); - if (id === undefined) { - return; - } - - return { - ext: { - eid: [{ - 'source': 'nextroll', - id - }] - } - }; -} - -function _buildResponse(bidResponse, bid) { - let response = { - requestId: bidResponse.id, - cpm: bid.price, - width: bid.w, - height: bid.h, - creativeId: bid.crid, - dealId: bidResponse.dealId, - currency: 'USD', - netRevenue: true, - ttl: 300 - }; - if (utils.isStr(bid.adm)) { - response.mediaType = BANNER; - response.ad = utils.replaceAuctionPrice(bid.adm, bid.price); - } else { - response.mediaType = NATIVE; - response.native = _getNativeResponse(bid.adm, bid.price); - } - return response; -} - -const privacyLink = 'https://info.evidon.com/pub_info/573'; -const privacyIcon = 'https://c.betrad.com/pub/icon1.png'; - -function _getNativeResponse(adm, price) { - let baseResponse = { - clickTrackers: (adm.link && adm.link.clicktrackers) || [], - jstracker: adm.jstracker || [], - clickUrl: utils.replaceAuctionPrice(adm.link.url, price), - impressionTrackers: adm.imptrackers.map(impTracker => utils.replaceAuctionPrice(impTracker, price)), - privacyLink: privacyLink, - privacyIcon: privacyIcon - }; - return adm.assets.reduce((accResponse, asset) => { - const assetMaps = NATIVE_ASSET_MAP.filter(assetMap => assetMap.id === asset.id && asset[assetMap.kind] !== undefined); - if (assetMaps.length === 0) return accResponse; - const assetMap = assetMaps[0]; - accResponse[assetMap.key] = _getAssetResponse(asset, assetMap); - return accResponse; - }, baseResponse); -} - -function _getAssetResponse(asset, assetMap) { - switch (assetMap.kind) { - case 'title': - return asset.title.text; - - case 'img': - return { - url: asset.img.url, - width: asset.img.w, - height: asset.img.h - }; - - case 'data': - return asset.data.value; - } -} - -function _getSite(bidRequest, topLocation) { - return { - page: topLocation.href, - domain: topLocation.hostname, - publisher: { - id: utils.getBidIdParameter('publisherId', bidRequest.params) - } - }; -} - -function _getSeller(bidRequest) { - return { - id: utils.getBidIdParameter('sellerId', bidRequest.params) - }; -} - -function _getSizes(bidRequest) { - if (!utils.isArray(bidRequest.sizes)) { - return undefined; - } - return bidRequest.sizes.filter(_isValidSize).map(size => { - return { - w: size[0], - h: size[1] - } - }); -} - -function _isValidSize(size) { - const isNumber = x => typeof x === 'number'; - return (size.length === 2 && isNumber(size[0]) && isNumber(size[1])); -} - -function _getDevice(_bidRequest) { - return { - ua: navigator.userAgent, - language: navigator['language'], - os: _getOs(navigator.userAgent.toLowerCase()), - osv: _getOsVersion(navigator.userAgent) - }; -} - -function _getRegs(bidderRequest) { - if (!bidderRequest || !bidderRequest.uspConsent) { - return undefined; - } - return { - ext: { - us_privacy: bidderRequest.uspConsent - } - }; -} - -function _getOs(userAgent) { - const osTable = { - 'android': /android/i, - 'ios': /iphone|ipad/i, - 'mac': /mac/i, - 'linux': /linux/i, - 'windows': /windows/i - }; - - return find(Object.keys(osTable), os => { - if (userAgent.match(osTable[os])) { - return os; - } - }) || 'etc'; -} - -function _getOsVersion(userAgent) { - const clientStrings = [ - { s: 'Android', r: /Android/ }, - { s: 'iOS', r: /(iPhone|iPad|iPod)/ }, - { s: 'Mac OS X', r: /Mac OS X/ }, - { s: 'Mac OS', r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ }, - { s: 'Linux', r: /(Linux|X11)/ }, - { s: 'Windows 10', r: /(Windows 10.0|Windows NT 10.0)/ }, - { s: 'Windows 8.1', r: /(Windows 8.1|Windows NT 6.3)/ }, - { s: 'Windows 8', r: /(Windows 8|Windows NT 6.2)/ }, - { s: 'Windows 7', r: /(Windows 7|Windows NT 6.1)/ }, - { s: 'Windows Vista', r: /Windows NT 6.0/ }, - { s: 'Windows Server 2003', r: /Windows NT 5.2/ }, - { s: 'Windows XP', r: /(Windows NT 5.1|Windows XP)/ }, - { s: 'UNIX', r: /UNIX/ }, - { s: 'Search Bot', r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/ } - ]; - let cs = find(clientStrings, cs => cs.r.test(userAgent)); - return cs ? cs.s : 'unknown'; -} - -registerBidder(spec); diff --git a/modules/oneVideoBidAdapter.md b/modules/oneVideoBidAdapter.md index c1762ac0cd3..149a4b20e2f 100644 --- a/modules/oneVideoBidAdapter.md +++ b/modules/oneVideoBidAdapter.md @@ -348,7 +348,7 @@ var adUnits = [ id: 1, page: 'https://verizonmedia.com', referrer: 'https://verizonmedia.com' - }, + }, pubId: 'HBExchange' } } 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/openxBidAdapter.js b/modules/openxBidAdapter.js index a398a20a5c5..b49f7ef2c3c 100644 --- a/modules/openxBidAdapter.js +++ b/modules/openxBidAdapter.js @@ -31,7 +31,6 @@ export const USER_ID_CODE_TO_QUERY_ARG = { parrableId: 'parrableid', // Parrable ID pubcid: 'pubcid', // PubCommon ID quantcastId: 'quantcastid', // Quantcast ID - sharedId: 'sharedid', // Shared ID User ID tapadId: 'tapadid', // Tapad Id tdid: 'ttduuid', // The Trade Desk Unified ID verizonMediaId: 'verizonmediaid', // Verizon Media ConnectID diff --git a/modules/optimeraBidAdapter.js b/modules/optimeraBidAdapter.js deleted file mode 100644 index b470e901ec6..00000000000 --- a/modules/optimeraBidAdapter.js +++ /dev/null @@ -1,85 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { deepAccess } from '../src/utils.js'; - -const BIDDER_CODE = 'optimera'; -const SCORES_BASE_URL = 'https://dyv1bugovvq1g.cloudfront.net/'; - -export const spec = { - code: BIDDER_CODE, - /** - * Determines whether or not the given bid request is valid. - * - * @param {bidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid (bidRequest) { - if (typeof bidRequest.params !== 'undefined' && typeof bidRequest.params.clientID !== 'undefined') { - return true; - } - return false; - }, - /** - * Make a server request from the list of BidRequests. - * - * We call the existing scores data file for ad slot placement scores. - * These scores will be added to the dealId to be pushed to DFP. - * - * @param {validBidRequests[]} - an array of bids - * @return ServerRequest Info describing the request to the server. - */ - buildRequests (validBidRequests) { - const optimeraHost = window.location.host; - const optimeraPathName = window.location.pathname; - if (typeof validBidRequests[0].params.clientID !== 'undefined') { - const { clientID } = validBidRequests[0].params; - const scoresURL = `${SCORES_BASE_URL + clientID}/${optimeraHost}${optimeraPathName}.js`; - return { - method: 'GET', - url: scoresURL, - payload: validBidRequests, - }; - } - return {}; - }, - /** - * Unpack the response from the server into a list of bids. - * - * Some required bid params are not needed for this so default - * values are used. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse (serverResponse, bidRequest) { - const validBids = bidRequest.payload; - const bidResponses = []; - let dealId = ''; - if (typeof serverResponse.body !== 'undefined') { - const scores = serverResponse.body; - for (let i = 0; i < validBids.length; i += 1) { - if (typeof validBids[i].params.clientID !== 'undefined') { - if (validBids[i].adUnitCode in scores) { - const deviceDealId = deepAccess(scores, `device.${validBids[i].params.device}.${validBids[i].adUnitCode}`); - dealId = deviceDealId || scores[validBids[i].adUnitCode]; - } - const bidResponse = { - requestId: validBids[i].bidId, - ad: '
', - cpm: 0.01, - width: 0, - height: 0, - dealId, - ttl: 300, - creativeId: '1', - netRevenue: '0', - currency: 'USD' - }; - bidResponses.push(bidResponse); - } - } - } - return bidResponses; - } -} - -registerBidder(spec); diff --git a/modules/optimeraBidAdapter.md b/modules/optimeraBidAdapter.md deleted file mode 100644 index 25da9b6236f..00000000000 --- a/modules/optimeraBidAdapter.md +++ /dev/null @@ -1,58 +0,0 @@ -# Overview - -``` -Module Name: Optimera Bidder Adapter -Module Type: Bidder Adapter -Maintainer: kcandiotti@optimera.nyc -``` - -# Description - -Module that adds ad placement visibility scores for DFP. - -# Test Parameters -``` - var adUnits = [{ - code: 'div-1', - sizes: [[300, 250], [300,600]], - bids: [ - { - bidder: 'optimera', - params: { - clientID: '9999', - device: 'mo' - } - }] - },{ - code: 'div-0', - sizes: [[728, 90]], - bids: [ - { - bidder: 'optimera', - params: { - clientID: '9999', - device: 'mo' - } - }] - }]; -``` - -# AppNexus Issue -There is an issue where the plugin sometimes doesn't return impressions with AppNexus. - -There is an open issue here: [#3597](https://github.com/prebid/Prebid.js/issues/3597) - -## Configuration Workaround - -Optimera's configuration requires the use of size 0,0 which, in some instances, causes the AppNexus ad server to respond to ad requests but not fill impressions. AppNexus and vendors using the AppNexus ad server should monitor 3rd party numbers to ensure there is no decline in fill rate. - -Configuration Example: - -``` -code: ‘leaderboard', -mediaTypes: { - banner: { - sizes: [[970, 250],[970, 90],[970, 66],[728, 90],[320, 50],[320, 100],[300, 250],[0, 0]], - } -} -``` diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index 4a7d686a7bc..0ca0eeafe47 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -21,7 +21,6 @@ export const spec = { return !!(bid.sizes && bid.bidId && bid.params && (bid.params.accountId && (typeof bid.params.accountId === 'string')) && (bid.params.placementId && (typeof bid.params.placementId === 'string')) && - ((typeof bid.params.bidfloor === 'undefined') || (typeof bid.params.bidfloor === 'number')) && ((typeof bid.params.profile === 'undefined') || (typeof bid.params.profile === 'object'))); }, 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/ozoneBidAdapter.js b/modules/ozoneBidAdapter.js index 928344be74f..974fe3a4304 100644 --- a/modules/ozoneBidAdapter.js +++ b/modules/ozoneBidAdapter.js @@ -707,6 +707,7 @@ export const spec = { // @todo - what is Neustar fabrick called & where to look for it? If it's a simple value then it will automatically be ok // it is not in the table 'Bidder Adapter Implementation' on https://docs.prebid.org/dev-docs/modules/userId.html#prebidjs-adapters let searchKeysSingle = ['pubcid', 'tdid', 'idl_env', 'criteoId', 'lotamePanoramaId', 'fabrickId']; + if (bidRequest.hasOwnProperty('userId')) { for (let arrayId in searchKeysSingle) { let key = searchKeysSingle[arrayId]; 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/platformioBidAdapter.js b/modules/platformioBidAdapter.js deleted file mode 100644 index 314f738ef81..00000000000 --- a/modules/platformioBidAdapter.js +++ /dev/null @@ -1,307 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import includes from 'core-js-pure/features/array/includes.js'; - -const NATIVE_DEFAULTS = { - TITLE_LEN: 100, - DESCR_LEN: 200, - SPONSORED_BY_LEN: 50, - IMG_MIN: 150, - ICON_MIN: 50, -}; -const DEFAULT_MIMES = ['video/mp4', 'video/webm', 'application/x-shockwave-flash', 'application/javascript']; -const VIDEO_TARGETING = ['mimes', 'skippable', 'playback_method', 'protocols', 'api']; -const DEFAULT_PROTOCOLS = [2, 3, 5, 6]; -const DEFAULT_APIS = [1, 2]; - -export const spec = { - - code: 'platformio', - supportedMediaTypes: ['banner', 'native', 'video'], - - isBidRequestValid: bid => ( - !!(bid && bid.params && bid.params.pubId && bid.params.placementId) - ), - buildRequests: (bidRequests, bidderRequest) => { - const request = { - id: bidRequests[0].bidderRequestId, - at: 2, - imp: bidRequests.map(slot => impression(slot)), - site: site(bidRequests), - app: app(bidRequests), - device: device(bidRequests), - }; - applyGdpr(bidderRequest, request); - return { - method: 'POST', - url: 'https://piohbdisp.hb.adx1.com/', - data: JSON.stringify(request), - }; - }, - interpretResponse: (response, request) => ( - bidResponseAvailable(request, response.body) - ), -}; - -function bidResponseAvailable(bidRequest, bidResponse) { - const idToImpMap = {}; - const idToBidMap = {}; - const ortbRequest = parse(bidRequest.data); - ortbRequest.imp.forEach(imp => { - idToImpMap[imp.id] = imp; - }); - if (bidResponse) { - bidResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => { - idToBidMap[bid.impid] = bid; - })); - } - const bids = []; - Object.keys(idToImpMap).forEach(id => { - if (idToBidMap[id]) { - const bid = {}; - bid.requestId = id; - bid.adId = id; - bid.creativeId = id; - bid.cpm = idToBidMap[id].price; - bid.currency = bidResponse.cur; - bid.ttl = 360; - bid.netRevenue = true; - if (idToImpMap[id]['native']) { - bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]); - let nurl = idToBidMap[id].nurl; - nurl = nurl.replace(/\$(%7B|\{)AUCTION_IMP_ID(%7D|\})/gi, idToBidMap[id].impid); - nurl = nurl.replace(/\$(%7B|\{)AUCTION_PRICE(%7D|\})/gi, idToBidMap[id].price); - nurl = nurl.replace(/\$(%7B|\{)AUCTION_CURRENCY(%7D|\})/gi, bidResponse.cur); - nurl = nurl.replace(/\$(%7B|\{)AUCTION_BID_ID(%7D|\})/gi, bidResponse.bidid); - bid['native']['impressionTrackers'] = [nurl]; - bid.mediaType = 'native'; - } else if (idToImpMap[id]['video']) { - bid.vastUrl = idToBidMap[id].adm; - bid.vastUrl = bid.vastUrl.replace(/\$(%7B|\{)AUCTION_PRICE(%7D|\})/gi, idToBidMap[id].price); - bid.crid = idToBidMap[id].crid; - bid.width = idToImpMap[id].video.w; - bid.height = idToImpMap[id].video.h; - bid.mediaType = 'video'; - } else if (idToImpMap[id]['banner']) { - bid.ad = idToBidMap[id].adm; - bid.ad = bid.ad.replace(/\$(%7B|\{)AUCTION_IMP_ID(%7D|\})/gi, idToBidMap[id].impid); - bid.ad = bid.ad.replace(/\$(%7B|\{)AUCTION_AD_ID(%7D|\})/gi, idToBidMap[id].adid); - bid.ad = bid.ad.replace(/\$(%7B|\{)AUCTION_PRICE(%7D|\})/gi, idToBidMap[id].price); - bid.ad = bid.ad.replace(/\$(%7B|\{)AUCTION_CURRENCY(%7D|\})/gi, bidResponse.cur); - bid.ad = bid.ad.replace(/\$(%7B|\{)AUCTION_BID_ID(%7D|\})/gi, bidResponse.bidid); - bid.width = idToBidMap[id].w; - bid.height = idToBidMap[id].h; - bid.mediaType = 'banner'; - } - bids.push(bid); - } - }); - return bids; -} -function impression(slot) { - return { - id: slot.bidId, - secure: window.location.protocol === 'https:' ? 1 : 0, - 'banner': banner(slot), - 'native': nativeImpression(slot), - 'video': videoImpression(slot), - bidfloor: slot.params.bidFloor || '0.000001', - tagid: slot.params.placementId.toString(), - }; -} - -function banner(slot) { - if (slot.mediaType === 'banner' || utils.deepAccess(slot, 'mediaTypes.banner')) { - const sizes = utils.deepAccess(slot, 'mediaTypes.banner.sizes'); - if (sizes.length > 1) { - let format = []; - for (let f = 0; f < sizes.length; f++) { - format.push({'w': sizes[f][0], 'h': sizes[f][1]}); - } - return {'format': format}; - } else { - return { - w: sizes[0][0], - h: sizes[0][1] - } - } - } - return null; -} - -function videoImpression(slot) { - if (slot.mediaType === 'video' || utils.deepAccess(slot, 'mediaTypes.video')) { - const sizes = utils.deepAccess(slot, 'mediaTypes.video.playerSize'); - const video = { - w: sizes[0][0], - h: sizes[0][1], - mimes: DEFAULT_MIMES, - protocols: DEFAULT_PROTOCOLS, - api: DEFAULT_APIS, - }; - if (slot.params.video) { - Object.keys(slot.params.video).filter(param => includes(VIDEO_TARGETING, param)).forEach(param => video[param] = slot.params.video[param]); - } - return video; - } - return null; -} - -function nativeImpression(slot) { - if (slot.mediaType === 'native' || utils.deepAccess(slot, 'mediaTypes.native')) { - const assets = []; - addAsset(assets, titleAsset(1, slot.nativeParams.title, NATIVE_DEFAULTS.TITLE_LEN)); - addAsset(assets, dataAsset(2, slot.nativeParams.body, 2, NATIVE_DEFAULTS.DESCR_LEN)); - addAsset(assets, dataAsset(3, slot.nativeParams.sponsoredBy, 1, NATIVE_DEFAULTS.SPONSORED_BY_LEN)); - addAsset(assets, imageAsset(4, slot.nativeParams.icon, 1, NATIVE_DEFAULTS.ICON_MIN, NATIVE_DEFAULTS.ICON_MIN)); - addAsset(assets, imageAsset(5, slot.nativeParams.image, 3, NATIVE_DEFAULTS.IMG_MIN, NATIVE_DEFAULTS.IMG_MIN)); - return { - request: JSON.stringify({ assets }), - ver: '1.1', - }; - } - return null; -} - -function addAsset(assets, asset) { - if (asset) { - assets.push(asset); - } -} - -function titleAsset(id, params, defaultLen) { - if (params) { - return { - id, - required: params.required ? 1 : 0, - title: { - len: params.len || defaultLen, - }, - }; - } - return null; -} - -function imageAsset(id, params, type, defaultMinWidth, defaultMinHeight) { - return params ? { - id, - required: params.required ? 1 : 0, - img: { - type, - wmin: params.wmin || defaultMinWidth, - hmin: params.hmin || defaultMinHeight, - } - } : null; -} - -function dataAsset(id, params, type, defaultLen) { - return params ? { - id, - required: params.required ? 1 : 0, - data: { - type, - len: params.len || defaultLen, - } - } : null; -} - -function site(bidderRequest) { - const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.pubId : '0'; - const siteId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.siteId : '0'; - const appParams = bidderRequest[0].params.app; - if (!appParams) { - return { - publisher: { - id: pubId.toString(), - domain: window.location.hostname, - }, - id: siteId.toString(), - ref: window.top.document.referrer, - page: window.location.href, - } - } - return null; -} - -function app(bidderRequest) { - const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.pubId : '0'; - const appParams = bidderRequest[0].params.app; - if (appParams) { - return { - publisher: { - id: pubId.toString(), - }, - id: appParams.id, - name: appParams.name, - bundle: appParams.bundle, - storeurl: appParams.storeUrl, - domain: appParams.domain, - } - } - return null; -} - -function device(bidderRequest) { - const lat = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.latitude : ''; - const lon = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.longitude : ''; - const ifa = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.ifa : ''; - return { - dnt: utils.getDNT() ? 1 : 0, - ua: navigator.userAgent, - language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), - w: (window.screen.width || window.innerWidth), - h: (window.screen.height || window.innerHeigh), - geo: { - lat: lat, - lon: lon, - }, - ifa: ifa, - }; -} - -function parse(rawResponse) { - try { - if (rawResponse) { - return JSON.parse(rawResponse); - } - } catch (ex) { - utils.logError('platformio.parse', 'ERROR', ex); - } - return null; -} - -function applyGdpr(bidderRequest, ortbRequest) { - if (bidderRequest && bidderRequest.gdprConsent) { - ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; - ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; - } -} - -function nativeResponse(imp, bid) { - if (imp['native']) { - const nativeAd = parse(bid.adm); - const keys = {}; - keys.image = {}; - keys.icon = {}; - if (nativeAd && nativeAd['native'] && nativeAd['native'].assets) { - nativeAd['native'].assets.forEach(asset => { - keys.title = asset.title ? asset.title.text : keys.title; - keys.body = asset.data && asset.id === 2 ? asset.data.value : keys.body; - keys.sponsoredBy = asset.data && asset.id === 3 ? asset.data.value : keys.sponsoredBy; - keys.icon.url = asset.img && asset.id === 4 ? asset.img.url : keys.icon.url; - keys.icon.width = asset.img && asset.id === 4 ? asset.img.w : keys.icon.width; - keys.icon.height = asset.img && asset.id === 4 ? asset.img.h : keys.icon.height; - keys.image.url = asset.img && asset.id === 5 ? asset.img.url : keys.image.url; - keys.image.width = asset.img && asset.id === 5 ? asset.img.w : keys.image.width; - keys.image.height = asset.img && asset.id === 5 ? asset.img.h : keys.image.height; - }); - if (nativeAd['native'].link) { - keys.clickUrl = encodeURIComponent(nativeAd['native'].link.url); - } - return keys; - } - } - return null; -} - -registerBidder(spec); diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index ad5cb70cc23..bbf301fb072 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -602,6 +602,8 @@ const OPEN_RTB_PROTOCOL = { }); mediaTypes['banner'] = {format}; + + if (bannerParams.pos) mediaTypes['banner'].pos = bannerParams.pos; } if (!utils.isEmpty(videoParams)) { @@ -728,7 +730,8 @@ const OPEN_RTB_PROTOCOL = { source: {tid: s2sBidRequest.tid}, tmax: s2sConfig.timeout, imp: imps, - test: getConfig('debug') ? 1 : 0, + // to do: add setconfig option to pass test = 1 + test: 0, ext: { prebid: { // set ext.prebid.auctiontimestamp with the auction timestamp. Data type is long integer. @@ -746,6 +749,11 @@ const OPEN_RTB_PROTOCOL = { // Sets pbjs version, can be overwritten below if channel exists in s2sConfig.extPrebid request.ext.prebid = Object.assign(request.ext.prebid, {channel: {name: 'pbjs', version: $$PREBID_GLOBAL$$.version}}) + // set debug flag if in debug mode + if (getConfig('debug')) { + request.ext.prebid = Object.assign(request.ext.prebid, {debug: 1}) + } + // s2sConfig video.ext.prebid is passed through openrtb to PBS if (s2sConfig.extPrebid && typeof s2sConfig.extPrebid === 'object') { request.ext.prebid = Object.assign(request.ext.prebid, s2sConfig.extPrebid); 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/pubCommonIdSystem.js b/modules/pubCommonIdSystem.js deleted file mode 100644 index 95e539a4d6a..00000000000 --- a/modules/pubCommonIdSystem.js +++ /dev/null @@ -1,345 +0,0 @@ -/** - * This module adds PubCommonId to the User ID module - * The {@link module:modules/userId} module is required - * @module modules/pubCommonIdSystem - * @requires module:modules/userId - */ - -import * as utils from '../src/utils.js'; -import {submodule} from '../src/hook.js'; -import {getStorageManager} from '../src/storageManager.js'; -import {ajax} from '../src/ajax.js'; -import { uspDataHandler, coppaDataHandler } from '../src/adapterManager.js'; - -const PUB_COMMON_ID = 'PublisherCommonId'; -const MODULE_NAME = 'pubCommonId'; - -const COOKIE = 'cookie'; -const LOCAL_STORAGE = 'html5'; -const SHAREDID_OPT_OUT_VALUE = '00000000000000000000000000'; -const SHAREDID_URL = 'https://id.sharedid.org/id'; -const SHAREDID_SUFFIX = '_sharedid'; -const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT'; -const SHAREDID_DEFAULT_STATE = false; -const GVLID = 887; - -const storage = getStorageManager(GVLID, 'pubCommonId'); - -/** - * Store sharedid in either cookie or local storage - * @param {Object} config Need config.storage object to derive key, expiry time, and storage type. - * @param {string} value Shareid value to store - */ - -function storeData(config, value) { - try { - if (value) { - const key = config.storage.name + SHAREDID_SUFFIX; - const expiresStr = (new Date(Date.now() + (storage.expires * (60 * 60 * 24 * 1000)))).toUTCString(); - - if (config.storage.type === COOKIE) { - if (storage.cookiesAreEnabled()) { - storage.setCookie(key, value, expiresStr, 'LAX', pubCommonIdSubmodule.domainOverride()); - } - } else if (config.storage.type === LOCAL_STORAGE) { - if (storage.hasLocalStorage()) { - storage.setDataInLocalStorage(`${key}_exp`, expiresStr); - storage.setDataInLocalStorage(key, value); - } - } - } - } catch (error) { - utils.logError(error); - } -} - -/** - * Read sharedid from cookie or local storage - * @param config Need config.storage to derive key and storage type - * @return {string} - */ -function readData(config) { - try { - const key = config.storage.name + SHAREDID_SUFFIX; - if (config.storage.type === COOKIE) { - if (storage.cookiesAreEnabled()) { - return storage.getCookie(key); - } - } else if (config.storage.type === LOCAL_STORAGE) { - if (storage.hasLocalStorage()) { - const expValue = storage.getDataFromLocalStorage(`${key}_exp`); - if (!expValue) { - return storage.getDataFromLocalStorage(key); - } else if ((new Date(expValue)).getTime() - Date.now() > 0) { - return storage.getDataFromLocalStorage(key) - } - } - } - } catch (error) { - utils.logError(error); - } -} - -/** - * Delete sharedid from cookie or local storage - * @param config Need config.storage to derive key and storage type - */ -function delData(config) { - try { - const key = config.storage.name + SHAREDID_SUFFIX; - if (config.storage.type === COOKIE) { - if (storage.cookiesAreEnabled()) { - storage.setCookie(key, '', EXPIRED_COOKIE_DATE); - } - } else if (config.storage.type === LOCAL_STORAGE) { - storage.removeDataFromLocalStorage(`${key}_exp`); - storage.removeDataFromLocalStorage(key); - } - } catch (error) { - utils.logError(error); - } -} - -/** - * setup success and error handler for sharedid callback thru ajax - * @param {string} pubcid Current pubcommon id - * @param {function} callback userId module callback. - * @param {Object} config Need config.storage to derive sharedid storage params - * @return {{success: success, error: error}} - */ - -function handleResponse(pubcid, callback, config) { - return { - success: function (responseBody) { - if (responseBody) { - try { - let responseObj = JSON.parse(responseBody); - utils.logInfo('PubCommonId: Generated SharedId: ' + responseObj.sharedId); - if (responseObj.sharedId) { - if (responseObj.sharedId !== SHAREDID_OPT_OUT_VALUE) { - // Store sharedId locally - storeData(config, responseObj.sharedId); - } else { - // Delete local copy if the user has opted out - delData(config); - } - } - // Pass pubcid even though there is no change in order to trigger decode - callback(pubcid); - } catch (error) { - utils.logError(error); - } - } - }, - error: function (statusText, responseBody) { - utils.logInfo('PubCommonId: failed to get sharedid'); - } - } -} - -/** - * Builds and returns the shared Id URL with attached consent data if applicable - * @param {Object} consentData - * @return {string} - */ -function sharedIdUrl(consentData) { - const usPrivacyString = uspDataHandler.getConsentData(); - let sharedIdUrl = SHAREDID_URL; - if (usPrivacyString && typeof usPrivacyString === 'string') { - sharedIdUrl = `${SHAREDID_URL}?us_privacy=${usPrivacyString}`; - } - if (!consentData || typeof consentData.gdprApplies !== 'boolean' || !consentData.gdprApplies) return sharedIdUrl; - if (usPrivacyString) { - sharedIdUrl = `${sharedIdUrl}&gdpr=1&gdpr_consent=${consentData.consentString}` - return sharedIdUrl; - } - sharedIdUrl = `${SHAREDID_URL}?gdpr=1&gdpr_consent=${consentData.consentString}`; - return sharedIdUrl -} - -/** - * Wraps pixelCallback in order to call sharedid sync - * @param {string} pubcid Pubcommon id value - * @param {function|undefined} pixelCallback fires a pixel to first party server - * @param {Object} config Need config.storage to derive sharedid storage params. - * @return {function(...[*]=)} - */ - -function getIdCallback(pubcid, pixelCallback, config, consentData) { - return function (callback) { - if (typeof pixelCallback === 'function') { - pixelCallback(); - } - ajax(sharedIdUrl(consentData), handleResponse(pubcid, callback, config), undefined, {method: 'GET', withCredentials: true}); - } -} - -/** @type {Submodule} */ -export const pubCommonIdSubmodule = { - /** - * used to link submodule with config - * @type {string} - */ - name: MODULE_NAME, - /** - * Vendor id of prebid - * @type {Number} - */ - gvlid: GVLID, - /** - * Return a callback function that calls the pixelUrl with id as a query parameter - * @param pixelUrl - * @param id - * @returns {function} - */ - makeCallback: function (pixelUrl, id = '') { - if (!pixelUrl) { - return; - } - - // Use pubcid as a cache buster - const urlInfo = utils.parseUrl(pixelUrl); - urlInfo.search.id = encodeURIComponent('pubcid:' + id); - const targetUrl = utils.buildUrl(urlInfo); - - return function () { - utils.triggerPixel(targetUrl); - }; - }, - /** - * decode the stored id value for passing to bid requests - * @function - * @param {string} value - * @param {SubmoduleConfig} config - * @returns {{pubcid:string}} - */ - decode(value, config) { - const idObj = {'pubcid': value}; - const {params: {enableSharedId = SHAREDID_DEFAULT_STATE} = {}} = config; - - if (enableSharedId) { - const sharedId = readData(config); - if (sharedId) idObj['sharedid'] = {id: sharedId}; - } - - return idObj; - }, - /** - * performs action to obtain id - * @function - * @param {SubmoduleConfig} [config] Config object with params and storage properties - * @param {Object} consentData - * @param {string} storedId Existing pubcommon id - * @returns {IdResponse} - */ - getId: function (config = {}, consentData, storedId) { - const coppa = coppaDataHandler.getCoppa(); - if (coppa) { - utils.logInfo('PubCommonId: IDs not provided for coppa requests, exiting PubCommonId'); - return; - } - const {params: {create = true, pixelUrl, enableSharedId = SHAREDID_DEFAULT_STATE} = {}} = config; - let newId = storedId; - if (!newId) { - try { - if (typeof window[PUB_COMMON_ID] === 'object') { - // If the page includes its own pubcid module, then save a copy of id. - newId = window[PUB_COMMON_ID].getId(); - } - } catch (e) { - } - - if (!newId) newId = (create && utils.hasDeviceAccess()) ? utils.generateUUID() : undefined; - } - - const pixelCallback = this.makeCallback(pixelUrl, newId); - const combinedCallback = enableSharedId ? getIdCallback(newId, pixelCallback, config, consentData) : pixelCallback; - - return {id: newId, callback: combinedCallback}; - }, - /** - * performs action to extend an id. There are generally two ways to extend the expiration time - * of stored id: using pixelUrl or return the id and let main user id module write it again with - * the new expiration time. - * - * PixelUrl, if defined, should point back to a first party domain endpoint. On the server - * side, there is either a plugin, or customized logic to read and write back the pubcid cookie. - * The extendId function itself should return only the callback, and not the id itself to avoid - * having the script-side overwriting server-side. This applies to both pubcid and sharedid. - * - * On the other hand, if there is no pixelUrl, then the extendId should return storedId so that - * its expiration time is updated. Sharedid, however, will have to be updated by this submodule - * separately. - * - * @function - * @param {SubmoduleParams} [config] - * @param {ConsentData|undefined} consentData - * @param {Object} storedId existing id - * @returns {IdResponse|undefined} - */ - extendId: function(config = {}, consentData, storedId) { - const coppa = coppaDataHandler.getCoppa(); - if (coppa) { - utils.logInfo('PubCommonId: IDs not provided for coppa requests, exiting PubCommonId'); - return; - } - const {params: {extend = false, pixelUrl, enableSharedId = SHAREDID_DEFAULT_STATE} = {}} = config; - - if (extend) { - try { - if (typeof window[PUB_COMMON_ID] === 'object') { - if (enableSharedId) { - // If the page includes its own pubcid module, then there is nothing to do - // except to update sharedid's expiration time - storeData(config, readData(config)); - } - return; - } - } catch (e) { - } - - if (pixelUrl) { - const callback = this.makeCallback(pixelUrl, storedId); - return {callback: callback}; - } else { - if (enableSharedId) { - // Update with the same value to extend expiration time - storeData(config, readData(config)); - } - return {id: storedId}; - } - } - }, - - /** - * @param {string} domain - * @param {HTMLDocument} document - * @return {(string|undefined)} - */ - domainOverride: function () { - const domainElements = document.domain.split('.'); - const cookieName = `_gd${Date.now()}`; - for (let i = 0, topDomain, testCookie; i < domainElements.length; i++) { - const nextDomain = domainElements.slice(i).join('.'); - - // write test cookie - storage.setCookie(cookieName, '1', undefined, undefined, nextDomain); - - // read test cookie to verify domain was valid - testCookie = storage.getCookie(cookieName); - - // delete test cookie - storage.setCookie(cookieName, '', 'Thu, 01 Jan 1970 00:00:01 GMT', undefined, nextDomain); - - if (testCookie === '1') { - // cookie was written successfully using test domain so the topDomain is updated - topDomain = nextDomain; - } else { - // cookie failed to write using test domain so exit by returning the topDomain - return topDomain; - } - } - } -}; - -submodule('userId', pubCommonIdSubmodule); 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/revcontentBidAdapter.js b/modules/revcontentBidAdapter.js deleted file mode 100644 index b429f94eae0..00000000000 --- a/modules/revcontentBidAdapter.js +++ /dev/null @@ -1,275 +0,0 @@ -// jshint esversion: 6, es3: false, node: true -'use strict'; - -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; - -const BIDDER_CODE = 'revcontent'; -const NATIVE_PARAMS = { - title: { - id: 0, - name: 'title' - }, - image: { - id: 3, - type: 3, - name: 'img' - }, - sponsoredBy: { - id: 5, - name: 'data', - type: 1 - } -}; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['native'], - isBidRequestValid: function (bid) { - return (typeof bid.params.apiKey !== 'undefined' && typeof bid.params.userId !== 'undefined' && bid.hasOwnProperty('nativeParams')); - }, - buildRequests: (validBidRequests, bidderRequest) => { - const userId = validBidRequests[0].params.userId; - const widgetId = validBidRequests[0].params.widgetId; - const apiKey = validBidRequests[0].params.apiKey; - var domain = validBidRequests[0].params.domain; - var host = validBidRequests[0].params.endpoint; - - if (typeof host === 'undefined') { - host = 'trends.revcontent.com'; - } - - let serverRequests = []; - var refererInfo; - if (bidderRequest && bidderRequest.refererInfo) { - refererInfo = bidderRequest.refererInfo.referer; - } - - if (typeof domain === 'undefined') { - domain = extractHostname(refererInfo); - } - - var endpoint = 'https://' + host + '/rtb?apiKey=' + apiKey + '&userId=' + userId; - - if (!isNaN(widgetId) && widgetId > 0) { - endpoint = endpoint + '&widgetId=' + widgetId; - } - - let bidfloor = 0.1; - if (!isNaN(validBidRequests[0].params.bidfloor) && validBidRequests[0].params.bidfloor > 0) { - bidfloor = validBidRequests[0].params.bidfloor; - } - - const imp = validBidRequests.map((bid, id) => { - if (bid.hasOwnProperty('nativeParams')) { - 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 wmin, hmin, w, h; - 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; - } - - asset[props.name] = { - len: bidParams.len, - type: props.type, - wmin, - hmin, - w, - h - }; - - return asset; - } - }).filter(Boolean); - - return { - id: id + 1, - tagid: bid.params.mid, - bidderRequestId: bid.bidderRequestId, - auctionId: bid.auctionId, - transactionId: bid.transactionId, - native: { - request: { - ver: '1.1', - context: 2, - contextsubtype: 21, - plcmttype: 1, - plcmtcnt: 1, - assets: assets - }, - ver: '1.1', - battr: [1, 3, 8, 11, 17] - }, - instl: 0, - bidfloor: bidfloor, - secure: '1' - }; - } - }); - - let data = { - id: bidderRequest.auctionId, - imp: imp, - site: { - id: widgetId, - domain: domain, - page: refererInfo, - cat: ['IAB17'], - publisher: { - id: userId, - domain: domain - } - }, - device: { - ua: navigator.userAgent, - language: 'en' - }, - user: { - id: 1 - }, - at: 2, - bcat: [ - 'IAB24', - 'IAB25', - 'IAB25-1', - 'IAB25-2', - 'IAB25-3', - 'IAB25-4', - 'IAB25-5', - 'IAB25-6', - 'IAB25-7', - 'IAB26', - 'IAB26-1', - 'IAB26-2', - 'IAB26-3', - 'IAB26-4' - ] - }; - serverRequests.push({ - method: 'POST', - options: { - contentType: 'application/json' - }, - url: endpoint, - data: JSON.stringify(data), - bid: validBidRequests - }); - - return serverRequests; - }, - interpretResponse: function (serverResponse, originalBidRequest) { - if (!serverResponse.body) { - return; - } - const seatbid = serverResponse.body.seatbid[0]; - const bidResponses = []; - - for (var x in seatbid.bid) { - let adm = JSON.parse(seatbid.bid[x]['adm']); - let ad = { - clickUrl: adm.link.url - }; - - adm.assets.forEach(asset => { - switch (asset.id) { - case 3: - ad['image'] = { - url: asset.img.url, - height: 1, - width: 1 - }; - break; - case 0: - ad['title'] = asset.title.text; - break; - case 5: - ad['sponsoredBy'] = asset.data.value; - break; - } - }); - - var size = originalBidRequest.bid[0].params.size; - - const bidResponse = { - bidder: BIDDER_CODE, - requestId: originalBidRequest.bid[0].bidId, - cpm: seatbid.bid[x]['price'], - creativeId: seatbid.bid[x]['adid'], - currency: 'USD', - netRevenue: true, - ttl: 360, - nurl: seatbid.bid[x]['nurl'], - bidderCode: 'revcontent', - mediaType: 'native', - native: ad, - width: size.width, - height: size.height, - ad: displayNative(ad, getTemplate(size, originalBidRequest.bid[0].params.template)) - }; - - bidResponses.push(bidResponse); - } - - return bidResponses; - }, - onBidWon: function (bid) { - utils.triggerPixel(bid.nurl); - return true; - } -}; - -registerBidder(spec); - -function displayNative(ad, template) { - template = template.replace(/{image}/g, ad['image']['url']); - template = template.replace(/{title}/g, ad['title']); - template = template.replace(/{clickUrl}/g, ad['clickUrl']); - template = template.replace(/{sponsoredBy}/g, ad['sponsoredBy']); - return template; -} - -function getTemplate(size, customTemplate) { - if (typeof (customTemplate) !== 'undefined' && customTemplate !== '') { - return customTemplate; - } - - if (size.width == 300 && size.height == 250) { - return '

{title}

SEE MORE
'; - } - - if (size.width == 728 && size.height == 90) { - return '

{title}

>
'; - } - - if (size.width == 300 && size.height == 600) { - return '

{title}

>
'; - } - - return ''; -} - -function extractHostname(url) { - if (typeof url == 'undefined' || url == null) { - return ''; - } - var hostname; - if (url.indexOf('//') > -1) { - hostname = url.split('/')[2]; - } else { - hostname = url.split('/')[0]; - } - - hostname = hostname.split(':')[0]; - hostname = hostname.split('?')[0]; - - return hostname; -} diff --git a/modules/rhythmoneBidAdapter.js b/modules/rhythmoneBidAdapter.js index fa090044f05..36b2c369213 100644 --- a/modules/rhythmoneBidAdapter.js +++ b/modules/rhythmoneBidAdapter.js @@ -38,7 +38,7 @@ function RhythmOneBidAdapter() { slotsToBids[BRs[i].adUnitCode] = BRs[i]; var impObj = {}; impObj.id = BRs[i].adUnitCode; - impObj.bidfloor = parseFloat(utils.deepAccess(BRs[i], 'params.floor')) || 0; + impObj.bidfloor = 0; impObj.secure = isSecure; if (utils.deepAccess(BRs[i], 'mediaTypes.banner') || utils.deepAccess(BRs[i], 'mediaType') === 'banner') { diff --git a/modules/riseBidAdapter.js b/modules/riseBidAdapter.js deleted file mode 100644 index e3265ad5d3e..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: params.floorPrice, - 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/rtbdemandBidAdapter.js b/modules/rtbdemandBidAdapter.js deleted file mode 100644 index be5fb39f53a..00000000000 --- a/modules/rtbdemandBidAdapter.js +++ /dev/null @@ -1,123 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'rtbdemand'; -const BIDDER_SERVER = 'bidding.rtbdemand.com'; -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function(bid) { - return !!(bid && bid.params && bid.params.zoneid); - }, - buildRequests: function(validBidRequests, bidderRequest) { - return validBidRequests.map(bidRequest => { - var server = bidRequest.params.server || BIDDER_SERVER; - var parse = getSize(bidderRequest.bids[0].sizes); - const payload = { - from: 'hb', - v: '1.0', - request_id: bidRequest.bidderRequestId, - imp_id: bidRequest.bidId, - aff: bidRequest.params.zoneid, - bid_floor: parseFloat(bidRequest.params.floor) > 0 ? bidRequest.params.floor : 0, - charset: document.charSet || document.characterSet, - site_domain: document.location.hostname, - site_page: window.location.href, - subid: 'hb', - flashver: getFlashVersion(), - tmax: bidderRequest.timeout, - hb: '1', - name: document.location.hostname, - width: parse.width, - height: parse.height, - device_width: screen.width, - device_height: screen.height, - dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, - secure: isSecure(), - make: navigator.vendor ? navigator.vendor : '', - }; - if (document.referrer) { - payload.referrer = document.referrer; - } - - return { - method: 'GET', - url: 'https://' + server + '/hb', - data: payload - }; - }); - }, - interpretResponse: function(serverResponse) { - serverResponse = serverResponse.body; - const bidResponses = []; - if (serverResponse && serverResponse.seatbid) { - serverResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => { - const bidResponse = { - requestId: bid.impid, - creativeId: bid.impid, - cpm: bid.price, - width: bid.w, - height: bid.h, - ad: bid.adm, - netRevenue: true, - currency: 'USD', - ttl: 360, - }; - - bidResponses.push(bidResponse); - })); - } - return bidResponses; - }, - getUserSyncs: function getUserSyncs(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: 'https://' + BIDDER_SERVER + '/delivery/matches.php?type=iframe', - }]; - } - } -} - -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 || ''; -} - -/* Get parsed size from request size */ -function getSize(requestSizes) { - const parsed = {}; - const size = utils.parseSizesInput(requestSizes)[0]; - - if (typeof size !== 'string') { - return parsed; - } - - const parsedSize = size.toUpperCase().split('X'); - const width = parseInt(parsedSize[0], 10); - if (width) { - parsed.width = width; - } - - const height = parseInt(parsedSize[1], 10); - if (height) { - parsed.height = height; - } - - return parsed; -} - -function isSecure() { - return document.location.protocol === 'https:'; -} - -registerBidder(spec); 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/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 078b5404baf..222d40043f6 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -482,7 +482,9 @@ export const spec = { // add p_pos only if specified and valid // For SRA we need to explicitly put empty semi colons so AE treats it as empty, instead of copying the latter value - data['p_pos'] = (params.position === 'atf' || params.position === 'btf') ? params.position : ''; + let posMapping = {1: 'atf', 3: 'btf'}; + let pos = posMapping[utils.deepAccess(bidRequest, 'mediaTypes.banner.pos')] || ''; + data['p_pos'] = (params.position === 'atf' || params.position === 'btf') ? params.position : pos; // pass publisher provided userId if configured const configUserId = config.getConfig('user.id'); @@ -505,8 +507,6 @@ export const spec = { } } else if (eid.source === 'liveramp.com') { data['x_liverampidl'] = eid.uids[0].id; - } else if (eid.source === 'sharedid.org') { - data['eid_sharedid.org'] = `${eid.uids[0].id}^${eid.uids[0].atype}^${(eid.uids[0].ext && eid.uids[0].ext.third) || ''}`; } else if (eid.source === 'id5-sync.com') { data['eid_id5-sync.com'] = `${eid.uids[0].id}^${eid.uids[0].atype}^${(eid.uids[0].ext && eid.uids[0].ext.linkType) || ''}`; } else { diff --git a/modules/saambaaBidAdapter.js b/modules/saambaaBidAdapter.js deleted file mode 100755 index 0e53d2a300d..00000000000 --- a/modules/saambaaBidAdapter.js +++ /dev/null @@ -1,401 +0,0 @@ -import * as utils from '../src/utils.js'; -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; -import find from 'core-js-pure/features/array/find.js'; -import includes from 'core-js-pure/features/array/includes.js'; - -const ADAPTER_VERSION = '1.0'; -const BIDDER_CODE = 'saambaa'; - -export const VIDEO_ENDPOINT = 'https://nep.advangelists.com/xp/get?pubid='; -export const BANNER_ENDPOINT = 'https://nep.advangelists.com/xp/get?pubid='; -export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js'; -export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'skip']; -export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; - -let pubid = ''; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid(bidRequest) { - if (typeof bidRequest != 'undefined') { - if (bidRequest.bidder !== BIDDER_CODE && typeof bidRequest.params === 'undefined') { return false; } - if (bidRequest === '' || bidRequest.params.placement === '' || bidRequest.params.pubid === '') { return false; } - return true; - } else { return false; } - }, - - buildRequests(bids, bidderRequest) { - let requests = []; - let videoBids = bids.filter(bid => isVideoBidValid(bid)); - let bannerBids = bids.filter(bid => isBannerBidValid(bid)); - videoBids.forEach(bid => { - pubid = getVideoBidParam(bid, 'pubid'); - requests.push({ - method: 'POST', - url: VIDEO_ENDPOINT + pubid, - data: createVideoRequestData(bid, bidderRequest), - bidRequest: bid - }); - }); - - bannerBids.forEach(bid => { - pubid = getBannerBidParam(bid, 'pubid'); - - requests.push({ - method: 'POST', - url: BANNER_ENDPOINT + pubid, - data: createBannerRequestData(bid, bidderRequest), - bidRequest: bid - }); - }); - return requests; - }, - - interpretResponse(serverResponse, {bidRequest}) { - let response = serverResponse.body; - if (response !== null && utils.isEmpty(response) == false) { - if (isVideoBid(bidRequest)) { - let bidResponse = { - requestId: response.id, - bidderCode: BIDDER_CODE, - cpm: response.seatbid[0].bid[0].price, - width: response.seatbid[0].bid[0].w, - height: response.seatbid[0].bid[0].h, - ttl: response.seatbid[0].bid[0].ttl || 60, - creativeId: response.seatbid[0].bid[0].crid, - currency: response.cur, - meta: { 'advertiserDomains': response.seatbid[0].bid[0].adomain }, - mediaType: VIDEO, - netRevenue: true - } - - if (response.seatbid[0].bid[0].adm) { - bidResponse.vastXml = response.seatbid[0].bid[0].adm; - bidResponse.adResponse = { - content: response.seatbid[0].bid[0].adm - }; - } else { - bidResponse.vastUrl = response.seatbid[0].bid[0].nurl; - } - - return bidResponse; - } else { - return { - requestId: response.id, - bidderCode: BIDDER_CODE, - cpm: response.seatbid[0].bid[0].price, - width: response.seatbid[0].bid[0].w, - height: response.seatbid[0].bid[0].h, - ad: response.seatbid[0].bid[0].adm, - ttl: response.seatbid[0].bid[0].ttl || 60, - creativeId: response.seatbid[0].bid[0].crid, - currency: response.cur, - meta: { 'advertiserDomains': response.seatbid[0].bid[0].adomain }, - mediaType: BANNER, - netRevenue: true - } - } - } - } -}; - -function isBannerBid(bid) { - return utils.deepAccess(bid, 'mediaTypes.banner') || !isVideoBid(bid); -} - -function isVideoBid(bid) { - return utils.deepAccess(bid, 'mediaTypes.video'); -} - -function isVideoBidValid(bid) { - return isVideoBid(bid) && getVideoBidParam(bid, 'pubid') && getVideoBidParam(bid, 'placement'); -} - -function isBannerBidValid(bid) { - return isBannerBid(bid) && getBannerBidParam(bid, 'pubid') && getBannerBidParam(bid, 'placement'); -} - -function getVideoBidParam(bid, key) { - return utils.deepAccess(bid, 'params.video.' + key) || utils.deepAccess(bid, 'params.' + key); -} - -function getBannerBidParam(bid, key) { - return utils.deepAccess(bid, 'params.banner.' + key) || utils.deepAccess(bid, 'params.' + key); -} - -function isMobile() { - return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); -} - -function isConnectedTV() { - return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); -} - -function getDoNotTrack() { - return navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNoTrack === '1' || navigator.doNotTrack === 'yes'; -} - -function findAndFillParam(o, key, value) { - try { - if (typeof value === 'function') { - o[key] = value(); - } else { - o[key] = value; - } - } catch (ex) {} -} - -function getOsVersion() { - let clientStrings = [ - { s: 'Android', r: /Android/ }, - { s: 'iOS', r: /(iPhone|iPad|iPod)/ }, - { s: 'Mac OS X', r: /Mac OS X/ }, - { s: 'Mac OS', r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ }, - { s: 'Linux', r: /(Linux|X11)/ }, - { s: 'Windows 10', r: /(Windows 10.0|Windows NT 10.0)/ }, - { s: 'Windows 8.1', r: /(Windows 8.1|Windows NT 6.3)/ }, - { s: 'Windows 8', r: /(Windows 8|Windows NT 6.2)/ }, - { s: 'Windows 7', r: /(Windows 7|Windows NT 6.1)/ }, - { s: 'Windows Vista', r: /Windows NT 6.0/ }, - { s: 'Windows Server 2003', r: /Windows NT 5.2/ }, - { s: 'Windows XP', r: /(Windows NT 5.1|Windows XP)/ }, - { s: 'UNIX', r: /UNIX/ }, - { s: 'Search Bot', r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/ } - ]; - let cs = find(clientStrings, cs => cs.r.test(navigator.userAgent)); - return cs ? cs.s : 'unknown'; -} - -function getFirstSize(sizes) { - return (sizes && sizes.length) ? sizes[0] : { w: undefined, h: undefined }; -} - -function parseSizes(sizes) { - return utils.parseSizesInput(sizes).map(size => { - let [ width, height ] = size.split('x'); - return { - w: parseInt(width, 10) || undefined, - h: parseInt(height, 10) || undefined - }; - }); -} - -function getVideoSizes(bid) { - return parseSizes(utils.deepAccess(bid, 'mediaTypes.video.playerSize') || bid.sizes); -} - -function getBannerSizes(bid) { - return parseSizes(utils.deepAccess(bid, 'mediaTypes.banner.sizes') || bid.sizes); -} - -function getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } -} - -function getVideoTargetingParams(bid) { - return Object.keys(Object(bid.params.video)) - .filter(param => includes(VIDEO_TARGETING, param)) - .reduce((obj, param) => { - obj[ param ] = bid.params.video[ param ]; - return obj; - }, {}); -} - -function createVideoRequestData(bid, bidderRequest) { - let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); - - // if size is explicitly given via adapter params - let paramSize = getVideoBidParam(bid, 'size'); - let sizes = []; - - if (typeof paramSize !== 'undefined' && paramSize != '') { - sizes = parseSizes(paramSize); - } else { - sizes = getVideoSizes(bid); - } - const firstSize = getFirstSize(sizes); - - let video = getVideoTargetingParams(bid); - const o = { - 'device': { - 'langauge': (global.navigator.language).split('-')[0], - 'dnt': (global.navigator.doNotTrack === 1 ? 1 : 0), - 'devicetype': isMobile() ? 4 : isConnectedTV() ? 3 : 2, - 'js': 1, - 'os': getOsVersion() - }, - 'at': 2, - 'site': {}, - 'tmax': 3000, - 'cur': ['USD'], - 'id': bid.bidId, - 'imp': [], - 'regs': { - 'ext': { - } - }, - 'user': { - 'ext': { - } - } - }; - - o.site['page'] = topLocation.href; - o.site['domain'] = topLocation.hostname; - o.site['search'] = topLocation.search; - o.site['domain'] = topLocation.hostname; - o.site['ref'] = topReferrer; - o.site['mobile'] = isMobile() ? 1 : 0; - const secure = topLocation.protocol.indexOf('https') === 0 ? 1 : 0; - - o.device['dnt'] = getDoNotTrack() ? 1 : 0; - - findAndFillParam(o.site, 'name', function() { - return global.top.document.title; - }); - - findAndFillParam(o.device, 'h', function() { - return global.screen.height; - }); - findAndFillParam(o.device, 'w', function() { - return global.screen.width; - }); - - let placement = getVideoBidParam(bid, 'placement'); - let floor = getVideoBidParam(bid, 'floor'); - if (floor == null) { floor = 0.5; } - - for (let j = 0; j < sizes.length; j++) { - o.imp.push({ - 'id': '' + j, - 'displaymanager': '' + BIDDER_CODE, - 'displaymanagerver': '' + ADAPTER_VERSION, - 'tagId': placement, - 'bidfloor': floor, - 'bidfloorcur': 'USD', - 'secure': secure, - 'video': Object.assign({ - 'id': utils.generateUUID(), - 'pos': 0, - 'w': firstSize.w, - 'h': firstSize.h, - 'mimes': DEFAULT_MIMES - }, video) - - }); - } - - if (bidderRequest && bidderRequest.gdprConsent) { - let { gdprApplies, consentString } = bidderRequest.gdprConsent; - o.regs.ext = {'gdpr': gdprApplies ? 1 : 0}; - o.user.ext = {'consent': consentString}; - } - - return o; -} - -function getTopWindowLocation(bidderRequest) { - let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return utils.parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); -} - -function createBannerRequestData(bid, bidderRequest) { - let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); - - // if size is explicitly given via adapter params - - let paramSize = getBannerBidParam(bid, 'size'); - let sizes = []; - if (typeof paramSize !== 'undefined' && paramSize != '') { - sizes = parseSizes(paramSize); - } else { - sizes = getBannerSizes(bid); - } - - const o = { - 'device': { - 'langauge': (global.navigator.language).split('-')[0], - 'dnt': (global.navigator.doNotTrack === 1 ? 1 : 0), - 'devicetype': isMobile() ? 4 : isConnectedTV() ? 3 : 2, - 'js': 1 - }, - 'at': 2, - 'site': {}, - 'tmax': 3000, - 'cur': ['USD'], - 'id': bid.bidId, - 'imp': [], - 'regs': { - 'ext': { - } - }, - 'user': { - 'ext': { - } - } - }; - - o.site['page'] = topLocation.href; - o.site['domain'] = topLocation.hostname; - o.site['search'] = topLocation.search; - o.site['domain'] = topLocation.hostname; - o.site['ref'] = topReferrer; - o.site['mobile'] = isMobile() ? 1 : 0; - const secure = topLocation.protocol.indexOf('https') === 0 ? 1 : 0; - - o.device['dnt'] = getDoNotTrack() ? 1 : 0; - - findAndFillParam(o.site, 'name', function() { - return global.top.document.title; - }); - - findAndFillParam(o.device, 'h', function() { - return global.screen.height; - }); - findAndFillParam(o.device, 'w', function() { - return global.screen.width; - }); - - let placement = getBannerBidParam(bid, 'placement'); - for (let j = 0; j < sizes.length; j++) { - let size = sizes[j]; - - let floor = getBannerBidParam(bid, 'floor'); - if (floor == null) { floor = 0.1; } - - o.imp.push({ - 'id': '' + j, - 'displaymanager': '' + BIDDER_CODE, - 'displaymanagerver': '' + ADAPTER_VERSION, - 'tagId': placement, - 'bidfloor': floor, - 'bidfloorcur': 'USD', - 'secure': secure, - 'banner': { - 'id': utils.generateUUID(), - 'pos': 0, - 'w': size['w'], - 'h': size['h'] - } - }); - } - - if (bidderRequest && bidderRequest.gdprConsent) { - let { gdprApplies, consentString } = bidderRequest.gdprConsent; - o.regs.ext = {'gdpr': gdprApplies ? 1 : 0}; - o.user.ext = {'consent': consentString}; - } - - return o; -} -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/sekindoUMBidAdapter.js b/modules/sekindoUMBidAdapter.js deleted file mode 100644 index bea25173747..00000000000 --- a/modules/sekindoUMBidAdapter.js +++ /dev/null @@ -1,119 +0,0 @@ -import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -export const spec = { - code: 'sekindoUM', - 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) { - if (bid.mediaType == 'video' || (typeof bid.mediaTypes == 'object' && typeof bid.mediaTypes.video == 'object')) { - if (typeof bid.params.video != 'object' || typeof bid.params.video.playerWidth == 'undefined' || typeof bid.params.video.playerHeight == 'undefined') { - return false; - } - } - return !!(bid.params.spaceId); - }, - /** - * 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) { - var pubUrl = null; - try { - if (window.top == window) { - pubUrl = window.location.href; - } else { - try { - pubUrl = window.top.location.href; - } catch (e2) { - pubUrl = document.referrer; - } - } - } catch (e1) {} - - return validBidRequests.map(bidRequest => { - var subId = utils.getBidIdParameter('subId', bidRequest.params); - var spaceId = utils.getBidIdParameter('spaceId', bidRequest.params); - var bidfloor = utils.getBidIdParameter('bidfloor', bidRequest.params); - var protocol = (document.location.protocol === 'https:' ? 's' : ''); - var queryString = ''; - - queryString = utils.tryAppendQueryString(queryString, 's', spaceId); - queryString = utils.tryAppendQueryString(queryString, 'subId', subId); - queryString = utils.tryAppendQueryString(queryString, 'pubUrl', pubUrl); - queryString = utils.tryAppendQueryString(queryString, 'hbTId', bidRequest.transactionId); - queryString = utils.tryAppendQueryString(queryString, 'hbBidId', bidRequest.bidId); - queryString = utils.tryAppendQueryString(queryString, 'hbver', '4'); - queryString = utils.tryAppendQueryString(queryString, 'hbcb', '1');/// legasy - queryString = utils.tryAppendQueryString(queryString, 'dcpmflr', bidfloor); - queryString = utils.tryAppendQueryString(queryString, 'protocol', protocol); - queryString = utils.tryAppendQueryString(queryString, 'x', bidRequest.params.width); - queryString = utils.tryAppendQueryString(queryString, 'y', bidRequest.params.height); - if (bidderRequest && bidderRequest.gdprConsent) { - queryString = utils.tryAppendQueryString(queryString, 'gdprConsent', bidderRequest.gdprConsent.consentString); - queryString = utils.tryAppendQueryString(queryString, 'gdpr', (bidderRequest.gdprConsent.gdprApplies) ? '1' : '0'); - } - if (bidRequest.mediaType === 'video' || (typeof bidRequest.mediaTypes == 'object' && typeof bidRequest.mediaTypes.video == 'object')) { - queryString = utils.tryAppendQueryString(queryString, 'x', bidRequest.params.playerWidth); - queryString = utils.tryAppendQueryString(queryString, 'y', bidRequest.params.playerHeight); - if (typeof vid_vastType != 'undefined') { // eslint-disable-line camelcase - queryString = utils.tryAppendQueryString(queryString, 'vid_vastType', bidRequest.params.vid_vastType); - } - if (typeof bidRequest.mediaTypes == 'object' && typeof bidRequest.mediaTypes.video == 'object' && typeof bidRequest.mediaTypes.video.context == 'string') { - queryString = utils.tryAppendQueryString(queryString, 'vid_context', bidRequest.mediaTypes.video.context); - } - } - - var endpointUrl = 'https' + '://hb.sekindo.com/live/liveView.php'; - - return { - method: 'GET', - url: endpointUrl, - data: queryString, - }; - }); - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest) { - if (typeof serverResponse !== 'object') { - return []; - } - - let bidResponses = []; - var bidResponse = { - requestId: serverResponse.body.id, - bidderCode: spec.code, - cpm: serverResponse.body.cpm, - width: serverResponse.body.width, - height: serverResponse.body.height, - creativeId: serverResponse.body.creativeId, - currency: serverResponse.body.currency, - netRevenue: serverResponse.body.netRevenue, - ttl: serverResponse.body.ttl - }; - if (bidRequest.mediaType == 'video') { - if (typeof serverResponse.body.vastUrl != 'undefined') { - bidResponse.vastUrl = serverResponse.body.vastUrl; - } else { - bidResponse.vastXml = serverResponse.body.vastXml; - } - } else { - bidResponse.ad = serverResponse.body.ad; - } - - bidResponses.push(bidResponse); - return bidResponses; - } -} -registerBidder(spec); diff --git a/modules/sharedIdSystem.js b/modules/sharedIdSystem.js index defa8d22639..5bb20492758 100644 --- a/modules/sharedIdSystem.js +++ b/modules/sharedIdSystem.js @@ -1,280 +1,138 @@ /** - * This module adds Shared ID support to the User ID module - * The {@link module:modules/userId} module is required. + * This module adds SharedId to the User ID module + * The {@link module:modules/userId} module is required * @module modules/sharedIdSystem * @requires module:modules/userId */ -import * as utils from '../src/utils.js' -import {ajax} from '../src/ajax.js'; +import * as utils from '../src/utils.js'; import {submodule} from '../src/hook.js'; +import {ajax} from '../src/ajax.js'; import { uspDataHandler, coppaDataHandler } from '../src/adapterManager.js'; +import {getStorageManager} from '../src/storageManager.js'; -const MODULE_NAME = 'sharedId'; -const ID_SVC = 'https://id.sharedid.org/id'; -const DEFAULT_24_HOURS = 86400; -const OPT_OUT_VALUE = '00000000000000000000000000'; -// These values should NEVER change. If -// they do, we're no longer making ulids! -const ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'; // Crockford's Base32 -const ENCODING_LEN = ENCODING.length; -const TIME_MAX = Math.pow(2, 48) - 1; -const TIME_LEN = 10; -const RANDOM_LEN = 16; -const id = factory(); const GVLID = 887; -/** - * Constructs cookie value - * @param value - * @param needsSync - * @returns {string} - */ -function constructCookieValue(value, needsSync) { - const cookieValue = {}; - cookieValue.id = value; - cookieValue.ts = utils.timestamp(); - if (needsSync) { - cookieValue.ns = true; - } - utils.logInfo('SharedId: cookie Value: ' + JSON.stringify(cookieValue)); - return cookieValue; -} +const storage = getStorageManager(GVLID, 'pubCommonId'); +const COOKIE = 'cookie'; +const LOCAL_STORAGE = 'html5'; +const SHAREDID_OPT_OUT_VALUE = '00000000000000000000000000'; +const SHAREDID_URL = 'https://id.sharedid.org/id'; +const SHAREDID_SUFFIX = '_sharedid'; +const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT'; +const SHAREDID_DEFAULT_STATE = true; + +const PUB_COMMON_ID = 'PublisherCommonId'; /** - * Checks if id needs to be synced - * @param configParams - * @param storedId - * @returns {boolean} + * Store sharedid in either cookie or local storage + * @param {Object} config Need config.storage object to derive key, expiry time, and storage type. + * @param {string} value Shareid value to store */ -function isIdSynced(configParams, storedId) { - const needSync = storedId.ns; - if (needSync) { - return true; - } - if (!configParams || typeof configParams.syncTime !== 'number') { - utils.logInfo('SharedId: Sync time is not configured or is not a number'); - } - let syncTime = (!configParams || typeof configParams.syncTime !== 'number') ? DEFAULT_24_HOURS : configParams.syncTime; - if (syncTime > DEFAULT_24_HOURS) { - syncTime = DEFAULT_24_HOURS; - } - const cookieTimestamp = storedId.ts; - if (cookieTimestamp) { - var secondBetweenTwoDate = timeDifferenceInSeconds(utils.timestamp(), cookieTimestamp); - return secondBetweenTwoDate >= syncTime; + +function storeData(config, value) { + try { + if (value) { + const key = config.storage.name + SHAREDID_SUFFIX; + const expiresStr = (new Date(Date.now() + (storage.expires * (60 * 60 * 24 * 1000)))).toUTCString(); + + if (config.storage.type === COOKIE) { + if (storage.cookiesAreEnabled()) { + storage.setCookie(key, value, expiresStr, 'LAX', sharedIdSystemSubmodule.domainOverride()); + } + } else if (config.storage.type === LOCAL_STORAGE) { + if (storage.hasLocalStorage()) { + storage.setDataInLocalStorage(`${key}_exp`, expiresStr); + storage.setDataInLocalStorage(key, value); + } + } + } + } catch (error) { + utils.logError(error); } - return false; } /** - * Gets time difference in secounds - * @param date1 - * @param date2 - * @returns {number} + * Read sharedid from cookie or local storage + * @param config Need config.storage to derive key and storage type + * @return {string} */ -function timeDifferenceInSeconds(date1, date2) { - const diff = (date1 - date2) / 1000; - return Math.abs(Math.round(diff)); +function readData(config) { + try { + const key = config.storage.name + SHAREDID_SUFFIX; + if (config.storage.type === COOKIE) { + if (storage.cookiesAreEnabled()) { + return storage.getCookie(key); + } + } else if (config.storage.type === LOCAL_STORAGE) { + if (storage.hasLocalStorage()) { + const expValue = storage.getDataFromLocalStorage(`${key}_exp`); + if (!expValue) { + return storage.getDataFromLocalStorage(key); + } else if ((new Date(expValue)).getTime() - Date.now() > 0) { + return storage.getDataFromLocalStorage(key) + } + } + } + } catch (error) { + utils.logError(error); + } } /** - * id generation call back - * @param result - * @param callback - * @returns {{success: success, error: error}} + * Delete sharedid from cookie or local storage + * @param config Need config.storage to derive key and storage type */ -function idGenerationCallback(callback) { - return { - success: function (responseBody) { - let value = {}; - if (responseBody) { - try { - let responseObj = JSON.parse(responseBody); - utils.logInfo('SharedId: Generated SharedId: ' + responseObj.sharedId); - value = constructCookieValue(responseObj.sharedId, false); - } catch (error) { - utils.logError(error); - } +function delData(config) { + try { + const key = config.storage.name + SHAREDID_SUFFIX; + if (config.storage.type === COOKIE) { + if (storage.cookiesAreEnabled()) { + storage.setCookie(key, '', EXPIRED_COOKIE_DATE); } - callback(value); - }, - error: function (statusText, responseBody) { - const value = constructCookieValue(id(), true); - utils.logInfo('SharedId: Ulid Generated SharedId: ' + value.id); - callback(value); + } else if (config.storage.type === LOCAL_STORAGE) { + storage.removeDataFromLocalStorage(`${key}_exp`); + storage.removeDataFromLocalStorage(key); } + } catch (error) { + utils.logError(error); } } /** - * existing id generation call back - * @param result - * @param callback - * @returns {{success: success, error: error}} + * setup success and error handler for sharedid callback thru ajax + * @param {string} pubcid Current pubcommon id + * @param {function} callback userId module callback. + * @param {Object} config Need config.storage to derive sharedid storage params + * @return {{success: success, error: error}} */ -function existingIdCallback(storedId, callback) { + +function handleResponse(pubcid, callback, config) { return { success: function (responseBody) { - utils.logInfo('SharedId: id to be synced: ' + storedId.id); if (responseBody) { try { let responseObj = JSON.parse(responseBody); - storedId = constructCookieValue(responseObj.sharedId, false); - utils.logInfo('SharedId: Older SharedId: ' + storedId.id); + utils.logInfo('PubCommonId: Generated SharedId: ' + responseObj.sharedId); + if (responseObj.sharedId) { + if (responseObj.sharedId !== SHAREDID_OPT_OUT_VALUE) { + // Store sharedId locally + storeData(config, responseObj.sharedId); + } else { + // Delete local copy if the user has opted out + delData(config); + } + } + // Pass pubcid even though there is no change in order to trigger decode + callback(responseObj.sharedId); } catch (error) { utils.logError(error); } } - callback(storedId); }, - error: function () { - utils.logInfo('SharedId: Sync error for id : ' + storedId.id); - callback(storedId); - } - } -} - -/** - * Encode the id - * @param value - * @returns {string|*} - */ -function encodeId(value) { - const result = {}; - const sharedId = (value && typeof value['id'] === 'string') ? value['id'] : undefined; - if (sharedId == OPT_OUT_VALUE) { - return undefined; - } - if (sharedId) { - const bidIds = { - id: sharedId, - } - const ns = (value && typeof value['ns'] === 'boolean') ? value['ns'] : undefined; - if (ns == undefined) { - bidIds.third = sharedId; - } - result.sharedid = bidIds; - utils.logInfo('SharedId: Decoded value ' + JSON.stringify(result)); - return result; - } - return sharedId; -} - -/** - * the factory to generate unique identifier based on time and current pseudorandom number - * @param {string} the current pseudorandom number generator - * @returns {function(*=): *} - */ -function factory(currPrng) { - if (!currPrng) { - currPrng = detectPrng(); - } - return function ulid(seedTime) { - if (isNaN(seedTime)) { - seedTime = Date.now(); + error: function (statusText, responseBody) { + utils.logInfo('PubCommonId: failed to get sharedid'); } - return encodeTime(seedTime, TIME_LEN) + encodeRandom(RANDOM_LEN, currPrng); - }; -} - -/** - * creates and logs the error message - * @function - * @param {string} error message - * @returns {Error} - */ -function createError(message) { - utils.logError(message); - const err = new Error(message); - err.source = 'sharedId'; - return err; -} - -/** - * gets a a random charcter from generated pseudorandom number - * @param {string} the generated pseudorandom number - * @returns {string} - */ -function randomChar(prng) { - let rand = Math.floor(prng() * ENCODING_LEN); - if (rand === ENCODING_LEN) { - rand = ENCODING_LEN - 1; - } - return ENCODING.charAt(rand); -} - -/** - * encodes the time based on the length - * @param now - * @param len - * @returns {string} encoded time. - */ -function encodeTime (now, len) { - if (isNaN(now)) { - throw new Error(now + ' must be a number'); - } - - if (Number.isInteger(now) === false) { - throw createError('time must be an integer'); - } - - if (now > TIME_MAX) { - throw createError('cannot encode time greater than ' + TIME_MAX); - } - if (now < 0) { - throw createError('time must be positive'); - } - - if (Number.isInteger(len) === false) { - throw createError('length must be an integer'); - } - if (len < 0) { - throw createError('length must be positive'); } - - let mod; - let str = ''; - for (; len > 0; len--) { - mod = now % ENCODING_LEN; - str = ENCODING.charAt(mod) + str; - now = (now - mod) / ENCODING_LEN; - } - return str; -} - -/** - * encodes random character - * @param len - * @param prng - * @returns {string} - */ -function encodeRandom (len, prng) { - let str = ''; - for (; len > 0; len--) { - str = randomChar(prng) + str; - } - return str; -} - -/** - * detects the pseudorandom number generator and generates the random number - * @function - * @param {string} error message - * @returns {string} a random number - */ -function detectPrng(root) { - if (!root) { - root = typeof window !== 'undefined' ? window : null; - } - const browserCrypto = root && (root.crypto || root.msCrypto); - if (browserCrypto) { - return () => { - const buffer = new Uint8Array(1); - browserCrypto.getRandomValues(buffer); - return buffer[0] / 0xff; - }; - } - return () => Math.random(); } /** @@ -284,90 +142,195 @@ function detectPrng(root) { */ function sharedIdUrl(consentData) { const usPrivacyString = uspDataHandler.getConsentData(); - let sharedIdUrl = ID_SVC; - if (usPrivacyString) { - sharedIdUrl = `${ID_SVC}?us_privacy=${usPrivacyString}`; + let sharedIdUrl = SHAREDID_URL; + if (usPrivacyString && typeof usPrivacyString === 'string') { + sharedIdUrl = `${SHAREDID_URL}?us_privacy=${usPrivacyString}`; } if (!consentData || typeof consentData.gdprApplies !== 'boolean' || !consentData.gdprApplies) return sharedIdUrl; if (usPrivacyString) { sharedIdUrl = `${sharedIdUrl}&gdpr=1&gdpr_consent=${consentData.consentString}` return sharedIdUrl; } - sharedIdUrl = `${ID_SVC}?gdpr=1&gdpr_consent=${consentData.consentString}`; + sharedIdUrl = `${SHAREDID_URL}?gdpr=1&gdpr_consent=${consentData.consentString}`; return sharedIdUrl } -/** @type {Submodule} */ -export const sharedIdSubmodule = { +/** + * Wraps pixelCallback in order to call sharedid sync + * @param {string} pubcid Pubcommon id value + * @param {function|undefined} pixelCallback fires a pixel to first party server + * @param {Object} config Need config.storage to derive sharedid storage params. + * @return {function(...[*]=)} + */ + +function getIdCallback(pubcid, pixelCallback, config, consentData) { + return function (callback) { + if (typeof pixelCallback === 'function') { + pixelCallback(); + } + ajax(sharedIdUrl(consentData), handleResponse(pubcid, callback, config), undefined, {method: 'GET', withCredentials: true}); + } +} +export const sharedIdSystemSubmodule = { /** * used to link submodule with config * @type {string} */ - name: MODULE_NAME, - + name: 'sharedId', + aliasName: 'pubCommonId', /** - * Vendor id of Prebid + * Vendor id of prebid * @type {Number} */ gvlid: GVLID, + makeCallback: function (pixelUrl, id = '') { + if (!pixelUrl) { + return; + } + + // Use pubcid as a cache buster + const urlInfo = utils.parseUrl(pixelUrl); + urlInfo.search.id = encodeURIComponent('pubcid:' + id); + const targetUrl = utils.buildUrl(urlInfo); + + return function () { + utils.triggerPixel(targetUrl); + }; + }, /** * decode the stored id value for passing to bid requests * @function * @param {string} value - * @returns {{sharedid:{ id: string, third:string}} or undefined if value doesn't exists + * @param {SubmoduleConfig} config + * @returns {{pubcid:string}} */ - decode(value) { - return (value) ? encodeId(value) : undefined; - }, + decode(value, config) { + const idObj = {'pubcid': value}; + const {params: {enableSharedId = SHAREDID_DEFAULT_STATE} = {}} = config; + + if (enableSharedId) { + const sharedId = readData(config); + if (sharedId) idObj['sharedid'] = {id: sharedId}; + } + return idObj; + }, /** - * performs action to obtain id and return a value. + * performs action to obtain id * @function - * @param {SubmoduleConfig} [config] - * @param {ConsentData|undefined} consentData - * @returns {sharedId} + * @param {SubmoduleConfig} [config] Config object with params and storage properties + * @param {Object} consentData + * @param {string} storedId Existing pubcommon id + * @returns {IdResponse} */ - getId(config, consentData) { + getId: function (config = {}, consentData, storedId) { const coppa = coppaDataHandler.getCoppa(); if (coppa) { - utils.logInfo('SharedId: IDs not provided for coppa requests, exiting SharedId'); + utils.logInfo('PubCommonId: IDs not provided for coppa requests, exiting PubCommonId'); return; } - const resp = function (callback) { - utils.logInfo('SharedId: Sharedid doesnt exists, new cookie creation'); - ajax(sharedIdUrl(consentData), idGenerationCallback(callback), undefined, {method: 'GET', withCredentials: true}); - }; - return {callback: resp}; - }, + const {params: {create = true, pixelUrl, enableSharedId = SHAREDID_DEFAULT_STATE} = {}} = config; + let newId = storedId; + if (!newId) { + try { + if (typeof window[PUB_COMMON_ID] === 'object') { + // If the page includes its own pubcid module, then save a copy of id. + newId = window[PUB_COMMON_ID].getId(); + } + } catch (e) { + } + + if (!newId) newId = (create && utils.hasDeviceAccess()) ? utils.generateUUID() : undefined; + } + + const pixelCallback = this.makeCallback(pixelUrl, newId); + const combinedCallback = enableSharedId ? getIdCallback(newId, pixelCallback, config, consentData) : pixelCallback; + return {id: newId, callback: combinedCallback}; + }, /** - * performs actions even if the id exists and returns a value - * @param config - * @param consentData - * @param storedId - * @returns {{callback: *}} + * performs action to extend an id. There are generally two ways to extend the expiration time + * of stored id: using pixelUrl or return the id and let main user id module write it again with + * the new expiration time. + * + * PixelUrl, if defined, should point back to a first party domain endpoint. On the server + * side, there is either a plugin, or customized logic to read and write back the pubcid cookie. + * The extendId function itself should return only the callback, and not the id itself to avoid + * having the script-side overwriting server-side. This applies to both pubcid and sharedid. + * + * On the other hand, if there is no pixelUrl, then the extendId should return storedId so that + * its expiration time is updated. Sharedid, however, will have to be updated by this submodule + * separately. + * + * @function + * @param {SubmoduleParams} [config] + * @param {ConsentData|undefined} consentData + * @param {Object} storedId existing id + * @returns {IdResponse|undefined} */ - extendId(config, consentData, storedId) { + extendId: function(config = {}, consentData, storedId) { const coppa = coppaDataHandler.getCoppa(); if (coppa) { - utils.logInfo('SharedId: IDs not provided for coppa requests, exiting SharedId'); + utils.logInfo('PubCommonId: IDs not provided for coppa requests, exiting PubCommonId'); return; } - const configParams = (config && config.params) || {}; - utils.logInfo('SharedId: Existing shared id ' + storedId.id); - const resp = function (callback) { - const needSync = isIdSynced(configParams, storedId); - if (needSync) { - utils.logInfo('SharedId: Existing shared id ' + storedId + ' is not synced'); - const sharedIdPayload = {}; - sharedIdPayload.sharedId = storedId.id; - const payloadString = JSON.stringify(sharedIdPayload); - ajax(sharedIdUrl(consentData), existingIdCallback(storedId, callback), payloadString, {method: 'POST', withCredentials: true}); + const {params: {extend = false, pixelUrl, enableSharedId = SHAREDID_DEFAULT_STATE} = {}} = config; + + if (extend) { + try { + if (typeof window[PUB_COMMON_ID] === 'object') { + if (enableSharedId) { + // If the page includes its own pubcid module, then there is nothing to do + // except to update sharedid's expiration time + storeData(config, readData(config)); + } + return; + } + } catch (e) { + } + + if (pixelUrl) { + const callback = this.makeCallback(pixelUrl, storedId); + return {callback: callback}; + } else { + if (enableSharedId) { + // Update with the same value to extend expiration time + storeData(config, readData(config)); + } + return {id: storedId}; + } + } + }, + + /** + * @param {string} domain + * @param {HTMLDocument} document + * @return {(string|undefined)} + */ + domainOverride: function () { + const domainElements = document.domain.split('.'); + const cookieName = `_gd${Date.now()}`; + for (let i = 0, topDomain, testCookie; i < domainElements.length; i++) { + const nextDomain = domainElements.slice(i).join('.'); + + // write test cookie + storage.setCookie(cookieName, '1', undefined, undefined, nextDomain); + + // read test cookie to verify domain was valid + testCookie = storage.getCookie(cookieName); + + // delete test cookie + storage.setCookie(cookieName, '', 'Thu, 01 Jan 1970 00:00:01 GMT', undefined, nextDomain); + + if (testCookie === '1') { + // cookie was written successfully using test domain so the topDomain is updated + topDomain = nextDomain; + } else { + // cookie failed to write using test domain so exit by returning the topDomain + return topDomain; } - }; - return {callback: resp}; + } } }; -// Register submodule for userId -submodule('userId', sharedIdSubmodule); +submodule('userId', sharedIdSystemSubmodule); diff --git a/modules/sharedIdSystem.md b/modules/sharedIdSystem.md deleted file mode 100644 index a4541c16c49..00000000000 --- a/modules/sharedIdSystem.md +++ /dev/null @@ -1,43 +0,0 @@ -## Shared ID User ID Submodule - -Shared ID User ID Module generates a UUID that can be utilized to improve user matching.This module enables timely synchronization which handles sharedId.org optout. This module does not require any registration. - -### Building Prebid with Shared Id Support -Your Prebid build must include the modules for both **userId** and **sharedId** submodule. Follow the build instructions for Prebid as -explained in the top level README.md file of the Prebid source tree. - -ex: $ gulp build --modules=userId,sharedIdSystem - -### Prebid Params - -Individual params may be set for the Shared ID User ID Submodule. -``` -pbjs.setConfig({ - userSync: { - userIds: [{ - name: 'sharedId', - params: { - syncTime: 60 // in seconds, default is 24 hours - }, - storage: { - name: 'sharedid', - type: 'cookie', - expires: 28 - }, - }] - } -}); -``` - -### Parameter Descriptions for the `usersync` Configuration Section -The below parameters apply only to the Shared ID User ID Module integration. - -| Params under usersync.userIds[]| Scope | Type | Description | Example | -| --- | --- | --- | --- | --- | -| name | Required | String | ID value for the Shared ID module - `"sharedId"` | `"sharedId"` | -| params | Optional | Object | Details for sharedId syncing. | | -| params.syncTime | Optional | Object | Configuration to define the frequency(in seconds) of id synchronization. By default id is synchronized every 24 hours | 60 | -| storage | Required | Object | The publisher must specify the local storage in which to store the results of the call to get the user ID. This can be either cookie or HTML5 storage. | | -| storage.type | Required | String | This is where the results of the user ID will be stored. The recommended method is `localStorage` by specifying `html5`. | `"html5"` | -| storage.name | Required | String | The name of the cookie or html5 local storage where the user ID will be stored. | `"sharedid"` | -| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. | `28` | diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index 59cf2a3a035..eea42af4a4c 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -166,9 +166,6 @@ function handleUniversalIds(bidRequest) { const lipb = utils.deepAccess(bidRequest, 'userId.lipb.lipbid'); if (lipb) universalIds.liuid = lipb; - const shd = utils.deepAccess(bidRequest, 'userId.sharedid'); - if (shd) universalIds.shduid = shd; // object with keys: id & third - return universalIds; } 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 = '`; - break; - } - }); - } - 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); -} - -function getNativeAssets(bid) { - return utils._map(bid.nativeParams, (bidParams, key) => { - const props = NATIVE_PARAMS[key]; - const asset = { - required: bidParams.required & 1, - }; - if (props) { - asset.id = props.id; - let wmin, hmin, w, h; - 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); - w = sizes[0]; - h = sizes[1]; - } - - asset[props.name] = { - len: bidParams.len, - type: props.type, - wmin, - hmin, - w, - h - }; - - return asset; - } - }).filter(Boolean); -} - -/* Turn bid request sizes into ut-compatible format */ -function transformSizes(requestSizes) { - if (!utils.isArray(requestSizes)) { - return []; - } - - if (requestSizes.length === 2 && !utils.isArray(requestSizes[0])) { - return [{ - w: parseInt(requestSizes[0], 10), - h: parseInt(requestSizes[1], 10) - }]; - } else if (utils.isArray(requestSizes[0])) { - return requestSizes.map(item => - ({ - w: parseInt(item[0], 10), - h: parseInt(item[1], 10) - }) - ); - } - - return []; -} diff --git a/modules/zemantaBidAdapter.md b/modules/zemantaBidAdapter.md deleted file mode 100644 index fa933ecd922..00000000000 --- a/modules/zemantaBidAdapter.md +++ /dev/null @@ -1,111 +0,0 @@ -# Overview - -``` -Module Name: Zemanta Adapter -Module Type: Bidder Adapter -Maintainer: prog-ops-team@outbrain.com -``` - -# Description - -Module that connects to zemanta bidder to fetch bids. -Both native and display formats are supported but not at the same time. Using OpenRTB standard. - -# Configuration - -## Bidder and usersync URLs - -The Zemanta adapter does not work without setting the correct bidder and usersync URLs. -You will receive the URLs when contacting us. - -``` -pbjs.setConfig({ - zemanta: { - bidderUrl: 'https://bidder-url.com', - usersyncUrl: 'https://usersync-url.com' - } -}); -``` - - -# Test Native Parameters -``` - var adUnits = [ - code: '/19968336/prebid_native_example_1', - mediaTypes: { - native: { - image: { - required: false, - sizes: [100, 50] - }, - title: { - required: false, - len: 140 - }, - sponsoredBy: { - required: false - }, - clickUrl: { - required: false - }, - body: { - required: false - }, - icon: { - required: false, - sizes: [50, 50] - } - } - }, - bids: [{ - bidder: 'zemanta', - params: { - publisher: { - id: '2706', // required - name: 'Publishers Name', - domain: 'publisher.com' - }, - tagid: 'tag-id', - bcat: ['IAB1-1'], - badv: ['example.com'] - } - }] - ]; - - pbjs.setConfig({ - zemanta: { - bidderUrl: 'https://prebidtest.zemanta.com/api/bidder/prebidtest/bid/' - } - }); -``` - -# Test Display Parameters -``` - var adUnits = [ - code: '/19968336/prebid_display_example_1', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - bids: [{ - bidder: 'zemanta', - params: { - publisher: { - id: '2706', // required - name: 'Publishers Name', - domain: 'publisher.com' - }, - tagid: 'tag-id', - bcat: ['IAB1-1'], - badv: ['example.com'] - }, - }] - ]; - - pbjs.setConfig({ - zemanta: { - bidderUrl: 'https://prebidtest.zemanta.com/api/bidder/prebidtest/bid/' - } - }); -``` diff --git a/src/constants.json b/src/constants.json index c43e88cf75f..c6fad4df3c6 100644 --- a/src/constants.json +++ b/src/constants.json @@ -79,10 +79,8 @@ "PRICE_BUCKET": "hb_pb", "SIZE": "hb_size", "DEAL": "hb_deal", - "SOURCE": "hb_source", "FORMAT": "hb_format", "UUID": "hb_uuid", - "CACHE_ID": "hb_cache_id", "CACHE_HOST": "hb_cache_host" }, "NATIVE_KEYS": { diff --git a/src/prebid.js b/src/prebid.js index f58c97ec581..7cdaa709d20 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -140,6 +140,20 @@ function validateNativeMediaType(adUnit) { return validatedAdUnit; } +function validateAdUnitPos(adUnit, mediaType) { + let pos = utils.deepAccess(adUnit, `mediaTypes.${mediaType}.pos`); + + if (!pos || !utils.isNumber(pos) || !isFinite(pos)) { + let warning = `Value of property 'pos' on ad unit ${adUnit.code} should be of type: Number`; + + utils.logWarn(warning); + events.emit(CONSTANTS.EVENTS.AUCTION_DEBUG, {type: 'WARNING', arguments: warning}); + delete adUnit.mediaTypes[mediaType].pos; + } + + return adUnit +} + export const adUnitSetupChecks = { validateBannerMediaType, validateVideoMediaType, @@ -167,10 +181,12 @@ export const checkAdUnitSetup = hook('sync', function (adUnits) { if (mediaTypes.banner) { validatedBanner = validateBannerMediaType(adUnit); + if (mediaTypes.banner.hasOwnProperty('pos')) validatedBanner = validateAdUnitPos(validatedBanner, 'banner'); } if (mediaTypes.video) { validatedVideo = validatedBanner ? validateVideoMediaType(validatedBanner) : validateVideoMediaType(adUnit); + if (mediaTypes.video.hasOwnProperty('pos')) validatedVideo = validateAdUnitPos(validatedVideo, 'video'); } if (mediaTypes.native) { diff --git a/src/refererDetection.js b/src/refererDetection.js index 56d1fa43f7b..7e9f2a7e6c7 100644 --- a/src/refererDetection.js +++ b/src/refererDetection.js @@ -42,6 +42,10 @@ export function detectReferer(win) { * @returns {string|null} */ function getCanonicalUrl(doc) { + let pageURL = config.getConfig('pageUrl'); + + if (pageURL) return pageURL; + try { const element = doc.querySelector("link[rel='canonical']"); diff --git a/src/sizeMapping.js b/src/sizeMapping.js index 313da3f422a..cd5f1190069 100644 --- a/src/sizeMapping.js +++ b/src/sizeMapping.js @@ -121,22 +121,17 @@ function evaluateSizeConfig(configs) { return configs.reduce((results, config) => { if ( typeof config === 'object' && - typeof config.mediaQuery === 'string' + typeof config.mediaQuery === 'string' && + config.mediaQuery.length > 0 ) { let ruleMatch = false; - // TODO: (Prebid - 4.0) Remove empty mediaQuery string check. Disallow empty mediaQuery in sizeConfig. - // Refer: https://github.com/prebid/Prebid.js/pull/4691, https://github.com/prebid/Prebid.js/issues/4810 for more details. - if (config.mediaQuery === '') { - ruleMatch = true; - } else { - try { - ruleMatch = getWindowTop().matchMedia(config.mediaQuery).matches; - } catch (e) { - logWarn('Unfriendly iFrame blocks sizeConfig from being correctly evaluated'); - - ruleMatch = matchMedia(config.mediaQuery).matches; - } + try { + ruleMatch = getWindowTop().matchMedia(config.mediaQuery).matches; + } catch (e) { + logWarn('Unfriendly iFrame blocks sizeConfig from being correctly evaluated'); + + ruleMatch = matchMedia(config.mediaQuery).matches; } if (ruleMatch) { diff --git a/test/spec/modules/1ad4goodBidAdapter_spec.js b/test/spec/modules/1ad4goodBidAdapter_spec.js deleted file mode 100644 index b9cd86a4cf7..00000000000 --- a/test/spec/modules/1ad4goodBidAdapter_spec.js +++ /dev/null @@ -1,548 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/1ad4goodBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import * as bidderFactory from 'src/adapters/bidderFactory.js'; -import { deepClone } from 'src/utils.js'; -import { config } from 'src/config.js'; - -const ENDPOINT = 'https://hb.1ad4good.org/prebid'; - -describe('AdforgoodAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': '1ad4good', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': '1ad4good', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should parse out private sizes', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - privateSizes: [300, 250] - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].private_sizes).to.exist; - expect(payload.tags[0].private_sizes).to.deep.equal([{width: 300, height: 250}]); - }); - - it('should add source and verison to the tag', function () { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.sdk).to.exist; - expect(payload.sdk).to.deep.equal({ - source: 'pbjs', - version: '$prebid.version$' - }); - }); - - it('should populate the ad_types array on all requests', function () { - ['banner', 'video'].forEach(type => { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes[type] = {}; - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].ad_types).to.deep.equal([type]); - }); - }); - - it('should populate the ad_types array on outstream requests', function () { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes.video = {context: 'outstream'}; - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].ad_types).to.deep.equal(['video']); - }); - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('POST'); - }); - - it('should attach valid video params to the tag', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - video: { - id: 123, - minduration: 100, - foobar: 'invalid' - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.tags[0].video).to.deep.equal({ - id: 123, - minduration: 100 - }); - }); - - it('should add video property when adUnit includes a renderer', function () { - const videoData = { - mediaTypes: { - video: { - context: 'outstream', - mimes: ['video/mp4'] - } - }, - params: { - placementId: '10433394', - video: { - skippable: true, - playback_method: ['auto_play_sound_off'] - } - } - }; - - let bidRequest1 = deepClone(bidRequests[0]); - bidRequest1 = Object.assign({}, bidRequest1, videoData, { - renderer: { - url: 'http://test.renderer.url', - render: function () {} - } - }); - - let bidRequest2 = deepClone(bidRequests[0]); - bidRequest2.adUnitCode = 'adUnit_code_2'; - bidRequest2 = Object.assign({}, bidRequest2, videoData); - - const request = spec.buildRequests([bidRequest1, bidRequest2]); - const payload = JSON.parse(request.data); - expect(payload.tags[0].video).to.deep.equal({ - skippable: true, - playback_method: ['auto_play_sound_off'], - custom_renderer_present: true - }); - expect(payload.tags[1].video).to.deep.equal({ - skippable: true, - playback_method: ['auto_play_sound_off'] - }); - }); - - it('should attach valid user params to the tag', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - user: { - externalUid: '123', - foobar: 'invalid' - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.user).to.exist; - expect(payload.user).to.deep.equal({ - externalUid: '123', - }); - }); - - // it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () { - // let bidRequest = Object.assign({}, - // bidRequests[0], - // { - // mediaType: 'native', - // nativeParams: { - // image: { required: true } - // } - // } - // ); - // bidRequest.sizes = [[150, 100], [300, 250]]; - - // let request = spec.buildRequests([bidRequest]); - // let payload = JSON.parse(request.data); - // expect(payload.tags[0].sizes).to.deep.equal([{width: 150, height: 100}, {width: 300, height: 250}]); - - // delete bidRequest.sizes; - - // request = spec.buildRequests([bidRequest]); - // payload = JSON.parse(request.data); - - // expect(payload.tags[0].sizes).to.deep.equal([{width: 1, height: 1}]); - // }); - - it('should convert keyword params to proper form and attaches to request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - keywords: { - single: 'val', - singleArr: ['val'], - singleArrNum: [5], - multiValMixed: ['value1', 2, 'value3'], - singleValNum: 123, - emptyStr: '', - emptyArr: [''], - badValue: {'foo': 'bar'} // should be dropped - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].keywords).to.deep.equal([{ - 'key': 'single', - 'value': ['val'] - }, { - 'key': 'singleArr', - 'value': ['val'] - }, { - 'key': 'singleArrNum', - 'value': ['5'] - }, { - 'key': 'multiValMixed', - 'value': ['value1', '2', 'value3'] - }, { - 'key': 'singleValNum', - 'value': ['123'] - }, { - 'key': 'emptyStr' - }, { - 'key': 'emptyArr' - }]); - }); - - it('should add payment rules to the request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - usePaymentRule: true - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].use_pmt_rule).to.equal(true); - }); - - it('should add gdpr consent information to the request', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let bidderRequest = { - 'bidderCode': '1ad4good', - 'auctionId': '1d1a030790a475', - 'bidderRequestId': '22edbae2733bf6', - 'timeout': 3000, - 'gdprConsent': { - consentString: consentString, - gdprApplies: true - } - }; - bidderRequest.bids = bidRequests; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.gdpr_consent).to.exist; - expect(payload.gdpr_consent.consent_string).to.exist.and.to.equal(consentString); - expect(payload.gdpr_consent.consent_required).to.exist.and.to.be.true; - }); - - it('supports sending hybrid mobile app parameters', function () { - let appRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - app: { - id: 'B1O2W3M4AN.com.prebid.webview', - geo: { - lat: 40.0964439, - lng: -75.3009142 - }, - device_id: { - idfa: '4D12078D-3246-4DA4-AD5E-7610481E7AE', // Apple advertising identifier - aaid: '38400000-8cf0-11bd-b23e-10b96e40000d', // Android advertising identifier - md5udid: '5756ae9022b2ea1e47d84fead75220c8', // MD5 hash of the ANDROID_ID - sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF', // SHA1 hash of the ANDROID_ID - windowsadid: '750c6be243f1c4b5c9912b95a5742fc5' // Windows advertising identifier - } - } - } - } - ); - const request = spec.buildRequests([appRequest]); - const payload = JSON.parse(request.data); - expect(payload.app).to.exist; - expect(payload.app).to.deep.equal({ - appid: 'B1O2W3M4AN.com.prebid.webview' - }); - expect(payload.device.device_id).to.exist; - expect(payload.device.device_id).to.deep.equal({ - aaid: '38400000-8cf0-11bd-b23e-10b96e40000d', - idfa: '4D12078D-3246-4DA4-AD5E-7610481E7AE', - md5udid: '5756ae9022b2ea1e47d84fead75220c8', - sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF', - windowsadid: '750c6be243f1c4b5c9912b95a5742fc5' - }); - expect(payload.device.geo).to.exist; - expect(payload.device.geo).to.deep.equal({ - lat: 40.0964439, - lng: -75.3009142 - }); - }); - - it('should add referer info to payload', function () { - const bidRequest = Object.assign({}, bidRequests[0]) - const bidderRequest = { - refererInfo: { - referer: 'http://example.com/page.html', - reachedTop: true, - numIframes: 2, - stack: [ - 'http://example.com/page.html', - 'http://example.com/iframe1.html', - 'http://example.com/iframe2.html' - ] - } - } - const request = spec.buildRequests([bidRequest], bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.referrer_detection).to.exist; - expect(payload.referrer_detection).to.deep.equal({ - rd_ref: 'http%3A%2F%2Fexample.com%2Fpage.html', - rd_top: true, - rd_ifs: 2, - rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') - }); - }); - }) - - describe('interpretResponse', function () { - let bfStub; - before(function() { - bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); - }); - - after(function() { - bfStub.restore(); - }); - - let response = { - 'version': '3.0.0', - 'tags': [ - { - 'uuid': '3db3773286ee59', - 'tag_id': 10433394, - 'auction_id': '4534722592064951574', - 'nobid': false, - 'no_ad_url': 'http://lax1-ib.adnxs.com/no-ad', - 'timeout_ms': 10000, - 'ad_profile_id': 27079, - 'ads': [ - { - 'content_source': 'rtb', - 'ad_type': 'banner', - 'buyer_member_id': 958, - 'creative_id': 29681110, - 'media_type_id': 1, - 'media_subtype_id': 1, - 'cpm': 0.5, - 'cpm_publisher_currency': 0.5, - 'publisher_currency_code': '$', - 'client_initiated_ad_counting': true, - 'viewability': { - 'config': '' - }, - 'rtb': { - 'banner': { - 'content': '', - 'width': 300, - 'height': 250 - }, - 'trackers': [ - { - 'impression_urls': [ - 'http://lax1-ib.adnxs.com/impression' - ], - 'video_events': {} - } - ] - } - } - ] - } - ] - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '3db3773286ee59', - 'cpm': 0.5, - 'creativeId': 29681110, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '', - 'mediaType': 'banner', - 'currency': 'USD', - 'ttl': 300, - 'netRevenue': true, - 'adUnitCode': 'code', - 'ads4good': { - 'buyerMemberId': 958 - } - } - ]; - let bidderRequest = { - bids: [{ - bidId: '3db3773286ee59', - adUnitCode: 'code' - }] - } - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - let response = { - 'version': '0.0.1', - 'tags': [{ - 'uuid': '84ab500420319d', - 'tag_id': 5976557, - 'auction_id': '297492697822162468', - 'nobid': true - }] - }; - let bidderRequest; - - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result.length).to.equal(0); - }); - - it('handles non-banner media responses', function () { - let response = { - 'tags': [{ - 'uuid': '84ab500420319d', - 'ads': [{ - 'ad_type': 'video', - 'cpm': 0.500000, - 'notify_url': 'imptracker.com', - 'rtb': { - 'video': { - 'content': '' - } - }, - 'javascriptTrackers': '' - }] - }] - }; - let bidderRequest = { - bids: [{ - bidId: '84ab500420319d', - adUnitCode: 'code' - }] - } - - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result[0]).to.have.property('vastUrl'); - expect(result[0]).to.have.property('vastImpUrl'); - expect(result[0]).to.have.property('mediaType', 'video'); - }); - - it('should add deal_priority and deal_code', function() { - let responseWithDeal = deepClone(response); - responseWithDeal.tags[0].ads[0].deal_priority = 'high'; - responseWithDeal.tags[0].ads[0].deal_code = '123'; - - let bidderRequest = { - bids: [{ - bidId: '3db3773286ee59', - adUnitCode: 'code' - }] - } - let result = spec.interpretResponse({ body: responseWithDeal }, {bidderRequest}); - expect(Object.keys(result[0].ads4good)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']); - }); - - it('should add advertiser id', function() { - let responseAdvertiserId = deepClone(response); - responseAdvertiserId.tags[0].ads[0].advertiser_id = '123'; - - let bidderRequest = { - bids: [{ - bidId: '3db3773286ee59', - adUnitCode: 'code' - }] - } - let result = spec.interpretResponse({ body: responseAdvertiserId }, {bidderRequest}); - expect(Object.keys(result[0].meta)).to.include.members(['advertiserId']); - }) - }); -}); diff --git a/test/spec/modules/7xbidBidAdapter_spec.js b/test/spec/modules/7xbidBidAdapter_spec.js deleted file mode 100644 index bed2c604349..00000000000 --- a/test/spec/modules/7xbidBidAdapter_spec.js +++ /dev/null @@ -1,160 +0,0 @@ -import {expect} from 'chai'; -import {spec, _getUrlVars} from 'modules/7xbidBidAdapter.js'; -import * as utils from 'src/utils.js'; - -const BASE_URI = '//bidder.7xbid.com/api/v1/prebid/banner' -const NATIVE_BASE_URI = '//bidder.7xbid.com/api/v1/prebid/native' - -describe('7xbid adapter', function() { - let bidRequests; - let nativeBidRequests; - - beforeEach(function() { - bidRequests = [ - { - bidder: '7xbid', - params: { - placementId: 1425292, - currency: 'USD' - } - } - ] - - nativeBidRequests = [ - { - bidder: '7xbid', - params: { - placementId: 1429695, - currency: 'USD' - }, - nativeParams: { - title: { - required: true, - len: 80 - }, - image: { - required: true, - sizes: [150, 50] - }, - sponsoredBy: { - required: true - } - } - } - ] - }) - describe('isBidRequestValid', function () { - it('valid bid case', function () { - let validBid = { - bidder: '7xbid', - params: { - placementId: 1425292, - currency: 'USD' - } - } - let isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - }); - - it('invalid bid case: placementId is not passed', function() { - let validBid = { - bidder: '7xbid', - params: { - } - } - let isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }) - - it('invalid bid case: currency is not support', function() { - let validBid = { - bidder: '7xbid', - params: { - placementId: 1108295, - currency: 'AUD' - } - } - let isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }) - }) - - describe('buildRequests', function () { - it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(BASE_URI); - expect(request.method).to.equal('GET'); - }); - - it('sends native bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(nativeBidRequests)[0]; - expect(request.url).to.equal(NATIVE_BASE_URI); - expect(request.method).to.equal('GET'); - }); - - it('buildRequests function should not modify original bidRequests object', function () { - let originalBidRequests = utils.deepClone(bidRequests); - let request = spec.buildRequests(bidRequests); - expect(bidRequests).to.deep.equal(originalBidRequests); - }); - - it('buildRequests function should not modify original nativeBidRequests object', function () { - let originalBidRequests = utils.deepClone(nativeBidRequests); - let request = spec.buildRequests(nativeBidRequests); - expect(nativeBidRequests).to.deep.equal(originalBidRequests); - }); - - it('Request params check', function() { - let request = spec.buildRequests(bidRequests)[0]; - const data = _getUrlVars(request.data) - expect(parseInt(data.placementid)).to.exist.and.to.equal(bidRequests[0].params.placementId); - expect(data.cur).to.exist.and.to.equal(bidRequests[0].params.currency); - }) - - it('Native request params check', function() { - let request = spec.buildRequests(nativeBidRequests)[0]; - const data = _getUrlVars(request.data) - expect(parseInt(data.placementid)).to.exist.and.to.equal(nativeBidRequests[0].params.placementId); - expect(data.cur).to.exist.and.to.equal(nativeBidRequests[0].params.currency); - }) - }) - - describe('interpretResponse', function () { - let response = { - 1425292: - { - 'creativeId': '', - 'cur': 'USD', - 'price': 0.0920, - 'width': 300, - 'height': 250, - 'requestid': '2e42361a6172bf', - 'adm': '' - } - } - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '2e42361a6172bf', - 'cpm': 0.0920, - 'width': 300, - 'height': 250, - 'netRevenue': true, - 'currency': 'USD', - 'creativeId': '', - 'ttl': 700, - 'ad': '' - } - ]; - let request = spec.buildRequests(bidRequests)[0]; - let result = spec.interpretResponse({body: response}, request); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - expect(result[0].cpm).to.not.equal(null); - expect(result[0].creativeId).to.not.equal(null); - expect(result[0].ad).to.not.equal(null); - expect(result[0].currency).to.equal('USD'); - expect(result[0].netRevenue).to.equal(true); - }); - }) -}) diff --git a/test/spec/modules/aardvarkBidAdapter_spec.js b/test/spec/modules/aardvarkBidAdapter_spec.js deleted file mode 100644 index 9671f961407..00000000000 --- a/test/spec/modules/aardvarkBidAdapter_spec.js +++ /dev/null @@ -1,569 +0,0 @@ -import { expect } from 'chai'; -import * as utils from 'src/utils.js'; -import { spec, resetUserSync } from 'modules/aardvarkBidAdapter.js'; - -describe('aardvarkAdapterTest', function () { - describe('forming valid bidRequests', function () { - it('should accept valid bidRequests', function () { - expect(spec.isBidRequestValid({ - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'TdAx', - }, - sizes: [[300, 250]] - })).to.equal(true); - }); - - it('should reject invalid bidRequests', function () { - expect(spec.isBidRequestValid({ - bidder: 'aardvark', - params: { - ai: 'xiby', - }, - sizes: [[300, 250]] - })).to.equal(false); - }); - }); - - describe('executing network requests', function () { - const bidRequests = [{ - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'TdAx', - }, - adUnitCode: 'aaa', - transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', - sizes: [300, 250], - bidId: '1abgs362e0x48a8', - bidderRequestId: '70deaff71c281d', - auctionId: '5c66da22-426a-4bac-b153-77360bef5337', - userId: { tdid: 'eff98622-b5fd-44fa-9a49-6e846922d532' } - }, - { - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'RAZd', - host: 'adzone.pub.com' - }, - adUnitCode: 'bbb', - transactionId: '193995b4-7122-4739-959b-2463282a138b', - sizes: [[800, 600]], - bidId: '22aidtbx5eabd9', - bidderRequestId: '70deaff71c281d', - auctionId: 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a' - }]; - - const bidderRequest = { - refererInfo: { - referer: 'https://example.com' - } - }; - - it('should use HTTP GET method', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - requests.forEach(function (requestItem) { - expect(requestItem.method).to.equal('GET'); - }); - }); - - it('should call the correct bidRequest url', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.match(new RegExp('^https:\/\/adzone.pub.com/xiby/TdAx_RAZd/aardvark\?')); - }); - - it('should have correct data', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests.length).to.equal(1); - expect(requests[0].data.version).to.equal(1); - expect(requests[0].data.jsonp).to.equal(false); - expect(requests[0].data.TdAx).to.equal('1abgs362e0x48a8'); - expect(requests[0].data.rtkreferer).to.not.be.undefined; - expect(requests[0].data.RAZd).to.equal('22aidtbx5eabd9'); - }); - - it('should have tdid, it is available in bidRequest', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - requests.forEach(function (requestItem) { - expect(requestItem.data.tdid).to.equal('eff98622-b5fd-44fa-9a49-6e846922d532'); - }); - }); - }); - - describe('splitting multi-auction ad units into own requests', function () { - const bidRequests = [{ - bidder: 'aardvark', - params: { - ai: 'Toby', - sc: 'TdAx', - categories: ['cat1', 'cat2'] - }, - adUnitCode: 'aaa', - transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', - sizes: [300, 250], - bidId: '1abgs362e0x48a8', - bidderRequestId: '70deaff71c281d', - auctionId: '5c66da22-426a-4bac-b153-77360bef5337' - }, - { - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'RAZd', - host: 'adzone.pub.com' - }, - adUnitCode: 'bbb', - transactionId: '193995b4-7122-4739-959b-2463282a138b', - sizes: [[800, 600]], - bidId: '22aidtbx5eabd9', - bidderRequestId: '70deaff71c281d', - auctionId: 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a' - }]; - - const bidderRequest = { - refererInfo: { - referer: 'https://example.com' - } - }; - - it('should use HTTP GET method', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - requests.forEach(function (requestItem) { - expect(requestItem.method).to.equal('GET'); - }); - }); - - it('should call the correct bidRequest urls for each auction', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].url).to.match(new RegExp('^https:\/\/bidder.rtk.io/Toby/TdAx/aardvark\?')); - expect(requests[0].data.categories.length).to.equal(2); - expect(requests[1].url).to.match(new RegExp('^https:\/\/adzone.pub.com/xiby/RAZd/aardvark\?')); - }); - - it('should have correct data', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests.length).to.equal(2); - expect(requests[0].data.version).to.equal(1); - expect(requests[0].data.jsonp).to.equal(false); - expect(requests[0].data.TdAx).to.equal('1abgs362e0x48a8'); - expect(requests[0].data.rtkreferer).to.not.be.undefined; - expect(requests[0].data.RAZd).to.be.undefined; - expect(requests[1].data.version).to.equal(1); - expect(requests[1].data.jsonp).to.equal(false); - expect(requests[1].data.TdAx).to.be.undefined; - expect(requests[1].data.rtkreferer).to.not.be.undefined; - expect(requests[1].data.RAZd).to.equal('22aidtbx5eabd9'); - }); - - it('should have no tdid, it is not available in bidRequest', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - requests.forEach(function (requestItem) { - expect(requestItem.data.tdid).to.be.undefined; - }); - }); - }); - - describe('GDPR conformity', function () { - const bidRequests = [{ - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'TdAx', - }, - adUnitCode: 'aaa', - transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', - sizes: [300, 250], - bidId: '1abgs362e0x48a8', - bidderRequestId: '70deaff71c281d', - auctionId: '5c66da22-426a-4bac-b153-77360bef5337' - }]; - - const bidderRequest = { - gdprConsent: { - consentString: 'awefasdfwefasdfasd', - gdprApplies: true - }, - refererInfo: { - referer: 'https://example.com' - } - }; - - it('should transmit correct data', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests.length).to.equal(1); - expect(requests[0].data.gdpr).to.equal(true); - expect(requests[0].data.consent).to.equal('awefasdfwefasdfasd'); - }); - }); - - describe('GDPR absence conformity', function () { - const bidRequests = [{ - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'TdAx', - }, - adUnitCode: 'aaa', - transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', - sizes: [300, 250], - bidId: '1abgs362e0x48a8', - bidderRequestId: '70deaff71c281d', - auctionId: '5c66da22-426a-4bac-b153-77360bef5337' - }]; - - const bidderRequest = { - gdprConsent: undefined, - refererInfo: { - referer: 'https://example.com' - } - }; - - it('should transmit correct data', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests.length).to.equal(1); - expect(requests[0].data.gdpr).to.be.undefined; - expect(requests[0].data.consent).to.be.undefined; - }); - }); - - describe('CCPA conformity', function () { - const bidRequests = [{ - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'TdAx', - }, - adUnitCode: 'aaa', - transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', - sizes: [300, 250], - bidId: '1abgs362e0x48a8', - bidderRequestId: '70deaff71c281d', - auctionId: '5c66da22-426a-4bac-b153-77360bef5337' - }]; - - it('should transmit us_privacy data', function () { - const usp = '1NY-'; - const bidderRequest = { - gdprConsent: { - consentString: 'awefasdfwefasdfasd', - gdprApplies: true - }, - refererInfo: { - referer: 'http://example.com' - }, - uspConsent: usp - }; - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests.length).to.equal(1); - expect(requests[0].data.gdpr).to.equal(true); - expect(requests[0].data.consent).to.equal('awefasdfwefasdfasd'); - expect(requests[0].data.us_privacy).to.equal(usp); - }); - - it('should not send us_privacy', function () { - const bidderRequest = { - refererInfo: { - referer: 'http://example.com' - } - }; - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests.length).to.equal(1); - expect(requests[0].data.gdpr).to.be.undefined; - expect(requests[0].data.consent).to.be.undefined; - expect(requests[0].data.us_privacy).to.be.undefined; - }); - }); - - describe('interpretResponse', function () { - it('should handle bid responses', function () { - const serverResponse = { - body: [ - { - media: 'banner', - nurl: 'https://www.nurl.com/0', - cpm: 0.09, - width: 300, - height: 250, - cid: '22aidtbx5eabd9', - adm: '', - dealId: 'dealing', - ttl: 200, - }, - { - media: 'banner', - nurl: 'https://www.nurl.com/1', - cpm: 0.19, - width: 300, - height: 250, - cid: '1abgs362e0x48a8', - adm: '', - ttl: 200, - ex: 'extraproperty' - } - ], - headers: {} - }; - - const result = spec.interpretResponse(serverResponse, {}); - expect(result.length).to.equal(2); - - expect(result[0].requestId).to.equal('22aidtbx5eabd9'); - expect(result[0].cpm).to.equal(0.09); - expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(250); - expect(result[0].currency).to.equal('USD'); - expect(result[0].ttl).to.equal(200); - expect(result[0].dealId).to.equal('dealing'); - expect(result[0].ex).to.be.undefined; - expect(result[0].ad).to.not.be.undefined; - - expect(result[1].requestId).to.equal('1abgs362e0x48a8'); - expect(result[1].cpm).to.equal(0.19); - expect(result[1].width).to.equal(300); - expect(result[1].height).to.equal(250); - expect(result[1].currency).to.equal('USD'); - expect(result[1].ttl).to.equal(200); - expect(result[1].ad).to.not.be.undefined; - expect(result[1].ex).to.equal('extraproperty'); - }); - - it('should handle nobid responses', function () { - var emptyResponse = [{ - nurl: '', - cid: '9e5a09319e18f1', - media: 'banner', - error: 'No bids received for 9DgF', - adm: '', - id: '9DgF', - cpm: 0.00 - }]; - - var result = spec.interpretResponse({ body: emptyResponse }, {}); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - const syncOptions = { - iframeEnabled: true - }; - - it('should produce sync url', function () { - const syncs = spec.getUserSyncs(syncOptions); - expect(syncs.length).to.equal(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://sync.rtk.io/cs'); - }); - - it('should return empty, as we sync only once', function () { - const syncs = spec.getUserSyncs(syncOptions); - expect(syncs.length).to.equal(0); - }); - - it('should reset hasSynced flag, allowing another sync', function () { - resetUserSync(); - - const syncs = spec.getUserSyncs(syncOptions); - expect(syncs.length).to.equal(1); - }); - - it('should return empty when iframe disallowed', function () { - resetUserSync(); - - const noIframeOptions = { iframeEnabled: false }; - const syncs = spec.getUserSyncs(noIframeOptions); - expect(syncs.length).to.equal(0); - }); - - it('should produce sync url with gdpr params', function () { - const gdprConsent = { - gdprApplies: true, - consentString: 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA' - }; - - resetUserSync(); - - const syncs = spec.getUserSyncs(syncOptions, null, gdprConsent); - expect(syncs.length).to.equal(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://sync.rtk.io/cs?g=1&c=BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'); - }); - - it('should produce sync url with ccpa params', function () { - resetUserSync(); - - const syncs = spec.getUserSyncs(syncOptions, null, {}, '1YYN'); - expect(syncs.length).to.equal(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://sync.rtk.io/cs?us_privacy=1YYN'); - }); - }); - - describe('reading window.top properties', function () { - const bidCategories = ['bcat1', 'bcat2', 'bcat3']; - const bidRequests = [{ - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'TdAx', - host: 'adzone.pub.com', - categories: bidCategories - }, - adUnitCode: 'RTK_aaaa', - transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', - sizes: [300, 250], - bidId: '1abgs362e0x48a8', - bidderRequestId: '70deaff71c281d', - auctionId: '5c66da22-426a-4bac-b153-77360bef5337', - userId: { tdid: 'eff98622-b5fd-44fa-9a49-6e846922d532' } - }]; - - const bidderRequest = { - refererInfo: { - referer: 'https://example.com' - } - }; - - const topWin = { - innerWidth: 1366, - innerHeight: 768, - rtkcategories: ['cat1', 'cat2', 'cat3'] - }; - - let sandbox; - beforeEach(function () { - sandbox = sinon.createSandbox(); - }); - - afterEach(function () { - sandbox.restore(); - }); - - it('should have window.top dimensions', function () { - sandbox.stub(utils, 'getWindowTop').returns(topWin); - - const requests = spec.buildRequests(bidRequests, bidderRequest); - requests.forEach(function (requestItem) { - expect(requestItem.data.w).to.equal(topWin.innerWidth); - expect(requestItem.data.h).to.equal(topWin.innerHeight); - }); - }); - - it('should have window dimensions, as backup', function () { - sandbox.stub(utils, 'getWindowTop').returns(undefined); - - const requests = spec.buildRequests(bidRequests, bidderRequest); - requests.forEach(function (requestItem) { - expect(requestItem.data.w).to.equal(window.innerWidth); - expect(requestItem.data.h).to.equal(window.innerHeight); - }); - }); - - it('should have window.top & bid categories', function () { - sandbox.stub(utils, 'getWindowTop').returns(topWin); - - const requests = spec.buildRequests(bidRequests, bidderRequest); - requests.forEach(function (requestItem) { - utils._each(topWin.categories, function (cat) { - expect(requestItem.data.categories).to.contain(cat); - }); - utils._each(bidCategories, function (cat) { - expect(requestItem.data.categories).to.contain(cat); - }); - }); - }); - }); - - describe('schain support', function() { - const nodePropsOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; - let schainConfig = { - ver: '1.0', - complete: 1, - nodes: [ - { - asi: 'rtk.io', - sid: '1234', - hp: 1, - rid: 'bid-request-1', - name: 'first pub', - domain: 'first.com' - }, - { - asi: 'rtk.io', - sid: '5678', - hp: 1, - rid: 'bid-request-2', - name: 'second pub', - domain: 'second.com' - } - ] - }; - - const bidRequests = [{ - bidder: 'aardvark', - params: { - ai: 'xiby', - sc: 'TdAx', - }, - adUnitCode: 'aaa', - transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', - sizes: [300, 250], - bidId: '1abgs362e0x48a8', - bidderRequestId: '70deaff71c281d', - auctionId: '5c66da22-426a-4bac-b153-77360bef5337', - schain: schainConfig, - }]; - - const bidderRequest = { - gdprConsent: undefined, - refererInfo: { - referer: 'https://example.com' - } - }; - - it('should properly serialize schain object with correct delimiters', () => { - const results = spec.buildRequests(bidRequests, bidderRequest); - const numNodes = schainConfig.nodes.length; - - const schain = results[0].data.schain; - - // each node serialization should start with an ! - expect(schain.match(/!/g).length).to.equal(numNodes); - - // 5 commas per node plus 1 for version - expect(schain.match(/,/g).length).to.equal(numNodes * 5 + 1); - }); - - it('should send the proper version for the schain', () => { - const results = spec.buildRequests(bidRequests, bidderRequest); - const schain = decodeURIComponent(results[0].data.schain).split('!'); - const version = schain.shift().split(',')[0]; - expect(version).to.equal(bidRequests[0].schain.ver); - }); - - it('should send the correct value for complete in schain', () => { - const results = spec.buildRequests(bidRequests, bidderRequest); - const schain = decodeURIComponent(results[0].data.schain).split('!'); - const complete = schain.shift().split(',')[1]; - expect(complete).to.equal(String(bidRequests[0].schain.complete)); - }); - - it('should send available params in the right order', () => { - const results = spec.buildRequests(bidRequests, bidderRequest); - const schain = decodeURIComponent(results[0].data.schain).split('!'); - schain.shift(); - - schain.forEach((serializeNode, nodeIndex) => { - const nodeProps = serializeNode.split(','); - nodeProps.forEach((nodeProp, propIndex) => { - const node = schainConfig.nodes[nodeIndex]; - const key = nodePropsOrder[propIndex]; - expect(nodeProp).to.equal(node[key] ? String(node[key]) : ''); - }); - }); - }); - }); -}); diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js index 4b66a96be16..53d1be78703 100644 --- a/test/spec/modules/adagioBidAdapter_spec.js +++ b/test/spec/modules/adagioBidAdapter_spec.js @@ -696,7 +696,7 @@ describe('Adagio bid adapter', () => { describe('with userID modules', function() { const userId = { - sharedid: {id: '01EAJWWNEPN3CYMM5N8M5VXY22', third: '01EAJWWNEPN3CYMM5N8M5VXY22'}, + pubcid: '01EAJWWNEPN3CYMM5N8M5VXY22', unsuported: '666' }; @@ -710,13 +710,10 @@ describe('Adagio bid adapter', () => { const requests = spec.buildRequests([bid01], bidderRequest); const expected = [{ - source: 'sharedid.org', + source: 'pubcid.org', uids: [ { atype: 1, - ext: { - third: '01EAJWWNEPN3CYMM5N8M5VXY22' - }, id: '01EAJWWNEPN3CYMM5N8M5VXY22' } ] diff --git a/test/spec/modules/adbutlerBidAdapter_spec.js b/test/spec/modules/adbutlerBidAdapter_spec.js deleted file mode 100644 index 6dedce321d8..00000000000 --- a/test/spec/modules/adbutlerBidAdapter_spec.js +++ /dev/null @@ -1,231 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/adbutlerBidAdapter.js'; - -describe('AdButler adapter', function () { - let bidRequests; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093', - keyword: 'red', - minCPM: '1.00', - maxCPM: '5.00', - extra: { - foo: 'bar', - } - }, - placementCode: '/19968336/header-bid-tag-1', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - }, - }, - bidId: '23acc48ad47af5', - auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - - describe('implementation', function () { - describe('for requests', function () { - it('should accept valid bid', function () { - let validBid = { - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093' - } - }, - isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject invalid bid', function () { - let invalidBid = { - bidder: 'adbutler', - params: { - accountID: '167283', - } - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should use custom domain string', function () { - let bidRequests = [ - { - bidId: '3c9408cdbf2f68', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '107878', - zoneID: '86133', - domain: 'servedbyadbutler.com.dan.test' - }, - auctionId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - ], - requests = spec.buildRequests(bidRequests), - requestURL = requests[0].url; - - expect(requestURL).to.have.string('.dan.test'); - }); - - it('should set default domain', function () { - let requests = spec.buildRequests(bidRequests), - request = requests[0]; - - let [domain] = request.url.split('/adserve/'); - - expect(domain).to.equal('https://servedbyadbutler.com'); - }); - - it('should set the keyword parameter', function () { - let requests = spec.buildRequests(bidRequests), - requestURL = requests[0].url; - - expect(requestURL).to.have.string(';kw=red;'); - }); - - it('should set the extra parameter', () => { - let requests = spec.buildRequests(bidRequests); - let requestURL = requests[0].url; - - expect(requestURL).to.have.string(';foo=bar;'); - }); - - it('should increment the count for the same zone', function () { - let bidRequests = [ - { - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '107878', - zoneID: '86133', - } - }, { - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '107878', - zoneID: '86133', - } - }, - ], - requests = spec.buildRequests(bidRequests), - firstRequest = requests[0].url, - secondRequest = requests[1].url; - - expect(firstRequest).to.have.string(';place=0;'); - expect(secondRequest).to.have.string(';place=1;'); - }); - }); - - describe('bid responses', function () { - it('should return complete bid response', function () { - let serverResponse = { - body: { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210093, - cpm: 1.5, - width: 300, - height: 250, - place: 0, - ad_code: '', - tracking_pixels: [ - 'http://tracking.pixel.com/params=info' - ] - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(1); - - expect(bids[0].bidderCode).to.equal('adbutler'); - 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); - expect(bids[0].ad).to.have.length.above(1); - expect(bids[0].ad).to.have.string('http://tracking.pixel.com/params=info'); - }); - - it('should return empty bid response', function () { - let serverResponse = { - body: { - status: 'NO_ELIGIBLE_ADS', - zone_id: 210083, - width: 300, - height: 250, - place: 0 - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response on incorrect size', function () { - let serverResponse = { - body: { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210083, - cpm: 1.5, - width: 728, - height: 90, - place: 0 - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with CPM too low', function () { - let serverResponse = { - body: { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210093, - cpm: 0.75, - width: 300, - height: 250, - place: 0 - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with CPM too high', function () { - let serverResponse = { - body: { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210093, - cpm: 7, - width: 300, - height: 250, - place: 0 - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - }); - }); -}); diff --git a/test/spec/modules/adfinityBidAdapter_spec.js b/test/spec/modules/adfinityBidAdapter_spec.js deleted file mode 100644 index 479a2303dd5..00000000000 --- a/test/spec/modules/adfinityBidAdapter_spec.js +++ /dev/null @@ -1,151 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/adfinityBidAdapter.js'; - -describe('AdfinityAdapter', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'adfinity', - 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', - domain: 'example.com' - } - ] - } - }; - let bidderRequest = { - bidderCode: 'adfinity', - auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff', - bidderRequestId: 'ffffffffffffff', - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000, - uspConsent: '1YN-', - refererInfo: { - referer: 'http://www.example.com', - reachedTop: true, - }, - bids: [bid] - } - - describe('isBidRequestValid', function () { - it('Should return true when placement_id can be cast to a number', 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://stat.adfinity.pro/?c=o&m=multi'); - }); - - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.language).to.be.a('string'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placements = data['placements']; - for (let i = 0; i < placements.length; i++) { - let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes', 'schain'); - expect(placement.schain).to.be.an('object') - expect(placement.placementId).to.be.a('number'); - expect(placement.bidId).to.be.a('string'); - expect(placement.traffic).to.be.a('string'); - expect(placement.sizes).to.be.an('array'); - } - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - let resObject = { - body: [ { - requestId: '123', - mediaType: 'banner', - cpm: 0.3, - width: 320, - height: 50, - ad: '

Hello ad

', - ttl: 1000, - creativeId: '123asd', - netRevenue: true, - currency: 'USD' - } ] - }; - let serverResponses = spec.interpretResponse(resObject); - it('Returns an array of valid server responses if response object is valid', function () { - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'mediaType'); - expect(dataItem.requestId).to.be.a('string'); - expect(dataItem.cpm).to.be.a('number'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); - expect(dataItem.ad).to.be.a('string'); - expect(dataItem.ttl).to.be.a('number'); - expect(dataItem.creativeId).to.be.a('string'); - expect(dataItem.netRevenue).to.be.a('boolean'); - expect(dataItem.currency).to.be.a('string'); - expect(dataItem.mediaType).to.be.a('string'); - } - it('Returns an empty array if invalid response is passed', function () { - serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - }); - - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://stat.adfinity.pro/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/adformBidAdapter_spec.js b/test/spec/modules/adformBidAdapter_spec.js deleted file mode 100644 index 79ea76da8dd..00000000000 --- a/test/spec/modules/adformBidAdapter_spec.js +++ /dev/null @@ -1,550 +0,0 @@ -import {assert, expect} from 'chai'; -import {spec} from 'modules/adformBidAdapter.js'; -import { BANNER, VIDEO } from 'src/mediaTypes.js'; -import { config } from 'src/config.js'; -import { createEidsArray } from 'modules/userId/eids.js'; - -describe('Adform adapter', function () { - let serverResponse, bidRequest, bidResponses; - let bids = []; - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'adform', - 'params': { - 'mid': '19910113' - } - }; - - it('should return true when required params found', function () { - assert(spec.isBidRequestValid(bid)); - }); - - it('should return false when required params are missing', function () { - bid.params = { - adxDomain: 'adx.adform.net' - }; - assert.isFalse(spec.isBidRequestValid(bid)); - }); - }); - - describe('buildRequests', function () { - it('should pass multiple bids via single request', function () { - let request = spec.buildRequests(bids); - let parsedUrl = parseUrl(request.url); - assert.lengthOf(parsedUrl.items, 7); - }); - - it('should handle global request parameters', function () { - let parsedUrl = parseUrl(spec.buildRequests([bids[0]]).url); - let query = parsedUrl.query; - - assert.equal(parsedUrl.path, 'https://newDomain/adx'); - assert.equal(query.tid, 45); - assert.equal(query.rp, 4); - assert.equal(query.fd, 1); - assert.equal(query.stid, '7aefb970-2045'); - assert.equal(query.url, encodeURIComponent('some// there')); - }); - - it('should set correct request method', function () { - let request = spec.buildRequests([bids[0]]); - assert.equal(request.method, 'GET'); - }); - - it('should pass request currency from config', function () { - config.setConfig({ currency: { adServerCurrency: 'PLN' } }); - let request = parseUrl(spec.buildRequests(bids).url); - - request.items.forEach(item => { - assert.equal(item.rcur, 'PLN'); - }); - }); - - it('should prefer bid currency over global config', function () { - config.setConfig({ currency: { adServerCurrency: 'PLN' } }); - bids[0].params.rcur = 'USD'; - let request = parseUrl(spec.buildRequests(bids).url); - const currencies = request.items.map(item => item.rcur); - - assert.deepEqual(currencies, [ 'USD', 'PLN', 'PLN', 'PLN', 'PLN', 'PLN', 'PLN' ]); - }); - - it('should correctly form bid items', function () { - let bidList = bids; - let request = spec.buildRequests(bidList); - let parsedUrl = parseUrl(request.url); - assert.deepEqual(parsedUrl.items, [ - { - mid: '1', - transactionId: '5f33781f-9552-4ca1' - }, - { - mid: '2', - someVar: 'someValue', - pt: 'gross', - transactionId: '5f33781f-9552-4iuy' - }, - { - mid: '3', - pdom: 'home', - transactionId: '5f33781f-9552-7ev3' - }, - { - mid: '3', - pdom: 'home', - transactionId: '5f33781f-9552-7ev3' - }, - { - mid: '3', - pdom: 'home', - transactionId: '5f33781f-9552-7ev3' - }, - { - mid: '5', - pt: 'net', - transactionId: '5f33781f-9552-7ev3', - }, - { - mid: '6', - pt: 'gross', - transactionId: '5f33781f-9552-7ev3' - } - ]); - }); - - it('should not change original validBidRequests object', function () { - var resultBids = JSON.parse(JSON.stringify(bids[0])); - let request = spec.buildRequests([bids[0]]); - assert.deepEqual(resultBids, bids[0]); - }); - - it('should set gross to the request, if there is any gross priceType', function () { - let request = spec.buildRequests([bids[5], bids[5]]); - let parsedUrl = parseUrl(request.url); - - assert.equal(parsedUrl.query.pt, 'net'); - - request = spec.buildRequests([bids[4], bids[3]]); - parsedUrl = parseUrl(request.url); - - assert.equal(parsedUrl.query.pt, 'gross'); - }); - - it('should pass extended ids', function () { - bids[0].userIdAsEids = createEidsArray({ - tdid: 'TTD_ID_FROM_USER_ID_MODULE', - pubcid: 'pubCommonId_FROM_USER_ID_MODULE' - }); - let request = spec.buildRequests(bids); - let eids = parseUrl(request.url).query.eids; - - assert.equal(eids, 'eyJhZHNlcnZlci5vcmciOnsiVFREX0lEX0ZST01fVVNFUl9JRF9NT0RVTEUiOlsxXX0sInB1YmNpZC5vcmciOnsicHViQ29tbW9uSWRfRlJPTV9VU0VSX0lEX01PRFVMRSI6WzFdfX0%3D'); - assert.deepEqual(JSON.parse(atob(decodeURIComponent(eids))), { - 'adserver.org': { - 'TTD_ID_FROM_USER_ID_MODULE': [1] - }, - 'pubcid.org': { - 'pubCommonId_FROM_USER_ID_MODULE': [1] - } - }); - }); - - it('should allow to pass custom extended ids', function () { - bids[0].params.eids = 'some_id_value'; - let request = spec.buildRequests(bids); - let eids = parseUrl(request.url).query.eids; - - assert.equal(eids, 'some_id_value'); - }); - - it('should add parameter to global parameters if it exists in all bids', function () { - const _bids = []; - _bids.push(bids[0]); - _bids.push(bids[1]); - _bids.push(bids[2]); - _bids[0].params.mkv = 'key:value,key1:value1'; - _bids[1].params.mkv = 'key:value,key1:value1,keyR:removed'; - _bids[2].params.mkv = 'key:value,key1:value1,keyR:removed,key8:value1'; - _bids[0].params.mkw = 'targeting'; - _bids[1].params.mkw = 'targeting'; - _bids[2].params.mkw = 'targeting,targeting2'; - _bids[0].params.msw = 'search:word,search:word2'; - _bids[1].params.msw = 'search:word'; - _bids[2].params.msw = 'search:word,search:word5'; - let bidList = _bids; - let request = spec.buildRequests(bidList); - let parsedUrl = parseUrl(request.url); - assert.equal(parsedUrl.query.mkv, encodeURIComponent('key:value,key1:value1')); - assert.equal(parsedUrl.query.mkw, 'targeting'); - assert.equal(parsedUrl.query.msw, encodeURIComponent('search:word')); - assert.ok(!parsedUrl.items[0].mkv); - assert.ok(!parsedUrl.items[0].mkw); - assert.equal(parsedUrl.items[0].msw, 'search:word2'); - assert.equal(parsedUrl.items[1].mkv, 'keyR:removed'); - assert.ok(!parsedUrl.items[1].mkw); - assert.ok(!parsedUrl.items[1].msw); - assert.equal(parsedUrl.items[2].mkv, 'keyR:removed,key8:value1'); - assert.equal(parsedUrl.items[2].mkw, 'targeting2'); - assert.equal(parsedUrl.items[2].msw, 'search:word5'); - }); - - describe('user privacy', function () { - it('should send GDPR Consent data to adform if gdprApplies', function () { - let request = spec.buildRequests([bids[0]], {gdprConsent: {gdprApplies: true, consentString: 'concentDataString'}}); - let parsedUrl = parseUrl(request.url).query; - - assert.equal(parsedUrl.gdpr, '1'); - assert.equal(parsedUrl.gdpr_consent, 'concentDataString'); - }); - - it('should not send GDPR Consent data to adform if gdprApplies is undefined', function () { - let request = spec.buildRequests([bids[0]], {gdprConsent: {gdprApplies: false, consentString: 'concentDataString'}}); - let parsedUrl = parseUrl(request.url).query; - - assert.equal(parsedUrl.gdpr, '0'); - assert.equal(parsedUrl.gdpr_consent, 'concentDataString'); - - request = spec.buildRequests([bids[0]], {gdprConsent: {gdprApplies: undefined, consentString: 'concentDataString'}}); - parsedUrl = parseUrl(request.url).query; - assert.ok(!parsedUrl.gdpr); - assert.ok(!parsedUrl.gdpr_consent); - }); - - it('should return GDPR Consent data with request data', function () { - let request = spec.buildRequests([bids[0]], {gdprConsent: {gdprApplies: true, consentString: 'concentDataString'}}); - - assert.deepEqual(request.gdpr, { - gdpr: true, - gdpr_consent: 'concentDataString' - }); - - request = spec.buildRequests([bids[0]]); - assert.ok(!request.gdpr); - }); - - it('should send CCPA Consent data to adform', function () { - const request = spec.buildRequests([bids[0]], {uspConsent: '1YA-'}); - const parsedUrl = parseUrl(request.url).query; - - assert.equal(parsedUrl.us_privacy, '1YA-'); - }); - }); - }); - - describe('interpretResponse', function () { - it('should respond with empty response when there is empty serverResponse', function () { - let result = spec.interpretResponse({ body: {} }, {}); - assert.deepEqual(result, []); - }); - it('should respond with empty response when response from server is not banner', function () { - serverResponse.body[0].response = 'not banner'; - serverResponse.body = [serverResponse.body[0]]; - bidRequest.bids = [bidRequest.bids[0]]; - let result = spec.interpretResponse(serverResponse, bidRequest); - - assert.deepEqual(result, []); - }); - it('should interpret server response correctly with one bid', function () { - serverResponse.body = [serverResponse.body[0]]; - bidRequest.bids = [bidRequest.bids[0]]; - let result = spec.interpretResponse(serverResponse, bidRequest)[0]; - - assert.equal(result.requestId, '2a0cf4e'); - assert.equal(result.cpm, 13.9); - assert.equal(result.width, 300); - assert.equal(result.height, 250); - assert.equal(result.creativeId, '2a0cf4e'); - assert.equal(result.dealId, '123abc'); - assert.equal(result.currency, 'EUR'); - assert.equal(result.netRevenue, true); - assert.equal(result.ttl, 360); - assert.deepEqual(result.meta.advertiserDomains, []) - assert.equal(result.ad, ''); - assert.equal(result.bidderCode, 'adform'); - assert.equal(result.transactionId, '5f33781f-9552-4ca1'); - }); - - it('should set correct netRevenue', function () { - serverResponse.body = [serverResponse.body[0]]; - bidRequest.bids = [bidRequest.bids[1]]; - bidRequest.netRevenue = 'gross'; - let result = spec.interpretResponse(serverResponse, bidRequest)[0]; - - assert.equal(result.netRevenue, false); - }); - - it('should create bid response item for every requested item', function () { - let result = spec.interpretResponse(serverResponse, bidRequest); - assert.lengthOf(result, 5); - }); - - it('should create bid response with vast xml', function () { - const result = spec.interpretResponse(serverResponse, bidRequest)[3]; - assert.equal(result.vastXml, ''); - }); - - it('should create bid response with vast url', function () { - const result = spec.interpretResponse(serverResponse, bidRequest)[4]; - assert.equal(result.vastUrl, 'vast://url'); - }); - - it('should set mediaType on bid response', function () { - const expected = [ BANNER, BANNER, BANNER, VIDEO, VIDEO ]; - const result = spec.interpretResponse(serverResponse, bidRequest); - for (let i = 0; i < result.length; i++) { - assert.equal(result[i].mediaType, expected[i]); - } - }); - - it('should set default netRevenue as gross', function () { - bidRequest.netRevenue = 'gross'; - const result = spec.interpretResponse(serverResponse, bidRequest); - for (let i = 0; i < result.length; i++) { - assert.equal(result[i].netRevenue, false); - } - }); - - it('should set gdpr if it exist in bidRequest', function () { - bidRequest.gdpr = { - gdpr: true, - gdpr_consent: 'ERW342EIOWT34234KMGds' - }; - let result = spec.interpretResponse(serverResponse, bidRequest); - for (let i = 0; i < result.length; i++) { - assert.equal(result[i].gdpr, true); - assert.equal(result[i].gdpr_consent, 'ERW342EIOWT34234KMGds'); - } - - bidRequest.gdpr = undefined; - result = spec.interpretResponse(serverResponse, bidRequest); - for (let i = 0; i < result.length; i++) { - assert.ok(!result[i].gdpr); - assert.ok(!result[i].gdpr_consent); - } - }); - - it('should set a renderer only for an outstream context', function () { - serverResponse.body = [serverResponse.body[3], serverResponse.body[2]]; - bidRequest.bids = [bidRequest.bids[6], bidRequest.bids[6]]; - let result = spec.interpretResponse(serverResponse, bidRequest); - assert.ok(result[0].renderer); - assert.equal(result[1].renderer, undefined); - }); - - describe('verifySizes', function () { - it('should respond with empty response when sizes doesn\'t match', function () { - serverResponse.body[0].response = 'banner'; - serverResponse.body[0].width = 100; - serverResponse.body[0].height = 150; - - serverResponse.body = [serverResponse.body[0]]; - bidRequest.bids = [bidRequest.bids[0]]; - let result = spec.interpretResponse(serverResponse, bidRequest); - - assert.equal(serverResponse.body.length, 1); - assert.equal(serverResponse.body[0].response, 'banner'); - assert.deepEqual(result, []); - }); - it('should respond with empty response when sizes as a strings doesn\'t match', function () { - serverResponse.body[0].response = 'banner'; - serverResponse.body[0].width = 100; - serverResponse.body[0].height = 150; - - serverResponse.body = [serverResponse.body[0]]; - bidRequest.bids = [bidRequest.bids[0]]; - - bidRequest.bids[0].sizes = [['101', '150']]; - let result = spec.interpretResponse(serverResponse, bidRequest); - - assert.equal(serverResponse.body.length, 1); - assert.equal(serverResponse.body[0].response, 'banner'); - assert.deepEqual(result, []); - }); - it('should support size dimensions as a strings', function () { - serverResponse.body[0].response = 'banner'; - serverResponse.body[0].width = 300; - serverResponse.body[0].height = 600; - - serverResponse.body = [serverResponse.body[0]]; - bidRequest.bids = [bidRequest.bids[0]]; - - bidRequest.bids[0].sizes = [['300', '250'], ['250', '300'], ['300', '600'], ['600', '300']]; - let result = spec.interpretResponse(serverResponse, bidRequest); - - assert.equal(result[0].width, 300); - assert.equal(result[0].height, 600); - }); - }); - }); - - beforeEach(function () { - config.setConfig({ currency: {} }); - - let sizes = [[250, 300], [300, 250], [300, 600], [600, 300]]; - let placementCode = ['div-01', 'div-02', 'div-03', 'div-04', 'div-05']; - let mediaTypes = [{video: {context: 'outstream'}, banner: {sizes: sizes[3]}}]; - let params = [{ mid: 1, url: 'some// there' }, {adxDomain: null, mid: 2, someVar: 'someValue', pt: 'gross'}, { adxDomain: null, mid: 3, pdom: 'home' }, {mid: 5, pt: 'net'}, {mid: 6, pt: 'gross'}]; - bids = [ - { - adUnitCode: placementCode[0], - auctionId: '7aefb970-2045', - bidId: '2a0cf4e', - bidder: 'adform', - bidderRequestId: '1ab8d9', - params: params[0], - adxDomain: 'newDomain', - tid: 45, - placementCode: placementCode[0], - sizes: [[300, 250], [250, 300], [300, 600], [600, 300]], - transactionId: '5f33781f-9552-4ca1' - }, - { - adUnitCode: placementCode[1], - auctionId: '7aefb970-2045', - bidId: '2a0cf5b', - bidder: 'adform', - bidderRequestId: '1ab8d9', - params: params[1], - placementCode: placementCode[1], - sizes: [[300, 250], [250, 300], [300, 600], [600, 300]], - transactionId: '5f33781f-9552-4iuy' - }, - { - adUnitCode: placementCode[2], - auctionId: '7aefb970-2045', - bidId: '2a0cf6n', - bidder: 'adform', - bidderRequestId: '1ab8d9', - params: params[2], - placementCode: placementCode[2], - sizes: [[300, 250], [250, 300], [300, 600], [600, 300]], - transactionId: '5f33781f-9552-7ev3' - }, - { - adUnitCode: placementCode[3], - auctionId: '7aefb970-2045', - bidId: '2a0cf6n', - bidder: 'adform', - bidderRequestId: '1ab8d9', - params: params[2], - placementCode: placementCode[2], - sizes: [], - transactionId: '5f33781f-9552-7ev3' - }, - { - adUnitCode: placementCode[4], - auctionId: '7aefb970-2045', - bidId: '2a0cf6n', - bidder: 'adform', - bidderRequestId: '1ab8d9', - params: params[2], - placementCode: placementCode[2], - sizes: [], - transactionId: '5f33781f-9552-7ev3' - }, - { - adUnitCode: placementCode[4], - auctionId: '7aefb970-2045', - bidId: '2a0cf6n', - bidder: 'adform', - bidderRequestId: '1ab8d9', - params: params[3], - placementCode: placementCode[2], - sizes: [], - transactionId: '5f33781f-9552-7ev3' - }, - { - adUnitCode: placementCode[4], - auctionId: '7aefb970-2045', - bidId: '2a0cf6n', - bidder: 'adform', - bidderRequestId: '1ab8d9', - params: params[4], - placementCode: placementCode[2], - sizes: [], - mediaTypes: mediaTypes[0], - transactionId: '5f33781f-9552-7ev3' - } - ]; - serverResponse = { - body: [ - { - banner: '', - deal_id: '123abc', - height: 250, - response: 'banner', - width: 300, - win_bid: 13.9, - win_cur: 'EUR' - }, - { - banner: '', - deal_id: '123abc', - height: 300, - response: 'banner', - width: 250, - win_bid: 13.9, - win_cur: 'EUR' - }, - { - banner: '', - deal_id: '123abc', - height: 300, - response: 'banner', - width: 600, - win_bid: 10, - win_cur: 'EUR' - }, - { - deal_id: '123abc', - height: 300, - response: 'vast_content', - width: 600, - win_bid: 10, - win_cur: 'EUR', - vast_content: '' - }, - { - deal_id: '123abc', - height: 300, - response: 'vast_url', - width: 600, - win_bid: 10, - win_cur: 'EUR', - vast_url: 'vast://url' - } - ], - headers: {} - }; - bidRequest = { - bidder: 'adform', - bids: bids, - method: 'GET', - url: 'url', - netRevenue: 'net' - }; - }); -}); - -function parseUrl(url) { - const parts = url.split('/'); - const query = parts.pop().split('&'); - return { - path: parts.join('/'), - items: query - .filter((i) => !~i.indexOf('=')) - .map((i) => atob(decodeURIComponent(i)) - .split('&') - .reduce(toObject, {})), - query: query - .filter((i) => ~i.indexOf('=')) - .map((i) => i.replace('?', '')) - .reduce(toObject, {}) - }; -} - -function toObject(cache, string) { - const keyValue = string.split('='); - cache[keyValue[0]] = keyValue[1]; - return cache; -} diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js deleted file mode 100644 index 927e7910723..00000000000 --- a/test/spec/modules/adgenerationBidAdapter_spec.js +++ /dev/null @@ -1,407 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/adgenerationBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; -import {NATIVE} from 'src/mediaTypes.js'; -import {config} from 'src/config.js'; -import prebid from '../../../package.json'; - -describe('AdgenerationAdapter', function () { - const adapter = newBidder(spec); - const ENDPOINT = ['https://api-test.scaleout.jp/adsv/v1', 'https://d.socdm.com/adsv/v1']; - - 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': 'adg', - 'params': { - id: '58278', // banner - } - }; - 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 = [ - { // banner - bidder: 'adg', - params: { - id: '58278', - currency: 'JPY', - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [320, 100]], - bidId: '2f6ac468a9c15e', - bidderRequestId: '14a9f773e30243', - auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', - transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' - }, - { // native - bidder: 'adg', - params: { - id: '58278', - currency: 'JPY', - }, - mediaTypes: { - native: { - image: { - required: true - }, - title: { - required: true, - len: 80 - }, - sponsoredBy: { - required: true - }, - clickUrl: { - required: true - }, - body: { - required: true - }, - icon: { - required: true - } - }, - }, - adUnitCode: 'adunit-code', - sizes: [[1, 1]], - bidId: '2f6ac468a9c15e', - bidderRequestId: '14a9f773e30243', - auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', - transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' - } - ]; - const bidderRequest = { - refererInfo: { - referer: 'https://example.com' - } - }; - const data = { - banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=https%3A%2F%2Fexample.com`, - bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=https%3A%2F%2Fexample.com`, - native: 'posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1¤cy=JPY&pbver=' + prebid.version + '&sdkname=prebidjs&adapterver=1.0.1&tp=https%3A%2F%2Fexample.com' - }; - it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.url).to.equal(ENDPOINT[1]); - expect(request.method).to.equal('GET'); - }); - - it('sends bid request to debug ENDPOINT via GET', function () { - bidRequests[0].params.debug = true; - const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.url).to.equal(ENDPOINT[0]); - expect(request.method).to.equal('GET'); - }); - - it('should attache params to the banner request', function () { - const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.data).to.equal(data.banner); - }); - - it('should attache params to the native request', function () { - const request = spec.buildRequests(bidRequests, bidderRequest)[1]; - expect(request.data).to.equal(data.native); - }); - it('allows setConfig to set bidder currency for JPY', function () { - config.setConfig({ - currency: { - adServerCurrency: 'JPY' - } - }); - const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.data).to.equal(data.banner); - config.resetConfig(); - }); - it('allows setConfig to set bidder currency for USD', function () { - config.setConfig({ - currency: { - adServerCurrency: 'USD' - } - }); - const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.data).to.equal(data.bannerUSD); - config.resetConfig(); - }); - }); - describe('interpretResponse', function () { - const bidRequests = { - banner: { - bidRequest: { - bidder: 'adg', - params: { - id: '58278', // banner - }, - adUnitCode: 'adunit-code', - sizes: [[320, 100]], - bidId: '2f6ac468a9c15e', - bidderRequestId: '14a9f773e30243', - auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', - transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' - }, - }, - native: { - bidRequest: { - bidder: 'adg', - params: { - id: '58278', // banner - }, - mediaTypes: { - native: { - image: { - required: true - }, - title: { - required: true, - len: 80 - }, - sponsoredBy: { - required: true - }, - clickUrl: { - required: true - }, - body: { - required: true - }, - icon: { - required: true - } - } - }, - adUnitCode: 'adunit-code', - sizes: [[1, 1]], - bidId: '2f6ac468a9c15e', - bidderRequestId: '14a9f773e30243', - auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', - transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' - }, - }, - }; - - const serverResponse = { - noAd: { - results: [], - }, - banner: { - ad: '
', - beacon: '', - cpm: 36.0008, - displaytype: '1', - ids: {}, - w: 320, - h: 100, - location_params: null, - locationid: '58279', - rotation: '0', - scheduleid: '512603', - sdktype: '0', - creativeid: '1k2kv35vsa5r', - dealid: 'fd5sa5fa7f', - ttl: 1000, - results: [ - {ad: '
'}, - ] - }, - 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/adtrueBidAdapter_spec.js b/test/spec/modules/adtrueBidAdapter_spec.js index 8e1c872d460..b499d077a3c 100644 --- a/test/spec/modules/adtrueBidAdapter_spec.js +++ b/test/spec/modules/adtrueBidAdapter_spec.js @@ -21,7 +21,7 @@ describe('AdTrueBidAdapter', function () { params: { publisherId: '1212', zoneId: '21423', - reserve: 0.2 + reserve: 0 }, placementCode: 'adunit-code-1', sizes: [[300, 250]], diff --git a/test/spec/modules/advangelistsBidAdapter_spec.js b/test/spec/modules/advangelistsBidAdapter_spec.js deleted file mode 100755 index 2b9615fb572..00000000000 --- a/test/spec/modules/advangelistsBidAdapter_spec.js +++ /dev/null @@ -1,137 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/advangelistsBidAdapter.js'; -import { BANNER, VIDEO } from 'src/mediaTypes.js'; - -describe('advangelistsBidAdapter', function () { - let bidRequests; - let bidRequestsVid; - - beforeEach(function () { - bidRequests = [{'bidder': 'advangelists', 'params': {'pubid': '0cf8d6d643e13d86a5b6374148a4afac', 'placement': 1234}, 'crumbs': {'pubcid': '979fde13-c71e-4ac2-98b7-28c90f99b449'}, 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': 'f72931e6-2b0e-4e37-a2bc-1ea912141f81', 'sizes': [[300, 250]], 'bidId': '2aa73f571eaf29', 'bidderRequestId': '1bac84515a7af3', 'auctionId': '5dbc60fa-1aa1-41ce-9092-e6bbd4d478f7', 'src': 'client', 'bidRequestsCount': 1, 'pageurl': 'http://google.com'}]; - - bidRequestsVid = [{'bidder': 'advangelists', 'params': {'pubid': '8537f00948fc37cc03c5f0f88e198a76', 'placement': 1234, 'video': {'id': 123, 'skip': 1, 'mimes': ['video/mp4', 'application/javascript'], 'playbackmethod': [2, 6], 'maxduration': 30}}, 'crumbs': {'pubcid': '979fde13-c71e-4ac2-98b7-28c90f99b449'}, 'mediaTypes': {'video': {'playerSize': [[320, 480]], 'context': 'instream'}}, 'adUnitCode': 'video1', 'transactionId': '8b060952-93f7-4863-af44-bb8796b97c42', 'sizes': [], 'bidId': '25c6ab92aa0e81', 'bidderRequestId': '1d420b73a013fc', 'auctionId': '9a69741c-34fb-474c-83e1-cfa003aaee17', 'src': 'client', 'bidRequestsCount': 1, 'pageurl': 'http://google.com'}]; - }); - - describe('spec.isBidRequestValid', function () { - it('should return true when the required params are passed for banner', function () { - const bidRequest = bidRequests[0]; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true when the required params are passed for video', function () { - const bidRequests = bidRequestsVid[0]; - expect(spec.isBidRequestValid(bidRequests)).to.equal(true); - }); - - it('should return false when no pub id params are passed', function () { - const bidRequest = bidRequests[0]; - bidRequest.params.pubid = ''; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when no placement params are passed', function () { - const bidRequest = bidRequests[0]; - bidRequest.params.placement = ''; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when a bid request is not passed', function () { - expect(spec.isBidRequestValid()).to.equal(false); - expect(spec.isBidRequestValid({})).to.equal(false); - }); - }); - - describe('spec.buildRequests', function () { - it('should create a POST request for each bid', function () { - const bidRequest = bidRequests[0]; - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].method).to.equal('POST'); - }); - - it('should create a POST request for each bid in video request', function () { - const bidRequest = bidRequestsVid[0]; - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].method).to.equal('POST'); - }); - - it('should have domain in request', function () { - const bidRequest = bidRequests[0]; - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].data.site.domain).length !== 0; - }); - }); - - describe('spec.interpretResponse', function () { - describe('for banner bids', function () { - it('should return no bids if the response is not valid', function () { - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {} }; - const bidResponse = spec.interpretResponse({ body: null }, { bidRequest }); - - if (typeof bidResponse !== 'undefined') { - expect(bidResponse.length).to.equal(0); - } else { - expect(true).to.equal(true); - } - }); - - it('should return no bids if the response is empty', function () { - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {} }; - const bidResponse = spec.interpretResponse({ body: [] }, { bidRequest }); - if (typeof bidResponse !== 'undefined') { - expect(bidResponse.length).to.equal(0); - } else { expect(true).to.equal(true); } - }); - - it('should return valid video bid responses', function () { - let _mediaTypes = VIDEO; - const advangelistsbidreqVid = {'bidRequest': {'mediaTypes': {'video': {'w': 320, 'h': 480}}}}; - const serverResponseVid = {'cur': 'USD', 'id': '25c6ab92aa0e81', 'seatbid': [{'seat': '3', 'bid': [{'crid': '1855', 'h': 480, 'protocol': 2, 'nurl': 'http://nep.advangelists.com/xp/evt?pp=1MO1wiaMhhq7wLRzZZwwwPkJxxKpYEnM5k5MH4qSGm1HR8rp3Nl7vDocvzZzSAvE4pnREL9mQ1kf5PDjk6E8em6DOk7vVrYUH1TYQyqCucd58PFpJNN7h30RXKHHFg3XaLuQ3PKfMuI1qZATBJ6WHcu875y0hqRdiewn0J4JsCYF53M27uwmcV0HnQxARQZZ72mPqrW95U6wgkZljziwKrICM3aBV07TU6YK5R5AyzJRuD6mtrQ2xtHlQ3jXVYKE5bvWFiUQd90t0jOGhPtYBNoOfP7uQ4ZZj4pyucxbr96orHe9PSOn9UpCSWArdx7s8lOfDpwOvbMuyGxynbStDWm38sDgd4bMHnIt762m5VMDNJfiUyX0vWzp05OsufJDVEaWhAM62i40lQZo7mWP4ipoOWLkmlaAzFIMsTcNaHAHiKKqGEOZLkCEhFNM0SLcvgN2HFRULOOIZvusq7TydOKxuXgCS91dLUDxDDDFUK83BFKlMkTxnCzkLbIR1bd9GKcr1TRryOrulyvRWAKAIhEsUzsc5QWFUhmI2dZ1eqnBQJ0c89TaPcnoaP2WipF68UgyiOstf2CBy0M34858tC5PmuQwQYwXscg6zyqDwR0i9MzGH4FkTyU5yeOlPcsA0ht6UcoCdFpHpumDrLUwAaxwGk1Nj8S6YlYYT5wNuTifDGbg22QKXzZBkUARiyVvgPn9nRtXnrd7WmiMYq596rya9RQj7LC0auQW8bHVQLEe49shsZDnAwZTWr4QuYKqgRGZcXteG7RVJe0ryBZezOq11ha9C0Lv0siNVBahOXE35Wzoq4c4BDaGpqvhaKN7pjeWLGlQR04ufWekwxiMWAvjmfgAfexBJ7HfbYNZpq__', 'adid': '61_1855', 'adomain': ['chevrolet.com.ar'], 'price': 2, 'w': 320, 'iurl': 'https://daf37cpxaja7f.cloudfront.net/c61/creative_url_14922301369663_1.png', 'cat': ['IAB2'], 'id': '7f570b40-aca1-4806-8ea8-818ea679c82b_0', 'attr': [], 'impid': '0', 'cid': '61'}]}], 'bidid': '7f570b40-aca1-4806-8ea8-818ea679c82b'} - const bidResponseVid = spec.interpretResponse({ body: serverResponseVid }, advangelistsbidreqVid); - delete bidResponseVid['vastUrl']; - delete bidResponseVid['ad']; - expect(bidResponseVid).to.deep.equal({ - requestId: bidRequestsVid[0].bidId, - bidderCode: 'advangelists', - creativeId: serverResponseVid.seatbid[0].bid[0].crid, - cpm: serverResponseVid.seatbid[0].bid[0].price, - width: serverResponseVid.seatbid[0].bid[0].w, - height: serverResponseVid.seatbid[0].bid[0].h, - mediaType: 'video', - currency: 'USD', - netRevenue: true, - ttl: 60 - }); - }); - - it('should return valid banner bid responses', function () { - const advangelistsbidreq = {bids: {}}; - bidRequests.forEach(bid => { - let _mediaTypes = (bid.mediaTypes && bid.mediaTypes.video ? VIDEO : BANNER); - advangelistsbidreq.bids[bid.bidId] = {mediaTypes: _mediaTypes, - w: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][0] : bid.mediaTypes[_mediaTypes].playerSize[0], - h: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1] - - }; - }); - const serverResponse = {'id': '2aa73f571eaf29', 'seatbid': [{'bid': [{'id': '2c5e8a1a84522d', 'impid': '2c5e8a1a84522d', 'price': 0.81, 'adid': 'abcde-12345', 'nurl': '', 'adm': '
', 'adomain': ['advertiserdomain.com'], 'iurl': '', 'cid': 'campaign1', 'crid': 'abcde-12345', 'w': 300, 'h': 250}], 'seat': '19513bcfca8006'}], 'bidid': '19513bcfca8006', 'cur': 'USD', 'w': 300, 'h': 250}; - - const bidResponse = spec.interpretResponse({ body: serverResponse }, advangelistsbidreq); - expect(bidResponse).to.deep.equal({ - requestId: bidRequests[0].bidId, - ad: serverResponse.seatbid[0].bid[0].adm, - bidderCode: 'advangelists', - creativeId: serverResponse.seatbid[0].bid[0].crid, - cpm: serverResponse.seatbid[0].bid[0].price, - width: serverResponse.seatbid[0].bid[0].w, - height: serverResponse.seatbid[0].bid[0].h, - mediaType: 'banner', - currency: 'USD', - netRevenue: true, - ttl: 60 - }); - }); - }); - }); -}); 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/apacdexBidAdapter_spec.js b/test/spec/modules/apacdexBidAdapter_spec.js index 5f6a935c453..527d16159bb 100644 --- a/test/spec/modules/apacdexBidAdapter_spec.js +++ b/test/spec/modules/apacdexBidAdapter_spec.js @@ -219,15 +219,6 @@ describe('ApacdexBidAdapter', function () { 'id': '2ae366c2-2576-45e5-bd21-72ed10598f17', 'atype': 1 }] - }, { - 'source': 'sharedid.org', - 'uids': [{ - 'id': '01EZXQDVAPER4KE1VBS29XKV4Z', - 'atype': 1, - 'ext': { - 'third': '01EZXQDVAPER4KE1VBS29XKV4Z' - } - }] }], }, { diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index fa2baf0db5f..9396c1e1928 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -215,6 +215,40 @@ describe('AppNexusAdapter', function () { expect(payload.tags[0].hb_source).to.deep.equal(1); }); + it('should include ORTB video values when video params were not set', function() { + let bidRequest = deepClone(bidRequests[0]); + bidRequest.params = { + placementId: '1234235', + video: { + skippable: true, + playback_method: ['auto_play_sound_off', 'auto_play_sound_unknown'], + context: 'outstream' + } + }; + bidRequest.mediaTypes = { + video: { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'], + skip: 0, + minduration: 5, + api: [1, 5, 6], + playbackmethod: [2, 4] + } + }; + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].video).to.deep.equal({ + minduration: 5, + playback_method: 2, + skippable: true, + context: 4 + }); + expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4]) + }); + it('should add video property when adUnit includes a renderer', function () { const videoData = { mediaTypes: { 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/betweenBidAdapter_spec.js b/test/spec/modules/betweenBidAdapter_spec.js index 0e772e7be02..62f36182d55 100644 --- a/test/spec/modules/betweenBidAdapter_spec.js +++ b/test/spec/modules/betweenBidAdapter_spec.js @@ -222,51 +222,6 @@ describe('betweenBidAdapterTests', function () { expect(req_data.sizes).to.deep.equal(['970x250', '240x400', '728x90']) }); - it('check sharedId with id and third', function() { - const bidRequestData = [{ - bidId: 'bid123', - bidder: 'between', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - params: { - s: 1112, - }, - userId: { - sharedid: { - id: '01EXQE7JKNDRDDVATB0S2GX1NT', - third: '01EXQE7JKNDRDDVATB0S2GX1NT' - } - } - }]; - const shid = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid; - const shid3 = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid3; - expect(shid).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT') && expect(shid3).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT'); - }); - it('check sharedId with only id', function() { - const bidRequestData = [{ - bidId: 'bid123', - bidder: 'between', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - params: { - s: 1112, - }, - userId: { - sharedid: { - id: '01EXQE7JKNDRDDVATB0S2GX1NT', - } - } - }]; - const shid = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid; - const shid3 = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid3; - expect(shid).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT') && expect(shid3).to.equal(''); - }); it('check adomain', function() { const serverResponse = { body: [{ diff --git a/test/spec/modules/bidfluenceBidAdapter_spec.js b/test/spec/modules/bidfluenceBidAdapter_spec.js deleted file mode 100644 index 6b3a0c2b044..00000000000 --- a/test/spec/modules/bidfluenceBidAdapter_spec.js +++ /dev/null @@ -1,114 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/bidfluenceBidAdapter.js'; - -const BIDDER_CODE = 'bidfluence'; -const PLACEMENT_ID = '1000'; -const PUB_ID = '1000'; -const CONSENT_STRING = 'DUXDSDFSFWRRR8345F=='; - -const validBidRequests = [{ - 'bidder': BIDDER_CODE, - 'params': { - 'placementId': PLACEMENT_ID, - 'publisherId': PUB_ID, - 'reservePrice': 0 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '2b1f23307fb8ef', - 'bidderRequestId': '10edf38ec1a719', - 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304' -}]; - -const bidderRequest = { - 'bidderCode': 'bidfluence', - 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304', - 'bidderRequestId': '10edf38ec1a719', - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'test', - 'stack': ['test'] - }, - 'timeout': 1000, - 'gdprConsent': { - 'gdprApplies': true, - 'consentString': CONSENT_STRING, - 'vendorData': '' - } -}; - -bidderRequest.bids = validBidRequests; - -describe('Bidfluence Adapter test', () => { - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(validBidRequests[0])).to.equal(true); - }); - it('should return the right bidder code', function () { - expect(spec.code).to.eql(BIDDER_CODE); - }); - }); - - describe('buildRequests', function () { - it('sends bid request to our endpoint via POST', function () { - const request = spec.buildRequests(validBidRequests, bidderRequest); - expect(request.method).to.equal('POST'); - const payload = JSON.parse(request.data); - - expect(payload.bids[0].bid).to.equal(validBidRequests[0].bidId); - expect(payload.azr).to.equal(true); - expect(payload.ck).to.not.be.undefined; - expect(payload.bids[0].tid).to.equal(PLACEMENT_ID); - expect(payload.bids[0].pid).to.equal(PUB_ID); - expect(payload.bids[0].rp).to.be.a('number'); - expect(payload.re).to.not.be.undefined; - expect(payload.st).to.not.be.undefined; - expect(payload.tz).to.not.be.undefined; - expect(payload.sr).to.not.be.undefined; - expect(payload.vp).to.not.be.undefined; - expect(payload.sdt).to.not.be.undefined; - expect(payload.bids[0].w).to.equal('300'); - expect(payload.bids[0].h).to.equal('250'); - }); - - it('sends gdpr info if exists', function () { - const request = spec.buildRequests(validBidRequests, bidderRequest); - const payload = JSON.parse(request.data); - expect(payload.gdpr).to.equal(true); - expect(payload.gdprc).to.equal(CONSENT_STRING); - }); - }); - - describe('interpretResponse', function () { - const response = { - body: { - Bids: - [{ - 'CreativeId': '1000', - 'Cpm': 0.50, - 'Ad': '
', - 'Height': 250, - 'Width': 300 - }] - } - }; - - it('should get correct bid response', function () { - const expectedResponse = [{ - requestId: response.body.Bids[0].BidId, - cpm: response.body.Bids[0].Cpm, - width: response.body.Bids[0].Width, - height: response.body.Bids[0].Height, - creativeId: response.body.Bids[0].CreativeId, - ad: response.body.Bids[0].Ad, - currency: 'USD', - netRevenue: true, - ttl: 360 - }]; - - let result = spec.interpretResponse(response, { 'bidderRequest': validBidRequests[0] }); - expect(result).to.deep.equal(expectedResponse); - }); - }); -}); diff --git a/test/spec/modules/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/c1xBidAdapter_spec.js b/test/spec/modules/c1xBidAdapter_spec.js deleted file mode 100644 index 00741abda7a..00000000000 --- a/test/spec/modules/c1xBidAdapter_spec.js +++ /dev/null @@ -1,182 +0,0 @@ -import { expect } from 'chai'; -import { c1xAdapter } from 'modules/c1xBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -const ENDPOINT = 'https://ht.c1exchange.com/ht'; -const BIDDER_CODE = 'c1x'; - -describe('C1XAdapter', function () { - const adapter = newBidder(c1xAdapter); - - 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': BIDDER_CODE, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'params': { - 'siteId': '9999' - } - }; - - it('should return true when required params are passed', function () { - expect(c1xAdapter.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not found', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'siteId': null - }; - expect(c1xAdapter.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': BIDDER_CODE, - 'params': { - 'siteId': '9999' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - const parseRequest = (data) => { - const parsedData = '{"' + data.replace(/=|&/g, (foundChar) => { - if (foundChar == '=') return '":"'; - else if (foundChar == '&') return '","'; - }) + '"}' - return parsedData; - }; - - it('sends bid request to ENDPOINT via GET', function () { - const request = c1xAdapter.buildRequests(bidRequests); - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('GET'); - }); - - it('should generate correct bid Id tag', function () { - const request = c1xAdapter.buildRequests(bidRequests); - expect(request.bids[0].adUnitCode).to.equal('adunit-code'); - expect(request.bids[0].bidId).to.equal('30b31c1838de1e'); - }); - - it('should convert params to proper form and attach to request', function () { - const request = c1xAdapter.buildRequests(bidRequests); - const originalPayload = parseRequest(request.data); - const payloadObj = JSON.parse(originalPayload); - expect(payloadObj.adunits).to.equal('1'); - expect(payloadObj.a1s).to.equal('300x250,300x600'); - expect(payloadObj.a1).to.equal('adunit-code'); - expect(payloadObj.site).to.equal('9999'); - }); - - it('should convert floor price to proper form and attach to request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - 'params': { - 'siteId': '9999', - 'floorPriceMap': { - '300x250': 4.35 - } - } - }); - const request = c1xAdapter.buildRequests([bidRequest]); - const originalPayload = parseRequest(request.data); - const payloadObj = JSON.parse(originalPayload); - expect(payloadObj.a1p).to.equal('4.35'); - }); - - it('should convert pageurl to proper form and attach to request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - 'params': { - 'siteId': '9999', - 'pageurl': 'https://c1exchange.com/' - } - }); - const request = c1xAdapter.buildRequests([bidRequest]); - const originalPayload = parseRequest(request.data); - const payloadObj = JSON.parse(originalPayload); - expect(payloadObj.pageurl).to.equal('https://c1exchange.com/'); - }); - - it('should convert GDPR Consent to proper form and attach to request', function () { - let consentString = 'BOP2gFWOQIFovABABAENBGAAAAAAMw'; - let bidderRequest = { - 'bidderCode': 'c1x', - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true - } - } - bidderRequest.bids = bidRequests; - - const request = c1xAdapter.buildRequests(bidRequests, bidderRequest); - const originalPayload = parseRequest(request.data); - const payloadObj = JSON.parse(originalPayload); - expect(payloadObj['consent_string']).to.equal('BOP2gFWOQIFovABABAENBGAAAAAAMw'); - expect(payloadObj['consent_required']).to.equal('true'); - }); - }); - - describe('interpretResponse', function () { - let response = { - 'bid': true, - 'cpm': 1.5, - 'ad': '', - 'width': 300, - 'height': 250, - 'crid': '8888', - 'adId': 'c1x-test', - 'bidType': 'GROSS_BID' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - width: 300, - height: 250, - cpm: 1.5, - ad: '', - creativeId: '8888', - currency: 'USD', - ttl: 300, - netRevenue: false, - requestId: 'yyyy' - } - ]; - let bidderRequest = {}; - bidderRequest.bids = [ - { adUnitCode: 'c1x-test', - bidId: 'yyyy' } - ]; - let result = c1xAdapter.interpretResponse({ body: [response] }, bidderRequest); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - let response = { - bid: false, - adId: 'c1x-test' - }; - let bidderRequest = {}; - let result = c1xAdapter.interpretResponse({ body: [response] }, bidderRequest); - expect(result.length).to.equal(0); - }); - }); -}); 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/cleanmedianetBidAdapter_spec.js b/test/spec/modules/cleanmedianetBidAdapter_spec.js index 5438f6c8701..c2eea6f32d7 100644 --- a/test/spec/modules/cleanmedianetBidAdapter_spec.js +++ b/test/spec/modules/cleanmedianetBidAdapter_spec.js @@ -31,22 +31,6 @@ describe('CleanmedianetAdapter', function () { ).to.equal(true); }); - it('should validate bid floor', function() { - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) - ).to.equal(true); // bidfloor has a default - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', bidfloor: '123' } - }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', bidfloor: 0.1 } - }) - ).to.equal(true); - }); - it('should validate adpos', function() { expect( spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) @@ -159,15 +143,6 @@ describe('CleanmedianetAdapter', function () { expect(response.data.imp[0].instl).to.equal( bidRequestWithInstlEquals0.params.instl ); - const bidRequestWithBidfloorEquals1 = utils.deepClone(bidRequest); - bidRequestWithBidfloorEquals1.params.bidfloor = 1; - response = spec.buildRequests( - [bidRequestWithBidfloorEquals1], - bidRequest2 - )[0]; - expect(response.data.imp[0].bidfloor).to.equal( - bidRequestWithBidfloorEquals1.params.bidfloor - ); }); it('builds request banner object correctly', function() { 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/cosmosBidAdapter_spec.js b/test/spec/modules/cosmosBidAdapter_spec.js deleted file mode 100644 index b33f53221e2..00000000000 --- a/test/spec/modules/cosmosBidAdapter_spec.js +++ /dev/null @@ -1,355 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/cosmosBidAdapter.js'; -import * as utils from 'src/utils.js'; -const constants = require('src/constants.json'); - -describe('Cosmos adapter', function () { - let bannerBidRequests; - let bannerBidResponse; - let videoBidRequests; - let videoBidResponse; - - beforeEach(function () { - bannerBidRequests = [ - { - bidder: 'cosmos', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - } - }, - params: { - publisherId: '1001', - currency: 'USD', - geo: { - lat: '09.5', - lon: '21.2', - } - }, - bidId: '29f8bd96defe76' - } - ]; - - videoBidRequests = - [ - { - mediaTypes: { - video: { - mimes: ['video/mp4', 'video/x-flv'], - context: 'instream' - } - }, - bidder: 'cosmos', - params: { - publisherId: 1001, - video: { - skippable: true, - minduration: 5, - maxduration: 30 - } - }, - bidId: '39f5cc6eff9b37' - } - ]; - - bannerBidResponse = { - 'body': { - 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', - 'seatbid': [{ - 'bid': [{ - 'id': '82DAAE22-FF66-4FAB-84AB-347B0C5CD02C', - 'impid': '29f8bd96defe76', - 'price': 1.858309, - 'adm': '

COSMOS\"Connecting Advertisers and Publishers directly\"

', - 'adid': 'v55jutrh', - 'adomain': ['febreze.com'], - 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', - 'cid': '1234', - 'crid': 'v55jutrh', - 'w': 300, - 'h': 250, - 'ext': { - 'prebid': { - 'type': 'banner' - } - } - }], - 'seat': 'zeta' - }] - } - }; - - videoBidResponse = { - 'body': { - 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', - 'seatbid': [{ - 'bid': [{ - 'id': '82DAAE22-FF66-4FAB-84AB-347B0C5CD02C', - 'impid': '39f5cc6eff9b37', - 'price': 0.858309, - 'adm': 'CosmosHQVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1https://track.cosmoshq.com/event?data=%7B%22id%22%3A%221566011421045%22%2C%22bid%22%3A%2282DAAE22-FF66-4FAB-84AB-347B0C5CD02C%22%2C%22ts%22%3A%2220190817031021%22%2C%22pid%22%3A1001%2C%22plcid%22%3A1%2C%22aid%22%3A1%2C%22did%22%3A1%2C%22cid%22%3A%2222918%22%2C%22af%22%3A3%2C%22at%22%3A1%2C%22w%22%3A300%2C%22h%22%3A250%2C%22crid%22%3A%22v55jutrh%22%2C%22pp%22%3A0.858309%2C%22cp%22%3A0.858309%2C%22mg%22%3A0%7D&type=1https//track.dsp.impression.com/impression00:00:60https//sync.cosmoshq.com/static/video/SampleVideo_1280x720_10mb.mp4', - 'adid': 'v55jutrh', - 'adomain': ['febreze.com'], - 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', - 'cid': '1234', - 'crid': 'v55jutrh', - 'w': 300, - 'h': 250, - 'ext': { - 'prebid': { - 'type': 'video' - } - } - }], - 'seat': 'zeta' - }] - } - }; - }); - - describe('isBidRequestValid', function () { - describe('validate the bid object: valid bid', function () { - it('valid bid case', function () { - let validBid = { - bidder: 'cosmos', - params: { - publisherId: 1001, - tagId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - }); - - it('validate the bid object: nil/empty bid object', function () { - let validBid = { - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - - it('validate the bid object: publisherId not passed', function () { - let validBid = { - bidder: 'cosmos', - params: { - tagId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - - it('validate the bid object: publisherId is not number', function () { - let validBid = { - bidder: 'cosmos', - params: { - publisherId: '301', - tagId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - - it('validate the bid object: mimes absent', function () { - let validBid = { - bidder: 'cosmos', - mediaTypes: { - video: {} - }, - params: { - publisherId: 1001 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - - it('validate the bid object: mimes present', function () { - let validBid = { - bidder: 'cosmos', - mediaTypes: { - video: { - mimes: ['video/mp4', 'application/javascript'] - } - }, - params: { - publisherId: 1001 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - }); - - it('validate the bid object: tagId is not passed', function () { - let validBid = { - bidder: 'cosmos', - params: { - publisherId: 1001 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - it('build request object: buildRequests function should not modify original bannerBidRequests object', function () { - let originalBidRequests = utils.deepClone(bannerBidRequests); - let request = spec.buildRequests(bannerBidRequests); - expect(bannerBidRequests).to.deep.equal(originalBidRequests); - }); - - it('build request object: endpoint check', function () { - let request = spec.buildRequests(bannerBidRequests); - expect(request[0].url).to.equal('https://bid.cosmoshq.com/openrtb2/bids'); - expect(request[0].method).to.equal('POST'); - }); - - it('build request object: request params check', function () { - let request = spec.buildRequests(bannerBidRequests); - let data = JSON.parse(request[0].data); - expect(data.site.publisher.id).to.equal(bannerBidRequests[0].params.publisherId); // publisher Id - expect(data.imp[0].bidfloorcur).to.equal(bannerBidRequests[0].params.currency); - }); - - it('build request object: request params check without tagId', function () { - delete bannerBidRequests[0].params.tagId; - let request = spec.buildRequests(bannerBidRequests); - let data = JSON.parse(request[0].data); - expect(data.site.publisher.id).to.equal(bannerBidRequests[0].params.publisherId); // publisher Id - expect(data.imp[0].tagid).to.equal(undefined); // tagid - expect(data.imp[0].bidfloorcur).to.equal(bannerBidRequests[0].params.currency); - }); - - it('build request object: request params multi size format object check', function () { - let bidRequest = [ - { - bidder: 'cosmos', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - } - }, - params: { - publisherId: 1001, - currency: 'USD' - } - } - ]; - /* case 1 - size passed in adslot */ - let request = spec.buildRequests(bidRequest); - let data = JSON.parse(request[0].data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - - /* case 2 - size passed in adslot as well as in sizes array */ - bidRequest[0].sizes = [[300, 600], [300, 250]]; - bidRequest[0].mediaTypes = { - banner: { - sizes: [[300, 600], [300, 250]] - } - }; - request = spec.buildRequests(bidRequest); - data = JSON.parse(request[0].data); - - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(600); // height - - /* case 3 - size passed in sizes but not in adslot */ - bidRequest[0].params.tagId = 1; - bidRequest[0].sizes = [[300, 250], [300, 600]]; - bidRequest[0].mediaTypes = { - banner: { - sizes: [[300, 250], [300, 600]] - } - }; - request = spec.buildRequests(bidRequest); - data = JSON.parse(request[0].data); - - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - expect(data.imp[0].banner.format).exist.and.to.be.an('array'); - expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); - expect(data.imp[0].banner.format[0].w).to.equal(300); // width - expect(data.imp[0].banner.format[0].h).to.equal(250); // height - }); - - it('build request object: request params currency check', function () { - let bidRequest = [ - { - bidder: 'cosmos', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - } - }, - params: { - publisherId: 1001, - tagId: 1, - currency: 'USD' - }, - sizes: [[300, 250], [300, 600]] - } - ]; - - /* case 1 - - currency specified in adunits - output: imp[0] use currency specified in bannerBidRequests[0].params.currency - - */ - let request = spec.buildRequests(bidRequest); - let data = JSON.parse(request[0].data); - expect(data.imp[0].bidfloorcur).to.equal(bidRequest[0].params.currency); - - /* case 2 - - currency specified in adunit - output: imp[0] use default currency - USD - - */ - delete bidRequest[0].params.currency; - request = spec.buildRequests(bidRequest); - data = JSON.parse(request[0].data); - expect(data.imp[0].bidfloorcur).to.equal('USD'); - }); - - it('build request object: request params check for video ad', function () { - let request = spec.buildRequests(videoBidRequests); - let data = JSON.parse(request[0].data); - expect(data.imp[0].video).to.exist; - expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); - expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].mediaTypes.video['mimes'][0]); - expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].mediaTypes.video['mimes'][1]); - expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); - expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); - }); - - describe('interpretResponse', function () { - it('check for banner response', function () { - let request = spec.buildRequests(bannerBidRequests); - let data = JSON.parse(request[0].data); - let response = spec.interpretResponse(bannerBidResponse, request[0]); - expect(response).to.be.an('array').with.length.above(0); - expect(response[0].requestId).to.equal(bannerBidResponse.body.seatbid[0].bid[0].impid); - expect(response[0].cpm).to.equal((bannerBidResponse.body.seatbid[0].bid[0].price).toFixed(2)); - expect(response[0].width).to.equal(bannerBidResponse.body.seatbid[0].bid[0].w); - expect(response[0].height).to.equal(bannerBidResponse.body.seatbid[0].bid[0].h); - if (bannerBidResponse.body.seatbid[0].bid[0].crid) { - expect(response[0].creativeId).to.equal(bannerBidResponse.body.seatbid[0].bid[0].crid); - } else { - expect(response[0].creativeId).to.equal(bannerBidResponse.body.seatbid[0].bid[0].id); - } - expect(response[0].dealId).to.equal(bannerBidResponse.body.seatbid[0].bid[0].dealid); - expect(response[0].currency).to.equal('USD'); - expect(response[0].netRevenue).to.equal(false); - expect(response[0].ttl).to.equal(300); - }); - it('check for video response', function () { - let request = spec.buildRequests(videoBidRequests); - let data = JSON.parse(request[0].data); - let response = spec.interpretResponse(videoBidResponse, request[0]); - }); - }); - }); - }); -}); 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/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index cad1e3f8114..550ead83380 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -1,5 +1,11 @@ import { expect } from 'chai'; -import { tryGetCriteoFastBid, spec, PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION } from 'modules/criteoBidAdapter.js'; +import { + tryGetCriteoFastBid, + spec, + PROFILE_ID_PUBLISHERTAG, + ADAPTER_VERSION, + canFastBid, getFastBidUrl, FAST_BID_VERSION_CURRENT +} from 'modules/criteoBidAdapter.js'; import { createBid } from 'src/bidfactory.js'; import CONSTANTS from 'src/constants.json'; import * as utils from 'src/utils.js'; @@ -66,7 +72,7 @@ describe('The Criteo bidding adapter', function () { expect(isValid).to.equal(true); }); - it('should return true when given a valid video bid request', function () { + it('should return true when given a valid video bid request using mix custom bidder video parameters', function () { expect(spec.isBidRequestValid({ bidder: 'criteo', mediaTypes: { @@ -112,6 +118,30 @@ describe('The Criteo bidding adapter', function () { })).to.equal(true); }); + it('should return true when given a valid video bid request using only mediaTypes.video parameters', function () { + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2], + skip: 1, + placement: 1, + minduration: 0, + playbackmethod: 1, + startdelay: 0 + } + }, + params: { + networkId: 456 + }, + })).to.equal(true); + }); + it('should return false when given an invalid video bid request', function () { expect(spec.isBidRequestValid({ bidder: 'criteo', @@ -896,6 +926,7 @@ describe('The Criteo bidding adapter', function () { width: 728, height: 90, dealCode: 'myDealCode', + adomain: ['criteo.com'], }], }, }; @@ -916,6 +947,7 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].width).to.equal(728); expect(bids[0].height).to.equal(90); expect(bids[0].dealId).to.equal('myDealCode'); + expect(bids[0].meta.advertiserDomains[0]).to.equal('criteo.com'); }); it('should properly parse a bid response with a zoneId', function () { @@ -1189,6 +1221,34 @@ describe('The Criteo bidding adapter', function () { }); }); + describe('canFastBid', function () { + it('should properly detect if can do fastbid', function () { + const testCasesAndExpectedResult = [['none', false], ['', true], [undefined, true], [123, true]]; + testCasesAndExpectedResult.forEach(testCase => { + const result = canFastBid(testCase[0]); + expect(result).to.equal(testCase[1]); + }) + }); + }); + + describe('getFastBidUrl', function () { + it('should properly detect the version of fastbid', function () { + const testCasesAndExpectedResult = [ + ['', 'https://static.criteo.net/js/ld/publishertag.prebid.' + FAST_BID_VERSION_CURRENT + '.js'], + [undefined, 'https://static.criteo.net/js/ld/publishertag.prebid.' + FAST_BID_VERSION_CURRENT + '.js'], + [null, 'https://static.criteo.net/js/ld/publishertag.prebid.' + FAST_BID_VERSION_CURRENT + '.js'], + [NaN, 'https://static.criteo.net/js/ld/publishertag.prebid.' + FAST_BID_VERSION_CURRENT + '.js'], + [123, 'https://static.criteo.net/js/ld/publishertag.prebid.123.js'], + ['123', 'https://static.criteo.net/js/ld/publishertag.prebid.123.js'], + ['latest', 'https://static.criteo.net/js/ld/publishertag.prebid.js'] + ]; + testCasesAndExpectedResult.forEach(testCase => { + const result = getFastBidUrl(testCase[0]); + expect(result).to.equal(testCase[1]); + }) + }); + }); + describe('tryGetCriteoFastBid', function () { const VALID_HASH = 'vBeD8Q7GU6lypFbzB07W8hLGj7NL+p7dI9ro2tCxkrmyv0F6stNuoNd75Us33iNKfEoW+cFWypelr6OJPXxki2MXWatRhJuUJZMcK4VBFnxi3Ro+3a0xEfxE4jJm4eGe98iC898M+/YFHfp+fEPEnS6pEyw124ONIFZFrcejpHU='; const INVALID_HASH = 'invalid'; diff --git a/test/spec/modules/dailyhuntBidAdapter_spec.js b/test/spec/modules/dailyhuntBidAdapter_spec.js deleted file mode 100644 index d571150dbee..00000000000 --- a/test/spec/modules/dailyhuntBidAdapter_spec.js +++ /dev/null @@ -1,400 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/dailyhuntBidAdapter.js'; - -const PROD_PREBID_ENDPOINT_URL = 'https://pbs.dailyhunt.in/openrtb2/auction?partner=dailyhunt'; -const PROD_PREBID_TEST_ENDPOINT_URL = 'https://qa-pbs-van.dailyhunt.in/openrtb2/auction?partner=dailyhunt'; - -const _encodeURIComponent = function (a) { - if (!a) { return } - let b = window.encodeURIComponent(a); - b = b.replace(/'/g, '%27'); - return b; -} - -describe('DailyhuntAdapter', function () { - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'dailyhunt', - 'params': { - placement_id: 1, - publisher_id: 1, - partner_name: 'dailyhunt' - } - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - describe('buildRequests', function() { - let bidRequests = [ - { - bidder: 'dailyhunt', - params: { - placement_id: 1, - publisher_id: 1, - partner_name: 'dailyhunt', - bidfloor: 0.1, - device: { - ip: '47.9.247.217' - }, - site: { - cat: ['1', '2', '3'] - } - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - adUnitCode: 'adunit-code', - sizes: [[300, 50]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843' - } - ]; - let nativeBidRequests = [ - { - bidder: 'dailyhunt', - params: { - placement_id: 1, - publisher_id: 1, - partner_name: 'dailyhunt', - }, - nativeParams: { - title: { - required: true, - len: 80 - }, - image: { - required: true, - sizes: [150, 50] - }, - }, - mediaTypes: { - native: { - title: { - required: true - }, - } - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 50]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843' - } - ]; - let videoBidRequests = [ - { - bidder: 'dailyhunt', - params: { - placement_id: 1, - publisher_id: 1, - partner_name: 'dailyhunt' - }, - nativeParams: { - video: { - context: 'instream' - } - }, - mediaTypes: { - video: { - context: 'instream' - } - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 50]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843' - } - ]; - let bidderRequest = { - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'bidderCode': 'dailyhunt', - 'bids': [ - { - ...bidRequests[0] - } - ], - 'refererInfo': { - 'referer': 'http://m.dailyhunt.in/' - } - }; - let nativeBidderRequest = { - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'bidderCode': 'dailyhunt', - 'bids': [ - { - ...nativeBidRequests[0] - } - ], - 'refererInfo': { - 'referer': 'http://m.dailyhunt.in/' - } - }; - let videoBidderRequest = { - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'bidderCode': 'dailyhunt', - 'bids': [ - { - ...videoBidRequests[0] - } - ], - 'refererInfo': { - 'referer': 'http://m.dailyhunt.in/' - } - }; - - it('sends display bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.url).to.equal(PROD_PREBID_ENDPOINT_URL); - expect(request.method).to.equal('POST'); - }); - - it('sends native bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(nativeBidRequests, nativeBidderRequest)[0]; - expect(request.url).to.equal(PROD_PREBID_ENDPOINT_URL); - expect(request.method).to.equal('POST'); - }); - - it('sends video bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(videoBidRequests, videoBidderRequest)[0]; - expect(request.url).to.equal(PROD_PREBID_ENDPOINT_URL); - expect(request.method).to.equal('POST'); - }); - }); - describe('interpretResponse', function () { - let bidResponses = { - id: 'da32def7-6779-403c-ada7-0b201dbc9744', - seatbid: [ - { - bid: [ - { - id: 'id1', - impid: 'banner-impid', - price: 1.4, - adm: 'adm', - adid: '66658', - crid: 'asd5ddbf014cac993.66466212', - dealid: 'asd5ddbf014cac993.66466212', - w: 300, - h: 250, - nurl: 'winUrl', - ext: { - prebid: { - type: 'banner' - } - } - }, - { - id: '5caccc1f-94a6-4230-a1f9-6186ee65da99', - impid: 'video-impid', - price: 1.4, - nurl: 'winUrl', - adm: 'adm', - adid: '980', - crid: '2394', - w: 300, - h: 250, - ext: { - prebid: { - 'type': 'video' - }, - bidder: { - cacheKey: 'cache_key', - vastUrl: 'vastUrl' - } - } - }, - { - id: '74973faf-cce7-4eff-abd0-b59b8e91ca87', - impid: 'native-impid', - price: 50, - nurl: 'winUrl', - adm: '{"native":{"link":{"url":"url","clicktrackers":[]},"assets":[{"id":1,"required":1,"img":{},"video":{},"data":{},"title":{"text":"TITLE"},"link":{}},{"id":1,"required":1,"img":{},"video":{},"data":{"type":2,"value":"Lorem Ipsum Lorem Ipsum Lorem Ipsum."},"title":{},"link":{}},{"id":1,"required":1,"img":{},"video":{},"data":{"type":12,"value":"Install Here"},"title":{},"link":{}},{"id":1,"required":1,"img":{"type":3,"url":"urk","w":990,"h":505},"video":{},"data":{},"title":{},"link":{}}],"imptrackers":[]}}', - adid: '968', - crid: '2370', - w: 300, - h: 250, - ext: { - prebid: { - type: 'native' - }, - bidder: null - } - }, - { - id: '5caccc1f-94a6-4230-a1f9-6186ee65da99', - impid: 'video-outstream-impid', - price: 1.4, - nurl: 'winUrl', - adm: 'adm', - adid: '980', - crid: '2394', - w: 300, - h: 250, - ext: { - prebid: { - 'type': 'video' - }, - bidder: { - cacheKey: 'cache_key', - vastUrl: 'vastUrl' - } - } - }, - ], - seat: 'dailyhunt' - } - ], - ext: { - responsetimemillis: { - dailyhunt: 119 - } - } - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - requestId: '1', - cpm: 1.4, - creativeId: 'asd5ddbf014cac993.66466212', - width: 300, - height: 250, - ttl: 360, - netRevenue: true, - currency: 'USD', - ad: 'adm', - mediaType: 'banner', - winUrl: 'winUrl' - }, - { - requestId: '2', - cpm: 1.4, - creativeId: '2394', - width: 300, - height: 250, - ttl: 360, - netRevenue: true, - currency: 'USD', - mediaType: 'video', - winUrl: 'winUrl', - videoCacheKey: 'cache_key', - vastUrl: 'vastUrl', - }, - { - requestId: '3', - cpm: 1.4, - creativeId: '2370', - width: 300, - height: 250, - ttl: 360, - netRevenue: true, - currency: 'USD', - mediaType: 'native', - winUrl: 'winUrl', - native: { - clickUrl: 'https%3A%2F%2Fmontu1996.github.io%2F', - clickTrackers: [], - impressionTrackers: [], - javascriptTrackers: [], - title: 'TITLE', - body: 'Lorem Ipsum Lorem Ipsum Lorem Ipsum.', - cta: 'Install Here', - image: { - url: 'url', - height: 505, - width: 990 - } - } - }, - { - requestId: '4', - cpm: 1.4, - creativeId: '2394', - width: 300, - height: 250, - ttl: 360, - netRevenue: true, - currency: 'USD', - mediaType: 'video', - winUrl: 'winUrl', - vastXml: 'adm', - }, - ]; - let bidderRequest = { - bids: [ - { - bidId: 'banner-impid', - adUnitCode: 'code1', - requestId: '1' - }, - { - bidId: 'video-impid', - adUnitCode: 'code2', - requestId: '2', - mediaTypes: { - video: { - context: 'instream' - } - } - }, - { - bidId: 'native-impid', - adUnitCode: 'code3', - requestId: '3' - }, - { - bidId: 'video-outstream-impid', - adUnitCode: 'code4', - requestId: '4', - mediaTypes: { - video: { - context: 'outstream' - } - } - }, - ] - } - let result = spec.interpretResponse({ body: bidResponses }, bidderRequest); - result.forEach((r, i) => { - expect(Object.keys(r)).to.have.members(Object.keys(expectedResponse[i])); - }); - }); - }) - describe('onBidWon', function () { - it('should hit win url when bid won', function () { - let bid = { - requestId: '1', - cpm: 1.4, - creativeId: 'asd5ddbf014cac993.66466212', - width: 300, - height: 250, - ttl: 360, - netRevenue: true, - currency: 'USD', - ad: 'adm', - mediaType: 'banner', - winUrl: 'winUrl' - }; - expect(spec.onBidWon(bid)).to.equal(undefined); - }); - }) -}) 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/districtmDmxBidAdapter_spec.js b/test/spec/modules/districtmDmxBidAdapter_spec.js index 90c18c6a84f..4c060b1f5a4 100644 --- a/test/spec/modules/districtmDmxBidAdapter_spec.js +++ b/test/spec/modules/districtmDmxBidAdapter_spec.js @@ -114,7 +114,6 @@ const bidRequest = [{ lotamePanoramaId: {}, parrableId: {}, netId: {}, - sharedid: {}, lipb: { lipbid: {} }, 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/ebdrBidAdapter_spec.js b/test/spec/modules/ebdrBidAdapter_spec.js deleted file mode 100644 index ba1cad475da..00000000000 --- a/test/spec/modules/ebdrBidAdapter_spec.js +++ /dev/null @@ -1,235 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/ebdrBidAdapter.js'; -import { VIDEO, BANNER } from 'src/mediaTypes.js'; -import * as utils from 'src/utils.js'; - -describe('ebdrBidAdapter', function () { - let bidRequests; - - beforeEach(function () { - bidRequests = [ - { - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - } - }, - bidder: 'ebdr', - params: { - zoneid: '99999', - bidfloor: '1.00', - IDFA: 'xxx-xxx', - ADID: 'xxx-xxx', - latitude: '34.089811', - longitude: '-118.392805' - }, - bidId: '2c5e8a1a84522d', - bidderRequestId: '1d0c4017f02458', - auctionId: '9adc85ed-43ee-4a78-816b-52b7e578f314' - }, { - adUnitCode: 'div-gpt-ad-1460505748561-1', - mediaTypes: { - video: { - context: 'instream', - playerSize: [300, 250] - } - }, - bidder: 'ebdr', - params: { - zoneid: '99998', - bidfloor: '1.00', - IDFA: 'xxx-xxx', - ADID: 'xxx-xxx', - latitude: '34.089811', - longitude: '-118.392805' - }, - bidId: '23a01e95856577', - bidderRequestId: '1d0c4017f02458', - auctionId: '9adc85ed-43ee-4a78-816b-52b7e578f314' - } - ]; - }); - - describe('spec.isBidRequestValid', function () { - it('should return true when the required params are passed', function () { - const bidRequest = bidRequests[0]; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true when the only required param is missing', function () { - const bidRequest = bidRequests[0]; - bidRequest.params = { - zoneid: '99998', - bidfloor: '1.00', - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true when the "bidfloor" param is missing', function () { - const bidRequest = bidRequests[0]; - bidRequest.params = { - zoneid: '99998', - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return false when no bid params are passed', function () { - const bidRequest = bidRequests[0]; - bidRequest.params = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when a bid request is not passed', function () { - expect(spec.isBidRequestValid()).to.equal(false); - expect(spec.isBidRequestValid({})).to.equal(false); - }); - }); - - describe('spec.buildRequests', function () { - describe('for banner bids', function () { - it('must handle an empty bid size', function () { - bidRequests[0].mediaTypes = { banner: {} }; - const requests = spec.buildRequests(bidRequests); - const bidRequest = {}; - bidRequest['2c5e8a1a84522d'] = { mediaTypes: BANNER, w: null, h: null }; - expect(requests.bids['2c5e8a1a84522d']).to.deep.equals(bidRequest['2c5e8a1a84522d']); - }); - it('should create a single GET', function () { - bidRequests[0].mediaTypes = { banner: {} }; - bidRequests[1].mediaTypes = { banner: {} }; - const requests = spec.buildRequests(bidRequests); - expect(requests.method).to.equal('GET'); - }); - it('must parse bid size from a nested array', function () { - const width = 640; - const height = 480; - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {sizes: [[ width, height ]]} }; - const requests = spec.buildRequests([ bidRequest ]); - const data = {}; - data['2c5e8a1a84522d'] = { mediaTypes: BANNER, w: width, h: height }; - expect(requests.bids['2c5e8a1a84522d']).to.deep.equal(data['2c5e8a1a84522d']); - }); - }); - describe('for video bids', function () { - it('must handle an empty bid size', function () { - bidRequests[1].mediaTypes = { video: {} }; - const requests = spec.buildRequests(bidRequests); - const bidRequest = {}; - bidRequest['23a01e95856577'] = { mediaTypes: VIDEO, w: null, h: null }; - expect(requests.bids['23a01e95856577']).to.deep.equals(bidRequest['23a01e95856577']); - }); - - it('should create a GET request for each bid', function () { - const bidRequest = bidRequests[1]; - const requests = spec.buildRequests([ bidRequest ]); - expect(requests.method).to.equal('GET'); - }); - }); - }); - - describe('spec.interpretResponse', function () { - describe('for video bids', function () { - it('should return no bids if the response is not valid', function () { - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { video: {} }; - const bidResponse = spec.interpretResponse({ body: null }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return a valid video bid response', function () { - const ebdrReq = {bids: {}}; - bidRequests.forEach(bid => { - let _mediaTypes = (bid.mediaTypes && bid.mediaTypes.video ? VIDEO : BANNER); - ebdrReq.bids[bid.bidId] = {mediaTypes: _mediaTypes, - w: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][0] : bid.mediaTypes[_mediaTypes].playerSize[0], - h: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1] - }; - }); - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '23a01e95856577', impid: '23a01e95856577', price: 0.81, adid: 'abcde-12345', nurl: 'https://cdn0.bnmla.com/vtest.xml', adm: '\nStatic VASTStatic VAST Tag00:00:15https//www.engagebdr.com/c', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, ebdrReq); - expect(bidResponse[0]).to.deep.equal({ - requestId: bidRequests[1].bidId, - vastXml: serverResponse.seatbid[0].bid[0].adm, - mediaType: 'video', - creativeId: serverResponse.seatbid[0].bid[0].crid, - cpm: serverResponse.seatbid[0].bid[0].price, - width: serverResponse.seatbid[0].bid[0].w, - height: serverResponse.seatbid[0].bid[0].h, - currency: 'USD', - netRevenue: true, - ttl: 3600, - vastUrl: serverResponse.seatbid[0].bid[0].nurl - }); - }); - }); - - describe('for banner bids', function () { - it('should return no bids if the response is not valid', function () { - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {} }; - const bidResponse = spec.interpretResponse({ body: null }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return no bids if the response is empty', function () { - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {} }; - const bidResponse = spec.interpretResponse({ body: [] }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return valid banner bid responses', function () { - const ebdrReq = {bids: {}}; - bidRequests.forEach(bid => { - let _mediaTypes = (bid.mediaTypes && bid.mediaTypes.video ? VIDEO : BANNER); - ebdrReq.bids[bid.bidId] = {mediaTypes: _mediaTypes, - w: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][0] : bid.mediaTypes[_mediaTypes].playerSize[0], - h: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1] - }; - }); - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, ebdrReq); - expect(bidResponse[0]).to.deep.equal({ - requestId: bidRequests[ 0 ].bidId, - ad: serverResponse.seatbid[0].bid[0].adm, - mediaType: 'banner', - creativeId: serverResponse.seatbid[0].bid[0].crid, - cpm: serverResponse.seatbid[0].bid[0].price, - width: serverResponse.seatbid[0].bid[0].w, - height: serverResponse.seatbid[0].bid[0].h, - currency: 'USD', - netRevenue: true, - ttl: 3600 - }); - }); - }); - }); - describe('spec.getUserSyncs', function () { - let syncOptions - beforeEach(function () { - syncOptions = { - enabledBidders: ['ebdr'], // only these bidders are allowed to sync - pixelEnabled: true - } - }); - it('sucess with usersync url', function () { - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: 'https://match.bnmla.com/usersync?sspid=59&redir=', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; - const result = []; - result.push({type: 'image', url: 'https://match.bnmla.com/usersync?sspid=59&redir='}); - expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result); - }); - - it('sucess without usersync url', function () { - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; - const result = []; - expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result); - }); - it('empty response', function () { - const serverResponse = {}; - const result = []; - expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result); - }); - }); -}); 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/eids_spec.js b/test/spec/modules/eids_spec.js index 1ccaab2b302..c343f4359f7 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -224,42 +224,6 @@ describe('eids array generation for known sub-modules', function() { uids: [{id: 'some-random-id-value', atype: 1}] }); }); - it('Sharedid', function() { - const userId = { - sharedid: { - id: 'test_sharedId', - third: 'test_sharedId' - } - }; - const newEids = createEidsArray(userId); - expect(newEids.length).to.equal(1); - expect(newEids[0]).to.deep.equal({ - source: 'sharedid.org', - uids: [{ - id: 'test_sharedId', - atype: 1, - ext: { - third: 'test_sharedId' - } - }] - }); - }); - it('Sharedid: Not Synched', function() { - const userId = { - sharedid: { - id: 'test_sharedId' - } - }; - const newEids = createEidsArray(userId); - expect(newEids.length).to.equal(1); - expect(newEids[0]).to.deep.equal({ - source: 'sharedid.org', - uids: [{ - id: 'test_sharedId', - atype: 1 - }] - }); - }); it('zeotapIdPlus', function() { const userId = { 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/getintentBidAdapter_spec.js b/test/spec/modules/getintentBidAdapter_spec.js deleted file mode 100644 index 1959bda5c39..00000000000 --- a/test/spec/modules/getintentBidAdapter_spec.js +++ /dev/null @@ -1,142 +0,0 @@ -import { expect } from 'chai' -import { spec } from 'modules/getintentBidAdapter.js' - -describe('GetIntent Adapter Tests:', function () { - const bidRequests = [{ - bidId: 'bid12345', - params: { - pid: 'p1000', - tid: 't1000' - }, - sizes: [[300, 250]] - }, - { - bidId: 'bid54321', - params: { - pid: 'p1000', - tid: 't1000' - }, - sizes: [[50, 50], [100, 100]] - }] - const videoBidRequest = { - bidId: 'bid789', - params: { - pid: 'p1001', - tid: 't1001', - video: { - mimes: ['video/mp4', 'application/javascript'], - max_dur: 20, - api: [1, 2], - skippable: true - } - }, - sizes: [300, 250], - mediaType: 'video' - }; - - it('Verify build request', function () { - const serverRequests = spec.buildRequests(bidRequests); - let serverRequest = serverRequests[0]; - expect(serverRequest.url).to.equal('https://px.adhigh.net/rtb/direct_banner'); - expect(serverRequest.method).to.equal('GET'); - expect(serverRequest.data.bid_id).to.equal('bid12345'); - expect(serverRequest.data.pid).to.equal('p1000'); - expect(serverRequest.data.tid).to.equal('t1000'); - expect(serverRequest.data.size).to.equal('300x250'); - expect(serverRequest.data.is_video).to.equal(false); - serverRequest = serverRequests[1]; - expect(serverRequest.data.size).to.equal('50x50,100x100'); - }); - - it('Verify build video request', function () { - const serverRequests = spec.buildRequests([videoBidRequest]); - let serverRequest = serverRequests[0]; - expect(serverRequest.url).to.equal('https://px.adhigh.net/rtb/direct_vast'); - expect(serverRequest.method).to.equal('GET'); - expect(serverRequest.data.bid_id).to.equal('bid789'); - expect(serverRequest.data.pid).to.equal('p1001'); - expect(serverRequest.data.tid).to.equal('t1001'); - expect(serverRequest.data.size).to.equal('300x250'); - expect(serverRequest.data.is_video).to.equal(true); - expect(serverRequest.data.mimes).to.equal('video/mp4,application/javascript'); - expect(serverRequest.data.max_dur).to.equal(20); - expect(serverRequest.data.api).to.equal('1,2'); - expect(serverRequest.data.skippable).to.equal(true); - }); - - it('Verify parse response', function () { - const serverResponse = { - body: { - bid_id: 'bid12345', - cpm: 2.25, - currency: 'USD', - size: '300x250', - creative_id: '1000', - ad: 'Ad markup' - }, - headers: { - } - }; - const bids = spec.interpretResponse(serverResponse); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.cpm).to.equal(2.25); - expect(bid.currency).to.equal('USD'); - expect(bid.creativeId).to.equal('1000'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.requestId).to.equal('bid12345'); - expect(bid.mediaType).to.equal('banner'); - expect(bid.ad).to.equal('Ad markup'); - }); - - it('Verify parse video response', function () { - const serverResponse = { - body: { - bid_id: 'bid789', - cpm: 3.25, - currency: 'USD', - size: '300x250', - creative_id: '2000', - vast_url: 'https://vast.xml/url' - }, - headers: { - } - }; - const bids = spec.interpretResponse(serverResponse); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.cpm).to.equal(3.25); - expect(bid.currency).to.equal('USD'); - expect(bid.creativeId).to.equal('2000'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.requestId).to.equal('bid789'); - expect(bid.mediaType).to.equal('video'); - expect(bid.vastUrl).to.equal('https://vast.xml/url'); - }); - - it('Verify bidder code', function () { - expect(spec.code).to.equal('getintent'); - }); - - it('Verify bidder aliases', function () { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.equal('getintentAdapter'); - }); - - it('Verify supported media types', function () { - expect(spec.supportedMediaTypes).to.have.lengthOf(2); - expect(spec.supportedMediaTypes[0]).to.equal('video'); - expect(spec.supportedMediaTypes[1]).to.equal('banner'); - }); - - it('Verify if bid request valid', function () { - expect(spec.isBidRequestValid(bidRequests[0])).to.equal(true); - expect(spec.isBidRequestValid(bidRequests[1])).to.equal(true); - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({ params: {} })).to.equal(false); - expect(spec.isBidRequestValid({ params: { test: 123 } })).to.equal(false); - expect(spec.isBidRequestValid({ params: { pid: 111, tid: 222 } })).to.equal(true); - }); -}); 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/iasBidAdapter_spec.js b/test/spec/modules/iasBidAdapter_spec.js deleted file mode 100644 index 1743ac947e6..00000000000 --- a/test/spec/modules/iasBidAdapter_spec.js +++ /dev/null @@ -1,343 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/iasBidAdapter.js'; - -describe('iasBidAdapter is an adapter that', function () { - it('has the correct bidder code', function () { - expect(spec.code).to.equal('ias'); - }); - describe('has a method `isBidRequestValid` that', function () { - it('exists', function () { - expect(spec.isBidRequestValid).to.be.a('function'); - }); - it('returns false if bid params misses `pubId`', function () { - expect(spec.isBidRequestValid( - { - params: { - adUnitPath: 'someAdUnitPath' - } - })).to.equal(false); - }); - it('returns false if bid params misses `adUnitPath`', function () { - expect(spec.isBidRequestValid( - { - params: { - pubId: 'somePubId' - } - })).to.equal(false); - }); - it('returns true otherwise', function () { - expect(spec.isBidRequestValid( - { - params: { - adUnitPath: 'someAdUnitPath', - pubId: 'somePubId', - someOtherParam: 'abc' - } - })).to.equal(true); - }); - }); - - describe('has a method `buildRequests` that', function () { - it('exists', function () { - expect(spec.buildRequests).to.be.a('function'); - }); - describe('given bid requests, returns a `ServerRequest` instance that', function () { - let bidRequests, IAS_HOST; - beforeEach(function () { - IAS_HOST = 'https://pixel.adsafeprotected.com/services/pub'; - bidRequests = [ - { - adUnitCode: 'one-div-id', - auctionId: 'someAuctionId', - bidId: 'someBidId', - bidder: 'ias', - bidderRequestId: 'someBidderRequestId', - params: { - pubId: '1234', - adUnitPath: '/a/b/c' - }, - sizes: [ - [10, 20], - [300, 400] - ], - transactionId: 'someTransactionId' - }, - { - adUnitCode: 'two-div-id', - auctionId: 'someAuctionId', - bidId: 'someBidId', - bidder: 'ias', - bidderRequestId: 'someBidderRequestId', - params: { - pubId: '1234', - adUnitPath: '/d/e/f' - }, - sizes: [ - [50, 60] - ], - transactionId: 'someTransactionId' - } - ]; - }); - it('has property `method` of `GET`', function () { - expect(spec.buildRequests(bidRequests)).to.deep.include({ - method: 'GET' - }); - }); - it('has property `url` to be the correct IAS endpoint', function () { - expect(spec.buildRequests(bidRequests)).to.deep.include({ - url: IAS_HOST - }); - }); - it('only includes the first `bidRequest` as the bidRequest variable on a multiple slot request', function () { - expect(spec.buildRequests(bidRequests).bidRequest.adUnitCode).to.equal(bidRequests[0].adUnitCode); - }); - describe('has property `data` that is an encode query string containing information such as', function () { - let val; - const ANID_PARAM = 'anId'; - const SLOT_PARAM = 'slot'; - const SLOT_ID_PARAM = 'id'; - const SLOT_SIZE_PARAM = 'ss'; - const SLOT_AD_UNIT_PATH_PARAM = 'p'; - - beforeEach(function () { - val = decodeURI(spec.buildRequests(bidRequests).data); - }); - it('publisher id', function () { - expect(val).to.have.string(`${ANID_PARAM}=1234`); - }); - it('ad slot`s id, size and ad unit path', function () { - expect(val).to.have.string(`${SLOT_PARAM}={${SLOT_ID_PARAM}:one-div-id,${SLOT_SIZE_PARAM}:[10.20,300.400],${SLOT_AD_UNIT_PATH_PARAM}:/a/b/c}`); - expect(val).to.have.string(`${SLOT_PARAM}={${SLOT_ID_PARAM}:two-div-id,${SLOT_SIZE_PARAM}:[50.60],${SLOT_AD_UNIT_PATH_PARAM}:/d/e/f}`); - }); - it('window size', function () { - expect(val).to.match(/.*wr=[0-9]*\.[0-9]*/); - }); - it('screen size', function () { - expect(val).to.match(/.*sr=[0-9]*\.[0-9]*/); - }); - it('url value', function () { - expect(val).to.match(/.*url=https?%3A%2F%2F[^\s$.?#].[^\s]*/); - }); - }); - it('has property `bidRequest` that is the first passed in bid request', function () { - expect(spec.buildRequests(bidRequests)).to.deep.include({ - bidRequest: bidRequests[0] - }); - }); - }); - }); - describe('has a method `interpretResponse` that', function () { - it('exists', function () { - expect(spec.interpretResponse).to.be.a('function'); - }); - describe('returns a list of bid response that', function () { - let bidRequests, bidResponse, slots, serverResponse; - beforeEach(function () { - bidRequests = [ - { - adUnitCode: 'one-div-id', - auctionId: 'someAuctionId', - bidId: 'someBidId1', - bidder: 'ias', - bidderRequestId: 'someBidderRequestId', - params: { - pubId: '1234', - adUnitPath: '/a/b/c' - }, - sizes: [ - [10, 20], - [300, 400] - ], - transactionId: 'someTransactionId' - }, - { - adUnitCode: 'two-div-id', - auctionId: 'someAuctionId', - bidId: 'someBidId2', - bidder: 'ias', - bidderRequestId: 'someBidderRequestId', - params: { - pubId: '1234', - adUnitPath: '/d/e/f' - }, - sizes: [ - [50, 60] - ], - transactionId: 'someTransactionId' - } - ]; - const request = { - bidRequest: { - bidId: '102938' - } - }; - slots = {}; - slots['test-div-id'] = { - id: '1234', - vw: ['60', '70'] - }; - slots['test-div-id-two'] = { - id: '5678', - vw: ['80', '90'] - }; - serverResponse = { - body: { - brandSafety: { - adt: 'adtVal', - alc: 'alcVal', - dlm: 'dlmVal', - drg: 'drgVal', - hat: 'hatVal', - off: 'offVal', - vio: 'vioVal' - }, - fr: 'false', - slots: slots - }, - headers: {} - }; - bidResponse = spec.interpretResponse(serverResponse, request); - }); - it('has IAS keyword `adt` as property', function () { - expect(bidResponse[0]).to.deep.include({ adt: 'adtVal' }); - }); - it('has IAS keyword `alc` as property', function () { - expect(bidResponse[0]).to.deep.include({ alc: 'alcVal' }); - }); - it('has IAS keyword `dlm` as property', function () { - expect(bidResponse[0]).to.deep.include({ dlm: 'dlmVal' }); - }); - it('has IAS keyword `drg` as property', function () { - expect(bidResponse[0]).to.deep.include({ drg: 'drgVal' }); - }); - it('has IAS keyword `hat` as property', function () { - expect(bidResponse[0]).to.deep.include({ hat: 'hatVal' }); - }); - it('has IAS keyword `off` as property', function () { - expect(bidResponse[0]).to.deep.include({ off: 'offVal' }); - }); - it('has IAS keyword `vio` as property', function () { - expect(bidResponse[0]).to.deep.include({ vio: 'vioVal' }); - }); - it('has IAS keyword `fr` as property', function () { - expect(bidResponse[0]).to.deep.include({ fr: 'false' }); - }); - it('has property `slots`', function () { - expect(bidResponse[0]).to.deep.include({ slots: slots }); - }); - it('response is the same for multiple slots', function () { - var adapter = spec; - var requests = adapter.buildRequests(bidRequests); - expect(adapter.interpretResponse(serverResponse, requests)).to.length(2); - }); - }); - describe('returns a list of bid response that with custom value', function () { - let bidRequests, bidResponse, slots, custom, serverResponse; - beforeEach(function () { - bidRequests = [ - { - adUnitCode: 'one-div-id', - auctionId: 'someAuctionId', - bidId: 'someBidId1', - bidder: 'ias', - bidderRequestId: 'someBidderRequestId', - params: { - pubId: '1234', - adUnitPath: '/a/b/c' - }, - sizes: [ - [10, 20], - [300, 400] - ], - transactionId: 'someTransactionId' - }, - { - adUnitCode: 'two-div-id', - auctionId: 'someAuctionId', - bidId: 'someBidId2', - bidder: 'ias', - bidderRequestId: 'someBidderRequestId', - params: { - pubId: '1234', - adUnitPath: '/d/e/f' - }, - sizes: [ - [50, 60] - ], - transactionId: 'someTransactionId' - } - ]; - const request = { - bidRequest: { - bidId: '102938' - } - }; - slots = {}; - slots['test-div-id'] = { - id: '1234', - vw: ['60', '70'] - }; - slots['test-div-id-two'] = { - id: '5678', - vw: ['80', '90'] - }; - custom = {}; - custom['ias-kw'] = ['IAS_1_KW', 'IAS_2_KW']; - serverResponse = { - body: { - brandSafety: { - adt: 'adtVal', - alc: 'alcVal', - dlm: 'dlmVal', - drg: 'drgVal', - hat: 'hatVal', - off: 'offVal', - vio: 'vioVal' - }, - fr: 'false', - slots: slots, - custom: custom - }, - headers: {} - }; - bidResponse = spec.interpretResponse(serverResponse, request); - }); - it('has IAS keyword `adt` as property', function () { - expect(bidResponse[0]).to.deep.include({ adt: 'adtVal' }); - }); - it('has IAS keyword `alc` as property', function () { - expect(bidResponse[0]).to.deep.include({ alc: 'alcVal' }); - }); - it('has IAS keyword `dlm` as property', function () { - expect(bidResponse[0]).to.deep.include({ dlm: 'dlmVal' }); - }); - it('has IAS keyword `drg` as property', function () { - expect(bidResponse[0]).to.deep.include({ drg: 'drgVal' }); - }); - it('has IAS keyword `hat` as property', function () { - expect(bidResponse[0]).to.deep.include({ hat: 'hatVal' }); - }); - it('has IAS keyword `off` as property', function () { - expect(bidResponse[0]).to.deep.include({ off: 'offVal' }); - }); - it('has IAS keyword `vio` as property', function () { - expect(bidResponse[0]).to.deep.include({ vio: 'vioVal' }); - }); - it('has IAS keyword `fr` as property', function () { - expect(bidResponse[0]).to.deep.include({ fr: 'false' }); - }); - it('has property `slots`', function () { - expect(bidResponse[0]).to.deep.include({ slots: slots }); - }); - it('has property `custom`', function () { - expect(bidResponse[0]).to.deep.include({ custom: custom }); - }); - it('response is the same for multiple slots', function () { - var adapter = spec; - var requests = adapter.buildRequests(bidRequests); - expect(adapter.interpretResponse(serverResponse, requests)).to.length(3); - }); - }); - }); -}); diff --git a/test/spec/modules/imonomyBidAdapter_spec.js b/test/spec/modules/imonomyBidAdapter_spec.js deleted file mode 100644 index 45b3bed6e77..00000000000 --- a/test/spec/modules/imonomyBidAdapter_spec.js +++ /dev/null @@ -1,164 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/imonomyBidAdapter.js'; - -describe('Imonomy Adapter Tests', function () { - const bidsRequest = [ - { - bidder: 'imonomy', - params: { - placementId: '170577', - hbid: '14567718624', - }, - placementCode: 'div-gpt-ad-1460505748561-0', - transactionId: '9f801c02-bbe8-4683-8ed4-bc816ea186bb', - sizes: [ - [300, 250] - ], - bidId: '2faedf1095f815', - bidderRequestId: '18065867f8ae39', - auctionId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' - }, - { - bidder: 'imonomy', - params: { - placementId: '281277', - hbid: '14567718624', - floorPrice: 0.5 - }, - placementCode: 'div-gpt-ad-1460505748561-0', - transactionId: '9f801c02-bbe8-4683-8ed4-bc816ea186bb', - sizes: [ - [728, 90] - ], - bidId: '3c34e2367a3f59', - bidderRequestId: '18065867f8ae39', - auctionId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' - }]; - - const bidsResponse = { - body: { - bids: [ - { - placementid: '170577', - uuid: '2faedf1095f815', - width: 300, - height: 250, - cpm: 0.51, - creative: '', - ttl: 360, - currency: 'USD', - netRevenue: true, - creativeId: 'd30b58c2ba' - } - ] - } - }; - - it('Verifies imonomyAdapter bidder code', function () { - expect(spec.code).to.equal('imonomy'); - }); - - it('Verifies imonomyAdapter bid request validation', function () { - expect(spec.isBidRequestValid(bidsRequest[0])).to.equal(true); - expect(spec.isBidRequestValid(bidsRequest[1])).to.equal(true); - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({ params: {} })).to.equal(false); - expect(spec.isBidRequestValid({ params: { hbid: 12345 } })).to.equal(false); - expect(spec.isBidRequestValid({ params: { placementid: 12345 } })).to.equal(false); - expect(spec.isBidRequestValid({ params: { hbid: 12345, placementId: 67890 } })).to.equal(true); - expect(spec.isBidRequestValid({ params: { hbid: 12345, placementId: 67890, floorPrice: 0.8 } })).to.equal(true); - }); - - it('Verify imonomyAdapter build request', function () { - var startTime = new Date().getTime(); - - const request = spec.buildRequests(bidsRequest); - expect(request.url).to.equal('https://b.imonomy.com/openrtb/hb/14567718624'); - expect(request.method).to.equal('POST'); - const requestData = JSON.parse(request.data); - - // bids object - let bids = requestData.bids; - expect(bids).to.have.lengthOf(2); - - // first bid request: no floor price - expect(bids[0].uuid).to.equal('2faedf1095f815'); - expect(bids[0].floorprice).to.be.undefined; - expect(bids[0].placementid).to.equal('170577'); - expect(bids[0].hbid).to.equal('14567718624'); - expect(bids[0].trid).to.equal('9f801c02-bbe8-4683-8ed4-bc816ea186bb'); - expect(bids[0].sizes).to.have.lengthOf(1); - expect(bids[0].sizes[0][0]).to.equal(300); - expect(bids[0].sizes[0][1]).to.equal(250); - - // second bid request: with floor price - expect(bids[1].uuid).to.equal('3c34e2367a3f59'); - expect(bids[1].floorprice).to.equal(0.5); - expect(bids[1].placementid).to.equal('281277'); - expect(bids[1].hbid).to.equal('14567718624'); - expect(bids[1].trid).to.equal('9f801c02-bbe8-4683-8ed4-bc816ea186bb'); - expect(bids[1]).to.have.property('sizes') - .that.is.an('array') - .of.length(1) - .that.deep.equals([[728, 90]]); - - // kbConf object - let kbConf = requestData.kbConf; - expect(kbConf.hdbdid).to.equal(bids[0].hbid); - expect(kbConf.hdbdid).to.equal(bids[1].hbid); - expect(kbConf.encode_bid).to.be.undefined; - // kbConf timezone and cb - expect(kbConf.cb).not.to.be.undefined; - expect(kbConf.ts_as).to.be.above(startTime - 1); - expect(kbConf.tz).to.equal(new Date().getTimezoneOffset()); - // kbConf bid ids - expect(kbConf.hb_placement_bidids) - .to.have.property(bids[0].placementid) - .that.equal(bids[0].uuid); - expect(kbConf.hb_placement_bidids) - .to.have.property(bids[1].placementid) - .that.equal(bids[1].uuid); - // kbConf floor price - expect(kbConf.hb_floors).not.to.have.property(bids[0].placementid) - expect(kbConf.hb_floors).to.have.property(bids[1].placementid).that.equal(bids[1].floorprice); - // kbConf placement ids - expect(kbConf.hb_placements).to.have.lengthOf(2); - expect(kbConf.hb_placements[0]).to.equal(bids[0].placementid); - expect(kbConf.hb_placements[1]).to.equal(bids[1].placementid); - }); - - it('Verify imonomyAdapter build response', function () { - const request = spec.buildRequests(bidsRequest); - const bids = spec.interpretResponse(bidsResponse, request); - - // 'server' return single bid - expect(bids).to.have.lengthOf(1); - - // verify bid object - const bid = bids[0]; - const responseBids = bidsResponse.body.bids; - - expect(bid.cpm).to.equal(responseBids[0].cpm); - expect(bid.ad).to.equal(responseBids[0].creative); - expect(bid.requestId).equal(responseBids[0].uuid); - expect(bid.uuid).equal(responseBids[0].uuid); - expect(bid.width).to.equal(responseBids[0].width); - expect(bid.height).to.equal(responseBids[0].height); - expect(bid.ttl).to.equal(responseBids[0].ttl); - expect(bid.currency).to.equal('USD'); - expect(bid.netRevenue).to.equal(true); - expect(bid.creativeId).to.equal(responseBids[0].creativeId); - }); - - it('Verifies imonomyAdapter sync options', function () { - // user sync disabled - expect(spec.getUserSyncs({})).to.be.undefined; - expect(spec.getUserSyncs({ iframeEnabled: false })).to.be.undefined; - // user sync enabled - 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://b.imonomy.com/UserMatching/b/'); - }); -}); 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/komoonaBidAdapter_spec.js b/test/spec/modules/komoonaBidAdapter_spec.js deleted file mode 100644 index 3d62f91cae6..00000000000 --- a/test/spec/modules/komoonaBidAdapter_spec.js +++ /dev/null @@ -1,164 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/komoonaBidAdapter.js'; - -describe('Komoona.com Adapter Tests', function () { - const bidsRequest = [ - { - bidder: 'komoona', - params: { - placementId: '170577', - hbid: 'abc12345678', - }, - placementCode: 'div-gpt-ad-1460505748561-0', - transactionId: '9f801c02-bbe8-4683-8ed4-bc816ea186bb', - sizes: [ - [300, 250] - ], - bidId: '2faedf1095f815', - bidderRequestId: '18065867f8ae39', - auctionId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' - }, - { - bidder: 'komoona', - params: { - placementId: '281277', - hbid: 'abc12345678', - floorPrice: 0.5 - }, - placementCode: 'div-gpt-ad-1460505748561-0', - transactionId: '9f801c02-bbe8-4683-8ed4-bc816ea186bb', - sizes: [ - [728, 90] - ], - bidId: '3c34e2367a3f59', - bidderRequestId: '18065867f8ae39', - auctionId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' - }]; - - const bidsResponse = { - body: { - bids: [ - { - placementid: '170577', - uuid: '2faedf1095f815', - width: 300, - height: 250, - cpm: 0.51, - creative: '', - ttl: 360, - currency: 'USD', - netRevenue: true, - creativeId: 'd30b58c2ba' - } - ] - } - }; - - it('Verifies komoonaAdapter bidder code', function () { - expect(spec.code).to.equal('komoona'); - }); - - it('Verifies komoonaAdapter bid request validation', function () { - expect(spec.isBidRequestValid(bidsRequest[0])).to.equal(true); - expect(spec.isBidRequestValid(bidsRequest[1])).to.equal(true); - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({ params: {} })).to.equal(false); - expect(spec.isBidRequestValid({ params: { hbid: 12345 } })).to.equal(false); - expect(spec.isBidRequestValid({ params: { placementid: 12345 } })).to.equal(false); - expect(spec.isBidRequestValid({ params: { hbid: 12345, placementId: 67890 } })).to.equal(true); - expect(spec.isBidRequestValid({ params: { hbid: 12345, placementId: 67890, floorPrice: 0.8 } })).to.equal(true); - }); - - it('Verify komoonaAdapter build request', function () { - var startTime = new Date().getTime(); - - const request = spec.buildRequests(bidsRequest); - expect(request.url).to.equal('https://bidder.komoona.com/v1/GetSBids'); - expect(request.method).to.equal('POST'); - const requestData = JSON.parse(request.data); - - // bids object - let bids = requestData.bids; - expect(bids).to.have.lengthOf(2); - - // first bid request: no floor price - expect(bids[0].uuid).to.equal('2faedf1095f815'); - expect(bids[0].floorprice).to.be.undefined; - expect(bids[0].placementid).to.equal('170577'); - expect(bids[0].hbid).to.equal('abc12345678'); - expect(bids[0].trid).to.equal('9f801c02-bbe8-4683-8ed4-bc816ea186bb'); - expect(bids[0].sizes).to.have.lengthOf(1); - expect(bids[0].sizes[0][0]).to.equal(300); - expect(bids[0].sizes[0][1]).to.equal(250); - - // second bid request: with floor price - expect(bids[1].uuid).to.equal('3c34e2367a3f59'); - expect(bids[1].floorprice).to.equal(0.5); - expect(bids[1].placementid).to.equal('281277'); - expect(bids[1].hbid).to.equal('abc12345678'); - expect(bids[1].trid).to.equal('9f801c02-bbe8-4683-8ed4-bc816ea186bb'); - expect(bids[1]).to.have.property('sizes') - .that.is.an('array') - .of.length(1) - .that.deep.equals([[728, 90]]); - - // kbConf object - let kbConf = requestData.kbConf; - expect(kbConf.hdbdid).to.equal(bids[0].hbid); - expect(kbConf.hdbdid).to.equal(bids[1].hbid); - expect(kbConf.encode_bid).to.be.undefined; - // kbConf timezone and cb - expect(kbConf.cb).not.to.be.undefined; - expect(kbConf.ts_as).to.be.above(startTime - 1); - expect(kbConf.tz).to.equal(new Date().getTimezoneOffset()); - // kbConf bid ids - expect(kbConf.hb_placement_bidids) - .to.have.property(bids[0].placementid) - .that.equal(bids[0].uuid); - expect(kbConf.hb_placement_bidids) - .to.have.property(bids[1].placementid) - .that.equal(bids[1].uuid); - // kbConf floor price - expect(kbConf.hb_floors).not.to.have.property(bids[0].placementid) - expect(kbConf.hb_floors).to.have.property(bids[1].placementid).that.equal(bids[1].floorprice); - // kbConf placement ids - expect(kbConf.hb_placements).to.have.lengthOf(2); - expect(kbConf.hb_placements[0]).to.equal(bids[0].placementid); - expect(kbConf.hb_placements[1]).to.equal(bids[1].placementid); - }); - - it('Verify komoonaAdapter build response', function () { - const request = spec.buildRequests(bidsRequest); - const bids = spec.interpretResponse(bidsResponse, request); - - // 'server' return single bid - expect(bids).to.have.lengthOf(1); - - // verify bid object - const bid = bids[0]; - const responseBids = bidsResponse.body.bids; - - expect(bid.cpm).to.equal(responseBids[0].cpm); - expect(bid.ad).to.equal(responseBids[0].creative); - expect(bid.requestId).equal(responseBids[0].uuid); - expect(bid.uuid).equal(responseBids[0].uuid); - expect(bid.width).to.equal(responseBids[0].width); - expect(bid.height).to.equal(responseBids[0].height); - expect(bid.ttl).to.equal(responseBids[0].ttl); - expect(bid.currency).to.equal('USD'); - expect(bid.netRevenue).to.equal(true); - expect(bid.creativeId).to.equal(responseBids[0].creativeId); - }); - - it('Verifies komoonaAdapter sync options', function () { - // user sync disabled - expect(spec.getUserSyncs({})).to.be.undefined; - expect(spec.getUserSyncs({ iframeEnabled: false })).to.be.undefined; - // user sync enabled - 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://s.komoona.com/sync/usync.html'); - }); -}); 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/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js deleted file mode 100644 index 1df4370b2ba..00000000000 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ /dev/null @@ -1,259 +0,0 @@ -import { expect, assert } from 'chai'; -import { spec } from 'modules/kubientBidAdapter.js'; - -describe('KubientAdapter', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'kubient', - bidderRequestId: '145e1d6a7837c9', - params: { - zoneid: '5678', - floor: 0.05, - }, - 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', - domain: 'example.com' - } - ] - } - }; - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let uspConsentData = '1YCC'; - let bidderRequest = { - bidderCode: 'kubient', - auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff', - bidderRequestId: 'ffffffffffffff', - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000, - refererInfo: { - referer: 'http://www.example.com', - reachedTop: true, - }, - gdprConsent: { - consentString: consentString, - gdprApplies: true - }, - uspConsent: uspConsentData, - bids: [bid] - }; - describe('buildRequests', function () { - let serverRequests = spec.buildRequests([bid], bidderRequest); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequests).to.be.an('array'); - }); - for (let i = 0; i < serverRequests.length; i++) { - let serverRequest = serverRequests[i]; - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest.method).to.be.a('string'); - expect(serverRequest.url).to.be.a('string'); - expect(serverRequest.data).to.be.a('string'); - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/pbjs'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = JSON.parse(serverRequest.data); - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('v', 'requestId', 'adSlots', 'gdpr', 'referer', 'tmax', 'consent', 'consentGiven', 'uspConsent'); - expect(data.v).to.exist.and.to.be.a('string'); - expect(data.requestId).to.exist.and.to.be.a('string'); - expect(data.referer).to.be.a('string'); - expect(data.tmax).to.exist.and.to.be.a('number'); - expect(data.gdpr).to.exist.and.to.be.within(0, 1); - expect(data.consent).to.equal(consentString); - expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); - for (let j = 0; j < data['adSlots'].length; j++) { - let adSlot = data['adSlots'][i]; - expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'sizes', 'schain', 'mediaTypes'); - expect(adSlot.bidId).to.be.a('string'); - expect(adSlot.zoneId).to.be.a('string'); - expect(adSlot.floor).to.be.a('number'); - expect(adSlot.sizes).to.be.an('array'); - expect(adSlot.schain).to.be.an('object'); - expect(adSlot.mediaTypes).to.be.an('object'); - } - }); - } - }); - - describe('isBidRequestValid', function () { - it('Should return true when required params are found', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false when required params are not found', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false when params are not found', function () { - delete bid.params; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('interpretResponse', function () { - it('Should interpret response', function () { - const serverResponse = { - body: - { - seatbid: [ - { - bid: [ - { - bidId: '000', - price: 1.5, - adm: '
test
', - creativeId: 'creativeId', - w: 300, - h: 250, - cur: 'USD', - netRevenue: false, - ttl: 360 - } - ] - } - ] - } - }; - let bannerResponses = spec.interpretResponse(serverResponse); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'ad', 'creativeId', 'width', 'height', 'currency', 'netRevenue', 'ttl'); - expect(dataItem.requestId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].bidId); - expect(dataItem.cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); - expect(dataItem.ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); - expect(dataItem.creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].creativeId); - expect(dataItem.width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); - expect(dataItem.height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); - expect(dataItem.currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].cur); - expect(dataItem.netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(serverResponse.body.seatbid[0].bid[0].netRevenue); - expect(dataItem.ttl).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].ttl); - }); - - it('Should return no ad when not given a server response', function () { - const ads = spec.interpretResponse(null); - expect(ads).to.be.an('array').and.to.have.length(0); - }); - }); - - describe('getUserSyncs', function () { - it('should register the sync iframe without gdpr', function () { - let syncOptions = { - iframeEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - consentString: consentString - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.html?consent_str=' + consentString + '&consent_given=0'); - }); - it('should register the sync iframe with gdpr', function () { - let syncOptions = { - iframeEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - gdprApplies: true, - consentString: consentString - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.html?consent_str=' + consentString + '&gdpr=1&consent_given=0'); - }); - it('should register the sync iframe with gdpr vendor', function () { - let syncOptions = { - iframeEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - gdprApplies: true, - consentString: consentString, - apiVersion: 1, - vendorData: { - vendorConsents: { - 794: 1 - } - } - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.html?consent_str=' + consentString + '&gdpr=1&consent_given=1'); - }); - it('should register the sync image without gdpr', function () { - let syncOptions = { - pixelEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - consentString: consentString - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&consent_given=0'); - }); - it('should register the sync image with gdpr', function () { - let syncOptions = { - pixelEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - gdprApplies: true, - consentString: consentString - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&gdpr=1&consent_given=0'); - }); - it('should register the sync image with gdpr vendor', function () { - let syncOptions = { - pixelEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - gdprApplies: true, - consentString: consentString, - apiVersion: 2, - vendorData: { - vendor: { - consents: { - 794: 1 - } - } - } - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&gdpr=1&consent_given=1'); - }); - }) -}); diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js deleted file mode 100644 index a3a70a39731..00000000000 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ /dev/null @@ -1,426 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/lemmaBidAdapter.js'; -import * as utils from 'src/utils.js'; -const constants = require('src/constants.json'); - -describe('lemmaBidAdapter', function() { - var bidRequests; - var videoBidRequests; - var bidResponses; - beforeEach(function() { - bidRequests = [{ - bidder: 'lemma', - mediaType: 'banner', - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ], - } - }, - params: { - pubId: 1001, - adunitId: 1, - currency: 'AUD', - bidFloor: 1.3, - geo: { - lat: '12.3', - lon: '23.7', - } - }, - sizes: [ - [300, 250], - [300, 600] - ] - }]; - videoBidRequests = [{ - code: 'video1', - mediaType: 'video', - mediaTypes: { - video: { - playerSize: [640, 480], - context: 'instream' - } - }, - bidder: 'lemma', - params: { - pubId: 1001, - adunitId: 1, - bidFloor: 1.3, - video: { - mimes: ['video/mp4', 'video/x-flv'], - skippable: true, - minduration: 5, - maxduration: 30 - } - } - }]; - bidResponses = { - 'body': { - 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', - 'seatbid': [{ - 'bid': [{ - 'id': '74858439-49D7-4169-BA5D-44A046315B2F', - 'impid': '22bddb28db77d', - 'price': 1.3, - 'adm': '

lemma"Connecting Advertisers and Publishers directly"

', - 'adomain': ['amazon.com'], - 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', - 'cid': '22918', - 'crid': 'v55jutrh', - 'h': 250, - 'w': 300, - 'ext': {} - }] - }] - } - }; - }); - describe('implementation', function() { - describe('Bid validations', function() { - it('valid bid case', function() { - var validBid = { - bidder: 'lemma', - params: { - pubId: 1001, - adunitId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - }); - it('invalid bid case', function() { - var isValid = spec.isBidRequestValid(); - expect(isValid).to.equal(false); - }); - it('invalid bid case: pubId not passed', function() { - var validBid = { - bidder: 'lemma', - params: { - adunitId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - it('invalid bid case: pubId is not number', function() { - var validBid = { - bidder: 'lemma', - params: { - pubId: '301', - adunitId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - it('invalid bid case: adunitId is not passed', function() { - var validBid = { - bidder: 'lemma', - params: { - pubId: 1001 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - it('invalid bid case: video bid request mimes is not passed', function() { - var validBid = { - bidder: 'lemma', - params: { - pubId: 1001, - adunitId: 1, - video: { - skippable: true, - minduration: 5, - maxduration: 30 - } - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - validBid.params.video.mimes = []; - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - }); - describe('Request formation', function() { - it('buildRequests function should not modify original bidRequests object', function() { - var originalBidRequests = utils.deepClone(bidRequests); - var request = spec.buildRequests(bidRequests); - expect(bidRequests).to.deep.equal(originalBidRequests); - }); - it('Endpoint checking', function() { - var request = spec.buildRequests(bidRequests); - expect(request.url).to.equal('https://ads.lemmatechnologies.com/lemma/servad?pid=1001&aid=1'); - expect(request.method).to.equal('POST'); - }); - it('Request params check', function() { - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - expect(data.site.domain).to.be.a('string'); // domain should be set - expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id - expect(data.imp[0].tagid).to.equal('1'); // tagid - expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); - expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.bidFloor); - }); - it('Request params check without mediaTypes object', function() { - var bidRequests = [{ - bidder: 'lemma', - params: { - pubId: 1001, - adunitId: 1, - currency: 'AUD' - }, - sizes: [ - [300, 250], - [300, 600] - ] - }]; - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - expect(data.imp[0].banner.format).exist.and.to.be.an('array'); - expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); - expect(data.imp[0].banner.format[0].w).to.equal(300); // width - expect(data.imp[0].banner.format[0].h).to.equal(600); // height - }); - it('Request params check: without tagId', function() { - delete bidRequests[0].params.adunitId; - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - expect(data.site.domain).to.be.a('string'); // domain should be set - expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id - expect(data.imp[0].tagid).to.equal(undefined); // tagid - expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); - expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.bidFloor); - }); - it('Request params multi size format object check', function() { - var bidRequests = [{ - bidder: 'lemma', - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ], - } - }, - params: { - pubId: 1001, - adunitId: 1, - currency: 'AUD' - }, - sizes: [ - [300, 250], - [300, 600] - ] - }]; - /* case 1 - size passed in adslot */ - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - /* case 2 - size passed in adslot as well as in sizes array */ - bidRequests[0].sizes = [ - [300, 600], - [300, 250] - ]; - bidRequests[0].mediaTypes = { - banner: { - sizes: [ - [300, 600], - [300, 250] - ] - } - }; - request = spec.buildRequests(bidRequests); - data = JSON.parse(request.data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(600); // height - /* case 3 - size passed in sizes but not in adslot */ - bidRequests[0].params.adunitId = 1; - bidRequests[0].sizes = [ - [300, 250], - [300, 600] - ]; - bidRequests[0].mediaTypes = { - banner: { - sizes: [ - [300, 250], - [300, 600] - ] - } - }; - request = spec.buildRequests(bidRequests); - data = JSON.parse(request.data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - expect(data.imp[0].banner.format).exist.and.to.be.an('array'); - expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); - expect(data.imp[0].banner.format[0].w).to.equal(300); // width - expect(data.imp[0].banner.format[0].h).to.equal(250); // height - }); - it('Request params currency check', function() { - var bidRequest = [{ - bidder: 'lemma', - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ], - } - }, - params: { - pubId: 1001, - adunitId: 1, - currency: 'AUD' - }, - sizes: [ - [300, 250], - [300, 600] - ] - }]; - /* case 1 - - currency specified in adunits - output: imp[0] use currency specified in bidRequests[0].params.currency - */ - var request = spec.buildRequests(bidRequest); - var data = JSON.parse(request.data); - expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); - /* case 2 - - currency specified in adunit - output: imp[0] use default currency - USD - */ - delete bidRequest[0].params.currency; - request = spec.buildRequests(bidRequest); - data = JSON.parse(request.data); - expect(data.imp[0].bidfloorcur).to.equal('USD'); - }); - it('Request params check for video ad', function() { - var request = spec.buildRequests(videoBidRequests); - var data = JSON.parse(request.data); - expect(data.imp[0].video).to.exist; - expect(data.imp[0].tagid).to.equal('1'); - expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); - expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]); - expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]); - expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); - expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); - expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); - expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); - }); - describe('setting imp.floor using floorModule', function() { - /* - Use the minimum value among floor from floorModule per mediaType - If params.bidFloor is set then take max(floor, min(floors from floorModule)) - set imp.bidfloor only if it is more than 0 - */ - - let newRequest; - let floorModuleTestData; - let getFloor = function(req) { - return floorModuleTestData[req.mediaType]; - }; - - beforeEach(() => { - floorModuleTestData = { - 'banner': { - 'currency': 'AUD', - 'floor': 1.50 - }, - 'video': { - 'currency': 'AUD', - 'floor': 2.00 - } - }; - newRequest = utils.deepClone(bidRequests); - newRequest[0].getFloor = getFloor; - }); - - it('bidfloor should be undefined if calculation is <= 0', function() { - floorModuleTestData.banner.floor = 0; // lowest of them all - newRequest[0].params.bidFloor = undefined; - let request = spec.buildRequests(newRequest); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.bidfloor).to.equal(undefined); - }); - - it('ignore floormodule o/p if floor is not number', function() { - floorModuleTestData.banner.floor = 'INR'; - newRequest[0].params.bidFloor = undefined; - let request = spec.buildRequests(newRequest); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.bidfloor).to.equal(undefined); // video will be lowest now - }); - - it('ignore floormodule o/p if currency is not matched', function() { - floorModuleTestData.banner.currency = 'INR'; - newRequest[0].params.bidFloor = undefined; - let request = spec.buildRequests(newRequest); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.bidfloor).to.equal(undefined); // video will be lowest now - }); - - it('bidFloor is not passed, use minimum from floorModule', function() { - newRequest[0].params.bidFloor = undefined; - let request = spec.buildRequests(newRequest); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.bidfloor).to.equal(1.5); - }); - - it('bidFloor is passed as 1, use min of floorModule as it is highest', function() { - newRequest[0].params.bidFloor = '1.0';// yes, we want it as a string - let request = spec.buildRequests(newRequest); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.bidfloor).to.equal(1.5); - }); - }); - describe('Response checking', function() { - it('should check for valid response values', function() { - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - var response = spec.interpretResponse(bidResponses, request); - expect(response).to.be.an('array').with.length.above(0); - expect(response[0].requestId).to.equal(bidResponses.body.seatbid[0].bid[0].impid); - expect(response[0].cpm).to.equal((bidResponses.body.seatbid[0].bid[0].price).toFixed(2)); - expect(response[0].width).to.equal(bidResponses.body.seatbid[0].bid[0].w); - expect(response[0].height).to.equal(bidResponses.body.seatbid[0].bid[0].h); - if (bidResponses.body.seatbid[0].bid[0].crid) { - expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].crid); - } else { - expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].id); - } - expect(response[0].dealId).to.equal(bidResponses.body.seatbid[0].bid[0].dealid); - expect(response[0].currency).to.equal('USD'); - expect(response[0].netRevenue).to.equal(false); - expect(response[0].ttl).to.equal(300); - }); - }); - }); - describe('getUserSyncs', function() { - const syncurl_iframe = 'https://sync.lemmatechnologies.com/js/usersync.html?pid=1001'; - let sandbox; - beforeEach(function() { - sandbox = sinon.sandbox.create(); - }); - afterEach(function() { - sandbox.restore(); - }); - - it('execute as per config', function() { - expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{ - type: 'iframe', url: syncurl_iframe - }]); - }); - }); - }); -}); 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/mediaforceBidAdapter_spec.js b/test/spec/modules/mediaforceBidAdapter_spec.js index be9b528aedd..0b5c4d00f53 100644 --- a/test/spec/modules/mediaforceBidAdapter_spec.js +++ b/test/spec/modules/mediaforceBidAdapter_spec.js @@ -27,7 +27,7 @@ describe('mediaforce bid adapter', function () { bidder: 'mediaforce', params: { property: '10433394', - bidfloor: 0.3, + bidfloor: 0, }, }; @@ -157,7 +157,7 @@ describe('mediaforce bid adapter', function () { it('should return proper banner imp', function () { let bid = utils.deepClone(defaultBid); - bid.params.bidfloor = 0.5; + bid.params.bidfloor = 0; let bidRequests = [bid]; let bidderRequest = { @@ -219,7 +219,7 @@ describe('mediaforce bid adapter', function () { assert.deepEqual(request, { method: 'POST', url: requestUrl, - data: '{"id":"' + data.id + '","site":{"page":"' + pageUrl + '","ref":"https%3A%2F%2Fwww.prebid.org","id":"pub123","publisher":{"id":"pub123"}},"device":{"ua":"' + navigator.userAgent + '","js":1,"dnt":' + dnt + ',"language":"' + language + '"},"ext":{"mediaforce":{"hb_key":"210a474e-88f0-4646-837f-4253b7cf14fb"}},"tmax":1500,"imp":[{"tagid":"202","secure":' + secure + ',"bidfloor":0.5,"ext":{"mediaforce":{"transactionId":"d45dd707-a418-42ec-b8a7-b70a6c6fab0b"}},"banner":{"w":300,"h":250},"native":{"ver":"1.2","request":{"assets":[{"required":1,"id":1,"title":{"len":800}},{"required":1,"id":3,"img":{"type":3,"w":300,"h":250}},{"required":1,"id":5,"data":{"type":1}}],"context":1,"plcmttype":1,"ver":"1.2"}}}]}', + data: '{"id":"' + data.id + '","site":{"page":"' + pageUrl + '","ref":"https%3A%2F%2Fwww.prebid.org","id":"pub123","publisher":{"id":"pub123"}},"device":{"ua":"' + navigator.userAgent + '","js":1,"dnt":' + dnt + ',"language":"' + language + '"},"ext":{"mediaforce":{"hb_key":"210a474e-88f0-4646-837f-4253b7cf14fb"}},"tmax":1500,"imp":[{"tagid":"202","secure":' + secure + ',"bidfloor":0,"ext":{"mediaforce":{"transactionId":"d45dd707-a418-42ec-b8a7-b70a6c6fab0b"}},"banner":{"w":300,"h":250},"native":{"ver":"1.2","request":{"assets":[{"required":1,"id":1,"title":{"len":800}},{"required":1,"id":3,"img":{"type":3,"w":300,"h":250}},{"required":1,"id":5,"data":{"type":1}}],"context":1,"plcmttype":1,"ver":"1.2"}}}]}', }); }); 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/mgidBidAdapter_spec.js b/test/spec/modules/mgidBidAdapter_spec.js deleted file mode 100644 index 16f4f0b4607..00000000000 --- a/test/spec/modules/mgidBidAdapter_spec.js +++ /dev/null @@ -1,702 +0,0 @@ -import {assert, expect} from 'chai'; -import {spec} from 'modules/mgidBidAdapter.js'; -import * as utils from '../../../src/utils.js'; - -describe('Mgid bid adapter', function () { - let sandbox; - let logErrorSpy; - let logWarnSpy; - beforeEach(function () { - sandbox = sinon.sandbox.create(); - logErrorSpy = sinon.spy(utils, 'logError'); - logWarnSpy = sinon.spy(utils, 'logWarn'); - }); - - afterEach(function () { - sandbox.restore(); - utils.logError.restore(); - utils.logWarn.restore(); - }); - const ua = navigator.userAgent; - const screenHeight = screen.height; - const screenWidth = screen.width; - const dnt = (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0; - const language = navigator.language ? 'language' : 'userLanguage'; - let lang = navigator[language].split('-')[0]; - if (lang.length != 2 && lang.length != 3) { - lang = ''; - } - const secure = window.location.protocol === 'https:' ? 1 : 0; - const mgid_ver = spec.VERSION; - const prebid_ver = $$PREBID_GLOBAL$$.version; - const utcOffset = (new Date()).getTimezoneOffset().toString(); - - describe('isBidRequestValid', function () { - let bid = { - 'adUnitCode': 'div', - 'bidder': 'mgid', - 'params': { - 'property': '10433394', - 'zone': 'zone' - }, - }; - - it('should not accept bid without required params', function () { - let isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - - it('should return false when 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 false when valid params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {accountId: '', placementId: ''}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when valid params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.adUnitCode = ''; - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - bid.params = {accountId: 2, placementId: 1}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when adUnitCode not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.adUnitCode = ''; - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - bid.params = {accountId: 2, placementId: 1}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when valid params are passed as nums', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.adUnitCode = 'div'; - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - bid.params = {accountId: 2, placementId: 1}; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when valid params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.mediaTypes = { - native: { - sizes: [[300, 250]] - } - }; - bid.params = {accountId: '0', placementId: '00'}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when valid mediaTypes are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {accountId: '1', placementId: '1'}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when valid mediaTypes.banner are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {accountId: '1', placementId: '1'}; - bid.mediaTypes = { - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when valid mediaTypes.banner.sizes are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {accountId: '1', placementId: '1'}; - bid.mediaTypes = { - sizes: [] - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when valid mediaTypes.banner.sizes are not valid', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {accountId: '1', placementId: '1'}; - bid.mediaTypes = { - sizes: [300, 250] - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when valid params are passed as strings', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.adUnitCode = 'div'; - bid.params = {accountId: '1', placementId: '1'}; - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when valid mediaTypes.native is not object', function () { - let bid = Object.assign({}, bid); - bid.params = {accountId: '1', placementId: '1'}; - bid.mediaTypes = { - native: [] - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when mediaTypes.native is empty object', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {accountId: '1', placementId: '1'}; - bid.mediaTypes = { - native: {} - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when mediaTypes.native is invalid object', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {accountId: '1', placementId: '1'}; - bid.mediaTypes = { - native: { - image: { - sizes: [80, 80] - }, - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when mediaTypes.native has unsupported required asset', function () { - let bid = Object.assign({}, bid); - bid.params = {accountId: '2', placementId: '1'}; - bid.mediaTypes = { - native: { - title: {required: true}, - image: {required: false, sizes: [80, 80]}, - sponsored: {required: false}, - }, - }; - bid.nativeParams = { - title: {required: true}, - image: {required: false, sizes: [80, 80]}, - sponsored: {required: false}, - unsupported: {required: true}, - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when mediaTypes.native all assets needed', function () { - let bid = Object.assign({}, bid); - bid.adUnitCode = 'div'; - bid.params = {accountId: '2', placementId: '1'}; - bid.mediaTypes = { - native: { - title: {required: true}, - image: {required: false, sizes: [80, 80]}, - sponsored: {required: false}, - }, - }; - bid.nativeParams = { - title: {required: true}, - image: {required: false, sizes: [80, 80]}, - sponsored: {required: false}, - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - - describe('override defaults', function () { - let bid = { - bidder: 'mgid', - params: { - accountId: '1', - placementId: '2', - }, - }; - it('should return object', function () { - let bid = Object.assign({}, bid); - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - let bidRequests = [bid]; - const request = spec.buildRequests(bidRequests); - expect(request).to.exist.and.to.be.a('object'); - }); - - it('should return overwrite default bidurl', function () { - let bid = Object.assign({}, bid); - bid.params = { - bidUrl: 'https://newbidurl.com/', - accountId: '1', - placementId: '2', - }; - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - let bidRequests = [bid]; - const request = spec.buildRequests(bidRequests); - expect(request.url).to.include('https://newbidurl.com/1'); - }); - it('should return overwrite default bidFloor', function () { - let bid = Object.assign({}, bid); - bid.params = { - bidFloor: 1.1, - accountId: '1', - placementId: '2', - }; - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - let bidRequests = [bid]; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.a('string'); - const data = JSON.parse(request.data); - expect(data).to.be.a('object'); - expect(data.imp).to.be.a('array'); - expect(data.imp).to.have.lengthOf(1); - expect(data.imp[0].bidfloor).to.deep.equal(1.1); - }); - it('should return overwrite default currency', function () { - let bid = Object.assign({}, bid); - bid.params = { - cur: 'GBP', - accountId: '1', - placementId: '2', - }; - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - let bidRequests = [bid]; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.a('string'); - const data = JSON.parse(request.data); - expect(data).to.be.a('object'); - expect(data.cur).to.deep.equal(['GBP']); - }); - }); - - describe('buildRequests', function () { - it('should return undefined if no validBidRequests passed', function () { - expect(spec.buildRequests([])).to.be.undefined; - }); - - let abid = { - adUnitCode: 'div', - bidder: 'mgid', - params: { - accountId: '1', - placementId: '2', - }, - }; - it('should return proper request url', function () { - localStorage.setItem('mgMuidn', 'xxx'); - let bid = Object.assign({}, abid); - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - let bidRequests = [bid]; - const request = spec.buildRequests(bidRequests); - expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1?muid=xxx'); - localStorage.removeItem('mgMuidn') - }); - it('should proper handle gdpr', function () { - let bid = Object.assign({}, abid); - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - let bidRequests = [bid]; - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'gdpr', gdprApplies: true}}); - expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); - expect(request.method).deep.equal('POST'); - const data = JSON.parse(request.data); - expect(data.user).deep.equal({ext: {consent: 'gdpr'}}); - expect(data.regs).deep.equal({ext: {gdpr: 1}}); - }); - it('should return proper banner imp', function () { - let bid = Object.assign({}, abid); - bid.mediaTypes = { - banner: { - sizes: [[300, 250]] - } - }; - let bidRequests = [bid]; - const page = top.location.href; - const domain = utils.parseUrl(page).hostname; - const request = spec.buildRequests(bidRequests); - expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); - expect(request.method).deep.equal('POST'); - const data = JSON.parse(request.data); - expect(data.site.domain).to.deep.equal(domain); - expect(data.site.page).to.deep.equal(page); - expect(data.cur).to.deep.equal(['USD']); - expect(data.device.ua).to.deep.equal(ua); - expect(data.device.dnt).equal(dnt); - expect(data.device.h).equal(screenHeight); - expect(data.device.w).equal(screenWidth); - expect(data.device.language).to.deep.equal(lang); - expect(data.imp[0].tagid).to.deep.equal('2/div'); - expect(data.imp[0].banner).to.deep.equal({w: 300, h: 250}); - expect(data.imp[0].secure).to.deep.equal(secure); - expect(request).to.deep.equal({ - 'method': 'POST', - 'url': 'https://prebid.mgid.com/prebid/1', - 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"banner\":{\"w\":300,\"h\":250}}]}', - }); - }); - it('should not return native imp if minimum asset list not requested', function () { - let bid = Object.assign({}, abid); - bid.mediaTypes = { - native: '', - }; - bid.nativeParams = { - title: {required: true}, - image: {sizes: [80, 80]}, - }; - let bidRequests = [bid]; - const request = spec.buildRequests(bidRequests); - expect(request).to.be.undefined; - }); - it('should return proper native imp', function () { - let bid = Object.assign({}, abid); - bid.mediaTypes = { - native: '', - }; - bid.nativeParams = { - title: {required: true}, - image: {sizes: [80, 80]}, - sponsored: { }, - }; - - let bidRequests = [bid]; - const page = top.location.href; - const domain = utils.parseUrl(page).hostname; - const request = spec.buildRequests(bidRequests); - expect(request).to.be.a('object'); - expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); - expect(request.method).deep.equal('POST'); - const data = JSON.parse(request.data); - expect(data.site.domain).to.deep.equal(domain); - expect(data.site.page).to.deep.equal(page); - expect(data.cur).to.deep.equal(['USD']); - expect(data.device.ua).to.deep.equal(ua); - expect(data.device.dnt).equal(dnt); - expect(data.device.h).equal(screenHeight); - expect(data.device.w).equal(screenWidth); - expect(data.device.language).to.deep.equal(lang); - expect(data.imp[0].tagid).to.deep.equal('2/div'); - expect(data.imp[0].native).is.a('object').and.to.deep.equal({'request': {'assets': [{'id': 1, 'required': 1, 'title': {'len': 80}}, {'id': 2, 'img': {'h': 80, 'type': 3, 'w': 80}, 'required': 0}, {'data': {'type': 1}, 'id': 11, 'required': 0}], 'plcmtcnt': 1}}); - expect(data.imp[0].secure).to.deep.equal(secure); - expect(request).to.deep.equal({ - 'method': 'POST', - 'url': 'https://prebid.mgid.com/prebid/1', - 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"native\":{\"request\":{\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":80}},{\"id\":2,\"required\":0,\"img\":{\"type\":3,\"w\":80,\"h\":80}},{\"id\":11,\"required\":0,\"data\":{\"type\":1}}]}}}]}', - }); - }); - it('should return proper native imp', function () { - let bid = Object.assign({}, abid); - bid.mediaTypes = { - native: '', - }; - bid.nativeParams = { - title: {required: true}, - image: {wmin: 50, hmin: 50, required: true}, - icon: {}, - sponsored: { }, - }; - - let bidRequests = [bid]; - const page = top.location.href; - const domain = utils.parseUrl(page).hostname; - const request = spec.buildRequests(bidRequests); - expect(request).to.be.a('object'); - expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); - expect(request.method).deep.equal('POST'); - const data = JSON.parse(request.data); - expect(data.site.domain).to.deep.equal(domain); - expect(data.site.page).to.deep.equal(page); - expect(data.cur).to.deep.equal(['USD']); - expect(data.device.ua).to.deep.equal(ua); - expect(data.device.dnt).equal(dnt); - expect(data.device.h).equal(screenHeight); - expect(data.device.w).equal(screenWidth); - expect(data.device.language).to.deep.equal(lang); - expect(data.imp[0].tagid).to.deep.equal('2/div'); - expect(data.imp[0].native).is.a('object').and.to.deep.equal({'request': {'assets': [{'id': 1, 'required': 1, 'title': {'len': 80}}, {'id': 2, 'img': {'h': 328, hmin: 50, 'type': 3, 'w': 492, wmin: 50}, 'required': 1}, {'id': 3, 'img': {'h': 50, 'type': 1, 'w': 50}, 'required': 0}, {'data': {'type': 1}, 'id': 11, 'required': 0}], 'plcmtcnt': 1}}); - expect(data.imp[0].secure).to.deep.equal(secure); - expect(request).to.deep.equal({ - 'method': 'POST', - 'url': 'https://prebid.mgid.com/prebid/1', - 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"native\":{\"request\":{\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":80}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"w\":492,\"h\":328,\"wmin\":50,\"hmin\":50}},{\"id\":3,\"required\":0,\"img\":{\"type\":1,\"w\":50,\"h\":50}},{\"id\":11,\"required\":0,\"data\":{\"type\":1}}]}}}]}', - }); - }); - it('should return proper native imp with sponsoredBy', function () { - let bid = Object.assign({}, abid); - bid.mediaTypes = { - native: '', - }; - bid.nativeParams = { - title: {required: true}, - image: {sizes: [80, 80]}, - sponsoredBy: { }, - }; - - let bidRequests = [bid]; - const page = top.location.href; - const domain = utils.parseUrl(page).hostname; - const request = spec.buildRequests(bidRequests); - expect(request).to.be.a('object'); - expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); - expect(request.method).deep.equal('POST'); - const data = JSON.parse(request.data); - expect(data.site.domain).to.deep.equal(domain); - expect(data.site.page).to.deep.equal(page); - expect(data.cur).to.deep.equal(['USD']); - expect(data.device.ua).to.deep.equal(ua); - expect(data.device.dnt).equal(dnt); - expect(data.device.h).equal(screenHeight); - expect(data.device.w).equal(screenWidth); - expect(data.device.language).to.deep.equal(lang); - expect(data.imp[0].tagid).to.deep.equal('2/div'); - expect(data.imp[0].native).is.a('object').and.to.deep.equal({'request': {'assets': [{'id': 1, 'required': 1, 'title': {'len': 80}}, {'id': 2, 'img': {'h': 80, 'type': 3, 'w': 80}, 'required': 0}, {'data': {'type': 1}, 'id': 4, 'required': 0}], 'plcmtcnt': 1}}); - expect(data.imp[0].secure).to.deep.equal(secure); - expect(request).to.deep.equal({ - 'method': 'POST', - 'url': 'https://prebid.mgid.com/prebid/1', - 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"native\":{\"request\":{\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":80}},{\"id\":2,\"required\":0,\"img\":{\"type\":3,\"w\":80,\"h\":80}},{\"id\":4,\"required\":0,\"data\":{\"type\":1}}]}}}]}', - }); - }); - it('should return proper banner request', function () { - let bid = Object.assign({}, abid); - bid.mediaTypes = { - banner: { - sizes: [[300, 600], [300, 250]], - } - }; - let bidRequests = [bid]; - const request = spec.buildRequests(bidRequests); - - const page = top.location.href; - const domain = utils.parseUrl(page).hostname; - expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); - expect(request.method).deep.equal('POST'); - const data = JSON.parse(request.data); - expect(data.site.domain).to.deep.equal(domain); - expect(data.site.page).to.deep.equal(page); - expect(data.cur).to.deep.equal(['USD']); - expect(data.device.ua).to.deep.equal(ua); - expect(data.device.dnt).equal(dnt); - expect(data.device.h).equal(screenHeight); - expect(data.device.w).equal(screenWidth); - expect(data.device.language).to.deep.equal(lang); - expect(data.imp[0].tagid).to.deep.equal('2/div'); - expect(data.imp[0].banner).to.deep.equal({w: 300, h: 600, format: [{w: 300, h: 600}, {w: 300, h: 250}]}); - expect(data.imp[0].secure).to.deep.equal(secure); - - expect(request).to.deep.equal({ - 'method': 'POST', - 'url': 'https://prebid.mgid.com/prebid/1', - 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"banner\":{\"w\":300,\"h\":600,\"format\":[{\"w\":300,\"h\":600},{\"w\":300,\"h\":250}]}}]}', - }); - }); - }); - describe('interpretResponse banner', function () { - it('should not push bid response', function () { - let bids = spec.interpretResponse(); - expect(bids).to.be.undefined; - }); - it('should push proper banner bid response', function () { - let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': '', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': 'html: adm', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2']}], 'seat': '44082'}]} - }; - let bids = spec.interpretResponse(resp); - expect(bids).to.deep.equal([ - { - 'ad': 'html: adm', - 'cpm': 1.5, - 'creativeId': '2898532/2419121/2592854/2499195', - 'currency': 'USD', - 'dealId': '', - 'height': 600, - 'isBurl': true, - 'mediaType': 'banner', - 'netRevenue': true, - 'nurl': 'https nurl', - 'burl': 'https burl', - 'requestId': '61e40632c53fc2', - 'ttl': 300, - 'width': 300, - } - ]); - }); - }); - describe('interpretResponse native', function () { - it('should not push proper native bid response if adm is missing', function () { - let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} - }; - let bids = spec.interpretResponse(resp); - expect(bids).to.deep.equal([]) - }); - it('should not push proper native bid response if assets is empty', function () { - let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} - }; - let bids = spec.interpretResponse(resp); - expect(bids).to.deep.equal([]) - }); - it('should push proper native bid response', function () { - let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}], ext: {'muidn': 'userid'}} - }; - let bids = spec.interpretResponse(resp); - expect(bids).to.deep.equal([{ - 'ad': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', - 'burl': 'https burl', - 'cpm': 1.5, - 'creativeId': '2898532/2419121/2592854/2499195', - 'currency': 'GBP', - 'dealId': '', - 'height': 0, - 'isBurl': true, - 'mediaType': 'native', - 'native': { - 'clickTrackers': [], - 'clickUrl': 'link_url', - 'data': 'price1', - 'icon': { - 'height': 50, - 'url': 'icon_src', - 'width': 50 - }, - 'image': { - 'height': 80, - 'url': 'image_src', - 'width': 80 - }, - 'impressionTrackers': [ - 'imptrackers1' - ], - 'jstracker': [], - 'sponsoredBy': 'sponsored', - 'title': 'title1' - }, - 'netRevenue': true, - 'nurl': 'https nurl', - 'requestId': '61e40632c53fc2', - 'ttl': 300, - 'width': 0 - }]) - }); - it('should push proper native bid response', function () { - let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} - }; - let bids = spec.interpretResponse(resp); - expect(bids).to.deep.equal([ - { - 'ad': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}}],\"imptrackers\":[\"imptrackers1\"]}}', - 'cpm': 1.5, - 'creativeId': '2898532/2419121/2592854/2499195', - 'currency': 'GBP', - 'dealId': '', - 'height': 0, - 'isBurl': true, - 'mediaType': 'native', - 'netRevenue': true, - 'nurl': 'https nurl', - 'burl': 'https burl', - 'requestId': '61e40632c53fc2', - 'ttl': 300, - 'width': 0, - 'native': { - clickTrackers: [], - title: 'title1', - image: { - url: 'image_src', - width: 80, - height: 80, - }, - icon: { - url: 'icon_src', - width: 50, - height: 50, - }, - impressionTrackers: ['imptrackers1'], - jstracker: [], - clickUrl: 'link_url', - } - } - ]); - }); - }); - - describe('getUserSyncs', function () { - it('should do nothing on getUserSyncs', function () { - spec.getUserSyncs() - }); - }); - describe('on bidWon', function () { - beforeEach(function() { - sinon.stub(utils, 'triggerPixel'); - }); - afterEach(function() { - utils.triggerPixel.restore(); - }); - it('should replace nurl and burl for native', function () { - const burl = 'burl&s=${' + 'AUCTION_PRICE}'; - const nurl = 'nurl&s=${' + 'AUCTION_PRICE}'; - const bid = {'bidderCode': 'mgid', 'width': 0, 'height': 0, 'statusMessage': 'Bid available', 'adId': '3d0b6ff1dda89', 'requestId': '2a423489e058a1', 'mediaType': 'native', 'source': 'client', 'ad': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"LinkURL\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"TITLE\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"ImageURL\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"IconURL\"}},{\"id\":11,\"required\":0,\"data\":{\"type\":1,\"value\":\"sponsored\"}}],\"imptrackers\":[\"ImpTrackerURL\"]}}', 'cpm': 0.66, 'creativeId': '353538_591471', 'currency': 'USD', 'dealId': '', 'netRevenue': true, 'ttl': 300, 'nurl': nurl, 'burl': burl, 'isBurl': true, 'native': {'title': 'TITLE', 'image': {'url': 'ImageURL', 'height': 80, 'width': 80}, 'icon': {'url': 'IconURL', 'height': 50, 'width': 50}, 'sponsored': 'sponsored', 'clickUrl': 'LinkURL', 'clickTrackers': [], 'impressionTrackers': ['ImpTrackerURL'], 'jstracker': []}, 'auctionId': 'a92bffce-14d2-4f8f-a78a-7b9b5e4d28fa', 'responseTimestamp': 1556867386065, 'requestTimestamp': 1556867385916, 'bidder': 'mgid', 'adUnitCode': 'div-gpt-ad-1555415275793-0', 'timeToRespond': 149, 'pbLg': '0.50', 'pbMg': '0.60', 'pbHg': '0.66', 'pbAg': '0.65', 'pbDg': '0.66', 'pbCg': '', 'size': '0x0', 'adserverTargeting': {'hb_bidder': 'mgid', 'hb_adid': '3d0b6ff1dda89', 'hb_pb': '0.66', 'hb_size': '0x0', 'hb_source': 'client', 'hb_format': 'native', 'hb_native_title': 'TITLE', 'hb_native_image': 'hb_native_image:3d0b6ff1dda89', 'hb_native_icon': 'IconURL', 'hb_native_linkurl': 'hb_native_linkurl:3d0b6ff1dda89'}, 'status': 'targetingSet', 'params': [{'accountId': '184', 'placementId': '353538'}]}; - spec.onBidWon(bid); - expect(bid.nurl).to.deep.equal('nurl&s=0.66'); - expect(bid.burl).to.deep.equal('burl&s=0.66'); - }); - it('should replace nurl and burl for banner', function () { - const burl = 'burl&s=${' + 'AUCTION_PRICE}'; - const nurl = 'nurl&s=${' + 'AUCTION_PRICE}'; - const bid = {'bidderCode': 'mgid', 'width': 0, 'height': 0, 'statusMessage': 'Bid available', 'adId': '3d0b6ff1dda89', 'requestId': '2a423489e058a1', 'mediaType': 'banner', 'source': 'client', 'ad': burl, 'cpm': 0.66, 'creativeId': '353538_591471', 'currency': 'USD', 'dealId': '', 'netRevenue': true, 'ttl': 300, 'nurl': nurl, 'burl': burl, 'isBurl': true, 'auctionId': 'a92bffce-14d2-4f8f-a78a-7b9b5e4d28fa', 'responseTimestamp': 1556867386065, 'requestTimestamp': 1556867385916, 'bidder': 'mgid', 'adUnitCode': 'div-gpt-ad-1555415275793-0', 'timeToRespond': 149, 'pbLg': '0.50', 'pbMg': '0.60', 'pbHg': '0.66', 'pbAg': '0.65', 'pbDg': '0.66', 'pbCg': '', 'size': '0x0', 'adserverTargeting': {'hb_bidder': 'mgid', 'hb_adid': '3d0b6ff1dda89', 'hb_pb': '0.66', 'hb_size': '0x0', 'hb_source': 'client', 'hb_format': 'banner', 'hb_banner_title': 'TITLE', 'hb_banner_image': 'hb_banner_image:3d0b6ff1dda89', 'hb_banner_icon': 'IconURL', 'hb_banner_linkurl': 'hb_banner_linkurl:3d0b6ff1dda89'}, 'status': 'targetingSet', 'params': [{'accountId': '184', 'placementId': '353538'}]}; - spec.onBidWon(bid); - expect(bid.nurl).to.deep.equal('nurl&s=0.66'); - expect(bid.burl).to.deep.equal(burl); - expect(bid.ad).to.deep.equal('burl&s=0.66'); - }); - }); -}); 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/mobfoxBidAdapter_spec.js b/test/spec/modules/mobfoxBidAdapter_spec.js deleted file mode 100644 index d3178d77a1a..00000000000 --- a/test/spec/modules/mobfoxBidAdapter_spec.js +++ /dev/null @@ -1,123 +0,0 @@ -describe('mobfox adapter tests', function () { - const expect = require('chai').expect; - const utils = require('src/utils'); - const adapter = require('modules/mobfoxBidAdapter'); - - const bidRequest = [{ - code: 'div-gpt-ad-1460505748561-0', - sizes: [[320, 480], [300, 250], [300, 600]], - // Replace this object to test a new Adapter! - bidder: 'mobfox', - bidId: '5t5t5t5', - params: { - s: '267d72ac3f77a3f447b32cf7ebf20673', // required - The hash of your inventory to identify which app is making the request, - imp_instl: 1 // optional - set to 1 if using interstitial otherwise delete or set to 0 - }, - placementCode: 'div-gpt-ad-1460505748561-0', - auctionId: 'c241c810-18d9-4aa4-a62f-8c1980d8d36b', - transactionId: '31f42cba-5920-4e47-adad-69c79d0d4fb4' - }]; - - describe('validRequests', function () { - let bidRequestInvalid1 = [{ - code: 'div-gpt-ad-1460505748561-0', - sizes: [[320, 480], [300, 250], [300, 600]], - // Replace this object to test a new Adapter! - bidder: 'mobfox', - bidId: '5t5t5t5', - params: { - imp_instl: 1 // optional - set to 1 if using interstitial otherwise delete or set to 0 - }, - placementCode: 'div-gpt-ad-1460505748561-0', - auctionId: 'c241c810-18d9-4aa4-a62f-8c1980d8d36b', - transactionId: '31f42cba-5920-4e47-adad-69c79d0d4fb4' - }]; - - it('test valid MF request success', function () { - let isValid = adapter.spec.isBidRequestValid(bidRequest[0]); - expect(isValid).to.equal(true); - }); - - it('test valid MF request failed1', function () { - let isValid = adapter.spec.isBidRequestValid(bidRequestInvalid1[0]); - expect(isValid).to.equal(false); - }); - }) - - describe('buildRequests', function () { - it('test build MF request', function () { - let request = adapter.spec.buildRequests(bidRequest); - let payload = request.data.split('&'); - expect(payload[0]).to.equal('rt=api-fetchip'); - expect(payload[1]).to.equal('r_type=banner'); - expect(payload[2]).to.equal('r_resp=json'); - expect(payload[3]).to.equal('s=267d72ac3f77a3f447b32cf7ebf20673'); - expect(payload[5]).to.equal('adspace_width=320'); - expect(payload[6]).to.equal('adspace_height=480'); - expect(payload[7]).to.equal('imp_instl=1'); - }); - - it('test build MF request', function () { - let request = adapter.spec.buildRequests(bidRequest); - let payload = request.data.split('&'); - expect(payload[0]).to.equal('rt=api-fetchip'); - expect(payload[1]).to.equal('r_type=banner'); - expect(payload[2]).to.equal('r_resp=json'); - expect(payload[3]).to.equal('s=267d72ac3f77a3f447b32cf7ebf20673'); - expect(payload[5]).to.equal('adspace_width=320'); - expect(payload[6]).to.equal('adspace_height=480'); - expect(payload[7]).to.equal('imp_instl=1'); - }); - }) - - describe('interceptResponse', function () { - let mockServerResponse = { - body: { - request: { - clicktype: 'safari', - clickurl: 'https://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0', - cpmPrice: 50, - htmlString: 'test', - refresh: '30', - scale: 'no', - skippreflight: 'yes', - type: 'textAd', - urltype: 'link' - } - }, - headers: { - get: function (header) { - if (header === 'X-Pricing-CPM') { - return 50; - } - } - } - }; - it('test intercept response', function () { - let request = adapter.spec.buildRequests(bidRequest); - let bidResponses = adapter.spec.interpretResponse(mockServerResponse, request); - expect(bidResponses.length).to.equal(1); - expect(bidResponses[0].ad).to.equal('test'); - expect(bidResponses[0].cpm).to.equal(50); - expect(bidResponses[0].creativeId).to.equal('267d72ac3f77a3f447b32cf7ebf20673'); - expect(bidResponses[0].requestId).to.equal('5t5t5t5'); - expect(bidResponses[0].currency).to.equal('USD'); - expect(bidResponses[0].height).to.equal('480'); - expect(bidResponses[0].netRevenue).to.equal(true); - expect(bidResponses[0].referrer).to.equal('https://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0'); - expect(bidResponses[0].ttl).to.equal(360); - expect(bidResponses[0].width).to.equal('320'); - }); - - it('test intercept response with empty server response', function () { - let request = adapter.spec.buildRequests(bidRequest); - let serverResponse = { - request: { - error: 'cannot get response' - } - }; - let bidResponses = adapter.spec.interpretResponse(serverResponse, request); - expect(bidResponses.length).to.equal(0); - }) - }) -}); 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/mytargetBidAdapter_spec.js b/test/spec/modules/mytargetBidAdapter_spec.js deleted file mode 100644 index ea998303fe3..00000000000 --- a/test/spec/modules/mytargetBidAdapter_spec.js +++ /dev/null @@ -1,229 +0,0 @@ -import { expect } from 'chai'; -import { config } from 'src/config.js'; -import { spec } from 'modules/mytargetBidAdapter.js'; - -describe('MyTarget Adapter', function() { - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - let validBid = { - bidder: 'mytarget', - params: { - placementId: '1' - } - }; - - expect(spec.isBidRequestValid(validBid)).to.equal(true); - }); - - it('should return false for when required params are not passed', function () { - let invalidBid = { - bidder: 'mytarget', - params: {} - }; - - expect(spec.isBidRequestValid(invalidBid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - bidId: 'bid1', - bidder: 'mytarget', - params: { - placementId: '1' - } - }, - { - bidId: 'bid2', - bidder: 'mytarget', - params: { - placementId: '2', - position: 1, - response: 1, - bidfloor: 10000 - } - } - ]; - let bidderRequest = { - refererInfo: { - referer: 'https://example.com?param=value' - } - }; - - let 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://ad.mail.ru/hbid_prebid/'); - expect(bidRequest.data).to.be.an('object'); - expect(bidRequest.data.places).to.be.an('array'); - expect(bidRequest.data.places).to.have.lengthOf(2); - }); - - it('should pass bid parameters', function() { - let place1 = bidRequest.data.places[0]; - let 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 default position and response type', function() { - let place = bidRequest.data.places[0]; - - expect(place.position).to.equal(0); - expect(place.response).to.equal(0); - }); - - it('should pass provided position and response type', function() { - let place = bidRequest.data.places[1]; - - expect(place.position).to.equal(1); - expect(place.response).to.equal(1); - }); - - it('should not pass default bidfloor', function() { - let place = bidRequest.data.places[0]; - - expect(place.bidfloor).not.to.exist; - }); - - it('should not pass provided bidfloor', function() { - let place = bidRequest.data.places[1]; - - expect(place.bidfloor).to.exist; - expect(place.bidfloor).to.equal(10000); - }); - - it('should pass site parameters', function() { - let site = bidRequest.data.site; - - expect(site).to.be.an('object'); - expect(site.sitename).to.equal('example.com'); - expect(site.page).to.equal('https://example.com?param=value'); - }); - - it('should pass settings', function() { - let settings = bidRequest.data.settings; - - expect(settings).to.be.an('object'); - expect(settings.currency).to.equal('RUB'); - expect(settings.windowSize).to.be.an('object'); - expect(settings.windowSize.width).to.equal(window.screen.width); - expect(settings.windowSize.height).to.equal(window.screen.height); - }); - - it('should pass currency from currency.adServerCurrency', function() { - const configStub = sinon.stub(config, 'getConfig').callsFake( - key => key === 'currency.adServerCurrency' ? 'USD' : ''); - - let bidRequest = spec.buildRequests(bidRequests, bidderRequest); - let settings = bidRequest.data.settings; - - expect(settings).to.be.an('object'); - expect(settings.currency).to.equal('USD'); - expect(settings.windowSize).to.be.an('object'); - expect(settings.windowSize.width).to.equal(window.screen.width); - expect(settings.windowSize.height).to.equal(window.screen.height); - - configStub.restore(); - }); - - it('should ignore currency other than "RUB" or "USD"', function() { - const configStub = sinon.stub(config, 'getConfig').callsFake( - key => key === 'currency.adServerCurrency' ? 'EUR' : ''); - - let bidRequest = spec.buildRequests(bidRequests, bidderRequest); - let settings = bidRequest.data.settings; - - expect(settings).to.be.an('object'); - expect(settings.currency).to.equal('RUB'); - - configStub.restore(); - }); - }); - - describe('interpretResponse', function () { - let serverResponse = { - body: { - 'bidder_status': - [ - { - 'bidder': 'mail.ru', - 'response_time_ms': 100, - 'num_bids': 2 - } - ], - 'bids': - [ - { - 'displayUrl': 'https://ad.mail.ru/hbid_imp/12345', - 'size': - { - 'height': '400', - 'width': '240' - }, - 'id': '1', - 'currency': 'RUB', - 'price': 100, - 'ttl': 360, - 'creativeId': '123456' - }, - { - 'adm': '

Ad

', - 'size': - { - 'height': '250', - 'width': '300' - }, - 'id': '2', - 'price': 200 - } - ] - } - }; - - let bids = spec.interpretResponse(serverResponse); - - it('should return empty array for response with no bids', function() { - let 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 with ad url', function() { - expect(bids[0].requestId).to.equal('1'); - expect(bids[0].cpm).to.equal(100); - expect(bids[0].width).to.equal('240'); - expect(bids[0].height).to.equal('400'); - expect(bids[0].ttl).to.equal(360); - expect(bids[0].currency).to.equal('RUB'); - expect(bids[0]).to.have.property('creativeId'); - expect(bids[0].creativeId).to.equal('123456'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].adUrl).to.equal('https://ad.mail.ru/hbid_imp/12345'); - expect(bids[0]).to.not.have.property('ad'); - }); - - it('should parse bid with ad markup', function() { - expect(bids[1].requestId).to.equal('2'); - expect(bids[1].cpm).to.equal(200); - expect(bids[1].width).to.equal('300'); - expect(bids[1].height).to.equal('250'); - expect(bids[1].ttl).to.equal(180); - expect(bids[1].currency).to.equal('RUB'); - expect(bids[1]).to.have.property('creativeId'); - expect(bids[1].creativeId).not.to.equal('123456'); - expect(bids[1].netRevenue).to.equal(true); - expect(bids[1].ad).to.equal('

Ad

'); - expect(bids[1]).to.not.have.property('adUrl'); - }); - }); -}); diff --git a/test/spec/modules/nafdigitalBidAdapter_spec.js b/test/spec/modules/nafdigitalBidAdapter_spec.js deleted file mode 100644 index c8ffb9fbbaf..00000000000 --- a/test/spec/modules/nafdigitalBidAdapter_spec.js +++ /dev/null @@ -1,283 +0,0 @@ -import { expect } from 'chai'; -import * as utils from 'src/utils.js'; -import { spec } from 'modules/nafdigitalBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -const URL = 'https://nafdigitalbidder.com/hb'; - -describe('nafdigitalBidAdapter', function() { - const adapter = newBidder(spec); - let element, win; - let bidRequests; - let sandbox; - - beforeEach(function() { - element = { - x: 0, - y: 0, - - width: 0, - height: 0, - - getBoundingClientRect: () => { - return { - width: element.width, - height: element.height, - - left: element.x, - top: element.y, - right: element.x + element.width, - bottom: element.y + element.height - }; - } - }; - win = { - document: { - visibilityState: 'visible' - }, - - innerWidth: 800, - innerHeight: 600 - }; - bidRequests = [{ - 'bidder': 'nafdigital', - 'params': { - 'publisherId': 1234567 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '5fb26ac22bde4', - 'bidderRequestId': '4bf93aeb730cb9', - 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e' - }]; - - sandbox = sinon.sandbox.create(); - sandbox.stub(document, 'getElementById').withArgs('adunit-code').returns(element); - sandbox.stub(utils, 'getWindowTop').returns(win); - sandbox.stub(utils, 'getWindowSelf').returns(win); - }); - - afterEach(function() { - sandbox.restore(); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'nafdigital', - 'params': { - 'publisherId': 1234567 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '5fb26ac22bde4', - 'bidderRequestId': '4bf93aeb730cb9', - 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when tagid not passed correctly', function () { - bid.params.publisherId = undefined; - 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 () { - it('sends bid request to our endpoint via POST', function () { - const request = spec.buildRequests(bidRequests); - expect(request.method).to.equal('POST'); - }); - - it('request url should match our endpoint url', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.equal(URL); - }); - - it('sets the proper banner object', function() { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); - }); - - it('accepts a single array as a size', function() { - bidRequests[0].sizes = [300, 250]; - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}]); - }); - - it('sends bidfloor param if present', function () { - bidRequests[0].params.bidFloor = 0.05; - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].bidfloor).to.equal(0.05); - }); - - it('sends tagid', function () { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].tagid).to.equal('adunit-code'); - }); - - it('sends publisher id', function () { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.site.publisher.id).to.equal(1234567); - }); - - context('when element is fully in view', function() { - it('returns 100', function() { - Object.assign(element, { width: 600, height: 400 }); - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].banner.ext.viewability).to.equal(100); - }); - }); - - context('when element is out of view', function() { - it('returns 0', function() { - Object.assign(element, { x: -300, y: 0, width: 207, height: 320 }); - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].banner.ext.viewability).to.equal(0); - }); - }); - - context('when element is partially in view', function() { - it('returns percentage', function() { - Object.assign(element, { width: 800, height: 800 }); - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].banner.ext.viewability).to.equal(75); - }); - }); - - context('when width or height of the element is zero', function() { - it('try to use alternative values', function() { - Object.assign(element, { width: 0, height: 0 }); - bidRequests[0].sizes = [[800, 2400]]; - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].banner.ext.viewability).to.equal(25); - }); - }); - - context('when nested iframes', function() { - it('returns \'na\'', function() { - Object.assign(element, { width: 600, height: 400 }); - - utils.getWindowTop.restore(); - utils.getWindowSelf.restore(); - sandbox.stub(utils, 'getWindowTop').returns(win); - sandbox.stub(utils, 'getWindowSelf').returns({}); - - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].banner.ext.viewability).to.equal('na'); - }); - }); - - context('when tab is inactive', function() { - it('returns 0', function() { - Object.assign(element, { width: 600, height: 400 }); - - utils.getWindowTop.restore(); - win.document.visibilityState = 'hidden'; - sandbox.stub(utils, 'getWindowTop').returns(win); - - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.imp[0].banner.ext.viewability).to.equal(0); - }); - }); - }); - - describe('interpretResponse', function () { - let response; - beforeEach(function () { - response = { - body: { - 'id': '37386aade21a71', - 'seatbid': [{ - 'bid': [{ - 'id': '376874781', - 'impid': '283a9f4cd2415d', - 'price': 0.35743275, - 'nurl': '', - 'adm': '', - 'w': 300, - 'h': 250 - }] - }] - } - }; - }); - - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': '283a9f4cd2415d', - 'cpm': 0.35743275, - 'width': 300, - 'height': 250, - 'creativeId': '376874781', - 'currency': 'USD', - 'netRevenue': true, - 'mediaType': 'banner', - 'ad': `
`, - 'ttl': 60 - }]; - - let result = spec.interpretResponse(response); - expect(result[0]).to.deep.equal(expectedResponse[0]); - }); - - it('crid should default to the bid id if not on the response', function () { - let expectedResponse = [{ - 'requestId': '283a9f4cd2415d', - 'cpm': 0.35743275, - 'width': 300, - 'height': 250, - 'creativeId': response.body.seatbid[0].bid[0].id, - 'currency': 'USD', - 'netRevenue': true, - 'mediaType': 'banner', - 'ad': `
`, - 'ttl': 60 - }]; - - let result = spec.interpretResponse(response); - expect(result[0]).to.deep.equal(expectedResponse[0]); - }); - - it('handles empty bid response', function () { - let response = { - body: '' - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs ', () => { - let syncOptions = {iframeEnabled: true, pixelEnabled: true}; - - it('should not return', () => { - let returnStatement = spec.getUserSyncs(syncOptions, []); - expect(returnStatement).to.be.empty; - }); - }); -}); 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/newborntownWebBidAdapter_spec.js b/test/spec/modules/newborntownWebBidAdapter_spec.js deleted file mode 100644 index 3d3285328fe..00000000000 --- a/test/spec/modules/newborntownWebBidAdapter_spec.js +++ /dev/null @@ -1,152 +0,0 @@ -import { expect } from 'chai'; -import {spec} from 'modules/newborntownWebBidAdapter.js'; -describe('NewborntownWebAdapter', function() { - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'newborntownWeb', - 'params': { - 'publisher_id': '1238122', - 'slot_id': '123123', - 'bidfloor': 0.3 - }, - 'adUnitCode': '/19968336/header-bid-tag-1', - 'sizes': [[300, 250]], - 'bidId': '2e9cf65f23dbd9', - 'bidderRequestId': '1f01d9d22ee657', - 'auctionId': '2bf455a4-a889-41d5-b48f-9b56b89fbec7', - } - it('should return true where required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }) - describe('buildRequests', function () { - let bidderRequest = { - 'bidderCode': 'newborntownWeb', - 'bidderRequestId': '1f5c279a4c5de3', - 'bids': [ - { - 'bidder': 'newborntownWeb', - 'params': { - 'publisher_id': '1238122', - 'slot_id': '123123', - 'bidfloor': 0.3 - }, - 'mediaTypes': { - 'banner': {'sizes': [[300, 250]]} - }, - 'adUnitCode': '/19968336/header-bid-tag-1', - 'transactionId': '9b954797-d6f4-4730-9cbe-5a1bc8480f52', - 'sizes': [[300, 250]], - 'bidId': '215f48d07eb8b8', - 'bidderRequestId': '1f5c279a4c5de3', - 'auctionId': '5ed4f607-e11c-45b0-aba9-f67768e1f9f4', - 'src': 'client', - 'bidRequestsCount': 1 - } - ], - 'auctionStart': 1573123289380, - 'timeout': 9000, - 'start': 1573123289383 - } - it('Returns POST method', function () { - const request = spec.buildRequests(bidderRequest['bids'], bidderRequest); - expect(request[0].method).to.equal('POST'); - expect(request[0].url.indexOf('//us-west.solortb.com/adx/api/rtb?from=4') !== -1).to.equal(true); - expect(request[0].data).to.exist; - }); - it('request params multi size format object check', function () { - let bidderRequest = { - 'bidderCode': 'newborntownWeb', - 'bidderRequestId': '1f5c279a4c5de3', - 'bids': [ - { - 'bidder': 'newborntownWeb', - 'params': { - 'publisher_id': '1238122', - 'slot_id': '123123', - 'bidfloor': 0.3 - }, - 'mediaTypes': { - 'native': {'sizes': [[300, 250]]} - }, - 'adUnitCode': '/19968336/header-bid-tag-1', - 'transactionId': '9b954797-d6f4-4730-9cbe-5a1bc8480f52', - 'sizes': [300, 250], - 'bidId': '215f48d07eb8b8', - 'bidderRequestId': '1f5c279a4c5de3', - 'auctionId': '5ed4f607-e11c-45b0-aba9-f67768e1f9f4', - 'src': 'client', - 'bidRequestsCount': 1 - } - ], - 'auctionStart': 1573123289380, - 'timeout': 9000, - 'start': 1573123289383 - } - let requstTest = spec.buildRequests(bidderRequest['bids'], bidderRequest) - expect(requstTest[0].data.imp[0].banner.w).to.equal(300); - expect(requstTest[0].data.imp[0].banner.h).to.equal(250); - }); - }) - describe('interpretResponse', function () { - let serverResponse; - let bidRequest = { - data: { - bidId: '2d359291dcf53b' - } - }; - beforeEach(function () { - serverResponse = { - 'body': { - 'id': '174548259807190369860081', - 'seatbid': [ - { - 'bid': [ - { - 'id': '1573540665390298996', - 'impid': '1', - 'price': 0.3001, - 'adid': '1573540665390299172', - 'nurl': 'https://us-west.solortb.com/winnotice?price=${AUCTION_PRICE}&ssp=4&req_unique_id=740016d1-175b-4c19-9744-58a59632dabe&unique_id=06b08e40-2489-439a-8f9e-6413f3dd0bc8&isbidder=1&up=bQyvVo7tgbBVW2dDXzTdBP95Mv35YqqEika0T_btI1h6xjqA8GSXQe51_2CCHQcfuwAEOgdwN8u3VgUHmCuqNPKiBmIPaYUOQBBKjJr05zeKtabKnGT7_JJKcurrXqQ5Sl804xJear_qf2-jOaKB4w', - 'adm': "
", - 'adomain': [ - 'newborntown.com' - ], - 'iurl': 'https://sdkvideo.s3.amazonaws.com/4aa1d9533c4ce71bb1cf750ed38e3a58.png', - 'cid': '345', - 'crid': '41_11113', - 'cat': [ - '' - ], - 'h': 250, - 'w': 300 - } - ], - 'seat': '1' - } - ], - 'bidid': 'bid1573540665390298585' - }, - 'headers': { - - } - } - }); - it('result is correct', function () { - const result = spec.interpretResponse(serverResponse, bidRequest); - if (result && result[0]) { - expect(result[0].requestId).to.equal('2d359291dcf53b'); - expect(result[0].cpm).to.equal(0.3001); - expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(250); - expect(result[0].creativeId).to.equal('345'); - } - }); - }) -}) 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/nextrollBidAdapter_spec.js b/test/spec/modules/nextrollBidAdapter_spec.js deleted file mode 100644 index 7722443e584..00000000000 --- a/test/spec/modules/nextrollBidAdapter_spec.js +++ /dev/null @@ -1,268 +0,0 @@ -import { expect } from 'chai'; -import { spec, tryGetPubtag, hasCCPAConsent } from 'modules/nextrollBidAdapter.js'; -import * as utils from 'src/utils.js'; - -describe('nextrollBidAdapter', function() { - let utilsMock; - beforeEach(function () { - utilsMock = sinon.mock(utils); - }); - - afterEach(function() { - global.NextRoll = undefined; - utilsMock.restore(); - }); - - let validBid = { - bidder: 'nextroll', - adUnitCode: 'adunit-code', - bidId: 'bid_id', - sizes: [[300, 200]], - params: { - bidfloor: 1, - zoneId: 'zone1', - publisherId: 'publisher_id' - } - }; - let bidWithoutValidId = { id: '' }; - let bidWithoutId = { params: { zoneId: 'zone1' } }; - - describe('nativeBidRequest', () => { - it('validates native spec', () => { - let nativeAdUnit = [{ - bidder: 'nextroll', - adUnitCode: 'adunit-code', - bidId: 'bid_id', - mediaTypes: { - native: { - title: {required: true, len: 80}, - image: {required: true, sizes: [728, 90]}, - sponsoredBy: {required: false, len: 20}, - clickUrl: {required: true}, - body: {required: true, len: 25}, - icon: {required: true, sizes: [50, 50], aspect_ratios: [{ratio_height: 3, ratio_width: 4}]}, - someRandomAsset: {required: false, len: 100} // This should be ignored - } - }, - params: { - bidfloor: 1, - zoneId: 'zone1', - publisherId: 'publisher_id' - } - }]; - - let request = spec.buildRequests(nativeAdUnit) - let assets = request[0].data.imp.native.request.native.assets - - let excptedAssets = [ - {id: 1, required: 1, title: {len: 80}}, - {id: 2, required: 1, img: {w: 728, h: 90, wmin: 1, hmin: 1, type: 3}}, - {id: 3, required: 1, img: {w: 50, h: 50, wmin: 4, hmin: 3, type: 1}}, - {id: 5, required: 0, data: {len: 20, type: 1}}, - {id: 6, required: 1, data: {len: 25, type: 2}} - ] - expect(assets).to.be.deep.equal(excptedAssets) - }) - }) - - describe('isBidRequestValid', function() { - it('validates the bids correctly when the bid has an id', function() { - expect(spec.isBidRequestValid(validBid)).to.be.true; - }); - - it('validates the bids correcly when the bid does not have an id', function() { - expect(spec.isBidRequestValid(bidWithoutValidId)).to.be.false; - expect(spec.isBidRequestValid(bidWithoutId)).to.be.false; - }); - }); - - describe('buildRequests', function() { - it('builds the same amount of requests as valid requests it takes', function() { - expect(spec.buildRequests([validBid, validBid], {})).to.be.lengthOf(2); - }); - - it('doest not build a request when there is no valid requests', function () { - expect(spec.buildRequests([], {})).to.be.lengthOf(0); - }); - - it('builds a request with POST method', function () { - expect(spec.buildRequests([validBid], {})[0].method).to.equal('POST'); - }); - - it('builds a request with cookies method', function () { - expect(spec.buildRequests([validBid], {})[0].options.withCredentials).to.be.true; - }); - - it('builds a request with id, url and imp object', function () { - const request = spec.buildRequests([validBid], {})[0]; - expect(request.data.id).to.be.an('string').that.is.not.empty; - expect(request.url).to.equal('https://d.adroll.com/bid/prebid/'); - expect(request.data.imp).to.exist.and.to.be.a('object'); - }); - - it('builds a request with site and device information', function () { - const request = spec.buildRequests([validBid], {})[0]; - - expect(request.data.site).to.exist.and.to.be.a('object'); - expect(request.data.device).to.exist.and.to.be.a('object'); - }); - - it('builds a request with a complete imp object', function () { - const request = spec.buildRequests([validBid], {})[0]; - - expect(request.data.imp.id).to.equal('bid_id'); - expect(request.data.imp.bidfloor).to.be.equal(1); - expect(request.data.imp.banner).to.exist.and.to.be.a('object'); - expect(request.data.imp.ext.zone.id).to.be.equal('zone1'); - }); - - it('includes the sizes into the request correctly', function () { - const bannerObject = spec.buildRequests([validBid], {})[0].data.imp.banner; - - expect(bannerObject.format).to.exist; - expect(bannerObject.format).to.be.lengthOf(1); - expect(bannerObject.format[0].w).to.be.equal(300); - expect(bannerObject.format[0].h).to.be.equal(200); - }); - - it('sets the CCPA consent string', function () { - const us_privacy = '1YYY'; - const request = spec.buildRequests([validBid], {'uspConsent': us_privacy})[0]; - - expect(request.data.regs.ext.us_privacy).to.be.equal(us_privacy); - }); - }); - - describe('interpretResponse', function () { - let responseBody = { - id: 'bidresponse_id', - dealId: 'deal_id', - seatbid: [ - { - bid: [ - { - price: 1.2, - w: 300, - h: 200, - crid: 'crid1', - adm: 'adm1' - } - ] - }, - { - bid: [ - { - price: 2.1, - w: 250, - h: 300, - crid: 'crid2', - adm: 'adm2' - } - ] - } - ] - }; - - it('returns an empty list when there is no response body', function () { - expect(spec.interpretResponse({}, {})).to.be.eql([]); - }); - - it('builds the same amount of responses as server responses it receives', function () { - expect(spec.interpretResponse({body: responseBody}, {})).to.be.lengthOf(2); - }); - - it('builds a response with the expected fields', function () { - const response = spec.interpretResponse({body: responseBody}, {})[0]; - - expect(response.requestId).to.be.equal('bidresponse_id'); - expect(response.cpm).to.be.equal(1.2); - expect(response.width).to.be.equal(300); - expect(response.height).to.be.equal(200); - expect(response.creativeId).to.be.equal('crid1'); - expect(response.dealId).to.be.equal('deal_id'); - expect(response.currency).to.be.equal('USD'); - expect(response.netRevenue).to.be.equal(true); - expect(response.ttl).to.be.equal(300); - expect(response.ad).to.be.equal('adm1'); - }); - }); - - describe('interpret native response', () => { - let clickUrl = 'https://clickurl.com/with/some/path' - let titleText = 'Some title' - let imgW = 300 - let imgH = 250 - let imgUrl = 'https://clickurl.com/img.png' - let brandText = 'Some Brand' - let impUrl = 'https://clickurl.com/imptracker' - - let responseBody = { - body: { - id: 'bidresponse_id', - seatbid: [{ - bid: [{ - price: 1.2, - crid: 'crid1', - adm: { - link: {url: clickUrl}, - assets: [ - {id: 1, title: {text: titleText}}, - {id: 2, img: {w: imgW, h: imgH, url: imgUrl}}, - {id: 5, data: {value: brandText}} - ], - imptrackers: [impUrl] - } - }] - }] - } - }; - - it('Should interpret response', () => { - let response = spec.interpretResponse(utils.deepClone(responseBody)) - let expectedResponse = { - clickUrl: clickUrl, - impressionTrackers: [impUrl], - privacyLink: 'https://info.evidon.com/pub_info/573', - privacyIcon: 'https://c.betrad.com/pub/icon1.png', - title: titleText, - image: {url: imgUrl, width: imgW, height: imgH}, - sponsoredBy: brandText, - clickTrackers: [], - jstracker: [] - } - - expect(response[0].native).to.be.deep.equal(expectedResponse) - }) - - it('Should interpret all assets', () => { - let allAssetsResponse = utils.deepClone(responseBody) - let iconUrl = imgUrl + '?icon=true', iconW = 10, iconH = 15 - let logoUrl = imgUrl + '?logo=true', logoW = 20, logoH = 25 - let bodyText = 'Some body text' - - allAssetsResponse.body.seatbid[0].bid[0].adm.assets.push(...[ - {id: 3, img: {w: iconW, h: iconH, url: iconUrl}}, - {id: 4, img: {w: logoW, h: logoH, url: logoUrl}}, - {id: 6, data: {value: bodyText}} - ]) - - let response = spec.interpretResponse(allAssetsResponse) - let expectedResponse = { - clickUrl: clickUrl, - impressionTrackers: [impUrl], - jstracker: [], - clickTrackers: [], - privacyLink: 'https://info.evidon.com/pub_info/573', - privacyIcon: 'https://c.betrad.com/pub/icon1.png', - title: titleText, - image: {url: imgUrl, width: imgW, height: imgH}, - icon: {url: iconUrl, width: iconW, height: iconH}, - logo: {url: logoUrl, width: logoW, height: logoH}, - body: bodyText, - sponsoredBy: brandText - } - - expect(response[0].native).to.be.deep.equal(expectedResponse) - }) - }) -}); 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/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index 2a380277e55..112dd4768df 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -1064,7 +1064,6 @@ describe('OpenxAdapter', function () { parrableId: { eid: 'eidVersion.encryptionKeyReference.encryptedValue' }, pubcid: '1111-pubcid', quantcastId: '1111-quantcastid', - sharedId: '1111-sharedid', tapadId: '111-tapadid', tdid: '1111-tdid', verizonMediaId: '1111-verizonmediaid', diff --git a/test/spec/modules/optimeraBidAdapter_spec.js b/test/spec/modules/optimeraBidAdapter_spec.js deleted file mode 100644 index ada07fe25c2..00000000000 --- a/test/spec/modules/optimeraBidAdapter_spec.js +++ /dev/null @@ -1,99 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/optimeraBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('OptimeraAdapter', 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': 'optimera', - 'params': { - 'clientID': '9999' - }, - 'adUnitCode': 'div-0', - '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); - }); - }) - - describe('buildRequests', function () { - let bid = [ - { - 'adUnitCode': 'div-0', - 'auctionId': '1ab30503e03994', - 'bidId': '313e0afede8cdb', - 'bidder': 'optimera', - 'bidderRequestId': '202be1ce3f6194', - 'params': { - 'clientID': '0' - } - } - ]; - it('buildRequests fires', function () { - let request = spec.buildRequests(bid); - expect(request).to.exist; - expect(request.method).to.equal('GET'); - expect(request.payload).to.exist; - }); - }) - - describe('interpretResponse', function () { - let serverResponse = {}; - serverResponse.body = JSON.parse('{"div-0":["RB_K","728x90K"], "timestamp":["RB_K","1507565666"], "device": { "de": { "div-0":["A1","728x90K"] }, "mo": { "div-0":["RB_K","728x90K"] }, "tb": { "div-0":["RB_K","728x90K"] } } }'); - var bidRequest = { - 'method': 'get', - 'payload': [ - { - 'bidder': 'optimera', - 'params': { - 'clientID': '0' - }, - 'adUnitCode': 'div-0', - 'bidId': '307440db8538ab' - } - ] - } - it('interpresResponse fires', function () { - let bidResponses = spec.interpretResponse(serverResponse, bidRequest); - expect(bidResponses[0].dealId[0]).to.equal('RB_K'); - expect(bidResponses[0].dealId[1]).to.equal('728x90K'); - }); - }); - - describe('interpretResponse with optional device param', function () { - let serverResponse = {}; - serverResponse.body = JSON.parse('{"div-0":["RB_K","728x90K"], "timestamp":["RB_K","1507565666"], "device": { "de": { "div-0":["A1","728x90K"] }, "mo": { "div-0":["RB_K","728x90K"] }, "tb": { "div-0":["RB_K","728x90K"] } } }'); - var bidRequest = { - 'method': 'get', - 'payload': [ - { - 'bidder': 'optimera', - 'params': { - 'clientID': '0', - 'device': 'de' - }, - 'adUnitCode': 'div-0', - 'bidId': '307440db8538ab' - } - ] - } - it('interpresResponse fires', function () { - let bidResponses = spec.interpretResponse(serverResponse, bidRequest); - expect(bidResponses[0].dealId[0]).to.equal('A1'); - expect(bidResponses[0].dealId[1]).to.equal('728x90K'); - }); - }); -}); diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 42cc25ae04f..c6dbb24614a 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -68,21 +68,6 @@ describe('orbidderBidAdapter', () => { delete bidRequest.params; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); - - it('accepts optional bidfloor', () => { - const bidRequest = deepClone(defaultBidRequest); - bidRequest.params.bidfloor = 123; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - - bidRequest.params.bidfloor = 1.23; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('doesn\'t accept malformed bidfloor', () => { - const bidRequest = deepClone(defaultBidRequest); - bidRequest.params.bidfloor = 'another not usable string'; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); }); describe('buildRequests', () => { 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/platformioBidAdapter_spec.js b/test/spec/modules/platformioBidAdapter_spec.js deleted file mode 100644 index ee753be17a7..00000000000 --- a/test/spec/modules/platformioBidAdapter_spec.js +++ /dev/null @@ -1,348 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/platformioBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('Platform.io 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.platform.apps', - storeUrl: 'https://platform.io/apps', - domain: 'platform.io' - } - } - }]; - - it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('https://piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // site object - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.publisher).to.not.equal(null); - expect(ortbRequest.site.publisher.id).to.equal('29521'); - expect(ortbRequest.site.ref).to.equal(window.top.document.referrer); - expect(ortbRequest.site.page).to.equal(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.001'); - // slot 2 - expect(ortbRequest.imp[1].tagid).to.equal('1234'); - expect(ortbRequest.imp[1].banner).to.not.equal(null); - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); - expect(ortbRequest.imp[1].bidfloor).to.equal('0.000001'); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad', - 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://piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // native impression - expect(ortbRequest.imp[0].tagid).to.equal('123'); - const nativePart = ortbRequest.imp[0]['native']; - expect(nativePart).to.not.equal(null); - expect(nativePart.ver).to.equal('1.1'); - expect(nativePart.request).to.not.equal(null); - // native request assets - const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request); - expect(nativeRequest).to.not.equal(null); - expect(nativeRequest.assets).to.have.lengthOf(5); - expect(nativeRequest.assets[0].id).to.equal(1); - expect(nativeRequest.assets[1].id).to.equal(2); - expect(nativeRequest.assets[2].id).to.equal(3); - expect(nativeRequest.assets[3].id).to.equal(4); - expect(nativeRequest.assets[4].id).to.equal(5); - expect(nativeRequest.assets[0].required).to.equal(1); - expect(nativeRequest.assets[0].title).to.not.equal(null); - expect(nativeRequest.assets[0].title.len).to.equal(200); - expect(nativeRequest.assets[1].title).to.be.undefined; - expect(nativeRequest.assets[1].data).to.not.equal(null); - expect(nativeRequest.assets[1].data.type).to.equal(2); - expect(nativeRequest.assets[1].data.len).to.equal(200); - expect(nativeRequest.assets[2].required).to.equal(0); - expect(nativeRequest.assets[3].img).to.not.equal(null); - expect(nativeRequest.assets[3].img.wmin).to.equal(50); - expect(nativeRequest.assets[3].img.hmin).to.equal(50); - expect(nativeRequest.assets[3].img.type).to.equal(1); - expect(nativeRequest.assets[4].img).to.not.equal(null); - expect(nativeRequest.assets[4].img.wmin).to.equal(100); - expect(nativeRequest.assets[4].img.hmin).to.equal(150); - expect(nativeRequest.assets[4].img.type).to.equal(3); - }); - - it('Verify Native response', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('https://piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - const nativeResponse = { - 'native': { - assets: [ - { id: 1, title: { text: 'Ad Title' } }, - { id: 2, data: { value: 'Test description' } }, - { id: 3, data: { value: 'Brand' } }, - { id: 4, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_icon.png', w: 100, h: 100 } }, - { id: 5, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_image.png', w: 300, h: 300 } } - ], - link: { url: '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://piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const videoRequest = JSON.parse(request.data); - // site object - expect(videoRequest.site).to.not.equal(null); - expect(videoRequest.site.publisher.id).to.equal('29521'); - expect(videoRequest.site.ref).to.equal(window.top.document.referrer); - expect(videoRequest.site.page).to.equal(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('platformio'); - }); - - it('Verifies supported media types', function () { - expect(spec.supportedMediaTypes).to.have.lengthOf(3); - expect(spec.supportedMediaTypes[0]).to.equal('banner'); - expect(spec.supportedMediaTypes[1]).to.equal('native'); - expect(spec.supportedMediaTypes[2]).to.equal('video'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(slotConfigs[0])).to.equal(true); - expect(spec.isBidRequestValid(slotConfigs[1])).to.equal(true); - expect(spec.isBidRequestValid(nativeSlotConfig[0])).to.equal(true); - expect(spec.isBidRequestValid(videoSlotConfig[0])).to.equal(true); - }); - - it('Verify app requests', function () { - const request = spec.buildRequests(appSlotConfig); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.publisher).to.not.equal(null); - expect(ortbRequest.app.publisher.id).to.equal('29521'); - expect(ortbRequest.app.id).to.equal('1111'); - expect(ortbRequest.app.name).to.equal('app name'); - expect(ortbRequest.app.bundle).to.equal('io.platform.apps'); - expect(ortbRequest.app.storeurl).to.equal('https://platform.io/apps'); - expect(ortbRequest.app.domain).to.equal('platform.io'); - }); - - it('Verify GDPR', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'serialized_gpdr_data' - } - }; - const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('https://piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.user).to.not.equal(null); - expect(ortbRequest.user.ext).to.not.equal(null); - expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data'); - expect(ortbRequest.regs).to.not.equal(null); - expect(ortbRequest.regs.ext).to.not.equal(null); - expect(ortbRequest.regs.ext.gdpr).to.equal(1); - }); -}); diff --git a/test/spec/modules/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/revcontentBidAdapter_spec.js b/test/spec/modules/revcontentBidAdapter_spec.js deleted file mode 100644 index 0a0263837c6..00000000000 --- a/test/spec/modules/revcontentBidAdapter_spec.js +++ /dev/null @@ -1,351 +0,0 @@ -// jshint esversion: 6, es3: false, node: true -import {assert, expect} from 'chai'; -import {spec} from 'modules/revcontentBidAdapter.js'; -import { NATIVE } from 'src/mediaTypes.js'; -import { config } from 'src/config.js'; -import * as utils from 'src/utils.js'; - -describe('revcontent adapter', function () { - let serverResponse, bidRequest, bidResponses; - let bids = []; - - describe('isBidRequestValid', function () { - let bid = { - bidder: 'revcontent', - nativeParams: {}, - params: { - size: {width: 300, height: 250}, - apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', - userId: 673, - domain: 'test.com', - endpoint: 'trends-s0.revcontent.com' - } - }; - - it('should return true when required params found', function () { - assert(spec.isBidRequestValid(bid)); - }); - - it('should return false when required params are missing', function () { - bid.params.apiKey = undefined; - assert.isFalse(spec.isBidRequestValid(bid)); - }); - }); - - describe('buildRequests', function () { - it('should send request with correct structure', function () { - let validBidRequests = [{ - bidder: 'revcontent', - nativeParams: {}, - params: { - size: {width: 300, height: 250}, - apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', - userId: 673, - widgetId: 33861, - endpoint: 'trends-s0.revcontent.com' - } - }]; - let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); - request = request[0]; - assert.equal(request.method, 'POST'); - assert.equal(request.url, 'https://trends-s0.revcontent.com/rtb?apiKey=8a33fa9cf220ae685dcc3544f847cdda858d3b1c&userId=673&widgetId=33861'); - assert.deepEqual(request.options, {contentType: 'application/json'}); - assert.ok(request.data); - }); - - it('should have default request structure', function () { - let keys = 'method,options,url,data,bid'.split(','); - let validBidRequests = [{ - bidder: 'revcontent', - nativeParams: {}, - params: { - size: {width: 300, height: 250}, - apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', - userId: 673, - domain: 'test.com', - endpoint: 'trends-s0.revcontent.com' - } - }]; - let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); - - request = request[0]; - let data = Object.keys(request); - - assert.deepEqual(keys, data); - }); - - it('should send info about device and unique bidfloor', function () { - let validBidRequests = [{ - bidder: 'revcontent', - nativeParams: {}, - params: { - size: {width: 300, height: 250}, - apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', - userId: 673, - domain: 'test.com', - endpoint: 'trends-s0.revcontent.com', - bidfloor: 0.05 - } - }]; - let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); - request = JSON.parse(request[0].data); - assert.equal(request.imp[0].bidfloor, 0.05); - assert.equal(request.device.ua, navigator.userAgent); - }); - - it('should send info about the site and default bidfloor', function () { - let validBidRequests = [{ - bidder: 'revcontent', - nativeParams: { - image: { - required: false - }, - 'title': { - required: false, - len: 140 - }, - clickUrl: { - required: false - }, - sponsoredBy: { - id: 5, - name: 'data', - type: 1 - } - }, - params: { - size: {width: 300, height: 250}, - apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', - userId: 673, - domain: 'test.com', - endpoint: 'trends-s0.revcontent.com' - } - }]; - let refererInfo = {referer: 'page'}; - let request = spec.buildRequests(validBidRequests, {refererInfo}); - - request = JSON.parse(request[0].data); - assert.equal(request.imp[0].bidfloor, 0.1); - assert.deepEqual(request.site, { - domain: 'test.com', - page: 'page', - cat: ['IAB17'], - publisher: {id: 673, domain: 'test.com'} - }); - }); - }); - - describe('interpretResponse', function () { - it('should return if no body in response', function () { - let serverResponse = {}; - let bidRequest = {}; - - assert.ok(!spec.interpretResponse(serverResponse, bidRequest)); - }); - - const serverResponse = { - body: { - id: '5d61ca27-1b7a-4d5a-90ad-bbfc93e53f58', - seatbid: [ - { - bid: [ - { - id: '6bbe3eed-f443-4e2b-a8da-57fd6327b37d', - impid: '1', - price: 0.1, - adid: '4162547', - nurl: 'https://trends-s0.revcontent.com/push/track/?p=${AUCTION_PRICE}&d=nTCdHIfsgKOLFuV7DS1LF%2FnTk5HiFduGU65BgKgB%2BvKyG9YV7ceQWN76HMbBE0C6gwQeXUjravv3Hq5x9TT8CM6r2oUNgkGC9mhgv2yroTH9i3cSoH%2BilxyY19fMXFirtBz%2BF%2FEXKi4bsNh%2BDMPfj0L4elo%2FJEZmx4nslvOneJJjsFjJJtUJc%2F3UPivOisSCa%2B36mAgFQqt%2FSWBriYB%2BVAufz70LaGspF6T6jDzuIyVFJUpLhZVDtLRSJEzh7Lyzzw1FmYarp%2FPg0gZDY48aDdjw5A3Tlj%2Bap0cPHLDprNOyF0dmHDn%2FOVJEDRTWvrQ2JNK1t%2Fg1bGHIih0ec6XBVIBNurqRpLFBuUY6LgXCt0wRZWTByTEZ8AEv8IoYVILJAL%2BXL%2F9IyS4eTcdOUfn5X7gT8QBghCrAFrsCg8ZXKgWddTEXbpN1lU%2FzHdI5eSHkxkJ6WcYxSkY9PyripaIbmKiyb98LQMgTD%2B20RJO5dAmXTQTAcauw6IUPTjgSPEU%2Bd6L5Txd3CM00Hbd%2Bw1bREIQcpKEmlMwrRSwe4bu1BCjlh5A9gvU9Xc2sf7ekS3qPPmtp059r5IfzdNFQJB5aH9HqeDEU%2FxbMHx4ggMgojLBBL1fKrCKLAteEDQxd7PVmFJv7GHU2733vt5TnjKiEhqxHVFyi%2B0MIYMGIziM5HfUqfq3KUf%2F%2FeiCtJKXjg7FS6hOambdimSt7BdGDIZq9QECWdXsXcQqqVLwli27HYDMFVU3TWWRyjkjbhnQID9gQJlcpwIi87jVAODb6qP%2FKGQ%3D%3D', - adm: '{"ver":"1.1","assets":[{"id":3,"required":1,"img":{"url":"//img.revcontent.com/?url=https://revcontent-p0.s3.amazonaws.com/content/images/15761052960288727821.jpg&static=true"}},{"id":0,"required":1,"title":{"text":"Do You Eat Any of These Craving-trigger Foods?"}},{"id":5,"required":1,"data":{"value":""}}],"link":{"url":"https://trends-s0.revcontent.com/click.php?d=A7EVbNYBVyonty19Ak08zCr9J54qg%2Bmduq6p0Zyn5%2F%2Bapm4deUo9VAXmOGEIbUBf6i7m3%2F%2FWJm%2FzTha8SJ%2Br9MZL9jhhUxDeiKb6aRY1biLrvr6tFUd1phvtKqVmPd76l9VBLFMxS1brSzKjRCJlIGmyGJg7ueFvxpE9X%2BpHmdbE2uqUdRC49ENO3XZyHCCKMAZ8XD29fasX9Kli9mKpZTqw8vayFlXbVYSUwB8wfSwCt1sIUrt0aICYc0jcyWU3785GTS1xXzQj%2FIVszFYYrdTWd%2BDijjNZtFny0OomPHp8lRy5VcQVCuLpw0Fks4myvsE38XcNvs4wO3tWTNrI%2BMqcW1%2BD2OnMSq5nN5FCbmi2ly%2F1LbN9fibaFvW%2FQbzQhN9ZsAwmhm409UTtdmSA6hd96vDxDWLeUJhVO3UQyI0yq2TtVnB9tEICD8mZNWwYehOab%2BQ1EWmTerF6ZCDx8RyZus1UrsDfRwvTCyUjCmkZhmeo4QVJkpPy6QobCsngSaxkkKhH%2Fb7coZyBXXEt3ORoYBLUbfRO6nR8GdIt8413vrYr4gTAroh46VcWK0ls0gFNe2u3%2FqP%2By1yLKbzDVaR%2Fa02G%2Biiqbw86sCYfsy7qK9atyjNTm8RkH6JLESUzxc6IEazu4iwHKGnu5phTacmseXCi8y9Y5AdBZn8VnLP%2F2a%2FyAqq93xEH%2BIrkAdhGRY1tY39rBYAtvH%2FVyNFZcong%2FutUMYbp0WhDNyfl6iWxmpE28Cx9KDcqXss0NIwQm0AWeu8ogJCIG3faAkm5PdFsUdf2X9h3HuFDbnbvnXW27ml6z9GykEzv%2F8aSZlMZ"}}' - } - ] - } - ], - bidid: '7f729368-edb2-427a-bde7-a55b3bf8837c' - }, - headers: {} - }; - - const bidRequest = { - method: 'POST', - options: { - contentType: 'application/json' - }, - url: 'https://trends-s0.revcontent.com/rtb?apiKey=8a33fa9cf220ae685dcc3544f847cdda858d3b1c&userId=673', - data: '{"id":"5d61ca27-1b7a-4d5a-90ad-bbfc93e53f58","imp":[{"id":1,"bidderRequestId":"14e4dab7b5396e8","auctionId":"5d61ca27-1b7a-4d5a-90ad-bbfc93e53f58","transactionId":"69e69abf-a3ea-484d-a81c-d48dd0d5eaa3","native":{"request":{"ver":"1.1","context":2,"contextsubtype":21,"plcmttype":4,"plcmtcnt":4,"assets":[{"required":0,"id":3,"img":{"type":3}},{"required":0,"id":0,"title":{"len":140}},{"required":0,"id":5,"data":{"type":1}}]},"ver":"1.1","battr":[1,3,8,11,17]},"instl":0,"bidfloor":0.1,"secure":"1"}],"site":{"domain":"test.com","page":"https://feudfun.com/test22/revcontent_example.php","cat":["IAB17"],"publisher":{"id":673,"domain":"test.com"}},"device":{"ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:71.0) Gecko/20100101 Firefox/71.0","language":"en"},"user":{"id":1},"at":2,"bcat":["IAB24","IAB25","IAB25-1","IAB25-2","IAB25-3","IAB25-4","IAB25-5","IAB25-6","IAB25-7","IAB26","IAB26-1","IAB26-2","IAB26-3","IAB26-4"]}', - bid: [ - { - bidder: 'revcontent', - params: { - size: { - width: 300, - height: 250 - }, - apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', - userId: 673, - domain: 'test.com', - endpoint: 'trends-s0.revcontent.com' - }, - crumbs: { - pubcid: '7a0b4adc-c109-49f0-aadc-4a4b62ebe269' - }, - nativeParams: { - image: { - required: false - }, - 'title': { - required: false, - len: 140 - }, - clickUrl: { - required: false - }, - sponsoredBy: { - id: 5, - name: 'data', - type: 1 - } - }, - mediaTypes: { - native: { - image: { - required: false - }, - title: { - required: false, - len: 140 - }, - clickUrl: { - required: false - }, - sponsoredBy: { - id: 5, - name: 'data', - type: 1 - } - } - }, - adUnitCode: '/19968336/header-bid-tag-1', - transactionId: '69e69abf-a3ea-484d-a81c-d48dd0d5eaa3', - sizes: [], - bidId: '294a7f446202848', - bidderRequestId: '14e4dab7b5396e8', - auctionId: '5d61ca27-1b7a-4d5a-90ad-bbfc93e53f58', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - } - ] - }; - - it('should set correct native params', function () { - const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); - assert.equal(result.mediaType, 'native'); - assert.equal(result.requestId, '294a7f446202848'); - assert.equal(result.cpm, '0.1'); - assert.equal(result.creativeId, '4162547'); - }); - - it('validate template 728x90', function () { - bidRequest.bid[0].params.size.width = 728; - bidRequest.bid[0].params.size.height = 90; - - const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); - assert.equal(result.mediaType, 'native'); - assert.equal(result.requestId, '294a7f446202848'); - assert.equal(result.cpm, '0.1'); - assert.equal(result.creativeId, '4162547'); - }); - - it('validate template 300x600', function () { - bidRequest.bid[0].params.size.width = 300; - bidRequest.bid[0].params.size.height = 600; - - const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); - assert.equal(result.mediaType, 'native'); - assert.equal(result.requestId, '294a7f446202848'); - assert.equal(result.cpm, '0.1'); - assert.equal(result.creativeId, '4162547'); - }); - - it('validate template custom template', function () { - bidRequest.bid[0].params.template = '

{title}

SEE MORE
'; - - const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); - assert.equal(result.mediaType, 'native'); - assert.equal(result.requestId, '294a7f446202848'); - assert.equal(result.cpm, '0.1'); - assert.equal(result.creativeId, '4162547'); - }); - - it('validate template custom invalid template', function () { - bidRequest.bid[0].params.size.width = 100; - bidRequest.bid[0].params.size.height = 200; - - const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); - assert.equal(result.mediaType, 'native'); - assert.equal(result.requestId, '294a7f446202848'); - assert.equal(result.cpm, '0.1'); - assert.equal(result.creativeId, '4162547'); - }); - - it('should return empty when there is no bids in response', function () { - const serverResponse = { - body: { - id: null, - bidid: null, - seatbid: [{bid: []}], - cur: 'USD' - } - }; - let bidRequest = { - data: {}, - bids: [{bidId: 'bidId1'}] - }; - const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.ok(!result); - }); - }); - - describe('onBidWon', function () { - it('default bid won', function () { - const bid = { - nurl: 'https://trends-s0.revcontent.com/push/track/?p=${AUCTION_PRICE}&d=nTCdHIfsgKOLFuV7DS1LF%2FnTk5HiFduGU65BgKgB%2BvKyG9YV7ceQWN76HMbBE0C6gwQeXUjravv3Hq5x9TT8CM6r2oUNgkGC9mhgv2yroTH9i3cSoH%2BilxyY19fMXFirtBz%2BF%2FEXKi4bsNh%2BDMPfj0L4elo%2FJEZmx4nslvOneJJjsFjJJtUJc%2F3UPivOisSCa%2B36mAgFQqt%2FSWBriYB%2BVAufz70LaGspF6T6jDzuIyVFJUpLhZVDtLRSJEzh7Lyzzw1FmYarp%2FPg0gZDY48aDdjw5A3Tlj%2Bap0cPHLDprNOyF0dmHDn%2FOVJEDRTWvrQ2JNK1t%2Fg1bGHIih0ec6XBVIBNurqRpLFBuUY6LgXCt0wRZWTByTEZ8AEv8IoYVILJAL%2BXL%2F9IyS4eTcdOUfn5X7gT8QBghCrAFrsCg8ZXKgWddTEXbpN1lU%2FzHdI5eSHkxkJ6WcYxSkY9PyripaIbmKiyb98LQMgTD%2B20RJO5dAmXTQTAcauw6IUPTjgSPEU%2Bd6L5Txd3CM00Hbd%2Bw1bREIQcpKEmlMwrRSwe4bu1BCjlh5A9gvU9Xc2sf7ekS3qPPmtp059r5IfzdNFQJB5aH9HqeDEU%2FxbMHx4ggMgojLBBL1fKrCKLAteEDQxd7PVmFJv7GHU2733vt5TnjKiEhqxHVFyi%2B0MIYMGIziM5HfUqfq3KUf%2F%2FeiCtJKXjg7FS6hOambdimSt7BdGDIZq9QECWdXsXcQqqVLwli27HYDMFVU3TWWRyjkjbhnQID9gQJlcpwIi87jVAODb6qP%2FKGQ%3D%3D', - cpm: '0.1' - }; - const result = spec.onBidWon(bid); - assert.ok(result); - }); - }); - - describe('onBidWon', function() { - const bid = { - nurl: 'https://trends-s0.revcontent.com/push/track/?p=${AUCTION_PRICE}&d=nTCdHIfsgKOLFuV7DS1LF%2FnTk5HiFduGU65BgKgB%2BvKyG9YV7ceQWN76HMbBE0C6gwQeXUjravv3Hq5x9TT8CM6r2oUNgkGC9mhgv2yroTH9i3cSoH%2BilxyY19fMXFirtBz%2BF%2FEXKi4bsNh%2BDMPfj0L4elo%2FJEZmx4nslvOneJJjsFjJJtUJc%2F3UPivOisSCa%2B36mAgFQqt%2FSWBriYB%2BVAufz70LaGspF6T6jDzuIyVFJUpLhZVDtLRSJEzh7Lyzzw1FmYarp%2FPg0gZDY48aDdjw5A3Tlj%2Bap0cPHLDprNOyF0dmHDn%2FOVJEDRTWvrQ2JNK1t%2Fg1bGHIih0ec6XBVIBNurqRpLFBuUY6LgXCt0wRZWTByTEZ8AEv8IoYVILJAL%2BXL%2F9IyS4eTcdOUfn5X7gT8QBghCrAFrsCg8ZXKgWddTEXbpN1lU%2FzHdI5eSHkxkJ6WcYxSkY9PyripaIbmKiyb98LQMgTD%2B20RJO5dAmXTQTAcauw6IUPTjgSPEU%2Bd6L5Txd3CM00Hbd%2Bw1bREIQcpKEmlMwrRSwe4bu1BCjlh5A9gvU9Xc2sf7ekS3qPPmtp059r5IfzdNFQJB5aH9HqeDEU%2FxbMHx4ggMgojLBBL1fKrCKLAteEDQxd7PVmFJv7GHU2733vt5TnjKiEhqxHVFyi%2B0MIYMGIziM5HfUqfq3KUf%2F%2FeiCtJKXjg7FS6hOambdimSt7BdGDIZq9QECWdXsXcQqqVLwli27HYDMFVU3TWWRyjkjbhnQID9gQJlcpwIi87jVAODb6qP%2FKGQ%3D%3D', - cpm: '0.1' - }; - - beforeEach(function() { - sinon.stub(utils, 'triggerPixel'); - }); - - afterEach(function() { - utils.triggerPixel.restore(); - }); - - it('make sure only 1 ajax call is happening', function() { - spec.onBidWon(bid); - expect(utils.triggerPixel.calledOnce).to.equal(true); - }); - }); -}); diff --git a/test/spec/modules/rhythmoneBidAdapter_spec.js b/test/spec/modules/rhythmoneBidAdapter_spec.js index 93735c019e1..e0e58fc89cd 100644 --- a/test/spec/modules/rhythmoneBidAdapter_spec.js +++ b/test/spec/modules/rhythmoneBidAdapter_spec.js @@ -444,7 +444,7 @@ describe('rhythmone adapter tests', function () { expect(openrtbRequest.device.dnt).to.equal(1); }); - it('sets floor', function () { + it('sets floor to zero', function () { var bidRequestList = [ { 'bidder': 'rhythmone', @@ -469,7 +469,7 @@ describe('rhythmone adapter tests', function () { var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); const openrtbRequest = JSON.parse(bidRequest.data); - expect(openrtbRequest.imp[0].bidfloor).to.equal(100.0); + expect(openrtbRequest.imp[0].bidfloor).to.equal(0); }); it('supports string video sizes', function () { 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/rtbdemandBidAdapter_spec.js b/test/spec/modules/rtbdemandBidAdapter_spec.js deleted file mode 100644 index be9872ec01b..00000000000 --- a/test/spec/modules/rtbdemandBidAdapter_spec.js +++ /dev/null @@ -1,174 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/rtbdemandBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('rtbdemandAdapter', 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': 'rtbdemand', - 'params': { - 'zoneid': '37', - 'floor': '0.05', - 'server': 'bidding.rtbdemand.com', - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return true when required params found', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'zoneid': '37', - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'zoneid': 0, - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidderRequest = { - bidderCode: 'rtbdemand', - auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - bidderRequestId: '178e34bad3658f', - bids: [ - { - bidder: 'rtbdemand', - params: { - zoneid: '37', - floor: '0.05', - server: 'bidding.rtbdemand.com', - }, - placementCode: '/19968336/header-bid-tag-0', - sizes: [[300, 250], [320, 50]], - bidId: '2ffb201a808da7', - bidderRequestId: '178e34bad3658f', - auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' - }, - { - bidder: 'rtbdemand', - params: { - zoneid: '37', - floor: '0.05', - server: 'bidding.rtbdemand.com', - }, - placementCode: '/19968336/header-bid-tag-0', - sizes: [[728, 90], [320, 50]], - bidId: '2ffb201a808da7', - bidderRequestId: '178e34bad3658f', - auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' - } - ], - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000 - }; - - it('should add source and verison to the tag', function () { - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - const payload = request.data; - expect(payload.from).to.exist; - expect(payload.v).to.exist; - expect(payload.request_id).to.exist; - expect(payload.imp_id).to.exist; - expect(payload.aff).to.exist; - expect(payload.bid_floor).to.exist; - expect(payload.charset).to.exist; - expect(payload.site_domain).to.exist; - expect(payload.site_page).to.exist; - expect(payload.subid).to.exist; - expect(payload.flashver).to.exist; - expect(payload.tmax).to.exist; - }); - - it('sends bid request to ENDPOINT via GET', function () { - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.url).to.equal('https://bidding.rtbdemand.com/hb'); - expect(request.method).to.equal('GET'); - }); - }) - - describe('interpretResponse', function () { - let response = { - 'id': '543210', - 'seatbid': [ { - 'bid': [ { - 'id': '1111111', - 'impid': 'bidId-123456-1', - 'w': 728, - 'h': 90, - 'price': 0.09, - 'adm': '', - } ], - } ] - }; - - 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://bidding.rtbdemand.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/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/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index a290a9bdb0a..4c0b27ca8be 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -229,7 +229,6 @@ describe('the rubicon adapter', function () { bid.userId = { lipb: {lipbid: '0000-1111-2222-3333', segments: ['segA', 'segB']}, idl_env: '1111-2222-3333-4444', - sharedid: {id: '1111', third: '2222'}, tdid: '3000', pubcid: '4000', pubProvidedId: [{ @@ -511,6 +510,38 @@ describe('the rubicon adapter', function () { expect(data['p_pos']).to.equal(undefined); }); + it('should not send p_pos to AE if not mediaTypes.banner.pos is invalid', function () { + var bidRequest = utils.deepClone(bidderRequest); + bidRequest.bids[0].mediaTypes = { + banner: { + pos: 5 + } + }; + delete bidRequest.bids[0].params.position; + + let [request] = spec.buildRequests(bidRequest.bids, bidRequest); + let data = parseQuery(request.data); + + expect(data['site_id']).to.equal('70608'); + expect(data['p_pos']).to.equal(undefined); + }); + + it('should send p_pos to AE if mediaTypes.banner.pos is valid', function () { + var bidRequest = utils.deepClone(bidderRequest); + bidRequest.bids[0].mediaTypes = { + banner: { + pos: 1 + } + }; + delete bidRequest.bids[0].params.position; + + let [request] = spec.buildRequests(bidRequest.bids, bidRequest); + let data = parseQuery(request.data); + + expect(data['site_id']).to.equal('70608'); + expect(data['p_pos']).to.equal('atf'); + }); + it('should not send p_pos to AE if not params.position is invalid', function () { var badposRequest = utils.deepClone(bidderRequest); badposRequest.bids[0].params.position = 'bad'; @@ -1226,23 +1257,6 @@ describe('the rubicon adapter', function () { }); }); - describe('SharedID support', function () { - it('should send sharedid when userIdAsEids contains sharedId', function () { - const clonedBid = utils.deepClone(bidderRequest.bids[0]); - clonedBid.userId = { - sharedid: { - id: '1111', - third: '2222' - } - }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); - let [request] = spec.buildRequests([clonedBid], bidderRequest); - let data = parseQuery(request.data); - - expect(data['eid_sharedid.org']).to.equal('1111^1^2222'); - }); - }); - describe('pubProvidedId support', function () { it('should send pubProvidedId when userIdAsEids contains pubProvidedId ids', function () { const clonedBid = utils.deepClone(bidderRequest.bids[0]); @@ -1312,10 +1326,7 @@ describe('the rubicon adapter', function () { config.setConfig({user: {id: '123'}}); const clonedBid = utils.deepClone(bidderRequest.bids[0]); clonedBid.userId = { - sharedid: { - id: '1111', - third: '2222' - } + pubcid: '1111' }; let [request] = spec.buildRequests([clonedBid], bidderRequest); let data = parseQuery(request.data); @@ -1537,29 +1548,24 @@ describe('the rubicon adapter', function () { expect(post.user.ext.eids[1].source).to.equal('liveramp.com'); expect(post.user.ext.eids[1].uids[0].id).to.equal('1111-2222-3333-4444'); expect(post.user.ext.eids[1].uids[0].atype).to.equal(3); - // SharedId should exist - expect(post.user.ext.eids[2].source).to.equal('sharedid.org'); - expect(post.user.ext.eids[2].uids[0].id).to.equal('1111'); - expect(post.user.ext.eids[2].uids[0].atype).to.equal(1); - expect(post.user.ext.eids[2].uids[0].ext.third).to.equal('2222'); // UnifiedId should exist - expect(post.user.ext.eids[3].source).to.equal('adserver.org'); - expect(post.user.ext.eids[3].uids[0].atype).to.equal(1); - expect(post.user.ext.eids[3].uids[0].id).to.equal('3000'); + expect(post.user.ext.eids[2].source).to.equal('adserver.org'); + expect(post.user.ext.eids[2].uids[0].atype).to.equal(1); + expect(post.user.ext.eids[2].uids[0].id).to.equal('3000'); // PubCommonId should exist - expect(post.user.ext.eids[4].source).to.equal('pubcid.org'); - expect(post.user.ext.eids[4].uids[0].atype).to.equal(1); - expect(post.user.ext.eids[4].uids[0].id).to.equal('4000'); + expect(post.user.ext.eids[3].source).to.equal('pubcid.org'); + expect(post.user.ext.eids[3].uids[0].atype).to.equal(1); + expect(post.user.ext.eids[3].uids[0].id).to.equal('4000'); // example should exist - expect(post.user.ext.eids[5].source).to.equal('example.com'); - expect(post.user.ext.eids[5].uids[0].id).to.equal('333333'); + expect(post.user.ext.eids[4].source).to.equal('example.com'); + expect(post.user.ext.eids[4].uids[0].id).to.equal('333333'); // id-partner.com - expect(post.user.ext.eids[6].source).to.equal('id-partner.com'); - expect(post.user.ext.eids[6].uids[0].id).to.equal('4444444'); + expect(post.user.ext.eids[5].source).to.equal('id-partner.com'); + expect(post.user.ext.eids[5].uids[0].id).to.equal('4444444'); // CriteoId should exist - expect(post.user.ext.eids[7].source).to.equal('criteo.com'); - expect(post.user.ext.eids[7].uids[0].id).to.equal('1111'); - expect(post.user.ext.eids[7].uids[0].atype).to.equal(1); + expect(post.user.ext.eids[6].source).to.equal('criteo.com'); + expect(post.user.ext.eids[6].uids[0].id).to.equal('1111'); + expect(post.user.ext.eids[6].uids[0].atype).to.equal(1); expect(post.regs.ext.gdpr).to.equal(1); expect(post.regs.ext.us_privacy).to.equal('1NYN'); diff --git a/test/spec/modules/saambaaBidAdapter_spec.js b/test/spec/modules/saambaaBidAdapter_spec.js deleted file mode 100755 index 80a85ae895d..00000000000 --- a/test/spec/modules/saambaaBidAdapter_spec.js +++ /dev/null @@ -1,139 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/saambaaBidAdapter.js'; -import { BANNER, VIDEO } from 'src/mediaTypes.js'; - -describe('saambaaBidAdapter', function () { - let bidRequests; - let bidRequestsVid; - - beforeEach(function () { - bidRequests = [{'bidder': 'saambaa', 'params': {'pubid': '121ab139faf7ac67428a23f1d0a9a71b', 'floor': 0.5, 'placement': 1234, size: '320x250'}, 'crumbs': {'pubcid': '979fde13-c71e-4ac2-98b7-28c90f99b449'}, 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': 'f72931e6-2b0e-4e37-a2bc-1ea912141f81', 'sizes': [[300, 250]], 'bidId': '2aa73f571eaf29', 'bidderRequestId': '1bac84515a7af3', 'auctionId': '5dbc60fa-1aa1-41ce-9092-e6bbd4d478f7', 'src': 'client', 'bidRequestsCount': 1, 'pageurl': 'http://google.com'}]; - - bidRequestsVid = [{'bidder': 'saambaa', 'params': {'pubid': '121ab139faf7ac67428a23f1d0a9a71b', 'floor': 1.0, 'placement': 1234, size: '320x480', 'video': {'id': 123, 'skip': 1, 'mimes': ['video/mp4', 'application/javascript'], 'playbackmethod': [2, 6], 'maxduration': 30}}, 'crumbs': {'pubcid': '979fde13-c71e-4ac2-98b7-28c90f99b449'}, 'mediaTypes': {'video': {'playerSize': [[320, 480]], 'context': 'instream'}}, 'adUnitCode': 'video1', 'transactionId': '8b060952-93f7-4863-af44-bb8796b97c42', 'sizes': [], 'bidId': '25c6ab92aa0e81', 'bidderRequestId': '1d420b73a013fc', 'auctionId': '9a69741c-34fb-474c-83e1-cfa003aaee17', 'src': 'client', 'bidRequestsCount': 1, 'pageurl': 'http://google.com'}]; - }); - - describe('spec.isBidRequestValid', function () { - it('should return true when the required params are passed for banner', function () { - const bidRequest = bidRequests[0]; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true when the required params are passed for video', function () { - const bidRequests = bidRequestsVid[0]; - expect(spec.isBidRequestValid(bidRequests)).to.equal(true); - }); - - it('should return false when no pub id params are passed', function () { - const bidRequest = bidRequests[0]; - bidRequest.params.pubid = ''; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when no placement params are passed', function () { - const bidRequest = bidRequests[0]; - bidRequest.params.placement = ''; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when a bid request is not passed', function () { - expect(spec.isBidRequestValid()).to.equal(false); - expect(spec.isBidRequestValid({})).to.equal(false); - }); - }); - - describe('spec.buildRequests', function () { - it('should create a POST request for each bid', function () { - const bidRequest = bidRequests[0]; - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].method).to.equal('POST'); - }); - - it('should create a POST request for each bid in video request', function () { - const bidRequest = bidRequestsVid[0]; - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].method).to.equal('POST'); - }); - - it('should have domain in request', function () { - const bidRequest = bidRequests[0]; - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].data.site.domain).length !== 0; - }); - }); - - describe('spec.interpretResponse', function () { - describe('for banner bids', function () { - it('should return no bids if the response is not valid', function () { - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {} }; - const bidResponse = spec.interpretResponse({ body: null }, { bidRequest }); - - if (typeof bidResponse !== 'undefined') { - expect(bidResponse.length).to.equal(0); - } else { - expect(true).to.equal(true); - } - }); - - it('should return no bids if the response is empty', function () { - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {} }; - const bidResponse = spec.interpretResponse({ body: [] }, { bidRequest }); - if (typeof bidResponse !== 'undefined') { - expect(bidResponse.length).to.equal(0); - } else { expect(true).to.equal(true); } - }); - - it('should return valid video bid responses', function () { - let _mediaTypes = VIDEO; - const saambaabidreqVid = {'bidRequest': {'mediaTypes': {'video': {'w': 320, 'h': 480}}}}; - const serverResponseVid = {'cur': 'USD', 'id': '25c6ab92aa0e81', 'seatbid': [{'seat': '3', 'bid': [{'crid': '1855', 'h': 480, 'protocol': 2, 'nurl': 'http://nep.advangelists.com/xp/evt?pp=1MO1wiaMhhq7wLRzZZwwwPkJxxKpYEnM5k5MH4qSGm1HR8rp3Nl7vDocvzZzSAvE4pnREL9mQ1kf5PDjk6E8em6DOk7vVrYUH1TYQyqCucd58PFpJNN7h30RXKHHFg3XaLuQ3PKfMuI1qZATBJ6WHcu875y0hqRdiewn0J4JsCYF53M27uwmcV0HnQxARQZZ72mPqrW95U6wgkZljziwKrICM3aBV07TU6YK5R5AyzJRuD6mtrQ2xtHlQ3jXVYKE5bvWFiUQd90t0jOGhPtYBNoOfP7uQ4ZZj4pyucxbr96orHe9PSOn9UpCSWArdx7s8lOfDpwOvbMuyGxynbStDWm38sDgd4bMHnIt762m5VMDNJfiUyX0vWzp05OsufJDVEaWhAM62i40lQZo7mWP4ipoOWLkmlaAzFIMsTcNaHAHiKKqGEOZLkCEhFNM0SLcvgN2HFRULOOIZvusq7TydOKxuXgCS91dLUDxDDDFUK83BFKlMkTxnCzkLbIR1bd9GKcr1TRryOrulyvRWAKAIhEsUzsc5QWFUhmI2dZ1eqnBQJ0c89TaPcnoaP2WipF68UgyiOstf2CBy0M34858tC5PmuQwQYwXscg6zyqDwR0i9MzGH4FkTyU5yeOlPcsA0ht6UcoCdFpHpumDrLUwAaxwGk1Nj8S6YlYYT5wNuTifDGbg22QKXzZBkUARiyVvgPn9nRtXnrd7WmiMYq596rya9RQj7LC0auQW8bHVQLEe49shsZDnAwZTWr4QuYKqgRGZcXteG7RVJe0ryBZezOq11ha9C0Lv0siNVBahOXE35Wzoq4c4BDaGpqvhaKN7pjeWLGlQR04ufWekwxiMWAvjmfgAfexBJ7HfbYNZpq__', 'adid': '61_1855', 'adomain': ['chevrolet.com'], 'price': 2, 'w': 320, 'iurl': 'https://daf37cpxaja7f.cloudfront.net/c61/creative_url_14922301369663_1.png', 'cat': ['IAB2'], 'id': '7f570b40-aca1-4806-8ea8-818ea679c82b_0', 'attr': [], 'impid': '0', 'cid': '61'}]}], 'bidid': '7f570b40-aca1-4806-8ea8-818ea679c82b'} - const bidResponseVid = spec.interpretResponse({ body: serverResponseVid }, saambaabidreqVid); - delete bidResponseVid['vastUrl']; - delete bidResponseVid['ad']; - expect(bidResponseVid).to.deep.equal({ - requestId: bidRequestsVid[0].bidId, - bidderCode: 'saambaa', - creativeId: serverResponseVid.seatbid[0].bid[0].crid, - cpm: serverResponseVid.seatbid[0].bid[0].price, - width: serverResponseVid.seatbid[0].bid[0].w, - height: serverResponseVid.seatbid[0].bid[0].h, - mediaType: 'video', - meta: { advertiserDomains: serverResponseVid.seatbid[0].bid[0].adomain }, - currency: 'USD', - netRevenue: true, - ttl: 60 - }); - }); - - it('should return valid banner bid responses', function () { - const saambaabidreq = {bids: {}}; - bidRequests.forEach(bid => { - let _mediaTypes = (bid.mediaTypes && bid.mediaTypes.video ? VIDEO : BANNER); - saambaabidreq.bids[bid.bidId] = {mediaTypes: _mediaTypes, - w: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][0] : bid.mediaTypes[_mediaTypes].playerSize[0], - h: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1] - - }; - }); - const serverResponse = {'id': '2aa73f571eaf29', 'seatbid': [{'bid': [{'id': '2c5e8a1a84522d', 'impid': '2c5e8a1a84522d', 'price': 0.81, 'adid': 'abcde-12345', 'nurl': '', 'adm': '
', 'adomain': ['advertiserdomain.com'], 'iurl': '', 'cid': 'campaign1', 'crid': 'abcde-12345', 'w': 300, 'h': 250}], 'seat': '19513bcfca8006'}], 'bidid': '19513bcfca8006', 'cur': 'USD', 'w': 300, 'h': 250}; - - const bidResponse = spec.interpretResponse({ body: serverResponse }, saambaabidreq); - expect(bidResponse).to.deep.equal({ - requestId: bidRequests[0].bidId, - ad: serverResponse.seatbid[0].bid[0].adm, - bidderCode: 'saambaa', - creativeId: serverResponse.seatbid[0].bid[0].crid, - cpm: serverResponse.seatbid[0].bid[0].price, - width: serverResponse.seatbid[0].bid[0].w, - height: serverResponse.seatbid[0].bid[0].h, - mediaType: 'banner', - meta: { advertiserDomains: serverResponse.seatbid[0].bid[0].adomain }, - currency: 'USD', - netRevenue: true, - ttl: 60 - }); - }); - }); - }); -}); 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/sekindoUMBidAdapter_spec.js b/test/spec/modules/sekindoUMBidAdapter_spec.js deleted file mode 100644 index 2c361c21303..00000000000 --- a/test/spec/modules/sekindoUMBidAdapter_spec.js +++ /dev/null @@ -1,168 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/sekindoUMBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('sekindoUMAdapter', function () { - const adapter = newBidder(spec); - - const bannerParams = { - 'spaceId': '14071' - }; - - const videoParams = { - 'spaceId': '14071', - 'video': { - playerWidth: 300, - playerHeight: 250, - vid_vastType: 2 // optional - } - }; - - var bidRequests = { - 'bidder': 'sekindoUM', - 'params': bannerParams, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'mediaType': 'banner' - }; - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - bidRequests.mediaType = 'banner'; - bidRequests.params = bannerParams; - expect(spec.isBidRequestValid(bidRequests)).to.equal(true); - }); - - it('should return false when required video params are missing', function () { - bidRequests.mediaType = 'video'; - bidRequests.params = bannerParams; - expect(spec.isBidRequestValid(bidRequests)).to.equal(false); - }); - - it('should return true when required Video params found', function () { - bidRequests.mediaType = 'video'; - bidRequests.params = videoParams; - expect(spec.isBidRequestValid(bidRequests)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - it('banner data should be a query string and method = GET', function () { - bidRequests.mediaType = 'banner'; - bidRequests.params = bannerParams; - const request = spec.buildRequests([bidRequests]); - expect(request[0].data).to.be.a('string'); - expect(request[0].method).to.equal('GET'); - }); - - it('with gdprConsent, banner data should be a query string and method = GET', function () { - bidRequests.mediaType = 'banner'; - bidRequests.params = bannerParams; - const request = spec.buildRequests([bidRequests], {'gdprConsent': {'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', 'vendorData': {}, 'gdprApplies': true}}); - expect(request[0].data).to.be.a('string'); - expect(request[0].method).to.equal('GET'); - }); - - it('video data should be a query string and method = GET', function () { - bidRequests.mediaType = 'video'; - bidRequests.params = videoParams; - const request = spec.buildRequests([bidRequests]); - expect(request[0].data).to.be.a('string'); - expect(request[0].method).to.equal('GET'); - }); - }); - - describe('interpretResponse', function () { - it('banner should get correct bid response', function () { - let response = { - 'headers': function(header) { - return 'dummy header'; - }, - 'body': {'id': '30b31c1838de1e', 'bidderCode': 'sekindoUM', 'cpm': 2.1951, 'width': 300, 'height': 250, 'ad': '

sekindo creative<\/h1>', 'ttl': 36000, 'creativeId': '323774', 'netRevenue': true, 'currency': 'USD'} - }; - - bidRequests.mediaType = 'banner'; - bidRequests.params = bannerParams; - let expectedResponse = [ - { - 'requestId': '30b31c1838de1e', - 'bidderCode': 'sekindoUM', - 'cpm': 2.1951, - 'width': 300, - 'height': 250, - 'creativeId': '323774', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 36000, - 'ad': '

sekindo creative

' - } - ]; - let result = spec.interpretResponse(response, bidRequests); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('vastXml video should get correct bid response', function () { - let response = { - 'headers': function(header) { - return 'dummy header'; - }, - 'body': {'id': '30b31c1838de1e', 'bidderCode': 'sekindoUM', 'cpm': 2.1951, 'width': 300, 'height': 250, 'vastXml': '', 'ttl': 36000, 'creativeId': '323774', 'netRevenue': true, 'currency': 'USD'} - }; - - bidRequests.mediaType = 'video'; - bidRequests.params = videoParams; - let expectedResponse = [ - { - 'requestId': '30b31c1838de1e', - 'bidderCode': 'sekindoUM', - 'cpm': 2.1951, - 'width': 300, - 'height': 250, - 'creativeId': '323774', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 36000, - 'vastXml': '' - } - ]; - let result = spec.interpretResponse(response, bidRequests); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('vastUrl video should get correct bid response', function () { - let response = { - 'headers': function(header) { - return 'dummy header'; - }, - 'body': {'id': '30b31c1838de1e', 'bidderCode': 'sekindoUM', 'cpm': 2.1951, 'width': 300, 'height': 250, 'vastUrl': 'https://vastUrl', 'ttl': 36000, 'creativeId': '323774', 'netRevenue': true, 'currency': 'USD'} - }; - bidRequests.mediaType = 'video'; - bidRequests.params = videoParams; - let expectedResponse = [ - { - 'requestId': '30b31c1838de1e', - 'bidderCode': 'sekindoUM', - 'cpm': 2.1951, - 'width': 300, - 'height': 250, - 'creativeId': '323774', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 36000, - 'vastUrl': 'https://vastUrl' - } - ]; - let result = spec.interpretResponse(response, bidRequests); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - }); -}); diff --git a/test/spec/modules/sharedIdSystem_spec.js b/test/spec/modules/sharedIdSystem_spec.js index ad51fe81cde..d8056fcc616 100644 --- a/test/spec/modules/sharedIdSystem_spec.js +++ b/test/spec/modules/sharedIdSystem_spec.js @@ -1,8 +1,9 @@ import { - sharedIdSubmodule, + sharedIdSystemSubmodule, } from 'modules/sharedIdSystem.js'; import { server } from 'test/mocks/xhr.js'; import {uspDataHandler} from 'src/adapterManager'; +import sinon from 'sinon'; let expect = require('chai').expect; @@ -22,7 +23,7 @@ describe('SharedId System', function() { }); it('should call shared id endpoint without consent data and handle a valid response', function () { - let submoduleCallback = sharedIdSubmodule.getId(undefined, undefined).callback; + let submoduleCallback = sharedIdSystemSubmodule.getId(undefined, undefined).callback; submoduleCallback(callbackSpy); let request = server.requests[0]; @@ -32,7 +33,7 @@ describe('SharedId System', function() { request.respond(200, {}, JSON.stringify(SHAREDID_RESPONSE)); expect(callbackSpy.calledOnce).to.be.true; - expect(callbackSpy.lastCall.lastArg.id).to.equal(SHAREDID_RESPONSE.sharedId); + expect(callbackSpy.lastCall.lastArg).to.equal(SHAREDID_RESPONSE.sharedId); }); it('should call shared id endpoint with consent data and handle a valid response', function () { @@ -41,7 +42,7 @@ describe('SharedId System', function() { consentString: 'abc12345234', }; - let submoduleCallback = sharedIdSubmodule.getId(undefined, consentData).callback; + let submoduleCallback = sharedIdSystemSubmodule.getId(undefined, consentData).callback; submoduleCallback(callbackSpy); let request = server.requests[0]; @@ -51,7 +52,7 @@ describe('SharedId System', function() { request.respond(200, {}, JSON.stringify(SHAREDID_RESPONSE)); expect(callbackSpy.calledOnce).to.be.true; - expect(callbackSpy.lastCall.lastArg.id).to.equal(SHAREDID_RESPONSE.sharedId); + expect(callbackSpy.lastCall.lastArg).to.equal(SHAREDID_RESPONSE.sharedId); }); it('should call shared id endpoint with usp consent data and handle a valid response', function () { @@ -61,7 +62,7 @@ describe('SharedId System', function() { consentString: 'abc12345234', }; - let submoduleCallback = sharedIdSubmodule.getId(undefined, consentData).callback; + let submoduleCallback = sharedIdSystemSubmodule.getId(undefined, consentData).callback; submoduleCallback(callbackSpy); let request = server.requests[0]; @@ -71,7 +72,7 @@ describe('SharedId System', function() { request.respond(200, {}, JSON.stringify(SHAREDID_RESPONSE)); expect(callbackSpy.calledOnce).to.be.true; - expect(callbackSpy.lastCall.lastArg.id).to.equal(SHAREDID_RESPONSE.sharedId); + expect(callbackSpy.lastCall.lastArg).to.equal(SHAREDID_RESPONSE.sharedId); }); }); }); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index b8d91249ec3..68d7b6210df 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -24,10 +24,6 @@ const bidRequests = [ linkType: 2 } }, - sharedid: { - id: 'fake-sharedid', - third: 'fake-sharedthird' - }, lipb: { lipbid: 'fake-lipbid' } @@ -375,12 +371,6 @@ describe('sharethrough adapter spec', function() { expect(bidRequest.data.id5uid.linkType).to.eq(2); }); - it('should add the shduid parameter if a bid request contains a value for Shared ID', function() { - const bidRequest = spec.buildRequests(bidRequests)[0]; - expect(bidRequest.data.shduid.id).to.eq('fake-sharedid'); - expect(bidRequest.data.shduid.third).to.eq('fake-sharedthird'); - }); - it('should add the liuid parameter if a bid request contains a value for LiveIntent ID', function() { const bidRequest = spec.buildRequests(bidRequests)[0]; expect(bidRequest.data.liuid).to.eq('fake-lipbid'); 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: '', - 'adomain': [''], - 'cid': '1', - 'crid': '700', - 'w': 300, - 'h': 250 - }]}], - 'bidid': 'bidid', - 'cur': 'USD' - }, - 'headers': {} - }; - it('required keys', function () { - const result = spec.interpretResponse(validServerResponse, validBidRequest); - - let requiredKeys = [ - 'requestId', - 'creativeId', - 'adId', - 'cpm', - 'width', - 'height', - 'currency', - 'netRevenue', - 'ttl', - 'ad' - ]; - - let resultKeys = Object.keys(result[0]); - requiredKeys.forEach(function(key) { - expect(resultKeys.indexOf(key) !== -1).to.equal(true); - }); - }) - }); - - describe('getUserSyncs', function () { - it('check empty response getUserSyncs', function () { - const result = spec.getUserSyncs('', ''); - expect(result).to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/topRTBBidAdapter_spec.js b/test/spec/modules/topRTBBidAdapter_spec.js deleted file mode 100644 index 9b97917a0b6..00000000000 --- a/test/spec/modules/topRTBBidAdapter_spec.js +++ /dev/null @@ -1,67 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/topRTBBidAdapter.js'; - -describe('topRTBBidAdapterTests', function () { - it('validate_pub_params', function () { - expect(spec.isBidRequestValid({ - bidder: 'topRTB', - params: { - adUnitId: 'c5c06f77430c4c33814a0577cb4cc978' - }, - adName: 'banner' - })); - }); - - it('validate_generated_params', function () { - let bidRequestData = [{ - bidId: 'bid12345', - bidder: 'topRTB', - adName: 'banner', - adType: '{"banner":{"sizes":[[]]}}', - params: { - adUnitId: 'c5c06f77430c4c33814a0577cb4cc978' - }, - sizes: [[728, 90]] - }]; - - let request = spec.buildRequests(bidRequestData); - const current_url = request.url; - const search_params = current_url.searchParams; - }); - - it('validate_response_params', function () { - let bidRequestData = { - data: { - bidId: 'bid12345' - } - }; - - let serverResponse = { - body: [{ - 'cpm': 1, - 'mediadata': "Banner 728x90", - 'width': 728, - 'currency': 'USD', - 'id': 'cd95dffec6b645afbc4e5aa9f68f2ff3', - 'type': 'RICHMEDIA', - 'ttl': 4000, - 'bidId': 'bid12345', - 'status': 'success', - 'height': 90}], - 'adName': 'banner', - 'vastXml': '', - 'mediaType': 'banner', - 'tracking': 'https://ssp.toprtb.com/ssp/tracking?F0cloTiKIw%2BjZ2UNDvlKGn5%2FWoAO9cnlAUDm6gFBM8bImY2fKo%2BMTvI0XvXzFTZSb5v8o4EUbPId9hckptTqA4QPaWvpVYCRKRZceXNa4kjtvfm4j2e%2FcRKgkns2goHXi7IZC0sBIbE77WWg%2BPBYv%2BCu84H%2FSH69mi%2FDaWcQlfaEOdkaJdstJEkaZtkgWnFnS7aagte%2BfdEbOqcTxq5hzj%2BZ4NZbwgReuWTQZbfrMWjkXFbn%2B35vZuI319o6XH9n9fKLS4xp8zstXfQT2oSgjw1NmrwqRKf1efB1UaWlS1TbkSqxZ7Kcy7nJvAZrDk0tzcSeIxe4VfHpwgPPs%2BueUeGwz3o7OCh7H1sCmogSrmJFB9JTeXudFjC13iANAtu4SvG9bGIbiJxS%2BNfkjy2mLFm8kSIcIobjNkMEcUAwmoqJNRndwb66a3Iovk2NTo0Ly%2FV7Y5ECPcS5%2FPBrIEOuQXS5SNUPRWKoklX5nexHtOc%3D', - 'impression': 'https://ssp.toprtb.com/ssp/impression?id=64f29f7b226249f19925a680a506b32d' - }; - - let bids = spec.interpretResponse(serverResponse, bidRequestData); - 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(728); - expect(bid.height).to.equal(90); - expect(bid.requestId).to.equal('bid12345'); - }); -}); diff --git a/test/spec/modules/trendqubeBidAdapter_spec.js b/test/spec/modules/trendqubeBidAdapter_spec.js deleted file mode 100644 index f2ce95832ff..00000000000 --- a/test/spec/modules/trendqubeBidAdapter_spec.js +++ /dev/null @@ -1,270 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/trendqubeBidAdapter.js'; -import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; - -describe('TrendqubebBidAdapter', function () { - const bid = { - bidId: '23fhj33i987f', - bidder: 'trendqube', - 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://ads.trendqube.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; - }); - }); -}); diff --git a/test/spec/modules/tribeosBidAdapter_spec.js b/test/spec/modules/tribeosBidAdapter_spec.js deleted file mode 100644 index fd7f7087eb7..00000000000 --- a/test/spec/modules/tribeosBidAdapter_spec.js +++ /dev/null @@ -1,86 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/tribeosBidAdapter.js'; - -describe('tribeosBidAdapter', function() { - describe('isBidRequestValid', function() { - it('should return true if all parameters are passed', function() { - expect(spec.isBidRequestValid({ - bidder: 'tribeos', - params: { - placementId: '12345' - } - })).to.equal(true); - }); - - it('should return false is placementId is missing', function() { - expect(spec.isBidRequestValid({ - bidder: 'tribeos', - params: {} - })).to.equal(false); - }); - }); - - it('validate bid request data from backend', function() { - let bidRequestData = [{ - bidId: 'bid12', - bidder: 'tribeos', - mediaTypes: { - banner: { - sizes: [ - [300, 250] - ], - } - }, - params: { - placementId: 'test-bid' - } - }]; - - let request = spec.buildRequests(bidRequestData); - let payload = JSON.parse(request[0].data); - - expect(payload.bidId).to.equal('bid12'); - }); - - it('validate response parameters', function() { - let bidRequestData = { - data: { - bidId: '21f3e9c3ce92f2' - } - }; - - let serverResponse = { - body: { - 'id': '5e23a6c74314aa782328376f5954', - 'bidid': '5e23a6c74314aa782328376f5954', - 'seatbid': [{ - 'bid': [{ - 'id': '5e23a6c74314aa782328376f5954', - 'impid': '21f3e9c3ce92f2', - 'price': 1.1, - 'adid': '5e23a6c74314aa782328376f5954', - 'adm': '', - 'cid': '5e1eea895d37673aef2134825195rnd2', - 'crid': '5e0b71e6823bb66fcb6c9858', - 'h': 250, - 'w': 300 - }], - 'seats': '1' - }], - 'cur': 'USD' - } - }; - - let bids = spec.interpretResponse(serverResponse, bidRequestData); - expect(bids).to.have.lengthOf(1); - let bid = bids[0]; - - expect(bid.cpm).to.equal(1.1); - expect(bid.currency).to.equal('USD'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.netRevenue).to.equal(true); - expect(bid.requestId).to.equal('21f3e9c3ce92f2'); - expect(bid.ad).to.equal(''); - }); -}); diff --git a/test/spec/modules/truereachBidAdapter_spec.js b/test/spec/modules/truereachBidAdapter_spec.js index 36441722648..3c78c4b848d 100644 --- a/test/spec/modules/truereachBidAdapter_spec.js +++ b/test/spec/modules/truereachBidAdapter_spec.js @@ -40,7 +40,7 @@ describe('truereachBidAdapterTests', function () { expect(req_data.imp[0].id).to.equal('34ce3f3b15190a'); expect(req_data.imp[0].banner.w).to.equal(300); expect(req_data.imp[0].banner.h).to.equal(250); - expect(req_data.imp[0].bidfloor).to.equal(0.1); + expect(req_data.imp[0].bidfloor).to.equal(0); }); it('validate_response_params', function () { diff --git a/test/spec/modules/turktelekomBidAdapter_spec.js b/test/spec/modules/turktelekomBidAdapter_spec.js deleted file mode 100644 index c4e55178638..00000000000 --- a/test/spec/modules/turktelekomBidAdapter_spec.js +++ /dev/null @@ -1,749 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/turktelekomBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('TurkTelekomAdapter', 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': 'turktelekom', - 'params': { - 'uid': '17' - }, - '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': 'turktelekom', - 'params': { - 'uid': '18' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '18' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90], [300, 250]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '20' - }, - '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', '18'); - 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', '18,18,20'); - 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', '18,18,20'); - 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', '18,18,20'); - 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'); - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 17, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 18, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 17, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 19, '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': 'turktelekom', - 'params': { - 'uid': '17' - }, - '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': 17, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - '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': 'turktelekom', - 'params': { - 'uid': '17' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '18' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '17' - }, - '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': 17, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 18, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 2
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 0.15, - 'creativeId': 17, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 3
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - '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': 'turktelekom', - 'params': { - 'uid': '19' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '20' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '25' - }, - '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': 17, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 18, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 17, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0.15, 'adm': '
test content 4
', 'auid': 17, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 5
', 'auid': 18, 'h': 600, 'w': 350}], 'seat': '1'}, - ]; - const bidRequests = [ - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '17' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '2164be6358b9', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '17' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '326bde7fbf69', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '18' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4e111f1b66e4', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '17' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '26d6f897b516', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '44' - }, - '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': 17, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4e111f1b66e4', - 'cpm': 0.5, - 'creativeId': 18, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 2
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '26d6f897b516', - 'cpm': 0.15, - 'creativeId': 17, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 3
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '326bde7fbf69', - 'cpm': 0.15, - 'creativeId': 17, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 4
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - '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': 17, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 17, 'h': 250, 'w': 300}], 'seat': '1'}, - ]; - const bidRequests = [ - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '17' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '5126e301f4be', - 'bidderRequestId': '171c5405a390', - 'auctionId': '35bcbc0f7e79c', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '17' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '57b2ebe70e16', - 'bidderRequestId': '171c5405a390', - 'auctionId': '35bcbc0f7e79c', - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '17' - }, - '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': 17, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - 'mediaType': 'banner', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '57b2ebe70e16', - 'cpm': 0.5, - 'creativeId': 17, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 2
', - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - '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': 'turktelekom', - 'params': { - 'uid': '25' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '57dfefb80eca', - 'bidderRequestId': '20394420a762a2', - 'auctionId': '140132d07b031', - 'mediaTypes': { - 'video': { - 'context': 'instream' - } - } - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '26' - }, - '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': 25, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, - {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 26, content_type: 'video'}], 'seat': '2'} - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '57dfefb80eca', - 'cpm': 1.15, - 'creativeId': 25, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - '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': 'turktelekom', - 'params': { - 'uid': '25' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': 'e6e65553fc8', - 'bidderRequestId': '1380f393215dc7', - 'auctionId': '10b8d2f3c697e3', - 'mediaTypes': { - 'video': { - 'context': 'outstream' - } - } - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '26' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': 'c8fdcb3f269f', - 'bidderRequestId': '1380f393215dc7', - 'auctionId': '10b8d2f3c697e3' - }, - { - 'bidder': 'turktelekom', - 'params': { - 'uid': '27' - }, - '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': 25, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, - {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 26, content_type: 'video', w: 300, h: 250}], 'seat': '2'}, - {'bid': [{'price': 1.20, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 27, content_type: 'video', w: 300, h: 250}], 'seat': '2'} - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': 'e6e65553fc8', - 'cpm': 1.15, - 'creativeId': 25, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - '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': 26, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - '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': 27, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'bidderCode': 'turktelekom', - 'currency': 'TRY', - '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); - }); -}); diff --git a/test/spec/modules/ucfunnelBidAdapter_spec.js b/test/spec/modules/ucfunnelBidAdapter_spec.js index 5899554244b..ac788e537e2 100644 --- a/test/spec/modules/ucfunnelBidAdapter_spec.js +++ b/test/spec/modules/ucfunnelBidAdapter_spec.js @@ -14,7 +14,6 @@ const userId = { 'netId': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', 'parrableId': {'eid': '01.1608624401.fe44bca9b96873084a0d4e9d0ac5729f13790ba8f8e58fa4707b6b3c096df91c6b5f254992bdad4ab1dd4a89919081e9b877d7a039ac3183709277665bac124f28e277d109f0ff965058'}, 'pubcid': 'd8aa10fa-d86c-451d-aad8-5f16162a9e64', - 'sharedid': {'id': '01ESHXW4HD29KMF387T63JQ9H5', 'third': '01ESHXW4HD29KMF387T63JQ9H5'}, 'tdid': 'D6885E90-2A7A-4E0F-87CB-7734ED1B99A3', 'haloId': {}, 'uid2': {'id': 'eb33b0cb-8d35-4722-b9c0-1a31d4064888'}, diff --git a/test/spec/modules/unicornBidAdapter_spec.js b/test/spec/modules/unicornBidAdapter_spec.js deleted file mode 100644 index dcd446b2bb0..00000000000 --- a/test/spec/modules/unicornBidAdapter_spec.js +++ /dev/null @@ -1,490 +0,0 @@ -import { assert, expect } from 'chai'; -import { spec } from 'modules/unicornBidAdapter.js'; -import * as _ from 'lodash'; - -const bidRequests = [ - { - bidder: 'unicorn', - params: { - bidfloorCpm: 0, - accountId: 12345 - }, - mediaTypes: { - banner: { - sizes: [[300, 250], [336, 280]] - } - }, - adUnitCode: '/19968336/header-bid-tag-0', - transactionId: 'ea0aa332-a6e1-4474-8180-83720e6b87bc', - sizes: [[300, 250], [336, 280]], - bidId: '226416e6e6bf41', - bidderRequestId: '1f41cbdcbe58d5', - auctionId: '77987c3a-9be9-4e43-985a-26fc91d84724', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - }, - { - bidder: 'unicorn', - params: { - bidfloorCpm: 0, - accountId: 12345 - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - transactionId: 'cf801303-cf98-4b4a-9e0a-c27b93bce6d8', - sizes: [[300, 250]], - bidId: '37cdc0b5d0363b', - bidderRequestId: '1f41cbdcbe58d5', - auctionId: '77987c3a-9be9-4e43-985a-26fc91d84724', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - }, - { - bidder: 'unicorn', - params: { - bidfloorCpm: 0 - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - adUnitCode: '/19968336/header-bid-tag-2', - transactionId: 'ba7f114c-3676-4a08-a26d-1ee293d521ed', - sizes: [[300, 250]], - bidId: '468569a6597a4', - bidderRequestId: '1f41cbdcbe58d5', - auctionId: '77987c3a-9be9-4e43-985a-26fc91d84724', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - } -]; - -const validBidRequests = [ - { - bidder: 'unicorn', - params: { - placementId: 'rectangle-ad-1', - bidfloorCpm: 0, - accountId: 12345, - publisherId: 99999, - mediaId: 'example' - }, - mediaTypes: { - banner: { - sizes: [[300, 250], [336, 280]] - } - }, - adUnitCode: '/19968336/header-bid-tag-0', - transactionId: 'fbf94ccf-f377-4201-a662-32c2feb8ab6d', - sizes: [[300, 250], [336, 280]], - bidId: '2fb90842443e24', - bidderRequestId: '123ae4cc3eeb7e', - auctionId: 'c594a888-6744-46c6-8b0e-d188e40e83ef', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - }, - { - bidder: 'unicorn', - params: { - bidfloorCpm: 0, - accountId: 12345 - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - adUnitCode: '/19968336/header-bid-tag-1', - transactionId: '2d65e313-f8a6-4888-b9ab-50fb3ca744ea', - sizes: [[300, 250]], - bidId: '352f86f158d97a', - bidderRequestId: '123ae4cc3eeb7e', - auctionId: 'c594a888-6744-46c6-8b0e-d188e40e83ef', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - }, - { - bidder: 'unicorn', - params: { - placementId: 'rectangle-ad-2', - bidfloorCpm: 0, - accountId: 12345 - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - adUnitCode: '/19968336/header-bid-tag-2', - transactionId: '82f445a8-44bc-40bc-9913-739b40375566', - sizes: [[300, 250]], - bidId: '4cde82cc90126b', - bidderRequestId: '123ae4cc3eeb7e', - auctionId: 'c594a888-6744-46c6-8b0e-d188e40e83ef', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - } -]; - -const bidderRequest = { - bidderCode: 'unicorn', - auctionId: 'c594a888-6744-46c6-8b0e-d188e40e83ef', - bidderRequestId: '123ae4cc3eeb7e', - bids: [ - { - bidder: 'unicorn', - params: { - placementId: 'rectangle-ad-1', - bidfloorCpm: 0, - accountId: 12345 - }, - mediaTypes: { - banner: { - sizes: [[300, 250], [336, 280]] - } - }, - adUnitCode: '/19968336/header-bid-tag-0', - transactionId: 'fbf94ccf-f377-4201-a662-32c2feb8ab6d', - sizes: [[300, 250], [336, 280]], - bidId: '2fb90842443e24', - bidderRequestId: '123ae4cc3eeb7e', - auctionId: 'c594a888-6744-46c6-8b0e-d188e40e83ef', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - }, - { - bidder: 'unicorn', - params: { - bidfloorCpm: 0, - accountId: 12345 - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - adUnitCode: '/19968336/header-bid-tag-1', - transactionId: '2d65e313-f8a6-4888-b9ab-50fb3ca744ea', - sizes: [[300, 250]], - bidId: '352f86f158d97a', - bidderRequestId: '123ae4cc3eeb7e', - auctionId: 'c594a888-6744-46c6-8b0e-d188e40e83ef', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - }, - { - bidder: 'unicorn', - params: { - placementId: 'rectangle-ad-2', - bidfloorCpm: 0, - accountId: 12345 - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - adUnitCode: '/19968336/header-bid-tag-2', - transactionId: '82f445a8-44bc-40bc-9913-739b40375566', - sizes: [[300, 250]], - bidId: '4cde82cc90126b', - bidderRequestId: '123ae4cc3eeb7e', - auctionId: 'c594a888-6744-46c6-8b0e-d188e40e83ef', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 - } - ], - auctionStart: 1581064124172, - timeout: 1000, - refererInfo: { - referer: 'https://uni-corn.net/', - reachedTop: true, - numIframes: 0, - stack: ['https://uni-corn.net/'] - }, - start: 1581064124177 -}; - -const openRTBRequest = { - id: '5ebea288-f13a-4754-be6d-4ade66c68877', - at: 1, - imp: [ - { - id: '216255f234b602', - banner: { - w: 300, - h: 250, - format: [ - { - w: 300, - h: 250 - }, - { - w: 336, - h: 280 - } - ] - }, - secure: 1, - bidfloor: 0, - tagid: 'rectangle-ad-1' - }, - { - id: '31e2b28ced2475', - banner: { - w: 300, - h: 250, - format: [ - { - w: 300, - h: 250 - } - ] - }, - secure: 1, - bidfloor: 0, - tagid: '/19968336/header-bid-tag-1' - }, - { - id: '40a333e047a9bd', - banner: { - w: 300, - h: 250, - format: [ - { - w: 300, - h: 250 - } - ] - }, - secure: 1, - bidfloor: 0, - tagid: 'rectangle-ad-2' - } - ], - cur: 'JPY', - ext: { - accountId: 12345 - }, - site: { - id: 'example', - publisher: { - id: 99999 - }, - domain: 'uni-corn.net', - page: 'https://uni-corn.net/', - ref: 'https://uni-corn.net/' - }, - device: { - language: 'ja', - ua: - 'Mozilla/5.0 (Linux; Android 8.0.0; ONEPLUS A5000) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36' - }, - user: { - id: '69d9e1c2-801e-4901-a665-fad467550fec' - }, - bcat: [], - source: { - ext: { - stype: 'prebid_uncn', - bidder: 'unicorn', - prebid_version: '1.0' - } - } -}; - -const serverResponse = { - body: { - bidid: '04db8629-179d-4bcd-acce-e54722969006', - cur: 'JPY', - ext: {}, - id: '5ebea288-f13a-4754-be6d-4ade66c68877', - seatbid: [ - { - bid: [ - { - adid: 'uqgbp4y0_OoqM1QOt', - adm: '
test
', - adomain: ['test1.co.jp'], - attr: [], - bundle: 'com.test1.android', - cat: ['IAB9'], - cid: '2196', - crid: 'ABCDE', - ext: { - imptrackers: ['https://uncn.jp/pb/2/view/test1'] - }, - h: 250, - id: '1', - impid: '216255f234b602', - iurl: 'https://assets.ucontent.net/test1.jpg', - price: 1.0017, - w: 300 - }, - { - adid: 'uqgbp4y0_uqjrNT7h_25512', - adm: '
test
', - adomain: ['test1.co.jp'], - attr: ['6'], - bundle: 'com.test1.android', - cat: ['IAB9'], - cid: '2196', - crid: 'abcde', - ext: { - imptrackers: ['https://uncn.jp/pb/2/view/test1'] - }, - h: 250, - id: '2', - impid: '31e2b28ced2475', - iurl: 'https://assets.ucontent.net/test1.jpg', - price: 0.9513, - w: 300 - } - ], - group: 0, - seat: '65' - }, - { - bid: [ - { - adid: 'uoNYC6II_eoySuXNi', - adm: '
test
', - adomain: ['test2.co.jp'], - attr: [], - bundle: 'jp.co.test2', - cat: ['IAB9'], - cid: '7315', - crid: 'XYZXYZ', - ext: { - imptrackers: ['https://uncn.jp/pb/2/view/test2'] - }, - h: 250, - id: '3', - impid: '40a333e047a9bd', - iurl: 'https://assets.ucontent.net/test2.jpg', - price: 0.674, - w: 300 - } - ], - group: 0, - seat: '274' - } - ], - units: 0 - }, - headers: {} -}; - -const request = { - method: 'POST', - url: 'https://ds.uncn.jp/pb/0/bid.json', - data: - '{"id":"5ebea288-f13a-4754-be6d-4ade66c68877","at":1,"imp":[{"id":"216255f234b602","banner":{"w":300,"h":250},"format":[{"w":300,"h":250},{"w":336,"h":280}],"secure":1,"bidfloor":0,"tagid":"/19968336/header-bid-tag-0"},{"id":"31e2b28ced2475","banner":{"w":"300","h":"250"},"format":[{"w":"300","h":"250"}],"secure":1,"bidfloor":0"tagid":"/19968336/header-bid-tag-1"},{"id":"40a333e047a9bd","banner":{"w":300,"h":250},"format":[{"w":300,"h":250}],"secure":1,"bidfloor":0,"tagid":"/19968336/header-bid-tag-2"}],"cur":"JPY","site":{"id":"uni-corn.net","publisher":{"id":12345},"domain":"uni-corn.net","page":"https://uni-corn.net/","ref":"https://uni-corn.net/"},"device":{"language":"ja","ua":"Mozilla/5.0 (Linux; Android 8.0.0; ONEPLUS A5000) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36"},"user":{"id":"69d9e1c2-801e-4901-a665-fad467550fec"},"bcat":[],"source":{"ext":{"stype":"prebid_uncn","bidder":"unicorn","prebid_version":"1.0"}}}' -}; - -const interpretedBids = [ - { - requestId: '216255f234b602', - cpm: 1.0017, - width: 300, - height: 250, - ad: '
test
', - ttl: 1000, - creativeId: 'ABCDE', - netRevenue: false, - currency: 'JPY' - }, - { - requestId: '31e2b28ced2475', - cpm: 0.9513, - width: 300, - height: 250, - ad: '
test
', - ttl: 1000, - creativeId: 'abcde', - netRevenue: false, - currency: 'JPY' - }, - { - requestId: '40a333e047a9bd', - cpm: 0.674, - width: 300, - height: 250, - ad: '
test
', - ttl: 1000, - creativeId: 'XYZXYZ', - netRevenue: false, - currency: 'JPY' - } -]; - -describe('unicornBidAdapterTest', () => { - describe('isBidRequestValid', () => { - it('isBidRequestValid', () => { - expect(spec.isBidRequestValid(bidRequests[0])).to.equal(true); - expect(spec.isBidRequestValid(bidRequests[1])).to.equal(false); - expect(spec.isBidRequestValid(bidRequests[2])).to.equal(false); - }); - }); - - describe('buildBidRequest', () => { - it('buildBidRequest', () => { - const req = spec.buildRequests(validBidRequests, bidderRequest); - const removeUntestableAttrs = data => { - delete data['device']; - delete data['site']['domain']; - delete data['site']['page']; - delete data['id']; - data['imp'].forEach(imp => { - delete imp['id']; - }) - delete data['user']['id']; - return data; - }; - const uid = JSON.parse(req.data)['user']['id']; - const reqData = removeUntestableAttrs(JSON.parse(req.data)); - const openRTBRequestData = removeUntestableAttrs(openRTBRequest); - assert.deepStrictEqual(reqData, openRTBRequestData); - const req2 = spec.buildRequests(validBidRequests, bidderRequest); - const uid2 = JSON.parse(req2.data)['user']['id']; - assert.deepStrictEqual(uid, uid2); - }); - }); - - describe('interpretResponse', () => { - it('interpretResponse', () => { - const bids = spec.interpretResponse(serverResponse, request); - assert.deepStrictEqual(bids, interpretedBids); - }); - it('interpretResponseEmptyString', () => { - const bids = spec.interpretResponse('', request); - assert.deepStrictEqual(bids, []); - }); - it('interpretResponseEmptyArray', () => { - const bids = spec.interpretResponse([], request); - assert.deepStrictEqual(bids, []); - }); - }); -}); diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 420d2ddce91..9f48127b6f9 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -25,7 +25,6 @@ import { import {server} from 'test/mocks/xhr.js'; import find from 'core-js-pure/features/array/find.js'; import {unifiedIdSubmodule} from 'modules/unifiedIdSystem.js'; -import {pubCommonIdSubmodule} from 'modules/pubCommonIdSystem.js'; import {britepoolIdSubmodule} from 'modules/britepoolIdSystem.js'; import {id5IdSubmodule} from 'modules/id5IdSystem.js'; import {identityLinkSubmodule} from 'modules/identityLinkIdSystem.js'; @@ -36,7 +35,7 @@ import {netIdSubmodule} from 'modules/netIdSystem.js'; import {nextrollIdSubmodule} from 'modules/nextrollIdSystem.js'; import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js'; import {zeotapIdPlusSubmodule} from 'modules/zeotapIdPlusIdSystem.js'; -import {sharedIdSubmodule} from 'modules/sharedIdSystem.js'; +import {sharedIdSystemSubmodule} from 'modules/sharedIdSystem.js'; import {haloIdSubmodule} from 'modules/haloIdSystem.js'; import {pubProvidedIdSubmodule} from 'modules/pubProvidedIdSystem.js'; import {criteoIdSubmodule} from 'modules/criteoIdSystem.js'; @@ -137,7 +136,7 @@ describe('User ID', function () { let pubcid = coreStorage.getCookie('pubcid'); expect(pubcid).to.be.null; // there should be no cookie initially - setSubmoduleRegistry([pubCommonIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); @@ -171,7 +170,7 @@ describe('User ID', function () { let pubcid1; let pubcid2; - setSubmoduleRegistry([pubCommonIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); requestBidsHook((config) => { @@ -191,7 +190,7 @@ describe('User ID', function () { }); }); - setSubmoduleRegistry([pubCommonIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); requestBidsHook((config) => { @@ -218,7 +217,7 @@ describe('User ID', function () { let adUnits = [getAdUnitMock()]; let innerAdUnits; - setSubmoduleRegistry([pubCommonIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid_alt', 'cookie'])); requestBidsHook((config) => { @@ -246,7 +245,7 @@ describe('User ID', function () { let customConfig = getConfigMock(['pubCommonId', 'pubcid_alt', 'cookie']); customConfig = addConfig(customConfig, 'params', {extend: true}); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule]); init(config); config.setConfig(customConfig); requestBidsHook((config) => { @@ -273,7 +272,7 @@ describe('User ID', function () { let customConfig = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); customConfig = addConfig(customConfig, 'params', {create: false}); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule]); init(config); config.setConfig(customConfig); requestBidsHook((config) => { @@ -290,7 +289,7 @@ describe('User ID', function () { }); it('pbjs.getUserIds', function () { - setSubmoduleRegistry([pubCommonIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); config.setConfig({ userSync: { @@ -305,7 +304,7 @@ describe('User ID', function () { }); it('pbjs.getUserIdsAsEids', function () { - setSubmoduleRegistry([pubCommonIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); config.setConfig({ userSync: { @@ -440,14 +439,14 @@ describe('User ID', function () { }); it('fails initialization if opt out cookie exists', function () { - setSubmoduleRegistry([pubCommonIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - opt-out cookie found, exit module'); }); it('initializes if no opt out cookie exists', function () { - setSubmoduleRegistry([pubCommonIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 1 submodules'); @@ -466,7 +465,7 @@ describe('User ID', function () { }); it('handles config with no usersync object', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule]); init(config); config.setConfig({}); // usersync is undefined, and no logInfo message for 'User ID - usersync config updated' @@ -474,14 +473,14 @@ describe('User ID', function () { }); it('handles config with empty usersync object', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule]); init(config); config.setConfig({userSync: {}}); expect(typeof utils.logInfo.args[0]).to.equal('undefined'); }); it('handles config with usersync and userIds that are empty objs', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); init(config); config.setConfig({ userSync: { @@ -492,7 +491,7 @@ describe('User ID', function () { }); it('handles config with usersync and userIds with empty names or that dont match a submodule.name', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); init(config); config.setConfig({ userSync: { @@ -509,7 +508,7 @@ describe('User ID', function () { }); it('config with 1 configurations should create 1 submodules', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule]); init(config); config.setConfig(getConfigMock(['unifiedId', 'unifiedid', 'cookie'])); @@ -531,849 +530,731 @@ describe('User ID', function () { }); it('config with 21 configurations should result in 21 submodules add', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); - init(config); - config.setConfig({ - userSync: { - syncDelay: 0, - userIds: [{ - name: 'pubProvidedId' - }, { - name: 'pubCommonId', value: {'pubcid': '11111'} - }, { - name: 'unifiedId', - storage: {name: 'unifiedid', type: 'cookie'} - }, { - name: 'id5Id', - storage: {name: 'id5id', type: 'cookie'} - }, { - name: 'identityLink', - storage: {name: 'idl_env', type: 'cookie'} - }, { - name: 'liveIntentId', - storage: {name: '_li_pbid', type: 'cookie'} - }, { - name: 'britepoolId', - value: {'primaryBPID': '279c0161-5152-487f-809e-05d7f7e653fd'} - }, { - name: 'netId', - storage: {name: 'netId', type: 'cookie'} - }, { - name: 'nextrollId' - }, { - name: 'sharedId', - storage: {name: 'sharedid', type: 'cookie'} - }, { - name: 'intentIqId', - storage: {name: 'intentIqId', type: 'cookie'} - }, { - name: 'haloId', - storage: {name: 'haloId', type: 'cookie'} - }, { - name: 'zeotapIdPlus' - }, { - name: 'criteo' - }, { - name: 'mwOpenLinkId' - }, { - name: 'tapadId', - storage: {name: 'tapad_id', type: 'cookie'} - }, { - name: 'uid2' - }, { - name: 'admixerId', - storage: {name: 'admixerId', type: 'cookie'} - }, { - name: 'deepintentId', - storage: {name: 'deepintentId', type: 'cookie'} - }, { - name: 'flocId' - }, { - name: 'dmdId', - storage: {name: 'dmdId', type: 'cookie'} - }] - } + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); + it('config with 14 configurations should result in 14 submodules add', function () { + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule]); + init(config); + config.setConfig({ + userSync: { + syncDelay: 0, + userIds: [{ + name: 'pubProvidedId' + }, { + name: 'pubCommonId', value: {'pubcid': '11111'} + }, { + name: 'unifiedId', + storage: {name: 'unifiedid', type: 'cookie'} + }, { + name: 'id5Id', + storage: {name: 'id5id', type: 'cookie'} + }, { + name: 'identityLink', + storage: {name: 'idl_env', type: 'cookie'} + }, { + name: 'liveIntentId', + storage: {name: '_li_pbid', type: 'cookie'} + }, { + name: 'britepoolId', + value: {'primaryBPID': '279c0161-5152-487f-809e-05d7f7e653fd'} + }, { + name: 'netId', + storage: {name: 'netId', type: 'cookie'} + }, { + name: 'nextrollId' + }, { + name: 'intentIqId', + storage: {name: 'intentIqId', type: 'cookie'} + }, { + name: 'haloId', + storage: {name: 'haloId', type: 'cookie'} + }, { + name: 'zeotapIdPlus' + }, { + name: 'criteo' + }, { + name: 'mwOpenLinkId' + }, { + name: 'tapadId', + storage: {name: 'tapad_id', type: 'cookie'} + }, { + name: 'uid2' + }, { + name: 'admixerId', + storage: {name: 'admixerId', type: 'cookie'} + }, { + name: 'deepintentId', + storage: {name: 'deepintentId', type: 'cookie'} + }, { + name: 'flocId' + }, { + name: 'dmdId', + storage: {name: 'dmdId', type: 'cookie'} + }] + } + }); + expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 20 submodules'); }); - expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 21 submodules'); - }); - it('config syncDelay updates module correctly', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); + it('config syncDelay updates module correctly', function () { + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); - init(config); - config.setConfig({ - userSync: { - syncDelay: 99, - userIds: [{ - name: 'unifiedId', - storage: {name: 'unifiedid', type: 'cookie'} - }] - } + init(config); + config.setConfig({ + userSync: { + syncDelay: 99, + userIds: [{ + name: 'unifiedId', + storage: {name: 'unifiedid', type: 'cookie'} + }] + } + }); + expect(syncDelay).to.equal(99); }); - expect(syncDelay).to.equal(99); - }); - it('config auctionDelay updates module correctly', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); - init(config); - config.setConfig({ - userSync: { - auctionDelay: 100, - userIds: [{ - name: 'unifiedId', - storage: {name: 'unifiedid', type: 'cookie'} - }] - } + it('config auctionDelay updates module correctly', function () { + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); + init(config); + config.setConfig({ + userSync: { + auctionDelay: 100, + userIds: [{ + name: 'unifiedId', + storage: {name: 'unifiedid', type: 'cookie'} + }] + } + }); + expect(auctionDelay).to.equal(100); }); - expect(auctionDelay).to.equal(100); - }); - it('config auctionDelay defaults to 0 if not a number', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); - init(config); - config.setConfig({ - userSync: { - auctionDelay: '', - userIds: [{ - name: 'unifiedId', - storage: {name: 'unifiedid', type: 'cookie'} - }] - } + it('config auctionDelay defaults to 0 if not a number', function () { + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule]); + init(config); + config.setConfig({ + userSync: { + auctionDelay: '', + userIds: [{ + name: 'unifiedId', + storage: {name: 'unifiedid', type: 'cookie'} + }] + } + }); + expect(auctionDelay).to.equal(0); }); - expect(auctionDelay).to.equal(0); }); - }); - describe('auction and user sync delays', function () { - let sandbox; - let adUnits; - let mockIdCallback; - let auctionSpy; + describe('auction and user sync delays', function () { + let sandbox; + let adUnits; + let mockIdCallback; + let auctionSpy; - beforeEach(function () { - sandbox = sinon.createSandbox(); - sandbox.stub(global, 'setTimeout').returns(2); - sandbox.stub(global, 'clearTimeout'); - sandbox.stub(events, 'on'); - sandbox.stub(coreStorage, 'getCookie'); + beforeEach(function () { + sandbox = sinon.createSandbox(); + sandbox.stub(global, 'setTimeout').returns(2); + sandbox.stub(global, 'clearTimeout'); + sandbox.stub(events, 'on'); + sandbox.stub(coreStorage, 'getCookie'); - // remove cookie - coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE); + // remove cookie + coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE); - adUnits = [getAdUnitMock()]; + adUnits = [getAdUnitMock()]; - auctionSpy = sandbox.spy(); - mockIdCallback = sandbox.stub(); - const mockIdSystem = { - name: 'mockId', - decode: function (value) { - return { - 'mid': value['MOCKID'] - }; - }, - getId: function () { - const storedId = coreStorage.getCookie('MOCKID'); - if (storedId) { - return {id: {'MOCKID': storedId}}; + auctionSpy = sandbox.spy(); + mockIdCallback = sandbox.stub(); + const mockIdSystem = { + name: 'mockId', + decode: function (value) { + return { + 'mid': value['MOCKID'] + }; + }, + getId: function () { + const storedId = coreStorage.getCookie('MOCKID'); + if (storedId) { + return {id: {'MOCKID': storedId}}; + } + return {callback: mockIdCallback}; } - return {callback: mockIdCallback}; - } - }; - - init(config); + }; - attachIdSystem(mockIdSystem, true); - }); + init(config); - afterEach(function () { - $$PREBID_GLOBAL$$.requestBids.removeAll(); - config.resetConfig(); - sandbox.restore(); - }); + attachIdSystem(mockIdSystem, true); + }); - it('delays auction if auctionDelay is set, timing out at auction delay', function () { - config.setConfig({ - userSync: { - auctionDelay: 33, - syncDelay: 77, - userIds: [{ - name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} - }] - } + afterEach(function () { + $$PREBID_GLOBAL$$.requestBids.removeAll(); + config.resetConfig(); + sandbox.restore(); }); - requestBidsHook(auctionSpy, {adUnits}); + it('delays auction if auctionDelay is set, timing out at auction delay', function () { + config.setConfig({ + userSync: { + auctionDelay: 33, + syncDelay: 77, + userIds: [{ + name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} + }] + } + }); - // check auction was delayed - global.clearTimeout.calledOnce.should.equal(false); - global.setTimeout.calledOnce.should.equal(true); - global.setTimeout.calledWith(sinon.match.func, 33); - auctionSpy.calledOnce.should.equal(false); + requestBidsHook(auctionSpy, {adUnits}); - // check ids were fetched - mockIdCallback.calledOnce.should.equal(true); + // check auction was delayed + global.clearTimeout.calledOnce.should.equal(false); + global.setTimeout.calledOnce.should.equal(true); + global.setTimeout.calledWith(sinon.match.func, 33); + auctionSpy.calledOnce.should.equal(false); - // callback to continue auction if timed out - global.setTimeout.callArg(0); - auctionSpy.calledOnce.should.equal(true); + // check ids were fetched + mockIdCallback.calledOnce.should.equal(true); - // does not call auction again once ids are synced - mockIdCallback.callArgWith(0, {'MOCKID': '1234'}); - auctionSpy.calledOnce.should.equal(true); + // callback to continue auction if timed out + global.setTimeout.callArg(0); + auctionSpy.calledOnce.should.equal(true); - // no sync after auction ends - events.on.called.should.equal(false); - }); + // does not call auction again once ids are synced + mockIdCallback.callArgWith(0, {'MOCKID': '1234'}); + auctionSpy.calledOnce.should.equal(true); - it('delays auction if auctionDelay is set, continuing auction if ids are fetched before timing out', function (done) { - config.setConfig({ - userSync: { - auctionDelay: 33, - syncDelay: 77, - userIds: [{ - name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} - }] - } + // no sync after auction ends + events.on.called.should.equal(false); }); - requestBidsHook(auctionSpy, {adUnits}); + it('delays auction if auctionDelay is set, continuing auction if ids are fetched before timing out', function (done) { + config.setConfig({ + userSync: { + auctionDelay: 33, + syncDelay: 77, + userIds: [{ + name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} + }] + } + }); - // check auction was delayed - // global.setTimeout.calledOnce.should.equal(true); - global.clearTimeout.calledOnce.should.equal(false); - global.setTimeout.calledWith(sinon.match.func, 33); - auctionSpy.calledOnce.should.equal(false); + requestBidsHook(auctionSpy, {adUnits}); - // check ids were fetched - mockIdCallback.calledOnce.should.equal(true); + // check auction was delayed + // global.setTimeout.calledOnce.should.equal(true); + global.clearTimeout.calledOnce.should.equal(false); + global.setTimeout.calledWith(sinon.match.func, 33); + auctionSpy.calledOnce.should.equal(false); - // if ids returned, should continue auction - mockIdCallback.callArgWith(0, {'MOCKID': '1234'}); - auctionSpy.calledOnce.should.equal(true); + // check ids were fetched + mockIdCallback.calledOnce.should.equal(true); - // check ids were copied to bids - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.mid'); - expect(bid.userId.mid).to.equal('1234'); - expect(bid.userIdAsEids.length).to.equal(0);// "mid" is an un-known submodule for USER_IDS_CONFIG in eids.js - }); - done(); - }); + // if ids returned, should continue auction + mockIdCallback.callArgWith(0, {'MOCKID': '1234'}); + auctionSpy.calledOnce.should.equal(true); - // no sync after auction ends - events.on.called.should.equal(false); - }); + // check ids were copied to bids + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.mid'); + expect(bid.userId.mid).to.equal('1234'); + expect(bid.userIdAsEids.length).to.equal(0);// "mid" is an un-known submodule for USER_IDS_CONFIG in eids.js + }); + done(); + }); - it('does not delay auction if not set, delays id fetch after auction ends with syncDelay', function () { - config.setConfig({ - userSync: { - syncDelay: 77, - userIds: [{ - name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} - }] - } + // no sync after auction ends + events.on.called.should.equal(false); }); - // check config has been set correctly - expect(auctionDelay).to.equal(0); - expect(syncDelay).to.equal(77); + it('does not delay auction if not set, delays id fetch after auction ends with syncDelay', function () { + config.setConfig({ + userSync: { + syncDelay: 77, + userIds: [{ + name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} + }] + } + }); - requestBidsHook(auctionSpy, {adUnits}); + // check config has been set correctly + expect(auctionDelay).to.equal(0); + expect(syncDelay).to.equal(77); - // should not delay auction - global.setTimeout.calledOnce.should.equal(false); - auctionSpy.calledOnce.should.equal(true); + requestBidsHook(auctionSpy, {adUnits}); - // check user sync is delayed after auction is ended - mockIdCallback.calledOnce.should.equal(false); - events.on.calledOnce.should.equal(true); - events.on.calledWith(CONSTANTS.EVENTS.AUCTION_END, sinon.match.func); + // should not delay auction + global.setTimeout.calledOnce.should.equal(false); + auctionSpy.calledOnce.should.equal(true); - // once auction is ended, sync user ids after delay - events.on.callArg(1); - global.setTimeout.calledOnce.should.equal(true); - global.setTimeout.calledWith(sinon.match.func, 77); - mockIdCallback.calledOnce.should.equal(false); + // check user sync is delayed after auction is ended + mockIdCallback.calledOnce.should.equal(false); + events.on.calledOnce.should.equal(true); + events.on.calledWith(CONSTANTS.EVENTS.AUCTION_END, sinon.match.func); - // once sync delay is over, ids should be fetched - global.setTimeout.callArg(0); - mockIdCallback.calledOnce.should.equal(true); - }); + // once auction is ended, sync user ids after delay + events.on.callArg(1); + global.setTimeout.calledOnce.should.equal(true); + global.setTimeout.calledWith(sinon.match.func, 77); + mockIdCallback.calledOnce.should.equal(false); - it('does not delay user id sync after auction ends if set to 0', function () { - config.setConfig({ - userSync: { - syncDelay: 0, - userIds: [{ - name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} - }] - } + // once sync delay is over, ids should be fetched + global.setTimeout.callArg(0); + mockIdCallback.calledOnce.should.equal(true); }); - expect(syncDelay).to.equal(0); + it('does not delay user id sync after auction ends if set to 0', function () { + config.setConfig({ + userSync: { + syncDelay: 0, + userIds: [{ + name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} + }] + } + }); - requestBidsHook(auctionSpy, {adUnits}); + expect(syncDelay).to.equal(0); - // auction should not be delayed - global.setTimeout.calledOnce.should.equal(false); - auctionSpy.calledOnce.should.equal(true); + requestBidsHook(auctionSpy, {adUnits}); - // sync delay after auction is ended - mockIdCallback.calledOnce.should.equal(false); - events.on.calledOnce.should.equal(true); - events.on.calledWith(CONSTANTS.EVENTS.AUCTION_END, sinon.match.func); + // auction should not be delayed + global.setTimeout.calledOnce.should.equal(false); + auctionSpy.calledOnce.should.equal(true); - // once auction is ended, if no sync delay, fetch ids - events.on.callArg(1); - global.setTimeout.calledOnce.should.equal(false); - mockIdCallback.calledOnce.should.equal(true); - }); + // sync delay after auction is ended + mockIdCallback.calledOnce.should.equal(false); + events.on.calledOnce.should.equal(true); + events.on.calledWith(CONSTANTS.EVENTS.AUCTION_END, sinon.match.func); - it('does not delay auction if there are no ids to fetch', function () { - coreStorage.getCookie.withArgs('MOCKID').returns('123456778'); - config.setConfig({ - userSync: { - auctionDelay: 33, - syncDelay: 77, - userIds: [{ - name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} - }] - } + // once auction is ended, if no sync delay, fetch ids + events.on.callArg(1); + global.setTimeout.calledOnce.should.equal(false); + mockIdCallback.calledOnce.should.equal(true); }); - requestBidsHook(auctionSpy, {adUnits}); + it('does not delay auction if there are no ids to fetch', function () { + coreStorage.getCookie.withArgs('MOCKID').returns('123456778'); + config.setConfig({ + userSync: { + auctionDelay: 33, + syncDelay: 77, + userIds: [{ + name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} + }] + } + }); + + requestBidsHook(auctionSpy, {adUnits}); - global.setTimeout.calledOnce.should.equal(false); - auctionSpy.calledOnce.should.equal(true); - mockIdCallback.calledOnce.should.equal(false); + global.setTimeout.calledOnce.should.equal(false); + auctionSpy.calledOnce.should.equal(true); + mockIdCallback.calledOnce.should.equal(false); - // no sync after auction ends - events.on.called.should.equal(false); + // no sync after auction ends + events.on.called.should.equal(false); + }); }); - }); - describe('Request bids hook appends userId to bid objs in adapters', function () { - let adUnits; + describe('Request bids hook appends userId to bid objs in adapters', function () { + let adUnits; - beforeEach(function () { - adUnits = [getAdUnitMock()]; - }); + beforeEach(function () { + adUnits = [getAdUnitMock()]; + }); - it('test hook from pubcommonid cookie', function (done) { - coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 100000).toUTCString())); + it('test hook from pubcommonid cookie', function (done) { + coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 100000).toUTCString())); - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); + setSubmoduleRegistry([sharedIdSystemSubmodule]); + init(config); + config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'pubcid.org', - uids: [{id: 'testpubcid', atype: 1}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.pubcid'); + expect(bid.userId.pubcid).to.equal('testpubcid'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'pubcid.org', + uids: [{id: 'testpubcid', atype: 1}] + }); }); - - // verify no sharedid was added - expect(bid.userId).to.not.have.property('sharedid'); - expect(findEid(bid.userIdAsEids, 'sharedid.org')).to.be.undefined; }); - }); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from pubcommonid html5', function (done) { + it('test hook from pubcommonid html5', function (done) { // simulate existing browser local storage values - localStorage.setItem('pubcid', 'testpubcid'); - localStorage.setItem('pubcid_exp', new Date(Date.now() + 100000).toUTCString()); + localStorage.setItem('pubcid', 'testpubcid'); + localStorage.setItem('pubcid_exp', new Date(Date.now() + 100000).toUTCString()); - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'html5'])); + setSubmoduleRegistry([sharedIdSystemSubmodule]); + init(config); + config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'pubcid.org', - uids: [{id: 'testpubcid', atype: 1}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.pubcid'); + expect(bid.userId.pubcid).to.equal('testpubcid'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'pubcid.org', + uids: [{id: 'testpubcid', atype: 1}] + }); }); - - // verify no sharedid was added - expect(bid.userId).to.not.have.property('sharedid'); - expect(findEid(bid.userIdAsEids, 'sharedid.org')).to.be.undefined; }); - }); - localStorage.removeItem('pubcid'); - localStorage.removeItem('pubcid_exp'); - done(); - }, {adUnits}); - }); - - it('test hook from pubcommonid config value object', function (done) { - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - config.setConfig(getConfigValueMock('pubCommonId', {'pubcidvalue': 'testpubcidvalue'})); + localStorage.removeItem('pubcid'); + localStorage.removeItem('pubcid_exp'); + done(); + }, {adUnits}); + }); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.pubcidvalue'); - expect(bid.userId.pubcidvalue).to.equal('testpubcidvalue'); - expect(bid.userIdAsEids.length).to.equal(0);// "pubcidvalue" is an un-known submodule for USER_IDS_CONFIG in eids.js + it('test hook from pubcommonid config value object', function (done) { + setSubmoduleRegistry([sharedIdSystemSubmodule]); + init(config); + config.setConfig(getConfigValueMock('pubCommonId', {'pubcidvalue': 'testpubcidvalue'})); + + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.pubcidvalue'); + expect(bid.userId.pubcidvalue).to.equal('testpubcidvalue'); + expect(bid.userIdAsEids.length).to.equal(0);// "pubcidvalue" is an un-known submodule for USER_IDS_CONFIG in eids.js + }); }); - }); - done(); - }, {adUnits}); - }); + done(); + }, {adUnits}); + }); - it('test hook from UnifiedId html5', function (done) { + it('test hook from UnifiedId html5', function (done) { // simulate existing browser local storage values - localStorage.setItem('unifiedid_alt', JSON.stringify({'TDID': 'testunifiedid_alt'})); - localStorage.setItem('unifiedid_alt_exp', ''); + localStorage.setItem('unifiedid_alt', JSON.stringify({'TDID': 'testunifiedid_alt'})); + localStorage.setItem('unifiedid_alt_exp', ''); - setSubmoduleRegistry([unifiedIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['unifiedId', 'unifiedid_alt', 'html5'])); + setSubmoduleRegistry([unifiedIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['unifiedId', 'unifiedid_alt', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.tdid'); - expect(bid.userId.tdid).to.equal('testunifiedid_alt'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'adserver.org', - uids: [{id: 'testunifiedid_alt', atype: 1, ext: {rtiPartner: 'TDID'}}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.tdid'); + expect(bid.userId.tdid).to.equal('testunifiedid_alt'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'adserver.org', + uids: [{id: 'testunifiedid_alt', atype: 1, ext: {rtiPartner: 'TDID'}}] + }); }); }); - }); - localStorage.removeItem('unifiedid_alt'); - localStorage.removeItem('unifiedid_alt_exp'); - done(); - }, {adUnits}); - }); + localStorage.removeItem('unifiedid_alt'); + localStorage.removeItem('unifiedid_alt_exp'); + done(); + }, {adUnits}); + }); - it('test hook from identityLink html5', function (done) { + it('test hook from identityLink html5', function (done) { // simulate existing browser local storage values - localStorage.setItem('idl_env', 'AiGNC8Z5ONyZKSpIPf'); - localStorage.setItem('idl_env_exp', ''); + localStorage.setItem('idl_env', 'AiGNC8Z5ONyZKSpIPf'); + localStorage.setItem('idl_env_exp', ''); - setSubmoduleRegistry([identityLinkSubmodule]); - init(config); - config.setConfig(getConfigMock(['identityLink', 'idl_env', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.idl_env'); - expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'liveramp.com', - uids: [{id: 'AiGNC8Z5ONyZKSpIPf', atype: 3}] + setSubmoduleRegistry([identityLinkSubmodule]); + init(config); + config.setConfig(getConfigMock(['identityLink', 'idl_env', 'html5'])); + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.idl_env'); + expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'liveramp.com', + uids: [{id: 'AiGNC8Z5ONyZKSpIPf', atype: 3}] + }); }); }); - }); - localStorage.removeItem('idl_env'); - localStorage.removeItem('idl_env_exp'); - done(); - }, {adUnits}); - }); + localStorage.removeItem('idl_env'); + localStorage.removeItem('idl_env_exp'); + done(); + }, {adUnits}); + }); - it('test hook from identityLink cookie', function (done) { - coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', (new Date(Date.now() + 100000).toUTCString())); + it('test hook from identityLink cookie', function (done) { + coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', (new Date(Date.now() + 100000).toUTCString())); - setSubmoduleRegistry([identityLinkSubmodule]); - init(config); - config.setConfig(getConfigMock(['identityLink', 'idl_env', 'cookie'])); + setSubmoduleRegistry([identityLinkSubmodule]); + init(config); + config.setConfig(getConfigMock(['identityLink', 'idl_env', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.idl_env'); - expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'liveramp.com', - uids: [{id: 'AiGNC8Z5ONyZKSpIPf', atype: 3}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.idl_env'); + expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'liveramp.com', + uids: [{id: 'AiGNC8Z5ONyZKSpIPf', atype: 3}] + }); }); }); - }); - coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from criteoIdModule cookie', function (done) { - coreStorage.setCookie('storage_bidid', JSON.stringify({'criteoId': 'test_bidid'}), (new Date(Date.now() + 100000).toUTCString())); + it('test hook from criteoIdModule cookie', function (done) { + coreStorage.setCookie('storage_bidid', JSON.stringify({'criteoId': 'test_bidid'}), (new Date(Date.now() + 100000).toUTCString())); - setSubmoduleRegistry([criteoIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['criteo', 'storage_bidid', 'cookie'])); + setSubmoduleRegistry([criteoIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['criteo', 'storage_bidid', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.criteoId'); - expect(bid.userId.criteoId).to.equal('test_bidid'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'criteo.com', - uids: [{id: 'test_bidid', atype: 1}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.criteoId'); + expect(bid.userId.criteoId).to.equal('test_bidid'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'criteo.com', + uids: [{id: 'test_bidid', atype: 1}] + }); }); }); - }); - coreStorage.setCookie('storage_bidid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('storage_bidid', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from tapadIdModule cookie', function (done) { - coreStorage.setCookie('tapad_id', 'test-tapad-id', (new Date(Date.now() + 100000).toUTCString())); + it('test hook from tapadIdModule cookie', function (done) { + coreStorage.setCookie('tapad_id', 'test-tapad-id', (new Date(Date.now() + 100000).toUTCString())); - setSubmoduleRegistry([tapadIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['tapadId', 'tapad_id', 'cookie'])); + setSubmoduleRegistry([tapadIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['tapadId', 'tapad_id', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.tapadId'); - expect(bid.userId.tapadId).to.equal('test-tapad-id'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'tapad.com', - uids: [{id: 'test-tapad-id', atype: 1}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.tapadId'); + expect(bid.userId.tapadId).to.equal('test-tapad-id'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'tapad.com', + uids: [{id: 'test-tapad-id', atype: 1}] + }); }); - }); - }) - coreStorage.setCookie('tapad_id', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + }) + coreStorage.setCookie('tapad_id', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from liveIntentId html5', function (done) { + it('test hook from liveIntentId html5', function (done) { // simulate existing browser local storage values - localStorage.setItem('_li_pbid', JSON.stringify({'unifiedId': 'random-ls-identifier'})); - localStorage.setItem('_li_pbid_exp', ''); + localStorage.setItem('_li_pbid', JSON.stringify({'unifiedId': 'random-ls-identifier'})); + localStorage.setItem('_li_pbid_exp', ''); - setSubmoduleRegistry([liveIntentIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.lipb'); - expect(bid.userId.lipb.lipbid).to.equal('random-ls-identifier'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'liveintent.com', - uids: [{id: 'random-ls-identifier', atype: 3}] + setSubmoduleRegistry([liveIntentIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'html5'])); + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.lipb'); + expect(bid.userId.lipb.lipbid).to.equal('random-ls-identifier'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'liveintent.com', + uids: [{id: 'random-ls-identifier', atype: 3}] + }); }); }); - }); - localStorage.removeItem('_li_pbid'); - localStorage.removeItem('_li_pbid_exp'); - done(); - }, {adUnits}); - }); + localStorage.removeItem('_li_pbid'); + localStorage.removeItem('_li_pbid_exp'); + done(); + }, {adUnits}); + }); - it('test hook from liveIntentId cookie', function (done) { - coreStorage.setCookie('_li_pbid', JSON.stringify({'unifiedId': 'random-cookie-identifier'}), (new Date(Date.now() + 100000).toUTCString())); + it('test hook from liveIntentId cookie', function (done) { + coreStorage.setCookie('_li_pbid', JSON.stringify({'unifiedId': 'random-cookie-identifier'}), (new Date(Date.now() + 100000).toUTCString())); - setSubmoduleRegistry([liveIntentIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'cookie'])); + setSubmoduleRegistry([liveIntentIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.lipb'); - expect(bid.userId.lipb.lipbid).to.equal('random-cookie-identifier'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'liveintent.com', - uids: [{id: 'random-cookie-identifier', atype: 3}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.lipb'); + expect(bid.userId.lipb.lipbid).to.equal('random-cookie-identifier'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'liveintent.com', + uids: [{id: 'random-cookie-identifier', atype: 3}] + }); }); }); - }); - coreStorage.setCookie('_li_pbid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('_li_pbid', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from sharedId html5', function (done) { - // simulate existing browser local storage values - localStorage.setItem('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611})); - localStorage.setItem('sharedid_exp', ''); + it('eidPermissions fun with bidders', function (done) { + coreStorage.setCookie('pubcid', 'test222', (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([sharedIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['sharedId', 'sharedid', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.have.deep.nested.property('id'); - expect(bid.userId.sharedid).to.have.deep.nested.property('third'); - expect(bid.userId.sharedid).to.deep.equal({ - id: 'test_sharedId', - third: 'test_sharedId' - }); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'sharedid.org', - uids: [{ - id: 'test_sharedId', - atype: 1, - ext: { - third: 'test_sharedId' + setSubmoduleRegistry([sharedIdSystemSubmodule]); + let eidPermissions; + getPrebidInternal().setEidPermissions = function (newEidPermissions) { + eidPermissions = newEidPermissions; + } + init(config); + config.setConfig({ + userSync: { + syncDelay: 0, + userIds: [ + { + name: 'pubCommonId', + bidders: [ + 'sampleBidder' + ], + storage: { + type: 'cookie', + name: 'pubcid', + expires: 28 } - }] - }); - }); + } + ] + } }); - localStorage.removeItem('sharedid'); - localStorage.removeItem('sharedid_exp'); - done(); - }, {adUnits}); - }); - it('test hook from sharedId html5 (id not synced)', function (done) { - // simulate existing browser local storage values - localStorage.setItem('sharedid', JSON.stringify({'id': 'test_sharedId', 'ns': true, 'ts': 1590525289611})); - localStorage.setItem('sharedid_exp', ''); - - setSubmoduleRegistry([sharedIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['sharedId', 'sharedid', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.have.deep.nested.property('id'); - expect(bid.userId.sharedid).to.deep.equal({ - id: 'test_sharedId' - }); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'sharedid.org', - uids: [{ - id: 'test_sharedId', - atype: 1 - }] + requestBidsHook(function () { + expect(eidPermissions).to.deep.equal( + [ + { + bidders: [ + 'sampleBidder' + ], + source: 'pubcid.org' + } + ] + ); + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + if (bid.bidder === 'sampleBidder') { + expect(bid).to.have.deep.nested.property('userId.pubcid'); + expect(bid.userId.pubcid).to.equal('test222'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'pubcid.org', + uids: [ + { + id: 'test222', + atype: 1 + } + ] + }); + } + if (bid.bidder === 'anotherSampleBidder') { + expect(bid).to.not.have.deep.nested.property('userId.pubcid'); + expect(bid).to.not.have.property('userIdAsEids'); + } }); }); - }); - localStorage.removeItem('sharedid'); - localStorage.removeItem('sharedid_exp'); - done(); - }, {adUnits}); - }); - it('test hook from sharedId cookie', function (done) { - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': 'test_sharedId', - 'ts': 1590525289611 - }), (new Date(Date.now() + 100000).toUTCString())); + coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); + getPrebidInternal().setEidPermissions = undefined; + done(); + }, {adUnits}); + }); - setSubmoduleRegistry([sharedIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['sharedId', 'sharedid', 'cookie'])); + it('eidPermissions fun without bidders', function (done) { + coreStorage.setCookie('pubcid', 'test222', new Date(Date.now() + 5000).toUTCString()); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.have.deep.nested.property('id'); - expect(bid.userId.sharedid).to.have.deep.nested.property('third'); - expect(bid.userId.sharedid).to.deep.equal({ - id: 'test_sharedId', - third: 'test_sharedId' - }); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'sharedid.org', - uids: [{ - id: 'test_sharedId', - atype: 1, - ext: { - third: 'test_sharedId' + setSubmoduleRegistry([sharedIdSystemSubmodule]); + let eidPermissions; + getPrebidInternal().setEidPermissions = function (newEidPermissions) { + eidPermissions = newEidPermissions; + } + init(config); + config.setConfig({ + userSync: { + syncDelay: 0, + userIds: [ + { + name: 'pubCommonId', + storage: { + type: 'cookie', + name: 'pubcid', + expires: 28 } - }] - }); - }); - }); - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - it('test hook from sharedId cookie (id not synced) ', function (done) { - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': 'test_sharedId', - 'ns': true, - 'ts': 1590525289611 - }), (new Date(Date.now() + 100000).toUTCString())); - - setSubmoduleRegistry([sharedIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['sharedId', 'sharedid', 'cookie'])); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.have.deep.nested.property('id'); - expect(bid.userId.sharedid).to.deep.equal({ - id: 'test_sharedId' - }); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'sharedid.org', - uids: [{ - id: 'test_sharedId', - atype: 1 - }] - }); - }); - }); - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - - it('eidPermissions fun with bidders', function (done) { - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': 'test222', - 'ts': 1590525289611 - }), (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([sharedIdSubmodule]); - let eidPermissions; - getPrebidInternal().setEidPermissions = function (newEidPermissions) { - eidPermissions = newEidPermissions; - } - init(config); - config.setConfig({ - userSync: { - syncDelay: 0, - userIds: [ - { - name: 'sharedId', - bidders: [ - 'sampleBidder' - ], - storage: { - type: 'cookie', - name: 'sharedid', - expires: 28 } - } - ] - } - }); + ] + } + }); - requestBidsHook(function () { - expect(eidPermissions).to.deep.equal( - [ - { - bidders: [ - 'sampleBidder' - ], - source: 'sharedid.org' - } - ] - ); - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - if (bid.bidder === 'sampleBidder') { - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid.id).to.equal('test222'); + requestBidsHook(function () { + expect(eidPermissions).to.deep.equal( + [] + ); + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.pubcid'); + expect(bid.userId.pubcid).to.equal('test222'); expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'sharedid.org', + source: 'pubcid.org', uids: [ { id: 'test222', - atype: 1, - ext: { - third: 'test222' - } - } - ] + atype: 1 + }] }); - } - if (bid.bidder === 'anotherSampleBidder') { - expect(bid).to.not.have.deep.nested.property('userId.sharedid'); - expect(bid).to.not.have.property('userIdAsEids'); - } + }); }); - }); - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - getPrebidInternal().setEidPermissions = undefined; - done(); - }, {adUnits}); - }); - - it('eidPermissions fun without bidders', function (done) { - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': 'test222', - 'ts': 1590525289611 - }), (new Date(Date.now() + 5000).toUTCString())); + getPrebidInternal().setEidPermissions = undefined; + coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - setSubmoduleRegistry([sharedIdSubmodule]); - let eidPermissions; - getPrebidInternal().setEidPermissions = function (newEidPermissions) { - eidPermissions = newEidPermissions; - } - init(config); - config.setConfig({ - userSync: { - syncDelay: 0, - userIds: [ - { - name: 'sharedId', - storage: { - type: 'cookie', - name: 'sharedid', - expires: 28 + it('test hook from pubProvidedId config params', function (done) { + setSubmoduleRegistry([pubProvidedIdSubmodule]); + init(config); + config.setConfig({ + userSync: { + syncDelay: 0, + userIds: [{ + name: 'pubProvidedId', + params: { + eids: [{ + source: 'example.com', + uids: [{ + id: 'value read from cookie or local storage', + ext: { + stype: 'ppuid' + } + }] + }, { + source: 'id-partner.com', + uids: [{ + id: 'value read from cookie or local storage', + ext: { + stype: 'dmp' + } + }] + }], + eidsFunction: function () { + return [{ + source: 'provider.com', + uids: [{ + id: 'value read from cookie or local storage', + ext: { + stype: 'sha256email' + } + }] + }] + } } } - ] - } - }); - - requestBidsHook(function () { - expect(eidPermissions).to.deep.equal( - [] - ); - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid.id).to.equal('test222'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'sharedid.org', - uids: [ - { - id: 'test222', - atype: 1, - ext: { - third: 'test222' - } - }] - }); - }); + ] + } }); - getPrebidInternal().setEidPermissions = undefined; - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - it('test hook from pubProvidedId config params', function (done) { - setSubmoduleRegistry([pubProvidedIdSubmodule]); - init(config); - config.setConfig({ - userSync: { - syncDelay: 0, - userIds: [{ - name: 'pubProvidedId', - params: { - eids: [{ + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.pubProvidedId'); + expect(bid.userId.pubProvidedId).to.deep.equal([{ source: 'example.com', uids: [{ id: 'value read from cookie or local storage', @@ -1389,1537 +1270,1122 @@ describe('User ID', function () { stype: 'dmp' } }] - }], - eidsFunction: function () { - return [{ - source: 'provider.com', - uids: [{ - id: 'value read from cookie or local storage', - ext: { - stype: 'sha256email' - } - }] + }, { + source: 'provider.com', + uids: [{ + id: 'value read from cookie or local storage', + ext: { + stype: 'sha256email' + } }] - } - } - } - ] - } - }); + }]); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.pubProvidedId'); - expect(bid.userId.pubProvidedId).to.deep.equal([{ - source: 'example.com', - uids: [{ - id: 'value read from cookie or local storage', - ext: { - stype: 'ppuid' - } - }] - }, { - source: 'id-partner.com', - uids: [{ - id: 'value read from cookie or local storage', - ext: { - stype: 'dmp' - } - }] - }, { - source: 'provider.com', - uids: [{ - id: 'value read from cookie or local storage', - ext: { - stype: 'sha256email' - } - }] - }]); - - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'example.com', - uids: [{ - id: 'value read from cookie or local storage', - ext: { - stype: 'ppuid' - } - }] - }); - expect(bid.userIdAsEids[2]).to.deep.equal({ - source: 'provider.com', - uids: [{ - id: 'value read from cookie or local storage', - ext: { - stype: 'sha256email' - } - }] + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'example.com', + uids: [{ + id: 'value read from cookie or local storage', + ext: { + stype: 'ppuid' + } + }] + }); + expect(bid.userIdAsEids[2]).to.deep.equal({ + source: 'provider.com', + uids: [{ + id: 'value read from cookie or local storage', + ext: { + stype: 'sha256email' + } + }] + }); }); }); - }); - done(); - }, {adUnits}); - }); + done(); + }, {adUnits}); + }); - it('test hook from liveIntentId html5', function (done) { + it('test hook from liveIntentId html5', function (done) { // simulate existing browser local storage values - localStorage.setItem('_li_pbid', JSON.stringify({'unifiedId': 'random-ls-identifier', 'segments': ['123']})); - localStorage.setItem('_li_pbid_exp', ''); + localStorage.setItem('_li_pbid', JSON.stringify({'unifiedId': 'random-ls-identifier', 'segments': ['123']})); + localStorage.setItem('_li_pbid_exp', ''); - setSubmoduleRegistry([liveIntentIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.lipb'); - expect(bid.userId.lipb.lipbid).to.equal('random-ls-identifier'); - expect(bid.userId.lipb.segments).to.include('123'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'liveintent.com', - uids: [{id: 'random-ls-identifier', atype: 3}], - ext: {segments: ['123']} + setSubmoduleRegistry([liveIntentIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'html5'])); + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.lipb'); + expect(bid.userId.lipb.lipbid).to.equal('random-ls-identifier'); + expect(bid.userId.lipb.segments).to.include('123'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'liveintent.com', + uids: [{id: 'random-ls-identifier', atype: 3}], + ext: {segments: ['123']} + }); }); }); - }); - localStorage.removeItem('_li_pbid'); - localStorage.removeItem('_li_pbid_exp'); - done(); - }, {adUnits}); - }); - - it('test hook from liveIntentId cookie', function (done) { - coreStorage.setCookie('_li_pbid', JSON.stringify({ - 'unifiedId': 'random-cookie-identifier', - 'segments': ['123'] - }), (new Date(Date.now() + 100000).toUTCString())); + localStorage.removeItem('_li_pbid'); + localStorage.removeItem('_li_pbid_exp'); + done(); + }, {adUnits}); + }); - setSubmoduleRegistry([liveIntentIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'cookie'])); + it('test hook from liveIntentId cookie', function (done) { + coreStorage.setCookie('_li_pbid', JSON.stringify({ + 'unifiedId': 'random-cookie-identifier', + 'segments': ['123'] + }), (new Date(Date.now() + 100000).toUTCString())); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.lipb'); - expect(bid.userId.lipb.lipbid).to.equal('random-cookie-identifier'); - expect(bid.userId.lipb.segments).to.include('123'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'liveintent.com', - uids: [{id: 'random-cookie-identifier', atype: 3}], - ext: {segments: ['123']} + setSubmoduleRegistry([liveIntentIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'cookie'])); + + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.lipb'); + expect(bid.userId.lipb.lipbid).to.equal('random-cookie-identifier'); + expect(bid.userId.lipb.segments).to.include('123'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'liveintent.com', + uids: [{id: 'random-cookie-identifier', atype: 3}], + ext: {segments: ['123']} + }); }); }); - }); - coreStorage.setCookie('_li_pbid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('_li_pbid', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from britepoolid cookies', function (done) { + it('test hook from britepoolid cookies', function (done) { // simulate existing browser local storage values - coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': '279c0161-5152-487f-809e-05d7f7e653fd'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': '279c0161-5152-487f-809e-05d7f7e653fd'}), (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([britepoolIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['britepoolId', 'britepoolid', 'cookie'])); + setSubmoduleRegistry([britepoolIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['britepoolId', 'britepoolid', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.britepoolid'); - expect(bid.userId.britepoolid).to.equal('279c0161-5152-487f-809e-05d7f7e653fd'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'britepool.com', - uids: [{id: '279c0161-5152-487f-809e-05d7f7e653fd', atype: 3}] - }); - }); - }); - coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - - it('test hook from dmdId cookies', function (done) { - // simulate existing browser local storage values - coreStorage.setCookie('dmdId', 'testdmdId', (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([dmdIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['dmdId', 'dmdId', 'cookie'])); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.dmdId'); - expect(bid.userId.dmdId).to.equal('testdmdId'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'hcn.health', - uids: [{id: 'testdmdId', atype: 3}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.britepoolid'); + expect(bid.userId.britepoolid).to.equal('279c0161-5152-487f-809e-05d7f7e653fd'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'britepool.com', + uids: [{id: '279c0161-5152-487f-809e-05d7f7e653fd', atype: 3}] + }); }); }); - }); - coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from netId cookies', function (done) { + it('test hook from dmdId cookies', function (done) { // simulate existing browser local storage values - coreStorage.setCookie('netId', JSON.stringify({'netId': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('dmdId', 'testdmdId', (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([netIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['netId', 'netId', 'cookie'])); + setSubmoduleRegistry([dmdIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['dmdId', 'dmdId', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.netId'); - expect(bid.userId.netId).to.equal('fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'netid.de', - uids: [{id: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', atype: 1}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.dmdId'); + expect(bid.userId.dmdId).to.equal('testdmdId'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'hcn.health', + uids: [{id: 'testdmdId', atype: 3}] + }); }); }); - }); - coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from intentIqId cookies', function (done) { + it('test hook from netId cookies', function (done) { // simulate existing browser local storage values - coreStorage.setCookie('intentIqId', 'abcdefghijk', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('netId', JSON.stringify({'netId': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg'}), (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([intentIqIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['intentIqId', 'intentIqId', 'cookie'])); + setSubmoduleRegistry([netIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['netId', 'netId', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.intentIqId'); - expect(bid.userId.intentIqId).to.equal('abcdefghijk'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'intentiq.com', - uids: [{id: 'abcdefghijk', atype: 1}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.netId'); + expect(bid.userId.netId).to.equal('fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'netid.de', + uids: [{id: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', atype: 1}] + }); }); }); - }); - coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from haloId html5', function (done) { + it('test hook from intentIqId cookies', function (done) { // simulate existing browser local storage values - localStorage.setItem('haloId', JSON.stringify({'haloId': 'random-ls-identifier'})); - localStorage.setItem('haloId_exp', ''); + coreStorage.setCookie('intentIqId', 'abcdefghijk', (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([haloIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['haloId', 'haloId', 'html5'])); + setSubmoduleRegistry([intentIqIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['intentIqId', 'intentIqId', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.haloId'); - expect(bid.userId.haloId).to.equal('random-ls-identifier'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'audigent.com', - uids: [{id: 'random-ls-identifier', atype: 1}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.intentIqId'); + expect(bid.userId.intentIqId).to.equal('abcdefghijk'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'intentiq.com', + uids: [{id: 'abcdefghijk', atype: 1}] + }); }); }); - }); - localStorage.removeItem('haloId'); - localStorage.removeItem('haloId_exp', ''); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from merkleId cookies', function (done) { + it('test hook from haloId html5', function (done) { // simulate existing browser local storage values - coreStorage.setCookie('merkleId', JSON.stringify({'pam_id': {'id': 'testmerkleId', 'keyID': 1}}), (new Date(Date.now() + 5000).toUTCString())); + localStorage.setItem('haloId', JSON.stringify({'haloId': 'random-ls-identifier'})); + localStorage.setItem('haloId_exp', ''); - setSubmoduleRegistry([merkleIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['merkleId', 'merkleId', 'cookie'])); + setSubmoduleRegistry([haloIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['haloId', 'haloId', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.merkleId'); - expect(bid.userId.merkleId).to.deep.equal({'id': 'testmerkleId', 'keyID': 1}); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'merkleinc.com', - uids: [{id: 'testmerkleId', atype: 3, ext: {keyID: 1}}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.haloId'); + expect(bid.userId.haloId).to.equal('random-ls-identifier'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'audigent.com', + uids: [{id: 'random-ls-identifier', atype: 1}] + }); }); }); - }); - coreStorage.setCookie('merkleId', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + localStorage.removeItem('haloId'); + localStorage.removeItem('haloId_exp', ''); + done(); + }, {adUnits}); + }); - it('test hook from zeotapIdPlus cookies', function (done) { + it('test hook from merkleId cookies', function (done) { // simulate existing browser local storage values - coreStorage.setCookie('IDP', btoa(JSON.stringify('abcdefghijk')), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('merkleId', JSON.stringify({'pam_id': {'id': 'testmerkleId', 'keyID': 1}}), (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([zeotapIdPlusSubmodule]); - init(config); - config.setConfig(getConfigMock(['zeotapIdPlus', 'IDP', 'cookie'])); + setSubmoduleRegistry([merkleIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['merkleId', 'merkleId', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.IDP'); - expect(bid.userId.IDP).to.equal('abcdefghijk'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'zeotap.com', - uids: [{id: 'abcdefghijk', atype: 1}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.merkleId'); + expect(bid.userId.merkleId).to.deep.equal({'id': 'testmerkleId', 'keyID': 1}); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'merkleinc.com', + uids: [{id: 'testmerkleId', atype: 3, ext: {keyID: 1}}] + }); }); }); - }); - coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - - it('test hook from mwOpenLinkId cookies', function (done) { - // simulate existing browser local storage values - coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([mwOpenLinkIdSubModule]); - init(config); - config.setConfig(getConfigMock(['mwOpenLinkId', 'mwol', 'cookie'])); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.mwOpenLinkId'); - expect(bid.userId.mwOpenLinkId).to.equal('XX-YY-ZZ-123'); - }); - }); - coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('merkleId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from admixerId html5', function (done) { + it('test hook from zeotapIdPlus cookies', function (done) { // simulate existing browser local storage values - localStorage.setItem('admixerId', 'testadmixerId'); - localStorage.setItem('admixerId_exp', ''); - - setSubmoduleRegistry([admixerIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['admixerId', 'admixerId', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.admixerId'); - expect(bid.userId.admixerId).to.equal('testadmixerId'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'admixer.net', - uids: [{id: 'testadmixerId', atype: 3}] - }); - }); - }); - localStorage.removeItem('admixerId'); - done(); - }, {adUnits}); - }); - - it('test hook from admixerId cookie', function (done) { - coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 100000).toUTCString())); + coreStorage.setCookie('IDP', btoa(JSON.stringify('abcdefghijk')), (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([admixerIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['admixerId', 'admixerId', 'cookie'])); + setSubmoduleRegistry([zeotapIdPlusSubmodule]); + init(config); + config.setConfig(getConfigMock(['zeotapIdPlus', 'IDP', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.admixerId'); - expect(bid.userId.admixerId).to.equal('testadmixerId'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'admixer.net', - uids: [{id: 'testadmixerId', atype: 3}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal('abcdefghijk'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'zeotap.com', + uids: [{id: 'abcdefghijk', atype: 1}] + }); }); }); - }); - coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from deepintentId cookies', function (done) { + it('test hook from mwOpenLinkId cookies', function (done) { // simulate existing browser local storage values - coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([deepintentDpesSubmodule]); - init(config); - config.setConfig(getConfigMock(['deepintentId', 'deepintentId', 'cookie'])); + setSubmoduleRegistry([mwOpenLinkIdSubModule]); + init(config); + config.setConfig(getConfigMock(['mwOpenLinkId', 'mwol', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.deepintentId'); - expect(bid.userId.deepintentId).to.deep.equal('testdeepintentId'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'deepintent.com', - uids: [{id: 'testdeepintentId', atype: 3}] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.mwOpenLinkId'); + expect(bid.userId.mwOpenLinkId).to.equal('XX-YY-ZZ-123'); }); }); - }); - coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); + coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook from deepintentId html5', function (done) { + it('test hook from admixerId html5', function (done) { // simulate existing browser local storage values - localStorage.setItem('deepintentId', 'testdeepintentId'); - localStorage.setItem('deepintentId_exp', ''); - - setSubmoduleRegistry([deepintentDpesSubmodule]); - init(config); - config.setConfig(getConfigMock(['deepintentId', 'deepintentId', 'html5'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.deepintentId'); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'deepintent.com', - uids: [{id: 'testdeepintentId', atype: 3}] - }); - }); - }); - localStorage.removeItem('deepintentId'); - done(); - }, {adUnits}); - }); - - it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, zeotapIdPlus, sharedId, netId, haloId, Criteo, UID 2.0, admixerId, dmdId and mwOpenLinkId have data to pass', function (done) { - coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('dmdId', 'testdmdId', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': 'test_sharedId', - 'ts': 1590525289611 - }), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('storage_criteo', JSON.stringify({'criteoId': 'test_bidid'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], - ['unifiedId', 'unifiedid', 'cookie'], - ['id5Id', 'id5id', 'cookie'], - ['identityLink', 'idl_env', 'cookie'], - ['britepoolId', 'britepoolid', 'cookie'], - ['dmdId', 'dmdId', 'cookie'], - ['netId', 'netId', 'cookie'], - ['sharedId', 'sharedid', 'cookie'], - ['intentIqId', 'intentIqId', 'cookie'], - ['zeotapIdPlus', 'IDP', 'cookie'], - ['haloId', 'haloId', 'cookie'], - ['criteo', 'storage_criteo', 'cookie'], - ['mwOpenLinkId', 'mwol', 'cookie'], - ['tapadId', 'tapad_id', 'cookie'], - ['uid2', 'uid2id', 'cookie'], - ['admixerId', 'admixerId', 'cookie'], - ['deepintentId', 'deepintentId', 'cookie'])); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - // verify that the PubCommonId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - // also check that UnifiedId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.tdid'); - expect(bid.userId.tdid).to.equal('testunifiedid'); - // also check that Id5Id id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.id5id.uid'); - expect(bid.userId.id5id.uid).to.equal('testid5id'); - // check that identityLink id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.idl_env'); - expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); - // also check that britepoolId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.britepoolid'); - expect(bid.userId.britepoolid).to.equal('testbritepoolid'); - // also check that dmdID id was copied to bid - expect(bid).to.have.deep.nested.property('userId.dmdId'); - expect(bid.userId.dmdId).to.equal('testdmdId'); - // also check that netId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.netId'); - expect(bid.userId.netId).to.equal('testnetId'); - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.deep.equal({ - id: 'test_sharedId', - third: 'test_sharedId' - }); - // also check that intentIqId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.intentIqId'); - expect(bid.userId.intentIqId).to.equal('testintentIqId'); - // also check that zeotapIdPlus id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.IDP'); - expect(bid.userId.IDP).to.equal('zeotapId'); - // also check that haloId id was copied to bid - expect(bid).to.have.deep.nested.property('userId.haloId'); - expect(bid.userId.haloId).to.equal('testHaloId'); - // also check that criteo id was copied to bid - expect(bid).to.have.deep.nested.property('userId.criteoId'); - expect(bid.userId.criteoId).to.equal('test_bidid'); - // also check that mwOpenLink id was copied to bid - expect(bid).to.have.deep.nested.property('userId.mwOpenLinkId'); - expect(bid.userId.mwOpenLinkId).to.equal('XX-YY-ZZ-123'); - expect(bid.userId.uid2).to.deep.equal({ - id: 'Sample_AD_Token' - }); - // also check that criteo id was copied to bid - expect(bid).to.have.deep.nested.property('userId.admixerId'); - expect(bid.userId.admixerId).to.equal('testadmixerId'); - - // also check that deepintentId was copied to bid - expect(bid).to.have.deep.nested.property('userId.deepintentId'); - expect(bid.userId.deepintentId).to.equal('testdeepintentId'); - - expect(bid.userIdAsEids.length).to.equal(16); - }); - }); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('id5id', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('storage_criteo', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('deepintentId', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - - it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, dmdId, intentIqId, zeotapIdPlus, sharedId, criteo, netId, haloId, UID 2.0, admixerId and mwOpenLinkId have their modules added before and after init', function (done) { - coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': 'test_sharedId', - 'ts': 1590525289611 - }), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('dmdId', 'testdmdId', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('storage_criteo', JSON.stringify({'criteoId': 'test_bidid'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([]); - - // attaching before init - attachIdSystem(pubCommonIdSubmodule); + localStorage.setItem('admixerId', 'testadmixerId'); + localStorage.setItem('admixerId_exp', ''); - init(config); - - // attaching after init - attachIdSystem(unifiedIdSubmodule); - attachIdSystem(id5IdSubmodule); - attachIdSystem(identityLinkSubmodule); - attachIdSystem(britepoolIdSubmodule); - attachIdSystem(netIdSubmodule); - attachIdSystem(sharedIdSubmodule); - attachIdSystem(intentIqIdSubmodule); - attachIdSystem(zeotapIdPlusSubmodule); - attachIdSystem(haloIdSubmodule); - attachIdSystem(dmdIdSubmodule); - attachIdSystem(criteoIdSubmodule); - attachIdSystem(mwOpenLinkIdSubModule); - attachIdSystem(tapadIdSubmodule); - attachIdSystem(uid2IdSubmodule); - attachIdSystem(admixerIdSubmodule); - attachIdSystem(deepintentDpesSubmodule); - - config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], - ['unifiedId', 'unifiedid', 'cookie'], - ['id5Id', 'id5id', 'cookie'], - ['identityLink', 'idl_env', 'cookie'], - ['britepoolId', 'britepoolid', 'cookie'], - ['netId', 'netId', 'cookie'], - ['sharedId', 'sharedid', 'cookie'], - ['intentIqId', 'intentIqId', 'cookie'], - ['zeotapIdPlus', 'IDP', 'cookie'], - ['haloId', 'haloId', 'cookie'], - ['dmdId', 'dmdId', 'cookie'], - ['criteo', 'storage_criteo', 'cookie'], - ['mwOpenLinkId', 'mwol', 'cookie'], - ['tapadId', 'tapad_id', 'cookie'], - ['uid2', 'uid2id', 'cookie'], - ['admixerId', 'admixerId', 'cookie'], - ['deepintentId', 'deepintentId', 'cookie'])); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - // verify that the PubCommonId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - // also check that UnifiedId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.tdid'); - expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations'); - // also check that Id5Id id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.id5id.uid'); - expect(bid.userId.id5id.uid).to.equal('testid5id'); - // also check that identityLink id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.idl_env'); - expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); - // also check that britepoolId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.britepoolid'); - expect(bid.userId.britepoolid).to.equal('testbritepoolid'); - // also check that britepoolId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.netId'); - expect(bid.userId.netId).to.equal('testnetId'); - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.deep.equal({ - id: 'test_sharedId', - third: 'test_sharedId' - }); - // also check that intentIqId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.intentIqId'); - expect(bid.userId.intentIqId).to.equal('testintentIqId'); - - // also check that zeotapIdPlus id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.IDP'); - expect(bid.userId.IDP).to.equal('zeotapId'); - // also check that haloId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.haloId'); - expect(bid.userId.haloId).to.equal('testHaloId'); - // also check that dmdId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.dmdId'); - expect(bid.userId.dmdId).to.equal('testdmdId'); - - // also check that criteo id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.criteoId'); - expect(bid.userId.criteoId).to.equal('test_bidid'); - - // also check that mwOpenLink id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.mwOpenLinkId'); - expect(bid.userId.mwOpenLinkId).to.equal('XX-YY-ZZ-123') - expect(bid.userId.uid2).to.deep.equal({ - id: 'Sample_AD_Token' + setSubmoduleRegistry([admixerIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['admixerId', 'admixerId', 'html5'])); + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.admixerId'); + expect(bid.userId.admixerId).to.equal('testadmixerId'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'admixer.net', + uids: [{id: 'testadmixerId', atype: 3}] + }); }); - - // also check that admixerId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.admixerId'); - expect(bid.userId.admixerId).to.equal('testadmixerId'); - // also check that deepintentId was copied to bid - expect(bid).to.have.deep.nested.property('userId.deepintentId'); - expect(bid.userId.deepintentId).to.equal('testdeepintentId'); - - expect(bid.userIdAsEids.length).to.equal(16); - }); - }); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('id5id', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('storage_criteo', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - - it('test hook when sharedId(opted out) have their modules added before and after init', function (done) { - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': '00000000000000000000000000', - 'ts': 1590525289611 - }), (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([]); - init(config); - - attachIdSystem(sharedIdSubmodule); - - config.setConfig(getConfigMock(['sharedId', 'sharedid', 'cookie'])); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid.userIdAsEids).to.be.undefined; - }); - }); - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - - it('test sharedid enabled via pubcid cookie', function (done) { - coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('pubcid_sharedid', 'testsharedid', (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - - const customCfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); - addConfig(customCfg, 'params', {enableSharedId: true}); - config.setConfig(customCfg); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - // verify that the PubCommonId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - expect(findEid(bid.userIdAsEids, 'pubcid.org')).to.deep.equal( - {'source': 'pubcid.org', 'uids': [{'id': 'testpubcid', 'atype': 1}]} - ); - // verify that the sharedid was also copied to bid - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.deep.equal({id: 'testsharedid'}); - expect(findEid(bid.userIdAsEids, 'sharedid.org')).to.deep.equal( - {'source': 'sharedid.org', 'uids': [{'id': 'testsharedid', 'atype': 1}]} - ); - }); - }); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('pubcid_sharedid', '', EXPIRED_COOKIE_DATE); - - done(); - }, {adUnits}); - }); - - it('test sharedid disabled via pubcid cookie', function (done) { - coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('pubcid_sharedid', 'testsharedid', (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - - // pubCommonId's support for sharedId is off by default - config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - // verify that the PubCommonId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - expect(findEid(bid.userIdAsEids, 'pubcid.org')).to.deep.equal( - {'source': 'pubcid.org', 'uids': [{'id': 'testpubcid', 'atype': 1}]} - ); - // verify that the sharedid was not added to bid - expect(bid.userId).to.not.have.property('sharedid'); - expect(findEid(bid.userIdAsEids, 'sharedid.org')).to.be.undefined; - }); - }); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('pubcid_sharedid', '', EXPIRED_COOKIE_DATE); - - done(); - }, {adUnits}); - }); - - it('test sharedid enabled via pubcid html5', function (done) { - coreStorage.setDataInLocalStorage('pubcid', 'testpubcid'); - coreStorage.setDataInLocalStorage('pubcid_exp', new Date(Date.now() + 5000).toUTCString()); - coreStorage.setDataInLocalStorage('pubcid_sharedid', 'testsharedid'); - coreStorage.setDataInLocalStorage('pubcid_sharedid_exp', new Date(Date.now() + 5000).toUTCString()); - - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - - const customCfg = getConfigMock(['pubCommonId', 'pubcid', 'html5']); - addConfig(customCfg, 'params', {enableSharedId: true}); - config.setConfig(customCfg); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - // verify that the PubCommonId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - expect(findEid(bid.userIdAsEids, 'pubcid.org')).to.deep.equal( - {'source': 'pubcid.org', 'uids': [{'id': 'testpubcid', 'atype': 1}]} - ); - // verify that the sharedid was also copied to bid - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.deep.equal({id: 'testsharedid'}); - expect(findEid(bid.userIdAsEids, 'sharedid.org')).to.deep.equal( - {'source': 'sharedid.org', 'uids': [{'id': 'testsharedid', 'atype': 1}]} - ); - }); - }); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('pubcid_sharedid', '', EXPIRED_COOKIE_DATE); - - coreStorage.removeDataFromLocalStorage('pubcid'); - coreStorage.removeDataFromLocalStorage('pubcid_exp'); - coreStorage.removeDataFromLocalStorage('pubcid_sharedid'); - coreStorage.removeDataFromLocalStorage('pubcid_sharedid_exp'); - done(); - }, {adUnits}); - }); - - it('test expired sharedid via pubcid html5', function (done) { - coreStorage.setDataInLocalStorage('pubcid', 'testpubcid'); - coreStorage.setDataInLocalStorage('pubcid_exp', new Date(Date.now() + 5000).toUTCString()); - - // set sharedid to expired already - coreStorage.setDataInLocalStorage('pubcid_sharedid', 'testsharedid'); - coreStorage.setDataInLocalStorage('pubcid_sharedid_exp', new Date(Date.now() - 100).toUTCString()); - - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - - const customCfg = getConfigMock(['pubCommonId', 'pubcid', 'html5']); - addConfig(customCfg, 'params', {enableSharedId: true}); - config.setConfig(customCfg); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - // verify that the PubCommonId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - expect(findEid(bid.userIdAsEids, 'pubcid.org')).to.deep.equal( - {'source': 'pubcid.org', 'uids': [{'id': 'testpubcid', 'atype': 1}]} - ); - // verify that the sharedid was not added - expect(bid.userId).to.not.have.property('sharedid'); - expect(findEid(bid.userIdAsEids, 'sharedid.org')).to.be.undefined; - }); - }); - - coreStorage.removeDataFromLocalStorage('pubcid'); - coreStorage.removeDataFromLocalStorage('pubcid_exp'); - coreStorage.removeDataFromLocalStorage('pubcid_sharedid'); - coreStorage.removeDataFromLocalStorage('pubcid_sharedid_exp'); - done(); - }, {adUnits}); - }); - - it('test pubcid coexisting with sharedid', function (done) { - coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('pubcid_sharedid', 'test111', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': 'test222', - 'ts': 1590525289611 - }), (new Date(Date.now() + 5000).toUTCString())); - - // When both pubcommon and sharedid are configured, pubcommon are invoked first due to - // module loading order. This mean the output from the primary sharedid module will overwrite - // the one in pubcommon. - - setSubmoduleRegistry([pubCommonIdSubmodule, sharedIdSubmodule]); - init(config); - config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], - ['sharedId', 'sharedid', 'cookie'], - )); - - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - // verify that the PubCommonId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - expect(findEid(bid.userIdAsEids, 'pubcid.org')).to.deep.equal( - {'source': 'pubcid.org', 'uids': [{'id': 'testpubcid', 'atype': 1}]} - ); - // verify that the sharedid was also copied to bid - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid.id).to.equal('test222'); - expect(findEid(bid.userIdAsEids, 'sharedid.org').uids[0].id).to.equal('test222'); }); - }); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('pubcid_sharedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - - done(); - }, {adUnits}); - }); + localStorage.removeItem('admixerId'); + done(); + }, {adUnits}); + }); - it('test hook from UID2 cookie', function (done) { - coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); + it('test hook from admixerId cookie', function (done) { + coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 100000).toUTCString())); - setSubmoduleRegistry([uid2IdSubmodule]); - init(config); - config.setConfig(getConfigMock(['uid2', 'uid2id', 'cookie'])); + setSubmoduleRegistry([admixerIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['admixerId', 'admixerId', 'cookie'])); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - expect(bid).to.have.deep.nested.property('userId.uid2'); - expect(bid.userId.uid2).to.have.deep.nested.property('id'); - expect(bid.userId.uid2).to.deep.equal({ - id: 'Sample_AD_Token' - }); - expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'uidapi.com', - uids: [{ - id: 'Sample_AD_Token', - atype: 3, - }] + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.admixerId'); + expect(bid.userId.admixerId).to.equal('testadmixerId'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'admixer.net', + uids: [{id: 'testadmixerId', atype: 3}] + }); }); }); - }); - coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - it('should add new id system ', function (done) { - coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('dmdId', 'testdmdId', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('sharedid', JSON.stringify({ - 'id': 'test_sharedId', - 'ts': 1590525289611 - }), new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('admixerId', 'testadmixerId', new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('deepintentId', 'testdeepintentId', new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('__uid2_advertising_token', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); - - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule]); - init(config); - - config.setConfig({ - userSync: { - syncDelay: 0, - userIds: [{ - name: 'pubCommonId', storage: {name: 'pubcid', type: 'cookie'} - }, { - name: 'unifiedId', storage: {name: 'unifiedid', type: 'cookie'} - }, { - name: 'id5Id', storage: {name: 'id5id', type: 'cookie'} - }, { - name: 'identityLink', storage: {name: 'idl_env', type: 'cookie'} - }, { - name: 'britepoolId', storage: {name: 'britepoolid', type: 'cookie'} - }, { - name: 'dmdId', storage: {name: 'dmdId', type: 'cookie'} - }, { - name: 'netId', storage: {name: 'netId', type: 'cookie'} - }, { - name: 'sharedId', storage: {name: 'sharedid', type: 'cookie'} - }, { - name: 'intentIqId', storage: {name: 'intentIqId', type: 'cookie'} - }, { - name: 'zeotapIdPlus' - }, { - name: 'haloId', storage: {name: 'haloId', type: 'cookie'} - }, { - name: 'admixerId', storage: {name: 'admixerId', type: 'cookie'} - }, { - name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} - }, { - name: 'uid2' - }, { - name: 'deepintentId', storage: {name: 'deepintentId', type: 'cookie'} - }] - } - }); - - // Add new submodule named 'mockId' - attachIdSystem({ - name: 'mockId', - decode: function (value) { - return { - 'mid': value['MOCKID'] - }; - }, - getId: function (config, storedId) { - if (storedId) return {}; - return {id: {'MOCKID': '1234'}}; - } + coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); }); - requestBidsHook(function () { - adUnits.forEach(unit => { - unit.bids.forEach(bid => { - // check PubCommonId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.pubcid'); - expect(bid.userId.pubcid).to.equal('testpubcid'); - // check UnifiedId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.tdid'); - expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations'); - // also check that Id5Id id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.id5id.uid'); - expect(bid.userId.id5id.uid).to.equal('testid5id'); - // also check that identityLink id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.idl_env'); - expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); - // also check that britepoolId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.britepoolid'); - expect(bid.userId.britepoolid).to.equal('testbritepoolid'); - // also check that dmdId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.dmdId'); - expect(bid.userId.dmdId).to.equal('testdmdId'); - // check MockId data was copied to bid - expect(bid).to.have.deep.nested.property('userId.netId'); - expect(bid.userId.netId).to.equal('testnetId'); - // also check that sharedId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.sharedid'); - expect(bid.userId.sharedid).to.deep.equal({ - id: 'test_sharedId', - third: 'test_sharedId' - }); - // check MockId data was copied to bid - expect(bid).to.have.deep.nested.property('userId.mid'); - expect(bid.userId.mid).to.equal('1234'); - // also check that intentIqId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.intentIqId'); - expect(bid.userId.intentIqId).to.equal('testintentIqId'); - // also check that zeotapIdPlus id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.IDP'); - expect(bid.userId.IDP).to.equal('zeotapId'); - // also check that haloId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.haloId'); - expect(bid.userId.haloId).to.equal('testHaloId'); - expect(bid.userId.uid2).to.deep.equal({ - id: 'Sample_AD_Token' - }); - - // also check that admixerId id data was copied to bid - expect(bid).to.have.deep.nested.property('userId.admixerId'); - expect(bid.userId.admixerId).to.equal('testadmixerId'); + it('test hook from deepintentId cookies', function (done) { + // simulate existing browser local storage values + coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); - // also check that deepintentId was copied to bid - expect(bid).to.have.deep.nested.property('userId.deepintentId'); - expect(bid.userId.deepintentId).to.equal('testdeepintentId'); + setSubmoduleRegistry([deepintentDpesSubmodule]); + init(config); + config.setConfig(getConfigMock(['deepintentId', 'deepintentId', 'cookie'])); - expect(bid.userIdAsEids.length).to.equal(14); + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userId.deepintentId).to.deep.equal('testdeepintentId'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'deepintent.com', + uids: [{id: 'testdeepintentId', atype: 3}] + }); + }); }); - }); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('id5id', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); - done(); - }, {adUnits}); - }); - }); - - describe('callbacks at the end of auction', function () { - beforeEach(function () { - sinon.stub(events, 'getEvents').returns([]); - sinon.stub(utils, 'triggerPixel'); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('pubcid_sharedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('_parrable_eid', '', EXPIRED_COOKIE_DATE); - }); - - afterEach(function () { - events.getEvents.restore(); - utils.triggerPixel.restore(); - coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('pubcid_sharedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('_parrable_eid', '', EXPIRED_COOKIE_DATE); - resetConsentData(); - delete window.__tcfapi; - }); - - it('pubcid callback with url', function () { - let adUnits = [getAdUnitMock()]; - let innerAdUnits; - let customCfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); - customCfg = addConfig(customCfg, 'params', {pixelUrl: '/any/pubcid/url'}); - - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule]); - init(config); - config.setConfig(customCfg); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - expect(utils.triggerPixel.called).to.be.false; - events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); - expect(utils.triggerPixel.getCall(0).args[0]).to.include('/any/pubcid/url'); - }); + it('test hook from deepintentId html5', function (done) { + // simulate existing browser local storage values + localStorage.setItem('deepintentId', 'testdeepintentId'); + localStorage.setItem('deepintentId_exp', ''); - it('unifiedid callback with url', function () { - let adUnits = [getAdUnitMock()]; - let innerAdUnits; - let customCfg = getConfigMock(['unifiedId', 'unifiedid', 'cookie']); - addConfig(customCfg, 'params', {url: '/any/unifiedid/url'}); + setSubmoduleRegistry([deepintentDpesSubmodule]); + init(config); + config.setConfig(getConfigMock(['deepintentId', 'deepintentId', 'html5'])); + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'deepintent.com', + uids: [{id: 'testdeepintentId', atype: 3}] + }); + }); + }); + localStorage.removeItem('deepintentId'); + done(); + }, {adUnits}); + }); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule]); - init(config); - config.setConfig(customCfg); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, zeotapIdPlus, netId, haloId, Criteo, UID 2.0, admixerId, dmdId and mwOpenLinkId have data to pass', function (done) { + coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('dmdId', 'testdmdId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('storage_criteo', JSON.stringify({'criteoId': 'test_bidid'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); + + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule]); + init(config); + config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], + ['unifiedId', 'unifiedid', 'cookie'], + ['id5Id', 'id5id', 'cookie'], + ['identityLink', 'idl_env', 'cookie'], + ['britepoolId', 'britepoolid', 'cookie'], + ['dmdId', 'dmdId', 'cookie'], + ['netId', 'netId', 'cookie'], + ['intentIqId', 'intentIqId', 'cookie'], + ['zeotapIdPlus', 'IDP', 'cookie'], + ['haloId', 'haloId', 'cookie'], + ['criteo', 'storage_criteo', 'cookie'], + ['mwOpenLinkId', 'mwol', 'cookie'], + ['tapadId', 'tapad_id', 'cookie'], + ['uid2', 'uid2id', 'cookie'], + ['admixerId', 'admixerId', 'cookie'], + ['deepintentId', 'deepintentId', 'cookie'])); + + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + // verify that the PubCommonId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.pubcid'); + expect(bid.userId.pubcid).to.equal('testpubcid'); + // also check that UnifiedId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.tdid'); + expect(bid.userId.tdid).to.equal('testunifiedid'); + // also check that Id5Id id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.id5id.uid'); + expect(bid.userId.id5id.uid).to.equal('testid5id'); + // check that identityLink id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.idl_env'); + expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); + // also check that britepoolId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.britepoolid'); + expect(bid.userId.britepoolid).to.equal('testbritepoolid'); + // also check that dmdID id was copied to bid + expect(bid).to.have.deep.nested.property('userId.dmdId'); + expect(bid.userId.dmdId).to.equal('testdmdId'); + // also check that netId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.netId'); + expect(bid.userId.netId).to.equal('testnetId'); + // also check that intentIqId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.intentIqId'); + expect(bid.userId.intentIqId).to.equal('testintentIqId'); + // also check that zeotapIdPlus id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal('zeotapId'); + // also check that haloId id was copied to bid + expect(bid).to.have.deep.nested.property('userId.haloId'); + expect(bid.userId.haloId).to.equal('testHaloId'); + // also check that criteo id was copied to bid + expect(bid).to.have.deep.nested.property('userId.criteoId'); + expect(bid.userId.criteoId).to.equal('test_bidid'); + // also check that mwOpenLink id was copied to bid + expect(bid).to.have.deep.nested.property('userId.mwOpenLinkId'); + expect(bid.userId.mwOpenLinkId).to.equal('XX-YY-ZZ-123'); + expect(bid.userId.uid2).to.deep.equal({ + id: 'Sample_AD_Token' + }); + // also check that criteo id was copied to bid + expect(bid).to.have.deep.nested.property('userId.admixerId'); + expect(bid.userId.admixerId).to.equal('testadmixerId'); - expect(server.requests).to.be.empty; - events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); - expect(server.requests[0].url).to.equal('/any/unifiedid/url'); - }); + // also check that deepintentId was copied to bid + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userId.deepintentId).to.equal('testdeepintentId'); - it('unifiedid callback with partner', function () { - let adUnits = [getAdUnitMock()]; - let innerAdUnits; - let customCfg = getConfigMock(['unifiedId', 'unifiedid', 'cookie']); - addConfig(customCfg, 'params', {partner: 'rubicon'}); + expect(bid.userIdAsEids.length).to.equal(15); + }); + }); + coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('id5id', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('storage_criteo', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('deepintentId', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule]); - init(config); - config.setConfig(customCfg); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, dmdId, intentIqId, zeotapIdPlus, criteo, netId, haloId, UID 2.0, admixerId and mwOpenLinkId have their modules added before and after init', function (done) { + coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('dmdId', 'testdmdId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('storage_criteo', JSON.stringify({'criteoId': 'test_bidid'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); + + setSubmoduleRegistry([]); + + // attaching before init + attachIdSystem(sharedIdSystemSubmodule); - expect(server.requests).to.be.empty; - events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); - expect(server.requests[0].url).to.equal('https://match.adsrvr.org/track/rid?ttd_pid=rubicon&fmt=json'); - }); + init(config); - it('verify sharedid callback via pubcid when enabled', function () { - let adUnits = [getAdUnitMock()]; - let innerAdUnits; - let customCfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); - customCfg = addConfig(customCfg, 'params', {pixelUrl: '/any/pubcid/url', enableSharedId: true}); + // attaching after init + attachIdSystem(unifiedIdSubmodule); + attachIdSystem(id5IdSubmodule); + attachIdSystem(identityLinkSubmodule); + attachIdSystem(britepoolIdSubmodule); + attachIdSystem(netIdSubmodule); + attachIdSystem(intentIqIdSubmodule); + attachIdSystem(zeotapIdPlusSubmodule); + attachIdSystem(haloIdSubmodule); + attachIdSystem(dmdIdSubmodule); + attachIdSystem(criteoIdSubmodule); + attachIdSystem(mwOpenLinkIdSubModule); + attachIdSystem(tapadIdSubmodule); + attachIdSystem(uid2IdSubmodule); + attachIdSystem(admixerIdSubmodule); + attachIdSystem(deepintentDpesSubmodule); + + config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], + ['unifiedId', 'unifiedid', 'cookie'], + ['id5Id', 'id5id', 'cookie'], + ['identityLink', 'idl_env', 'cookie'], + ['britepoolId', 'britepoolid', 'cookie'], + ['netId', 'netId', 'cookie'], + ['intentIqId', 'intentIqId', 'cookie'], + ['zeotapIdPlus', 'IDP', 'cookie'], + ['haloId', 'haloId', 'cookie'], + ['dmdId', 'dmdId', 'cookie'], + ['criteo', 'storage_criteo', 'cookie'], + ['mwOpenLinkId', 'mwol', 'cookie'], + ['tapadId', 'tapad_id', 'cookie'], + ['uid2', 'uid2id', 'cookie'], + ['admixerId', 'admixerId', 'cookie'], + ['deepintentId', 'deepintentId', 'cookie'])); + + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + // verify that the PubCommonId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.pubcid'); + expect(bid.userId.pubcid).to.equal('testpubcid'); + // also check that UnifiedId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.tdid'); + expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations'); + // also check that Id5Id id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.id5id.uid'); + expect(bid.userId.id5id.uid).to.equal('testid5id'); + // also check that identityLink id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.idl_env'); + expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); + // also check that britepoolId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.britepoolid'); + expect(bid.userId.britepoolid).to.equal('testbritepoolid'); + // also check that britepoolId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.netId'); + expect(bid.userId.netId).to.equal('testnetId'); + // also check that intentIqId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.intentIqId'); + expect(bid.userId.intentIqId).to.equal('testintentIqId'); + + // also check that zeotapIdPlus id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal('zeotapId'); + // also check that haloId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.haloId'); + expect(bid.userId.haloId).to.equal('testHaloId'); + // also check that dmdId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.dmdId'); + expect(bid.userId.dmdId).to.equal('testdmdId'); + + // also check that criteo id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.criteoId'); + expect(bid.userId.criteoId).to.equal('test_bidid'); + + // also check that mwOpenLink id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.mwOpenLinkId'); + expect(bid.userId.mwOpenLinkId).to.equal('XX-YY-ZZ-123') + expect(bid.userId.uid2).to.deep.equal({ + id: 'Sample_AD_Token' + }); + + // also check that admixerId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.admixerId'); + expect(bid.userId.admixerId).to.equal('testadmixerId'); + // also check that deepintentId was copied to bid + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userId.deepintentId).to.equal('testdeepintentId'); - server.respondWith('https://id.sharedid.org/id', function(xhr) { - xhr.respond(200, {}, '{"sharedId":"testsharedid"}'); + expect(bid.userIdAsEids.length).to.equal(15); + }); + }); + coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('id5id', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('storage_criteo', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); }); - server.respondImmediately = true; - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - config.setConfig(customCfg); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + it('test hook from UID2 cookie', function (done) { + coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); - expect(utils.triggerPixel.called).to.be.false; - events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); - expect(utils.triggerPixel.getCall(0).args[0]).to.include('/any/pubcid/url'); + setSubmoduleRegistry([uid2IdSubmodule]); + init(config); + config.setConfig(getConfigMock(['uid2', 'uid2id', 'cookie'])); + + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.uid2'); + expect(bid.userId.uid2).to.have.deep.nested.property('id'); + expect(bid.userId.uid2).to.deep.equal({ + id: 'Sample_AD_Token' + }); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'uidapi.com', + uids: [{ + id: 'Sample_AD_Token', + atype: 3, + }] + }); + }); + }); + coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); + it('should add new id system ', function (done) { + coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('dmdId', 'testdmdId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('admixerId', 'testadmixerId', new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('deepintentId', 'testdeepintentId', new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('__uid2_advertising_token', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); + + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule]); + init(config); - expect(server.requests[0].url).to.equal('https://id.sharedid.org/id'); - expect(coreStorage.getCookie('pubcid_sharedid')).to.equal('testsharedid'); - }); + config.setConfig({ + userSync: { + syncDelay: 0, + userIds: [{ + name: 'pubCommonId', storage: {name: 'pubcid', type: 'cookie'} + }, { + name: 'unifiedId', storage: {name: 'unifiedid', type: 'cookie'} + }, { + name: 'id5Id', storage: {name: 'id5id', type: 'cookie'} + }, { + name: 'identityLink', storage: {name: 'idl_env', type: 'cookie'} + }, { + name: 'britepoolId', storage: {name: 'britepoolid', type: 'cookie'} + }, { + name: 'dmdId', storage: {name: 'dmdId', type: 'cookie'} + }, { + name: 'netId', storage: {name: 'netId', type: 'cookie'} + }, { + name: 'intentIqId', storage: {name: 'intentIqId', type: 'cookie'} + }, { + name: 'zeotapIdPlus' + }, { + name: 'haloId', storage: {name: 'haloId', type: 'cookie'} + }, { + name: 'admixerId', storage: {name: 'admixerId', type: 'cookie'} + }, { + name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} + }, { + name: 'uid2' + }, { + name: 'deepintentId', storage: {name: 'deepintentId', type: 'cookie'} + }] + } + }); - it('verify no sharedid callback via pubcid when disabled', function () { - let adUnits = [getAdUnitMock()]; - let innerAdUnits; - let customCfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); - customCfg = addConfig(customCfg, 'params', {pixelUrl: '/any/pubcid/url'}); + // Add new submodule named 'mockId' + attachIdSystem({ + name: 'mockId', + decode: function (value) { + return { + 'mid': value['MOCKID'] + }; + }, + getId: function (config, storedId) { + if (storedId) return {}; + return {id: {'MOCKID': '1234'}}; + } + }); - server.respondWith('https://id.sharedid.org/id', function(xhr) { - xhr.respond(200, {}, '{"sharedId":"testsharedid"}'); - }); - server.respondImmediately = true; + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + // check PubCommonId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.pubcid'); + expect(bid.userId.pubcid).to.equal('testpubcid'); + // check UnifiedId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.tdid'); + expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations'); + // also check that Id5Id id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.id5id.uid'); + expect(bid.userId.id5id.uid).to.equal('testid5id'); + // also check that identityLink id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.idl_env'); + expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf'); + // also check that britepoolId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.britepoolid'); + expect(bid.userId.britepoolid).to.equal('testbritepoolid'); + // also check that dmdId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.dmdId'); + expect(bid.userId.dmdId).to.equal('testdmdId'); + // check MockId data was copied to bid + expect(bid).to.have.deep.nested.property('userId.netId'); + expect(bid.userId.netId).to.equal('testnetId'); + // check MockId data was copied to bid + expect(bid).to.have.deep.nested.property('userId.mid'); + expect(bid.userId.mid).to.equal('1234'); + // also check that intentIqId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.intentIqId'); + expect(bid.userId.intentIqId).to.equal('testintentIqId'); + // also check that zeotapIdPlus id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal('zeotapId'); + // also check that haloId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.haloId'); + expect(bid.userId.haloId).to.equal('testHaloId'); + expect(bid.userId.uid2).to.deep.equal({ + id: 'Sample_AD_Token' + }); - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - config.setConfig(customCfg); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + // also check that admixerId id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.admixerId'); + expect(bid.userId.admixerId).to.equal('testadmixerId'); - expect(utils.triggerPixel.called).to.be.false; - events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); - expect(utils.triggerPixel.getCall(0).args[0]).to.include('/any/pubcid/url'); + // also check that deepintentId was copied to bid + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userId.deepintentId).to.equal('testdeepintentId'); - expect(server.requests).to.have.lengthOf(0); - expect(coreStorage.getCookie('pubcid_sharedid')).to.be.null; + expect(bid.userIdAsEids.length).to.equal(13); + }); + }); + coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('id5id', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); }); - it('verify sharedid optout via pubcid when enabled', function () { - let adUnits = [getAdUnitMock()]; - let innerAdUnits; - let customCfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); - customCfg = addConfig(customCfg, 'params', {pixelUrl: '/any/pubcid/url', enableSharedId: true}); - coreStorage.setCookie('pubcid_sharedid', 'testsharedid', (new Date(Date.now() + 5000).toUTCString())); + describe('callbacks at the end of auction', function () { + beforeEach(function () { + sinon.stub(events, 'getEvents').returns([]); + sinon.stub(utils, 'triggerPixel'); + coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('_parrable_eid', '', EXPIRED_COOKIE_DATE); + }); - server.respondWith('https://id.sharedid.org/id', function(xhr) { - xhr.respond(200, {}, '{"sharedId":"00000000000000000000000000"}'); + afterEach(function () { + events.getEvents.restore(); + utils.triggerPixel.restore(); + coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('_parrable_eid', '', EXPIRED_COOKIE_DATE); + resetConsentData(); + delete window.__tcfapi; }); - server.respondImmediately = true; - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - config.setConfig(customCfg); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + it('pubcid callback with url', function () { + let adUnits = [getAdUnitMock()]; + let innerAdUnits; + let customCfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); + customCfg = addConfig(customCfg, 'params', {pixelUrl: '/any/pubcid/url'}); - expect(utils.triggerPixel.called).to.be.false; - events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); - expect(utils.triggerPixel.getCall(0).args[0]).to.include('/any/pubcid/url'); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule]); + init(config); + config.setConfig(customCfg); + requestBidsHook((config) => { + innerAdUnits = config.adUnits + }, {adUnits}); - expect(server.requests[0].url).to.equal('https://id.sharedid.org/id'); - expect(coreStorage.getCookie('pubcid_sharedid')).to.be.null; - }); + expect(utils.triggerPixel.called).to.be.false; + events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); + expect(utils.triggerPixel.getCall(0).args[0]).to.include('/any/pubcid/url'); + }); - it('verify sharedid called with consent data when gdpr applies', function () { - let adUnits = [getAdUnitMock()]; - let customCfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); - let consentConfig = { - cmpApi: 'iab', - timeout: 7500, - allowAuctionWithoutConsent: false - }; - customCfg = addConfig(customCfg, 'params', {pixelUrl: '/any/pubcid/url', enableSharedId: true}); - - server.respondWith('https://id.sharedid.org/id?gdpr=1&gdpr_consent=abc12345234', function(xhr) { - xhr.respond(200, {}, '{"sharedId":"testsharedid"}'); - }); - server.respondImmediately = true; - - let testConsentData = { - tcString: 'abc12345234', - gdprApplies: true, - purposeOneTreatment: false, - eventStatus: 'tcloaded', - vendor: {consents: {887: true}}, - purpose: { - consents: { - 1: true - } - } - }; + it('unifiedid callback with url', function () { + let adUnits = [getAdUnitMock()]; + let innerAdUnits; + let customCfg = getConfigMock(['unifiedId', 'unifiedid', 'cookie']); + addConfig(customCfg, 'params', {url: '/any/unifiedid/url'}); - window.__tcfapi = function () { }; - sinon.stub(window, '__tcfapi').callsFake((...args) => { - args[2](testConsentData, true); - }); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule]); + init(config); + config.setConfig(customCfg); + requestBidsHook((config) => { + innerAdUnits = config.adUnits + }, {adUnits}); - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - config.setConfig(customCfg); - setConsentConfig(consentConfig); + expect(server.requests).to.be.empty; + events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); + expect(server.requests[0].url).to.equal('/any/unifiedid/url'); + }); - consentManagementRequestBidsHook(() => { - }, {}); - requestBidsHook((config) => { - }, {adUnits}); + it('unifiedid callback with partner', function () { + let adUnits = [getAdUnitMock()]; + let innerAdUnits; + let customCfg = getConfigMock(['unifiedId', 'unifiedid', 'cookie']); + addConfig(customCfg, 'params', {partner: 'rubicon'}); - expect(utils.triggerPixel.called).to.be.false; - events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); - expect(utils.triggerPixel.getCall(0).args[0]).to.include('/any/pubcid/url'); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule]); + init(config); + config.setConfig(customCfg); + requestBidsHook((config) => { + innerAdUnits = config.adUnits + }, {adUnits}); - expect(server.requests[0].url).to.equal('https://id.sharedid.org/id?gdpr=1&gdpr_consent=abc12345234'); - expect(coreStorage.getCookie('pubcid_sharedid')).to.equal('testsharedid'); + expect(server.requests).to.be.empty; + events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); + expect(server.requests[0].url).to.equal('https://match.adsrvr.org/track/rid?ttd_pid=rubicon&fmt=json'); + }); }); - }); - describe('Set cookie behavior', function () { - let coreStorageSpy; - beforeEach(function () { - coreStorageSpy = sinon.spy(coreStorage, 'setCookie'); - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - }); - afterEach(function () { - coreStorageSpy.restore(); - }); - it('should allow submodules to override the domain', function () { - const submodule = { - submodule: { - domainOverride: function () { - return 'foo.com' - } - }, - config: { - storage: { - type: 'cookie' + describe('Set cookie behavior', function () { + let coreStorageSpy; + beforeEach(function () { + coreStorageSpy = sinon.spy(coreStorage, 'setCookie'); + setSubmoduleRegistry([sharedIdSystemSubmodule]); + init(config); + }); + afterEach(function () { + coreStorageSpy.restore(); + }); + it('should allow submodules to override the domain', function () { + const submodule = { + submodule: { + domainOverride: function () { + return 'foo.com' + } + }, + config: { + storage: { + type: 'cookie' + } } } - } - setStoredValue(submodule, 'bar'); - expect(coreStorage.setCookie.getCall(0).args[4]).to.equal('foo.com'); - }); + setStoredValue(submodule, 'bar'); + expect(coreStorage.setCookie.getCall(0).args[4]).to.equal('foo.com'); + }); - it('should pass null for domain if submodule does not override the domain', function () { - const submodule = { - submodule: {}, - config: { - storage: { - type: 'cookie' + it('should pass null for domain if submodule does not override the domain', function () { + const submodule = { + submodule: {}, + config: { + storage: { + type: 'cookie' + } } } - } - setStoredValue(submodule, 'bar'); - expect(coreStorage.setCookie.getCall(0).args[4]).to.equal(null); + setStoredValue(submodule, 'bar'); + expect(coreStorage.setCookie.getCall(0).args[4]).to.equal(null); + }); }); - }); - describe('Consent changes determine getId refreshes', function () { - let expStr; - let adUnits; - - const mockIdCookieName = 'MOCKID'; - let mockGetId = sinon.stub(); - let mockDecode = sinon.stub(); - let mockExtendId = sinon.stub(); - const mockIdSystem = { - name: 'mockId', - getId: mockGetId, - decode: mockDecode, - extendId: mockExtendId - }; - const userIdConfig = { - userSync: { - userIds: [{ - name: 'mockId', - storage: { - name: 'MOCKID', - type: 'cookie', - refreshInSeconds: 30 - } - }], - auctionDelay: 5 - } - }; + describe('Consent changes determine getId refreshes', function () { + let expStr; + let adUnits; - let cmpStub; - let testConsentData; - const consentConfig = { - cmpApi: 'iab', - timeout: 7500, - allowAuctionWithoutConsent: false - }; + const mockIdCookieName = 'MOCKID'; + let mockGetId = sinon.stub(); + let mockDecode = sinon.stub(); + let mockExtendId = sinon.stub(); + const mockIdSystem = { + name: 'mockId', + getId: mockGetId, + decode: mockDecode, + extendId: mockExtendId + }; + const userIdConfig = { + userSync: { + userIds: [{ + name: 'mockId', + storage: { + name: 'MOCKID', + type: 'cookie', + refreshInSeconds: 30 + } + }], + auctionDelay: 5 + } + }; - const sharedBeforeFunction = function () { - // clear cookies - expStr = (new Date(Date.now() + 25000).toUTCString()); - coreStorage.setCookie(mockIdCookieName, '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie(`${mockIdCookieName}_last`, '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie(CONSENT_LOCAL_STORAGE_NAME, '', EXPIRED_COOKIE_DATE); + let cmpStub; + let testConsentData; + const consentConfig = { + cmpApi: 'iab', + timeout: 7500, + allowAuctionWithoutConsent: false + }; - // init - adUnits = [getAdUnitMock()]; - init(config); + const sharedBeforeFunction = function () { + // clear cookies + expStr = (new Date(Date.now() + 25000).toUTCString()); + coreStorage.setCookie(mockIdCookieName, '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie(`${mockIdCookieName}_last`, '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie(CONSENT_LOCAL_STORAGE_NAME, '', EXPIRED_COOKIE_DATE); - // init id system - attachIdSystem(mockIdSystem); - config.setConfig(userIdConfig); - } - const sharedAfterFunction = function () { - config.resetConfig(); - mockGetId.reset(); - mockDecode.reset(); - mockExtendId.reset(); - cmpStub.restore(); - resetConsentData(); - delete window.__cmp; - delete window.__tcfapi; - }; + // init + adUnits = [getAdUnitMock()]; + init(config); - describe('TCF v1', function () { - testConsentData = { - gdprApplies: true, - consentData: 'xyz', - apiVersion: 1 + // init id system + attachIdSystem(mockIdSystem); + config.setConfig(userIdConfig); + } + const sharedAfterFunction = function () { + config.resetConfig(); + mockGetId.reset(); + mockDecode.reset(); + mockExtendId.reset(); + cmpStub.restore(); + resetConsentData(); + delete window.__cmp; + delete window.__tcfapi; }; - beforeEach(function () { - sharedBeforeFunction(); - - // init v1 consent management - window.__cmp = function () { + describe('TCF v1', function () { + testConsentData = { + gdprApplies: true, + consentData: 'xyz', + apiVersion: 1 }; - delete window.__tcfapi; - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); - }); - setConsentConfig(consentConfig); - }); - afterEach(function () { - sharedAfterFunction(); - }); + beforeEach(function () { + sharedBeforeFunction(); - it('calls getId if no stored consent data and refresh is not needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); + // init v1 consent management + window.__cmp = function () { + }; + delete window.__tcfapi; + cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { + args[2](testConsentData); + }); + setConsentConfig(consentConfig); + }); - let innerAdUnits; - consentManagementRequestBidsHook(() => { - }, {}); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + afterEach(function () { + sharedAfterFunction(); + }); - sinon.assert.calledOnce(mockGetId); - sinon.assert.calledOnce(mockDecode); - sinon.assert.notCalled(mockExtendId); - }); + it('calls getId if no stored consent data and refresh is not needed', function () { + coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); + coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); - it('calls getId if no stored consent data but refresh is needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 60 * 1000).toUTCString()), expStr); + let innerAdUnits; + consentManagementRequestBidsHook(() => { + }, {}); + requestBidsHook((config) => { + innerAdUnits = config.adUnits + }, {adUnits}); - let innerAdUnits; - consentManagementRequestBidsHook(() => { - }, {}); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + sinon.assert.calledOnce(mockGetId); + sinon.assert.calledOnce(mockDecode); + sinon.assert.notCalled(mockExtendId); + }); - sinon.assert.calledOnce(mockGetId); - sinon.assert.calledOnce(mockDecode); - sinon.assert.notCalled(mockExtendId); - }); + it('calls getId if no stored consent data but refresh is needed', function () { + coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); + coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 60 * 1000).toUTCString()), expStr); - it('calls getId if empty stored consent and refresh not needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); + let innerAdUnits; + consentManagementRequestBidsHook(() => { + }, {}); + requestBidsHook((config) => { + innerAdUnits = config.adUnits + }, {adUnits}); - setStoredConsentData(); + sinon.assert.calledOnce(mockGetId); + sinon.assert.calledOnce(mockDecode); + sinon.assert.notCalled(mockExtendId); + }); - let innerAdUnits; - consentManagementRequestBidsHook(() => { - }, {}); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + it('calls getId if empty stored consent and refresh not needed', function () { + coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); + coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); - sinon.assert.calledOnce(mockGetId); - sinon.assert.calledOnce(mockDecode); - sinon.assert.notCalled(mockExtendId); - }); + setStoredConsentData(); - it('calls getId if stored consent does not match current consent and refresh not needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); + let innerAdUnits; + consentManagementRequestBidsHook(() => { + }, {}); + requestBidsHook((config) => { + innerAdUnits = config.adUnits + }, {adUnits}); - setStoredConsentData({ - gdprApplies: testConsentData.gdprApplies, - consentString: 'abc', - apiVersion: testConsentData.apiVersion + sinon.assert.calledOnce(mockGetId); + sinon.assert.calledOnce(mockDecode); + sinon.assert.notCalled(mockExtendId); }); - let innerAdUnits; - consentManagementRequestBidsHook(() => { - }, {}); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + it('calls getId if stored consent does not match current consent and refresh not needed', function () { + coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); + coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); - sinon.assert.calledOnce(mockGetId); - sinon.assert.calledOnce(mockDecode); - sinon.assert.notCalled(mockExtendId); - }); + setStoredConsentData({ + gdprApplies: testConsentData.gdprApplies, + consentString: 'abc', + apiVersion: testConsentData.apiVersion + }); - it('does not call getId if stored consent matches current consent and refresh not needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); + let innerAdUnits; + consentManagementRequestBidsHook(() => { + }, {}); + requestBidsHook((config) => { + innerAdUnits = config.adUnits + }, {adUnits}); - setStoredConsentData({ - gdprApplies: testConsentData.gdprApplies, - consentString: testConsentData.consentData, - apiVersion: testConsentData.apiVersion + sinon.assert.calledOnce(mockGetId); + sinon.assert.calledOnce(mockDecode); + sinon.assert.notCalled(mockExtendId); }); - let innerAdUnits; - consentManagementRequestBidsHook(() => { - }, {}); - requestBidsHook((config) => { - innerAdUnits = config.adUnits - }, {adUnits}); + it('does not call getId if stored consent matches current consent and refresh not needed', function () { + coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); + coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); - sinon.assert.notCalled(mockGetId); - sinon.assert.calledOnce(mockDecode); - sinon.assert.calledOnce(mockExtendId); - }); - }); + setStoredConsentData({ + gdprApplies: testConsentData.gdprApplies, + consentString: testConsentData.consentData, + apiVersion: testConsentData.apiVersion + }); - describe('findRootDomain', function () { - let sandbox; + let innerAdUnits; + consentManagementRequestBidsHook(() => { + }, {}); + requestBidsHook((config) => { + innerAdUnits = config.adUnits + }, {adUnits}); - beforeEach(function () { - setSubmoduleRegistry([pubCommonIdSubmodule]); - init(config); - config.setConfig({ - userSync: { - syncDelay: 0, - userIds: [ - { - name: 'pubCommonId', - value: { pubcid: '11111' }, - }, - ], - }, + sinon.assert.notCalled(mockGetId); + sinon.assert.calledOnce(mockDecode); + sinon.assert.calledOnce(mockExtendId); }); - sandbox = sinon.createSandbox(); - sandbox - .stub(coreStorage, 'getCookie') - .onFirstCall() - .returns(null) // .co.uk - .onSecondCall() - .returns('writeable'); // realdomain.co.uk; }); - afterEach(function () { - sandbox.restore(); - }); + describe('findRootDomain', function () { + let sandbox; - it('should just find the root domain', function () { - var domain = findRootDomain('sub.realdomain.co.uk'); - expect(domain).to.be.eq('realdomain.co.uk'); - }); + beforeEach(function () { + setSubmoduleRegistry([sharedIdSystemSubmodule]); + init(config); + config.setConfig({ + userSync: { + syncDelay: 0, + userIds: [ + { + name: 'pubCommonId', + value: { pubcid: '11111' }, + }, + ], + }, + }); + sandbox = sinon.createSandbox(); + sandbox + .stub(coreStorage, 'getCookie') + .onFirstCall() + .returns(null) // .co.uk + .onSecondCall() + .returns('writeable'); // realdomain.co.uk; + }); + + afterEach(function () { + sandbox.restore(); + }); - it('should find the full domain when no subdomain is present', function () { - var domain = findRootDomain('realdomain.co.uk'); - expect(domain).to.be.eq('realdomain.co.uk'); + it('should just find the root domain', function () { + var domain = findRootDomain('sub.realdomain.co.uk'); + expect(domain).to.be.eq('realdomain.co.uk'); + }); + + it('should find the full domain when no subdomain is present', function () { + var domain = findRootDomain('realdomain.co.uk'); + expect(domain).to.be.eq('realdomain.co.uk'); + }); }); }); - }); + }) }); diff --git a/test/spec/modules/vdoaiBidAdapter_spec.js b/test/spec/modules/vdoaiBidAdapter_spec.js deleted file mode 100644 index d78a5ce04f6..00000000000 --- a/test/spec/modules/vdoaiBidAdapter_spec.js +++ /dev/null @@ -1,141 +0,0 @@ -import {assert, expect} from 'chai'; -import {spec} from 'modules/vdoaiBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -const ENDPOINT_URL = 'https://prebid.vdo.ai/auction'; - -describe('vdoaiBidAdapter', function () { - const adapter = newBidder(spec); - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'vdoai', - 'params': { - placementId: 'testPlacementId' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '1234asdf1234', - 'bidderRequestId': '1234asdf1234asdf', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' - }; - it('should return true where required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'vdoai', - 'params': { - placementId: 'testPlacementId' - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - 'mediaTypes': 'banner' - } - ]; - - let bidderRequests = { - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'https://example.com', - 'stack': ['https://example.com'] - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequests); - it('sends bid request to our endpoint via POST', function () { - expect(request[0].method).to.equal('POST'); - }); - it('attaches source and version to endpoint URL as query params', function () { - expect(request[0].url).to.equal(ENDPOINT_URL); - }); - }); - - describe('interpretResponse', function () { - let bidRequest = [ - { - 'method': 'POST', - 'url': ENDPOINT_URL, - 'data': { - 'placementId': 'testPlacementId', - 'width': '300', - 'height': '200', - 'bidId': 'bidId123', - 'referer': 'www.example.com' - } - - } - ]; - let serverResponse = { - body: { - 'vdoCreative': '

I am an ad

', - 'price': 4.2, - 'adid': '12345asdfg', - 'currency': 'EUR', - 'statusMessage': 'Bid available', - 'requestId': 'bidId123', - 'width': 300, - 'height': 250, - 'netRevenue': true - } - }; - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': 'bidId123', - 'cpm': 4.2, - 'width': 300, - 'height': 250, - 'creativeId': '12345asdfg', - 'currency': 'EUR', - 'netRevenue': true, - 'ttl': 3000, - 'ad': '

I am an ad

' - }]; - let result = spec.interpretResponse(serverResponse, bidRequest[0]); - expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); - }); - - it('handles instream video responses', function () { - let serverResponse = { - body: { - 'vdoCreative': '', - 'price': 4.2, - 'adid': '12345asdfg', - 'currency': 'EUR', - 'statusMessage': 'Bid available', - 'requestId': 'bidId123', - 'width': 300, - 'height': 250, - 'netRevenue': true, - 'mediaType': 'video' - } - }; - let bidRequest = [ - { - 'method': 'POST', - 'url': ENDPOINT_URL, - 'data': { - 'placementId': 'testPlacementId', - 'width': '300', - 'height': '200', - 'bidId': 'bidId123', - 'referer': 'www.example.com', - 'mediaType': 'video' - } - } - ]; - - let result = spec.interpretResponse(serverResponse, bidRequest[0]); - expect(result[0]).to.have.property('vastXml'); - expect(result[0]).to.have.property('mediaType', 'video'); - }); - }); -}); diff --git a/test/spec/modules/viBidAdapter_spec.js b/test/spec/modules/viBidAdapter_spec.js deleted file mode 100644 index e1a88c004bb..00000000000 --- a/test/spec/modules/viBidAdapter_spec.js +++ /dev/null @@ -1,911 +0,0 @@ -import { - ratioToPercentageCeil, - merge, - getDocumentHeight, - getOffset, - getWindowParents, - getRectCuts, - getTopmostReachableWindow, - topDocumentIsReachable, - isInsideIframe, - isInsideSafeframe, - getIframeType, - getFrameElements, - getElementCuts, - getInViewRatio, - getMayBecomeVisible, - getInViewPercentage, - getInViewRatioInsideTopFrame, - getOffsetTopDocument, - getOffsetTopDocumentPercentage, - getOffsetToView, - getOffsetToViewPercentage, - area, - get, - getViewabilityDescription, - mergeArrays, - documentFocus -} from 'modules/viBidAdapter.js'; - -describe('ratioToPercentageCeil', () => { - it('1 converts to percentage', () => - expect(ratioToPercentageCeil(0.01)).to.equal(1)); - it('2 converts to percentage', () => - expect(ratioToPercentageCeil(0.00000000001)).to.equal(1)); - it('3 converts to percentage', () => - expect(ratioToPercentageCeil(0.5)).to.equal(50)); - it('4 converts to percentage', () => - expect(ratioToPercentageCeil(1)).to.equal(100)); - it('5 converts to percentage', () => - expect(ratioToPercentageCeil(0.99)).to.equal(99)); - it('6 converts to percentage', () => - expect(ratioToPercentageCeil(0.990000000000001)).to.equal(100)); -}); - -describe('merge', () => { - it('merges two objects', () => { - expect( - merge({ a: 1, b: 2, d: 0 }, { a: 2, b: 2, c: 3 }, (a, b) => a + b) - ).to.deep.equal({ a: 3, b: 4, c: 3, d: 0 }); - }); -}); - -describe('getDocumentHeight', () => { - [ - { - curDocument: { - body: { - clientHeight: 0, - offsetHeight: 0, - scrollHeight: 0 - }, - documentElement: { - clientHeight: 0, - offsetHeight: 0, - scrollHeight: 0 - } - }, - expected: 0 - }, - { - curDocument: { - body: { - clientHeight: 0, - offsetHeight: 13, - scrollHeight: 24 - }, - documentElement: { - clientHeight: 0, - offsetHeight: 0, - scrollHeight: 0 - } - }, - expected: 24 - }, - { - curDocument: { - body: { - clientHeight: 0, - offsetHeight: 13, - scrollHeight: 24 - }, - documentElement: { - clientHeight: 100, - offsetHeight: 50, - scrollHeight: 30 - } - }, - expected: 100 - } - ].forEach(({ curDocument, expected }) => - expect(getDocumentHeight(curDocument)).to.be.equal(expected) - ); -}); - -describe('getOffset', () => { - [ - { - element: { - ownerDocument: { - defaultView: { - pageXOffset: 0, - pageYOffset: 0 - } - }, - getBoundingClientRect: () => ({ - top: 0, - right: 0, - bottom: 0, - left: 0 - }) - }, - expected: { - top: 0, - right: 0, - bottom: 0, - left: 0 - } - } - ].forEach(({ description, element, expected }, i) => - it( - 'returns element offsets from the document edges (including scroll): ' + - i, - () => expect(getOffset(element)).to.be.deep.equal(expected) - ) - ); - it('Throws when there is no window', () => - expect( - getOffset.bind(null, { - ownerDocument: { - defaultView: null - }, - getBoundingClientRect: () => ({ - top: 0, - right: 0, - bottom: 0, - left: 0 - }) - }) - ).to.throw()); -}); - -describe('getWindowParents', () => { - const win = {}; - win.top = win; - win.parent = win; - const win1 = { top: win, parent: win }; - const win2 = { top: win, parent: win1 }; - const win3 = { top: win, parent: win2 }; - - it('get parents up to the top', () => - expect(getWindowParents(win3)).to.be.deep.equal([win2, win1, win])); -}); - -describe('getTopmostReachableWindow', () => { - const win = {}; - win.top = win; - win.parent = win; - const win1 = { top: win, parent: win }; - const win2 = { top: win, parent: win1 }; - const win3 = { top: win, parent: win2 }; - - it('get parents up to the top', () => - expect(getTopmostReachableWindow(win3)).to.be.equal(win)); -}); - -const topWindow = { document, frameElement: 0 }; -topWindow.top = topWindow; -topWindow.parent = topWindow; -const topFrameElement = { - ownerDocument: { - defaultView: topWindow - } -}; -const frameWindow1 = { - top: topWindow, - parent: topWindow, - frameElement: topFrameElement -}; -const frameElement1 = { - ownerDocument: { - defaultView: frameWindow1 - } -}; -const frameWindow2 = { - top: topWindow, - parent: frameWindow1, - frameElement: frameElement1 -}; -const frameElement2 = { - ownerDocument: { - defaultView: frameWindow2 - } -}; -const frameWindow3 = { - top: topWindow, - parent: frameWindow2, - frameElement: frameElement2 -}; - -describe('topDocumentIsReachable', () => { - it('returns true if it no inside iframe', () => - expect(topDocumentIsReachable(topWindow)).to.be.true); - it('returns true if it can access top document', () => - expect(topDocumentIsReachable(frameWindow3)).to.be.true); -}); - -describe('isInsideIframe', () => { - it('returns true if window !== window.top', () => - expect(isInsideIframe(topWindow)).to.be.false); - it('returns true if window !== window.top', () => - expect(isInsideIframe(frameWindow1)).to.be.true); -}); - -const safeframeWindow = { $sf: {} }; - -describe('isInsideSafeframe', () => { - it('returns true if top window is not reachable and window.$sf is defined', () => - expect(isInsideSafeframe(safeframeWindow)).to.be.true); -}); - -const hostileFrameWindow = {}; - -describe('getIframeType', () => { - it('returns undefined when is not inside iframe', () => - expect(getIframeType(topWindow)).to.be.undefined); - it("returns 'safeframe' when inside sf", () => - expect(getIframeType(safeframeWindow)).to.be.equal('safeframe')); - it("returns 'friendly' when inside friendly iframe and can reach top window", () => - expect(getIframeType(frameWindow3)).to.be.equal('friendly')); - it("returns 'nonfriendly' when cannot get top window", () => - expect(getIframeType(hostileFrameWindow)).to.be.equal('nonfriendly')); -}); - -describe('getFrameElements', () => { - it('it returns a list iframe elements up to the top, topmost goes first', () => { - expect(getFrameElements(frameWindow3)).to.be.deep.equal([ - topFrameElement, - frameElement1, - frameElement2 - ]); - }); -}); - -describe('area', () => { - it('calculates area', () => expect(area(10, 10)).to.be.equal(100)); - it('calculates area', () => - expect( - area(10, 10, { top: -2, left: -2, bottom: 0, right: 0 }) - ).to.be.equal(64)); -}); - -describe('getElementCuts', () => { - it('returns element cuts', () => - expect( - getElementCuts({ - getBoundingClientRect() { - return { - top: 0, - right: 200, - bottom: 200, - left: 0 - }; - }, - ownerDocument: { - defaultView: { - innerHeight: 1000, - innerWidth: 1000 - } - } - }) - ).to.be.deep.equal({ - top: 0, - right: 0, - bottom: 0, - left: 0 - })); -}); - -describe('getInViewRatio', () => { - it('returns inViewRatio', () => - expect( - getInViewRatio({ - ownerDocument: { - defaultView: { - innerHeight: 1000, - innerWidth: 1000 - } - }, - offsetWidth: 200, - offsetHeight: 200, - getBoundingClientRect() { - return { - top: 0, - right: 200, - bottom: 200, - left: 0 - }; - } - }) - ).to.be.deep.equal(1)); -}); - -describe('getMayBecomeVisible', () => { - it('returns true if not inside iframe of visible inside the iframe', () => - expect( - getMayBecomeVisible({ - ownerDocument: { - defaultView: { - innerHeight: 1000, - innerWidth: 1000 - } - }, - offsetWidth: 200, - offsetHeight: 200, - getBoundingClientRect() { - return { - top: 0, - right: 200, - bottom: 200, - left: 0 - }; - } - }) - ).to.be.true); -}); - -describe('getInViewPercentage', () => { - it('returns inViewRatioPercentage', () => - expect( - getInViewPercentage({ - ownerDocument: { - defaultView: { - innerHeight: 1000, - innerWidth: 1000 - } - }, - offsetWidth: 200, - offsetHeight: 200, - getBoundingClientRect() { - return { - top: 0, - right: 200, - bottom: 200, - left: 0 - }; - } - }) - ).to.be.deep.equal(100)); -}); - -describe('getInViewRatioInsideTopFrame', () => { - it('returns inViewRatio', () => - expect( - getInViewRatioInsideTopFrame({ - ownerDocument: { - defaultView: { - innerHeight: 1000, - innerWidth: 1000 - } - }, - offsetWidth: 200, - offsetHeight: 200, - getBoundingClientRect() { - return { - top: 0, - right: 200, - bottom: 200, - left: 0 - }; - } - }) - ).to.be.deep.equal(1)); -}); - -describe('getOffsetTopDocument', () => { - it('returns offset relative to the top document', () => - expect( - getOffsetTopDocument({ - ownerDocument: { - defaultView: { - pageXOffset: 0, - pageYOffset: 0 - } - }, - getBoundingClientRect: () => ({ - top: 0, - right: 0, - bottom: 0, - left: 0 - }) - }) - ).to.be.deep.equal({ - top: 0, - right: 0, - bottom: 0, - left: 0 - })); -}); - -describe('getOffsetTopDocumentPercentage', () => { - it('returns offset from the top as a percentage of the page length', () => { - const topWindow = { - pageXOffset: 0, - pageYOffset: 100, - document: { - body: { - clientHeight: 1000 - } - } - }; - topWindow.top = topWindow; - topWindow.parent = topWindow; - expect( - getOffsetTopDocumentPercentage({ - ownerDocument: { - defaultView: topWindow - }, - getBoundingClientRect: () => ({ - top: 100, - right: 0, - bottom: 0, - left: 0 - }) - }) - ).to.be.equal(20); - }); - it('throws when cannot get window', () => - expect(() => - getOffsetTopDocumentPercentage({ - ownerDocument: {} - }) - ).to.throw()); - it("throw when top document isn't reachable", () => { - const topWindow = { ...topWindow, document: null }; - expect(() => - getOffsetTopDocumentPercentage({ - ownerDocument: { - defaultView: { - top: topWindow - } - } - }) - ).to.throw(); - }); -}); - -describe('getOffsetToView', () => { - expect( - getOffsetToView({ - ownerDocument: { - defaultView: { - scrollY: 0, - pageXOffset: 0, - pageYOffset: 0 - } - }, - getBoundingClientRect: () => ({ - top: 0, - right: 0, - bottom: 0, - left: 0 - }) - }) - ).to.be.equal(0); -}); - -describe('getOffsetToView', () => { - expect( - getOffsetToViewPercentage({ - ownerDocument: { - defaultView: { - scrollY: 0, - pageXOffset: 0, - pageYOffset: 0, - document: { - body: { - clientHeight: 1000 - } - } - } - }, - getBoundingClientRect: () => ({ - top: 0, - right: 0, - bottom: 0, - left: 0 - }) - }) - ).to.be.equal(0); -}); - -describe('getCuts without vCuts', () => { - const cases = { - 'completely in view 1': { - top: 0, - bottom: 200, - right: 200, - left: 0, - vw: 300, - vh: 300, - expected: { - top: 0, - right: 0, - bottom: 0, - left: 0 - } - }, - 'completely in view 2': { - top: 100, - bottom: 200, - right: 200, - left: 0, - vw: 300, - vh: 300, - expected: { - top: 0, - right: 0, - bottom: 0, - left: 0 - } - }, - 'half cut from the top': { - top: -200, - bottom: 200, - right: 200, - left: 0, - vw: 300, - vh: 300, - expected: { - top: -200, - right: 0, - bottom: 0, - left: 0 - } - }, - 'half cut from the bottom': { - top: 0, - bottom: 600, - right: 200, - left: 0, - vw: 300, - vh: 300, - expected: { - top: 0, - right: 0, - bottom: -300, - left: 0 - } - }, - 'quarter cut from top and bottom': { - top: -25, - bottom: 75, - right: 200, - left: 0, - vw: 300, - vh: 50, - expected: { - top: -25, - right: 0, - bottom: -25, - left: 0 - } - }, - 'out of view top': { - top: -200, - bottom: -5, - right: 200, - left: 0, - vw: 300, - vh: 200, - expected: { - top: -200, - right: 0, - bottom: 0, - left: 0 - } - }, - 'out of view bottom': { - top: 250, - bottom: 500, - right: 200, - left: 0, - vw: 300, - vh: 200, - expected: { - top: 0, - right: 0, - bottom: -300, - left: 0 - } - }, - 'half cut from left': { - top: 0, - bottom: 200, - left: -200, - right: 200, - vw: 300, - vh: 300, - expected: { - top: 0, - right: 0, - bottom: 0, - left: -200 - } - }, - 'half cut from left and top': { - top: -100, - bottom: 100, - left: -200, - right: 200, - vw: 300, - vh: 300, - expected: { - top: -100, - right: 0, - bottom: 0, - left: -200 - } - }, - 'quarter cut from all sides': { - top: -100, - left: -100, - bottom: 300, - right: 300, - vw: 200, - vh: 200, - expected: { - top: -100, - right: -100, - bottom: -100, - left: -100 - } - } - }; - for (let descr in cases) { - it(descr, () => { - const { expected, vh, vw, ...rect } = cases[descr]; - expect(getRectCuts(rect, vh, vw)).to.deep.equal(expected); - }); - } -}); - -describe('getCuts with vCuts', () => { - const cases = { - 'completely in view 1, half-cut viewport from top': { - top: 0, - right: 200, - bottom: 200, - left: 0, - vw: 200, - vh: 200, - vCuts: { - top: -100, - right: 0, - bottom: 0, - left: 0 - }, - expected: { - top: -100, - right: 0, - bottom: 0, - left: 0 - } - }, - 'completely in view 2, half-cut viewport from bottom': { - top: 100, - bottom: 200, - right: 200, - left: 0, - vw: 300, - vh: 300, - vCuts: { - top: 0, - right: 0, - bottom: -150, - left: 0 - }, - expected: { - top: 0, - right: 0, - bottom: -50, - left: 0 - } - }, - 'half cut from the top, 1/3 viewport cut from the bottom': { - top: -200, - bottom: 200, - right: 200, - left: 0, - vw: 300, - vh: 300, - vCuts: { - top: 0, - right: 0, - bottom: -100, - left: 0 - }, - expected: { - top: -200, - right: 0, - bottom: 0, - left: 0 - } - }, - 'half cut from the bottom': { - top: 0, - bottom: 600, - right: 200, - left: 0, - vw: 300, - vh: 300, - expected: { - top: 0, - right: 0, - bottom: -300, - left: 0 - } - }, - 'quarter cut from top and bottom': { - top: -25, - bottom: 75, - right: 200, - left: 0, - vw: 300, - vh: 50, - expected: { - top: -25, - right: 0, - bottom: -25, - left: 0 - } - }, - 'out of view top': { - top: -200, - bottom: -5, - right: 200, - left: 0, - vw: 300, - vh: 200, - expected: { - top: -200, - right: 0, - bottom: 0, - left: 0 - } - }, - 'out of view bottom': { - top: 250, - bottom: 500, - right: 200, - left: 0, - vw: 300, - vh: 200, - expected: { - top: 0, - right: 0, - bottom: -300, - left: 0 - } - }, - 'half cut from left': { - top: 0, - bottom: 200, - left: -200, - right: 200, - vw: 300, - vh: 300, - expected: { - top: 0, - right: 0, - bottom: 0, - left: -200 - } - }, - 'half cut from left and top': { - top: -100, - bottom: 100, - left: -200, - right: 200, - vw: 300, - vh: 300, - expected: { - top: -100, - right: 0, - bottom: 0, - left: -200 - } - }, - 'quarter cut from all sides': { - top: -100, - left: -100, - bottom: 300, - right: 300, - vw: 200, - vh: 200, - expected: { - top: -100, - right: -100, - bottom: -100, - left: -100 - } - } - }; - for (let descr in cases) { - it(descr, () => { - const { expected, vh, vw, vCuts, ...rect } = cases[descr]; - expect(getRectCuts(rect, vh, vw, vCuts)).to.deep.equal(expected); - }); - } -}); - -describe('get', () => { - it('returns a property in a nested object 1', () => - expect(get(['a'], { a: 1 })).to.equal(1)); - it('returns a property in a nested object 2', () => - expect(get(['a', 'b'], { a: { b: 1 } })).to.equal(1)); - it('returns a property in a nested object 3', () => - expect(get(['a', 'b'], { a: { b: 1 } })).to.equal(1)); - it('returns undefined if property does not exist', () => - expect(get(['a', 'b'], { b: 1 })).to.equal(undefined)); - it('returns undefined if property does not exist', () => - expect(get(['a', 'b'], undefined)).to.equal(undefined)); - it('returns undefined if property does not exist', () => - expect(get(['a', 'b'], 1213)).to.equal(undefined)); - const DEFAULT = -5; - it('returns defaultValue if property does not exist', () => - expect(get(['a', 'b'], { b: 1 }, DEFAULT)).to.equal(DEFAULT)); - it('returns defaultValue if property does not exist', () => - expect(get(['a', 'b'], undefined, DEFAULT)).to.equal(DEFAULT)); - it('returns defaultValue if property does not exist', () => - expect(get(['a', 'b'], 1213, DEFAULT)).to.equal(DEFAULT)); - it('can work with arrays 1', () => expect(get([0, 1], [[1, 2]])).to.equal(2)); - it('can work with arrays 2', () => - expect(get([0, 'a'], [{ a: 42 }])).to.equal(42)); -}); - -describe('getViewabilityDescription', () => { - it('returns error when there is no element', () => { - expect(getViewabilityDescription(null)).to.deep.equal({ - error: 'no element' - }); - }); - it('returns only iframe type for nonfrienly iframe', () => { - expect( - getViewabilityDescription({ - ownerDocument: { - defaultView: {} - } - }) - ).to.deep.equal({ - iframeType: 'nonfriendly' - }); - }); - it('returns only iframe type for safeframe iframe', () => { - expect( - getViewabilityDescription({ - ownerDocument: { - defaultView: { - $sf: true - } - } - }) - ).to.deep.equal({ - iframeType: 'safeframe' - }); - }); -}); - -describe('mergeSizes', () => { - it('merges provides arrays of tuples, leaving only unique', () => { - expect( - mergeArrays(x => x.join(','), [[1, 2], [2, 4]], [[1, 2]]) - ).to.deep.equal([[1, 2], [2, 4]]); - }); - it('merges provides arrays of tuples, leaving only unique', () => { - expect( - mergeArrays( - x => x.join(','), - [[1, 2], [2, 4]], - [[1, 2]], - [[400, 500], [500, 600]] - ) - ).to.deep.equal([[1, 2], [2, 4], [400, 500], [500, 600]]); - }); -}); - -describe('documentFocus', () => { - it('calls hasFocus function if it present, converting boolean to an int 0/1 value, returns undefined otherwise', () => { - expect( - documentFocus({ - hasFocus: () => true - }) - ).to.equal(1); - expect( - documentFocus({ - hasFocus: () => false - }) - ).to.equal(0); - expect(documentFocus({})).to.be.undefined; - }); -}); diff --git a/test/spec/modules/vidazooBidAdapter_spec.js b/test/spec/modules/vidazooBidAdapter_spec.js deleted file mode 100644 index d7f20c434ca..00000000000 --- a/test/spec/modules/vidazooBidAdapter_spec.js +++ /dev/null @@ -1,372 +0,0 @@ -import { expect } from 'chai'; -import { - spec as adapter, - SUPPORTED_ID_SYSTEMS, - createDomain, - hashCode, - extractPID, - extractCID, - extractSubDomain, - getStorageItem, - setStorageItem, - tryParseJSON, - getUniqueDealId, - getNextDealId, - getVidazooSessionId, -} from 'modules/vidazooBidAdapter.js'; -import * as utils from 'src/utils.js'; -import { version } from 'package.json'; -import { useFakeTimers } from 'sinon'; - -const SUB_DOMAIN = 'openrtb'; - -const BID = { - 'bidId': '2d52001cabd527', - 'adUnitCode': 'div-gpt-ad-12345-0', - 'params': { - 'subDomain': SUB_DOMAIN, - 'cId': '59db6b3b4ffaa70004f45cdc', - 'pId': '59ac17c192832d0011283fe3', - 'bidFloor': 0.1, - 'ext': { - 'param1': 'loremipsum', - 'param2': 'dolorsitamet' - } - }, - 'placementCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf', - 'sizes': [[300, 250], [300, 600]], - 'bidderRequestId': '1fdb5ff1b6eaa7', - 'requestId': 'b0777d85-d061-450e-9bc7-260dd54bbb7a' -}; - -const BIDDER_REQUEST = { - 'gdprConsent': { - 'consentString': 'consent_string', - 'gdprApplies': true - }, - 'uspConsent': 'consent_string', - 'refererInfo': { - 'referer': 'https://www.greatsite.com' - } -}; - -const SERVER_RESPONSE = { - body: { - results: [{ - 'ad': '', - 'price': 0.8, - 'creativeId': '12610997325162499419', - 'exp': 30, - 'width': 300, - 'height': 250, - 'cookies': [{ - 'src': 'https://sync.com', - 'type': 'iframe' - }, { - 'src': 'https://sync.com', - 'type': 'img' - }] - }] - } -}; - -const REQUEST = { - data: { - width: 300, - height: 250, - bidId: '2d52001cabd527' - } -}; - -describe('VidazooBidAdapter', function () { - describe('validtae spec', 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'); - }); - - it('exists and is a function', function () { - expect(adapter.getUserSyncs).to.exist.and.to.be.a('function'); - }); - - it('exists and is a string', function () { - expect(adapter.code).to.exist.and.to.be.a('string'); - }); - }); - - describe('validate bid requests', function () { - it('should require cId', function () { - const isValid = adapter.isBidRequestValid({ - params: { - pId: 'pid' - } - }); - expect(isValid).to.be.false; - }); - - it('should require pId', function () { - const isValid = adapter.isBidRequestValid({ - params: { - cId: 'cid' - } - }); - expect(isValid).to.be.false; - }); - - it('should validate correctly', function () { - const isValid = adapter.isBidRequestValid({ - params: { - cId: 'cid', - pId: 'pid' - } - }); - expect(isValid).to.be.true; - }); - }); - - describe('build requests', function () { - let sandbox; - before(function () { - sandbox = sinon.sandbox.create(); - sandbox.stub(Date, 'now').returns(1000); - }); - - it('should build request for each size', function () { - const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.referer); - const requests = adapter.buildRequests([BID], BIDDER_REQUEST); - expect(requests).to.have.length(1); - expect(requests[0]).to.deep.equal({ - method: 'POST', - url: `${createDomain(SUB_DOMAIN)}/prebid/multi/59db6b3b4ffaa70004f45cdc`, - data: { - gdprConsent: 'consent_string', - gdpr: 1, - usPrivacy: 'consent_string', - sizes: ['300x250', '300x600'], - url: 'https%3A%2F%2Fwww.greatsite.com', - cb: 1000, - bidFloor: 0.1, - bidId: '2d52001cabd527', - adUnitCode: 'div-gpt-ad-12345-0', - publisherId: '59ac17c192832d0011283fe3', - dealId: 1, - sessionId: '', - uniqueDealId: `${hashUrl}_${Date.now().toString()}`, - bidderVersion: adapter.version, - prebidVersion: version, - res: `${window.top.screen.width}x${window.top.screen.height}`, - 'ext.param1': 'loremipsum', - 'ext.param2': 'dolorsitamet', - } - }); - }); - - after(function () { - sandbox.restore(); - }); - }); - describe('getUserSyncs', function () { - it('should have valid user sync with iframeEnabled', function () { - const result = adapter.getUserSyncs({ iframeEnabled: true }, [SERVER_RESPONSE]); - - expect(result).to.deep.equal([{ - type: 'iframe', - url: 'https://prebid.cootlogix.com/api/sync/iframe/?gdpr=0&gdpr_consent=&us_privacy=' - }]); - }); - - it('should have valid user sync with pixelEnabled', function () { - const result = adapter.getUserSyncs({ pixelEnabled: true }, [SERVER_RESPONSE]); - - expect(result).to.deep.equal([{ - 'url': 'https://prebid.cootlogix.com/api/sync/image/?gdpr=0&gdpr_consent=&us_privacy=', - 'type': 'image' - }]); - }) - }); - - describe('interpret response', function () { - it('should return empty array when there is no response', function () { - const responses = adapter.interpretResponse(null); - expect(responses).to.be.empty; - }); - - it('should return empty array when there is no ad', function () { - const responses = adapter.interpretResponse({ price: 1, ad: '' }); - expect(responses).to.be.empty; - }); - - it('should return empty array when there is no price', function () { - const responses = adapter.interpretResponse({ price: null, ad: 'great ad' }); - expect(responses).to.be.empty; - }); - - it('should return an array of interpreted responses', function () { - const responses = adapter.interpretResponse(SERVER_RESPONSE, REQUEST); - expect(responses).to.have.length(1); - expect(responses[0]).to.deep.equal({ - requestId: '2d52001cabd527', - cpm: 0.8, - width: 300, - height: 250, - creativeId: '12610997325162499419', - currency: 'USD', - netRevenue: true, - ttl: 30, - ad: '' - }); - }); - - it('should take default TTL', function () { - const serverResponse = utils.deepClone(SERVER_RESPONSE); - delete serverResponse.body.results[0].exp; - const responses = adapter.interpretResponse(serverResponse, REQUEST); - expect(responses).to.have.length(1); - expect(responses[0].ttl).to.equal(300); - }); - }); - - describe('user id system', function () { - Object.keys(SUPPORTED_ID_SYSTEMS).forEach((idSystemProvider) => { - const id = Date.now().toString(); - const bid = utils.deepClone(BID); - - const userId = (function () { - switch (idSystemProvider) { - case 'digitrustid': return { data: { id: id } }; - case 'lipb': return { lipbid: id }; - case 'parrableId': return { eid: id }; - case 'id5id': return { uid: id }; - default: return id; - } - })(); - - bid.userId = { - [idSystemProvider]: userId - }; - - it(`should include 'uid.${idSystemProvider}' in request params`, function () { - const requests = adapter.buildRequests([bid], BIDDER_REQUEST); - expect(requests[0].data[`uid.${idSystemProvider}`]).to.equal(id); - }); - }); - }); - - describe('alternate param names extractors', function () { - it('should return undefined when param not supported', function () { - const cid = extractCID({ 'c_id': '1' }); - const pid = extractPID({ 'p_id': '1' }); - const subDomain = extractSubDomain({ 'sub_domain': 'prebid' }); - expect(cid).to.be.undefined; - expect(pid).to.be.undefined; - expect(subDomain).to.be.undefined; - }); - - it('should return value when param supported', function () { - const cid = extractCID({ 'cID': '1' }); - const pid = extractPID({ 'Pid': '2' }); - const subDomain = extractSubDomain({ 'subDOMAIN': 'prebid' }); - expect(cid).to.be.equal('1'); - expect(pid).to.be.equal('2'); - expect(subDomain).to.be.equal('prebid'); - }); - }); - - describe('vidazoo session id', function () { - it('should get undefined vidazoo session id', function () { - const sessionId = getVidazooSessionId(); - expect(sessionId).to.be.empty; - }); - - it('should get vidazoo session id from storage', function () { - const vidSid = '1234-5678'; - window.localStorage.setItem('vidSid', vidSid); - const sessionId = getVidazooSessionId(); - expect(sessionId).to.be.equal(vidSid); - }); - }); - - describe('deal id', function () { - const key = 'myDealKey'; - - it('should get the next deal id', function () { - const dealId = getNextDealId(key); - const nextDealId = getNextDealId(key); - expect(dealId).to.be.equal(1); - expect(nextDealId).to.be.equal(2); - }); - - it('should get the first deal id on expiration', function (done) { - setTimeout(function () { - const dealId = getNextDealId(key, 100); - expect(dealId).to.be.equal(1); - done(); - }, 200); - }); - }); - - describe('unique deal id', function () { - const key = 'myKey'; - let uniqueDealId; - uniqueDealId = getUniqueDealId(key); - - it('should get current unique deal id', function (done) { - // waiting some time so `now` will become past - setTimeout(() => { - const current = getUniqueDealId(key); - expect(current).to.be.equal(uniqueDealId); - done(); - }, 200); - }); - - it('should get new unique deal id on expiration', function () { - const current = getUniqueDealId(key, 100); - expect(current).to.not.be.equal(uniqueDealId); - }); - }); - - describe('storage utils', function () { - it('should get value from storage with create param', function () { - const now = Date.now(); - const clock = useFakeTimers({ - shouldAdvanceTime: true, - now - }); - setStorageItem('myKey', 2020); - const { value, created } = getStorageItem('myKey'); - expect(created).to.be.equal(now); - expect(value).to.be.equal(2020); - expect(typeof value).to.be.equal('number'); - expect(typeof created).to.be.equal('number'); - clock.restore(); - }); - - it('should get external stored value', function () { - const value = 'superman' - window.localStorage.setItem('myExternalKey', value); - const item = getStorageItem('myExternalKey'); - expect(item).to.be.equal(value); - }); - - it('should parse JSON value', function () { - const data = JSON.stringify({ event: 'send' }); - const { event } = tryParseJSON(data); - expect(event).to.be.equal('send'); - }); - - it('should get original value on parse fail', function () { - const value = 21; - const parsed = tryParseJSON(value); - expect(typeof parsed).to.be.equal('number'); - expect(parsed).to.be.equal(value); - }); - }); -}); diff --git a/test/spec/modules/videoNowBidAdapter_spec.js b/test/spec/modules/videoNowBidAdapter_spec.js deleted file mode 100644 index a419c73456b..00000000000 --- a/test/spec/modules/videoNowBidAdapter_spec.js +++ /dev/null @@ -1,599 +0,0 @@ -import { expect } from 'chai' -import { spec } from 'modules/videoNowBidAdapter.js' -import { replaceAuctionPrice } from 'src/utils.js' -import * as utils from 'src/utils.js'; - -// childNode.remove polyfill for ie11 -// suggested by: https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove - -// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md -(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('remove')) { - return; - } - Object.defineProperty(item, 'remove', { - configurable: true, - enumerable: true, - writable: true, - value: function remove() { - if (this.parentNode === null) { - return; - } - this.parentNode.removeChild(this); - } - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); - -const placementId = 'div-gpt-ad-1438287399331-1' -const LS_ITEM_NAME = 'videonow-config' - -const getValidServerResponse = () => { - const serverResponse = { - body: { - id: '111-111', - bidid: '2955a162-699e-4811-ce88-5c3ac973e73c', - cur: 'RUB', - seatbid: [ - { - bid: [ - { - id: 'e3bf2b82e3e9485113fad6c9b27f8768.1', - impid: '1', - price: 10.97, - nurl: 'https://localhost:8086/event/nurl', - netRevenue: false, - ttl: 800, - adm: '', - crid: 'e3bf2b82e3e9485113fad6c9b27f8768.1', - h: 640, - w: 480, - ext: { - init: 'https://localhost:8086/vn_init.js', - module: { - min: 'https://localhost:8086/vn_module.js', - log: 'https://localhost:8086/vn_module.js?log=1' - }, - format: { - name: 'flyRoll', - }, - }, - - }, - ], - group: 0, - }, - ], - price: 10, - ext: { - placementId, - pixels: [ - 'https://localhost:8086/event/pxlcookiematching?uiid=1', - 'https://localhost:8086/event/pxlcookiematching?uiid=2', - ], - iframes: [ - 'https://localhost:8086/event/ifrcookiematching?uiid=1', - 'https://localhost:8086/event/ifrcookiematching?uiid=2', - ], - }, - }, - headers: {}, - } - - return JSON.parse(JSON.stringify(serverResponse)) -} - -describe('videonowAdapterTests', function() { - describe('bidRequestValidity', function() { - it('bidRequest with pId', function() { - expect(spec.isBidRequestValid({ - bidder: 'videonow', - params: { - pId: '86858', - }, - })).to.equal(true) - }) - - it('bidRequest without pId', function() { - expect(spec.isBidRequestValid({ - bidder: 'videonow', - params: { - nomater: 86858, - }, - })).to.equal(false) - - it('bidRequest is empty', function() { - expect(spec.isBidRequestValid({})).to.equal(false) - }) - - it('bidRequest is undefned', function() { - expect(spec.isBidRequestValid(undefined)).to.equal(false) - }) - }) - - describe('bidRequest', function() { - const validBidRequests = [ - { - bidder: 'videonow', - params: { - pId: '1', - placementId, - url: 'https://localhost:8086/bid?p=exists', - bidFloor: 10, - cur: 'RUB' - }, - crumbs: { - pubcid: 'feded041-35dd-4b54-979a-6d7805abfa75', - }, - mediaTypes: { - banner: { - sizes: [[640, 480], [320, 200]] - }, - }, - adUnitCode: 'test-ad', - transactionId: '676403c7-09c9-4b56-be82-e7cae81f40b9', - sizes: [[640, 480], [320, 200]], - bidId: '268c309f46390d', - bidderRequestId: '1dfdd514c36ef6', - auctionId: '4d523546-889a-4029-9a79-13d3c69f9922', - src: 'client', - bidRequestsCount: 1, - }, - ] - - const bidderRequest = { - bidderCode: 'videonow', - auctionId: '4d523546-889a-4029-9a79-13d3c69f9922', - bidderRequestId: '1dfdd514c36ef6', - bids: [ - { - bidder: 'videonow', - params: { - pId: '1', - placementId, - url: 'https://localhost:8086/bid', - bidFloor: 10, - cur: 'RUB', - }, - crumbs: { - pubcid: 'feded041-35dd-4b54-979a-6d7805abfa75', - }, - mediaTypes: { - banner: { - sizes: [[640, 480], [320, 200]], - }, - }, - adUnitCode: 'test-ad', - transactionId: '676403c7-09c9-4b56-be82-e7cae81f40b9', - sizes: [[640, 480], [320, 200]], - bidId: '268c309f46390d', - bidderRequestId: '1dfdd514c36ef6', - auctionId: '4d523546-889a-4029-9a79-13d3c69f9922', - src: 'client', - bidRequestsCount: 1, - }, - ], - auctionStart: 1565794308584, - timeout: 3000, - refererInfo: { - referer: 'https://localhost:8086/page', - reachedTop: true, - numIframes: 0, - stack: [ - 'https://localhost:8086/page', - ], - }, - start: 1565794308589, - } - - const requests = spec.buildRequests(validBidRequests, bidderRequest) - const request = (requests && requests.length && requests[0]) || {} - - it('bidRequest count', function() { - expect(requests.length).to.equal(1) - }) - - it('bidRequest method', function() { - expect(request.method).to.equal('POST') - }) - - it('bidRequest url', function() { - expect(request.url).to.equal('https://localhost:8086/bid?p=exists&profile_id=1') - }) - - it('bidRequest data', function() { - const data = request.data - expect(data.aid).to.be.eql(validBidRequests[0].params.aid) - expect(data.id).to.be.eql(validBidRequests[0].bidId) - expect(data.sizes).to.be.eql(validBidRequests[0].sizes) - }) - - describe('bidRequest advanced', function() { - const bidderRequestEmptyParamsAndExtParams = { - bidder: 'videonow', - params: { - pId: '1', - }, - ext: { - p1: 'ext1', - p2: 'ext2', - }, - } - - it('bidRequest count', function() { - const requests = spec.buildRequests([bidderRequestEmptyParamsAndExtParams], bidderRequest) - expect(requests.length).to.equal(1) - }) - - it('bidRequest default url', function() { - const requests = spec.buildRequests([bidderRequestEmptyParamsAndExtParams], bidderRequest) - const request = (requests && requests.length && requests[0]) || {} - expect(request.url).to.equal('https://bidder.videonow.ru/prebid?profile_id=1') - }) - - it('bidRequest default currency', function() { - const requests = spec.buildRequests([bidderRequestEmptyParamsAndExtParams], bidderRequest) - const request = (requests && requests.length && requests[0]) || {} - const data = (request && request.data) || {} - expect(data.cur).to.equal('RUB') - }) - - it('bidRequest ext parameters ', function() { - const requests = spec.buildRequests([bidderRequestEmptyParamsAndExtParams], bidderRequest) - const request = (requests && requests.length && requests[0]) || {} - const data = (request && request.data) || {} - expect(data['ext_p1']).to.equal('ext1') - expect(data['ext_p2']).to.equal('ext2') - }) - - it('bidRequest without params', function() { - const bidderReq = { - bidder: 'videonow', - } - const requests = spec.buildRequests([bidderReq], bidderRequest) - expect(requests.length).to.equal(1) - }) - }) - }) - - describe('onBidWon', function() { - const cpm = 10 - const nurl = 'https://fakedomain.nld?price=${AUCTION_PRICE}' - const imgSrc = replaceAuctionPrice(nurl, cpm) - - beforeEach(function() { - sinon.stub(utils, 'triggerPixel') - }) - - afterEach(function() { - utils.triggerPixel.restore() - }) - - it('Should not create nurl pixel if bid is undefined', function() { - spec.onBidWon() - expect(utils.triggerPixel.called).to.equal(false); - }) - - it('Should not create nurl pixel if bid does not contains nurl', function() { - spec.onBidWon({}) - expect(utils.triggerPixel.called).to.equal(false); - }) - - it('Should create nurl pixel if bid nurl', function() { - spec.onBidWon({ nurl, cpm }) - expect(utils.triggerPixel.calledWith(imgSrc)).to.equal(true); - }) - }) - - describe('getUserSyncs', function() { - it('Should return an empty array if not get serverResponses', function() { - expect(spec.getUserSyncs({}).length).to.equal(0) - }) - - it('Should return an empty array if get serverResponses as empty array', function() { - expect(spec.getUserSyncs({}, []).length).to.equal(0) - }) - - it('Should return an empty array if serverResponses has no body', function() { - const serverResp = getValidServerResponse() - delete serverResp.body - const syncs = spec.getUserSyncs({}, [serverResp]) - expect(syncs.length).to.equal(0) - }) - - it('Should return an empty array if serverResponses has no ext', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.ext - const syncs = spec.getUserSyncs({}, [serverResp]) - expect(syncs.length).to.equal(0) - }) - - it('Should return an array', function() { - const serverResp = getValidServerResponse() - const syncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [serverResp]) - expect(syncs.length).to.equal(4) - }) - - it('Should return pixels', function() { - const serverResp = getValidServerResponse() - const syncs = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [serverResp]) - expect(syncs.length).to.equal(2) - expect(syncs[0].type).to.equal('image') - expect(syncs[1].type).to.equal('image') - }) - - it('Should return iframes', function() { - const serverResp = getValidServerResponse() - const syncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [serverResp]) - expect(syncs.length).to.equal(2) - expect(syncs[0].type).to.equal('iframe') - expect(syncs[1].type).to.equal('iframe') - }) - }) - - describe('interpretResponse', function() { - const bidRequest = { - method: 'POST', - url: 'https://localhost:8086/bid?profile_id=1', - data: { - id: '217b8ab59a18e8', - cpm: 10, - sizes: [[640, 480], [320, 200]], - cur: 'RUB', - placementId, - ref: 'https://localhost:8086/page', - }, - } - - it('Should have only one bid', function() { - const serverResponse = getValidServerResponse() - const result = spec.interpretResponse(serverResponse, bidRequest) - expect(result.length).to.equal(1) - }) - - it('Should have required keys', function() { - const serverResponse = getValidServerResponse() - const result = spec.interpretResponse(serverResponse, bidRequest) - const bid = serverResponse.body.seatbid[0].bid[0] - const res = result[0] - expect(res.requestId).to.be.eql(bidRequest.data.id) - expect(res.cpm).to.be.eql(bid.price) - expect(res.creativeId).to.be.eql(bid.crid) - expect(res.netRevenue).to.be.a('boolean') - expect(res.ttl).to.be.eql(bid.ttl) - expect(res.renderer).to.be.a('Object') - expect(res.renderer.render).to.be.a('function') - }) - - it('Should return an empty array if empty or no bids in response', function() { - expect(spec.interpretResponse({ body: '' }, {}).length).to.equal(0) - }) - - it('Should return an empty array if bidRequest\'s data is absent', function() { - const serverResponse = getValidServerResponse() - expect(spec.interpretResponse(serverResponse, undefined).length).to.equal(0) - }) - - it('Should return an empty array if bidRequest\'s data is not contains bidId ', function() { - const serverResponse = getValidServerResponse() - expect(spec.interpretResponse(serverResponse, { data: {} }).length).to.equal(0) - }) - - it('Should return an empty array if bidRequest\'s data bidId is undefined', function() { - const serverResponse = getValidServerResponse() - expect(spec.interpretResponse(serverResponse, { data: { id: null } }).length).to.equal(0) - }) - - it('Should return an empty array if serverResponse do not contains seatbid', function() { - expect(spec.interpretResponse({ body: {} }, bidRequest).length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s seatbid is empty', function() { - expect(spec.interpretResponse({ body: { seatbid: [] } }, bidRequest).length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s placementId is undefined', function() { - expect(spec.interpretResponse({ body: { seatbid: [1, 2] } }, bidRequest).length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s id in the bid is undefined', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].id - let res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s price in the bid is undefined', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].price - const res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s price in the bid is 0', function() { - const serverResp = getValidServerResponse() - serverResp.body.seatbid[0].bid[0].price = 0 - const res = spec.interpretResponse(serverResp, bidRequest) - - expect(res.length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s init in the bid\'s ext is undefined', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].ext.init - const res = spec.interpretResponse(serverResp, bidRequest) - - expect(res.length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s module in the bid\'s ext is undefined', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].ext.module - const res = spec.interpretResponse(serverResp, bidRequest) - - expect(res.length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s adm in the bid is undefined', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].adm - const res = spec.interpretResponse(serverResp, bidRequest) - - expect(res.length).to.equal(0) - }) - - it('Should return an empty array if serverResponse\'s the bid\'s ext is undefined', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].ext - const res = spec.interpretResponse(serverResp, bidRequest) - - expect(res.length).to.equal(0) - }) - - it('Default ttl is 300', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].ttl - const res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(1) - expect(res[0].ttl).to.equal(300) - }) - - it('Default netRevenue is true', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].netRevenue - const res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(1) - expect(res[0].netRevenue).to.be.true; - }) - - it('Default currency is RUB', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.cur - const res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(1) - expect(res[0].currency).to.equal('RUB') - }) - - describe('different module paths', function() { - beforeEach(function() { - window.localStorage && localStorage.setItem(LS_ITEM_NAME, '{}') - }) - - afterEach(function() { - const serverResp = getValidServerResponse() - const { module: { log, min }, init } = serverResp.body.seatbid[0].bid[0].ext - remove(init) - remove(log) - remove(min) - - function remove(src) { - if (!src) return - const d = document.querySelectorAll(`script[src^="${src}"]`) - // using the Array.prototype.forEach as a workaround for IE11... - // see https://developer.mozilla.org/en-US/docs/Web/API/NodeList - d && d.length && Array.prototype.forEach.call(d, el => el && el.remove()) - } - }) - - it('should use prod module by default', function() { - const serverResp = getValidServerResponse() - const res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(1) - - const renderer = res[0].renderer - expect(renderer).to.be.an('object') - expect(renderer.url).to.equal(serverResp.body.seatbid[0].bid[0].ext.module.min) - }) - - it('should use "log" module if "prod" is not exists', function() { - const serverResp = getValidServerResponse() - delete serverResp.body.seatbid[0].bid[0].ext.module.min - const res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(1) - - const renderer = res[0].renderer - expect(renderer).to.be.an('object') - expect(renderer.url).to.equal(serverResp.body.seatbid[0].bid[0].ext.module.log) - }) - - it('should correct combine src for init', function() { - const serverResp = getValidServerResponse() - - const src = `${serverResp.body.seatbid[0].bid[0].ext.init}?profileId=1` - const placementElement = document.createElement('div') - placementElement.setAttribute('id', placementId) - - const resp = spec.interpretResponse(serverResp, bidRequest) - expect(resp.length).to.equal(1) - - const renderer = resp[0].renderer - expect(renderer).to.be.an('object') - - document.body.appendChild(placementElement) - - renderer.render() - - // const res = document.querySelectorAll(`script[src="${src}"]`) - // expect(res.length).to.equal(1) - }) - - it('should correct combine src for init if init url contains "?"', function() { - const serverResp = getValidServerResponse() - - serverResp.body.seatbid[0].bid[0].ext.init += '?div=1' - const src = `${serverResp.body.seatbid[0].bid[0].ext.init}&profileId=1` - - const placementElement = document.createElement('div') - placementElement.setAttribute('id', placementId) - - const resp = spec.interpretResponse(serverResp, bidRequest) - expect(resp.length).to.equal(1) - - const renderer = resp[0].renderer - expect(renderer).to.be.an('object') - - document.body.appendChild(placementElement) - - renderer.render() - - // const res = document.querySelectorAll(`script[src="${src}"]`) - // expect(res.length).to.equal(1) - }) - }) - - describe('renderer object', function() { - it('execute renderer.render() should create window.videonow object', function() { - const serverResp = getValidServerResponse() - const res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(1) - - const renderer = res[0].renderer - expect(renderer).to.be.an('object') - expect(renderer.render).to.a('function') - - const doc = window.document - const placementElement = doc.createElement('div') - placementElement.setAttribute('id', placementId) - doc.body.appendChild(placementElement) - - renderer.render() - expect(window.videonow).to.an('object') - }) - }) - - it('execute renderer.render() should not create window.videonow object if placement element not found', function() { - const serverResp = getValidServerResponse() - const res = spec.interpretResponse(serverResp, bidRequest) - expect(res.length).to.equal(1) - - const renderer = res[0].renderer - expect(renderer).to.be.an('object') - expect(renderer.render).to.a('function') - - renderer.render() - expect(window.videonow).to.be.undefined - }) - }) - }) -}) diff --git a/test/spec/modules/videofyBidAdapter_spec.js b/test/spec/modules/videofyBidAdapter_spec.js deleted file mode 100644 index 270eefd1efc..00000000000 --- a/test/spec/modules/videofyBidAdapter_spec.js +++ /dev/null @@ -1,253 +0,0 @@ -import { spec } from 'modules/videofyBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import * as utils from '../../../src/utils.js'; - -const { expect } = require('chai'); - -describe('Videofy Bid Adapter Test', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'videofy', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'video1', - 'sizes': [[300, 250], [640, 480]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - something: 'is wrong' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bid2Requests = [ - { - 'bidder': 'videofy', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'test1', - 'sizes': [[300, 250], [640, 480]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - } - ]; - let bid1Request = [ - { - 'bidder': 'videofy', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'test1', - 'sizes': [640, 480], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - } - ]; - - it('Test 2 requests', function () { - const requests = spec.buildRequests(bid2Requests); - expect(requests.length).to.equal(2); - const r1 = requests[0]; - const d1 = requests[0].data; - expect(d1).to.have.property('AV_PUBLISHERID'); - expect(d1.AV_PUBLISHERID).to.equal('123456'); - expect(d1).to.have.property('AV_CHANNELID'); - expect(d1.AV_CHANNELID).to.equal('123456'); - expect(d1).to.have.property('AV_WIDTH'); - expect(d1.AV_WIDTH).to.equal(300); - expect(d1).to.have.property('AV_HEIGHT'); - expect(d1.AV_HEIGHT).to.equal(250); - expect(d1).to.have.property('AV_URL'); - expect(d1).to.have.property('cb'); - expect(d1).to.have.property('s2s'); - expect(d1.s2s).to.equal('1'); - expect(d1).to.have.property('pbjs'); - expect(d1.pbjs).to.equal(1); - expect(r1).to.have.property('url'); - expect(r1.url).to.contain('https://servx.srv-mars.com/api/adserver/vast3/'); - const r2 = requests[1]; - const d2 = requests[1].data; - expect(d2).to.have.property('AV_PUBLISHERID'); - expect(d2.AV_PUBLISHERID).to.equal('123456'); - expect(d2).to.have.property('AV_CHANNELID'); - expect(d2.AV_CHANNELID).to.equal('123456'); - expect(d2).to.have.property('AV_WIDTH'); - expect(d2.AV_WIDTH).to.equal(640); - expect(d2).to.have.property('AV_HEIGHT'); - expect(d2.AV_HEIGHT).to.equal(480); - expect(d2).to.have.property('AV_URL'); - expect(d2).to.have.property('cb'); - expect(d2).to.have.property('s2s'); - expect(d2.s2s).to.equal('1'); - expect(d2).to.have.property('pbjs'); - expect(d2.pbjs).to.equal(1); - expect(r2).to.have.property('url'); - expect(r2.url).to.contain('https://servx.srv-mars.com/api/adserver/vast3/'); - }); - - it('Test 1 request', function () { - const requests = spec.buildRequests(bid1Request); - expect(requests.length).to.equal(1); - const r = requests[0]; - const d = requests[0].data; - expect(d).to.have.property('AV_PUBLISHERID'); - expect(d.AV_PUBLISHERID).to.equal('123456'); - expect(d).to.have.property('AV_CHANNELID'); - expect(d.AV_CHANNELID).to.equal('123456'); - expect(d).to.have.property('AV_WIDTH'); - expect(d.AV_WIDTH).to.equal(640); - expect(d).to.have.property('AV_HEIGHT'); - expect(d.AV_HEIGHT).to.equal(480); - expect(d).to.have.property('AV_URL'); - expect(d).to.have.property('cb'); - expect(d).to.have.property('s2s'); - expect(d.s2s).to.equal('1'); - expect(d).to.have.property('pbjs'); - expect(d.pbjs).to.equal(1); - expect(r).to.have.property('url'); - expect(r.url).to.contain('https://servx.srv-mars.com/api/adserver/vast3/'); - }); - }); - - describe('interpretResponse', function () { - let bidRequest = { - 'url': 'https://servx.srv-mars.com/api/adserver/vast3/', - 'data': { - 'bidId': '253dcb69fb2577', - AV_PUBLISHERID: '55b78633181f4603178b4568', - AV_CHANNELID: '55b7904d181f46410f8b4568', - } - }; - let serverResponse = {}; - serverResponse.body = 'FORDFORD00:00:15'; - - it('Check bid interpretResponse', function () { - const BIDDER_CODE = 'videofy'; - let bidResponses = spec.interpretResponse(serverResponse, bidRequest); - expect(bidResponses.length).to.equal(1); - let bidResponse = bidResponses[0]; - expect(bidResponse.requestId).to.equal(bidRequest.data.bidId); - expect(bidResponse.bidderCode).to.equal(BIDDER_CODE); - expect(bidResponse.cpm).to.equal('2'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.currency).to.equal('USD'); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.mediaType).to.equal('video'); - }); - - it('safely handles XML parsing failure from invalid bid response', function () { - let invalidServerResponse = {}; - invalidServerResponse.body = ''; - - let result = spec.interpretResponse(invalidServerResponse, bidRequest); - expect(result.length).to.equal(0); - }); - - it('handles nobid responses', function () { - let nobidResponse = {}; - nobidResponse.body = ''; - - let result = spec.interpretResponse(nobidResponse, bidRequest); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - it('Check get sync pixels from response', function () { - let pixelUrl = 'https://sync.pixel.url/sync'; - let pixelEvent = 'inventory'; - let pixelType = '3'; - let pixelStr = '{"url":"' + pixelUrl + '", "e":"' + pixelEvent + '", "t":' + pixelType + '}'; - let bidResponse = 'FORDFORD00:00:15'; - let serverResponse = [ - {body: bidResponse} - ]; - let syncPixels = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, serverResponse); - expect(syncPixels.length).to.equal(1); - let pixel = syncPixels[0]; - expect(pixel.url).to.equal(pixelUrl); - expect(pixel.type).to.equal('iframe'); - }); - }); - - describe('on bidWon', function () { - beforeEach(function() { - sinon.stub(utils, 'triggerPixel'); - }); - afterEach(function() { - utils.triggerPixel.restore(); - }); - it('exists and is a function', () => { - expect(spec.onBidWon).to.exist.and.to.be.a('function'); - }); - it('should return nothing', function () { - var response = spec.onBidWon({}); - expect(response).to.be.an('undefined') - expect(utils.triggerPixel.called).to.equal(true); - }); - }); - - describe('on Timeout', function () { - beforeEach(function() { - sinon.stub(utils, 'triggerPixel'); - }); - afterEach(function() { - utils.triggerPixel.restore(); - }); - it('exists and is a function', () => { - expect(spec.onTimeout).to.exist.and.to.be.a('function'); - }); - it('should return nothing', function () { - var response = spec.onTimeout({}); - expect(response).to.be.an('undefined') - expect(utils.triggerPixel.called).to.equal(true); - }); - }); - - describe('on Set Targeting', function () { - beforeEach(function() { - sinon.stub(utils, 'triggerPixel'); - }); - afterEach(function() { - utils.triggerPixel.restore(); - }); - it('exists and is a function', () => { - expect(spec.onSetTargeting).to.exist.and.to.be.a('function'); - }); - it('should return nothing', function () { - var response = spec.onSetTargeting({}); - expect(response).to.be.an('undefined') - expect(utils.triggerPixel.called).to.equal(true); - }); - }); -}); diff --git a/test/spec/modules/videoreachBidAdapter_spec.js b/test/spec/modules/videoreachBidAdapter_spec.js deleted file mode 100644 index e5c6b9b30ad..00000000000 --- a/test/spec/modules/videoreachBidAdapter_spec.js +++ /dev/null @@ -1,141 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/videoreachBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -const ENDPOINT_URL = 'https://a.videoreach.com/hb/'; - -describe('videoreachBidAdapter', function () { - describe('isBidRequestValid', function () { - let bid = { - 'params': { - 'TagId': 'ABCDE' - }, - 'bidId': '242d506d4e4f15', - 'bidderRequestId': '1893a2136a84a2', - 'auctionId': '8fb7b1c7-317b-4edf-83f0-c4669a318522', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'TagId': '' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'videoreach', - 'params': { - 'TagId': 'ABCDE' - }, - 'adUnitCode': 'adzone', - 'auctionId': '8fb7b1c7-317b-4edf-83f0-c4669a318522', - 'sizes': [[1, 1]], - 'bidId': '242d506d4e4f15', - 'bidderRequestId': '1893a2136a84a2', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622', - 'mediaTypes': { - 'banner': { - 'sizes': [1, 1] - }, - } - } - ]; - - it('send bid request to endpoint', function () { - const request = spec.buildRequests(bidRequests); - - expect(request.url).to.equal(ENDPOINT_URL); - expect(request.method).to.equal('POST'); - }); - - it('send bid request with GDPR to endpoint', function () { - let consentString = 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'; - - let bidderRequest = { - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.gdpr.consent_required).to.exist; - expect(payload.gdpr.consent_string).to.equal(consentString); - }); - }); - - describe('interpretResponse', function () { - let serverResponse = - { - 'body': { - 'responses': [{ - 'bidId': '242d506d4e4f15', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622', - 'cpm': 10.0, - 'width': '1', - 'height': '1', - 'ad': '', - 'ttl': 360, - 'creativeId': '5cb5dc9375c0e', - 'netRevenue': true, - 'currency': 'EUR', - 'sync': ['https:\/\/SYNC_URL'] - }] - } - }; - - it('should handle response', function() { - let expectedResponse = [ - { - cpm: 10.0, - width: '1', - height: '1', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: '', - requestId: '242d506d4e4f15', - creativeId: '5cb5dc9375c0e' - } - ]; - - let result = spec.interpretResponse(serverResponse); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('should handles empty response', function() { - let serverResponse = { - 'body': { - 'responses': [] - } - }; - - let result = spec.interpretResponse(serverResponse); - expect(result.length).to.equal(0); - }); - - describe('getUserSyncs', () => { - it('should push user sync images if enabled', () => { - const syncOptions = { pixelEnabled: true }; - const syncs = spec.getUserSyncs(syncOptions, [serverResponse]); - - expect(syncs[0]).to.deep.equal({ - type: 'image', - url: 'https://SYNC_URL' - }); - }) - }); - }); -}); diff --git a/test/spec/modules/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/vrtcalBidAdapter_spec.js b/test/spec/modules/vrtcalBidAdapter_spec.js deleted file mode 100644 index 729b0a723e4..00000000000 --- a/test/spec/modules/vrtcalBidAdapter_spec.js +++ /dev/null @@ -1,135 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/vrtcalBidAdapter.js'; - -describe('Vrtcal Adapter', function () { - let bid = { - bidId: 'bidID0001', - bidder: 'vrtcal', - bidderRequestId: 'brID0001', - auctionId: 'auID0001', - sizes: [[300, 250]], - transactionId: 'tid0001', - adUnitCode: 'vrtcal-test-adunit' - }; - - describe('isBidRequestValid', function () { - it('Should return true when base params as set', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false when bid.bidId is blank', function () { - bid.bidId = ''; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - it('Should return false when bid.auctionId is blank', function () { - bid.auctionId = ''; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequests = spec.buildRequests([bid]); - - let serverRequest = serverRequests[0]; - - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://rtb.vrtcal.com/bidder_prebid.vap?ssp=1804'); - }); - - it('Returns valid data if array of bids is valid', function () { - let data = JSON.parse(serverRequest.data); - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('prebidJS', 'prebidAdUnitCode', 'id', 'imp', 'site', 'device'); - expect(data.prebidJS).to.not.equal(''); - expect(data.prebidAdUnitCode).to.not.equal(''); - }); - - it('Sets width and height based on existence of bid.mediaTypes.banner', function () { - let data = JSON.parse(serverRequest.data); - if (typeof (bid.mediaTypes) !== 'undefined' && typeof (bid.mediaTypes.banner) !== 'undefined' && typeof (bid.mediaTypes.banner.sizes) !== 'undefined') { - expect(data.imp[0].banner.w).to.equal(bid.mediaTypes.banner.sizes[0][0]); - expect(data.imp[0].banner.h).to.equal(bid.mediaTypes.banner.sizes[0][1]); - } else { - expect(data.imp[0].banner.w).to.equal(bid.sizes[0][0]); - expect(data.imp[0].banner.h).to.equal(bid.sizes[0][1]); - } - }); - - it('Returns empty data if no valid requests are passed', function () { - serverRequests = spec.buildRequests([]); - expect(serverRequests).to.be.an('array').that.is.empty; - }); - }); - - describe('interpretResponse', function () { - let bid = { - bidId: 'bidID0001', - bidder: 'vrtcal', - bidderRequestId: 'brID0001', - auctionId: 'auID0001', - sizes: [[300, 250]], - transactionId: 'tid0001', - adUnitCode: 'vrtcal-test-adunit' - }; - - let serverRequests = spec.buildRequests([bid]); - - let resObject = {body: {id: 'vrtcal-test-id', width: 300, height: 250, seatbid: [{bid: [{price: 3.0, w: 300, h: 250, crid: 'testcrid', adm: 'testad', nurl: 'https://vrtcal.com/faketracker'}]}], currency: 'USD', netRevenue: true, ttl: 900}}; - - let serverResponses = spec.interpretResponse(resObject, serverRequests); - - it('Returns an array of valid server responses if response object is valid', function () { - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'nurl'); - expect(dataItem.requestId).to.be.a('string'); - expect(dataItem.cpm).to.be.a('number'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); - expect(dataItem.ad).to.be.a('string'); - expect(dataItem.ttl).to.be.a('number'); - expect(dataItem.creativeId).to.be.a('string'); - expect(dataItem.netRevenue).to.be.a('boolean'); - expect(dataItem.currency).to.be.a('string'); - expect(dataItem.nurl).to.be.a('string'); - } - - it('Returns an empty array if invalid response is passed', function () { - serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - }); - - describe('onBidWon', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'vrtcal', - bidderRequestId: '145e1d6a7837c9', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', - adUnitCode: 'vrtcal-test-adunit' - }; - - let serverRequests = spec.buildRequests([bid]); - let resObject = {body: {id: 'vrtcal-test-id', width: 300, height: 250, seatbid: [{bid: [{price: 3.0, w: 300, h: 250, crid: 'testcrid', adm: 'testad', nurl: 'https://vrtcal.com/faketracker'}]}], currency: 'USD', netRevenue: true, ttl: 900}}; - let serverResponses = spec.interpretResponse(resObject, serverRequests); - let wonbid = serverResponses[0]; - - it('Returns true is nurl is good/not blank', function () { - expect(wonbid.nurl).to.not.equal(''); - expect(spec.onBidWon(wonbid)).to.be.true; - }); - }); -}); diff --git a/test/spec/modules/vubleBidAdapter_spec.js b/test/spec/modules/vubleBidAdapter_spec.js deleted file mode 100644 index 2f0d1c1e262..00000000000 --- a/test/spec/modules/vubleBidAdapter_spec.js +++ /dev/null @@ -1,412 +0,0 @@ -// import or require modules necessary for the test, e.g.: - -import {expect} from 'chai'; -import {spec as adapter} from 'modules/vubleBidAdapter.js'; -import * as utils from 'src/utils.js'; - -describe('VubleAdapter', 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'); - }); - it('exists and is a function', function () { - expect(adapter.getUserSyncs).to.exist.and.to.be.a('function'); - }); - }); - - describe('Check method isBidRequestValid return', function () { - let bid = { - bidder: 'vuble', - params: { - env: 'net', - pubId: '3', - zoneId: '12345', - floorPrice: 5.00 // optional - }, - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'instream' - } - }, - }; - let bid2 = { - bidder: 'vuble', - params: { - env: 'net', - pubId: '3', - zoneId: '12345', - floorPrice: 5.00 // optional - }, - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 360] - } - }, - }; - - it('should be true', function () { - expect(adapter.isBidRequestValid(bid)).to.be.true; - expect(adapter.isBidRequestValid(bid2)).to.be.true; - }); - - it('should be false because the sizes are missing or in the wrong format', function () { - let wrongBid = utils.deepClone(bid); - wrongBid.sizes = '640360'; - expect(adapter.isBidRequestValid(wrongBid)).to.be.false; - - wrongBid = utils.deepClone(bid); - delete wrongBid.sizes; - expect(adapter.isBidRequestValid(wrongBid)).to.be.false; - }); - - it('should be false because the mediaType is missing or wrong', function () { - let wrongBid = utils.deepClone(bid); - wrongBid.mediaTypes = {}; - expect(adapter.isBidRequestValid(wrongBid)).to.be.false; - - wrongBid = utils.deepClone(bid); - delete wrongBid.mediaTypes; - expect(adapter.isBidRequestValid(wrongBid)).to.be.false; - }); - - it('should be false because the env is missing or wrong', function () { - let wrongBid = utils.deepClone(bid); - wrongBid.params.env = 'us'; - expect(adapter.isBidRequestValid(wrongBid)).to.be.false; - - wrongBid = utils.deepClone(bid); - delete wrongBid.params.env; - expect(adapter.isBidRequestValid(wrongBid)).to.be.false; - }); - - it('should be false because params.pubId is missing', function () { - let wrongBid = utils.deepClone(bid); - delete wrongBid.params.pubId; - expect(adapter.isBidRequestValid(wrongBid)).to.be.false; - }); - - it('should be false because params.zoneId is missing', function () { - let wrongBid = utils.deepClone(bid); - delete wrongBid.params.zoneId; - expect(adapter.isBidRequestValid(wrongBid)).to.be.false; - }); - }); - - describe('Check buildRequests method', function () { - // Bids to be formatted - let bid1 = { - bidder: 'vuble', - params: { - env: 'net', - pubId: '3', - zoneId: '12345', - floorPrice: 5.50 // optional - }, - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'instream' - } - }, - bidId: 'abdc', - adUnitCode: '' - }; - let bid2 = { - bidder: 'vuble', - params: { - env: 'com', - pubId: '8', - zoneId: '2468', - referrer: 'https://www.vuble.fr/' - }, - sizes: '640x360', - mediaTypes: { - video: { - context: 'outstream' - } - }, - bidId: 'efgh', - adUnitCode: 'code' - }; - let bid3 = { - bidder: 'vuble', - params: { - env: 'net', - pubId: '3', - zoneId: '3579', - }, - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 360] - } - }, - bidId: 'ijkl', - adUnitCode: '' - }; - - // Formatted requets - let request1 = { - method: 'POST', - url: 'https://player.mediabong.net/prebid/request', - data: { - width: '640', - height: '360', - pub_id: '3', - zone_id: '12345', - context: 'instream', - floor_price: 5.5, - url: '', - env: 'net', - bid_id: 'abdc', - adUnitCode: '' - } - }; - let request2 = { - method: 'POST', - url: 'https://player.mediabong.com/prebid/request', - data: { - width: '640', - height: '360', - pub_id: '8', - zone_id: '2468', - context: 'outstream', - floor_price: 0, - url: 'https://www.vuble.fr/', - env: 'com', - bid_id: 'efgh', - adUnitCode: 'code' - } - }; - let request3 = { - method: 'POST', - url: 'https://player.mediabong.net/prebid/request', - data: { - width: '640', - height: '360', - pub_id: '3', - zone_id: '3579', - context: 'instream', - floor_price: 0, - url: 'https://www.vuble.tv/', - env: 'net', - bid_id: 'ijkl', - adUnitCode: '' - } - }; - let request4 = { - method: 'POST', - url: 'https://player.mediabong.net/prebid/request', - data: { - width: '640', - height: '360', - pub_id: '3', - zone_id: '3579', - context: 'instream', - floor_price: 0, - url: '', - env: 'net', - bid_id: 'ijkl', - adUnitCode: '', - gdpr_consent: { - consent_string: 'test', - gdpr_applies: true - } - } - }; - let bidderRequest1 = { - refererInfo: { - referer: 'https://www.vuble.tv/', - reachedTop: true, - numIframes: 1, - stack: [ - 'http://example.com/page.html', - 'http://example.com/iframe1.html', - 'http://example.com/iframe2.html' - ] - } - }; - let bidderRequest2 = { - 'gdprConsent': { - consentString: 'test', - gdprApplies: true - } - }; - - it('must return the right formatted requests', function () { - expect(adapter.buildRequests([bid1, bid2])).to.deep.equal([request1, request2]); - expect(adapter.buildRequests([bid3], bidderRequest1)).to.deep.equal([request3]); - expect(adapter.buildRequests([bid3], bidderRequest2)).to.deep.equal([request4]); - }); - }); - - describe('Check interpretResponse method return', function () { - // Server's response - let response = { - body: { - status: 'ok', - cpm: 5.00, - creativeId: '2468', - url: 'https//player.mediabong.net/prebid/ad/a1b2c3d4', - dealId: 'MDB-TEST-1357' - } - }; - // bid Request - let bid = { - data: { - context: 'instream', - env: 'net', - width: '640', - height: '360', - pub_id: '3', - zone_id: '12345', - bid_id: 'abdc', - floor_price: 5.50, // optional - adUnitCode: 'code' - }, - method: 'POST', - url: 'https://player.mediabong.net/prebid/request' - }; - // Formatted reponse - let result = { - requestId: 'abdc', - cpm: 5.00, - width: '640', - height: '360', - ttl: 60, - creativeId: '2468', - dealId: 'MDB-TEST-1357', - netRevenue: true, - currency: 'USD', - vastUrl: 'https//player.mediabong.net/prebid/ad/a1b2c3d4', - mediaType: 'video' - }; - - it('should equal to the expected formatted result', function () { - expect(adapter.interpretResponse(response, bid)).to.deep.equal([result]); - }); - - it('should be empty because the status is missing or wrong', function () { - let wrongResponse = utils.deepClone(response); - wrongResponse.body.status = 'ko'; - expect(adapter.interpretResponse(wrongResponse, bid)).to.be.empty; - - wrongResponse = utils.deepClone(response); - delete wrongResponse.body.status; - expect(adapter.interpretResponse(wrongResponse, bid)).to.be.empty; - }); - - it('should be empty because the body is missing or wrong', function () { - let wrongResponse = utils.deepClone(response); - wrongResponse.body = [1, 2, 3]; - expect(adapter.interpretResponse(wrongResponse, bid)).to.be.empty; - - wrongResponse = utils.deepClone(response); - delete wrongResponse.body; - expect(adapter.interpretResponse(wrongResponse, bid)).to.be.empty; - }); - - it('should equal to the expected formatted result', function () { - response.body.renderer_url = 'vuble_renderer.js'; - result.adUnitCode = 'code'; - let formattedResponses = adapter.interpretResponse(response, bid); - expect(formattedResponses[0].adUnitCode).to.equal(result.adUnitCode); - }); - }); - - describe('Check getUserSyncs method return', function () { - // Sync options - let syncOptions = { - iframeEnabled: false - }; - // Server's response - let response = { - body: { - status: 'ok', - cpm: 5.00, - creativeId: '2468', - url: 'https//player.mediabong.net/prebid/ad/a1b2c3d4' - } - }; - // Formatted reponse - let result = { - type: 'iframe', - url: 'https://player.mediabong.net/csifr?1234' - }; - - it('should return an empty array', function () { - expect(adapter.getUserSyncs({}, [])).to.be.empty; - expect(adapter.getUserSyncs({}, [])).to.be.empty; - expect(adapter.getUserSyncs(syncOptions, [response])).to.be.empty; - expect(adapter.getUserSyncs(syncOptions, [response])).to.be.empty; - syncOptions.iframeEnabled = true; - expect(adapter.getUserSyncs(syncOptions, [response])).to.be.empty; - expect(adapter.getUserSyncs(syncOptions, [response])).to.be.empty; - }); - - it('should be equal to the expected result', function () { - response.body.iframeSync = 'https://player.mediabong.net/csifr?1234'; - expect(adapter.getUserSyncs(syncOptions, [response])).to.deep.equal([result]); - }) - }); - - describe('Check outstream scenario with renderer', function () { - // bid Request - let bid = { - data: { - context: 'outstream', - env: 'net', - width: '640', - height: '360', - pub_id: '3', - zone_id: '12345', - bid_id: 'abdc', - floor_price: 5.50, // optional - adUnitCode: 'code' - }, - method: 'POST', - url: 'https://player.mediabong.net/prebid/request' - }; - // Server's response - let response = { - body: { - status: 'ok', - cpm: 5.00, - creativeId: '2468', - url: 'https//player.mediabong.net/prebid/ad/a1b2c3d4', - dealId: 'MDB-TEST-1357', - renderer_id: 0, - renderer_url: 'vuble_renderer.js', - content: 'test' - } - }; - - let adResponse = { - ad: { - video: { - content: 'test' - } - } - }; - let adUnitCode = 'code'; - let rendererUrl = 'vuble_renderer.js'; - let rendererId = 0; - - let formattedResponses = adapter.interpretResponse(response, bid); - it('should equal to the expected format result', function () { - expect(formattedResponses[0].adResponse).to.deep.equal(adResponse); - expect(formattedResponses[0].adUnitCode).to.deep.equal(adUnitCode); - expect(formattedResponses[0].renderer.url).to.equal(rendererUrl); - expect(formattedResponses[0].renderer.id).to.equal(rendererId); - expect(formattedResponses[0].renderer.render).to.exist.and.to.be.a('function'); - }); - }); -}); diff --git a/test/spec/modules/waardexBidAdapter_spec.js b/test/spec/modules/waardexBidAdapter_spec.js index 73094dd72a0..0b2e971aafd 100644 --- a/test/spec/modules/waardexBidAdapter_spec.js +++ b/test/spec/modules/waardexBidAdapter_spec.js @@ -210,14 +210,14 @@ describe('waardexBidAdapter', () => { const { data: payload, url, - method, + method } = spec.buildRequests(validBidRequests, bidderRequest); const ENDPOINT = `https://hb.justbidit.xyz:8843/prebid?pubId=${validBidRequests[0].params.zoneId}`; expect(payload.bidRequests[0]).deep.equal({ bidId: validBidRequests[0].bidId, - bidfloor: validBidRequests[0].params.bidfloor, + bidfloor: 0, position: validBidRequests[0].params.position, instl: validBidRequests[0].params.instl, banner: { @@ -280,7 +280,6 @@ describe('waardexBidAdapter', () => { 'bidRequests': [ { 'bidId': 'unique-bid-id-1', - 'bidfloor': 0.1, 'position': 1, 'instl': 1, 'banner': { 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 222a7611b01..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.001'); - // slot 2 - expect(ortbRequest.imp[1].tagid).to.equal('1234'); - expect(ortbRequest.imp[1].banner).to.not.equal(null); - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); - expect(ortbRequest.imp[1].bidfloor).to.equal('0.000001'); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad', - 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/xhbBidAdapter_spec.js b/test/spec/modules/xhbBidAdapter_spec.js deleted file mode 100644 index a12abc74c64..00000000000 --- a/test/spec/modules/xhbBidAdapter_spec.js +++ /dev/null @@ -1,495 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/xhbBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import { deepClone } from 'src/utils.js'; - -const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid'; - -describe('xhbAdapter', 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': 'xhb', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return true when required params found', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'member': '1234', - 'invCode': 'ABCD' - }; - - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'xhb', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should parse out private sizes', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - privateSizes: [300, 250] - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].private_sizes).to.exist; - expect(payload.tags[0].private_sizes).to.deep.equal([{width: 300, height: 250}]); - }); - - it('should add source and verison to the tag', function () { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.sdk).to.exist; - expect(payload.sdk).to.deep.equal({ - source: 'pbjs', - version: '$prebid.version$' - }); - }); - - it('should populate the ad_types array on all requests', function () { - ['banner', 'video', 'native'].forEach(type => { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes[type] = {}; - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].ad_types).to.deep.equal([type]); - }); - }); - - it('should populate the ad_types array on outstream requests', function () { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes.video = {context: 'outstream'}; - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].ad_types).to.deep.equal(['video']); - }); - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('POST'); - }); - - it('should attach valid video params to the tag', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - video: { - id: 123, - minduration: 100, - foobar: 'invalid' - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.tags[0].video).to.deep.equal({ - id: 123, - minduration: 100 - }); - }); - - it('should attach valid user params to the tag', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - user: { - external_uid: '123', - foobar: 'invalid' - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.user).to.exist; - expect(payload.user).to.deep.equal({ - external_uid: '123', - }); - }); - - it('should attach native params to the request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - title: {required: true}, - body: {required: true}, - image: {required: true, sizes: [{ width: 100, height: 100 }]}, - cta: {required: false}, - sponsoredBy: {required: true} - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - title: {required: true}, - description: {required: true}, - main_image: {required: true, sizes: [{ width: 100, height: 100 }]}, - ctatext: {required: false}, - sponsored_by: {required: true} - }); - }); - - it('sets minimum native asset params when not provided on adunit', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - image: {required: true}, - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - main_image: {required: true, sizes: [{}]}, - }); - }); - - it('does not overwrite native ad unit params with mimimum params', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - image: { - aspect_ratios: [{ - min_width: 100, - ratio_width: 2, - ratio_height: 3, - }] - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - main_image: { - required: true, - aspect_ratios: [{ - min_width: 100, - ratio_width: 2, - ratio_height: 3, - }] - }, - }); - }); - - it('should convert keyword params to proper form and attaches to request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - keywords: { - single: 'val', - singleArr: ['val'], - singleArrNum: [5], - multiValMixed: ['value1', 2, 'value3'], - singleValNum: 123, - badValue: {'foo': 'bar'} // should be dropped - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].keywords).to.deep.equal([{ - 'key': 'single', - 'value': ['val'] - }, { - 'key': 'singleArr', - 'value': ['val'] - }, { - 'key': 'singleArrNum', - 'value': ['5'] - }, { - 'key': 'multiValMixed', - 'value': ['value1', '2', 'value3'] - }, { - 'key': 'singleValNum', - 'value': ['123'] - }]); - }); - - it('should add payment rules to the request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - usePaymentRule: true - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].use_pmt_rule).to.equal(true); - }); - - it('should add gdpr consent information to the request', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let bidderRequest = { - 'bidderCode': 'xhb', - 'auctionId': '1d1a030790a475', - 'bidderRequestId': '22edbae2733bf6', - 'timeout': 3000, - 'gdprConsent': { - consentString: consentString, - gdprApplies: true - } - }; - bidderRequest.bids = bidRequests; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.gdpr_consent).to.exist; - expect(payload.gdpr_consent.consent_string).to.exist.and.to.equal(consentString); - expect(payload.gdpr_consent.consent_required).to.exist.and.to.be.true; - }); - }); - - describe('interpretResponse', function () { - let response = { - 'version': '3.0.0', - 'tags': [ - { - 'uuid': '3db3773286ee59', - 'tag_id': 10433394, - 'auction_id': '4534722592064951574', - 'nobid': false, - 'no_ad_url': 'https://lax1-ib.adnxs.com/no-ad', - 'timeout_ms': 10000, - 'ad_profile_id': 27079, - 'ads': [ - { - 'content_source': 'rtb', - 'ad_type': 'banner', - 'buyer_member_id': 958, - 'creative_id': 29681110, - 'media_type_id': 1, - 'media_subtype_id': 1, - 'cpm': 0.5, - 'cpm_publisher_currency': 0.5, - 'publisher_currency_code': '$', - 'client_initiated_ad_counting': true, - 'rtb': { - 'banner': { - 'content': '', - 'width': 300, - 'height': 250 - }, - 'trackers': [ - { - 'impression_urls': [ - 'https://lax1-ib.adnxs.com/impression' - ], - 'video_events': {} - } - ] - } - } - ] - } - ] - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '3db3773286ee59', - 'cpm': 0.5, - 'creativeId': 29681110, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '', - 'mediaType': 'banner', - 'currency': 'USD', - 'ttl': 300, - 'netRevenue': true, - 'appnexus': { - 'buyerMemberId': 958 - } - } - ]; - let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - let response = { - 'version': '0.0.1', - 'tags': [{ - 'uuid': '84ab500420319d', - 'tag_id': 5976557, - 'auction_id': '297492697822162468', - 'nobid': true - }] - }; - let bidderRequest; - - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result.length).to.equal(0); - }); - - it('handles non-banner media responses', function () { - let response = { - 'tags': [{ - 'uuid': '84ab500420319d', - 'ads': [{ - 'ad_type': 'video', - 'cpm': 0.500000, - 'notify_url': 'imptracker.com', - 'rtb': { - 'video': { - 'content': '' - } - } - }] - }] - }; - let bidderRequest; - - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result[0]).to.have.property('vastUrl'); - expect(result[0]).to.have.property('vastImpUrl'); - expect(result[0]).to.have.property('mediaType', 'video'); - }); - - it('handles native responses', function () { - let response1 = deepClone(response); - response1.tags[0].ads[0].ad_type = 'native'; - response1.tags[0].ads[0].rtb.native = { - 'title': 'Native Creative', - 'desc': 'Cool description great stuff', - 'ctatext': 'Do it', - 'sponsored': 'AppNexus', - 'icon': { - 'width': 0, - 'height': 0, - 'url': 'https://cdn.adnxs.com/icon.png' - }, - 'main_img': { - 'width': 2352, - 'height': 1516, - 'url': 'https://cdn.adnxs.com/img.png' - }, - 'link': { - 'url': 'https://www.appnexus.com', - 'fallback_url': '', - 'click_trackers': ['https://nym1-ib.adnxs.com/click'] - }, - 'impression_trackers': ['https://example.com'], - }; - let bidderRequest; - - let result = spec.interpretResponse({ body: response1 }, {bidderRequest}); - expect(result[0].native.title).to.equal('Native Creative'); - expect(result[0].native.body).to.equal('Cool description great stuff'); - expect(result[0].native.cta).to.equal('Do it'); - expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png'); - }); - - it('supports configuring outstream renderers', function () { - const outstreamResponse = deepClone(response); - outstreamResponse.tags[0].ads[0].rtb.video = {}; - outstreamResponse.tags[0].ads[0].renderer_url = 'renderer.js'; - - const bidderRequest = { - bids: [{ - renderer: { - options: { - adText: 'configured' - } - } - }] - }; - - const result = spec.interpretResponse({ body: outstreamResponse }, {bidderRequest}); - expect(result[0].renderer.config).to.deep.equal( - bidderRequest.bids[0].renderer.options - ); - }); - }); -}); 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); - }); - }); -}); diff --git a/test/spec/modules/zemantaBidAdapter_spec.js b/test/spec/modules/zemantaBidAdapter_spec.js deleted file mode 100644 index 523cdcd2eb3..00000000000 --- a/test/spec/modules/zemantaBidAdapter_spec.js +++ /dev/null @@ -1,558 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/zemantaBidAdapter.js'; -import {config} from 'src/config.js'; -import {server} from 'test/mocks/xhr'; - -describe('Zemanta Adapter', function () { - describe('Bid request and response', function () { - const commonBidRequest = { - bidder: 'zemanta', - params: { - publisher: { - id: 'publisher-id' - }, - }, - bidId: '2d6815a92ba1ba', - auctionId: '12043683-3254-4f74-8934-f941b085579e', - } - const nativeBidRequestParams = { - nativeParams: { - image: { - required: true, - sizes: [ - 120, - 100 - ], - sendId: true - }, - title: { - required: true, - sendId: true - }, - sponsoredBy: { - required: false - } - }, - } - - const displayBidRequestParams = { - sizes: [ - [ - 300, - 250 - ] - ] - } - - describe('isBidRequestValid', function () { - before(() => { - config.setConfig({ - zemanta: { - bidderUrl: 'https://bidder-url.com', - } - } - ) - }) - after(() => { - config.resetConfig() - }) - - it('should fail when bid is invalid', function () { - const bid = { - bidder: 'zemanta', - params: { - publisher: { - id: 'publisher-id', - } - }, - } - expect(spec.isBidRequestValid(bid)).to.equal(false) - }) - it('should succeed when bid contains native params', function () { - const bid = { - bidder: 'zemanta', - params: { - publisher: { - id: 'publisher-id', - } - }, - ...nativeBidRequestParams, - } - expect(spec.isBidRequestValid(bid)).to.equal(true) - }) - it('should succeed when bid contains sizes', function () { - const bid = { - bidder: 'zemanta', - params: { - publisher: { - id: 'publisher-id', - } - }, - ...displayBidRequestParams, - } - expect(spec.isBidRequestValid(bid)).to.equal(true) - }) - it('should fail if publisher id is not set', function () { - const bid = { - bidder: 'zemanta', - ...nativeBidRequestParams, - } - expect(spec.isBidRequestValid(bid)).to.equal(false) - }) - it('should succeed with outbrain config', function () { - const bid = { - bidder: 'zemanta', - params: { - publisher: { - id: 'publisher-id', - } - }, - ...nativeBidRequestParams, - } - config.resetConfig() - config.setConfig({ - outbrain: { - bidderUrl: 'https://bidder-url.com', - } - }) - expect(spec.isBidRequestValid(bid)).to.equal(true) - }) - it('should fail if bidder url is not set', function () { - const bid = { - bidder: 'zemanta', - params: { - publisher: { - id: 'publisher-id', - } - }, - ...nativeBidRequestParams, - } - config.resetConfig() - expect(spec.isBidRequestValid(bid)).to.equal(false) - }) - }) - - describe('buildRequests', function () { - before(() => { - config.setConfig({ - zemanta: { - bidderUrl: 'https://bidder-url.com', - } - } - ) - }) - after(() => { - config.resetConfig() - }) - - const commonBidderRequest = { - refererInfo: { - referer: 'https://example.com/' - } - } - - it('should build native request', function () { - const bidRequest = { - ...commonBidRequest, - ...nativeBidRequestParams, - } - const expectedNativeAssets = { - assets: [ - { - required: 1, - id: 3, - img: { - type: 3, - w: 120, - h: 100 - } - }, - { - required: 1, - id: 0, - title: {} - }, - { - required: 0, - id: 5, - data: { - type: 1 - } - } - ] - } - const expectedData = { - site: { - page: 'https://example.com/', - publisher: { - id: 'publisher-id' - } - }, - device: { - ua: navigator.userAgent - }, - source: { - fd: 1 - }, - cur: [ - 'USD' - ], - imp: [ - { - id: '1', - native: { - request: JSON.stringify(expectedNativeAssets) - } - } - ] - } - const res = spec.buildRequests([bidRequest], commonBidderRequest) - expect(res.url).to.equal('https://bidder-url.com') - expect(res.data).to.deep.equal(JSON.stringify(expectedData)) - }); - - it('should build display request', function () { - const bidRequest = { - ...commonBidRequest, - ...displayBidRequestParams, - } - const expectedData = { - site: { - page: 'https://example.com/', - publisher: { - id: 'publisher-id' - } - }, - device: { - ua: navigator.userAgent - }, - source: { - fd: 1 - }, - cur: [ - 'USD' - ], - imp: [ - { - id: '1', - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - } - } - ] - } - const res = spec.buildRequests([bidRequest], commonBidderRequest) - expect(res.url).to.equal('https://bidder-url.com') - expect(res.data).to.deep.equal(JSON.stringify(expectedData)) - }) - - it('should pass optional parameters in request', function () { - const bidRequest = { - ...commonBidRequest, - ...nativeBidRequestParams, - } - bidRequest.params.tagid = 'test-tag' - bidRequest.params.publisher.name = 'test-publisher' - bidRequest.params.publisher.domain = 'test-publisher.com' - bidRequest.params.bcat = ['bad-category'] - bidRequest.params.badv = ['bad-advertiser'] - - const res = spec.buildRequests([bidRequest], commonBidderRequest) - const resData = JSON.parse(res.data) - expect(resData.imp[0].tagid).to.equal('test-tag') - expect(resData.site.publisher.name).to.equal('test-publisher') - expect(resData.site.publisher.domain).to.equal('test-publisher.com') - expect(resData.bcat).to.deep.equal(['bad-category']) - expect(resData.badv).to.deep.equal(['bad-advertiser']) - }); - - it('should pass bidder timeout', function () { - const bidRequest = { - ...commonBidRequest, - ...nativeBidRequestParams, - } - const bidderRequest = { - ...commonBidderRequest, - timeout: 500 - } - const res = spec.buildRequests([bidRequest], bidderRequest) - const resData = JSON.parse(res.data) - expect(resData.tmax).to.equal(500) - }); - - it('should pass GDPR consent', function () { - const bidRequest = { - ...commonBidRequest, - ...nativeBidRequestParams, - } - const bidderRequest = { - ...commonBidderRequest, - gdprConsent: { - gdprApplies: true, - consentString: 'consentString', - } - } - const res = spec.buildRequests([bidRequest], bidderRequest) - const resData = JSON.parse(res.data) - expect(resData.user.ext.consent).to.equal('consentString') - expect(resData.regs.ext.gdpr).to.equal(1) - }); - - it('should pass us privacy consent', function () { - const bidRequest = { - ...commonBidRequest, - ...nativeBidRequestParams, - } - const bidderRequest = { - ...commonBidderRequest, - uspConsent: 'consentString' - } - const res = spec.buildRequests([bidRequest], bidderRequest) - const resData = JSON.parse(res.data) - expect(resData.regs.ext.us_privacy).to.equal('consentString') - }); - - it('should pass coppa consent', function () { - const bidRequest = { - ...commonBidRequest, - ...nativeBidRequestParams, - } - config.setConfig({coppa: true}) - - const res = spec.buildRequests([bidRequest], commonBidderRequest) - const resData = JSON.parse(res.data) - expect(resData.regs.coppa).to.equal(1) - - config.resetConfig() - }); - }) - - describe('interpretResponse', function () { - it('should return empty array if no valid bids', function () { - const res = spec.interpretResponse({}, []) - expect(res).to.be.an('array').that.is.empty - }); - - it('should interpret native response', function () { - const serverResponse = { - body: { - id: '0a73e68c-9967-4391-b01b-dda2d9fc54e4', - seatbid: [ - { - bid: [ - { - id: '82822cf5-259c-11eb-8a52-f29e5275aa57', - impid: '1', - price: 1.1, - nurl: 'http://example.com/win/${AUCTION_PRICE}', - adm: '{"ver":"1.2","assets":[{"id":3,"required":1,"img":{"url":"http://example.com/img/url","w":120,"h":100}},{"id":0,"required":1,"title":{"text":"Test title"}},{"id":5,"data":{"value":"Test sponsor"}}],"link":{"url":"http://example.com/click/url"},"eventtrackers":[{"event":1,"method":1,"url":"http://example.com/impression"}]}', - adomain: [ - 'example.com' - ], - cid: '3487171', - crid: '28023739', - cat: [ - 'IAB10-2' - ] - } - ], - seat: 'acc-5537' - } - ], - bidid: '82822cf5-259c-11eb-8a52-b48e7518c657', - cur: 'USD' - }, - } - const request = { - bids: [ - { - ...commonBidRequest, - ...nativeBidRequestParams, - } - ] - } - const expectedRes = [ - { - requestId: request.bids[0].bidId, - cpm: 1.1, - creativeId: '28023739', - ttl: 360, - netRevenue: false, - currency: 'USD', - mediaType: 'native', - nurl: 'http://example.com/win/${AUCTION_PRICE}', - meta: { - 'advertiserDomains': [ - 'example.com' - ] - }, - native: { - clickTrackers: undefined, - clickUrl: 'http://example.com/click/url', - image: { - url: 'http://example.com/img/url', - width: 120, - height: 100 - }, - title: 'Test title', - sponsoredBy: 'Test sponsor', - impressionTrackers: [ - 'http://example.com/impression', - ] - } - } - ] - - const res = spec.interpretResponse(serverResponse, request) - expect(res).to.deep.equal(expectedRes) - }); - - it('should interpret display response', function () { - const serverResponse = { - body: { - id: '6b2eedc8-8ff5-46ef-adcf-e701b508943e', - seatbid: [ - { - bid: [ - { - id: 'd90fe7fa-28d7-11eb-8ce4-462a842a7cf9', - impid: '1', - price: 1.1, - nurl: 'http://example.com/win/${AUCTION_PRICE}', - adm: '
ad
', - adomain: [ - 'example.com' - ], - cid: '3865084', - crid: '29998660', - cat: [ - 'IAB10-2' - ], - w: 300, - h: 250 - } - ], - seat: 'acc-6536' - } - ], - bidid: 'd90fe7fa-28d7-11eb-8ce4-13d94bfa26f9', - cur: 'USD' - } - } - const request = { - bids: [ - { - ...commonBidRequest, - ...displayBidRequestParams - } - ] - } - const expectedRes = [ - { - requestId: request.bids[0].bidId, - cpm: 1.1, - creativeId: '29998660', - ttl: 360, - netRevenue: false, - currency: 'USD', - mediaType: 'banner', - nurl: 'http://example.com/win/${AUCTION_PRICE}', - ad: '
ad
', - width: 300, - height: 250, - meta: { - 'advertiserDomains': [ - 'example.com' - ] - }, - } - ] - - const res = spec.interpretResponse(serverResponse, request) - expect(res).to.deep.equal(expectedRes) - }); - }) - }) - - describe('getUserSyncs', function () { - const usersyncUrl = 'https://usersync-url.com'; - beforeEach(() => { - config.setConfig({ - zemanta: { - usersyncUrl: usersyncUrl, - } - } - ) - }) - after(() => { - config.resetConfig() - }) - - it('should return user sync if pixel enabled', function () { - const ret = spec.getUserSyncs({pixelEnabled: true}) - expect(ret).to.deep.equal([{type: 'image', url: 'https://usersync-url.com'}]) - }) - it('should return user sync if pixel enabled with outbrain config', function () { - config.resetConfig() - config.setConfig({ - outbrain: { - usersyncUrl: 'https://usersync-url.com', - } - }) - const ret = spec.getUserSyncs({pixelEnabled: true}) - expect(ret).to.deep.equal([{type: 'image', url: 'https://usersync-url.com'}]) - }) - - it('should not return user sync if pixel disabled', function () { - const ret = spec.getUserSyncs({pixelEnabled: false}) - expect(ret).to.be.an('array').that.is.empty - }) - - it('should not return user sync if url is not set', function () { - config.resetConfig() - const ret = spec.getUserSyncs({pixelEnabled: true}) - expect(ret).to.be.an('array').that.is.empty - }) - - it('should pass GDPR consent', function() { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=foo` - }]); - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=0&gdpr_consent=foo` - }]); - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=` - }]); - }); - - it('should pass US consent', function() { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&us_privacy=1NYN` - }]); - }); - - it('should pass GDPR and US consent', function() { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, '1NYN')).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=foo&us_privacy=1NYN` - }]); - }); - }) - - describe('onBidWon', function () { - it('should make an ajax call with the original cpm', function () { - const bid = { - nurl: 'http://example.com/win/${AUCTION_PRICE}', - cpm: 2.1, - originalCpm: 1.1, - } - spec.onBidWon(bid) - expect(server.requests[0].url).to.equals('http://example.com/win/1.1') - }); - }) -}) diff --git a/test/spec/refererDetection_spec.js b/test/spec/refererDetection_spec.js index 46990ae841f..a404e4f883e 100644 --- a/test/spec/refererDetection_spec.js +++ b/test/spec/refererDetection_spec.js @@ -1,4 +1,5 @@ import { detectReferer } from 'src/refererDetection.js'; +import { config } from 'src/config.js'; import { expect } from 'chai'; /** @@ -91,6 +92,10 @@ function buildWindowTree(urls, topReferrer = '', canonicalUrl = null, ancestorOr describe('Referer detection', () => { describe('Non cross-origin scenarios', () => { describe('No iframes', () => { + afterEach(function () { + config.resetConfig(); + }); + it('Should return the current window location and no canonical URL', () => { const testWindow = buildWindowTree(['https://example.com/some/page'], 'https://othersite.com/'), result = detectReferer(testWindow)(); @@ -156,6 +161,26 @@ describe('Referer detection', () => { canonicalUrl: 'https://example.com/canonical/page' }); }); + + it('Should override canonical URL with config pageUrl', () => { + config.setConfig({'pageUrl': 'testUrl.com'}); + + const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'), + result = detectReferer(testWindow)(); + + expect(result).to.deep.equal({ + referer: 'https://example.com/some/page', + reachedTop: true, + isAmp: false, + numIframes: 2, + stack: [ + 'https://example.com/some/page', + 'https://example.com/other/page', + 'https://example.com/third/page' + ], + canonicalUrl: 'testUrl.com' + }); + }); }); }); diff --git a/test/spec/sizeMapping_spec.js b/test/spec/sizeMapping_spec.js index 78dd9797c36..a3c39a52441 100644 --- a/test/spec/sizeMapping_spec.js +++ b/test/spec/sizeMapping_spec.js @@ -93,6 +93,15 @@ describe('sizeMapping', function () { expect(utils.logWarn.firstCall.args[0]).to.match(/missing.+?mediaQuery/); }); + it('should log a warning message when mediaQuery property is declared as an empty string', function() { + const errorConfig = deepClone(sizeConfig); + errorConfig[0].mediaQuery = ''; + + sandbox.stub(utils, 'logWarn'); + resolveStatus(undefined, testSizes, undefined, errorConfig); + expect(utils.logWarn.firstCall.args[0]).to.match(/missing.+?mediaQuery/); + }); + it('should allow deprecated adUnit.sizes', function() { matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 0bd3380f737..199ce699dc8 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -1783,6 +1783,42 @@ describe('Unit: Prebid Module', function () { expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[300, 250]]); expect(auctionArgs.adUnits[0].mediaTypes.banner.sizes).to.deep.equal([[300, 250]]); }); + + it('should filter mediaType pos value if not integer', function () { + let adUnit = [{ + code: 'test5', + bids: [], + sizes: [300, 250], + mediaTypes: { + banner: { + sizes: [300, 250], + pos: 'foo' + } + } + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: adUnit + }); + expect(auctionArgs.adUnits[0].mediaTypes.banner.pos).to.be.undefined; + }); + + it('should pass mediaType pos value if integer', function () { + let adUnit = [{ + code: 'test5', + bids: [], + sizes: [300, 250], + mediaTypes: { + banner: { + sizes: [300, 250], + pos: 2 + } + } + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: adUnit + }); + expect(auctionArgs.adUnits[0].mediaTypes.banner.pos).to.equal(2); + }); }); describe('negative tests for validating adUnits', function() {