Skip to content

Commit

Permalink
medianetBidAdapter sending ortb2imp in bid request (prebid#7443)
Browse files Browse the repository at this point in the history
Co-authored-by: monis.q <[email protected]>
  • Loading branch information
2 people authored and Chris Pabst committed Jan 10, 2022
1 parent 395df5f commit e6c11d1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/medianetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') || {};
Expand Down
63 changes: 62 additions & 1 deletion test/spec/modules/medianetBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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': {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e6c11d1

Please sign in to comment.