From ce15b44d4c9201c749a007557e31d187a37001c1 Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Thu, 18 Nov 2021 18:15:53 +0300 Subject: [PATCH 01/23] add uspConsent to sunc URL --- modules/kubientBidAdapter.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 07c614230a7..465abbb0d99 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -110,24 +110,27 @@ export const spec = { }, getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - let gdprParams = ''; + let params = ''; if (gdprConsent && typeof gdprConsent.consentString === 'string') { - gdprParams = `?consent_str=${gdprConsent.consentString}`; + params = `?consent_str=${gdprConsent.consentString}`; if (typeof gdprConsent.gdprApplies === 'boolean') { - gdprParams = gdprParams + `&gdpr=${Number(gdprConsent.gdprApplies)}`; + params = params + `&gdpr=${Number(gdprConsent.gdprApplies)}`; } - gdprParams = gdprParams + `&consent_given=` + kubientGetConsentGiven(gdprConsent); + params = params + `&consent_given=` + kubientGetConsentGiven(gdprConsent); + } + if (uspConsent) { + params += `${params ? '&' : '?'}us_privacy=${encodeURIComponent(uspConsent)}`; } if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: 'https://kdmp.kbntx.ch/init.html' + gdprParams + url: 'https://kdmp.kbntx.ch/init.html' + params }); } if (syncOptions.pixelEnabled) { syncs.push({ type: 'image', - url: 'https://kdmp.kbntx.ch/init.png' + gdprParams + url: 'https://kdmp.kbntx.ch/init.png' + params }); } return syncs; From 29f9866e85324e054438124fe0e9e1bf2fd16c20 Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Mon, 6 Dec 2021 17:03:21 +0300 Subject: [PATCH 02/23] kubient: add coppa --- modules/kubientBidAdapter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 465abbb0d99..657a4563aa8 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,6 +1,7 @@ import { isArray, deepAccess } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'kubient'; const END_POINT = 'https://kssp.kbntx.ch/kubprebidjs'; @@ -59,7 +60,12 @@ export const spec = { gdpr: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0, consentGiven: kubientGetConsentGiven(bidderRequest.gdprConsent), uspConsent: bidderRequest.uspConsent - }; + } + + if (config.getConfig('coppa') === true) { + data.coppa = 1 + } + if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { data.referer = bidderRequest.refererInfo.referer From d0ddee7159ac52ead9b864020ac16d4e0beca05d Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Tue, 7 Dec 2021 13:16:36 +0300 Subject: [PATCH 03/23] added test for coppa --- modules/kubientBidAdapter.js | 1 - test/spec/modules/kubientBidAdapter_spec.js | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 657a4563aa8..d8ab9f4f0e3 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -66,7 +66,6 @@ export const spec = { data.coppa = 1 } - if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { data.referer = bidderRequest.refererInfo.referer } diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 5449de0c4de..90edc5d55d3 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -292,6 +292,22 @@ describe('KubientAdapter', function () { }); }); + describe('with COPPA', function() { + beforeEach(function() { + sinon.stub(config, 'getConfig') + .withArgs('coppa') + .returns(true); + }); + afterEach(function() { + config.getConfig.restore(); + }); + + it('should send the Coppa "required" flag set to "1" in the request', function () { + let serverRequest = spec.buildRequests([bidBanner]); + expect(serverRequest.data.coppa).to.equal(1); + }); + }); + describe('getUserSyncs', function () { it('should register the sync iframe without gdpr', function () { let syncOptions = { From 9693ce43da37fdd26a59eceff683b1a698a97a22 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Tue, 7 Dec 2021 18:01:53 +0300 Subject: [PATCH 04/23] fix-test --- test/spec/modules/kubientBidAdapter_spec.js | 44 +++++++++++++-------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 90edc5d55d3..f9e70c27980 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -292,22 +292,6 @@ describe('KubientAdapter', function () { }); }); - describe('with COPPA', function() { - beforeEach(function() { - sinon.stub(config, 'getConfig') - .withArgs('coppa') - .returns(true); - }); - afterEach(function() { - config.getConfig.restore(); - }); - - it('should send the Coppa "required" flag set to "1" in the request', function () { - let serverRequest = spec.buildRequests([bidBanner]); - expect(serverRequest.data.coppa).to.equal(1); - }); - }); - describe('getUserSyncs', function () { it('should register the sync iframe without gdpr', function () { let syncOptions = { @@ -411,5 +395,33 @@ describe('KubientAdapter', function () { expect(syncs[0].type).to.equal('image'); expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&gdpr=1&consent_given=1'); }); + it('should register the sync image without gdpr and with uspConsent', function () { + let syncOptions = { + iframeEnabled: true + }; + let serverResponses = null; + let gdprConsent = { + consentString: consentString + }; + let uspConsent = '1YNN'; + let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + expect(syncs).to.be.an('array').and.to.have.length(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.html?consent_str=' + consentString + '&consent_given=0&us_privacy=' + uspConsent); + }); + it('should register the sync image without gdpr and with uspConsent', function () { + let syncOptions = { + pixelEnabled: true + }; + let serverResponses = null; + let gdprConsent = { + consentString: consentString + }; + let uspConsent = '1YNN'; + let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + expect(syncs).to.be.an('array').and.to.have.length(1); + expect(syncs[0].type).to.equal('image'); + expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&consent_given=0&us_privacy=' + uspConsent); + }); }) }); From bea48019ebb3d09dae6441779269e0b774fecb14 Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Thu, 9 Dec 2021 14:19:54 +0300 Subject: [PATCH 05/23] replace kdmp.kbntx.ch by matching.kubient.net remove iframe pixel support rename us_privacy -> usp rename consent_str -> consent use URLSearchParams for GET params --- modules/kubientBidAdapter.js | 21 +++--- test/spec/modules/kubientBidAdapter_spec.js | 72 ++------------------- 2 files changed, 13 insertions(+), 80 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index d8ab9f4f0e3..ba3cd91c950 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,8 +1,10 @@ import { isArray, deepAccess } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; +import URLSearchParams from 'core-js-pure/web/url-search-params' import {BANNER, VIDEO} from '../src/mediaTypes.js'; import { config } from '../src/config.js'; + const BIDDER_CODE = 'kubient'; const END_POINT = 'https://kssp.kbntx.ch/kubprebidjs'; const VERSION = '1.1'; @@ -115,27 +117,22 @@ export const spec = { }, getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - let params = ''; + var values = new URLSearchParams(); + if (gdprConsent && typeof gdprConsent.consentString === 'string') { - params = `?consent_str=${gdprConsent.consentString}`; + values.append("consent", gdprConsent.consentString); if (typeof gdprConsent.gdprApplies === 'boolean') { - params = params + `&gdpr=${Number(gdprConsent.gdprApplies)}`; + values.append("gdpr", Number(gdprConsent.gdprApplies)); } - params = params + `&consent_given=` + kubientGetConsentGiven(gdprConsent); } if (uspConsent) { - params += `${params ? '&' : '?'}us_privacy=${encodeURIComponent(uspConsent)}`; - } - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: 'https://kdmp.kbntx.ch/init.html' + params - }); + values.append("usp", uspConsent); } + if (syncOptions.pixelEnabled) { syncs.push({ type: 'image', - url: 'https://kdmp.kbntx.ch/init.png' + params + url: 'https://matching.kubient.net/match/sp?' + values.toString() }); } return syncs; diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index f9e70c27980..cb7c05e8e80 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -293,56 +293,6 @@ describe('KubientAdapter', function () { }); describe('getUserSyncs', function () { - it('should register the sync iframe without gdpr', function () { - let syncOptions = { - iframeEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - consentString: consentString - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.html?consent_str=' + consentString + '&consent_given=0'); - }); - it('should register the sync iframe with gdpr', function () { - let syncOptions = { - iframeEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - gdprApplies: true, - consentString: consentString - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.html?consent_str=' + consentString + '&gdpr=1&consent_given=0'); - }); - it('should register the sync iframe with gdpr vendor', function () { - let syncOptions = { - iframeEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - gdprApplies: true, - consentString: consentString, - apiVersion: 1, - vendorData: { - vendorConsents: { - 794: 1 - } - } - }; - let uspConsent = null; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.html?consent_str=' + consentString + '&gdpr=1&consent_given=1'); - }); it('should register the sync image without gdpr', function () { let syncOptions = { pixelEnabled: true @@ -355,7 +305,7 @@ describe('KubientAdapter', function () { let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&consent_given=0'); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?consent=' + consentString); }); it('should register the sync image with gdpr', function () { let syncOptions = { @@ -370,7 +320,7 @@ describe('KubientAdapter', function () { let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&gdpr=1&consent_given=0'); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?consent=' + consentString + '&gdpr=1'); }); it('should register the sync image with gdpr vendor', function () { let syncOptions = { @@ -393,21 +343,7 @@ describe('KubientAdapter', function () { let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&gdpr=1&consent_given=1'); - }); - it('should register the sync image without gdpr and with uspConsent', function () { - let syncOptions = { - iframeEnabled: true - }; - let serverResponses = null; - let gdprConsent = { - consentString: consentString - }; - let uspConsent = '1YNN'; - let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - expect(syncs).to.be.an('array').and.to.have.length(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.html?consent_str=' + consentString + '&consent_given=0&us_privacy=' + uspConsent); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?consent=' + consentString + '&gdpr=1'); }); it('should register the sync image without gdpr and with uspConsent', function () { let syncOptions = { @@ -421,7 +357,7 @@ describe('KubientAdapter', function () { let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://kdmp.kbntx.ch/init.png?consent_str=' + consentString + '&consent_given=0&us_privacy=' + uspConsent); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?consent=' + consentString + '&usp=' + uspConsent); }); }) }); From 3511dcc58302802d1ded26e5192f4c90a03af0df Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 10 Dec 2021 01:38:49 +0300 Subject: [PATCH 06/23] fix-test-and-code --- modules/kubientBidAdapter.js | 11 +- test/spec/modules/kubientBidAdapter_spec.js | 109 +++++++++++++++++++- 2 files changed, 110 insertions(+), 10 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index ba3cd91c950..d9b4220acbc 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,10 +1,9 @@ import { isArray, deepAccess } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import URLSearchParams from 'core-js-pure/web/url-search-params' +import URLSearchParams from 'core-js-pure/web/url-search-params'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import { config } from '../src/config.js'; - const BIDDER_CODE = 'kubient'; const END_POINT = 'https://kssp.kbntx.ch/kubprebidjs'; const VERSION = '1.1'; @@ -117,16 +116,16 @@ export const spec = { }, getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - var values = new URLSearchParams(); + let values = new URLSearchParams(); if (gdprConsent && typeof gdprConsent.consentString === 'string') { - values.append("consent", gdprConsent.consentString); + values.append('consent', gdprConsent.consentString); if (typeof gdprConsent.gdprApplies === 'boolean') { - values.append("gdpr", Number(gdprConsent.gdprApplies)); + values.append('gdpr', Number(gdprConsent.gdprApplies)); } } if (uspConsent) { - values.append("usp", uspConsent); + values.append('usp', uspConsent); } if (syncOptions.pixelEnabled) { diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index cb7c05e8e80..04392ab8d21 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -1,6 +1,8 @@ import { expect, assert } from 'chai'; import { spec } from 'modules/kubientBidAdapter.js'; import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; +import URLSearchParams from 'core-js-pure/web/url-search-params'; +import {config} from '../../../src/config'; describe('KubientAdapter', function () { let bidBanner = { @@ -175,6 +177,94 @@ describe('KubientAdapter', function () { }); } }); + describe('buildRequestBanner', function () { + config.setConfig({coppa: true}); + let serverRequests = spec.buildRequests([bidBanner], Object.assign({}, bidderRequest, {bids: [bidBanner]})); + config.resetConfig(); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequests).to.be.an('array'); + }); + for (let i = 0; i < serverRequests.length; i++) { + let serverRequest = serverRequests[i]; + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest.method).to.be.a('string'); + expect(serverRequest.url).to.be.a('string'); + expect(serverRequest.data).to.be.a('string'); + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/kubprebidjs'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = JSON.parse(serverRequest.data); + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('v', 'requestId', 'adSlots', 'gdpr', 'coppa', 'referer', 'tmax', 'consent', 'consentGiven', 'uspConsent'); + expect(data.v).to.exist.and.to.be.a('string'); + expect(data.requestId).to.exist.and.to.be.a('string'); + expect(data.coppa).to.be.a('number').and.to.equal(1); + expect(data.referer).to.be.a('string'); + expect(data.tmax).to.exist.and.to.be.a('number'); + expect(data.gdpr).to.exist.and.to.be.within(0, 1); + expect(data.consent).to.equal(consentString); + expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); + for (let j = 0; j < data['adSlots'].length; j++) { + let adSlot = data['adSlots'][i]; + expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain'); + expect(adSlot.bidId).to.be.a('string').and.to.equal(bidBanner.bidId); + expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidBanner.params.zoneid); + expect(adSlot.floor).to.be.a('number'); + expect(adSlot.schain).to.be.an('object'); + expect(adSlot.banner).to.be.an('object'); + } + }); + } + }); + describe('buildRequestVideo', function () { + config.setConfig({coppa: true}); + let serverRequests = spec.buildRequests([bidVideo], Object.assign({}, bidderRequest, {bids: [bidVideo]})); + config.resetConfig(); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequests).to.be.an('array'); + }); + for (let i = 0; i < serverRequests.length; i++) { + let serverRequest = serverRequests[i]; + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest.method).to.be.a('string'); + expect(serverRequest.url).to.be.a('string'); + expect(serverRequest.data).to.be.a('string'); + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/kubprebidjs'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = JSON.parse(serverRequest.data); + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('v', 'requestId', 'adSlots', 'gdpr', 'coppa', 'referer', 'tmax', 'consent', 'consentGiven', 'uspConsent'); + expect(data.v).to.exist.and.to.be.a('string'); + expect(data.requestId).to.exist.and.to.be.a('string'); + expect(data.coppa).to.be.a('number').and.to.equal(1); + expect(data.referer).to.be.a('string'); + expect(data.tmax).to.exist.and.to.be.a('number'); + expect(data.gdpr).to.exist.and.to.be.within(0, 1); + expect(data.consent).to.equal(consentString); + expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); + for (let j = 0; j < data['adSlots'].length; j++) { + let adSlot = data['adSlots'][i]; + expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'video', 'schain'); + expect(adSlot.bidId).to.be.a('string').and.to.equal(bidVideo.bidId); + expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidVideo.params.zoneid); + expect(adSlot.floor).to.be.a('number'); + expect(adSlot.schain).to.be.an('object'); + expect(adSlot.video).to.be.an('object'); + } + }); + } + }); describe('isBidRequestValid', function () { it('Should return true when required params are found', function () { @@ -297,20 +387,23 @@ describe('KubientAdapter', function () { let syncOptions = { pixelEnabled: true }; + let values = new URLSearchParams(); let serverResponses = null; let gdprConsent = { consentString: consentString }; let uspConsent = null; let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + values.append('consent', consentString); expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?consent=' + consentString); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + values.toString()); }); it('should register the sync image with gdpr', function () { let syncOptions = { pixelEnabled: true }; + let values = new URLSearchParams(); let serverResponses = null; let gdprConsent = { gdprApplies: true, @@ -318,14 +411,17 @@ describe('KubientAdapter', function () { }; let uspConsent = null; let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + values.append('consent', consentString); + values.append('gdpr', 1); expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?consent=' + consentString + '&gdpr=1'); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + values.toString()); }); it('should register the sync image with gdpr vendor', function () { let syncOptions = { pixelEnabled: true }; + let values = new URLSearchParams(); let serverResponses = null; let gdprConsent = { gdprApplies: true, @@ -341,23 +437,28 @@ describe('KubientAdapter', function () { }; let uspConsent = null; let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + values.append('consent', consentString); + values.append('gdpr', 1); expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?consent=' + consentString + '&gdpr=1'); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + values.toString()); }); it('should register the sync image without gdpr and with uspConsent', function () { let syncOptions = { pixelEnabled: true }; + let values = new URLSearchParams(); let serverResponses = null; let gdprConsent = { consentString: consentString }; let uspConsent = '1YNN'; let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + values.append('consent', consentString); + values.append('usp', uspConsent); expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?consent=' + consentString + '&usp=' + uspConsent); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + values.toString()); }); }) }); From 290ee9737cfff148f10676d5dac1badc5e65f2dc Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Wed, 29 Dec 2021 16:33:41 +0300 Subject: [PATCH 07/23] removed URLSearchParams --- modules/kubientBidAdapter.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index d9b4220acbc..8130bf5b0e4 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,6 +1,5 @@ import { isArray, deepAccess } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import URLSearchParams from 'core-js-pure/web/url-search-params'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import { config } from '../src/config.js'; @@ -116,28 +115,34 @@ export const spec = { }, getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - let values = new URLSearchParams(); + let values = {}; if (gdprConsent && typeof gdprConsent.consentString === 'string') { - values.append('consent', gdprConsent.consentString); + values['consent'] = gdprConsent.consentString; if (typeof gdprConsent.gdprApplies === 'boolean') { - values.append('gdpr', Number(gdprConsent.gdprApplies)); + values['gdpr'] = Number(gdprConsent.gdprApplies); } } if (uspConsent) { - values.append('usp', uspConsent); + values['usp'] = uspConsent; } if (syncOptions.pixelEnabled) { syncs.push({ type: 'image', - url: 'https://matching.kubient.net/match/sp?' + values.toString() + url: 'https://matching.kubient.net/match/sp?' + encodeQueryData(values) }); } return syncs; } }; +function encodeQueryData(data) { + return Object.keys(data).map(function(key) { + return [key, data[key]].map(encodeURIComponent).join('='); + }).join('&'); +}; + function kubientGetConsentGiven(gdprConsent) { let consentGiven = 0; if (typeof gdprConsent !== 'undefined') { From 6dcf684eb598fe63185c29e3af02d96005a23521 Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Wed, 29 Dec 2021 17:07:01 +0300 Subject: [PATCH 08/23] early exit for getUserSyncs, updated test --- modules/kubientBidAdapter.js | 16 ++++----- test/spec/modules/kubientBidAdapter_spec.js | 37 ++++++++++++--------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 8130bf5b0e4..61f599a00b3 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -114,7 +114,10 @@ export const spec = { return bidResponses; }, getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = []; + if (!syncOptions.pixelEnabled) { + return []; + } + let values = {}; if (gdprConsent && typeof gdprConsent.consentString === 'string') { @@ -127,13 +130,10 @@ export const spec = { values['usp'] = uspConsent; } - if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: 'https://matching.kubient.net/match/sp?' + encodeQueryData(values) - }); - } - return syncs; + return [{ + type: 'image', + url: 'https://matching.kubient.net/match/sp?' + encodeQueryData(values) + }]; } }; diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 04392ab8d21..7ebe5dad4ac 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -1,9 +1,14 @@ import { expect, assert } from 'chai'; import { spec } from 'modules/kubientBidAdapter.js'; import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; -import URLSearchParams from 'core-js-pure/web/url-search-params'; import {config} from '../../../src/config'; +function encodeQueryData(data) { + return Object.keys(data).map(function(key) { + return [key, data[key]].map(encodeURIComponent).join('='); + }).join('&'); +}; + describe('KubientAdapter', function () { let bidBanner = { bidId: '2dd581a2b6281d', @@ -387,23 +392,23 @@ describe('KubientAdapter', function () { let syncOptions = { pixelEnabled: true }; - let values = new URLSearchParams(); + let values = {}; let serverResponses = null; let gdprConsent = { consentString: consentString }; let uspConsent = null; let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - values.append('consent', consentString); + values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + values.toString()); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + encodeQueryData(values)); }); it('should register the sync image with gdpr', function () { let syncOptions = { pixelEnabled: true }; - let values = new URLSearchParams(); + let values = {}; let serverResponses = null; let gdprConsent = { gdprApplies: true, @@ -411,17 +416,17 @@ describe('KubientAdapter', function () { }; let uspConsent = null; let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - values.append('consent', consentString); - values.append('gdpr', 1); + values['consent'] = consentString; + values['gdpr'] = 1; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + values.toString()); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + encodeQueryData(values)); }); it('should register the sync image with gdpr vendor', function () { let syncOptions = { pixelEnabled: true }; - let values = new URLSearchParams(); + let values = {}; let serverResponses = null; let gdprConsent = { gdprApplies: true, @@ -437,28 +442,28 @@ describe('KubientAdapter', function () { }; let uspConsent = null; let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - values.append('consent', consentString); - values.append('gdpr', 1); + values['consent'] = consentString; + values['gdpr'] = 1; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + values.toString()); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + encodeQueryData(values)); }); it('should register the sync image without gdpr and with uspConsent', function () { let syncOptions = { pixelEnabled: true }; - let values = new URLSearchParams(); + let values = {}; let serverResponses = null; let gdprConsent = { consentString: consentString }; let uspConsent = '1YNN'; let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - values.append('consent', consentString); - values.append('usp', uspConsent); + values['consent'] = consentString; + values['usp'] = uspConsent; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + values.toString()); + expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + encodeQueryData(values)); }); }) }); From f6b708341d92d43891b2b0dd402c1a549b980e92 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Wed, 29 Dec 2021 21:11:08 +0300 Subject: [PATCH 09/23] test-back --- modules/kubientBidAdapter.js | 45 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 61f599a00b3..07c614230a7 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,7 +1,6 @@ import { isArray, deepAccess } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; const BIDDER_CODE = 'kubient'; const END_POINT = 'https://kssp.kbntx.ch/kubprebidjs'; @@ -60,11 +59,7 @@ export const spec = { gdpr: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0, consentGiven: kubientGetConsentGiven(bidderRequest.gdprConsent), uspConsent: bidderRequest.uspConsent - } - - if (config.getConfig('coppa') === true) { - data.coppa = 1 - } + }; if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { data.referer = bidderRequest.refererInfo.referer @@ -114,35 +109,31 @@ export const spec = { return bidResponses; }, getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { - if (!syncOptions.pixelEnabled) { - return []; - } - - let values = {}; - + const syncs = []; + let gdprParams = ''; if (gdprConsent && typeof gdprConsent.consentString === 'string') { - values['consent'] = gdprConsent.consentString; + gdprParams = `?consent_str=${gdprConsent.consentString}`; if (typeof gdprConsent.gdprApplies === 'boolean') { - values['gdpr'] = Number(gdprConsent.gdprApplies); + gdprParams = gdprParams + `&gdpr=${Number(gdprConsent.gdprApplies)}`; } + gdprParams = gdprParams + `&consent_given=` + kubientGetConsentGiven(gdprConsent); } - if (uspConsent) { - values['usp'] = uspConsent; + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: 'https://kdmp.kbntx.ch/init.html' + gdprParams + }); } - - return [{ - type: 'image', - url: 'https://matching.kubient.net/match/sp?' + encodeQueryData(values) - }]; + if (syncOptions.pixelEnabled) { + syncs.push({ + type: 'image', + url: 'https://kdmp.kbntx.ch/init.png' + gdprParams + }); + } + return syncs; } }; -function encodeQueryData(data) { - return Object.keys(data).map(function(key) { - return [key, data[key]].map(encodeURIComponent).join('='); - }).join('&'); -}; - function kubientGetConsentGiven(gdprConsent) { let consentGiven = 0; if (typeof gdprConsent !== 'undefined') { From 6c0ceedf2e165471736dd7eb26491d0d29ed66c3 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 31 Dec 2021 00:15:37 +0300 Subject: [PATCH 10/23] test-filter-settings --- modules/kubientBidAdapter.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 07c614230a7..49fe02e5ad3 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,11 +1,31 @@ -import { isArray, deepAccess } from '../src/utils.js'; +import {isArray, deepAccess, contains} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {config} from "../src/config"; const BIDDER_CODE = 'kubient'; const END_POINT = 'https://kssp.kbntx.ch/kubprebidjs'; const VERSION = '1.1'; const VENDOR_ID = 794; + +function kubientGetSyncInclude(config) { + try { + let kubientSync = {}; + if (config.getConfig('userSync').filterSettings != null && typeof config.getConfig('userSync').filterSettings != 'undefined') { + let filterSettings = config.getConfig('userSync').filterSettings + if (filterSettings.iframe !== null && typeof filterSettings.iframe !== 'undefined') { + kubientSync.iframe = ((isArray(filterSettings.image.bidders) && filterSettings.iframe.bidders.indexOf('kubient') !== -1) || filterSettings.iframe.bidders === '*') ? filterSettings.iframe.filter : 'exclude'; + } + if (filterSettings.image !== null && typeof filterSettings.image !== 'undefined') { + kubientSync.image = ((isArray(filterSettings.image.bidders) && filterSettings.image.bidders.indexOf('kubient') !== -1) || filterSettings.image.bidders === '*') ? filterSettings.image.filter : 'exclude'; + } + } + return kubientSync; + } catch (e) { + return null; + } +} + export const spec = { code: BIDDER_CODE, gvlid: VENDOR_ID, @@ -110,6 +130,8 @@ export const spec = { }, getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; + + let kubientSync = kubientGetSyncInclude(config); let gdprParams = ''; if (gdprConsent && typeof gdprConsent.consentString === 'string') { gdprParams = `?consent_str=${gdprConsent.consentString}`; @@ -118,13 +140,13 @@ export const spec = { } gdprParams = gdprParams + `&consent_given=` + kubientGetConsentGiven(gdprConsent); } - if (syncOptions.iframeEnabled) { + if (syncOptions.iframeEnabled && kubientSync.iframe !== 'exclude') { syncs.push({ type: 'iframe', url: 'https://kdmp.kbntx.ch/init.html' + gdprParams }); } - if (syncOptions.pixelEnabled) { + if (syncOptions.pixelEnabled && kubientSync.image !== 'exclude') { syncs.push({ type: 'image', url: 'https://kdmp.kbntx.ch/init.png' + gdprParams From 4d32180a1f678bb5334ab4905161249fe7daf807 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 31 Dec 2021 00:18:32 +0300 Subject: [PATCH 11/23] test-filter-settings --- modules/kubientBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 49fe02e5ad3..e1f559a85e2 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,7 +1,7 @@ import {isArray, deepAccess, contains} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {config} from "../src/config"; +import {config} from '../src/config.js'; const BIDDER_CODE = 'kubient'; const END_POINT = 'https://kssp.kbntx.ch/kubprebidjs'; From 68720cb9ff8b01eaa71734d7bc1cda12c8a66630 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 31 Dec 2021 00:21:31 +0300 Subject: [PATCH 12/23] test-filter-settings --- modules/kubientBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index e1f559a85e2..eb169771109 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,4 +1,4 @@ -import {isArray, deepAccess, contains} from '../src/utils.js'; +import {isArray, deepAccess} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; From 4fc4bf218ce0f58977f86d6cecc9fb721654f0f2 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 31 Dec 2021 00:37:35 +0300 Subject: [PATCH 13/23] test-filter-settings --- modules/kubientBidAdapter.js | 87 +++++++++++---------- test/spec/modules/kubientBidAdapter_spec.js | 44 +++++++++++ 2 files changed, 91 insertions(+), 40 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index eb169771109..c86ba1bf1ca 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -1,31 +1,12 @@ -import {isArray, deepAccess} from '../src/utils.js'; +import { isArray, deepAccess } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {config} from '../src/config.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'kubient'; const END_POINT = 'https://kssp.kbntx.ch/kubprebidjs'; const VERSION = '1.1'; const VENDOR_ID = 794; - -function kubientGetSyncInclude(config) { - try { - let kubientSync = {}; - if (config.getConfig('userSync').filterSettings != null && typeof config.getConfig('userSync').filterSettings != 'undefined') { - let filterSettings = config.getConfig('userSync').filterSettings - if (filterSettings.iframe !== null && typeof filterSettings.iframe !== 'undefined') { - kubientSync.iframe = ((isArray(filterSettings.image.bidders) && filterSettings.iframe.bidders.indexOf('kubient') !== -1) || filterSettings.iframe.bidders === '*') ? filterSettings.iframe.filter : 'exclude'; - } - if (filterSettings.image !== null && typeof filterSettings.image !== 'undefined') { - kubientSync.image = ((isArray(filterSettings.image.bidders) && filterSettings.image.bidders.indexOf('kubient') !== -1) || filterSettings.image.bidders === '*') ? filterSettings.image.filter : 'exclude'; - } - } - return kubientSync; - } catch (e) { - return null; - } -} - export const spec = { code: BIDDER_CODE, gvlid: VENDOR_ID, @@ -79,7 +60,11 @@ export const spec = { gdpr: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0, consentGiven: kubientGetConsentGiven(bidderRequest.gdprConsent), uspConsent: bidderRequest.uspConsent - }; + } + + if (config.getConfig('coppa') === true) { + data.coppa = 1 + } if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { data.referer = bidderRequest.refererInfo.referer @@ -129,33 +114,37 @@ export const spec = { return bidResponses; }, getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = []; - let kubientSync = kubientGetSyncInclude(config); - let gdprParams = ''; + + if (!syncOptions.pixelEnabled || kubientSync.image === 'exclude') { + return []; + } + + let values = {}; + if (gdprConsent && typeof gdprConsent.consentString === 'string') { - gdprParams = `?consent_str=${gdprConsent.consentString}`; + values['consent'] = gdprConsent.consentString; if (typeof gdprConsent.gdprApplies === 'boolean') { - gdprParams = gdprParams + `&gdpr=${Number(gdprConsent.gdprApplies)}`; + values['gdpr'] = Number(gdprConsent.gdprApplies); } - gdprParams = gdprParams + `&consent_given=` + kubientGetConsentGiven(gdprConsent); } - if (syncOptions.iframeEnabled && kubientSync.iframe !== 'exclude') { - syncs.push({ - type: 'iframe', - url: 'https://kdmp.kbntx.ch/init.html' + gdprParams - }); + if (uspConsent) { + values['usp'] = uspConsent; } - if (syncOptions.pixelEnabled && kubientSync.image !== 'exclude') { - syncs.push({ - type: 'image', - url: 'https://kdmp.kbntx.ch/init.png' + gdprParams - }); - } - return syncs; + + return [{ + type: 'image', + url: 'https://matching.kubient.net/match/sp?' + encodeQueryData(values) + }]; } }; +function encodeQueryData(data) { + return Object.keys(data).map(function(key) { + return [key, data[key]].map(encodeURIComponent).join('='); + }).join('&'); +} + function kubientGetConsentGiven(gdprConsent) { let consentGiven = 0; if (typeof gdprConsent !== 'undefined') { @@ -171,4 +160,22 @@ function kubientGetConsentGiven(gdprConsent) { } return consentGiven; } + +function kubientGetSyncInclude(config) { + try { + let kubientSync = {}; + if (config.getConfig('userSync').filterSettings != null && typeof config.getConfig('userSync').filterSettings != 'undefined') { + let filterSettings = config.getConfig('userSync').filterSettings + if (filterSettings.iframe !== null && typeof filterSettings.iframe !== 'undefined') { + kubientSync.iframe = ((isArray(filterSettings.image.bidders) && filterSettings.iframe.bidders.indexOf('kubient') !== -1) || filterSettings.iframe.bidders === '*') ? filterSettings.iframe.filter : 'exclude'; + } + if (filterSettings.image !== null && typeof filterSettings.image !== 'undefined') { + kubientSync.image = ((isArray(filterSettings.image.bidders) && filterSettings.image.bidders.indexOf('kubient') !== -1) || filterSettings.image.bidders === '*') ? filterSettings.image.filter : 'exclude'; + } + } + return kubientSync; + } catch (e) { + return null; + } +} registerBidder(spec); diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 7ebe5dad4ac..fc15bf692a9 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -398,7 +398,18 @@ describe('KubientAdapter', function () { consentString: consentString }; let uspConsent = null; + config.setConfig({ + userSync: { + filterSettings: { + image: { + bidders: '*', + filter: 'include' + } + } + } + }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + config.resetConfig(); values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); @@ -415,7 +426,18 @@ describe('KubientAdapter', function () { consentString: consentString }; let uspConsent = null; + config.setConfig({ + userSync: { + filterSettings: { + image: { + bidders: '*', + filter: 'include' + } + } + } + }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + config.resetConfig(); values['consent'] = consentString; values['gdpr'] = 1; expect(syncs).to.be.an('array').and.to.have.length(1); @@ -441,7 +463,18 @@ describe('KubientAdapter', function () { } }; let uspConsent = null; + config.setConfig({ + userSync: { + filterSettings: { + image: { + bidders: '*', + filter: 'include' + } + } + } + }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + config.resetConfig(); values['consent'] = consentString; values['gdpr'] = 1; expect(syncs).to.be.an('array').and.to.have.length(1); @@ -458,7 +491,18 @@ describe('KubientAdapter', function () { consentString: consentString }; let uspConsent = '1YNN'; + config.setConfig({ + userSync: { + filterSettings: { + image: { + bidders: '*', + filter: 'include' + } + } + } + }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); + config.resetConfig(); values['consent'] = consentString; values['usp'] = uspConsent; expect(syncs).to.be.an('array').and.to.have.length(1); From bf3d701a009a6faa3a8bc416551d8032bcb410c7 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Mon, 10 Jan 2022 12:43:28 +0300 Subject: [PATCH 14/23] fix for review --- modules/kubientBidAdapter.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index c86ba1bf1ca..380b4368558 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -122,12 +122,13 @@ export const spec = { let values = {}; - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - values['consent'] = gdprConsent.consentString; - if (typeof gdprConsent.gdprApplies === 'boolean') { - values['gdpr'] = Number(gdprConsent.gdprApplies); + if (typeof gdprConsent.gdprApplies === 'boolean') { + values['gdpr'] = Number(gdprConsent.gdprApplies); + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + values['consent'] = gdprConsent.consentString; } } + if (uspConsent) { values['usp'] = uspConsent; } From 0ed0394d218bbbbbbc4bd8d0a22babd19ca8c052 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Mon, 10 Jan 2022 13:02:10 +0300 Subject: [PATCH 15/23] fix for review --- test/spec/modules/kubientBidAdapter_spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index fc15bf692a9..b5055924c55 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -410,7 +410,7 @@ describe('KubientAdapter', function () { }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); config.resetConfig(); - values['consent'] = consentString; + // values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + encodeQueryData(values)); @@ -438,8 +438,8 @@ describe('KubientAdapter', function () { }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); config.resetConfig(); - values['consent'] = consentString; values['gdpr'] = 1; + values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + encodeQueryData(values)); @@ -475,8 +475,8 @@ describe('KubientAdapter', function () { }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); config.resetConfig(); - values['consent'] = consentString; values['gdpr'] = 1; + values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + encodeQueryData(values)); @@ -503,7 +503,7 @@ describe('KubientAdapter', function () { }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); config.resetConfig(); - values['consent'] = consentString; + // values['consent'] = consentString; values['usp'] = uspConsent; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); From b8576d41c97c8eafe2ec27525ca785013e6b5c03 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Wed, 12 Jan 2022 19:09:30 +0300 Subject: [PATCH 16/23] fix test for ci passing --- test/spec/modules/kubientBidAdapter_spec.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index b5055924c55..f890076b5c7 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -7,7 +7,7 @@ function encodeQueryData(data) { return Object.keys(data).map(function(key) { return [key, data[key]].map(encodeURIComponent).join('='); }).join('&'); -}; +} describe('KubientAdapter', function () { let bidBanner = { @@ -102,6 +102,7 @@ describe('KubientAdapter', function () { }; describe('buildRequestBanner', function () { let serverRequests = spec.buildRequests([bidBanner], Object.assign({}, bidderRequest, {bids: [bidBanner]})); + config.resetConfig(); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequests).to.be.an('array'); }); @@ -143,6 +144,7 @@ describe('KubientAdapter', function () { }); describe('buildRequestVideo', function () { let serverRequests = spec.buildRequests([bidVideo], Object.assign({}, bidderRequest, {bids: [bidVideo]})); + config.resetConfig(); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequests).to.be.an('array'); }); @@ -275,16 +277,19 @@ describe('KubientAdapter', function () { it('Should return true when required params are found', function () { expect(spec.isBidRequestValid(bidBanner)).to.be.true; expect(spec.isBidRequestValid(bidVideo)).to.be.true; + config.resetConfig(); }); it('Should return false when required params are not found', function () { expect(spec.isBidRequestValid(bidBanner)).to.be.true; expect(spec.isBidRequestValid(bidVideo)).to.be.true; + config.resetConfig(); }); it('Should return false when params are not found', function () { delete bidBanner.params; expect(spec.isBidRequestValid(bidBanner)).to.be.false; delete bidVideo.params; expect(spec.isBidRequestValid(bidVideo)).to.be.false; + config.resetConfig(); }); }); @@ -314,6 +319,7 @@ describe('KubientAdapter', function () { } }; let bannerResponses = spec.interpretResponse(serverResponse); + config.resetConfig(); expect(bannerResponses).to.be.an('array').that.is.not.empty; let dataItem = bannerResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'ad', 'creativeId', 'width', 'height', 'currency', 'netRevenue', 'ttl', 'meta'); @@ -332,6 +338,7 @@ describe('KubientAdapter', function () { it('Should return no ad when not given a server response', function () { const ads = spec.interpretResponse(null); + config.resetConfig(); expect(ads).to.be.an('array').and.to.have.length(0); }); }); @@ -363,6 +370,7 @@ describe('KubientAdapter', function () { } }; let bannerResponses = spec.interpretResponse(serverResponse); + config.resetConfig(); expect(bannerResponses).to.be.an('array').that.is.not.empty; let dataItem = bannerResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'ad', 'creativeId', 'width', 'height', 'currency', 'netRevenue', 'ttl', 'meta', 'mediaType', 'vastXml'); @@ -383,6 +391,7 @@ describe('KubientAdapter', function () { it('Should return no ad when not given a server response', function () { const ads = spec.interpretResponse(null); + config.resetConfig(); expect(ads).to.be.an('array').and.to.have.length(0); }); }); From d4aec3c25083bca9d338706b64622f221242ed92 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Wed, 12 Jan 2022 19:48:11 +0300 Subject: [PATCH 17/23] fix 2 for ci passing --- test/spec/modules/kubientBidAdapter_spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index f890076b5c7..0b514d0ca2b 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -101,6 +101,7 @@ describe('KubientAdapter', function () { uspConsent: uspConsentData }; describe('buildRequestBanner', function () { + config.setConfig({}); let serverRequests = spec.buildRequests([bidBanner], Object.assign({}, bidderRequest, {bids: [bidBanner]})); config.resetConfig(); it('Creates a ServerRequest object with method, URL and data', function () { @@ -143,6 +144,7 @@ describe('KubientAdapter', function () { } }); describe('buildRequestVideo', function () { + config.setConfig({}); let serverRequests = spec.buildRequests([bidVideo], Object.assign({}, bidderRequest, {bids: [bidVideo]})); config.resetConfig(); it('Creates a ServerRequest object with method, URL and data', function () { @@ -275,19 +277,28 @@ describe('KubientAdapter', function () { describe('isBidRequestValid', function () { it('Should return true when required params are found', function () { + config.setConfig({}); expect(spec.isBidRequestValid(bidBanner)).to.be.true; + config.resetConfig(); + config.setConfig({}); expect(spec.isBidRequestValid(bidVideo)).to.be.true; config.resetConfig(); }); it('Should return false when required params are not found', function () { + config.setConfig({}); expect(spec.isBidRequestValid(bidBanner)).to.be.true; + config.resetConfig(); + config.setConfig({}); expect(spec.isBidRequestValid(bidVideo)).to.be.true; config.resetConfig(); }); it('Should return false when params are not found', function () { delete bidBanner.params; + config.setConfig({}); expect(spec.isBidRequestValid(bidBanner)).to.be.false; + config.resetConfig(); delete bidVideo.params; + config.setConfig({}); expect(spec.isBidRequestValid(bidVideo)).to.be.false; config.resetConfig(); }); @@ -318,6 +329,7 @@ describe('KubientAdapter', function () { ] } }; + config.setConfig({}); let bannerResponses = spec.interpretResponse(serverResponse); config.resetConfig(); expect(bannerResponses).to.be.an('array').that.is.not.empty; @@ -337,6 +349,7 @@ describe('KubientAdapter', function () { }); it('Should return no ad when not given a server response', function () { + config.setConfig({}); const ads = spec.interpretResponse(null); config.resetConfig(); expect(ads).to.be.an('array').and.to.have.length(0); @@ -369,6 +382,7 @@ describe('KubientAdapter', function () { ] } }; + config.setConfig({}); let bannerResponses = spec.interpretResponse(serverResponse); config.resetConfig(); expect(bannerResponses).to.be.an('array').that.is.not.empty; @@ -390,6 +404,7 @@ describe('KubientAdapter', function () { }); it('Should return no ad when not given a server response', function () { + config.setConfig({}); const ads = spec.interpretResponse(null); config.resetConfig(); expect(ads).to.be.an('array').and.to.have.length(0); @@ -482,6 +497,7 @@ describe('KubientAdapter', function () { } } }); + config.setConfig({}); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); config.resetConfig(); values['gdpr'] = 1; From 8f8a9e8e0bba565326f5f666a6bbaa6a4cae6493 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Thu, 13 Jan 2022 21:15:17 +0300 Subject: [PATCH 18/23] refactored-test-for-ci --- test/spec/modules/kubientBidAdapter_spec.js | 145 +++++++------------- 1 file changed, 52 insertions(+), 93 deletions(-) diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 0b514d0ca2b..8e4264b4fd7 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -101,26 +101,20 @@ describe('KubientAdapter', function () { uspConsent: uspConsentData }; describe('buildRequestBanner', function () { - config.setConfig({}); - let serverRequests = spec.buildRequests([bidBanner], Object.assign({}, bidderRequest, {bids: [bidBanner]})); - config.resetConfig(); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequests).to.be.an('array'); + beforeEach(function () { + config.resetConfig(); }); - for (let i = 0; i < serverRequests.length; i++) { - let serverRequest = serverRequests[i]; - it('Creates a ServerRequest object with method, URL and data', function () { + it('Creates Banner 1 ServerRequest object with method, URL and data', function () { + config.setConfig({'coppa': false}); + let serverRequests = spec.buildRequests([bidBanner], Object.assign({}, bidderRequest, {bids: [bidBanner]})); + expect(serverRequests).to.be.an('array'); + for (let i = 0; i < serverRequests.length; i++) { + let serverRequest = serverRequests[i]; expect(serverRequest.method).to.be.a('string'); expect(serverRequest.url).to.be.a('string'); expect(serverRequest.data).to.be.a('string'); - }); - it('Returns POST method', function () { expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/kubprebidjs'); - }); - it('Returns valid data if array of bids is valid', function () { let data = JSON.parse(serverRequest.data); expect(data).to.be.an('object'); expect(data).to.have.all.keys('v', 'requestId', 'adSlots', 'gdpr', 'referer', 'tmax', 'consent', 'consentGiven', 'uspConsent'); @@ -140,30 +134,24 @@ describe('KubientAdapter', function () { expect(adSlot.schain).to.be.an('object'); expect(adSlot.banner).to.be.an('object'); } - }); - } + } + }); }); describe('buildRequestVideo', function () { - config.setConfig({}); - let serverRequests = spec.buildRequests([bidVideo], Object.assign({}, bidderRequest, {bids: [bidVideo]})); - config.resetConfig(); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequests).to.be.an('array'); + beforeEach(function () { + config.resetConfig(); }); - for (let i = 0; i < serverRequests.length; i++) { - let serverRequest = serverRequests[i]; - it('Creates a ServerRequest object with method, URL and data', function () { + it('Creates Video 1 ServerRequest object with method, URL and data', function () { + config.setConfig({'coppa': false}); + let serverRequests = spec.buildRequests([bidVideo], Object.assign({}, bidderRequest, {bids: [bidVideo]})); + expect(serverRequests).to.be.an('array'); + for (let i = 0; i < serverRequests.length; i++) { + let serverRequest = serverRequests[i]; expect(serverRequest.method).to.be.a('string'); expect(serverRequest.url).to.be.a('string'); expect(serverRequest.data).to.be.a('string'); - }); - it('Returns POST method', function () { expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/kubprebidjs'); - }); - it('Returns valid data if array of bids is valid', function () { let data = JSON.parse(serverRequest.data); expect(data).to.be.an('object'); expect(data).to.have.all.keys('v', 'requestId', 'adSlots', 'gdpr', 'referer', 'tmax', 'consent', 'consentGiven', 'uspConsent'); @@ -183,30 +171,24 @@ describe('KubientAdapter', function () { expect(adSlot.schain).to.be.an('object'); expect(adSlot.video).to.be.an('object'); } - }); - } + } + }); }); describe('buildRequestBanner', function () { - config.setConfig({coppa: true}); - let serverRequests = spec.buildRequests([bidBanner], Object.assign({}, bidderRequest, {bids: [bidBanner]})); - config.resetConfig(); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequests).to.be.an('array'); + beforeEach(function () { + config.resetConfig(); }); - for (let i = 0; i < serverRequests.length; i++) { - let serverRequest = serverRequests[i]; - it('Creates a ServerRequest object with method, URL and data', function () { + it('Creates Banner 2 ServerRequest object with method, URL and data with bidBanner', function () { + config.setConfig({'coppa': true}); + let serverRequests = spec.buildRequests([bidBanner], Object.assign({}, bidderRequest, {bids: [bidBanner]})); + expect(serverRequests).to.be.an('array'); + for (let i = 0; i < serverRequests.length; i++) { + let serverRequest = serverRequests[i]; expect(serverRequest.method).to.be.a('string'); expect(serverRequest.url).to.be.a('string'); expect(serverRequest.data).to.be.a('string'); - }); - it('Returns POST method', function () { expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/kubprebidjs'); - }); - it('Returns valid data if array of bids is valid', function () { let data = JSON.parse(serverRequest.data); expect(data).to.be.an('object'); expect(data).to.have.all.keys('v', 'requestId', 'adSlots', 'gdpr', 'coppa', 'referer', 'tmax', 'consent', 'consentGiven', 'uspConsent'); @@ -227,30 +209,24 @@ describe('KubientAdapter', function () { expect(adSlot.schain).to.be.an('object'); expect(adSlot.banner).to.be.an('object'); } - }); - } + } + }); }); describe('buildRequestVideo', function () { - config.setConfig({coppa: true}); - let serverRequests = spec.buildRequests([bidVideo], Object.assign({}, bidderRequest, {bids: [bidVideo]})); - config.resetConfig(); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequests).to.be.an('array'); + beforeEach(function () { + config.resetConfig(); }); - for (let i = 0; i < serverRequests.length; i++) { - let serverRequest = serverRequests[i]; - it('Creates a ServerRequest object with method, URL and data', function () { + it('Creates Video 2 ServerRequest object with method, URL and data', function () { + config.setConfig({'coppa': true}); + let serverRequests = spec.buildRequests([bidVideo], Object.assign({}, bidderRequest, {bids: [bidVideo]})); + expect(serverRequests).to.be.an('array'); + for (let i = 0; i < serverRequests.length; i++) { + let serverRequest = serverRequests[i]; expect(serverRequest.method).to.be.a('string'); expect(serverRequest.url).to.be.a('string'); expect(serverRequest.data).to.be.a('string'); - }); - it('Returns POST method', function () { expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { expect(serverRequest.url).to.equal('https://kssp.kbntx.ch/kubprebidjs'); - }); - it('Returns valid data if array of bids is valid', function () { let data = JSON.parse(serverRequest.data); expect(data).to.be.an('object'); expect(data).to.have.all.keys('v', 'requestId', 'adSlots', 'gdpr', 'coppa', 'referer', 'tmax', 'consent', 'consentGiven', 'uspConsent'); @@ -271,40 +247,32 @@ describe('KubientAdapter', function () { expect(adSlot.schain).to.be.an('object'); expect(adSlot.video).to.be.an('object'); } - }); - } + } + }); }); - describe('isBidRequestValid', function () { + beforeEach(function () { + config.resetConfig(); + }); it('Should return true when required params are found', function () { - config.setConfig({}); expect(spec.isBidRequestValid(bidBanner)).to.be.true; - config.resetConfig(); - config.setConfig({}); expect(spec.isBidRequestValid(bidVideo)).to.be.true; - config.resetConfig(); }); it('Should return false when required params are not found', function () { - config.setConfig({}); expect(spec.isBidRequestValid(bidBanner)).to.be.true; - config.resetConfig(); - config.setConfig({}); expect(spec.isBidRequestValid(bidVideo)).to.be.true; - config.resetConfig(); }); it('Should return false when params are not found', function () { delete bidBanner.params; - config.setConfig({}); expect(spec.isBidRequestValid(bidBanner)).to.be.false; - config.resetConfig(); delete bidVideo.params; - config.setConfig({}); expect(spec.isBidRequestValid(bidVideo)).to.be.false; - config.resetConfig(); }); }); - describe('interpretResponse', function () { + beforeEach(function () { + config.resetConfig(); + }); it('Should interpret response', function () { const serverResponse = { body: @@ -329,9 +297,7 @@ describe('KubientAdapter', function () { ] } }; - config.setConfig({}); let bannerResponses = spec.interpretResponse(serverResponse); - config.resetConfig(); expect(bannerResponses).to.be.an('array').that.is.not.empty; let dataItem = bannerResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'ad', 'creativeId', 'width', 'height', 'currency', 'netRevenue', 'ttl', 'meta'); @@ -347,16 +313,16 @@ describe('KubientAdapter', function () { expect(dataItem.meta).to.exist.and.to.be.a('object'); expect(dataItem.meta.advertiserDomains).to.exist.and.to.be.a('array').and.to.equal(serverResponse.body.seatbid[0].bid[0].meta.adomain); }); - it('Should return no ad when not given a server response', function () { - config.setConfig({}); const ads = spec.interpretResponse(null); - config.resetConfig(); expect(ads).to.be.an('array').and.to.have.length(0); }); }); describe('interpretResponse Video', function () { + beforeEach(function () { + config.resetConfig(); + }); it('Should interpret response', function () { const serverResponse = { body: @@ -382,9 +348,7 @@ describe('KubientAdapter', function () { ] } }; - config.setConfig({}); let bannerResponses = spec.interpretResponse(serverResponse); - config.resetConfig(); expect(bannerResponses).to.be.an('array').that.is.not.empty; let dataItem = bannerResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'ad', 'creativeId', 'width', 'height', 'currency', 'netRevenue', 'ttl', 'meta', 'mediaType', 'vastXml'); @@ -402,16 +366,16 @@ describe('KubientAdapter', function () { expect(dataItem.mediaType).to.exist.and.to.equal(VIDEO); expect(dataItem.vastXml).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].adm); }); - it('Should return no ad when not given a server response', function () { - config.setConfig({}); const ads = spec.interpretResponse(null); - config.resetConfig(); expect(ads).to.be.an('array').and.to.have.length(0); }); }); describe('getUserSyncs', function () { + beforeEach(function () { + config.resetConfig(); + }); it('should register the sync image without gdpr', function () { let syncOptions = { pixelEnabled: true @@ -433,7 +397,6 @@ describe('KubientAdapter', function () { } }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - config.resetConfig(); // values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); @@ -461,7 +424,6 @@ describe('KubientAdapter', function () { } }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - config.resetConfig(); values['gdpr'] = 1; values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); @@ -497,9 +459,7 @@ describe('KubientAdapter', function () { } } }); - config.setConfig({}); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - config.resetConfig(); values['gdpr'] = 1; values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); @@ -527,7 +487,6 @@ describe('KubientAdapter', function () { } }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - config.resetConfig(); // values['consent'] = consentString; values['usp'] = uspConsent; expect(syncs).to.be.an('array').and.to.have.length(1); From e68454754b19c54d23581c1d362d0cd056a2a06d Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 14 Jan 2022 17:33:40 +0300 Subject: [PATCH 19/23] fix-for-review --- modules/kubientBidAdapter.js | 6 +++--- test/spec/modules/kubientBidAdapter_spec.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 380b4368558..fe9f41de8ca 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -124,9 +124,9 @@ export const spec = { if (typeof gdprConsent.gdprApplies === 'boolean') { values['gdpr'] = Number(gdprConsent.gdprApplies); - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - values['consent'] = gdprConsent.consentString; - } + values['consent'] = gdprConsent.consentString; + } else { + values['consent'] = gdprConsent.consentString; } if (uspConsent) { diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 8e4264b4fd7..2d3801450ba 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -397,7 +397,7 @@ describe('KubientAdapter', function () { } }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - // values['consent'] = consentString; + values['consent'] = consentString; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); expect(syncs[0].url).to.equal('https://matching.kubient.net/match/sp?' + encodeQueryData(values)); @@ -487,7 +487,7 @@ describe('KubientAdapter', function () { } }); let syncs = spec.getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent); - // values['consent'] = consentString; + values['consent'] = consentString; values['usp'] = uspConsent; expect(syncs).to.be.an('array').and.to.have.length(1); expect(syncs[0].type).to.equal('image'); From e1695545455bbc2dfbab443cbd823ecbcd242d8f Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 14 Jan 2022 19:41:29 +0300 Subject: [PATCH 20/23] fix --- modules/kubientBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index fe9f41de8ca..6671f7194cf 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -124,8 +124,8 @@ export const spec = { if (typeof gdprConsent.gdprApplies === 'boolean') { values['gdpr'] = Number(gdprConsent.gdprApplies); - values['consent'] = gdprConsent.consentString; - } else { + } + if (typeof gdprConsent.consentString === 'string') { values['consent'] = gdprConsent.consentString; } From 587d6e8c4f26bb0d3b03b3b012ebdd510cbf9172 Mon Sep 17 00:00:00 2001 From: Artem Aleksashkin Date: Fri, 14 Jan 2022 20:30:15 +0300 Subject: [PATCH 21/23] fix --- modules/kubientBidAdapter.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 6671f7194cf..fd776793d91 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -121,12 +121,13 @@ export const spec = { } let values = {}; - - if (typeof gdprConsent.gdprApplies === 'boolean') { - values['gdpr'] = Number(gdprConsent.gdprApplies); - } - if (typeof gdprConsent.consentString === 'string') { - values['consent'] = gdprConsent.consentString; + if (gdprConsent) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + values['gdpr'] = Number(gdprConsent.gdprApplies); + } + if (typeof gdprConsent.consentString === 'string') { + values['consent'] = gdprConsent.consentString; + } } if (uspConsent) { From 7978d89af456a06b74810031404d113db247c785 Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Mon, 24 Jan 2022 14:39:04 +0300 Subject: [PATCH 22/23] avoid sending zero bid floor if it is not defined --- modules/kubientBidAdapter.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index fd776793d91..a0b1a54d902 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -24,22 +24,20 @@ export const spec = { return; } return validBidRequests.map(function (bid) { - let floor = 0.0; + let adSlot = { + bidId: bid.bidId, + zoneId: bid.params.zoneid || '' + }; + if (typeof bid.getFloor === 'function') { const mediaType = (Object.keys(bid.mediaTypes).length == 1) ? Object.keys(bid.mediaTypes)[0] : '*'; const sizes = bid.sizes || '*'; const floorInfo = bid.getFloor({currency: 'USD', mediaType: mediaType, size: sizes}); if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { - floor = parseFloat(floorInfo.floor); + adSlot.floor = parseFloat(floorInfo.floor); } } - let adSlot = { - bidId: bid.bidId, - zoneId: bid.params.zoneid || '', - floor: floor || 0.0 - }; - if (bid.mediaTypes.banner) { adSlot.banner = bid.mediaTypes.banner; } From 38b8fd7aa43b3995cf1f4a78c712436e887a714b Mon Sep 17 00:00:00 2001 From: Marsel Taipov Date: Thu, 3 Feb 2022 18:29:31 +0300 Subject: [PATCH 23/23] do not send 0 bidfloor --- modules/kubientBidAdapter.js | 7 +++++-- test/spec/modules/kubientBidAdapter_spec.js | 8 +++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index a0b1a54d902..46360572576 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -33,8 +33,11 @@ export const spec = { const mediaType = (Object.keys(bid.mediaTypes).length == 1) ? Object.keys(bid.mediaTypes)[0] : '*'; const sizes = bid.sizes || '*'; const floorInfo = bid.getFloor({currency: 'USD', mediaType: mediaType, size: sizes}); - if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { - adSlot.floor = parseFloat(floorInfo.floor); + if (typeof floorInfo === 'object' && floorInfo.currency === 'USD') { + let floor = parseFloat(floorInfo.floor) + if (!isNaN(floor) && floor > 0) { + adSlot.floor = parseFloat(floorInfo.floor); + } } } diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 2d3801450ba..f7afc709564 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -19,7 +19,7 @@ describe('KubientAdapter', function () { }, getFloor: function(params) { return { - floor: 0.05, + floor: 0, currency: 'USD' }; }, @@ -127,10 +127,9 @@ describe('KubientAdapter', function () { expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); for (let j = 0; j < data['adSlots'].length; j++) { let adSlot = data['adSlots'][i]; - expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain'); + expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'banner', 'schain'); expect(adSlot.bidId).to.be.a('string').and.to.equal(bidBanner.bidId); expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidBanner.params.zoneid); - expect(adSlot.floor).to.be.a('number'); expect(adSlot.schain).to.be.an('object'); expect(adSlot.banner).to.be.an('object'); } @@ -202,10 +201,9 @@ describe('KubientAdapter', function () { expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); for (let j = 0; j < data['adSlots'].length; j++) { let adSlot = data['adSlots'][i]; - expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain'); + expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'banner', 'schain'); expect(adSlot.bidId).to.be.a('string').and.to.equal(bidBanner.bidId); expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidBanner.params.zoneid); - expect(adSlot.floor).to.be.a('number'); expect(adSlot.schain).to.be.an('object'); expect(adSlot.banner).to.be.an('object'); }