-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PublinkId - validate hash and fix decode
- Loading branch information
Showing
3 changed files
with
34 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ describe('PublinkIdSystem', () => { | |
describe('decode', () => { | ||
it('decode', () => { | ||
const result = publinkIdSubmodule.decode(TEST_COOKIE_VALUE); | ||
expect(result).deep.equals({publink: TEST_COOKIE_VALUE}); | ||
expect(result).deep.equals({publinkId: TEST_COOKIE_VALUE}); | ||
}); | ||
}); | ||
|
||
|
@@ -69,6 +69,7 @@ describe('PublinkIdSystem', () => { | |
expect(result).to.exist; | ||
expect(result.callback).to.be.a('function'); | ||
}); | ||
|
||
it('Use local copy', () => { | ||
const result = publinkIdSubmodule.getId({}, undefined, TEST_COOKIE_VALUE); | ||
expect(result).to.be.undefined; | ||
|
@@ -82,31 +83,41 @@ describe('PublinkIdSystem', () => { | |
}); | ||
|
||
it('Fetch with consent data', () => { | ||
const config = {storage: {type: 'cookie'}, params: {e: 'hashedemailvalue'}}; | ||
const config = {storage: {type: 'cookie'}, params: {e: 'ca11c0ca7'}}; | ||
const consentData = {gdprApplies: 1, consentString: 'myconsentstring'}; | ||
let submoduleCallback = publinkIdSubmodule.getId(config, consentData).callback; | ||
submoduleCallback(callbackSpy); | ||
|
||
let request = server.requests[0]; | ||
request.url = request.url.replace(':443', ''); | ||
expect(request.url).to.equal('https://proc.ad.cpe.dotomi.com/cvx/client/sync/publink?deh=hashedemailvalue&mpn=Prebid.js&mpv=$prebid.version$&gdpr=1&gdpr_consent=myconsentstring'); | ||
expect(request.url).to.equal('https://proc.ad.cpe.dotomi.com/cvx/client/sync/publink?deh=ca11c0ca7&mpn=Prebid.js&mpv=$prebid.version$&gdpr=1&gdpr_consent=myconsentstring'); | ||
|
||
request.respond(200, {}, JSON.stringify(serverResponse)); | ||
expect(callbackSpy.calledOnce).to.be.true; | ||
expect(callbackSpy.lastCall.lastArg).to.equal(serverResponse.publink); | ||
}); | ||
|
||
it('server doesnt respond', () => { | ||
const config = {storage: {type: 'cookie'}, params: {e: 'hashedemailvalue'}}; | ||
const config = {storage: {type: 'cookie'}, params: {e: 'ca11c0ca7'}}; | ||
let submoduleCallback = publinkIdSubmodule.getId(config).callback; | ||
submoduleCallback(callbackSpy); | ||
|
||
let request = server.requests[0]; | ||
request.url = request.url.replace(':443', ''); | ||
expect(request.url).to.equal('https://proc.ad.cpe.dotomi.com/cvx/client/sync/publink?deh=hashedemailvalue&mpn=Prebid.js&mpv=$prebid.version$'); | ||
expect(request.url).to.equal('https://proc.ad.cpe.dotomi.com/cvx/client/sync/publink?deh=ca11c0ca7&mpn=Prebid.js&mpv=$prebid.version$'); | ||
|
||
request.respond(204, {}, JSON.stringify(serverResponse)); | ||
expect(callbackSpy.calledOnce).to.be.false; | ||
expect(callbackSpy.called).to.be.false; | ||
}); | ||
|
||
it('reject plain email address', () => { | ||
const config = {storage: {type: 'cookie'}, params: {e: '[email protected]'}}; | ||
const consentData = {gdprApplies: 1, consentString: 'myconsentstring'}; | ||
let submoduleCallback = publinkIdSubmodule.getId(config, consentData).callback; | ||
submoduleCallback(callbackSpy); | ||
|
||
expect(server.requests).to.have.lengthOf(0); | ||
expect(callbackSpy.called).to.be.false; | ||
}); | ||
}); | ||
|
||
|
@@ -122,13 +133,13 @@ describe('PublinkIdSystem', () => { | |
}); | ||
|
||
it('Fetch with usprivacy data', () => { | ||
const config = {storage: {type: 'cookie'}, params: {e: 'hashedemailvalue'}}; | ||
const config = {storage: {type: 'cookie'}, params: {e: 'ca11c0ca7'}}; | ||
let submoduleCallback = publinkIdSubmodule.getId(config).callback; | ||
submoduleCallback(callbackSpy); | ||
|
||
let request = server.requests[0]; | ||
request.url = request.url.replace(':443', ''); | ||
expect(request.url).to.equal('https://proc.ad.cpe.dotomi.com/cvx/client/sync/publink?deh=hashedemailvalue&mpn=Prebid.js&mpv=$prebid.version$&us_privacy=1YNN'); | ||
expect(request.url).to.equal('https://proc.ad.cpe.dotomi.com/cvx/client/sync/publink?deh=ca11c0ca7&mpn=Prebid.js&mpv=$prebid.version$&us_privacy=1YNN'); | ||
|
||
request.respond(200, {}, JSON.stringify(serverResponse)); | ||
expect(callbackSpy.calledOnce).to.be.true; | ||
|