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

Smart: GDPR support #2528

Merged
merged 5 commits into from
May 15, 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
9 changes: 8 additions & 1 deletion modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ export const spec = {
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids
* @param {bidderRequest} - bidder request object
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests) {
buildRequests: function (validBidRequests, bidderRequest) {
// use bidderRequest.bids[] to get bidder-dependent request info

// if your bidder supports multiple currencies, use config.getConfig(currency)
Expand Down Expand Up @@ -53,6 +54,12 @@ export const spec = {
bidId: bid.bidId,
prebidVersion: '$prebid.version$'
};

if (bidderRequest && bidderRequest.gdprConsent) {
payload.gdpr_consent = bidderRequest.gdprConsent.consentString;
payload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side
}

var payloadString = JSON.stringify(payload);
return {
method: 'POST',
Expand Down
63 changes: 59 additions & 4 deletions test/spec/modules/smartadserverBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,51 @@ describe('Smart bid adapter tests', () => {
expect(requestContent).to.have.property('ckid').and.to.equal(42);
});

it('Verify build request with GDPR', () => {
config.setConfig({
'currency': {
'adServerCurrency': 'EUR'
},
consentManagement: {
cmp: 'iab',
consentRequired: true,
timeout: 1000,
allowAuctionWithoutConsent: true
}
});
const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, {
gdprConsent: {
consentString: 'BOKAVy4OKAVy4ABAB8AAAAAZ+A==',
gdprApplies: true
}
});
const requestContent = JSON.parse(request[0].data);
expect(requestContent).to.have.property('gdpr').and.to.equal(true);
expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOKAVy4OKAVy4ABAB8AAAAAZ+A==');
});

it('Verify build request with GDPR without gdprApplies', () => {
config.setConfig({
'currency': {
'adServerCurrency': 'EUR'
},
consentManagement: {
cmp: 'iab',
consentRequired: true,
timeout: 1000,
allowAuctionWithoutConsent: true
}
});
const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, {
gdprConsent: {
consentString: 'BOKAVy4OKAVy4ABAB8AAAAAZ+A=='
}
});
const requestContent = JSON.parse(request[0].data);
expect(requestContent).to.not.have.property('gdpr');
expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOKAVy4OKAVy4ABAB8AAAAAZ+A==');
});

it('Verify parse response', () => {
const request = spec.buildRequests(DEFAULT_PARAMS);
const bids = spec.interpretResponse(BID_RESPONSE, request[0]);
Expand All @@ -116,7 +161,11 @@ describe('Smart bid adapter tests', () => {
expect(bid.requestId).to.equal(DEFAULT_PARAMS[0].bidId);
expect(bid.referrer).to.equal(utils.getTopWindowUrl());

expect(function() { spec.interpretResponse(BID_RESPONSE, {data: 'invalid Json'}) }).to.not.throw();
expect(function () {
spec.interpretResponse(BID_RESPONSE, {
data: 'invalid Json'
})
}).to.not.throw();
});

it('Verifies bidder code', () => {
Expand Down Expand Up @@ -187,15 +236,21 @@ describe('Smart bid adapter tests', () => {
});

it('Verifies user sync', () => {
var syncs = spec.getUserSyncs({iframeEnabled: true}, [BID_RESPONSE]);
var syncs = spec.getUserSyncs({
iframeEnabled: true
}, [BID_RESPONSE]);
expect(syncs).to.have.lengthOf(1);
expect(syncs[0].type).to.equal('iframe');
expect(syncs[0].url).to.equal('http://awesome.fake.csync.url');

syncs = spec.getUserSyncs({iframeEnabled: false}, [BID_RESPONSE]);
syncs = spec.getUserSyncs({
iframeEnabled: false
}, [BID_RESPONSE]);
expect(syncs).to.have.lengthOf(0);

syncs = spec.getUserSyncs({iframeEnabled: true}, []);
syncs = spec.getUserSyncs({
iframeEnabled: true
}, []);
expect(syncs).to.have.lengthOf(0);
});
});