Skip to content

Commit

Permalink
ARGO-715 added change to fall back to the TCF cookies when no data is…
Browse files Browse the repository at this point in the history
… present in the consentData object.
  • Loading branch information
Tonsil committed Jan 20, 2021
1 parent 15b58dc commit deb5350
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 8 deletions.
19 changes: 15 additions & 4 deletions modules/lotamePanoramaIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,22 @@ export const lotamePanoramaIdSubmodule = {
queryParams.fp = storedUserId;
}

if (consentData && utils.isBoolean(consentData.gdprApplies)) {
queryParams.gdpr_applies = consentData.gdprApplies;
if (consentData.gdprApplies) {
queryParams.gdpr_consent = consentData.consentString;
let consentString;
if (consentData) {
if (utils.isBoolean(consentData.gdprApplies)) {
queryParams.gdpr_applies = consentData.gdprApplies;
}
consentString = consentData.consentString;
}
// If no consent string, try to read it from 1st party cookies
if (!consentString) {
consentString = getFromStorage('eupubconsent-v2');
}
if (!consentString) {
consentString = getFromStorage('euconsent-v2');
}
if (consentString) {
queryParams.gdpr_consent = consentString;
}
const url = utils.buildUrl({
protocol: 'https',
Expand Down
174 changes: 170 additions & 4 deletions test/spec/modules/lotamePanoramaIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,176 @@ describe('LotameId', function() {
});
});

it('should retrieve the id when decode is called', function() {
var id = lotamePanoramaIdSubmodule.decode('1234');
expect(id).to.be.eql({
'lotamePanoramaId': '1234'
describe('when gdpr applies and falls back to eupubconsent cookie', function () {
let request;
let callBackSpy = sinon.spy();
let consentData = {
gdprApplies: true,
consentString: undefined
};

beforeEach(function () {
getCookieStub
.withArgs('eupubconsent-v2')
.returns('consentGiven');

let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
submoduleCallback(callBackSpy);

// the contents of the response don't matter for this
request = server.requests[0];
request.respond(200, responseHeader, '');
});

it('should call the remote server when getId is called', function () {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
);
});
});

describe('when gdpr applies and falls back to euconsent cookie', function () {
let request;
let callBackSpy = sinon.spy();
let consentData = {
gdprApplies: true,
consentString: undefined
};

beforeEach(function () {
getCookieStub
.withArgs('euconsent-v2')
.returns('consentGiven');

let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
submoduleCallback(callBackSpy);

// the contents of the response don't matter for this
request = server.requests[0];
request.respond(200, responseHeader, '');
});

it('should call the remote server when getId is called', function () {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
);
});
});

describe('when gdpr applies but no consent string is available', function () {
let request;
let callBackSpy = sinon.spy();
let consentData = {
gdprApplies: true,
consentString: undefined
};

beforeEach(function () {
let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
submoduleCallback(callBackSpy);

// the contents of the response don't matter for this
request = server.requests[0];
request.respond(200, responseHeader, '');
});

it('should call the remote server when getId is called', function () {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should not include the gdpr consent string on the url', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=true'
);
});
});

describe('when no consentData and falls back to eupubconsent cookie', function () {
let request;
let callBackSpy = sinon.spy();
let consentData;

beforeEach(function () {
getCookieStub
.withArgs('eupubconsent-v2')
.returns('consentGiven');

let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
submoduleCallback(callBackSpy);

// the contents of the response don't matter for this
request = server.requests[0];
request.respond(200, responseHeader, '');
});

it('should call the remote server when getId is called', function () {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_consent=consentGiven'
);
});
});

describe('when no consentData and falls back to euconsent cookie', function () {
let request;
let callBackSpy = sinon.spy();
let consentData;

beforeEach(function () {
getCookieStub
.withArgs('euconsent-v2')
.returns('consentGiven');

let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
submoduleCallback(callBackSpy);

// the contents of the response don't matter for this
request = server.requests[0];
request.respond(200, responseHeader, '');
});

it('should call the remote server when getId is called', function () {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_consent=consentGiven'
);
});
});

describe('when no consentData and no cookies', function () {
let request;
let callBackSpy = sinon.spy();
let consentData;

beforeEach(function () {
let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
submoduleCallback(callBackSpy);

// the contents of the response don't matter for this
request = server.requests[0];
request.respond(200, responseHeader, '');
});

it('should call the remote server when getId is called', function () {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq('https://id.crwdcntrl.net/id');
});
});
});

0 comments on commit deb5350

Please sign in to comment.