Skip to content

Commit

Permalink
Discovery Bid Adapter : not filter params (#10965)
Browse files Browse the repository at this point in the history
* feat(isBidRequestValid): just filter token once. not filter publisher and tagid

* feat(isBidRequestValid): add unit test

* feat(spec): fix eslint

* feat(spec): fix unit test

* feat(spec): fix unit test

---------

Co-authored-by: yubei01 <yubei01@baidu.com>
  • Loading branch information
ecoeco163 and yubei01 authored Jan 25, 2024
1 parent 57c18bd commit 379b687
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/discoveryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export const spec = {
if (bid.params.badv) {
globals['badv'] = Array.isArray(bid.params.badv) ? bid.params.badv : [];
}
return !!(bid.params.token && bid.params.publisher && bid.params.tagid);
return true;
},

/**
Expand All @@ -522,6 +522,8 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
if (!globals['token']) return;

let payload = getParam(validBidRequests, bidderRequest);

const payloadString = JSON.stringify(payload);
Expand Down
80 changes: 80 additions & 0 deletions test/spec/modules/discoveryBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,77 @@ describe('discovery:BidAdapterTests', function () {
};
let request = [];

let bidRequestDataNoParams = {
bidderCode: 'discovery',
auctionId: 'ff66e39e-4075-4d18-9854-56fde9b879ac',
bidderRequestId: '4fec04e87ad785',
bids: [
{
bidder: 'discovery',
params: {
referrer: 'https://discovery.popin.cc',
},
refererInfo: {
page: 'https://discovery.popin.cc',
stack: [
'a.com',
'b.com'
]
},
mediaTypes: {
banner: {
sizes: [[300, 250]],
pos: 'left',
},
},
ortb2: {
user: {
ext: {
data: {
CxSegments: []
}
}
},
site: {
domain: 'discovery.popin.cc',
publisher: {
domain: 'discovery.popin.cc'
},
page: 'https://discovery.popin.cc',
cat: ['IAB-19', 'IAB-20'],
},
},
ortb2Imp: {
ext: {
gpid: 'adslot_gpid',
tid: 'tid_01',
data: {
browsi: {
browsiViewability: 'NA',
},
adserver: {
name: 'adserver_name',
adslot: 'adslot_name',
},
keywords: ['travel', 'sport'],
pbadslot: '202309999'
}
}
},
adUnitCode: 'regular_iframe',
transactionId: 'd163f9e2-7ecd-4c2c-a3bd-28ceb52a60ee',
sizes: [[300, 250]],
bidId: '276092a19e05eb',
bidderRequestId: '1fadae168708b',
auctionId: 'ff66e39e-4075-4d18-9854-56fde9b879ac',
src: 'client',
bidRequestsCount: 1,
bidderRequestsCount: 1,
bidderWinsCount: 0,
},
],
};

it('discovery:validate_pub_params', function () {
expect(
spec.isBidRequestValid({
Expand All @@ -93,6 +164,15 @@ describe('discovery:BidAdapterTests', function () {
).to.equal(true);
});

it('isBidRequestValid:no_params', function () {
expect(
spec.isBidRequestValid({
bidder: 'discovery',
params: {},
})
).to.equal(true);
});

it('discovery:validate_generated_params', function () {
request = spec.buildRequests(bidRequestData.bids, bidRequestData);
let req_data = JSON.parse(request.data);
Expand Down

0 comments on commit 379b687

Please sign in to comment.