Skip to content

Commit

Permalink
Sonobi Bid Adapter: added Coppa Flag check (#6631)
Browse files Browse the repository at this point in the history
* Sonobi - Added Coppa Flag check

* added unit test for sonobi coppa flag
  • Loading branch information
JonGoSonobi authored Apr 27, 2021
1 parent 960c669 commit d6a2ed7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions modules/sonobiBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 15 additions & 1 deletion test/spec/modules/sonobiBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d6a2ed7

Please sign in to comment.