prebid.js 6.20.0 → 6.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/.circleci/config.yml +0 -1
  2. package/dist/33acrossBidAdapter.js +1 -1
  3. package/dist/adagioBidAdapter.js +1 -1
  4. package/dist/adbookpspBidAdapter.js +1 -1
  5. package/dist/adgenerationBidAdapter.js +1 -1
  6. package/dist/adomikAnalyticsAdapter.js +1 -1
  7. package/dist/adotBidAdapter.js +1 -1
  8. package/dist/adrelevantisBidAdapter.js +1 -1
  9. package/dist/adxcgBidAdapter.js +1 -1
  10. package/dist/ajaBidAdapter.js +1 -1
  11. package/dist/amxBidAdapter.js +1 -1
  12. package/dist/amxIdSystem.js +1 -1
  13. package/dist/apacdexBidAdapter.js +1 -1
  14. package/dist/appierAnalyticsAdapter.js +1 -1
  15. package/dist/appnexusBidAdapter.js +1 -1
  16. package/dist/asoBidAdapter.js +1 -1
  17. package/dist/audiencerunBidAdapter.js +1 -1
  18. package/dist/axonixBidAdapter.js +1 -1
  19. package/dist/betweenBidAdapter.js +1 -1
  20. package/dist/bidglassBidAdapter.js +1 -1
  21. package/dist/big-richmediaBidAdapter.js +1 -1
  22. package/dist/bridgewellBidAdapter.js +1 -1
  23. package/dist/brightMountainMediaBidAdapter.js +1 -1
  24. package/dist/cointrafficBidAdapter.js +1 -1
  25. package/dist/colossussspBidAdapter.js +1 -1
  26. package/dist/concertBidAdapter.js +1 -1
  27. package/dist/connectadBidAdapter.js +1 -1
  28. package/dist/consentManagement.js +1 -1
  29. package/dist/consentManagementUsp.js +1 -1
  30. package/dist/consumableBidAdapter.js +1 -1
  31. package/dist/conversantBidAdapter.js +1 -1
  32. package/dist/craftBidAdapter.js +1 -1
  33. package/dist/criteoBidAdapter.js +1 -1
  34. package/dist/dspxBidAdapter.js +1 -1
  35. package/dist/e_volutionBidAdapter.js +1 -1
  36. package/dist/eplanningBidAdapter.js +1 -1
  37. package/dist/ftrackIdSystem.js +1 -1
  38. package/dist/glimpseBidAdapter.js +1 -1
  39. package/dist/gmosspBidAdapter.js +1 -1
  40. package/dist/goldbachBidAdapter.js +1 -1
  41. package/dist/gridBidAdapter.js +1 -1
  42. package/dist/gridNMBidAdapter.js +1 -1
  43. package/dist/gumgumBidAdapter.js +1 -1
  44. package/dist/h12mediaBidAdapter.js +1 -1
  45. package/dist/id5IdSystem.js +1 -1
  46. package/dist/improvedigitalBidAdapter.js +1 -1
  47. package/dist/inmarBidAdapter.js +1 -1
  48. package/dist/insticatorBidAdapter.js +1 -1
  49. package/dist/ixBidAdapter.js +1 -1
  50. package/dist/justpremiumBidAdapter.js +1 -1
  51. package/dist/konduitAnalyticsAdapter.js +1 -1
  52. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  53. package/dist/logicadBidAdapter.js +1 -1
  54. package/dist/loglyliftBidAdapter.js +1 -1
  55. package/dist/malltvAnalyticsAdapter.js +1 -1
  56. package/dist/marsmediaBidAdapter.js +1 -1
  57. package/dist/mediafuseBidAdapter.js +1 -1
  58. package/dist/mediasquareBidAdapter.js +1 -1
  59. package/dist/mgidBidAdapter.js +1 -1
  60. package/dist/minutemediaBidAdapter.js +1 -1
  61. package/dist/mobfoxpbBidAdapter.js +1 -0
  62. package/dist/nextMillenniumBidAdapter.js +1 -1
  63. package/dist/nexx360BidAdapter.js +1 -1
  64. package/dist/not-for-prod/prebid.js +118 -117
  65. package/dist/oguryBidAdapter.js +1 -1
  66. package/dist/oneVideoBidAdapter.js +1 -1
  67. package/dist/onetagBidAdapter.js +1 -1
  68. package/dist/ooloAnalyticsAdapter.js +1 -1
  69. package/dist/otmBidAdapter.js +1 -1
  70. package/dist/outbrainBidAdapter.js +1 -1
  71. package/dist/parrableIdSystem.js +1 -1
  72. package/dist/pixfutureBidAdapter.js +1 -1
  73. package/dist/prebid-core.js +3 -3
  74. package/dist/prebidServerBidAdapter.js +1 -1
  75. package/dist/publinkIdSystem.js +1 -1
  76. package/dist/pubmaticBidAdapter.js +1 -1
  77. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  78. package/dist/pxyzBidAdapter.js +1 -1
  79. package/dist/quantcastBidAdapter.js +1 -1
  80. package/dist/readpeakBidAdapter.js +1 -1
  81. package/dist/relaidoBidAdapter.js +1 -1
  82. package/dist/rhythmoneBidAdapter.js +1 -1
  83. package/dist/riseBidAdapter.js +1 -1
  84. package/dist/rubiconAnalyticsAdapter.js +1 -1
  85. package/dist/rubiconBidAdapter.js +1 -1
  86. package/dist/seedingAllianceBidAdapter.js +1 -1
  87. package/dist/seedtagBidAdapter.js +1 -1
  88. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  89. package/dist/sharethroughBidAdapter.js +1 -1
  90. package/dist/smaatoBidAdapter.js +1 -1
  91. package/dist/smartadserverBidAdapter.js +1 -1
  92. package/dist/smartxBidAdapter.js +1 -1
  93. package/dist/smilewantedBidAdapter.js +1 -1
  94. package/dist/sonobiBidAdapter.js +1 -1
  95. package/dist/sortableBidAdapter.js +1 -1
  96. package/dist/sovrnAnalyticsAdapter.js +1 -1
  97. package/dist/sovrnBidAdapter.js +1 -1
  98. package/dist/sspBCBidAdapter.js +1 -1
  99. package/dist/sublimeBidAdapter.js +1 -1
  100. package/dist/synacormediaBidAdapter.js +1 -1
  101. package/dist/targetVideoBidAdapter.js +1 -1
  102. package/dist/teadsBidAdapter.js +1 -1
  103. package/dist/trionBidAdapter.js +1 -1
  104. package/dist/tripleliftBidAdapter.js +1 -1
  105. package/dist/trustxBidAdapter.js +1 -1
  106. package/dist/ttdBidAdapter.js +1 -1
  107. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  108. package/dist/underdogmediaBidAdapter.js +1 -1
  109. package/dist/undertoneBidAdapter.js +1 -1
  110. package/dist/vidazooBidAdapter.js +1 -1
  111. package/dist/videobyteBidAdapter.js +1 -1
  112. package/dist/visxBidAdapter.js +1 -1
  113. package/dist/vuukleBidAdapter.js +1 -1
  114. package/dist/widespaceBidAdapter.js +1 -1
  115. package/dist/winrBidAdapter.js +1 -1
  116. package/dist/yahoosspBidAdapter.js +1 -1
  117. package/dist/yieldmoBidAdapter.js +1 -1
  118. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  119. package/modules/adomikAnalyticsAdapter.js +67 -43
  120. package/modules/adotBidAdapter.js +1 -1
  121. package/modules/apacdexBidAdapter.js +52 -41
  122. package/modules/audiencerunBidAdapter.js +75 -22
  123. package/modules/betweenBidAdapter.js +1 -1
  124. package/modules/cointrafficBidAdapter.js +1 -1
  125. package/modules/colossussspBidAdapter.js +5 -1
  126. package/modules/consentManagement.js +4 -4
  127. package/modules/consentManagementUsp.js +2 -2
  128. package/modules/e_volutionBidAdapter.js +19 -1
  129. package/modules/ftrackIdSystem.js +16 -2
  130. package/modules/ftrackIdSystem.md +12 -1
  131. package/modules/malltvAnalyticsAdapter.js +1 -1
  132. package/modules/mobfoxpbBidAdapter.js +135 -0
  133. package/modules/mobfoxpbBidAdapter.md +3 -3
  134. package/modules/nextMillenniumBidAdapter.js +6 -2
  135. package/modules/nexx360BidAdapter.js +14 -4
  136. package/modules/otmBidAdapter.js +43 -35
  137. package/modules/prebidServerBidAdapter/index.js +58 -14
  138. package/modules/pubmaticBidAdapter.js +34 -2
  139. package/modules/seedingAllianceBidAdapter.js +8 -4
  140. package/package.json +1 -1
  141. package/src/adapters/bidderFactory.js +17 -0
  142. package/src/auction.js +1 -7
  143. package/test/spec/auctionmanager_spec.js +2 -0
  144. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +133 -33
  145. package/test/spec/modules/adotBidAdapter_spec.js +1 -1
  146. package/test/spec/modules/apacdexBidAdapter_spec.js +6 -6
  147. package/test/spec/modules/audiencerunBidAdapter_spec.js +185 -97
  148. package/test/spec/modules/cointrafficBidAdapter_spec.js +1 -1
  149. package/test/spec/modules/colossussspBidAdapter_spec.js +97 -3
  150. package/test/spec/modules/consentManagementUsp_spec.js +1 -0
  151. package/test/spec/modules/consentManagement_spec.js +22 -0
  152. package/test/spec/modules/e_volutionBidAdapter_spec.js +67 -10
  153. package/test/spec/modules/ftrackIdSystem_spec.js +75 -1
  154. package/test/spec/modules/mobfoxpbBidAdapter_spec.js +307 -0
  155. package/test/spec/modules/nexx360BidAdapter_spec.js +49 -0
  156. package/test/spec/modules/otmBidAdapter_spec.js +32 -11
  157. package/test/spec/modules/prebidServerBidAdapter_spec.js +200 -0
  158. package/test/spec/modules/pubmaticBidAdapter_spec.js +129 -0
  159. package/test/spec/unit/core/bidderFactory_spec.js +137 -0
@@ -18,6 +18,7 @@ import { decorateAdUnitsWithNativeParams } from '../../../src/native.js';
18
18
  import { auctionManager } from '../../../src/auctionManager.js';
19
19
  import { stubAuctionIndex } from '../../helpers/indexStub.js';
20
20
  import { registerBidder } from 'src/adapters/bidderFactory.js';
21
+ import {getGlobal} from '../../../src/prebidGlobal.js';
21
22
 
22
23
  let CONFIG = {
23
24
  accountId: '1',
@@ -1038,6 +1039,205 @@ describe('S2S Adapter', function () {
1038
1039
  })
1039
1040
  ).to.be.true;
1040
1041
  });
1042
+
1043
+ it('should find the floor when not all bidderRequests contain it', () => {
1044
+ config.setConfig({
1045
+ s2sConfig: {
1046
+ ...CONFIG,
1047
+ bidders: ['b1', 'b2']
1048
+ },
1049
+ });
1050
+ const bidderRequests = [
1051
+ {
1052
+ ...BID_REQUESTS[0],
1053
+ bidderCode: 'b1',
1054
+ bids: [{
1055
+ bidder: 'b1',
1056
+ bidId: 1,
1057
+ }]
1058
+ },
1059
+ {
1060
+ ...BID_REQUESTS[0],
1061
+ bidderCode: 'b2',
1062
+ bids: [{
1063
+ bidder: 'b2',
1064
+ bidId: 2,
1065
+ getFloor: () => ({
1066
+ currency: 'CUR',
1067
+ floor: 123
1068
+ })
1069
+ }],
1070
+ }
1071
+ ];
1072
+ const adUnits = [
1073
+ {
1074
+ code: 'au1',
1075
+ transactionId: 't1',
1076
+ mediaTypes: {
1077
+ banner: {sizes: [1, 1]}
1078
+ },
1079
+ bids: [{bidder: 'b1', bid_id: 1}]
1080
+ },
1081
+ {
1082
+ code: 'au2',
1083
+ transactionId: 't2',
1084
+ bids: [{bidder: 'b2', bid_id: 2}],
1085
+ mediaTypes: {
1086
+ banner: {sizes: [1, 1]}
1087
+ }
1088
+ }
1089
+ ];
1090
+ const s2sReq = {
1091
+ ...REQUEST,
1092
+ ad_units: adUnits
1093
+ }
1094
+
1095
+ adapter.callBids(s2sReq, bidderRequests, addBidResponse, done, ajax);
1096
+
1097
+ const pbsReq = JSON.parse(server.requests[server.requests.length - 1].requestBody);
1098
+ const [imp1, imp2] = pbsReq.imp;
1099
+
1100
+ expect(imp1.bidfloor).to.be.undefined;
1101
+ expect(imp1.bidfloorcur).to.be.undefined;
1102
+
1103
+ expect(imp2.bidfloor).to.eql(123);
1104
+ expect(imp2.bidfloorcur).to.eql('CUR');
1105
+ });
1106
+
1107
+ describe('when different bids have different floors', () => {
1108
+ let s2sReq;
1109
+ beforeEach(() => {
1110
+ config.setConfig({
1111
+ s2sConfig: {
1112
+ ...CONFIG,
1113
+ bidders: ['b1', 'b2', 'b3']
1114
+ },
1115
+ });
1116
+ BID_REQUESTS = [
1117
+ {
1118
+ ...BID_REQUESTS[0],
1119
+ bidderCode: 'b2',
1120
+ bids: [{
1121
+ bidder: 'b2',
1122
+ bidId: 2,
1123
+ getFloor: () => ({
1124
+ currency: '1',
1125
+ floor: 2
1126
+ })
1127
+ }],
1128
+ },
1129
+ {
1130
+ ...BID_REQUESTS[0],
1131
+ bidderCode: 'b1',
1132
+ bids: [{
1133
+ bidder: 'b1',
1134
+ bidId: 1,
1135
+ getFloor: () => ({
1136
+ floor: 10,
1137
+ currency: '0.1'
1138
+ })
1139
+ }]
1140
+ },
1141
+ {
1142
+ ...BID_REQUESTS[0],
1143
+ bidderCode: 'b3',
1144
+ bids: [{
1145
+ bidder: 'b3',
1146
+ bidId: 3,
1147
+ getFloor: () => ({
1148
+ currency: '10',
1149
+ floor: 1
1150
+ })
1151
+ }],
1152
+ }
1153
+ ];
1154
+ s2sReq = {
1155
+ ...REQUEST,
1156
+ ad_units: [
1157
+ {
1158
+ code: 'au1',
1159
+ transactionId: 't1',
1160
+ mediaTypes: {
1161
+ banner: {sizes: [1, 1]}
1162
+ },
1163
+ bids: [
1164
+ {bidder: 'b2', bid_id: 2},
1165
+ {bidder: 'b3', bid_id: 3},
1166
+ {bidder: 'b1', bid_id: 1},
1167
+ ]
1168
+ }
1169
+ ]
1170
+ };
1171
+ });
1172
+
1173
+ Object.entries({
1174
+ 'cannot compute a floor': (bid) => { bid.getFloor = () => { throw new Error() } },
1175
+ 'does not set a floor': (bid) => { delete bid.getFloor; },
1176
+ }).forEach(([t, updateBid]) => {
1177
+ it(`should not set pricefloor if any one of them ${t}`, () => {
1178
+ updateBid(BID_REQUESTS[1].bids[0]);
1179
+ adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax);
1180
+ const pbsReq = JSON.parse(server.requests[server.requests.length - 1].requestBody);
1181
+ expect(pbsReq.imp[0].bidfloor).to.be.undefined;
1182
+ expect(pbsReq.imp[0].bidfloorcur).to.be.undefined;
1183
+ });
1184
+ })
1185
+
1186
+ Object.entries({
1187
+ 'is available': {
1188
+ expectDesc: 'minimum after conversion',
1189
+ expectedFloor: 10,
1190
+ expectedCur: '0.1',
1191
+ conversionFn: (amount, from, to) => {
1192
+ from = parseFloat(from);
1193
+ to = parseFloat(to);
1194
+ return amount * from / to;
1195
+ },
1196
+ },
1197
+ 'is not available': {
1198
+ expectDesc: 'absolute minimum',
1199
+ expectedFloor: 1,
1200
+ expectedCur: '10',
1201
+ conversionFn: null
1202
+ },
1203
+ 'is not working': {
1204
+ expectDesc: 'first',
1205
+ expectedFloor: 2,
1206
+ expectedCur: '1',
1207
+ conversionFn: () => {
1208
+ throw new Error();
1209
+ }
1210
+ }
1211
+ }).forEach(([t, {expectDesc, expectedFloor, expectedCur, conversionFn}]) => {
1212
+ describe(`and currency conversion ${t}`, () => {
1213
+ let mockConvertCurrency;
1214
+ const origConvertCurrency = getGlobal().convertCurrency;
1215
+ beforeEach(() => {
1216
+ if (conversionFn) {
1217
+ getGlobal().convertCurrency = mockConvertCurrency = sinon.stub().callsFake(conversionFn)
1218
+ } else {
1219
+ mockConvertCurrency = null;
1220
+ delete getGlobal().convertCurrency;
1221
+ }
1222
+ });
1223
+
1224
+ afterEach(() => {
1225
+ if (origConvertCurrency != null) {
1226
+ getGlobal().convertCurrency = origConvertCurrency;
1227
+ } else {
1228
+ delete getGlobal().convertCurrency;
1229
+ }
1230
+ })
1231
+
1232
+ it(`should pick the ${expectDesc}`, () => {
1233
+ adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax);
1234
+ const pbsReq = JSON.parse(server.requests[server.requests.length - 1].requestBody);
1235
+ expect(pbsReq.imp[0].bidfloor).to.eql(expectedFloor);
1236
+ expect(pbsReq.imp[0].bidfloorcur).to.eql(expectedCur);
1237
+ });
1238
+ });
1239
+ });
1240
+ });
1041
1241
  });
1042
1242
 
1043
1243
  it('adds device.w and device.h even if the config lacks a device object', function () {
@@ -3130,6 +3130,115 @@ describe('PubMatic adapter', function () {
3130
3130
  });
3131
3131
  });
3132
3132
 
3133
+ describe('Request param acat checking', function() {
3134
+ let multipleBidRequests = [
3135
+ {
3136
+ bidder: 'pubmatic',
3137
+ params: {
3138
+ publisherId: '301',
3139
+ adSlot: '/15671365/DMDemo@300x250:0',
3140
+ kadfloor: '1.2',
3141
+ pmzoneid: 'aabc, ddef',
3142
+ kadpageurl: 'www.publisher.com',
3143
+ yob: '1986',
3144
+ gender: 'M',
3145
+ lat: '12.3',
3146
+ lon: '23.7',
3147
+ wiid: '1234567890',
3148
+ profId: '100',
3149
+ verId: '200',
3150
+ currency: 'AUD',
3151
+ dctr: 'key1=val1|key2=val2,!val3'
3152
+ },
3153
+ placementCode: '/19968336/header-bid-tag-1',
3154
+ sizes: [[300, 250], [300, 600]],
3155
+ bidId: '23acc48ad47af5',
3156
+ requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
3157
+ bidderRequestId: '1c56ad30b9b8ca8',
3158
+ transactionId: '92489f71-1bf2-49a0-adf9-000cea934729'
3159
+ },
3160
+ {
3161
+ bidder: 'pubmatic',
3162
+ params: {
3163
+ publisherId: '301',
3164
+ adSlot: '/15671365/DMDemo@300x250:0',
3165
+ kadfloor: '1.2',
3166
+ pmzoneid: 'aabc, ddef',
3167
+ kadpageurl: 'www.publisher.com',
3168
+ yob: '1986',
3169
+ gender: 'M',
3170
+ lat: '12.3',
3171
+ lon: '23.7',
3172
+ wiid: '1234567890',
3173
+ profId: '100',
3174
+ verId: '200',
3175
+ currency: 'GBP',
3176
+ dctr: 'key1=val3|key2=val1,!val3|key3=val123'
3177
+ },
3178
+ placementCode: '/19968336/header-bid-tag-1',
3179
+ sizes: [[300, 250], [300, 600]],
3180
+ bidId: '23acc48ad47af5',
3181
+ requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
3182
+ bidderRequestId: '1c56ad30b9b8ca8',
3183
+ transactionId: '92489f71-1bf2-49a0-adf9-000cea934729'
3184
+ }
3185
+ ];
3186
+
3187
+ it('acat: pass only strings', function() {
3188
+ multipleBidRequests[0].params.acat = [1, 2, 3, 'IAB1', 'IAB2'];
3189
+ let request = spec.buildRequests(multipleBidRequests, {
3190
+ auctionId: 'new-auction-id'
3191
+ });
3192
+ let data = JSON.parse(request.data);
3193
+ expect(data.ext.acat).to.exist.and.to.deep.equal(['IAB1', 'IAB2']);
3194
+ });
3195
+
3196
+ it('acat: trim the strings', function() {
3197
+ multipleBidRequests[0].params.acat = [' IAB1 ', ' IAB2 '];
3198
+ let request = spec.buildRequests(multipleBidRequests, {
3199
+ auctionId: 'new-auction-id'
3200
+ });
3201
+ let data = JSON.parse(request.data);
3202
+ expect(data.ext.acat).to.exist.and.to.deep.equal(['IAB1', 'IAB2']);
3203
+ });
3204
+
3205
+ it('acat: pass only unique strings', function() {
3206
+ multipleBidRequests[0].params.acat = ['IAB1', 'IAB2', 'IAB1', 'IAB2', 'IAB1', 'IAB2'];
3207
+ multipleBidRequests[1].params.acat = ['IAB1', 'IAB2', 'IAB1', 'IAB2', 'IAB1', 'IAB3'];
3208
+ let request = spec.buildRequests(multipleBidRequests, {
3209
+ auctionId: 'new-auction-id'
3210
+ });
3211
+ let data = JSON.parse(request.data);
3212
+ expect(data.ext.acat).to.exist.and.to.deep.equal(['IAB1', 'IAB2', 'IAB3']);
3213
+ });
3214
+ it('ortb2.ext.prebid.bidderparams.pubmatic.acat should be passed in request payload', function() {
3215
+ let sandbox = sinon.sandbox.create();
3216
+ sandbox.stub(config, 'getConfig').callsFake(key => {
3217
+ const config = {
3218
+ 'ortb2': {
3219
+ ext: {
3220
+ prebid: {
3221
+ bidderparams: {
3222
+ pubmatic: {
3223
+ acat: ['IAB1', 'IAB2', 'IAB1', 'IAB2', 'IAB1', 'IAB2']
3224
+ }
3225
+ }
3226
+ }
3227
+ }
3228
+ }
3229
+ };
3230
+ return config[key];
3231
+ });
3232
+ const request = spec.buildRequests(bidRequests, {
3233
+ auctionId: 'new-auction-id',
3234
+ bidderCode: 'pubmatic'
3235
+ });
3236
+ let data = JSON.parse(request.data);
3237
+ expect(data.ext.acat).to.deep.equal(['IAB1', 'IAB2']);
3238
+ sandbox.restore();
3239
+ });
3240
+ });
3241
+
3133
3242
  describe('Request param bcat checking', function() {
3134
3243
  let multipleBidRequests = [
3135
3244
  {
@@ -3231,6 +3340,26 @@ describe('PubMatic adapter', function () {
3231
3340
  });
3232
3341
  let data = JSON.parse(request.data);
3233
3342
  expect(data.bcat).to.deep.equal(undefined);
3343
+ });
3344
+
3345
+ it('ortb2.bcat should merged with slot level bcat param', function() {
3346
+ multipleBidRequests[0].params.bcat = ['IAB-1', 'IAB-2'];
3347
+ let sandbox = sinon.sandbox.create();
3348
+ sandbox.stub(config, 'getConfig').callsFake(key => {
3349
+ const config = {
3350
+ 'ortb2': {
3351
+ bcat: ['IAB-3', 'IAB-4']
3352
+ }
3353
+ };
3354
+ return config[key];
3355
+ });
3356
+ const request = spec.buildRequests(multipleBidRequests, {
3357
+ auctionId: 'new-auction-id',
3358
+ bidderCode: 'pubmatic'
3359
+ });
3360
+ let data = JSON.parse(request.data);
3361
+ expect(data.bcat).to.deep.equal(['IAB-1', 'IAB-2', 'IAB-3', 'IAB-4']);
3362
+ sandbox.restore();
3234
3363
  });
3235
3364
  });
3236
3365
 
@@ -11,6 +11,7 @@ import * as events from 'src/events.js';
11
11
  import {hook} from '../../../../src/hook.js';
12
12
  import {auctionManager} from '../../../../src/auctionManager.js';
13
13
  import {stubAuctionIndex} from '../../../helpers/indexStub.js';
14
+ import { bidderSettings } from '../../../../src/bidderSettings.js';
14
15
 
15
16
  const CODE = 'sampleBidder';
16
17
  const MOCK_BIDS_REQUEST = {
@@ -1022,6 +1023,142 @@ describe('validate bid response: ', function () {
1022
1023
  expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement');
1023
1024
  expect(logErrorSpy.callCount).to.equal(0);
1024
1025
  });
1026
+
1027
+ describe(' Check for alternateBiddersList ', function() {
1028
+ let bidRequest;
1029
+ let bids1;
1030
+ let logWarnSpy;
1031
+ let bidderSettingStub, aliasRegistryStub;
1032
+ let aliasRegistry;
1033
+
1034
+ beforeEach(function () {
1035
+ bidRequest = {
1036
+ bids: [{
1037
+ bidId: '1',
1038
+ bidder: CODE,
1039
+ auctionId: 'first-bid-id',
1040
+ adUnitCode: 'mock/placement',
1041
+ transactionId: 'au',
1042
+ }]
1043
+ };
1044
+
1045
+ bids1 = Object.assign({},
1046
+ bids[0],
1047
+ {
1048
+ bidderCode: 'validAlternateBidder',
1049
+ adapterCode: 'knownAdapter1'
1050
+ }
1051
+ );
1052
+ logWarnSpy = sinon.spy(utils, 'logWarn');
1053
+ bidderSettingStub = sinon.stub(bidderSettings, 'get');
1054
+ aliasRegistry = {};
1055
+ aliasRegistryStub = sinon.stub(adapterManager, 'aliasRegistry');
1056
+ aliasRegistryStub.get(() => aliasRegistry);
1057
+ });
1058
+
1059
+ afterEach(function () {
1060
+ logWarnSpy.restore();
1061
+ bidderSettingStub.restore();
1062
+ aliasRegistryStub.restore();
1063
+ });
1064
+
1065
+ it('should log warning when bidder is unknown and allowAlternateBidderCodes flag is false', function () {
1066
+ bidderSettingStub.returns(false);
1067
+
1068
+ const bidder = newBidder(spec);
1069
+ spec.interpretResponse.returns(bids1);
1070
+ bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
1071
+
1072
+ expect(addBidResponseStub.calledOnce).to.equal(false);
1073
+ expect(logWarnSpy.callCount).to.equal(1);
1074
+ });
1075
+
1076
+ it('should accept the bid, when allowAlternateBidderCodes flag is undefined (default should be true)', function () {
1077
+ bidderSettingStub.returns(undefined);
1078
+
1079
+ const bidder = newBidder(spec);
1080
+ spec.interpretResponse.returns(bids1);
1081
+ bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
1082
+
1083
+ expect(addBidResponseStub.calledOnce).to.equal(true);
1084
+ expect(logWarnSpy.callCount).to.equal(0);
1085
+ expect(logErrorSpy.callCount).to.equal(0);
1086
+ });
1087
+
1088
+ it('should log warning when the particular bidder is not specified in allowedAlternateBidderCodes and allowAlternateBidderCodes flag is true', function () {
1089
+ bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true);
1090
+ bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns(['invalidAlternateBidder02']);
1091
+
1092
+ const bidder = newBidder(spec);
1093
+ spec.interpretResponse.returns(bids1);
1094
+ bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
1095
+
1096
+ expect(addBidResponseStub.calledOnce).to.equal(false);
1097
+ expect(logWarnSpy.callCount).to.equal(1);
1098
+ });
1099
+
1100
+ it('should accept the bid, when allowedAlternateBidderCodes is empty and allowAlternateBidderCodes flag is true', function () {
1101
+ bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true);
1102
+ bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns();
1103
+
1104
+ const bidder = newBidder(spec);
1105
+ spec.interpretResponse.returns(bids1);
1106
+ bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
1107
+
1108
+ expect(addBidResponseStub.calledOnce).to.equal(true);
1109
+ expect(logWarnSpy.callCount).to.equal(0);
1110
+ expect(logErrorSpy.callCount).to.equal(0);
1111
+ });
1112
+
1113
+ it('should accept the bid, when allowedAlternateBidderCodes is marked as * and allowAlternateBidderCodes flag is true', function () {
1114
+ bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true);
1115
+ bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns(['*']);
1116
+
1117
+ const bidder = newBidder(spec);
1118
+ spec.interpretResponse.returns(bids1);
1119
+ bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
1120
+
1121
+ expect(addBidResponseStub.calledOnce).to.equal(true);
1122
+ expect(logWarnSpy.callCount).to.equal(0);
1123
+ expect(logErrorSpy.callCount).to.equal(0);
1124
+ });
1125
+
1126
+ it('should accept the bid, when allowedAlternateBidderCodes contains bidder name and allowAlternateBidderCodes flag is true', function () {
1127
+ bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true);
1128
+ bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns(['validAlternateBidder']);
1129
+
1130
+ const bidder = newBidder(spec);
1131
+ spec.interpretResponse.returns(bids1);
1132
+ bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
1133
+
1134
+ expect(addBidResponseStub.calledOnce).to.equal(true);
1135
+ expect(logWarnSpy.callCount).to.equal(0);
1136
+ expect(logErrorSpy.callCount).to.equal(0);
1137
+ });
1138
+
1139
+ it('should not accept the bid, when bidder is an alias but bidderSetting is missing for the bidder. It should fallback to standard setting and reject the bid', function () {
1140
+ bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(false);
1141
+ aliasRegistry = {'validAlternateBidder': CODE};
1142
+
1143
+ const bidder = newBidder(spec);
1144
+ spec.interpretResponse.returns(bids1);
1145
+ bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
1146
+
1147
+ expect(addBidResponseStub.calledOnce).to.equal(false);
1148
+ expect(logWarnSpy.callCount).to.equal(1);
1149
+ });
1150
+
1151
+ it('should not accept the bid, when bidderSetting is missing for the bidder. It should fallback to standard setting and reject the bid', function () {
1152
+ bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(false);
1153
+
1154
+ const bidder = newBidder(spec);
1155
+ spec.interpretResponse.returns(bids1);
1156
+ bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
1157
+
1158
+ expect(addBidResponseStub.calledOnce).to.equal(false);
1159
+ expect(logWarnSpy.callCount).to.equal(1);
1160
+ });
1161
+ })
1025
1162
  });
1026
1163
 
1027
1164
  describe('preload mapping url hook', function() {