diff --git a/modules/consumableBidAdapter.js b/modules/consumableBidAdapter.js index 5c34fbe8c64..9a5f5f4675b 100644 --- a/modules/consumableBidAdapter.js +++ b/modules/consumableBidAdapter.js @@ -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'; @@ -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({ diff --git a/test/spec/modules/consumableBidAdapter_spec.js b/test/spec/modules/consumableBidAdapter_spec.js index 23851c0da40..4e860cb771d 100644 --- a/test/spec/modules/consumableBidAdapter_spec.js +++ b/test/spec/modules/consumableBidAdapter_spec.js @@ -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 @@ -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 () {