Skip to content

Commit

Permalink
Rubicon Adapter pchain support (#4480)
Browse files Browse the repository at this point in the history
* rubicon pchain support

* removed describe.only
  • Loading branch information
harpere authored Nov 19, 2019
1 parent 287bc33 commit f4c1980
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export const spec = {
.concat([
'tk_flint',
'x_source.tid',
'x_source.pchain',
'p_screen_res',
'rp_floor',
'rp_secure',
Expand Down Expand Up @@ -434,6 +435,7 @@ export const spec = {
'rp_secure': '1',
'tk_flint': `${configIntType || DEFAULT_INTEGRATION}_v$prebid.version$`,
'x_source.tid': bidRequest.transactionId,
'x_source.pchain': params.pchain,
'p_screen_res': _getScreenResolution(),
'kw': Array.isArray(params.keywords) ? params.keywords.join(',') : '',
'tk_user_key': params.userId,
Expand Down
15 changes: 13 additions & 2 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ describe('the rubicon adapter', function () {
accountId: '14062',
siteId: '70608',
zoneId: '335918',
pchain: 'GAM:11111-reseller1:22222',
userId: '12346',
keywords: ['a', 'b', 'c'],
inventory: {
Expand Down Expand Up @@ -360,7 +361,7 @@ describe('the rubicon adapter', function () {
describe('buildRequests implementation', function () {
describe('for requests', function () {
describe('to fastlane', function () {
it('should make a well-formed request objects', function () {
it('should make a well-formed request object', function () {
sandbox.stub(Math, 'random').callsFake(() => 0.1);
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let data = parseQuery(request.data);
Expand All @@ -379,6 +380,7 @@ describe('the rubicon adapter', function () {
'rand': '0.1',
'tk_flint': INTEGRATION,
'x_source.tid': 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b',
'x_source.pchain': 'GAM:11111-reseller1:22222',
'p_screen_res': /\d+x\d+/,
'tk_user_key': '12346',
'kw': 'a,b,c',
Expand Down Expand Up @@ -460,11 +462,20 @@ describe('the rubicon adapter', function () {
expect(data['p_pos']).to.equal('atf;;btf;;');
});

it('should not send x_source.pchain to AE if params.pchain is not specified', function() {
var noPchainRequest = utils.deepClone(bidderRequest);
delete noPchainRequest.bids[0].params.pchain;

let [request] = spec.buildRequests(noPchainRequest.bids, noPchainRequest);
expect(request.data).to.contain('&site_id=70608&');
expect(request.data).to.not.contain('x_source.pchain');
});

it('ad engine query params should be ordered correctly', function () {
sandbox.stub(Math, 'random').callsFake(() => 0.1);
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);

const referenceOrdering = ['account_id', 'site_id', 'zone_id', 'size_id', 'alt_size_ids', 'p_pos', 'rf', 'p_geo.latitude', 'p_geo.longitude', 'kw', 'tg_v.ucat', 'tg_v.lastsearch', 'tg_v.likes', 'tg_i.rating', 'tg_i.prodtype', 'tk_flint', 'x_source.tid', 'p_screen_res', 'rp_floor', 'rp_secure', 'tk_user_key', 'tg_fl.eid', 'slots', 'rand'];
const referenceOrdering = ['account_id', 'site_id', 'zone_id', 'size_id', 'alt_size_ids', 'p_pos', 'rf', 'p_geo.latitude', 'p_geo.longitude', 'kw', 'tg_v.ucat', 'tg_v.lastsearch', 'tg_v.likes', 'tg_i.rating', 'tg_i.prodtype', 'tk_flint', 'x_source.tid', 'x_source.pchain', 'p_screen_res', 'rp_floor', 'rp_secure', 'tk_user_key', 'tg_fl.eid', 'slots', 'rand'];

request.data.split('&').forEach((item, i) => {
expect(item.split('=')[0]).to.equal(referenceOrdering[i]);
Expand Down

0 comments on commit f4c1980

Please sign in to comment.