From d644363b37636da7751bc409c1bc7c6497f9de9d Mon Sep 17 00:00:00 2001 From: Brittany Zellman <33695402+brittanyzellman@users.noreply.github.com> Date: Wed, 7 Nov 2018 14:06:51 -0500 Subject: [PATCH] TripleliftBidAdapter - remove dependency on getTopWindowLocation util (#3139) * removed dependancy on getTopWindowUrl for referer * protect against undefined obj and remove test on old dependency * added unit test for referer and gdpr in query string * removed gdpr test * removed gdpr from bidderRequest obj * decontructed bidder request obj in chai test * just need to run karma tests again * added gdpr consent to all bidderRequest obj in chai tests --- modules/tripleliftBidAdapter.js | 7 ++- .../spec/modules/tripleliftBidAdapter_spec.js | 44 +++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 795c75ef9bc..5989d0c2fca 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -17,12 +17,15 @@ export const tripleliftAdapterSpec = { buildRequests: function(bidRequests, bidderRequest) { let tlCall = STR_ENDPOINT; - let referrer = utils.getTopWindowUrl(); let data = _buildPostBody(bidRequests); tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid'); tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$'); - tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer); + + if (bidderRequest && bidderRequest.refererInfo) { + let referrer = bidderRequest.refererInfo.referer; + tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer); + } if (bidderRequest && bidderRequest.timeout) { tlCall = utils.tryAppendQueryString(tlCall, 'tmax', bidderRequest.timeout); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index d3013d9be22..f614bdbd31a 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -68,19 +68,42 @@ describe('triplelift adapter', function () { } ]; + let bidderRequest = { + bidderCode: 'triplelift', + auctionId: 'a7ebcd1d-66ff-4b5c-a82c-6a21a6ee5a18', + bidderRequestId: '5c55612f99bc11', + bids: [ + { + imp_id: 0, + cpm: 1.062, + width: 300, + height: 250, + ad: 'ad-markup', + iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg' + } + ], + refererInfo: { + referer: 'http://examplereferer.com' + }, + gdprConsent: { + consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', + gdprApplies: true + } + }; + it('exists and is an object', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request).to.exist.and.to.be.a('object'); }); it('should only parse sizes that are of the proper length and format', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].banner.format).to.have.length(2); expect(request.data.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); }); it('should be a post request and populate the payload', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.exist; expect(payload.imp[0].tagid).to.equal('12345'); @@ -89,16 +112,15 @@ describe('triplelift adapter', function () { }); it('should return a query string for TL call', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const url = request.url; expect(url).to.exist; expect(url).to.be.a('string'); expect(url).to.match(/(?:tlx.3lift.com\/header\/auction)/) expect(url).to.match(/(?:lib=prebid)/) expect(url).to.match(/(?:prebid.version)/) - // expect(url).to.match(/(?:fe=)/) // - expect(url).to.match(/(?:referrer)/) - }) + expect(url).to.match(/(?:referrer)/); + }); }); describe('interpretResponse', function () { @@ -130,8 +152,11 @@ describe('triplelift adapter', function () { iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg' } ], + refererInfo: { + referer: 'http://examplereferer.com' + }, gdprConsent: { - consentString: 'BOONm0NOONma-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVOQ6gEaY', + consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', gdprApplies: true } }; @@ -201,6 +226,9 @@ describe('triplelift adapter', function () { iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg' } ], + refererInfo: { + referer: 'http://examplereferer.com' + }, gdprConsent: { consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', gdprApplies: true