diff --git a/modules/oneVideoBidAdapter.js b/modules/oneVideoBidAdapter.js index 38367837faf7..5b1fd999ee64 100644 --- a/modules/oneVideoBidAdapter.js +++ b/modules/oneVideoBidAdapter.js @@ -36,14 +36,17 @@ export const spec = { * Make a server request from the list of BidRequests. * * @param {validBidRequests[]} - an array of bids + * @param bidderRequest * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(bids) { + buildRequests: function(bids, bidRequest) { + let consentData = bidRequest ? bidRequest.gdprConsent : null; + return bids.map(bid => { return { method: 'POST', url: location.protocol + spec.ENDPOINT + bid.params.pubId, - data: getRequestData(bid), + data: getRequestData(bid, consentData), options: {contentType: 'application/json'}, bidRequest: bid } @@ -127,7 +130,11 @@ function getSize(sizes) { }; } -function getRequestData(bid) { +function isConsentRequired(consentData) { + return !!(consentData && consentData.gdprApplies); +} + +function getRequestData(bid, consentData) { let loc = utils.getTopWindowLocation(); let global = (window.top) ? window.top : window; let page = (bid.params.site && bid.params.site.page) ? (bid.params.site.page) : (loc.href); @@ -179,6 +186,23 @@ function getRequestData(bid) { if (bid.params.site && bid.params.site.id) { bidData.site.id = bid.params.site.id } + + if (isConsentRequired(consentData)) { + bidData.regs = { + ext: { + gdpr: 1 + } + }; + + if (consentData.consentString) { + bidData.user = { + ext: { + consent: consentData.consentString + } + }; + } + } + return bidData; } diff --git a/test/spec/modules/oneVideoBidAdapter_spec.js b/test/spec/modules/oneVideoBidAdapter_spec.js index 3d7bba417f9f..278b39fd0794 100644 --- a/test/spec/modules/oneVideoBidAdapter_spec.js +++ b/test/spec/modules/oneVideoBidAdapter_spec.js @@ -1,9 +1,12 @@ import { expect } from 'chai'; import { spec } from 'modules/oneVideoBidAdapter'; import * as utils from 'src/utils'; +import {config} from 'src/config'; describe('OneVideoBidAdapter', () => { let bidRequest; + let bidderRequest; + let mockConfig; beforeEach(() => { bidRequest = { @@ -132,4 +135,33 @@ describe('OneVideoBidAdapter', () => { expect(bidResponse).to.deep.equal(o); }); }); + + describe('when GDPR applies', function () { + beforeEach(function () { + bidderRequest = { + gdprConsent: { + consentString: 'test-gdpr-consent-string', + gdprApplies: true + } + }; + + mockConfig = { + consentManagement: { + cmpApi: 'iab', + timeout: 1111, + allowAuctionWithoutConsent: 'cancel' + } + }; + }); + + it('should send a signal to specify that GDPR applies to this request', function () { + const request = spec.buildRequests([ bidRequest ], bidderRequest); + expect(request[0].data.regs.ext.gdpr).to.equal(1); + }); + + it('should send the consent string', function () { + const request = spec.buildRequests([ bidRequest ], bidderRequest); + expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + }); + }); });