Skip to content

Commit

Permalink
Add coppa support for AppNexus adapter (prebid#4253)
Browse files Browse the repository at this point in the history
* Add coppa support for AppNexus adapter

* test name
  • Loading branch information
mkendall07 authored and Mike Chowla committed Oct 3, 2019
1 parent 976718f commit 1aecd87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ export const spec = {
buildRequests: function(bidRequests, bidderRequest) {
const tags = bidRequests.map(bidToTag);
const userObjBid = find(bidRequests, hasUserInfo);
let userObj;
let userObj = {};
if (config.getConfig('coppa') === true) {
userObj = {'coppa': true};
}
if (userObjBid) {
userObj = {};
Object.keys(userObjBid.params.user)
.filter(param => includes(USER_PARAMS, param))
.forEach(param => userObj[param] = userObjBid.params.user[param]);
Expand Down
14 changes: 14 additions & 0 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,20 @@ describe('AppNexusAdapter', function () {
]
});
});

it('should populate coppa if set in config', function () {
let bidRequest = Object.assign({}, bidRequests[0]);
sinon.stub(config, 'getConfig')
.withArgs('coppa')
.returns(true);

const request = spec.buildRequests([bidRequest]);
const payload = JSON.parse(request.data);

expect(payload.user.coppa).to.equal(true);

config.getConfig.restore();
});
})

describe('interpretResponse', function () {
Expand Down

0 comments on commit 1aecd87

Please sign in to comment.