diff --git a/modules/lassoBidAdapter.js b/modules/lassoBidAdapter.js index 6215af03a97..dc36cb4af23 100644 --- a/modules/lassoBidAdapter.js +++ b/modules/lassoBidAdapter.js @@ -44,6 +44,8 @@ export const spec = { sizes, aimXR, uid: '$UID', + npi: bidRequest.params.npi || '', + npi_hash: bidRequest.params.npiHash || '', params: JSON.stringify(bidRequest.params), crumbs: JSON.stringify(bidRequest.crumbs), prebidVersion: '$prebid.version$', @@ -128,10 +130,10 @@ function getBidRequestUrl(aimXR, params) { if (params && params.dtc) { path = '/dtc-request'; } - if (!aimXR) { - return GET_IUD_URL + ENDPOINT_URL + path; + if (aimXR || params.npi || params.npiHash) { + return ENDPOINT_URL + path; } - return ENDPOINT_URL + path; + return GET_IUD_URL + ENDPOINT_URL + path; } function getDeviceData() { diff --git a/test/spec/modules/lassoBidAdapter_spec.js b/test/spec/modules/lassoBidAdapter_spec.js index 15dee20e566..f33869e9366 100644 --- a/test/spec/modules/lassoBidAdapter_spec.js +++ b/test/spec/modules/lassoBidAdapter_spec.js @@ -3,6 +3,7 @@ import { spec } from 'modules/lassoBidAdapter.js'; import { server } from '../../mocks/xhr'; const ENDPOINT_URL = 'https://trc.lhmos.com/prebid'; +const GET_IUD_URL = 'https://secure.adnxs.com/getuid?'; const bid = { bidder: 'lasso', @@ -78,7 +79,7 @@ describe('lassoBidAdapter', function () { }); }); - describe('buildRequests', function () { + describe('buildRequests with standard flow', function () { let validBidRequests, bidRequest; before(() => { validBidRequests = spec.buildRequests([bid], bidderRequest); @@ -97,6 +98,75 @@ describe('lassoBidAdapter', function () { expect(bidRequest.method).to.exist; expect(bidRequest.method).to.equal('GET'); }); + + it('should send request to get uid and trc via get request', () => { + expect(bidRequest.method).to.equal('GET'); + expect(bidRequest.url).to.equal(GET_IUD_URL + ENDPOINT_URL + '/request'); + }); + }); + + describe('buildRequests with npi', function () { + let validBidRequests, bidRequest; + before(() => { + const updateBidParams = Object.assign({}, bid, { + params: { + adUnitId: 123456, + npi: '123' + } + }); + validBidRequests = spec.buildRequests([updateBidParams], bidderRequest); + expect(validBidRequests).to.be.an('array').that.is.not.empty; + bidRequest = validBidRequests[0]; + }) + + it('Returns valid bidRequest', function () { + expect(bidRequest).to.exist; + expect(bidRequest.method).to.exist; + expect(bidRequest.url).to.exist; + expect(bidRequest.data).to.exist; + }); + + it('Returns GET method', function() { + expect(bidRequest.method).to.exist; + expect(bidRequest.method).to.equal('GET'); + }); + + it('should send request to trc via get request with npi', () => { + expect(bidRequest.method).to.equal('GET'); + expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request'); + }); + }); + + describe('buildRequests with npi hash', function () { + let validBidRequests, bidRequest; + before(() => { + const updateBidParams = Object.assign({}, bid, { + params: { + adUnitId: 123456, + npiHash: '123' + } + }); + validBidRequests = spec.buildRequests([updateBidParams], bidderRequest); + expect(validBidRequests).to.be.an('array').that.is.not.empty; + bidRequest = validBidRequests[0]; + }) + + it('Returns valid bidRequest', function () { + expect(bidRequest).to.exist; + expect(bidRequest.method).to.exist; + expect(bidRequest.url).to.exist; + expect(bidRequest.data).to.exist; + }); + + it('Returns GET method', function() { + expect(bidRequest.method).to.exist; + expect(bidRequest.method).to.equal('GET'); + }); + + it('should send request to trc via get request with npi', () => { + expect(bidRequest.method).to.equal('GET'); + expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request'); + }); }); describe('interpretResponse', function () {