Skip to content

Commit

Permalink
Merge branch 'master' into parrableIdSystem/PBID-46_send_pbidlib_vers…
Browse files Browse the repository at this point in the history
…ion_to_nest
  • Loading branch information
victorigualada authored Feb 5, 2021
2 parents 522ad99 + 0a33349 commit 59be5ca
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 11 deletions.
8 changes: 6 additions & 2 deletions modules/adWMGBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,18 @@ export const spec = {
return bidResponses;
},
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
if (gdprConsent) {
if (gdprConsent && SYNC_ENDPOINT.indexOf('gdpr') === -1) {
SYNC_ENDPOINT = utils.tryAppendQueryString(SYNC_ENDPOINT, 'gdpr', (gdprConsent.gdprApplies ? 1 : 0));
}

if (gdprConsent && typeof gdprConsent.consentString === 'string') {
if (gdprConsent && typeof gdprConsent.consentString === 'string' && SYNC_ENDPOINT.indexOf('gdpr_consent') === -1) {
SYNC_ENDPOINT = utils.tryAppendQueryString(SYNC_ENDPOINT, 'gdpr_consent', gdprConsent.consentString);
}

if (SYNC_ENDPOINT.slice(-1) === '&') {
SYNC_ENDPOINT = SYNC_ENDPOINT.slice(0, -1);
}

/* if (uspConsent) {
SYNC_ENDPOINT = utils.tryAppendQueryString(SYNC_ENDPOINT, 'us_privacy', uspConsent);
} */
Expand Down
9 changes: 5 additions & 4 deletions modules/adWMGBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Module that connects to adWMG demand sources to fetch bids. Supports 'banner' ad

# Bid Parameters

| Key | Required | Example | Description |
| --- | -------- | ------- | ----------- |
| `publisherId` | yes | `'5cebea3c9eea646c7b623d5e'` | publisher ID from WMG Dashboard |
| `IABCategories` | no | `['IAB1', 'IAB5']` | IAB ad categories for adUnit |
| Key | Required | Example | Description |
| --------------- | -------- | -----------------------------| ------------------------------- |
| `publisherId` | yes | `'5cebea3c9eea646c7b623d5e'` | publisher ID from WMG Dashboard |
| `IABCategories` | no | `['IAB1', 'IAB5']` | IAB ad categories for adUnit |
| `floorCPM` | no | `0.5` | Floor price for adUnit |


# Test Parameters
Expand Down
20 changes: 20 additions & 0 deletions modules/adprimeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as utils from '../src/utils.js';

const BIDDER_CODE = 'adprime';
const AD_URL = 'https://delta.adprime.com/?c=o&m=multi';
const SYNC_URL = 'https://delta.adprime.com/?c=rtb&m=sync';

function isBidResponseValid(bid) {
if (!bid.requestId || !bid.cpm || !bid.creativeId ||
Expand Down Expand Up @@ -104,6 +105,25 @@ export const spec = {
}
return response;
},

getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
let syncUrl = SYNC_URL
if (gdprConsent && gdprConsent.consentString) {
if (typeof gdprConsent.gdprApplies === 'boolean') {
syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
} else {
syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`;
}
}
if (uspConsent && uspConsent.consentString) {
syncUrl += `&ccpa_consent=${uspConsent.consentString}`;
}
return [{
type: 'image',
url: syncUrl
}];
}

};

registerBidder(spec);
1 change: 1 addition & 0 deletions modules/parrableIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ function fetchId(configParams) {
trackers: configParams.partner.split(','),
url: refererInfo.referer,
prebidVersion: '$prebid.version$'
isIframe: utils.inIframe(),
};

const searchParams = {
Expand Down
20 changes: 16 additions & 4 deletions modules/zeotapIdPlusIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@ import {submodule} from '../src/hook.js';
import { getStorageManager } from '../src/storageManager.js';

const ZEOTAP_COOKIE_NAME = 'IDP';
export const storage = getStorageManager();
const ZEOTAP_VENDOR_ID = 301;
const ZEOTAP_MODULE_NAME = 'zeotapIdPlus';

function readCookie() {
return storage.cookiesAreEnabled ? storage.getCookie(ZEOTAP_COOKIE_NAME) : null;
return storage.cookiesAreEnabled() ? storage.getCookie(ZEOTAP_COOKIE_NAME) : null;
}

function readFromLocalStorage() {
return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(ZEOTAP_COOKIE_NAME) : null;
return storage.localStorageIsEnabled() ? storage.getDataFromLocalStorage(ZEOTAP_COOKIE_NAME) : null;
}

export function getStorage() {
return getStorageManager(ZEOTAP_VENDOR_ID, ZEOTAP_MODULE_NAME);
}

export const storage = getStorage();

/** @type {Submodule} */
export const zeotapIdPlusSubmodule = {
/**
* used to link submodule with config
* @type {string}
*/
name: 'zeotapIdPlus',
name: ZEOTAP_MODULE_NAME,
/**
* Vendor ID of Zeotap
* @type {Number}
*/
gvlid: ZEOTAP_VENDOR_ID,
/**
* decode the stored id value for passing to bid requests
* @function
Expand Down
40 changes: 40 additions & 0 deletions test/spec/modules/adWMGBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,45 @@ describe('adWMGBidAdapter', function () {
expect(syncs[0].url).includes('gdpr=1');
expect(syncs[0].url).includes(`gdpr_consent=${gdprConsent.consentString}`);
});

it('should not add GDPR consent params twice', function() {
const syncOptions = {
'iframeEnabled': true,
'pixelEnabled': true
};
const gdprConsent = {
consentString: 'CO9rhBTO9rhBTAcABBENBCCsAP_AAH_AACiQHItf_X_fb3_j-_59_9t0eY1f9_7_v20zjgeds-8Nyd_X_L8X42M7vB36pq4KuR4Eu3LBIQdlHOHcTUmw6IkVqTPsbk2Mr7NKJ7PEinMbe2dYGH9_n9XTuZKY79_s___z__-__v__7_f_r-3_3_vp9V---3YHIgEmGpfARZiWOBJNGlUKIEIVxIdACACihGFomsICVwU7K4CP0EDABAagIwIgQYgoxZBAAAAAElEQEgB4IBEARAIAAQAqQEIACNAEFgBIGAQACgGhYARQBCBIQZHBUcpgQESLRQTyVgCUXexhhCGUUANAg4AA.YAAAAAAAAAAA',
vendorData: {},
gdprApplies: true,
apiVersion: 2
};
const gdprConsent2 = {
consentString: 'CO9rhBTO9rhBTAcABBENBCCsAP_AAH_AACiQHItf_7_fb3_j-_59_9t0eY1f9_7_v20zjgeds-8Nyd_X_L8X42M7vB36pq4KuR4Eu3LBIQdlHOHcTUmw6IkVqTPsbk2Mr7NKJ7PEinMbe2dYGH9_n9XTuZKY79_s___z__-__v__7_f_r-3_3_vp9V---3YHIgEmGpfARZiWOBJNGlUKIEIVxIdACACihGFomsICVwU7K4CP0EDABAagIwIgQYgoxZBAAAAAElEQEgB4IBEARAIAAQAqQEIACNAEFgBIGAQACgGhYARQBCBIQZHBUcpgQESLRQTyVgCUXexhhCGUUANAg4AA.YAAAAAAAAAAA',
vendorData: {},
gdprApplies: true,
apiVersion: 2
};
const serverResponse = {};
let syncs = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent);
syncs = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent2);
expect(syncs[0].url.match(/gdpr/g).length).to.equal(2); // gdpr + gdpr_consent
expect(syncs[0].url.match(/gdpr_consent/g).length).to.equal(1);
});

it('should delete \'&\' symbol at the end of usersync URL', function() {
const syncOptions = {
'iframeEnabled': true,
'pixelEnabled': true
};
const gdprConsent = {
consentString: 'CO9rhBTO9rhBTAcABBENBCCsAP_AAH_AACiQHItf_X_fb3_j-_59_9t0eY1f9_7_v20zjgeds-8Nyd_X_L8X42M7vB36pq4KuR4Eu3LBIQdlHOHcTUmw6IkVqTPsbk2Mr7NKJ7PEinMbe2dYGH9_n9XTuZKY79_s___z__-__v__7_f_r-3_3_vp9V---3YHIgEmGpfARZiWOBJNGlUKIEIVxIdACACihGFomsICVwU7K4CP0EDABAagIwIgQYgoxZBAAAAAElEQEgB4IBEARAIAAQAqQEIACNAEFgBIGAQACgGhYARQBCBIQZHBUcpgQESLRQTyVgCUXexhhCGUUANAg4AA.YAAAAAAAAAAA',
vendorData: {},
gdprApplies: true,
apiVersion: 2
};
const serverResponse = {};
let syncs = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent);
expect(syncs[0].url.slice(-1)).to.not.equal('&');
});
});
});
10 changes: 10 additions & 0 deletions test/spec/modules/adprimeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,14 @@ describe('AdprimebBidAdapter', function () {
expect(serverResponses).to.be.an('array').that.is.empty;
});
});
describe('getUserSyncs', function () {
let userSync = spec.getUserSyncs();
it('Returns valid URL and type', function () {
expect(userSync).to.be.an('array').with.lengthOf(1);
expect(userSync[0].type).to.exist;
expect(userSync[0].url).to.exist;
expect(userSync[0].type).to.be.equal('image');
expect(userSync[0].url).to.be.equal('https://delta.adprime.com/?c=rtb&m=sync');
});
});
});
1 change: 1 addition & 0 deletions test/spec/modules/parrableIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ describe('Parrable ID System', function() {
trackers: P_CONFIG_MOCK.params.partner.split(','),
url: getRefererInfo().referer,
prebidVersion: '$prebid.version$',
isIframe: true
});

server.requests[0].respond(200,
Expand Down
64 changes: 63 additions & 1 deletion test/spec/modules/zeotapIdPlusIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { expect } from 'chai';
import find from 'core-js-pure/features/array/find.js';
import { config } from 'src/config.js';
import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js';
import { storage, zeotapIdPlusSubmodule } from 'modules/zeotapIdPlusIdSystem.js';
import { storage, getStorage, zeotapIdPlusSubmodule } from 'modules/zeotapIdPlusIdSystem.js';
import * as storageManager from 'src/storageManager.js';

const ZEOTAP_COOKIE_NAME = 'IDP';
const ZEOTAP_COOKIE = 'THIS-IS-A-DUMMY-COOKIE';
Expand Down Expand Up @@ -43,6 +44,67 @@ function unsetLocalStorage() {
}

describe('Zeotap ID System', function() {
describe('Zeotap Module invokes StorageManager with appropriate arguments', function() {
let getStorageManagerSpy;

beforeEach(function() {
getStorageManagerSpy = sinon.spy(storageManager, 'getStorageManager');
});

it('when a stored Zeotap ID exists it is added to bids', function() {
let store = getStorage();
expect(getStorageManagerSpy.calledOnce).to.be.true;
sinon.assert.calledWith(getStorageManagerSpy, 301, 'zeotapIdPlus');
});
});

describe('test method: getId calls storage methods to fetch ID', function() {
let cookiesAreEnabledStub;
let getCookieStub;
let localStorageIsEnabledStub;
let getDataFromLocalStorageStub;

beforeEach(() => {
cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled');
getCookieStub = sinon.stub(storage, 'getCookie');
localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled');
getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
});

afterEach(() => {
storage.cookiesAreEnabled.restore();
storage.getCookie.restore();
storage.localStorageIsEnabled.restore();
storage.getDataFromLocalStorage.restore();
unsetCookie();
unsetLocalStorage();
});

it('should check if cookies are enabled', function() {
let id = zeotapIdPlusSubmodule.getId();
expect(cookiesAreEnabledStub.calledOnce).to.be.true;
});

it('should call getCookie if cookies are enabled', function() {
cookiesAreEnabledStub.returns(true);
let id = zeotapIdPlusSubmodule.getId();
expect(cookiesAreEnabledStub.calledOnce).to.be.true;
expect(getCookieStub.calledOnce).to.be.true;
sinon.assert.calledWith(getCookieStub, 'IDP');
});

it('should check for localStorage if cookies are disabled', function() {
cookiesAreEnabledStub.returns(false);
localStorageIsEnabledStub.returns(true)
let id = zeotapIdPlusSubmodule.getId();
expect(cookiesAreEnabledStub.calledOnce).to.be.true;
expect(getCookieStub.called).to.be.false;
expect(localStorageIsEnabledStub.calledOnce).to.be.true;
expect(getDataFromLocalStorageStub.calledOnce).to.be.true;
sinon.assert.calledWith(getDataFromLocalStorageStub, 'IDP');
});
});

describe('test method: getId', function() {
afterEach(() => {
unsetCookie();
Expand Down

0 comments on commit 59be5ca

Please sign in to comment.