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

GDPR consent management for madvertise bidder adapter #2655

Merged
merged 9 commits into from
Jun 5, 2018
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
8 changes: 7 additions & 1 deletion modules/madvertiseBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as utils from 'src/utils';
import {config} from 'src/config';
import {registerBidder} from 'src/adapters/bidderFactory';

// use protocol relative urls for http or https
Expand Down Expand Up @@ -29,9 +30,10 @@ export const spec = {
},
/**
* @param {BidRequest[]} bidRequests
* @param bidderRequest
* @return ServerRequest[]
*/
buildRequests: function (bidRequests) {
buildRequests: function (bidRequests, bidderRequest) {
return bidRequests.map(bidRequest => {
bidRequest.startTime = new Date().getTime();

Expand All @@ -50,6 +52,10 @@ export const spec = {
src = src + '&u=' + navigator.userAgent;
}

if (bidderRequest && bidderRequest.gdprConsent) {
src = src + '&gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? '1' : '0') + '&consent[0][format]=' + config.getConfig('consentManagement.cmpApi') + '&consent[0][value]=' + bidderRequest.gdprConsent.consentString;
}

return {
method: 'GET',
url: MADVERTISE_ENDPOINT + src,
Expand Down
74 changes: 60 additions & 14 deletions test/spec/modules/madvertiseBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {expect} from 'chai';
import {config} from 'src/config';
import * as utils from 'src/utils';
import {spec} from 'modules/madvertiseBidAdapter';

describe('madvertise adapater', () => {
Expand Down Expand Up @@ -70,26 +72,70 @@ describe('madvertise adapater', () => {
});

describe('Test build request', () => {
it('minimum request', () => {
let bid = [{
bidder: 'madvertise',
sizes: [[728, 90], [300, 100]],
bidId: '51ef8751f9aead',
adUnitCode: 'div-gpt-ad-1460505748561-0',
transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
auctionId: '18fd8b8b0bd757',
bidderRequestId: '418b37f85e772c',
params: {
s: 'test',
beforeEach(function () {
let mockConfig = {
consentManagement: {
cmpApi: 'IAB',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a note more-so - the value will be iab instead of IAB.

timeout: 1111,
allowAuctionWithoutConsent: 'cancel'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to above, this should be a boolean value (false in this case) not the string cancel. Passing in a string here actually causes the config to the opposite value (ie true) which allows the auction to proceed without consent.

}
}];
const req = spec.buildRequests(bid);
};

sinon.stub(config, 'getConfig').callsFake((key) => {
return utils.deepAccess(mockConfig, key);
});
});
afterEach(function () {
config.getConfig.restore();
});
let bid = [{
bidder: 'madvertise',
sizes: [[728, 90], [300, 100]],
bidId: '51ef8751f9aead',
adUnitCode: 'div-gpt-ad-1460505748561-0',
transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
auctionId: '18fd8b8b0bd757',
bidderRequestId: '418b37f85e772c',
params: {
s: 'test',
}
}];
it('minimum request with gdpr consent', () => {
let bidderRequest = {
gdprConsent: {
consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
vendorData: {},
gdprApplies: true
}
};
const req = spec.buildRequests(bid, bidderRequest);

expect(req).to.exist.and.to.be.a('array');
expect(req[0]).to.have.property('method');
expect(req[0].method).to.equal('GET');
expect(req[0]).to.have.property('url');
expect(req[0].url).to.contain('//mobile.mng-ads.com/?rt=bid_request&v=1.0');
expect(req[0].url).to.contain(`&s=test`);
expect(req[0].url).to.contain(`&sizes[0]=728x90`);
expect(req[0].url).to.contain(`&gdpr=1`);
expect(req[0].url).to.contain(`&consent[0][format]=IAB`);
expect(req[0].url).to.contain(`&consent[0][value]=BOJ/P2HOJ/P2HABABMAAAAAZ+A==`)
});

it('minimum request without gdpr consent', () => {
let bidderRequest = {};
const req = spec.buildRequests(bid, bidderRequest);

expect(req).to.exist.and.to.be.a('array');
expect(req[0]).to.have.property('method');
expect(req[0].method).to.equal('GET');
expect(req[0]).to.have.property('url');
expect(req[0].url).to.contain('//mobile.mng-ads.com/?rt=bid_request&v=1.0').and.to.contain(`&s=test`).and.to.contain(`&sizes[0]=728x90`)
expect(req[0].url).to.contain('//mobile.mng-ads.com/?rt=bid_request&v=1.0');
expect(req[0].url).to.contain(`&s=test`);
expect(req[0].url).to.contain(`&sizes[0]=728x90`);
expect(req[0].url).not.to.contain(`&gdpr=1`);
expect(req[0].url).not.to.contain(`&consent[0][format]=`);
expect(req[0].url).not.to.contain(`&consent[0][value]=`)
});
});

Expand Down