Skip to content

Commit

Permalink
NoBid Bid Adapter: add support for config.ortb2 (#7503)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
redaguermas and Reda Guermas authored Oct 6, 2021
1 parent 22ca1d8 commit 1acfbe3
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
3 changes: 2 additions & 1 deletion modules/nobidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
66 changes: 65 additions & 1 deletion test/spec/modules/nobidBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 1acfbe3

Please sign in to comment.