Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change in Aardvark adapter to handle additional data #3821

Merged
merged 2 commits into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/aardvarkBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const spec = {
var auctionCodes = [];
var requests = [];
var requestsMap = {};
var referer = utils.getTopWindowUrl();
var referer = bidderRequest.refererInfo.referer;
var pageCategories = [];

// This reference to window.top can cause issues when loaded in an iframe if not protected with a try/catch.
Expand Down Expand Up @@ -124,6 +124,10 @@ export const spec = {
bidResponse.dealId = rawBid.dealId
}

if (rawBid.hasOwnProperty('ex')) {
bidResponse.ex = rawBid.ex;
}

switch (rawBid.media) {
case 'banner':
bidResponse.ad = rawBid.adm + utils.createTrackPixelHtml(decodeURIComponent(rawBid.nurl));
Expand Down
35 changes: 28 additions & 7 deletions test/spec/modules/aardvarkBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,27 @@ describe('aardvarkAdapterTest', function () {
auctionId: 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a'
}];

const bidderRequest = {
refererInfo: {
referer: 'http://example.com'
}
};

it('should use HTTP GET method', function () {
const requests = spec.buildRequests(bidRequests);
const requests = spec.buildRequests(bidRequests, bidderRequest);
requests.forEach(function(requestItem) {
expect(requestItem.method).to.equal('GET');
});
});

it('should call the correct bidRequest url', function () {
const requests = spec.buildRequests(bidRequests);
const requests = spec.buildRequests(bidRequests, bidderRequest);
expect(requests.length).to.equal(1);
expect(requests[0].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/TdAx_RAZd/aardvark\?'));
});

it('should have correct data', function () {
const requests = spec.buildRequests(bidRequests);
const requests = spec.buildRequests(bidRequests, bidderRequest);
expect(requests.length).to.equal(1);
expect(requests[0].data.version).to.equal(1);
expect(requests[0].data.jsonp).to.equal(false);
Expand Down Expand Up @@ -108,22 +114,28 @@ describe('aardvarkAdapterTest', function () {
auctionId: 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a'
}];

const bidderRequest = {
refererInfo: {
referer: 'http://example.com'
}
};

it('should use HTTP GET method', function () {
const requests = spec.buildRequests(bidRequests);
const requests = spec.buildRequests(bidRequests, bidderRequest);
requests.forEach(function(requestItem) {
expect(requestItem.method).to.equal('GET');
});
});

it('should call the correct bidRequest urls for each auction', function () {
const requests = spec.buildRequests(bidRequests);
const requests = spec.buildRequests(bidRequests, bidderRequest);
expect(requests[0].url).to.match(new RegExp('^\/\/bidder.rtk.io/Toby/TdAx/aardvark\?'));
expect(requests[0].data.categories.length).to.equal(2);
expect(requests[1].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/RAZd/aardvark\?'));
});

it('should have correct data', function () {
const requests = spec.buildRequests(bidRequests);
const requests = spec.buildRequests(bidRequests, bidderRequest);
expect(requests.length).to.equal(2);
expect(requests[0].data.version).to.equal(1);
expect(requests[0].data.jsonp).to.equal(false);
Expand Down Expand Up @@ -157,6 +169,9 @@ describe('aardvarkAdapterTest', function () {
gdprConsent: {
consentString: 'awefasdfwefasdfasd',
gdprApplies: true
},
refererInfo: {
referer: 'http://example.com'
}
};

Expand Down Expand Up @@ -184,7 +199,10 @@ describe('aardvarkAdapterTest', function () {
}];

const bidderRequest = {
gdprConsent: undefined
gdprConsent: undefined,
refererInfo: {
referer: 'http://example.com'
}
};

it('should transmit correct data', function () {
Expand Down Expand Up @@ -219,6 +237,7 @@ describe('aardvarkAdapterTest', function () {
cid: '1abgs362e0x48a8',
adm: '</tag2>',
ttl: 200,
ex: 'extraproperty'
}
],
headers: {}
Expand All @@ -234,6 +253,7 @@ describe('aardvarkAdapterTest', function () {
expect(result[0].currency).to.equal('USD');
expect(result[0].ttl).to.equal(200);
expect(result[0].dealId).to.equal('dealing');
expect(result[0].ex).to.be.undefined;
expect(result[0].ad).to.not.be.undefined;

expect(result[1].requestId).to.equal('1abgs362e0x48a8');
Expand All @@ -243,6 +263,7 @@ describe('aardvarkAdapterTest', function () {
expect(result[1].currency).to.equal('USD');
expect(result[1].ttl).to.equal(200);
expect(result[1].ad).to.not.be.undefined;
expect(result[1].ex).to.equal('extraproperty');
});

it('should handle nobid responses', function () {
Expand Down