From d6a2ed7d151ca31e81fe2e6e61c61aec96c165a0 Mon Sep 17 00:00:00 2001 From: JonGoSonobi Date: Mon, 26 Apr 2021 21:18:53 -0400 Subject: [PATCH] Sonobi Bid Adapter: added Coppa Flag check (#6631) * Sonobi - Added Coppa Flag check * added unit test for sonobi coppa flag --- modules/sonobiBidAdapter.js | 6 ++++++ test/spec/modules/sonobiBidAdapter_spec.js | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 0e4bfb37829..e5bd76eba9f 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -140,6 +140,12 @@ export const spec = { payload.us_privacy = bidderRequest.uspConsent; } + if (config.getConfig('coppa') === true) { + payload.coppa = 1; + } else { + payload.coppa = 0; + } + // If there is no key_maker data, then don't make the request. if (isEmpty(data)) { return null; diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index d1ac200394c..0314ffb71c1 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -2,10 +2,10 @@ import { expect } from 'chai' import { spec, _getPlatform } from 'modules/sonobiBidAdapter.js' import { newBidder } from 'src/adapters/bidderFactory.js' import {userSync} from '../../../src/userSync.js'; +import { config } from 'src/config.js'; describe('SonobiBidAdapter', function () { const adapter = newBidder(spec) - describe('.code', function () { it('should return a bidder code of sonobi', function () { expect(spec.code).to.equal('sonobi') @@ -304,6 +304,20 @@ describe('SonobiBidAdapter', function () { uspConsent: 'someCCPAString' }; + it('should populate coppa as 1 if set in config', function () { + config.setConfig({coppa: true}); + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + + expect(bidRequests.data.coppa).to.equal(1); + }); + + it('should populate coppa as 0 if set in config', function () { + config.setConfig({coppa: false}); + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + + expect(bidRequests.data.coppa).to.equal(0); + }); + it('should return a properly formatted request', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests) const bidRequestsPageViewID = spec.buildRequests(bidRequest, bidderRequests)