From 9334591ca85d0822ffcfd0ce9097cc90d53f7ee3 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Tue, 21 Jul 2020 16:30:02 +0530 Subject: [PATCH 01/10] IDU-117 IDU-119 Add zeotap submodule --- gulpfile.js | 2 +- integrationExamples/gpt/userId_example.html | 11 +++ modules/userId/eids.js | 5 ++ modules/userId/eids.md | 9 ++- modules/zeotapId+.js | 71 ++++++++++++++++ test/spec/modules/userId_spec.js | 89 ++++++++++++++++----- 6 files changed, 165 insertions(+), 22 deletions(-) create mode 100644 modules/zeotapId+.js diff --git a/gulpfile.js b/gulpfile.js index 879e34ae588..b10fda86f97 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -362,7 +362,7 @@ gulp.task('build-bundle-dev', gulp.series(makeDevpackPkg, gulpBundle.bind(null, gulp.task('build-bundle-prod', gulp.series(makeWebpackPkg, gulpBundle.bind(null, false))); // public tasks (dependencies are needed for each task since they can be ran on their own) -gulp.task('test', gulp.series(clean, lint, test)); +gulp.task('test', gulp.series(clean, test)); gulp.task('test-coverage', gulp.series(clean, testCoverage)); gulp.task(viewCoverage); diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index 8115e60fcd1..a97d1dd9a05 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -230,6 +230,17 @@ name: "_li_pbid", expires: 28 } + }, + { + name: "zeotapId+", + params: { + partner: '301826f9b2b5a1324ea09b' + }, + storage: { + type: "cookie", + name: "IDP", + expires: 365 + } }], syncDelay: 5000, auctionDelay: 1000 diff --git a/modules/userId/eids.js b/modules/userId/eids.js index 15399b9b980..25d24a6c968 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -123,6 +123,11 @@ const USER_IDS_CONFIG = { third: data.third } : undefined; } + }, + // zeotapId+ + 'IDP': { + source: 'zeotap.com', + atype: 1 } }; diff --git a/modules/userId/eids.md b/modules/userId/eids.md index 846b9b19207..fc46fef7b97 100644 --- a/modules/userId/eids.md +++ b/modules/userId/eids.md @@ -95,6 +95,13 @@ userIdAsEids = [ third: 'some-random-id-value' } }] - } + }, + { + source: 'zeotap.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }, ] ``` diff --git a/modules/zeotapId+.js b/modules/zeotapId+.js new file mode 100644 index 00000000000..a7a30d8997f --- /dev/null +++ b/modules/zeotapId+.js @@ -0,0 +1,71 @@ +/** + * This module adds Zeotap to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/zeotapId+ + * @requires module:modules/userId + */ + +import * as utils from '../src/utils.js' +import {submodule} from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const ZEOTAP_COOKIE_NAME = 'IDP'; + +const storage = getStorageManager(); + +function isValidConfig(configParams) { + if (!configParams) { + utils.logError('User ID - zeotapId submodule requires configParams'); + return false; + } + if (!configParams.partner) { + utils.logError('User ID - zeotapId submodule requires partner list'); + return false; + } + return true; +} + +function readCookie() { + return storage.cookiesAreEnabled ? storage.readCookie(ZEOTAP_COOKIE_NAME) : null; +} + +function readFromLocalStorage() { + return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(ZEOTAP_COOKIE_NAME) : null; +} + +function fetchId(configParams) { + if (!isValidConfig(configParams)) return undefined; + return readCookie() || readFromLocalStorage(); +}; + +/** @type {Submodule} */ +export const zeotapIdPlusSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'zeotapId+', + /** + * decode the stored id value for passing to bid requests + * @function + * @param { Object | string } value + * @return { Object | undefined } + */ + decode(value) { + return value ? { + 'IDP': utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined + } : undefined; + }, + + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleParams} configParams + * @return {string} + */ + getId(configParams) { + return fetchId(configParams); + } +}; + +submodule('userId', zeotapIdPlusSubmodule); diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 5ac68de345d..5a88db9423c 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -26,6 +26,7 @@ import {liveIntentIdSubmodule} from 'modules/liveIntentIdSystem.js'; import {merkleIdSubmodule} from 'modules/merkleIdSystem.js'; import {netIdSubmodule} from 'modules/netIdSystem.js'; import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js'; +import {zeotapIdPlusSubModule} from 'modules/zeotapId+.js'; import {sharedIdSubmodule} from 'modules/sharedIdSystem.js'; import {server} from 'test/mocks/xhr.js'; @@ -34,8 +35,8 @@ let expect = require('chai').expect; const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT'; const CONSENT_LOCAL_STORAGE_NAME = '_pbjs_userid_consent_data'; -describe('User ID', function() { - function getConfigMock(configArr1, configArr2, configArr3, configArr4, configArr5, configArr6, configArr7, configArr8, configArr9) { +describe.only('User ID', function() { + function getConfigMock(configArr1, configArr2, configArr3, configArr4, configArr5, configArr6, configArr7, configArr8, configArr9, configArr10) { return { userSync: { syncDelay: 0, @@ -48,7 +49,8 @@ describe('User ID', function() { (configArr6 && configArr6.length >= 3) ? getStorageMock.apply(null, configArr6) : null, (configArr7 && configArr7.length >= 3) ? getStorageMock.apply(null, configArr7) : null, (configArr8 && configArr8.length >= 3) ? getStorageMock.apply(null, configArr8) : null, - (configArr9 && configArr9.length >= 3) ? getStorageMock.apply(null, configArr9) : null + (configArr9 && configArr9.length >= 3) ? getStorageMock.apply(null, configArr9) : null, + (configArr10 && configArr10.length >= 3) ? getStorageMock.apply(null, configArr10) : null ].filter(i => i) } } @@ -354,7 +356,7 @@ describe('User ID', function() { }); it('handles config with no usersync object', function() { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({}); // usersync is undefined, and no logInfo message for 'User ID - usersync config updated' @@ -362,25 +364,25 @@ describe('User ID', function() { }); it('handles config with empty usersync object', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({userSync: {}}); expect(typeof utils.logInfo.args[0]).to.equal('undefined'); }); it('handles config with usersync and userIds that are empty objs', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({ userSync: { userIds: [{}] } }); - expect(typeof utils.logInfo.args[0]).to.equal('undefined'); + // expect(typeof utils.logInfo.args[0]).to.equal('undefined'); }); it('handles config with usersync and userIds with empty names or that dont match a submodule.name', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({ userSync: { @@ -397,15 +399,15 @@ describe('User ID', function() { }); it('config with 1 configurations should create 1 submodules', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig(getConfigMock(['unifiedId', 'unifiedid', 'cookie'])); expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - usersync config updated for 1 submodules'); }); - it('config with 9 configurations should result in 9 submodules add', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + it('config with 10 configurations should result in 10 submodules add', function () { + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({ userSync: { @@ -436,6 +438,9 @@ describe('User ID', function() { }, { name: 'intentIqId', storage: { name: 'intentIqId', type: 'cookie' } + }, { + name: 'zeotapId+', + storage: { name: 'IDP', type: 'cookie' } }] } }); @@ -443,7 +448,7 @@ describe('User ID', function() { }); it('config syncDelay updates module correctly', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({ userSync: { @@ -458,7 +463,7 @@ describe('User ID', function() { }); it('config auctionDelay updates module correctly', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({ userSync: { @@ -473,7 +478,7 @@ describe('User ID', function() { }); it('config auctionDelay defaults to 0 if not a number', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({ userSync: { @@ -1141,8 +1146,32 @@ describe('User ID', function() { done(); }, {adUnits}); }); + + it('test hook from zeotapId+ cookies', function(done) { + // simulate existing browser local storage values + coreStorage.setCookie('IDP', 'abcdefghijk', (new Date(Date.now() + 5000).toUTCString())); + + setSubmoduleRegistry([zeotapIdPlusSubModule]); + init(config); + config.setConfig(getConfigMock(['zeotapId+', 'IDP', 'cookie'])); + + requestBidsHook(function() { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal('abcdefghijk'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'zeotap.com', + uids: [{id: 'abcdefghijk', atype: 1}] + }); + }); + }); + coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); - it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, sharedId and netId have data to pass', function(done) { + it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, zeotapId+, sharedId and netId have data to pass', function(done) { coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); @@ -1150,9 +1179,10 @@ describe('User ID', function() { coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', 'zeotapId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], ['unifiedId', 'unifiedid', 'cookie'], @@ -1161,7 +1191,8 @@ describe('User ID', function() { ['britepoolId', 'britepoolid', 'cookie'], ['netId', 'netId', 'cookie'], ['sharedId', 'sharedid', 'cookie'], - ['intentIqId', 'intentIqId', 'cookie'])); + ['intentIqId', 'intentIqId', 'cookie'], + ['zeotapId+', 'IDP', 'cookie'])); requestBidsHook(function() { adUnits.forEach(unit => { @@ -1193,6 +1224,9 @@ describe('User ID', function() { expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); expect(bid.userIdAsEids.length).to.equal(8); + // also check that zeotapId+ id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal('zeotapId'); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); @@ -1203,11 +1237,12 @@ describe('User ID', function() { coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); done(); }, {adUnits}); }); - it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, intentIqId, sharedId and netId have their modules added before and after init', function(done) { + it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, intentIqId, zeotapId+, sharedId and netId have their modules added before and after init', function(done) { coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); @@ -1216,6 +1251,7 @@ describe('User ID', function() { coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', 'zeotapId', (new Date(Date.now() + 5000).toUTCString())); setSubmoduleRegistry([]); @@ -1232,6 +1268,7 @@ describe('User ID', function() { attachIdSystem(netIdSubmodule); attachIdSystem(sharedIdSubmodule); attachIdSystem(intentIqIdSubmodule); + attachIdSystem(zeotapIdPlusSubModule); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], ['unifiedId', 'unifiedid', 'cookie'], @@ -1240,7 +1277,8 @@ describe('User ID', function() { ['britepoolId', 'britepoolid', 'cookie'], ['netId', 'netId', 'cookie'], ['sharedId', 'sharedid', 'cookie'], - ['intentIqId', 'intentIqId', 'cookie'])); + ['intentIqId', 'intentIqId', 'cookie'], + ['zeotapId+', 'IDP', 'cookie'])); requestBidsHook(function() { adUnits.forEach(unit => { @@ -1272,6 +1310,9 @@ describe('User ID', function() { expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); expect(bid.userIdAsEids.length).to.equal(8); + // also check that zeotapId+ id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal('zeotapId'); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); @@ -1282,6 +1323,7 @@ describe('User ID', function() { coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); done(); }, {adUnits}); }); @@ -1316,9 +1358,10 @@ describe('User ID', function() { coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', 'zeotapId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString()); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); init(config); config.setConfig({ @@ -1340,6 +1383,8 @@ describe('User ID', function() { name: 'sharedId', storage: {name: 'sharedid', type: 'cookie'} }, { name: 'intentIqId', storage: { name: 'intentIqId', type: 'cookie' } + }, { + name: 'zeotapId+', storage: { name: 'IDP', type: 'cookie' } }, { name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} }] @@ -1394,6 +1439,9 @@ describe('User ID', function() { expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); expect(bid.userIdAsEids.length).to.equal(8); + // also check that zeotapId+ id data was copied to bid + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal('zeotapId'); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); @@ -1404,6 +1452,7 @@ describe('User ID', function() { coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE); done(); }, {adUnits}); From 699c53a954632ce9176c0a04a533b7f242df1c06 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Wed, 22 Jul 2020 13:58:27 +0530 Subject: [PATCH 02/10] IDU-117 IDU-119 Add tests for zeotapId+ module --- gulpfile.js | 2 +- modules/zeotapId+.js | 13 +++++------ test/spec/modules/userId_spec.js | 37 ++++++++++++++++---------------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b10fda86f97..879e34ae588 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -362,7 +362,7 @@ gulp.task('build-bundle-dev', gulp.series(makeDevpackPkg, gulpBundle.bind(null, gulp.task('build-bundle-prod', gulp.series(makeWebpackPkg, gulpBundle.bind(null, false))); // public tasks (dependencies are needed for each task since they can be ran on their own) -gulp.task('test', gulp.series(clean, test)); +gulp.task('test', gulp.series(clean, lint, test)); gulp.task('test-coverage', gulp.series(clean, testCoverage)); gulp.task(viewCoverage); diff --git a/modules/zeotapId+.js b/modules/zeotapId+.js index a7a30d8997f..e896541c7f8 100644 --- a/modules/zeotapId+.js +++ b/modules/zeotapId+.js @@ -4,13 +4,11 @@ * @module modules/zeotapId+ * @requires module:modules/userId */ - import * as utils from '../src/utils.js' import {submodule} from '../src/hook.js'; import { getStorageManager } from '../src/storageManager.js'; const ZEOTAP_COOKIE_NAME = 'IDP'; - const storage = getStorageManager(); function isValidConfig(configParams) { @@ -35,7 +33,8 @@ function readFromLocalStorage() { function fetchId(configParams) { if (!isValidConfig(configParams)) return undefined; - return readCookie() || readFromLocalStorage(); + const id = readCookie() || readFromLocalStorage(); + return { id }; }; /** @type {Submodule} */ @@ -48,24 +47,22 @@ export const zeotapIdPlusSubmodule = { /** * decode the stored id value for passing to bid requests * @function - * @param { Object | string } value - * @return { Object | undefined } + * @param { Object | string | undefined } value + * @return { Object | string | undefined } */ decode(value) { return value ? { 'IDP': utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined } : undefined; }, - /** * performs action to obtain id and return a value in the callback's response argument * @function * @param {SubmoduleParams} configParams - * @return {string} + * @return {{id: string | undefined} | undefined} */ getId(configParams) { return fetchId(configParams); } }; - submodule('userId', zeotapIdPlusSubmodule); diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 5a88db9423c..e196452a57f 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -26,7 +26,7 @@ import {liveIntentIdSubmodule} from 'modules/liveIntentIdSystem.js'; import {merkleIdSubmodule} from 'modules/merkleIdSystem.js'; import {netIdSubmodule} from 'modules/netIdSystem.js'; import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js'; -import {zeotapIdPlusSubModule} from 'modules/zeotapId+.js'; +import {zeotapIdPlusSubmodule} from 'modules/zeotapId+.js'; import {sharedIdSubmodule} from 'modules/sharedIdSystem.js'; import {server} from 'test/mocks/xhr.js'; @@ -35,8 +35,8 @@ let expect = require('chai').expect; const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT'; const CONSENT_LOCAL_STORAGE_NAME = '_pbjs_userid_consent_data'; -describe.only('User ID', function() { - function getConfigMock(configArr1, configArr2, configArr3, configArr4, configArr5, configArr6, configArr7, configArr8, configArr9, configArr10) { +describe('User ID', function() { + function getConfigMock(configArr1, configArr2, configArr3, configArr4, configArr5, configArr6, configArr7, configArr8, configArr9) { return { userSync: { syncDelay: 0, @@ -49,8 +49,7 @@ describe.only('User ID', function() { (configArr6 && configArr6.length >= 3) ? getStorageMock.apply(null, configArr6) : null, (configArr7 && configArr7.length >= 3) ? getStorageMock.apply(null, configArr7) : null, (configArr8 && configArr8.length >= 3) ? getStorageMock.apply(null, configArr8) : null, - (configArr9 && configArr9.length >= 3) ? getStorageMock.apply(null, configArr9) : null, - (configArr10 && configArr10.length >= 3) ? getStorageMock.apply(null, configArr10) : null + (configArr9 && configArr9.length >= 3) ? getStorageMock.apply(null, configArr9) : null ].filter(i => i) } } @@ -378,7 +377,7 @@ describe.only('User ID', function() { userIds: [{}] } }); - // expect(typeof utils.logInfo.args[0]).to.equal('undefined'); + expect(typeof utils.logInfo.args[0]).to.equal('undefined'); }); it('handles config with usersync and userIds with empty names or that dont match a submodule.name', function () { @@ -399,7 +398,7 @@ describe.only('User ID', function() { }); it('config with 1 configurations should create 1 submodules', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig(getConfigMock(['unifiedId', 'unifiedid', 'cookie'])); @@ -407,7 +406,7 @@ describe.only('User ID', function() { }); it('config with 10 configurations should result in 10 submodules add', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({ userSync: { @@ -444,11 +443,11 @@ describe.only('User ID', function() { }] } }); - expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - usersync config updated for 9 submodules'); + expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - usersync config updated for 10 submodules'); }); it('config syncDelay updates module correctly', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({ userSync: { @@ -463,7 +462,7 @@ describe.only('User ID', function() { }); it('config auctionDelay updates module correctly', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({ userSync: { @@ -478,7 +477,7 @@ describe.only('User ID', function() { }); it('config auctionDelay defaults to 0 if not a number', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({ userSync: { @@ -1151,7 +1150,7 @@ describe.only('User ID', function() { // simulate existing browser local storage values coreStorage.setCookie('IDP', 'abcdefghijk', (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([zeotapIdPlusSubModule]); + setSubmoduleRegistry([zeotapIdPlusSubmodule]); init(config); config.setConfig(getConfigMock(['zeotapId+', 'IDP', 'cookie'])); @@ -1182,7 +1181,7 @@ describe.only('User ID', function() { coreStorage.setCookie('IDP', 'zeotapId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], ['unifiedId', 'unifiedid', 'cookie'], @@ -1223,10 +1222,10 @@ describe.only('User ID', function() { // also check that intentIqId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); - expect(bid.userIdAsEids.length).to.equal(8); // also check that zeotapId+ id data was copied to bid expect(bid).to.have.deep.nested.property('userId.IDP'); expect(bid.userId.IDP).to.equal('zeotapId'); + expect(bid.userIdAsEids.length).to.equal(9); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); @@ -1268,7 +1267,7 @@ describe.only('User ID', function() { attachIdSystem(netIdSubmodule); attachIdSystem(sharedIdSubmodule); attachIdSystem(intentIqIdSubmodule); - attachIdSystem(zeotapIdPlusSubModule); + attachIdSystem(zeotapIdPlusSubmodule); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], ['unifiedId', 'unifiedid', 'cookie'], @@ -1309,10 +1308,10 @@ describe.only('User ID', function() { // also check that intentIqId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); - expect(bid.userIdAsEids.length).to.equal(8); // also check that zeotapId+ id data was copied to bid expect(bid).to.have.deep.nested.property('userId.IDP'); expect(bid.userId.IDP).to.equal('zeotapId'); + expect(bid.userIdAsEids.length).to.equal(9); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); @@ -1361,7 +1360,7 @@ describe.only('User ID', function() { coreStorage.setCookie('IDP', 'zeotapId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString()); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({ @@ -1438,10 +1437,10 @@ describe.only('User ID', function() { // also check that intentIqId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); - expect(bid.userIdAsEids.length).to.equal(8); // also check that zeotapId+ id data was copied to bid expect(bid).to.have.deep.nested.property('userId.IDP'); expect(bid.userId.IDP).to.equal('zeotapId'); + expect(bid.userIdAsEids.length).to.equal(9); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); From 8bf0bc7f535ad2597201ec0e2caa7dd641d1ebb7 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Wed, 12 Aug 2020 13:25:06 +0530 Subject: [PATCH 03/10] add zeotapId+ module spec --- modules/zeotapId+.js | 6 +- test/spec/modules/zeotapId+_spec.js | 163 ++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 test/spec/modules/zeotapId+_spec.js diff --git a/modules/zeotapId+.js b/modules/zeotapId+.js index e896541c7f8..084ea555d0d 100644 --- a/modules/zeotapId+.js +++ b/modules/zeotapId+.js @@ -16,15 +16,15 @@ function isValidConfig(configParams) { utils.logError('User ID - zeotapId submodule requires configParams'); return false; } - if (!configParams.partner) { - utils.logError('User ID - zeotapId submodule requires partner list'); + if (!configParams.name || !configParams.storage) { + utils.logError('User ID - zeotapId submodule requires valid config params: name, storage'); return false; } return true; } function readCookie() { - return storage.cookiesAreEnabled ? storage.readCookie(ZEOTAP_COOKIE_NAME) : null; + return storage.cookiesAreEnabled ? storage.getCookie(ZEOTAP_COOKIE_NAME) : null; } function readFromLocalStorage() { diff --git a/test/spec/modules/zeotapId+_spec.js b/test/spec/modules/zeotapId+_spec.js new file mode 100644 index 00000000000..8ddb56fd60c --- /dev/null +++ b/test/spec/modules/zeotapId+_spec.js @@ -0,0 +1,163 @@ +import { expect } from 'chai'; +import find from 'core-js-pure/features/array/find.js'; +import { config } from 'src/config.js'; +import { newStorageManager } from 'src/storageManager.js'; +import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js'; +import { zeotapIdPlusSubmodule } from 'modules/zeotapId+.js'; + +const storage = newStorageManager(); + +const ZEOTAP_COOKIE_NAME = 'IDP'; +const ZEOTAP_COOKIE = 'THIS-IS-A-DUMMY-COOKIE'; +const CONFIG_PARAMS_MOCK = { + name: 'zeotapId+', + storage: { + name: 'IDP', + type: 'cookie', + expires: 30, + refreshInSeconds: null + } +}; + +function getConfigMock() { + return { + userSync: { + syncDelay: 0, + userIds: [{ + name: 'zeotapId+', + storage: { + name: 'IDP', + type: 'cookie', + expires: 30, + refreshInSeconds: null + } + }] + } + } +} + +function getAdUnitMock(code = 'adUnit-code') { + return { + code, + mediaTypes: {banner: {}, native: {}}, + sizes: [ + [300, 200], + [300, 600] + ], + bids: [{ + bidder: 'sampleBidder', + params: { placementId: 'banner-only-bidder' } + }] + }; +} + +function writeZeotapCookie() { + storage.setCookie( + ZEOTAP_COOKIE_NAME, + ZEOTAP_COOKIE, + (new Date(Date.now() + 5000).toUTCString()), + ); +} + +function unsetCookie() { + storage.setCookie(ZEOTAP_COOKIE_NAME, ''); +} + +function unsetLocalStorage() { + storage.setDataInLocalStorage(ZEOTAP_COOKIE_NAME, ''); +} + +describe('Zeotap ID System', function() { + describe('test method: getId', function() { + afterEach(() => { + unsetCookie(); + unsetLocalStorage(); + }) + + it('return undefined if incorrect config as argument', function() { + writeZeotapCookie(); + let id = zeotapIdPlusSubmodule.getId({}); + expect(id).to.be.undefined; + }); + + it('provides the stored Zeotap id if a cookie exists', function() { + writeZeotapCookie(); + let id = zeotapIdPlusSubmodule.getId(CONFIG_PARAMS_MOCK); + expect(id).to.deep.equal({ + id: ZEOTAP_COOKIE + }); + }); + + it('provides the stored Zeotap id if cookie is absent but present in local storage', function() { + writeZeotapCookie(); + let id = zeotapIdPlusSubmodule.getId(CONFIG_PARAMS_MOCK); + expect(id).to.deep.equal({ + id: ZEOTAP_COOKIE + }); + }); + + it('returns empty id in object if both cookie and local storage are empty', function() { + let id = zeotapIdPlusSubmodule.getId(CONFIG_PARAMS_MOCK); + expect(id).to.deep.equal({ + id: '' + }); + }) + }); + + describe('test method: decode', function() { + it('provides the Zeotap ID (IDP) from a stored object', function() { + let zeotapId = { + id: ZEOTAP_COOKIE, + }; + + expect(zeotapIdPlusSubmodule.decode(zeotapId)).to.deep.equal({ + IDP: ZEOTAP_COOKIE + }); + }); + + it('provides the Zeotap ID (IDP) from a stored string', function() { + let zeotapId = ZEOTAP_COOKIE; + + expect(zeotapIdPlusSubmodule.decode(zeotapId)).to.deep.equal({ + IDP: ZEOTAP_COOKIE + }); + }); + }); + + describe('requestBids hook', function() { + let adUnits; + + beforeEach(function() { + adUnits = [getAdUnitMock()]; + writeZeotapCookie(); + setSubmoduleRegistry([zeotapIdPlusSubmodule]); + init(config); + config.setConfig(getConfigMock()); + }); + + afterEach(function() { + unsetCookie(); + unsetLocalStorage(); + }); + + it('when a stored Zeotap ID exists it is added to bids', function(done) { + requestBidsHook(function() { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.IDP'); + expect(bid.userId.IDP).to.equal(ZEOTAP_COOKIE); + const zeotapIdAsEid = find(bid.userIdAsEids, e => e.source == 'zeotap.com'); + expect(zeotapIdAsEid).to.deep.equal({ + source: 'zeotap.com', + uids: [{ + id: ZEOTAP_COOKIE, + atype: 1, + }] + }); + }); + }); + done(); + }, { adUnits }); + }); + }); +}); From 5e055e8495eb10f3e237e26d3453e4df0ecbcdda Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Fri, 14 Aug 2020 14:29:08 +0530 Subject: [PATCH 04/10] Add IDP base64 decode logic --- modules/zeotapId+.js | 17 +++++++++++------ test/spec/modules/userId_spec.js | 8 ++++---- test/spec/modules/zeotapId+_spec.js | 23 +++++++---------------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/modules/zeotapId+.js b/modules/zeotapId+.js index 084ea555d0d..85d15d82fc3 100644 --- a/modules/zeotapId+.js +++ b/modules/zeotapId+.js @@ -16,8 +16,8 @@ function isValidConfig(configParams) { utils.logError('User ID - zeotapId submodule requires configParams'); return false; } - if (!configParams.name || !configParams.storage) { - utils.logError('User ID - zeotapId submodule requires valid config params: name, storage'); + if (!configParams.name) { + utils.logError('User ID - zeotapId submodule requires valid config params: name'); return false; } return true; @@ -34,7 +34,8 @@ function readFromLocalStorage() { function fetchId(configParams) { if (!isValidConfig(configParams)) return undefined; const id = readCookie() || readFromLocalStorage(); - return { id }; + if (!id) return undefined; + return { id: JSON.parse(atob(id)) }; }; /** @type {Submodule} */ @@ -51,9 +52,13 @@ export const zeotapIdPlusSubmodule = { * @return { Object | string | undefined } */ decode(value) { - return value ? { - 'IDP': utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined - } : undefined; + const id = value ? utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined : undefined; + if (!id) { + return undefined; + } + return { + 'IDP': JSON.parse(atob(id)) + } }, /** * performs action to obtain id and return a value in the callback's response argument diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index e196452a57f..520b88b168a 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -1148,7 +1148,7 @@ describe('User ID', function() { it('test hook from zeotapId+ cookies', function(done) { // simulate existing browser local storage values - coreStorage.setCookie('IDP', 'abcdefghijk', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', btoa(JSON.stringify('abcdefghijk')), (new Date(Date.now() + 5000).toUTCString())); setSubmoduleRegistry([zeotapIdPlusSubmodule]); init(config); @@ -1178,7 +1178,7 @@ describe('User ID', function() { coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('IDP', 'zeotapId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString())); setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); @@ -1250,7 +1250,7 @@ describe('User ID', function() { coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('IDP', 'zeotapId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); setSubmoduleRegistry([]); @@ -1357,7 +1357,7 @@ describe('User ID', function() { coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('IDP', 'zeotapId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString()); setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); diff --git a/test/spec/modules/zeotapId+_spec.js b/test/spec/modules/zeotapId+_spec.js index 8ddb56fd60c..cbc89fdb8c7 100644 --- a/test/spec/modules/zeotapId+_spec.js +++ b/test/spec/modules/zeotapId+_spec.js @@ -11,12 +11,7 @@ const ZEOTAP_COOKIE_NAME = 'IDP'; const ZEOTAP_COOKIE = 'THIS-IS-A-DUMMY-COOKIE'; const CONFIG_PARAMS_MOCK = { name: 'zeotapId+', - storage: { - name: 'IDP', - type: 'cookie', - expires: 30, - refreshInSeconds: null - } + storage: { name: 'IDP', type: 'cookie' } }; function getConfigMock() { @@ -27,9 +22,7 @@ function getConfigMock() { name: 'zeotapId+', storage: { name: 'IDP', - type: 'cookie', - expires: 30, - refreshInSeconds: null + type: 'cookie' } }] } @@ -54,7 +47,7 @@ function getAdUnitMock(code = 'adUnit-code') { function writeZeotapCookie() { storage.setCookie( ZEOTAP_COOKIE_NAME, - ZEOTAP_COOKIE, + btoa(JSON.stringify(ZEOTAP_COOKIE)), (new Date(Date.now() + 5000).toUTCString()), ); } @@ -96,18 +89,16 @@ describe('Zeotap ID System', function() { }); }); - it('returns empty id in object if both cookie and local storage are empty', function() { + it('returns undefined if both cookie and local storage are empty', function() { let id = zeotapIdPlusSubmodule.getId(CONFIG_PARAMS_MOCK); - expect(id).to.deep.equal({ - id: '' - }); + expect(id).to.be.undefined }) }); describe('test method: decode', function() { it('provides the Zeotap ID (IDP) from a stored object', function() { let zeotapId = { - id: ZEOTAP_COOKIE, + id: btoa(JSON.stringify(ZEOTAP_COOKIE)), }; expect(zeotapIdPlusSubmodule.decode(zeotapId)).to.deep.equal({ @@ -116,7 +107,7 @@ describe('Zeotap ID System', function() { }); it('provides the Zeotap ID (IDP) from a stored string', function() { - let zeotapId = ZEOTAP_COOKIE; + let zeotapId = btoa(JSON.stringify(ZEOTAP_COOKIE)); expect(zeotapIdPlusSubmodule.decode(zeotapId)).to.deep.equal({ IDP: ZEOTAP_COOKIE From 9b52f8401ad9692a1bee02bc8e5c48e6c11ab013 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Mon, 17 Aug 2020 12:21:24 +0530 Subject: [PATCH 05/10] remove unwanted file changes --- integrationExamples/gpt/userId_example.html | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index a97d1dd9a05..8115e60fcd1 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -230,17 +230,6 @@ name: "_li_pbid", expires: 28 } - }, - { - name: "zeotapId+", - params: { - partner: '301826f9b2b5a1324ea09b' - }, - storage: { - type: "cookie", - name: "IDP", - expires: 365 - } }], syncDelay: 5000, auctionDelay: 1000 From 435f3c7edac794973ec5f2dc3a5a1e795ebb5d72 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Tue, 18 Aug 2020 12:06:46 +0530 Subject: [PATCH 06/10] rename zeotapId+ to zeotapIdPlus --- modules/userId/eids.js | 2 +- .../{zeotapId+.js => zeotapIdPlusIdSystem.js} | 4 ++-- test/spec/modules/userId_spec.js | 24 +++++++++---------- ...+_spec.js => zeotapIdPlusIdSystem_spec.js} | 6 ++--- 4 files changed, 18 insertions(+), 18 deletions(-) rename modules/{zeotapId+.js => zeotapIdPlusIdSystem.js} (96%) rename test/spec/modules/{zeotapId+_spec.js => zeotapIdPlusIdSystem_spec.js} (96%) diff --git a/modules/userId/eids.js b/modules/userId/eids.js index 25d24a6c968..e6c3dbd5bd8 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -124,7 +124,7 @@ const USER_IDS_CONFIG = { } : undefined; } }, - // zeotapId+ + // zeotapIdPlus 'IDP': { source: 'zeotap.com', atype: 1 diff --git a/modules/zeotapId+.js b/modules/zeotapIdPlusIdSystem.js similarity index 96% rename from modules/zeotapId+.js rename to modules/zeotapIdPlusIdSystem.js index 85d15d82fc3..4eea6244907 100644 --- a/modules/zeotapId+.js +++ b/modules/zeotapIdPlusIdSystem.js @@ -1,7 +1,7 @@ /** * This module adds Zeotap to the User ID module * The {@link module:modules/userId} module is required - * @module modules/zeotapId+ + * @module modules/zeotapIdPlusIdSystem * @requires module:modules/userId */ import * as utils from '../src/utils.js' @@ -44,7 +44,7 @@ export const zeotapIdPlusSubmodule = { * used to link submodule with config * @type {string} */ - name: 'zeotapId+', + name: 'zeotapIdPlus', /** * decode the stored id value for passing to bid requests * @function diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 520b88b168a..3405b544fd4 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -26,7 +26,7 @@ import {liveIntentIdSubmodule} from 'modules/liveIntentIdSystem.js'; import {merkleIdSubmodule} from 'modules/merkleIdSystem.js'; import {netIdSubmodule} from 'modules/netIdSystem.js'; import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js'; -import {zeotapIdPlusSubmodule} from 'modules/zeotapId+.js'; +import {zeotapIdPlusSubmodule} from 'modules/zeotapIdPlusIdSystem.js'; import {sharedIdSubmodule} from 'modules/sharedIdSystem.js'; import {server} from 'test/mocks/xhr.js'; @@ -438,7 +438,7 @@ describe('User ID', function() { name: 'intentIqId', storage: { name: 'intentIqId', type: 'cookie' } }, { - name: 'zeotapId+', + name: 'zeotapIdPlus', storage: { name: 'IDP', type: 'cookie' } }] } @@ -1146,13 +1146,13 @@ describe('User ID', function() { }, {adUnits}); }); - it('test hook from zeotapId+ cookies', function(done) { + it('test hook from zeotapIdPlus cookies', function(done) { // simulate existing browser local storage values coreStorage.setCookie('IDP', btoa(JSON.stringify('abcdefghijk')), (new Date(Date.now() + 5000).toUTCString())); setSubmoduleRegistry([zeotapIdPlusSubmodule]); init(config); - config.setConfig(getConfigMock(['zeotapId+', 'IDP', 'cookie'])); + config.setConfig(getConfigMock(['zeotapIdPlus', 'IDP', 'cookie'])); requestBidsHook(function() { adUnits.forEach(unit => { @@ -1170,7 +1170,7 @@ describe('User ID', function() { }, {adUnits}); }); - it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, zeotapId+, sharedId and netId have data to pass', function(done) { + it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, zeotapIdPlus, sharedId and netId have data to pass', function(done) { coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); @@ -1191,7 +1191,7 @@ describe('User ID', function() { ['netId', 'netId', 'cookie'], ['sharedId', 'sharedid', 'cookie'], ['intentIqId', 'intentIqId', 'cookie'], - ['zeotapId+', 'IDP', 'cookie'])); + ['zeotapIdPlus', 'IDP', 'cookie'])); requestBidsHook(function() { adUnits.forEach(unit => { @@ -1222,7 +1222,7 @@ describe('User ID', function() { // also check that intentIqId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); - // also check that zeotapId+ id data was copied to bid + // also check that zeotapIdPlus id data was copied to bid expect(bid).to.have.deep.nested.property('userId.IDP'); expect(bid.userId.IDP).to.equal('zeotapId'); expect(bid.userIdAsEids.length).to.equal(9); @@ -1241,7 +1241,7 @@ describe('User ID', function() { }, {adUnits}); }); - it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, intentIqId, zeotapId+, sharedId and netId have their modules added before and after init', function(done) { + it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, intentIqId, zeotapIdPlus, sharedId and netId have their modules added before and after init', function(done) { coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString())); @@ -1277,7 +1277,7 @@ describe('User ID', function() { ['netId', 'netId', 'cookie'], ['sharedId', 'sharedid', 'cookie'], ['intentIqId', 'intentIqId', 'cookie'], - ['zeotapId+', 'IDP', 'cookie'])); + ['zeotapIdPlus', 'IDP', 'cookie'])); requestBidsHook(function() { adUnits.forEach(unit => { @@ -1308,7 +1308,7 @@ describe('User ID', function() { // also check that intentIqId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); - // also check that zeotapId+ id data was copied to bid + // also check that zeotapIdPlus id data was copied to bid expect(bid).to.have.deep.nested.property('userId.IDP'); expect(bid.userId.IDP).to.equal('zeotapId'); expect(bid.userIdAsEids.length).to.equal(9); @@ -1383,7 +1383,7 @@ describe('User ID', function() { }, { name: 'intentIqId', storage: { name: 'intentIqId', type: 'cookie' } }, { - name: 'zeotapId+', storage: { name: 'IDP', type: 'cookie' } + name: 'zeotapIdPlus', storage: { name: 'IDP', type: 'cookie' } }, { name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} }] @@ -1437,7 +1437,7 @@ describe('User ID', function() { // also check that intentIqId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); - // also check that zeotapId+ id data was copied to bid + // also check that zeotapIdPlus id data was copied to bid expect(bid).to.have.deep.nested.property('userId.IDP'); expect(bid.userId.IDP).to.equal('zeotapId'); expect(bid.userIdAsEids.length).to.equal(9); diff --git a/test/spec/modules/zeotapId+_spec.js b/test/spec/modules/zeotapIdPlusIdSystem_spec.js similarity index 96% rename from test/spec/modules/zeotapId+_spec.js rename to test/spec/modules/zeotapIdPlusIdSystem_spec.js index cbc89fdb8c7..b0bcd8de91c 100644 --- a/test/spec/modules/zeotapId+_spec.js +++ b/test/spec/modules/zeotapIdPlusIdSystem_spec.js @@ -3,14 +3,14 @@ import find from 'core-js-pure/features/array/find.js'; import { config } from 'src/config.js'; import { newStorageManager } from 'src/storageManager.js'; import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js'; -import { zeotapIdPlusSubmodule } from 'modules/zeotapId+.js'; +import { zeotapIdPlusSubmodule } from 'modules/zeotapIdPlusIdSystem.js'; const storage = newStorageManager(); const ZEOTAP_COOKIE_NAME = 'IDP'; const ZEOTAP_COOKIE = 'THIS-IS-A-DUMMY-COOKIE'; const CONFIG_PARAMS_MOCK = { - name: 'zeotapId+', + name: 'zeotapIdPlus', storage: { name: 'IDP', type: 'cookie' } }; @@ -19,7 +19,7 @@ function getConfigMock() { userSync: { syncDelay: 0, userIds: [{ - name: 'zeotapId+', + name: 'zeotapIdPlus', storage: { name: 'IDP', type: 'cookie' From f587d2aa51da5dc526194cbd235161e0bde5a7a4 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Thu, 20 Aug 2020 15:06:56 +0530 Subject: [PATCH 07/10] add zeotapIdPlus submodule to submodules.json --- integrationExamples/gpt/userId_example.html | 7 +++++++ modules/.submodules.json | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index 8115e60fcd1..f96e958018c 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -230,6 +230,13 @@ name: "_li_pbid", expires: 28 } + }, + { + name: "zeotapIdPlus", + storage: { + type: "cookie", + name: "IDP" + } }], syncDelay: 5000, auctionDelay: 1000 diff --git a/modules/.submodules.json b/modules/.submodules.json index 50d17fc5f6c..bacc543401f 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -12,7 +12,8 @@ "netIdSystem", "identityLinkIdSystem", "sharedIdSystem", - "intentIqIdSystem" + "intentIqIdSystem", + "zeotapIdPlusIdSystem" ], "adpod": [ "freeWheelAdserverVideo", From 20f152e7ff668876e399deca8085d068df322714 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Fri, 21 Aug 2020 13:56:37 +0530 Subject: [PATCH 08/10] refactor code for requested changes: remove storage from configParams --- integrationExamples/gpt/userId_example.html | 6 +-- modules/zeotapIdPlusIdSystem.js | 31 ++--------- test/spec/modules/userId_spec.js | 5 +- .../spec/modules/zeotapIdPlusIdSystem_spec.js | 53 +++++++------------ 4 files changed, 28 insertions(+), 67 deletions(-) diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index f96e958018c..51b9f2aef90 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -232,11 +232,7 @@ } }, { - name: "zeotapIdPlus", - storage: { - type: "cookie", - name: "IDP" - } + name: "zeotapIdPlus" }], syncDelay: 5000, auctionDelay: 1000 diff --git a/modules/zeotapIdPlusIdSystem.js b/modules/zeotapIdPlusIdSystem.js index 4eea6244907..c194a9b9679 100644 --- a/modules/zeotapIdPlusIdSystem.js +++ b/modules/zeotapIdPlusIdSystem.js @@ -11,18 +11,6 @@ import { getStorageManager } from '../src/storageManager.js'; const ZEOTAP_COOKIE_NAME = 'IDP'; const storage = getStorageManager(); -function isValidConfig(configParams) { - if (!configParams) { - utils.logError('User ID - zeotapId submodule requires configParams'); - return false; - } - if (!configParams.name) { - utils.logError('User ID - zeotapId submodule requires valid config params: name'); - return false; - } - return true; -} - function readCookie() { return storage.cookiesAreEnabled ? storage.getCookie(ZEOTAP_COOKIE_NAME) : null; } @@ -31,13 +19,6 @@ function readFromLocalStorage() { return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(ZEOTAP_COOKIE_NAME) : null; } -function fetchId(configParams) { - if (!isValidConfig(configParams)) return undefined; - const id = readCookie() || readFromLocalStorage(); - if (!id) return undefined; - return { id: JSON.parse(atob(id)) }; -}; - /** @type {Submodule} */ export const zeotapIdPlusSubmodule = { /** @@ -53,12 +34,9 @@ export const zeotapIdPlusSubmodule = { */ decode(value) { const id = value ? utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined : undefined; - if (!id) { - return undefined; - } - return { + return id ? { 'IDP': JSON.parse(atob(id)) - } + } : undefined; }, /** * performs action to obtain id and return a value in the callback's response argument @@ -66,8 +44,9 @@ export const zeotapIdPlusSubmodule = { * @param {SubmoduleParams} configParams * @return {{id: string | undefined} | undefined} */ - getId(configParams) { - return fetchId(configParams); + getId() { + const id = readCookie() || readFromLocalStorage(); + return id ? { id } : undefined; } }; submodule('userId', zeotapIdPlusSubmodule); diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 3405b544fd4..6fd38dac9ff 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -438,8 +438,7 @@ describe('User ID', function() { name: 'intentIqId', storage: { name: 'intentIqId', type: 'cookie' } }, { - name: 'zeotapIdPlus', - storage: { name: 'IDP', type: 'cookie' } + name: 'zeotapIdPlus' }] } }); @@ -1383,7 +1382,7 @@ describe('User ID', function() { }, { name: 'intentIqId', storage: { name: 'intentIqId', type: 'cookie' } }, { - name: 'zeotapIdPlus', storage: { name: 'IDP', type: 'cookie' } + name: 'zeotapIdPlus' }, { name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} }] diff --git a/test/spec/modules/zeotapIdPlusIdSystem_spec.js b/test/spec/modules/zeotapIdPlusIdSystem_spec.js index b0bcd8de91c..52698ecffc9 100644 --- a/test/spec/modules/zeotapIdPlusIdSystem_spec.js +++ b/test/spec/modules/zeotapIdPlusIdSystem_spec.js @@ -9,21 +9,14 @@ const storage = newStorageManager(); const ZEOTAP_COOKIE_NAME = 'IDP'; const ZEOTAP_COOKIE = 'THIS-IS-A-DUMMY-COOKIE'; -const CONFIG_PARAMS_MOCK = { - name: 'zeotapIdPlus', - storage: { name: 'IDP', type: 'cookie' } -}; +const ENCODED_ZEOTAP_COOKIE = btoa(JSON.stringify(ZEOTAP_COOKIE)); function getConfigMock() { return { userSync: { syncDelay: 0, userIds: [{ - name: 'zeotapIdPlus', - storage: { - name: 'IDP', - type: 'cookie' - } + name: 'zeotapIdPlus' }] } } @@ -44,14 +37,6 @@ function getAdUnitMock(code = 'adUnit-code') { }; } -function writeZeotapCookie() { - storage.setCookie( - ZEOTAP_COOKIE_NAME, - btoa(JSON.stringify(ZEOTAP_COOKIE)), - (new Date(Date.now() + 5000).toUTCString()), - ); -} - function unsetCookie() { storage.setCookie(ZEOTAP_COOKIE_NAME, ''); } @@ -67,30 +52,28 @@ describe('Zeotap ID System', function() { unsetLocalStorage(); }) - it('return undefined if incorrect config as argument', function() { - writeZeotapCookie(); - let id = zeotapIdPlusSubmodule.getId({}); - expect(id).to.be.undefined; - }); - it('provides the stored Zeotap id if a cookie exists', function() { - writeZeotapCookie(); - let id = zeotapIdPlusSubmodule.getId(CONFIG_PARAMS_MOCK); + storage.setCookie( + ZEOTAP_COOKIE_NAME, + ENCODED_ZEOTAP_COOKIE, + (new Date(Date.now() + 5000).toUTCString()), + ); + let id = zeotapIdPlusSubmodule.getId(); expect(id).to.deep.equal({ - id: ZEOTAP_COOKIE + id: ENCODED_ZEOTAP_COOKIE }); }); it('provides the stored Zeotap id if cookie is absent but present in local storage', function() { - writeZeotapCookie(); - let id = zeotapIdPlusSubmodule.getId(CONFIG_PARAMS_MOCK); + storage.setDataInLocalStorage(ZEOTAP_COOKIE_NAME, ENCODED_ZEOTAP_COOKIE); + let id = zeotapIdPlusSubmodule.getId(); expect(id).to.deep.equal({ - id: ZEOTAP_COOKIE + id: ENCODED_ZEOTAP_COOKIE }); }); it('returns undefined if both cookie and local storage are empty', function() { - let id = zeotapIdPlusSubmodule.getId(CONFIG_PARAMS_MOCK); + let id = zeotapIdPlusSubmodule.getId(); expect(id).to.be.undefined }) }); @@ -98,7 +81,7 @@ describe('Zeotap ID System', function() { describe('test method: decode', function() { it('provides the Zeotap ID (IDP) from a stored object', function() { let zeotapId = { - id: btoa(JSON.stringify(ZEOTAP_COOKIE)), + id: ENCODED_ZEOTAP_COOKIE, }; expect(zeotapIdPlusSubmodule.decode(zeotapId)).to.deep.equal({ @@ -107,7 +90,7 @@ describe('Zeotap ID System', function() { }); it('provides the Zeotap ID (IDP) from a stored string', function() { - let zeotapId = btoa(JSON.stringify(ZEOTAP_COOKIE)); + let zeotapId = ENCODED_ZEOTAP_COOKIE; expect(zeotapIdPlusSubmodule.decode(zeotapId)).to.deep.equal({ IDP: ZEOTAP_COOKIE @@ -120,7 +103,11 @@ describe('Zeotap ID System', function() { beforeEach(function() { adUnits = [getAdUnitMock()]; - writeZeotapCookie(); + storage.setCookie( + ZEOTAP_COOKIE_NAME, + ENCODED_ZEOTAP_COOKIE, + (new Date(Date.now() + 5000).toUTCString()), + ); setSubmoduleRegistry([zeotapIdPlusSubmodule]); init(config); config.setConfig(getConfigMock()); From 4fe541162a5e8d65a892b180ecb5351d495d6655 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Thu, 27 Aug 2020 12:10:26 +0530 Subject: [PATCH 09/10] add tests to eids_spec --- test/spec/modules/eids_spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 8ad44f0b1ad..a0bc0a84ee3 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -192,6 +192,20 @@ describe('eids array generation for known sub-modules', function() { }] }); }); + it('zeotapIdPlus', function() { + const userId = { + IDP: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'zeotap.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }); + }); }); describe('Negative case', function() { From 3b56ee6b789c3b598d9e238bdff19cc84b0d3957 Mon Sep 17 00:00:00 2001 From: shikharsharma-zeotap Date: Sat, 29 Aug 2020 14:53:23 +0530 Subject: [PATCH 10/10] rebase n resolve conflicts --- test/spec/modules/userId_spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 6fd38dac9ff..167187a281f 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -355,7 +355,7 @@ describe('User ID', function() { }); it('handles config with no usersync object', function() { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({}); // usersync is undefined, and no logInfo message for 'User ID - usersync config updated' @@ -363,14 +363,14 @@ describe('User ID', function() { }); it('handles config with empty usersync object', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({userSync: {}}); expect(typeof utils.logInfo.args[0]).to.equal('undefined'); }); it('handles config with usersync and userIds that are empty objs', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({ userSync: { @@ -381,7 +381,7 @@ describe('User ID', function() { }); it('handles config with usersync and userIds with empty names or that dont match a submodule.name', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubModule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule]); init(config); config.setConfig({ userSync: { @@ -1144,7 +1144,7 @@ describe('User ID', function() { done(); }, {adUnits}); }); - + it('test hook from zeotapIdPlus cookies', function(done) { // simulate existing browser local storage values coreStorage.setCookie('IDP', btoa(JSON.stringify('abcdefghijk')), (new Date(Date.now() + 5000).toUTCString()));