-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Identity link id system - handle empty response #5279
Merged
smenzer
merged 5 commits into
prebid:master
from
mamatic:IdentityLinkIdSystem-handleEmptyResponse
May 25, 2020
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3df1213
IdentityLinkIdSystem - handle empty response
mamatic 4d3f2ad
Merge branch 'master' into IdentityLinkIdSystem-handleEmptyResponse
mamatic d385078
IdentityLinkIdSystem - add tests
mamatic b465633
Merge branch 'master' into IdentityLinkIdSystem-handleEmptyResponse
mamatic e531f1d
IdentityLinkIdSystem - rename describe in tests
mamatic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import {identityLinkSubmodule} from 'modules/identityLinkIdSystem.js'; | ||
import * as utils from 'src/utils.js'; | ||
import {server} from 'test/mocks/xhr.js'; | ||
|
||
const pid = '14'; | ||
const defaultConfigParams = {pid: pid}; | ||
const responseHeader = {'Content-Type': 'application/json'} | ||
|
||
describe('LiveIntentId', function () { | ||
let logErrorStub; | ||
|
||
beforeEach(function () { | ||
logErrorStub = sinon.stub(utils, 'logError'); | ||
}); | ||
|
||
afterEach(function () { | ||
logErrorStub.restore(); | ||
}); | ||
|
||
it('should log an error if no configParams were passed when getId', function () { | ||
identityLinkSubmodule.getId(); | ||
expect(logErrorStub.calledOnce).to.be.true; | ||
}); | ||
|
||
it('should log an error if pid configParam was not passed when getId', function () { | ||
identityLinkSubmodule.getId({}); | ||
expect(logErrorStub.calledOnce).to.be.true; | ||
}); | ||
|
||
it('should call the LiveRamp envelope endpoint', function () { | ||
let callBackSpy = sinon.spy(); | ||
let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; | ||
submoduleCallback(callBackSpy); | ||
let request = server.requests[0]; | ||
expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14'); | ||
request.respond( | ||
200, | ||
responseHeader, | ||
JSON.stringify({}) | ||
); | ||
expect(callBackSpy.calledOnce).to.be.true; | ||
}); | ||
|
||
it('should call the LiveRamp envelope endpoint with consent string', function () { | ||
let callBackSpy = sinon.spy(); | ||
let consentData = { | ||
gdprApplies: true, | ||
consentString: 'BOkIpDSOkIpDSADABAENCc-AAAApOAFAAMAAsAMIAcAA_g' | ||
}; | ||
let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams, consentData).callback; | ||
submoduleCallback(callBackSpy); | ||
let request = server.requests[0]; | ||
expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14&ct=1&cv=BOkIpDSOkIpDSADABAENCc-AAAApOAFAAMAAsAMIAcAA_g'); | ||
request.respond( | ||
200, | ||
responseHeader, | ||
JSON.stringify({}) | ||
); | ||
expect(callBackSpy.calledOnce).to.be.true; | ||
}); | ||
|
||
it('should not throw Uncaught TypeError when envelope endpoint returns empty response', function () { | ||
let callBackSpy = sinon.spy(); | ||
let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; | ||
submoduleCallback(callBackSpy); | ||
let request = server.requests[0]; | ||
expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14'); | ||
request.respond( | ||
204, | ||
responseHeader, | ||
'' | ||
); | ||
expect(callBackSpy.calledOnce).to.be.true; | ||
expect(request.response).to.equal(''); | ||
expect(logErrorStub.calledOnce).to.not.be.true; | ||
}); | ||
|
||
it('should log an error and continue to callback if ajax request errors', function () { | ||
let callBackSpy = sinon.spy(); | ||
let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; | ||
submoduleCallback(callBackSpy); | ||
let request = server.requests[0]; | ||
expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14'); | ||
request.respond( | ||
503, | ||
responseHeader, | ||
'Unavailable' | ||
); | ||
expect(logErrorStub.calledOnce).to.be.true; | ||
expect(callBackSpy.calledOnce).to.be.true; | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be
IdentityLinkId
:-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups :) right away.