Skip to content

Commit

Permalink
Added adjustment for aliasing unregistered bidders for server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
RRSchweitzer committed Oct 17, 2022
1 parent 5e18b2d commit 466c4ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ Object.assign(ORTB2.prototype, {
const bidder = adapterManager.bidderRegistry[bid.bidder];
// adding alias only if alias source bidder exists and alias isn't configured to be standalone
// pbs adapter
if (bidder && !bidder.getSpec().skipPbsAliasing) {
if (!bidder || !bidder.getSpec().skipPbsAliasing) {
aliases[bid.bidder] = adapterManager.aliasRegistry[bid.bidder];
}
}
Expand Down
25 changes: 25 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { auctionManager } from '../../../src/auctionManager.js';
import { stubAuctionIndex } from '../../helpers/indexStub.js';
import { registerBidder } from 'src/adapters/bidderFactory.js';
import {getGlobal} from '../../../src/prebidGlobal.js';
import { hasConsoleLogger } from '../../../src/utils.js';

let CONFIG = {
accountId: '1',
Expand Down Expand Up @@ -1466,6 +1467,30 @@ describe('S2S Adapter', function () {
});
});

it('unregistered bidder should alias', function () {
const adjustedConfig = utils.deepClone(CONFIG);
adjustedConfig.bidders = 'bidderD'
config.setConfig({ s2sConfig: adjustedConfig });

const aliasBidder = {
bidder: 'bidderD',
params: {
unit: '10433394',
}
};

$$PREBID_GLOBAL$$.aliasBidder('mockBidder', aliasBidder.bidder);

const request = utils.deepClone(REQUEST);
request.ad_units[0].bids = [aliasBidder];
request.s2sConfig = adjustedConfig;

adapter.callBids(request, BID_REQUESTS, addBidResponse, done, ajax);

const requestBid = JSON.parse(server.requests[0].requestBody);
expect(requestBid.ext.prebid.aliases).to.deep.equal({ bidderD: 'mockBidder' });
});

it('adds dynamic aliases to request', function () {
config.setConfig({ s2sConfig: CONFIG });

Expand Down

0 comments on commit 466c4ad

Please sign in to comment.