From 5de03203e1b7891737b2cc519eeb7aed3ca92bfb Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Fri, 6 Apr 2018 12:32:36 -0400 Subject: [PATCH 1/3] initial commit - place AN notify url in vast wrapper imp field --- modules/appnexusBidAdapter.js | 1 + src/videoCache.js | 8 +++++--- test/spec/videoCache_spec.js | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 034824f6fda..75e48d1ee0b 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -200,6 +200,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { width: rtbBid.rtb.video.player_width, height: rtbBid.rtb.video.player_height, vastUrl: rtbBid.rtb.video.asset_url, + vastImpUrl: rtbBid.notify_url, ttl: 3600 }); // This supports Outstream Video diff --git a/src/videoCache.js b/src/videoCache.js index 2af980316fa..cec2a3ec864 100644 --- a/src/videoCache.js +++ b/src/videoCache.js @@ -32,18 +32,20 @@ import { config } from '../src/config'; * Function which wraps a URI that serves VAST XML, so that it can be loaded. * * @param {string} uri The URI where the VAST content can be found. + * @param {string} impUrl An impression tracker URL for the delivery of the video ad * @return A VAST URL which loads XML from the given URI. */ -function wrapURI(uri) { +function wrapURI(uri, impUrl) { // Technically, this is vulnerable to cross-script injection by sketchy vastUrl bids. // We could make sure it's a valid URI... but since we're loading VAST XML from the // URL they provide anyway, that's probably not a big deal. + let vastImp = (impUrl) ? `` : ``; return ` prebid.org wrapper - + ${vastImp} @@ -57,7 +59,7 @@ function wrapURI(uri) { * @param {CacheableBid} bid */ function toStorageRequest(bid) { - const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl); + const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl); return { type: 'xml', value: vastValue diff --git a/test/spec/videoCache_spec.js b/test/spec/videoCache_spec.js index ab52b3be145..ef25c8c7c2b 100644 --- a/test/spec/videoCache_spec.js +++ b/test/spec/videoCache_spec.js @@ -101,6 +101,20 @@ describe('The video cache', () => { assertRequestMade({ vastUrl: 'my-mock-url.com' }, expectedValue) }); + it('should make the expected request when store() is called on an ad with a vastUrl and vastImpUrl', () => { + const expectedValue = ` + + + prebid.org wrapper + + + + + + `; + assertRequestMade({ vastUrl: 'my-mock-url.com', vastImpUrl: 'imptracker.com' }, expectedValue) + }); + it('should make the expected request when store() is called on an ad with vastXml', () => { const vastXml = ''; assertRequestMade({ vastXml: vastXml }, vastXml); From 4d5d11da1fa00d5362652ce03fb33cb87b5cecb0 Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Fri, 6 Apr 2018 13:38:27 -0400 Subject: [PATCH 2/3] add unit test for appnexusBidAdapter --- test/spec/modules/appnexusBidAdapter_spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 7038e2e572c..1ba4edfa4ea 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -412,6 +412,7 @@ describe('AppNexusAdapter', () => { 'ads': [{ 'ad_type': 'video', 'cpm': 0.500000, + 'notify_url': 'imptracker.com', 'rtb': { 'video': { 'content': '' @@ -424,6 +425,7 @@ describe('AppNexusAdapter', () => { let result = spec.interpretResponse({ body: response }, {bidderRequest}); expect(result[0]).to.have.property('vastUrl'); + expect(result[0]).to.have.property('vastImpUrl'); expect(result[0]).to.have.property('mediaType', 'video'); }); From 6257c5d58631a1f40416c4f8408e339830e3393b Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Tue, 10 Apr 2018 10:45:27 -0400 Subject: [PATCH 3/3] small change in unit test --- test/spec/videoCache_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/videoCache_spec.js b/test/spec/videoCache_spec.js index ef25c8c7c2b..b853da708fc 100644 --- a/test/spec/videoCache_spec.js +++ b/test/spec/videoCache_spec.js @@ -101,7 +101,7 @@ describe('The video cache', () => { assertRequestMade({ vastUrl: 'my-mock-url.com' }, expectedValue) }); - it('should make the expected request when store() is called on an ad with a vastUrl and vastImpUrl', () => { + it('should make the expected request when store() is called on an ad with a vastUrl and a vastImpUrl', () => { const expectedValue = `