-
Notifications
You must be signed in to change notification settings - Fork 2.2k
PubMatic to support DigiTrust Id passing #3160
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
Changes from 5 commits
a6e5d71
e7eda6b
ba9eeb9
b102fcf
e6636c8
1116dda
dcc529b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import {expect} from 'chai'; | ||
import {spec} from 'modules/pubmaticBidAdapter'; | ||
import * as utils from 'src/utils'; | ||
import {config} from 'src/config'; | ||
const constants = require('src/constants.json'); | ||
|
||
describe('PubMatic adapter', function () { | ||
|
@@ -448,6 +449,197 @@ describe('PubMatic adapter', function () { | |
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid | ||
}); | ||
|
||
it('Request should have digitrust params', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you update the arrow functions in the various test functions to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have made these changes now. |
||
window.DigiTrust = { | ||
getUser: function () { | ||
} | ||
}; | ||
var bidRequest = {}; | ||
let sandbox = sinon.sandbox.create(); | ||
sandbox.stub(window.DigiTrust, 'getUser').callsFake(() => | ||
({ | ||
success: true, | ||
identity: { | ||
privacy: {optout: false}, | ||
id: 'testId', | ||
keyv: 4 | ||
} | ||
}) | ||
); | ||
|
||
let request = spec.buildRequests(bidRequests, bidRequest); | ||
let data = JSON.parse(request.data); | ||
expect(data.user.eids).to.deep.equal([{ | ||
'source': 'digitru.st', | ||
'uids': [{ | ||
'id': 'testId', | ||
'atype': 1, | ||
'ext': { | ||
'keyv': 4 | ||
} | ||
}] | ||
}]); | ||
sandbox.restore(); | ||
delete window.DigiTrust; | ||
}); | ||
|
||
it('Request should not have digitrust params when DigiTrust not loaded', () => { | ||
let request = spec.buildRequests(bidRequests, {}); | ||
let data = JSON.parse(request.data); | ||
expect(data.user.eids).to.deep.equal(undefined); | ||
}); | ||
|
||
it('Request should not have digitrust params due to optout', () => { | ||
window.DigiTrust = { | ||
getUser: function () { | ||
} | ||
}; | ||
let sandbox = sinon.sandbox.create(); | ||
sandbox.stub(window.DigiTrust, 'getUser').callsFake(() => | ||
({ | ||
success: true, | ||
identity: { | ||
privacy: {optout: true}, | ||
id: 'testId', | ||
keyv: 4 | ||
} | ||
}) | ||
); | ||
|
||
let request = spec.buildRequests(bidRequests, {}); | ||
let data = JSON.parse(request.data); | ||
expect(data.user.eids).to.deep.equal(undefined); | ||
sandbox.restore(); | ||
delete window.DigiTrust; | ||
}); | ||
|
||
it('Request should not have digitrust params due to failure', () => { | ||
window.DigiTrust = { | ||
getUser: function () { | ||
} | ||
}; | ||
let sandbox = sinon.sandbox.create(); | ||
sandbox.stub(window.DigiTrust, 'getUser').callsFake(() => | ||
({ | ||
success: false, | ||
identity: { | ||
privacy: {optout: false}, | ||
id: 'testId', | ||
keyv: 4 | ||
} | ||
}) | ||
); | ||
|
||
let request = spec.buildRequests(bidRequests, {}); | ||
let data = JSON.parse(request.data); | ||
expect(data.user.eids).to.deep.equal(undefined); | ||
sandbox.restore(); | ||
delete window.DigiTrust; | ||
}); | ||
|
||
describe('DigiTrustId from config', () => { | ||
var origGetConfig; | ||
let sandbox; | ||
beforeEach(() => { | ||
sandbox = sinon.sandbox.create(); | ||
window.DigiTrust = { | ||
getUser: sandbox.spy() | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
delete window.DigiTrust; | ||
}); | ||
|
||
it('Request should have digiTrustId config params', () => { | ||
sandbox.stub(config, 'getConfig').callsFake((key) => { | ||
var config = { | ||
digiTrustId: { | ||
success: true, | ||
identity: { | ||
privacy: {optout: false}, | ||
id: 'testId', | ||
keyv: 4 | ||
} | ||
} | ||
}; | ||
return config[key]; | ||
}); | ||
|
||
let request = spec.buildRequests(bidRequests, {}); | ||
let data = JSON.parse(request.data); | ||
expect(data.user.eids).to.deep.equal([{ | ||
'source': 'digitru.st', | ||
'uids': [{ | ||
'id': 'testId', | ||
'atype': 1, | ||
'ext': { | ||
'keyv': 4 | ||
} | ||
}] | ||
}]); | ||
// should not have called DigiTrust.getUser() | ||
expect(window.DigiTrust.getUser.notCalled).to.equal(true); | ||
}); | ||
|
||
it('Request should not have digiTrustId config params due to optout', () => { | ||
sandbox.stub(config, 'getConfig').callsFake((key) => { | ||
var config = { | ||
digiTrustId: { | ||
success: true, | ||
identity: { | ||
privacy: {optout: true}, | ||
id: 'testId', | ||
keyv: 4 | ||
} | ||
} | ||
} | ||
return config[key]; | ||
}); | ||
let request = spec.buildRequests(bidRequests, {}); | ||
let data = JSON.parse(request.data); | ||
expect(data.user.eids).to.deep.equal(undefined); | ||
// should not have called DigiTrust.getUser() | ||
expect(window.DigiTrust.getUser.notCalled).to.equal(true); | ||
}); | ||
|
||
it('Request should not have digiTrustId config params due to failure', () => { | ||
sandbox.stub(config, 'getConfig').callsFake((key) => { | ||
var config = { | ||
digiTrustId: { | ||
success: false, | ||
identity: { | ||
privacy: {optout: false}, | ||
id: 'testId', | ||
keyv: 4 | ||
} | ||
} | ||
} | ||
return config[key]; | ||
}); | ||
|
||
let request = spec.buildRequests(bidRequests, {}); | ||
let data = JSON.parse(request.data); | ||
expect(data.user.eids).to.deep.equal(undefined); | ||
// should not have called DigiTrust.getUser() | ||
expect(window.DigiTrust.getUser.notCalled).to.equal(true); | ||
}); | ||
|
||
it('Request should not have digiTrustId config params if they do not exist', () => { | ||
sandbox.stub(config, 'getConfig').callsFake((key) => { | ||
var config = {}; | ||
return config[key]; | ||
}); | ||
|
||
let request = spec.buildRequests(bidRequests, {}); | ||
let data = JSON.parse(request.data); | ||
expect(data.user.eids).to.deep.equal(undefined); | ||
// should have called DigiTrust.getUser() once | ||
expect(window.DigiTrust.getUser.calledOnce).to.equal(true); | ||
}); | ||
}); | ||
|
||
it('Request params check for video ad', function () { | ||
let request = spec.buildRequests(videoBidRequests); | ||
let data = JSON.parse(request.data); | ||
|
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.
To clarify - is this still an open question? Or has it been confirmed?
If the latter, can you remove the comment?
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.
Hello @jsnellbaker ,
I have removed the comment now.