Skip to content

Commit ab4f80a

Browse files
authored
Adding Test mode for the IronSource bidder (#5831)
* Change ironsource to be lower case all over code * Add test mode to the IronSource bidder
1 parent 7d27095 commit ab4f80a

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

modules/ironsourceBidAdapter.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ const SUPPORTED_AD_TYPES = [VIDEO];
77
const BIDDER_CODE = 'ironsource';
88
const BIDDER_VERSION = '4.0.0';
99
const TTL = 360;
10-
const SELLER_ENDPOINT = 'https://hb.yellowblue.io/hb';
10+
const SELLER_ENDPOINT = 'https://hb.yellowblue.io/';
11+
const MODES = {
12+
PRODUCTION: 'hb',
13+
TEST: 'hb-test'
14+
}
1115
const SUPPORTED_SYNC_METHODS = {
1216
IFRAME: 'iframe',
1317
PIXEL: 'pixel'
@@ -86,9 +90,10 @@ registerBidder(spec);
8690
*/
8791
function buildVideoRequest(bid, bidderRequest) {
8892
const sellerParams = generateParameters(bid, bidderRequest);
93+
const {params} = bid;
8994
return {
9095
method: 'GET',
91-
url: SELLER_ENDPOINT,
96+
url: getEndpoint(params.testMode),
9297
data: sellerParams
9398
};
9499
}
@@ -169,6 +174,17 @@ function isSyncMethodAllowed(syncRule, bidderCode) {
169174
return isInclude && utils.contains(bidders, bidderCode);
170175
}
171176

177+
/**
178+
* Get the seller endpoint
179+
* @param testMode {boolean}
180+
* @returns {string}
181+
*/
182+
function getEndpoint(testMode) {
183+
return testMode
184+
? SELLER_ENDPOINT + MODES.TEST
185+
: SELLER_ENDPOINT + MODES.PRODUCTION;
186+
}
187+
172188
/**
173189
* Generate query parameters for the request
174190
* @param bid {bid}

modules/ironsourceBidAdapter.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The adapter supports Video(instream). For the integration, IronSource returns co
2323
| `isOrg` | required | String | IronSource publisher Id provided by your IronSource representative | "56f91cd4d3e3660002000033"
2424
| `floorPrice` | optional | Number | Minimum price in USD. Misuse of this parameter can impact revenue | 2.00
2525
| `ifa` | optional | String | The ID for advertisers (also referred to as "IDFA") | "XXX-XXX"
26+
| `testMode` | optional | Boolean | This activates the test mode | false
2627

2728
# Test Parameters
2829
```javascript
@@ -42,6 +43,7 @@ var adUnits = [
4243
isOrg: '56f91cd4d3e3660002000033', // Required
4344
floorPrice: 2.00, // Optional
4445
ifa: 'XXX-XXX', // Optional
46+
testMode: false // Optional
4547
}
4648
}]
4749
}

test/spec/modules/ironsourceBidAdapter_spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { config } from 'src/config.js';
55
import { VIDEO } from '../../../src/mediaTypes.js';
66

77
const ENDPOINT = 'https://hb.yellowblue.io/hb';
8+
const TEST_ENDPOINT = 'https://hb.yellowblue.io/hb-test';
89
const TTL = 360;
910

1011
describe('ironsourceAdapter', function () {
@@ -55,6 +56,21 @@ describe('ironsourceAdapter', function () {
5556
}
5657
];
5758

59+
const testModeBidRequests = [
60+
{
61+
'bidder': spec.code,
62+
'adUnitCode': 'adunit-code',
63+
'sizes': [[640, 480]],
64+
'params': {
65+
'isOrg': 'jdye8weeyirk00000001',
66+
'testMode': true
67+
},
68+
'bidId': '299ffc8cca0b87',
69+
'bidderRequestId': '1144f487e563f9',
70+
'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
71+
}
72+
];
73+
5874
const bidderRequest = {
5975
bidderCode: 'ironsource',
6076
}
@@ -67,6 +83,14 @@ describe('ironsourceAdapter', function () {
6783
}
6884
});
6985

86+
it('sends bid request to test ENDPOINT via GET', function () {
87+
const requests = spec.buildRequests(testModeBidRequests, bidderRequest);
88+
for (const request of requests) {
89+
expect(request.url).to.equal(TEST_ENDPOINT);
90+
expect(request.method).to.equal('GET');
91+
}
92+
});
93+
7094
it('should send the correct bid Id', function () {
7195
const requests = spec.buildRequests(bidRequests, bidderRequest);
7296
for (const request of requests) {

0 commit comments

Comments
 (0)