Skip to content
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

Make default s2s ttl configurable #5419

Merged
merged 17 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from 13 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
3 changes: 2 additions & 1 deletion modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ const OPEN_RTB_PROTOCOL = {
bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY;

// TODO: Remove when prebid-server returns ttl and netRevenue
bidObject.ttl = (bid.ttl) ? bid.ttl : DEFAULT_S2S_TTL;
const configTtl = _s2sConfig.defaultS2sTtl || DEFAULT_S2S_TTL;
bidObject.ttl = (bid.ttl) ? bid.ttl : configTtl;
bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE;
bretg marked this conversation as resolved.
Show resolved Hide resolved

bids.push({ adUnit: bid.impid, bid: bidObject });
Expand Down
27 changes: 27 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,24 @@ describe('S2S Adapter', function () {
expect(response).to.have.property('cpm', 0.5);
expect(response).to.not.have.property('vastUrl');
expect(response).to.not.have.property('videoCacheKey');
expect(response).to.have.property('ttl', 60);
});

it('respects defaultS2sTtl', function () {
const s2sConfig = Object.assign({}, CONFIG, {
endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction',
defaultS2sTtl: 30
});
config.setConfig({ s2sConfig });

adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB));

sinon.assert.calledOnce(events.emit);
const event = events.emit.firstCall.args;
sinon.assert.calledOnce(addBidResponse);
const response = addBidResponse.firstCall.args[1];
expect(response).to.have.property('ttl', 30);
});

it('handles OpenRTB video responses', function () {
Expand Down Expand Up @@ -2155,6 +2173,15 @@ describe('S2S Adapter', function () {
})
});

it('should set default s2s ttl', function () {
config.setConfig({
s2sConfig: {
defaultS2sTtl: 30
}
});
expect(config.getConfig('s2sConfig').defaultS2sTtl).to.deep.equal(30);
});

it('should set syncUrlModifier', function () {
config.setConfig({
s2sConfig: {
Expand Down