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

OpenX Bid Adapter: video support for platform IDs #3374

Merged
merged 1 commit into from
Dec 14, 2018
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
4 changes: 3 additions & 1 deletion modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,10 @@ function buildOXBannerRequest(bids, bidderRequest) {
}

function buildOXVideoRequest(bid, bidderRequest) {
let url = `//${bid.params.delDomain}/v/1.0/avjp`;
let oxVideoParams = generateVideoParameters(bid, bidderRequest);
let url = oxVideoParams.ph
? `//u.openx.net/v/1.0/avjp`
: `//${bid.params.delDomain}/v/1.0/avjp`;
return {
method: 'GET',
url: url,
Expand Down
141 changes: 95 additions & 46 deletions test/spec/modules/openxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,57 +179,106 @@ describe('OpenxAdapter', function () {
});

describe('when request is for a video ad', function () {
const videoBidWithMediaTypes = {
bidder: 'openx',
params: {
unit: '12345678',
delDomain: 'test-del-domain'
},
adUnitCode: 'adunit-code',
mediaTypes: {
video: {
playerSize: [640, 480]
}
},
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e'
};

const videoBidWithMediaType = {
'bidder': 'openx',
'params': {
'unit': '12345678',
'delDomain': 'test-del-domain'
},
'adUnitCode': 'adunit-code',
'mediaType': 'video',
'sizes': [640, 480],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(true);
});
describe('and request config uses mediaTypes', () => {
const videoBidWithMediaTypes = {
bidder: 'openx',
params: {
unit: '12345678',
delDomain: 'test-del-domain'
},
adUnitCode: 'adunit-code',
mediaTypes: {
video: {
playerSize: [640, 480]
}
},
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(true);
});

it('should return false when required params are not passed', function () {
let videoBidWithMediaTypes = Object.assign({}, videoBidWithMediaTypes);
videoBidWithMediaTypes.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false);
it('should return false when required params are not passed', function () {
let videoBidWithMediaTypes = Object.assign({}, videoBidWithMediaTypes);
videoBidWithMediaTypes.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false);
});
it('should send bid request to openx url via GET, with mediaType specified as video', function () {
const request = spec.buildRequests([videoBidWithMediaTypes]);
expect(request[0].url).to.equal(`//${videoBidWithMediaTypes.params.delDomain}${URLBASEVIDEO}`);
expect(request[0].data.ph).to.be.undefined;
expect(request[0].method).to.equal('GET');
});
});
describe('and request config uses both delDomain and platform', () => {
const videoBidWithDelDomainAndPlatform = {
bidder: 'openx',
params: {
unit: '12345678',
delDomain: 'test-del-domain',
platform: '1cabba9e-cafe-3665-beef-f00f00f00f00',
},
adUnitCode: 'adunit-code',
mediaTypes: {
video: {
playerSize: [640, 480]
}
},
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithDelDomainAndPlatform)).to.equal(true);
});

it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(true);
it('should return false when required params are not passed', function () {
let videoBidWithMediaTypes = Object.assign({}, videoBidWithDelDomainAndPlatform);
videoBidWithMediaTypes.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false);
});
it('should send bid request to openx url via GET, with mediaType specified as video', function () {
const request = spec.buildRequests([videoBidWithDelDomainAndPlatform]);
expect(request[0].url).to.equal(`//u.openx.net${URLBASEVIDEO}`);
expect(request[0].data.ph).to.equal(videoBidWithDelDomainAndPlatform.params.platform);
expect(request[0].method).to.equal('GET');
});
});
describe('and request config uses mediaType', () => {
const videoBidWithMediaType = {
'bidder': 'openx',
'params': {
'unit': '12345678',
'delDomain': 'test-del-domain'
},
'adUnitCode': 'adunit-code',
'mediaType': 'video',
'sizes': [640, 480],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(true);
});

it('should return false when required params are not passed', function () {
let videoBidWithMediaType = Object.assign({}, videoBidWithMediaType);
delete videoBidWithMediaType.params;
videoBidWithMediaType.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(false);
it('should return false when required params are not passed', function () {
let videoBidWithMediaType = Object.assign({}, videoBidWithMediaType);
delete videoBidWithMediaType.params;
videoBidWithMediaType.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(false);
});
it('should send bid request to openx url via GET, with mediaType specified as video', function () {
const request = spec.buildRequests([videoBidWithMediaType]);
expect(request[0].url).to.equal(`//${videoBidWithMediaType.params.delDomain}${URLBASEVIDEO}`);
expect(request[0].data.ph).to.be.undefined;
expect(request[0].method).to.equal('GET');
});
});
});
});
Expand Down