From 75602dcab220730576317919b49ff06b95864e99 Mon Sep 17 00:00:00 2001 From: Denis Logachov Date: Thu, 18 Apr 2024 17:25:40 +0300 Subject: [PATCH 1/4] Adkernel Bid Adapter: bid.mtype support (#11355) --- modules/adkernelBidAdapter.js | 12 +++++++++--- test/spec/modules/adkernelBidAdapter_spec.js | 13 +++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/adkernelBidAdapter.js b/modules/adkernelBidAdapter.js index ae02a8967b1..0c353e4332a 100644 --- a/modules/adkernelBidAdapter.js +++ b/modules/adkernelBidAdapter.js @@ -51,6 +51,12 @@ const MULTI_FORMAT_SUFFIX_BANNER = 'b' + MULTI_FORMAT_SUFFIX; const MULTI_FORMAT_SUFFIX_VIDEO = 'v' + MULTI_FORMAT_SUFFIX; const MULTI_FORMAT_SUFFIX_NATIVE = 'n' + MULTI_FORMAT_SUFFIX; +const MEDIA_TYPES = { + BANNER: 1, + VIDEO: 2, + NATIVE: 4 +}; + /** * Adapter for requesting bids from AdKernel white-label display platform */ @@ -159,17 +165,17 @@ export const spec = { if (prBid.requestId.endsWith(MULTI_FORMAT_SUFFIX)) { prBid.requestId = stripMultiformatSuffix(prBid.requestId); } - if ('banner' in imp) { + if (rtbBid.mtype === MEDIA_TYPES.BANNER) { prBid.mediaType = BANNER; prBid.width = rtbBid.w; prBid.height = rtbBid.h; prBid.ad = formatAdMarkup(rtbBid); - } else if ('video' in imp) { + } else if (rtbBid.mtype === MEDIA_TYPES.VIDEO) { prBid.mediaType = VIDEO; prBid.vastUrl = rtbBid.nurl; prBid.width = imp.video.w; prBid.height = imp.video.h; - } else if ('native' in imp) { + } else if (rtbBid.mtype === MEDIA_TYPES.NATIVE) { prBid.mediaType = NATIVE; prBid.native = { ortb: buildNativeAd(rtbBid.adm) diff --git a/test/spec/modules/adkernelBidAdapter_spec.js b/test/spec/modules/adkernelBidAdapter_spec.js index cdfc9795b85..ceb5d029203 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -218,7 +218,8 @@ describe('Adkernel adapter', function () { adm: '', w: 300, h: 250, - dealid: 'deal' + dealid: 'deal', + mtype: 1 }] }], ext: { @@ -234,7 +235,8 @@ describe('Adkernel adapter', function () { price: 0.00145, adid: '158801', nurl: 'https://rtb.com/win?i=sZSYq5zYMxo_0&f=nurl', - cid: '16855' + cid: '16855', + mtype: 2 }] }], }, usersyncOnlyResponse = { @@ -269,6 +271,7 @@ describe('Adkernel adapter', function () { cat: ['IAB1-4', 'IAB8-16', 'IAB25-5'], cid: '1', crid: '4', + mtype: 4, ext: { 'advertiser_id': 777, 'advertiser_name': 'advertiser', @@ -290,7 +293,8 @@ describe('Adkernel adapter', function () { adid: '158801', adm: '', nurl: 'https://rtb.com/win?i=sZSYq5zYMxo_0&f=nurl', - cid: '16855' + cid: '16855', + mtype: 1 }, { id: 'sZSYq5zYMxo_1', impid: 'Bid_01v__mf', @@ -298,7 +302,8 @@ describe('Adkernel adapter', function () { price: 0.25, adid: '158801', nurl: 'https://rtb.com/win?i=sZSYq5zYMxo_1&f=nurl', - cid: '16855' + cid: '16855', + mtype: 2 }] }], bidid: 'pTuOlf5KHUo', From 08ac74f3ca062fb3a34c42e073d39dadfff94d46 Mon Sep 17 00:00:00 2001 From: Kevin Siow Date: Thu, 18 Apr 2024 18:13:10 +0200 Subject: [PATCH 2/4] Dailymotion Bid Adaptor: initial release (#10970) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Dailymotion Bid Adaptor: initial release * .md file lint issue resolved * Dailymotion Bid Adaptor: build bidder request based on param with fallbacks * Dailymotion Bid Adaptor: support video metadata * Dailymotion Bid Adaptor: add support for sending adUnitCode * Dailymotion Bid Adaptor: add support for sending startDelay * feat(LEO-528): Allow multiple IAB categories in video metadata The same way as we can have an array of IAB categories level 1 in the ORTB request, this PR introduces an array for the IAB categories level 2. To be forward compatible with level [2.2](https://github.com/InteractiveAdvertisingBureau/Taxonomies/blob/main/Content%20Taxonomies/Content%20Taxonomy%202.2.tsv) and [3.0](https://github.com/InteractiveAdvertisingBureau/Taxonomies/blob/main/Content%20Taxonomies/Content%20Taxonomy%203.0.tsv) specifications, the category IDs should be sent as strings. * Dailymotion bid adapter: Clarify the video metadata to provide in each player context * Dailymotion bid adapter: Move API key to bid params * Dailymotion bid adapter: Verify API key is string Co-authored-by: Rumesh * Dailymotion bid adapter: Move API key to bid params (fix tests) * Dailymotion Bid Adaptor: add gpp support and get coppa from request * Dailymotion Bid Adaptor: fix lint error * Dailymotion Bid Adaptor: add iabcat1 and fallback to ortb2 for iabcat2 * Dailymotion Bid Adaptor: get iabcats from ortb2.site.content.data --------- Co-authored-by: Kevin Siow Co-authored-by: Aditi Chaudhary Co-authored-by: Sébastien Millet Co-authored-by: Rumesh --- modules/dailymotionBidAdapter.js | 139 +++++++ modules/dailymotionBidAdapter.md | 140 +++++++ .../modules/dailymotionBidAdapter_spec.js | 369 ++++++++++++++++++ 3 files changed, 648 insertions(+) create mode 100644 modules/dailymotionBidAdapter.js create mode 100644 modules/dailymotionBidAdapter.md create mode 100644 test/spec/modules/dailymotionBidAdapter_spec.js diff --git a/modules/dailymotionBidAdapter.js b/modules/dailymotionBidAdapter.js new file mode 100644 index 00000000000..2be5edad78e --- /dev/null +++ b/modules/dailymotionBidAdapter.js @@ -0,0 +1,139 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { VIDEO } from '../src/mediaTypes.js'; +import { deepAccess } from '../src/utils.js'; + +/** + * Get video metadata from bid request + * + * @param {BidRequest} bidRequest A valid bid requests that should be sent to the Server. + * @return video metadata + */ +function getVideoMetadata(bidRequest, bidderRequest) { + const videoAdUnit = deepAccess(bidRequest, 'mediaTypes.video', {}); + const videoBidderParams = deepAccess(bidRequest, 'params.video', {}); + + const videoParams = { + ...videoAdUnit, + ...videoBidderParams, // Bidder Specific overrides + }; + + // Store as object keys to ensure uniqueness + const iabcat1 = {}; + const iabcat2 = {}; + + deepAccess(bidderRequest, 'ortb2.site.content.data', []).forEach((data) => { + if ([4, 5, 6, 7].includes(data?.ext?.segtax)) { + (Array.isArray(data.segment) ? data.segment : []).forEach((segment) => { + if (typeof segment.id === 'string') { + // See https://docs.prebid.org/features/firstPartyData.html#segments-and-taxonomy + // Only take IAB cats of taxonomy V1 + if (data.ext.segtax === 4) iabcat1[segment.id] = 1; + // Only take IAB cats of taxonomy V2 or higher + if ([5, 6, 7].includes(data.ext.segtax)) iabcat2[segment.id] = 1; + } + }); + } + }); + + const videoMetadata = { + description: videoParams.description || '', + duration: videoParams.duration || 0, + iabcat1: Object.keys(iabcat1), + iabcat2: Array.isArray(videoParams.iabcat2) + ? videoParams.iabcat2 + : Object.keys(iabcat2), + id: videoParams.id || '', + lang: videoParams.lang || '', + private: videoParams.private || false, + tags: videoParams.tags || '', + title: videoParams.title || '', + topics: videoParams.topics || '', + xid: videoParams.xid || '', + }; + + return videoMetadata; +} + +export const spec = { + code: 'dailymotion', + gvlid: 573, + supportedMediaTypes: [VIDEO], + + /** + * Determines whether or not the given bid request is valid. + * The only mandatory parameter for a bid to be valid is the API key. + * Other parameters are optional. + * + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return typeof bid?.params?.apiKey === 'string' && bid.params.apiKey.length > 10; + }, + + /** + * Make a server request from the list of valid BidRequests (that already passed the isBidRequestValid call) + * + * @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server. + * @param {BidderRequest} bidderRequest + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: (validBidRequests = [], bidderRequest) => validBidRequests.map(bid => ({ + method: 'POST', + url: 'https://pb.dmxleo.com', + data: { + bidder_request: { + gdprConsent: { + apiVersion: bidderRequest?.gdprConsent?.apiVersion || 1, + consentString: bidderRequest?.gdprConsent?.consentString || '', + // Cast boolean in any case (eg: if value is int) to ensure type + gdprApplies: !!bidderRequest?.gdprConsent?.gdprApplies, + }, + refererInfo: { + page: bidderRequest?.refererInfo?.page || '', + }, + uspConsent: bidderRequest?.uspConsent || '', + gppConsent: { + gppString: deepAccess(bidderRequest, 'gppConsent.gppString') || + deepAccess(bidderRequest, 'ortb2.regs.gpp', ''), + applicableSections: deepAccess(bidderRequest, 'gppConsent.applicableSections') || + deepAccess(bidderRequest, 'ortb2.regs.gpp_sid', []), + }, + }, + config: { + api_key: bid.params.apiKey + }, + // Cast boolean in any case (value should be 0 or 1) to ensure type + coppa: !!deepAccess(bidderRequest, 'ortb2.regs.coppa'), + request: { + adUnitCode: bid.adUnitCode || '', + auctionId: bid.auctionId || '', + bidId: bid.bidId || '', + mediaTypes: { + video: { + playerSize: bid.mediaTypes?.[VIDEO]?.playerSize || [], + api: bid.mediaTypes?.[VIDEO]?.api || [], + startDelay: bid.mediaTypes?.[VIDEO]?.startdelay || 0, + }, + }, + sizes: bid.sizes || [], + }, + video_metadata: getVideoMetadata(bid, bidderRequest), + }, + options: { + withCredentials: true, + crossOrigin: true, + }, + })), + + /** + * Map the response from the server into a list of bids. + * As dailymotion prebid server returns an entry with the correct Prebid structure, + * we directly include it as the only bid in the response. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: serverResponse => serverResponse?.body ? [serverResponse.body] : [], +}; + +registerBidder(spec); diff --git a/modules/dailymotionBidAdapter.md b/modules/dailymotionBidAdapter.md new file mode 100644 index 00000000000..795273c9229 --- /dev/null +++ b/modules/dailymotionBidAdapter.md @@ -0,0 +1,140 @@ +# Overview + +``` +Module Name: Dailymotion Bid Adapter +Module Type: Bidder Adapter +Maintainer: ad-leo-engineering@dailymotion.com +``` + +# Description + +Dailymotion prebid adapter. + +# Configuration options + +Before calling this adapter, you need to set at least the API key in the bid parameters: + +```javascript +const adUnits = [ + { + bids: [{ + bidder: 'dailymotion', + params: { + apiKey: 'fake_api_key' + } + }] + } +]; +``` + +`apiKey` is your publisher API key. For testing purpose, you can use "dailymotion-testing". + +# Test Parameters + +By setting the following bid parameters, you'll get a constant response to any request, to validate your adapter integration: + +```javascript +const adUnits = [ + { + bids: [{ + bidder: 'dailymotion', + params: { + apiKey: 'dailymotion-testing' + } + }] + } +]; +``` + +Please note that failing to set these will result in the adapter not bidding at all. + +# Sample video AdUnit + +To allow better targeting, you should provide as much context about the video as possible. +There are two ways of doing this depending on if you're using Dailymotion player or a third party one. + +If you are using the Dailymotion player, you should only provide the video `xid` in your ad unit, example: + +```javascript +const adUnits = [ + { + bids: [{ + bidder: 'dailymotion', + params: { + apiKey: 'dailymotion-testing' + } + }], + code: 'test-ad-unit', + mediaTypes: { + video: { + api: [2, 7], + context: 'instream', + playerSize: [ [1280, 720] ], + startDelay: 0, + xid: 'x123456' // Dailymotion infrastructure unique video ID + }, + } + } +]; +``` + +This will automatically fetch the most up-to-date information about the video. +If you provide any other metadata in addition to the `xid`, they will be ignored. + +If you are using a third party video player, you should not provide any `xid` and instead fill the following members: + +```javascript +const adUnits = [ + { + bids: [{ + bidder: 'dailymotion', + params: { + apiKey: 'dailymotion-testing', + video: { + description: 'overriden video description' + } + } + }], + code: 'test-ad-unit', + mediaTypes: { + video: { + api: [2, 7], + context: 'instream', + description: 'this is a video description', + duration: 556, + iabcat2: ['6', '17'], + id: '54321', + lang: 'FR', + playerSize: [ [1280, 720] ], + private: false, + startDelay: 0, + tags: 'tag_1,tag_2,tag_3', + title: 'test video', + topics: 'topic_1, topic_2', + }, + } + } +]; +``` + +Each of the following video metadata fields can be added in mediaTypes.video or bids.params.video. +If a field exists in both places, it will be overridden by bids.params.video. + +* `description` - Video description +* `duration` - Video duration in seconds +* `iabcat2` - List of IAB category IDs from the [2.0 taxonomy](https://github.com/InteractiveAdvertisingBureau/Taxonomies/blob/main/Content%20Taxonomies/Content%20Taxonomy%202.0.tsv) +* `id` - Video unique ID in host video infrastructure +* `lang` - ISO 639-1 code for main language used in the video +* `private` - True if video is not publicly available +* `tags` - Tags for the video, comma separated +* `title` - Video title +* `topics` - Main topics for the video, comma separated +* `xid` - Dailymotion video identifier (only applicable if using the Dailymotion player) + +# Integrating the adapter + +To use the adapter with any non-test request, you first need to ask an API key from Dailymotion. Please contact us through **DailymotionPrebid.js@dailymotion.com**. + +You will then be able to use it within the bid parameters before making a bid request. + +This API key will ensure proper identification of your inventory and allow you to get real bids. diff --git a/test/spec/modules/dailymotionBidAdapter_spec.js b/test/spec/modules/dailymotionBidAdapter_spec.js new file mode 100644 index 00000000000..a102c26dca2 --- /dev/null +++ b/test/spec/modules/dailymotionBidAdapter_spec.js @@ -0,0 +1,369 @@ +import { config } from 'src/config.js'; +import { expect } from 'chai'; +import { spec } from 'modules/dailymotionBidAdapter.js'; +import { VIDEO } from '../../../src/mediaTypes'; + +describe('dailymotionBidAdapterTests', () => { + // Validate that isBidRequestValid only validates requests with apiKey + it('validates isBidRequestValid', () => { + expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid())).to.be.false; + + const bidWithEmptyApi = { + params: { + apiKey: '', + }, + }; + + expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid(bidWithEmptyApi))).to.be.false; + + const bidWithApi = { + params: { + apiKey: 'test_api_key', + }, + }; + + expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid(bidWithApi))).to.be.true; + }); + + // Validate request generation + it('validates buildRequests', () => { + const bidRequestData = [{ + auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + bidId: 123456, + adUnitCode: 'preroll', + mediaTypes: { + video: { + playerSize: [[1280, 720]], + api: [2, 7], + description: 'this is a test video', + duration: 300, + iabcat2: ['6', '17'], + lang: 'ENG', + startdelay: 0, + }, + }, + sizes: [[1920, 1080]], + params: { + apiKey: 'test_api_key', + video: { + duration: 556, + id: '54321', + lang: 'FR', + private: false, + tags: 'tag_1,tag_2,tag_3', + title: 'test video', + topics: 'topic_1, topic_2', + xid: 'x123456', + }, + }, + }]; + + const bidderRequestData = { + refererInfo: { + page: 'https://publisher.com', + }, + uspConsent: '1YN-', + gdprConsent: { + apiVersion: 2, + consentString: 'xxx', + gdprApplies: true, + }, + gppConsent: { + gppString: 'xxx', + applicableSections: [5], + }, + ortb2: { + regs: { + coppa: 1, + }, + site: { + content: { + data: [ + { + name: 'dataprovider.com', + ext: { segtax: 4 }, + segment: [{ id: 'IAB-1' }], + }, + { + name: 'dataprovider.com', + ext: { segtax: 5 }, + segment: [{ id: '200' }], + }, + ], + }, + }, + }, + }; + + const [request] = config.runWithBidder( + 'dailymotion', + () => spec.buildRequests(bidRequestData, bidderRequestData), + ); + + const { data: reqData } = request; + + expect(request.url).to.equal('https://pb.dmxleo.com'); + + expect(reqData.bidder_request).to.eql({ + refererInfo: bidderRequestData.refererInfo, + uspConsent: bidderRequestData.uspConsent, + gdprConsent: bidderRequestData.gdprConsent, + gppConsent: bidderRequestData.gppConsent, + }); + expect(reqData.config.api_key).to.eql(bidRequestData[0].params.apiKey); + expect(reqData.coppa).to.be.true; + expect(reqData.request.auctionId).to.eql(bidRequestData[0].auctionId); + expect(reqData.request.bidId).to.eql(bidRequestData[0].bidId); + expect(reqData.request.mediaTypes.video.api).to.eql(bidRequestData[0].mediaTypes.video.api); + expect(reqData.request.mediaTypes.video.playerSize).to.eql(bidRequestData[0].mediaTypes.video.playerSize); + expect(reqData.request.mediaTypes.video.startDelay).to.eql(bidRequestData[0].mediaTypes.video.startdelay); + expect(reqData.video_metadata).to.eql({ + description: bidRequestData[0].mediaTypes.video.description, + iabcat1: ['IAB-1'], // Taxonomy v2 or higher is excluded + iabcat2: bidRequestData[0].mediaTypes.video.iabcat2, + id: bidRequestData[0].params.video.id, + lang: bidRequestData[0].params.video.lang, + private: bidRequestData[0].params.video.private, + tags: bidRequestData[0].params.video.tags, + title: bidRequestData[0].params.video.title, + topics: bidRequestData[0].params.video.topics, + xid: bidRequestData[0].params.video.xid, + // Overriden through bidder params + duration: bidRequestData[0].params.video.duration, + }); + }); + + it('validates buildRequests with fallback values on ortb2 for gpp & iabcat', () => { + const bidRequestData = [{ + auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + bidId: 123456, + adUnitCode: 'preroll', + mediaTypes: { + video: { + playerSize: [[1280, 720]], + api: [2, 7], + description: 'this is a test video', + duration: 300, + lang: 'ENG', + startdelay: 0, + }, + }, + sizes: [[1920, 1080]], + params: { + apiKey: 'test_api_key', + video: { + duration: 556, + id: '54321', + lang: 'FR', + private: false, + tags: 'tag_1,tag_2,tag_3', + title: 'test video', + topics: 'topic_1, topic_2', + xid: 'x123456', + }, + }, + }]; + + const bidderRequestData = { + refererInfo: { + page: 'https://publisher.com', + }, + uspConsent: '1YN-', + gdprConsent: { + apiVersion: 2, + consentString: 'xxx', + gdprApplies: true, + }, + ortb2: { + regs: { + gpp: 'xxx', + gpp_sid: [5], + coppa: 0, + }, + site: { + content: { + data: [ + undefined, // Undefined to check proper handling of edge cases + {}, // Empty object to check proper handling of edge cases + { ext: {} }, // Empty ext to check proper handling of edge cases + { + name: 'dataprovider.com', + ext: { segtax: 22 }, // Invalid segtax to check proper handling of edge cases + segment: [{ id: '400' }], + }, + { + name: 'dataprovider.com', + ext: { segtax: 5 }, + segment: undefined, // Invalid segment to check proper handling of edge cases + }, + { + name: 'dataprovider.com', + ext: { segtax: 4 }, + segment: undefined, // Invalid segment to check proper handling of edge cases + }, + { + name: 'dataprovider.com', + ext: { segtax: 4 }, + segment: [{ id: 2222 }], // Invalid segment id to check proper handling of edge cases + }, + { + name: 'dataprovider.com', + ext: { segtax: 5 }, + segment: [{ id: '6' }], + }, + { + name: 'dataprovider.com', + ext: { segtax: 5 }, + segment: [{ id: '6' }], // Check that same cat won't be duplicated + }, + { + name: 'dataprovider.com', + ext: { segtax: 5 }, + segment: [{ id: '17' }, { id: '20' }], + }, + ], + }, + }, + }, + }; + + const [request] = config.runWithBidder( + 'dailymotion', + () => spec.buildRequests(bidRequestData, bidderRequestData), + ); + + const { data: reqData } = request; + + expect(request.url).to.equal('https://pb.dmxleo.com'); + + expect(reqData.bidder_request).to.eql({ + refererInfo: bidderRequestData.refererInfo, + uspConsent: bidderRequestData.uspConsent, + gdprConsent: bidderRequestData.gdprConsent, + gppConsent: { + gppString: bidderRequestData.ortb2.regs.gpp, + applicableSections: bidderRequestData.ortb2.regs.gpp_sid, + }, + }); + expect(reqData.config.api_key).to.eql(bidRequestData[0].params.apiKey); + expect(reqData.coppa).to.be.false; + expect(reqData.request.auctionId).to.eql(bidRequestData[0].auctionId); + expect(reqData.request.bidId).to.eql(bidRequestData[0].bidId); + expect(reqData.request.mediaTypes.video.api).to.eql(bidRequestData[0].mediaTypes.video.api); + expect(reqData.request.mediaTypes.video.playerSize).to.eql(bidRequestData[0].mediaTypes.video.playerSize); + expect(reqData.request.mediaTypes.video.startDelay).to.eql(bidRequestData[0].mediaTypes.video.startdelay); + expect(reqData.video_metadata).to.eql({ + description: bidRequestData[0].mediaTypes.video.description, + // No iabcat1 here because nothing matches taxonomy + iabcat1: [], + iabcat2: ['6', '17', '20'], + id: bidRequestData[0].params.video.id, + lang: bidRequestData[0].params.video.lang, + private: bidRequestData[0].params.video.private, + tags: bidRequestData[0].params.video.tags, + title: bidRequestData[0].params.video.title, + topics: bidRequestData[0].params.video.topics, + xid: bidRequestData[0].params.video.xid, + // Overriden through bidder params + duration: bidRequestData[0].params.video.duration, + }); + }); + + it('validates buildRequests - with default values on empty bid & bidder request', () => { + const bidRequestDataWithApi = [{ + params: { + apiKey: 'test_api_key', + }, + }]; + + const [request] = config.runWithBidder( + 'dailymotion', + () => spec.buildRequests(bidRequestDataWithApi, {}), + ); + + const { data: reqData } = request; + + expect(request.url).to.equal('https://pb.dmxleo.com'); + + expect(reqData.config.api_key).to.eql(bidRequestDataWithApi[0].params.apiKey); + expect(reqData.coppa).to.be.false; + + expect(reqData.bidder_request).to.eql({ + gdprConsent: { + apiVersion: 1, + consentString: '', + gdprApplies: false, + }, + refererInfo: { + page: '', + }, + uspConsent: '', + gppConsent: { + gppString: '', + applicableSections: [], + }, + }); + + expect(reqData.request).to.eql({ + auctionId: '', + bidId: '', + adUnitCode: '', + mediaTypes: { + video: { + playerSize: [], + startDelay: 0, + api: [], + }, + }, + sizes: [], + }); + + expect(reqData.video_metadata).to.eql({ + description: '', + duration: 0, + iabcat1: [], + iabcat2: [], + id: '', + lang: '', + private: false, + tags: '', + title: '', + topics: '', + xid: '', + }); + }); + + it('validates buildRequests - with empty/undefined validBidRequests', () => { + expect(spec.buildRequests([], {})).to.have.lengthOf(0); + + expect(spec.buildRequests(undefined, {})).to.have.lengthOf(0); + }); + + it('validates interpretResponse', () => { + const serverResponse = { + body: { + ad: 'https://fakecacheserver/cache?uuid=1234', + cacheId: '1234', + cpm: 20.0, + creativeId: '5678', + currency: 'USD', + dealId: 'deal123', + nurl: 'https://bid/nurl', + requestId: 'test_requestid', + vastUrl: 'https://fakecacheserver/cache?uuid=1234', + }, + }; + + const bids = spec.interpretResponse(serverResponse); + expect(bids).to.have.lengthOf(1); + + const [bid] = bids; + expect(bid).to.eql(serverResponse.body); + }); + + it('validates interpretResponse - with empty/undefined serverResponse', () => { + expect(spec.interpretResponse({})).to.have.lengthOf(0); + + expect(spec.interpretResponse(undefined)).to.have.lengthOf(0); + }); +}); From ed7e942c3c074be9febb16a62e59663a1c017862 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Thu, 18 Apr 2024 09:14:54 -0700 Subject: [PATCH 3/4] Core: update creative code and example (#11350) --- integrationExamples/gpt/x-domain/creative.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrationExamples/gpt/x-domain/creative.html b/integrationExamples/gpt/x-domain/creative.html index bf2bd5f3fad..0d0f63cbf1b 100644 --- a/integrationExamples/gpt/x-domain/creative.html +++ b/integrationExamples/gpt/x-domain/creative.html @@ -2,7 +2,7 @@ // creative will be rendered, e.g. GAM delivering a SafeFrame // this code is autogenerated, also available in 'build/creative/creative.js' - +