Skip to content

Commit 7877972

Browse files
authored
Lotame: added change to fall back to the TCF cookies when no data is present in the consentData object. (#6192)
1 parent 2a62f6c commit 7877972

File tree

2 files changed

+185
-8
lines changed

2 files changed

+185
-8
lines changed

modules/lotamePanoramaIdSystem.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,22 @@ export const lotamePanoramaIdSubmodule = {
192192
queryParams.fp = storedUserId;
193193
}
194194

195-
if (consentData && utils.isBoolean(consentData.gdprApplies)) {
196-
queryParams.gdpr_applies = consentData.gdprApplies;
197-
if (consentData.gdprApplies) {
198-
queryParams.gdpr_consent = consentData.consentString;
195+
let consentString;
196+
if (consentData) {
197+
if (utils.isBoolean(consentData.gdprApplies)) {
198+
queryParams.gdpr_applies = consentData.gdprApplies;
199199
}
200+
consentString = consentData.consentString;
201+
}
202+
// If no consent string, try to read it from 1st party cookies
203+
if (!consentString) {
204+
consentString = getFromStorage('eupubconsent-v2');
205+
}
206+
if (!consentString) {
207+
consentString = getFromStorage('euconsent-v2');
208+
}
209+
if (consentString) {
210+
queryParams.gdpr_consent = consentString;
200211
}
201212
const url = utils.buildUrl({
202213
protocol: 'https',

test/spec/modules/lotamePanoramaIdSystem_spec.js

+170-4
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,176 @@ describe('LotameId', function() {
440440
});
441441
});
442442

443-
it('should retrieve the id when decode is called', function() {
444-
var id = lotamePanoramaIdSubmodule.decode('1234');
445-
expect(id).to.be.eql({
446-
'lotamePanoramaId': '1234'
443+
describe('when gdpr applies and falls back to eupubconsent cookie', function () {
444+
let request;
445+
let callBackSpy = sinon.spy();
446+
let consentData = {
447+
gdprApplies: true,
448+
consentString: undefined
449+
};
450+
451+
beforeEach(function () {
452+
getCookieStub
453+
.withArgs('eupubconsent-v2')
454+
.returns('consentGiven');
455+
456+
let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
457+
submoduleCallback(callBackSpy);
458+
459+
// the contents of the response don't matter for this
460+
request = server.requests[0];
461+
request.respond(200, responseHeader, '');
462+
});
463+
464+
it('should call the remote server when getId is called', function () {
465+
expect(callBackSpy.calledOnce).to.be.true;
466+
});
467+
468+
it('should pass the gdpr consent string back', function() {
469+
expect(request.url).to.be.eq(
470+
'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
471+
);
472+
});
473+
});
474+
475+
describe('when gdpr applies and falls back to euconsent cookie', function () {
476+
let request;
477+
let callBackSpy = sinon.spy();
478+
let consentData = {
479+
gdprApplies: true,
480+
consentString: undefined
481+
};
482+
483+
beforeEach(function () {
484+
getCookieStub
485+
.withArgs('euconsent-v2')
486+
.returns('consentGiven');
487+
488+
let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
489+
submoduleCallback(callBackSpy);
490+
491+
// the contents of the response don't matter for this
492+
request = server.requests[0];
493+
request.respond(200, responseHeader, '');
494+
});
495+
496+
it('should call the remote server when getId is called', function () {
497+
expect(callBackSpy.calledOnce).to.be.true;
498+
});
499+
500+
it('should pass the gdpr consent string back', function() {
501+
expect(request.url).to.be.eq(
502+
'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
503+
);
504+
});
505+
});
506+
507+
describe('when gdpr applies but no consent string is available', function () {
508+
let request;
509+
let callBackSpy = sinon.spy();
510+
let consentData = {
511+
gdprApplies: true,
512+
consentString: undefined
513+
};
514+
515+
beforeEach(function () {
516+
let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
517+
submoduleCallback(callBackSpy);
518+
519+
// the contents of the response don't matter for this
520+
request = server.requests[0];
521+
request.respond(200, responseHeader, '');
522+
});
523+
524+
it('should call the remote server when getId is called', function () {
525+
expect(callBackSpy.calledOnce).to.be.true;
526+
});
527+
528+
it('should not include the gdpr consent string on the url', function() {
529+
expect(request.url).to.be.eq(
530+
'https://id.crwdcntrl.net/id?gdpr_applies=true'
531+
);
532+
});
533+
});
534+
535+
describe('when no consentData and falls back to eupubconsent cookie', function () {
536+
let request;
537+
let callBackSpy = sinon.spy();
538+
let consentData;
539+
540+
beforeEach(function () {
541+
getCookieStub
542+
.withArgs('eupubconsent-v2')
543+
.returns('consentGiven');
544+
545+
let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
546+
submoduleCallback(callBackSpy);
547+
548+
// the contents of the response don't matter for this
549+
request = server.requests[0];
550+
request.respond(200, responseHeader, '');
551+
});
552+
553+
it('should call the remote server when getId is called', function () {
554+
expect(callBackSpy.calledOnce).to.be.true;
555+
});
556+
557+
it('should pass the gdpr consent string back', function() {
558+
expect(request.url).to.be.eq(
559+
'https://id.crwdcntrl.net/id?gdpr_consent=consentGiven'
560+
);
561+
});
562+
});
563+
564+
describe('when no consentData and falls back to euconsent cookie', function () {
565+
let request;
566+
let callBackSpy = sinon.spy();
567+
let consentData;
568+
569+
beforeEach(function () {
570+
getCookieStub
571+
.withArgs('euconsent-v2')
572+
.returns('consentGiven');
573+
574+
let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
575+
submoduleCallback(callBackSpy);
576+
577+
// the contents of the response don't matter for this
578+
request = server.requests[0];
579+
request.respond(200, responseHeader, '');
580+
});
581+
582+
it('should call the remote server when getId is called', function () {
583+
expect(callBackSpy.calledOnce).to.be.true;
584+
});
585+
586+
it('should pass the gdpr consent string back', function() {
587+
expect(request.url).to.be.eq(
588+
'https://id.crwdcntrl.net/id?gdpr_consent=consentGiven'
589+
);
590+
});
591+
});
592+
593+
describe('when no consentData and no cookies', function () {
594+
let request;
595+
let callBackSpy = sinon.spy();
596+
let consentData;
597+
598+
beforeEach(function () {
599+
let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
600+
submoduleCallback(callBackSpy);
601+
602+
// the contents of the response don't matter for this
603+
request = server.requests[0];
604+
request.respond(200, responseHeader, '');
605+
});
606+
607+
it('should call the remote server when getId is called', function () {
608+
expect(callBackSpy.calledOnce).to.be.true;
609+
});
610+
611+
it('should pass the gdpr consent string back', function() {
612+
expect(request.url).to.be.eq('https://id.crwdcntrl.net/id');
447613
});
448614
});
449615
});

0 commit comments

Comments
 (0)