From afdf755a2674611939c6f33d299b7007ba73b97d Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Wed, 9 Jan 2019 15:28:39 +0100 Subject: [PATCH 01/15] initial orbidder version in personal github repo --- modules/orbidderBidAdapter.js | 73 ++++++++ modules/orbidderBidAdapter.md | 40 ++++ test/spec/modules/orbidderBidAdapter_spec.js | 184 +++++++++++++++++++ 3 files changed, 297 insertions(+) create mode 100644 modules/orbidderBidAdapter.js create mode 100644 modules/orbidderBidAdapter.md create mode 100644 test/spec/modules/orbidderBidAdapter_spec.js diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js new file mode 100644 index 00000000000..1c070cb5811 --- /dev/null +++ b/modules/orbidderBidAdapter.js @@ -0,0 +1,73 @@ +import * as utils from 'src/utils'; +import {ajax} from 'src/ajax'; +import {registerBidder} from 'src/adapters/bidderFactory'; + +export const spec = { + code: 'orbidder', + orbidderHost: (() => { + let ret = 'https://orbidder.otto.de'; + try { + ret = localStorage.getItem('ov_orbidder_host') || ret; + } catch (e) { + } + return ret; + })(), + + isBidRequestValid(bid) { + return !!(bid.sizes && bid.bidId); + }, + + buildRequests(validBidRequests) { + return validBidRequests.map((bidRequest) => { + const ret = { + url: `${this.orbidderHost}/bid`, + method: 'POST', + data: { + pageUrl: utils.getTopWindowUrl(), + referrer: utils.getTopWindowReferrer(), + bidId: bidRequest.bidId, + auctionId: bidRequest.auctionId, + transactionId: bidRequest.transactionId, + adUnitCode: bidRequest.adUnitCode, + sizes: bidRequest.sizes, + params: bidRequest.params + } + }; + if (bidRequest && bidRequest.gdprConsent) { + ret.data.gdprConsent = { + consentString: bidRequest.gdprConsent.consentString, + consentRequired: (typeof bidRequest.gdprConsent.gdprApplies === 'boolean') + ? bidRequest.gdprConsent.gdprApplies + : true + }; + } + return ret; + }); + }, + + interpretResponse(serverResponse) { + const bidResponses = []; + serverResponse = serverResponse.body; + if (serverResponse && (serverResponse.length > 0)) { + for (const bid of serverResponse) { + const bidResponse = {}; + for (const requiredKey of ['requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency']) { + if (!bid.hasOwnProperty(requiredKey)) { + return []; + } + bidResponse[requiredKey] = bid[requiredKey]; + } + bidResponses.push(bidResponse); + } + } + return bidResponses; + }, + + onBidWon(winObj) { + winObj.pageUrl = utils.getTopWindowUrl(); + winObj.referrer = utils.getTopWindowReferrer(); + ajax(`${this.orbidderHost}/win`, null, JSON.stringify(winObj)); + } +}; + +registerBidder(spec); diff --git a/modules/orbidderBidAdapter.md b/modules/orbidderBidAdapter.md new file mode 100644 index 00000000000..59f8ea5fc81 --- /dev/null +++ b/modules/orbidderBidAdapter.md @@ -0,0 +1,40 @@ +#Overview + +``` +Module Name: Orbidder Bid Adapter +Module Type: Bidder Adapter +Maintainer: orbidder@otto.de +``` + +# Description + +Module that connects to orbidder demand sources + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div1', + sizes: [[300, 250]], // display 300x250 + bids: [ + { + bidder: 'orbidder', + params: { + siteId: '3608' + } + } + ] + },{ + code: 'test-div2', + sizes: [[728, 90]], // display 728x90 + bids: [ + { + bidder: 'orbidder', + params: { + siteId: '3608' + } + } + ] + } + ]; +``` diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js new file mode 100644 index 00000000000..cd7f085a12d --- /dev/null +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -0,0 +1,184 @@ +import {expect} from 'chai'; +import {spec} from 'modules/orbidderBidAdapter'; +import {newBidder} from 'src/adapters/bidderFactory'; +import * as ajax from 'src/ajax'; + +describe('orbidderBidAdapter', () => { + const adapter = newBidder(spec); + const bidRequest = { + bidId: 'd66fa86787e0b0ca900a96eacfd5f0bb', + auctionId: 'ccc4c7cdfe11cfbd74065e6dd28413d8', + transactionId: 'd58851660c0c4461e4aa06344fc9c0c6', + adUnitCode: 'adunit-code', + sizes: [[300, 250], [300, 600]], + params: { + 'foo': 'bar' + } + }; + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', () => { + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + + it('should return false when required params are not passed', () => { + let bidRequest = Object.assign({}, bidRequest); + delete bidRequest.params; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + }); + + describe('buildRequests', () => { + const request = spec.buildRequests([bidRequest])[0]; + + it('sends bid request to endpoint via https using post', () => { + expect(request.method).to.equal('POST'); + expect(request.url.indexOf('https://')).to.equal(0); + expect(request.url).to.equal(`${spec.orbidderHost}/bid`); + }); + + it('sends correct bid parameters', () => { + expect(Object.keys(request.data).length).to.equal(Object.keys(bidRequest).length + 2); + expect(request.data.pageUrl).to.equal('http://localhost:9876/'); + expect(request.data.referrer).to.equal(''); + Object.keys(bidRequest).forEach((key) => { + expect(bidRequest[key]).to.equal(request.data[key]); + }); + }); + + it('handles empty gdpr object', () => { + let bidRequest = Object.assign({}, bidRequest); + bidRequest.gdprConsent = {}; + + const request = spec.buildRequests([bidRequest])[0]; + expect(request.data.gdprConsent.consentRequired).to.be.equal(true); + }); + + it('handles non-existent gdpr object', () => { + let bidRequest = Object.assign({}, bidRequest); + bidRequest.gdprConsent = null; + + const request = spec.buildRequests([bidRequest])[0]; + expect(request.data.gdprConsent).to.be.undefined; + }); + + it('handles properly filled gdpr object where gdpr applies', () => { + const consentString = 'someWeirdString'; + const bidRequest = Object.assign({}, bidRequest); + bidRequest.gdprConsent = { + gdprApplies: true, + consentString: 'someWeirdString' + }; + + const request = spec.buildRequests([bidRequest])[0]; + const gdprConsent = request.data.gdprConsent; + expect(gdprConsent.consentRequired).to.be.equal(true); + expect(gdprConsent.consentString).to.be.equal(consentString); + }); + + it('handles properly filled gdpr object where gdpr does not apply', () => { + const consentString = 'someWeirdString'; + const bidRequest = Object.assign({}, bidRequest); + bidRequest.gdprConsent = { + gdprApplies: false, + consentString: 'someWeirdString' + }; + + const request = spec.buildRequests([bidRequest])[0]; + const gdprConsent = request.data.gdprConsent; + expect(gdprConsent.consentRequired).to.be.equal(false); + expect(gdprConsent.consentString).to.be.equal(consentString); + }); + }); + + describe('onBidWon', () => { + let ajaxStub; + const winObj = { + test: 1, + pageUrl: 'www.someurl.de', + referrer: 'www.somereferrer.de' + }; + + beforeEach(() => { + ajaxStub = sinon.stub(ajax, 'ajax'); + }); + + afterEach(() => { + ajaxStub.restore(); + }); + + it('calls orbidder\'s win endpoint', () => { + spec.onBidWon(winObj); + expect(ajaxStub.calledOnce).to.equal(true); + expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0); + expect(ajaxStub.firstCall.args[0]).to.equal(`${spec.orbidderHost}/win`); + expect(ajaxStub.firstCall.args[2]).to.equal(JSON.stringify(winObj)); + }); + }); + + describe('interpretResponse', () => { + it('should get correct bid response', () => { + const serverResponse = [ + { + 'width': 300, + 'height': 250, + 'creativeId': '29681110', + 'ad': '', + 'cpm': 0.5, + 'requestId': '30b31c1838de1e', + 'ttl': 60, + 'netRevenue': true, + 'currency': 'EUR' + } + ]; + + const expectedResponse = [ + { + 'requestId': '30b31c1838de1e', + 'cpm': 0.5, + 'creativeId': '29681110', + 'width': 300, + 'height': 250, + 'ttl': 60, + 'currency': 'EUR', + 'ad': '', + 'netRevenue': true + } + ]; + + const result = spec.interpretResponse({body: serverResponse}); + + expect(result.length).to.equal(expectedResponse.length); + Object.keys(expectedResponse[0]).forEach((key) => { + expect(result[0][key]).to.equal(expectedResponse[0][key]); + }); + }); + + it('handles broken server response', () => { + const serverResponse = [ + { + 'ad': '', + 'cpm': 0.5, + 'requestId': '30b31c1838de1e', + 'ttl': 60 + } + ]; + const result = spec.interpretResponse({body: serverResponse}); + + expect(result.length).to.equal(0); + }); + + it('handles nobid responses', () => { + const serverResponse = []; + const result = spec.interpretResponse({body: serverResponse}); + + expect(result.length).to.equal(0); + }); + }); +}); From ffc6f0be7837f03a0e5a59a4fc7e84bfab25e7f8 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Wed, 9 Jan 2019 16:47:42 +0100 Subject: [PATCH 02/15] use adUnits from orbidder_example.html --- modules/orbidderBidAdapter.md | 36 +++++++++++------------------------ 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/modules/orbidderBidAdapter.md b/modules/orbidderBidAdapter.md index 59f8ea5fc81..7a9600142e7 100644 --- a/modules/orbidderBidAdapter.md +++ b/modules/orbidderBidAdapter.md @@ -12,29 +12,15 @@ Module that connects to orbidder demand sources # Test Parameters ``` - var adUnits = [ - { - code: 'test-div1', - sizes: [[300, 250]], // display 300x250 - bids: [ - { - bidder: 'orbidder', - params: { - siteId: '3608' - } - } - ] - },{ - code: 'test-div2', - sizes: [[728, 90]], // display 728x90 - bids: [ - { - bidder: 'orbidder', - params: { - siteId: '3608' - } - } - ] - } - ]; +var adUnits = [{ + code: '/105091519/bidder_test', + mediaTypes: { + banner: { + sizes: [728, 90] + } + }, + bids: [{ + bidder: 'orbidder' + }] +}]; ``` From 5c9a947434b312080b055b39192e5dde70e2ae4d Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Thu, 10 Jan 2019 16:17:31 +0100 Subject: [PATCH 03/15] replace obsolete functions --- modules/orbidderBidAdapter.js | 16 ++++++++++------ test/spec/modules/orbidderBidAdapter_spec.js | 10 +++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index 1c070cb5811..41b817f705d 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from 'src/utils'; +import {detectReferer} from 'src/refererDetection'; import {ajax} from 'src/ajax'; import {registerBidder} from 'src/adapters/bidderFactory'; @@ -17,14 +17,17 @@ export const spec = { return !!(bid.sizes && bid.bidId); }, - buildRequests(validBidRequests) { + buildRequests(validBidRequests, bidderRequest) { return validBidRequests.map((bidRequest) => { + let referer = ''; + if (bidderRequest.refererInfo) { + referer = bidderRequest.refererInfo.referer || ''; + } const ret = { url: `${this.orbidderHost}/bid`, method: 'POST', data: { - pageUrl: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), + pageUrl: referer, bidId: bidRequest.bidId, auctionId: bidRequest.auctionId, transactionId: bidRequest.transactionId, @@ -64,8 +67,9 @@ export const spec = { }, onBidWon(winObj) { - winObj.pageUrl = utils.getTopWindowUrl(); - winObj.referrer = utils.getTopWindowReferrer(); + const getRefererInfo = detectReferer(window); + const refererInfo = getRefererInfo(); + winObj.pageUrl = refererInfo.referer; ajax(`${this.orbidderHost}/win`, null, JSON.stringify(winObj)); } }; diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index cd7f085a12d..fd80224ee28 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -10,6 +10,9 @@ describe('orbidderBidAdapter', () => { auctionId: 'ccc4c7cdfe11cfbd74065e6dd28413d8', transactionId: 'd58851660c0c4461e4aa06344fc9c0c6', adUnitCode: 'adunit-code', + refererInfo: { + referer: 'http://localhost:9876/' + }, sizes: [[300, 250], [300, 600]], params: { 'foo': 'bar' @@ -44,11 +47,12 @@ describe('orbidderBidAdapter', () => { }); it('sends correct bid parameters', () => { - expect(Object.keys(request.data).length).to.equal(Object.keys(bidRequest).length + 2); + expect(Object.keys(request.data).length).to.equal(Object.keys(bidRequest).length); expect(request.data.pageUrl).to.equal('http://localhost:9876/'); - expect(request.data.referrer).to.equal(''); Object.keys(bidRequest).forEach((key) => { - expect(bidRequest[key]).to.equal(request.data[key]); + if (key !== 'refererInfo') { + expect(bidRequest[key]).to.equal(request.data[key]); + } }); }); From 06d127ee7c50dc1d3c8f7a789e71e350d7f12077 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Thu, 10 Jan 2019 17:12:16 +0100 Subject: [PATCH 04/15] forgot to commit the test --- test/spec/modules/orbidderBidAdapter_spec.js | 31 ++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index fd80224ee28..50955404a5e 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -10,15 +10,22 @@ describe('orbidderBidAdapter', () => { auctionId: 'ccc4c7cdfe11cfbd74065e6dd28413d8', transactionId: 'd58851660c0c4461e4aa06344fc9c0c6', adUnitCode: 'adunit-code', - refererInfo: { - referer: 'http://localhost:9876/' - }, sizes: [[300, 250], [300, 600]], params: { 'foo': 'bar' } }; + const buildRequest = function (buildRequest) { + return spec.buildRequests( + [buildRequest], + { + refererInfo: { + referer: 'http://localhost:9876/' + } + })[0]; + } + describe('inherited functions', () => { it('exists and is a function', () => { expect(adapter.callBids).to.exist.and.to.be.a('function'); @@ -38,7 +45,7 @@ describe('orbidderBidAdapter', () => { }); describe('buildRequests', () => { - const request = spec.buildRequests([bidRequest])[0]; + const request = buildRequest(bidRequest); it('sends bid request to endpoint via https using post', () => { expect(request.method).to.equal('POST'); @@ -47,12 +54,12 @@ describe('orbidderBidAdapter', () => { }); it('sends correct bid parameters', () => { - expect(Object.keys(request.data).length).to.equal(Object.keys(bidRequest).length); + // we add one, because we add referer information from bidderRequest object + expect(Object.keys(request.data).length).to.equal(Object.keys(bidRequest).length + 1); expect(request.data.pageUrl).to.equal('http://localhost:9876/'); + // expect(request.data.referrer).to.equal(''); Object.keys(bidRequest).forEach((key) => { - if (key !== 'refererInfo') { - expect(bidRequest[key]).to.equal(request.data[key]); - } + expect(bidRequest[key]).to.equal(request.data[key]); }); }); @@ -60,7 +67,7 @@ describe('orbidderBidAdapter', () => { let bidRequest = Object.assign({}, bidRequest); bidRequest.gdprConsent = {}; - const request = spec.buildRequests([bidRequest])[0]; + const request = buildRequest(bidRequest); expect(request.data.gdprConsent.consentRequired).to.be.equal(true); }); @@ -68,7 +75,7 @@ describe('orbidderBidAdapter', () => { let bidRequest = Object.assign({}, bidRequest); bidRequest.gdprConsent = null; - const request = spec.buildRequests([bidRequest])[0]; + const request = buildRequest(bidRequest); expect(request.data.gdprConsent).to.be.undefined; }); @@ -80,7 +87,7 @@ describe('orbidderBidAdapter', () => { consentString: 'someWeirdString' }; - const request = spec.buildRequests([bidRequest])[0]; + const request = buildRequest(bidRequest); const gdprConsent = request.data.gdprConsent; expect(gdprConsent.consentRequired).to.be.equal(true); expect(gdprConsent.consentString).to.be.equal(consentString); @@ -94,7 +101,7 @@ describe('orbidderBidAdapter', () => { consentString: 'someWeirdString' }; - const request = spec.buildRequests([bidRequest])[0]; + const request = buildRequest(bidRequest); const gdprConsent = request.data.gdprConsent; expect(gdprConsent.consentRequired).to.be.equal(false); expect(gdprConsent.consentString).to.be.equal(consentString); From 8617515dcef5f43cbc8c272c3b022c43c10e63d7 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Thu, 10 Jan 2019 17:17:46 +0100 Subject: [PATCH 05/15] check if bidderRequest object is available --- modules/orbidderBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index 41b817f705d..626de9ca3be 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -20,7 +20,7 @@ export const spec = { buildRequests(validBidRequests, bidderRequest) { return validBidRequests.map((bidRequest) => { let referer = ''; - if (bidderRequest.refererInfo) { + if (bidderRequest && bidderRequest.refererInfo) { referer = bidderRequest.refererInfo.referer || ''; } const ret = { From 8b5c884ad338f401967f604519f1f0b260b28f06 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Thu, 10 Jan 2019 17:26:09 +0100 Subject: [PATCH 06/15] try to fix weird safari/ie issue --- modules/orbidderBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index 626de9ca3be..9a6cce01f4e 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -52,7 +52,7 @@ export const spec = { const bidResponses = []; serverResponse = serverResponse.body; if (serverResponse && (serverResponse.length > 0)) { - for (const bid of serverResponse) { + serverResponse.forEach((bid) => { const bidResponse = {}; for (const requiredKey of ['requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency']) { if (!bid.hasOwnProperty(requiredKey)) { @@ -61,7 +61,7 @@ export const spec = { bidResponse[requiredKey] = bid[requiredKey]; } bidResponses.push(bidResponse); - } + }); } return bidResponses; }, From 367b1a7974975d6cc2335b6261f5833ac3b5617c Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Fri, 18 Jan 2019 15:16:33 +0100 Subject: [PATCH 07/15] ebayK: add more params --- modules/orbidderBidAdapter.js | 15 ++++-- test/spec/modules/orbidderBidAdapter_spec.js | 48 +++++++++++++++----- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index 20ccfcfdace..d1626d26431 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -4,6 +4,7 @@ import {registerBidder} from '../src/adapters/bidderFactory'; export const spec = { code: 'orbidder', + bidParams: {}, orbidderHost: (() => { let ret = 'https://orbidder.otto.de'; try { @@ -14,7 +15,10 @@ export const spec = { })(), isBidRequestValid(bid) { - return !!(bid.sizes && bid.bidId); + return !!(bid.sizes && bid.bidId && bid.params && + (bid.params.accountId && (typeof bid.params.accountId === 'string')) && + (bid.params.placementId && (typeof bid.params.placementId === 'string')) && + ((typeof bid.params.keyValues === 'undefined') || (typeof bid.params.keyValues === 'object'))); }, buildRequests(validBidRequests, bidderRequest) { @@ -36,6 +40,7 @@ export const spec = { params: bidRequest.params } }; + spec.bidParams[bidRequest.bidId] = bidRequest.params; if (bidRequest && bidRequest.gdprConsent) { ret.data.gdprConsent = { consentString: bidRequest.gdprConsent.consentString, @@ -68,8 +73,12 @@ export const spec = { onBidWon(winObj) { const getRefererInfo = detectReferer(window); - const refererInfo = getRefererInfo(); - winObj.pageUrl = refererInfo.referer; + + winObj.pageUrl = getRefererInfo().referer; + if (spec.bidParams[winObj.adId]) { + winObj.params = spec.bidParams[winObj.adId]; + } + spec.ajaxCall(`${this.orbidderHost}/win`, JSON.stringify(winObj)); }, diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index bf31a6ad7e5..29c6c2c6d9a 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -4,17 +4,22 @@ import {newBidder} from 'src/adapters/bidderFactory'; describe('orbidderBidAdapter', () => { const adapter = newBidder(spec); - const bidRequest = { + const defaultBidRequest = { bidId: 'd66fa86787e0b0ca900a96eacfd5f0bb', auctionId: 'ccc4c7cdfe11cfbd74065e6dd28413d8', transactionId: 'd58851660c0c4461e4aa06344fc9c0c6', adUnitCode: 'adunit-code', sizes: [[300, 250], [300, 600]], params: { - 'foo': 'bar' + 'accountId': 'string1', + 'placementId': 'string2' } }; + const deepClone = function (val) { + return JSON.parse(JSON.stringify(val)); + }; + const buildRequest = function (buildRequest) { return spec.buildRequests( [buildRequest], @@ -23,7 +28,7 @@ describe('orbidderBidAdapter', () => { referer: 'http://localhost:9876/' } })[0]; - } + }; describe('inherited functions', () => { it('exists and is a function', () => { @@ -33,18 +38,36 @@ describe('orbidderBidAdapter', () => { describe('isBidRequestValid', () => { it('should return true when required params found', () => { + expect(spec.isBidRequestValid(defaultBidRequest)).to.equal(true); + }); + + it('accepts optional keyValues object', () => { + const bidRequest = deepClone(defaultBidRequest); + bidRequest.params.keyValues = {'key': 'value'}; expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); + it('performs type checking', () => { + const bidRequest = deepClone(defaultBidRequest); + bidRequest.params.accountId = 1; // supposed to be a string + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + + it('doesn\'t accept malformed keyValues', () => { + const bidRequest = deepClone(defaultBidRequest); + bidRequest.params.keyValues = 'another not usable string'; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + it('should return false when required params are not passed', () => { - let bidRequest = Object.assign({}, bidRequest); + const bidRequest = deepClone(defaultBidRequest); delete bidRequest.params; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); }); describe('buildRequests', () => { - const request = buildRequest(bidRequest); + const request = buildRequest(defaultBidRequest); it('sends bid request to endpoint via https using post', () => { expect(request.method).to.equal('POST'); @@ -54,16 +77,16 @@ describe('orbidderBidAdapter', () => { it('sends correct bid parameters', () => { // we add one, because we add referer information from bidderRequest object - expect(Object.keys(request.data).length).to.equal(Object.keys(bidRequest).length + 1); + expect(Object.keys(request.data).length).to.equal(Object.keys(defaultBidRequest).length + 1); expect(request.data.pageUrl).to.equal('http://localhost:9876/'); // expect(request.data.referrer).to.equal(''); - Object.keys(bidRequest).forEach((key) => { - expect(bidRequest[key]).to.equal(request.data[key]); + Object.keys(defaultBidRequest).forEach((key) => { + expect(defaultBidRequest[key]).to.equal(request.data[key]); }); }); it('handles empty gdpr object', () => { - let bidRequest = Object.assign({}, bidRequest); + const bidRequest = deepClone(defaultBidRequest); bidRequest.gdprConsent = {}; const request = buildRequest(bidRequest); @@ -71,7 +94,7 @@ describe('orbidderBidAdapter', () => { }); it('handles non-existent gdpr object', () => { - let bidRequest = Object.assign({}, bidRequest); + const bidRequest = deepClone(defaultBidRequest); bidRequest.gdprConsent = null; const request = buildRequest(bidRequest); @@ -80,7 +103,7 @@ describe('orbidderBidAdapter', () => { it('handles properly filled gdpr object where gdpr applies', () => { const consentString = 'someWeirdString'; - const bidRequest = Object.assign({}, bidRequest); + const bidRequest = deepClone(defaultBidRequest); bidRequest.gdprConsent = { gdprApplies: true, consentString: 'someWeirdString' @@ -94,7 +117,7 @@ describe('orbidderBidAdapter', () => { it('handles properly filled gdpr object where gdpr does not apply', () => { const consentString = 'someWeirdString'; - const bidRequest = Object.assign({}, bidRequest); + const bidRequest = deepClone(defaultBidRequest); bidRequest.gdprConsent = { gdprApplies: false, consentString: 'someWeirdString' @@ -110,6 +133,7 @@ describe('orbidderBidAdapter', () => { describe('onBidWon', () => { let ajaxStub; const winObj = { + adId: 'testId', test: 1, pageUrl: 'www.someurl.de', referrer: 'www.somereferrer.de' From cfe0911bf4a2f987dd7bbb4c979bcb8c1966c05b Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Fri, 18 Jan 2019 17:01:04 +0100 Subject: [PATCH 08/15] update orbidderBidAdapter.md --- modules/orbidderBidAdapter.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/orbidderBidAdapter.md b/modules/orbidderBidAdapter.md index 7a9600142e7..c7676e6774f 100644 --- a/modules/orbidderBidAdapter.md +++ b/modules/orbidderBidAdapter.md @@ -21,6 +21,10 @@ var adUnits = [{ }, bids: [{ bidder: 'orbidder' + params: { + accountId: "someAccount", + placementId: "somePlace" + } }] }]; ``` From 4279c11efaf4f6b3e0b78f4f92aad44ada32900e Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Mon, 21 Jan 2019 11:05:59 +0100 Subject: [PATCH 09/15] use spec. instead of this. for consistency reasons --- modules/orbidderBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index d1626d26431..de365fe87de 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -28,7 +28,7 @@ export const spec = { referer = bidderRequest.refererInfo.referer || ''; } const ret = { - url: `${this.orbidderHost}/bid`, + url: `${spec.orbidderHost}/bid`, method: 'POST', data: { pageUrl: referer, @@ -79,7 +79,7 @@ export const spec = { winObj.params = spec.bidParams[winObj.adId]; } - spec.ajaxCall(`${this.orbidderHost}/win`, JSON.stringify(winObj)); + spec.ajaxCall(`${spec.orbidderHost}/win`, JSON.stringify(winObj)); }, ajaxCall(endpoint, data) { From b05496fa84d05843a8a666fd2683073bc6bd26a3 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Fri, 15 Mar 2019 14:30:38 +0100 Subject: [PATCH 10/15] add bidfloor parameter to params object --- modules/orbidderBidAdapter.js | 1 + test/spec/modules/orbidderBidAdapter_spec.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index de365fe87de..e316f3ef212 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -18,6 +18,7 @@ export const spec = { return !!(bid.sizes && bid.bidId && bid.params && (bid.params.accountId && (typeof bid.params.accountId === 'string')) && (bid.params.placementId && (typeof bid.params.placementId === 'string')) && + ((typeof bid.params.bidfloor === 'undefined') || (typeof bid.params.bidfloor === 'number')) && ((typeof bid.params.keyValues === 'undefined') || (typeof bid.params.keyValues === 'object'))); }, diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 29c6c2c6d9a..0761ed8d31e 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -64,6 +64,21 @@ describe('orbidderBidAdapter', () => { delete bidRequest.params; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); + + it('accepts optional bidfloor', () => { + const bidRequest = deepClone(defaultBidRequest); + bidRequest.params.bidfloor = 123; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + + bidRequest.params.bidfloor = 1.23; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + + it('doesn\'t accept malformed bidfloor', () => { + const bidRequest = deepClone(defaultBidRequest); + bidRequest.params.bidfloor = 'another not usable string'; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); }); describe('buildRequests', () => { From 476c431305e6e81526e852eedd7ea7df4946aed7 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Tue, 16 Apr 2019 16:20:59 +0200 Subject: [PATCH 11/15] fix gdpr object handling --- modules/orbidderBidAdapter.js | 8 +-- test/spec/modules/orbidderBidAdapter_spec.js | 57 ++++++++++---------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index e316f3ef212..fc5eecbab08 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -42,11 +42,11 @@ export const spec = { } }; spec.bidParams[bidRequest.bidId] = bidRequest.params; - if (bidRequest && bidRequest.gdprConsent) { + if (bidderRequest && bidderRequest.gdprConsent) { ret.data.gdprConsent = { - consentString: bidRequest.gdprConsent.consentString, - consentRequired: (typeof bidRequest.gdprConsent.gdprApplies === 'boolean') - ? bidRequest.gdprConsent.gdprApplies + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') + ? bidderRequest.gdprConsent.gdprApplies : true }; } diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 0761ed8d31e..bc88090095b 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -20,14 +20,17 @@ describe('orbidderBidAdapter', () => { return JSON.parse(JSON.stringify(val)); }; - const buildRequest = function (buildRequest) { - return spec.buildRequests( - [buildRequest], - { - refererInfo: { - referer: 'http://localhost:9876/' - } - })[0]; + const buildRequest = (buildRequest, bidderRequest) => { + if (!Array.isArray(buildRequest)) { + buildRequest = [buildRequest]; + } + + return spec.buildRequests(buildRequest, { + ...bidderRequest || {}, + refererInfo: { + referer: 'http://localhost:9876/' + } + })[0]; }; describe('inherited functions', () => { @@ -101,30 +104,28 @@ describe('orbidderBidAdapter', () => { }); it('handles empty gdpr object', () => { - const bidRequest = deepClone(defaultBidRequest); - bidRequest.gdprConsent = {}; - - const request = buildRequest(bidRequest); + const request = buildRequest(defaultBidRequest, { + gdprConsent: {} + }); expect(request.data.gdprConsent.consentRequired).to.be.equal(true); }); it('handles non-existent gdpr object', () => { - const bidRequest = deepClone(defaultBidRequest); - bidRequest.gdprConsent = null; - - const request = buildRequest(bidRequest); + const request = buildRequest(defaultBidRequest, { + gdprConsent: null + }); expect(request.data.gdprConsent).to.be.undefined; }); it('handles properly filled gdpr object where gdpr applies', () => { const consentString = 'someWeirdString'; - const bidRequest = deepClone(defaultBidRequest); - bidRequest.gdprConsent = { - gdprApplies: true, - consentString: 'someWeirdString' - }; + const request = buildRequest(defaultBidRequest, { + gdprConsent: { + gdprApplies: true, + consentString: consentString + } + }); - const request = buildRequest(bidRequest); const gdprConsent = request.data.gdprConsent; expect(gdprConsent.consentRequired).to.be.equal(true); expect(gdprConsent.consentString).to.be.equal(consentString); @@ -132,13 +133,13 @@ describe('orbidderBidAdapter', () => { it('handles properly filled gdpr object where gdpr does not apply', () => { const consentString = 'someWeirdString'; - const bidRequest = deepClone(defaultBidRequest); - bidRequest.gdprConsent = { - gdprApplies: false, - consentString: 'someWeirdString' - }; + const request = buildRequest(defaultBidRequest, { + gdprConsent: { + gdprApplies: false, + consentString: consentString + } + }); - const request = buildRequest(bidRequest); const gdprConsent = request.data.gdprConsent; expect(gdprConsent.consentRequired).to.be.equal(false); expect(gdprConsent.consentString).to.be.equal(consentString); From da8dbde3b5da30c90a8086645e41dbdbe0ef9f10 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Tue, 7 May 2019 11:27:17 +0200 Subject: [PATCH 12/15] default to consentRequired: false when not explicitly given --- modules/orbidderBidAdapter.js | 4 +--- test/spec/modules/orbidderBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index fc5eecbab08..d5af85d8c83 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -45,9 +45,7 @@ export const spec = { if (bidderRequest && bidderRequest.gdprConsent) { ret.data.gdprConsent = { consentString: bidderRequest.gdprConsent.consentString, - consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') - ? bidderRequest.gdprConsent.gdprApplies - : true + consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') && bidderRequest.gdprConsent.gdprApplies }; } return ret; diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index bc88090095b..639881d5489 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -107,7 +107,7 @@ describe('orbidderBidAdapter', () => { const request = buildRequest(defaultBidRequest, { gdprConsent: {} }); - expect(request.data.gdprConsent.consentRequired).to.be.equal(true); + expect(request.data.gdprConsent.consentRequired).to.be.equal(false); }); it('handles non-existent gdpr object', () => { From 07c805cb9fe09202a6838382f2030fbf1bdd37e7 Mon Sep 17 00:00:00 2001 From: Mathias Methner Date: Tue, 7 May 2019 12:54:34 +0200 Subject: [PATCH 13/15] wip - use onSetTargeting callback --- modules/orbidderBidAdapter.js | 18 +++++++++++++----- test/spec/modules/orbidderBidAdapter_spec.js | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index d5af85d8c83..fa1941ac56f 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -70,15 +70,23 @@ export const spec = { return bidResponses; }, - onBidWon(winObj) { + onBidWon(bid) { + this.onHandler(bid, '/win'); + }, + + onSetTargeting (bid) { + this.onHandler(bid, '/targeting'); + }, + + onHandler (bid, route) { const getRefererInfo = detectReferer(window); - winObj.pageUrl = getRefererInfo().referer; - if (spec.bidParams[winObj.adId]) { - winObj.params = spec.bidParams[winObj.adId]; + bid.pageUrl = getRefererInfo().referer; + if (spec.bidParams[bid.adId]) { + bid.params = spec.bidParams[bid.adId]; } - spec.ajaxCall(`${spec.orbidderHost}/win`, JSON.stringify(winObj)); + spec.ajaxCall(`${spec.orbidderHost}`+{route}, JSON.stringify(bid)); }, ajaxCall(endpoint, data) { diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 639881d5489..2ac97077fd3 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -1,6 +1,7 @@ import {expect} from 'chai'; import {spec} from 'modules/orbidderBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; +import openxAdapter from "../../../modules/openxAnalyticsAdapter"; describe('orbidderBidAdapter', () => { const adapter = newBidder(spec); @@ -146,9 +147,9 @@ describe('orbidderBidAdapter', () => { }); }); - describe('onBidWon', () => { + describe('onCallbackHandler', () => { let ajaxStub; - const winObj = { + const bidObj = { adId: 'testId', test: 1, pageUrl: 'www.someurl.de', @@ -164,11 +165,19 @@ describe('orbidderBidAdapter', () => { }); it('calls orbidder\'s win endpoint', () => { - spec.onBidWon(winObj); + spec.onBidWon(bidObj); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0); expect(ajaxStub.firstCall.args[0]).to.equal(`${spec.orbidderHost}/win`); - expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(winObj)); + expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObj)); + }); + + it('calls orbidder\'s targeting endpoint', () => { + spec.onBidWon(bidObj); + expect(ajaxStub.calledOnce).to.equal(true); + expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0); + expect(ajaxStub.firstCall.args[0]).to.equal(`${spec.orbidderHost}/targeting`); + expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObj)); }); }); From 86664b59a85f62ac4e378670250c875225a3f56c Mon Sep 17 00:00:00 2001 From: Mathias Methner Date: Tue, 7 May 2019 14:35:41 +0200 Subject: [PATCH 14/15] add tests for onSetTargeting callback --- modules/orbidderBidAdapter.js | 2 +- package-lock.json | 30 ++++++++++++++------ test/spec/modules/orbidderBidAdapter_spec.js | 16 +++++------ 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index fa1941ac56f..1123cc5d50e 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -86,7 +86,7 @@ export const spec = { bid.params = spec.bidParams[bid.adId]; } - spec.ajaxCall(`${spec.orbidderHost}`+{route}, JSON.stringify(bid)); + spec.ajaxCall(`${spec.orbidderHost}${route}`, JSON.stringify(bid)); }, ajaxCall(endpoint, data) { diff --git a/package-lock.json b/package-lock.json index c3bd739008f..6f908eeba52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "2.13.0-pre", + "version": "2.14.0-pre", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -6093,12 +6093,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -6113,17 +6115,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -6240,7 +6245,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -6252,6 +6258,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -6266,6 +6273,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -6273,12 +6281,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -6297,6 +6307,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -6377,7 +6388,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -6389,6 +6401,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -6510,6 +6523,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 2ac97077fd3..3818f502901 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -1,7 +1,7 @@ import {expect} from 'chai'; import {spec} from 'modules/orbidderBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; -import openxAdapter from "../../../modules/openxAnalyticsAdapter"; +import openxAdapter from '../../../modules/openxAnalyticsAdapter'; describe('orbidderBidAdapter', () => { const adapter = newBidder(spec); @@ -164,20 +164,18 @@ describe('orbidderBidAdapter', () => { ajaxStub.restore(); }); - it('calls orbidder\'s win endpoint', () => { + it('calls orbidder\'s callback endpoint', () => { spec.onBidWon(bidObj); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0); expect(ajaxStub.firstCall.args[0]).to.equal(`${spec.orbidderHost}/win`); expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObj)); - }); - it('calls orbidder\'s targeting endpoint', () => { - spec.onBidWon(bidObj); - expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0); - expect(ajaxStub.firstCall.args[0]).to.equal(`${spec.orbidderHost}/targeting`); - expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObj)); + spec.onSetTargeting(bidObj); + expect(ajaxStub.calledTwice).to.equal(true); + expect(ajaxStub.secondCall.args[0].indexOf('https://')).to.equal(0); + expect(ajaxStub.secondCall.args[0]).to.equal(`${spec.orbidderHost}/targeting`); + expect(ajaxStub.secondCall.args[1]).to.equal(JSON.stringify(bidObj)); }); }); From 0664e97b43c1a8e4e729065553c5ffb2bc900576 Mon Sep 17 00:00:00 2001 From: "Volk, Rainer" Date: Wed, 8 May 2019 15:24:01 +0200 Subject: [PATCH 15/15] fix params and respective tests --- modules/orbidderBidAdapter.js | 5 ++--- test/spec/modules/orbidderBidAdapter_spec.js | 14 +++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index 1123cc5d50e..e085a14c6b8 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -82,10 +82,9 @@ export const spec = { const getRefererInfo = detectReferer(window); bid.pageUrl = getRefererInfo().referer; - if (spec.bidParams[bid.adId]) { - bid.params = spec.bidParams[bid.adId]; + if (spec.bidParams[bid.requestId] && (typeof bid.params === 'undefined')) { + bid.params = [spec.bidParams[bid.requestId]]; } - spec.ajaxCall(`${spec.orbidderHost}${route}`, JSON.stringify(bid)); }, diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 3818f502901..55f5e2cae4c 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -2,6 +2,7 @@ import {expect} from 'chai'; import {spec} from 'modules/orbidderBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; import openxAdapter from '../../../modules/openxAnalyticsAdapter'; +import {detectReferer} from 'src/refererDetection'; describe('orbidderBidAdapter', () => { const adapter = newBidder(spec); @@ -153,9 +154,16 @@ describe('orbidderBidAdapter', () => { adId: 'testId', test: 1, pageUrl: 'www.someurl.de', - referrer: 'www.somereferrer.de' + referrer: 'www.somereferrer.de', + requestId: '123req456' }; + spec.bidParams['123req456'] = {'accountId': '123acc456'}; + + let bidObjClone = deepClone(bidObj); + bidObjClone.pageUrl = detectReferer(window)().referer; + bidObjClone.params = [{'accountId': '123acc456'}]; + beforeEach(() => { ajaxStub = sinon.stub(spec, 'ajaxCall'); }); @@ -169,13 +177,13 @@ describe('orbidderBidAdapter', () => { expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0); expect(ajaxStub.firstCall.args[0]).to.equal(`${spec.orbidderHost}/win`); - expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObj)); + expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObjClone)); spec.onSetTargeting(bidObj); expect(ajaxStub.calledTwice).to.equal(true); expect(ajaxStub.secondCall.args[0].indexOf('https://')).to.equal(0); expect(ajaxStub.secondCall.args[0]).to.equal(`${spec.orbidderHost}/targeting`); - expect(ajaxStub.secondCall.args[1]).to.equal(JSON.stringify(bidObj)); + expect(ajaxStub.secondCall.args[1]).to.equal(JSON.stringify(bidObjClone)); }); });