From 6f865c67d2d68c292e62ac8c4afce40cdde8cf34 Mon Sep 17 00:00:00 2001 From: Jesso Date: Thu, 30 Sep 2021 17:11:38 +0530 Subject: [PATCH 01/36] Ventes Avenues initial changes --- modules/ventes.md | 71 ++++ modules/ventesAdaptor.js | 733 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 804 insertions(+) create mode 100644 modules/ventes.md create mode 100644 modules/ventesAdaptor.js diff --git a/modules/ventes.md b/modules/ventes.md new file mode 100644 index 00000000000..5f0f571ecd8 --- /dev/null +++ b/modules/ventes.md @@ -0,0 +1,71 @@ +--- +layout: bidder +title: ventes +description: Prebid ventes Bidder Adapter +pbjs: false +biddercode: ventes +gdpr_supported: false +usp_supported: false +media_types: banner +coppa_supported: false +schain_supported: false +dchain_supported: false +prebid_member: false +--- + +### BidParams +{: .table .table-bordered .table-striped } +| Name | Scope | Description | Example | Type | +|-----------------|----------|-----------------------------------------------------------|----------------------------------------------|---------------| +| `placementId` | required | Placement ID from Ventes Avenues | `'VA-062-0013-0183'` | `string` | +| `publisherId` | required | Publisher ID from Ventes Avenues | `'VA-062'` | `string` | +| `user` | optional | Object that specifies information about an external user. | `user: { age: 25, gender: 0, dnt: true}` | `object` | +| `app` | optional | Object containing mobile app parameters. | `app : { id: 'app-id'}` | `object` | + +#### User Object + +{: .table .table-bordered .table-striped } +| Name | Description | Example | Type | +|-------------------|-------------------------------------------------------------------------------------------|-----------------------|-----------------------| +| `age` | The age of the user. | `35` | `integer` | +| `externalUid` | Specifies a string that corresponds to an external user ID for this user. | `'1234567890abcdefg'` | `string` | +| `segments` | Specifies the segments to which the user belongs. | `[1, 2]` | `Array` | +| `gender` | Specifies the gender of the user. Allowed values: Unknown: `0`; Male: `1`; Female: `2` | `1` | `integer` | +| `dnt` | Do not track flag. Indicates if tracking cookies should be disabled for this auction | `true` | `boolean` | +| `language` | Two-letter ANSI code for this user's language. | `EN` | `string` | + + +### Ad Unit Setup for Banner +```javascript +var adUnits = [ +{ + code: 'test-hb-ad-11111-1', + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + bids: [{ + bidder: 'ventes', + params: { + placementId: 'VA-062-0013-0183', + publisherId: '5cebea3c9eea646c7b623d5e', + IABCategories: "['IAB1', 'IAB5']", + device:{ + ip: '123.145.167.189', + ifa:"AEBE52E7-03EE-455A-B3C4-E57283966239", + }, + app: { + id: "agltb3B1Yi1pbmNyDAsSA0FwcBiJkfIUDA", + name: "Yahoo Weather", + bundle: 'com.kiloo.subwaysurf', + storeurl: 'https://play.google.com/store/apps/details?id=com.kiloo.subwaysurf&hl=en', + domain: 'somoaudience.com', + } + } + }] + } +] +``` diff --git a/modules/ventesAdaptor.js b/modules/ventesAdaptor.js new file mode 100644 index 00000000000..75999b449f7 --- /dev/null +++ b/modules/ventesAdaptor.js @@ -0,0 +1,733 @@ +import {Renderer} from '../src/Renderer.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {isStr, isArray, isNumber, isPlainObject, isBoolean, logError, replaceAuctionPrice} from '../src/utils.js'; +import find from 'core-js-pure/features/array/find.js'; +import { config } from '../src/config.js'; + +const ADAPTER_VERSION = 'v1.0.0'; +const BID_METHOD = 'POST'; +const BIDDER_URL = 'http://13.234.201.146:8088/va/ad'; +const FIRST_PRICE = 1; +const NET_REVENUE = true; +const AUCTION_PRICE = '${AUCTION_PRICE}'; +const TTL = 10; + +const SUPPORTED_VIDEO_CONTEXTS = ['instream', 'outstream']; +const SUPPORTED_INSTREAM_CONTEXTS = ['pre-roll', 'mid-roll', 'post-roll']; +const SUPPORTED_VIDEO_MIMES = ['video/mp4']; +const OUTSTREAM_VIDEO_PLAYER_URL = 'videoplayer-url'; +const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; +const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately + +const NATIVE_PLACEMENTS = { + title: {id: 1, name: 'title'}, + icon: {id: 2, type: 1, name: 'img'}, + image: {id: 3, type: 3, name: 'img'}, + sponsoredBy: {id: 4, name: 'data', type: 1}, + body: {id: 5, name: 'data', type: 2}, + cta: {id: 6, type: 12, name: 'data'} +}; +const NATIVE_ID_MAPPING = {1: 'title', 2: 'icon', 3: 'image', 4: 'sponsoredBy', 5: 'body', 6: 'cta'}; +const NATIVE_PRESET_FORMATTERS = { + image: formatNativePresetImage +} + +function isNone(value) { + return (value === null) || (value === undefined); +} + +function groupBy(values, key) { + const groups = values.reduce((acc, value) => { + const groupId = value[key]; + + if (!acc[groupId]) acc[groupId] = []; + acc[groupId].push(value); + + return acc; + }, {}); + + return Object + .keys(groups) + .map(id => ({id, key, values: groups[id]})); +} + +function validateMediaTypes(mediaTypes, allowedMediaTypes) { + if (!isPlainObject(mediaTypes)) return false; + if (!allowedMediaTypes.some(mediaType => mediaType in mediaTypes)) return false; + + if (isBanner(mediaTypes)) { + if (!validateBanner(mediaTypes.banner)) return false; + } + + if (isVideo(mediaTypes)) { + if (!validateVideo(mediaTypes.video)) return false; + } + + return true; +} + +function isBanner(mediaTypes) { + return isPlainObject(mediaTypes) && isPlainObject(mediaTypes.banner); +} + +function isVideo(mediaTypes) { + return isPlainObject(mediaTypes) && 'video' in mediaTypes; +} + +function validateBanner(banner) { + return isPlainObject(banner) && + isArray(banner.sizes) && + (banner.sizes.length > 0) && + banner.sizes.every(validateMediaSizes); +} + +function validateVideo(video) { + if (!isPlainObject(video)) return false; + if (!isStr(video.context)) return false; + if (SUPPORTED_VIDEO_CONTEXTS.indexOf(video.context) === -1) return false; + + if (!video.playerSize) return true; + if (!isArray(video.playerSize)) return false; + + return video.playerSize.every(validateMediaSizes); +} + +function validateMediaSizes(mediaSize) { + return isArray(mediaSize) && + (mediaSize.length === 2) && + mediaSize.every(size => (isNumber(size) && size >= 0)); +} + +function validateParameters(parameters, adUnit) { + if (isVideo(adUnit.mediaTypes)) { + if (!isPlainObject(parameters)) return false; + if (!isPlainObject(adUnit.mediaTypes.video)) return false; + if (!validateVideoParameters(parameters.video, adUnit)) return false; + } + if (!(parameters.placementId)) { + return false; + } + if (!(parameters.publisherId)) { + return false; + } + + return true; +} + +function validateVideoParameters(videoParams, adUnit) { + const video = adUnit.mediaTypes.video; + + if (!video) return false; + + if (!isArray(video.mimes)) return false; + if (video.mimes.length === 0) return false; + if (!video.mimes.every(isStr)) return false; + + if (video.minDuration && !isNumber(video.minDuration)) return false; + if (video.maxDuration && !isNumber(video.maxDuration)) return false; + + if (!isArray(video.protocols)) return false; + if (video.protocols.length === 0) return false; + if (!video.protocols.every(isNumber)) return false; + + if (isInstream(video)) { + if (!videoParams.instreamContext) return false; + if (SUPPORTED_INSTREAM_CONTEXTS.indexOf(videoParams.instreamContext) === -1) return false; + } + + return true; +} + +function validateServerRequest(serverRequest) { + return isPlainObject(serverRequest) && + isPlainObject(serverRequest.data) && + isArray(serverRequest.data.imp) +} + +function createServerRequestFromAdUnits(adUnits, bidRequestId, adUnitContext) { + return { + method: BID_METHOD, + url: BIDDER_URL, + data: generateBidRequestsFromAdUnits(adUnits, bidRequestId, adUnitContext), + options: { + contentType: 'application/json', + withCredentials: false, + } + } +} + +function generateBidRequestsFromAdUnits(adUnits, bidRequestId, adUnitContext) { + const userObjBid = find(bidRequests, hasUserInfo); + let userObj = {}; + if (config.getConfig('coppa') === true) { + userObj = { 'coppa': true }; + } + if (userObjBid) { + Object.keys(userObjBid.params.user) + .filter(param => includes(USER_PARAMS, param)) + .forEach((param) => { + let uparam = utils.convertCamelToUnderscore(param); + if (param === 'segments' && utils.isArray(userObjBid.params.user[param])) { + let segs = []; + userObjBid.params.user[param].forEach(val => { + if (utils.isNumber(val)) { + segs.push({'id': val}); + } else if (utils.isPlainObject(val)) { + segs.push(val); + } + }); + userObj[uparam] = segs; + } else if (param !== 'segments') { + userObj[uparam] = 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]); + if(!appDeviceObjBid.hasOwnProperty("ua")){ + appDeviceObj.ua = navigator.userAgent; + } + if(!appDeviceObjBid.hasOwnProperty("language")){ + appDeviceObj.language = navigator.language.anchor; + } + } + 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 = {} + payload.id = bidRequestId + payload.at = FIRST_PRICE + payload.cur = ["USD"] + payload.imp = adUnits.reduce(generateImpressionsFromAdUnit, []) + payload.site = site(adUnits, adUnitContext) + if (appDeviceObjBid) { + payload.device = appDeviceObj + } + if (appIdObjBid) { + payload.app = appIdObj; + } + payload.user = userObj + //payload.regs = getRegulationFromAdUnitContext(adUnitContext) + //payload.ext = generateBidRequestExtension() + + return payload +} + +function generateImpressionsFromAdUnit(acc, adUnit) { + const {bidId, mediaTypes, params} = adUnit; + const {placementId} = params; + const pmp = {}; + const ext = {placementId}; + + if (placementId) pmp.deals = [{id: placementId}] + + const imps = Object + .keys(mediaTypes) + .reduce((acc, mediaType) => { + const data = mediaTypes[mediaType]; + const impId = `${bidId}`; + + if (mediaType === 'banner') return acc.concat(generateBannerFromAdUnit(impId, data, params)); + if (mediaType === 'video') return acc.concat({id: impId, video: generateVideoFromAdUnit(data, params), pmp, ext}); + if (mediaType === 'native') return acc.concat({id: impId, native: generateNativeFromAdUnit(data), pmp, ext}); + }, []); + + return acc.concat(imps); +} + +function isImpressionAVideo(impression) { + return isPlainObject(impression) && isPlainObject(impression.video); +} + +function generateBannerFromAdUnit(impId, data, params) { + const {position, placementId} = params; + const pos = position || 0; + const pmp = {}; + const ext = {placementId}; + + if (placementId) pmp.deals = [{id: placementId}] + + return data.sizes.map(([w, h]) => ({id: `${impId}`, banner: {format: [{w, h}], w, h, pos}, pmp, ext, tagid: placementId})); +} + +function generateVideoFromAdUnit(data, params) { + const {playerSize} = data; + const video = data + + const hasPlayerSize = isArray(playerSize) && playerSize.length > 0; + const {minDuration, maxDuration, protocols} = video; + + const size = {width: hasPlayerSize ? playerSize[0][0] : null, height: hasPlayerSize ? playerSize[0][1] : null}; + const duration = {min: isNumber(minDuration) ? minDuration : null, max: isNumber(maxDuration) ? maxDuration : null}; + const startdelay = computeStartDelay(data, params); + + return { + mimes: SUPPORTED_VIDEO_MIMES, + skip: video.skippable || 0, + w: size.width, + h: size.height, + startdelay: startdelay, + linearity: video.linearity || null, + minduration: duration.min, + maxduration: duration.max, + protocols, + api: getApi(protocols), + format: hasPlayerSize ? playerSize.map(s => { + return {w: s[0], h: s[1]}; + }) : null, + pos: video.position || 0 + }; +} + +function getApi(protocols) { + let defaultValue = [2]; + let listProtocols = [ + {key: 'VPAID_1_0', value: 1}, + {key: 'VPAID_2_0', value: 2}, + {key: 'MRAID_1', value: 3}, + {key: 'ORMMA', value: 4}, + {key: 'MRAID_2', value: 5}, + {key: 'MRAID_3', value: 6}, + ]; + if (protocols) { + return listProtocols.filter(p => { + return protocols.indexOf(p.key) !== -1; + }).map(p => p.value) + } else { + return defaultValue; + } +} + +function isInstream(video) { + return isPlainObject(video) && (video.context === 'instream'); +} + +function isOutstream(video) { + return isPlainObject(video) && (video.startdelay === null) +} + +function computeStartDelay(data, params) { + if (isInstream(data)) { + if (params.video.instreamContext === 'pre-roll') return 0; + if (params.video.instreamContext === 'mid-roll') return -1; + if (params.video.instreamContext === 'post-roll') return -2; + } + + return null; +} + +function generateNativeFromAdUnit(data) { + const {type} = data; + const presetFormatter = type && NATIVE_PRESET_FORMATTERS[data.type]; + const nativeFields = presetFormatter ? presetFormatter(data) : data; + + const assets = Object + .keys(nativeFields) + .reduce((acc, placement) => { + const placementData = nativeFields[placement]; + const assetInfo = NATIVE_PLACEMENTS[placement]; + + if (!assetInfo) return acc; + + const {id, name, type} = assetInfo; + const {required, len, sizes = []} = placementData; + let wmin; + let hmin; + + if (isArray(sizes[0])) { + wmin = sizes[0][0]; + hmin = sizes[0][1]; + } else { + wmin = sizes[0]; + hmin = sizes[1]; + } + + const content = {}; + + if (type) content.type = type; + if (len) content.len = len; + if (wmin) content.wmin = wmin; + if (hmin) content.hmin = hmin; + + acc.push({id, required, [name]: content}); + + return acc; + }, []); + + return { + request: JSON.stringify({assets}) + }; +} + +function formatNativePresetImage(data) { + const sizes = data.sizes; + + return { + image: { + required: true, + sizes + }, + title: { + required: true + }, + sponsoredBy: { + required: true + }, + body: { + required: false + }, + cta: { + required: false + }, + icon: { + required: false + } + }; +} + +function site(bidRequests, bidderRequest) { + const url = + config.getConfig('pageUrl') || (bidderRequest && + bidderRequest.refererInfo && + bidderRequest.refererInfo.referer); + + const pubId = + bidRequests && bidRequests.length > 0 + ? bidRequests[0].params.publisherId + : '0'; + const siteId = + bidRequests && bidRequests.length > 0 ? bidRequests[0].params.siteId : '0'; + const appParams = bidRequests[0].params.app; + if (!appParams) { + return { + publisher: { + id: pubId.toString(), + domain: config.getConfig('publisherDomain') + }, + id: siteId ? siteId.toString() : pubId.toString(), + page: url, + domain: + (url && parseUrl(url).hostname) || config.getConfig('publisherDomain') + }; + } + return undefined; +} + +function app(bidderRequest) { + const pubId = bidderRequest && bidderRequest.length > 0 + ? bidderRequest[0].params.publisherId + : '0'; + const appParams = bidderRequest[0].params.app; + if (appParams) { + var pub = { + id:pubId.toString() + }; + appParams.publisher= pub; + return appParams; + } + return undefined; +} + +function validateServerResponse(serverResponse) { + return isPlainObject(serverResponse) && + isPlainObject(serverResponse.body) && + isStr(serverResponse.body.cur) && + isArray(serverResponse.body.seatbid); +} + +function seatBidsToAds(seatBid, bidResponse, serverRequest) { + return seatBid.bid + .filter(bid => validateBids(bid, serverRequest)) + .map(bid => generateAdFromBid(bid, bidResponse)); +} + +function validateBids(bid, serverRequest) { + if (!isPlainObject(bid)) return false; + if (!isStr(bid.impid)) return false; + if (!isStr(bid.crid)) return false; + if (!isNumber(bid.price)) return false; + + if (!bid.adm && !bid.nurl) return false; + if (bid.adm) { + if (!isStr(bid.adm)) return false; + if (bid.adm.indexOf(AUCTION_PRICE) === -1) return false; + } + if (bid.nurl) { + if (!isStr(bid.nurl)) return false; + if (bid.nurl.indexOf(AUCTION_PRICE) === -1) return false; + } + + if (isBidABanner(bid)) { + if (!isNumber(bid.h)) return false; + if (!isNumber(bid.w)) return false; + } + if (isBidAVideo(bid)) { + if (!(isNone(bid.h) || isNumber(bid.h))) return false; + if (!(isNone(bid.w) || isNumber(bid.w))) return false; + } + + const impression = getImpressionData(serverRequest, bid.impid); + + if (!isPlainObject(impression.openRTB)) return false; + if (!isPlainObject(impression.internal)) return false; + if (!isStr(impression.internal.adUnitCode)) return false; + + if (isBidABanner(bid)) { + if (!isPlainObject(impression.openRTB.banner)) return false; + } + if (isBidAVideo(bid)) { + if (!isPlainObject(impression.openRTB.video)) return false; + } + if (isBidANative(bid)) { + if (!isPlainObject(impression.openRTB.native) || !tryParse(bid.adm)) return false; + } + + return true; +} + +function isBidABanner(bid) { + return isPlainObject(bid) && + isPlainObject(bid.ext) && + bid.ext.venaven.media_type === 'banner'; +} + +function isBidAVideo(bid) { + return isPlainObject(bid) && + isPlainObject(bid.ext) && + bid.ext.venaven.media_type === 'video'; +} + +function isBidANative(bid) { + return isPlainObject(bid) && + isPlainObject(bid.ext) && + bid.ext.venaven.media_type === 'native'; +} + +function getImpressionData(serverRequest, impressionId) { + const openRTBImpression = find(serverRequest.data.imp, imp => imp.id === impressionId); + + return { + id: impressionId, + openRTB: openRTBImpression || null + }; +} + +const VAST_REGEXP = /VAST\s+version/; + +function getMediaType(adm) { + const videoRegex = new RegExp(VAST_REGEXP); + + if (videoRegex.test(adm)) { + return VIDEO; + } + + const markup = safeJSONparse(adm.replace(/\\/g, '')); + + if (markup && utils.isPlainObject(markup.native)) { + return NATIVE; + } + + return BANNER; +} + +function safeJSONparse(...args) { + try { + return JSON.parse(...args); + } catch (_) { + return undefined; + } +} + +function generateAdFromBid(bid, bidResponse) { + const isVideo = isBidAVideo(bid); + const mediaType = getMediaType(bid.adm); + const base = { + requestId: bid.impid, + cpm: bid.price, + currency: bidResponse.cur, + ttl: TTL, + creativeId: bid.crid, + mediaType:mediaType, + netRevenue: NET_REVENUE + }; + + if (bid.adomain) { + base.meta = { advertiserDomains: bid.adomain }; + } + + if (isBidANative(bid)) return {...base, native: formatNativeData(bid)}; + + const size = getSizeFromBid(bid, impressionData); + const creative = getCreativeFromBid(bid, impressionData); + + return { + ...base, + height: size.height, + width: size.width, + ad: creative.markup, + adUrl: creative.markupUrl, + vastXml: isVideo && !isStr(creative.markupUrl) ? creative.markup : null, + vastUrl: isVideo && isStr(creative.markupUrl) ? creative.markupUrl : null, + renderer: creative.renderer + }; +} + +function formatNativeData({adm, price}) { + const parsedAdm = tryParse(adm); + const {assets, link: {url, clicktrackers}, imptrackers, jstracker} = parsedAdm.native; + const placements = NATIVE_PLACEMENTS; + const placementIds = NATIVE_ID_MAPPING; + + return assets.reduce((acc, asset) => { + const placementName = placementIds[asset.id]; + const content = placementName && asset[placements[placementName].name]; + if (!content) return acc; + acc[placementName] = content.text || content.value || {url: content.url, width: content.w, height: content.h}; + return acc; + }, { + clickUrl: url, + clickTrackers: clicktrackers, + impressionTrackers: imptrackers && imptrackers.map(impTracker => replaceAuctionPrice(impTracker, price)), + javascriptTrackers: jstracker && [jstracker] + }); +} + +function getSizeFromBid(bid, impressionData) { + if (isNumber(bid.w) && isNumber(bid.h)) { + return { width: bid.w, height: bid.h }; + } + + if (isImpressionAVideo(impressionData.openRTB)) { + const { video } = impressionData.openRTB; + + if (isNumber(video.w) && isNumber(video.h)) { + return { width: video.w, height: video.h }; + } + } + + return { width: null, height: null }; +} + +function getCreativeFromBid(bid, impressionData) { + const shouldUseAdMarkup = !!bid.adm; + const price = bid.price; + + return { + markup: shouldUseAdMarkup ? replaceAuctionPrice(bid.adm, price) : null, + markupUrl: !shouldUseAdMarkup ? replaceAuctionPrice(bid.nurl, price) : null, + renderer: getRendererFromBid(bid, impressionData) + }; +} + +function getRendererFromBid(bid, impressionData) { + const isOutstreamImpression = isBidAVideo(bid) && + isImpressionAVideo(impressionData.openRTB) && + isOutstream(impressionData.openRTB.video); + + return isOutstreamImpression + ? buildOutstreamRenderer(impressionData) + : null; +} + +function buildOutstreamRenderer(impressionData) { + const renderer = Renderer.install({ + url: OUTSTREAM_VIDEO_PLAYER_URL, + loaded: false, + adUnitCode: impressionData.internal.adUnitCode + }); + + renderer.setRender((ad) => { + ad.renderer.push(() => { + const container = impressionData.internal.container + ? document.querySelector(impressionData.internal.container) + : document.getElementById(impressionData.internal.adUnitCode); + + const player = new window.VASTPlayer(container); + + player.on('ready', () => { + player.adVolume = 0; + player.startAd(); + }); + + try { + isStr(ad.adUrl) + ? player.load(ad.adUrl) + : player.loadXml(ad.ad) + } catch (err) { + logError(err); + } + }); + }); + + return renderer; +} + +function tryParse(data) { + try { + return JSON.parse(data); + } catch (err) { + logError(err); + return null; + } +} + +function hasAppDeviceInfo(bid) { + if (bid.params) { + return !!bid.params.app + } +} + +const venavenBidderSpec = { + code: 'ventes', + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + isBidRequestValid(adUnit) { + const allowedBidderCodes = [this.code]; + + return isPlainObject(adUnit) && + allowedBidderCodes.indexOf(adUnit.bidder) !== -1 && + isStr(adUnit.adUnitCode) && + isStr(adUnit.bidderRequestId) && + isStr(adUnit.bidId) && + validateMediaTypes(adUnit.mediaTypes, this.supportedMediaTypes) && + validateParameters(adUnit.params, adUnit); + }, + buildRequests(bidRequests, bidderRequest) { + if (!bidRequests) return null; + + return groupBy(bidRequests, 'bidderRequestId').map(group => { + const bidRequestId = group.id; + const adUnits = groupBy(group.values, 'bidId').map((group) => { + const length = group.values.length; + return length > 0 && group.values[length - 1] + }); + + return createServerRequestFromAdUnits(adUnits, bidRequestId, bidderRequest) + }); + }, + interpretResponse(serverResponse, serverRequest) { + if (!validateServerRequest(serverRequest)) return []; + if (!validateServerResponse(serverResponse)) return []; + + const bidResponse = serverResponse.body; + + return bidResponse.seatbid + .filter(seatBid => isPlainObject(seatBid) && isArray(seatBid.bid)) + .reduce((acc, seatBid) => acc.concat(seatBidsToAds(seatBid, bidResponse, serverRequest)), []); + } +}; + +registerBidder(venavenBidderSpec); + +export {venavenBidderSpec as spec}; From c43d631da949558b06779843007119fff2237986 Mon Sep 17 00:00:00 2001 From: Jesso Date: Thu, 30 Sep 2021 17:14:23 +0530 Subject: [PATCH 02/36] Ventes Avenues initial changes --- modules/{ventesAdaptor.js => ventesBidAdaptor.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename modules/{ventesAdaptor.js => ventesBidAdaptor.js} (100%) diff --git a/modules/ventesAdaptor.js b/modules/ventesBidAdaptor.js similarity index 100% rename from modules/ventesAdaptor.js rename to modules/ventesBidAdaptor.js From 293945829d739b52de7615b48d6efab639c81b8a Mon Sep 17 00:00:00 2001 From: Jesso Date: Fri, 1 Oct 2021 17:00:57 +0530 Subject: [PATCH 03/36] Ventes Avenues Solved issues --- modules/ventes.md | 1 + modules/ventesBidAdaptor.js | 391 ++++-------------------------------- 2 files changed, 37 insertions(+), 355 deletions(-) diff --git a/modules/ventes.md b/modules/ventes.md index 5f0f571ecd8..b55daad829a 100644 --- a/modules/ventes.md +++ b/modules/ventes.md @@ -11,6 +11,7 @@ coppa_supported: false schain_supported: false dchain_supported: false prebid_member: false + --- ### BidParams diff --git a/modules/ventesBidAdaptor.js b/modules/ventesBidAdaptor.js index 75999b449f7..a3a69b4ed17 100644 --- a/modules/ventesBidAdaptor.js +++ b/modules/ventesBidAdaptor.js @@ -1,41 +1,19 @@ -import {Renderer} from '../src/Renderer.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; -import {isStr, isArray, isNumber, isPlainObject, isBoolean, logError, replaceAuctionPrice} from '../src/utils.js'; +import {convertCamelToUnderscore, parseUrl, isStr, isArray, isNumber, isPlainObject, replaceAuctionPrice} from '../src/utils.js'; import find from 'core-js-pure/features/array/find.js'; +import includes from 'core-js-pure/features/array/includes.js'; import { config } from '../src/config.js'; -const ADAPTER_VERSION = 'v1.0.0'; const BID_METHOD = 'POST'; const BIDDER_URL = 'http://13.234.201.146:8088/va/ad'; const FIRST_PRICE = 1; const NET_REVENUE = true; const AUCTION_PRICE = '${AUCTION_PRICE}'; const TTL = 10; - -const SUPPORTED_VIDEO_CONTEXTS = ['instream', 'outstream']; -const SUPPORTED_INSTREAM_CONTEXTS = ['pre-roll', 'mid-roll', 'post-roll']; -const SUPPORTED_VIDEO_MIMES = ['video/mp4']; -const OUTSTREAM_VIDEO_PLAYER_URL = 'videoplayer-url'; const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately -const NATIVE_PLACEMENTS = { - title: {id: 1, name: 'title'}, - icon: {id: 2, type: 1, name: 'img'}, - image: {id: 3, type: 3, name: 'img'}, - sponsoredBy: {id: 4, name: 'data', type: 1}, - body: {id: 5, name: 'data', type: 2}, - cta: {id: 6, type: 12, name: 'data'} -}; -const NATIVE_ID_MAPPING = {1: 'title', 2: 'icon', 3: 'image', 4: 'sponsoredBy', 5: 'body', 6: 'cta'}; -const NATIVE_PRESET_FORMATTERS = { - image: formatNativePresetImage -} - -function isNone(value) { - return (value === null) || (value === undefined); -} function groupBy(values, key) { const groups = values.reduce((acc, value) => { @@ -59,11 +37,6 @@ function validateMediaTypes(mediaTypes, allowedMediaTypes) { if (isBanner(mediaTypes)) { if (!validateBanner(mediaTypes.banner)) return false; } - - if (isVideo(mediaTypes)) { - if (!validateVideo(mediaTypes.video)) return false; - } - return true; } @@ -71,10 +44,6 @@ function isBanner(mediaTypes) { return isPlainObject(mediaTypes) && isPlainObject(mediaTypes.banner); } -function isVideo(mediaTypes) { - return isPlainObject(mediaTypes) && 'video' in mediaTypes; -} - function validateBanner(banner) { return isPlainObject(banner) && isArray(banner.sizes) && @@ -82,28 +51,19 @@ function validateBanner(banner) { banner.sizes.every(validateMediaSizes); } -function validateVideo(video) { - if (!isPlainObject(video)) return false; - if (!isStr(video.context)) return false; - if (SUPPORTED_VIDEO_CONTEXTS.indexOf(video.context) === -1) return false; - - if (!video.playerSize) return true; - if (!isArray(video.playerSize)) return false; - - return video.playerSize.every(validateMediaSizes); -} - function validateMediaSizes(mediaSize) { return isArray(mediaSize) && (mediaSize.length === 2) && mediaSize.every(size => (isNumber(size) && size >= 0)); } +function hasUserInfo(bid) { + return !!bid.params.user; +} + function validateParameters(parameters, adUnit) { if (isVideo(adUnit.mediaTypes)) { if (!isPlainObject(parameters)) return false; - if (!isPlainObject(adUnit.mediaTypes.video)) return false; - if (!validateVideoParameters(parameters.video, adUnit)) return false; } if (!(parameters.placementId)) { return false; @@ -115,30 +75,6 @@ function validateParameters(parameters, adUnit) { return true; } -function validateVideoParameters(videoParams, adUnit) { - const video = adUnit.mediaTypes.video; - - if (!video) return false; - - if (!isArray(video.mimes)) return false; - if (video.mimes.length === 0) return false; - if (!video.mimes.every(isStr)) return false; - - if (video.minDuration && !isNumber(video.minDuration)) return false; - if (video.maxDuration && !isNumber(video.maxDuration)) return false; - - if (!isArray(video.protocols)) return false; - if (video.protocols.length === 0) return false; - if (!video.protocols.every(isNumber)) return false; - - if (isInstream(video)) { - if (!videoParams.instreamContext) return false; - if (SUPPORTED_INSTREAM_CONTEXTS.indexOf(videoParams.instreamContext) === -1) return false; - } - - return true; -} - function validateServerRequest(serverRequest) { return isPlainObject(serverRequest) && isPlainObject(serverRequest.data) && @@ -157,7 +93,7 @@ function createServerRequestFromAdUnits(adUnits, bidRequestId, adUnitContext) { } } -function generateBidRequestsFromAdUnits(adUnits, bidRequestId, adUnitContext) { +function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext) { const userObjBid = find(bidRequests, hasUserInfo); let userObj = {}; if (config.getConfig('coppa') === true) { @@ -167,13 +103,13 @@ function generateBidRequestsFromAdUnits(adUnits, bidRequestId, adUnitContext) { Object.keys(userObjBid.params.user) .filter(param => includes(USER_PARAMS, param)) .forEach((param) => { - let uparam = utils.convertCamelToUnderscore(param); - if (param === 'segments' && utils.isArray(userObjBid.params.user[param])) { + let uparam = convertCamelToUnderscore(param); + if (param === 'segments' && isArray(userObjBid.params.user[param])) { let segs = []; userObjBid.params.user[param].forEach(val => { - if (utils.isNumber(val)) { + if (isNumber(val)) { segs.push({'id': val}); - } else if (utils.isPlainObject(val)) { + } else if (isPlainObject(val)) { segs.push(val); } }); @@ -191,25 +127,25 @@ function generateBidRequestsFromAdUnits(adUnits, bidRequestId, adUnitContext) { Object.keys(appDeviceObjBid.params.app) .filter(param => includes(APP_DEVICE_PARAMS, param)) .forEach(param => appDeviceObj[param] = appDeviceObjBid.params.app[param]); - if(!appDeviceObjBid.hasOwnProperty("ua")){ + if (!appDeviceObjBid.hasOwnProperty('ua')) { appDeviceObj.ua = navigator.userAgent; } - if(!appDeviceObjBid.hasOwnProperty("language")){ + if (!appDeviceObjBid.hasOwnProperty('language')) { appDeviceObj.language = navigator.language.anchor; } } const appIdObjBid = find(bidRequests, hasAppId); - let appIdObj; - if (appIdObjBid && appIdObjBid.params && appDeviceObjBid.params.app && appDeviceObjBid.params.app.id) { - appIdObj = { - appid: appIdObjBid.params.app.id - }; - } + let appIdObj; + if (appIdObjBid && appIdObjBid.params && appDeviceObjBid.params.app && appDeviceObjBid.params.app.id) { + appIdObj = { + appid: appIdObjBid.params.app.id + }; + } const payload = {} payload.id = bidRequestId payload.at = FIRST_PRICE - payload.cur = ["USD"] + payload.cur = ['USD'] payload.imp = adUnits.reduce(generateImpressionsFromAdUnit, []) payload.site = site(adUnits, adUnitContext) if (appDeviceObjBid) { @@ -219,8 +155,8 @@ function generateBidRequestsFromAdUnits(adUnits, bidRequestId, adUnitContext) { payload.app = appIdObj; } payload.user = userObj - //payload.regs = getRegulationFromAdUnitContext(adUnitContext) - //payload.ext = generateBidRequestExtension() + // payload.regs = getRegulationFromAdUnitContext(adUnitContext) + // payload.ext = generateBidRequestExtension() return payload } @@ -240,17 +176,11 @@ function generateImpressionsFromAdUnit(acc, adUnit) { const impId = `${bidId}`; if (mediaType === 'banner') return acc.concat(generateBannerFromAdUnit(impId, data, params)); - if (mediaType === 'video') return acc.concat({id: impId, video: generateVideoFromAdUnit(data, params), pmp, ext}); - if (mediaType === 'native') return acc.concat({id: impId, native: generateNativeFromAdUnit(data), pmp, ext}); }, []); return acc.concat(imps); } -function isImpressionAVideo(impression) { - return isPlainObject(impression) && isPlainObject(impression.video); -} - function generateBannerFromAdUnit(impId, data, params) { const {position, placementId} = params; const pos = position || 0; @@ -262,140 +192,6 @@ function generateBannerFromAdUnit(impId, data, params) { return data.sizes.map(([w, h]) => ({id: `${impId}`, banner: {format: [{w, h}], w, h, pos}, pmp, ext, tagid: placementId})); } -function generateVideoFromAdUnit(data, params) { - const {playerSize} = data; - const video = data - - const hasPlayerSize = isArray(playerSize) && playerSize.length > 0; - const {minDuration, maxDuration, protocols} = video; - - const size = {width: hasPlayerSize ? playerSize[0][0] : null, height: hasPlayerSize ? playerSize[0][1] : null}; - const duration = {min: isNumber(minDuration) ? minDuration : null, max: isNumber(maxDuration) ? maxDuration : null}; - const startdelay = computeStartDelay(data, params); - - return { - mimes: SUPPORTED_VIDEO_MIMES, - skip: video.skippable || 0, - w: size.width, - h: size.height, - startdelay: startdelay, - linearity: video.linearity || null, - minduration: duration.min, - maxduration: duration.max, - protocols, - api: getApi(protocols), - format: hasPlayerSize ? playerSize.map(s => { - return {w: s[0], h: s[1]}; - }) : null, - pos: video.position || 0 - }; -} - -function getApi(protocols) { - let defaultValue = [2]; - let listProtocols = [ - {key: 'VPAID_1_0', value: 1}, - {key: 'VPAID_2_0', value: 2}, - {key: 'MRAID_1', value: 3}, - {key: 'ORMMA', value: 4}, - {key: 'MRAID_2', value: 5}, - {key: 'MRAID_3', value: 6}, - ]; - if (protocols) { - return listProtocols.filter(p => { - return protocols.indexOf(p.key) !== -1; - }).map(p => p.value) - } else { - return defaultValue; - } -} - -function isInstream(video) { - return isPlainObject(video) && (video.context === 'instream'); -} - -function isOutstream(video) { - return isPlainObject(video) && (video.startdelay === null) -} - -function computeStartDelay(data, params) { - if (isInstream(data)) { - if (params.video.instreamContext === 'pre-roll') return 0; - if (params.video.instreamContext === 'mid-roll') return -1; - if (params.video.instreamContext === 'post-roll') return -2; - } - - return null; -} - -function generateNativeFromAdUnit(data) { - const {type} = data; - const presetFormatter = type && NATIVE_PRESET_FORMATTERS[data.type]; - const nativeFields = presetFormatter ? presetFormatter(data) : data; - - const assets = Object - .keys(nativeFields) - .reduce((acc, placement) => { - const placementData = nativeFields[placement]; - const assetInfo = NATIVE_PLACEMENTS[placement]; - - if (!assetInfo) return acc; - - const {id, name, type} = assetInfo; - const {required, len, sizes = []} = placementData; - let wmin; - let hmin; - - if (isArray(sizes[0])) { - wmin = sizes[0][0]; - hmin = sizes[0][1]; - } else { - wmin = sizes[0]; - hmin = sizes[1]; - } - - const content = {}; - - if (type) content.type = type; - if (len) content.len = len; - if (wmin) content.wmin = wmin; - if (hmin) content.hmin = hmin; - - acc.push({id, required, [name]: content}); - - return acc; - }, []); - - return { - request: JSON.stringify({assets}) - }; -} - -function formatNativePresetImage(data) { - const sizes = data.sizes; - - return { - image: { - required: true, - sizes - }, - title: { - required: true - }, - sponsoredBy: { - required: true - }, - body: { - required: false - }, - cta: { - required: false - }, - icon: { - required: false - } - }; -} function site(bidRequests, bidderRequest) { const url = @@ -425,21 +221,6 @@ function site(bidRequests, bidderRequest) { return undefined; } -function app(bidderRequest) { - const pubId = bidderRequest && bidderRequest.length > 0 - ? bidderRequest[0].params.publisherId - : '0'; - const appParams = bidderRequest[0].params.app; - if (appParams) { - var pub = { - id:pubId.toString() - }; - appParams.publisher= pub; - return appParams; - } - return undefined; -} - function validateServerResponse(serverResponse) { return isPlainObject(serverResponse) && isPlainObject(serverResponse.body) && @@ -473,10 +254,6 @@ function validateBids(bid, serverRequest) { if (!isNumber(bid.h)) return false; if (!isNumber(bid.w)) return false; } - if (isBidAVideo(bid)) { - if (!(isNone(bid.h) || isNumber(bid.h))) return false; - if (!(isNone(bid.w) || isNumber(bid.w))) return false; - } const impression = getImpressionData(serverRequest, bid.impid); @@ -487,12 +264,6 @@ function validateBids(bid, serverRequest) { if (isBidABanner(bid)) { if (!isPlainObject(impression.openRTB.banner)) return false; } - if (isBidAVideo(bid)) { - if (!isPlainObject(impression.openRTB.video)) return false; - } - if (isBidANative(bid)) { - if (!isPlainObject(impression.openRTB.native) || !tryParse(bid.adm)) return false; - } return true; } @@ -503,18 +274,6 @@ function isBidABanner(bid) { bid.ext.venaven.media_type === 'banner'; } -function isBidAVideo(bid) { - return isPlainObject(bid) && - isPlainObject(bid.ext) && - bid.ext.venaven.media_type === 'video'; -} - -function isBidANative(bid) { - return isPlainObject(bid) && - isPlainObject(bid.ext) && - bid.ext.venaven.media_type === 'native'; -} - function getImpressionData(serverRequest, impressionId) { const openRTBImpression = find(serverRequest.data.imp, imp => imp.id === impressionId); @@ -524,6 +283,13 @@ function getImpressionData(serverRequest, impressionId) { }; } +function hasAppId(bid) { + if (bid.params && bid.params.app) { + return !!bid.params.app.id + } + return !!bid.params.app +} + const VAST_REGEXP = /VAST\s+version/; function getMediaType(adm) { @@ -535,7 +301,7 @@ function getMediaType(adm) { const markup = safeJSONparse(adm.replace(/\\/g, '')); - if (markup && utils.isPlainObject(markup.native)) { + if (markup && isPlainObject(markup.native)) { return NATIVE; } @@ -551,7 +317,6 @@ function safeJSONparse(...args) { } function generateAdFromBid(bid, bidResponse) { - const isVideo = isBidAVideo(bid); const mediaType = getMediaType(bid.adm); const base = { requestId: bid.impid, @@ -567,10 +332,8 @@ function generateAdFromBid(bid, bidResponse) { base.meta = { advertiserDomains: bid.adomain }; } - if (isBidANative(bid)) return {...base, native: formatNativeData(bid)}; - - const size = getSizeFromBid(bid, impressionData); - const creative = getCreativeFromBid(bid, impressionData); + const size = getSizeFromBid(bid); + const creative = getCreativeFromBid(bid); return { ...base, @@ -584,105 +347,23 @@ function generateAdFromBid(bid, bidResponse) { }; } -function formatNativeData({adm, price}) { - const parsedAdm = tryParse(adm); - const {assets, link: {url, clicktrackers}, imptrackers, jstracker} = parsedAdm.native; - const placements = NATIVE_PLACEMENTS; - const placementIds = NATIVE_ID_MAPPING; - - return assets.reduce((acc, asset) => { - const placementName = placementIds[asset.id]; - const content = placementName && asset[placements[placementName].name]; - if (!content) return acc; - acc[placementName] = content.text || content.value || {url: content.url, width: content.w, height: content.h}; - return acc; - }, { - clickUrl: url, - clickTrackers: clicktrackers, - impressionTrackers: imptrackers && imptrackers.map(impTracker => replaceAuctionPrice(impTracker, price)), - javascriptTrackers: jstracker && [jstracker] - }); -} - -function getSizeFromBid(bid, impressionData) { +function getSizeFromBid(bid) { if (isNumber(bid.w) && isNumber(bid.h)) { return { width: bid.w, height: bid.h }; } - - if (isImpressionAVideo(impressionData.openRTB)) { - const { video } = impressionData.openRTB; - - if (isNumber(video.w) && isNumber(video.h)) { - return { width: video.w, height: video.h }; - } - } - return { width: null, height: null }; } -function getCreativeFromBid(bid, impressionData) { +function getCreativeFromBid(bid) { const shouldUseAdMarkup = !!bid.adm; const price = bid.price; return { markup: shouldUseAdMarkup ? replaceAuctionPrice(bid.adm, price) : null, - markupUrl: !shouldUseAdMarkup ? replaceAuctionPrice(bid.nurl, price) : null, - renderer: getRendererFromBid(bid, impressionData) + markupUrl: !shouldUseAdMarkup ? replaceAuctionPrice(bid.nurl, price) : null }; } -function getRendererFromBid(bid, impressionData) { - const isOutstreamImpression = isBidAVideo(bid) && - isImpressionAVideo(impressionData.openRTB) && - isOutstream(impressionData.openRTB.video); - - return isOutstreamImpression - ? buildOutstreamRenderer(impressionData) - : null; -} - -function buildOutstreamRenderer(impressionData) { - const renderer = Renderer.install({ - url: OUTSTREAM_VIDEO_PLAYER_URL, - loaded: false, - adUnitCode: impressionData.internal.adUnitCode - }); - - renderer.setRender((ad) => { - ad.renderer.push(() => { - const container = impressionData.internal.container - ? document.querySelector(impressionData.internal.container) - : document.getElementById(impressionData.internal.adUnitCode); - - const player = new window.VASTPlayer(container); - - player.on('ready', () => { - player.adVolume = 0; - player.startAd(); - }); - - try { - isStr(ad.adUrl) - ? player.load(ad.adUrl) - : player.loadXml(ad.ad) - } catch (err) { - logError(err); - } - }); - }); - - return renderer; -} - -function tryParse(data) { - try { - return JSON.parse(data); - } catch (err) { - logError(err); - return null; - } -} - function hasAppDeviceInfo(bid) { if (bid.params) { return !!bid.params.app @@ -691,7 +372,7 @@ function hasAppDeviceInfo(bid) { const venavenBidderSpec = { code: 'ventes', - supportedMediaTypes: [BANNER, VIDEO, NATIVE], + supportedMediaTypes: [BANNER], isBidRequestValid(adUnit) { const allowedBidderCodes = [this.code]; From 6b5846931af4ea7adf076502034db81c0620cd43 Mon Sep 17 00:00:00 2001 From: Jesso Date: Fri, 1 Oct 2021 17:30:33 +0530 Subject: [PATCH 04/36] Ventes Avenues Solved issues --- modules/ventesBidAdaptor.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/ventesBidAdaptor.js b/modules/ventesBidAdaptor.js index a3a69b4ed17..ebb7e24e001 100644 --- a/modules/ventesBidAdaptor.js +++ b/modules/ventesBidAdaptor.js @@ -9,12 +9,12 @@ const BID_METHOD = 'POST'; const BIDDER_URL = 'http://13.234.201.146:8088/va/ad'; const FIRST_PRICE = 1; const NET_REVENUE = true; +// eslint-disable-next-line no-template-curly-in-string const AUCTION_PRICE = '${AUCTION_PRICE}'; const TTL = 10; const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately - function groupBy(values, key) { const groups = values.reduce((acc, value) => { const groupId = value[key]; @@ -62,9 +62,6 @@ function hasUserInfo(bid) { } function validateParameters(parameters, adUnit) { - if (isVideo(adUnit.mediaTypes)) { - if (!isPlainObject(parameters)) return false; - } if (!(parameters.placementId)) { return false; } @@ -87,8 +84,8 @@ function createServerRequestFromAdUnits(adUnits, bidRequestId, adUnitContext) { url: BIDDER_URL, data: generateBidRequestsFromAdUnits(adUnits, bidRequestId, adUnitContext), options: { - contentType: 'application/json', - withCredentials: false, + contentType: 'application/json', + withCredentials: false, } } } @@ -146,8 +143,8 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext payload.id = bidRequestId payload.at = FIRST_PRICE payload.cur = ['USD'] - payload.imp = adUnits.reduce(generateImpressionsFromAdUnit, []) - payload.site = site(adUnits, adUnitContext) + payload.imp = bidRequests.reduce(generateImpressionsFromAdUnit, []) + payload.site = site(bidRequests, adUnitContext) if (appDeviceObjBid) { payload.device = appDeviceObj } @@ -165,7 +162,6 @@ function generateImpressionsFromAdUnit(acc, adUnit) { const {bidId, mediaTypes, params} = adUnit; const {placementId} = params; const pmp = {}; - const ext = {placementId}; if (placementId) pmp.deals = [{id: placementId}] @@ -192,7 +188,6 @@ function generateBannerFromAdUnit(impId, data, params) { return data.sizes.map(([w, h]) => ({id: `${impId}`, banner: {format: [{w, h}], w, h, pos}, pmp, ext, tagid: placementId})); } - function site(bidRequests, bidderRequest) { const url = config.getConfig('pageUrl') || (bidderRequest && @@ -239,7 +234,6 @@ function validateBids(bid, serverRequest) { if (!isStr(bid.impid)) return false; if (!isStr(bid.crid)) return false; if (!isNumber(bid.price)) return false; - if (!bid.adm && !bid.nurl) return false; if (bid.adm) { if (!isStr(bid.adm)) return false; @@ -324,7 +318,7 @@ function generateAdFromBid(bid, bidResponse) { currency: bidResponse.cur, ttl: TTL, creativeId: bid.crid, - mediaType:mediaType, + mediaType: mediaType, netRevenue: NET_REVENUE }; @@ -341,8 +335,8 @@ function generateAdFromBid(bid, bidResponse) { width: size.width, ad: creative.markup, adUrl: creative.markupUrl, - vastXml: isVideo && !isStr(creative.markupUrl) ? creative.markup : null, - vastUrl: isVideo && isStr(creative.markupUrl) ? creative.markupUrl : null, + // vastXml: isVideo && !isStr(creative.markupUrl) ? creative.markup : null, + // vastUrl: isVideo && isStr(creative.markupUrl) ? creative.markupUrl : null, renderer: creative.renderer }; } From a9c8a7f9f317ffc9025e44cc0ffdaec05cf3bafb Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 19:17:18 +0530 Subject: [PATCH 05/36] Ventes Avenues Solved issues --- ...entesBidAdaptor.js => ventesBidAdapter.js} | 0 test/spec/modules/ventesBidAdapter_spec.js | 1180 +++++++++++++++++ 2 files changed, 1180 insertions(+) rename modules/{ventesBidAdaptor.js => ventesBidAdapter.js} (100%) create mode 100644 test/spec/modules/ventesBidAdapter_spec.js diff --git a/modules/ventesBidAdaptor.js b/modules/ventesBidAdapter.js similarity index 100% rename from modules/ventesBidAdaptor.js rename to modules/ventesBidAdapter.js diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js new file mode 100644 index 00000000000..6b9eb672314 --- /dev/null +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -0,0 +1,1180 @@ +import { expect } from 'chai'; +import * as utils from 'src/utils.js'; +import { spec } from 'modules/ventesBidAdapter.js'; + +const BIDDER_URL = 'http://13.234.201.146:8088/va/ad'; + +describe('Ventes Adapter', function () { + const examples = { + adUnit_banner: { + adUnitCode: 'ad_unit_banner', + bidder: 'ventes', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: {}, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + }, + + serverRequest_banner: { + method: 'POST', + url: 'http://13.234.201.146:8088/va/ad', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_banner', + banner: { + format: [{ + w: 300, + h: 200 + }] + } + } + ], + site: { + page: 'https://ventesavenues.in', + domain: 'ventesavenues.in', + name: 'ventesavenues.in' + }, + device: { + ua: '', + ip: "123.145.167.189", + ifa: "AEBE52E7-03EE-455A-B3C4-E57283966239", + }, + user: null, + regs: null, + at: 1 + } + }, + serverResponse_banner: { + body: { + cur: 'USD', + seatbid: [ + { + seat: '4', + bid: [ + { + id: 'id', + impid: 'imp_id_banner', + cid: 'campaign_id', + crid: 'creative_id', + adm: '..', + price: 1.5, + } + ] + } + ] + } + } + }; + + describe('isBidRequestValid', function () { + describe('General', function () { + it('should return false when not given an ad unit', function () { + const adUnit = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an invalid ad unit', function () { + const adUnit = 'bad_bid'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without bidder code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidder = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a bad bidder code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidder = 'unknownBidder'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without ad unit code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.adUnitCode = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid ad unit code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.adUnitCode = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without bid request identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidderRequestId = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid bid request identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidderRequestId = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without impression identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidId = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid impression identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidId = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with empty media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with invalid media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = 'bad_media_types'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + }); + + describe('Banner', function () { + it('should return true when given a valid ad unit', function () { + const adUnit = examples.adUnit_banner; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid ad unit without bidder parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.params = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid ad unit with invalid publisher id', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.params = {}; + adUnit.params.publisherId = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid ad unit without placement id', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.params = {}; + adUnit.params.publisherId = 'agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid ad unit with invalid placement id', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.params = {}; + adUnit.params.publisherId = 'agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV'; + adUnit.params.placementId = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return false when given an ad unit without size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = 'bad_banner_size'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an empty size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = ['bad_banner_size_value']; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with less than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with more than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, 250, 30]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative width value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[-300, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative height value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, -250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid width value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[false, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid height value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, {}]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + }); + }); + + describe('buildRequests', function () { + describe('ServerRequest', function () { + it('should return a server request when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + expect(serverRequests).to.be.an('array').and.to.have.length(1); + expect(serverRequests[0].method).to.exist.and.to.be.a('string').and.to.equal('POST'); + expect(serverRequests[0].url).to.exist.and.to.be.a('string').and.to.equal(BIDDER_URL); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + }); + + it('should return an empty server request list when given an empty ad unit list and a valid ad unit context', function () { + const adUnits = []; + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + expect(serverRequests).to.be.an('array').and.to.have.length(0); + }); + + it('should not return a server request when given no ad unit and a valid ad unit context', function () { + const serverRequests = spec.buildRequests(null, examples.adUnitContext); + expect(serverRequests).to.equal(null); + }); + + it('should not return a server request when given a valid ad unit and no ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + const serverRequests = spec.buildRequests(adUnits, null); + expect(serverRequests).to.be.an('array').and.to.have.length(1); + }); + + it('should not return a server request when given a valid ad unit and an invalid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + const serverRequests = spec.buildRequests(adUnits, {}); + expect(serverRequests).to.be.an('array').and.to.have.length(1); + }); + }); + + describe('BidRequest', function () { + it('should return a valid server request when given a valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.at).to.exist.and.to.be.a('number').and.to.equal(1); + expect(serverRequests[0].data.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.ext.adot).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.ext.adot.adapter_version).to.exist.and.to.be.a('string').and.to.equal('v1.0.0'); + }); + + it('should return one server request when given one valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + }); + }); + + describe('Impression', function () { + describe('Banner', function () { + it('should return a server request with one impression when given a valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + }); + }); + }); + + describe('Site', function () { + it('should return a server request with site information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.site.page).to.exist.and.to.be.an('string').and.to.equal(adUnitContext.refererInfo.referer); + expect(serverRequests[0].data.site.id).to.equal(undefined); + expect(serverRequests[0].data.site.domain).to.exist.and.to.be.an('string').and.to.equal('we-are-adot.com'); + expect(serverRequests[0].data.site.name).to.exist.and.to.be.an('string').and.to.equal('we-are-adot.com'); + }); + + it('should return a server request without site information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context without referer information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with invalid referer information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo = 'bad_referer_information'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context without referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with an invalid referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = {}; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with a misformatted referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = 'we-are-adot'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + }); + + describe('Device', function () { + it('should return a server request with device information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.device).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.device.ua).to.exist.and.to.be.a('string'); + expect(serverRequests[0].data.device.language).to.exist.and.to.be.a('string'); + }); + }); + + describe('Regs', function () { + it('should return a server request with regulations information when given a valid ad unit and a valid ad unit context with GDPR applying', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext.gdpr).to.exist.and.to.be.a('boolean').and.to.equal(adUnitContext.gdprConsent.gdprApplies); + }); + + it('should return a server request with regulations information when given a valid ad unit and a valid ad unit context with GDPR not applying', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.gdprApplies = false; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext.gdpr).to.exist.and.to.be.a('boolean').and.to.equal(adUnitContext.gdprConsent.gdprApplies); + }); + + it('should return a server request without regulations information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context without GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context with invalid GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = 'bad_gdpr_consent'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context with invalid GDPR application information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.gdprApplies = 'bad_gdpr_applies'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + }); + + describe('User', function () { + it('should return a server request with user information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.user.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.user.ext.consent).to.exist.and.to.be.a('string').and.to.equal(adUnitContext.gdprConsent.consentString); + }); + + it('should return a server request without user information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context without GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context with invalid GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = 'bad_gdpr_consent'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context with an invalid consent string', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.consentString = true; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + }); + }); + + describe('interpretResponse', function () { + describe('General', function () { + it('should return an ad when given a valid server response with one bid with USD currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = 'USD'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return no ad when not given a server response', function () { + const ads = spec.interpretResponse(null); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when not given a server response body', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given an invalid server response body', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body = 'invalid_body'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response without seat bids', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with invalid seat bids', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = 'invalid_seat_bids'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an empty seat bids array', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = []; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an invalid seat bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = 'invalid_bids'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an empty bids array', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = []; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an invalid bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = ['invalid_bid']; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without impression identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].impid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid impression identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].impid = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without creative identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].crid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid creative identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].crid = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without ad markup and ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = undefined; + serverResponse.body.seatbid[0].bid[0].nurl = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid ad markup', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an ad markup without auction price macro', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = 'creative_data'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an ad serving URL without auction price macro', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = 'win_notice_url'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without bid price', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].price = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid bid price', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].price = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext = 'bad_ext'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without adot extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid adot extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot = 'bad_adot_ext'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an unknown media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = 'unknown_media_type'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and no server request', function () { + const serverRequest = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and an invalid server request', function () { + const serverRequest = 'bad_server_request'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without bid request', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with an invalid bid request', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data = 'bad_bid_request'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with an invalid impression field', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp = 'invalid_impressions'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without matching impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp[0].id = 'unknown_imp_id'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + }); + + describe('Banner', function () { + it('should return an ad when given a valid server response with one bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid without a win notice URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.equal(admWithAuctionPriceReplaced); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid using an ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + const nurlWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].nurl, serverResponse.body.seatbid[0].bid[0].price); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].ad).to.equal(null); + expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.equal(nurlWithAuctionPriceReplaced); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return no ad when given a server response with a bid without height', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].h = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid height', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].h = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without width', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].w = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid width', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].w = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without banner impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp[0].banner = undefined; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + }); + }); +}); \ No newline at end of file From d39fe181c2affdad81d09c84722c13d7f98fce5b Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 19:20:20 +0530 Subject: [PATCH 06/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 6b9eb672314..0ca267299ca 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -42,8 +42,8 @@ describe('Ventes Adapter', function () { }, device: { ua: '', - ip: "123.145.167.189", - ifa: "AEBE52E7-03EE-455A-B3C4-E57283966239", + ip: '123.145.167.189', + ifa: AEBE52E7-03EE-455A-B3C4-E57283966239', }, user: null, regs: null, @@ -1077,6 +1077,7 @@ describe('Ventes Adapter', function () { const serverRequest = examples.serverRequest_banner; const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = undefined; const ads = spec.interpretResponse(serverResponse, serverRequest); From a9a3af053b492c9d6b638a95d847180bdb20a39e Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 19:22:29 +0530 Subject: [PATCH 07/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 0ca267299ca..5bf73945897 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -43,7 +43,7 @@ describe('Ventes Adapter', function () { device: { ua: '', ip: '123.145.167.189', - ifa: AEBE52E7-03EE-455A-B3C4-E57283966239', + ifa: 'AEBE52E7-03EE-455A-B3C4-E57283966239', }, user: null, regs: null, From 89ba39dc63b5be9160327b3b71f69db64dc27e4a Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 19:25:14 +0530 Subject: [PATCH 08/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 26 ---------------------- 1 file changed, 26 deletions(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 5bf73945897..71ccde4454d 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -1073,32 +1073,6 @@ describe('Ventes Adapter', function () { expect(ads[0].renderer).to.equal(null); }); - it('should return an ad when given a valid server response with one bid without a win notice URL', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - - serverResponse.body.seatbid[0].bid[0].nurl = undefined; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price); - - expect(ads).to.be.an('array').and.to.have.length(1); - expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.equal(admWithAuctionPriceReplaced); - expect(ads[0].adUrl).to.equal(null); - expect(ads[0].vastXml).to.equal(null); - expect(ads[0].vastUrl).to.equal(null); - expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); - expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); - expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); - expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); - expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); - expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); - expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); - expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); - expect(ads[0].renderer).to.equal(null); - }); - it('should return an ad when given a valid server response with one bid using an ad serving URL', function () { const serverRequest = examples.serverRequest_banner; From 8c2c49f98fe3a76c406233261765176bd59fe64e Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 19:27:06 +0530 Subject: [PATCH 09/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 71ccde4454d..8417157a30f 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -1152,4 +1152,4 @@ describe('Ventes Adapter', function () { }); }); }); -}); \ No newline at end of file +}); From f2464d018770a98c123a4acfb6e8376ac1a1a363 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 19:36:32 +0530 Subject: [PATCH 10/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 8417157a30f..3b96f453d96 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -11,7 +11,10 @@ describe('Ventes Adapter', function () { bidder: 'ventes', bidderRequestId: 'bid_request_id', bidId: 'bid_id', - params: {}, + params: { + publisherId: 'agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV', + placementId: 'VA-062-0013-0183', + }, mediaTypes: { banner: { sizes: [[300, 250]] From ba106c61d1174ecc2ba6161446f5f764a0a59463 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 19:45:57 +0530 Subject: [PATCH 11/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 3b96f453d96..c1f01dff701 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -22,6 +22,12 @@ describe('Ventes Adapter', function () { } }, + adUnitContext: { + refererInfo: { + referer: 'http://127.0.0.1:5500/modules/Adapter.html', + } + }, + serverRequest_banner: { method: 'POST', url: 'http://13.234.201.146:8088/va/ad', @@ -178,7 +184,7 @@ describe('Ventes Adapter', function () { const adUnit = utils.deepClone(examples.adUnit_banner); adUnit.params = undefined; - expect(spec.isBidRequestValid(adUnit)).to.equal(true); + expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return true when given a valid ad unit with invalid publisher id', function () { @@ -186,7 +192,7 @@ describe('Ventes Adapter', function () { adUnit.params = {}; adUnit.params.publisherId = undefined; - expect(spec.isBidRequestValid(adUnit)).to.equal(true); + expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return true when given a valid ad unit without placement id', function () { @@ -194,7 +200,7 @@ describe('Ventes Adapter', function () { adUnit.params = {}; adUnit.params.publisherId = 'agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV'; - expect(spec.isBidRequestValid(adUnit)).to.equal(true); + expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return true when given a valid ad unit with invalid placement id', function () { @@ -203,7 +209,7 @@ describe('Ventes Adapter', function () { adUnit.params.publisherId = 'agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV'; adUnit.params.placementId = undefined; - expect(spec.isBidRequestValid(adUnit)).to.equal(true); + expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit without size', function () { From 170b8653dafa43155ac074ece3c93f4ab1c7e30c Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 20:33:38 +0530 Subject: [PATCH 12/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 171 +-------------------- 1 file changed, 5 insertions(+), 166 deletions(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index c1f01dff701..f7ca6983614 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -24,7 +24,7 @@ describe('Ventes Adapter', function () { adUnitContext: { refererInfo: { - referer: 'http://127.0.0.1:5500/modules/Adapter.html', + referer: 'https://ventesavenues.in', } }, @@ -53,6 +53,7 @@ describe('Ventes Adapter', function () { ua: '', ip: '123.145.167.189', ifa: 'AEBE52E7-03EE-455A-B3C4-E57283966239', + language: 'en' }, user: null, regs: null, @@ -180,13 +181,6 @@ describe('Ventes Adapter', function () { expect(spec.isBidRequestValid(adUnit)).to.equal(true); }); - it('should return true when given a valid ad unit without bidder parameters', function () { - const adUnit = utils.deepClone(examples.adUnit_banner); - adUnit.params = undefined; - - expect(spec.isBidRequestValid(adUnit)).to.equal(false); - }); - it('should return true when given a valid ad unit with invalid publisher id', function () { const adUnit = utils.deepClone(examples.adUnit_banner); adUnit.params = {}; @@ -326,9 +320,6 @@ describe('Ventes Adapter', function () { expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); expect(serverRequests[0].data.at).to.exist.and.to.be.a('number').and.to.equal(1); - expect(serverRequests[0].data.ext).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.ext.adot).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.ext.adot.adapter_version).to.exist.and.to.be.a('string').and.to.equal('v1.0.0'); }); it('should return one server request when given one valid ad unit', function () { @@ -351,7 +342,7 @@ describe('Ventes Adapter', function () { expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}`); expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][0]); expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][1]); @@ -377,22 +368,8 @@ describe('Ventes Adapter', function () { expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); expect(serverRequests[0].data.site).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.site.page).to.exist.and.to.be.an('string').and.to.equal(adUnitContext.refererInfo.referer); - expect(serverRequests[0].data.site.id).to.equal(undefined); - expect(serverRequests[0].data.site.domain).to.exist.and.to.be.an('string').and.to.equal('we-are-adot.com'); - expect(serverRequests[0].data.site.name).to.exist.and.to.be.an('string').and.to.equal('we-are-adot.com'); - }); - - it('should return a server request without site information when not given an ad unit context', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = undefined; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.site).to.equal(null); + expect(serverRequests[0].data.site.domain).to.exist.and.to.be.an('string').and.to.equal('ventesavenues.in'); + expect(serverRequests[0].data.site.name).to.exist.and.to.be.an('string').and.to.equal('ventesavenues.in'); }); it('should return a server request without site information when given an ad unit context without referer information', function () { @@ -406,7 +383,6 @@ describe('Ventes Adapter', function () { expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.site).to.equal(null); }); it('should return a server request without site information when given an ad unit context with invalid referer information', function () { @@ -420,7 +396,6 @@ describe('Ventes Adapter', function () { expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.site).to.equal(null); }); it('should return a server request without site information when given an ad unit context without referer', function () { @@ -434,7 +409,6 @@ describe('Ventes Adapter', function () { expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.site).to.equal(null); }); it('should return a server request without site information when given an ad unit context with an invalid referer', function () { @@ -448,7 +422,6 @@ describe('Ventes Adapter', function () { expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.site).to.equal(null); }); it('should return a server request without site information when given an ad unit context with a misformatted referer', function () { @@ -462,7 +435,6 @@ describe('Ventes Adapter', function () { expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.site).to.equal(null); }); }); @@ -481,94 +453,6 @@ describe('Ventes Adapter', function () { }); }); - describe('Regs', function () { - it('should return a server request with regulations information when given a valid ad unit and a valid ad unit context with GDPR applying', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = examples.adUnitContext; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.regs).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.regs.ext).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.regs.ext.gdpr).to.exist.and.to.be.a('boolean').and.to.equal(adUnitContext.gdprConsent.gdprApplies); - }); - - it('should return a server request with regulations information when given a valid ad unit and a valid ad unit context with GDPR not applying', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = utils.deepClone(examples.adUnitContext); - adUnitContext.gdprConsent.gdprApplies = false; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.regs).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.regs.ext).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.regs.ext.gdpr).to.exist.and.to.be.a('boolean').and.to.equal(adUnitContext.gdprConsent.gdprApplies); - }); - - it('should return a server request without regulations information when not given an ad unit context', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = undefined; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.regs).to.equal(null); - }); - - it('should return a server request without regulations information when given an ad unit context without GDPR information', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = utils.deepClone(examples.adUnitContext); - adUnitContext.gdprConsent = undefined; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.regs).to.equal(null); - }); - - it('should return a server request without regulations information when given an ad unit context with invalid GDPR information', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = utils.deepClone(examples.adUnitContext); - adUnitContext.gdprConsent = 'bad_gdpr_consent'; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.regs).to.equal(null); - }); - - it('should return a server request without regulations information when given an ad unit context with invalid GDPR application information', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = utils.deepClone(examples.adUnitContext); - adUnitContext.gdprConsent.gdprApplies = 'bad_gdpr_applies'; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.regs).to.equal(null); - }); - }); - describe('User', function () { it('should return a server request with user information when given a valid ad unit and a valid ad unit context', function () { const adUnits = [examples.adUnit_banner]; @@ -581,8 +465,6 @@ describe('Ventes Adapter', function () { expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); expect(serverRequests[0].data.user).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.user.ext).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.user.ext.consent).to.exist.and.to.be.a('string').and.to.equal(adUnitContext.gdprConsent.consentString); }); it('should return a server request without user information when not given an ad unit context', function () { @@ -595,49 +477,6 @@ describe('Ventes Adapter', function () { expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.user).to.equal(null); - }); - - it('should return a server request without user information when given an ad unit context without GDPR information', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = utils.deepClone(examples.adUnitContext); - adUnitContext.gdprConsent = undefined; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.user).to.equal(null); - }); - - it('should return a server request without user information when given an ad unit context with invalid GDPR information', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = utils.deepClone(examples.adUnitContext); - adUnitContext.gdprConsent = 'bad_gdpr_consent'; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.user).to.equal(null); - }); - - it('should return a server request without user information when given an ad unit context with an invalid consent string', function () { - const adUnits = [examples.adUnit_banner]; - - const adUnitContext = utils.deepClone(examples.adUnitContext); - adUnitContext.gdprConsent.consentString = true; - - const serverRequests = spec.buildRequests(adUnits, adUnitContext); - - expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); - expect(serverRequests[0].data).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); - expect(serverRequests[0].data.user).to.equal(null); }); }); }); From 7620b4b410795524fe58a168c619c6a0f5e3ab5e Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 20:48:07 +0530 Subject: [PATCH 13/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 65 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index ebb7e24e001..ee665f468c8 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -9,11 +9,10 @@ const BID_METHOD = 'POST'; const BIDDER_URL = 'http://13.234.201.146:8088/va/ad'; const FIRST_PRICE = 1; const NET_REVENUE = true; -// eslint-disable-next-line no-template-curly-in-string -const AUCTION_PRICE = '${AUCTION_PRICE}'; const TTL = 10; const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately +const DOMAIN_REGEX = new RegExp('//([^/]*)'); function groupBy(values, key) { const groups = values.reduce((acc, value) => { @@ -72,6 +71,34 @@ function validateParameters(parameters, adUnit) { return true; } +function extractSiteDomainFromURL(url) { + if (!url || !isStr(url)) return null; + + const domain = url.match(DOMAIN_REGEX); + + if (isArray(domain) && domain.length === 2) return domain[1]; + + return null; +} + +function generateSiteFromAdUnitContext(bidRequests, adUnitContext) { + if (!adUnitContext || !adUnitContext.refererInfo) return null; + + const domain = extractSiteDomainFromURL(adUnitContext.refererInfo.referer); + const publisherId = bidRequests.params.publisherId; + + if (!domain) return null; + + return { + page: adUnitContext.refererInfo.referer, + domain: domain, + name: domain, + publisher: { + id: publisherId + } + }; +} + function validateServerRequest(serverRequest) { return isPlainObject(serverRequest) && isPlainObject(serverRequest.data) && @@ -144,6 +171,7 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext payload.at = FIRST_PRICE payload.cur = ['USD'] payload.imp = bidRequests.reduce(generateImpressionsFromAdUnit, []) + payload.site = generateSiteFromAdUnitContext(bidRequests, adUnitContext), payload.site = site(bidRequests, adUnitContext) if (appDeviceObjBid) { payload.device = appDeviceObj @@ -188,34 +216,6 @@ function generateBannerFromAdUnit(impId, data, params) { return data.sizes.map(([w, h]) => ({id: `${impId}`, banner: {format: [{w, h}], w, h, pos}, pmp, ext, tagid: placementId})); } -function site(bidRequests, bidderRequest) { - const url = - config.getConfig('pageUrl') || (bidderRequest && - bidderRequest.refererInfo && - bidderRequest.refererInfo.referer); - - const pubId = - bidRequests && bidRequests.length > 0 - ? bidRequests[0].params.publisherId - : '0'; - const siteId = - bidRequests && bidRequests.length > 0 ? bidRequests[0].params.siteId : '0'; - const appParams = bidRequests[0].params.app; - if (!appParams) { - return { - publisher: { - id: pubId.toString(), - domain: config.getConfig('publisherDomain') - }, - id: siteId ? siteId.toString() : pubId.toString(), - page: url, - domain: - (url && parseUrl(url).hostname) || config.getConfig('publisherDomain') - }; - } - return undefined; -} - function validateServerResponse(serverResponse) { return isPlainObject(serverResponse) && isPlainObject(serverResponse.body) && @@ -237,11 +237,6 @@ function validateBids(bid, serverRequest) { if (!bid.adm && !bid.nurl) return false; if (bid.adm) { if (!isStr(bid.adm)) return false; - if (bid.adm.indexOf(AUCTION_PRICE) === -1) return false; - } - if (bid.nurl) { - if (!isStr(bid.nurl)) return false; - if (bid.nurl.indexOf(AUCTION_PRICE) === -1) return false; } if (isBidABanner(bid)) { From 4b7049bfb7cb561dd9d2af88761b23c495272ae9 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 20:50:30 +0530 Subject: [PATCH 14/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index ee665f468c8..5541b0b56f2 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -1,6 +1,6 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; -import {convertCamelToUnderscore, parseUrl, isStr, isArray, isNumber, isPlainObject, replaceAuctionPrice} from '../src/utils.js'; +import {convertCamelToUnderscore, isStr, isArray, isNumber, isPlainObject, replaceAuctionPrice} from '../src/utils.js'; import find from 'core-js-pure/features/array/find.js'; import includes from 'core-js-pure/features/array/includes.js'; import { config } from '../src/config.js'; @@ -171,8 +171,7 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext payload.at = FIRST_PRICE payload.cur = ['USD'] payload.imp = bidRequests.reduce(generateImpressionsFromAdUnit, []) - payload.site = generateSiteFromAdUnitContext(bidRequests, adUnitContext), - payload.site = site(bidRequests, adUnitContext) + payload.site = generateSiteFromAdUnitContext(bidRequests, adUnitContext) if (appDeviceObjBid) { payload.device = appDeviceObj } From 627d12ef62a6e1e1cb6ec45f614902efac1877d5 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 20:57:47 +0530 Subject: [PATCH 15/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index 5541b0b56f2..6e8dcb33f6e 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -85,7 +85,7 @@ function generateSiteFromAdUnitContext(bidRequests, adUnitContext) { if (!adUnitContext || !adUnitContext.refererInfo) return null; const domain = extractSiteDomainFromURL(adUnitContext.refererInfo.referer); - const publisherId = bidRequests.params.publisherId; + const publisherId = bidRequests[0].params.publisherId; if (!domain) return null; From 91f5c6c24de37b4f91ab996d5c690700440a920d Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 21:13:00 +0530 Subject: [PATCH 16/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 2 +- test/spec/modules/ventesBidAdapter_spec.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index 6e8dcb33f6e..052535e2213 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -233,7 +233,7 @@ function validateBids(bid, serverRequest) { if (!isStr(bid.impid)) return false; if (!isStr(bid.crid)) return false; if (!isNumber(bid.price)) return false; - if (!bid.adm && !bid.nurl) return false; + if (!bid.adm) return false; if (bid.adm) { if (!isStr(bid.adm)) return false; } diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index f7ca6983614..6ce2d45af28 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -14,6 +14,10 @@ describe('Ventes Adapter', function () { params: { publisherId: 'agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV', placementId: 'VA-062-0013-0183', + device: { + ip: '123.145.167.189', + ifa:"AEBE52E7-03EE-455A-B3C4-E57283966239", + } }, mediaTypes: { banner: { @@ -489,11 +493,11 @@ describe('Ventes Adapter', function () { const serverResponse = utils.deepClone(examples.serverResponse_banner); serverResponse.body.cur = 'USD'; + console.log(serverResponse) + console.log(serverRequest) const ads = spec.interpretResponse(serverResponse, serverRequest); - const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price); expect(ads).to.be.an('array').and.to.have.length(1); - expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced); expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); From dba02e83cee21f670c2e2f0e6c8335dd44afa9a6 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 21:15:11 +0530 Subject: [PATCH 17/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 6ce2d45af28..3091472cb09 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -16,7 +16,7 @@ describe('Ventes Adapter', function () { placementId: 'VA-062-0013-0183', device: { ip: '123.145.167.189', - ifa:"AEBE52E7-03EE-455A-B3C4-E57283966239", + ifa: 'AEBE52E7-03EE-455A-B3C4-E57283966239', } }, mediaTypes: { @@ -492,9 +492,7 @@ describe('Ventes Adapter', function () { const serverResponse = utils.deepClone(examples.serverResponse_banner); serverResponse.body.cur = 'USD'; - - console.log(serverResponse) - console.log(serverRequest) + const ads = spec.interpretResponse(serverResponse, serverRequest); expect(ads).to.be.an('array').and.to.have.length(1); From 8d0f56b355c41d6239ccc50b4e107f6d7b2ecf8d Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 21:18:36 +0530 Subject: [PATCH 18/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 3091472cb09..7bd42189953 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -492,7 +492,6 @@ describe('Ventes Adapter', function () { const serverResponse = utils.deepClone(examples.serverResponse_banner); serverResponse.body.cur = 'USD'; - const ads = spec.interpretResponse(serverResponse, serverRequest); expect(ads).to.be.an('array').and.to.have.length(1); From c96e025b646a5ae149c06c573e302b6ab257e77e Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 22:12:58 +0530 Subject: [PATCH 19/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 45 +++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index 052535e2213..183845e98aa 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -11,6 +11,7 @@ const FIRST_PRICE = 1; const NET_REVENUE = true; const TTL = 10; const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; +const DEVICE_PARAMS = ['ua','geo', 'dnt','lmt', 'ip','ipv6', 'devicetype']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately const DOMAIN_REGEX = new RegExp('//([^/]*)'); @@ -144,26 +145,26 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext }); } - 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]); - if (!appDeviceObjBid.hasOwnProperty('ua')) { - appDeviceObj.ua = navigator.userAgent; + const deviceObjBid = find(bidRequests, hasDeviceInfo); + let deviceObj; + if (deviceObjBid && deviceObjBid.params && deviceObjBid.params.device) { + deviceObj = {}; + Object.keys(deviceObjBid.params.device) + .filter(param => includes(DEVICE_PARAMS, param)) + .forEach(param => deviceObj[param] = deviceObjBid.params.app[param]); + if (!deviceObjBid.hasOwnProperty('ua')) { + deviceObj.ua = navigator.userAgent; } - if (!appDeviceObjBid.hasOwnProperty('language')) { - appDeviceObj.language = navigator.language.anchor; + if (!deviceObjBid.hasOwnProperty('language')) { + deviceObj.language = navigator.language.anchor; } } - const appIdObjBid = find(bidRequests, hasAppId); + const appIdObjBid = find(bidRequests, hasAppInfo); let appIdObj; if (appIdObjBid && appIdObjBid.params && appDeviceObjBid.params.app && appDeviceObjBid.params.app.id) { - appIdObj = { - appid: appIdObjBid.params.app.id - }; + Object.keys(appDeviceObjBid.params.app) + .filter(param => includes(APP_DEVICE_PARAMS, param)) + .forEach(param => appIdObjBid[param] = appIdObjBid.params.app[param]); } const payload = {} @@ -172,10 +173,10 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext payload.cur = ['USD'] payload.imp = bidRequests.reduce(generateImpressionsFromAdUnit, []) payload.site = generateSiteFromAdUnitContext(bidRequests, adUnitContext) - if (appDeviceObjBid) { - payload.device = appDeviceObj + if (deviceObjBid) { + payload.device = deviceObj } - if (appIdObjBid) { + if (appIdObjBid && payload.site != null) { payload.app = appIdObj; } payload.user = userObj @@ -352,7 +353,13 @@ function getCreativeFromBid(bid) { }; } -function hasAppDeviceInfo(bid) { +function hasDeviceInfo(bid) { + if (bid.params) { + return !!bid.params.device + } +} + +function hasAppInfo(bid) { if (bid.params) { return !!bid.params.app } From 7eb855ff2f4864fae3092467e1e9e8b3a29c5892 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 22:18:20 +0530 Subject: [PATCH 20/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index 183845e98aa..98fcf5f1f51 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -11,7 +11,7 @@ const FIRST_PRICE = 1; const NET_REVENUE = true; const TTL = 10; const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; -const DEVICE_PARAMS = ['ua','geo', 'dnt','lmt', 'ip','ipv6', 'devicetype']; +const DEVICE_PARAMS = ['ua', 'geo', 'dnt', 'lmt', 'ip', 'ipv6', 'devicetype']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately const DOMAIN_REGEX = new RegExp('//([^/]*)'); @@ -159,12 +159,12 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext deviceObj.language = navigator.language.anchor; } } - const appIdObjBid = find(bidRequests, hasAppInfo); + const appDeviceObjBid = find(bidRequests, hasAppInfo); let appIdObj; - if (appIdObjBid && appIdObjBid.params && appDeviceObjBid.params.app && appDeviceObjBid.params.app.id) { + if (appDeviceObjBid && appDeviceObjBid.params && appDeviceObjBid.params.app && appDeviceObjBid.params.app.id) { Object.keys(appDeviceObjBid.params.app) .filter(param => includes(APP_DEVICE_PARAMS, param)) - .forEach(param => appIdObjBid[param] = appIdObjBid.params.app[param]); + .forEach(param => appDeviceObjBid[param] = appDeviceObjBid.params.app[param]); } const payload = {} @@ -176,7 +176,7 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext if (deviceObjBid) { payload.device = deviceObj } - if (appIdObjBid && payload.site != null) { + if (appDeviceObjBid && payload.site != null) { payload.app = appIdObj; } payload.user = userObj @@ -272,13 +272,6 @@ function getImpressionData(serverRequest, impressionId) { }; } -function hasAppId(bid) { - if (bid.params && bid.params.app) { - return !!bid.params.app.id - } - return !!bid.params.app -} - const VAST_REGEXP = /VAST\s+version/; function getMediaType(adm) { From 9477c385e06f63ee3c86c0a6486bb8967388bfcd Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 22:27:51 +0530 Subject: [PATCH 21/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index 98fcf5f1f51..e02291f8277 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -151,7 +151,7 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext deviceObj = {}; Object.keys(deviceObjBid.params.device) .filter(param => includes(DEVICE_PARAMS, param)) - .forEach(param => deviceObj[param] = deviceObjBid.params.app[param]); + .forEach(param => deviceObj[param] = deviceObjBid.params.device[param]); if (!deviceObjBid.hasOwnProperty('ua')) { deviceObj.ua = navigator.userAgent; } From 9f80d601fab1dbacb6bbbc90fde913979b517de8 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 22:44:40 +0530 Subject: [PATCH 22/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 37 ++-------------------- modules/{ventes.md => ventesBidAdapter.md} | 0 test/spec/modules/ventesBidAdapter_spec.js | 1 + 3 files changed, 4 insertions(+), 34 deletions(-) rename modules/{ventes.md => ventesBidAdapter.md} (100%) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index e02291f8277..71cc4fa8639 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -156,7 +156,7 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext deviceObj.ua = navigator.userAgent; } if (!deviceObjBid.hasOwnProperty('language')) { - deviceObj.language = navigator.language.anchor; + deviceObj.language = navigator.language; } } const appDeviceObjBid = find(bidRequests, hasAppInfo); @@ -225,11 +225,11 @@ function validateServerResponse(serverResponse) { function seatBidsToAds(seatBid, bidResponse, serverRequest) { return seatBid.bid - .filter(bid => validateBids(bid, serverRequest)) + .filter(bid => validateBids(bid)) .map(bid => generateAdFromBid(bid, bidResponse)); } -function validateBids(bid, serverRequest) { +function validateBids(bid) { if (!isPlainObject(bid)) return false; if (!isStr(bid.impid)) return false; if (!isStr(bid.crid)) return false; @@ -238,40 +238,9 @@ function validateBids(bid, serverRequest) { if (bid.adm) { if (!isStr(bid.adm)) return false; } - - if (isBidABanner(bid)) { - if (!isNumber(bid.h)) return false; - if (!isNumber(bid.w)) return false; - } - - const impression = getImpressionData(serverRequest, bid.impid); - - if (!isPlainObject(impression.openRTB)) return false; - if (!isPlainObject(impression.internal)) return false; - if (!isStr(impression.internal.adUnitCode)) return false; - - if (isBidABanner(bid)) { - if (!isPlainObject(impression.openRTB.banner)) return false; - } - return true; } -function isBidABanner(bid) { - return isPlainObject(bid) && - isPlainObject(bid.ext) && - bid.ext.venaven.media_type === 'banner'; -} - -function getImpressionData(serverRequest, impressionId) { - const openRTBImpression = find(serverRequest.data.imp, imp => imp.id === impressionId); - - return { - id: impressionId, - openRTB: openRTBImpression || null - }; -} - const VAST_REGEXP = /VAST\s+version/; function getMediaType(adm) { diff --git a/modules/ventes.md b/modules/ventesBidAdapter.md similarity index 100% rename from modules/ventes.md rename to modules/ventesBidAdapter.md diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 7bd42189953..704c94f44ff 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -64,6 +64,7 @@ describe('Ventes Adapter', function () { at: 1 } }, + serverResponse_banner: { body: { cur: 'USD', From 746e38859631c2073ac040d2e6b0a249818eaf7c Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 22:47:02 +0530 Subject: [PATCH 23/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 704c94f44ff..7bd42189953 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -64,7 +64,6 @@ describe('Ventes Adapter', function () { at: 1 } }, - serverResponse_banner: { body: { cur: 'USD', From 81e7c6e874ec09da8b44334e48796b4d621d6897 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 23:05:00 +0530 Subject: [PATCH 24/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 137 --------------------- 1 file changed, 137 deletions(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 7bd42189953..40aca15bd79 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -689,39 +689,6 @@ describe('Ventes Adapter', function () { expect(ads).to.be.an('array').and.to.have.length(0); }); - it('should return no ad when given a server response with a bid with an ad markup without auction price macro', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].adm = 'creative_data'; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - - it('should return no ad when given a server response with a bid with an invalid ad serving URL', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].nurl = {}; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - - it('should return no ad when given a server response with a bid with an ad serving URL without auction price macro', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].nurl = 'win_notice_url'; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - it('should return no ad when given a server response with a bid without bid price', function () { const serverRequest = examples.serverRequest_banner; @@ -744,83 +711,6 @@ describe('Ventes Adapter', function () { expect(ads).to.be.an('array').and.to.have.length(0); }); - it('should return no ad when given a server response with a bid without extension', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].ext = undefined; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - - it('should return no ad when given a server response with a bid with an invalid extension', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].ext = 'bad_ext'; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - - it('should return no ad when given a server response with a bid without adot extension', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].ext.adot = undefined; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - - it('should return no ad when given a server response with a bid with an invalid adot extension', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].ext.adot = 'bad_adot_ext'; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - - it('should return no ad when given a server response with a bid without media type', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = undefined; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - - it('should return no ad when given a server response with a bid with an invalid media type', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = {}; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - - it('should return no ad when given a server response with a bid with an unknown media type', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = 'unknown_media_type'; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); - it('should return no ad when given a valid server response and no server request', function () { const serverRequest = undefined; @@ -884,17 +774,6 @@ describe('Ventes Adapter', function () { expect(ads).to.be.an('array').and.to.have.length(0); }); - - it('should return no ad when given a valid server response and a server request without matching impression', function () { - const serverRequest = utils.deepClone(examples.serverRequest_banner); - serverRequest.data.imp[0].id = 'unknown_imp_id'; - - const serverResponse = examples.serverResponse_banner; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); }); describe('Banner', function () { @@ -904,13 +783,10 @@ describe('Ventes Adapter', function () { const serverResponse = examples.serverResponse_banner; const ads = spec.interpretResponse(serverResponse, serverRequest); - const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price); expect(ads).to.be.an('array').and.to.have.length(1); expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced); expect(ads[0].adUrl).to.equal(null); - expect(ads[0].vastXml).to.equal(null); - expect(ads[0].vastUrl).to.equal(null); expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); @@ -929,11 +805,9 @@ describe('Ventes Adapter', function () { serverResponse.body.seatbid[0].bid[0].adm = undefined; const ads = spec.interpretResponse(serverResponse, serverRequest); - const nurlWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].nurl, serverResponse.body.seatbid[0].bid[0].price); expect(ads).to.be.an('array').and.to.have.length(1); expect(ads[0].ad).to.equal(null); - expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.equal(nurlWithAuctionPriceReplaced); expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); @@ -988,17 +862,6 @@ describe('Ventes Adapter', function () { expect(ads).to.be.an('array').and.to.have.length(0); }); - - it('should return no ad when given a valid server response and a server request without banner impression', function () { - const serverRequest = utils.deepClone(examples.serverRequest_banner); - serverRequest.data.imp[0].banner = undefined; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(0); - }); }); }); }); From a0bf1283e9c145e3ee397a34ca3f9569be39f158 Mon Sep 17 00:00:00 2001 From: Jesso Date: Sat, 2 Oct 2021 23:12:28 +0530 Subject: [PATCH 25/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 40aca15bd79..9b94a4aafcd 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -785,7 +785,6 @@ describe('Ventes Adapter', function () { const ads = spec.interpretResponse(serverResponse, serverRequest); expect(ads).to.be.an('array').and.to.have.length(1); - expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced); expect(ads[0].adUrl).to.equal(null); expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); From 04904e0d10ab75578c257b3209fd0f9f267a0dbd Mon Sep 17 00:00:00 2001 From: Jesso Date: Fri, 8 Oct 2021 08:55:45 +0530 Subject: [PATCH 26/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index 71cc4fa8639..b1ebc20cc4a 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -308,7 +308,6 @@ function getSizeFromBid(bid) { function getCreativeFromBid(bid) { const shouldUseAdMarkup = !!bid.adm; const price = bid.price; - return { markup: shouldUseAdMarkup ? replaceAuctionPrice(bid.adm, price) : null, markupUrl: !shouldUseAdMarkup ? replaceAuctionPrice(bid.nurl, price) : null From 8934dfd90d9051205377996833a230d2a3fdcaa9 Mon Sep 17 00:00:00 2001 From: Jesso Date: Fri, 8 Oct 2021 13:22:06 +0530 Subject: [PATCH 27/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 2 ++ test/spec/modules/ventesBidAdapter_spec.js | 21 --------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index b1ebc20cc4a..3efd38a80cb 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -234,6 +234,8 @@ function validateBids(bid) { if (!isStr(bid.impid)) return false; if (!isStr(bid.crid)) return false; if (!isNumber(bid.price)) return false; + if (!isNumber(bid.w)) return false; + if (!isNumber(bid.h)) return false; if (!bid.adm) return false; if (bid.adm) { if (!isStr(bid.adm)) return false; diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 9b94a4aafcd..20f10dcfafb 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -797,27 +797,6 @@ describe('Ventes Adapter', function () { expect(ads[0].renderer).to.equal(null); }); - it('should return an ad when given a valid server response with one bid using an ad serving URL', function () { - const serverRequest = examples.serverRequest_banner; - - const serverResponse = utils.deepClone(examples.serverResponse_banner); - serverResponse.body.seatbid[0].bid[0].adm = undefined; - - const ads = spec.interpretResponse(serverResponse, serverRequest); - - expect(ads).to.be.an('array').and.to.have.length(1); - expect(ads[0].ad).to.equal(null); - expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); - expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); - expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); - expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); - expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); - expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); - expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); - expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); - expect(ads[0].renderer).to.equal(null); - }); - it('should return no ad when given a server response with a bid without height', function () { const serverRequest = examples.serverRequest_banner; From 132a6f5834c1fb947bbb9770a753096445da3b4e Mon Sep 17 00:00:00 2001 From: Jesso Date: Fri, 8 Oct 2021 15:53:20 +0530 Subject: [PATCH 28/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 20f10dcfafb..d31371e8cc1 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -78,6 +78,8 @@ describe('Ventes Adapter', function () { crid: 'creative_id', adm: '..', price: 1.5, + w: 300, + h: 200 } ] } From 85d9e147a13064532d1e18a46ca8964486a0adc1 Mon Sep 17 00:00:00 2001 From: Jesso Date: Fri, 8 Oct 2021 15:59:06 +0530 Subject: [PATCH 29/36] Ventes Avenues Solved issues --- test/spec/modules/ventesBidAdapter_spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index d31371e8cc1..219c24deced 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -505,7 +505,6 @@ describe('Ventes Adapter', function () { expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); - expect(ads[0].renderer).to.equal(null); }); it('should return no ad when not given a server response', function () { @@ -796,7 +795,6 @@ describe('Ventes Adapter', function () { expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); - expect(ads[0].renderer).to.equal(null); }); it('should return no ad when given a server response with a bid without height', function () { From 3a01f974363ff87a59f92d5f0e07d8c636c9514a Mon Sep 17 00:00:00 2001 From: Jesso Date: Tue, 12 Oct 2021 08:21:20 +0530 Subject: [PATCH 30/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index 3efd38a80cb..ad50d3a4143 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -121,10 +121,7 @@ function createServerRequestFromAdUnits(adUnits, bidRequestId, adUnitContext) { function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext) { const userObjBid = find(bidRequests, hasUserInfo); let userObj = {}; - if (config.getConfig('coppa') === true) { - userObj = { 'coppa': true }; - } - if (userObjBid) { + if (userObjBid) { Object.keys(userObjBid.params.user) .filter(param => includes(USER_PARAMS, param)) .forEach((param) => { From 8115a5054f717a1f6d408490647c66dab691ea5e Mon Sep 17 00:00:00 2001 From: Jesso Date: Tue, 12 Oct 2021 08:24:00 +0530 Subject: [PATCH 31/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index ad50d3a4143..76d689162fe 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -3,7 +3,6 @@ import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {convertCamelToUnderscore, isStr, isArray, isNumber, isPlainObject, replaceAuctionPrice} from '../src/utils.js'; import find from 'core-js-pure/features/array/find.js'; import includes from 'core-js-pure/features/array/includes.js'; -import { config } from '../src/config.js'; const BID_METHOD = 'POST'; const BIDDER_URL = 'http://13.234.201.146:8088/va/ad'; @@ -121,7 +120,7 @@ function createServerRequestFromAdUnits(adUnits, bidRequestId, adUnitContext) { function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext) { const userObjBid = find(bidRequests, hasUserInfo); let userObj = {}; - if (userObjBid) { + if (userObjBid) { Object.keys(userObjBid.params.user) .filter(param => includes(USER_PARAMS, param)) .forEach((param) => { From b214705dfaf7178b19e97a3cc58b7326ffcae64e Mon Sep 17 00:00:00 2001 From: Jesso Date: Wed, 13 Oct 2021 09:02:27 +0530 Subject: [PATCH 32/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index 76d689162fe..c4ec3da2385 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -154,6 +154,14 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext if (!deviceObjBid.hasOwnProperty('language')) { deviceObj.language = navigator.language; } + }else{ + deviceObj = {}; + if (!deviceObjBid.hasOwnProperty('ua')) { + deviceObj.ua = navigator.userAgent; + } + if (!deviceObjBid.hasOwnProperty('language')) { + deviceObj.language = navigator.language; + } } const appDeviceObjBid = find(bidRequests, hasAppInfo); let appIdObj; From 57f9b0d10ba7ced4f7adecaa8c68215199452be4 Mon Sep 17 00:00:00 2001 From: Jesso Date: Wed, 13 Oct 2021 09:11:59 +0530 Subject: [PATCH 33/36] Ventes Avenues Solved issues --- modules/ventesBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index c4ec3da2385..a84d88de261 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -154,7 +154,7 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext if (!deviceObjBid.hasOwnProperty('language')) { deviceObj.language = navigator.language; } - }else{ + } else { deviceObj = {}; if (!deviceObjBid.hasOwnProperty('ua')) { deviceObj.ua = navigator.userAgent; From 874f4d30ed1d2272bf08d0e91396b759056ece3b Mon Sep 17 00:00:00 2001 From: Jesso Date: Tue, 19 Oct 2021 20:45:31 +0530 Subject: [PATCH 34/36] Ventes Avenues Solved issues for user agent --- modules/ventesBidAdapter.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index a84d88de261..c51df82f8c3 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -177,9 +177,7 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext payload.cur = ['USD'] payload.imp = bidRequests.reduce(generateImpressionsFromAdUnit, []) payload.site = generateSiteFromAdUnitContext(bidRequests, adUnitContext) - if (deviceObjBid) { - payload.device = deviceObj - } + payload.device = deviceObj if (appDeviceObjBid && payload.site != null) { payload.app = appIdObj; } From e51f9e3a66c8e80018115f58e1b354c6b182607d Mon Sep 17 00:00:00 2001 From: Jesso Date: Tue, 19 Oct 2021 21:03:14 +0530 Subject: [PATCH 35/36] Added few more info --- modules/ventesBidAdapter.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/ventesBidAdapter.md b/modules/ventesBidAdapter.md index b55daad829a..479f6dd2898 100644 --- a/modules/ventesBidAdapter.md +++ b/modules/ventesBidAdapter.md @@ -11,7 +11,6 @@ coppa_supported: false schain_supported: false dchain_supported: false prebid_member: false - --- ### BidParams @@ -21,7 +20,8 @@ prebid_member: false | `placementId` | required | Placement ID from Ventes Avenues | `'VA-062-0013-0183'` | `string` | | `publisherId` | required | Publisher ID from Ventes Avenues | `'VA-062'` | `string` | | `user` | optional | Object that specifies information about an external user. | `user: { age: 25, gender: 0, dnt: true}` | `object` | -| `app` | optional | Object containing mobile app parameters. | `app : { id: 'app-id'}` | `object` | +| `app` | required | Object containing mobile app parameters. | `app : { id: 'app-id'}` | `object` | +| `device` | required | Object containing device info mandatory for mobile devices| `device : { ifa: 'device-id'}` | `object` | #### User Object @@ -36,7 +36,7 @@ prebid_member: false | `language` | Two-letter ANSI code for this user's language. | `EN` | `string` | -### Ad Unit Setup for Banner +### Ad Unit Setup for Banner through mobile devices ```javascript var adUnits = [ { @@ -70,3 +70,25 @@ var adUnits = [ } ] ``` + +### Ad Unit Setup for Banner through Websites +```javascript +var adUnits = [ +{ + code: 'test-hb-ad-11111-1', + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + bids: [{ + bidder: 'ventes', + params: { + placementId: 'VA-002-0007-0799', + publisherId: '5cebea3c9eea646c7b623d5e', + } + }] + } +] From ea8c356c563426436534626ac41b64eaa0fd6aad Mon Sep 17 00:00:00 2001 From: Jesso Date: Wed, 20 Oct 2021 22:54:14 +0530 Subject: [PATCH 36/36] Ventes Avenues Solved issues for user agent --- modules/ventesBidAdapter.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/ventesBidAdapter.js b/modules/ventesBidAdapter.js index c51df82f8c3..7a2b60d2ee2 100644 --- a/modules/ventesBidAdapter.js +++ b/modules/ventesBidAdapter.js @@ -156,12 +156,8 @@ function generateBidRequestsFromAdUnits(bidRequests, bidRequestId, adUnitContext } } else { deviceObj = {}; - if (!deviceObjBid.hasOwnProperty('ua')) { - deviceObj.ua = navigator.userAgent; - } - if (!deviceObjBid.hasOwnProperty('language')) { - deviceObj.language = navigator.language; - } + deviceObj.ua = navigator.userAgent; + deviceObj.language = navigator.language; } const appDeviceObjBid = find(bidRequests, hasAppInfo); let appIdObj;