From f2a376b069c3c4160cc245d7e8e7a334f628c914 Mon Sep 17 00:00:00 2001 From: Philip Watson Date: Fri, 9 Feb 2024 13:47:11 +1300 Subject: [PATCH] StroeerCore Bid Adapter: add DSA support --- modules/stroeerCoreBidAdapter.js | 11 +++- .../modules/stroeerCoreBidAdapter_spec.js | 60 +++++++++++++++++-- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/modules/stroeerCoreBidAdapter.js b/modules/stroeerCoreBidAdapter.js index 307a50c7f78..89ed6995a7e 100644 --- a/modules/stroeerCoreBidAdapter.js +++ b/modules/stroeerCoreBidAdapter.js @@ -1,4 +1,4 @@ -import { buildUrl, deepAccess, generateUUID, getWindowSelf, getWindowTop, isEmpty, isStr, logWarn } from '../src/utils.js'; +import { buildUrl, deepAccess, deepSetValue, generateUUID, getWindowSelf, getWindowTop, isEmpty, isStr, logWarn } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {find} from '../src/polyfill.js'; @@ -76,6 +76,12 @@ export const spec = { }; } + const DSA_KEY = 'ortb2.regs.ext.dsa'; + const dsa = deepAccess(bidderRequest, DSA_KEY); + if (dsa) { + deepSetValue(basePayload, DSA_KEY, dsa); + } + const bannerBids = validBidRequests .filter(hasBanner) .map(mapToPayloadBannerBid); @@ -108,7 +114,8 @@ export const spec = { netRevenue: true, creativeId: '', meta: { - advertiserDomains: bidResponse.adomain + advertiserDomains: bidResponse.adomain, + dsa: bidResponse.dsa }, mediaType, }; diff --git a/test/spec/modules/stroeerCoreBidAdapter_spec.js b/test/spec/modules/stroeerCoreBidAdapter_spec.js index 2ed5f80f152..66e0da6ddf8 100644 --- a/test/spec/modules/stroeerCoreBidAdapter_spec.js +++ b/test/spec/modules/stroeerCoreBidAdapter_spec.js @@ -844,6 +844,39 @@ describe('stroeerCore bid adapter', function () { assert.nestedPropertyVal(bid, 'ban.fp.cur', 'EUR'); assert.deepNestedPropertyVal(bid, 'ban.fp.siz', [{w: 160, h: 60, p: 2.7}]); }); + + it('should add the DSA signals', () => { + const bidReq = buildBidderRequest(); + const dsa = { + dsarequired: 3, + pubrender: 0, + datatopub: 2, + transparency: [ + { + domain: 'testplatform.com', + dsaparams: [1], + }, + { + domain: 'testdomain.com', + dsaparams: [1, 2] + } + ] + } + const ortb2 = { + regs: { + ext: { + dsa + } + } + } + + bidReq.ortb2 = utils.deepClone(ortb2); + + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); + const sentOrtb2 = serverRequestInfo.data.ortb2; + + assert.deepEqual(sentOrtb2, ortb2); + }); }); }); }); @@ -882,13 +915,32 @@ describe('stroeerCore bid adapter', function () { assertStandardFieldsOnVideoBid(videoBidResponse, 'bid1', 'video', 800, 250, 4); }) - it('should add data to meta object', () => { + it('should add advertiser domains to meta object', () => { const response = buildBidderResponse(); response.bids[0] = Object.assign(response.bids[0], {adomain: ['website.org', 'domain.com']}); const result = spec.interpretResponse({body: response}); - assert.deepPropertyVal(result[0], 'meta', {advertiserDomains: ['website.org', 'domain.com']}); - // nothing provided for the second bid - assert.deepPropertyVal(result[1], 'meta', {advertiserDomains: undefined}); + assert.deepPropertyVal(result[0].meta, 'advertiserDomains', ['website.org', 'domain.com']); + assert.propertyVal(result[1].meta, 'advertiserDomains', undefined); + }); + + it('should add dsa info to meta object', () => { + const dsaResponse = { + behalf: 'AdvertiserA', + paid: 'AdvertiserB', + transparency: [{ + domain: 'dspexample.com', + dsaparams: [1, 2], + }], + adrender: 1 + }; + + const response = buildBidderResponse(); + response.bids[0] = Object.assign(response.bids[0], {dsa: utils.deepClone(dsaResponse)}); + + const result = spec.interpretResponse({body: response}); + + assert.deepPropertyVal(result[0].meta, 'dsa', dsaResponse); + assert.propertyVal(result[1].meta, 'dsa', undefined); }); });