Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into connatix_viewability_support
Browse files Browse the repository at this point in the history
  • Loading branch information
rares-mihai-preda committed Aug 8, 2024
2 parents d472ea5 + 439d6ed commit e2e4223
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 56 deletions.
2 changes: 1 addition & 1 deletion modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ function bidToTag(bid) {
// page.html?ast_override_div=divId:creativeId,divId2:creativeId2
const overrides = getParameterByName('ast_override_div');
if (isStr(overrides) && overrides !== '') {
const adUnitOverride = overrides.split(',').find((pair) => pair.startsWith(`${bid.adUnitCode}:`));
const adUnitOverride = decodeURIComponent(overrides).split(',').find((pair) => pair.startsWith(`${bid.adUnitCode}:`));
if (adUnitOverride) {
const forceCreativeId = adUnitOverride.split(':')[1];
if (forceCreativeId) {
Expand Down
7 changes: 1 addition & 6 deletions modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ const converter = ortbConverter({
bidResponse.meta.advertiserId = bid.ext.buyer_id;
bidResponse.meta.brandId = bid.ext.brand_id;
}
const {ortbResponse} = context;
if (ortbResponse.ext && ortbResponse.ext.paf) {
bidResponse.meta.paf = Object.assign({}, ortbResponse.ext.paf);
bidResponse.meta.paf.content_id = utils.deepAccess(bid, 'ext.paf.content_id');
}
return bidResponse;
},
response(buildResponse, bidResponses, ortbResponse, context) {
Expand Down Expand Up @@ -117,7 +112,7 @@ const converter = ortbConverter({
paapi: fledgeAuctionConfigs,
}
} else {
return response.bids
return response
}
},
overrides: {
Expand Down
9 changes: 8 additions & 1 deletion modules/richaudienceBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export const spec = {
cpuc: (typeof window.navigator != 'undefined' ? window.navigator.hardwareConcurrency : null),
kws: getAllOrtbKeywords(bidderRequest.ortb2, bid.params.keywords).join(','),
schain: bid.schain,
gpid: raiSetPbAdSlot(bid)
gpid: raiSetPbAdSlot(bid),
dsa: setDSA(bid),
userData: deepAccess(bid, 'ortb2.user.data')
};

REFERER = (typeof bidderRequest.refererInfo.page != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.page) : null)
Expand Down Expand Up @@ -373,3 +375,8 @@ function raiGetTimeoutURL(data) {
}
return url
}

function setDSA(bid) {
let dsa = bid?.ortb2?.regs?.ext?.dsa ? bid?.ortb2?.regs?.ext?.dsa : null;
return dsa;
}
63 changes: 15 additions & 48 deletions test/spec/modules/openxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ describe('OpenxRtbAdapter', function () {
let bid;

context('when there is an nbr response', function () {
let bids;
let response;
beforeEach(function () {
bidRequestConfigs = [{
bidder: 'openx',
Expand All @@ -1131,16 +1131,16 @@ describe('OpenxRtbAdapter', function () {
bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0];

bidResponse = {nbr: 0}; // Unknown error
bids = spec.interpretResponse({body: bidResponse}, bidRequest);
response = spec.interpretResponse({body: bidResponse}, bidRequest);
});

it('should not return any bids', function () {
expect(bids.length).to.equal(0);
expect(response.bids.length).to.equal(0);
});
});

context('when no seatbid in response', function () {
let bids;
let response;
beforeEach(function () {
bidRequestConfigs = [{
bidder: 'openx',
Expand All @@ -1162,16 +1162,16 @@ describe('OpenxRtbAdapter', function () {
bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0];

bidResponse = {ext: {}, id: 'test-bid-id'};
bids = spec.interpretResponse({body: bidResponse}, bidRequest);
response = spec.interpretResponse({body: bidResponse}, bidRequest);
});

it('should not return any bids', function () {
expect(bids.length).to.equal(0);
expect(response.bids.length).to.equal(0);
});
});

context('when there is no response', function () {
let bids;
let response;
beforeEach(function () {
bidRequestConfigs = [{
bidder: 'openx',
Expand All @@ -1193,11 +1193,11 @@ describe('OpenxRtbAdapter', function () {
bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0];

bidResponse = ''; // Unknown error
bids = spec.interpretResponse({body: bidResponse}, bidRequest);
response = spec.interpretResponse({body: bidResponse}, bidRequest);
});

it('should not return any bids', function () {
expect(bids.length).to.equal(0);
expect(response.bids.length).to.equal(0);
});
});

Expand Down Expand Up @@ -1232,19 +1232,11 @@ describe('OpenxRtbAdapter', function () {
ext: {
dsp_id: '123',
buyer_id: '456',
brand_id: '789',
paf: {
content_id: 'paf_content_id'
}
brand_id: '789'
}
}]
}],
cur: 'AUS',
ext: {
paf: {
transmission: {version: '12'}
}
}
cur: 'AUS'
};

context('when there is a response, the common response properties', function () {
Expand All @@ -1253,7 +1245,7 @@ describe('OpenxRtbAdapter', function () {
bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0];
bidResponse = deepClone(SAMPLE_BID_RESPONSE);

bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0];
bid = spec.interpretResponse({body: bidResponse}, bidRequest).bids[0];
});

it('should return a price', function () {
Expand Down Expand Up @@ -1308,33 +1300,8 @@ describe('OpenxRtbAdapter', function () {
it('should return adomain', function () {
expect(bid.meta.advertiserDomains).to.equal(bidResponse.seatbid[0].bid[0].adomain);
});

it('should return paf fields', function () {
const paf = {
transmission: {version: '12'},
content_id: 'paf_content_id'
}
expect(bid.meta.paf).to.deep.equal(paf);
});
});

context('when there is more than one response', () => {
let bids;
beforeEach(function () {
bidRequestConfigs = deepClone(SAMPLE_BID_REQUESTS);
bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0];
bidResponse = deepClone(SAMPLE_BID_RESPONSE);
bidResponse.seatbid[0].bid.push(deepClone(bidResponse.seatbid[0].bid[0]));
bidResponse.seatbid[0].bid[1].ext.paf.content_id = 'second_paf'

bids = spec.interpretResponse({body: bidResponse}, bidRequest);
});

it('should not confuse paf content_id', () => {
expect(bids.map(b => b.meta.paf.content_id)).to.eql(['paf_content_id', 'second_paf']);
});
})

context('when the response is a banner', function() {
beforeEach(function () {
bidRequestConfigs = [{
Expand Down Expand Up @@ -1371,7 +1338,7 @@ describe('OpenxRtbAdapter', function () {
cur: 'AUS'
};

bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0];
bid = spec.interpretResponse({body: bidResponse}, bidRequest).bids[0];
});

it('should return the proper mediaType', function () {
Expand Down Expand Up @@ -1420,14 +1387,14 @@ describe('OpenxRtbAdapter', function () {
});

it('should return the proper mediaType', function () {
bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0];
bid = spec.interpretResponse({body: bidResponse}, bidRequest).bids[0];
expect(bid.mediaType).to.equal(Object.keys(bidRequestConfigs[0].mediaTypes)[0]);
});

it('should return the proper mediaType', function () {
const winUrl = 'https//my.win.url';
bidResponse.seatbid[0].bid[0].nurl = winUrl
bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0];
bid = spec.interpretResponse({body: bidResponse}, bidRequest).bids[0];

expect(bid.vastUrl).to.equal(winUrl);
});
Expand Down
62 changes: 62 additions & 0 deletions test/spec/modules/richaudienceBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,53 @@ describe('Richaudience adapter tests', function () {
user: {}
}];

var DEFAULT_PARAMS_NEW_DSA = [{
adUnitCode: 'test-div',
bidId: '2c7c8e9c900244',
mediaTypes: {
banner: {
sizes: [
[300, 250], [300, 600], [728, 90], [970, 250]]
}
},
bidder: 'richaudience',
params: {
bidfloor: 0.5,
pid: 'ADb1f40rmi',
supplyType: 'site',
keywords: 'key1=value1;key2=value2'
},
auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563',
bidRequestsCount: 1,
bidderRequestId: '1858b7382993ca',
ortb2: {
regs: {
ext: {
dsa: {
dsarequired: 2,
pubrender: 1,
datatopub: 1,
transparency: [
{
domain: 'richaudience.com',
dsaparams: [1, 3, 6]
},
{
domain: 'adpone.com',
dsaparams: [8, 10, 12]
},
{
domain: 'sunmedia.com',
dsaparams: [14, 16, 18]
}
]
}
}
}
},
user: {}
}];

var DEFAULT_PARAMS_NEW_SIZES_GPID = [{
adUnitCode: 'test-div',
bidId: '2c7c8e9c900244',
Expand Down Expand Up @@ -893,6 +940,21 @@ describe('Richaudience adapter tests', function () {
expect(requestContent).to.have.property('schain').to.deep.equal(schain);
})

it('should pass DSA', function() {
const request = spec.buildRequests(DEFAULT_PARAMS_NEW_DSA, {
gdprConsent: {
consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA',
gdprApplies: true
},
refererInfo: {}
})
const requestContent = JSON.parse(request[0].data);
expect(requestContent).to.have.property('dsa').property('dsarequired').and.to.equal(2)
expect(requestContent).to.have.property('dsa').property('pubrender').and.to.equal(1);
expect(requestContent).to.have.property('dsa').property('datatopub').and.to.equal(1);
expect(requestContent.dsa.transparency[0]).to.have.property('domain').and.to.equal('richaudience.com');
})

it('should pass gpid', function() {
const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES_GPID, {
gdprConsent: {
Expand Down

0 comments on commit e2e4223

Please sign in to comment.