Skip to content

Commit

Permalink
support setting coopSync in s2sConfig (prebid#6213)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Monday <mmonday@rubiconproject.com>
  • Loading branch information
msm0504 and Mark Monday authored Feb 1, 2021
1 parent f613117 commit 25dd35c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ function queueSync(bidderCodes, gdprConsent, uspConsent, s2sConfig) {
payload.us_privacy = uspConsent;
}

if (typeof _s2sConfig.coopSync === 'boolean') {
payload.coopSync = _s2sConfig.coopSync;
}

const jsonPayload = JSON.stringify(payload);
ajax(s2sConfig.syncEndpoint,
(response) => {
Expand Down
31 changes: 31 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2434,5 +2434,36 @@ describe('S2S Adapter', function () {
const requestBid = JSON.parse(server.requests[0].requestBody);
expect(requestBid.bidders).to.deep.equal(['appnexus', 'rubicon']);
});

it('should add cooperative sync flag to cookie_sync request if property is present', function () {
let cookieSyncConfig = utils.deepClone(CONFIG);
cookieSyncConfig.coopSync = false;
cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync';

let consentConfig = { s2sConfig: cookieSyncConfig };
config.setConfig(consentConfig);

let bidRequest = utils.deepClone(BID_REQUESTS);

adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax);
let requestBid = JSON.parse(server.requests[0].requestBody);

expect(requestBid.coopSync).to.equal(false);
});

it('should not add cooperative sync flag to cookie_sync request if property is not present', function () {
let cookieSyncConfig = utils.deepClone(CONFIG);
cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync';

let consentConfig = { s2sConfig: cookieSyncConfig };
config.setConfig(consentConfig);

let bidRequest = utils.deepClone(BID_REQUESTS);

adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax);
let requestBid = JSON.parse(server.requests[0].requestBody);

expect(requestBid.coopSync).to.be.undefined;
});
});
});

0 comments on commit 25dd35c

Please sign in to comment.