Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parrableIdSystem: Read legacy ID and optout cookies and migrate to new cookie storage implementation #5219

Merged
merged 31 commits into from
Jun 8, 2020
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0540240
Add unit coverage for parrableIdSystem getId callback
icflournoy Apr 28, 2020
4af9a6f
PBID-14: Pass uspString to Parrable as us_privacy query parameter
icflournoy Apr 29, 2020
8c84fa3
Merge pull request #6 from Parrable/parrableIdSystem/better-unit-tests
icflournoy Apr 29, 2020
11b457b
PBID-14: Simplify parrableIdSystem us_privacy test
icflournoy Apr 30, 2020
914503e
PBID-14: Only send us_privacy to Parrable when a value exists
icflournoy Apr 30, 2020
82dba43
Merge pull request #7 from Parrable/parrableIdSystem/us-privacy
icflournoy May 1, 2020
1e2ee99
Merge remote-tracking branch 'upstream/master' into parrableIdSystem/…
icflournoy May 5, 2020
98835fa
PBID-11: Read new Parrable compound cookie _parrable_id
icflournoy May 5, 2020
43724a3
Remove path check from parrableIdSystem url test
icflournoy May 5, 2020
e88c929
PBID-11: Integrate Parrable compound cookie, consolidating old cookies
icflournoy May 7, 2020
1286adc
PBID-11: Update parrableIdSystem requestBids hook test to support com…
icflournoy May 7, 2020
2be1fb3
PBID-11: Small refactor to parrableIdSystem spec to support compound …
icflournoy May 7, 2020
a9d67ee
PBID-11: Handle legacy ibaOptout as truthy value when migrating to co…
icflournoy May 7, 2020
b71f7fd
PBID-11: Add parrableIdSystem spec tests covering migration of legacy…
icflournoy May 7, 2020
742e3d9
PBID-11: Remove storage documentation from test pages and userId modu…
icflournoy May 7, 2020
16dd083
PBID-11: Remove SUBMODULES_THAT_ALWAYS_REFRESH_ID feature from userId…
icflournoy May 7, 2020
2f80f58
Merge branch 'parrableIdSystem/base' into parrableIdSystem/PBID-11
icflournoy May 7, 2020
7bf438b
PBID-11: Use better serialize implementation for Parrable compound co…
icflournoy May 8, 2020
527303e
PBID-11: Update parrableIdSystem interface documentation
icflournoy May 8, 2020
8f717da
Add missing extension to mock xhr import
icflournoy May 11, 2020
af77318
Merge remote-tracking branch 'origin/parrableIdSystem/base' into parr…
icflournoy May 11, 2020
5d972c0
Merge pull request #9 from Parrable/parrableIdSystem/PBID-11
icflournoy May 12, 2020
39a7ad4
Merge remote-tracking branch 'upstream/master' into parrableIdSystem/…
icflournoy May 12, 2020
6ba511b
PBID-11: Try to access eid property only when parrableId object exists
icflournoy May 13, 2020
8e084ab
PBID-11: Construct parrableId from legacy cookies in same manner as c…
icflournoy May 13, 2020
e34e55f
Use hardcoded expiration date for legacy cookies
icflournoy May 13, 2020
253a8ec
Merge remote-tracking branch 'origin/master' into parrableIdSystem/base
icflournoy May 15, 2020
2486d2d
Merge remote-tracking branch 'upstream/master' into parrableIdSystem/…
icflournoy May 18, 2020
373075f
parrableIdSystem: Relocate new unit test from upstream
icflournoy May 18, 2020
df73ab9
PBID-39: Fallback to cookie values when backend response is missing c…
icflournoy May 19, 2020
50dc9ef
Merge remote-tracking branch 'upstream/master' into parrableIdSystem/…
icflournoy May 26, 2020
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
Prev Previous commit
Next Next commit
parrableIdSystem: Relocate new unit test from upstream
  • Loading branch information
icflournoy committed May 18, 2020
commit 373075fe0a8a9b18d2866b9272e07330a403e85f
17 changes: 10 additions & 7 deletions modules/parrableIdSystem.js
Original file line number Diff line number Diff line change
@@ -102,12 +102,14 @@ function readLegacyCookies() {
}

function migrateLegacyCookies(parrableId) {
writeCookie(parrableId);
if (parrableId.eid) {
storage.setCookie(LEGACY_ID_COOKIE_NAME, '', EXPIRE_COOKIE_DATE);
}
if (parrableId.ibaOptout) {
storage.setCookie(LEGACY_OPTOUT_COOKIE_NAME, '', EXPIRE_COOKIE_DATE);
if (parrableId) {
writeCookie(parrableId);
if (parrableId.eid) {
storage.setCookie(LEGACY_ID_COOKIE_NAME, '', EXPIRE_COOKIE_DATE);
}
if (parrableId.ibaOptout) {
storage.setCookie(LEGACY_OPTOUT_COOKIE_NAME, '', EXPIRE_COOKIE_DATE);
}
}
}

@@ -161,10 +163,11 @@ function fetchId(configParams) {
parrableId.ibaOptout = true;
}
writeCookie(responseObj);
cb(parrableId);
}
} catch (error) {
utils.logError(error);
cb(eid);
cb();
}
}
},
36 changes: 18 additions & 18 deletions test/spec/modules/parrableIdSystem_spec.js
Original file line number Diff line number Diff line change
@@ -75,15 +75,18 @@ function removeParrableCookie() {

describe('Parrable ID System', function() {
describe('parrableIdSystem.getId() callback', function() {
let logErrorStub;
let callbackSpy = sinon.spy();

beforeEach(function() {
logErrorStub = sinon.stub(utils, 'logError');
callbackSpy.resetHistory();
writeParrableCookie({ eid: P_COOKIE_EID });
});

afterEach(function() {
removeParrableCookie();
logErrorStub.restore();
})

it('creates xhr to Parrable that synchronizes the ID', function() {
@@ -130,6 +133,21 @@ describe('Parrable ID System', function() {
uspDataHandler.setConsentData(null);
expect(server.requests[0].url).to.contain('us_privacy=' + uspString);
});

it('should log an error and continue to callback if ajax request errors', function () {
let callBackSpy = sinon.spy();
let submoduleCallback = parrableIdSubmodule.getId({partner: 'prebid'}).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.contain('h.parrable.com');
request.respond(
503,
null,
'Unavailable'
);
expect(logErrorStub.calledOnce).to.be.true;
expect(callBackSpy.calledOnce).to.be.true;
});
});

describe('parrableIdSystem.getId() id', function() {
@@ -182,21 +200,18 @@ describe('Parrable ID System', function() {

describe('userId requestBids hook', function() {
let adUnits;
let logErrorStub;

beforeEach(function() {
adUnits = [getAdUnitMock()];
writeParrableCookie({ eid: P_COOKIE_EID });
setSubmoduleRegistry([parrableIdSubmodule]);
init(config);
config.setConfig(getConfigMock());
logErrorStub = sinon.stub(utils, 'logError');
});

afterEach(function() {
removeParrableCookie();
storage.setCookie(P_COOKIE_NAME, '', EXPIRED_COOKIE_DATE);
logErrorStub.restore();
});

it('when a stored Parrable ID exists it is added to bids', function(done) {
@@ -210,20 +225,5 @@ describe('Parrable ID System', function() {
done();
}, { adUnits });
});

it('should log an error and continue to callback if ajax request errors', function () {
let callBackSpy = sinon.spy();
let submoduleCallback = parrableIdSubmodule.getId({partner: 'prebid'}).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.contain('h.parrable.com');
request.respond(
503,
null,
'Unavailable'
);
expect(logErrorStub.calledOnce).to.be.true;
expect(callBackSpy.calledOnce).to.be.true;
});
});
});