From 75f5bdfba8acbdcd4180e6244f7ef4fd98bdc31c Mon Sep 17 00:00:00 2001 From: vincentproxistore <56686565+vincentproxistore@users.noreply.github.com> Date: Mon, 12 Apr 2021 11:37:54 +0200 Subject: [PATCH] Proxistore Bid Adapter: add support for tcf v2 consent (#6543) * use tcf v2 consent * set cosentGiven to false and test Gdpr api v2 --- modules/proxistoreBidAdapter.js | 32 ++++----- .../spec/modules/proxistoreBidAdapter_spec.js | 72 +++++++++++++------ 2 files changed, 65 insertions(+), 39 deletions(-) diff --git a/modules/proxistoreBidAdapter.js b/modules/proxistoreBidAdapter.js index 0b553ce995b..9b1675722be 100644 --- a/modules/proxistoreBidAdapter.js +++ b/modules/proxistoreBidAdapter.js @@ -1,5 +1,4 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; - const BIDDER_CODE = 'proxistore'; const PROXISTORE_VENDOR_ID = 418; @@ -27,38 +26,35 @@ function _createServerRequest(bidRequests, bidderRequest) { language: bidRequests[0].params.language, gdpr: { applies: false, + consentGiven: false }, }; if (bidderRequest && bidderRequest.gdprConsent) { - if ( - typeof bidderRequest.gdprConsent.gdprApplies === 'boolean' && - bidderRequest.gdprConsent.gdprApplies - ) { + const { gdprConsent } = bidderRequest; + if (typeof gdprConsent.gdprApplies === 'boolean' && gdprConsent.gdprApplies) { payload.gdpr.applies = true; } - if ( - typeof bidderRequest.gdprConsent.consentString === 'string' && - bidderRequest.gdprConsent.consentString - ) { + if (typeof gdprConsent.consentString === 'string' && gdprConsent.consentString) { payload.gdpr.consentString = bidderRequest.gdprConsent.consentString; } - - if ( - bidderRequest.gdprConsent.vendorData && - bidderRequest.gdprConsent.vendorData.vendorConsents && - typeof bidderRequest.gdprConsent.vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined' - ) { - payload.gdpr.consentGiven = !!bidderRequest.gdprConsent.vendorData - .vendorConsents[PROXISTORE_VENDOR_ID.toString(10)]; + if (gdprConsent.vendorData) { + const {vendorData} = gdprConsent; + const {apiVersion} = gdprConsent; + if (apiVersion === 2 && vendorData.vendor && vendorData.vendor.consents && typeof vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined') { + payload.gdpr.consentGiven = !!vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)]; + } else if (apiVersion === 1 && vendorData.vendorConsents && typeof vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined') { + payload.gdpr.consentGiven = !!vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)]; + } } } const options = { contentType: 'application/json', - withCredentials: !!payload.gdpr.consentGiven, + withCredentials: payload.gdpr.consentGiven, }; + const endPointUri = payload.gdpr.consentGiven || !payload.gdpr.applies ? `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi` : `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi/cookieless`; diff --git a/test/spec/modules/proxistoreBidAdapter_spec.js b/test/spec/modules/proxistoreBidAdapter_spec.js index f98d9633320..e7db01828e0 100644 --- a/test/spec/modules/proxistoreBidAdapter_spec.js +++ b/test/spec/modules/proxistoreBidAdapter_spec.js @@ -2,16 +2,20 @@ import { expect } from 'chai'; let { spec } = require('modules/proxistoreBidAdapter'); const BIDDER_CODE = 'proxistore'; describe('ProxistoreBidAdapter', function () { + const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; const bidderRequest = { bidderCode: BIDDER_CODE, auctionId: '1025ba77-5463-4877-b0eb-14b205cb9304', bidderRequestId: '10edf38ec1a719', gdprConsent: { + apiVersion: 2, gdprApplies: true, - consentString: 'CONSENT_STRING', + consentString: consentString, vendorData: { - vendorConsents: { - 418: true, + vendor: { + consents: { + 418: true, + }, }, }, }, @@ -75,6 +79,29 @@ describe('ProxistoreBidAdapter', function () { expect(request.url).equal(url.cookieBase); // doens't have gpdr consent bidderRequest.gdprConsent.vendorData = null; + + request = spec.buildRequests([bid], bidderRequest); + expect(request.url).equal(url.cookieLess); + + // api v2 + bidderRequest.gdprConsent = { + gdprApplies: true, + allowAuctionWithoutConsent: true, + consentString: consentString, + vendorData: { + vendor: { + consents: { + '418': true + } + }, + }, + apiVersion: 2 + }; + // has gdpr consent + request = spec.buildRequests([bid], bidderRequest); + expect(request.url).equal(url.cookieBase); + + bidderRequest.gdprConsent.vendorData.vendor = {}; request = spec.buildRequests([bid], bidderRequest); expect(request.url).equal(url.cookieLess); }); @@ -105,26 +132,29 @@ describe('ProxistoreBidAdapter', function () { expect(data.bids[0].floor).to.be.null; }); }); - describe('interpretResponse', function() { - const emptyResponseParam = {body: []}; - const fakeResponseParam = {body: [ - { ad: '', - cpm: 6.25, - creativeId: '22c3290b-8cd5-4cd6-8e8c-28a2de180ccd', - currency: 'EUR', - dealId: '2021-03_a63ec55e-b9bb-4ca4-b2c9-f456be67e656', - height: 600, - netRevenue: true, - requestId: '3543724f2a033c9', - segments: [], - ttl: 10, - vastUrl: null, - vastXml: null, - width: 300} - ] + describe('interpretResponse', function () { + const emptyResponseParam = { body: [] }; + const fakeResponseParam = { + body: [ + { + ad: '', + cpm: 6.25, + creativeId: '22c3290b-8cd5-4cd6-8e8c-28a2de180ccd', + currency: 'EUR', + dealId: '2021-03_a63ec55e-b9bb-4ca4-b2c9-f456be67e656', + height: 600, + netRevenue: true, + requestId: '3543724f2a033c9', + segments: [], + ttl: 10, + vastUrl: null, + vastXml: null, + width: 300, + }, + ], }; - it('should always return an array', function() { + it('should always return an array', function () { let response = spec.interpretResponse(emptyResponseParam, bid); expect(response).to.be.an('array'); expect(response.length).equal(0);