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

Sovrn Bid Adapter: Enforce required video parameters #8276

Merged
merged 2 commits into from
May 4, 2022
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
19 changes: 16 additions & 3 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ const ORTB_VIDEO_PARAMS = {
'api': (value) => Array.isArray(value) && value.every(v => v >= 1 && v <= 6)
}

const REQUIRED_VIDEO_PARAMS = {
context: (value) => value !== ADPOD,
mimes: ORTB_VIDEO_PARAMS.mimes,
minduration: ORTB_VIDEO_PARAMS.minduration,
maxduration: ORTB_VIDEO_PARAMS.maxduration,
protocols: ORTB_VIDEO_PARAMS.protocols
}

export const spec = {
code: 'sovrn',
supportedMediaTypes: [BANNER, VIDEO],
Expand All @@ -40,12 +48,17 @@ export const spec = {
* @param {object} bid the Sovrn bid to validate
* @return boolean for whether or not a bid is valid
*/
isBidRequestValid: function(bid) {
isBidRequestValid: function (bid) {
const video = bid?.mediaTypes?.video
return !!(
bid.params.tagid &&
!isNaN(parseFloat(bid.params.tagid)) &&
isFinite(bid.params.tagid) &&
deepAccess(bid, 'mediaTypes.video.context') !== ADPOD
isFinite(bid.params.tagid) && (
!video || (
Object.keys(REQUIRED_VIDEO_PARAMS)
.every(key => REQUIRED_VIDEO_PARAMS[key](video[key]))
)
)
)
},

Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ describe('sovrnBidAdapter', function() {

expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
});

it('should return false when require video params are not passed', function () {
const bidRequest = {
...baseBidRequest,
'mediaTypes': {
'video': {
}
}
}

expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
});
});

describe('buildRequests', function () {
Expand Down