From 77bf6daccfaf56cae8a46b0389b2cf742d7419b3 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 9 Mar 2022 05:55:56 -0700 Subject: [PATCH 1/5] pass imp and fix test --- modules/prebidServerBidAdapter/index.js | 2 +- .../modules/prebidServerBidAdapter_spec.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 909dc1d42fb..92202567ab0 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -714,7 +714,7 @@ Object.assign(ORTB2.prototype, { return acc; }, {...deepAccess(adUnit, 'ortb2Imp.ext')}); - const imp = { id: impressionId, ext, secure: s2sConfig.secure }; + const imp = {...adUnit.ortb2Imp, id: impressionId, ext, secure: s2sConfig.secure }; const ortb2 = {...deepAccess(adUnit, 'ortb2Imp.ext.data')}; Object.keys(ortb2).forEach(prop => { diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 0d62f458969..0bb4b95f2dc 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2910,6 +2910,25 @@ describe('S2S Adapter', function () { expect(requestBid.coopSync).to.be.undefined; }); + it('should set imp banner if ortb2Imp.banner is present', function() { + const consentConfig = { s2sConfig: CONFIG }; + config.setConfig(consentConfig); + const bidRequest = utils.deepClone(REQUEST); + bidRequest.ad_units[0].ortb2Imp = { + banner: { + api: 7 + } + }; + + adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + + expect(parsedRequestBody.imp).to.be.a('array'); + expect(parsedRequestBody.imp[0]).to.be.a('object'); + expect(parsedRequestBody.imp[0]).to.have.property('banner'); + expect(parsedRequestBody.imp[0].banner.api).to.equal(7); + }); + it('adds debug flag', function () { config.setConfig({debug: true}); From ee7e1568c609acd1ddfe3a45776e3b09da223932 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 9 Mar 2022 06:05:39 -0700 Subject: [PATCH 2/5] fix lint --- modules/prebidServerBidAdapter/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 92202567ab0..f9d62ffa6e3 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -714,7 +714,7 @@ Object.assign(ORTB2.prototype, { return acc; }, {...deepAccess(adUnit, 'ortb2Imp.ext')}); - const imp = {...adUnit.ortb2Imp, id: impressionId, ext, secure: s2sConfig.secure }; + const imp = { ...adUnit.ortb2Imp, id: impressionId, ext, secure: s2sConfig.secure }; const ortb2 = {...deepAccess(adUnit, 'ortb2Imp.ext.data')}; Object.keys(ortb2).forEach(prop => { From b39c3449a04a5bc21beedba47257055e08194a05 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 9 Mar 2022 06:33:56 -0700 Subject: [PATCH 3/5] fix to mergeDeep --- modules/prebidServerBidAdapter/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index f9d62ffa6e3..99922bb9681 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -745,7 +745,7 @@ Object.assign(ORTB2.prototype, { } }); - Object.assign(imp, mediaTypes); + mergeDeep(imp, mediaTypes); // if storedAuctionResponse has been set, pass SRID const storedAuctionResponseBid = find(firstBidRequest.bids, bid => (bid.adUnitCode === adUnit.code && bid.storedAuctionResponse)); From 87a04873d8b72c4c3dbd37d09babf4c0f60c36f8 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 9 Mar 2022 07:04:24 -0700 Subject: [PATCH 4/5] add instl test --- test/spec/modules/prebidServerBidAdapter_spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 0bb4b95f2dc..365cd7c4e6b 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2917,7 +2917,8 @@ describe('S2S Adapter', function () { bidRequest.ad_units[0].ortb2Imp = { banner: { api: 7 - } + }, + instl: 1 }; adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax); @@ -2927,6 +2928,8 @@ describe('S2S Adapter', function () { expect(parsedRequestBody.imp[0]).to.be.a('object'); expect(parsedRequestBody.imp[0]).to.have.property('banner'); expect(parsedRequestBody.imp[0].banner.api).to.equal(7); + expect(parsedRequestBody.imp[0]).to.have.property('instl'); + expect(parsedRequestBody.imp[0].instl).to.equal(1); }); it('adds debug flag', function () { From 75b2238d1ac53e428822a202073fd40f7ce2519b Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 9 Mar 2022 07:07:11 -0700 Subject: [PATCH 5/5] remove overlapping testing --- test/spec/modules/prebidServerBidAdapter_spec.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 365cd7c4e6b..aa9c229203b 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2924,11 +2924,7 @@ describe('S2S Adapter', function () { adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax); const parsedRequestBody = JSON.parse(server.requests[0].requestBody); - expect(parsedRequestBody.imp).to.be.a('array'); - expect(parsedRequestBody.imp[0]).to.be.a('object'); - expect(parsedRequestBody.imp[0]).to.have.property('banner'); expect(parsedRequestBody.imp[0].banner.api).to.equal(7); - expect(parsedRequestBody.imp[0]).to.have.property('instl'); expect(parsedRequestBody.imp[0].instl).to.equal(1); });