Skip to content

Adding Test mode for the IronSource bidder #5831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions modules/ironsourceBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ const SUPPORTED_AD_TYPES = [VIDEO];
const BIDDER_CODE = 'ironsource';
const BIDDER_VERSION = '4.0.0';
const TTL = 360;
const SELLER_ENDPOINT = 'https://hb.yellowblue.io/hb';
const SELLER_ENDPOINT = 'https://hb.yellowblue.io/';
const MODES = {
PRODUCTION: 'hb',
TEST: 'hb-test'
}
const SUPPORTED_SYNC_METHODS = {
IFRAME: 'iframe',
PIXEL: 'pixel'
Expand Down Expand Up @@ -86,9 +90,10 @@ registerBidder(spec);
*/
function buildVideoRequest(bid, bidderRequest) {
const sellerParams = generateParameters(bid, bidderRequest);
const {params} = bid;
return {
method: 'GET',
url: SELLER_ENDPOINT,
url: getEndpoint(params.testMode),
data: sellerParams
};
}
Expand Down Expand Up @@ -169,6 +174,17 @@ function isSyncMethodAllowed(syncRule, bidderCode) {
return isInclude && utils.contains(bidders, bidderCode);
}

/**
* Get the seller endpoint
* @param testMode {boolean}
* @returns {string}
*/
function getEndpoint(testMode) {
return testMode
? SELLER_ENDPOINT + MODES.TEST
: SELLER_ENDPOINT + MODES.PRODUCTION;
}

/**
* Generate query parameters for the request
* @param bid {bid}
Expand Down
2 changes: 2 additions & 0 deletions modules/ironsourceBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The adapter supports Video(instream). For the integration, IronSource returns co
| `isOrg` | required | String | IronSource publisher Id provided by your IronSource representative | "56f91cd4d3e3660002000033"
| `floorPrice` | optional | Number | Minimum price in USD. Misuse of this parameter can impact revenue | 2.00
| `ifa` | optional | String | The ID for advertisers (also referred to as "IDFA") | "XXX-XXX"
| `testMode` | optional | Boolean | This activates the test mode | false

# Test Parameters
```javascript
Expand All @@ -42,6 +43,7 @@ var adUnits = [
isOrg: '56f91cd4d3e3660002000033', // Required
floorPrice: 2.00, // Optional
ifa: 'XXX-XXX', // Optional
testMode: false // Optional
}
}]
}
Expand Down
24 changes: 24 additions & 0 deletions test/spec/modules/ironsourceBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { config } from 'src/config.js';
import { VIDEO } from '../../../src/mediaTypes.js';

const ENDPOINT = 'https://hb.yellowblue.io/hb';
const TEST_ENDPOINT = 'https://hb.yellowblue.io/hb-test';
const TTL = 360;

describe('ironsourceAdapter', function () {
Expand Down Expand Up @@ -55,6 +56,21 @@ describe('ironsourceAdapter', function () {
}
];

const testModeBidRequests = [
{
'bidder': spec.code,
'adUnitCode': 'adunit-code',
'sizes': [[640, 480]],
'params': {
'isOrg': 'jdye8weeyirk00000001',
'testMode': true
},
'bidId': '299ffc8cca0b87',
'bidderRequestId': '1144f487e563f9',
'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
}
];

const bidderRequest = {
bidderCode: 'ironsource',
}
Expand All @@ -67,6 +83,14 @@ describe('ironsourceAdapter', function () {
}
});

it('sends bid request to test ENDPOINT via GET', function () {
const requests = spec.buildRequests(testModeBidRequests, bidderRequest);
for (const request of requests) {
expect(request.url).to.equal(TEST_ENDPOINT);
expect(request.method).to.equal('GET');
}
});

it('should send the correct bid Id', function () {
const requests = spec.buildRequests(bidRequests, bidderRequest);
for (const request of requests) {
Expand Down