Skip to content

Commit

Permalink
6012: Fix for passing US Privacy string in buildVideoUrl and buildAdp…
Browse files Browse the repository at this point in the history
…odVideoUrl (#6075)

* added support for pubcommon, digitrust, id5id

* added support for IdentityLink

* changed the source for id5

* added unit test cases

* changed source param for identityLink

* pass USP consent string in dfpVideoUrl and dfpAdpodVideoUrl

* added test cases
  • Loading branch information
pm-harshad-mane authored Dec 7, 2020
1 parent b9a4cc6 commit 5f6dab3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/dfpAdServerVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { deepAccess, isEmpty, logError, parseSizesInput, formatQS, parseUrl, bui
import { config } from '../src/config.js';
import { getHook, submodule } from '../src/hook.js';
import { auctionManager } from '../src/auctionManager.js';
import { uspDataHandler } from '../src/adapterManager.js';
import events from '../src/events.js';
import CONSTANTS from '../src/constants.json';

Expand Down Expand Up @@ -100,6 +101,9 @@ export function buildDfpVideoUrl(options) {
const descriptionUrl = getDescriptionUrl(bid, options, 'params');
if (descriptionUrl) { queryParams.description_url = descriptionUrl; }

const uspConsent = uspDataHandler.getConsentData();
if (uspConsent) { queryParams.us_privacy = uspConsent; }

return buildUrl({
protocol: 'https',
host: 'securepubads.g.doubleclick.net',
Expand Down Expand Up @@ -183,6 +187,9 @@ export function buildAdpodVideoUrl({code, params, callback} = {}) {
{ cust_params: encodedCustomParams }
);

const uspConsent = uspDataHandler.getConsentData();
if (uspConsent) { queryParams.us_privacy = uspConsent; }

const masterTag = buildUrl({
protocol: 'https',
host: 'securepubads.g.doubleclick.net',
Expand Down
43 changes: 43 additions & 0 deletions test/spec/modules/dfpAdServerVideo_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as utils from 'src/utils.js';
import { config } from 'src/config.js';
import { targeting } from 'src/targeting.js';
import { auctionManager } from 'src/auctionManager.js';
import { uspDataHandler } from 'src/adapterManager.js';
import * as adpod from 'modules/adpod.js';
import { server } from 'test/mocks/xhr.js';

Expand Down Expand Up @@ -115,6 +116,44 @@ describe('The DFP video support module', function () {
expect(customParams).to.have.property('hb_cache_id', bid.videoCacheKey);
});

it('should include the us_privacy key when USP Consent is available', function () {
let uspDataHandlerStub = sinon.stub(uspDataHandler, 'getConsentData');
uspDataHandlerStub.returns('1YYY');

const bidCopy = utils.deepClone(bid);
bidCopy.adserverTargeting = Object.assign(bidCopy.adserverTargeting, {
hb_adid: 'ad_id',
});

const url = parse(buildDfpVideoUrl({
adUnit: adUnit,
bid: bidCopy,
params: {
'iu': 'my/adUnit'
}
}));
const queryObject = utils.parseQS(url.query);
expect(queryObject.us_privacy).to.equal('1YYY');
uspDataHandlerStub.restore();
});

it('should not include the us_privacy key when USP Consent is not available', function () {
const bidCopy = utils.deepClone(bid);
bidCopy.adserverTargeting = Object.assign(bidCopy.adserverTargeting, {
hb_adid: 'ad_id',
});

const url = parse(buildDfpVideoUrl({
adUnit: adUnit,
bid: bidCopy,
params: {
'iu': 'my/adUnit'
}
}));
const queryObject = utils.parseQS(url.query);
expect(queryObject.us_privacy).to.equal(undefined);
});

describe('special targeting unit test', function () {
const allTargetingData = {
'hb_format': 'video',
Expand Down Expand Up @@ -350,6 +389,8 @@ describe('The DFP video support module', function () {

it('should return masterTag url', function() {
amStub.returns(getBidsReceived());
let uspDataHandlerStub = sinon.stub(uspDataHandler, 'getConsentData');
uspDataHandlerStub.returns('1YYY');
let url;
parse(buildAdpodVideoUrl({
code: 'adUnitCode-1',
Expand Down Expand Up @@ -380,10 +421,12 @@ describe('The DFP video support module', function () {
expect(queryParams).to.have.property('unviewed_position_start', '1');
expect(queryParams).to.have.property('url');
expect(queryParams).to.have.property('cust_params');
expect(queryParams).to.have.property('us_privacy', '1YYY');

const custParams = utils.parseQS(decodeURIComponent(queryParams.cust_params));
expect(custParams).to.have.property('hb_cache_id', '123');
expect(custParams).to.have.property('hb_pb_cat_dur', '15.00_395_15s,15.00_406_30s,10.00_395_15s');
uspDataHandlerStub.restore();
}
});

Expand Down

0 comments on commit 5f6dab3

Please sign in to comment.