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

CCPA and Schain support #4537

Merged
merged 20 commits into from
Dec 10, 2019
9 changes: 9 additions & 0 deletions modules/colossussspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export const spec = {
'placements': placements
};

if (bidderRequest) {
if (bidderRequest.uspConsent) {
request.ccpa = bidderRequest.uspConsent;
}
}

for (let i = 0; i < validBidRequests.length; i++) {
let bid = validBidRequests[i];
let traff = bid.params.traffic || BANNER
Expand All @@ -72,6 +78,9 @@ export const spec = {
sizes: bid.mediaTypes[traff].sizes,
traffic: traff
};
if (bid.schain) {
placement.schain = bid.schain;
}
placements.push(placement);
}
return {
Expand Down
41 changes: 37 additions & 4 deletions test/spec/modules/colossussspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,36 @@ describe('ColossussspAdapter', function () {
sizes: [[300, 250]]
}
},
transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62'
transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62',
schain: {
ver: '1.0',
complete: 1,
nodes: [
{
asi: 'example.com',
sid: '0',
hp: 1,
rid: 'bidrequestid',
// name: 'alladsallthetime',
domain: 'example.com'
}
]
}
};
let bidderRequest = {
bidderCode: 'colossus',
auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff',
bidderRequestId: 'ffffffffffffff',
start: 1472239426002,
auctionStart: 1472239426000,
timeout: 5000,
uspConsent: '1YN-',
refererInfo: {
referer: 'http://www.example.com',
reachedTop: true,
},
bids: [bid]
}

describe('isBidRequestValid', function () {
it('Should return true when placement_id can be cast to a number', function () {
Expand All @@ -30,7 +58,7 @@ describe('ColossussspAdapter', function () {
});

describe('buildRequests', function () {
let serverRequest = spec.buildRequests([bid]);
let serverRequest = spec.buildRequests([bid], bidderRequest);
it('Creates a ServerRequest object with method, URL and data', function () {
expect(serverRequest).to.exist;
expect(serverRequest.method).to.exist;
Expand All @@ -43,10 +71,14 @@ describe('ColossussspAdapter', function () {
it('Returns valid URL', function () {
expect(serverRequest.url).to.equal('https://colossusssp.com/?c=o&m=multi');
});
it('Should contain ccpa', function() {
expect(serverRequest.data.ccpa).to.be.an('string')
})

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');
expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa');
expect(data.deviceWidth).to.be.a('number');
expect(data.deviceHeight).to.be.a('number');
expect(data.language).to.be.a('string');
Expand All @@ -56,7 +88,8 @@ describe('ColossussspAdapter', function () {
let placements = data['placements'];
for (let i = 0; i < placements.length; i++) {
let placement = placements[i];
expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes');
expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes', 'schain');
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');
Expand Down