Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BizzClick Bid Adapter: add at, ccpa, gdpr and coppa support #6405

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions modules/bizzclickBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ export const spec = {
let data = {
id: bidRequest.bidId,
test: config.getConfig('debug') ? 1 : 0,
at: 1,
cur: ['USD'],
device: {
w: winTop.screen.width,
h: winTop.screen.height,
dnt: utils.getDNT() ? 1 : 0,
language: (navigator && navigator.language) ? navigator.language.indexOf('-') != -1 ? navigator.language.split('-')[0] : navigator.language : '',
},
site: {
Expand All @@ -94,9 +96,26 @@ export const spec = {
source: {
tid: bidRequest.transactionId
},
regs: {
coppa: config.getConfig('coppa') === true ? 1 : 0,
ext: {}
},
user: {
ext: {}
},
tmax: bidRequest.timeout,
imp: [impObject],
};
if (bidRequest) {
if (bidRequest.gdprConsent && bidRequest.gdprConsent.gdprApplies) {
utils.deepSetValue(data, 'regs.ext.gdpr', bidRequest.gdprConsent.gdprApplies ? 1 : 0);
utils.deepSetValue(data, 'user.ext.consent', bidRequest.gdprConsent.consentString);
}

if (bidRequest.uspConsent !== undefined) {
utils.deepSetValue(data, 'regs.ext.us_privacy', bidRequest.uspConsent);
}
}
bids.push(data)
}
return {
Expand Down
29 changes: 28 additions & 1 deletion test/spec/modules/bizzclickBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { spec } from 'modules/bizzclickBidAdapter.js';
import {config} from 'src/config.js';

const NATIVE_BID_REQUEST = {
code: 'native_example',
Expand Down Expand Up @@ -53,7 +54,11 @@ const BANNER_BID_REQUEST = {
accountId: 'accountId'
},
timeout: 1000,

gdprConsent: {
consentString: 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA',
gdprApplies: 1,
},
uspConsent: 'uspConsent'
}

const bidRequest = {
Expand Down Expand Up @@ -172,6 +177,22 @@ const NATIVE_BID_RESPONSE = {
};

describe('BizzclickAdapter', function() {
describe('with COPPA', function() {
beforeEach(function() {
sinon.stub(config, 'getConfig')
.withArgs('coppa')
.returns(true);
});
afterEach(function() {
config.getConfig.restore();
});

it('should send the Coppa "required" flag set to "1" in the request', function () {
let serverRequest = spec.buildRequests([BANNER_BID_REQUEST]);
expect(serverRequest.data[0].regs.coppa).to.equal(1);
});
});

describe('isBidRequestValid', function() {
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(NATIVE_BID_REQUEST)).to.equal(true);
Expand Down Expand Up @@ -225,6 +246,12 @@ describe('BizzclickAdapter', function() {
expect(request.method).to.equal('POST');
});

it('check consent and ccpa string is set properly', function() {
expect(request.data[0].regs.ext.gdpr).to.equal(1);
expect(request.data[0].user.ext.consent).to.equal(BANNER_BID_REQUEST.gdprConsent.consentString);
expect(request.data[0].regs.ext.us_privacy).to.equal(BANNER_BID_REQUEST.uspConsent);
})

it('Returns valid URL', function () {
expect(request.url).to.equal('https://us-e-node1.bizzclick.com/bid?rtb_seat_id=prebidjs&secret_key=accountId');
});
Expand Down