Skip to content

Commit

Permalink
TripleliftBidAdapter - remove dependency on getTopWindowLocation util (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
brittanyzellman authored and idettman committed Nov 7, 2018
1 parent 459a2e2 commit d644363
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
7 changes: 5 additions & 2 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
44 changes: 36 additions & 8 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 () {
Expand Down Expand Up @@ -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
}
};
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d644363

Please sign in to comment.