From 78ea51db0b1e3b579a87cd3d62af3fe559811b3e Mon Sep 17 00:00:00 2001 From: Bret Gorsline Date: Wed, 18 Sep 2019 15:06:57 -0400 Subject: [PATCH 1/5] rubicon: not passing pos if not specified --- modules/rubiconBidAdapter.js | 5 ++++- test/spec/modules/rubiconBidAdapter_spec.js | 22 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index f309e4b7cac..73b3b6663eb 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -395,7 +395,6 @@ export const spec = { 'zone_id': params.zoneId, 'size_id': parsedSizes[0], 'alt_size_ids': parsedSizes.slice(1).join(',') || undefined, - 'p_pos': params.position === 'atf' || params.position === 'btf' ? params.position : 'unknown', 'rp_floor': (params.floor = parseFloat(params.floor)) > 0.01 ? params.floor : 0.01, 'rp_secure': isSecure() ? '1' : '0', 'tk_flint': `${configIntType || DEFAULT_INTEGRATION}_v$prebid.version$`, @@ -409,6 +408,10 @@ export const spec = { 'rf': _getPageUrl(bidRequest, bidderRequest) }; + if (params.position === 'atf' || params.position === 'btf') { + data['p_pos'] = params.position; + } + if ((bidRequest.userId || {}).tdid) { data['tpid_tdid'] = bidRequest.userId.tdid; } diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index f7432435060..671dec58eff 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -353,6 +353,28 @@ describe('the rubicon adapter', function () { }); }); + it('should not send p_pos to AE if not params.position specified', function() { + var noposRequest = utils.deepClone(bidderRequest); + delete noposRequest.bids[0].params.position; + + let [request] = spec.buildRequests(noposRequest.bids, noposRequest); + let data = parseQuery(request.data); + + expect(data['site_id']).to.equal('70608'); + expect(data['p_pos']).to.equal(undefined); + }); + + it('should not send p_pos to AE if not params.position is invalid', function() { + var badposRequest = utils.deepClone(bidderRequest); + badposRequest.bids[0].params.position = 'bad'; + + let [request] = spec.buildRequests(badposRequest.bids, badposRequest); + let data = parseQuery(request.data); + + expect(data['site_id']).to.equal('70608'); + expect(data['p_pos']).to.equal(undefined); + }); + it('ad engine query params should be ordered correctly', function () { sandbox.stub(Math, 'random').callsFake(() => 0.1); let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); From eaa6f004e73f5d946f2927a05cb9b2f20ea47e43 Mon Sep 17 00:00:00 2001 From: Bret Gorsline Date: Wed, 18 Sep 2019 15:24:34 -0400 Subject: [PATCH 2/5] added comment --- modules/rubiconBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 73b3b6663eb..deb916cbcdd 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -408,6 +408,7 @@ export const spec = { 'rf': _getPageUrl(bidRequest, bidderRequest) }; + // add p_pos only if specified and valid if (params.position === 'atf' || params.position === 'btf') { data['p_pos'] = params.position; } From d12fee87cde47df2302c6d6a8599df231155b941 Mon Sep 17 00:00:00 2001 From: Bret Gorsline Date: Wed, 18 Sep 2019 16:31:02 -0400 Subject: [PATCH 3/5] not sending pos for video when undefined --- modules/rubiconBidAdapter.js | 8 +++++++- test/spec/modules/rubiconBidAdapter_spec.js | 11 ++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index deb916cbcdd..a1cdfdf8fea 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -772,8 +772,14 @@ function addVideoParameters(data, bidRequest) { if (typeof data.imp[0].video === 'object' && data.imp[0].video.skipafter === undefined) { data.imp[0].video.skipafter = bidRequest.params.video.skipdelay; } + // video.pos can already be specified by adunit.mediatypes.video.pos. + // but if not, it might be specified in the params if (typeof data.imp[0].video === 'object' && data.imp[0].video.pos === undefined) { - data.imp[0].video.pos = bidRequest.params.position === 'atf' ? 1 : (bidRequest.params.position === 'btf' ? 3 : 0); + if (bidRequest.params.position === 'atf') { + data.imp[0].video.pos = 1; + } else if (bidRequest.params.position === 'btf') { + data.imp[0].video.pos = 3; + } } const size = parseSizes(bidRequest, 'video') diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 671dec58eff..1ab0143cf82 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1157,12 +1157,13 @@ describe('the rubicon adapter', function () { expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(false) }); - it('should send request with proper ad position', function () { + it('should not send pos for bad param entry', function () { createVideoBidderRequest(); let positionBidderRequest = utils.deepClone(bidderRequest); - positionBidderRequest.bids[0].mediaTypes.video.pos = 1; + delete positionBidderRequest.bids[0].mediaTypes.video.pos; + positionBidderRequest.bids[0].params.position = 'bad'; let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(1); + expect(request.data.imp[0].video.pos).to.equal(undefined); }); it('should send correct bidfloor to PBS', function() { @@ -1199,7 +1200,7 @@ describe('the rubicon adapter', function () { positionBidderRequest.bids[0].params.position = undefined; positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(0); + expect(request.data.imp[0].video.pos).to.equal(undefined); positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].params.position = 'atf' @@ -1217,7 +1218,7 @@ describe('the rubicon adapter', function () { positionBidderRequest.bids[0].params.position = 'foobar'; positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(0); + expect(request.data.imp[0].video.pos).to.equal(undefined); }); it('should properly enforce video.context to be either instream or outstream', function () { From 9005d7736e7e8413ddb8590273fc6af5cc6da1b0 Mon Sep 17 00:00:00 2001 From: Bret Gorsline Date: Wed, 18 Sep 2019 16:36:40 -0400 Subject: [PATCH 4/5] cleaning up test --- test/spec/modules/rubiconBidAdapter_spec.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 1ab0143cf82..3cf933784ef 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1157,15 +1157,6 @@ describe('the rubicon adapter', function () { expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(false) }); - it('should not send pos for bad param entry', function () { - createVideoBidderRequest(); - let positionBidderRequest = utils.deepClone(bidderRequest); - delete positionBidderRequest.bids[0].mediaTypes.video.pos; - positionBidderRequest.bids[0].params.position = 'bad'; - let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(undefined); - }); - it('should send correct bidfloor to PBS', function() { createVideoBidderRequest(); @@ -1195,6 +1186,12 @@ describe('the rubicon adapter', function () { }); it('should send request with proper ad position when mediaTypes.video.pos is not defined', function () { + createVideoBidderRequest(); + let positionBidderRequest = utils.deepClone(bidderRequest); + positionBidderRequest.bids[0].mediaTypes.video.pos = 1; + let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); + expect(request.data.imp[0].video.pos).to.equal(1); + createVideoBidderRequest(); let positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].params.position = undefined; From 55d7c03bba91df202e98fdcb133e25406eecf00a Mon Sep 17 00:00:00 2001 From: Bret Gorsline Date: Wed, 18 Sep 2019 16:41:15 -0400 Subject: [PATCH 5/5] fixed unit test --- test/spec/modules/rubiconBidAdapter_spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 3cf933784ef..8d65e1e97b4 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1185,18 +1185,17 @@ describe('the rubicon adapter', function () { expect(request.data.imp[0]).to.not.haveOwnProperty('bidfloor'); }); - it('should send request with proper ad position when mediaTypes.video.pos is not defined', function () { + it('should send request with proper ad position', function () { createVideoBidderRequest(); let positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].mediaTypes.video.pos = 1; let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); expect(request.data.imp[0].video.pos).to.equal(1); - createVideoBidderRequest(); - let positionBidderRequest = utils.deepClone(bidderRequest); + positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].params.position = undefined; positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; - let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); + [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); expect(request.data.imp[0].video.pos).to.equal(undefined); positionBidderRequest = utils.deepClone(bidderRequest);