From 1acfbe3ebfc83a4154e9240277d1b5bc7c589a71 Mon Sep 17 00:00:00 2001 From: redaguermas Date: Wed, 6 Oct 2021 05:14:12 -0700 Subject: [PATCH] NoBid Bid Adapter: add support for config.ortb2 (#7503) * Enable supplyChain support * Added support for COPPA * rebuilt * Added support for Extended User IDs. * Added support for the "meta" attribute in bid response. * Added support for config.ortb2. * Delete nobidBidAdapter.js.orig * Delete .project * Delete .jsdtscope * Delete org.eclipse.wst.jsdt.ui.superType.container * Delete org.eclipse.wst.jsdt.ui.superType.name * Delete a * Tests for "ortb2" support. Co-authored-by: Reda Guermas --- modules/nobidBidAdapter.js | 3 +- test/spec/modules/nobidBidAdapter_spec.js | 66 ++++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/modules/nobidBidAdapter.js b/modules/nobidBidAdapter.js index 5c017852d3e..d10c1d0e430 100644 --- a/modules/nobidBidAdapter.js +++ b/modules/nobidBidAdapter.js @@ -7,7 +7,7 @@ import { getStorageManager } from '../src/storageManager.js'; const GVLID = 816; const BIDDER_CODE = 'nobid'; const storage = getStorageManager(GVLID, BIDDER_CODE); -window.nobidVersion = '1.3.1'; +window.nobidVersion = '1.3.2'; window.nobid = window.nobid || {}; window.nobid.bidResponses = window.nobid.bidResponses || {}; window.nobid.timeoutTotal = 0; @@ -152,6 +152,7 @@ function nobidBuildRequests(bids, bidderRequest) { if (cop) state['coppa'] = cop; const eids = getEIDs(deepAccess(bids, '0.userIdAsEids')); if (eids && eids.length > 0) state['eids'] = eids; + if (config && config.getConfig('ortb2')) state['ortb2'] = config.getConfig('ortb2'); return state; } function newAdunit(adunitObject, adunits) { diff --git a/test/spec/modules/nobidBidAdapter_spec.js b/test/spec/modules/nobidBidAdapter_spec.js index f775e439a80..eccf0e84031 100644 --- a/test/spec/modules/nobidBidAdapter_spec.js +++ b/test/spec/modules/nobidBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import * as utils from 'src/utils.js'; import { spec } from 'modules/nobidBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; import * as bidderFactory from 'src/adapters/bidderFactory.js'; describe('Nobid Adapter', function () { @@ -50,6 +51,70 @@ describe('Nobid Adapter', function () { }); }); + describe('Request with ORTB2', function () { + const SITE_ID = 2; + const REFERER = 'https://www.examplereferer.com'; + const BIDDER_CODE = 'duration'; + let bidRequests = [ + { + 'bidder': BIDDER_CODE, + 'params': { + 'siteId': SITE_ID + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + let bidderRequest = { + refererInfo: {referer: REFERER}, bidderCode: BIDDER_CODE + } + + const siteName = 'example'; + const siteDomain = 'page.example.com'; + const sitePage = 'https://page.example.com/here.html'; + const siteRef = 'https://ref.example.com'; + const siteKeywords = 'power tools, drills'; + const siteSearch = 'drill'; + const siteCat = 'IAB2'; + const siteSectionCat = 'IAB2-2'; + const sitePageCat = 'IAB2-12'; + + it('ortb2 should exist', function () { + config.setConfig({ + ortb2: { + site: { + name: siteName, + domain: siteDomain, + cat: [ siteCat ], + sectioncat: [ siteSectionCat ], + pagecat: [ sitePageCat ], + page: sitePage, + ref: siteRef, + keywords: siteKeywords, + search: siteSearch + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + let payload = JSON.parse(request.data); + payload = JSON.parse(JSON.stringify(payload)); + expect(payload.sid).to.equal(SITE_ID); + expect(payload.ortb2.site.name).to.equal(siteName); + expect(payload.ortb2.site.domain).to.equal(siteDomain); + expect(payload.ortb2.site.page).to.equal(sitePage); + expect(payload.ortb2.site.ref).to.equal(siteRef); + expect(payload.ortb2.site.keywords).to.equal(siteKeywords); + expect(payload.ortb2.site.search).to.equal(siteSearch); + expect(payload.ortb2.site.cat[0]).to.equal(siteCat); + expect(payload.ortb2.site.sectioncat[0]).to.equal(siteSectionCat); + expect(payload.ortb2.site.pagecat[0]).to.equal(sitePageCat); + }); + }); + describe('isDurationBidRequestValid', function () { const SITE_ID = 2; const REFERER = 'https://www.examplereferer.com'; @@ -255,7 +320,6 @@ describe('Nobid Adapter', function () { expect(payload.a).to.exist; expect(payload.t).to.exist; expect(payload.tz).to.exist; - expect(payload.r).to.exist.and.to.equal('100x100'); expect(payload.lang).to.exist; expect(payload.ref).to.exist; expect(payload.a[0].d).to.exist.and.to.equal('adunit-code');