From 65f29a3851d66f5b9d3fcceaeed427cfcf9b6f91 Mon Sep 17 00:00:00 2001 From: Peixun Zhang Date: Fri, 22 Sep 2023 12:25:30 +0200 Subject: [PATCH 1/8] Add support for openx cookies --- modules/liveIntentIdSystem.js | 48 +++-- package-lock.json | 18 +- test/spec/modules/eids_spec.js | 175 ++++++++++------- .../modules/liveIntentIdMinimalSystem_spec.js | 137 +++++++------ test/spec/modules/liveIntentIdSystem_spec.js | 185 ++++++++++-------- 5 files changed, 327 insertions(+), 236 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 2d9e6b63a35..8cda487e6b1 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -9,14 +9,14 @@ import { ajaxBuilder } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/validate-imports import { gdprDataHandler, uspDataHandler } from '../src/adapterManager.js'; -import {getStorageManager} from '../src/storageManager.js'; -import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { MODULE_TYPE_UID } from '../src/activities/modules.js'; const EVENTS_TOPIC = 'pre_lips' const MODULE_NAME = 'liveIntentId'; const LI_PROVIDER_DOMAIN = 'liveintent.com'; -export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); -const defaultRequestedAttributes = {'nonId': true} +export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME }); +const defaultRequestedAttributes = { 'nonId': true } const calls = { ajaxGet: (url, onSuccess, onError, timeout) => { ajaxBuilder(timeout)( @@ -79,7 +79,7 @@ function parseRequestedAttributes(overrides) { return Object.entries(config).flatMap(([k, v]) => (typeof v === 'boolean' && v) ? [k] : []); } if (typeof overrides === 'object') { - return createParameterArray({...defaultRequestedAttributes, ...overrides}) + return createParameterArray({ ...defaultRequestedAttributes, ...overrides }) } else { return createParameterArray(defaultRequestedAttributes); } @@ -209,6 +209,10 @@ export const liveIntentIdSubmodule = { result.index = { 'id': value.index, ext: { provider: LI_PROVIDER_DOMAIN } } } + if (value.openx) { + result.openx = { 'id': value.openx, ext: { provider: LI_PROVIDER_DOMAIN } } + } + return result } @@ -233,7 +237,7 @@ export const liveIntentIdSubmodule = { return; } tryFireEvent(); - const result = function(callback) { + const result = function (callback) { liveConnect.resolve( response => { callback(response); @@ -249,12 +253,12 @@ export const liveIntentIdSubmodule = { }, eids: { 'lipb': { - getValue: function(data) { + getValue: function (data) { return data.lipbid; }, source: 'liveintent.com', atype: 3, - getEidExt: function(data) { + getEidExt: function (data) { if (Array.isArray(data.segments) && data.segments.length) { return { segments: data.segments @@ -265,10 +269,10 @@ export const liveIntentIdSubmodule = { 'bidswitch': { source: 'bidswitch.net', atype: 3, - getValue: function(data) { + getValue: function (data) { return data.id; }, - getUidExt: function(data) { + getUidExt: function (data) { if (data.ext) { return data.ext; } @@ -277,10 +281,10 @@ export const liveIntentIdSubmodule = { 'medianet': { source: 'media.net', atype: 3, - getValue: function(data) { + getValue: function (data) { return data.id; }, - getUidExt: function(data) { + getUidExt: function (data) { if (data.ext) { return data.ext; } @@ -289,10 +293,10 @@ export const liveIntentIdSubmodule = { 'magnite': { source: 'rubiconproject.com', atype: 3, - getValue: function(data) { + getValue: function (data) { return data.id; }, - getUidExt: function(data) { + getUidExt: function (data) { if (data.ext) { return data.ext; } @@ -301,10 +305,22 @@ export const liveIntentIdSubmodule = { 'index': { source: 'liveintent.indexexchange.com', atype: 3, - getValue: function(data) { + getValue: function (data) { + return data.id; + }, + getUidExt: function (data) { + if (data.ext) { + return data.ext; + } + } + }, + 'openx': { + source: 'opex.com', + atype: 3, + getValue: function (data) { return data.id; }, - getUidExt: function(data) { + getUidExt: function (data) { if (data.ext) { return data.ext; } diff --git a/package-lock.json b/package-lock.json index dbfc057de9f..85aff19a30f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "prebid.js", - "version": "8.8.0-pre", + "version": "8.14.0-pre", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.16.7", @@ -6997,9 +6997,9 @@ "dev": true }, "node_modules/caniuse-lite": { - "version": "1.0.30001429", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", - "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==", + "version": "1.0.30001538", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", + "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==", "funding": [ { "type": "opencollective", @@ -7008,6 +7008,10 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ] }, @@ -30653,9 +30657,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001429", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", - "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==" + "version": "1.0.30001538", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", + "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==" }, "caseless": { "version": "0.12.0", diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 1597790e652..2af0ba6ea23 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -1,11 +1,11 @@ -import {createEidsArray} from 'modules/userId/eids.js'; -import {expect} from 'chai'; +import { createEidsArray } from 'modules/userId/eids.js'; +import { expect } from 'chai'; -// Note: In unit tets cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids +// Note: In unit test cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids // this way the request will stay consistent and unit test cases will not need lots of changes. -describe('eids array generation for known sub-modules', function() { - it('pubCommonId', function() { +describe('eids array generation for known sub-modules', function () { + it('pubCommonId', function () { const userId = { pubcid: 'some-random-id-value' }; @@ -13,11 +13,11 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'pubcid.org', - uids: [{id: 'some-random-id-value', atype: 1}] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('unifiedId: ext generation', function() { + it('unifiedId: ext generation', function () { const userId = { tdid: 'some-random-id-value' }; @@ -25,12 +25,12 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'adserver.org', - uids: [{id: 'some-random-id-value', atype: 1, ext: { rtiPartner: 'TDID' }}] + uids: [{ id: 'some-random-id-value', atype: 1, ext: { rtiPartner: 'TDID' } }] }); }); - describe('id5Id', function() { - it('does not include an ext if not provided', function() { + describe('id5Id', function () { + it('does not include an ext if not provided', function () { const userId = { id5id: { uid: 'some-random-id-value' @@ -44,7 +44,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('includes ext if provided', function() { + it('includes ext if provided', function () { const userId = { id5id: { uid: 'some-random-id-value', @@ -68,7 +68,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('parrableId', function() { + it('parrableId', function () { const userId = { parrableId: { eid: 'some-random-id-value' @@ -78,11 +78,11 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'parrable.com', - uids: [{id: 'some-random-id-value', atype: 1}] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('merkleId (legacy) - supports single id', function() { + it('merkleId (legacy) - supports single id', function () { const userId = { merkleId: { id: 'some-random-id-value', keyID: 1 @@ -101,7 +101,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('merkleId supports multiple source providers', function() { + it('merkleId supports multiple source providers', function () { const userId = { merkleId: [{ id: 'some-random-id-value', ext: { enc: 1, keyID: 16, idName: 'pamId', ssp: 'ssp1' } @@ -120,7 +120,8 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(2); expect(newEids[0]).to.deep.equal({ source: 'ssp1.merkleinc.com', - uids: [{id: 'some-random-id-value', + uids: [{ + id: 'some-random-id-value', atype: 3, ext: { enc: 1, @@ -132,7 +133,8 @@ describe('eids array generation for known sub-modules', function() { }); expect(newEids[1]).to.deep.equal({ source: 'ssp2.merkleinc.com', - uids: [{id: 'another-random-id-value', + uids: [{ + id: 'another-random-id-value', atype: 3, ext: { third: 4, @@ -144,7 +146,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('identityLink', function() { + it('identityLink', function () { const userId = { idl_env: 'some-random-id-value' }; @@ -152,11 +154,11 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveramp.com', - uids: [{id: 'some-random-id-value', atype: 3}] + uids: [{ id: 'some-random-id-value', atype: 3 }] }); }); - it('liveIntentId; getValue call and ext', function() { + it('liveIntentId; getValue call and ext', function () { const userId = { lipb: { lipbid: 'some-random-id-value', @@ -167,14 +169,14 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveintent.com', - uids: [{id: 'some-random-id-value', atype: 3}], - ext: {segments: ['s1', 's2']} + uids: [{ id: 'some-random-id-value', atype: 3 }], + ext: { segments: ['s1', 's2'] } }); }); - it('bidswitch', function() { + it('bidswitch', function () { const userId = { - bidswitch: {'id': 'sample_id'} + bidswitch: { 'id': 'sample_id' } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -187,9 +189,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('bidswitch with ext', function() { + it('bidswitch with ext', function () { const userId = { - bidswitch: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} + bidswitch: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -205,9 +207,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('medianet', function() { + it('medianet', function () { const userId = { - medianet: {'id': 'sample_id'} + medianet: { 'id': 'sample_id' } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -220,9 +222,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('medianet with ext', function() { + it('medianet with ext', function () { const userId = { - medianet: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} + medianet: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -238,9 +240,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('magnite', function() { + it('magnite', function () { const userId = { - magnite: {'id': 'sample_id'} + magnite: { 'id': 'sample_id' } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -253,9 +255,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('magnite with ext', function() { + it('magnite with ext', function () { const userId = { - magnite: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} + magnite: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -271,9 +273,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('index', function() { + it('index', function () { const userId = { - index: {'id': 'sample_id'} + index: { 'id': 'sample_id' } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -286,9 +288,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('index with ext', function() { + it('index with ext', function () { const userId = { - index: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} + index: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -304,7 +306,40 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('liveIntentId; getValue call and NO ext', function() { + it('openx', function () { + const userId = { + openx: { 'id': 'sample_id' } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'opex.com', + uids: [{ + id: 'sample_id', + atype: 3 + }] + }); + }); + + it('openx with ext', function () { + const userId = { + index: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'opex.com', + uids: [{ + id: 'sample_id', + atype: 3, + ext: { + provider: 'some.provider.com' + } + }] + }); + }); + + it('liveIntentId; getValue call and NO ext', function () { const userId = { lipb: { lipbid: 'some-random-id-value' @@ -314,11 +349,11 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveintent.com', - uids: [{id: 'some-random-id-value', atype: 3}] + uids: [{ id: 'some-random-id-value', atype: 3 }] }); }); - it('britepoolId', function() { + it('britepoolId', function () { const userId = { britepoolid: 'some-random-id-value' }; @@ -326,7 +361,7 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'britepool.com', - uids: [{id: 'some-random-id-value', atype: 3}] + uids: [{ id: 'some-random-id-value', atype: 3 }] }); }); @@ -342,7 +377,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('criteo', function() { + it('criteo', function () { const userId = { criteoId: 'some-random-id-value' }; @@ -350,11 +385,11 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'criteo.com', - uids: [{id: 'some-random-id-value', atype: 1}] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('tapadId', function() { + it('tapadId', function () { const userId = { tapadId: 'some-random-id-value' }; @@ -362,11 +397,11 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'tapad.com', - uids: [{id: 'some-random-id-value', atype: 1}] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('deepintentId', function() { + it('deepintentId', function () { const userId = { deepintentId: 'some-random-id-value' }; @@ -374,11 +409,11 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'deepintent.com', - uids: [{id: 'some-random-id-value', atype: 3}] + uids: [{ id: 'some-random-id-value', atype: 3 }] }); }); - it('NetId', function() { + it('NetId', function () { const userId = { netId: 'some-random-id-value' }; @@ -386,11 +421,11 @@ describe('eids array generation for known sub-modules', function() { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'netid.de', - uids: [{id: 'some-random-id-value', atype: 1}] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('zeotapIdPlus', function() { + it('zeotapIdPlus', function () { const userId = { IDP: 'some-random-id-value' }; @@ -405,7 +440,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('hadronId', function() { + it('hadronId', function () { const userId = { hadronId: 'some-random-id-value' }; @@ -420,7 +455,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('quantcastId', function() { + it('quantcastId', function () { const userId = { quantcastId: 'some-random-id-value' }; @@ -435,9 +470,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('uid2', function() { + it('uid2', function () { const userId = { - uid2: {'id': 'Sample_AD_Token'} + uid2: { 'id': 'Sample_AD_Token' } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -450,9 +485,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('uid2 with ext', function() { + it('uid2 with ext', function () { const userId = { - uid2: {'id': 'Sample_AD_Token', 'ext': {'provider': 'some.provider.com'}} + uid2: { 'id': 'Sample_AD_Token', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -468,9 +503,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('euid', function() { + it('euid', function () { const userId = { - euid: {'id': 'Sample_AD_Token'} + euid: { 'id': 'Sample_AD_Token' } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -483,7 +518,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('kpuid', function() { + it('kpuid', function () { const userId = { kpuid: 'Sample_Token' }; @@ -498,7 +533,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('tncid', function() { + it('tncid', function () { const userId = { tncid: 'TEST_TNCID' }; @@ -513,7 +548,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('pubProvidedId', function() { + it('pubProvidedId', function () { const userId = { pubProvidedId: [{ source: 'example.com', @@ -565,7 +600,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('qid', function() { + it('qid', function () { const userId = { qid: 'some-random-id-value' }; @@ -580,7 +615,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('operaId', function() { + it('operaId', function () { const userId = { operaId: 'some-random-id-value' }; @@ -595,7 +630,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('33acrossId', function() { + it('33acrossId', function () { const userId = { '33acrossId': { envelope: 'some-random-id-value' @@ -655,8 +690,8 @@ describe('eids array generation for known sub-modules', function() { }); }); - describe('imuid', function() { - it('should return the correct EID schema with imuid', function() { + describe('imuid', function () { + it('should return the correct EID schema with imuid', function () { const userId = { imuid: 'testimuid' }; @@ -671,7 +706,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('should return the correct EID schema with imppid', function() { + it('should return the correct EID schema with imppid', function () { const userId = { imppid: 'imppid-value-imppid-value-imppid-value' }; @@ -689,7 +724,7 @@ describe('eids array generation for known sub-modules', function() { }); describe('Negative case', function () { - it('eids array generation for UN-known sub-module', function() { + it('eids array generation for UN-known sub-module', function () { // UnknownCommonId const userId = { unknowncid: 'some-random-id-value' @@ -698,7 +733,7 @@ describe('Negative case', function () { expect(newEids.length).to.equal(0); }); - it('eids array generation for known sub-module with non-string value', function() { + it('eids array generation for known sub-module with non-string value', function () { // pubCommonId let userId = { pubcid: undefined diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 0929a022937..8f73e8ff048 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -4,10 +4,10 @@ import { server } from 'test/mocks/xhr.js'; import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } from 'modules/liveIntentIdSystem.js'; const PUBLISHER_ID = '89899'; -const defaultConfigParams = { params: {publisherId: PUBLISHER_ID} }; -const responseHeader = {'Content-Type': 'application/json'}; +const defaultConfigParams = { params: { publisherId: PUBLISHER_ID } }; +const responseHeader = { 'Content-Type': 'application/json' }; -describe('LiveIntentMinimalId', function() { +describe('LiveIntentMinimalId', function () { let logErrorStub; let uspConsentDataStub; let gdprConsentDataStub; @@ -15,7 +15,7 @@ describe('LiveIntentMinimalId', function() { let getDataFromLocalStorageStub; let imgStub; - beforeEach(function() { + beforeEach(function () { liveIntentIdSubmodule.setModuleMode('minimal'); imgStub = sinon.stub(utils, 'triggerPixel'); getCookieStub = sinon.stub(storage, 'getCookie'); @@ -25,7 +25,7 @@ describe('LiveIntentMinimalId', function() { gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); }); - afterEach(function() { + afterEach(function () { imgStub.restore(); getCookieStub.restore(); getDataFromLocalStorageStub.restore(); @@ -35,7 +35,7 @@ describe('LiveIntentMinimalId', function() { liveIntentIdSubmodule.setModuleMode('minimal'); resetLiveIntentIdSubmodule(); }); - it('should not fire an event when getId', function() { + it('should not fire an event when getId', function () { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -45,12 +45,12 @@ describe('LiveIntentMinimalId', function() { expect(server.requests[0]).to.eql(undefined) }); - it('should not return a decoded identifier when the unifiedId is not present in the value', function() { + it('should not return a decoded identifier when the unifiedId is not present in the value', function () { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); expect(result).to.be.eql({}); }); - it('should initialize LiveConnect and send no data', function() { + it('should initialize LiveConnect and send no data', function () { liveIntentIdSubmodule.getId(defaultConfigParams); liveIntentIdSubmodule.decode({}, defaultConfigParams); liveIntentIdSubmodule.getId(defaultConfigParams); @@ -58,10 +58,10 @@ describe('LiveIntentMinimalId', function() { expect(server.requests.length).to.be.eq(0); }); - it('should call the Custom URL of the LiveIntent Identity Exchange endpoint', function() { + it('should call the Custom URL of the LiveIntent Identity Exchange endpoint', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, ...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); @@ -73,7 +73,7 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the Identity Exchange endpoint with the privided distributorId', function() { + it('should call the Identity Exchange endpoint with the privided distributorId', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback; @@ -87,7 +87,7 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function() { + it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback; @@ -101,16 +101,18 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function() { + it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { - ...defaultConfigParams.params, - ...{ - 'url': 'https://dummy.liveintent.com/idex', - 'partner': 'rubicon' + let submoduleCallback = liveIntentIdSubmodule.getId({ + params: { + ...defaultConfigParams.params, + ...{ + 'url': 'https://dummy.liveintent.com/idex', + 'partner': 'rubicon' + } } - } }).callback; + }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899?resolve=nonId'); @@ -122,7 +124,7 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function() { + it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -137,7 +139,7 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors', function() { + it('should log an error and continue to callback if ajax request errors', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -153,7 +155,7 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function() { + it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie); let callBackSpy = sinon.spy(); @@ -169,16 +171,18 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier and additional Identifiers to resolve', function() { + it('should include the LiveConnect identifier and additional Identifiers to resolve', function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie); getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc'); - const configParams = { params: { - ...defaultConfigParams.params, - ...{ - 'identifiersToResolve': ['_thirdPC'] + const configParams = { + params: { + ...defaultConfigParams.params, + ...{ + 'identifiersToResolve': ['_thirdPC'] + } } - }}; + }; let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); @@ -192,15 +196,17 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include an additional identifier value to resolve even if it is an object', function() { + it('should include an additional identifier value to resolve even if it is an object', function () { getCookieStub.returns(null); - getDataFromLocalStorageStub.withArgs('_thirdPC').returns({'key': 'value'}); - const configParams = { params: { - ...defaultConfigParams.params, - ...{ - 'identifiersToResolve': ['_thirdPC'] + getDataFromLocalStorageStub.withArgs('_thirdPC').returns({ 'key': 'value' }); + const configParams = { + params: { + ...defaultConfigParams.params, + ...{ + 'identifiersToResolve': ['_thirdPC'] + } } - }}; + }; let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); @@ -214,22 +220,24 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a unifiedId to lipbId and remove it', function() { + it('should decode a unifiedId to lipbId and remove it', function () { const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); - expect(result).to.eql({'lipb': {'lipbid': 'data'}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'data' } }); }); - it('should decode a nonId to lipbId', function() { + it('should decode a nonId to lipbId', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); - expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'data', 'nonId': 'data' } }); }); - it('should resolve extra attributes', function() { + it('should resolve extra attributes', function () { let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { - ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } - } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ + params: { + ...defaultConfigParams.params, + ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } + } + }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=nonId&resolve=foo`); @@ -241,42 +249,49 @@ describe('LiveIntentMinimalId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a uid2 to a seperate object when present', function() { + it('should decode a uid2 to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar'}, 'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar' }, 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode values with uid2 but no nonId', function() { + it('should decode values with uid2 but no nonId', function () { const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); - expect(result).to.eql({'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a bidswitch id to a seperate object when present', function() { + it('should decode a bidswitch id to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar'}, 'bidswitch': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar' }, 'bidswitch': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a medianet id to a seperate object when present', function() { + it('should decode a medianet id to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar'}, 'medianet': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar' }, 'medianet': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a magnite id to a seperate object when present', function() { + it('should decode a magnite id to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar'}, 'magnite': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'magnite': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an index id to a seperate object when present', function() { + it('should decode an index id to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'index': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should allow disabling nonId resolution', function() { + it('should decode an openx id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + }) + + it('should allow disabling nonId resolution', function () { let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { - ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } - } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ + params: { + ...defaultConfigParams.params, + ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } + } + }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=uid2`); diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 4f11af57711..e7314f687a7 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -5,10 +5,10 @@ import { server } from 'test/mocks/xhr.js'; resetLiveIntentIdSubmodule(); liveIntentIdSubmodule.setModuleMode('standard') const PUBLISHER_ID = '89899'; -const defaultConfigParams = { params: {publisherId: PUBLISHER_ID, fireEventDelay: 1} }; -const responseHeader = {'Content-Type': 'application/json'} +const defaultConfigParams = { params: { publisherId: PUBLISHER_ID, fireEventDelay: 1 } }; +const responseHeader = { 'Content-Type': 'application/json' } -describe('LiveIntentId', function() { +describe('LiveIntentId', function () { let logErrorStub; let uspConsentDataStub; let gdprConsentDataStub; @@ -16,7 +16,7 @@ describe('LiveIntentId', function() { let getDataFromLocalStorageStub; let imgStub; - beforeEach(function() { + beforeEach(function () { liveIntentIdSubmodule.setModuleMode('standard'); imgStub = sinon.stub(utils, 'triggerPixel'); getCookieStub = sinon.stub(storage, 'getCookie'); @@ -26,7 +26,7 @@ describe('LiveIntentId', function() { gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); }); - afterEach(function() { + afterEach(function () { imgStub.restore(); getCookieStub.restore(); getDataFromLocalStorageStub.restore(); @@ -59,7 +59,7 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnceWith(response)).to.be.true; }); - it('should fire an event when getId', function(done) { + it('should fire an event when getId', function (done) { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -72,11 +72,13 @@ describe('LiveIntentId', function() { }, 200); }); - it('should fire an event when getId and a hash is provided', function(done) { - liveIntentIdSubmodule.getId({ params: { - ...defaultConfigParams, - emailHash: '58131bc547fb87af94cebdaf3102321f' - }}); + it('should fire an event when getId and a hash is provided', function (done) { + liveIntentIdSubmodule.getId({ + params: { + ...defaultConfigParams, + emailHash: '58131bc547fb87af94cebdaf3102321f' + } + }); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*e=58131bc547fb87af94cebdaf3102321f.+/) done(); @@ -84,16 +86,18 @@ describe('LiveIntentId', function() { }); it('should initialize LiveConnect with the config params when decode and emit an event', function (done) { - liveIntentIdSubmodule.decode({}, { params: { - ...defaultConfigParams.params, - ...{ - url: 'https://dummy.liveintent.com', - liCollectConfig: { - appId: 'a-0001', - collectorUrl: 'https://collector.liveintent.com' + liveIntentIdSubmodule.decode({}, { + params: { + ...defaultConfigParams.params, + ...{ + url: 'https://dummy.liveintent.com', + liCollectConfig: { + appId: 'a-0001', + collectorUrl: 'https://collector.liveintent.com' + } } } - }}); + }); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/collector.liveintent.com\/j\?.*aid=a-0001.*&wpn=prebid.*/); done(); @@ -117,7 +121,7 @@ describe('LiveIntentId', function() { }, 200); }); - it('should initialize LiveConnect and emit an event with a privacy string when decode', function(done) { + it('should initialize LiveConnect and emit an event with a privacy string when decode', function (done) { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: false, @@ -130,23 +134,25 @@ describe('LiveIntentId', function() { }, 200); }); - it('should fire an event when decode and a hash is provided', function(done) { - liveIntentIdSubmodule.decode({}, { params: { - ...defaultConfigParams.params, - emailHash: '58131bc547fb87af94cebdaf3102321f' - }}); + it('should fire an event when decode and a hash is provided', function (done) { + liveIntentIdSubmodule.decode({}, { + params: { + ...defaultConfigParams.params, + emailHash: '58131bc547fb87af94cebdaf3102321f' + } + }); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*e=58131bc547fb87af94cebdaf3102321f.+/); done(); }, 200); }); - it('should not return a decoded identifier when the unifiedId is not present in the value', function() { + it('should not return a decoded identifier when the unifiedId is not present in the value', function () { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); expect(result).to.be.eql({}); }); - it('should fire an event when decode', function(done) { + it('should fire an event when decode', function (done) { liveIntentIdSubmodule.decode({}, defaultConfigParams); setTimeout(() => { expect(server.requests[0].url).to.be.not.null @@ -154,7 +160,7 @@ describe('LiveIntentId', function() { }, 200); }); - it('should initialize LiveConnect and send data only once', function(done) { + it('should initialize LiveConnect and send data only once', function (done) { liveIntentIdSubmodule.getId(defaultConfigParams); liveIntentIdSubmodule.decode({}, defaultConfigParams); liveIntentIdSubmodule.getId(defaultConfigParams); @@ -165,10 +171,10 @@ describe('LiveIntentId', function() { }, 200); }); - it('should call the custom URL of the LiveIntent Identity Exchange endpoint', function() { + it('should call the custom URL of the LiveIntent Identity Exchange endpoint', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, ...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); @@ -179,7 +185,7 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint with the privided distributorId', function() { + it('should call the Identity Exchange endpoint with the privided distributorId', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback; @@ -193,7 +199,7 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function() { + it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback; @@ -207,16 +213,18 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function() { + it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { - ...defaultConfigParams.params, - ...{ - 'url': 'https://dummy.liveintent.com/idex', - 'partner': 'rubicon' + let submoduleCallback = liveIntentIdSubmodule.getId({ + params: { + ...defaultConfigParams.params, + ...{ + 'url': 'https://dummy.liveintent.com/idex', + 'partner': 'rubicon' + } } - } }).callback; + }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899?resolve=nonId'); @@ -228,7 +236,7 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function() { + it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -243,7 +251,7 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors', function() { + it('should log an error and continue to callback if ajax request errors', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -259,7 +267,7 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function() { + it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getCookieStub.withArgs('_lc2_fpi').returns(oldCookie) let callBackSpy = sinon.spy(); @@ -275,16 +283,18 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier and additional Identifiers to resolve', function() { + it('should include the LiveConnect identifier and additional Identifiers to resolve', function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getCookieStub.withArgs('_lc2_fpi').returns(oldCookie); getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc'); - const configParams = { params: { - ...defaultConfigParams.params, - ...{ - 'identifiersToResolve': ['_thirdPC'] + const configParams = { + params: { + ...defaultConfigParams.params, + ...{ + 'identifiersToResolve': ['_thirdPC'] + } } - }}; + }; let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); @@ -298,15 +308,17 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include an additional identifier value to resolve even if it is an object', function() { + it('should include an additional identifier value to resolve even if it is an object', function () { getCookieStub.returns(null); - getDataFromLocalStorageStub.withArgs('_thirdPC').returns({'key': 'value'}); - const configParams = { params: { - ...defaultConfigParams.params, - ...{ - 'identifiersToResolve': ['_thirdPC'] + getDataFromLocalStorageStub.withArgs('_thirdPC').returns({ 'key': 'value' }); + const configParams = { + params: { + ...defaultConfigParams.params, + ...{ + 'identifiersToResolve': ['_thirdPC'] + } } - }}; + }; let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); @@ -320,28 +332,30 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should send an error when the cookie jar throws an unexpected error', function() { + it('should send an error when the cookie jar throws an unexpected error', function () { getCookieStub.throws('CookieError', 'A message'); liveIntentIdSubmodule.getId(defaultConfigParams); expect(imgStub.getCall(0).args[0]).to.match(/.*ae=.+/); }); - it('should decode a unifiedId to lipbId and remove it', function() { + it('should decode a unifiedId to lipbId and remove it', function () { const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); - expect(result).to.eql({'lipb': {'lipbid': 'data'}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'data' } }); }); - it('should decode a nonId to lipbId', function() { + it('should decode a nonId to lipbId', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); - expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'data', 'nonId': 'data' } }); }); - it('should resolve extra attributes', function() { + it('should resolve extra attributes', function () { let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { - ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } - } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ + params: { + ...defaultConfigParams.params, + ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } + } + }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=nonId&resolve=foo`); @@ -353,42 +367,49 @@ describe('LiveIntentId', function() { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a uid2 to a seperate object when present', function() { + it('should decode a uid2 to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar'}, 'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar' }, 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode values with uid2 but no nonId', function() { + it('should decode values with uid2 but no nonId', function () { const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); - expect(result).to.eql({'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a bidswitch id to a seperate object when present', function() { + it('should decode a bidswitch id to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar'}, 'bidswitch': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar' }, 'bidswitch': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a medianet id to a seperate object when present', function() { + it('should decode a medianet id to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar'}, 'medianet': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar' }, 'medianet': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a magnite id to a seperate object when present', function() { + it('should decode a magnite id to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar'}, 'magnite': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'magnite': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an index id to a seperate object when present', function() { + it('should decode an index id to a seperate object when present', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'index': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should allow disabling nonId resolution', function() { + it('should decode an openx id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + }); + + it('should allow disabling nonId resolution', function () { let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { - ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } - } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ + params: { + ...defaultConfigParams.params, + ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } + } + }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=uid2`); From 79e34925bdf3603ff88da8a7ede88806c00fb78f Mon Sep 17 00:00:00 2001 From: Peixun Zhang Date: Fri, 22 Sep 2023 12:43:03 +0200 Subject: [PATCH 2/8] fix typo: --- modules/liveIntentIdSystem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 8cda487e6b1..feed0b126a0 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -315,7 +315,7 @@ export const liveIntentIdSubmodule = { } }, 'openx': { - source: 'opex.com', + source: 'openx.com', atype: 3, getValue: function (data) { return data.id; From 87b3400a177963bbc96372b41b2a1ef2df9d4147 Mon Sep 17 00:00:00 2001 From: Peixun Zhang Date: Fri, 22 Sep 2023 12:57:54 +0200 Subject: [PATCH 3/8] new changes --- modules/liveIntentIdSystem.js | 44 +++-- test/spec/modules/eids_spec.js | 157 ++++++++--------- .../modules/liveIntentIdMinimalSystem_spec.js | 108 ++++++------ test/spec/modules/liveIntentIdSystem_spec.js | 160 +++++++++--------- 4 files changed, 233 insertions(+), 236 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index feed0b126a0..846bb149882 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -4,21 +4,21 @@ * @module modules/liveIntentIdSystem * @requires module:modules/userId */ -import { triggerPixel, logError } from '../src/utils.js'; +import { triggerPixel,logError } from '../src/utils.js'; import { ajaxBuilder } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/validate-imports -import { gdprDataHandler, uspDataHandler } from '../src/adapterManager.js'; +import { gdprDataHandler,uspDataHandler } from '../src/adapterManager.js'; import { getStorageManager } from '../src/storageManager.js'; import { MODULE_TYPE_UID } from '../src/activities/modules.js'; const EVENTS_TOPIC = 'pre_lips' const MODULE_NAME = 'liveIntentId'; const LI_PROVIDER_DOMAIN = 'liveintent.com'; -export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME }); +export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID,moduleName: MODULE_NAME }); const defaultRequestedAttributes = { 'nonId': true } const calls = { - ajaxGet: (url, onSuccess, onError, timeout) => { + ajaxGet: (url,onSuccess,onError,timeout) => { ajaxBuilder(timeout)( url, { @@ -32,7 +32,7 @@ const calls = { } ) }, - pixelGet: (url, onload) => triggerPixel(url, onload) + pixelGet: (url,onload) => triggerPixel(url,onload) } let eventFired = false; @@ -43,7 +43,7 @@ let liveConnect = null; */ export function reset() { if (window && window.liQ_instances) { - window.liQ_instances.forEach(i => i.eventBus.off(EVENTS_TOPIC, setEventFiredFlag)) + window.liQ_instances.forEach(i => i.eventBus.off(EVENTS_TOPIC,setEventFiredFlag)) window.liQ_instances = []; } liveIntentIdSubmodule.setModuleMode(null) @@ -76,10 +76,10 @@ function parseLiveIntentCollectorConfig(collectConfig) { */ function parseRequestedAttributes(overrides) { function createParameterArray(config) { - return Object.entries(config).flatMap(([k, v]) => (typeof v === 'boolean' && v) ? [k] : []); + return Object.entries(config).flatMap(([k,v]) => (typeof v === 'boolean' && v) ? [k] : []); } if (typeof overrides === 'object') { - return createParameterArray({ ...defaultRequestedAttributes, ...overrides }) + return createParameterArray({ ...defaultRequestedAttributes,...overrides }) } else { return createParameterArray(defaultRequestedAttributes); } @@ -128,7 +128,7 @@ function initializeLiveConnect(configParams) { // The second param is the storage object, LS & Cookie manipulation uses PBJS // The third param is the ajax and pixel object, the ajax and pixel use PBJS - liveConnect = liveIntentIdSubmodule.getInitializer()(liveConnectConfig, storage, calls); + liveConnect = liveIntentIdSubmodule.getInitializer()(liveConnectConfig,storage,calls); if (configParams.emailHash) { liveConnect.push({ hash: configParams.emailHash }) } @@ -140,11 +140,11 @@ function tryFireEvent() { const eventDelay = liveConnect.config.fireEventDelay || 500 setTimeout(() => { const instances = window.liQ_instances - instances.forEach(i => i.eventBus.once(EVENTS_TOPIC, setEventFiredFlag)) + instances.forEach(i => i.eventBus.once(EVENTS_TOPIC,setEventFiredFlag)) if (!eventFired && liveConnect) { liveConnect.fire(); } - }, eventDelay) + },eventDelay) } } @@ -161,7 +161,7 @@ export const liveIntentIdSubmodule = { this.moduleMode = mode }, getInitializer() { - return (liveConnectConfig, storage, calls) => LiveConnect(liveConnectConfig, storage, calls, this.moduleMode) + return (liveConnectConfig,storage,calls) => LiveConnect(liveConnectConfig,storage,calls,this.moduleMode) }, /** @@ -173,7 +173,7 @@ export const liveIntentIdSubmodule = { * @param {SubmoduleConfig|undefined} config * @returns {{lipb:Object}} */ - decode(value, config) { + decode(value,config) { const configParams = (config && config.params) || {}; function composeIdObject(value) { const result = {}; @@ -190,27 +190,23 @@ export const liveIntentIdSubmodule = { // As adapters are applied in lexicographical order, we will always // be overwritten by the 'proper' uid2 module if it is present. if (value.uid2) { - result.uid2 = { 'id': value.uid2, ext: { provider: LI_PROVIDER_DOMAIN } } + result.uid2 = { 'id': value.uid2,ext: { provider: LI_PROVIDER_DOMAIN } } } if (value.bidswitch) { - result.bidswitch = { 'id': value.bidswitch, ext: { provider: LI_PROVIDER_DOMAIN } } + result.bidswitch = { 'id': value.bidswitch,ext: { provider: LI_PROVIDER_DOMAIN } } } if (value.medianet) { - result.medianet = { 'id': value.medianet, ext: { provider: LI_PROVIDER_DOMAIN } } + result.medianet = { 'id': value.medianet,ext: { provider: LI_PROVIDER_DOMAIN } } } if (value.magnite) { - result.magnite = { 'id': value.magnite, ext: { provider: LI_PROVIDER_DOMAIN } } + result.magnite = { 'id': value.magnite,ext: { provider: LI_PROVIDER_DOMAIN } } } if (value.index) { - result.index = { 'id': value.index, ext: { provider: LI_PROVIDER_DOMAIN } } - } - - if (value.openx) { - result.openx = { 'id': value.openx, ext: { provider: LI_PROVIDER_DOMAIN } } + result.index = { 'id': value.index,ext: { provider: LI_PROVIDER_DOMAIN } } } return result @@ -243,7 +239,7 @@ export const liveIntentIdSubmodule = { callback(response); }, error => { - logError(`${MODULE_NAME}: ID fetch encountered an error: `, error); + logError(`${MODULE_NAME}: ID fetch encountered an error: `,error); callback(); } ) @@ -329,4 +325,4 @@ export const liveIntentIdSubmodule = { } }; -submodule('userId', liveIntentIdSubmodule); +submodule('userId',liveIntentIdSubmodule); diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 2af0ba6ea23..a4acfa8fc6d 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -1,11 +1,11 @@ import { createEidsArray } from 'modules/userId/eids.js'; import { expect } from 'chai'; -// Note: In unit test cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids +// Note: In unit tets cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids // this way the request will stay consistent and unit test cases will not need lots of changes. -describe('eids array generation for known sub-modules', function () { - it('pubCommonId', function () { +describe('eids array generation for known sub-modules',function () { + it('pubCommonId',function () { const userId = { pubcid: 'some-random-id-value' }; @@ -13,11 +13,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'pubcid.org', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{ id: 'some-random-id-value',atype: 1 }] }); }); - it('unifiedId: ext generation', function () { + it('unifiedId: ext generation',function () { const userId = { tdid: 'some-random-id-value' }; @@ -25,12 +25,12 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'adserver.org', - uids: [{ id: 'some-random-id-value', atype: 1, ext: { rtiPartner: 'TDID' } }] + uids: [{ id: 'some-random-id-value',atype: 1,ext: { rtiPartner: 'TDID' } }] }); }); - describe('id5Id', function () { - it('does not include an ext if not provided', function () { + describe('id5Id',function () { + it('does not include an ext if not provided',function () { const userId = { id5id: { uid: 'some-random-id-value' @@ -40,11 +40,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'id5-sync.com', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{ id: 'some-random-id-value',atype: 1 }] }); }); - it('includes ext if provided', function () { + it('includes ext if provided',function () { const userId = { id5id: { uid: 'some-random-id-value', @@ -68,7 +68,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('parrableId', function () { + it('parrableId',function () { const userId = { parrableId: { eid: 'some-random-id-value' @@ -78,14 +78,14 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'parrable.com', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{ id: 'some-random-id-value',atype: 1 }] }); }); - it('merkleId (legacy) - supports single id', function () { + it('merkleId (legacy) - supports single id',function () { const userId = { merkleId: { - id: 'some-random-id-value', keyID: 1 + id: 'some-random-id-value',keyID: 1 } }; const newEids = createEidsArray(userId); @@ -101,11 +101,11 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('merkleId supports multiple source providers', function () { + it('merkleId supports multiple source providers',function () { const userId = { merkleId: [{ - id: 'some-random-id-value', ext: { enc: 1, keyID: 16, idName: 'pamId', ssp: 'ssp1' } - }, { + id: 'some-random-id-value',ext: { enc: 1,keyID: 16,idName: 'pamId',ssp: 'ssp1' } + },{ id: 'another-random-id-value', ext: { enc: 1, @@ -146,7 +146,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('identityLink', function () { + it('identityLink',function () { const userId = { idl_env: 'some-random-id-value' }; @@ -154,27 +154,27 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveramp.com', - uids: [{ id: 'some-random-id-value', atype: 3 }] + uids: [{ id: 'some-random-id-value',atype: 3 }] }); }); - it('liveIntentId; getValue call and ext', function () { + it('liveIntentId; getValue call and ext',function () { const userId = { lipb: { lipbid: 'some-random-id-value', - segments: ['s1', 's2'] + segments: ['s1','s2'] } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveintent.com', - uids: [{ id: 'some-random-id-value', atype: 3 }], - ext: { segments: ['s1', 's2'] } + uids: [{ id: 'some-random-id-value',atype: 3 }], + ext: { segments: ['s1','s2'] } }); }); - it('bidswitch', function () { + it('bidswitch',function () { const userId = { bidswitch: { 'id': 'sample_id' } }; @@ -189,9 +189,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('bidswitch with ext', function () { + it('bidswitch with ext',function () { const userId = { - bidswitch: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + bidswitch: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -207,7 +207,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('medianet', function () { + it('medianet',function () { const userId = { medianet: { 'id': 'sample_id' } }; @@ -222,9 +222,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('medianet with ext', function () { + it('medianet with ext',function () { const userId = { - medianet: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + medianet: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -240,7 +240,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('magnite', function () { + it('magnite',function () { const userId = { magnite: { 'id': 'sample_id' } }; @@ -255,9 +255,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('magnite with ext', function () { + it('magnite with ext',function () { const userId = { - magnite: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + magnite: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -273,7 +273,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('index', function () { + it('index',function () { const userId = { index: { 'id': 'sample_id' } }; @@ -288,9 +288,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('index with ext', function () { + it('index with ext',function () { const userId = { - index: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + index: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -306,9 +306,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('openx', function () { + it('openx',function () { const userId = { - openx: { 'id': 'sample_id' } + index: { 'id': 'sample_id' } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -321,9 +321,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('openx with ext', function () { + it('openx with ext',function () { const userId = { - index: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + index: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -339,7 +339,8 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('liveIntentId; getValue call and NO ext', function () { + + it('liveIntentId; getValue call and NO ext',function () { const userId = { lipb: { lipbid: 'some-random-id-value' @@ -349,11 +350,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveintent.com', - uids: [{ id: 'some-random-id-value', atype: 3 }] + uids: [{ id: 'some-random-id-value',atype: 3 }] }); }); - it('britepoolId', function () { + it('britepoolId',function () { const userId = { britepoolid: 'some-random-id-value' }; @@ -361,11 +362,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'britepool.com', - uids: [{ id: 'some-random-id-value', atype: 3 }] + uids: [{ id: 'some-random-id-value',atype: 3 }] }); }); - it('lotamePanoramaId', function () { + it('lotamePanoramaId',function () { const userId = { lotamePanoramaId: 'some-random-id-value', }; @@ -373,11 +374,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'crwdcntrl.net', - uids: [{ id: 'some-random-id-value', atype: 1 }], + uids: [{ id: 'some-random-id-value',atype: 1 }], }); }); - it('criteo', function () { + it('criteo',function () { const userId = { criteoId: 'some-random-id-value' }; @@ -385,11 +386,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'criteo.com', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{ id: 'some-random-id-value',atype: 1 }] }); }); - it('tapadId', function () { + it('tapadId',function () { const userId = { tapadId: 'some-random-id-value' }; @@ -397,11 +398,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'tapad.com', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{ id: 'some-random-id-value',atype: 1 }] }); }); - it('deepintentId', function () { + it('deepintentId',function () { const userId = { deepintentId: 'some-random-id-value' }; @@ -409,11 +410,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'deepintent.com', - uids: [{ id: 'some-random-id-value', atype: 3 }] + uids: [{ id: 'some-random-id-value',atype: 3 }] }); }); - it('NetId', function () { + it('NetId',function () { const userId = { netId: 'some-random-id-value' }; @@ -421,11 +422,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'netid.de', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{ id: 'some-random-id-value',atype: 1 }] }); }); - it('zeotapIdPlus', function () { + it('zeotapIdPlus',function () { const userId = { IDP: 'some-random-id-value' }; @@ -440,7 +441,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('hadronId', function () { + it('hadronId',function () { const userId = { hadronId: 'some-random-id-value' }; @@ -455,7 +456,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('quantcastId', function () { + it('quantcastId',function () { const userId = { quantcastId: 'some-random-id-value' }; @@ -470,7 +471,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('uid2', function () { + it('uid2',function () { const userId = { uid2: { 'id': 'Sample_AD_Token' } }; @@ -485,9 +486,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('uid2 with ext', function () { + it('uid2 with ext',function () { const userId = { - uid2: { 'id': 'Sample_AD_Token', 'ext': { 'provider': 'some.provider.com' } } + uid2: { 'id': 'Sample_AD_Token','ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -503,7 +504,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('euid', function () { + it('euid',function () { const userId = { euid: { 'id': 'Sample_AD_Token' } }; @@ -518,7 +519,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('kpuid', function () { + it('kpuid',function () { const userId = { kpuid: 'Sample_Token' }; @@ -533,7 +534,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('tncid', function () { + it('tncid',function () { const userId = { tncid: 'TEST_TNCID' }; @@ -548,7 +549,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('pubProvidedId', function () { + it('pubProvidedId',function () { const userId = { pubProvidedId: [{ source: 'example.com', @@ -558,7 +559,7 @@ describe('eids array generation for known sub-modules', function () { stype: 'ppuid' } }] - }, { + },{ source: 'id-partner.com', uids: [{ id: 'value read from cookie or local storage' @@ -584,7 +585,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('amxId', () => { + it('amxId',() => { const id = 'c4bcadb0-124f-4468-a91a-d3d44cf311c5' const userId = { amxId: id @@ -600,7 +601,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('qid', function () { + it('qid',function () { const userId = { qid: 'some-random-id-value' }; @@ -615,7 +616,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('operaId', function () { + it('operaId',function () { const userId = { operaId: 'some-random-id-value' }; @@ -630,7 +631,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('33acrossId', function () { + it('33acrossId',function () { const userId = { '33acrossId': { envelope: 'some-random-id-value' @@ -647,18 +648,18 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('czechAdId', () => { + it('czechAdId',() => { const id = 'some-random-id-value' const userId = { czechAdId: id }; const [eid] = createEidsArray(userId); expect(eid).to.deep.equal({ source: 'czechadid.cz', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{ id: 'some-random-id-value',atype: 1 }] }); }); - describe('ftrackId', () => { - it('should return the correct EID schema', () => { + describe('ftrackId',() => { + it('should return the correct EID schema',() => { // This is the schema returned from the ftrack decode() method expect(createEidsArray({ ftrackId: { @@ -690,8 +691,8 @@ describe('eids array generation for known sub-modules', function () { }); }); - describe('imuid', function () { - it('should return the correct EID schema with imuid', function () { + describe('imuid',function () { + it('should return the correct EID schema with imuid',function () { const userId = { imuid: 'testimuid' }; @@ -706,7 +707,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('should return the correct EID schema with imppid', function () { + it('should return the correct EID schema with imppid',function () { const userId = { imppid: 'imppid-value-imppid-value-imppid-value' }; @@ -723,8 +724,8 @@ describe('eids array generation for known sub-modules', function () { }); }); -describe('Negative case', function () { - it('eids array generation for UN-known sub-module', function () { +describe('Negative case',function () { + it('eids array generation for UN-known sub-module',function () { // UnknownCommonId const userId = { unknowncid: 'some-random-id-value' @@ -733,7 +734,7 @@ describe('Negative case', function () { expect(newEids.length).to.equal(0); }); - it('eids array generation for known sub-module with non-string value', function () { + it('eids array generation for known sub-module with non-string value',function () { // pubCommonId let userId = { pubcid: undefined diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 8f73e8ff048..31b7c6d6ede 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -1,13 +1,13 @@ import * as utils from 'src/utils.js'; -import { gdprDataHandler, uspDataHandler } from '../../../src/adapterManager.js'; +import { gdprDataHandler,uspDataHandler } from '../../../src/adapterManager.js'; import { server } from 'test/mocks/xhr.js'; -import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } from 'modules/liveIntentIdSystem.js'; +import { liveIntentIdSubmodule,reset as resetLiveIntentIdSubmodule,storage } from 'modules/liveIntentIdSystem.js'; const PUBLISHER_ID = '89899'; const defaultConfigParams = { params: { publisherId: PUBLISHER_ID } }; const responseHeader = { 'Content-Type': 'application/json' }; -describe('LiveIntentMinimalId', function () { +describe('LiveIntentMinimalId',function () { let logErrorStub; let uspConsentDataStub; let gdprConsentDataStub; @@ -17,12 +17,12 @@ describe('LiveIntentMinimalId', function () { beforeEach(function () { liveIntentIdSubmodule.setModuleMode('minimal'); - imgStub = sinon.stub(utils, 'triggerPixel'); - getCookieStub = sinon.stub(storage, 'getCookie'); - getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); - logErrorStub = sinon.stub(utils, 'logError'); - uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData'); - gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); + imgStub = sinon.stub(utils,'triggerPixel'); + getCookieStub = sinon.stub(storage,'getCookie'); + getDataFromLocalStorageStub = sinon.stub(storage,'getDataFromLocalStorage'); + logErrorStub = sinon.stub(utils,'logError'); + uspConsentDataStub = sinon.stub(uspDataHandler,'getConsentData'); + gdprConsentDataStub = sinon.stub(gdprDataHandler,'getConsentData'); }); afterEach(function () { @@ -35,7 +35,7 @@ describe('LiveIntentMinimalId', function () { liveIntentIdSubmodule.setModuleMode('minimal'); resetLiveIntentIdSubmodule(); }); - it('should not fire an event when getId', function () { + it('should not fire an event when getId',function () { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -45,23 +45,23 @@ describe('LiveIntentMinimalId', function () { expect(server.requests[0]).to.eql(undefined) }); - it('should not return a decoded identifier when the unifiedId is not present in the value', function () { + it('should not return a decoded identifier when the unifiedId is not present in the value',function () { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); expect(result).to.be.eql({}); }); - it('should initialize LiveConnect and send no data', function () { + it('should initialize LiveConnect and send no data',function () { liveIntentIdSubmodule.getId(defaultConfigParams); - liveIntentIdSubmodule.decode({}, defaultConfigParams); + liveIntentIdSubmodule.decode({},defaultConfigParams); liveIntentIdSubmodule.getId(defaultConfigParams); - liveIntentIdSubmodule.decode({}, defaultConfigParams); + liveIntentIdSubmodule.decode({},defaultConfigParams); expect(server.requests.length).to.be.eq(0); }); - it('should call the Custom URL of the LiveIntent Identity Exchange endpoint', function () { + it('should call the Custom URL of the LiveIntent Identity Exchange endpoint',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, ...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params,...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); @@ -73,10 +73,10 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the Identity Exchange endpoint with the privided distributorId', function () { + it('should call the Identity Exchange endpoint with the privided distributorId',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1,distributorId: 'did-1111' } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://idx.liadm.com/idex/did-1111/any?did=did-1111&resolve=nonId'); @@ -87,10 +87,10 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function () { + it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1,distributorId: 'did-1111',liCollectConfig: { appId: 'a-0001' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/any?resolve=nonId'); @@ -101,7 +101,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () { + it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ @@ -124,7 +124,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function () { + it('should call the LiveIntent Identity Exchange endpoint, with no additional query params',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -139,7 +139,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors', function () { + it('should log an error and continue to callback if ajax request errors',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -155,7 +155,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function () { + it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint',function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie); let callBackSpy = sinon.spy(); @@ -171,7 +171,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier and additional Identifiers to resolve', function () { + it('should include the LiveConnect identifier and additional Identifiers to resolve',function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie); getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc'); @@ -196,7 +196,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include an additional identifier value to resolve even if it is an object', function () { + it('should include an additional identifier value to resolve even if it is an object',function () { getCookieStub.returns(null); getDataFromLocalStorageStub.withArgs('_thirdPC').returns({ 'key': 'value' }); const configParams = { @@ -220,22 +220,22 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a unifiedId to lipbId and remove it', function () { + it('should decode a unifiedId to lipbId and remove it',function () { const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); expect(result).to.eql({ 'lipb': { 'lipbid': 'data' } }); }); - it('should decode a nonId to lipbId', function () { + it('should decode a nonId to lipbId',function () { const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'data', 'nonId': 'data' } }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'data','nonId': 'data' } }); }); - it('should resolve extra attributes', function () { + it('should resolve extra attributes',function () { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } + ...{ requestedAttributesOverrides: { 'foo': true,'bar': false } } } }).callback; submoduleCallback(callBackSpy); @@ -249,47 +249,47 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a uid2 to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar' }, 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode a uid2 to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',uid2: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','uid2': 'bar' },'uid2': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode values with uid2 but no nonId', function () { + it('should decode values with uid2 but no nonId',function () { const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); - expect(result).to.eql({ 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({ 'uid2': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a bidswitch id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar' }, 'bidswitch': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode a bidswitch id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',bidswitch: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','bidswitch': 'bar' },'bidswitch': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a medianet id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar' }, 'medianet': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode a medianet id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',medianet: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','medianet': 'bar' },'medianet': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a magnite id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'magnite': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode a magnite id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',magnite: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','magnite': 'bar' },'magnite': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an index id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'index': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode an index id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',index: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','index': 'bar' },'index': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an openx id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); - }) + it('should decode an openx id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',openx: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','openx': 'bar' },'openx': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + }); - it('should allow disabling nonId resolution', function () { + it('should allow disabling nonId resolution',function () { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } + ...{ requestedAttributesOverrides: { 'nonId': false,'uid2': true } } } }).callback; submoduleCallback(callBackSpy); diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index e7314f687a7..0ad05a771c8 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -1,14 +1,14 @@ -import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } from 'modules/liveIntentIdSystem.js'; +import { liveIntentIdSubmodule,reset as resetLiveIntentIdSubmodule,storage } from 'modules/liveIntentIdSystem.js'; import * as utils from 'src/utils.js'; -import { gdprDataHandler, uspDataHandler } from '../../../src/adapterManager.js'; +import { gdprDataHandler,uspDataHandler } from '../../../src/adapterManager.js'; import { server } from 'test/mocks/xhr.js'; resetLiveIntentIdSubmodule(); liveIntentIdSubmodule.setModuleMode('standard') const PUBLISHER_ID = '89899'; -const defaultConfigParams = { params: { publisherId: PUBLISHER_ID, fireEventDelay: 1 } }; +const defaultConfigParams = { params: { publisherId: PUBLISHER_ID,fireEventDelay: 1 } }; const responseHeader = { 'Content-Type': 'application/json' } -describe('LiveIntentId', function () { +describe('LiveIntentId',function () { let logErrorStub; let uspConsentDataStub; let gdprConsentDataStub; @@ -18,12 +18,12 @@ describe('LiveIntentId', function () { beforeEach(function () { liveIntentIdSubmodule.setModuleMode('standard'); - imgStub = sinon.stub(utils, 'triggerPixel'); - getCookieStub = sinon.stub(storage, 'getCookie'); - getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); - logErrorStub = sinon.stub(utils, 'logError'); - uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData'); - gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); + imgStub = sinon.stub(utils,'triggerPixel'); + getCookieStub = sinon.stub(storage,'getCookie'); + getDataFromLocalStorageStub = sinon.stub(storage,'getDataFromLocalStorage'); + logErrorStub = sinon.stub(utils,'logError'); + uspConsentDataStub = sinon.stub(uspDataHandler,'getConsentData'); + gdprConsentDataStub = sinon.stub(gdprDataHandler,'getConsentData'); }); afterEach(function () { @@ -36,7 +36,7 @@ describe('LiveIntentId', function () { resetLiveIntentIdSubmodule(); }); - it('should initialize LiveConnect with a privacy string when getId, and include it in the resolution request', function () { + it('should initialize LiveConnect with a privacy string when getId, and include it in the resolution request',function () { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -49,7 +49,7 @@ describe('LiveIntentId', function () { expect(request.url).to.match(/.*us_privacy=1YNY.*&gdpr=1&n3pc=1&gdpr_consent=consentDataString.*/); const response = { unifiedId: 'a_unified_id', - segments: [123, 234] + segments: [123,234] } request.respond( 200, @@ -59,7 +59,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnceWith(response)).to.be.true; }); - it('should fire an event when getId', function (done) { + it('should fire an event when getId',function (done) { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -69,10 +69,10 @@ describe('LiveIntentId', function () { setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*&us_privacy=1YNY.*&wpn=prebid.*&gdpr=1&n3pc=1&n3pct=1&nb=1&gdpr_consent=consentDataString.*/); done(); - }, 200); + },200); }); - it('should fire an event when getId and a hash is provided', function (done) { + it('should fire an event when getId and a hash is provided',function (done) { liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams, @@ -82,11 +82,11 @@ describe('LiveIntentId', function () { setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*e=58131bc547fb87af94cebdaf3102321f.+/) done(); - }, 200); + },200); }); - it('should initialize LiveConnect with the config params when decode and emit an event', function (done) { - liveIntentIdSubmodule.decode({}, { + it('should initialize LiveConnect with the config params when decode and emit an event',function (done) { + liveIntentIdSubmodule.decode({},{ params: { ...defaultConfigParams.params, ...{ @@ -101,41 +101,41 @@ describe('LiveIntentId', function () { setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/collector.liveintent.com\/j\?.*aid=a-0001.*&wpn=prebid.*/); done(); - }, 200); + },200); }); - it('should fire an event with the provided distributorId', function (done) { - liveIntentIdSubmodule.decode({}, { params: { fireEventDelay: 1, distributorId: 'did-1111' } }); + it('should fire an event with the provided distributorId',function (done) { + liveIntentIdSubmodule.decode({},{ params: { fireEventDelay: 1,distributorId: 'did-1111' } }); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*did=did-1111.*&wpn=prebid.*/); done(); - }, 200); + },200); }); - it('should fire an event without the provided distributorId when appId is provided', function (done) { - liveIntentIdSubmodule.decode({}, { params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }); + it('should fire an event without the provided distributorId when appId is provided',function (done) { + liveIntentIdSubmodule.decode({},{ params: { fireEventDelay: 1,distributorId: 'did-1111',liCollectConfig: { appId: 'a-0001' } } }); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*aid=a-0001.*&wpn=prebid.*/); expect(server.requests[0].url).to.not.match(/.*did=*/); done(); - }, 200); + },200); }); - it('should initialize LiveConnect and emit an event with a privacy string when decode', function (done) { + it('should initialize LiveConnect and emit an event with a privacy string when decode',function (done) { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: false, consentString: 'consentDataString' }) - liveIntentIdSubmodule.decode({}, defaultConfigParams); + liveIntentIdSubmodule.decode({},defaultConfigParams); setTimeout(() => { expect(server.requests[0].url).to.match(/.*us_privacy=1YNY.*&gdpr=0&gdpr_consent=consentDataString.*/); done(); - }, 200); + },200); }); - it('should fire an event when decode and a hash is provided', function (done) { - liveIntentIdSubmodule.decode({}, { + it('should fire an event when decode and a hash is provided',function (done) { + liveIntentIdSubmodule.decode({},{ params: { ...defaultConfigParams.params, emailHash: '58131bc547fb87af94cebdaf3102321f' @@ -144,37 +144,37 @@ describe('LiveIntentId', function () { setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*e=58131bc547fb87af94cebdaf3102321f.+/); done(); - }, 200); + },200); }); - it('should not return a decoded identifier when the unifiedId is not present in the value', function () { + it('should not return a decoded identifier when the unifiedId is not present in the value',function () { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); expect(result).to.be.eql({}); }); - it('should fire an event when decode', function (done) { - liveIntentIdSubmodule.decode({}, defaultConfigParams); + it('should fire an event when decode',function (done) { + liveIntentIdSubmodule.decode({},defaultConfigParams); setTimeout(() => { expect(server.requests[0].url).to.be.not.null done(); - }, 200); + },200); }); - it('should initialize LiveConnect and send data only once', function (done) { + it('should initialize LiveConnect and send data only once',function (done) { liveIntentIdSubmodule.getId(defaultConfigParams); - liveIntentIdSubmodule.decode({}, defaultConfigParams); + liveIntentIdSubmodule.decode({},defaultConfigParams); liveIntentIdSubmodule.getId(defaultConfigParams); - liveIntentIdSubmodule.decode({}, defaultConfigParams); + liveIntentIdSubmodule.decode({},defaultConfigParams); setTimeout(() => { expect(server.requests.length).to.be.eq(1); done(); - }, 200); + },200); }); - it('should call the custom URL of the LiveIntent Identity Exchange endpoint', function () { + it('should call the custom URL of the LiveIntent Identity Exchange endpoint',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, ...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params,...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); @@ -185,10 +185,10 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint with the privided distributorId', function () { + it('should call the Identity Exchange endpoint with the privided distributorId',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1,distributorId: 'did-1111' } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://idx.liadm.com/idex/did-1111/any?did=did-1111&resolve=nonId'); @@ -199,10 +199,10 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function () { + it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1,distributorId: 'did-1111',liCollectConfig: { appId: 'a-0001' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/any?resolve=nonId'); @@ -213,7 +213,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () { + it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ @@ -236,7 +236,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function () { + it('should call the LiveIntent Identity Exchange endpoint, with no additional query params',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -251,7 +251,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors', function () { + it('should log an error and continue to callback if ajax request errors',function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -267,7 +267,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function () { + it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint',function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getCookieStub.withArgs('_lc2_fpi').returns(oldCookie) let callBackSpy = sinon.spy(); @@ -283,7 +283,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier and additional Identifiers to resolve', function () { + it('should include the LiveConnect identifier and additional Identifiers to resolve',function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getCookieStub.withArgs('_lc2_fpi').returns(oldCookie); getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc'); @@ -308,7 +308,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include an additional identifier value to resolve even if it is an object', function () { + it('should include an additional identifier value to resolve even if it is an object',function () { getCookieStub.returns(null); getDataFromLocalStorageStub.withArgs('_thirdPC').returns({ 'key': 'value' }); const configParams = { @@ -332,28 +332,28 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should send an error when the cookie jar throws an unexpected error', function () { - getCookieStub.throws('CookieError', 'A message'); + it('should send an error when the cookie jar throws an unexpected error',function () { + getCookieStub.throws('CookieError','A message'); liveIntentIdSubmodule.getId(defaultConfigParams); expect(imgStub.getCall(0).args[0]).to.match(/.*ae=.+/); }); - it('should decode a unifiedId to lipbId and remove it', function () { + it('should decode a unifiedId to lipbId and remove it',function () { const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); expect(result).to.eql({ 'lipb': { 'lipbid': 'data' } }); }); - it('should decode a nonId to lipbId', function () { + it('should decode a nonId to lipbId',function () { const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'data', 'nonId': 'data' } }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'data','nonId': 'data' } }); }); - it('should resolve extra attributes', function () { + it('should resolve extra attributes',function () { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } + ...{ requestedAttributesOverrides: { 'foo': true,'bar': false } } } }).callback; submoduleCallback(callBackSpy); @@ -367,47 +367,47 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a uid2 to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar' }, 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode a uid2 to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',uid2: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','uid2': 'bar' },'uid2': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode values with uid2 but no nonId', function () { + it('should decode values with uid2 but no nonId',function () { const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); - expect(result).to.eql({ 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({ 'uid2': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a bidswitch id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar' }, 'bidswitch': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode a bidswitch id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',bidswitch: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','bidswitch': 'bar' },'bidswitch': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a medianet id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar' }, 'medianet': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode a medianet id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',medianet: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','medianet': 'bar' },'medianet': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a magnite id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'magnite': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode a magnite id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',magnite: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','magnite': 'bar' },'magnite': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an index id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'index': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode an index id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',index: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','index': 'bar' },'index': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an openx id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + it('should decode an openx id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',openx: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','openx': 'bar' },'openx': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); }); - it('should allow disabling nonId resolution', function () { + it('should allow disabling nonId resolution',function () { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } + ...{ requestedAttributesOverrides: { 'nonId': false,'uid2': true } } } }).callback; submoduleCallback(callBackSpy); From da96e63d43952a64fa5a2ca1942b8a9c0703e774 Mon Sep 17 00:00:00 2001 From: Peixun Zhang Date: Fri, 22 Sep 2023 13:13:52 +0200 Subject: [PATCH 4/8] Revert "new changes" This reverts commit 87b3400a177963bbc96372b41b2a1ef2df9d4147. --- modules/liveIntentIdSystem.js | 44 ++--- test/spec/modules/eids_spec.js | 157 +++++++++-------- .../modules/liveIntentIdMinimalSystem_spec.js | 108 ++++++------ test/spec/modules/liveIntentIdSystem_spec.js | 160 +++++++++--------- 4 files changed, 236 insertions(+), 233 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 846bb149882..feed0b126a0 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -4,21 +4,21 @@ * @module modules/liveIntentIdSystem * @requires module:modules/userId */ -import { triggerPixel,logError } from '../src/utils.js'; +import { triggerPixel, logError } from '../src/utils.js'; import { ajaxBuilder } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/validate-imports -import { gdprDataHandler,uspDataHandler } from '../src/adapterManager.js'; +import { gdprDataHandler, uspDataHandler } from '../src/adapterManager.js'; import { getStorageManager } from '../src/storageManager.js'; import { MODULE_TYPE_UID } from '../src/activities/modules.js'; const EVENTS_TOPIC = 'pre_lips' const MODULE_NAME = 'liveIntentId'; const LI_PROVIDER_DOMAIN = 'liveintent.com'; -export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID,moduleName: MODULE_NAME }); +export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME }); const defaultRequestedAttributes = { 'nonId': true } const calls = { - ajaxGet: (url,onSuccess,onError,timeout) => { + ajaxGet: (url, onSuccess, onError, timeout) => { ajaxBuilder(timeout)( url, { @@ -32,7 +32,7 @@ const calls = { } ) }, - pixelGet: (url,onload) => triggerPixel(url,onload) + pixelGet: (url, onload) => triggerPixel(url, onload) } let eventFired = false; @@ -43,7 +43,7 @@ let liveConnect = null; */ export function reset() { if (window && window.liQ_instances) { - window.liQ_instances.forEach(i => i.eventBus.off(EVENTS_TOPIC,setEventFiredFlag)) + window.liQ_instances.forEach(i => i.eventBus.off(EVENTS_TOPIC, setEventFiredFlag)) window.liQ_instances = []; } liveIntentIdSubmodule.setModuleMode(null) @@ -76,10 +76,10 @@ function parseLiveIntentCollectorConfig(collectConfig) { */ function parseRequestedAttributes(overrides) { function createParameterArray(config) { - return Object.entries(config).flatMap(([k,v]) => (typeof v === 'boolean' && v) ? [k] : []); + return Object.entries(config).flatMap(([k, v]) => (typeof v === 'boolean' && v) ? [k] : []); } if (typeof overrides === 'object') { - return createParameterArray({ ...defaultRequestedAttributes,...overrides }) + return createParameterArray({ ...defaultRequestedAttributes, ...overrides }) } else { return createParameterArray(defaultRequestedAttributes); } @@ -128,7 +128,7 @@ function initializeLiveConnect(configParams) { // The second param is the storage object, LS & Cookie manipulation uses PBJS // The third param is the ajax and pixel object, the ajax and pixel use PBJS - liveConnect = liveIntentIdSubmodule.getInitializer()(liveConnectConfig,storage,calls); + liveConnect = liveIntentIdSubmodule.getInitializer()(liveConnectConfig, storage, calls); if (configParams.emailHash) { liveConnect.push({ hash: configParams.emailHash }) } @@ -140,11 +140,11 @@ function tryFireEvent() { const eventDelay = liveConnect.config.fireEventDelay || 500 setTimeout(() => { const instances = window.liQ_instances - instances.forEach(i => i.eventBus.once(EVENTS_TOPIC,setEventFiredFlag)) + instances.forEach(i => i.eventBus.once(EVENTS_TOPIC, setEventFiredFlag)) if (!eventFired && liveConnect) { liveConnect.fire(); } - },eventDelay) + }, eventDelay) } } @@ -161,7 +161,7 @@ export const liveIntentIdSubmodule = { this.moduleMode = mode }, getInitializer() { - return (liveConnectConfig,storage,calls) => LiveConnect(liveConnectConfig,storage,calls,this.moduleMode) + return (liveConnectConfig, storage, calls) => LiveConnect(liveConnectConfig, storage, calls, this.moduleMode) }, /** @@ -173,7 +173,7 @@ export const liveIntentIdSubmodule = { * @param {SubmoduleConfig|undefined} config * @returns {{lipb:Object}} */ - decode(value,config) { + decode(value, config) { const configParams = (config && config.params) || {}; function composeIdObject(value) { const result = {}; @@ -190,23 +190,27 @@ export const liveIntentIdSubmodule = { // As adapters are applied in lexicographical order, we will always // be overwritten by the 'proper' uid2 module if it is present. if (value.uid2) { - result.uid2 = { 'id': value.uid2,ext: { provider: LI_PROVIDER_DOMAIN } } + result.uid2 = { 'id': value.uid2, ext: { provider: LI_PROVIDER_DOMAIN } } } if (value.bidswitch) { - result.bidswitch = { 'id': value.bidswitch,ext: { provider: LI_PROVIDER_DOMAIN } } + result.bidswitch = { 'id': value.bidswitch, ext: { provider: LI_PROVIDER_DOMAIN } } } if (value.medianet) { - result.medianet = { 'id': value.medianet,ext: { provider: LI_PROVIDER_DOMAIN } } + result.medianet = { 'id': value.medianet, ext: { provider: LI_PROVIDER_DOMAIN } } } if (value.magnite) { - result.magnite = { 'id': value.magnite,ext: { provider: LI_PROVIDER_DOMAIN } } + result.magnite = { 'id': value.magnite, ext: { provider: LI_PROVIDER_DOMAIN } } } if (value.index) { - result.index = { 'id': value.index,ext: { provider: LI_PROVIDER_DOMAIN } } + result.index = { 'id': value.index, ext: { provider: LI_PROVIDER_DOMAIN } } + } + + if (value.openx) { + result.openx = { 'id': value.openx, ext: { provider: LI_PROVIDER_DOMAIN } } } return result @@ -239,7 +243,7 @@ export const liveIntentIdSubmodule = { callback(response); }, error => { - logError(`${MODULE_NAME}: ID fetch encountered an error: `,error); + logError(`${MODULE_NAME}: ID fetch encountered an error: `, error); callback(); } ) @@ -325,4 +329,4 @@ export const liveIntentIdSubmodule = { } }; -submodule('userId',liveIntentIdSubmodule); +submodule('userId', liveIntentIdSubmodule); diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index a4acfa8fc6d..2af0ba6ea23 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -1,11 +1,11 @@ import { createEidsArray } from 'modules/userId/eids.js'; import { expect } from 'chai'; -// Note: In unit tets cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids +// Note: In unit test cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids // this way the request will stay consistent and unit test cases will not need lots of changes. -describe('eids array generation for known sub-modules',function () { - it('pubCommonId',function () { +describe('eids array generation for known sub-modules', function () { + it('pubCommonId', function () { const userId = { pubcid: 'some-random-id-value' }; @@ -13,11 +13,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'pubcid.org', - uids: [{ id: 'some-random-id-value',atype: 1 }] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('unifiedId: ext generation',function () { + it('unifiedId: ext generation', function () { const userId = { tdid: 'some-random-id-value' }; @@ -25,12 +25,12 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'adserver.org', - uids: [{ id: 'some-random-id-value',atype: 1,ext: { rtiPartner: 'TDID' } }] + uids: [{ id: 'some-random-id-value', atype: 1, ext: { rtiPartner: 'TDID' } }] }); }); - describe('id5Id',function () { - it('does not include an ext if not provided',function () { + describe('id5Id', function () { + it('does not include an ext if not provided', function () { const userId = { id5id: { uid: 'some-random-id-value' @@ -40,11 +40,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'id5-sync.com', - uids: [{ id: 'some-random-id-value',atype: 1 }] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('includes ext if provided',function () { + it('includes ext if provided', function () { const userId = { id5id: { uid: 'some-random-id-value', @@ -68,7 +68,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('parrableId',function () { + it('parrableId', function () { const userId = { parrableId: { eid: 'some-random-id-value' @@ -78,14 +78,14 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'parrable.com', - uids: [{ id: 'some-random-id-value',atype: 1 }] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('merkleId (legacy) - supports single id',function () { + it('merkleId (legacy) - supports single id', function () { const userId = { merkleId: { - id: 'some-random-id-value',keyID: 1 + id: 'some-random-id-value', keyID: 1 } }; const newEids = createEidsArray(userId); @@ -101,11 +101,11 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('merkleId supports multiple source providers',function () { + it('merkleId supports multiple source providers', function () { const userId = { merkleId: [{ - id: 'some-random-id-value',ext: { enc: 1,keyID: 16,idName: 'pamId',ssp: 'ssp1' } - },{ + id: 'some-random-id-value', ext: { enc: 1, keyID: 16, idName: 'pamId', ssp: 'ssp1' } + }, { id: 'another-random-id-value', ext: { enc: 1, @@ -146,7 +146,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('identityLink',function () { + it('identityLink', function () { const userId = { idl_env: 'some-random-id-value' }; @@ -154,27 +154,27 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveramp.com', - uids: [{ id: 'some-random-id-value',atype: 3 }] + uids: [{ id: 'some-random-id-value', atype: 3 }] }); }); - it('liveIntentId; getValue call and ext',function () { + it('liveIntentId; getValue call and ext', function () { const userId = { lipb: { lipbid: 'some-random-id-value', - segments: ['s1','s2'] + segments: ['s1', 's2'] } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveintent.com', - uids: [{ id: 'some-random-id-value',atype: 3 }], - ext: { segments: ['s1','s2'] } + uids: [{ id: 'some-random-id-value', atype: 3 }], + ext: { segments: ['s1', 's2'] } }); }); - it('bidswitch',function () { + it('bidswitch', function () { const userId = { bidswitch: { 'id': 'sample_id' } }; @@ -189,9 +189,9 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('bidswitch with ext',function () { + it('bidswitch with ext', function () { const userId = { - bidswitch: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } + bidswitch: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -207,7 +207,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('medianet',function () { + it('medianet', function () { const userId = { medianet: { 'id': 'sample_id' } }; @@ -222,9 +222,9 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('medianet with ext',function () { + it('medianet with ext', function () { const userId = { - medianet: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } + medianet: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -240,7 +240,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('magnite',function () { + it('magnite', function () { const userId = { magnite: { 'id': 'sample_id' } }; @@ -255,9 +255,9 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('magnite with ext',function () { + it('magnite with ext', function () { const userId = { - magnite: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } + magnite: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -273,7 +273,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('index',function () { + it('index', function () { const userId = { index: { 'id': 'sample_id' } }; @@ -288,9 +288,9 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('index with ext',function () { + it('index with ext', function () { const userId = { - index: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } + index: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -306,9 +306,9 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('openx',function () { + it('openx', function () { const userId = { - index: { 'id': 'sample_id' } + openx: { 'id': 'sample_id' } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -321,9 +321,9 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('openx with ext',function () { + it('openx with ext', function () { const userId = { - index: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } + index: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -339,8 +339,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - - it('liveIntentId; getValue call and NO ext',function () { + it('liveIntentId; getValue call and NO ext', function () { const userId = { lipb: { lipbid: 'some-random-id-value' @@ -350,11 +349,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveintent.com', - uids: [{ id: 'some-random-id-value',atype: 3 }] + uids: [{ id: 'some-random-id-value', atype: 3 }] }); }); - it('britepoolId',function () { + it('britepoolId', function () { const userId = { britepoolid: 'some-random-id-value' }; @@ -362,11 +361,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'britepool.com', - uids: [{ id: 'some-random-id-value',atype: 3 }] + uids: [{ id: 'some-random-id-value', atype: 3 }] }); }); - it('lotamePanoramaId',function () { + it('lotamePanoramaId', function () { const userId = { lotamePanoramaId: 'some-random-id-value', }; @@ -374,11 +373,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'crwdcntrl.net', - uids: [{ id: 'some-random-id-value',atype: 1 }], + uids: [{ id: 'some-random-id-value', atype: 1 }], }); }); - it('criteo',function () { + it('criteo', function () { const userId = { criteoId: 'some-random-id-value' }; @@ -386,11 +385,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'criteo.com', - uids: [{ id: 'some-random-id-value',atype: 1 }] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('tapadId',function () { + it('tapadId', function () { const userId = { tapadId: 'some-random-id-value' }; @@ -398,11 +397,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'tapad.com', - uids: [{ id: 'some-random-id-value',atype: 1 }] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('deepintentId',function () { + it('deepintentId', function () { const userId = { deepintentId: 'some-random-id-value' }; @@ -410,11 +409,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'deepintent.com', - uids: [{ id: 'some-random-id-value',atype: 3 }] + uids: [{ id: 'some-random-id-value', atype: 3 }] }); }); - it('NetId',function () { + it('NetId', function () { const userId = { netId: 'some-random-id-value' }; @@ -422,11 +421,11 @@ describe('eids array generation for known sub-modules',function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'netid.de', - uids: [{ id: 'some-random-id-value',atype: 1 }] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - it('zeotapIdPlus',function () { + it('zeotapIdPlus', function () { const userId = { IDP: 'some-random-id-value' }; @@ -441,7 +440,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('hadronId',function () { + it('hadronId', function () { const userId = { hadronId: 'some-random-id-value' }; @@ -456,7 +455,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('quantcastId',function () { + it('quantcastId', function () { const userId = { quantcastId: 'some-random-id-value' }; @@ -471,7 +470,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('uid2',function () { + it('uid2', function () { const userId = { uid2: { 'id': 'Sample_AD_Token' } }; @@ -486,9 +485,9 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('uid2 with ext',function () { + it('uid2 with ext', function () { const userId = { - uid2: { 'id': 'Sample_AD_Token','ext': { 'provider': 'some.provider.com' } } + uid2: { 'id': 'Sample_AD_Token', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -504,7 +503,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('euid',function () { + it('euid', function () { const userId = { euid: { 'id': 'Sample_AD_Token' } }; @@ -519,7 +518,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('kpuid',function () { + it('kpuid', function () { const userId = { kpuid: 'Sample_Token' }; @@ -534,7 +533,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('tncid',function () { + it('tncid', function () { const userId = { tncid: 'TEST_TNCID' }; @@ -549,7 +548,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('pubProvidedId',function () { + it('pubProvidedId', function () { const userId = { pubProvidedId: [{ source: 'example.com', @@ -559,7 +558,7 @@ describe('eids array generation for known sub-modules',function () { stype: 'ppuid' } }] - },{ + }, { source: 'id-partner.com', uids: [{ id: 'value read from cookie or local storage' @@ -585,7 +584,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('amxId',() => { + it('amxId', () => { const id = 'c4bcadb0-124f-4468-a91a-d3d44cf311c5' const userId = { amxId: id @@ -601,7 +600,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('qid',function () { + it('qid', function () { const userId = { qid: 'some-random-id-value' }; @@ -616,7 +615,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('operaId',function () { + it('operaId', function () { const userId = { operaId: 'some-random-id-value' }; @@ -631,7 +630,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('33acrossId',function () { + it('33acrossId', function () { const userId = { '33acrossId': { envelope: 'some-random-id-value' @@ -648,18 +647,18 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('czechAdId',() => { + it('czechAdId', () => { const id = 'some-random-id-value' const userId = { czechAdId: id }; const [eid] = createEidsArray(userId); expect(eid).to.deep.equal({ source: 'czechadid.cz', - uids: [{ id: 'some-random-id-value',atype: 1 }] + uids: [{ id: 'some-random-id-value', atype: 1 }] }); }); - describe('ftrackId',() => { - it('should return the correct EID schema',() => { + describe('ftrackId', () => { + it('should return the correct EID schema', () => { // This is the schema returned from the ftrack decode() method expect(createEidsArray({ ftrackId: { @@ -691,8 +690,8 @@ describe('eids array generation for known sub-modules',function () { }); }); - describe('imuid',function () { - it('should return the correct EID schema with imuid',function () { + describe('imuid', function () { + it('should return the correct EID schema with imuid', function () { const userId = { imuid: 'testimuid' }; @@ -707,7 +706,7 @@ describe('eids array generation for known sub-modules',function () { }); }); - it('should return the correct EID schema with imppid',function () { + it('should return the correct EID schema with imppid', function () { const userId = { imppid: 'imppid-value-imppid-value-imppid-value' }; @@ -724,8 +723,8 @@ describe('eids array generation for known sub-modules',function () { }); }); -describe('Negative case',function () { - it('eids array generation for UN-known sub-module',function () { +describe('Negative case', function () { + it('eids array generation for UN-known sub-module', function () { // UnknownCommonId const userId = { unknowncid: 'some-random-id-value' @@ -734,7 +733,7 @@ describe('Negative case',function () { expect(newEids.length).to.equal(0); }); - it('eids array generation for known sub-module with non-string value',function () { + it('eids array generation for known sub-module with non-string value', function () { // pubCommonId let userId = { pubcid: undefined diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 31b7c6d6ede..8f73e8ff048 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -1,13 +1,13 @@ import * as utils from 'src/utils.js'; -import { gdprDataHandler,uspDataHandler } from '../../../src/adapterManager.js'; +import { gdprDataHandler, uspDataHandler } from '../../../src/adapterManager.js'; import { server } from 'test/mocks/xhr.js'; -import { liveIntentIdSubmodule,reset as resetLiveIntentIdSubmodule,storage } from 'modules/liveIntentIdSystem.js'; +import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } from 'modules/liveIntentIdSystem.js'; const PUBLISHER_ID = '89899'; const defaultConfigParams = { params: { publisherId: PUBLISHER_ID } }; const responseHeader = { 'Content-Type': 'application/json' }; -describe('LiveIntentMinimalId',function () { +describe('LiveIntentMinimalId', function () { let logErrorStub; let uspConsentDataStub; let gdprConsentDataStub; @@ -17,12 +17,12 @@ describe('LiveIntentMinimalId',function () { beforeEach(function () { liveIntentIdSubmodule.setModuleMode('minimal'); - imgStub = sinon.stub(utils,'triggerPixel'); - getCookieStub = sinon.stub(storage,'getCookie'); - getDataFromLocalStorageStub = sinon.stub(storage,'getDataFromLocalStorage'); - logErrorStub = sinon.stub(utils,'logError'); - uspConsentDataStub = sinon.stub(uspDataHandler,'getConsentData'); - gdprConsentDataStub = sinon.stub(gdprDataHandler,'getConsentData'); + imgStub = sinon.stub(utils, 'triggerPixel'); + getCookieStub = sinon.stub(storage, 'getCookie'); + getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + logErrorStub = sinon.stub(utils, 'logError'); + uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData'); + gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); }); afterEach(function () { @@ -35,7 +35,7 @@ describe('LiveIntentMinimalId',function () { liveIntentIdSubmodule.setModuleMode('minimal'); resetLiveIntentIdSubmodule(); }); - it('should not fire an event when getId',function () { + it('should not fire an event when getId', function () { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -45,23 +45,23 @@ describe('LiveIntentMinimalId',function () { expect(server.requests[0]).to.eql(undefined) }); - it('should not return a decoded identifier when the unifiedId is not present in the value',function () { + it('should not return a decoded identifier when the unifiedId is not present in the value', function () { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); expect(result).to.be.eql({}); }); - it('should initialize LiveConnect and send no data',function () { + it('should initialize LiveConnect and send no data', function () { liveIntentIdSubmodule.getId(defaultConfigParams); - liveIntentIdSubmodule.decode({},defaultConfigParams); + liveIntentIdSubmodule.decode({}, defaultConfigParams); liveIntentIdSubmodule.getId(defaultConfigParams); - liveIntentIdSubmodule.decode({},defaultConfigParams); + liveIntentIdSubmodule.decode({}, defaultConfigParams); expect(server.requests.length).to.be.eq(0); }); - it('should call the Custom URL of the LiveIntent Identity Exchange endpoint',function () { + it('should call the Custom URL of the LiveIntent Identity Exchange endpoint', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params,...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, ...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); @@ -73,10 +73,10 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the Identity Exchange endpoint with the privided distributorId',function () { + it('should call the Identity Exchange endpoint with the privided distributorId', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1,distributorId: 'did-1111' } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://idx.liadm.com/idex/did-1111/any?did=did-1111&resolve=nonId'); @@ -87,10 +87,10 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided',function () { + it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1,distributorId: 'did-1111',liCollectConfig: { appId: 'a-0001' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/any?resolve=nonId'); @@ -101,7 +101,7 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner',function () { + it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ @@ -124,7 +124,7 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the LiveIntent Identity Exchange endpoint, with no additional query params',function () { + it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -139,7 +139,7 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors',function () { + it('should log an error and continue to callback if ajax request errors', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -155,7 +155,7 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint',function () { + it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie); let callBackSpy = sinon.spy(); @@ -171,7 +171,7 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier and additional Identifiers to resolve',function () { + it('should include the LiveConnect identifier and additional Identifiers to resolve', function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie); getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc'); @@ -196,7 +196,7 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include an additional identifier value to resolve even if it is an object',function () { + it('should include an additional identifier value to resolve even if it is an object', function () { getCookieStub.returns(null); getDataFromLocalStorageStub.withArgs('_thirdPC').returns({ 'key': 'value' }); const configParams = { @@ -220,22 +220,22 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a unifiedId to lipbId and remove it',function () { + it('should decode a unifiedId to lipbId and remove it', function () { const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); expect(result).to.eql({ 'lipb': { 'lipbid': 'data' } }); }); - it('should decode a nonId to lipbId',function () { + it('should decode a nonId to lipbId', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'data','nonId': 'data' } }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'data', 'nonId': 'data' } }); }); - it('should resolve extra attributes',function () { + it('should resolve extra attributes', function () { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'foo': true,'bar': false } } + ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } } }).callback; submoduleCallback(callBackSpy); @@ -249,47 +249,47 @@ describe('LiveIntentMinimalId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a uid2 to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',uid2: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','uid2': 'bar' },'uid2': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode a uid2 to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar' }, 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode values with uid2 but no nonId',function () { + it('should decode values with uid2 but no nonId', function () { const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); - expect(result).to.eql({ 'uid2': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({ 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a bidswitch id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',bidswitch: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','bidswitch': 'bar' },'bidswitch': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode a bidswitch id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar' }, 'bidswitch': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a medianet id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',medianet: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','medianet': 'bar' },'medianet': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode a medianet id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar' }, 'medianet': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a magnite id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',magnite: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','magnite': 'bar' },'magnite': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode a magnite id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'magnite': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an index id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',index: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','index': 'bar' },'index': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode an index id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'index': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an openx id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',openx: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','openx': 'bar' },'openx': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); - }); + it('should decode an openx id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + }) - it('should allow disabling nonId resolution',function () { + it('should allow disabling nonId resolution', function () { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'nonId': false,'uid2': true } } + ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } } }).callback; submoduleCallback(callBackSpy); diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 0ad05a771c8..e7314f687a7 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -1,14 +1,14 @@ -import { liveIntentIdSubmodule,reset as resetLiveIntentIdSubmodule,storage } from 'modules/liveIntentIdSystem.js'; +import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } from 'modules/liveIntentIdSystem.js'; import * as utils from 'src/utils.js'; -import { gdprDataHandler,uspDataHandler } from '../../../src/adapterManager.js'; +import { gdprDataHandler, uspDataHandler } from '../../../src/adapterManager.js'; import { server } from 'test/mocks/xhr.js'; resetLiveIntentIdSubmodule(); liveIntentIdSubmodule.setModuleMode('standard') const PUBLISHER_ID = '89899'; -const defaultConfigParams = { params: { publisherId: PUBLISHER_ID,fireEventDelay: 1 } }; +const defaultConfigParams = { params: { publisherId: PUBLISHER_ID, fireEventDelay: 1 } }; const responseHeader = { 'Content-Type': 'application/json' } -describe('LiveIntentId',function () { +describe('LiveIntentId', function () { let logErrorStub; let uspConsentDataStub; let gdprConsentDataStub; @@ -18,12 +18,12 @@ describe('LiveIntentId',function () { beforeEach(function () { liveIntentIdSubmodule.setModuleMode('standard'); - imgStub = sinon.stub(utils,'triggerPixel'); - getCookieStub = sinon.stub(storage,'getCookie'); - getDataFromLocalStorageStub = sinon.stub(storage,'getDataFromLocalStorage'); - logErrorStub = sinon.stub(utils,'logError'); - uspConsentDataStub = sinon.stub(uspDataHandler,'getConsentData'); - gdprConsentDataStub = sinon.stub(gdprDataHandler,'getConsentData'); + imgStub = sinon.stub(utils, 'triggerPixel'); + getCookieStub = sinon.stub(storage, 'getCookie'); + getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + logErrorStub = sinon.stub(utils, 'logError'); + uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData'); + gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); }); afterEach(function () { @@ -36,7 +36,7 @@ describe('LiveIntentId',function () { resetLiveIntentIdSubmodule(); }); - it('should initialize LiveConnect with a privacy string when getId, and include it in the resolution request',function () { + it('should initialize LiveConnect with a privacy string when getId, and include it in the resolution request', function () { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -49,7 +49,7 @@ describe('LiveIntentId',function () { expect(request.url).to.match(/.*us_privacy=1YNY.*&gdpr=1&n3pc=1&gdpr_consent=consentDataString.*/); const response = { unifiedId: 'a_unified_id', - segments: [123,234] + segments: [123, 234] } request.respond( 200, @@ -59,7 +59,7 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnceWith(response)).to.be.true; }); - it('should fire an event when getId',function (done) { + it('should fire an event when getId', function (done) { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -69,10 +69,10 @@ describe('LiveIntentId',function () { setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*&us_privacy=1YNY.*&wpn=prebid.*&gdpr=1&n3pc=1&n3pct=1&nb=1&gdpr_consent=consentDataString.*/); done(); - },200); + }, 200); }); - it('should fire an event when getId and a hash is provided',function (done) { + it('should fire an event when getId and a hash is provided', function (done) { liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams, @@ -82,11 +82,11 @@ describe('LiveIntentId',function () { setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*e=58131bc547fb87af94cebdaf3102321f.+/) done(); - },200); + }, 200); }); - it('should initialize LiveConnect with the config params when decode and emit an event',function (done) { - liveIntentIdSubmodule.decode({},{ + it('should initialize LiveConnect with the config params when decode and emit an event', function (done) { + liveIntentIdSubmodule.decode({}, { params: { ...defaultConfigParams.params, ...{ @@ -101,41 +101,41 @@ describe('LiveIntentId',function () { setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/collector.liveintent.com\/j\?.*aid=a-0001.*&wpn=prebid.*/); done(); - },200); + }, 200); }); - it('should fire an event with the provided distributorId',function (done) { - liveIntentIdSubmodule.decode({},{ params: { fireEventDelay: 1,distributorId: 'did-1111' } }); + it('should fire an event with the provided distributorId', function (done) { + liveIntentIdSubmodule.decode({}, { params: { fireEventDelay: 1, distributorId: 'did-1111' } }); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*did=did-1111.*&wpn=prebid.*/); done(); - },200); + }, 200); }); - it('should fire an event without the provided distributorId when appId is provided',function (done) { - liveIntentIdSubmodule.decode({},{ params: { fireEventDelay: 1,distributorId: 'did-1111',liCollectConfig: { appId: 'a-0001' } } }); + it('should fire an event without the provided distributorId when appId is provided', function (done) { + liveIntentIdSubmodule.decode({}, { params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*aid=a-0001.*&wpn=prebid.*/); expect(server.requests[0].url).to.not.match(/.*did=*/); done(); - },200); + }, 200); }); - it('should initialize LiveConnect and emit an event with a privacy string when decode',function (done) { + it('should initialize LiveConnect and emit an event with a privacy string when decode', function (done) { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: false, consentString: 'consentDataString' }) - liveIntentIdSubmodule.decode({},defaultConfigParams); + liveIntentIdSubmodule.decode({}, defaultConfigParams); setTimeout(() => { expect(server.requests[0].url).to.match(/.*us_privacy=1YNY.*&gdpr=0&gdpr_consent=consentDataString.*/); done(); - },200); + }, 200); }); - it('should fire an event when decode and a hash is provided',function (done) { - liveIntentIdSubmodule.decode({},{ + it('should fire an event when decode and a hash is provided', function (done) { + liveIntentIdSubmodule.decode({}, { params: { ...defaultConfigParams.params, emailHash: '58131bc547fb87af94cebdaf3102321f' @@ -144,37 +144,37 @@ describe('LiveIntentId',function () { setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*e=58131bc547fb87af94cebdaf3102321f.+/); done(); - },200); + }, 200); }); - it('should not return a decoded identifier when the unifiedId is not present in the value',function () { + it('should not return a decoded identifier when the unifiedId is not present in the value', function () { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); expect(result).to.be.eql({}); }); - it('should fire an event when decode',function (done) { - liveIntentIdSubmodule.decode({},defaultConfigParams); + it('should fire an event when decode', function (done) { + liveIntentIdSubmodule.decode({}, defaultConfigParams); setTimeout(() => { expect(server.requests[0].url).to.be.not.null done(); - },200); + }, 200); }); - it('should initialize LiveConnect and send data only once',function (done) { + it('should initialize LiveConnect and send data only once', function (done) { liveIntentIdSubmodule.getId(defaultConfigParams); - liveIntentIdSubmodule.decode({},defaultConfigParams); + liveIntentIdSubmodule.decode({}, defaultConfigParams); liveIntentIdSubmodule.getId(defaultConfigParams); - liveIntentIdSubmodule.decode({},defaultConfigParams); + liveIntentIdSubmodule.decode({}, defaultConfigParams); setTimeout(() => { expect(server.requests.length).to.be.eq(1); done(); - },200); + }, 200); }); - it('should call the custom URL of the LiveIntent Identity Exchange endpoint',function () { + it('should call the custom URL of the LiveIntent Identity Exchange endpoint', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params,...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, ...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); @@ -185,10 +185,10 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint with the privided distributorId',function () { + it('should call the Identity Exchange endpoint with the privided distributorId', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1,distributorId: 'did-1111' } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://idx.liadm.com/idex/did-1111/any?did=did-1111&resolve=nonId'); @@ -199,10 +199,10 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided',function () { + it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1,distributorId: 'did-1111',liCollectConfig: { appId: 'a-0001' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/any?resolve=nonId'); @@ -213,7 +213,7 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner',function () { + it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ @@ -236,7 +236,7 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the LiveIntent Identity Exchange endpoint, with no additional query params',function () { + it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -251,7 +251,7 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors',function () { + it('should log an error and continue to callback if ajax request errors', function () { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -267,7 +267,7 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint',function () { + it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getCookieStub.withArgs('_lc2_fpi').returns(oldCookie) let callBackSpy = sinon.spy(); @@ -283,7 +283,7 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier and additional Identifiers to resolve',function () { + it('should include the LiveConnect identifier and additional Identifiers to resolve', function () { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getCookieStub.withArgs('_lc2_fpi').returns(oldCookie); getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc'); @@ -308,7 +308,7 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include an additional identifier value to resolve even if it is an object',function () { + it('should include an additional identifier value to resolve even if it is an object', function () { getCookieStub.returns(null); getDataFromLocalStorageStub.withArgs('_thirdPC').returns({ 'key': 'value' }); const configParams = { @@ -332,28 +332,28 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should send an error when the cookie jar throws an unexpected error',function () { - getCookieStub.throws('CookieError','A message'); + it('should send an error when the cookie jar throws an unexpected error', function () { + getCookieStub.throws('CookieError', 'A message'); liveIntentIdSubmodule.getId(defaultConfigParams); expect(imgStub.getCall(0).args[0]).to.match(/.*ae=.+/); }); - it('should decode a unifiedId to lipbId and remove it',function () { + it('should decode a unifiedId to lipbId and remove it', function () { const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); expect(result).to.eql({ 'lipb': { 'lipbid': 'data' } }); }); - it('should decode a nonId to lipbId',function () { + it('should decode a nonId to lipbId', function () { const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'data','nonId': 'data' } }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'data', 'nonId': 'data' } }); }); - it('should resolve extra attributes',function () { + it('should resolve extra attributes', function () { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'foo': true,'bar': false } } + ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } } }).callback; submoduleCallback(callBackSpy); @@ -367,47 +367,47 @@ describe('LiveIntentId',function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a uid2 to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',uid2: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','uid2': 'bar' },'uid2': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode a uid2 to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar' }, 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode values with uid2 but no nonId',function () { + it('should decode values with uid2 but no nonId', function () { const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); - expect(result).to.eql({ 'uid2': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({ 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a bidswitch id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',bidswitch: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','bidswitch': 'bar' },'bidswitch': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode a bidswitch id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar' }, 'bidswitch': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a medianet id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',medianet: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','medianet': 'bar' },'medianet': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode a medianet id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar' }, 'medianet': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode a magnite id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',magnite: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','magnite': 'bar' },'magnite': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode a magnite id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'magnite': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an index id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',index: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','index': 'bar' },'index': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode an index id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'index': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should decode an openx id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',openx: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','openx': 'bar' },'openx': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode an openx id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); - it('should allow disabling nonId resolution',function () { + it('should allow disabling nonId resolution', function () { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'nonId': false,'uid2': true } } + ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } } }).callback; submoduleCallback(callBackSpy); From 4b819753bcde5f52a03822e2a003a39c48b89902 Mon Sep 17 00:00:00 2001 From: Peixun Zhang Date: Fri, 22 Sep 2023 13:14:51 +0200 Subject: [PATCH 5/8] Revert "fix typo:" This reverts commit 79e34925bdf3603ff88da8a7ede88806c00fb78f. --- modules/liveIntentIdSystem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index feed0b126a0..8cda487e6b1 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -315,7 +315,7 @@ export const liveIntentIdSubmodule = { } }, 'openx': { - source: 'openx.com', + source: 'opex.com', atype: 3, getValue: function (data) { return data.id; From ba0053acb9f6c9096c15dd36a4cb5db80370f721 Mon Sep 17 00:00:00 2001 From: Peixun Zhang Date: Fri, 22 Sep 2023 13:15:25 +0200 Subject: [PATCH 6/8] Revert "Add support for openx cookies" This reverts commit 65f29a3851d66f5b9d3fcceaeed427cfcf9b6f91. --- modules/liveIntentIdSystem.js | 48 ++--- package-lock.json | 18 +- test/spec/modules/eids_spec.js | 175 +++++++---------- .../modules/liveIntentIdMinimalSystem_spec.js | 137 ++++++------- test/spec/modules/liveIntentIdSystem_spec.js | 185 ++++++++---------- 5 files changed, 236 insertions(+), 327 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 8cda487e6b1..2d9e6b63a35 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -9,14 +9,14 @@ import { ajaxBuilder } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/validate-imports import { gdprDataHandler, uspDataHandler } from '../src/adapterManager.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { MODULE_TYPE_UID } from '../src/activities/modules.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const EVENTS_TOPIC = 'pre_lips' const MODULE_NAME = 'liveIntentId'; const LI_PROVIDER_DOMAIN = 'liveintent.com'; -export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME }); -const defaultRequestedAttributes = { 'nonId': true } +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); +const defaultRequestedAttributes = {'nonId': true} const calls = { ajaxGet: (url, onSuccess, onError, timeout) => { ajaxBuilder(timeout)( @@ -79,7 +79,7 @@ function parseRequestedAttributes(overrides) { return Object.entries(config).flatMap(([k, v]) => (typeof v === 'boolean' && v) ? [k] : []); } if (typeof overrides === 'object') { - return createParameterArray({ ...defaultRequestedAttributes, ...overrides }) + return createParameterArray({...defaultRequestedAttributes, ...overrides}) } else { return createParameterArray(defaultRequestedAttributes); } @@ -209,10 +209,6 @@ export const liveIntentIdSubmodule = { result.index = { 'id': value.index, ext: { provider: LI_PROVIDER_DOMAIN } } } - if (value.openx) { - result.openx = { 'id': value.openx, ext: { provider: LI_PROVIDER_DOMAIN } } - } - return result } @@ -237,7 +233,7 @@ export const liveIntentIdSubmodule = { return; } tryFireEvent(); - const result = function (callback) { + const result = function(callback) { liveConnect.resolve( response => { callback(response); @@ -253,12 +249,12 @@ export const liveIntentIdSubmodule = { }, eids: { 'lipb': { - getValue: function (data) { + getValue: function(data) { return data.lipbid; }, source: 'liveintent.com', atype: 3, - getEidExt: function (data) { + getEidExt: function(data) { if (Array.isArray(data.segments) && data.segments.length) { return { segments: data.segments @@ -269,10 +265,10 @@ export const liveIntentIdSubmodule = { 'bidswitch': { source: 'bidswitch.net', atype: 3, - getValue: function (data) { + getValue: function(data) { return data.id; }, - getUidExt: function (data) { + getUidExt: function(data) { if (data.ext) { return data.ext; } @@ -281,10 +277,10 @@ export const liveIntentIdSubmodule = { 'medianet': { source: 'media.net', atype: 3, - getValue: function (data) { + getValue: function(data) { return data.id; }, - getUidExt: function (data) { + getUidExt: function(data) { if (data.ext) { return data.ext; } @@ -293,10 +289,10 @@ export const liveIntentIdSubmodule = { 'magnite': { source: 'rubiconproject.com', atype: 3, - getValue: function (data) { + getValue: function(data) { return data.id; }, - getUidExt: function (data) { + getUidExt: function(data) { if (data.ext) { return data.ext; } @@ -305,22 +301,10 @@ export const liveIntentIdSubmodule = { 'index': { source: 'liveintent.indexexchange.com', atype: 3, - getValue: function (data) { - return data.id; - }, - getUidExt: function (data) { - if (data.ext) { - return data.ext; - } - } - }, - 'openx': { - source: 'opex.com', - atype: 3, - getValue: function (data) { + getValue: function(data) { return data.id; }, - getUidExt: function (data) { + getUidExt: function(data) { if (data.ext) { return data.ext; } diff --git a/package-lock.json b/package-lock.json index 85aff19a30f..dbfc057de9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "prebid.js", - "version": "8.14.0-pre", + "version": "8.8.0-pre", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.16.7", @@ -6997,9 +6997,9 @@ "dev": true }, "node_modules/caniuse-lite": { - "version": "1.0.30001538", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", - "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==", + "version": "1.0.30001429", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", + "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==", "funding": [ { "type": "opencollective", @@ -7008,10 +7008,6 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" } ] }, @@ -30657,9 +30653,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001538", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", - "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==" + "version": "1.0.30001429", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", + "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==" }, "caseless": { "version": "0.12.0", diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 2af0ba6ea23..1597790e652 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -1,11 +1,11 @@ -import { createEidsArray } from 'modules/userId/eids.js'; -import { expect } from 'chai'; +import {createEidsArray} from 'modules/userId/eids.js'; +import {expect} from 'chai'; -// Note: In unit test cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids +// Note: In unit tets cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids // this way the request will stay consistent and unit test cases will not need lots of changes. -describe('eids array generation for known sub-modules', function () { - it('pubCommonId', function () { +describe('eids array generation for known sub-modules', function() { + it('pubCommonId', function() { const userId = { pubcid: 'some-random-id-value' }; @@ -13,11 +13,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'pubcid.org', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{id: 'some-random-id-value', atype: 1}] }); }); - it('unifiedId: ext generation', function () { + it('unifiedId: ext generation', function() { const userId = { tdid: 'some-random-id-value' }; @@ -25,12 +25,12 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'adserver.org', - uids: [{ id: 'some-random-id-value', atype: 1, ext: { rtiPartner: 'TDID' } }] + uids: [{id: 'some-random-id-value', atype: 1, ext: { rtiPartner: 'TDID' }}] }); }); - describe('id5Id', function () { - it('does not include an ext if not provided', function () { + describe('id5Id', function() { + it('does not include an ext if not provided', function() { const userId = { id5id: { uid: 'some-random-id-value' @@ -44,7 +44,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('includes ext if provided', function () { + it('includes ext if provided', function() { const userId = { id5id: { uid: 'some-random-id-value', @@ -68,7 +68,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('parrableId', function () { + it('parrableId', function() { const userId = { parrableId: { eid: 'some-random-id-value' @@ -78,11 +78,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'parrable.com', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{id: 'some-random-id-value', atype: 1}] }); }); - it('merkleId (legacy) - supports single id', function () { + it('merkleId (legacy) - supports single id', function() { const userId = { merkleId: { id: 'some-random-id-value', keyID: 1 @@ -101,7 +101,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('merkleId supports multiple source providers', function () { + it('merkleId supports multiple source providers', function() { const userId = { merkleId: [{ id: 'some-random-id-value', ext: { enc: 1, keyID: 16, idName: 'pamId', ssp: 'ssp1' } @@ -120,8 +120,7 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(2); expect(newEids[0]).to.deep.equal({ source: 'ssp1.merkleinc.com', - uids: [{ - id: 'some-random-id-value', + uids: [{id: 'some-random-id-value', atype: 3, ext: { enc: 1, @@ -133,8 +132,7 @@ describe('eids array generation for known sub-modules', function () { }); expect(newEids[1]).to.deep.equal({ source: 'ssp2.merkleinc.com', - uids: [{ - id: 'another-random-id-value', + uids: [{id: 'another-random-id-value', atype: 3, ext: { third: 4, @@ -146,7 +144,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('identityLink', function () { + it('identityLink', function() { const userId = { idl_env: 'some-random-id-value' }; @@ -154,11 +152,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveramp.com', - uids: [{ id: 'some-random-id-value', atype: 3 }] + uids: [{id: 'some-random-id-value', atype: 3}] }); }); - it('liveIntentId; getValue call and ext', function () { + it('liveIntentId; getValue call and ext', function() { const userId = { lipb: { lipbid: 'some-random-id-value', @@ -169,14 +167,14 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveintent.com', - uids: [{ id: 'some-random-id-value', atype: 3 }], - ext: { segments: ['s1', 's2'] } + uids: [{id: 'some-random-id-value', atype: 3}], + ext: {segments: ['s1', 's2']} }); }); - it('bidswitch', function () { + it('bidswitch', function() { const userId = { - bidswitch: { 'id': 'sample_id' } + bidswitch: {'id': 'sample_id'} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -189,9 +187,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('bidswitch with ext', function () { + it('bidswitch with ext', function() { const userId = { - bidswitch: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + bidswitch: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -207,9 +205,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('medianet', function () { + it('medianet', function() { const userId = { - medianet: { 'id': 'sample_id' } + medianet: {'id': 'sample_id'} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -222,9 +220,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('medianet with ext', function () { + it('medianet with ext', function() { const userId = { - medianet: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + medianet: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -240,9 +238,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('magnite', function () { + it('magnite', function() { const userId = { - magnite: { 'id': 'sample_id' } + magnite: {'id': 'sample_id'} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -255,9 +253,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('magnite with ext', function () { + it('magnite with ext', function() { const userId = { - magnite: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + magnite: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -273,9 +271,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('index', function () { + it('index', function() { const userId = { - index: { 'id': 'sample_id' } + index: {'id': 'sample_id'} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -288,9 +286,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('index with ext', function () { + it('index with ext', function() { const userId = { - index: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } + index: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -306,40 +304,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('openx', function () { - const userId = { - openx: { 'id': 'sample_id' } - }; - const newEids = createEidsArray(userId); - expect(newEids.length).to.equal(1); - expect(newEids[0]).to.deep.equal({ - source: 'opex.com', - uids: [{ - id: 'sample_id', - atype: 3 - }] - }); - }); - - it('openx with ext', function () { - const userId = { - index: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } - }; - const newEids = createEidsArray(userId); - expect(newEids.length).to.equal(1); - expect(newEids[0]).to.deep.equal({ - source: 'opex.com', - uids: [{ - id: 'sample_id', - atype: 3, - ext: { - provider: 'some.provider.com' - } - }] - }); - }); - - it('liveIntentId; getValue call and NO ext', function () { + it('liveIntentId; getValue call and NO ext', function() { const userId = { lipb: { lipbid: 'some-random-id-value' @@ -349,11 +314,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'liveintent.com', - uids: [{ id: 'some-random-id-value', atype: 3 }] + uids: [{id: 'some-random-id-value', atype: 3}] }); }); - it('britepoolId', function () { + it('britepoolId', function() { const userId = { britepoolid: 'some-random-id-value' }; @@ -361,7 +326,7 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'britepool.com', - uids: [{ id: 'some-random-id-value', atype: 3 }] + uids: [{id: 'some-random-id-value', atype: 3}] }); }); @@ -377,7 +342,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('criteo', function () { + it('criteo', function() { const userId = { criteoId: 'some-random-id-value' }; @@ -385,11 +350,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'criteo.com', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{id: 'some-random-id-value', atype: 1}] }); }); - it('tapadId', function () { + it('tapadId', function() { const userId = { tapadId: 'some-random-id-value' }; @@ -397,11 +362,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'tapad.com', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{id: 'some-random-id-value', atype: 1}] }); }); - it('deepintentId', function () { + it('deepintentId', function() { const userId = { deepintentId: 'some-random-id-value' }; @@ -409,11 +374,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'deepintent.com', - uids: [{ id: 'some-random-id-value', atype: 3 }] + uids: [{id: 'some-random-id-value', atype: 3}] }); }); - it('NetId', function () { + it('NetId', function() { const userId = { netId: 'some-random-id-value' }; @@ -421,11 +386,11 @@ describe('eids array generation for known sub-modules', function () { expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'netid.de', - uids: [{ id: 'some-random-id-value', atype: 1 }] + uids: [{id: 'some-random-id-value', atype: 1}] }); }); - it('zeotapIdPlus', function () { + it('zeotapIdPlus', function() { const userId = { IDP: 'some-random-id-value' }; @@ -440,7 +405,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('hadronId', function () { + it('hadronId', function() { const userId = { hadronId: 'some-random-id-value' }; @@ -455,7 +420,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('quantcastId', function () { + it('quantcastId', function() { const userId = { quantcastId: 'some-random-id-value' }; @@ -470,9 +435,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('uid2', function () { + it('uid2', function() { const userId = { - uid2: { 'id': 'Sample_AD_Token' } + uid2: {'id': 'Sample_AD_Token'} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -485,9 +450,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('uid2 with ext', function () { + it('uid2 with ext', function() { const userId = { - uid2: { 'id': 'Sample_AD_Token', 'ext': { 'provider': 'some.provider.com' } } + uid2: {'id': 'Sample_AD_Token', 'ext': {'provider': 'some.provider.com'}} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -503,9 +468,9 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('euid', function () { + it('euid', function() { const userId = { - euid: { 'id': 'Sample_AD_Token' } + euid: {'id': 'Sample_AD_Token'} }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -518,7 +483,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('kpuid', function () { + it('kpuid', function() { const userId = { kpuid: 'Sample_Token' }; @@ -533,7 +498,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('tncid', function () { + it('tncid', function() { const userId = { tncid: 'TEST_TNCID' }; @@ -548,7 +513,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('pubProvidedId', function () { + it('pubProvidedId', function() { const userId = { pubProvidedId: [{ source: 'example.com', @@ -600,7 +565,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('qid', function () { + it('qid', function() { const userId = { qid: 'some-random-id-value' }; @@ -615,7 +580,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('operaId', function () { + it('operaId', function() { const userId = { operaId: 'some-random-id-value' }; @@ -630,7 +595,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('33acrossId', function () { + it('33acrossId', function() { const userId = { '33acrossId': { envelope: 'some-random-id-value' @@ -690,8 +655,8 @@ describe('eids array generation for known sub-modules', function () { }); }); - describe('imuid', function () { - it('should return the correct EID schema with imuid', function () { + describe('imuid', function() { + it('should return the correct EID schema with imuid', function() { const userId = { imuid: 'testimuid' }; @@ -706,7 +671,7 @@ describe('eids array generation for known sub-modules', function () { }); }); - it('should return the correct EID schema with imppid', function () { + it('should return the correct EID schema with imppid', function() { const userId = { imppid: 'imppid-value-imppid-value-imppid-value' }; @@ -724,7 +689,7 @@ describe('eids array generation for known sub-modules', function () { }); describe('Negative case', function () { - it('eids array generation for UN-known sub-module', function () { + it('eids array generation for UN-known sub-module', function() { // UnknownCommonId const userId = { unknowncid: 'some-random-id-value' @@ -733,7 +698,7 @@ describe('Negative case', function () { expect(newEids.length).to.equal(0); }); - it('eids array generation for known sub-module with non-string value', function () { + it('eids array generation for known sub-module with non-string value', function() { // pubCommonId let userId = { pubcid: undefined diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 8f73e8ff048..0929a022937 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -4,10 +4,10 @@ import { server } from 'test/mocks/xhr.js'; import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } from 'modules/liveIntentIdSystem.js'; const PUBLISHER_ID = '89899'; -const defaultConfigParams = { params: { publisherId: PUBLISHER_ID } }; -const responseHeader = { 'Content-Type': 'application/json' }; +const defaultConfigParams = { params: {publisherId: PUBLISHER_ID} }; +const responseHeader = {'Content-Type': 'application/json'}; -describe('LiveIntentMinimalId', function () { +describe('LiveIntentMinimalId', function() { let logErrorStub; let uspConsentDataStub; let gdprConsentDataStub; @@ -15,7 +15,7 @@ describe('LiveIntentMinimalId', function () { let getDataFromLocalStorageStub; let imgStub; - beforeEach(function () { + beforeEach(function() { liveIntentIdSubmodule.setModuleMode('minimal'); imgStub = sinon.stub(utils, 'triggerPixel'); getCookieStub = sinon.stub(storage, 'getCookie'); @@ -25,7 +25,7 @@ describe('LiveIntentMinimalId', function () { gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); }); - afterEach(function () { + afterEach(function() { imgStub.restore(); getCookieStub.restore(); getDataFromLocalStorageStub.restore(); @@ -35,7 +35,7 @@ describe('LiveIntentMinimalId', function () { liveIntentIdSubmodule.setModuleMode('minimal'); resetLiveIntentIdSubmodule(); }); - it('should not fire an event when getId', function () { + it('should not fire an event when getId', function() { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -45,12 +45,12 @@ describe('LiveIntentMinimalId', function () { expect(server.requests[0]).to.eql(undefined) }); - it('should not return a decoded identifier when the unifiedId is not present in the value', function () { + it('should not return a decoded identifier when the unifiedId is not present in the value', function() { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); expect(result).to.be.eql({}); }); - it('should initialize LiveConnect and send no data', function () { + it('should initialize LiveConnect and send no data', function() { liveIntentIdSubmodule.getId(defaultConfigParams); liveIntentIdSubmodule.decode({}, defaultConfigParams); liveIntentIdSubmodule.getId(defaultConfigParams); @@ -58,10 +58,10 @@ describe('LiveIntentMinimalId', function () { expect(server.requests.length).to.be.eq(0); }); - it('should call the Custom URL of the LiveIntent Identity Exchange endpoint', function () { + it('should call the Custom URL of the LiveIntent Identity Exchange endpoint', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, ...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); @@ -73,7 +73,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the Identity Exchange endpoint with the privided distributorId', function () { + it('should call the Identity Exchange endpoint with the privided distributorId', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback; @@ -87,7 +87,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function () { + it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback; @@ -101,18 +101,16 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () { + it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ - params: { - ...defaultConfigParams.params, - ...{ - 'url': 'https://dummy.liveintent.com/idex', - 'partner': 'rubicon' - } + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ + 'url': 'https://dummy.liveintent.com/idex', + 'partner': 'rubicon' } - }).callback; + } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899?resolve=nonId'); @@ -124,7 +122,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function () { + it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -139,7 +137,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors', function () { + it('should log an error and continue to callback if ajax request errors', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -155,7 +153,7 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function () { + it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function() { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie); let callBackSpy = sinon.spy(); @@ -171,18 +169,16 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier and additional Identifiers to resolve', function () { + it('should include the LiveConnect identifier and additional Identifiers to resolve', function() { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie); getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc'); - const configParams = { - params: { - ...defaultConfigParams.params, - ...{ - 'identifiersToResolve': ['_thirdPC'] - } + const configParams = { params: { + ...defaultConfigParams.params, + ...{ + 'identifiersToResolve': ['_thirdPC'] } - }; + }}; let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); @@ -196,17 +192,15 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include an additional identifier value to resolve even if it is an object', function () { + it('should include an additional identifier value to resolve even if it is an object', function() { getCookieStub.returns(null); - getDataFromLocalStorageStub.withArgs('_thirdPC').returns({ 'key': 'value' }); - const configParams = { - params: { - ...defaultConfigParams.params, - ...{ - 'identifiersToResolve': ['_thirdPC'] - } + getDataFromLocalStorageStub.withArgs('_thirdPC').returns({'key': 'value'}); + const configParams = { params: { + ...defaultConfigParams.params, + ...{ + 'identifiersToResolve': ['_thirdPC'] } - }; + }}; let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); @@ -220,24 +214,22 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a unifiedId to lipbId and remove it', function () { + it('should decode a unifiedId to lipbId and remove it', function() { const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'data' } }); + expect(result).to.eql({'lipb': {'lipbid': 'data'}}); }); - it('should decode a nonId to lipbId', function () { + it('should decode a nonId to lipbId', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'data', 'nonId': 'data' } }); + expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}}); }); - it('should resolve extra attributes', function () { + it('should resolve extra attributes', function() { let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ - params: { - ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } - } - }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } + } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=nonId&resolve=foo`); @@ -249,49 +241,42 @@ describe('LiveIntentMinimalId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a uid2 to a seperate object when present', function () { + it('should decode a uid2 to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar' }, 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar'}, 'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode values with uid2 but no nonId', function () { + it('should decode values with uid2 but no nonId', function() { const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); - expect(result).to.eql({ 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode a bidswitch id to a seperate object when present', function () { + it('should decode a bidswitch id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar' }, 'bidswitch': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar'}, 'bidswitch': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode a medianet id to a seperate object when present', function () { + it('should decode a medianet id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar' }, 'medianet': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar'}, 'medianet': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode a magnite id to a seperate object when present', function () { + it('should decode a magnite id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'magnite': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar'}, 'magnite': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode an index id to a seperate object when present', function () { + it('should decode an index id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'index': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode an openx id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); - }) - - it('should allow disabling nonId resolution', function () { + it('should allow disabling nonId resolution', function() { let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ - params: { - ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } - } - }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } + } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=uid2`); diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index e7314f687a7..4f11af57711 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -5,10 +5,10 @@ import { server } from 'test/mocks/xhr.js'; resetLiveIntentIdSubmodule(); liveIntentIdSubmodule.setModuleMode('standard') const PUBLISHER_ID = '89899'; -const defaultConfigParams = { params: { publisherId: PUBLISHER_ID, fireEventDelay: 1 } }; -const responseHeader = { 'Content-Type': 'application/json' } +const defaultConfigParams = { params: {publisherId: PUBLISHER_ID, fireEventDelay: 1} }; +const responseHeader = {'Content-Type': 'application/json'} -describe('LiveIntentId', function () { +describe('LiveIntentId', function() { let logErrorStub; let uspConsentDataStub; let gdprConsentDataStub; @@ -16,7 +16,7 @@ describe('LiveIntentId', function () { let getDataFromLocalStorageStub; let imgStub; - beforeEach(function () { + beforeEach(function() { liveIntentIdSubmodule.setModuleMode('standard'); imgStub = sinon.stub(utils, 'triggerPixel'); getCookieStub = sinon.stub(storage, 'getCookie'); @@ -26,7 +26,7 @@ describe('LiveIntentId', function () { gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); }); - afterEach(function () { + afterEach(function() { imgStub.restore(); getCookieStub.restore(); getDataFromLocalStorageStub.restore(); @@ -59,7 +59,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnceWith(response)).to.be.true; }); - it('should fire an event when getId', function (done) { + it('should fire an event when getId', function(done) { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: true, @@ -72,13 +72,11 @@ describe('LiveIntentId', function () { }, 200); }); - it('should fire an event when getId and a hash is provided', function (done) { - liveIntentIdSubmodule.getId({ - params: { - ...defaultConfigParams, - emailHash: '58131bc547fb87af94cebdaf3102321f' - } - }); + it('should fire an event when getId and a hash is provided', function(done) { + liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams, + emailHash: '58131bc547fb87af94cebdaf3102321f' + }}); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*e=58131bc547fb87af94cebdaf3102321f.+/) done(); @@ -86,18 +84,16 @@ describe('LiveIntentId', function () { }); it('should initialize LiveConnect with the config params when decode and emit an event', function (done) { - liveIntentIdSubmodule.decode({}, { - params: { - ...defaultConfigParams.params, - ...{ - url: 'https://dummy.liveintent.com', - liCollectConfig: { - appId: 'a-0001', - collectorUrl: 'https://collector.liveintent.com' - } + liveIntentIdSubmodule.decode({}, { params: { + ...defaultConfigParams.params, + ...{ + url: 'https://dummy.liveintent.com', + liCollectConfig: { + appId: 'a-0001', + collectorUrl: 'https://collector.liveintent.com' } } - }); + }}); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/collector.liveintent.com\/j\?.*aid=a-0001.*&wpn=prebid.*/); done(); @@ -121,7 +117,7 @@ describe('LiveIntentId', function () { }, 200); }); - it('should initialize LiveConnect and emit an event with a privacy string when decode', function (done) { + it('should initialize LiveConnect and emit an event with a privacy string when decode', function(done) { uspConsentDataStub.returns('1YNY'); gdprConsentDataStub.returns({ gdprApplies: false, @@ -134,25 +130,23 @@ describe('LiveIntentId', function () { }, 200); }); - it('should fire an event when decode and a hash is provided', function (done) { - liveIntentIdSubmodule.decode({}, { - params: { - ...defaultConfigParams.params, - emailHash: '58131bc547fb87af94cebdaf3102321f' - } - }); + it('should fire an event when decode and a hash is provided', function(done) { + liveIntentIdSubmodule.decode({}, { params: { + ...defaultConfigParams.params, + emailHash: '58131bc547fb87af94cebdaf3102321f' + }}); setTimeout(() => { expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*e=58131bc547fb87af94cebdaf3102321f.+/); done(); }, 200); }); - it('should not return a decoded identifier when the unifiedId is not present in the value', function () { + it('should not return a decoded identifier when the unifiedId is not present in the value', function() { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); expect(result).to.be.eql({}); }); - it('should fire an event when decode', function (done) { + it('should fire an event when decode', function(done) { liveIntentIdSubmodule.decode({}, defaultConfigParams); setTimeout(() => { expect(server.requests[0].url).to.be.not.null @@ -160,7 +154,7 @@ describe('LiveIntentId', function () { }, 200); }); - it('should initialize LiveConnect and send data only once', function (done) { + it('should initialize LiveConnect and send data only once', function(done) { liveIntentIdSubmodule.getId(defaultConfigParams); liveIntentIdSubmodule.decode({}, defaultConfigParams); liveIntentIdSubmodule.getId(defaultConfigParams); @@ -171,10 +165,10 @@ describe('LiveIntentId', function () { }, 200); }); - it('should call the custom URL of the LiveIntent Identity Exchange endpoint', function () { + it('should call the custom URL of the LiveIntent Identity Exchange endpoint', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, ...{ 'url': 'https://dummy.liveintent.com/idex' } } }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); @@ -185,7 +179,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint with the privided distributorId', function () { + it('should call the Identity Exchange endpoint with the privided distributorId', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback; @@ -199,7 +193,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function () { + it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback; @@ -213,18 +207,16 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnceWith({})).to.be.true; }); - it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () { + it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ - params: { - ...defaultConfigParams.params, - ...{ - 'url': 'https://dummy.liveintent.com/idex', - 'partner': 'rubicon' - } + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ + 'url': 'https://dummy.liveintent.com/idex', + 'partner': 'rubicon' } - }).callback; + } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899?resolve=nonId'); @@ -236,7 +228,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function () { + it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -251,7 +243,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors', function () { + it('should log an error and continue to callback if ajax request errors', function() { getCookieStub.returns(null); let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; @@ -267,7 +259,7 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function () { + it('should include the LiveConnect identifier when calling the LiveIntent Identity Exchange endpoint', function() { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getCookieStub.withArgs('_lc2_fpi').returns(oldCookie) let callBackSpy = sinon.spy(); @@ -283,18 +275,16 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include the LiveConnect identifier and additional Identifiers to resolve', function () { + it('should include the LiveConnect identifier and additional Identifiers to resolve', function() { const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000' getCookieStub.withArgs('_lc2_fpi').returns(oldCookie); getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc'); - const configParams = { - params: { - ...defaultConfigParams.params, - ...{ - 'identifiersToResolve': ['_thirdPC'] - } + const configParams = { params: { + ...defaultConfigParams.params, + ...{ + 'identifiersToResolve': ['_thirdPC'] } - }; + }}; let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); @@ -308,17 +298,15 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should include an additional identifier value to resolve even if it is an object', function () { + it('should include an additional identifier value to resolve even if it is an object', function() { getCookieStub.returns(null); - getDataFromLocalStorageStub.withArgs('_thirdPC').returns({ 'key': 'value' }); - const configParams = { - params: { - ...defaultConfigParams.params, - ...{ - 'identifiersToResolve': ['_thirdPC'] - } + getDataFromLocalStorageStub.withArgs('_thirdPC').returns({'key': 'value'}); + const configParams = { params: { + ...defaultConfigParams.params, + ...{ + 'identifiersToResolve': ['_thirdPC'] } - }; + }}; let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); @@ -332,30 +320,28 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should send an error when the cookie jar throws an unexpected error', function () { + it('should send an error when the cookie jar throws an unexpected error', function() { getCookieStub.throws('CookieError', 'A message'); liveIntentIdSubmodule.getId(defaultConfigParams); expect(imgStub.getCall(0).args[0]).to.match(/.*ae=.+/); }); - it('should decode a unifiedId to lipbId and remove it', function () { + it('should decode a unifiedId to lipbId and remove it', function() { const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'data' } }); + expect(result).to.eql({'lipb': {'lipbid': 'data'}}); }); - it('should decode a nonId to lipbId', function () { + it('should decode a nonId to lipbId', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'data', 'nonId': 'data' } }); + expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}}); }); - it('should resolve extra attributes', function () { + it('should resolve extra attributes', function() { let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ - params: { - ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } - } - }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } + } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=nonId&resolve=foo`); @@ -367,49 +353,42 @@ describe('LiveIntentId', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should decode a uid2 to a seperate object when present', function () { + it('should decode a uid2 to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar' }, 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar'}, 'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode values with uid2 but no nonId', function () { + it('should decode values with uid2 but no nonId', function() { const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); - expect(result).to.eql({ 'uid2': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode a bidswitch id to a seperate object when present', function () { + it('should decode a bidswitch id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar' }, 'bidswitch': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar'}, 'bidswitch': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode a medianet id to a seperate object when present', function () { + it('should decode a medianet id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar' }, 'medianet': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar'}, 'medianet': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode a magnite id to a seperate object when present', function () { + it('should decode a magnite id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'magnite': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar'}, 'magnite': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode an index id to a seperate object when present', function () { + it('should decode an index id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar' }, 'index': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode an openx id to a seperate object when present', function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); - }); - - it('should allow disabling nonId resolution', function () { + it('should allow disabling nonId resolution', function() { let callBackSpy = sinon.spy(); - let submoduleCallback = liveIntentIdSubmodule.getId({ - params: { - ...defaultConfigParams.params, - ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } - } - }).callback; + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } + } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=uid2`); From fc1674b0e87ac8338dc149731d9aa595eb2c812e Mon Sep 17 00:00:00 2001 From: Peixun Zhang Date: Fri, 22 Sep 2023 13:21:42 +0200 Subject: [PATCH 7/8] changes without formatting: --- modules/liveIntentIdSystem.js | 4 +++ test/spec/modules/eids_spec.js | 33 +++++++++++++++++++ .../modules/liveIntentIdMinimalSystem_spec.js | 4 +++ test/spec/modules/liveIntentIdSystem_spec.js | 5 +++ 4 files changed, 46 insertions(+) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 2d9e6b63a35..a25f4d29072 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -209,6 +209,10 @@ export const liveIntentIdSubmodule = { result.index = { 'id': value.index, ext: { provider: LI_PROVIDER_DOMAIN } } } + if (value.openx) { + result.openx = { 'id': value.openx, ext: { provider: LI_PROVIDER_DOMAIN } } + } + return result } diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 1597790e652..160bebde1d2 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -304,6 +304,39 @@ describe('eids array generation for known sub-modules', function() { }); }); + it('openx',function () { + const userId = { + openx: { 'id': 'sample_id' } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'opex.com', + uids: [{ + id: 'sample_id', + atype: 3 + }] + }); + }); + + it('openx with ext',function () { + const userId = { + openx: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'opex.com', + uids: [{ + id: 'sample_id', + atype: 3, + ext: { + provider: 'some.provider.com' + } + }] + }); + }); + it('liveIntentId; getValue call and NO ext', function() { const userId = { lipb: { diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 0929a022937..a073945ab82 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -271,6 +271,10 @@ describe('LiveIntentMinimalId', function() { expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); + it('should decode an openx id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',openx: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','openx': 'bar' },'openx': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should allow disabling nonId resolution', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 4f11af57711..8ee48f89d18 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -383,6 +383,11 @@ describe('LiveIntentId', function() { expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); + it('should decode an openx id to a seperate object when present',function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo',openx: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','openx': 'bar' },'openx': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + }); + it('should allow disabling nonId resolution', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { From d8431f987d334e3e7a165e512f3db012aa5cc038 Mon Sep 17 00:00:00 2001 From: Peixun Zhang Date: Fri, 22 Sep 2023 13:43:19 +0200 Subject: [PATCH 8/8] fix --- test/spec/modules/eids_spec.js | 8 ++++---- test/spec/modules/liveIntentIdMinimalSystem_spec.js | 7 ++++--- test/spec/modules/liveIntentIdSystem_spec.js | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 160bebde1d2..7fa642505ab 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -304,7 +304,7 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('openx',function () { + it('openx', function () { const userId = { openx: { 'id': 'sample_id' } }; @@ -319,9 +319,9 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('openx with ext',function () { + it('openx with ext', function () { const userId = { - openx: { 'id': 'sample_id','ext': { 'provider': 'some.provider.com' } } + openx: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } } }; const newEids = createEidsArray(userId); expect(newEids.length).to.equal(1); @@ -336,7 +336,7 @@ describe('eids array generation for known sub-modules', function() { }] }); }); - + it('liveIntentId; getValue call and NO ext', function() { const userId = { lipb: { diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index a073945ab82..1da1aa4ef76 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -271,9 +271,10 @@ describe('LiveIntentMinimalId', function() { expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode an openx id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',openx: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','openx': 'bar' },'openx': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode an openx id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'openx': 'bar'}, 'openx': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); + }); it('should allow disabling nonId resolution', function() { let callBackSpy = sinon.spy(); diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 8ee48f89d18..c4be420a977 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -383,9 +383,9 @@ describe('LiveIntentId', function() { expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode an openx id to a seperate object when present',function () { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo',openx: 'bar' }); - expect(result).to.eql({ 'lipb': { 'lipbid': 'foo','nonId': 'foo','openx': 'bar' },'openx': { 'id': 'bar','ext': { 'provider': 'liveintent.com' } } }); + it('should decode an openx id to a seperate object when present', function () { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' }); + expect(result).to.eql({ 'lipb': { 'lipbid': 'foo', 'nonId': 'foo', 'openx': 'bar' }, 'openx': { 'id': 'bar', 'ext': { 'provider': 'liveintent.com' } } }); }); it('should allow disabling nonId resolution', function() {