Skip to content

Commit

Permalink
consumableBidAdapter - add schain and coppa support (prebid#8703)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpiros authored and jorgeluisrocha committed May 18, 2023
1 parent 8176519 commit 5df845e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
9 changes: 9 additions & 0 deletions modules/consumableBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { logWarn, createTrackPixelHtml, deepAccess, isArray, deepSetValue } from '../src/utils.js';
import {config} from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'consumable';
Expand Down Expand Up @@ -66,6 +67,14 @@ export const spec = {
data.ccpa = bidderRequest.uspConsent;
}

if (bidderRequest && bidderRequest.schain) {
data.schain = bidderRequest.schain;
}

if (config.getConfig('coppa')) {
data.coppa = true;
}

validBidRequests.map(bid => {
const sizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes || [];
const placement = Object.assign({
Expand Down
48 changes: 47 additions & 1 deletion test/spec/modules/consumableBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ const BIDDER_REQUEST_1 = {
transactionId: '92489f71-1bf2-49a0-adf9-000cea934729'
}
],
schain: {
'ver': '1.0',
'complete': 1,
'nodes': [
{
'asi': 'indirectseller.com',
'sid': '00001',
'hp': 1
},
{
'asi': 'indirectseller-2.com',
'sid': '00002',
'hp': 2
},
]
},
gdprConsent: {
consentString: 'consent-test',
gdprApplies: false
Expand Down Expand Up @@ -335,7 +351,37 @@ describe('Consumable BidAdapter', function () {
let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);

expect(request.bidderRequest).to.equal(BIDDER_REQUEST_1);
})
});

it('should contain schain if it exists in the bidRequest', function () {
let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
let data = JSON.parse(request.data);

expect(data.schain).to.deep.equal(BIDDER_REQUEST_1.schain)
});

it('should not contain schain if it does not exist in the bidRequest', function () {
let request = spec.buildRequests(BIDDER_REQUEST_2.bidRequest, BIDDER_REQUEST_2);
let data = JSON.parse(request.data);

expect(data.schain).to.be.undefined;
});

it('should contain coppa if configured', function () {
config.setConfig({ coppa: true });
let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
let data = JSON.parse(request.data);

expect(data.coppa).to.be.true;
});

it('should not contain coppa if not configured', function () {
config.setConfig({ coppa: false });
let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
let data = JSON.parse(request.data);

expect(data.coppa).to.be.undefined;
});
});
describe('interpretResponse validation', function () {
it('response should have valid bidderCode', function () {
Expand Down

0 comments on commit 5df845e

Please sign in to comment.