Skip to content

Commit

Permalink
TrustX Bid Adapter: convert all id-like request fields to a string (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
PWyrembak authored Sep 7, 2021
1 parent b4daf00 commit 5b87fdc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/trustxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ export const spec = {
}
}
let impObj = {
id: bidId,
id: bidId && bidId.toString(),
tagid: uid.toString(),
ext: {
divid: adUnitCode
divid: adUnitCode && adUnitCode.toString()
}
};

Expand Down Expand Up @@ -132,7 +132,7 @@ export const spec = {
});

const source = {
tid: auctionId,
tid: auctionId && auctionId.toString(),
ext: {
wrapper: 'Prebid_js',
wrapper_version: '$prebid.version$'
Expand All @@ -147,7 +147,7 @@ export const spec = {
const tmax = timeout ? Math.min(bidderTimeout, timeout) : bidderTimeout;

let request = {
id: bidderRequestId,
id: bidderRequestId && bidderRequestId.toString(),
site: {
page: referer
},
Expand Down
45 changes: 45 additions & 0 deletions test/spec/modules/trustxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,51 @@ describe('TrustXAdapter', function () {
expect(payload.tmax).to.equal(3000);
getConfigStub.restore();
});
it('all id like request fields must be a string', function () {
const bidderRequestWithNumId = Object.assign({}, bidderRequest, { bidderRequestId: 123123, auctionId: 345345543 });

let bidRequestWithNumId = {
'bidder': 'trustx',
'params': {
'uid': 43,
},
'adUnitCode': 111111,
'sizes': [[300, 250], [300, 600]],
'mediaTypes': {
'banner': {
'sizes': [[300, 250], [300, 600]]
}
},
'bidId': 23423423,
'bidderRequestId': 123123,
'auctionId': 345345543,
};

const request = spec.buildRequests([bidRequestWithNumId], bidderRequestWithNumId);
expect(request.data).to.be.an('string');
const payload = parseRequest(request.data);
expect(payload).to.deep.equal({
'id': '123123',
'site': {
'page': referrer
},
'tmax': bidderRequest.timeout,
'source': {
'tid': '345345543',
'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'}
},
'imp': [{
'id': '23423423',
'tagid': '43',
'ext': {'divid': '111111'},
'banner': {
'w': 300,
'h': 250,
'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}]
}
}]
});
});

describe('floorModule', function () {
const floorTestData = {
Expand Down

0 comments on commit 5b87fdc

Please sign in to comment.