From 6ffeb3d0b40003c19cd6682e163010f2ae6fa314 Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Fri, 15 Dec 2023 12:30:35 -0600 Subject: [PATCH 1/2] remove duplicated 33across ID test --- test/spec/modules/33acrossIdSystem_spec.js | 36 ++-------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/test/spec/modules/33acrossIdSystem_spec.js b/test/spec/modules/33acrossIdSystem_spec.js index 8f23d4614b5..f59a334b058 100644 --- a/test/spec/modules/33acrossIdSystem_spec.js +++ b/test/spec/modules/33acrossIdSystem_spec.js @@ -127,8 +127,8 @@ describe('33acrossIdSystem', () => { }); }); - context('if the response doesn\'t include a first-party ID', () => { - it('should try to remove any first-party ID that could be stored', () => { + context('if the response lacks a first-party ID', () => { + it('should wipe any existing first-party ID from storage', () => { const completeCallback = () => {}; const { callback } = thirthyThreeAcrossIdSubmodule.getId({ @@ -167,38 +167,6 @@ describe('33acrossIdSystem', () => { }); }); - context('if the response lacks a first-party ID', () => { - it('should wipe any existing first-party ID from storage', () => { - const completeCallback = () => {}; - - const { callback } = thirthyThreeAcrossIdSubmodule.getId({ - params: { - pid: '12345' - } - }); - - callback(completeCallback); - - const [request] = server.requests; - - const removeDataFromLocalStorage = sinon.stub(storage, 'removeDataFromLocalStorage'); - - request.respond(200, { - 'Content-Type': 'application/json' - }, JSON.stringify({ - succeeded: true, - data: { - envelope: 'foo' - }, - expires: 1645667805067 - })); - - expect(removeDataFromLocalStorage.calledOnceWithExactly('33acrossIdFp')).to.be.true; - - removeDataFromLocalStorage.restore(); - }); - }); - context('when GDPR applies', () => { it('should call endpoint with \'gdpr=1\'', () => { const completeCallback = () => {}; From 54fd3a6e2bc7f48487095a246235cca02d923692 Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Fri, 15 Dec 2023 18:20:11 -0600 Subject: [PATCH 2/2] clear 33across ID from localstorage --- modules/33acrossIdSystem.js | 10 ++++-- test/spec/modules/33acrossIdSystem_spec.js | 40 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/modules/33acrossIdSystem.js b/modules/33acrossIdSystem.js index 0a24ef54731..5320f562ae4 100644 --- a/modules/33acrossIdSystem.js +++ b/modules/33acrossIdSystem.js @@ -146,7 +146,7 @@ export const thirthyThreeAcrossIdSubmodule = { * @param {SubmoduleConfig} [config] * @returns {IdResponse|undefined} */ - getId({ params = { }, storage }, gdprConsentData) { + getId({ params = { }, storage: storageConfig }, gdprConsentData) { if (typeof params.pid !== 'string') { logError(`${MODULE_NAME}: Submodule requires a partner ID to be defined`); @@ -167,7 +167,11 @@ export const thirthyThreeAcrossIdSubmodule = { logError(`${MODULE_NAME}: ID reading error:`, err); } - handleFpId(responseObj.fp, storage); + if (!responseObj.envelope) { + deleteFromStorage(MODULE_NAME); + } + + handleFpId(responseObj.fp, storageConfig); cb(responseObj.envelope); }, @@ -176,7 +180,7 @@ export const thirthyThreeAcrossIdSubmodule = { cb(); } - }, calculateQueryStringParams(pid, gdprConsentData, storage), { method: 'GET', withCredentials: true }); + }, calculateQueryStringParams(pid, gdprConsentData, storageConfig), { method: 'GET', withCredentials: true }); } }; }, diff --git a/test/spec/modules/33acrossIdSystem_spec.js b/test/spec/modules/33acrossIdSystem_spec.js index f59a334b058..0c91d54aba7 100644 --- a/test/spec/modules/33acrossIdSystem_spec.js +++ b/test/spec/modules/33acrossIdSystem_spec.js @@ -167,6 +167,46 @@ describe('33acrossIdSystem', () => { }); }); + context('if the response lacks the 33across "envelope" ID', () => { + it('should wipe any existing "envelope" ID from storage', () => { + const completeCallback = () => {}; + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + }, + storage: { + type: 'html5' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + const removeDataFromLocalStorage = sinon.stub(storage, 'removeDataFromLocalStorage'); + const setCookie = sinon.stub(storage, 'setCookie'); + const cookiesAreEnabled = sinon.stub(storage, 'cookiesAreEnabled').returns(true); + + request.respond(200, { + 'Content-Type': 'application/json' + }, JSON.stringify({ + succeeded: true, + data: { + envelope: '' // no 'envelope' field + }, + expires: 1645667805067 + })); + + expect(removeDataFromLocalStorage.calledWith('33acrossId')).to.be.true; + expect(setCookie.calledWith('33acrossId', '', sinon.match.string, 'Lax')).to.be.true; + + removeDataFromLocalStorage.restore(); + setCookie.restore(); + cookiesAreEnabled.restore(); + }); + }); + context('when GDPR applies', () => { it('should call endpoint with \'gdpr=1\'', () => { const completeCallback = () => {};