Skip to content

Commit

Permalink
MerkleID: add check for typof configParams.endpoint on extendId (preb…
Browse files Browse the repository at this point in the history
…id#7611)

* Chore: Added check for typof configParams.endpoint on extendId

* Chore: Fixed various test issues

* Chore: Removed stray console.log Console Log

* Removed Package-lock.json

* Chore: Added back original package-lock.json
  • Loading branch information
Yehuda64 authored and Chris Pabst committed Jan 10, 2022
1 parent 4db903f commit 5c2ae02
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/merkleIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export const merkleIdSubmodule = {
logInfo('User ID - merkleId stored id ' + storedId);
const configParams = (config && config.params) || {};

if (typeof configParams.endpoint !== 'string') {
logWarn('User ID - merkleId submodule endpoint string is not defined');
configParams.endpoint = ID_URL
}

if (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) {
logError('User ID - merkleId submodule does not currently handle consent strings');
return;
Expand Down
1 change: 0 additions & 1 deletion test/spec/modules/konduitWrapper_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('The Konduit vast wrapper module', function () {
const callback = sinon.spy();
processBids({ bid, callback });
server.respond();

expect(server.requests.length).to.equal(1);

const requestBody = JSON.parse(server.requests[0].requestBody);
Expand Down
18 changes: 18 additions & 0 deletions test/spec/modules/merkleIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,24 @@ describe('Merkle System', function () {

expect(id.id).to.exist.and.to.equal(storedId);
});
it('extendId() should warn on missing endpoint', function () {
let config = {
params: {
...CONFIG_PARAMS,
endpoint: undefined
},
storage: STORAGE_PARAMS
};

let yesterday = new Date(Date.now() - 86400000).toUTCString();
let storedId = {value: 'Merkle_Stored_ID', date: yesterday};

let submoduleCallback = merkleIdSubmodule.extendId(config, undefined,
storedId).callback;
submoduleCallback(callbackSpy);
expect(callbackSpy.calledOnce).to.be.true;
expect(utils.logWarn.args[0][0]).to.exist.and.to.equal('User ID - merkleId submodule endpoint string is not defined');
});

it('extendId() callback on configured storageParam.refreshInSeconds', function () {
let config = {
Expand Down

0 comments on commit 5c2ae02

Please sign in to comment.