Skip to content

Commit

Permalink
PubMatic to send test:1 in the request if pubmaticTest=true is presen…
Browse files Browse the repository at this point in the history
…t in URL (prebid#4553)

* added support for pubcommon, digitrust, id5id

* added support for IdentityLink

* changed the source for id5

* added unit test cases

* changed source param for identityLink

* PubMatic to send test:1 if pubmaticTest=true is present in URL

* added a note in pubmaticBidAdapter.md file
  • Loading branch information
pm-harshad-mane authored and Isaac A. Dettman committed Dec 11, 2019
1 parent 317aaa3 commit 01450f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,11 @@ export const spec = {
payload.site.page = conf.kadpageurl.trim() || payload.site.page.trim();
payload.site.domain = _getDomainFromURL(payload.site.page);

// test bids
if (window.location.href.indexOf('pubmaticTest=true') !== -1) {
payload.test = 1;
}

// adding schain object
if (validBidRequests[0].schain) {
payload.source = {
Expand Down
5 changes: 4 additions & 1 deletion modules/pubmaticBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,7 @@ pbjs.setConfig({
});

```
Note: Combine the above the configuration with any other UserSync configuration. Multiple setConfig() calls overwrite each other and only last call for a given attribute will take effect.
Note: Combine the above the configuration with any other UserSync configuration. Multiple setConfig() calls overwrite each other and only last call for a given attribute will take effect.

Note: PubMatic will return a test-bid if "pubmaticTest=true" is present in page URL

18 changes: 16 additions & 2 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,23 @@ describe('PubMatic adapter', function () {
expect(request.method).to.equal('POST');
});

it('test flag not sent when pubmaticTest=true is absent in page url', function() {
let request = spec.buildRequests(bidRequests);
let data = JSON.parse(request.data);
expect(data.test).to.equal(undefined);
});

it('test flag set to 1 when pubmaticTest=true is present in page url', function() {
window.location.href += '#pubmaticTest=true';
// now all the test cases below will have window.location.href with #pubmaticTest=true
let request = spec.buildRequests(bidRequests);
let data = JSON.parse(request.data);
expect(data.test).to.equal(1);
});

it('Request params check', function () {
let request = spec.buildRequests(bidRequests);
let data = JSON.parse(request.data);
let request = spec.buildRequests(bidRequests);
let data = JSON.parse(request.data);
expect(data.at).to.equal(1); // auction type
expect(data.cur[0]).to.equal('USD'); // currency
expect(data.site.domain).to.be.a('string'); // domain should be set
Expand Down

0 comments on commit 01450f5

Please sign in to comment.