diff --git a/modules/welectBidAdapter.js b/modules/welectBidAdapter.js deleted file mode 100644 index c90a3d29498..00000000000 --- a/modules/welectBidAdapter.js +++ /dev/null @@ -1,106 +0,0 @@ -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'welect'; -const DEFAULT_DOMAIN = 'www.welect.de'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['wlt'], - gvlid: 282, - supportedMediaTypes: ['video'], - - // 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 ( - utils.deepAccess(bid, 'mediaTypes.video.context') === 'instream' && - !!bid.params.placementId - ); - }, - /** - * 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) { - return validBidRequests.map((bidRequest) => { - let rawSizes = - utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize') || - bidRequest.sizes; - let size = rawSizes[0]; - - let domain = bidRequest.params.domain || DEFAULT_DOMAIN; - - let url = `https://${domain}/api/v2/preflight/${bidRequest.params.placementId}`; - - let gdprConsent = null; - - if (bidRequest && bidRequest.gdprConsent) { - gdprConsent = { - gdpr_consent: { - gdprApplies: bidRequest.gdprConsent.gdprApplies, - tcString: bidRequest.gdprConsent.gdprConsent, - }, - }; - } - - const data = { - width: size[0], - height: size[1], - bid_id: bidRequest.bidId, - ...gdprConsent, - }; - - return { - method: 'POST', - url: url, - data: data, - options: { - contentType: 'application/json', - withCredentials: false, - crossOrigin: true, - }, - }; - }); - }, - /** - * 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 responseBody = serverResponse.body; - - if (typeof responseBody !== 'object' || responseBody.available !== true) { - return []; - } - - const bidResponses = []; - const bidResponse = { - requestId: responseBody.bidResponse.requestId, - cpm: responseBody.bidResponse.cpm, - width: responseBody.bidResponse.width, - height: responseBody.bidResponse.height, - creativeId: responseBody.bidResponse.creativeId, - currency: responseBody.bidResponse.currency, - netRevenue: responseBody.bidResponse.netRevenue, - ttl: responseBody.bidResponse.ttl, - ad: responseBody.bidResponse.ad, - vastUrl: responseBody.bidResponse.vastUrl, - meta: { - advertiserDomains: responseBody.bidResponse.meta.advertiserDomains - } - }; - bidResponses.push(bidResponse); - return bidResponses; - }, -}; -registerBidder(spec); diff --git a/modules/widespaceBidAdapter.js b/modules/widespaceBidAdapter.js deleted file mode 100644 index 7a6deec3004..00000000000 --- a/modules/widespaceBidAdapter.js +++ /dev/null @@ -1,258 +0,0 @@ -import {config} from '../src/config.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { - parseQueryStringParameters, - parseSizesInput -} from '../src/utils.js'; -import includes from 'core-js-pure/features/array/includes.js'; -import find from 'core-js-pure/features/array/find.js'; -import { getStorageManager } from '../src/storageManager.js'; - -export const storage = getStorageManager(); - -const BIDDER_CODE = 'widespace'; -const WS_ADAPTER_VERSION = '2.0.1'; -const LS_KEYS = { - PERF_DATA: 'wsPerfData', - LC_UID: 'wsLcuid', - CUST_DATA: 'wsCustomData' -}; - -let preReqTime = 0; - -export const spec = { - code: BIDDER_CODE, - - supportedMediaTypes: ['banner'], - - isBidRequestValid: function (bid) { - if (bid.params && bid.params.sid) { - return true; - } - return false; - }, - - buildRequests: function (validBidRequests, bidderRequest) { - let serverRequests = []; - const REQUEST_SERVER_URL = getEngineUrl(); - const DEMO_DATA_PARAMS = ['gender', 'country', 'region', 'postal', 'city', 'yob']; - const PERF_DATA = getData(LS_KEYS.PERF_DATA).map(perfData => JSON.parse(perfData)); - const CUST_DATA = getData(LS_KEYS.CUST_DATA, false)[0]; - const LC_UID = getLcuid(); - - let isInHostileIframe = false; - try { - window.top.location.toString(); - isInHostileIframe = false; - } catch (e) { - isInHostileIframe = true; - } - - validBidRequests.forEach((bid, i) => { - let data = { - 'screenWidthPx': screen && screen.width, - 'screenHeightPx': screen && screen.height, - 'adSpaceHttpRefUrl': getTopWindowReferrer(), - 'referer': (isInHostileIframe ? window : window.top).location.href.split('#')[0], - 'inFrame': 1, - 'sid': bid.params.sid, - 'lcuid': LC_UID, - 'vol': isInHostileIframe ? '' : visibleOnLoad(document.getElementById(bid.adUnitCode)), - 'gdprCmp': bidderRequest && bidderRequest.gdprConsent ? 1 : 0, - 'hb': '1', - 'hb.cd': CUST_DATA ? encodedParamValue(CUST_DATA) : '', - 'hb.floor': '', - 'hb.spb': i === 0 ? pixelSyncPossibility() : -1, - 'hb.ver': WS_ADAPTER_VERSION, - 'hb.name': 'prebidjs-$prebid.version$', - 'hb.bidId': bid.bidId, - 'hb.sizes': parseSizesInput(bid.sizes).join(','), - 'hb.currency': bid.params.cur || bid.params.currency || '' - }; - - // Include demo data - if (bid.params.demo) { - DEMO_DATA_PARAMS.forEach((key) => { - if (bid.params.demo[key]) { - data[key] = bid.params.demo[key]; - } - }); - } - - // Include performance data - if (PERF_DATA[i]) { - Object.keys(PERF_DATA[i]).forEach((perfDataKey) => { - data[perfDataKey] = PERF_DATA[i][perfDataKey]; - }); - } - - // Include connection info if available - const CONNECTION = navigator.connection || navigator.webkitConnection; - if (CONNECTION && CONNECTION.type && CONNECTION.downlinkMax) { - data['netinfo.type'] = CONNECTION.type; - data['netinfo.downlinkMax'] = CONNECTION.downlinkMax; - } - - // Include debug data when available - if (!isInHostileIframe) { - const DEBUG_AD = (find(window.top.location.hash.split('&'), - val => includes(val, 'WS_DEBUG_FORCEADID') - ) || '').split('=')[1]; - data.forceAdId = DEBUG_AD; - } - - // GDPR Consent info - if (data.gdprCmp) { - const {gdprApplies, consentString, vendorData} = bidderRequest.gdprConsent; - const hasGlobalScope = vendorData && vendorData.hasGlobalScope; - data.gdprApplies = gdprApplies ? 1 : gdprApplies === undefined ? '' : 0; - data.gdprConsentData = consentString; - data.gdprHasGlobalScope = hasGlobalScope ? 1 : hasGlobalScope === undefined ? '' : 0; - } - - // Remove empty params - Object.keys(data).forEach((key) => { - if (data[key] === '' || data[key] === undefined) { - delete data[key]; - } - }); - - serverRequests.push({ - method: 'POST', - options: { - contentType: 'application/x-www-form-urlencoded' - }, - url: REQUEST_SERVER_URL, - data: parseQueryStringParameters(data) - }); - }); - preReqTime = Date.now(); - return serverRequests; - }, - - interpretResponse: function (serverResponse, request) { - const responseTime = Date.now() - preReqTime; - const successBids = serverResponse.body || []; - let bidResponses = []; - successBids.forEach((bid) => { - storeData({ - 'perf_status': 'OK', - 'perf_reqid': bid.reqId, - 'perf_ms': responseTime - }, `${LS_KEYS.PERF_DATA}${bid.reqId}`); - if (bid.status === 'ad') { - bidResponses.push({ - requestId: bid.bidId, - cpm: bid.cpm, - width: bid.width, - height: bid.height, - creativeId: bid.adId, - currency: bid.currency, - netRevenue: Boolean(bid.netRev), - ttl: bid.ttl, - referrer: getTopWindowReferrer(), - ad: bid.code - }); - } - }); - - return bidResponses - }, - - getUserSyncs: function (syncOptions, serverResponses = []) { - let userSyncs = []; - userSyncs = serverResponses.reduce((allSyncPixels, response) => { - if (response && response.body && response.body[0]) { - (response.body[0].syncPixels || []).forEach((url) => { - allSyncPixels.push({type: 'image', url}); - }); - } - return allSyncPixels; - }, []); - return userSyncs; - } -}; - -function storeData(data, name, stringify = true) { - const value = stringify ? JSON.stringify(data) : data; - if (storage.hasLocalStorage()) { - storage.setDataInLocalStorage(name, value); - return true; - } else if (storage.cookiesAreEnabled()) { - const theDate = new Date(); - const expDate = new Date(theDate.setMonth(theDate.getMonth() + 12)).toGMTString(); - storage.setCookie(name, value, expDate); - return true; - } -} - -function getData(name, remove = true) { - let data = []; - if (storage.hasLocalStorage()) { - Object.keys(localStorage).filter((key) => { - if (key.indexOf(name) > -1) { - data.push(storage.getDataFromLocalStorage(key)); - if (remove) { - storage.removeDataFromLocalStorage(key); - } - } - }); - } - - if (storage.cookiesAreEnabled()) { - document.cookie.split(';').forEach((item) => { - let value = item.split('='); - if (value[0].indexOf(name) > -1) { - data.push(value[1]); - if (remove) { - storage.setCookie(value[0], '', 'Thu, 01 Jan 1970 00:00:01 GMT'); - } - } - }); - } - return data; -} - -function pixelSyncPossibility() { - const userSync = config.getConfig('userSync'); - return userSync && userSync.pixelEnabled && userSync.syncEnabled ? userSync.syncsPerBidder : -1; -} - -function visibleOnLoad(element) { - if (element && element.getBoundingClientRect) { - const topPos = element.getBoundingClientRect().top; - return topPos < screen.height && topPos >= window.top.pageYOffset ? 1 : 0; - } - ; - return ''; -} - -function getLcuid() { - let lcuid = getData(LS_KEYS.LC_UID, false)[0]; - if (!lcuid) { - const random = ('4' + new Date().getTime() + String(Math.floor(Math.random() * 1000000000))).substring(0, 18); - storeData(random, LS_KEYS.LC_UID, false); - lcuid = getData(LS_KEYS.LC_UID, false)[0]; - } - return lcuid; -} - -function encodedParamValue(value) { - const requiredStringify = typeof JSON.parse(JSON.stringify(value)) === 'object'; - return encodeURIComponent(requiredStringify ? JSON.stringify(value) : value); -} - -function getEngineUrl() { - const ENGINE_URL = 'https://engine.widespace.com/map/engine/dynadreq'; - return window.wisp && window.wisp.ENGINE_URL ? window.wisp.ENGINE_URL : ENGINE_URL; -} - -function getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } -} - -registerBidder(spec); diff --git a/modules/windtalkerBidAdapter.js b/modules/windtalkerBidAdapter.js deleted file mode 100644 index 788c98449de..00000000000 --- a/modules/windtalkerBidAdapter.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: 'windtalker', - 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://windtalkerdisplay.hb.adp3.net/', - 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: '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('windtalker.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/wipesBidAdapter.js b/modules/wipesBidAdapter.js deleted file mode 100644 index f381bcb68a0..00000000000 --- a/modules/wipesBidAdapter.js +++ /dev/null @@ -1,71 +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 = 'wipes'; -const ALIAS_BIDDER_CODE = ['wi']; -const SUPPORTED_MEDIA_TYPES = [BANNER] -const ENDPOINT_URL = 'https://adn-srv.reckoner-api.com/v1/prebid'; - -function isBidRequestValid(bid) { - switch (true) { - case !!(bid.params.asid): - break; - default: - utils.logWarn(`isBidRequestValid Error. ${bid.params}, please check your implementation.`); - return false; - } - return true; -} - -function buildRequests(validBidRequests, bidderRequest) { - return validBidRequests.map(bidRequest => { - const bidId = bidRequest.bidId - const params = bidRequest.params; - const asid = params.asid; - return { - method: 'GET', - url: ENDPOINT_URL, - data: { - asid: asid, - bid_id: bidId, - } - } - }); -} - -function interpretResponse(serverResponse, bidRequest) { - const bidResponses = []; - const response = serverResponse.body; - const cpm = response.cpm || 0; - if (cpm !== 0) { - const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue; - const bidResponse = { - requestId: response.bid_id, - cpm: cpm, - width: response.width, - height: response.height, - creativeId: response.video_creative_id || 0, - dealId: response.deal_id, - currency: 'JPY', - netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), - referrer: bidRequest.data.r || '', - mediaType: BANNER, - ad: response.ad_tag, - }; - bidResponses.push(bidResponse); - } - return bidResponses; -} - -export const spec = { - code: BIDDER_CODE, - aliases: ALIAS_BIDDER_CODE, - isBidRequestValid, - buildRequests, - interpretResponse, - supportedMediaTypes: SUPPORTED_MEDIA_TYPES -} -registerBidder(spec); diff --git a/modules/zedoBidAdapter.js b/modules/zedoBidAdapter.js deleted file mode 100644 index e75b9c82065..00000000000 --- a/modules/zedoBidAdapter.js +++ /dev/null @@ -1,342 +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'; -import { Renderer } from '../src/Renderer.js'; -import { getRefererInfo } from '../src/refererDetection.js'; - -const BIDDER_CODE = 'zedo'; -const SECURE_URL = 'https://saxp.zedo.com/asw/fmh.json'; -const DIM_TYPE = { - '7': 'display', - '9': 'display', - '14': 'display', - '70': 'SBR', - '83': 'CurtainRaiser', - '85': 'Inarticle', - '86': 'pswipeup', - '88': 'Inview', - '100': 'display', - '101': 'display', - '102': 'display', - '103': 'display' - // '85': 'pre-mid-post-roll', -}; -const SECURE_EVENT_PIXEL_URL = 'tt1.zedo.com/log/p.gif'; - -export const spec = { - code: BIDDER_CODE, - aliases: [], - 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 && bid.params.channelCode && bid.params.dimId); - }, - - /** - * 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) { - let data = { - placements: [] - }; - bidRequests.map(bidRequest => { - let channelCode = parseInt(bidRequest.params.channelCode); - let network = parseInt(channelCode / 1000000); - let channel = channelCode % 1000000; - let dim = getSizes(bidRequest.sizes); - let placement = { - id: bidRequest.bidId, - network: network, - channel: channel, - publisher: bidRequest.params.pubId ? bidRequest.params.pubId : 0, - width: dim[0], - height: dim[1], - dimension: bidRequest.params.dimId, - version: '$prebid.version$', - keyword: '', - transactionId: bidRequest.transactionId - } - if (bidderRequest && bidderRequest.gdprConsent) { - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - data.gdpr = Number(bidderRequest.gdprConsent.gdprApplies); - } - data.gdpr_consent = bidderRequest.gdprConsent.consentString; - } - // Add CCPA consent string - if (bidderRequest && bidderRequest.uspConsent) { - data.usp = bidderRequest.uspConsent; - } - - let dimType = DIM_TYPE[String(bidRequest.params.dimId)] - if (dimType) { - placement['renderers'] = [{ - 'name': dimType - }] - } else { // default to display - placement['renderers'] = [{ - 'name': 'display' - }] - } - data['placements'].push(placement); - }); - // adding schain object - if (bidRequests[0].schain) { - data['supplyChain'] = getSupplyChain(bidRequests[0].schain); - } - return { - method: 'GET', - url: SECURE_URL, - data: 'g=' + JSON.stringify(data) - } - }, - - /** - * 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) { - serverResponse = serverResponse.body; - const bids = []; - if (!serverResponse || serverResponse.error) { - let errorMessage = `in response for ${request.bidderCode} adapter`; - if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; } - utils.logError(errorMessage); - return bids; - } - - if (serverResponse.ad) { - serverResponse.ad.forEach(ad => { - const creativeBid = getCreative(ad); - if (creativeBid) { - if (parseInt(creativeBid.cpm) !== 0) { - const bid = newBid(ad, creativeBid, request); - bid.mediaType = parseMediaType(creativeBid); - bids.push(bid); - } - } - }); - } - return bids; - }, - - getUserSyncs: function (syncOptions, responses, gdprConsent) { - if (syncOptions.iframeEnabled) { - let url = 'https://tt3.zedo.com/rs/us/fcs.html'; - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - // add 'gdpr' only if 'gdprApplies' is defined - if (typeof gdprConsent.gdprApplies === 'boolean') { - url += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - url += `?gdpr_consent=${gdprConsent.consentString}`; - } - } - return [{ - type: 'iframe', - url: url - }]; - } - }, - - onTimeout: function (timeoutData) { - try { - logEvent('117', timeoutData); - } catch (e) { - utils.logError(e); - } - }, - - onBidWon: function (bid) { - try { - logEvent('116', [bid]); - } catch (e) { - utils.logError(e); - } - } - -}; - -function getSupplyChain (supplyChain) { - return { - complete: supplyChain.complete, - nodes: supplyChain.nodes - } -}; - -function getCreative(ad) { - return ad && ad.creatives && ad.creatives.length && find(ad.creatives, creative => creative.adId); -}; -/** - * Unpack the Server's Bid into a Prebid-compatible one. - * @param serverBid - * @param rtbBid - * @param bidderRequest - * @return Bid - */ -function newBid(serverBid, creativeBid, bidderRequest) { - const bid = { - requestId: serverBid.slotId, - creativeId: creativeBid.adId, - network: serverBid.network, - adType: creativeBid.creativeDetails.type, - dealId: 99999999, - currency: 'USD', - netRevenue: true, - ttl: 300 - }; - - if (creativeBid.creativeDetails.type === 'VAST') { - Object.assign(bid, { - width: creativeBid.width, - height: creativeBid.height, - vastXml: creativeBid.creativeDetails.adContent, - cpm: parseInt(creativeBid.bidCpm) / 1000000, - ttl: 3600 - }); - const rendererOptions = utils.deepAccess( - bidderRequest, - 'renderer.options' - ); - let rendererUrl = 'https://ss3.zedo.com/gecko/beta/fmpbgt.min.js'; - Object.assign(bid, { - adResponse: serverBid, - renderer: getRenderer(bid.adUnitCode, serverBid.slotId, rendererUrl, rendererOptions) - }); - } else { - Object.assign(bid, { - width: creativeBid.width, - height: creativeBid.height, - cpm: parseInt(creativeBid.bidCpm) / 1000000, - ad: creativeBid.creativeDetails.adContent, - }); - } - - return bid; -} -/* Turn bid request sizes into compatible format */ -function getSizes(requestSizes) { - let width = 0; - let height = 0; - if (utils.isArray(requestSizes) && requestSizes.length === 2 && - !utils.isArray(requestSizes[0])) { - width = parseInt(requestSizes[0], 10); - height = parseInt(requestSizes[1], 10); - } else if (typeof requestSizes === 'object') { - for (let i = 0; i < requestSizes.length; i++) { - let size = requestSizes[i]; - width = parseInt(size[0], 10); - height = parseInt(size[1], 10); - break; - } - } - return [width, height]; -} - -function getRenderer(adUnitCode, rendererId, rendererUrl, rendererOptions = {}) { - const renderer = Renderer.install({ - id: rendererId, - url: rendererUrl, - config: rendererOptions, - loaded: false, - }); - - try { - renderer.setRender(videoRenderer); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - - renderer.setEventHandlers({ - impression: () => utils.logMessage('ZEDO video impression'), - loaded: () => utils.logMessage('ZEDO video loaded'), - ended: () => { - utils.logMessage('ZEDO renderer video ended'); - document.querySelector(`#${adUnitCode}`).style.display = 'none'; - } - }); - return renderer; -} - -function videoRenderer(bid) { - // push to render queue - const refererInfo = getRefererInfo(); - let referrer = ''; - if (refererInfo) { - referrer = refererInfo.referer; - } - bid.renderer.push(() => { - let channelCode = utils.deepAccess(bid, 'params.0.channelCode') || 0; - let dimId = utils.deepAccess(bid, 'params.0.dimId') || 0; - let publisher = utils.deepAccess(bid, 'params.0.pubId') || 0; - let options = utils.deepAccess(bid, 'params.0.options') || {}; - let channel = (channelCode > 0) ? (channelCode - (bid.network * 1000000)) : 0; - - var rndr = new window.ZdPBTag(bid.adUnitCode, bid.network, bid.width, bid.height, bid.adType, bid.vastXml, channel, dimId, - (encodeURI(referrer) || ''), options); - rndr.renderAd(publisher); - }); -} - -function parseMediaType(creativeBid) { - const adType = creativeBid.creativeDetails.type; - if (adType === 'VAST') { - return VIDEO; - } else { - return BANNER; - } -} - -function logEvent(eid, data) { - let getParams = { - protocol: 'https', - hostname: SECURE_EVENT_PIXEL_URL, - search: getLoggingData(eid, data) - }; - let eventUrl = utils.buildUrl(getParams).replace(/&/g, ';'); - utils.triggerPixel(eventUrl); -} - -function getLoggingData(eid, data) { - data = (utils.isArray(data) && data) || []; - - let params = {}; - let channel, network, dim, publisher, adunitCode, timeToRespond, cpm; - data.map((adunit) => { - adunitCode = adunit.adUnitCode; - channel = utils.deepAccess(adunit, 'params.0.channelCode') || 0; - network = channel > 0 ? parseInt(channel / 1000000) : 0; - dim = utils.deepAccess(adunit, 'params.0.dimId') * 256 || 0; - publisher = utils.deepAccess(adunit, 'params.0.pubId') || 0; - timeToRespond = adunit.timeout ? adunit.timeout : adunit.timeToRespond; - cpm = adunit.cpm; - }); - let referrer = ''; - const refererInfo = getRefererInfo(); - if (refererInfo) { - referrer = refererInfo.referer; - } - params.n = network; - params.c = channel; - params.s = publisher; - params.x = dim; - params.ai = encodeURI('Prebid^zedo^' + adunitCode + '^' + cpm + '^' + timeToRespond); - params.pu = encodeURI(referrer) || ''; - params.eid = eid; - params.e = 'e'; - params.z = Math.random(); - - return params; -} - -registerBidder(spec); 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/widespaceBidAdapter_spec.js b/test/spec/modules/widespaceBidAdapter_spec.js deleted file mode 100644 index 382bf2c593e..00000000000 --- a/test/spec/modules/widespaceBidAdapter_spec.js +++ /dev/null @@ -1,265 +0,0 @@ -import {expect} from 'chai'; -import {spec, storage} from 'modules/widespaceBidAdapter.js'; -import includes from 'core-js-pure/features/array/includes.js'; - -describe('+widespaceAdatperTest', function () { - // Dummy bid request - const bidRequest = [{ - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'auctionId': 'bf1e57ee-fff2-4304-8143-91aaf423a948', - 'bidId': '4045696e2278cd', - 'bidder': 'widespace', - 'params': { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3', - currency: 'EUR', - demo: { - gender: 'M', - country: 'Sweden', - region: 'Stockholm', - postal: '15115', - city: 'Stockholm', - yob: '1984' - } - }, - 'bidderRequestId': '37a5f053efef34', - 'sizes': [[320, 320], [300, 250], [300, 300]], - 'transactionId': '4f68b713-04ba-4d7f-8df9-643bcdab5efb' - }, { - 'adUnitCode': 'div-gpt-ad-1460505748561-1', - 'auctionId': 'bf1e57ee-fff2-4304-8143-91aaf423a944', - 'bidId': '4045696e2278ab', - 'bidder': 'widespace', - 'params': { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad4', - demo: { - gender: 'M', - country: 'Sweden', - region: 'Stockholm', - postal: '15115', - city: 'Stockholm', - yob: '1984' - } - }, - 'bidderRequestId': '37a5f053efef34', - 'sizes': [[300, 300]], - 'transactionId': '4f68b713-04ba-4d7f-8df9-643bcdab5efv' - }]; - - // Dummy bidderRequest object - const bidderRequest = { - auctionId: 'bf1e57ee-fff2-4304-8143-91aaf423a944', - auctionStart: 1527418994278, - bidderCode: 'widespace', - bidderRequestId: '37a5f053efef34', - timeout: 3000, - gdprConsent: { - consentString: 'consentString', - gdprApplies: true, - vendorData: { - hasGlobalScope: false - } - } - }; - - // Dummy bid response with ad code - const bidResponse = { - body: [{ - 'adId': '12345', - 'bidId': '67890', - 'code': '
', - 'cpm': 6.6, - 'currency': 'EUR', - 'height': 300, - 'netRev': true, - 'reqId': '224804081406', - 'status': 'ad', - 'ttl': 30, - 'width': 300, - 'syncPixels': ['https://url1.com/url', 'https://url2.com/url'] - }], - headers: {} - }; - - // Dummy bid response of noad - const bidResponseNoAd = { - body: [{ - 'status': 'noad', - }], - headers: {} - }; - - // Appending a div with id of adUnitCode so we can calculate vol - const div1 = document.createElement('div'); - div1.id = bidRequest[0].adUnitCode; - document.body.appendChild(div1); - const div2 = document.createElement('div'); - div2.id = bidRequest[0].adUnitCode; - document.body.appendChild(div2); - - // Adding custom data cookie se we can test cookie is readable - const theDate = new Date(); - const expDate = new Date(theDate.setMonth(theDate.getMonth() + 1)).toGMTString(); - window.document.cookie = `wsCustomData1={id: test};path=/;expires=${expDate};`; - const PERF_DATA = JSON.stringify({perf_status: 'OK', perf_reqid: '226920425154', perf_ms: '747'}); - window.document.cookie = `wsPerfData123=${PERF_DATA};path=/;expires=${expDate};`; - - // Connect dummy data test - const CONNECTION = navigator.connection || navigator.webkitConnection; - if (CONNECTION && CONNECTION.type && CONNECTION.downlinkMax) { - navigator.connection.downlinkMax = 80; - navigator.connection.type = 'wifi'; - } - - describe('+bidRequestValidity', function () { - it('bidRequest with sid and currency params', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3', - currency: 'EUR' - } - })).to.equal(true); - }); - - it('-bidRequest with missing sid', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - currency: 'EUR' - } - })).to.equal(false); - }); - - it('-bidRequest with missing currency', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3' - } - })).to.equal(true); - }); - }); - - describe('+bidRequest', function () { - let request; - const UrlRegExp = /^((ftp|http|https):)?\/\/[^ "]+$/; - before(function() { - request = spec.buildRequests(bidRequest, bidderRequest); - }) - - let fakeLocalStorage = {}; - let lsSetStub; - let lsGetStub; - let lsRemoveStub; - - beforeEach(function () { - lsSetStub = sinon.stub(storage, 'setDataInLocalStorage').callsFake(function (name, value) { - fakeLocalStorage[name] = value; - }); - - lsGetStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(function (key) { - return fakeLocalStorage[key] || null; - }); - - lsRemoveStub = sinon.stub(storage, 'removeDataFromLocalStorage').callsFake(function (key) { - if (key && (fakeLocalStorage[key] !== null || fakeLocalStorage[key] !== undefined)) { - delete fakeLocalStorage[key]; - } - return true; - }); - }); - - afterEach(function () { - lsSetStub.restore(); - lsGetStub.restore(); - lsRemoveStub.restore(); - fakeLocalStorage = {}; - }); - - it('-bidRequest method is POST', function () { - expect(request[0].method).to.equal('POST'); - }); - - it('-bidRequest url is valid', function () { - expect(UrlRegExp.test(request[0].url)).to.equal(true); - }); - - it('-bidRequest data exist', function () { - expect(request[0].data).to.exist; - }); - - it('-bidRequest data is form data', function () { - expect(typeof request[0].data).to.equal('string'); - }); - - it('-bidRequest options have header type', function () { - expect(request[0].options.contentType).to.exist; - }); - - it('-cookie test for wsCustomData ', function () { - expect(request[0].data.indexOf('hb.cd') > -1).to.equal(true); - }); - }); - - describe('+interpretResponse', function () { - it('-required params available in response', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - let requiredKeys = [ - 'requestId', - 'cpm', - 'width', - 'height', - 'creativeId', - 'currency', - 'netRevenue', - 'ttl', - 'referrer', - 'ad' - ]; - const resultKeys = Object.keys(result[0]); - requiredKeys.forEach((key) => { - expect(includes(resultKeys, key)).to.equal(true); - }); - - // Each value except referrer should not be empty|null|undefined - result.forEach((res) => { - Object.keys(res).forEach((resKey) => { - if (resKey !== 'referrer') { - expect(res[resKey]).to.not.be.null; - expect(res[resKey]).to.not.be.undefined; - expect(res[resKey]).to.not.equal(''); - } - }); - }); - }); - - it('-empty result if noad responded', function () { - const noAdResult = spec.interpretResponse(bidResponseNoAd, bidRequest); - expect(noAdResult.length).to.equal(0); - }); - - it('-empty response should not breake anything in adapter', function () { - const noResponse = spec.interpretResponse({}, bidRequest); - expect(noResponse.length).to.equal(0); - }); - }); - - describe('+getUserSyncs', function () { - it('-always return an array', function () { - const userSync_test1 = spec.getUserSyncs({}, [bidResponse]); - expect(Array.isArray(userSync_test1)).to.equal(true); - - const userSync_test2 = spec.getUserSyncs({}, [bidResponseNoAd]); - expect(Array.isArray(userSync_test2)).to.equal(true); - - const userSync_test3 = spec.getUserSyncs({}, [bidResponse, bidResponseNoAd]); - expect(Array.isArray(userSync_test3)).to.equal(true); - - const userSync_test4 = spec.getUserSyncs(); - expect(Array.isArray(userSync_test4)).to.equal(true); - - const userSync_test5 = spec.getUserSyncs({}, []); - expect(Array.isArray(userSync_test5)).to.equal(true); - }); - }); -}); diff --git a/test/spec/modules/windtalkerBidAdapter_spec.js b/test/spec/modules/windtalkerBidAdapter_spec.js deleted file mode 100644 index de123815cb2..00000000000 --- a/test/spec/modules/windtalkerBidAdapter_spec.js +++ /dev/null @@ -1,348 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/windtalkerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('Windtalker Adapter Tests', function () { - const slotConfigs = [{ - placementCode: '/DfpAccount1/slot1', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - bidId: 'bid12345', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '123', - bidFloor: '0.001', - ifa: 'IFA', - latitude: '40.712775', - longitude: '-74.005973' - } - }, { - placementCode: '/DfpAccount2/slot2', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - bidId: 'bid23456', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '1234', - bidFloor: '0.000001', - } - }]; - const nativeSlotConfig = [{ - placementCode: '/DfpAccount1/slot3', - bidId: 'bid12345', - mediaType: 'native', - nativeParams: { - title: { required: true, len: 200 }, - body: {}, - image: { wmin: 100 }, - sponsoredBy: { }, - icon: { } - }, - params: { - pubId: '29521', - placementId: '123', - siteId: '26047' - } - }]; - const videoSlotConfig = [{ - placementCode: '/DfpAccount1/slot4', - mediaTypes: { - video: { - playerSize: [[640, 480]] - } - }, - bidId: 'bid12345678', - mediaType: 'video', - video: { - skippable: true - }, - params: { - pubId: '29521', - placementId: '1234567', - siteId: '26047', - } - }]; - const appSlotConfig = [{ - placementCode: '/DfpAccount1/slot5', - bidId: 'bid12345', - params: { - pubId: '29521', - placementId: '1234', - app: { - id: '1111', - name: 'app name', - bundle: 'io.windtalker.apps', - storeUrl: 'https://windtalker.io/apps', - domain: 'windtalker.io' - } - } - }]; - - it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // site object - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.publisher).to.not.equal(null); - expect(ortbRequest.site.publisher.id).to.equal('29521'); - expect(ortbRequest.site.ref).to.equal(window.top.document.referrer); - expect(ortbRequest.site.page).to.equal(window.location.href); - expect(ortbRequest.imp).to.have.lengthOf(2); - // device object - expect(ortbRequest.device).to.not.equal(null); - expect(ortbRequest.device.ua).to.equal(navigator.userAgent); - expect(ortbRequest.device.ifa).to.equal('IFA'); - expect(ortbRequest.device.geo.lat).to.equal('40.712775'); - expect(ortbRequest.device.geo.lon).to.equal('-74.005973'); - // slot 1 - expect(ortbRequest.imp[0].tagid).to.equal('123'); - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - expect(ortbRequest.imp[0].bidfloor).to.equal('0.000001'); - // slot 2 - expect(ortbRequest.imp[1].tagid).to.equal('1234'); - expect(ortbRequest.imp[1].banner).to.not.equal(null); - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); - expect(ortbRequest.imp[1].bidfloor).to.equal('0.000001'); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad', - w: 300, - h: 250 - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - expect(bids).to.have.lengthOf(1); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.ad).to.equal('This is an Ad'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.adId).to.equal('bid12345'); - expect(bid.creativeId).to.equal('bid12345'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verify full passback', function () { - const request = spec.buildRequests(slotConfigs); - const bids = spec.interpretResponse({ body: null }, request) - expect(bids).to.have.lengthOf(0); - }); - - it('Verify Native request', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // native impression - expect(ortbRequest.imp[0].tagid).to.equal('123'); - const nativePart = ortbRequest.imp[0]['native']; - expect(nativePart).to.not.equal(null); - expect(nativePart.ver).to.equal('1.1'); - expect(nativePart.request).to.not.equal(null); - // native request assets - const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request); - expect(nativeRequest).to.not.equal(null); - expect(nativeRequest.assets).to.have.lengthOf(5); - expect(nativeRequest.assets[0].id).to.equal(1); - expect(nativeRequest.assets[1].id).to.equal(2); - expect(nativeRequest.assets[2].id).to.equal(3); - expect(nativeRequest.assets[3].id).to.equal(4); - expect(nativeRequest.assets[4].id).to.equal(5); - expect(nativeRequest.assets[0].required).to.equal(1); - expect(nativeRequest.assets[0].title).to.not.equal(null); - expect(nativeRequest.assets[0].title.len).to.equal(200); - expect(nativeRequest.assets[1].title).to.be.undefined; - expect(nativeRequest.assets[1].data).to.not.equal(null); - expect(nativeRequest.assets[1].data.type).to.equal(2); - expect(nativeRequest.assets[1].data.len).to.equal(200); - expect(nativeRequest.assets[2].required).to.equal(0); - expect(nativeRequest.assets[3].img).to.not.equal(null); - expect(nativeRequest.assets[3].img.wmin).to.equal(50); - expect(nativeRequest.assets[3].img.hmin).to.equal(50); - expect(nativeRequest.assets[3].img.type).to.equal(1); - expect(nativeRequest.assets[4].img).to.not.equal(null); - expect(nativeRequest.assets[4].img.wmin).to.equal(100); - expect(nativeRequest.assets[4].img.hmin).to.equal(150); - expect(nativeRequest.assets[4].img.type).to.equal(3); - }); - - it('Verify Native response', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - const nativeResponse = { - 'native': { - assets: [ - { id: 1, title: { text: 'Ad Title' } }, - { id: 2, data: { value: 'Test description' } }, - { id: 3, data: { value: 'Brand' } }, - { id: 4, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_icon.png', w: 100, h: 100 } }, - { id: 5, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_image.png', w: 300, h: 300 } } - ], - link: { url: 'https://brand.com/' } - } - }; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - nurl: 'https://rtb.adx1.com/log', - adm: JSON.stringify(nativeResponse) - }] - }], - cur: 'USD', - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - // verify bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.adId).to.equal('bid12345'); - expect(bid.ad).to.be.undefined; - expect(bid.mediaType).to.equal('native'); - const nativeBid = bid['native']; - expect(nativeBid).to.not.equal(null); - expect(nativeBid.title).to.equal('Ad Title'); - expect(nativeBid.sponsoredBy).to.equal('Brand'); - expect(nativeBid.icon.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_icon.png'); - expect(nativeBid.image.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_image.png'); - expect(nativeBid.image.width).to.equal(300); - expect(nativeBid.image.height).to.equal(300); - expect(nativeBid.icon.width).to.equal(100); - expect(nativeBid.icon.height).to.equal(100); - expect(nativeBid.clickUrl).to.equal(encodeURIComponent('https://brand.com/')); - expect(nativeBid.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('https://rtb.adx1.com/log'); - }); - - it('Verify Video request', function () { - const request = spec.buildRequests(videoSlotConfig); - expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); - expect(request.method).to.equal('POST'); - const videoRequest = JSON.parse(request.data); - // site object - expect(videoRequest.site).to.not.equal(null); - expect(videoRequest.site.publisher.id).to.equal('29521'); - expect(videoRequest.site.ref).to.equal(window.top.document.referrer); - expect(videoRequest.site.page).to.equal(window.location.href); - // device object - expect(videoRequest.device).to.not.equal(null); - expect(videoRequest.device.ua).to.equal(navigator.userAgent); - // slot 1 - expect(videoRequest.imp[0].tagid).to.equal('1234567'); - expect(videoRequest.imp[0].video).to.not.equal(null); - expect(videoRequest.imp[0].video.w).to.equal(640); - expect(videoRequest.imp[0].video.h).to.equal(480); - expect(videoRequest.imp[0].banner).to.equal(null); - expect(videoRequest.imp[0].native).to.equal(null); - }); - - it('Verify parse video response', function () { - const request = spec.buildRequests(videoSlotConfig); - const videoRequest = JSON.parse(request.data); - const videoResponse = { - seatbid: [{ - bid: [{ - impid: videoRequest.imp[0].id, - price: 1.90, - adm: 'https://vid.example.com/9876', - crid: '510511_754567308' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: videoResponse }, request); - expect(bids).to.have.lengthOf(1); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.90); - expect(bid.vastUrl).to.equal('https://vid.example.com/9876'); - expect(bid.crid).to.equal('510511_754567308'); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(480); - expect(bid.adId).to.equal('bid12345678'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verifies bidder code', function () { - expect(spec.code).to.equal('windtalker'); - }); - - it('Verifies supported media types', function () { - expect(spec.supportedMediaTypes).to.have.lengthOf(3); - expect(spec.supportedMediaTypes[0]).to.equal('banner'); - expect(spec.supportedMediaTypes[1]).to.equal('native'); - expect(spec.supportedMediaTypes[2]).to.equal('video'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(slotConfigs[0])).to.equal(true); - expect(spec.isBidRequestValid(slotConfigs[1])).to.equal(true); - expect(spec.isBidRequestValid(nativeSlotConfig[0])).to.equal(true); - expect(spec.isBidRequestValid(videoSlotConfig[0])).to.equal(true); - }); - - it('Verify app requests', function () { - const request = spec.buildRequests(appSlotConfig); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.publisher).to.not.equal(null); - expect(ortbRequest.app.publisher.id).to.equal('29521'); - expect(ortbRequest.app.id).to.equal('1111'); - expect(ortbRequest.app.name).to.equal('app name'); - expect(ortbRequest.app.bundle).to.equal('io.windtalker.apps'); - expect(ortbRequest.app.storeurl).to.equal('https://windtalker.io/apps'); - expect(ortbRequest.app.domain).to.equal('windtalker.io'); - }); - - it('Verify GDPR', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'serialized_gpdr_data' - } - }; - const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.user).to.not.equal(null); - expect(ortbRequest.user.ext).to.not.equal(null); - expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data'); - expect(ortbRequest.regs).to.not.equal(null); - expect(ortbRequest.regs.ext).to.not.equal(null); - expect(ortbRequest.regs.ext.gdpr).to.equal(1); - }); -}); diff --git a/test/spec/modules/wipesBidAdapter_spec.js b/test/spec/modules/wipesBidAdapter_spec.js deleted file mode 100644 index c453eca82c5..00000000000 --- a/test/spec/modules/wipesBidAdapter_spec.js +++ /dev/null @@ -1,150 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/wipesBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; - -const ENDPOINT_URL = 'https://adn-srv.reckoner-api.com/v1/prebid'; - -describe('wipesBidAdapter', function () { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'wipes', - 'params': { - asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' - }, - 'adUnitCode': 'adunit-code', - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '15246a574e859f', - 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when asid not passed correctly', function () { - bid.params.asid = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'wipes', - 'params': { - asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' - }, - 'adUnitCode': 'adunit-code', - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '15246a574e859f', - 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', - }, - { - 'bidder': 'wipes', - 'params': { - asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' - }, - 'adUnitCode': 'adunit-code2', - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '15246a574e859f', - 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', - } - ]; - - let bidderRequest = { - refererInfo: { - numIframes: 0, - reachedTop: true, - referer: 'http://example.com', - stack: ['http://example.com'] - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - - it('sends bid request to our endpoint via GET', function () { - expect(request[0].method).to.equal('GET'); - expect(request[1].method).to.equal('GET'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request[0].url).to.equal(ENDPOINT_URL); - expect(request[1].url).to.equal(ENDPOINT_URL); - }); - - it('adUnitCode should be sent as uc parameters on any requests', function () { - expect(request[0].data.asid).to.equal('dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ'); - expect(request[1].data.asid).to.equal('dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ'); - }); - }); - - describe('interpretResponse', function () { - let bidRequestVideo = [ - { - 'method': 'GET', - 'url': ENDPOINT_URL, - 'data': { - 'asid': 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ', - 'bid_id': '23beaa6af6cdde', - } - } - ]; - - let serverResponseVideo = { - body: { - 'uuid': 'a42947f8-f8fd-4cf7-bb72-31a87ab1f6ff', - 'ad_tag': '', - 'height': 160, - 'width': 300, - 'cpm': 850, - 'status_message': '', - 'currency': 'JPY', - 'video_creative_id': 600004, - 'bid_id': '23beaa6af6cdde' - } - }; - - it('should get the correct bid response for video', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 850, - 'width': 300, - 'height': 160, - 'creativeId': '600004', - 'dealId': undefined, - 'currency': 'JPY', - 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'mediaType': 'banner', - 'ad': '' - }]; - let result = spec.interpretResponse(serverResponseVideo, bidRequestVideo[0]); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'uid': 'a42947f8-f8fd-4cf7-bb72-31a87ab1f6ff', - 'height': 0, - 'crid': '', - 'statusMessage': '', - 'width': 0, - 'cpm': 0 - } - }; - let result = spec.interpretResponse(response, bidRequestVideo[0]); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/zedoBidAdapter_spec.js b/test/spec/modules/zedoBidAdapter_spec.js deleted file mode 100644 index 8e5a789656e..00000000000 --- a/test/spec/modules/zedoBidAdapter_spec.js +++ /dev/null @@ -1,354 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/zedoBidAdapter'; - -describe('The ZEDO bidding adapter', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'zedo', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - - it('should return true when given a channelcode bid', function () { - const bid = { - bidder: 'zedo', - params: { - channelCode: 20000000, - dimId: 9 - }, - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidderRequest = { - timeout: 3000, - }; - - it('should properly build a channelCode request for dim Id with type not defined', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [[300, 200]], - params: { - channelCode: 20000000, - dimId: 10, - pubId: 1 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^https:\/\/saxp.zedo.com\/asw\/fmh.json/); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":1,"width":300,"height":200,"dimension":10,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"display"}]}]}'); - }); - - it('should properly build a channelCode request for video with type defined', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [640, 480], - mediaTypes: { - video: { - context: 'instream', - }, - }, - params: { - channelCode: 20000000, - dimId: 85 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^https:\/\/saxp.zedo.com\/asw\/fmh.json/); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":0,"width":640,"height":480,"dimension":85,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"Inarticle"}]}]}'); - }); - - describe('buildGDPRRequests', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - const bidderRequest = { - timeout: 3000, - gdprConsent: { - 'consentString': consentString, - 'gdprApplies': true - } - }; - - it('should properly build request with gdpr consent', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [[300, 200]], - params: { - channelCode: 20000000, - dimId: 10 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":0,"width":300,"height":200,"dimension":10,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"display"}]}],"gdpr":1,"gdpr_consent":"BOJ8RZsOJ8RZsABAB8AAAAAZ+A=="}'); - }); - }); - }); - describe('interpretResponse', function () { - it('should return an empty array when there is bid response', function () { - const response = {}; - const request = { bidRequests: [] }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('should properly parse a bid response with no valid creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '600', - 'width': '160', - 'isFoc': true, - 'creativeDetails': { - 'type': 'StdBanner', - 'adContent': { - 'focImage': { - 'url': 'https://c13.zedo.com/OzoDB/0/0/0/blank.gif', - 'target': '_blank', - } - } - }, - 'cpm': '0' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'p12345', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 9 - } - }] - }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('should properly parse a bid response with valid display creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '600', - 'width': '160', - 'isFoc': true, - 'creativeDetails': { - 'type': 'StdBanner', - 'adContent': '' - }, - 'bidCpm': '720000' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'test-requestId', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 9 - }, - }] - }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('ad1d762'); - expect(bids[0].cpm).to.equal(0.72); - expect(bids[0].width).to.equal('160'); - expect(bids[0].height).to.equal('600'); - }); - - it('should properly parse a bid response with valid video creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '480', - 'width': '640', - 'isFoc': true, - 'creativeDetails': { - 'type': 'VAST', - 'adContent': '' - }, - 'bidCpm': '780000' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'test-requestId', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 85 - }, - }] - }; - - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('ad1d762'); - expect(bids[0].cpm).to.equal(0.78); - expect(bids[0].width).to.equal('640'); - expect(bids[0].height).to.equal('480'); - expect(bids[0].adType).to.equal('VAST'); - expect(bids[0].vastXml).to.not.equal(''); - expect(bids[0].ad).to.be.an('undefined'); - expect(bids[0].renderer).not.to.be.an('undefined'); - }); - }); - - describe('user sync', function () { - it('should register the iframe sync url', function () { - let syncs = spec.getUserSyncs({ - iframeEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - }); - - it('should pass gdpr params', function () { - let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { - gdprApplies: false, consentString: 'test' - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.contains('gdpr=0'); - }); - }); - - describe('bid events', function () { - it('should trigger a win pixel', function () { - const bid = { - 'bidderCode': 'zedo', - 'width': '300', - 'height': '250', - 'statusMessage': 'Bid available', - 'adId': '148018fe5e', - 'cpm': 0.5, - 'ad': 'dummy data', - 'ad_id': '12345', - 'sizeId': '15', - 'adResponse': - { - 'creatives': [ - { - 'adId': '12345', - 'height': '480', - 'width': '640', - 'isFoc': true, - 'creativeDetails': { - 'type': 'VAST', - 'adContent': '' - }, - 'seeder': { - 'network': 1234, - 'servedChan': 1234567, - }, - 'cpm': '1200000', - 'servedChan': 1234, - }] - }, - 'params': [{ - 'channelCode': '123456', - 'dimId': '85' - }], - 'requestTimestamp': 1540401686, - 'responseTimestamp': 1540401687, - 'timeToRespond': 6253, - 'pbLg': '0.50', - 'pbMg': '0.50', - 'pbHg': '0.53', - 'adUnitCode': '/123456/header-bid-tag-0', - 'bidder': 'zedo', - 'size': '300x250', - 'adserverTargeting': { - 'hb_bidder': 'zedo', - 'hb_adid': '148018fe5e', - 'hb_pb': '10.00', - } - }; - spec.onBidWon(bid); - spec.onTimeout(bid); - }); - it('should trigger a timeout pixel', function () { - const bid = { - 'bidderCode': 'zedo', - 'width': '300', - 'height': '250', - 'statusMessage': 'Bid available', - 'adId': '148018fe5e', - 'cpm': 0.5, - 'ad': 'dummy data', - 'ad_id': '12345', - 'sizeId': '15', - 'params': [{ - 'channelCode': '123456', - 'dimId': '85' - }], - 'timeout': 1, - 'requestTimestamp': 1540401686, - 'responseTimestamp': 1540401687, - 'timeToRespond': 6253, - 'adUnitCode': '/123456/header-bid-tag-0', - 'bidder': 'zedo', - 'size': '300x250', - }; - spec.onBidWon(bid); - spec.onTimeout(bid); - }); - }); -});