Skip to content

Commit

Permalink
Colossus Bid Adapter: update buildRequests (prebid#8272)
Browse files Browse the repository at this point in the history
* add video&native traffic colossus ssp

* Native obj validation

* Native obj validation #2

* Added size field in requests

* fixed test

* fix merge conflicts

* move to 3.0

* move to 3.0

* fix IE11 new URL issue

* fix IE11 new URL issue

* fix IE11 new URL issue

* https for 3.0

* add https test

* add ccp and schain features

* fix test

* sync with upstream, fix conflicts

* Update colossussspBidAdapter.js

remove commented code

* Update colossussspBidAdapter.js

lint fix

* identity extensions

* identity extensions

* fix

* fix

* fix

* fix

* fix

* add tests for user ids

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* add gdpr support

* add gdpr support

* id5id support

* Update colossussspBidAdapter.js

add bidfloor parameter

* Update colossussspBidAdapter.js

check bidfloor

* Update colossussspBidAdapter.js

* Update colossussspBidAdapter.js

* Update colossussspBidAdapter.js

* Update colossussspBidAdapter_spec.js

* use floor module

* Revert "use floor module"

This reverts commit f0c5c24.

* use floor module

* update to 5v

* fix

* add uid2 and bidFloor support

* fix

* add pbadslot support

* fix conflicts

* add onBidWon

* refactor

* add test for onBidWon()

* fix

* add group_id

* Trigger circleci

* fix

* update user sync

* fix window.location

* fix test

* updates

* fix conflict

* fix

* updates

Co-authored-by: Vladislav Isaiko <vladis@smartyads.com>
Co-authored-by: Aiholkin <artem.iholkin@smartyads.com>
Co-authored-by: Mykhailo Yaremchuk <m.yaremchuk@smartyads.com>
  • Loading branch information
4 people committed Apr 20, 2022
1 parent 2c0518f commit a2fc0b5
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 4 deletions.
6 changes: 5 additions & 1 deletion modules/colossussspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export const spec = {
placementId: bid.params.placement_id,
groupId: bid.params.group_id,
bidId: bid.bidId,
sizes: bid.mediaTypes[traff].sizes,
traffic: traff,
eids: [],
floor: {}
Expand Down Expand Up @@ -146,7 +145,12 @@ export const spec = {
rtiPartner: 'TDID'
});
}
if (traff === BANNER) {
placement.sizes = bid.mediaTypes[BANNER].sizes
}

if (traff === VIDEO) {
placement.sizes = bid.mediaTypes[VIDEO].playerSize;
placement.playerSize = bid.mediaTypes[VIDEO].playerSize;
placement.minduration = bid.mediaTypes[VIDEO].minduration;
placement.maxduration = bid.mediaTypes[VIDEO].maxduration;
Expand Down
100 changes: 97 additions & 3 deletions test/spec/modules/colossussspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ describe('ColossussspAdapter', function () {
auctionStart: 1472239426000,
timeout: 5000,
uspConsent: '1YN-',
gdprConsent: {
consentString: 'xxx',
gdprApplies: 1
},
refererInfo: {
referer: 'http://www.example.com',
reachedTop: true,
Expand Down Expand Up @@ -87,7 +91,7 @@ describe('ColossussspAdapter', function () {
it('Returns valid data if array of bids is valid', function () {
let data = serverRequest.data;
expect(data).to.be.an('object');
expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa');
expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr_consent', 'gdpr_require');
expect(data.deviceWidth).to.be.a('number');
expect(data.deviceHeight).to.be.a('number');
expect(data.language).to.be.a('string');
Expand All @@ -108,6 +112,53 @@ describe('ColossussspAdapter', function () {
expect(placement.gpid).to.be.an('string');
}
});

it('Returns valid video data if array of bids is valid', function () {
const videoBid = {
...bid,
params: {
placement_id: 0,
traffic: 'video',
},
mediaTypes: {
video: {
playerSize: [[300, 300]],
minduration: 5,
maxduration: 60
}
}
}
let serverRequest = spec.buildRequests([videoBid], bidderRequest);

let data = serverRequest.data;
expect(data).to.be.an('object');
expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr_consent', 'gdpr_require');
expect(data.deviceWidth).to.be.a('number');
expect(data.deviceHeight).to.be.a('number');
expect(data.language).to.be.a('string');
expect(data.secure).to.be.within(0, 1);
expect(data.host).to.be.a('string');
expect(data.page).to.be.a('string');
let placements = data['placements'];
for (let i = 0; i < placements.length; i++) {
let placement = placements[i];
expect(placement).to.have.all.keys('placementId', 'groupId', 'eids', 'bidId', 'traffic', 'schain', 'floor', 'gpid', 'sizes',
'playerSize', 'minduration', 'maxduration', 'mimes', 'protocols', 'startdelay', 'placement', 'skip', 'skipafter',
'minbitrate', 'maxbitrate', 'delivery', 'playbackmethod', 'api', 'linearity'
);
expect(placement.schain).to.be.an('object')
expect(placement.placementId).to.be.a('number');
expect(placement.bidId).to.be.a('string');
expect(placement.traffic).to.be.a('string');
expect(placement.floor).to.be.an('object');
expect(placement.gpid).to.be.an('string');
expect(placement.sizes).to.be.an('array');
expect(placement.playerSize).to.be.an('array');
expect(placement.minduration).to.be.an('number');
expect(placement.maxduration).to.be.an('number');
}
});

it('Returns empty data if no valid requests are passed', function () {
serverRequest = spec.buildRequests([], bidderRequest);
let data = serverRequest.data;
Expand Down Expand Up @@ -187,6 +238,49 @@ describe('ColossussspAdapter', function () {
expect(serverResponses).to.be.an('array').that.is.empty;
});
});

let videoResObject = {
body: [{
requestId: '123',
mediaType: 'video',
cpm: 0.3,
width: 320,
height: 50,
vastUrl: '<XML>',
ttl: 1000,
creativeId: '123asd',
netRevenue: true,
currency: 'USD',
meta: {
advertiserDomains: ['google.com'],
advertiserId: 1234
}
}]
};
let videoServerResponses = spec.interpretResponse(videoResObject);
it('Returns an array of valid server video responses if response object is valid', function () {
expect(videoServerResponses).to.be.an('array').that.is.not.empty;
for (let i = 0; i < videoServerResponses.length; i++) {
let dataItem = videoServerResponses[i];
expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastUrl', 'ttl', 'creativeId',
'netRevenue', 'currency', 'mediaType', 'meta');
expect(dataItem.requestId).to.be.a('string');
expect(dataItem.cpm).to.be.a('number');
expect(dataItem.width).to.be.a('number');
expect(dataItem.height).to.be.a('number');
expect(dataItem.vastUrl).to.be.a('string');
expect(dataItem.ttl).to.be.a('number');
expect(dataItem.creativeId).to.be.a('string');
expect(dataItem.netRevenue).to.be.a('boolean');
expect(dataItem.currency).to.be.a('string');
expect(dataItem.mediaType).to.be.a('string');
expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
}
it('Returns an empty array if invalid response is passed', function () {
videoServerResponses = spec.interpretResponse('invalid_response');
expect(videoServerResponses).to.be.an('array').that.is.empty;
});
});
});

describe('onBidWon', function () {
Expand All @@ -199,13 +293,13 @@ describe('ColossussspAdapter', function () {
})

describe('getUserSyncs', function () {
let userSync = spec.getUserSyncs({}, {}, {}, {});
let userSync = spec.getUserSyncs({}, {}, { consentString: 'xxx', gdprApplies: 1 }, { consentString: '1YN-' });
it('Returns valid URL and type', function () {
expect(userSync).to.be.an('array').with.lengthOf(1);
expect(userSync[0].type).to.exist;
expect(userSync[0].url).to.exist;
expect(userSync[0].type).to.be.equal('hms.gif');
expect(userSync[0].url).to.be.equal('https://sync.colossusssp.com/hms.gif?pbjs=1&coppa=0');
expect(userSync[0].url).to.be.equal('https://sync.colossusssp.com/hms.gif?pbjs=1&gdpr=0&gdpr_consent=xxx&ccpa_consent=1YN-&coppa=0');
});
});
});

0 comments on commit a2fc0b5

Please sign in to comment.