Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ 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 } }
}

if (value.pubmatic) {
result.pubmatic = { 'id': value.pubmatic, ext: { provider: LI_PROVIDER_DOMAIN } }
}

return result
}

Expand Down Expand Up @@ -310,6 +318,30 @@ export const liveIntentIdSubmodule = {
return data.ext;
}
}
},
'openx': {
source: 'openx.com',
atype: 3,
getValue: function(data) {
return data.id;
},
getUidExt: function(data) {
if (data.ext) {
return data.ext;
}
}
},
'pubmatic': {
source: 'pubmatic.com',
atype: 3,
getValue: function(data) {
return data.id;
},
getUidExt: function(data) {
if (data.ext) {
return data.ext;
}
}
}
}
};
Expand Down
66 changes: 66 additions & 0 deletions test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,72 @@ 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: 'openx.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: 'openx.com',
uids: [{
id: 'sample_id',
atype: 3,
ext: {
provider: 'some.provider.com'
}
}]
});
});

it('pubmatic', function() {
const userId = {
pubmatic: {'id': 'sample_id'}
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'pubmatic.com',
uids: [{
id: 'sample_id',
atype: 3
}]
});
});

it('pubmatic with ext', function() {
const userId = {
pubmatic: {'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: 'pubmatic.com',
uids: [{
id: 'sample_id',
atype: 3,
ext: {
provider: 'some.provider.com'
}
}]
});
});

it('liveIntentId; getValue call and NO ext', function() {
const userId = {
lipb: {
Expand Down
41 changes: 0 additions & 41 deletions test/spec/modules/liveIntentIdMinimalSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('LiveIntentMinimalId', function() {
logErrorStub.restore();
uspConsentDataStub.restore();
gdprConsentDataStub.restore();
liveIntentIdSubmodule.setModuleMode('minimal');
resetLiveIntentIdSubmodule();
});
it('should not fire an event when getId', function() {
Expand Down Expand Up @@ -214,16 +213,6 @@ describe('LiveIntentMinimalId', function() {
expect(callBackSpy.calledOnce).to.be.true;
});

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() {
const result = liveIntentIdSubmodule.decode({ nonId: 'data' });
expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}});
});

it('should resolve extra attributes', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
Expand All @@ -241,36 +230,6 @@ 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 values with uid2 but no nonId', function() {
const result = liveIntentIdSubmodule.decode({ uid2: 'bar' });
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 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 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 allow disabling nonId resolution', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
Expand Down
68 changes: 68 additions & 0 deletions test/spec/modules/liveIntentIdSystemCommon_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {expect} from 'chai';
import {reset as resetLiveIntentIdSubmodule, liveIntentIdSubmodule} from 'modules/liveIntentIdSystem.js';

describe('Standard LiveIntentId id decoding', function() {
doTest();
});

describe('Minimal LiveIntentId id decoding', function() {
before(function () {
liveIntentIdSubmodule.setModuleMode('minimal');
})
after(function() {
resetLiveIntentIdSubmodule();
})
doTest();
});

function doTest() {
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() {
const result = liveIntentIdSubmodule.decode({ nonId: 'data' });
expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}});
});

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() {
const result = liveIntentIdSubmodule.decode({ uid2: 'bar' });
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 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 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 pubmatic id to a seperate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', pubmatic: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'pubmatic': 'bar'}, 'pubmatic': {'id': 'bar', "ext": {"provider": "liveintent.com"}}});
});
}
40 changes: 0 additions & 40 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,6 @@ describe('LiveIntentId', function() {
expect(imgStub.getCall(0).args[0]).to.match(/.*ae=.+/);
});

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() {
const result = liveIntentIdSubmodule.decode({ nonId: 'data' });
expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}});
});

it('should resolve extra attributes', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
Expand All @@ -353,36 +343,6 @@ 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 values with uid2 but no nonId', function() {
const result = liveIntentIdSubmodule.decode({ uid2: 'bar' });
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 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 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 allow disabling nonId resolution', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
Expand Down