From 1267b64e111934951493121c6464cd25afa9d07e Mon Sep 17 00:00:00 2001 From: "monis.q" Date: Mon, 20 Sep 2021 08:30:40 +0530 Subject: [PATCH] medianetBidAdapter sending ortb2imp in bid request --- modules/medianetBidAdapter.js | 5 ++ test/spec/modules/medianetBidAdapter_spec.js | 63 +++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/modules/medianetBidAdapter.js b/modules/medianetBidAdapter.js index 3b7e555cc72..d78f4a70e2c 100644 --- a/modules/medianetBidAdapter.js +++ b/modules/medianetBidAdapter.js @@ -179,6 +179,11 @@ function slotParams(bidRequest) { }, all: bidRequest.params }; + + if (bidRequest.ortb2Imp) { + params.ortb2Imp = bidRequest.ortb2Imp; + } + let bannerSizes = utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes') || []; const videoInMediaType = utils.deepAccess(bidRequest, 'mediaTypes.video') || {}; diff --git a/test/spec/modules/medianetBidAdapter_spec.js b/test/spec/modules/medianetBidAdapter_spec.js index adb9663ba7c..8589c3b404f 100644 --- a/test/spec/modules/medianetBidAdapter_spec.js +++ b/test/spec/modules/medianetBidAdapter_spec.js @@ -1,4 +1,4 @@ -import {expect} from 'chai'; +import {expect, assert} from 'chai'; import {spec} from 'modules/medianetBidAdapter.js'; import { makeSlot } from '../integration/faker/googletag.js'; import { config } from 'src/config.js'; @@ -99,6 +99,56 @@ let VALID_BID_REQUEST = [{ 'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d', 'bidRequestsCount': 1 }], + VALID_BID_REQUEST_WITH_ORTB2 = [{ + 'bidder': 'medianet', + 'params': { + 'crid': 'crid', + 'cid': 'customer_id', + 'site': { + 'page': 'http://media.net/prebidtest', + 'domain': 'media.net', + 'ref': 'http://media.net/prebidtest', + 'isTop': true + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '277b631f-92f5-4844-8b19-ea13c095d3f1', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]], + } + }, + 'bidId': '28f8f8130a583e', + 'bidderRequestId': '1e9b1f07797c1c', + 'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d', + 'ortb2Imp': { 'ext': { 'data': { 'pbadslot': '/12345/my-gpt-tag-0' } } }, + 'bidRequestsCount': 1 + }, { + 'bidder': 'medianet', + 'params': { + 'crid': 'crid', + 'cid': 'customer_id', + 'site': { + 'page': 'http://media.net/prebidtest', + 'domain': 'media.net', + 'ref': 'http://media.net/prebidtest', + 'isTop': true + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-123', + 'transactionId': 'c52a5c62-3c2b-4b90-9ff8-ec1487754822', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 251]], + } + }, + 'sizes': [[300, 251]], + 'bidId': '3f97ca71b1e5c2', + 'bidderRequestId': '1e9b1f07797c1c', + 'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d', + 'ortb2Imp': { 'ext': { 'data': { 'pbadslot': '/12345/my-gpt-tag-0' } } }, + 'bidRequestsCount': 1 + }], VALID_BID_REQUEST_WITH_USERID = [{ 'bidder': 'medianet', 'params': { @@ -1247,6 +1297,17 @@ describe('Media.net bid adapter', function () { expect(JSON.parse(bidreq.data)).to.deep.equal(VALID_PAYLOAD_WITH_CRID); }); + it('should have valid ortb2Imp param present in bid request', function() { + let bidreq = spec.buildRequests(VALID_BID_REQUEST_WITH_ORTB2, VALID_AUCTIONDATA); + let actual = JSON.parse(bidreq.data).imp[0].ortb2Imp; + const expected = VALID_BID_REQUEST_WITH_ORTB2[0].ortb2Imp + assert.equal(JSON.stringify(actual), JSON.stringify(expected)) + + bidreq = spec.buildRequests(VALID_BID_REQUEST, VALID_AUCTIONDATA); + actual = JSON.parse(bidreq.data).imp[0].ortb2Imp; + assert.equal(actual, undefined) + }); + it('should have userid in bid request', function () { let bidReq = spec.buildRequests(VALID_BID_REQUEST_WITH_USERID, VALID_AUCTIONDATA); expect(JSON.parse(bidReq.data)).to.deep.equal(VALID_PAYLOAD_WITH_USERID);